|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using ESRI.ArcGIS.Geometry;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.Platform;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
|
|
namespace kingo.Plugin.BGResultManager.Helper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 变更年末库生成帮助类
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class BGNMKHelper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成地类图斑年末库
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="workspaceAPI">工作空间</param>
|
|
|
|
|
/// <param name="newDataset">要素集</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static IFeatureClass BgDLTBNMKData(IWorkspaceAPI workspaceAPI, IDataset newDataset)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer dltbgx_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBGX");
|
|
|
|
|
IFeatureLayer dltbgxgc_Layer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBGXGC");
|
|
|
|
|
IFeatureLayer JCdltb_Layer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("地类图斑");
|
|
|
|
|
IFeatureClass DLTBNMKLayer = workspaceAPI.CreateFeatureClass("DLTB", newDataset as IFeatureDataset, (JCdltb_Layer.FeatureClass as IGeoDataset).SpatialReference, esriGeometryType.esriGeometryPolygon, JCdltb_Layer.FeatureClass.Fields).FeatureClass;
|
|
|
|
|
IFeatureClassAPI JC_FcAPIs = new FeatureClassAPI(JCdltb_Layer.FeatureClass);
|
|
|
|
|
IFeatureClassAPI dltbgx_FcAPIs = new FeatureClassAPI(dltbgx_Layer.FeatureClass);
|
|
|
|
|
IQueryFilter queryFilter = new QueryFilterClass();
|
|
|
|
|
{
|
|
|
|
|
JC_FcAPIs.FcToFc(DLTBNMKLayer, null, false);
|
|
|
|
|
IFeatureCursor _cursor = dltbgxgc_Layer.FeatureClass.Search(new QueryFilterClass() { SubFields = "BGQTBBSM" }, true);
|
|
|
|
|
Dictionary<string, int> DicJcBSMs = new Dictionary<string, int>();
|
|
|
|
|
IFeature f = null;
|
|
|
|
|
int idx = dltbgxgc_Layer.FeatureClass.FindField("BGQTBBSM");
|
|
|
|
|
if (idx == -1) return null;
|
|
|
|
|
while ((f = _cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string jcbsm = f.Value[idx].ToTrim();
|
|
|
|
|
if (!DicJcBSMs.ContainsKey(jcbsm))
|
|
|
|
|
DicJcBSMs.Add(jcbsm, 0);
|
|
|
|
|
}
|
|
|
|
|
_cursor = DLTBNMKLayer.Update(null, true);
|
|
|
|
|
idx = DLTBNMKLayer.FindField("BSM");
|
|
|
|
|
if (idx == -1) return null;
|
|
|
|
|
while ((f = _cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string bsm = f.Value[idx].ToTrim();
|
|
|
|
|
if (DicJcBSMs.ContainsKey(bsm))
|
|
|
|
|
{
|
|
|
|
|
f.Value[idx] = "-1";
|
|
|
|
|
_cursor.UpdateFeature(f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_cursor.Flush();
|
|
|
|
|
(DLTBNMKLayer as ITable).DeleteSearchedRows(new QueryFilterClass() { WhereClause = "BSM = '-1'" });
|
|
|
|
|
dltbgx_FcAPIs.FcToFc(DLTBNMKLayer, null, false);//再加入更新数据
|
|
|
|
|
(DLTBNMKLayer as FeatureClass).Workspace.ExecuteSQL($"Update DLTB set SJNF = {2022} WHERE SJNF IS NULL");
|
|
|
|
|
IFeatureClassAPI fcAPIs = new FeatureClassAPI(DLTBNMKLayer);
|
|
|
|
|
if (fcAPIs.FeatureClass.FindField("XZQTZLX") != -1)
|
|
|
|
|
fcAPIs.DeleteField("XZQTZLX");
|
|
|
|
|
}
|
|
|
|
|
return DLTBNMKLayer;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
MessageHelper.ShowError("年末库导出失败!");
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void UpDataNMK(IFeatureClass NMKFC, IQueryFilter queryFilter, Dictionary<string, DataRow> bgylbDic)
|
|
|
|
|
{
|
|
|
|
|
List<DataDicTionary> TBXHLXdataDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.TBXHLX);
|
|
|
|
|
List<DataDicTionary> ZZSXdataDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.ZZSX);
|
|
|
|
|
List<DataDicTionary> DLBMdataDic = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.DLBM);
|
|
|
|
|
IFeatureCursor featureCursor = NMKFC.Update(null, true);
|
|
|
|
|
IFeature feature = null;
|
|
|
|
|
int bsmIdx = NMKFC.FindField("BSM");
|
|
|
|
|
IFeature featuresa = featureCursor.NextFeature();
|
|
|
|
|
while ((feature = featureCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
string bsm_S = feature.get_Value(bsmIdx).ToString().Trim();
|
|
|
|
|
if (bgylbDic.ContainsKey(bsm_S))
|
|
|
|
|
{
|
|
|
|
|
DataRow dr = bgylbDic[bsm_S];
|
|
|
|
|
for (int i = 0; i < feature.Fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = feature.Fields.Field[i];
|
|
|
|
|
string bghField = "BGH" + field.Name;
|
|
|
|
|
if (field.Name == "BSM") bghField = "BGHTBBSM";
|
|
|
|
|
if (dr.Table.Columns.Contains(bghField))
|
|
|
|
|
{
|
|
|
|
|
if (field.Type == esriFieldType.esriFieldTypeString)
|
|
|
|
|
{
|
|
|
|
|
feature.Value[i] = dr[bghField];
|
|
|
|
|
}
|
|
|
|
|
else if (field.Type == esriFieldType.esriFieldTypeDouble)
|
|
|
|
|
{
|
|
|
|
|
feature.Value[i] = dr[bghField].ToDouble();
|
|
|
|
|
}
|
|
|
|
|
else if (field.Type == esriFieldType.esriFieldTypeSmallInteger)
|
|
|
|
|
{
|
|
|
|
|
feature.Value[i] = dr[bghField].ToInt();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ("ZZSXMC".Contains(field.Name))
|
|
|
|
|
{
|
|
|
|
|
feature.Value[i] = ZZSXdataDic.FirstOrDefault(x => x.CODE == dr["BGHZZSXDM"].ToString()).NAME;
|
|
|
|
|
}
|
|
|
|
|
else if ("TBXHMC".Contains(field.Name))
|
|
|
|
|
{
|
|
|
|
|
feature.Value[i] = TBXHLXdataDic.FirstOrDefault(x => x.CODE == dr["BGHTBXHDM"].ToString()).NAME;
|
|
|
|
|
}
|
|
|
|
|
else if ("DLMC".Contains(field.Name))
|
|
|
|
|
{
|
|
|
|
|
feature.Value[i] = DLBMdataDic.FirstOrDefault(x => x.CODE == dr["BGHDLBM"].ToString()).NAME;
|
|
|
|
|
}
|
|
|
|
|
else if ("XZDWKD,TBYBH".Contains(field.Name))
|
|
|
|
|
{
|
|
|
|
|
feature.Value[i] = feature.Value[i];
|
|
|
|
|
}
|
|
|
|
|
else if ("TBDLMJ".Contains(field.Name))
|
|
|
|
|
{
|
|
|
|
|
feature.Value[i] = Math.Round(Convert.ToDouble(dr["BGMJ"]) - Convert.ToDouble(dr["BGHKCMJ"]), 2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
bgylbDic.Remove(bsm_S);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
featureCursor.UpdateFeature(feature);
|
|
|
|
|
}
|
|
|
|
|
featureCursor.Flush();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|