|
|
|
|
using ESRI.ArcGIS.Carto;
|
|
|
|
|
using ESRI.ArcGIS.Controls;
|
|
|
|
|
using ESRI.ArcGIS.DataSourcesFile;
|
|
|
|
|
using ESRI.ArcGIS.esriSystem;
|
|
|
|
|
using ESRI.ArcGIS.Geodatabase;
|
|
|
|
|
using ESRI.ArcGIS.Geometry;
|
|
|
|
|
using KGIS.Framework.AE;
|
|
|
|
|
using KGIS.Framework.AE.Enum;
|
|
|
|
|
using KGIS.Framework.AE.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.AE.GPHelper;
|
|
|
|
|
using KGIS.Framework.DBOperator;
|
|
|
|
|
using KGIS.Framework.Maps;
|
|
|
|
|
using KGIS.Framework.Platform;
|
|
|
|
|
using KGIS.Framework.Utils;
|
|
|
|
|
using KGIS.Framework.Utils.ExtensionMethod;
|
|
|
|
|
using KGIS.Framework.Utils.Helper;
|
|
|
|
|
using Kingo.PluginServiceInterface;
|
|
|
|
|
using Kingo.PluginServiceInterface.Helper;
|
|
|
|
|
using Kingo.PluginServiceInterface.Model;
|
|
|
|
|
using Kingo.RuleCheck;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.ObjectModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
|
|
|
|
using UIShell.OSGi;
|
|
|
|
|
|
|
|
|
|
namespace Kingo.Plugin.General.Helper
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 单图斑建库处理逻辑
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class DataOperationHelper_Default
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
#region DataCatalog
|
|
|
|
|
public IDataCatalogService DataCatalog
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return BundleRuntime.Instance.GetFirstOrDefaultService<IDataCatalogService>();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 初始化界面
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载单图斑属性数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual ObservableCollection<TreeNode> LoadTreeData()
|
|
|
|
|
{
|
|
|
|
|
ObservableCollection<TreeNode> DataSource = new ObservableCollection<TreeNode>();
|
|
|
|
|
LayerCfg LayerCfg = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TreeNode parentNodes = new TreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = $"单图斑任务列表(0个)",
|
|
|
|
|
Paixu = 0,
|
|
|
|
|
IsExpanded = true,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.DTBJK;component/Resources/列表.png",
|
|
|
|
|
NodeLevel = 0,
|
|
|
|
|
NodeID = Guid.NewGuid().ToString().Replace("-", ""),
|
|
|
|
|
Data = null,
|
|
|
|
|
IsOpenEdit = true,
|
|
|
|
|
ParentButtonVisibility = Visibility.Visible,
|
|
|
|
|
Nodes = new ObservableCollection<TreeNode>()
|
|
|
|
|
};
|
|
|
|
|
#region 单图斑建库任务矢量加载
|
|
|
|
|
IDataCatalogService DataCatalog = BundleRuntime.Instance.GetFirstOrDefaultService<IDataCatalogService>();
|
|
|
|
|
object LayerCfgobj = DataCatalog.CurrentLayers;
|
|
|
|
|
int TCXH = 1;//任务序号
|
|
|
|
|
if (LayerCfgobj is LayerCfg)
|
|
|
|
|
{
|
|
|
|
|
LayerCfg = (LayerCfgobj as LayerCfg).Layers.FirstOrDefault(f => f.LayerName == "监测数据" && f.LayerType == EnumLayerType.GroupLayer);
|
|
|
|
|
if (LayerCfg != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var LayerCfgitem in LayerCfg.Layers)
|
|
|
|
|
{
|
|
|
|
|
if (LayerCfgitem.Data is FeatureLayer)
|
|
|
|
|
{
|
|
|
|
|
IFeatureLayer JCTBFeaLayer = LayerCfgitem.Data as FeatureLayer;
|
|
|
|
|
IQueryFilter queryFilter = new QueryFilterClass();
|
|
|
|
|
if (JCTBFeaLayer is IFeatureLayerDefinition pFLDefinition)
|
|
|
|
|
{
|
|
|
|
|
queryFilter.WhereClause = pFLDefinition.DefinitionExpression;
|
|
|
|
|
}
|
|
|
|
|
var jctbcount = JCTBFeaLayer.FeatureClass.FeatureCount(queryFilter);
|
|
|
|
|
if (JCTBFeaLayer == null || JCTBFeaLayer.FeatureClass == null || jctbcount == 0) continue;
|
|
|
|
|
TreeNode parentNode = new TreeNode()//图层数据一级(类似任务包一级)
|
|
|
|
|
{
|
|
|
|
|
Name = $"{LayerCfgitem.LayerName}({jctbcount}个)",
|
|
|
|
|
Paixu = TCXH++,
|
|
|
|
|
IsExpanded = false,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.DTBJK;component/Resources/数据检查.png",
|
|
|
|
|
NodeLevel = 1,
|
|
|
|
|
NodeID = Guid.NewGuid().ToString().Replace("-", ""),
|
|
|
|
|
Data = LayerCfgitem.Data,
|
|
|
|
|
ParentNode = parentNodes,
|
|
|
|
|
ParentButtonVisibility = Visibility.Collapsed,
|
|
|
|
|
Nodes = new ObservableCollection<TreeNode>(),
|
|
|
|
|
LoadingVisibility = Visibility.Collapsed,
|
|
|
|
|
OpenPackageVisibility = Visibility.Visible
|
|
|
|
|
};
|
|
|
|
|
parentNodes.Nodes.Add(parentNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
parentNodes.Name = "单图斑任务列表(" + parentNodes.Nodes.Count + "个)";
|
|
|
|
|
}
|
|
|
|
|
#region 变更范围注释
|
|
|
|
|
//if (LayerCfgobj != null)
|
|
|
|
|
//{
|
|
|
|
|
// LayerCfg = (LayerCfgobj as LayerCfg).Layers.FirstOrDefault(f => f.LayerName == "变更数据" && f.LayerType == EnumLayerType.GroupLayer);
|
|
|
|
|
// foreach (var LayerCfgitem in LayerCfg.Layers)
|
|
|
|
|
// {
|
|
|
|
|
// if (LayerCfgitem.Data is FeatureLayer)
|
|
|
|
|
// {
|
|
|
|
|
// if (LayerCfgitem.FcName != "DLTBBG") continue;
|
|
|
|
|
// IFeatureLayer JCTBFeaLayer = LayerCfgitem.Data as FeatureLayer;
|
|
|
|
|
// IQueryFilter queryFilter = new QueryFilterClass();
|
|
|
|
|
// if (JCTBFeaLayer is IFeatureLayerDefinition pFLDefinition)
|
|
|
|
|
// {
|
|
|
|
|
// queryFilter.WhereClause = " SJLY='' OR SJLY is NULL";
|
|
|
|
|
// }
|
|
|
|
|
// var tbcount = JCTBFeaLayer.FeatureClass.FeatureCount(queryFilter);
|
|
|
|
|
// if (JCTBFeaLayer == null || JCTBFeaLayer.FeatureClass == null || tbcount == 0) continue;
|
|
|
|
|
// TreeNode parentNode = new TreeNode()
|
|
|
|
|
// {
|
|
|
|
|
// Name = $"{LayerCfgitem.LayerName}({tbcount}个)",
|
|
|
|
|
// Paixu = TCXH++,
|
|
|
|
|
// IsExpanded = false,
|
|
|
|
|
// Icon = "pack://application:,,,/Kingo.Plugin.DTBJK;component/Resources/数据检查.png",
|
|
|
|
|
// NodeLevel = 1,
|
|
|
|
|
// NodeID = Guid.NewGuid().ToString().Replace("-", ""),
|
|
|
|
|
// Data = LayerCfgitem.Data,
|
|
|
|
|
// ParentNode = parentNodes,
|
|
|
|
|
// ParentButtonVisibility = Visibility.Collapsed,
|
|
|
|
|
// Nodes = new ObservableCollection<TreeNode>(),
|
|
|
|
|
// LoadingVisibility = Visibility.Collapsed,
|
|
|
|
|
// OpenPackageVisibility = Visibility.Visible
|
|
|
|
|
// };
|
|
|
|
|
// parentNodes.Nodes.Add(parentNode);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// parentNodes.Name = "单图斑任务列表(" + parentNodes.Nodes.Count + "个)";
|
|
|
|
|
//}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 单图斑建库任务包加载
|
|
|
|
|
SyncPackage(projectInfo.TaskPath);
|
|
|
|
|
if (projectInfo.ListTaskPackage != null && projectInfo.ListTaskPackage.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
List<TaskPackage> lstDelete = new List<TaskPackage>();
|
|
|
|
|
foreach (TaskPackage item in projectInfo.ListTaskPackage)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(item.PackagePath) || !File.Exists(item.PackagePath))
|
|
|
|
|
{
|
|
|
|
|
lstDelete.Add(item);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
string fileName = System.IO.Path.GetFileName(item.PackagePath);
|
|
|
|
|
if (item.BID == null || string.IsNullOrWhiteSpace(item.BID.ToString()))
|
|
|
|
|
{
|
|
|
|
|
item.BID = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
}
|
|
|
|
|
TreeNode treeNode = new TreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = fileName + "(" + item.TBCount + "个)",
|
|
|
|
|
Paixu = TCXH++,
|
|
|
|
|
IsExpanded = false,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.DTBJK;component/Resources/数据检查.png",
|
|
|
|
|
NodeID = Guid.NewGuid().ToString().Replace("-", ""),
|
|
|
|
|
NodeLevel = 1,
|
|
|
|
|
Data = item,//可区分任务类型
|
|
|
|
|
ParentNode = parentNodes,
|
|
|
|
|
LoadingVisibility = Visibility.Collapsed,
|
|
|
|
|
OpenPackageVisibility = Visibility.Visible
|
|
|
|
|
};
|
|
|
|
|
parentNodes.Nodes.Add(treeNode);
|
|
|
|
|
}
|
|
|
|
|
foreach (var item in lstDelete)
|
|
|
|
|
{
|
|
|
|
|
projectInfo.ListTaskPackage.Remove(item);
|
|
|
|
|
}
|
|
|
|
|
parentNodes.Name = "单图斑任务列表(" + parentNodes.Nodes.Count + "个)";
|
|
|
|
|
DataSource = new ObservableCollection<TreeNode>();
|
|
|
|
|
projectInfo.Save();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
DataSource.Add(parentNodes);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
MessageHelper.ShowError("任务包加载失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
TreeDataSource = DataSource;
|
|
|
|
|
return DataSource;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 工具栏修改数据后,点击保存时更新任务包数据
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 工具栏修改数据后,点击保存时更新任务包数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="differenceCursorEx"></param>
|
|
|
|
|
/// <param name="modifiedClass"></param>
|
|
|
|
|
/// <param name="rdbHelper"></param>
|
|
|
|
|
/// <param name="type">0:新增 1:修改 2:删除</param>
|
|
|
|
|
public virtual void UpdateData(IDifferenceCursorEx differenceCursorEx, IRDBHelper rdbHelper, int type)
|
|
|
|
|
{
|
|
|
|
|
//准备输入参数
|
|
|
|
|
int featureOID = -1;
|
|
|
|
|
//新图形
|
|
|
|
|
IRow sourceRow = null;
|
|
|
|
|
//旧图形
|
|
|
|
|
IRow differenceRow = null;
|
|
|
|
|
//变化字段
|
|
|
|
|
ILongArray longArray = null;
|
|
|
|
|
// 获取
|
|
|
|
|
differenceCursorEx.Next(out featureOID, out sourceRow, out differenceRow, out longArray);
|
|
|
|
|
// 获取编辑图形信息
|
|
|
|
|
while (featureOID != -1)
|
|
|
|
|
{
|
|
|
|
|
int bsmIndex = -1;
|
|
|
|
|
string excuteSQL = string.Empty;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string bsm = string.Empty;
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case 0://0:新增
|
|
|
|
|
AddFeature(sourceRow as IFeature, rdbHelper);
|
|
|
|
|
break;
|
|
|
|
|
case 1://1:修改
|
|
|
|
|
AddFeature(sourceRow as IFeature, rdbHelper);
|
|
|
|
|
break;
|
|
|
|
|
case 2://2:删除
|
|
|
|
|
bsmIndex = differenceRow.Fields.FindField("BSM");
|
|
|
|
|
int jcbhIndex = differenceRow.Fields.FindField("JCBH");
|
|
|
|
|
int tbbsmIndex = differenceRow.Fields.FindField("TBBSM");
|
|
|
|
|
int sjlyIndex = differenceRow.Fields.FindField("SJLY");
|
|
|
|
|
string JCBHValue = "";
|
|
|
|
|
if (bsmIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
bsm = differenceRow.get_Value(bsmIndex) as string;
|
|
|
|
|
}
|
|
|
|
|
if (jcbhIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
JCBHValue = differenceRow.Value[jcbhIndex].ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (tbbsmIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
JCBHValue = differenceRow.Value[tbbsmIndex].ToString();
|
|
|
|
|
}
|
|
|
|
|
TreeNode treeNode = GetNodeByName(TreeDataSource[0], bsm, new List<int>() { 3 });
|
|
|
|
|
if (treeNode != null && treeNode.NodeLevel == 3)
|
|
|
|
|
{
|
|
|
|
|
TreeNode parNode = treeNode.ParentNode;
|
|
|
|
|
if (parNode != null)
|
|
|
|
|
{
|
|
|
|
|
IsAutoSaveEdit = false;//暂时作为避免再次触发保存
|
|
|
|
|
parNode.Nodes.Remove(treeNode);
|
|
|
|
|
if (parNode.PackageNode.Name.StartsWith("变更范围"))
|
|
|
|
|
{
|
|
|
|
|
//变更范围删除图斑更新二级节点信息
|
|
|
|
|
}
|
|
|
|
|
else if (parNode.Data is DataRow)
|
|
|
|
|
{
|
|
|
|
|
parNode.Name = (parNode.Data as DataRow)["JCBH"].ToString() + $"({parNode.Nodes.Count})";
|
|
|
|
|
}
|
|
|
|
|
else if (parNode.Data is WYRWTB)
|
|
|
|
|
{
|
|
|
|
|
parNode.Name = (parNode.Data as WYRWTB).TBBSM.ToString() + $"({parNode.Nodes.Count})";
|
|
|
|
|
excuteSQL = "delete from {0} where bsm='{1}'";
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(string.Format(excuteSQL, "DTBDLTBGX", bsm), CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(string.Format(excuteSQL, "DTBCCWJQGX", bsm), CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(string.Format(excuteSQL, "DTBCZCDYDGX", bsm), CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from DTBDLTBGXGC where BGHTBBSM ='{bsm}'", CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(string.Format(excuteSQL, "DTBGFBQGX", bsm), CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(string.Format(excuteSQL, "DTBLMFWGX", bsm), CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(string.Format(excuteSQL, "DTBLSYDGX", bsm), CommandType.Text);
|
|
|
|
|
//rdbHelper.ExecuteNonQueryWithException($"delete from FJGX where TBBSM ='{bsm}'", CommandType.Text);
|
|
|
|
|
//rdbHelper.ExecuteNonQueryWithException($"delete from FJGX where tbbsm not in(select bsm from DTBDLTBGX);", CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from PZWJ where bsm not in(select bsm from DTBDLTBGX);", CommandType.Text);
|
|
|
|
|
(DtbFeatureLayer.FeatureClass as FeatureClass).Workspace.ExecuteSQL("DELETE FROM TTQGX where BSM = '" + bsm + "'");
|
|
|
|
|
}
|
|
|
|
|
IsAutoSaveEdit = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
treeNode = GetNodeByName(TreeDataSource[0], JCBHValue, new List<int>() { 2 });
|
|
|
|
|
if (sjlyIndex != -1 && treeNode != null && treeNode.NodeLevel == 2)
|
|
|
|
|
{
|
|
|
|
|
//仅仅修改任务图斑中ZZTB类型数据
|
|
|
|
|
if (differenceRow.Value[sjlyIndex].ToString() == "ZZTB")
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from WYRW where JCBH='{JCBHValue}'", CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from dtbdltbgx where TBBSM='{JCBHValue}'", CommandType.Text);
|
|
|
|
|
TreeNode parNode = treeNode.ParentNode;
|
|
|
|
|
IsAutoSaveEdit = false;//暂时作为避免再次触发保存
|
|
|
|
|
parNode.Nodes.Remove(treeNode);
|
|
|
|
|
IsAutoSaveEdit = true;
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrWhiteSpace(differenceRow.Value[sjlyIndex].ToString()))
|
|
|
|
|
{
|
|
|
|
|
if (EngineEditorBG != null)//非新增数据来源数据不保存
|
|
|
|
|
{
|
|
|
|
|
EngineEditorBG.StopEditing(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//处理删除图斑后,被删除图斑的质检信息未清除问题。
|
|
|
|
|
var flagObj = rdbHelper.ExecuteScalar($"select IsDelete from DTBDLTBGX where bsm = '{bsm}'", CommandType.Text);
|
|
|
|
|
if (flagObj != null && !string.IsNullOrEmpty(flagObj.ToString()) && flagObj.ToString() == "1")
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from DTBDLTBGX where BSM ='{bsm}'", CommandType.Text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("UpdateData执行异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
differenceCursorEx.Next(out featureOID, out sourceRow, out differenceRow, out longArray);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 新增图斑
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 新增图斑(单图斑新增与修改合并)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual void AddFeature(IFeature Newfeature, IRDBHelper rdbHelper)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (Newfeature == null || Newfeature.Shape == null || Newfeature.Shape.IsEmpty) return;
|
|
|
|
|
IFeature featureTBBSM = null;
|
|
|
|
|
List<IFeature> features = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
object LayerCfgobj = DataCatalog.CurrentLayers;
|
|
|
|
|
if (LayerCfgobj is LayerCfg && rdbHelper == null)//矢量数据类型
|
|
|
|
|
{
|
|
|
|
|
LayerCfg jcsj = (LayerCfgobj as LayerCfg).Layers.FirstOrDefault(f => f.LayerName == "监测数据" && f.LayerType == EnumLayerType.GroupLayer);
|
|
|
|
|
if (jcsj == null) return;//获取所有的监测数据图层
|
|
|
|
|
string JCBHValue = string.Empty;
|
|
|
|
|
foreach (LayerCfg itemCfg in jcsj.Layers)
|
|
|
|
|
{
|
|
|
|
|
features = FeatureAPI.Identify(Newfeature.ShapeCopy, itemCfg.Data as IFeatureLayer);
|
|
|
|
|
if (features != null && features.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//如果仅压盖到了一个,则挂接到该外业任务图斑
|
|
|
|
|
if (features.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
featureTBBSM = features[0];
|
|
|
|
|
}
|
|
|
|
|
else if (features.Count > 1)
|
|
|
|
|
{
|
|
|
|
|
double _area = -1;
|
|
|
|
|
foreach (IFeature item in features)
|
|
|
|
|
{
|
|
|
|
|
//areaas1 = item.ShapeCopy as IArea;
|
|
|
|
|
IGeometry geometry = DtbFeatureLayer.FeatureClass.GetFeature(Newfeature.OID).ShapeCopy;
|
|
|
|
|
//此处报错可能是空间参考坐标系不一致
|
|
|
|
|
double interArea = FeatureAPI.GetInterArea(geometry, item.ShapeCopy);
|
|
|
|
|
if (_area < interArea)
|
|
|
|
|
{
|
|
|
|
|
_area = interArea;
|
|
|
|
|
featureTBBSM = item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int index = featureTBBSM.Fields.FindField("JCBH");
|
|
|
|
|
if (index > -1)
|
|
|
|
|
{
|
|
|
|
|
object obj = featureTBBSM.get_Value(index);
|
|
|
|
|
JCBHValue = obj == null ? "" : obj.ToString();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int tbBSMIndex = Newfeature.Fields.FindField("TBBSM");
|
|
|
|
|
int tbbhIndex = Newfeature.Fields.FindField("TBYBH");
|
|
|
|
|
int bsmIndex = Newfeature.Fields.FindField("BSM");
|
|
|
|
|
int tbmjIndex = Newfeature.Fields.FindField("TBMJ");
|
|
|
|
|
int zldwdmIndex = Newfeature.Fields.FindField("ZLDWDM");
|
|
|
|
|
int jckzldwdmIndex = JCKFeatureLayer.FeatureClass.Fields.FindField("ZLDWDM");
|
|
|
|
|
int qsdwdmIndex = Newfeature.Fields.FindField("QSDWDM");
|
|
|
|
|
int jckqsdwdmIndex = JCKFeatureLayer.FeatureClass.Fields.FindField("QSDWDM");
|
|
|
|
|
int zldwmcIndex = Newfeature.Fields.FindField("ZLDWMC");
|
|
|
|
|
int jckzldwmcIndex = JCKFeatureLayer.FeatureClass.Fields.FindField("ZLDWMC");
|
|
|
|
|
int qsdwmcIndex = Newfeature.Fields.FindField("QSDWMC");
|
|
|
|
|
int jckqsdwmcIndex = JCKFeatureLayer.FeatureClass.Fields.FindField("QSDWMC");
|
|
|
|
|
int qsxzIndex = Newfeature.Fields.FindField("QSXZ");
|
|
|
|
|
int jckqsxzIndex = JCKFeatureLayer.FeatureClass.Fields.FindField("QSXZ");
|
|
|
|
|
try
|
|
|
|
|
{ //继承基础库权属及性质
|
|
|
|
|
List<IFeature> featureJCKs = FeatureAPI.Identify2(Newfeature.ShapeCopy, JCKFeatureLayer);
|
|
|
|
|
double _area2 = -1;
|
|
|
|
|
IFeature featureJCK = null;
|
|
|
|
|
foreach (IFeature itemF in featureJCKs)
|
|
|
|
|
{
|
|
|
|
|
if (featureJCKs.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
featureJCK = itemF;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//此处报错可能是空间参考坐标系不一致
|
|
|
|
|
double interArea = FeatureAPI.GetInterArea(Newfeature.ShapeCopy, itemF.ShapeCopy);
|
|
|
|
|
if (_area2 < interArea)
|
|
|
|
|
{
|
|
|
|
|
_area2 = interArea;
|
|
|
|
|
featureJCK = itemF;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (featureJCK != null && jckqsxzIndex != -1 && jckqsdwmcIndex != -1 && jckqsdwdmIndex != -1)
|
|
|
|
|
{
|
|
|
|
|
//属性不为空 不继承基础库的属性
|
|
|
|
|
if (string.IsNullOrEmpty(Newfeature.Value[qsdwdmIndex].ToTrim()))
|
|
|
|
|
Newfeature.Value[qsdwdmIndex] = featureJCK.Value[jckqsdwdmIndex];
|
|
|
|
|
if (string.IsNullOrEmpty(Newfeature.Value[qsdwmcIndex].ToTrim()))
|
|
|
|
|
Newfeature.Value[qsdwmcIndex] = featureJCK.Value[jckqsdwmcIndex];
|
|
|
|
|
if (string.IsNullOrEmpty(Newfeature.Value[zldwmcIndex].ToTrim()))
|
|
|
|
|
Newfeature.Value[zldwmcIndex] = featureJCK.Value[jckzldwmcIndex];
|
|
|
|
|
if (string.IsNullOrEmpty(Newfeature.Value[zldwdmIndex].ToTrim()))
|
|
|
|
|
Newfeature.Value[zldwdmIndex] = featureJCK.Value[jckzldwdmIndex];
|
|
|
|
|
if (string.IsNullOrEmpty(Newfeature.Value[qsxzIndex].ToTrim()))
|
|
|
|
|
Newfeature.Value[qsxzIndex] = featureJCK.Value[jckqsxzIndex];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("继承基础库属性异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
Newfeature.Value[tbbhIndex] = JCBHValue;//图斑编号
|
|
|
|
|
if (featureTBBSM != null)
|
|
|
|
|
Newfeature.Value[tbBSMIndex] = featureTBBSM.Value[featureTBBSM.Fields.FindField("TBBSM")].ToString();//图斑标识码
|
|
|
|
|
IArea area1 = Newfeature.ShapeCopy as IArea;
|
|
|
|
|
Newfeature.Value[tbmjIndex] = Math.Round(area1.Area, 2);//图斑面积
|
|
|
|
|
Newfeature.Value[bsmIndex] = Guid.NewGuid().ToTrim().Replace("-", "").Substring(0, 18);
|
|
|
|
|
Newfeature.Store();
|
|
|
|
|
TreeNode treeNode = GetNodeByName(TreeDataSource[0], JCBHValue.Trim(), new List<int>() { 2 });
|
|
|
|
|
if (treeNode == null) return;
|
|
|
|
|
//节点修改
|
|
|
|
|
if (treeNode.Nodes.FirstOrDefault(x => x.NodeID.ToInt() == Newfeature.OID) == null)
|
|
|
|
|
{
|
|
|
|
|
TreeNode bgfwNode = new TreeNode()//第四级-变更图斑
|
|
|
|
|
{
|
|
|
|
|
Name = Newfeature.Value[bsmIndex] as string,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.General;component/Resources/变更图斑.png",
|
|
|
|
|
NodeID = Newfeature.OID,
|
|
|
|
|
NodeLevel = 3,
|
|
|
|
|
Data = Newfeature,
|
|
|
|
|
ParentNode = treeNode,
|
|
|
|
|
PackageNode = treeNode.PackageNode,
|
|
|
|
|
PackageState = "未完成",//新增图斑默认为“未完成”状态
|
|
|
|
|
LoadingVisibility = Visibility.Collapsed
|
|
|
|
|
};
|
|
|
|
|
treeNode.Nodes.Add(bgfwNode);
|
|
|
|
|
treeNode.PackageState = GetNodesJCZT(treeNode);
|
|
|
|
|
treeNode.Name = Newfeature.Value[tbbhIndex] + $"({treeNode.Nodes.Count})";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TreeNode node = treeNode.Nodes.FirstOrDefault(x => x.NodeID.ToInt() == Newfeature.OID);
|
|
|
|
|
node.NodeID = Newfeature.OID;
|
|
|
|
|
node.Data = Newfeature;
|
|
|
|
|
node.Name = Newfeature.Value[bsmIndex] as string;
|
|
|
|
|
}
|
|
|
|
|
//循环判断变更图斑图形是否存在,不存在则删除变更范围节点
|
|
|
|
|
if (treeNode.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
List<TreeNode> deleteList = new List<TreeNode>();
|
|
|
|
|
foreach (var item in treeNode.Nodes)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DtbFeatureLayer.FeatureClass.GetFeature(item.NodeID.ToInt());
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新增节点获取图层失败(不处理):" + ex);
|
|
|
|
|
deleteList.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
IsAutoSaveEdit = false;//暂时作为避免再次触发保存
|
|
|
|
|
foreach (var item in deleteList)
|
|
|
|
|
{
|
|
|
|
|
treeNode.Nodes.Remove(item);
|
|
|
|
|
}
|
|
|
|
|
IsAutoSaveEdit = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (Newfeature.Class.AliasName == "单图斑地类图斑更新" && rdbHelper != null)//任务包类型数据
|
|
|
|
|
{
|
|
|
|
|
//获取当前变更图斑对应的外业任务图斑
|
|
|
|
|
string BSMValue = string.Empty;
|
|
|
|
|
string tblx = string.Empty;
|
|
|
|
|
int dlbmIndex = Newfeature.Fields.FindField("TBBSM");//地类编码
|
|
|
|
|
if (dlbmIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
BSMValue = Newfeature.get_Value(dlbmIndex).ToString();
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrWhiteSpace(BSMValue) && CurrentWYRWTB != null)
|
|
|
|
|
{
|
|
|
|
|
BSMValue = GetTBBSM(Newfeature, ref tblx);
|
|
|
|
|
if (string.IsNullOrWhiteSpace(BSMValue))
|
|
|
|
|
BSMValue = CurrentWYRWTB.TBBSM;
|
|
|
|
|
}
|
|
|
|
|
GenerNewData(Newfeature, rdbHelper, BSMValue);
|
|
|
|
|
|
|
|
|
|
UpdateKCXS(Newfeature, rdbHelper, BSMValue);
|
|
|
|
|
}
|
|
|
|
|
else if (Newfeature.Class.AliasName == "外业图斑" && rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
string jcbhValue = string.Empty;
|
|
|
|
|
int jcbhIndex = Newfeature.Class.FindField("JCBH");
|
|
|
|
|
int sjlyIndex = Newfeature.Class.FindField("SJLY");
|
|
|
|
|
if (!Newfeature.Value[sjlyIndex].ToString().Contains("ZZTB") && !string.IsNullOrWhiteSpace(Newfeature.Value[sjlyIndex].ToString()))
|
|
|
|
|
{
|
|
|
|
|
if (EngineEditorBG != null)
|
|
|
|
|
EngineEditorBG.StopEditing(false);
|
|
|
|
|
return;//非新增任务图斑修改不保存
|
|
|
|
|
}
|
|
|
|
|
bool NewJCBH = false;
|
|
|
|
|
jcbhValue = Newfeature.Value[jcbhIndex].ToString();
|
|
|
|
|
if (string.IsNullOrWhiteSpace(jcbhValue))
|
|
|
|
|
{
|
|
|
|
|
IJKTBTask GetRWTBDataHelper = new JKTBTaskHelper();
|
|
|
|
|
jcbhValue = GetRWTBDataHelper.GetRWTBSEQ(projectInfo.CODE, CurrentTaskPackage.YWLX).ToString();
|
|
|
|
|
if (string.IsNullOrWhiteSpace(jcbhValue))
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("接口获取“JCBH”失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
NewJCBH = true;
|
|
|
|
|
}
|
|
|
|
|
#region 分割任务图斑情况
|
|
|
|
|
//如果是分割图斑,两个要素jcbhValue是一样的,判断存在多个图斑,则也需要重新赋值jcbhValue
|
|
|
|
|
if (!NewJCBH)
|
|
|
|
|
{
|
|
|
|
|
IQueryFilter queryFilter = new QueryFilterClass()
|
|
|
|
|
{
|
|
|
|
|
WhereClause = $"JCBH='{jcbhValue}'"
|
|
|
|
|
};
|
|
|
|
|
ICursor cursor = (Newfeature.Class as ITable).Search(queryFilter, false);
|
|
|
|
|
int count = 0;
|
|
|
|
|
IRow row = null;
|
|
|
|
|
while ((row = cursor.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
count++;
|
|
|
|
|
if (count > 1)
|
|
|
|
|
{
|
|
|
|
|
IJKTBTask GetRWTBDataHelper = new JKTBTaskHelper();
|
|
|
|
|
jcbhValue = GetRWTBDataHelper.GetRWTBSEQ(projectInfo.CODE, CurrentTaskPackage.YWLX).ToString();
|
|
|
|
|
if (string.IsNullOrWhiteSpace(jcbhValue))
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.ShowTips("接口获取“JCBH”失败!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
NewJCBH = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
GenerWYTBNewData(Newfeature, rdbHelper, jcbhValue, NewJCBH);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新增/修改图斑发生错误:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("可能原因为:空间参考不一样所致");
|
|
|
|
|
LogAPI.Debug(ex.StackTrace);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (features != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in features)
|
|
|
|
|
{
|
|
|
|
|
Marshal.ReleaseComObject(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex.Message);
|
|
|
|
|
LogAPI.Debug(ex.StackTrace);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public virtual void UpdateFeatureAttribute(IFeature Newfeature, IRDBHelper rdbHelper)
|
|
|
|
|
{
|
|
|
|
|
AddFeature(Newfeature, rdbHelper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 同步任务目录文件夹任务包文件
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 同步任务目录文件夹任务包文件
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="dbPath"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public virtual void SyncPackage(string taskPath)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(taskPath) || !Directory.Exists(taskPath))
|
|
|
|
|
{
|
|
|
|
|
projectInfo.ListTaskPackage = new List<TaskPackage>();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (projectInfo.ListTaskPackage == null)
|
|
|
|
|
{
|
|
|
|
|
projectInfo.ListTaskPackage = new List<TaskPackage>();
|
|
|
|
|
}
|
|
|
|
|
DirectoryInfo directory = new DirectoryInfo(System.IO.Path.Combine(taskPath, "未完成"));
|
|
|
|
|
string filter = "*.jkrw";
|
|
|
|
|
if (Platform.Instance.SystemType == SystemTypeEnum.WYZS)
|
|
|
|
|
{
|
|
|
|
|
filter = "*.shrw";
|
|
|
|
|
}
|
|
|
|
|
FileInfo[] files = directory.GetFiles(filter, SearchOption.AllDirectories);
|
|
|
|
|
if (files == null || files.Length <= 0)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
foreach (var item in files)
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TaskPackage taskPackage = projectInfo.ListTaskPackage.FirstOrDefault(x => x.PackagePath.Equals(item.FullName));
|
|
|
|
|
if (taskPackage != null && !string.IsNullOrWhiteSpace(taskPackage.PackageTempPath) && System.IO.File.Exists(taskPackage.PackageTempPath))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (taskPackage.State.Equals("已输出"))
|
|
|
|
|
{
|
|
|
|
|
File.Delete(item.FullName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper($"{taskPackage.PackageTempPath}{(MapsManager.Instance.CurrProjectInfo as ProjectInfo).Pathpassword}", DatabaseType.SQLite);
|
|
|
|
|
|
|
|
|
|
FileInfo file = new FileInfo(taskPackage.PackageTempPath);
|
|
|
|
|
if (file.IsReadOnly)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug($"选择的单图斑建库任务包{taskPackage.PackageTempPath}不允许是只读文件!");
|
|
|
|
|
throw new Exception("选择的单图斑建库任务包不允许是只读文件!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper($"{item.FullName}{(MapsManager.Instance.CurrProjectInfo as ProjectInfo).Pathpassword}", DatabaseType.SQLite);
|
|
|
|
|
|
|
|
|
|
FileInfo file = new FileInfo(item.FullName);
|
|
|
|
|
if (file.IsReadOnly)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug($"选择的单图斑建库任务包{item.FullName}不允许是只读文件!");
|
|
|
|
|
throw new Exception("选择的单图斑建库任务包不允许是只读文件!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!rdbHelper.TableIsExist("wyrw"))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("选择的单图斑建库任务包不存在外业任务(WYRW)表!");
|
|
|
|
|
}
|
|
|
|
|
if (!rdbHelper.TableIsExist("YSJ"))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("选择的单图斑建库任务包不存在元数据(YSJ)表!");
|
|
|
|
|
}
|
|
|
|
|
CheckTableExist(rdbHelper);
|
|
|
|
|
DataTable dataTable = rdbHelper.ExecuteDatatable("ysj", "select * from ysj", true);
|
|
|
|
|
if (dataTable == null || dataTable.Rows.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("选择的单图斑建库任务包元数据(YSJ)表数据为空!");
|
|
|
|
|
}
|
|
|
|
|
dataTable = rdbHelper.ExecuteDatatable("wyrw", "select ZT,TBBSM from wyrw", true);
|
|
|
|
|
if (dataTable == null || dataTable.Rows.Count <= 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("选择的单图斑建库任务包外业任务表数据为空!");
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException("update dtbdltbgx set ddtcbz='一般地类',ddtcmc='一般地类' where ddtcbz is null or ddtcbz=''", CommandType.Text);
|
|
|
|
|
foreach (DataRow dataRow in dataTable.Rows)
|
|
|
|
|
{
|
|
|
|
|
//如果单图斑一条数据都没有,则把外业任务图斑拷贝到DTBDLTBGX表中,作为一个默认的变更范围
|
|
|
|
|
long tbCount = (long)rdbHelper.ExecuteScalar($"select count(1) from dtbdltbgx where tbbsm='{dataRow["tbbsm"]}'", CommandType.Text);
|
|
|
|
|
if (tbCount <= 0)
|
|
|
|
|
{
|
|
|
|
|
string sql = $"INSERT INTO dtbdltbgx (BSM,TBBSM,EGeometry,ZXDX,ZXDY,MAXX,MAXY,MINX,MINY,JKRY,DLBM,ZZSXDM,TBXHDM,DDTCBZ,GDLX,TBMJ,YDYHFL,BZ) SELECT '{Guid.NewGuid().ToString().Replace("-", "")}' as BSM,A.TBBSM,A.EGeometry,A.ZXDX,A.ZXDY,A.MAXX,A.MAXY,A.MINX,A.MINY,'{projectInfo.UserName}' as JKRY,(case when length(b.HCBGDL)>4 then substr(b.HCBGDL,0,5) else B.HCBGDL end) as HCBGDL,B.ZZSX,B.TBXHSX,(case when length(replace(B.DDTCXX,' ',''))<4 then '一般地类' else replace(B.DDTCXX,' ','') end) as DDTCBZ,B.GDLX,(A.TBMJ*666.67) AS TBMJ,b.YDYHFL AS YDYHFL,b.XJBZ AS XJBZ FROM WYRW A LEFT JOIN WYHCCG B ON A.TBBSM = B.HCRWBSM where tbbsm = '{dataRow["tbbsm"]}' LIMIT 1;";
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(sql, CommandType.Text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (taskPackage == null)
|
|
|
|
|
{
|
|
|
|
|
projectInfo.ListTaskPackage.Add(
|
|
|
|
|
new TaskPackage()
|
|
|
|
|
{
|
|
|
|
|
BID = Guid.NewGuid().ToString().Replace("-", ""),
|
|
|
|
|
YWLX = UserLoginHelper.GetAppsetingValueByKey("JkTaskDBYWLX"),
|
|
|
|
|
PackagePath = item.FullName,
|
|
|
|
|
State = "未完成",
|
|
|
|
|
TBCount = $"({dataTable.Select("ZT='已输出'").Length}/{dataTable.Rows.Count})"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
taskPackage.TBCount = $"({dataTable.Select("ZT='已输出'").Length}/{dataTable.Rows.Count})";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(item + "无法添加:" + ex.Message);
|
|
|
|
|
LogAPI.Debug(item + "无法添加:" + ex.StackTrace);
|
|
|
|
|
MessageHelper.ShowTips(item + "无法添加:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
rdbHelper = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
projectInfo.Save();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 验证包表结构是否都存在
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 验证包表结构是否都存在
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual void CheckTableExist(IRDBHelper rdbHelper)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string excuteSQL = @"CREATE TABLE if not exists FJGX (
|
|
|
|
|
BSM INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
|
|
|
WYTBBSM TEXT NOT NULL,
|
|
|
|
|
FJARG TEXT NOT NULL,
|
|
|
|
|
TBBSM TEXT NOT NULL);
|
|
|
|
|
CREATE TABLE if not exists DTBDLTBGXGC (
|
|
|
|
|
BSM INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
|
|
|
TBBSM TEXT,
|
|
|
|
|
BGXW TEXT,
|
|
|
|
|
XZQTZLX INTEGER,
|
|
|
|
|
TBBGMJ NUMERIC,
|
|
|
|
|
BGQBSM TEXT,
|
|
|
|
|
BGQTBBH TEXT,
|
|
|
|
|
BGQDLBM TEXT,
|
|
|
|
|
BGQDLMC TEXT,
|
|
|
|
|
BGQQSXZ TEXT,
|
|
|
|
|
BGQQSDWDM TEXT,
|
|
|
|
|
BGQQSDWMC TEXT,
|
|
|
|
|
BGQZLDWDM TEXT,
|
|
|
|
|
BGQZLDWMC TEXT,
|
|
|
|
|
BGQKCDLBM TEXT,
|
|
|
|
|
BGQKCXS NUMERIC,
|
|
|
|
|
BGQKCMJ NUMERIC,
|
|
|
|
|
BGQTBDLMJ NUMERIC,
|
|
|
|
|
BGQGDLX TEXT,
|
|
|
|
|
BGQGDPDJB TEXT,
|
|
|
|
|
BGQXZDWKD NUMERIC,
|
|
|
|
|
BGQTBXHDM TEXT,
|
|
|
|
|
BGQTBXHMC TEXT,
|
|
|
|
|
BGQZZSXDM TEXT,
|
|
|
|
|
BGQZZSXMC TEXT,
|
|
|
|
|
BGQGDDB TEXT,
|
|
|
|
|
BGQFRDBS TEXT,
|
|
|
|
|
BGQCZCSXM TEXT,
|
|
|
|
|
BGQMSSM TEXT,
|
|
|
|
|
BGQHDMC TEXT,
|
|
|
|
|
BGHTBBSM TEXT,
|
|
|
|
|
BGHTBBH TEXT,
|
|
|
|
|
BGHDLBM TEXT,
|
|
|
|
|
BGHDLMC TEXT,
|
|
|
|
|
BGHQSXZ TEXT,
|
|
|
|
|
BGHQSDWDM TEXT,
|
|
|
|
|
BGHQSDWMC TEXT,
|
|
|
|
|
BGHZLDWDM TEXT,
|
|
|
|
|
BGHZLDWMC TEXT,
|
|
|
|
|
BGHKCDLBM TEXT,
|
|
|
|
|
BGHKCXS NUMERIC,
|
|
|
|
|
BGHKCMJ NUMERIC,
|
|
|
|
|
BGHTBDLMJ NUMERIC,
|
|
|
|
|
BGHGDLX TEXT,
|
|
|
|
|
BGHGDPDJB NUMERIC,
|
|
|
|
|
BGHXZDWKD NUMERIC,
|
|
|
|
|
BGHTBXHDM TEXT,
|
|
|
|
|
BGHTBXHMC TEXT,
|
|
|
|
|
BGHZZSXDM TEXT,
|
|
|
|
|
BGHZZSXMC TEXT,
|
|
|
|
|
BGHGDDB INTEGER,
|
|
|
|
|
BGHFRDBS TEXT,
|
|
|
|
|
BGHCZCSXM TEXT,
|
|
|
|
|
BGHMSSM INTEGER,
|
|
|
|
|
BGHHDMC INTEGER,
|
|
|
|
|
EGeometry TEXT,
|
|
|
|
|
GXSJ TEXT
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE if not exists DTBDLTBGX (
|
|
|
|
|
BSM TEXT NOT NULL PRIMARY KEY,
|
|
|
|
|
TBBSM TEXT,
|
|
|
|
|
YSDM TEXT,
|
|
|
|
|
TBYBH TEXT,
|
|
|
|
|
TBBH TEXT,
|
|
|
|
|
DLBM TEXT,
|
|
|
|
|
DLMC TEXT,
|
|
|
|
|
QSXZ TEXT,
|
|
|
|
|
QSDWDM TEXT,
|
|
|
|
|
QSDWMC TEXT,
|
|
|
|
|
ZLDWDM TEXT,
|
|
|
|
|
ZLDWMC TEXT,
|
|
|
|
|
TBMJ NUMERIC,
|
|
|
|
|
KCDLBM TEXT,
|
|
|
|
|
KCXS NUMERIC,
|
|
|
|
|
KCMJ NUMERIC,
|
|
|
|
|
TBDLMJ NUMERIC,
|
|
|
|
|
GDLX TEXT,
|
|
|
|
|
GDPDJB TEXT,
|
|
|
|
|
XZDWKD NUMERIC,
|
|
|
|
|
TBXHDM TEXT,
|
|
|
|
|
TBXHMC TEXT,
|
|
|
|
|
ZZSXDM TEXT,
|
|
|
|
|
ZZSXMC TEXT,
|
|
|
|
|
GDDB INTEGER,
|
|
|
|
|
FRDBS TEXT,
|
|
|
|
|
CZCSXM TEXT,
|
|
|
|
|
SJNF INTEGER,
|
|
|
|
|
MSSM TEXT,
|
|
|
|
|
HDMC TEXT,
|
|
|
|
|
BZ TEXT,
|
|
|
|
|
GXSJ TEXT,
|
|
|
|
|
TBLX TEXT,
|
|
|
|
|
DDTCBZ TEXT,
|
|
|
|
|
DDTCMC TEXT,
|
|
|
|
|
SFGX TEXT,
|
|
|
|
|
WBGYY TEXT,
|
|
|
|
|
SFJZ TEXT,
|
|
|
|
|
QKSM TEXT,
|
|
|
|
|
NBWQKSM TEXT,
|
|
|
|
|
SHLZQKSM TEXT,
|
|
|
|
|
LJLX TEXT,
|
|
|
|
|
DCJL TEXT,
|
|
|
|
|
YWTBSM TEXT,
|
|
|
|
|
EGeometry TEXT,
|
|
|
|
|
ZXDX NUMERIC,
|
|
|
|
|
ZXDY NUMERIC,
|
|
|
|
|
MAXX NUMERIC,
|
|
|
|
|
MAXY NUMERIC,
|
|
|
|
|
MINX NUMERIC,
|
|
|
|
|
MINY NUMERIC,
|
|
|
|
|
JKRY TEXT,
|
|
|
|
|
LNGDZB TEXT,
|
|
|
|
|
SFXML TEXT,
|
|
|
|
|
XMLX TEXT,
|
|
|
|
|
XMMC TEXT,
|
|
|
|
|
XMBH TEXT,
|
|
|
|
|
CZCTBBH TEXT,
|
|
|
|
|
LC TEXT,
|
|
|
|
|
NF TEXT
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE if not exists DTBCCWJQGX (
|
|
|
|
|
BSM TEXT NOT NULL,
|
|
|
|
|
DDTCBZ TEXT,
|
|
|
|
|
DDTCMC TEXT,
|
|
|
|
|
YSDM TEXT,
|
|
|
|
|
ZDMJ NUMERIC,
|
|
|
|
|
BZ TEXT,
|
|
|
|
|
GXSJ TEXT
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE if not exists DTBGFBQGX (
|
|
|
|
|
BSM TEXT NOT NULL,
|
|
|
|
|
DDTCBZ TEXT,
|
|
|
|
|
DDTCMC TEXT,
|
|
|
|
|
YSDM TEXT,
|
|
|
|
|
XMMC TEXT,
|
|
|
|
|
XMGM TEXT,
|
|
|
|
|
QYMJ NUMERIC,
|
|
|
|
|
PZYDSJ TEXT,
|
|
|
|
|
BZ TEXT,
|
|
|
|
|
GXSJ TEXT
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE if not exists DTBLSYDGX (
|
|
|
|
|
BSM TEXT NOT NULL,
|
|
|
|
|
DDTCBZ TEXT,
|
|
|
|
|
DDTCMC TEXT,
|
|
|
|
|
YSDM TEXT,
|
|
|
|
|
GLTBBSM TEXT,
|
|
|
|
|
PZWJMC TEXT,
|
|
|
|
|
PZWH TEXT,
|
|
|
|
|
TBMJ NUMERIC,
|
|
|
|
|
PZMJ NUMERIC,
|
|
|
|
|
YTFL TEXT,
|
|
|
|
|
JTXMYT TEXT,
|
|
|
|
|
PZRQ TEXT,
|
|
|
|
|
YQSX TEXT,
|
|
|
|
|
TDSYHT TEXT,
|
|
|
|
|
BZ TEXT,
|
|
|
|
|
GXSJ TEXT
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE if not exists PZWJ (
|
|
|
|
|
BSM TEXT NOT NULL,
|
|
|
|
|
Name TEXT,
|
|
|
|
|
Path TEXT,
|
|
|
|
|
Extension TEXT,
|
|
|
|
|
FileContent BLOB
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE if not exists DTBTTQGX (
|
|
|
|
|
BSM TEXT NOT NULL,
|
|
|
|
|
DDTCBZ TEXT,
|
|
|
|
|
DDTCMC TEXT,
|
|
|
|
|
YSDM TEXT,
|
|
|
|
|
TTQMJ NUMERIC,
|
|
|
|
|
BZ TEXT,
|
|
|
|
|
GXSJ TEXT
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE if not exists DTBCZCDYDGX (
|
|
|
|
|
BSM TEXT NOT NULL,
|
|
|
|
|
DDTCBZ TEXT,
|
|
|
|
|
DDTCMC TEXT,
|
|
|
|
|
YSDM TEXT,
|
|
|
|
|
CZCLX TEXT,
|
|
|
|
|
CZCDM TEXT,
|
|
|
|
|
CZCMC TEXT,
|
|
|
|
|
CZCMJ NUMERIC,
|
|
|
|
|
BZ TEXT,
|
|
|
|
|
GXSJ TEXT
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE if not exists DTBLMFWGX (
|
|
|
|
|
BSM TEXT NOT NULL,
|
|
|
|
|
DDTCBZ TEXT,
|
|
|
|
|
DDTCMC TEXT,
|
|
|
|
|
YSDM TEXT,
|
|
|
|
|
ZLDWDM TEXT,
|
|
|
|
|
KD NUMERIC,
|
|
|
|
|
MJ NUMERIC,
|
|
|
|
|
DLBM TEXT,
|
|
|
|
|
MC TEXT,
|
|
|
|
|
BZ TEXT,
|
|
|
|
|
GXSJ TEXT
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE if not exists CheckResult(
|
|
|
|
|
XH INTEGER NOT NULL,
|
|
|
|
|
RuleCode TEXT,
|
|
|
|
|
CheckObject TEXT,
|
|
|
|
|
TBBSM TEXT,
|
|
|
|
|
ErrorType TEXT,
|
|
|
|
|
ErrorId TEXT,
|
|
|
|
|
ErrorTip TEXT,
|
|
|
|
|
RuleName TEXT,
|
|
|
|
|
RuleContent TEXT,
|
|
|
|
|
GeometryType INTEGER,
|
|
|
|
|
Geometry TEXT
|
|
|
|
|
);
|
|
|
|
|
CREATE TABLE if not exists WYRWTB_VOICE (
|
|
|
|
|
BSM INTEGER PRIMARY KEY NOT NULL,
|
|
|
|
|
TBBSM TEXT NOT NULL,
|
|
|
|
|
YWLX TEXT NOT NULL,
|
|
|
|
|
VOICE BLOB
|
|
|
|
|
)";
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(excuteSQL, CommandType.Text);
|
|
|
|
|
//WYHRFJ外业核查附件表增加用户是否标记删除字段
|
|
|
|
|
DataTable dataTable = rdbHelper.ExecuteDatatable("wyhcfj", "select * from WYHCFJ where 1=2", true);
|
|
|
|
|
if (dataTable != null && !dataTable.Columns.Contains("UserDelete"))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException("ALTER TABLE WYHCFJ ADD 'UserDelete' INTEGER;");
|
|
|
|
|
//增加字段后,默认都为0:非删除状态,1是删除状态,删除状态的不展示该附件
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException("UPDATE WYHCFJ SET UserDelete=0;");
|
|
|
|
|
}
|
|
|
|
|
//单独图层添加列
|
|
|
|
|
#region 单独图层添加列
|
|
|
|
|
List<string> fields = new List<string>() { "DDTCBZ", "DDTCMC" };
|
|
|
|
|
List<string> tables = new List<string>() { "DTBCCWJQGX", "DTBGFBQGX", "DTBLSYDGX", "DTBTTQGX", "DTBCZCDYDGX", "DTBLMFWGX", "DTBDLTBGX" };
|
|
|
|
|
foreach (string table in tables)
|
|
|
|
|
{
|
|
|
|
|
dataTable = rdbHelper.ExecuteDatatable(table, $"select * from '{table}' where 1=2", true);
|
|
|
|
|
foreach (string field in fields)
|
|
|
|
|
{
|
|
|
|
|
if (dataTable != null && !dataTable.Columns.Contains(field))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"ALTER TABLE '{table}' ADD '{field}' TEXT;");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 省级审核标注 SJSHBZ
|
|
|
|
|
List<string> SJSHBZfields = new List<string>() { "TBZT", "UserID", "BzRole" };
|
|
|
|
|
dataTable = rdbHelper.ExecuteDatatable("SJSHBZ", $"select * from SJSHBZ where 1=2", true);
|
|
|
|
|
foreach (string field in SJSHBZfields)
|
|
|
|
|
{
|
|
|
|
|
if (dataTable != null && !dataTable.Columns.Contains(field))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"ALTER TABLE SJSHBZ ADD '{field}' TEXT;");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 省级反馈结果 ReturnComments
|
|
|
|
|
List<string> ReturnCommentsfields = new List<string>() { "JLDLHCJG", "JLDLHCSM", "JLSXHCJG", "JLSXHCSM", "JLTXHCJG", "JLTXHCSM", "JLSHSM", "JLBZ", "JLSHRY", "JLSHSJ" };
|
|
|
|
|
dataTable = rdbHelper.ExecuteDatatable("ReturnComments", $"select * from ReturnComments where 1=2", true);
|
|
|
|
|
foreach (string field in ReturnCommentsfields)
|
|
|
|
|
{
|
|
|
|
|
if (dataTable != null && !dataTable.Columns.Contains(field))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"ALTER TABLE ReturnComments ADD '{field}' TEXT;");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//DTBDLTBGX表增加LNGDZB历年耕地占比字段
|
|
|
|
|
dataTable = rdbHelper.ExecuteDatatable("dtbdltbgx", "select * from dtbdltbgx where 1=2", true);
|
|
|
|
|
List<string> lstStringField = null;
|
|
|
|
|
List<string> lstIntField = null;
|
|
|
|
|
if (dataTable != null)
|
|
|
|
|
{
|
|
|
|
|
lstStringField = new List<string>() { "LNGDZB", "SDMSSM", "YDYHFL", "ZGQKSM", "SFXML", "XMLX", "XMMC", "XMBH", "DKMC", "CZCTBBH", "LC", "NF", "LJBZ", "JZYBH", "LJTBBH", "IsDelete", "ZZZW", "SZLX", "LYZZZW", "LXJZGLBH" };
|
|
|
|
|
foreach (var item in lstStringField)
|
|
|
|
|
{
|
|
|
|
|
if (!dataTable.Columns.Contains(item))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"ALTER TABLE dtbdltbgx ADD '{item}' TEXT;");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!dataTable.Columns.Contains("XZDWKD"))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"ALTER TABLE dtbdltbgx ADD 'XZDWKD' NUMERIC;");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException("UPDATE dtbdltbgx SET SFXML='0' where SFXML is null or SFXML =''");
|
|
|
|
|
dataTable = rdbHelper.ExecuteDatatable("fjgx", "select * from fjgx where 1=2", true);
|
|
|
|
|
if (dataTable != null && !dataTable.Columns.Contains("WYTBBSM"))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException("ALTER TABLE fjgx ADD 'WYTBBSM' TEXT;");
|
|
|
|
|
}
|
|
|
|
|
//国家反馈意见添加照片合理性字段
|
|
|
|
|
dataTable = rdbHelper.ExecuteDatatable("GJFKJG", "select * from GJFKJG where 1=2", true);
|
|
|
|
|
if (dataTable != null && !dataTable.Columns.Contains("ZPHLX"))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException("ALTER TABLE GJFKJG ADD 'ZPHLX' TEXT;");
|
|
|
|
|
}
|
|
|
|
|
//WYRW表增加外业备注和状态字段
|
|
|
|
|
dataTable = rdbHelper.ExecuteDatatable("WYRW", "select * from WYRW where 1=2", true);
|
|
|
|
|
if (dataTable != null)
|
|
|
|
|
{
|
|
|
|
|
lstStringField = new List<string>() { "ZT", "WYBZ" };//"CheckR"
|
|
|
|
|
foreach (var item in lstStringField)
|
|
|
|
|
{
|
|
|
|
|
if (!dataTable.Columns.Contains(item))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"ALTER TABLE WYRW ADD '{item}' TEXT;");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException("UPDATE WYRW SET ZT='未完成' where zt is null or zt =''");
|
|
|
|
|
lstIntField = new List<string>() { "FWY", "XBTB", "SFSB", "GJDLBM" };
|
|
|
|
|
foreach (var item in lstIntField)
|
|
|
|
|
{
|
|
|
|
|
if (item == "SFSB")
|
|
|
|
|
{
|
|
|
|
|
if (!dataTable.Columns.Contains(item))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"ALTER TABLE WYRW ADD '{item}' NUMERIC;");
|
|
|
|
|
}
|
|
|
|
|
//continue;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!dataTable.Columns.Contains(item))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"ALTER TABLE WYRW ADD '{item}' TEXT;");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
dataTable = rdbHelper.ExecuteDatatable("CheckResult", "select * from CheckResult where 1=2", true);
|
|
|
|
|
if (dataTable != null)
|
|
|
|
|
{
|
|
|
|
|
lstStringField = new List<string>() { "TBBSM", "Geometry" };
|
|
|
|
|
foreach (var item in lstStringField)
|
|
|
|
|
{
|
|
|
|
|
if (!dataTable.Columns.Contains(item))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"ALTER TABLE CheckResult ADD '{item}' TEXT;");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!dataTable.Columns.Contains("GeometryType"))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException("ALTER TABLE CheckResult ADD 'GeometryType' INTEGER;");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//DTBDLTBGXGC表增加图形字段EGeometry
|
|
|
|
|
dataTable = rdbHelper.ExecuteDatatable("DTBDLTBGXGC", "select * from DTBDLTBGXGC where 1=2", true);
|
|
|
|
|
if (dataTable != null)
|
|
|
|
|
{
|
|
|
|
|
if (!dataTable.Columns.Contains("EGeometry"))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException("ALTER TABLE DTBDLTBGXGC ADD 'EGeometry' TEXT;");
|
|
|
|
|
}
|
|
|
|
|
DataTable dt = rdbHelper.ExecuteDatatable("DTBDLTBGXGC", "pragma table_info ('DTBDLTBGXGC')", true);
|
|
|
|
|
int pk = Convert.ToInt32(dt.Rows[0]["pk"].ToString()); //判断bsm字段pk列是否为1,name即为列名
|
|
|
|
|
if (pk != 1)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException("ALTER TABLE DTBDLTBGXGC RENAME TO DTBDLTBGXGC_Copy");
|
|
|
|
|
string sql = @"CREATE TABLE DTBDLTBGXGC(
|
|
|
|
|
BSM INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
|
|
|
|
|
TBBSM TEXT,
|
|
|
|
|
BGXW TEXT,
|
|
|
|
|
XZQTZLX INTEGER,
|
|
|
|
|
TBBGMJ NUMERIC,
|
|
|
|
|
BGQBSM TEXT,
|
|
|
|
|
BGQTBBH TEXT,
|
|
|
|
|
BGQDLBM TEXT,
|
|
|
|
|
BGQDLMC TEXT,
|
|
|
|
|
BGQQSXZ TEXT,
|
|
|
|
|
BGQQSDWDM TEXT,
|
|
|
|
|
BGQQSDWMC TEXT,
|
|
|
|
|
BGQZLDWDM TEXT,
|
|
|
|
|
BGQZLDWMC TEXT,
|
|
|
|
|
BGQKCDLBM TEXT,
|
|
|
|
|
BGQKCXS NUMERIC,
|
|
|
|
|
BGQKCMJ NUMERIC,
|
|
|
|
|
BGQTBDLMJ NUMERIC,
|
|
|
|
|
BGQGDLX TEXT,
|
|
|
|
|
BGQGDPDJB TEXT,
|
|
|
|
|
BGQXZDWKD NUMERIC,
|
|
|
|
|
BGQTBXHDM TEXT,
|
|
|
|
|
BGQTBXHMC TEXT,
|
|
|
|
|
BGQZZSXDM TEXT,
|
|
|
|
|
BGQZZSXMC TEXT,
|
|
|
|
|
BGQGDDB TEXT,
|
|
|
|
|
BGQFRDBS TEXT,
|
|
|
|
|
BGQCZCSXM TEXT,
|
|
|
|
|
BGQMSSM TEXT,
|
|
|
|
|
BGQHDMC TEXT,
|
|
|
|
|
BGHTBBSM TEXT,
|
|
|
|
|
BGHTBBH TEXT,
|
|
|
|
|
BGHDLBM TEXT,
|
|
|
|
|
BGHDLMC TEXT,
|
|
|
|
|
BGHQSXZ TEXT,
|
|
|
|
|
BGHQSDWDM TEXT,
|
|
|
|
|
BGHQSDWMC TEXT,
|
|
|
|
|
BGHZLDWDM TEXT,
|
|
|
|
|
BGHZLDWMC TEXT,
|
|
|
|
|
BGHKCDLBM TEXT,
|
|
|
|
|
BGHKCXS NUMERIC,
|
|
|
|
|
BGHKCMJ NUMERIC,
|
|
|
|
|
BGHTBDLMJ NUMERIC,
|
|
|
|
|
BGHGDLX TEXT,
|
|
|
|
|
BGHGDPDJB NUMERIC,
|
|
|
|
|
BGHXZDWKD NUMERIC,
|
|
|
|
|
BGHTBXHDM TEXT,
|
|
|
|
|
BGHTBXHMC TEXT,
|
|
|
|
|
BGHZZSXDM TEXT,
|
|
|
|
|
BGHZZSXMC TEXT,
|
|
|
|
|
BGHGDDB INTEGER,
|
|
|
|
|
BGHFRDBS TEXT,
|
|
|
|
|
BGHCZCSXM TEXT,
|
|
|
|
|
BGHMSSM INTEGER,
|
|
|
|
|
BGHHDMC INTEGER,
|
|
|
|
|
EGeometry TEXT,
|
|
|
|
|
GXSJ TEXT
|
|
|
|
|
)";
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(sql, CommandType.Text);
|
|
|
|
|
string coloum = "BSM,TBBSM,BGXW, XZQTZLX, TBBGMJ, BGQBSM, BGQTBBH, BGQDLBM, BGQDLMC, BGQQSXZ, BGQQSDWDM, BGQQSDWMC, BGQZLDWDM, BGQZLDWMC, BGQKCDLBM, BGQKCXS, BGQKCMJ, BGQTBDLMJ, BGQGDLX, BGQGDPDJB, BGQXZDWKD, BGQTBXHDM, BGQTBXHMC, BGQZZSXDM, BGQZZSXMC, BGQGDDB, BGQFRDBS, BGQCZCSXM, BGQMSSM, BGQHDMC,EGeometry,BGHTBBSM, BGHTBBH, BGHDLBM, BGHDLMC, BGHQSXZ, BGHQSDWDM, BGHQSDWMC, BGHZLDWDM, BGHZLDWMC, BGHKCDLBM, BGHKCXS, BGHKCMJ, BGHTBDLMJ, BGHGDLX, BGHGDPDJB, BGHXZDWKD, BGHTBXHDM, BGHTBXHMC, BGHZZSXDM, BGHZZSXMC, BGHGDDB, BGHFRDBS, BGHCZCSXM, BGHMSSM, BGHHDMC,GXSJ";
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(string.Format("INSERT INTO DTBDLTBGXGC({0}) SELECT {0} FROM DTBDLTBGXGC_Copy", coloum));
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException("DROP TABLE DTBDLTBGXGC_Copy");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
LogAPI.Debug("新建初始化任务表、外业指导草图表异常:" + ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 关闭任务包
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 单图斑建库/单图斑质检---关闭任务包
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="CurrentSelectNode"></param>
|
|
|
|
|
public virtual void ClosePackage(TreeNode CurrentSelectNode)
|
|
|
|
|
{
|
|
|
|
|
IWorkspaceAPI workspaceAPI = null;
|
|
|
|
|
IWorkspaceAPI workspaceSchemeAPI = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
#region 矢量数据关闭
|
|
|
|
|
if (CurrentSelectNode.Data is IFeatureLayer)
|
|
|
|
|
{
|
|
|
|
|
CurrentSelectNode.IsExpanded = false;
|
|
|
|
|
CurrentSelectNode.Nodes.Clear();
|
|
|
|
|
CurrentSelectNode.OpenPackageVisibility = Visibility.Visible;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
#region 任务包关闭
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 任务包关闭
|
|
|
|
|
if (!(CurrentSelectNode.Data is TaskPackage taskPackage)) return;
|
|
|
|
|
if (taskPackage != null && !File.Exists(taskPackage.PackagePath))
|
|
|
|
|
{
|
|
|
|
|
CurrentSelectNode.Nodes.Clear();
|
|
|
|
|
CurrentSelectNode.OpenPackageVisibility = Visibility.Visible;
|
|
|
|
|
LogAPI.Debug("单图斑打开任务包过程中未找到任务包:" + taskPackage.PackagePath);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (File.Exists(taskPackage.PackageTempPath))
|
|
|
|
|
{
|
|
|
|
|
workspaceAPI = new WorkspaceAPI(taskPackage.GDBPath, WorkspaceTypeEnum.GDBFile, true);
|
|
|
|
|
string excuteSQL = "DELETE FROM {0} where bid = '" + taskPackage.BID + "'";
|
|
|
|
|
workspaceAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "WYCTPoint"));
|
|
|
|
|
workspaceAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "WYCTLine"));
|
|
|
|
|
workspaceAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "WYCTPolygon"));
|
|
|
|
|
workspaceAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "MarkPoint"));
|
|
|
|
|
workspaceAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "MarkLine"));
|
|
|
|
|
workspaceAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "MarkPolygon"));
|
|
|
|
|
workspaceAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "SJSHPoint"));
|
|
|
|
|
workspaceAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "SJSHLine"));
|
|
|
|
|
workspaceAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "SJSHPolygon"));
|
|
|
|
|
workspaceAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "WYRW"));
|
|
|
|
|
workspaceSchemeAPI = new WorkspaceAPI(taskPackage.SchemeGDBPath, WorkspaceTypeEnum.GDBFile, true);
|
|
|
|
|
excuteSQL = "DELETE FROM {0} where bid = '" + taskPackage.BID + "'";
|
|
|
|
|
workspaceSchemeAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "DLTBBG"));
|
|
|
|
|
workspaceSchemeAPI.CurrentWorkspace.ExecuteSQL(string.Format(excuteSQL, "TTQGX"));
|
|
|
|
|
CurrentSelectNode.Nodes.Clear();
|
|
|
|
|
this.hookHelper.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewBackground | esriViewDrawPhase.esriViewGeoSelection, null, this.hookHelper.ActiveView.Extent);
|
|
|
|
|
CurrentSelectNode.OpenPackageVisibility = Visibility.Visible;
|
|
|
|
|
if (EngineEditorBG.EditState == esriEngineEditState.esriEngineStateEditing)
|
|
|
|
|
EngineEditorBG.StopEditing(true);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("关闭任务包-重置数据异常:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("关闭任务包-重置数据异常:" + ex.StackTrace);
|
|
|
|
|
MessageHelper.ShowError("关闭任务包-重置数据异常:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (workspaceSchemeAPI != null)
|
|
|
|
|
workspaceSchemeAPI.CloseWorkspace();
|
|
|
|
|
if (workspaceAPI != null)
|
|
|
|
|
workspaceAPI.CloseWorkspace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 加载矢量数据树结构
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载矢量数据树结构
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="parentNode"></param>
|
|
|
|
|
public void LoadSLDataTreeNode(TreeNode parentNode)
|
|
|
|
|
{
|
|
|
|
|
IQueryFilter queryFilter = new QueryFilterClass();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
#region 监测图斑
|
|
|
|
|
if (parentNode.Data as IFeatureLayer is IFeatureLayerDefinition pFLDefinition)
|
|
|
|
|
{
|
|
|
|
|
queryFilter.WhereClause = pFLDefinition.DefinitionExpression;
|
|
|
|
|
}
|
|
|
|
|
DataTable dataJCTB = AECommonHelper.GetTableByFeatureClass((parentNode.Data as IFeatureLayer).FeatureClass, queryFilter);
|
|
|
|
|
DataTable dataDtbBGFW = AECommonHelper.GetTableByFeatureClass(DtbFeatureLayer.FeatureClass);
|
|
|
|
|
if (dataDtbBGFW == null || dataJCTB.Rows.Count <= 0) return;
|
|
|
|
|
foreach (DataRow item in dataJCTB.Rows)
|
|
|
|
|
{
|
|
|
|
|
string jcbh = item["JCBH"] as string;
|
|
|
|
|
//第三级-监测图斑数据
|
|
|
|
|
TreeNode jctbNode = new TreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = jcbh + "(0)",
|
|
|
|
|
IsExpanded = false,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.DTBJK;component/Resources/监测图斑.png",
|
|
|
|
|
Data = item,
|
|
|
|
|
NodeLevel = 2,
|
|
|
|
|
NodeID = item[(parentNode.Data as IFeatureLayer).FeatureClass.OIDFieldName],
|
|
|
|
|
ParentNode = parentNode,
|
|
|
|
|
PackageNode = parentNode,//监测图层一级节点
|
|
|
|
|
PackageState = "未完成",
|
|
|
|
|
cMenu = new ContextMenu()
|
|
|
|
|
};
|
|
|
|
|
DataRow[] dataRows = dataDtbBGFW.Select($"TBYBH='{jcbh}'");
|
|
|
|
|
if (dataRows != null && dataRows.Length > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataRow row in dataRows)
|
|
|
|
|
{
|
|
|
|
|
TreeNode bgfwNode = new TreeNode()//第四级-变更图斑
|
|
|
|
|
{
|
|
|
|
|
Name = row["BSM"] as string,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.General;component/Resources/变更图斑.png",
|
|
|
|
|
NodeID = row[DtbFeatureLayer.FeatureClass.OIDFieldName],
|
|
|
|
|
NodeLevel = 3,
|
|
|
|
|
Data = DtbFeatureLayer.FeatureClass.GetFeature(Convert.ToInt32(row[DtbFeatureLayer.FeatureClass.OIDFieldName])),
|
|
|
|
|
ParentNode = jctbNode,
|
|
|
|
|
PackageNode = parentNode//监测图层一级节点
|
|
|
|
|
};
|
|
|
|
|
bgfwNode.PackageState = row["JCZT"].ToString() ?? "未完成";
|
|
|
|
|
jctbNode.Nodes.Add(bgfwNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
InitBGDataByJCSJ(jctbNode);//打开任务包加载数据时
|
|
|
|
|
jctbNode.PackageState = GetNodesJCZT(jctbNode);
|
|
|
|
|
}
|
|
|
|
|
jctbNode.Name = $"{jcbh}({jctbNode.Nodes.Count})";
|
|
|
|
|
jctbNode.PackageState = GetNodesJCZT(jctbNode);
|
|
|
|
|
parentNode.Nodes.Add(jctbNode);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("加载矢量数据树节点失败:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("加载矢量数据树节点失败:" + ex.StackTrace);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (queryFilter != null)
|
|
|
|
|
Marshal.ReleaseComObject(queryFilter);
|
|
|
|
|
MapsManager.Instance.MapService.getAxMapControl().Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 初始化图斑
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 初始化图斑
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
/// <param name="IsDirectoverlay">是否直接初始化</param>
|
|
|
|
|
public virtual void InitBGDataByJCSJ(TreeNode treeNode, bool IsDirectoverlay = false)
|
|
|
|
|
{
|
|
|
|
|
IRDBHelper rdbHelper = null;
|
|
|
|
|
IFeatureCursor cursor = null;
|
|
|
|
|
IFeature feature = null;
|
|
|
|
|
IQueryFilter queryFilter = null;
|
|
|
|
|
IFeature wyFeature = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (treeNode.Data is DataRow)//初始化矢量数据图斑
|
|
|
|
|
{
|
|
|
|
|
if (treeNode.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
System.Windows.Forms.DialogResult dialogResult = MessageHelper.ShowYesNoAndTips("是否覆盖已有变更范围?");
|
|
|
|
|
if (dialogResult != System.Windows.Forms.DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
FeatureClass featureClass = DtbFeatureLayer.FeatureClass as FeatureClass;
|
|
|
|
|
featureClass.Workspace.ExecuteSQL(string.Format("DELETE FROM DLTBBG where tbbsm='{0}'", (treeNode.Data as DataRow)["TBBSM"].ToString()));
|
|
|
|
|
treeNode.Nodes.Clear();//初始化变更图斑
|
|
|
|
|
IFeature JCfeature = (treeNode.ParentNode.Data as IFeatureLayer).FeatureClass.GetFeature(treeNode.NodeID.ToString().ToInt());
|
|
|
|
|
IFeatureCursor BGcursor = DtbFeatureLayer.FeatureClass.Insert(true);
|
|
|
|
|
IFeatureBuffer BGbuffer = DtbFeatureLayer.FeatureClass.CreateFeatureBuffer();
|
|
|
|
|
BGbuffer.Shape = JCfeature.ShapeCopy;
|
|
|
|
|
IFields fields = JCfeature.Fields;//JC
|
|
|
|
|
for (int i = 0; i < fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IField field = fields.get_Field(i);
|
|
|
|
|
if (BGbuffer.Fields.FindField(field.Name) != -1 && field.Name.ToUpper() == "SFJZ")
|
|
|
|
|
{
|
|
|
|
|
BGbuffer.Value[BGbuffer.Fields.FindField(field.Name)] = "0";//当前仅为“SFJZ”为不可为空情况
|
|
|
|
|
}
|
|
|
|
|
else if (BGbuffer.Fields.FindField(field.Name) != -1 && field.Editable == true && field.Name.ToUpper() != "SHAPE_AREA")
|
|
|
|
|
{
|
|
|
|
|
BGbuffer.Value[BGbuffer.Fields.FindField(field.Name)] = JCfeature.Value[i];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BGbuffer.Value[BGbuffer.Fields.FindField("TBBH")] = "";
|
|
|
|
|
//陕西需求
|
|
|
|
|
BGbuffer.Value[BGbuffer.Fields.FindField("TBYBH")] = JCfeature.Value[JCfeature.Fields.FindField("JCBH")].ToString();
|
|
|
|
|
IArea area1 = JCfeature.ShapeCopy as IArea;
|
|
|
|
|
BGbuffer.Value[BGbuffer.Fields.FindField("TBMJ")] = Math.Round(area1.Area, 2);//图斑面积
|
|
|
|
|
if (BGbuffer.Fields.FindField("GLTC") > -1)
|
|
|
|
|
BGbuffer.Value[BGbuffer.Fields.FindField("GLTC")] = ((IDataset)JCfeature.Class).Name;//关联图层
|
|
|
|
|
BGbuffer.Value[BGbuffer.Fields.FindField("BSM")] = Guid.NewGuid().ToTrim().Replace("-", "").Substring(0, 18);
|
|
|
|
|
object OIDXZ = BGcursor.InsertFeature(BGbuffer);
|
|
|
|
|
BGcursor.Flush();
|
|
|
|
|
IFeature DTBBgF = DtbFeatureLayer.FeatureClass.GetFeature(Convert.ToInt32(OIDXZ));
|
|
|
|
|
TreeNode bgfwNode = new TreeNode()//第四级-变更图斑
|
|
|
|
|
{
|
|
|
|
|
Name = BGbuffer.Value[BGbuffer.Fields.FindField("BSM")] as string,
|
|
|
|
|
Paixu = 1,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.General;component/Resources/变更图斑.png",
|
|
|
|
|
NodeID = OIDXZ,
|
|
|
|
|
NodeLevel = 3,
|
|
|
|
|
Data = DTBBgF,
|
|
|
|
|
ParentNode = treeNode,
|
|
|
|
|
PackageNode = treeNode.ParentNode,//图层一级
|
|
|
|
|
PackageState = "未完成"
|
|
|
|
|
};
|
|
|
|
|
treeNode.Nodes.Add(bgfwNode);
|
|
|
|
|
treeNode.Name = JCfeature.Value[JCfeature.Fields.FindField("JCBH")] + $"({treeNode.Nodes.Count})";
|
|
|
|
|
if (BGcursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(BGcursor);
|
|
|
|
|
if (BGbuffer != null)
|
|
|
|
|
Marshal.ReleaseComObject(BGbuffer);
|
|
|
|
|
if (JCfeature != null)
|
|
|
|
|
Marshal.ReleaseComObject(JCfeature);
|
|
|
|
|
}
|
|
|
|
|
else if (treeNode.Data is WYRWTB) //初始化任务包数据图斑
|
|
|
|
|
{
|
|
|
|
|
if (treeNode.Nodes.Count > 0 && !IsDirectoverlay)
|
|
|
|
|
{
|
|
|
|
|
System.Windows.Forms.DialogResult dialogResult = MessageHelper.ShowYesNoAndTips("是否覆盖已有变更范围?");
|
|
|
|
|
if (dialogResult != System.Windows.Forms.DialogResult.Yes)
|
|
|
|
|
{
|
|
|
|
|
return;//不覆盖当前图斑则不进行图斑初始化
|
|
|
|
|
}
|
|
|
|
|
treeNode.Nodes.Clear();//初始化变更图斑
|
|
|
|
|
treeNode.Name = (treeNode.Data as WYRWTB).TBBSM + $"({treeNode.Nodes.Count})";
|
|
|
|
|
}
|
|
|
|
|
else//IsDirectoverlay 是否直接初始化
|
|
|
|
|
{
|
|
|
|
|
treeNode.Nodes.Clear();//初始化变更图斑
|
|
|
|
|
}
|
|
|
|
|
#region 删除当前外业任务图斑下的变更图斑
|
|
|
|
|
//首先获取到当前外业图斑
|
|
|
|
|
wyFeature = WyrwFeatureLayer.FeatureClass.GetFeature(int.Parse(treeNode.NodeID.ToString()));
|
|
|
|
|
if (wyFeature == null || wyFeature.Shape.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
MessageHelper.Show("外业任务图斑图形为空:" + treeNode.NodeID.ToString());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
queryFilter = new QueryFilterClass()
|
|
|
|
|
{
|
|
|
|
|
WhereClause = $"TBBSM='{(treeNode.Data as WYRWTB).TBBSM}'"
|
|
|
|
|
};
|
|
|
|
|
StartEdit(DtbFeatureLayer);
|
|
|
|
|
EngineEditorBG.StartOperation();
|
|
|
|
|
cursor = DtbFeatureLayer.FeatureClass.Search(queryFilter, false);
|
|
|
|
|
while ((feature = cursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
feature.Delete();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
//新增外业任务图斑
|
|
|
|
|
IFeature newFeature = DtbFeatureLayer.FeatureClass.CreateFeature();
|
|
|
|
|
newFeature.Shape = wyFeature.ShapeCopy;
|
|
|
|
|
newFeature.set_Value(newFeature.Fields.FindField("BSM"), Guid.NewGuid().ToString().Replace("-", ""));
|
|
|
|
|
newFeature.set_Value(newFeature.Fields.FindField("TBBSM"), (treeNode.Data as WYRWTB).TBBSM);
|
|
|
|
|
rdbHelper = RDBFactory.CreateDbHelper($"{(treeNode.ParentNode.Data as TaskPackage).PackageTempPath}{(MapsManager.Instance.CurrProjectInfo as ProjectInfo).Pathpassword}", DatabaseType.SQLite);
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
//恢复已删除的外业照片
|
|
|
|
|
rdbHelper.BeginTransaction();
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"update wyhcfj set UserDelete=0 WHERE HCJLBSM='{(treeNode.Data as WYRWTB).TBBSM}'", CommandType.Text);
|
|
|
|
|
//继承外业属性字段
|
|
|
|
|
DataTable dataTable = rdbHelper.ExecuteDatatable("data", $"select HCBGDL as DLBM,WBGYY,ZZSX AS ZZSXDM,TBXHSX AS TBXHDM,(case when length(replace(ddtcxx,' ',''))< 4 then '一般地类' else replace(ddtcxx,' ','') end) AS DDTCBZ,GDLX,cast(XZDLKD as numeric) AS XZDWKD from wyhccg where hcrwbsm='{(treeNode.Data as WYRWTB).TBBSM}'", true);
|
|
|
|
|
if (dataTable != null && dataTable.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (DataColumn item in dataTable.Columns)
|
|
|
|
|
{
|
|
|
|
|
int fieldIndex = newFeature.Fields.FindField(item.ColumnName);
|
|
|
|
|
if (fieldIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
newFeature.set_Value(fieldIndex, dataTable.Rows[0][item.ColumnName]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
newFeature.Store();
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.Commit();
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
}
|
|
|
|
|
EngineEditorBG.StopOperation("初始化任务包变更图斑");
|
|
|
|
|
SaveEingineEdit();
|
|
|
|
|
EngineEditorBG.StopEditing(true);
|
|
|
|
|
MapsManager.Instance.MapService.getAxMapControl().CurrentTool = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("初始化图斑变量" + ex.Message);
|
|
|
|
|
if (EngineEditorBG != null)
|
|
|
|
|
EngineEditorBG.AbortOperation();
|
|
|
|
|
MessageHelper.ShowError("初始化图斑变量" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (rdbHelper != null)
|
|
|
|
|
rdbHelper.DisConnect();
|
|
|
|
|
if (cursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(cursor);
|
|
|
|
|
if (wyFeature != null)
|
|
|
|
|
Marshal.ReleaseComObject(wyFeature);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取监测图斑的修改状态
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取监测图斑的修改状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="JCtreeNode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string GetNodesJCZT(TreeNode JCtreeNode)
|
|
|
|
|
{
|
|
|
|
|
if (JCtreeNode.Nodes.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
if (JCtreeNode.Nodes.FirstOrDefault(x => x.PackageState == "质检错误") != null)
|
|
|
|
|
{
|
|
|
|
|
return "质检错误";
|
|
|
|
|
}
|
|
|
|
|
else if (JCtreeNode.Nodes.FirstOrDefault(x => x.PackageState == "未完成") != null)
|
|
|
|
|
{
|
|
|
|
|
return "未完成";
|
|
|
|
|
}
|
|
|
|
|
else if (JCtreeNode.Nodes.FirstOrDefault(x => string.IsNullOrWhiteSpace(x.PackageState)) != null)
|
|
|
|
|
{
|
|
|
|
|
return "未完成";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "已完成";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return "未完成";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 加载任务包
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 加载任务包
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="treeNode">任务包节点</param>
|
|
|
|
|
public virtual void LoadDBToTreeNode(TreeNode treeNode)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
TaskPackage taskPackage = treeNode.Data as TaskPackage;
|
|
|
|
|
if (string.IsNullOrWhiteSpace(taskPackage.PackagePath) || !File.Exists(taskPackage.PackagePath))
|
|
|
|
|
throw new Exception("任务包源文件已删除,无法打开!");
|
|
|
|
|
PluginServiceInterface.CommonHelper.UpdateAppsettingValueByKey("JkTaskDBName", $"{projectInfo.TaskPath}\\临时\\{taskPackage.PackageName}\\{taskPackage.PackageName.Replace("encrypt.", "")}", "UserLoginConfig");
|
|
|
|
|
Dictionary<WYRWTB, List<DTBDLTBGX>> dicTBInfo = new DTBDBLoadHelper().DBTaskLoad(treeNode.Data as TaskPackage, this.hookHelper);
|
|
|
|
|
if (dicTBInfo != null && dicTBInfo.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (var item in dicTBInfo)
|
|
|
|
|
{
|
|
|
|
|
//外业任务图斑
|
|
|
|
|
TreeNode treeWYRWNode = new TreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = item.Key.TBBSM + "(0)",
|
|
|
|
|
Paixu = i++,
|
|
|
|
|
IsExpanded = false,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.General;component/Resources/未星标.png",
|
|
|
|
|
Data = item.Key,
|
|
|
|
|
NodeLevel = 2,
|
|
|
|
|
NodeID = item.Key.ObjectID,
|
|
|
|
|
ParentNode = treeNode,
|
|
|
|
|
PackageNode = treeNode,
|
|
|
|
|
PackageState = item.Key.ZT,
|
|
|
|
|
cMenu = new ContextMenu()
|
|
|
|
|
};
|
|
|
|
|
if (item.Key.XBTB == 1)
|
|
|
|
|
{
|
|
|
|
|
treeWYRWNode.Icon = "pack://application:,,,/Kingo.Plugin.General;component/Resources/星标.png";
|
|
|
|
|
}
|
|
|
|
|
int j = 0;
|
|
|
|
|
if (item.Value != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var bgfw in item.Value)
|
|
|
|
|
{
|
|
|
|
|
TreeNode treeWYTBNode = new TreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = bgfw.BSM,
|
|
|
|
|
Paixu = j++,
|
|
|
|
|
IsExpanded = false,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.General;component/Resources/变更图斑.png",
|
|
|
|
|
NodeID = bgfw.ObjectID,
|
|
|
|
|
NodeLevel = 3,
|
|
|
|
|
Data = bgfw,
|
|
|
|
|
ParentNode = treeWYRWNode,
|
|
|
|
|
PackageNode = treeNode//任务包对应节点
|
|
|
|
|
};
|
|
|
|
|
treeWYRWNode.Nodes.Add(treeWYTBNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
treeWYRWNode.Name = item.Key.TBBSM + "(" + treeWYRWNode.Nodes.Count + ")";
|
|
|
|
|
treeNode.Nodes.Add(treeWYRWNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("LoadDBToTreeNode异常:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("LoadDBToTreeNode异常:" + ex.StackTrace);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region SelectedItemChanged
|
|
|
|
|
public virtual NYYSInfo SelectedItemChanged(TreeNode CurrentSelectNode, ref List<RuleEntity> ruleEntities)
|
|
|
|
|
{
|
|
|
|
|
NYYSInfo nYYSInfo = new NYYSInfo();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (CurrentSelectNode.NodeLevel == 3)
|
|
|
|
|
{
|
|
|
|
|
StartEdit(DtbFeatureLayer);
|
|
|
|
|
(DtbFeatureLayer as IFeatureSelection).Clear();
|
|
|
|
|
if (CurrentSelectNode.NodeID == null)
|
|
|
|
|
return nYYSInfo;
|
|
|
|
|
if (CurrentSelectNode.Data is DTBDLTBGX && CurrentSelectNode.ParentNode.Data is WYRWTB)
|
|
|
|
|
{
|
|
|
|
|
nYYSInfo.DTBDLTBGX = CurrentSelectNode.Data as DTBDLTBGX;
|
|
|
|
|
nYYSInfo.WYRWTB = CurrentSelectNode.ParentNode.Data as WYRWTB;
|
|
|
|
|
nYYSInfo.TaskPackages = CurrentSelectNode.ParentNode.ParentNode.Data as TaskPackage;
|
|
|
|
|
nYYSInfo.BingDataType = PluginServiceInterface.Enums.DTBDataTypeEnum.DTBJK;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
MapsManager.Instance.MapService.SelectFeature("DLTBBG", CurrentSelectNode.NodeID.ToString(), true);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{ }
|
|
|
|
|
LoadCheckResult();
|
|
|
|
|
return nYYSInfo;
|
|
|
|
|
}
|
|
|
|
|
else if (CurrentSelectNode.ParentNode.Data is DataRow)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//切换节点,定位当前变更图斑
|
|
|
|
|
int OID = CurrentSelectNode.NodeID.ToString().ToInt();
|
|
|
|
|
IFeature BGF = DtbFeatureLayer.FeatureClass.GetFeature(OID);
|
|
|
|
|
if (BGF != null)
|
|
|
|
|
{
|
|
|
|
|
CurrentSelectNode.Data = BGF;
|
|
|
|
|
//string BSMValue = BGF.Value[DtbFeatureLayer.FeatureClass.FindField("BSM")].ToString();
|
|
|
|
|
TreeNode BGtreeNode = CurrentSelectNode;// GetNodeByName(TreeDataSource[0], BSMValue, new List<int>() { 3 });
|
|
|
|
|
if (BGtreeNode != null)
|
|
|
|
|
{
|
|
|
|
|
BGtreeNode.LoadingVisibility = Visibility.Visible;
|
|
|
|
|
MapsManager.Instance.MapService.ClearFeatureSelection(hookHelper.Hook as IMapControlDefault);
|
|
|
|
|
MapsManager.Instance.MapService.SelectFeature("DLTBBG", BGF.OID.ToString(), true);
|
|
|
|
|
BGtreeNode.LoadingVisibility = Visibility.Collapsed;
|
|
|
|
|
ruleEntities = RuleCheck.XJRuleCheck.RuleCheckOpertion_DTB.StartXJSHCheck(BGF, null);
|
|
|
|
|
if (ruleEntities != null)
|
|
|
|
|
BGtreeNode.PackageState = ruleEntities.Count > 0 ? "质检错误" : "已完成";
|
|
|
|
|
CurrentSelectNode.ParentNode.PackageState = GetNodesJCZT(CurrentSelectNode.ParentNode);
|
|
|
|
|
return SetIVariantArrayData(BGtreeNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{ //若是该操作失败,移除当前节点
|
|
|
|
|
CurrentSelectNode.ParentNode.Nodes.Remove(CurrentSelectNode);
|
|
|
|
|
LogAPI.Debug("移除当前节点失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
return nYYSInfo;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (CurrentSelectNode.NodeLevel == 2)
|
|
|
|
|
{
|
|
|
|
|
StopEditForDTBJK(EngineEditorBG);
|
|
|
|
|
if (WyrwFeatureLayer != null)
|
|
|
|
|
(WyrwFeatureLayer as IFeatureSelection).Clear();
|
|
|
|
|
if (DtbFeatureLayer != null)
|
|
|
|
|
(DtbFeatureLayer as IFeatureSelection).Clear();
|
|
|
|
|
if (CurrentSelectNode.Data is WYRWTB)
|
|
|
|
|
{
|
|
|
|
|
if (CurrentSelectNode.Nodes.Count != 0)
|
|
|
|
|
nYYSInfo.DTBDLTBGX = CurrentSelectNode.Nodes[0].Data as DTBDLTBGX;
|
|
|
|
|
nYYSInfo.WYRWTB = CurrentSelectNode.Data as WYRWTB;
|
|
|
|
|
nYYSInfo.TaskPackages = CurrentSelectNode.ParentNode.Data as TaskPackage;
|
|
|
|
|
nYYSInfo.BingDataType = PluginServiceInterface.Enums.DTBDataTypeEnum.DTBJK;
|
|
|
|
|
|
|
|
|
|
MapsManager.Instance.MapService.SelectFeature("WYRW", (CurrentSelectNode.Data as WYRWTB).ObjectID.ToString(), true);
|
|
|
|
|
if (CurrentSelectNode.Nodes.Count >= 1)
|
|
|
|
|
LoadCheckResult();
|
|
|
|
|
return nYYSInfo;
|
|
|
|
|
}
|
|
|
|
|
else if (CurrentSelectNode.Nodes.Count != 0 && CurrentSelectNode.Data != null && CurrentSelectNode.Data is DataRow)
|
|
|
|
|
{
|
|
|
|
|
CurrentSelectNode.LoadingVisibility = Visibility.Visible;
|
|
|
|
|
//System.Windows.Forms.Application.DoEvents();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IFeature JCF = (CurrentSelectNode.ParentNode.Data as IFeatureLayer).FeatureClass.GetFeature(CurrentSelectNode.NodeID.ToString().ToInt());
|
|
|
|
|
string JCTCName = ((IDataset)JCF.Class).Name;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(JCTCName))
|
|
|
|
|
MapsManager.Instance.MapService.SelectFeature(JCTCName, JCF.OID.ToString(), true);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception)
|
|
|
|
|
{ }
|
|
|
|
|
CurrentSelectNode.LoadingVisibility = Visibility.Collapsed;
|
|
|
|
|
return SetIVariantArrayData(CurrentSelectNode);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (CurrentSelectNode.NodeLevel == 1)
|
|
|
|
|
{
|
|
|
|
|
if (CurrentSelectNode.Nodes.Count > 0)
|
|
|
|
|
StartEdit(WyrwFeatureLayer);//开启任务图斑图层编辑
|
|
|
|
|
//单图斑任务包一级
|
|
|
|
|
if (CurrentSelectNode.Data as TaskPackage == null) return nYYSInfo;
|
|
|
|
|
if (CurrentSelectNode.Nodes == null || CurrentSelectNode.Nodes.Count == 0) return nYYSInfo;
|
|
|
|
|
}
|
|
|
|
|
else if (CurrentSelectNode.NodeLevel == 0)
|
|
|
|
|
{
|
|
|
|
|
EngineEditorBG.StopEditing(false);//第一级仅关闭不保存
|
|
|
|
|
MapsManager.Instance.MapService.getAxMapControl().ActiveView.Refresh();
|
|
|
|
|
//StopEditForDTBJK(EngineEditorBG);
|
|
|
|
|
}
|
|
|
|
|
else if (CurrentTaskPackage != null)//避免加载任务包时,报错!
|
|
|
|
|
{
|
|
|
|
|
//应对任务图斑新增
|
|
|
|
|
PluginServiceInterface.CommonHelper.ExeCommandOperation("执行结束编辑");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("选择节点SelectedItemChanged异常:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("选择节点SelectedItemChanged异常:" + ex.StackTrace);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
return nYYSInfo;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region MyRegion
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置单图斑矢量数据绑定信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="treeNode">变更图斑对应的末级树节点</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private NYYSInfo SetIVariantArrayData(TreeNode treeNode)
|
|
|
|
|
{
|
|
|
|
|
NYYSInfo arrays = new NYYSInfo();
|
|
|
|
|
IFeatureLayer JCTBFL = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (treeNode == null) return null;
|
|
|
|
|
int JCOID = -1;
|
|
|
|
|
if (treeNode.Data is IFeature)
|
|
|
|
|
{
|
|
|
|
|
DTBDLTBGX dTBDLTBGX = new DTBDLTBGX()
|
|
|
|
|
{
|
|
|
|
|
BSM = (treeNode.Data as IFeature).Value[DtbFeatureLayer.FeatureClass.FindField("BSM")].ToString() ?? "",
|
|
|
|
|
TBBSM = (treeNode.Data as IFeature).Value[DtbFeatureLayer.FeatureClass.FindField("TBBSM")].ToString() ?? "",
|
|
|
|
|
ObjectID = (treeNode.Data as IFeature).OID
|
|
|
|
|
};
|
|
|
|
|
arrays.DTBDLTBGX = dTBDLTBGX;// 把单图斑矢量变更图斑封装为DTBDLTBGX
|
|
|
|
|
JCOID = treeNode.ParentNode.NodeID.ToString().ToInt();
|
|
|
|
|
}
|
|
|
|
|
else if (treeNode.Data is DataRow)
|
|
|
|
|
{
|
|
|
|
|
JCOID = treeNode.NodeID.ToString().ToInt();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
if (treeNode.ParentNode != null && treeNode.PackageNode.Data is IFeatureLayer && JCOID != -1)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
JCTBFL = treeNode.PackageNode.Data as IFeatureLayer;
|
|
|
|
|
if (JCTBFL == null || JCTBFL.FeatureClass == null) return null;
|
|
|
|
|
IFeature JCfeature = JCTBFL.FeatureClass.GetFeature(JCOID);
|
|
|
|
|
if (JCfeature != null)
|
|
|
|
|
{
|
|
|
|
|
WYRWTB wYRWTB = new WYRWTB()
|
|
|
|
|
{
|
|
|
|
|
ObjectID = JCfeature.OID,
|
|
|
|
|
TBBSM = JCTBFL.FeatureClass.FindField("JCBH") != -1 ? JCfeature.Value[JCTBFL.FeatureClass.FindField("JCBH")].ToString() : "",
|
|
|
|
|
XZQDM = JCTBFL.FeatureClass.FindField("XZQDM") != -1 ? JCfeature.Value[JCTBFL.FeatureClass.FindField("XZQDM")].ToString() : "",
|
|
|
|
|
XZDM = JCTBFL.FeatureClass.FindField("XZDM") != -1 ? JCfeature.Value[JCTBFL.FeatureClass.FindField("XZDM")].ToString() : "",
|
|
|
|
|
JCBH = JCTBFL.FeatureClass.FindField("JCBH") != -1 ? JCfeature.Value[JCTBFL.FeatureClass.FindField("JCBH")].ToString() : "",
|
|
|
|
|
TBLX = JCTBFL.FeatureClass.FindField("TBLX") != -1 ? JCfeature.Value[JCTBFL.FeatureClass.FindField("TBLX")].ToString() : "",
|
|
|
|
|
SJLY = JCTBFL.FeatureClass.FindField("SJLY") != -1 ? JCfeature.Value[JCTBFL.FeatureClass.FindField("SJLY")].ToString() : "",
|
|
|
|
|
JCMJ = JCTBFL.FeatureClass.FindField("JCMJ") != -1 ? JCfeature.Value[JCTBFL.FeatureClass.FindField("JCMJ")].ToDecimal() : 0,
|
|
|
|
|
TBMJ = JCTBFL.FeatureClass.FindField("TBMJ") != -1 ? JCfeature.Value[JCTBFL.FeatureClass.FindField("TBMJ")].ToDecimal() : 0
|
|
|
|
|
};
|
|
|
|
|
arrays.WYRWTB = wYRWTB;// 把单图斑矢量监测图斑封装为WYRWTB
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("把单图斑矢量监测图斑封装为WYRWTB失败:" + ex.Message);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
// 获取要素类的实际名称
|
|
|
|
|
string featureClassName = ((IDataset)JCTBFL.FeatureClass).Name;
|
|
|
|
|
arrays.JCTBFeatureClassName = featureClassName;// 当前为对应的监测图层实际名称(英文名称)
|
|
|
|
|
arrays.BingDataType = PluginServiceInterface.Enums.DTBDataTypeEnum.DTBSL;
|
|
|
|
|
//Marshal.ReleaseComObject(JCTBFL);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("设置单图斑矢量数据绑定信息" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
return arrays;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region MyRegion
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据树结构展示名为条件查询某一节点
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="treeNode"></param>
|
|
|
|
|
/// <param name="name"></param>
|
|
|
|
|
/// <param name="nodeLevel"></param>
|
|
|
|
|
/// <param name="nodeID"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public TreeNode GetNodeByName(TreeNode treeNode, string name, List<int> nodeLevel, string nodeID = null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (treeNode != null && nodeLevel.Contains(treeNode.NodeLevel))
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(nodeID))//获取图斑节点
|
|
|
|
|
{
|
|
|
|
|
if (treeNode.Name.StartsWith(name) && treeNode.ParentNode != null && treeNode.ParentNode.NodeID.ToString().Equals(nodeID))
|
|
|
|
|
{
|
|
|
|
|
return treeNode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (!string.IsNullOrWhiteSpace(name) && treeNode.Name.StartsWith(name))
|
|
|
|
|
{
|
|
|
|
|
return treeNode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (treeNode.Nodes != null && treeNode.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in treeNode.Nodes)
|
|
|
|
|
{
|
|
|
|
|
TreeNode node = GetNodeByName(item, name, nodeLevel, nodeID);
|
|
|
|
|
if (node != null)
|
|
|
|
|
{
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("GetNodeByName执行失败(特殊情况不处理):" + ex.Message);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据树名称为条件查询某一节点
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="treeNode">树节点</param>
|
|
|
|
|
/// <param name="name">树节点展示名</param>
|
|
|
|
|
/// <param name="nodeLevel">数层级</param>
|
|
|
|
|
/// <param name="nodeID">数ID</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private TreeNode GetNodeByName(TreeNode treeNode, string name, int nodeLevel, string nodeID = null)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Queue<TreeNode> queue = new Queue<TreeNode>();
|
|
|
|
|
queue.Enqueue(treeNode);
|
|
|
|
|
while (queue.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
TreeNode node = queue.Dequeue();
|
|
|
|
|
if (node.Name == name)
|
|
|
|
|
{
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
foreach (TreeNode child in node.Nodes)
|
|
|
|
|
{
|
|
|
|
|
queue.Enqueue(child);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("GetNodeByName执行异常:" + ex.Message);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region MyRegion
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取图斑标识码
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="geometry3"></param>
|
|
|
|
|
/// <param name="tblx"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private string GetTBBSM(IFeature geometry3, ref string tblx)
|
|
|
|
|
{
|
|
|
|
|
IFeature featureTBBSM = null;
|
|
|
|
|
List<IFeature> features = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
IGeometry geometry = geometry3.ShapeCopy;
|
|
|
|
|
features = FeatureAPI.Identify2(geometry, WyrwFeatureLayer);
|
|
|
|
|
string tbbsm = string.Empty;
|
|
|
|
|
if (features != null && features.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
//如果仅压盖到了一个,则挂接到该外业任务图斑
|
|
|
|
|
if (features.Count == 1)
|
|
|
|
|
{
|
|
|
|
|
featureTBBSM = features[0];
|
|
|
|
|
}
|
|
|
|
|
else //如果压盖到多个,则挂接到压盖面积大的外业任务图斑上
|
|
|
|
|
{
|
|
|
|
|
double _area = -1;
|
|
|
|
|
foreach (var item in features)
|
|
|
|
|
{
|
|
|
|
|
geometry = DtbFeatureLayer.FeatureClass.GetFeature(geometry3.OID).ShapeCopy;
|
|
|
|
|
double interArea = FeatureAPI.GetInterArea(geometry, item.ShapeCopy);
|
|
|
|
|
if (_area < interArea)
|
|
|
|
|
{
|
|
|
|
|
_area = interArea;
|
|
|
|
|
featureTBBSM = item;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int index = featureTBBSM.Fields.FindField("TBBSM");
|
|
|
|
|
if (index > -1)
|
|
|
|
|
{
|
|
|
|
|
object obj = featureTBBSM.get_Value(index);
|
|
|
|
|
tbbsm = obj == null ? "" : obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
index = featureTBBSM.Fields.FindField("TBLX");
|
|
|
|
|
if (index > -1)
|
|
|
|
|
{
|
|
|
|
|
object obj = featureTBBSM.get_Value(index);
|
|
|
|
|
tblx = obj == null ? "" : obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrWhiteSpace(tbbsm))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("图斑与外业任务图斑数据不重叠!");
|
|
|
|
|
}
|
|
|
|
|
return tbbsm;
|
|
|
|
|
}
|
|
|
|
|
else//如果未压盖到外业任务图斑,则去压盖单图斑地类图斑更新层,和压盖到的单图斑地类图斑层一样挂接到对应的外业任务图斑
|
|
|
|
|
{
|
|
|
|
|
if (DtbFeatureLayer == null)
|
|
|
|
|
DtbFeatureLayer = MapsManager.Instance.MapService.GetFeatureLayerByName("DLTBBG");
|
|
|
|
|
features = FeatureAPI.Identify(geometry, DtbFeatureLayer);
|
|
|
|
|
if (features == null || features.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("图斑与外业任务图斑数据不重叠!");
|
|
|
|
|
}
|
|
|
|
|
//如果仅压盖到了一个,则挂接到该变更范围挂接的外业任务图斑
|
|
|
|
|
if (features.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
featureTBBSM = features[0];
|
|
|
|
|
}//如果压盖到多个,则挂接到压盖面积大的外业任务图斑上
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("图斑与外业任务图斑数据不重叠!");
|
|
|
|
|
}
|
|
|
|
|
int index = featureTBBSM.Fields.FindField("TBBSM");
|
|
|
|
|
if (index > -1)
|
|
|
|
|
{
|
|
|
|
|
object obj = featureTBBSM.get_Value(index);
|
|
|
|
|
tbbsm = obj == null ? "" : obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
index = featureTBBSM.Fields.FindField("TBLX");
|
|
|
|
|
if (index > -1)
|
|
|
|
|
{
|
|
|
|
|
object obj = featureTBBSM.get_Value(index);
|
|
|
|
|
tblx = obj == null ? "" : obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrWhiteSpace(tbbsm))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("图斑与外业任务图斑数据不重叠!");
|
|
|
|
|
}
|
|
|
|
|
return tbbsm;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex);
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (features != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var item in features)
|
|
|
|
|
{
|
|
|
|
|
Marshal.ReleaseComObject(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region GenerNewData
|
|
|
|
|
public void GenerNewData(IFeature Newfeature, IRDBHelper rdbHelper, string tbbsm)
|
|
|
|
|
{
|
|
|
|
|
IFeature feature = null;
|
|
|
|
|
IGeometry convertGeometry = null;
|
|
|
|
|
IClone clone = null;
|
|
|
|
|
ICursor cursor = null;
|
|
|
|
|
IRow row = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string bsm = string.Empty;
|
|
|
|
|
int bsmIndex = Newfeature.Fields.FindField("BSM");
|
|
|
|
|
if (bsmIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
bsm = Newfeature.get_Value(bsmIndex) as string;
|
|
|
|
|
}
|
|
|
|
|
Guid guidBSM;
|
|
|
|
|
//如果没值,则赋值新的GUID
|
|
|
|
|
if (string.IsNullOrWhiteSpace(bsm) || !Guid.TryParse(bsm, out guidBSM))
|
|
|
|
|
{
|
|
|
|
|
bsm = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
Platform.Instance.SendMsg(new KGIS.Framework.Utils.Interface.NotifyMsgPackage() { MsgType = "UpdateFJGX", Content = bsm, Extend = rdbHelper });
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//如果是分割图斑,两个要素bsm是一样的,判断存在多个BSM图斑,则也需要重新赋值BSM
|
|
|
|
|
IQueryFilter queryFilter = new QueryFilterClass()
|
|
|
|
|
{
|
|
|
|
|
WhereClause = $"bsm='{bsm}'"
|
|
|
|
|
};
|
|
|
|
|
cursor = (Newfeature.Class as ITable).Search(queryFilter, false);
|
|
|
|
|
int count = 0;
|
|
|
|
|
while ((row = cursor.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
count++;
|
|
|
|
|
if (count > 1)
|
|
|
|
|
{
|
|
|
|
|
bsm = Guid.NewGuid().ToString().Replace("-", "");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 防止存在多部件图形,但另一部分又是空的图形
|
|
|
|
|
IGeometryCollection geometryCollection = Newfeature.ShapeCopy as IGeometryCollection;
|
|
|
|
|
if (geometryCollection.GeometryCount > 1)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < geometryCollection.GeometryCount; i++)
|
|
|
|
|
{
|
|
|
|
|
IGeometry geometry = geometryCollection.Geometry[i];
|
|
|
|
|
if (!(geometry is IArea areaSub) || Math.Abs(areaSub.Area) == 0)
|
|
|
|
|
{
|
|
|
|
|
geometryCollection.RemoveGeometries(i, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Newfeature.Shape = geometryCollection as IGeometry;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 设置图形属性
|
|
|
|
|
//计算椭球面积
|
|
|
|
|
clone = Newfeature.ShapeCopy as IClone;
|
|
|
|
|
double tqmj = (clone.Clone() as IPolygon).GetEllipseArea();
|
|
|
|
|
//获取图形json坐标串
|
|
|
|
|
clone = Newfeature.ShapeCopy as IClone;
|
|
|
|
|
IGeometry cloneGeometry = clone.Clone() as IGeometry;
|
|
|
|
|
string egeometry = GeometryConvertHelper.ConverIGometryToJson(cloneGeometry);
|
|
|
|
|
//此处是为了验证转换后的json坐标串是否可以转换回去,如果转换并投影后图形为空,说明转换后的坐标串egeometry不正确
|
|
|
|
|
convertGeometry = GeometryConvertHelper.ConverJsonToIGeoemtry(egeometry);
|
|
|
|
|
if (convertGeometry == null)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(egeometry);
|
|
|
|
|
throw new Exception("图形转换后的Json坐标串无法转回图形!");
|
|
|
|
|
}
|
|
|
|
|
convertGeometry.Project(this.hookHelper.FocusMap.SpatialReference);
|
|
|
|
|
if (convertGeometry == null || convertGeometry.IsEmpty)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(egeometry);
|
|
|
|
|
throw new Exception("图形转换的Json坐标串坐标参考不正确,请尝试重启软件!");
|
|
|
|
|
}
|
|
|
|
|
//获取图形四至、中心点坐标
|
|
|
|
|
IArea area = cloneGeometry as IArea;
|
|
|
|
|
string fields = "BSM,TBBSM,EGeometry,TBMJ,TBDLMJ,ZXDX,ZXDY,MAXX,MAXY,MINX,MINY,JKRY,TBLX,LNGDZB";
|
|
|
|
|
string fieldValues = $"'{bsm}','{tbbsm}','{egeometry}',{tqmj},{tqmj},{area.Centroid.X},{area.Centroid.Y},{cloneGeometry.Envelope.XMax},{cloneGeometry.Envelope.YMax},{cloneGeometry.Envelope.XMin},{cloneGeometry.Envelope.YMin},'{projectInfo.UserName}','{"0"}'";
|
|
|
|
|
#region 更新要素字段信息
|
|
|
|
|
|
|
|
|
|
int tempDDTCBZIndex = Newfeature.Fields.FindField("DDTCBZ");
|
|
|
|
|
string tempDDTCBZ = null;
|
|
|
|
|
if (tempDDTCBZIndex > -1)
|
|
|
|
|
tempDDTCBZ = Newfeature.get_Value(tempDDTCBZIndex).ToString();
|
|
|
|
|
|
|
|
|
|
int tempDLBMIndex = Newfeature.Fields.FindField("DLBM");
|
|
|
|
|
string tempDLBM = null;
|
|
|
|
|
if (tempDLBMIndex > -1)
|
|
|
|
|
tempDLBM = Newfeature.get_Value(tempDLBMIndex).ToString();
|
|
|
|
|
|
|
|
|
|
//图层信息选择单独图层的,除路面范围,默认地类直接继承基础库原地类
|
|
|
|
|
if (!string.IsNullOrEmpty(tempDDTCBZ) && tempDDTCBZ != "一般地类" && !tempDDTCBZ.Equals("1305", StringComparison.CurrentCultureIgnoreCase) && string.IsNullOrEmpty(tempDLBM))
|
|
|
|
|
{
|
|
|
|
|
ILayer layer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("基础_地类图斑");
|
|
|
|
|
if (layer != null)
|
|
|
|
|
{
|
|
|
|
|
List<IFeature> JCfeatures = FeatureAPI.Identify2(Newfeature.ShapeCopy, layer);
|
|
|
|
|
if (JCfeatures != null && JCfeatures.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
int jcdlbmIndex = JCfeatures[0].Fields.FindField("DLBM");
|
|
|
|
|
if (jcdlbmIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
tempDLBM = JCfeatures[0].get_Value(jcdlbmIndex).ToString();
|
|
|
|
|
Newfeature.set_Value(tempDLBMIndex, tempDLBM);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int fIndex = Newfeature.Fields.FindField("bsm");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, bsm);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("egeometry");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, egeometry);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("tbbsm");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, tbbsm);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("BID");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, CurrentTaskPackage.BID);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("TBMJ");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, tqmj);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("TBDLMJ");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, tqmj);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("ZXDX");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, area.Centroid.X);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("ZXDY");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, area.Centroid.Y);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("MAXX");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, cloneGeometry.Envelope.XMax);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("MAXY");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, cloneGeometry.Envelope.YMax);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("MINX");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, cloneGeometry.Envelope.XMin);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("MINY");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, cloneGeometry.Envelope.YMin);
|
|
|
|
|
}
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("JKRY");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, projectInfo.UserName);
|
|
|
|
|
}
|
|
|
|
|
string zzsxdm = null;
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("ZZSXDM");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
zzsxdm = Newfeature.get_Value(fIndex).ToString();
|
|
|
|
|
if (!string.IsNullOrEmpty(tempDDTCBZ) && !string.IsNullOrEmpty(tempDLBM) && "1301,1302,1303,1304".Contains(tempDDTCBZ) && "0101,0102,0103".Contains(tempDLBM))
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(zzsxdm))
|
|
|
|
|
{
|
|
|
|
|
zzsxdm = "WG";
|
|
|
|
|
Newfeature.set_Value(fIndex, "WG");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("ZZSXMC");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
//种植属性名称
|
|
|
|
|
string zzsxmc = string.Empty;
|
|
|
|
|
DataDicTionary dataDicTionary = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.ZZSX).FirstOrDefault(x => x.CODE.Equals(zzsxdm));
|
|
|
|
|
if (dataDicTionary != null)
|
|
|
|
|
{
|
|
|
|
|
zzsxmc = dataDicTionary.NAME;
|
|
|
|
|
}
|
|
|
|
|
Newfeature.set_Value(fIndex, zzsxmc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 计算变更范围与历年耕地图层的相交面积
|
|
|
|
|
double lngdArea = 0;
|
|
|
|
|
//shape_area图形面积
|
|
|
|
|
IArea area1 = Newfeature.ShapeCopy as IArea;
|
|
|
|
|
double jcmj = Math.Round(area1.Area, 2);
|
|
|
|
|
string lngdzb = Math.Round((lngdArea / jcmj) * 100, 2) + "%";
|
|
|
|
|
fIndex = Newfeature.Fields.FindField("LNGDZB");
|
|
|
|
|
if (fIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
Newfeature.set_Value(fIndex, lngdzb);
|
|
|
|
|
}
|
|
|
|
|
fieldValues += $",'{lngdzb}'";
|
|
|
|
|
#endregion
|
|
|
|
|
#endregion
|
|
|
|
|
Newfeature.Store();
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//删除库中已存在的数据
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from dtbdltbgx where bsm='{bsm}'", CommandType.Text);
|
|
|
|
|
string excuteSQL = string.Format("insert into dtbdltbgx({0})values({1})", fields, fieldValues);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(excuteSQL, CommandType.Text);
|
|
|
|
|
|
|
|
|
|
//保存其他属性字段和独立图层信息表
|
|
|
|
|
SaveBGFWAndDLTC(tbbsm, bsm, rdbHelper, Newfeature);
|
|
|
|
|
//保存更新过程数据
|
|
|
|
|
DTBDBLoadHelper.SaveGXGCData(bsm, tbbsm, Newfeature, rdbHelper, this.hookHelper);//同步保存
|
|
|
|
|
|
|
|
|
|
object dlbmOBJ = Newfeature.get_Value(Newfeature.Fields.FindField("DLBM"));
|
|
|
|
|
string dlbm = dlbmOBJ == null ? "" : dlbmOBJ.ToString();
|
|
|
|
|
//自动填充是否更新和是否举证字段
|
|
|
|
|
ValidationField(bsm, Newfeature, rdbHelper, dlbm, tqmj);
|
|
|
|
|
|
|
|
|
|
#region 同步更新树结构数据
|
|
|
|
|
TreeNode treeNode = GetNodeByName(TreeDataSource[0], tbbsm, new List<int>() { 2 });
|
|
|
|
|
if (treeNode != null && treeNode.NodeLevel == 2)
|
|
|
|
|
{
|
|
|
|
|
if (treeNode.Nodes == null)
|
|
|
|
|
{
|
|
|
|
|
treeNode.Nodes = new ObservableCollection<TreeNode>();
|
|
|
|
|
}
|
|
|
|
|
List<TreeNode> lsttree = treeNode.Nodes.Where(x => x.NodeID.Equals(Newfeature.OID)).ToList();
|
|
|
|
|
TreeNode addNode = null;
|
|
|
|
|
if (lsttree.Count() <= 0)
|
|
|
|
|
{
|
|
|
|
|
DataTable dataTable = rdbHelper.ExecuteDatatable("data", $"select * from dtbdltbgx where bsm='{bsm}'", true);
|
|
|
|
|
addNode = new TreeNode()
|
|
|
|
|
{
|
|
|
|
|
Name = bsm,
|
|
|
|
|
Paixu = treeNode.Nodes.Count + 10,
|
|
|
|
|
IsExpanded = false,
|
|
|
|
|
Icon = "pack://application:,,,/Kingo.Plugin.General;component/Resources/变更图斑.png",
|
|
|
|
|
NodeLevel = 3,
|
|
|
|
|
Data = KGIS.Framework.Utils.Utility.TBToList.ConvertEntity<DTBDLTBGX>(dataTable.Rows[0]),
|
|
|
|
|
cMenu = null,
|
|
|
|
|
PackageNode = treeNode.PackageNode,
|
|
|
|
|
ParentNode = treeNode,
|
|
|
|
|
NodeID = Newfeature.OID
|
|
|
|
|
};
|
|
|
|
|
(addNode.Data as DTBDLTBGX).ObjectID = Newfeature.OID;//补充OID值
|
|
|
|
|
treeNode.Name = tbbsm + "(" + (treeNode.Nodes.Count + 1) + ")";
|
|
|
|
|
treeNode.Nodes.Add(addNode);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
addNode = lsttree[0];
|
|
|
|
|
}
|
|
|
|
|
addNode.Name = bsm;
|
|
|
|
|
//循环判断变更图斑图形是否存在,不存在则删除变更范围节点
|
|
|
|
|
if (treeNode.Nodes.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
List<TreeNode> deleteList = new List<TreeNode>();
|
|
|
|
|
foreach (var item in treeNode.Nodes)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DtbFeatureLayer.FeatureClass.GetFeature((int)item.NodeID);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
deleteList.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach (var item in deleteList)
|
|
|
|
|
{
|
|
|
|
|
treeNode.Nodes.Remove(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//更新节点数量
|
|
|
|
|
treeNode.Name = tbbsm + "(" + (treeNode.Nodes.Count) + ")";
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
SyncDBData(Newfeature.Class as IFeatureClass, rdbHelper, tbbsm);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("新增或修改单图斑变更范围失败:" + ex.Message);
|
|
|
|
|
LogAPI.Debug("新增或修改单图斑变更范围失败:" + ex.StackTrace);
|
|
|
|
|
LogAPI.Debug("新增或修改单图斑变更范围失败:" + ex);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (row != null)
|
|
|
|
|
Marshal.ReleaseComObject(row);
|
|
|
|
|
if (cursor != null)
|
|
|
|
|
Marshal.ReleaseComObject(cursor);
|
|
|
|
|
if (clone != null)
|
|
|
|
|
Marshal.ReleaseComObject(clone);
|
|
|
|
|
if (convertGeometry != null)
|
|
|
|
|
Marshal.ReleaseComObject(convertGeometry);
|
|
|
|
|
if (feature != null)
|
|
|
|
|
Marshal.ReleaseComObject(feature);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 验证字段填写是否正确
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 验证字段填写是否正确
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void ValidationField(string bsm, IFeature feature, IRDBHelper rdbHelper, string dlbm, double tbmj)
|
|
|
|
|
{
|
|
|
|
|
/*
|
|
|
|
|
* 单图斑建库软件:“是否更新”“未变更原因”“是否举证”“情况说明”“类举类型”部分情况需软件自动填写及控制。具体如下:
|
|
|
|
|
(1)“是否更新”“是否举证”字段不允许地方填写,由系统依据相关情况自动填写。
|
|
|
|
|
(2)“是否更新”字段需系统自动填写,不允许县级进行编辑。填写规则为:
|
|
|
|
|
①对于绘制单图斑的地类编码、种植属性代码、图斑细化代码与单图斑叠加到的基础库图斑的地类编码、种植属性代码、图斑细化代码进行对比,三个属性完全一致的部分认定为“未变化部分”,若“未变化部分之和”占单图斑面积比例≥90%,“是否更新”系统自动填写为“否”。(特殊的:单图斑为0404A、1001A、1002A、1003A、1004A默认与基础库0404、1001、1002、1003、1004相同)
|
|
|
|
|
②除①条件外的其他图斑,认定为“变化图斑”,在“是否更新”属性自动填写为单图斑填写的地类编码(单图斑地类为0404A、1001A、1002A、1003A、1004A的分别填写为0404、1001、1002、1003、1004)。
|
|
|
|
|
(3)“未变更原因”字段需系统进行部分控制,当“是否更新”不为“否”的,“未变更原因”字段直接灰掉,不允许地方进行填写编辑。但“是否更新”为“否”时,“未变更原因”字段需由地方填写,且不得小于10个字符,否则保存时,定位到“未变更原因”字段红框提示。
|
|
|
|
|
(4)“是否举证”字段需系统进行控制,不允许县级进行编辑。填写规则为:
|
|
|
|
|
①当“类举类型”为“承诺举证”“军事用地”“类举举证个”“实地无法到达”“图斑不够上图面积”“影像支持”时,“是否举证”直接填入“类举类型”字段;
|
|
|
|
|
②除①以外,单图斑存在实地举证照片时,“是否举证”直接填入“实地举证”;
|
|
|
|
|
③除①和②以外的,未挂接照片的单图斑,“是否举证”直接填入“否”。
|
|
|
|
|
(5)“情况说明”字段需系统进行部分控制,当“是否举证”不为“否”的,“情况说明”字段可填写也可不填写,若填写则不得低于5个字符。当“是否举证”为“否”时,“情况说明”字段需由地方填写,且不得小于10个字符,否则保存时,定位到“情况说明”字段红框提示。
|
|
|
|
|
*/
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string sfgx = string.Empty;
|
|
|
|
|
double mj = 0;
|
|
|
|
|
int checkFieldIndex = -1;
|
|
|
|
|
//if (SysConfigsOprator.GetAppsetingValueByKey("ArearName").Equals("44"))
|
|
|
|
|
//{
|
|
|
|
|
#region (1)“是否更新”“是否举证”字段不允许地方填写,由系统依据相关情况自动填写。(3)“未变更原因”字段需系统进行部分控制
|
|
|
|
|
if (dlbm == "8801")
|
|
|
|
|
sfgx = "未变更";
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ILayer layer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("基础_地类图斑");
|
|
|
|
|
Dictionary<IGeometry, IFeature> listFeatures = DBLoadHelper.IdentifyReturnIntersect(feature.ShapeCopy, layer);
|
|
|
|
|
foreach (var item in listFeatures)
|
|
|
|
|
{
|
|
|
|
|
IFeature itemFeature = item.Value;
|
|
|
|
|
checkFieldIndex = itemFeature.Fields.FindField("dlbm");
|
|
|
|
|
if (checkFieldIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
string DLBM = itemFeature.get_Value(checkFieldIndex).ToString();
|
|
|
|
|
if (dlbm == DLBM)
|
|
|
|
|
continue;
|
|
|
|
|
mj += (item.Key as IPolygon).GetEllipseArea();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (mj / tbmj > 0.9)
|
|
|
|
|
sfgx = "整图斑变更";
|
|
|
|
|
if (mj / tbmj > 0.1 && mj / tbmj < 0.9)
|
|
|
|
|
sfgx = "部分变更";
|
|
|
|
|
if (mj / tbmj < 0.1)
|
|
|
|
|
sfgx = "未变更";
|
|
|
|
|
checkFieldIndex = feature.Fields.FindField("sfgx");
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"update dtbdltbgx set sfgx='{sfgx}' where bsm='{bsm}'", CommandType.Text);
|
|
|
|
|
if (checkFieldIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
feature.set_Value(checkFieldIndex, sfgx);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
#region (4)“是否举证”字段需系统进行控制,不允许县级进行编辑
|
|
|
|
|
//记录“是否举证”字段是否满足“类举类型”
|
|
|
|
|
//“是否举证”字段值是否为“否”,是则等于true
|
|
|
|
|
|
|
|
|
|
//2023.11.28 山西需求 不需要系统填写“是否举证”字段
|
|
|
|
|
if (!SysConfigsOprator.GetAppsetingValueByKey("ArearName").Equals("14"))
|
|
|
|
|
{
|
|
|
|
|
bool isValidation = false;
|
|
|
|
|
int sfjzIndex = feature.Fields.FindField("SFJZ");
|
|
|
|
|
if (sfjzIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
checkFieldIndex = feature.Fields.FindField("LJLX");
|
|
|
|
|
if (checkFieldIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
//①当“类举类型”为“承诺举证”“军事用地”“类举举证个”“实地无法到达”“图斑不够上图面积”“影像支持”时,“是否举证”直接填入“类举类型”字段;
|
|
|
|
|
object ljlx = feature.get_Value(checkFieldIndex);
|
|
|
|
|
List<string> checkValueList = new List<string>() { "承诺举证", "军事用地", "类举举证个", "实地无法到达", "图斑不够上图面积", "影像支持" };
|
|
|
|
|
if (!(ljlx is DBNull))
|
|
|
|
|
{
|
|
|
|
|
if (checkValueList.Contains(ljlx.ToString()))
|
|
|
|
|
{
|
|
|
|
|
feature.set_Value(sfjzIndex, "类举类型");
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"update dtbdltbgx set SFJZ='类举类型' where bsm='{bsm}'", CommandType.Text);
|
|
|
|
|
isValidation = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isValidation)
|
|
|
|
|
{
|
|
|
|
|
int index = feature.Fields.FindField("images");
|
|
|
|
|
if (index > -1)
|
|
|
|
|
{
|
|
|
|
|
object ljlx = feature.get_Value(index);
|
|
|
|
|
if (ljlx != null && !(ljlx is DBNull))
|
|
|
|
|
{
|
|
|
|
|
feature.set_Value(sfjzIndex, "实地举证");
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"update dtbdltbgx set SFJZ='实地举证' where bsm='{bsm}' and (select count(0) from FJGX WHERE TBBSM ='{bsm}')>0 ", CommandType.Text);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
feature.Store();
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("验证字段填写是否正确验证失败:" + ex);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 保存单图斑和独立图层数据
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存单图斑和独立图层数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="BSM"></param>
|
|
|
|
|
/// <param name="rdbHelper"></param>
|
|
|
|
|
/// <param name="feature"></param>
|
|
|
|
|
public virtual void SaveBGFWAndDLTC(string tbbsm, string BSM, IRDBHelper rdbHelper, IFeature feature)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ILayer layer = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("基础_地类图斑");
|
|
|
|
|
ILayer layerPodu = MapsManager.Instance.MapService.GetFeatureLayerByLayerName("基础_省级下发坡度图");
|
|
|
|
|
if (string.IsNullOrWhiteSpace(tbbsm) || string.IsNullOrWhiteSpace(BSM))
|
|
|
|
|
return;//图斑标识码和标识码不可为空
|
|
|
|
|
|
|
|
|
|
//判定DTBDLTBGX表中是否有XZGDFJ列 没有则添加
|
|
|
|
|
DataTable dataTableDTBDLTB = rdbHelper.ExecuteDatatable("DTBDLTBGX", "select * from DTBDLTBGX", true);
|
|
|
|
|
if (dataTableDTBDLTB != null)
|
|
|
|
|
{
|
|
|
|
|
if (!dataTableDTBDLTB.Columns.Contains("XZGDFJ"))
|
|
|
|
|
{
|
|
|
|
|
rdbHelper.ExecuteSQL(@"ALTER TABLE DTBDLTBGX ADD COLUMN XZGDFJ text(200);");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
string xzqdm = tbbsm.Substring(0, 6);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from DTBLSYDGX where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from DTBGFBQGX where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from DTBTTQGX where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from DTBCCWJQGX where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from DTBCZCDYDGX where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from DTBLMFWGX where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from PZWJ where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
//rdbHelper.ExecuteNonQueryWithException(string.Format("delete from fjgx where tbbsm='{0}'", BSM), CommandType.Text);
|
|
|
|
|
|
|
|
|
|
string excuteSQL = "UPDATE DTBDLTBGX SET {0} WHERE BSM='{1}'";
|
|
|
|
|
List<string> listField = new List<string>() { "TBBSM", "TBYBH", "DLBM", "KCDLBM", "QSXZ", "QSDWDM", "QSDWMC", "ZLDWDM", "ZLDWMC", "GDLX", "XZDWKD", "TBXHDM", "ZZSXDM", "TBXHMC", "GDDB", "CZCSXM", "SJNF", "FRDBS", "MSSM", "EGeometry", "DDTCBZ", "DDTCMC", "SFGX", "WBGYY1", "WBGYY", "SFJZ", "QKSM", "LJLX", "YWTBSM", "NBWQKSM", "SHLZQKSM", "LNGDZB", "SDMSSM", "YDYHFL", "ZGQKSM", "BZ", "SFXML", "XMMC", "XMLX", "XMBH", "DKMC", "CZCTBBH", "LC", "NF", "XZGDFJ", "GXSJ", "LJBZ", "JZYBH", "LJTBBH", "ZZZW", "SZLX", "LYZZZW", "LXJZGLBH", "GDPDJB" };
|
|
|
|
|
//独立图层代码
|
|
|
|
|
string ddtcbz = string.Empty;
|
|
|
|
|
string ddtcmc = string.Empty;
|
|
|
|
|
//城镇村属性码
|
|
|
|
|
string czcsxm = string.Empty;
|
|
|
|
|
//地类编码
|
|
|
|
|
string dlbm = string.Empty;
|
|
|
|
|
//权属性质
|
|
|
|
|
string qsxz = string.Empty;
|
|
|
|
|
//权属单位代码
|
|
|
|
|
string qsdwdm = string.Empty;
|
|
|
|
|
//权属单位名称
|
|
|
|
|
string qsdwmc = string.Empty;
|
|
|
|
|
//坐落单位代码
|
|
|
|
|
string zldwdm = string.Empty;
|
|
|
|
|
//坐落单位名称
|
|
|
|
|
string zldwmc = string.Empty;
|
|
|
|
|
//项目类型
|
|
|
|
|
string xmlx = string.Empty;
|
|
|
|
|
//种指属性代码
|
|
|
|
|
string zzsxdm = string.Empty;
|
|
|
|
|
//图斑细化代码
|
|
|
|
|
string tbxhdm = string.Empty;
|
|
|
|
|
//未变更原因描述
|
|
|
|
|
string wbgyyms = string.Empty;
|
|
|
|
|
//数据年份
|
|
|
|
|
string sjnf = string.Empty;
|
|
|
|
|
//求椭圆面积
|
|
|
|
|
double mj = Math.Round(feature.ShapeCopy.GetEllipseArea(), 2);
|
|
|
|
|
//变更后值
|
|
|
|
|
string bgHValue = $"jkry='{(MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo).UserName}',tbmj={mj},tbdlmj={mj},gxsj='{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}', jym = '{GetJym(feature)}', ";
|
|
|
|
|
//构建字段值
|
|
|
|
|
foreach (string item in listField)
|
|
|
|
|
{
|
|
|
|
|
int index = feature.Fields.FindField(item);
|
|
|
|
|
if (index <= -1)
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
object obj = feature.get_Value(index);
|
|
|
|
|
if (!(obj is DBNull) && !string.IsNullOrWhiteSpace(obj.ToString()))
|
|
|
|
|
{
|
|
|
|
|
if (item.Equals("ddtcbz", StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
ddtcbz = obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
if (item.Equals("ddtcmc", StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
ddtcmc = obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
if (item.Equals("CZCSXM", StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
czcsxm = obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (item.Equals("XMLX"))
|
|
|
|
|
{
|
|
|
|
|
xmlx = obj == null ? "" : obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
if (item.Equals("QSXZ"))
|
|
|
|
|
{
|
|
|
|
|
qsxz = obj == null ? "" : obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
if (item.Equals("DLBM"))
|
|
|
|
|
{
|
|
|
|
|
dlbm = obj == null ? "" : obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (item.Equals("ZZSXDM"))
|
|
|
|
|
{
|
|
|
|
|
zzsxdm = obj == null ? "" : obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (item.Equals("TBXHDM"))
|
|
|
|
|
tbxhdm = obj == null ? "" : obj.ToString();
|
|
|
|
|
else if (item.Equals("SJNF"))
|
|
|
|
|
sjnf = obj == null ? "" : obj.ToString();
|
|
|
|
|
IField field = feature.Fields.Field[index];
|
|
|
|
|
switch (field.Type)
|
|
|
|
|
{
|
|
|
|
|
case esriFieldType.esriFieldTypeSmallInteger:
|
|
|
|
|
case esriFieldType.esriFieldTypeInteger:
|
|
|
|
|
case esriFieldType.esriFieldTypeSingle:
|
|
|
|
|
case esriFieldType.esriFieldTypeDouble:
|
|
|
|
|
case esriFieldType.esriFieldTypeOID:
|
|
|
|
|
case esriFieldType.esriFieldTypeBlob:
|
|
|
|
|
if (obj == null || obj == DBNull.Value)
|
|
|
|
|
{
|
|
|
|
|
bgHValue += item + "=0,";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bgHValue += item + "=" + obj + ",";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (item.Equals("KCDLBM", StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
if (!dlbm.StartsWith("01"))
|
|
|
|
|
{
|
|
|
|
|
bgHValue += item + "='" + "" + "',";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bgHValue += item + "='" + obj + "',";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (item.Equals("WBGYY1", StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
//if (string.IsNullOrEmpty(obj.ToString()))
|
|
|
|
|
wbgyyms = obj.ToString();
|
|
|
|
|
}
|
|
|
|
|
else if (item.Equals("WBGYY", StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
if (obj.ToString() == "其他")
|
|
|
|
|
bgHValue += item + "='" + wbgyyms + "',";
|
|
|
|
|
else
|
|
|
|
|
bgHValue += item + "='" + obj + "',";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if (item.Equals("GDLX", StringComparison.CurrentCultureIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
bgHValue += item + "='" + obj + "',";
|
|
|
|
|
|
|
|
|
|
if (obj != null && (obj.ToString().Equals("TT") || obj.ToString().Equals("PD")))
|
|
|
|
|
{
|
|
|
|
|
string gdpdjb = GetPojb(feature, layerPodu);
|
|
|
|
|
double gdkcxs = DTBDBLoadHelper.GetTKXS(gdpdjb, obj.ToString());
|
|
|
|
|
double kcmj = gdkcxs * mj;
|
|
|
|
|
double tbdlmj = mj - kcmj;
|
|
|
|
|
bgHValue += $"gdpdjb = '{gdpdjb}',kcxs = {gdkcxs}, kcmj = {kcmj}, tbdlmj = {tbdlmj}, ";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
bgHValue += item + "='" + obj + "',";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
string sadff = string.Format(excuteSQL, bgHValue.TrimEnd(','), BSM);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(string.Format(excuteSQL, bgHValue.TrimEnd(','), BSM), CommandType.Text);
|
|
|
|
|
//地类名称
|
|
|
|
|
string dlmc = string.Empty;
|
|
|
|
|
DataDicTionary dataDicTionary = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.DLBM).FirstOrDefault(x => x.CODE.Equals(dlbm));
|
|
|
|
|
if (dataDicTionary != null)
|
|
|
|
|
{
|
|
|
|
|
dlmc = dataDicTionary.NAME;
|
|
|
|
|
}
|
|
|
|
|
//种植属性名称
|
|
|
|
|
string zzsxmc = string.Empty;
|
|
|
|
|
dataDicTionary = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.ZZSX).FirstOrDefault(x => x.CODE.Equals(zzsxdm));
|
|
|
|
|
if (dataDicTionary != null)
|
|
|
|
|
{
|
|
|
|
|
zzsxmc = dataDicTionary.NAME;
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"update dtbdltbgx set dlmc='{dlmc}',zzsxmc='{zzsxmc}',ddtcmc='{ddtcmc}' where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
|
|
|
|
|
//单独图层名称
|
|
|
|
|
dataDicTionary = Platform.Instance.DicHelper.GetAllDic().FirstOrDefault(x => x.CODE.Equals(ddtcbz));
|
|
|
|
|
if (dataDicTionary != null)
|
|
|
|
|
{
|
|
|
|
|
ddtcmc = dataDicTionary.NAME;
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"update dtbdltbgx set dlmc='{dlmc}',zzsxmc='{zzsxmc}',ddtcmc='{ddtcmc}' where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
|
|
|
|
|
//图斑细化名称
|
|
|
|
|
string tbxhmc = string.Empty;
|
|
|
|
|
dataDicTionary = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.TBXHLX).FirstOrDefault(x => x.CODE.Equals(tbxhdm));
|
|
|
|
|
if (dataDicTionary != null)
|
|
|
|
|
{
|
|
|
|
|
tbxhmc = dataDicTionary.NAME;
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"update dtbdltbgx set dlmc='{dlmc}',zzsxmc='{zzsxmc}',ddtcmc='{ddtcmc}',tbxhmc='{tbxhmc}',qsxz='{qsxz}' where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
|
|
|
|
|
//保存独立图层代码
|
|
|
|
|
switch (ddtcbz)
|
|
|
|
|
{
|
|
|
|
|
case "1301"://临时用地2099010100
|
|
|
|
|
DataTable dataTable = IRowToDataTable(feature as IRow);
|
|
|
|
|
if (dataTable != null && dataTable.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
DataRow dr = dataTable.Rows[0];
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"INSERT INTO DTBLSYDGX (BSM, DDTCBZ, DDTCMC, YSDM, GLTBBSM, PZWJMC, PZWH, TBMJ, PZMJ, YTFL, JTXMYT, PZRQ, YQSX, TDSYHT, BZ, GXSJ) VALUES('{BSM}', '{ddtcbz}', '{ddtcmc}', '2099010100', '{BSM}', '{dr["PZWJMC_LSYD"]}', '{dr["PZWH_LSYD"]}', {dr["TBMJ"]}, {dr["TBMJ"]}, '{dr["YTFL_LSYD"]}', '{dr["JTXMYT_LSYD"]}', '{dr["PZRQ_LSYD"]}', '{dr["YQSX_LSYD"]}', '{dr["TDSYHT_LSYD"]}', '{dr["BZ"]}', '{dr["GXSJ"]}')", CommandType.Text);
|
|
|
|
|
|
|
|
|
|
object obj = feature.get_Value(feature.Fields.FindField("PZWJ_LSYD"));
|
|
|
|
|
if (obj != null && !(obj is DBNull))
|
|
|
|
|
{
|
|
|
|
|
IMemoryBlobStreamVariant varBlobStream = (IMemoryBlobStreamVariant)obj;
|
|
|
|
|
object obj1 = null;
|
|
|
|
|
varBlobStream.ExportToVariant(out obj1);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"INSERT INTO PZWJ(BSM, Name, Path, Extension) VALUES('{BSM}', '{dr["PZWJMC_LSYD"]}', '', '')", CommandType.Text);
|
|
|
|
|
IDbDataParameter[] parameters = new IDbDataParameter[1];
|
|
|
|
|
parameters[0] = new System.Data.SQLite.SQLiteParameter("FileContent", DbType.Binary) { Value = obj1 };
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"update PZWJ SET FileContent=@FileContent where bsm='{BSM}'", CommandType.Text, parameters);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "1302"://光伏板区2099070100
|
|
|
|
|
dataTable = IRowToDataTable(feature as IRow);
|
|
|
|
|
if (dataTable != null && dataTable.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
DataRow dr = dataTable.Rows[0];
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"INSERT INTO DTBGFBQGX(BSM, DDTCBZ, DDTCMC, YSDM, XMMC, XMGM, QYMJ, PZYDSJ, BZ, GXSJ) VALUES('{BSM}', '{ddtcbz}', '{ddtcmc}', '2099070100', '{dr["XMMC_GFBQ"]}', '{dr["XMGM_GFBQ"]}', {dr["TBMJ"]}, '{dr["PZYDSJ_GFBQ"]}', '{dr["BZ"]}', '{dr["GXSJ"]}')", CommandType.Text);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case "1303"://推土区
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"INSERT INTO DTBTTQGX(BSM, DDTCBZ, DDTCMC, YSDM, TTQMJ, BZ, GXSJ) select bsm,ddtcbz,ddtcmc,'2099080100',tbmj,bz,gxsj from dtbdltbgx where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
break;
|
|
|
|
|
case "1304"://拆除未尽区2099090100
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"INSERT INTO DTBCCWJQGX (BSM, DDTCBZ, DDTCMC, YSDM, ZDMJ, BZ, GXSJ) select bsm,ddtcbz,ddtcmc,'2099090100',tbmj,bz,gxsj from dtbdltbgx where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
break;
|
|
|
|
|
case "1305"://路面范围2099100100
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"INSERT INTO DTBLMFWGX (BSM, DDTCBZ, DDTCMC, YSDM, ZLDWDM, KD, MJ, DLBM, MC, BZ, GXSJ) select bsm,ddtcbz,ddtcmc,'2099100100',zldwdm,xzdwkd,tbmj,dlbm,'',bz,gxsj from dtbdltbgx where bsm='{BSM}';", CommandType.Text);
|
|
|
|
|
break;
|
|
|
|
|
case "1306"://工厂化种植更新2099120100
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"INSERT INTO GCHZZGX (BSM,YSDM,ZDMJ,DLBM,DLMC,BZ,GXSJ) select bsm,'2099120100',tbmj,dlbm,'',bz,gxsj from dtbdltbgx where bsm='{BSM}';", CommandType.Text);
|
|
|
|
|
break;
|
|
|
|
|
case "一般地类":
|
|
|
|
|
if (xmlx == "1" || xmlx == "2")
|
|
|
|
|
{
|
|
|
|
|
DataTable dtXmlx2 = IRowToDataTable(feature as IRow);
|
|
|
|
|
if (dtXmlx2 != null && dtXmlx2.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
object obj = feature.get_Value(feature.Fields.FindField("XZGDFJ"));
|
|
|
|
|
if (obj != null && !(obj is DBNull))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
string[] files = obj.ToString().Split(';');
|
|
|
|
|
string strSql = string.Empty;
|
|
|
|
|
foreach (string file in files)
|
|
|
|
|
{
|
|
|
|
|
string strGuid = Guid.NewGuid().ToString();
|
|
|
|
|
var objBsm = rdbHelper.ExecuteScalar($"select bsm from wyhcfj where hcjlbsm = '{dtXmlx2.Rows[0]["TBBSM"].ToString()}' and fjmc = '{file.Substring(file.LastIndexOf("\\") + 1)}'", CommandType.Text);
|
|
|
|
|
|
|
|
|
|
using (System.IO.FileStream fs = new System.IO.FileStream(file, System.IO.FileMode.Open))
|
|
|
|
|
{
|
|
|
|
|
byte[] bytes = new byte[fs.Length];
|
|
|
|
|
fs.Read(bytes, 0, (int)fs.Length);
|
|
|
|
|
IDbDataParameter[] parameters = new IDbDataParameter[5];
|
|
|
|
|
if (objBsm == null)
|
|
|
|
|
{
|
|
|
|
|
strSql = "INSERT INTO WYHCFJ ( HCLX, HCJLBSM, DKID, FJMC, FJLX, MODE,IS_SELECTED, SEQUENCE, SUBTYPE, ARG, ARG4, CJSJ, LENGTH, POINTS_JSON, UserDelete ) VALUES ( 'WYRWTB', @HCJLBSM, @HCJLBSM, @FJMC, 'PDF', '4',1, '0', '1', @ARG, @ARG4, @CJSJ, '0', '[]', '0' )";
|
|
|
|
|
parameters[0] = new System.Data.SQLite.SQLiteParameter("HCJLBSM", DbType.String) { Value = dtXmlx2.Rows[0]["TBBSM"].ToString() };
|
|
|
|
|
parameters[1] = new System.Data.SQLite.SQLiteParameter("FJMC", DbType.String) { Value = file.Substring(file.LastIndexOf("\\") + 1) };
|
|
|
|
|
parameters[2] = new System.Data.SQLite.SQLiteParameter("ARG", DbType.String) { Value = strGuid };
|
|
|
|
|
parameters[3] = new System.Data.SQLite.SQLiteParameter("ARG4", DbType.Binary) { Value = bytes };
|
|
|
|
|
parameters[4] = new System.Data.SQLite.SQLiteParameter("CJSJ", DbType.DateTime) { Value = DateTime.Now };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql = "UPDATE WYHCFJ SET ARG = @ARG, ARG4 = @ARG4, CJSJ = @CJSJ WHERE HCJLBSM=@HCJLBSM AND FJMC = @FJMC";
|
|
|
|
|
parameters[0] = new System.Data.SQLite.SQLiteParameter("HCJLBSM", DbType.String) { Value = dtXmlx2.Rows[0]["TBBSM"].ToString() };
|
|
|
|
|
parameters[1] = new System.Data.SQLite.SQLiteParameter("FJMC", DbType.String) { Value = file.Substring(file.LastIndexOf("\\") + 1) };
|
|
|
|
|
parameters[2] = new System.Data.SQLite.SQLiteParameter("ARG", DbType.String) { Value = strGuid };
|
|
|
|
|
parameters[3] = new System.Data.SQLite.SQLiteParameter("ARG4", DbType.Binary) { Value = bytes };
|
|
|
|
|
parameters[4] = new System.Data.SQLite.SQLiteParameter("CJSJ", DbType.DateTime) { Value = DateTime.Now };
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(strSql, CommandType.Text, parameters);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"insert into fjgx (wytbbsm,fjarg,tbbsm) values ('{dtXmlx2.Rows[0]["TBBSM"].ToString()}','{strGuid}','{BSM}')", CommandType.Text);
|
|
|
|
|
fs.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
string czcmc = string.Empty;
|
|
|
|
|
//保存城镇村等用地
|
|
|
|
|
switch (czcsxm)
|
|
|
|
|
{
|
|
|
|
|
case "201":
|
|
|
|
|
case "201A":
|
|
|
|
|
case "202":
|
|
|
|
|
case "202A":
|
|
|
|
|
case "203":
|
|
|
|
|
case "203A":
|
|
|
|
|
case "204":
|
|
|
|
|
case "205":
|
|
|
|
|
dataDicTionary = Platform.Instance.DicHelper.GetNoGroupDic(DicTypeEnum.CZCJGKYD).FirstOrDefault(x => x.CODE.Equals(czcsxm));
|
|
|
|
|
if (dataDicTionary != null)
|
|
|
|
|
{
|
|
|
|
|
czcmc = dataDicTionary.NAME;
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"INSERT INTO DTBCZCDYDGX (BSM, DDTCBZ, DDTCMC, YSDM, CZCLX, CZCDM, CZCMC, CZCMJ, BZ, GXSJ) select bsm,ddtcbz,ddtcmc,'2099030100',czcsxm,'{xzqdm.PadRight(19, '0')}','{czcmc}',tbmj,bz,gxsj from dtbdltbgx where bsm='{BSM}'", CommandType.Text);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
////保存附件信息
|
|
|
|
|
//object images = feature.get_Value(feature.Fields.FindField("images"));
|
|
|
|
|
//if (images != null)
|
|
|
|
|
//{
|
|
|
|
|
// excuteSQL = "insert into fjgx(WYTBBSM,FJARG,tbbsm)values('{0}','{1}','{2}')";
|
|
|
|
|
// foreach (var item in images.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
|
|
|
|
|
// {
|
|
|
|
|
// rdbHelper.ExecuteNonQueryWithException(string.Format(excuteSQL, tbbsm, item, BSM), CommandType.Text);
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
//附件文件 保存
|
|
|
|
|
DataTable dtXmlx = IRowToDataTable(feature as IRow);
|
|
|
|
|
if (dtXmlx != null && dtXmlx.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
object obj = feature.get_Value(feature.Fields.FindField("XZGDFJ"));
|
|
|
|
|
if (obj != null && !(obj is DBNull) && !string.IsNullOrWhiteSpace(obj.ToString()))
|
|
|
|
|
{
|
|
|
|
|
string[] files = obj.ToString().Split(';');
|
|
|
|
|
string strSql = string.Empty;
|
|
|
|
|
foreach (string file in files)
|
|
|
|
|
{
|
|
|
|
|
string strGuid = Guid.NewGuid().ToString();
|
|
|
|
|
var objBsm = rdbHelper.ExecuteScalar($"select bsm from wyhcfj where hcjlbsm = '{dtXmlx.Rows[0]["TBBSM"].ToString()}' and fjmc = '{file.Substring(file.LastIndexOf("\\") + 1)}'", CommandType.Text);
|
|
|
|
|
|
|
|
|
|
using (System.IO.FileStream fs = new System.IO.FileStream(file, System.IO.FileMode.Open))
|
|
|
|
|
{
|
|
|
|
|
byte[] bytes = new byte[fs.Length];
|
|
|
|
|
fs.Read(bytes, 0, (int)fs.Length);
|
|
|
|
|
IDbDataParameter[] parameters = new IDbDataParameter[5];
|
|
|
|
|
if (objBsm == null)
|
|
|
|
|
{
|
|
|
|
|
strSql = "INSERT INTO WYHCFJ ( HCLX, HCJLBSM, DKID, FJMC, FJLX, MODE,IS_SELECTED, SEQUENCE, SUBTYPE, ARG, ARG4, CJSJ, LENGTH, POINTS_JSON, UserDelete ) VALUES ( 'WYRWTB', @HCJLBSM, @HCJLBSM, @FJMC, 'PDF', '4',1, '0', '1', @ARG, @ARG4, @CJSJ, '0', '[]', '0' )";
|
|
|
|
|
parameters[0] = new System.Data.SQLite.SQLiteParameter("HCJLBSM", DbType.String) { Value = dtXmlx.Rows[0]["TBBSM"].ToString() };
|
|
|
|
|
parameters[1] = new System.Data.SQLite.SQLiteParameter("FJMC", DbType.String) { Value = file.Substring(file.LastIndexOf("\\") + 1) };
|
|
|
|
|
parameters[2] = new System.Data.SQLite.SQLiteParameter("ARG", DbType.String) { Value = strGuid };
|
|
|
|
|
parameters[3] = new System.Data.SQLite.SQLiteParameter("ARG4", DbType.Binary) { Value = bytes };
|
|
|
|
|
parameters[4] = new System.Data.SQLite.SQLiteParameter("CJSJ", DbType.DateTime) { Value = DateTime.Now };
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql = "UPDATE WYHCFJ SET ARG = @ARG, ARG4 = @ARG4, CJSJ = @CJSJ WHERE HCJLBSM=@HCJLBSM AND FJMC = @FJMC";
|
|
|
|
|
parameters[0] = new System.Data.SQLite.SQLiteParameter("HCJLBSM", DbType.String) { Value = dtXmlx.Rows[0]["TBBSM"].ToString() };
|
|
|
|
|
parameters[1] = new System.Data.SQLite.SQLiteParameter("FJMC", DbType.String) { Value = file.Substring(file.LastIndexOf("\\") + 1) };
|
|
|
|
|
parameters[2] = new System.Data.SQLite.SQLiteParameter("ARG", DbType.String) { Value = strGuid };
|
|
|
|
|
parameters[3] = new System.Data.SQLite.SQLiteParameter("ARG4", DbType.Binary) { Value = bytes };
|
|
|
|
|
parameters[4] = new System.Data.SQLite.SQLiteParameter("CJSJ", DbType.DateTime) { Value = DateTime.Now };
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(strSql, CommandType.Text, parameters);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"insert into fjgx (wytbbsm,fjarg,tbbsm) values ('{dtXmlx.Rows[0]["TBBSM"].ToString()}','{strGuid}','{BSM}')", CommandType.Text);
|
|
|
|
|
fs.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//根据图斑面积面积,限制外业照片、视频数量
|
|
|
|
|
string strTbmj = string.Empty;
|
|
|
|
|
int tbmjIndex = feature.Fields.FindField("TBMJ");
|
|
|
|
|
if (tbmjIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
strTbmj = feature.get_Value(tbmjIndex).ToString();
|
|
|
|
|
DataTable dtFj = rdbHelper.ExecuteDatatable("wyhcfj", $"select sum(case when mode in ('5') then 1 else 0 end) as videocount,sum(case when mode not in ('4','5') then 1 else 0 end) as imagecount from wyhcfj a inner join fjgx b on a.hcjlbsm=b.wytbbsm and b.fjarg = a.arg and b.tbbsm ='{BSM}' where HCJLBSM='{tbbsm}' and (UserDelete <> 1 or UserDelete is not null)", true);
|
|
|
|
|
if (!string.IsNullOrEmpty(strTbmj) && dtFj != null && dtFj.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
int imageCount = 0, videoCount = 0;
|
|
|
|
|
if (dtFj.Rows[0]["imagecount"] != null && !string.IsNullOrEmpty(dtFj.Rows[0]["imagecount"].ToString()))
|
|
|
|
|
{
|
|
|
|
|
imageCount = int.Parse(dtFj.Rows[0]["imagecount"].ToString());
|
|
|
|
|
}
|
|
|
|
|
if (dtFj.Rows[0]["videocount"] != null && !string.IsNullOrEmpty(dtFj.Rows[0]["videocount"].ToString()))
|
|
|
|
|
{
|
|
|
|
|
videoCount = int.Parse(dtFj.Rows[0]["videocount"].ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
decimal tbmj = (Convert.ToDouble(strTbmj) / 666.67).ToDecimal(2);
|
|
|
|
|
if (tbmj <= 5)
|
|
|
|
|
{
|
|
|
|
|
if (imageCount > 15 || videoCount > 2)
|
|
|
|
|
{
|
|
|
|
|
//MessageHelper.Show("图斑面积小于5亩时,外业照片数量超过15张,或者外业视频数量超过2段");
|
|
|
|
|
LogAPI.Debug("图斑面积小于5亩时,外业照片数量超过15张,或者外业视频数量超过2段");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (5 < tbmj && tbmj <= 20)
|
|
|
|
|
{
|
|
|
|
|
if (imageCount > 30 || videoCount > 5)
|
|
|
|
|
{
|
|
|
|
|
//MessageHelper.Show("图斑面积大于5亩小于等于20亩时,外业照片数量超过30张,或者外业视频数量超过5段");
|
|
|
|
|
LogAPI.Debug("图斑面积大于5亩小于等于20亩时,外业照片数量超过30张,或者外业视频数量超过5段");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (tbmj > 20 && tbmj <= 50)
|
|
|
|
|
{
|
|
|
|
|
if (imageCount > 50 || videoCount > 7)
|
|
|
|
|
{
|
|
|
|
|
//MessageHelper.Show("图斑面积大于20亩时,外业照片数量超过50张,或者外业视频数量超过7段");
|
|
|
|
|
LogAPI.Debug("图斑面积大于20亩小于等于50亩时,外业照片数量超过50张,或者外业视频数量超过7段");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (tbmj > 50 && tbmj <= 100)
|
|
|
|
|
{
|
|
|
|
|
if (imageCount > 100 || videoCount > 7)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("图斑面积大于50亩小于等于100亩时,外业照片数量超过100张,或者外业视频数量超过7段");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (tbmj > 100)
|
|
|
|
|
{
|
|
|
|
|
if (imageCount > 120 || videoCount > 7)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("图斑面积大于100亩时,外业照片数量超过120张,或者外业视频数量超过7段");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug(ex.Message);
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取校验码
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取校验码
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="feature"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public string GetJym(IFeature feature)
|
|
|
|
|
{
|
|
|
|
|
string jymKey = "Images,MAXX,MAXY,MINX,MINY,ZXDX,ZXDY,Shape_Length,Shape_Area";
|
|
|
|
|
Dictionary<string, string> dicJym = new Dictionary<string, string>();
|
|
|
|
|
string addJym = string.Empty, jymJson = string.Empty;
|
|
|
|
|
addJym = KGIS.Framework.Utils.SysConfigsOprator.GetAppsetingValueByKey("JYM");
|
|
|
|
|
if (!string.IsNullOrEmpty(addJym))
|
|
|
|
|
{
|
|
|
|
|
jymKey = $"{addJym},{jymKey}";
|
|
|
|
|
}
|
|
|
|
|
foreach (string item in jymKey.Split(',').Distinct().ToArray())
|
|
|
|
|
{
|
|
|
|
|
int itemIndex = feature.Fields.FindField(item.Trim());
|
|
|
|
|
if (itemIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
object objValue = feature.get_Value(itemIndex);
|
|
|
|
|
if (objValue != null)
|
|
|
|
|
{
|
|
|
|
|
switch (item)
|
|
|
|
|
{
|
|
|
|
|
case "MAXX":
|
|
|
|
|
case "MAXY":
|
|
|
|
|
case "MINX":
|
|
|
|
|
case "MINY":
|
|
|
|
|
case "ZXDX":
|
|
|
|
|
case "ZXDY":
|
|
|
|
|
case "Shape_Length":
|
|
|
|
|
case "Shape_Area":
|
|
|
|
|
dicJym.Add(item, Math.Round(double.Parse(objValue.ToString()), 3).ToString());
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
dicJym.Add(item, objValue.ToString());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
jymJson = JsonConvert.SerializeObject(dicJym);
|
|
|
|
|
return EncryptionHelper.GetMd5Hash(jymJson);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region SyncDBData
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 防止编辑工具撤回,但是任务包 中已经保存进去了,删除这部分数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="featureClass"></param>
|
|
|
|
|
/// <param name="rdbHelper"></param>
|
|
|
|
|
/// <param name="tbbsm"></param>
|
|
|
|
|
public void SyncDBData(IFeatureClass featureClass, IRDBHelper rdbHelper, string tbbsm)
|
|
|
|
|
{
|
|
|
|
|
ICursor cursor = null;
|
|
|
|
|
IRow row = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
//如果拆分的时候两个要素bsm是一样的,判断有多个bsm的
|
|
|
|
|
IQueryFilter queryFilter = new QueryFilterClass()
|
|
|
|
|
{
|
|
|
|
|
WhereClause = $"tbbsm='{tbbsm}'"
|
|
|
|
|
};
|
|
|
|
|
cursor = (featureClass as ITable).Search(queryFilter, false);
|
|
|
|
|
string bsm = string.Empty;
|
|
|
|
|
while ((row = cursor.NextRow()) != null)
|
|
|
|
|
{
|
|
|
|
|
bsm += $"'{row.get_Value(featureClass.FindField("BSM"))}',";
|
|
|
|
|
}
|
|
|
|
|
if (string.IsNullOrWhiteSpace(bsm))
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
bsm = bsm.TrimEnd(',');
|
|
|
|
|
string excuteSQL = "delete from {0} where tbbsm='" + tbbsm + "' and bsm not in({1})";
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(string.Format(excuteSQL, "DTBDLTBGX", bsm), CommandType.Text);
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException($"delete from FJGX where wytbbsm='{tbbsm}' and TBBSM not in ({bsm})", CommandType.Text);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("同步db数据:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (row != null)
|
|
|
|
|
{
|
|
|
|
|
Marshal.ReleaseComObject(row);
|
|
|
|
|
}
|
|
|
|
|
if (cursor != null)
|
|
|
|
|
{
|
|
|
|
|
Marshal.ReleaseComObject(cursor);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region GetPojb
|
|
|
|
|
public string GetPojb(IFeature newFeature, ILayer layerPodu)
|
|
|
|
|
{
|
|
|
|
|
string poduMax = "";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Dictionary<ESRI.ArcGIS.Geometry.IGeometry, IFeature> data = DTBDBLoadHelper.IdentifyReturnIntersect(newFeature.ShapeCopy, layerPodu);
|
|
|
|
|
if (data != null && data.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
int poduindex = data.Values.FirstOrDefault().Fields.FindField("PDJB");
|
|
|
|
|
Dictionary<string, double> pdMj = new Dictionary<string, double>();
|
|
|
|
|
foreach (var item in data)
|
|
|
|
|
{
|
|
|
|
|
string pdjb = item.Value.get_Value(poduindex).ToString();
|
|
|
|
|
if (pdMj.ContainsKey(pdjb))
|
|
|
|
|
{
|
|
|
|
|
pdMj[pdjb] = pdMj[pdjb] + (item.Key as ESRI.ArcGIS.Geometry.IArea).Area;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pdMj.Add(pdjb, (item.Key as ESRI.ArcGIS.Geometry.IArea).Area);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
poduMax = pdMj.OrderByDescending(x => x.Value).FirstOrDefault().Key;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
return poduMax;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region IRowToDataTable
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 将IRow转换为DataTable
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="mTable"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static DataTable IRowToDataTable(IRow row)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
DataTable pTable = new DataTable();
|
|
|
|
|
for (int i = 0; i < row.Fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
pTable.Columns.Add(row.Fields.get_Field(i).Name);
|
|
|
|
|
}
|
|
|
|
|
DataRow pRow = pTable.NewRow();
|
|
|
|
|
string[] StrRow = new string[row.Fields.FieldCount];
|
|
|
|
|
for (int i = 0; i < row.Fields.FieldCount; i++)
|
|
|
|
|
{
|
|
|
|
|
StrRow[i] = row.get_Value(i).ToString();
|
|
|
|
|
}
|
|
|
|
|
pRow.ItemArray = StrRow;
|
|
|
|
|
pTable.Rows.Add(pRow);
|
|
|
|
|
return pTable;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
throw ex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 设置扣除系数
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 坡度图图层内查询耕地坡度级别
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="tbbsm">图斑标识码</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
private string GetGdpdjb(string tbbsm)
|
|
|
|
|
{
|
|
|
|
|
string gdpdjb = string.Empty;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
ProjectInfo projectInfo = MapsManager.Instance.MapService.GetProjectInfo() as ProjectInfo;
|
|
|
|
|
if (projectInfo != null && string.IsNullOrEmpty(projectInfo.PDTPath))
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("坡度图图层为空!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int wkid = -1;
|
|
|
|
|
if (projectInfo.GetCurentProjectedCoordinate() != null)
|
|
|
|
|
{
|
|
|
|
|
wkid = projectInfo.GetCurentProjectedCoordinate().FactoryCode;
|
|
|
|
|
if (wkid <= 0)
|
|
|
|
|
{
|
|
|
|
|
GaussCalculateLibrary.CoordinateReferenceMapping coordinateReferenceMapping = GaussCalculateLibrary.CoordinateHelper.ListCoordinateReference.FirstOrDefault(x => (projectInfo.ZYJD > x.MinX && projectInfo.ZYJD < x.MaxX) || x.Central_Meridian.Equals(projectInfo.ZYJD));
|
|
|
|
|
if (coordinateReferenceMapping != null)
|
|
|
|
|
{
|
|
|
|
|
wkid = coordinateReferenceMapping.WKID;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (CurrentWYRWTB == null || CurrentWYRWTBTreeNode.PackageNode == null || CurrentWYRWTBTreeNode.PackageNode.Data == null)
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("任务包信息获取失败");
|
|
|
|
|
}
|
|
|
|
|
string tempPath = System.IO.Path.Combine(projectInfo.TaskPath, "临时", (CurrentWYRWTBTreeNode.PackageNode.Data as TaskPackage).PackageName, "解压");
|
|
|
|
|
if (!System.IO.Directory.Exists(tempPath))
|
|
|
|
|
{
|
|
|
|
|
System.IO.Directory.CreateDirectory(tempPath);
|
|
|
|
|
}
|
|
|
|
|
//string gdbName = "db.GDB";
|
|
|
|
|
IFeatureLayer pFeatureLayer = null;
|
|
|
|
|
//如果存在图斑与坡度图相交后的shp文件,读取
|
|
|
|
|
if (File.Exists(System.IO.Path.Combine(tempPath, "IntersectPdt.shp")))
|
|
|
|
|
{
|
|
|
|
|
IWorkspaceFactory pWorkspaceFactory;
|
|
|
|
|
IFeatureWorkspace pFeatureWorkspace;
|
|
|
|
|
pWorkspaceFactory = new ShapefileWorkspaceFactory();
|
|
|
|
|
pFeatureWorkspace = (IFeatureWorkspace)pWorkspaceFactory.OpenFromFile(tempPath, 0);
|
|
|
|
|
IFeatureClass pFeatureClass = pFeatureWorkspace.OpenFeatureClass("IntersectPdt.shp");
|
|
|
|
|
pFeatureLayer = new FeatureLayer();
|
|
|
|
|
pFeatureLayer.FeatureClass = pFeatureClass;
|
|
|
|
|
pFeatureLayer.Name = pFeatureLayer.FeatureClass.AliasName;
|
|
|
|
|
}
|
|
|
|
|
else //如果不存在,模板与坡度图相交
|
|
|
|
|
{
|
|
|
|
|
string pdtPath = string.Empty;
|
|
|
|
|
if (projectInfo.PDTPath.IndexOf(".gdb") <= 0)
|
|
|
|
|
{
|
|
|
|
|
string[] dir = Directory.GetDirectories(projectInfo.PDTPath);
|
|
|
|
|
IEnumerable<string> filteredFilePath = dir.Where(x => x.EndsWith(".gdb") || x.EndsWith(".GDB"));
|
|
|
|
|
if (filteredFilePath.Any())
|
|
|
|
|
{
|
|
|
|
|
pdtPath = filteredFilePath.FirstOrDefault();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception("未找到gdb文件:" + projectInfo.PDTPath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pdtPath = projectInfo.PDTPath;
|
|
|
|
|
}
|
|
|
|
|
GPParamClass param = new GPParamClass()
|
|
|
|
|
{
|
|
|
|
|
FirstFeatureClassPath = System.IO.Path.Combine(pdtPath, "PDT"),
|
|
|
|
|
SecondFeatureClassPath = System.IO.Path.Combine(SysAppPath.GetCurrentAppPath() + "Project\\Scheme1.gdb", "DLTBBG"),
|
|
|
|
|
IsGetOutPutFeature = true,
|
|
|
|
|
OutFeatureClassPath = System.IO.Path.Combine(tempPath, "IntersectPdt"),
|
|
|
|
|
};
|
|
|
|
|
GeoprocessorHelper.IntersectAnalysis(param, ref pFeatureLayer);
|
|
|
|
|
}
|
|
|
|
|
//根据TBBSM查询坡度级别,如果压盖多个图斑,取面积最大的图斑对应的坡度级别
|
|
|
|
|
IQueryFilter queryFilter = new QueryFilterClass();
|
|
|
|
|
queryFilter.WhereClause = $"TBBSM='{tbbsm}'";
|
|
|
|
|
IFeatureCursor featureCursor = pFeatureLayer.Search(queryFilter, true);
|
|
|
|
|
IFeature feature = null;
|
|
|
|
|
double shapeArea = 0;
|
|
|
|
|
while ((feature = featureCursor.NextFeature()) != null)
|
|
|
|
|
{
|
|
|
|
|
int pdjbIndex = feature.Fields.FindField("PDJB");
|
|
|
|
|
int areaIndex = feature.Fields.FindField("Shape_Area");
|
|
|
|
|
if (areaIndex > -1 && pdjbIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
object pdjbValue = feature.get_Value(pdjbIndex);
|
|
|
|
|
object areaValue = feature.get_Value(areaIndex);
|
|
|
|
|
if (pdjbValue != null && !(pdjbValue is DBNull) && areaValue != null && !(areaValue is DBNull))
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug($"pdjbValue:{pdjbValue.ToString()},areaValue:{areaValue.ToString()}");
|
|
|
|
|
if (shapeArea < double.Parse(areaValue.ToString()))
|
|
|
|
|
{
|
|
|
|
|
shapeArea = double.Parse(areaValue.ToString());
|
|
|
|
|
gdpdjb = pdjbValue.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Marshal.ReleaseComObject(featureCursor);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("耕地坡度级别获取失败:" + ex.Message);
|
|
|
|
|
}
|
|
|
|
|
return gdpdjb;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 设置扣除系数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="Newfeature"></param>
|
|
|
|
|
/// <param name="rdbHelper"></param>
|
|
|
|
|
/// <param name="tbbsm"></param>
|
|
|
|
|
public void UpdateKCXS(IFeature Newfeature, IRDBHelper rdbHelper, string tbbsm)
|
|
|
|
|
{
|
|
|
|
|
string bsm = string.Empty;
|
|
|
|
|
int bsmIndex = Newfeature.Fields.FindField("BSM");//地类编码
|
|
|
|
|
if (bsmIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
bsm = Newfeature.get_Value(bsmIndex).ToString();
|
|
|
|
|
}
|
|
|
|
|
string dlbm = string.Empty;
|
|
|
|
|
int dlbmIndex = Newfeature.Fields.FindField("DLBM");//地类编码
|
|
|
|
|
if (dlbmIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
dlbm = Newfeature.get_Value(dlbmIndex).ToString();
|
|
|
|
|
}
|
|
|
|
|
string gdlx = string.Empty;
|
|
|
|
|
int gdlxIndex = Newfeature.Fields.FindField("GDLX");//耕地类型
|
|
|
|
|
if (gdlxIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
gdlx = Newfeature.get_Value(gdlxIndex).ToString();
|
|
|
|
|
}
|
|
|
|
|
string gdpdjb = string.Empty;
|
|
|
|
|
int gdpojbIndex = Newfeature.Fields.FindField("GDPDJB");//耕地坡度级别
|
|
|
|
|
if (gdpojbIndex > -1)
|
|
|
|
|
{
|
|
|
|
|
gdpdjb = Newfeature.get_Value(gdpojbIndex).ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(bsm) && !string.IsNullOrEmpty(dlbm) && !string.IsNullOrEmpty(gdlx))
|
|
|
|
|
{
|
|
|
|
|
DataTable dt = rdbHelper.ExecuteDatatable("dtbdltbgxgc", $"select bsm,bgqdlbm,bgqgdlx,bgqkcxs from dtbdltbgxgc where tbbsm='{tbbsm}' and bghtbbsm = '{bsm}'", true);
|
|
|
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
double kcxs = 0;
|
|
|
|
|
string strSql = string.Empty;
|
|
|
|
|
if (string.IsNullOrEmpty(gdpdjb))
|
|
|
|
|
{
|
|
|
|
|
gdpdjb = GetGdpdjb(tbbsm);
|
|
|
|
|
if (string.IsNullOrEmpty(gdpdjb))
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug($"TBBSM({tbbsm})耕地坡度级别为空");
|
|
|
|
|
return;
|
|
|
|
|
//throw new Exception($"TBBSM({tbbsm})耕地坡度级别为空");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (gdpdjb != "1")
|
|
|
|
|
{
|
|
|
|
|
kcxs = DTBDBLoadHelper.GetTKXS(gdpdjb, gdlx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//变更前为非耕地,变更后为耕地,新增耕地的扣除系数需根据坡度图,耕地级别等自动赋值扣除系数
|
|
|
|
|
if (!dt.Rows[0]["bgqdlbm"].ToString().StartsWith("01") && dlbm.StartsWith("01"))
|
|
|
|
|
{
|
|
|
|
|
strSql = $"update dtbdltbgx set kcdlbm = '1203',gdpdjb = '{gdpdjb}',kcxs = {kcxs},kcmj = kcxs * tbmj,tbdlmj = tbmj - kcmj where tbbsm ='{tbbsm}' and bsm = '{bsm}';";
|
|
|
|
|
}
|
|
|
|
|
//基础数据为0101TT/0102PD/0103PD,变更后还是为0101TT/0102PD/0103PD,只是图形范围变大或减小或者种植属性变化,扣除系数继承基础库的扣除系数
|
|
|
|
|
else if (dt.Rows[0]["bgqdlbm"].ToString() == dlbm && dt.Rows[0]["bgqgdlx"].ToString() == gdlx && !string.IsNullOrEmpty(dt.Rows[0]["bgqkcxs"].ToString()))
|
|
|
|
|
{
|
|
|
|
|
strSql = $"update dtbdltbgx set kcdlbm = '1203',gdpdjb = '{gdpdjb}',kcxs = {int.Parse(dt.Rows[0]["bgqkcxs"].ToString())},kcmj = kcxs * tbmj,tbdlmj = tbmj - kcmj where tbbsm ='{tbbsm}' and bsm = '{bsm}';";
|
|
|
|
|
}
|
|
|
|
|
//原来为0101TT,变更为0103PD,扣除系数需根据坡度图,耕地坡度级别等自动赋值扣除系数
|
|
|
|
|
else if (dt.Rows[0]["bgqdlbm"].ToString() == "0101" && dt.Rows[0]["bgqgdlx"].ToString() == "TT" && dlbm == "0103" && gdlx == "PD")
|
|
|
|
|
{
|
|
|
|
|
strSql = $"update dtbdltbgx set kcdlbm = '1203',gdpdjb = '{gdpdjb}',kcxs = {kcxs},kcmj = kcxs * tbmj,tbdlmj = tbmj - kcmj where tbbsm ='{tbbsm}' and bsm = '{bsm}';";
|
|
|
|
|
}
|
|
|
|
|
//原来为0103PD,变更为0101TT,扣除系数需根据坡度图,耕地坡度级别等自动赋值扣除系数
|
|
|
|
|
else if (dt.Rows[0]["bgqdlbm"].ToString() == "0103" && dt.Rows[0]["bgqgdlx"].ToString() == "PD" && dlbm == "0101" && gdlx == "TT")
|
|
|
|
|
{
|
|
|
|
|
strSql = $"update dtbdltb set kcdlbm = '1203',gdpdjb = '{gdpdjb}',kcxs = {kcxs},kcmj = kcxs * tbmj,tbdlmj = tbmj - kcmj where tbbsm ='{tbbsm}' and bsm = '{bsm}';";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug($"未检索到满足 TBBSM:{tbbsm} 的扣除系数筛选条件。");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
strSql += $"update dtbdltbgx set kcmj = kcxs * tbmj where tbbsm ='{tbbsm}' and bsm = '{bsm}';update dtbdltbgx set tbdlmj = tbmj - kcmj where tbbsm ='{tbbsm}' and bsm = '{bsm}';";
|
|
|
|
|
LogAPI.Debug($"UpdateKCXS Info SQL:{strSql}");
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(strSql, CommandType.Text);
|
|
|
|
|
|
|
|
|
|
if (gdpdjb == "1")
|
|
|
|
|
{
|
|
|
|
|
strSql = $"update dtbdltbgxgc set bghkcdlbm = '',bghgdpdjb = '{gdpdjb}',bghkcxs = 0 where tbbsm ='{tbbsm}' and bghtbbsm = '{bsm}';update dtbdltbgxgc set bghkcmj = bghkcxs * tbbgmj where tbbsm ='{tbbsm}' and bghtbbsm = '{bsm}';update dtbdltbgxgc set bghtbdlmj = tbbgmj - bghkcmj where tbbsm ='{tbbsm}' and bghtbbsm = '{bsm}'";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strSql = $"update dtbdltbgxgc set bghkcdlbm = '1203',bghgdpdjb = '{gdpdjb}',bghkcxs = {kcxs} where tbbsm ='{tbbsm}' and bghtbbsm = '{bsm}';update dtbdltbgxgc set bghkcmj = bghkcxs * tbbgmj where tbbsm ='{tbbsm}' and bghtbbsm = '{bsm}';update dtbdltbgxgc set bghtbdlmj = tbbgmj - bghkcmj where tbbsm ='{tbbsm}' and bghtbbsm = '{bsm}'";
|
|
|
|
|
}
|
|
|
|
|
rdbHelper.ExecuteNonQueryWithException(strSql, CommandType.Text);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
throw new Exception($"未检索到TBBSM:{tbbsm} 的 DTBDLTBGXGC 层数据");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ee)
|
|
|
|
|
{
|
|
|
|
|
LogAPI.Debug("扣除系数设置失败:" + ee.ToString());
|
|
|
|
|
throw new Exception("扣除系数设置失败:" + ee.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|