You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
171 lines
8.5 KiB
171 lines
8.5 KiB
using ESRI.ArcGIS.Carto; |
|
using ESRI.ArcGIS.Geodatabase; |
|
using KGIS.Framework.DBOperator; |
|
using KGIS.Framework.Maps; |
|
using KGIS.Framework.Utils; |
|
using KGIS.Framework.Utils.ExtensionMethod; |
|
using KGIS.Framework.Utils.Helper; |
|
using Kingo.PluginServiceInterface; |
|
using System; |
|
using System.Data; |
|
using System.Linq; |
|
|
|
namespace Kingo.Plugin.DataCheck.Helper |
|
{ |
|
public class BGTBAttribureCheck : DataCheckRule |
|
{ |
|
private string _RuleName; |
|
public override string RuleName { get => _RuleName; set => _RuleName = value; } |
|
private string _RuleDesc; |
|
public override string RuleDesc { get => _RuleDesc; set => _RuleDesc = value; } |
|
|
|
public BGTBAttribureCheck() : base() |
|
{ |
|
_RuleName = "属性逻辑一致性"; |
|
_RuleDesc = "变更图斑数据中图层内属性逻辑一致性检查、属性完整性"; |
|
} |
|
|
|
public override void StartCheck(object pParm) |
|
{ |
|
try |
|
{ |
|
base.CheckState = EnumCheckState.检查中; |
|
IFeatureClass m_Fc = MapsManager.Instance.MapService.GetFeatureClassByName("DLTBBG"); |
|
IDataCheckHelper dataCheckHelper = UIShell.OSGi.BundleRuntime.Instance.GetFirstOrDefaultService<IDataCheckHelper>(); |
|
if (dataCheckHelper == null) |
|
{ |
|
base.CheckState = EnumCheckState.检查失败; |
|
return; |
|
} |
|
dataCheckHelper.DataCheck(new CheckParametr() |
|
{ |
|
CheckType = enumCheckType.Attribute, |
|
DataSource = m_Fc, |
|
IDataCheckName = "BGQDataCheck" |
|
}); |
|
StartLoadData(pParm); |
|
base.CheckState = EnumCheckState.检查完成; |
|
} |
|
catch (Exception ex) |
|
{ |
|
base.CheckState = EnumCheckState.检查失败; |
|
LogAPI.Debug(string.Format("{0}", _RuleName)); |
|
LogAPI.Debug(ex); |
|
} |
|
} |
|
|
|
public override void StartLoadData(object pParm) |
|
{ |
|
try |
|
{ |
|
string dbPath = System.IO.Path.Combine((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ProjDir, "DataCheckrResult.db"); |
|
DataTable dtFJ = SQLiteDBOperate.Instance.ExceDataTable(dbPath, string.Format("select * from DataCheckResults WHERE ErrorCode like '1001%' and ErrorLayer='BGQDataCheck' order by ErrorType DESC")); |
|
if (dtFJ == null) return; |
|
for (int i = 0; i < dtFJ.Rows.Count; i++) |
|
{ |
|
int id = dtFJ.Rows[i]["ID"].ToInt(); |
|
int bgoid = dtFJ.Rows[i]["OBJECTID"].ToInt(); |
|
string jcError = dtFJ.Rows[i]["ErrorDesc"].ToTrim(); |
|
string jcErrorType = dtFJ.Rows[i]["ErrorType"].ToTrim(); |
|
string jcErrorCode = dtFJ.Rows[i]["ErrorCode"].ToTrim(); |
|
EnumErrorType errType = (EnumErrorType)Enum.Parse(typeof(EnumErrorType), jcErrorType); |
|
base.CheckResults.Add(new DataCheckResult() |
|
{ |
|
ID = id, |
|
ErrorDesc = jcError, |
|
ErrorCode = jcErrorCode, |
|
ErrorLayer = "DLTBBG", |
|
PrimaryKey = "OBJECTID", |
|
PrimaryKeyValue = dtFJ.Rows[i]["OBJECTID"].ToTrim(), |
|
ErrorType = errType, |
|
Icon = string.Format("pack://siteoforigin:,,,/Images/{0}.{1}", errType.ToString(), "png") |
|
}); |
|
} |
|
} |
|
catch (Exception ex) |
|
{ |
|
MessageHelper.ShowError("加载检查结果视图数据失败,请查看日志!"); |
|
LogAPI.Debug(ex.Message); |
|
} |
|
} |
|
public override void StartRepair(object pParm) |
|
{ |
|
DataTable dtED = null; |
|
try |
|
{ |
|
string dbPath = System.IO.Path.Combine((MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).ProjDir, "DataCheckrResult.db"); |
|
dtED = SQLiteDBOperate.Instance.ExceDataTable(dbPath, "select * from DataCheckResults where ErrorCategory='Attribute' and ErrorLayer='BGQDataCheck' "); |
|
if (dtED != null && dtED.Rows.Count > 0) |
|
{ |
|
IFeatureLayer BGLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBBG"); |
|
|
|
#region 备注赋值错误 |
|
var bzcw = dtED.Select("ErrorCode='1001000200000010'"); |
|
if (bzcw.Length > 0) |
|
{ |
|
(BGLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update DLTBBG set BZ = '' "); |
|
SQLiteDBOperate.Instance.ExecuteNonQuery(dbPath, " delete from DataCheckResults where ErrorCode='1001000200000010'", null); |
|
} |
|
#endregion |
|
|
|
#region MSSM赋值错误 |
|
var mmsmcw = dtED.Select("ErrorDesc='地类图斑变更层权属性质为21或41,描述说明须为01!' ").ToList(); |
|
if (mmsmcw.Count > 0) |
|
{ |
|
var objstr = string.Join(",", mmsmcw.Select(r => $"{r["OBJECTID"].ToString()}")); |
|
(BGLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update DLTBBG set MSSM = '01' where OBJECTID in ({objstr}) "); |
|
SQLiteDBOperate.Instance.ExecuteNonQuery(dbPath, $" delete from DataCheckResults where ErrorDesc='地类图斑变更层权属性质为21或41,描述说明须为01!' and OBJECTID in ({objstr}) ", null); |
|
} |
|
#endregion |
|
|
|
#region 飞入地标识赋值错误 |
|
var frdbs = dtED.Select("ErrorDesc='地类图斑变更层权属和坐落属于同一区县的国有土地飞入地标识不能为1!' or ErrorDesc='ZLDWDM前12位与QSDWDM前12位不致,地类图斑变更层FRDBS字段值不能为1!' ").ToList(); |
|
if (frdbs.Count > 0) |
|
{ |
|
var objstr = string.Join(",", frdbs.Select(r => $"{r["OBJECTID"].ToString()}")); |
|
(BGLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL($"Update DLTBBG set FRDBS = '0' where OBJECTID in ({objstr}) "); |
|
SQLiteDBOperate.Instance.ExecuteNonQuery(dbPath, $" delete from DataCheckResults where (ErrorDesc='地类图斑变更层权属和坐落属于同一区县的国有土地飞入地标识不能为1!' or ErrorDesc='ZLDWDM前12位与QSDWDM前12位不致,地类图斑变更层FRDBS字段值不能为1!') and OBJECTID in ({objstr}) ", null); |
|
} |
|
#endregion |
|
|
|
#region 线状地物宽度赋值错误 |
|
var xzdwkd = dtED.Select("ErrorDesc='地类图斑变更层线状地物宽度字段小数位数检查,保留1位小数!'").ToList(); |
|
if (xzdwkd.Count > 0) |
|
{ |
|
var objstr = string.Join(",", xzdwkd.Select(r => $"{r["OBJECTID"].ToString()}")); |
|
ICursor cursor = (BGLayer.FeatureClass as ITable).Update(new QueryFilterClass() { WhereClause = $" OBJECTID in ({objstr}) " }, true); |
|
IRow row = null; |
|
int idxXZDWKD = BGLayer.FeatureClass.FindField("XZDWKD"); |
|
while ((row = cursor.NextRow()) != null) |
|
{ |
|
string strxzdwkd = row.Value[idxXZDWKD].ToTrim(); |
|
if (!string.IsNullOrEmpty(strxzdwkd)) |
|
row.Value[idxXZDWKD] = Math.Round(Convert.ToDouble(strxzdwkd), 1).ToString("0.0");//四舍五入保留一位小数 |
|
cursor.UpdateRow(row); |
|
} |
|
SQLiteDBOperate.Instance.ExecuteNonQuery(dbPath, $" delete from DataCheckResults where ErrorDesc='地类图斑变更层线状地物宽度字段小数位数检查,保留1位小数!' and OBJECTID in ({objstr}) ", null); |
|
} |
|
#endregion |
|
|
|
dtED.Clear(); |
|
dtED = null; |
|
} |
|
StartLoadData(pParm); |
|
} |
|
catch (Exception ex) |
|
{ |
|
LogAPI.Debug(ex.Message); |
|
} |
|
} |
|
|
|
public override void StartSingleRepair(object pParm) |
|
{ |
|
|
|
} |
|
|
|
public override void StartCheckForThread(object pParam) |
|
{ |
|
|
|
} |
|
} |
|
}
|
|
|