guoshuang 2 년 전
부모
커밋
6956ca6d30
70개의 변경된 파일과 6453개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      .gitignore
  2. 25 0
      HH.YiDaSyncNC.sln
  3. 54 0
      HH.YiDaSyncNC/App.config
  4. 240 0
      HH.YiDaSyncNC/DataSync/CGDD_SyncService.cs
  5. 172 0
      HH.YiDaSyncNC/DataSync/FK_SyncService.cs
  6. 216 0
      HH.YiDaSyncNC/DataSync/GYS_SyncService.cs
  7. 172 0
      HH.YiDaSyncNC/DataSync/KH_SyncService.cs
  8. 562 0
      HH.YiDaSyncNC/DataSync/KP_SyncService.cs
  9. 213 0
      HH.YiDaSyncNC/DataSync/WL_SyncService.cs
  10. 163 0
      HH.YiDaSyncNC/DataSync/XMD_SyncService.cs
  11. 160 0
      HH.YiDaSyncNC/DataSync/ZC_SyncService.cs
  12. 20 0
      HH.YiDaSyncNC/Dtos/NC/EnumType.cs
  13. 27 0
      HH.YiDaSyncNC/Dtos/NC/bd_branddoc.cs
  14. 27 0
      HH.YiDaSyncNC/Dtos/NC/bd_custclass.cs
  15. 28 0
      HH.YiDaSyncNC/Dtos/NC/bd_customer.cs
  16. 29 0
      HH.YiDaSyncNC/Dtos/NC/bd_defdoc.cs
  17. 28 0
      HH.YiDaSyncNC/Dtos/NC/bd_income.cs
  18. 27 0
      HH.YiDaSyncNC/Dtos/NC/bd_marbasclass.cs
  19. 27 0
      HH.YiDaSyncNC/Dtos/NC/bd_material.cs
  20. 27 0
      HH.YiDaSyncNC/Dtos/NC/bd_mattaxes.cs
  21. 29 0
      HH.YiDaSyncNC/Dtos/NC/bd_measdoc.cs
  22. 207 0
      HH.YiDaSyncNC/Dtos/NC/bd_project.cs
  23. 28 0
      HH.YiDaSyncNC/Dtos/NC/bd_projectclass.cs
  24. 30 0
      HH.YiDaSyncNC/Dtos/NC/bd_psndoc.cs
  25. 28 0
      HH.YiDaSyncNC/Dtos/NC/bd_stordoc.cs
  26. 29 0
      HH.YiDaSyncNC/Dtos/NC/bd_supplier.cs
  27. 27 0
      HH.YiDaSyncNC/Dtos/NC/bd_supplierclass.cs
  28. 104 0
      HH.YiDaSyncNC/Dtos/NC/fa_card.cs
  29. 30 0
      HH.YiDaSyncNC/Dtos/NC/org_dept.cs
  30. 28 0
      HH.YiDaSyncNC/Dtos/NC/org_orgs.cs
  31. 28 0
      HH.YiDaSyncNC/Dtos/NC/pam_addreducestyle.cs
  32. 29 0
      HH.YiDaSyncNC/Dtos/NC/po_order.cs
  33. 35 0
      HH.YiDaSyncNC/Dtos/NC/po_order_b.cs
  34. 131 0
      HH.YiDaSyncNC/Dtos/NC/po_order_bb.cs
  35. 30 0
      HH.YiDaSyncNC/Dtos/NC/sm_user.cs
  36. 25 0
      HH.YiDaSyncNC/Dtos/NC/so_saleinvoice.cs
  37. 48 0
      HH.YiDaSyncNC/Dtos/NC/so_saleinvoice_b.cs
  38. 117 0
      HH.YiDaSyncNC/Dtos/NC/so_saleorder.cs
  39. 210 0
      HH.YiDaSyncNC/Dtos/NC/so_saleorder_b.cs
  40. 22 0
      HH.YiDaSyncNC/Dtos/NC/so_saleorder_exe.cs
  41. 29 0
      HH.YiDaSyncNC/Dtos/NC/so_squareinv_d.cs
  42. 39 0
      HH.YiDaSyncNC/Dtos/NC/xx_idcontrast.cs
  43. 36 0
      HH.YiDaSyncNC/Dtos/SyncRecord_CGDD.cs
  44. 36 0
      HH.YiDaSyncNC/Dtos/SyncRecord_GYS.cs
  45. 36 0
      HH.YiDaSyncNC/Dtos/SyncRecord_KH.cs
  46. 36 0
      HH.YiDaSyncNC/Dtos/SyncRecord_WL.cs
  47. 36 0
      HH.YiDaSyncNC/Dtos/SyncRecord_XMD.cs
  48. 16 0
      HH.YiDaSyncNC/Dtos/YiDaResDto.cs
  49. 207 0
      HH.YiDaSyncNC/HH.YiDaSyncNC.csproj
  50. 22 0
      HH.YiDaSyncNC/Helper/AbPrivoder.cs
  51. 101 0
      HH.YiDaSyncNC/Helper/CommHelper.cs
  52. 106 0
      HH.YiDaSyncNC/Helper/DBHelper.cs
  53. 273 0
      HH.YiDaSyncNC/Helper/DingTalkService.cs
  54. 30 0
      HH.YiDaSyncNC/Helper/DocDicHelper.cs
  55. 42 0
      HH.YiDaSyncNC/Helper/LogHelper.cs
  56. 42 0
      HH.YiDaSyncNC/Helper/NCImportFunc.cs
  57. 30 0
      HH.YiDaSyncNC/Helper/UnixTimeHelper.cs
  58. 244 0
      HH.YiDaSyncNC/Models/CGDD_SyncServiceModel.cs
  59. 106 0
      HH.YiDaSyncNC/Models/FK_SyncServiceModel.cs
  60. 102 0
      HH.YiDaSyncNC/Models/GYS_SyncServiceModel.cs
  61. 106 0
      HH.YiDaSyncNC/Models/KH_SyncServiceModel.cs
  62. 728 0
      HH.YiDaSyncNC/Models/KP_SyncServiceModel.cs
  63. 98 0
      HH.YiDaSyncNC/Models/WL_SyncServiceModel.cs
  64. 86 0
      HH.YiDaSyncNC/Models/XMD_SyncServiceModel.cs
  65. 278 0
      HH.YiDaSyncNC/Models/XSFP_SyncServiceModel.cs
  66. 89 0
      HH.YiDaSyncNC/Program.cs
  67. 36 0
      HH.YiDaSyncNC/Properties/AssemblyInfo.cs
  68. BIN
      HH.YiDaSyncNC/lib/RestSharp.dll
  69. BIN
      HH.YiDaSyncNC/lib/TopSdk.dll
  70. 28 0
      HH.YiDaSyncNC/packages.config

+ 3 - 0
.gitignore

@@ -3,3 +3,6 @@
 ################################################################################
 
 /.vs
+/HH.YiDaSyncNC/bin/Debug
+/HH.YiDaSyncNC/obj
+/packages

+ 25 - 0
HH.YiDaSyncNC.sln

@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.34114.132
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HH.YiDaSyncNC", "HH.YiDaSyncNC\HH.YiDaSyncNC.csproj", "{0C9830B2-D208-41CC-966B-E3509B3B3FC6}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+		Release|Any CPU = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{0C9830B2-D208-41CC-966B-E3509B3B3FC6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{0C9830B2-D208-41CC-966B-E3509B3B3FC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{0C9830B2-D208-41CC-966B-E3509B3B3FC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{0C9830B2-D208-41CC-966B-E3509B3B3FC6}.Release|Any CPU.Build.0 = Release|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {95463AC3-A790-4CF9-AEB6-B31B3DB06F3B}
+	EndGlobalSection
+EndGlobal

+ 54 - 0
HH.YiDaSyncNC/App.config

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<configuration>
+  <startup>
+    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
+  </startup>
+  <appSettings>
+    <add key="CorpId" value="dingef2eb0ecba261b8935c2f4657eb6378f" />
+    <add key="AgentId" value="2871877887" />
+    <add key="AppKey" value="dingfwn4kpmb4g3dy4fj" />
+    <add key="AppSecret" value="OwdkUc9nvBivpwsg0AiaEcyWLtZ678fskqBJwP7B5CQNrycIoyKuWslFTCOOaZG4" />
+    <add key="Conn" value="server=60.204.209.15;uid=test;pwd=aaa111...;database=YiDaSyncNC_Test" />
+    <add key="Conn_NC" value="server=58.246.128.122,2433;uid=sa;pwd=!lanyunnc@2023#;database=lanyun" />
+    <add key="NCApiUrl" value="http://58.246.128.122:9090/service/XChangeServlet"/>
+    <!--宜搭配置-->
+    <add key="AppType" value="APP_ERBDTFS82HOVBPL3NFH0" />
+    <add key="SystemToken" value="RRB66F91T97H1WN89QZYC47PKLZO2ZQOUMOQLP" />
+    <add key="UserId" value="153218553429137210" />
+    <!--物料档案-->
+    <add key="FormId_WL" value="FORM-C106F33B9A73410FBE750E8FFB72C2775YCF" />
+    <!--供应商档案-->
+    <add key="FormId_GYS" value="FORM-87B1C91392824C5AA9330F574C157622855R" />
+    <add key="FormId_XMD" value="FORM-97BA6C6C8C50416A9E5854F2F4B5C3F3R4WC" />
+    <add key="FormId_KH" value="FORM-E95BF43276BC4BD78B269729F716AA63LDR2" />
+    <add key="FormId_ZC" value="FORM-F3695066AABE41F6AF241489F8558ACA78OI" />
+
+    <add key="FormId_KP" value="FORM-6603375ED27B4D059CBB919C2BEFA44BZVOL" />
+    <add key="FormId_CGDD" value="FORM-61F329A9DFFE4CF0BBEC0FDC34C42C03QJKQ" />
+    <add key="FormId_FK" value="FORM-B8C2006FAA1645B4BC2A6E71F8CC35BFQ71Y" />
+
+    <!--NC写库主键配置-->
+    <add key="xx_idcontrast" value="DINGTALKIDC" />
+    <add key="bd_project" value="DINGTALKPRO" />
+    <add key="fa_card" value="DINGTALKFAC" />
+    <add key="so_saleorder" value="DINGTALKSAL" />
+    <add key="so_saleorder_b" value="DINGTALKSAB" />
+    <add key="po_order_bb" value="DINGTALKPBB" />
+
+    <!--NC关键字段信息-->
+    <!--集团组织主键-->
+    <add key="pk_org_jt" value="0001G11000000000066P" />
+  </appSettings>
+  <runtime>
+    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
+      <dependentAssembly>
+        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
+      </dependentAssembly>
+      <dependentAssembly>
+        <assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
+        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
+      </dependentAssembly>
+    </assemblyBinding>
+  </runtime>
+</configuration>

+ 240 - 0
HH.YiDaSyncNC/DataSync/CGDD_SyncService.cs

@@ -0,0 +1,240 @@
+using HH.YiDaSyncNC.Dtos;
+using HH.YiDaSyncNC.Dtos.NC;
+using HH.YiDaSyncNC.Helper;
+using HH.YiDaSyncNC.Models;
+using Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.DataSync
+{
+    class CGDD_SyncService
+    {
+        public string _AppType;
+        public string _SystemToken;
+        public string _UserId;
+        public string _FormId;
+        public SqlSugarClient _db;
+        public SqlSugarClient _db_nc;
+        public string _NCApiUrl;
+
+        public static string _Static_PK_po_order_bb = ConfigurationManager.AppSettings["po_order_bb"];
+
+        public CGDD_SyncService(string AppType, string SystemToken, string UserId, string FormId, SqlSugarClient db, SqlSugarClient db_nc, string NCApiUrl)
+        {
+            _AppType = AppType;
+            _SystemToken = SystemToken;
+            _UserId = UserId;
+            _FormId = FormId;
+            _db = db;
+            _db_nc = db_nc;
+            _NCApiUrl = NCApiUrl;
+        }
+
+        public class IdCodeModel
+        {
+            public int sourceId { get; set; }
+            public string Id { get; set; }
+        }
+
+        public void DataSync()
+        {
+            DingTalkService _dingTalkService = new DingTalkService(_AppType, _SystemToken, _UserId, _FormId);
+
+            // 宜搭全量数据Id
+            var idList = _dingTalkService.GetFormIdList().Where(w => w == "FINST-5V766V61W0KMVK80DUP2Z7UVHIX73V6XN9CYLQKP1").ToList();
+
+            LogHelper.WriteLog(JsonConvert.SerializeObject(idList.Count), "idList");
+
+            // 获取当前最大Id
+            var newId = 100000001;
+            var maxData = _db_nc.Queryable<po_order_bb>().Where(w => w.pk_order_bb.Contains(_Static_PK_po_order_bb)).OrderByDescending(obd => obd.pk_order_bb).First();
+            if (maxData != null && maxData.pk_order_bb.Contains(_Static_PK_po_order_bb))
+            {
+                newId = Convert.ToInt32(maxData.pk_order_bb.Replace(_Static_PK_po_order_bb, "")) + 1;
+            }
+
+            #region 获取NC中选项数据的Id
+            var bd_customerDic = _db_nc.Queryable<bd_customer>().ToList();
+            var bd_incomeDic = _db_nc.Queryable<bd_income>().ToList();
+            var org_orgsDic = _db_nc.Queryable<org_orgs>().ToList();
+            var bd_projectDic = _db_nc.Queryable<bd_project>().ToList();
+            var bd_materialDic = _db_nc.Queryable<bd_material>().ToList();
+            var bd_measdocDic = _db_nc.Queryable<bd_measdoc>().ToList();
+            var org_deptDic = _db_nc.Queryable<org_dept>().ToList();
+            var bd_psndocDic = _db_nc.Queryable<bd_psndoc>().ToList();
+            var sm_userDic = _db_nc.Queryable<sm_user>().ToList();
+            #endregion
+
+            #region 插入数据
+            // 向NC插入数据
+            foreach (var item in idList)
+            {
+                string createTime = "";
+                string modifyTime = "";
+
+                var ydDataSource = _dingTalkService.GetFormDataById(item, out createTime, out modifyTime);
+
+                var dataSource = new CGDD_SyncServiceModel.DataModel();
+                dataSource.集团 = "0";
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "selectField_lr26l3h7").Value != null)
+                {
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lr26l3h7"].ToString()))
+                    {
+                        var tempData = org_orgsDic.FirstOrDefault(f => f.name == ydDataSource["selectField_lr26l3h7"].ToString());
+                        if (tempData != null)
+                        {
+                            dataSource.组织 = tempData.code; // 组织
+                        }
+                    }
+                }
+
+                dataSource.订单编号 = ydDataSource["textField_lr26y1io"].ToString();
+                dataSource.订单日期 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                dataSource.供应商 = ydDataSource["textField_lr26l3hf"].ToString();
+
+                dataSource.制单人 = "OA-NC";
+                dataSource.创建人 = "OA-NC";
+
+                dataSource.制单时间 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                dataSource.创建时间 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+
+                var detailList = new List<CGDD_SyncServiceModel.DataModel.OrderB>();
+
+                var detailObjList = (List<object>)ydDataSource["tableField_ltxyt76f"]; // 采购物耗明细
+                foreach (var objItem in detailObjList)
+                {
+                    var detailItem = new CGDD_SyncServiceModel.DataModel.OrderB();
+
+                    detailItem.物料编码 = ((Dictionary<string, object>)objItem)["textField_ltxyt75w"].ToString(); // 物料编码
+                    detailItem.物料名称 = ((Dictionary<string, object>)objItem)["textField_ltxyt75x"].ToString(); // 物料编码
+
+                    if (!string.IsNullOrWhiteSpace(((Dictionary<string, object>)objItem)["textField_ltxyt75y"].ToString()))
+                    {
+                        detailItem.计量单位 = bd_measdocDic.FirstOrDefault(f => f.name == ((Dictionary<string, object>)objItem)["textField_ltxyt75y"].ToString()).code; // 计量单位
+                    }
+
+                    detailItem.项目 = ((Dictionary<string, object>)objItem)["textField_lu23oe2w"].ToString(); // 项目编码
+
+                    detailItem.数量 = ((Dictionary<string, object>)objItem)["numberField_ltxyt75z"].ToString(); // 主数量
+
+                    detailItem.无税单价 = ((Dictionary<string, object>)objItem)["numberField_lutkmlw0"].ToString(); // 本币无税单价
+
+                    detailItem.含税单价 = ((Dictionary<string, object>)objItem)["numberField_ltxyt761"].ToString(); // 含税单价
+
+                    detailItem.无税金额 = ((Dictionary<string, object>)objItem)["numberField_lutkmlvz"].ToString(); // 无税金额
+
+                    detailItem.税额 = ((Dictionary<string, object>)objItem)["numberField_lutkmlw3"].ToString(); // 税额
+
+                    detailItem.价税合计 = ((Dictionary<string, object>)objItem)["numberField_ltxyt764"].ToString(); // 本币价税合计
+
+                    detailItem.联系人 = ((Dictionary<string, object>)objItem)["textField_lutkmlwb"].ToString(); // 
+
+                    detailItem.收货地址 = ((Dictionary<string, object>)objItem)["textField_ltxyt76a"].ToString(); // 
+
+                    detailList.Add(detailItem);
+                }
+
+                dataSource.pk_order_b = detailList;
+
+
+                dataSource.数量 = dataSource.pk_order_b.Sum(s => Convert.ToDecimal(s.数量)).ToString();
+                dataSource.价税合计 = dataSource.pk_order_b.Sum(s => Convert.ToDecimal(s.价税合计)).ToString();
+
+
+
+                var results = NCImportFunc.NCImport(CGDD_SyncServiceModel.ImportXml.TemplateHeade(), CGDD_SyncServiceModel.ImportXml.Header(dataSource, item), _NCApiUrl + "?account=LY01&groupcode=0");
+
+                DBHelper.WriteLog(results);
+                XElement xE = XElement.Parse(results);
+
+                string resultcode = xE.Element("sendresult").Element("resultcode").Value;
+
+                DBHelper.WriteLog($"状态码:" + resultcode);
+
+                string content = xE.Element("sendresult").Element("content")?.Value;
+
+                string resultdescription = xE.Element("sendresult").Element("resultdescription")?.Value;
+
+                var ncResData = new YiDaResDto()
+                {
+                    syncTime = DateTime.Now,
+                };
+
+                // NC接口执行完成后的处理
+                if (resultcode == "1")
+                {
+                    DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作成功!");
+
+                    ncResData.bSuccess = true;
+                    ncResData.ncNo = xE.Element("sendresult").Element("content").Value;
+                    ncResData.log = "同步成功!";
+
+                    // 更新审核状态,并插入在途状态表
+                    var po_order = _db_nc.Queryable<po_order>().First(f => f.pk_order == xE.Element("sendresult").Element("content").Value);
+                    var po_order_b = _db_nc.Queryable<po_order_b>().Where(w => w.pk_order == xE.Element("sendresult").Element("content").Value).ToList();
+
+                    po_order.approver = "1001G1100000000B6553";
+                    po_order.forderstatus = "3";
+                    po_order.taudittime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+
+                    _db_nc.Updateable(po_order).ExecuteCommand();
+
+                    foreach (var itemB in po_order_b)
+                    {
+                        var bb = new po_order_bb();
+                        bb.dplanarrvdate = itemB.dplanarrvdate;
+                        bb.nmaxhandlenum = itemB.nastnum;
+                        bb.nonwaynum = itemB.nastnum;
+
+                        bb.pk_group = itemB.pk_group;
+                        bb.pk_order = itemB.pk_order;
+                        bb.pk_order_b = itemB.pk_order_b;
+                        bb.pk_org = itemB.pk_org;
+                        bb.pk_org_v = itemB.pk_org_v;
+                        bb.ts = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+
+                        bb.pk_order_bb = _Static_PK_po_order_bb + newId;
+
+                        _db_nc.Insertable(bb).ExecuteCommand();
+
+                        newId++;
+                    }
+                }
+                else
+                {
+
+                    DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作失败!" + resultdescription + ";");
+
+                    ncResData.bSuccess = false;
+                    ncResData.ncNo = "";
+                    ncResData.log = "同步失败!原因为【" + resultdescription + "】";
+                }
+
+                var ydRes = _dingTalkService.UpdateFormDataSyncDataById(ncResData, item);
+
+                //var ncResData = new YiDaResDto()
+                //{
+                //    syncTime = DateTime.Now,
+                //};
+
+                //ncResData.bSuccess = true;
+                //ncResData.ncNo = "1001G1100000000DETFP";
+                //ncResData.log = "同步成功!";
+
+                //var ydRes = _dingTalkService.UpdateFormDataSyncDataById(ncResData, "FINST-KTA66ID1E1IMTQSFE95D980PTM9G34463K6YL3NC");
+            }
+
+
+
+            #endregion
+        }
+    }
+}

+ 172 - 0
HH.YiDaSyncNC/DataSync/FK_SyncService.cs

@@ -0,0 +1,172 @@
+using HH.YiDaSyncNC.Dtos;
+using HH.YiDaSyncNC.Dtos.NC;
+using HH.YiDaSyncNC.Helper;
+using HH.YiDaSyncNC.Models;
+using Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.DataSync
+{
+    class FK_SyncService
+    {
+        public string _AppType;
+        public string _SystemToken;
+        public string _UserId;
+        public string _FormId;
+        public SqlSugarClient _db;
+        public SqlSugarClient _db_nc;
+        public string _NCApiUrl;
+
+        public static string _Static_PK_bd_project = ConfigurationManager.AppSettings["bd_project"];
+        public static string _Static_pk_org_jt = ConfigurationManager.AppSettings["pk_org_jt"];
+
+        public FK_SyncService(string AppType, string SystemToken, string UserId, string FormId, SqlSugarClient db, SqlSugarClient db_nc, string NCApiUrl)
+        {
+            _AppType = AppType;
+            _SystemToken = SystemToken;
+            _UserId = UserId;
+            _FormId = FormId;
+            _db = db;
+            _db_nc = db_nc;
+            _NCApiUrl = NCApiUrl;
+        }
+
+        public class IdCodeModel
+        {
+            public int sourceId { get; set; }
+            public string Id { get; set; }
+        }
+
+        public void DataSync()
+        {
+            DingTalkService _dingTalkService = new DingTalkService(_AppType, _SystemToken, _UserId, _FormId);
+
+            // 宜搭全量数据Id
+            var idList = _dingTalkService.GetModifyFormIdList();
+
+            //// 获取当前最大Id
+            //var newId = 100000001;
+            //var maxData = _db_nc.Queryable<bd_project>().OrderByDescending(obd => Convert.ToDateTime(obd.creationtime)).First();
+            //if (maxData != null && maxData.pk_project.Contains(_Static_PK_bd_project))
+            //{
+            //    newId = Convert.ToInt32(maxData.pk_project.Replace(_Static_PK_bd_project, "")) + 1;
+            //}
+
+            #region 获取NC中选项数据的Id
+            var bd_custclassDic = _db_nc.Queryable<bd_custclass>().ToList();
+            #endregion
+
+            #region 插入数据
+            // 向NC插入数据
+            foreach (var item in idList)
+            {
+
+                string createTime = "";
+                string modifyTime = "";
+
+                var ydDataSource = _dingTalkService.GetFormDataById(item, out createTime, out modifyTime);
+
+                var suplinkmanDataList = new List<KH_SyncServiceModel.DataModel.SuplinkmanItem>();
+
+                var suplinkmanObjList = new List<object>();
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "tableField_lrhhdm5m").Value != null)
+                    suplinkmanObjList = (List<object>)ydDataSource["tableField_lrhhdm5m"];
+
+                foreach (var objItem in suplinkmanObjList)
+                {
+                    suplinkmanDataList.Add(new KH_SyncServiceModel.DataModel.SuplinkmanItem()
+                    {
+                        name = ((Dictionary<string, object>)objItem)["textField_lrhhdm5n"].ToString(),
+                        cell = ((Dictionary<string, object>)objItem)["textField_lrhhdm5o"].ToString(),
+                        vjob = ((Dictionary<string, object>)objItem)["textField_lrhhdm5p"].ToString()
+                    });
+                }
+
+
+                var dataSource = new KH_SyncServiceModel.DataModel()
+                {
+                    pk_group = "0",
+                    pk_org = "0",
+                    code = ydDataSource["serialNumberField_ls14do3x"].ToString(),
+                    name = ydDataSource["textField_lr25icbn"].ToString(),
+                    taxpayerid = ydDataSource["textField_lt425f37"].ToString(),
+                    custprop = "0",
+
+                };
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "selectField_lrrdx03y").Value != null)
+                {
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lrrdx03y"].ToString()))
+                    {
+                        var a = bd_custclassDic.FirstOrDefault(f => f.name == ydDataSource["selectField_lrrdx03y"].ToString());
+                        if (a != null)
+                            dataSource.pk_custclass = a.code; // 分类s
+                    }
+                }
+
+                dataSource.suplinkman = suplinkmanDataList;
+
+                var xmlData = KH_SyncServiceModel.ImportXml.Header(dataSource, item);
+
+                XElement tempData = KH_SyncServiceModel.ImportXml.TemplateHeade();
+
+                var results = NCImportFunc.NCImport(tempData, xmlData, _NCApiUrl + "?account=01&groupcode=0");
+
+                // DBHelper.WriteLog(results);
+                XElement xE = XElement.Parse(results);
+
+                string resultcode = xE.Element("sendresult").Element("resultcode").Value;
+
+                // DBHelper.WriteLog($"状态码:" + resultcode);
+
+                string content = xE.Element("sendresult").Element("content")?.Value;
+
+                string resultdescription = xE.Element("sendresult").Element("resultdescription")?.Value;
+
+                var ncResData = new YiDaResDto()
+                {
+                    syncTime = DateTime.Now,
+                };
+
+                // NC接口执行完成后的处理
+                if (resultcode == "1")
+                {
+                    
+                    DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作成功!");
+
+                    ncResData.bSuccess = true;
+                    ncResData.ncNo = xE.Element("sendresult").Element("content").Value;
+                    ncResData.log = "同步成功!";
+                }
+                else
+                {
+                    DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作失败!" + resultdescription + ";");
+
+                    if (resultdescription.Contains("不允许重复"))
+                    {
+                        ncResData.bSuccess = true;
+                        ncResData.ncNo = "";
+                        ncResData.log = "数据已存在,无需同步!";
+                    }
+                    else
+                    {
+                        ncResData.bSuccess = false;
+                        ncResData.ncNo = "";
+                        ncResData.log = "同步失败!原因为【" + resultdescription + "】";
+                    }
+                }
+
+                var ydRes = _dingTalkService.UpdateFormDataSyncDataById(ncResData, item);
+            }
+            #endregion
+        }
+    }
+}

+ 216 - 0
HH.YiDaSyncNC/DataSync/GYS_SyncService.cs

@@ -0,0 +1,216 @@
+using HH.YiDaSyncNC.Dtos;
+using HH.YiDaSyncNC.Dtos.NC;
+using HH.YiDaSyncNC.Helper;
+using HH.YiDaSyncNC.Models;
+using Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.DataSync
+{
+    class GYS_SyncService
+    {
+        public string _AppType;
+        public string _SystemToken;
+        public string _UserId;
+        public string _FormId;
+        public SqlSugarClient _db;
+        public SqlSugarClient _db_nc;
+        public string _NCApiUrl;
+
+        public static string _Static_PK_xx_idcontrast = ConfigurationManager.AppSettings["xx_idcontrast"];
+        public static string _Static_pk_org_jt = ConfigurationManager.AppSettings["pk_org_jt"];
+
+        public GYS_SyncService(string AppType, string SystemToken, string UserId, string FormId, SqlSugarClient db, SqlSugarClient db_nc, string NCApiUrl)
+        {
+            _AppType = AppType;
+            _SystemToken = SystemToken;
+            _UserId = UserId;
+            _FormId = FormId;
+            _db = db;
+            _db_nc = db_nc;
+            _NCApiUrl = NCApiUrl;
+        }
+
+        public class IdCodeModel
+        {
+            public int sourceId { get; set; }
+            public string Id { get; set; }
+        }
+
+        public void DataSync()
+        {
+            DingTalkService _dingTalkService = new DingTalkService(_AppType, _SystemToken, _UserId, _FormId);
+
+            // 宜搭全量数据Id
+            // var idList = _dingTalkService.GetFormIdList();
+
+            //// NC ID对照表数据
+            //var ncDataIdList = _db_nc.Queryable<xx_idcontrast>().Where(w => w.bill_type == "supplier").ToList();
+
+            //// 获取当前最大Id
+            //var newId = 100000001;
+            //var maxData = ncDataIdList.OrderByDescending(obd => Convert.ToDateTime(obd.ts)).FirstOrDefault();
+            //if (maxData != null && maxData.pk_idcontra.Contains(_Static_PK_xx_idcontrast))
+            //{
+            //    newId = Convert.ToInt32(maxData.pk_idcontra.Replace(_Static_PK_xx_idcontrast, "")) + 1;
+            //}
+
+            //#region 获取NC中选项数据的Id
+            //var pk_supplierclassDic = _db_nc.Queryable<bd_supplierclass>().ToList();
+            //#endregion
+
+            //#region 循环数据处理业务逻辑
+            //// 向NC插入数据
+            //foreach (var item in idList)
+            //{
+            //    string createTime = "";
+            //    string modifyTime = "";
+
+            //    var ydDataSource = _dingTalkService.GetFormDataById(item, out createTime, out modifyTime);
+
+            //    var suplinkmanDataList = new List<GYS_SyncServiceModel.DataModel.SuplinkmanItem>();
+
+            //    //tableField_lrn5j23r
+
+            //    var suplinkmanObjList = new List<object>();
+
+            //    if (ydDataSource.FirstOrDefault(f => f.Key == "tableField_lrn5j24e").Value != null)
+            //        suplinkmanObjList = (List<object>)ydDataSource["tableField_lrn5j24e"];
+
+            //    foreach (var objItem in suplinkmanObjList)
+            //    {
+            //        suplinkmanDataList.Add(new GYS_SyncServiceModel.DataModel.SuplinkmanItem()
+            //        {
+            //            name = ((Dictionary<string, object>)objItem)["textField_lrn5j244"].ToString(),
+            //            cell = ((Dictionary<string, object>)objItem)["textField_lrn5j245"].ToString(),
+            //        });
+            //    }
+
+
+            //    var dataSource = new GYS_SyncServiceModel.DataModel()
+            //    {
+            //        pk_group = "0",
+            //        pk_org = "0",
+            //        code = ydDataSource["textField_lrhgjspd"].ToString(),
+            //        name = ydDataSource["textField_lrhgjspc"].ToString(),
+            //        taxpayerid = ydDataSource["textField_lrhgjspr"].ToString(),
+            //    };
+
+            //    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lrn5j22q"].ToString()))
+            //    {
+            //        var a = pk_supplierclassDic.FirstOrDefault(f => f.name == ydDataSource["selectField_lrn5j22q"].ToString());
+            //        if (a != null)
+            //            dataSource.pk_supplierclass = a.code; // 分类s
+            //    }
+            //    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lrn5j22p"].ToString()))
+            //    {
+
+            //        switch (ydDataSource["selectField_lrn5j22p"].ToString())
+            //        {
+            //            case "启用":
+            //                dataSource.enablestate = ((int)EnumType.enablestate.已启用).ToString();
+            //                break;
+            //            case "未启用":
+            //                dataSource.enablestate = ((int)EnumType.enablestate.已停用).ToString();
+            //                break;
+            //        }
+            //    }
+
+            //    dataSource.suplinkman = suplinkmanDataList;
+
+            //    var xmlData = GYS_SyncServiceModel.ImportXml.Header(dataSource, item);
+            //    XElement tempData = GYS_SyncServiceModel.ImportXml.TemplateHeade();
+
+            //    var results = NCImportFunc.NCImport(tempData, xmlData, _NCApiUrl + "?account=01&groupcode=0");
+
+            //    XElement xE = XElement.Parse(results);
+            //    string resultcode = xE.Element("sendresult").Element("resultcode").Value;
+            //    string resultdescription = xE.Element("sendresult").Element("resultdescription")?.Value;
+
+            //    var ncResData = new YiDaResDto()
+            //    {
+            //        syncTime = DateTime.Now,
+            //    };
+
+            //    // NC接口执行完成后的处理
+            //    if (resultcode == "1")
+            //    {
+            //        DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作成功!");
+
+            //        ncResData.bSuccess = true;
+            //        ncResData.ncNo = xE.Element("sendresult").Element("content").Value;
+            //        ncResData.log = "同步成功!";
+            //    }
+            //    else
+            //    {
+            //        if (resultdescription.Contains("不允许重复"))
+            //        {
+            //            // 已存在数据,绑定Id
+            //            var nowData = _db_nc.Queryable<bd_supplier>().First(f => f.code == dataSource.code && f.pk_org == _Static_pk_org_jt);
+
+            //            var idcData = new xx_idcontrast()
+            //            {
+            //                bill_type = "supplier",
+            //                dr = 0,
+            //                file_id = item,
+            //                pk_bill = nowData.pk_supplier,
+            //                pk_idcontra = _Static_PK_xx_idcontrast + newId
+            //            };
+            //            _db_nc.Insertable(idcData).ExecuteCommand();
+
+            //            newId++;
+
+            //            ncResData.bSuccess = true;
+            //            ncResData.ncNo = nowData.pk_supplier;
+            //            ncResData.log = "数据已存在,无需同步,已自动对照!";
+            //        }
+            //        else
+            //        {
+            //            DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作失败!" + resultdescription + ";");
+
+            //            ncResData.bSuccess = false;
+            //            ncResData.ncNo = "";
+            //            ncResData.log = "同步失败!原因为【" + resultdescription + "】";
+            //        }
+
+
+            //        //DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作失败!" + resultdescription + ";");
+
+            //        //if (resultdescription.Contains("不允许重复"))
+            //        //{
+            //        //    ncResData.bSuccess = true;
+            //        //    ncResData.ncNo = "";
+            //        //    ncResData.log = "数据已存在,无需同步!";
+            //        //}
+            //        //else
+            //        //{
+            //        //    ncResData.bSuccess = false;
+            //        //    ncResData.ncNo = "";
+            //        //    ncResData.log = "同步失败!原因为【" + resultdescription + "】";
+            //        //}
+            //    }
+
+            //    var ydRes = _dingTalkService.UpdateFormDataSyncDataById(ncResData, item);
+            //}
+            //#endregion
+
+            // radioField_lycrvvtk
+
+            var ncResData = new YiDaResDto()
+            {
+                syncTime = DateTime.Now,
+            };
+            ncResData.bSuccess = true;
+            ncResData.ncNo = "1001G1100000000DS51M";
+            ncResData.log = "同步成功! || 同步成功! ||  同步成功!";
+            var ydRes = _dingTalkService.UpdateFormDataSyncDataById(ncResData, "FINST-G0A66Z81V0KMGG7J93ECT8JZATO63QA8SGIYLH4N2");
+        }
+    }
+}

+ 172 - 0
HH.YiDaSyncNC/DataSync/KH_SyncService.cs

@@ -0,0 +1,172 @@
+using HH.YiDaSyncNC.Dtos;
+using HH.YiDaSyncNC.Dtos.NC;
+using HH.YiDaSyncNC.Helper;
+using HH.YiDaSyncNC.Models;
+using Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.DataSync
+{
+    class KH_SyncService
+    {
+        public string _AppType;
+        public string _SystemToken;
+        public string _UserId;
+        public string _FormId;
+        public SqlSugarClient _db;
+        public SqlSugarClient _db_nc;
+        public string _NCApiUrl;
+
+        public static string _Static_PK_bd_project = ConfigurationManager.AppSettings["bd_project"];
+        public static string _Static_pk_org_jt = ConfigurationManager.AppSettings["pk_org_jt"];
+
+        public KH_SyncService(string AppType, string SystemToken, string UserId, string FormId, SqlSugarClient db, SqlSugarClient db_nc, string NCApiUrl)
+        {
+            _AppType = AppType;
+            _SystemToken = SystemToken;
+            _UserId = UserId;
+            _FormId = FormId;
+            _db = db;
+            _db_nc = db_nc;
+            _NCApiUrl = NCApiUrl;
+        }
+
+        public class IdCodeModel
+        {
+            public int sourceId { get; set; }
+            public string Id { get; set; }
+        }
+
+        public void DataSync()
+        {
+            DingTalkService _dingTalkService = new DingTalkService(_AppType, _SystemToken, _UserId, _FormId);
+
+            // 宜搭全量数据Id
+            var idList = _dingTalkService.GetModifyFormIdList();
+
+            //// 获取当前最大Id
+            //var newId = 100000001;
+            //var maxData = _db_nc.Queryable<bd_project>().OrderByDescending(obd => Convert.ToDateTime(obd.creationtime)).First();
+            //if (maxData != null && maxData.pk_project.Contains(_Static_PK_bd_project))
+            //{
+            //    newId = Convert.ToInt32(maxData.pk_project.Replace(_Static_PK_bd_project, "")) + 1;
+            //}
+
+            #region 获取NC中选项数据的Id
+            var bd_custclassDic = _db_nc.Queryable<bd_custclass>().ToList();
+            #endregion
+
+            #region 插入数据
+            // 向NC插入数据
+            foreach (var item in idList)
+            {
+
+                string createTime = "";
+                string modifyTime = "";
+
+                var ydDataSource = _dingTalkService.GetFormDataById(item, out createTime, out modifyTime);
+
+                var suplinkmanDataList = new List<KH_SyncServiceModel.DataModel.SuplinkmanItem>();
+
+                var suplinkmanObjList = new List<object>();
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "tableField_lrhhdm5m").Value != null)
+                    suplinkmanObjList = (List<object>)ydDataSource["tableField_lrhhdm5m"];
+
+                foreach (var objItem in suplinkmanObjList)
+                {
+                    suplinkmanDataList.Add(new KH_SyncServiceModel.DataModel.SuplinkmanItem()
+                    {
+                        name = ((Dictionary<string, object>)objItem)["textField_lrhhdm5n"].ToString(),
+                        cell = ((Dictionary<string, object>)objItem)["textField_lrhhdm5o"].ToString(),
+                        vjob = ((Dictionary<string, object>)objItem)["textField_lrhhdm5p"].ToString()
+                    });
+                }
+
+
+                var dataSource = new KH_SyncServiceModel.DataModel()
+                {
+                    pk_group = "0",
+                    pk_org = "0",
+                    code = ydDataSource["serialNumberField_ls14do3x"].ToString(),
+                    name = ydDataSource["textField_lr25icbn"].ToString(),
+                    taxpayerid = ydDataSource["textField_lt425f37"].ToString(),
+                    custprop = "0",
+
+                };
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "selectField_lrrdx03y").Value != null)
+                {
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lrrdx03y"].ToString()))
+                    {
+                        var a = bd_custclassDic.FirstOrDefault(f => f.name == ydDataSource["selectField_lrrdx03y"].ToString());
+                        if (a != null)
+                            dataSource.pk_custclass = a.code; // 分类s
+                    }
+                }
+
+                dataSource.suplinkman = suplinkmanDataList;
+
+                var xmlData = KH_SyncServiceModel.ImportXml.Header(dataSource, item);
+
+                XElement tempData = KH_SyncServiceModel.ImportXml.TemplateHeade();
+
+                var results = NCImportFunc.NCImport(tempData, xmlData, _NCApiUrl + "?account=01&groupcode=0");
+
+                // DBHelper.WriteLog(results);
+                XElement xE = XElement.Parse(results);
+
+                string resultcode = xE.Element("sendresult").Element("resultcode").Value;
+
+                // DBHelper.WriteLog($"状态码:" + resultcode);
+
+                string content = xE.Element("sendresult").Element("content")?.Value;
+
+                string resultdescription = xE.Element("sendresult").Element("resultdescription")?.Value;
+
+                var ncResData = new YiDaResDto()
+                {
+                    syncTime = DateTime.Now,
+                };
+
+                // NC接口执行完成后的处理
+                if (resultcode == "1")
+                {
+                    
+                    DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作成功!");
+
+                    ncResData.bSuccess = true;
+                    ncResData.ncNo = xE.Element("sendresult").Element("content").Value;
+                    ncResData.log = "同步成功!";
+                }
+                else
+                {
+                    DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作失败!" + resultdescription + ";");
+
+                    if (resultdescription.Contains("不允许重复"))
+                    {
+                        ncResData.bSuccess = true;
+                        ncResData.ncNo = "";
+                        ncResData.log = "数据已存在,无需同步!";
+                    }
+                    else
+                    {
+                        ncResData.bSuccess = false;
+                        ncResData.ncNo = "";
+                        ncResData.log = "同步失败!原因为【" + resultdescription + "】";
+                    }
+                }
+
+                var ydRes = _dingTalkService.UpdateFormDataSyncDataById(ncResData, item);
+            }
+            #endregion
+        }
+    }
+}

+ 562 - 0
HH.YiDaSyncNC/DataSync/KP_SyncService.cs

@@ -0,0 +1,562 @@
+using HH.YiDaSyncNC.Dtos;
+using HH.YiDaSyncNC.Dtos.NC;
+using HH.YiDaSyncNC.Helper;
+using HH.YiDaSyncNC.Models;
+using Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.DataSync
+{
+    class KP_SyncService
+    {
+        public string _AppType;
+        public string _SystemToken;
+        public string _UserId;
+        public string _FormId;
+        public SqlSugarClient _db;
+        public SqlSugarClient _db_nc;
+        public string _NCApiUrl;
+
+        public static string _Static_PK_so_saleorder = ConfigurationManager.AppSettings["so_saleorder"];
+        public static string _Static_PK_so_saleorder_b = ConfigurationManager.AppSettings["so_saleorder_b"];
+        public static string _Static_pk_org_jt = ConfigurationManager.AppSettings["pk_org_jt"];
+
+        public KP_SyncService(string AppType, string SystemToken, string UserId, string FormId, SqlSugarClient db, SqlSugarClient db_nc, string NCApiUrl)
+        {
+            _AppType = AppType;
+            _SystemToken = SystemToken;
+            _UserId = UserId;
+            _FormId = FormId;
+            _db = db;
+            _db_nc = db_nc;
+            _NCApiUrl = NCApiUrl;
+        }
+
+        public class IdCodeModel
+        {
+            public int sourceId { get; set; }
+            public string Id { get; set; }
+        }
+
+        public class FormItem
+        {
+            public string title { get; set; }
+        }
+
+        public void DataSync()
+        {
+            DingTalkService _dingTalkService = new DingTalkService(_AppType, _SystemToken, _UserId, _FormId);
+
+            // 宜搭全量数据Id
+            var idList = _dingTalkService.GetFormIdList("{\"radioField_lycrvvtk\":\"Y\"}");
+
+            LogHelper.WriteLog(JsonConvert.SerializeObject(idList.Count), "idList");
+
+            #region 获取NC中选项数据的Id
+            var bd_customerDic = _db_nc.Queryable<bd_customer>().ToList();
+            var bd_incomeDic = _db_nc.Queryable<bd_income>().ToList();
+            var org_orgsDic = _db_nc.Queryable<org_orgs>().ToList();
+            var bd_projectDic = _db_nc.Queryable<bd_project>().ToList();
+            var bd_materialDic = _db_nc.Queryable<bd_material>().ToList();
+            var bd_measdocDic = _db_nc.Queryable<bd_measdoc>().ToList();
+            var org_deptDic = _db_nc.Queryable<org_dept>().ToList();
+            var bd_psndocDic = _db_nc.Queryable<bd_psndoc>().ToList();
+            var sm_userDic = _db_nc.Queryable<sm_user>().ToList();
+            var bd_defdoc_kplx = _db_nc.Queryable<bd_defdoc>().Where(w => w.pk_defdoclist == "1001G1100000000016FV").ToList(); // 开票类型
+            var bd_defdoc_htywlx = _db_nc.Queryable<bd_defdoc>().Where(w => w.pk_defdoclist == "1001G1100000000010PV").ToList(); // 合同业务类型
+            #endregion
+
+
+            #region 接口方式
+            // 向NC插入数据
+            foreach (var item in idList)
+            {
+                string createTime = "";
+                string modifyTime = "";
+
+                var ydDataSource = _dingTalkService.GetFormDataById(item, out createTime, out modifyTime);
+
+                var ncResData = new List<YiDaResDto>();
+
+
+                #region 表头
+                // 表头
+                var dataSource = new KP_SyncServiceModel.DataModel();
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "selectField_lvc9x4vo").Value != null)
+                {
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lvc9x4vo"].ToString()))
+                    {
+                        var tempData = org_orgsDic.FirstOrDefault(f => f.name == ydDataSource["selectField_lvc9x4vo"].ToString());
+                        if (tempData != null)
+                        {
+                            dataSource.组织 = tempData.code; // 组织
+                        }
+                    }
+                }
+
+                dataSource.单据日期 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "textField_lvdojfuj").Value != null)
+                {
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["textField_lvdojfuj"].ToString()))
+                    {
+                        var tempData = bd_customerDic.FirstOrDefault(f => f.code == ydDataSource["textField_lvdojfuj"].ToString());
+                        if (tempData != null)
+                        {
+                            dataSource.客户 = tempData.code; // 客户
+                        }
+                    }
+                }
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "selectField_lvc9x4vq").Value != null)
+                {
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lvc9x4vq"].ToString()))
+                    {
+                        var tempData = bd_incomeDic.FirstOrDefault(f => f.name == ydDataSource["selectField_lvc9x4vq"].ToString());
+                        if (tempData != null)
+                        {
+                            dataSource.收款协议 = tempData.code; // 收款协议
+                        }
+                    }
+                }
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "departmentSelectField_lvc7mi3w").Value != null)
+                {
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["departmentSelectField_lvc7mi3w"].ToString()))
+                    {
+                        var tempData = org_deptDic.FirstOrDefault(f => f.name == JsonConvert.DeserializeObject<List<string>>(JsonConvert.SerializeObject(ydDataSource["departmentSelectField_lvc7mi3w"]))[0]);
+                        if (tempData != null)
+                        {
+                            dataSource.部门 = tempData.code; // 部门
+                        }
+                    }
+                }
+
+                dataSource.审批人 = "OA-NC";
+                dataSource.制单人 = "OA-NC";
+                dataSource.创建人 = "OA-NC";
+
+                dataSource.审批时间 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                dataSource.制单时间 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                dataSource.创建时间 = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "textField_lvdntzul").Value != null)
+                {
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["textField_lvdntzul"].ToString()))
+                    {
+                        var tempData = bd_projectDic.FirstOrDefault(f => f.project_code == ydDataSource["textField_lvdntzul"].ToString());
+                        if (tempData != null)
+                        {
+                            dataSource.项目 = tempData.project_code; // 项目
+                        }
+                    }
+                }
+
+                dataSource.发票号 = ydDataSource["textField_lvd8pp35"].ToString();
+                dataSource.客户打印名称 = ydDataSource["selectField_lvdojfui"].ToString();
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "selectField_lvc9x4vp").Value != null)
+                {
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lvc9x4vp"].ToString()))
+                    {
+                        var tempName = ydDataSource["selectField_lvc9x4vp"].ToString();
+                        if (ydDataSource["selectField_lvc9x4vp"].ToString() == "增值税专票")
+                        {
+                            tempName = "增值税专用发票";
+                        }
+
+                        if (ydDataSource["selectField_lvc9x4vp"].ToString() == "增值税普票")
+                        {
+                            tempName = "增值税普通发票";
+                        }
+
+                        var tempData = bd_defdoc_kplx.FirstOrDefault(f => f.name == tempName);
+                        if (tempData != null)
+                        {
+                            dataSource.开票类型 = tempData.pk_defdoc; // 开票类型
+                        }
+                    }
+                }
+
+                dataSource.OA单据号 = ydDataSource["textField_lvdosccc"].ToString();
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "selectField_lvc9x4vn").Value != null)
+                {
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lvc9x4vn"].ToString()))
+                    {
+                        var tempData = bd_defdoc_htywlx.FirstOrDefault(f => f.name == ydDataSource["selectField_lvc9x4vn"].ToString());
+                        if (tempData != null)
+                        {
+                            dataSource.合同业务类型 = tempData.pk_defdoc; // 合同业务类型
+                        }
+                    }
+                }
+
+                dataSource.年份 = DateTime.Now.ToString("yyyy");
+                dataSource.月份 = DateTime.Now.ToString("MM");
+
+                #endregion
+
+                var detailList = new List<KP_SyncServiceModel.DataModel.OrderB>();
+
+                #region 大业主开票明细
+                if (ydDataSource.FirstOrDefault(f => f.Key == "tableField_lvc9x4vt").Value != null && dataSource.合同业务类型 == "1001G11000000000113D")
+                {
+                    var detailObjList1 = (List<object>)ydDataSource["tableField_lvc9x4vt"]; // 大业主开票明细
+                    if (ydDataSource.FirstOrDefault(f => f.Key == "tableField_lvc9x4vt").Value != null)
+                    {
+                        foreach (var objItem in detailObjList1)
+                        {
+                            var detailItem = new KP_SyncServiceModel.DataModel.OrderB();
+
+                            if (!string.IsNullOrWhiteSpace(((Dictionary<string, object>)objItem)["associationFormField_lvynhq7p_id"].ToString()))
+                            {
+                                var sourceStr = ((Dictionary<string, object>)objItem)["associationFormField_lvynhq7p_id"].ToString().Replace("\\", "");
+                                var a = sourceStr = sourceStr.Substring(1, sourceStr.Length - 2);
+                                var b = JsonConvert.DeserializeObject<List<FormItem>>(a);
+
+                                var materialData = bd_materialDic.FirstOrDefault(f => f.name == b[0].title);
+
+                                detailItem.物料 = materialData.code; // 物料
+
+                                var unitCode = bd_measdocDic.FirstOrDefault(f => f.pk_measdoc == materialData.pk_measdoc);
+
+                                detailItem.计量单位 = unitCode.code; // 计量单位
+                            }
+
+                            var hsdj = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp2v"].ToString());
+                            var se = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp2z"].ToString());
+                            var wsdj = hsdj - se;
+                            var sl = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp2w"].ToString());
+                            var wsje = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp30"].ToString());
+                            var jshj = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp2y"].ToString());
+
+                            // 含税单价
+                            detailItem.含税单价 = hsdj.ToString();
+
+                            // 无税单价
+                            detailItem.无税单价 = wsdj.ToString();
+
+                            //  含税净价
+                            detailItem.含税净价 = hsdj.ToString();
+
+                            // 无税净价
+                            detailItem.无税净价 = wsdj.ToString();
+
+                            // 税额
+                            detailItem.税额 = se.ToString();
+
+                            // 无税金额
+                            detailItem.无税金额 = wsje.ToString();
+
+                            // 数量
+                            detailItem.数量 = sl.ToString();
+
+                            // 价税合计
+                            detailItem.价税合计 = jshj.ToString();
+
+                            detailItem.换算率 = "1.00/1.00";
+                            detailItem.税码 = "CN04"; // 税率码 
+                            detailItem.税率 = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp2x"].ToString()).ToString(); // 税率
+
+                            detailItem.开票内容 = ((Dictionary<string, object>)objItem)["textField_lvd8pp2t"].ToString();
+
+                            detailItem.行id = ((Dictionary<string, object>)objItem)["textField_lvdojfup"].ToString();
+
+                            detailList.Add(detailItem);
+                        }
+                    }
+                }
+                #endregion
+
+                #region 工程订单开票明细
+                if (ydDataSource.FirstOrDefault(f => f.Key == "tableField_lvd8pp44").Value != null && dataSource.合同业务类型 == null)
+                {
+                    dataSource.项目 = "PM99001";
+                    dataSource.合同业务类型 = "1001G11000000000113F";
+
+                    var detailObjList2 = (List<object>)ydDataSource["tableField_lvd8pp44"]; // 工程订单开票明细
+                    if (ydDataSource.FirstOrDefault(f => f.Key == "tableField_lvd8pp44").Value != null)
+                    {
+                        foreach (var objItem in detailObjList2)
+                        {
+                            var detailItem = new KP_SyncServiceModel.DataModel.OrderB();
+
+                            if (!string.IsNullOrWhiteSpace(((Dictionary<string, object>)objItem)["associationFormField_lvynrr6a_id"].ToString()))
+                            {
+                                var sourceStr = ((Dictionary<string, object>)objItem)["associationFormField_lvynrr6a_id"].ToString().Replace("\\", "");
+                                var a = sourceStr = sourceStr.Substring(1, sourceStr.Length - 2);
+                                var b = JsonConvert.DeserializeObject<List<FormItem>>(a);
+
+                                var materialData = bd_materialDic.FirstOrDefault(f => f.name == b[0].title);
+
+                                detailItem.物料 = materialData.code; // 物料
+
+                                var unitCode = bd_measdocDic.FirstOrDefault(f => f.pk_measdoc == materialData.pk_measdoc);
+
+                                detailItem.计量单位 = unitCode.code; // 计量单位
+                            }
+
+                            var hsdj = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp3y"].ToString());
+                            var se = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp42"].ToString());
+                            var wsdj = hsdj - se;
+                            var sl = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp3z"].ToString());
+                            var wsje = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp43"].ToString());
+                            var jshj = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp41"].ToString());
+
+                            // 含税单价
+                            detailItem.含税单价 = hsdj.ToString();
+
+                            // 无税单价
+                            detailItem.无税单价 = wsdj.ToString();
+
+                            //  含税净价
+                            detailItem.含税净价 = hsdj.ToString();
+
+                            // 无税净价
+                            detailItem.无税净价 = wsdj.ToString();
+
+                            // 税额
+                            detailItem.税额 = se.ToString();
+
+                            // 无税金额
+                            detailItem.无税金额 = wsje.ToString();
+
+                            // 数量
+                            detailItem.数量 = sl.ToString();
+
+                            // 价税合计
+                            detailItem.价税合计 = jshj.ToString();
+
+                            detailItem.换算率 = "1.00/1.00";
+                            detailItem.税码 = "CN04"; // 税率码 
+                            detailItem.税率 = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvd8pp40"].ToString()).ToString(); // 税率
+
+                            detailItem.开票内容 = ((Dictionary<string, object>)objItem)["textField_lvd8pp3w"].ToString();
+
+                            detailItem.行id = ((Dictionary<string, object>)objItem)["textField_lvdojfur"].ToString();
+
+                            detailList.Add(detailItem);
+                        }
+                    }
+                }
+                #endregion
+
+                #region 小业主开票明细
+                if (ydDataSource.FirstOrDefault(f => f.Key == "tableField_lvdnme13").Value != null && dataSource.合同业务类型 == "1001G11000000000113E")
+                {
+                    var detailObjList3 = (List<object>)ydDataSource["tableField_lvdnme13"]; // 小业主
+                    if (ydDataSource.FirstOrDefault(f => f.Key == "tableField_lvdnme13").Value != null)
+                    {
+                        foreach (var objItem in detailObjList3)
+                        {
+                            var detailItem = new KP_SyncServiceModel.DataModel.OrderB();
+
+                            if (!string.IsNullOrWhiteSpace(((Dictionary<string, object>)objItem)["associationFormField_lvynrr6c_id"].ToString()))
+                            {
+                                var sourceStr = ((Dictionary<string, object>)objItem)["associationFormField_lvynrr6c_id"].ToString().Replace("\\", "");
+                                var a = sourceStr = sourceStr.Substring(1, sourceStr.Length - 2);
+                                var b = JsonConvert.DeserializeObject<List<FormItem>>(a);
+
+                                var materialData = bd_materialDic.FirstOrDefault(f => f.name == b[0].title);
+
+                                detailItem.物料 = materialData.code; // 物料
+
+                                var unitCode = bd_measdocDic.FirstOrDefault(f => f.pk_measdoc == materialData.pk_measdoc);
+
+                                detailItem.计量单位 = unitCode.code; // 计量单位
+                            }
+
+                            var hsdj = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvdnme0w"].ToString());
+                            var se = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvdnme10"].ToString());
+                            var wsdj = hsdj - se;
+                            var sl = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvdnme0x"].ToString());
+                            var wsje = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvdnme11"].ToString());
+                            var jshj = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvdnme0z"].ToString());
+
+                            // 含税单价
+                            detailItem.含税单价 = hsdj.ToString();
+
+                            // 无税单价
+                            detailItem.无税单价 = wsdj.ToString();
+
+                            //  含税净价
+                            detailItem.含税净价 = hsdj.ToString();
+
+                            // 无税净价
+                            detailItem.无税净价 = wsdj.ToString();
+
+                            // 税额
+                            detailItem.税额 = se.ToString();
+
+                            // 无税金额
+                            detailItem.无税金额 = wsje.ToString();
+
+                            // 数量
+                            detailItem.数量 = sl.ToString();
+
+                            // 价税合计
+                            detailItem.价税合计 = jshj.ToString();
+
+                            detailItem.换算率 = "1.00/1.00";
+                            detailItem.税码 = "CN04"; // 税率码 
+                            detailItem.税率 = Convert.ToDecimal(((Dictionary<string, object>)objItem)["numberField_lvdnme0y"].ToString()).ToString(); // 税率
+
+                            detailItem.开票内容 = ((Dictionary<string, object>)objItem)["textField_lvdnme0u"].ToString();
+
+                            detailItem.行id = ((Dictionary<string, object>)objItem)["textField_lvdojfus"].ToString();
+
+                            detailList.Add(detailItem);
+                        }
+                    }
+                }
+                #endregion
+
+                dataSource.明细 = detailList;
+
+                dataSource.数量 = dataSource.明细.Sum(s => Convert.ToDecimal(s.数量)).ToString();
+                dataSource.价税合计 = dataSource.明细.Sum(s => Convert.ToDecimal(s.价税合计)).ToString();
+
+
+                var results_销售订单 = NCImportFunc.NCImport(KP_SyncServiceModel.ImportXml_销售订单.TemplateHeade(), KP_SyncServiceModel.ImportXml_销售订单.Header(dataSource, item), _NCApiUrl + "?account=LY01&groupcode=0");
+
+                LogHelper.WriteLog(JsonConvert.SerializeObject(results_销售订单), "results_销售订单");
+
+                XElement xE_销售订单 = XElement.Parse(results_销售订单);
+                string resultcode_销售订单 = xE_销售订单.Element("sendresult").Element("resultcode").Value;
+                string resultdescription_销售订单 = xE_销售订单.Element("sendresult").Element("resultdescription")?.Value;
+
+                if (resultcode_销售订单 == "1")
+                {
+                    ncResData.Add(new YiDaResDto()
+                    {
+                        bSuccess = true,
+                        ncNo = xE_销售订单.Element("sendresult").Element("content").Value,
+                        log = "同步成功!"
+                    });
+                }
+                else
+                {
+                    ncResData.Add(new YiDaResDto()
+                    {
+                        bSuccess = false,
+                        ncNo = "",
+                        log = "同步失败!原因为【" + resultdescription_销售订单 + "】!"
+                    });
+                }
+
+                // -------------------------------销售订单同步完,开始同步销售发票
+
+                var saleorderData = _db_nc.Queryable<so_saleorder>().First(f => f.csaleorderid == xE_销售订单.Element("sendresult").Element("content").Value);
+                var saleorderbData = _db_nc.Queryable<so_saleorder_b>().Where(f => f.csaleorderid == xE_销售订单.Element("sendresult").Element("content").Value).ToList();
+
+                dataSource.销售订单单据号 = saleorderData.vbillcode;
+                dataSource.销售订单主表id = saleorderData.csaleorderid;
+
+                foreach (var detailItem in dataSource.明细)
+                {
+                    detailItem.销售订单子表id = saleorderbData.FirstOrDefault(f => f.vbdef10 == detailItem.行id).csaleorderbid;
+                }
+
+                var results_销售发票 = NCImportFunc.NCImport(KP_SyncServiceModel.ImportXml_销售发票.TemplateHeade(), KP_SyncServiceModel.ImportXml_销售发票.Header(dataSource, item), _NCApiUrl + "?account=LY01&groupcode=0");
+
+
+                LogHelper.WriteLog(JsonConvert.SerializeObject(results_销售发票), "results_销售发票");
+
+                XElement xE_销售发票 = XElement.Parse(results_销售发票);
+                string resultcode_销售发票 = xE_销售发票.Element("sendresult").Element("resultcode").Value;
+                string resultdescription_销售发票 = xE_销售发票.Element("sendresult").Element("resultdescription")?.Value;
+
+                if (resultcode_销售发票 == "1")
+                {
+                    ncResData.Add(new YiDaResDto()
+                    {
+                        bSuccess = true,
+                        ncNo = xE_销售发票.Element("sendresult").Element("content").Value,
+                        log = "同步成功!"
+                    });
+                }
+                else
+                {
+                    ncResData.Add(new YiDaResDto()
+                    {
+                        bSuccess = false,
+                        ncNo = "",
+                        log = "同步失败!原因为【" + resultdescription_销售发票 + "】!"
+                    });
+                }
+
+                // -------------------------------销售订单同步完,开始同步应收
+
+                var saleinvoicebData = _db_nc.Queryable<so_saleinvoice_b>().Where(f => f.csaleinvoiceid == xE_销售发票.Element("sendresult").Element("content").Value).ToList();
+                var squareinvbData = _db_nc.Queryable<so_squareinv_d>().Where(f => f.csquarebillid == xE_销售发票.Element("sendresult").Element("content").Value).ToList();
+
+                dataSource.销售发票主表id = xE_销售发票.Element("sendresult").Element("content").Value;
+
+                //foreach (var detailItem in dataSource.明细)
+                //{
+                //    var a = saleinvoicebData.FirstOrDefault(f => f.vbdef10 == detailItem.行id).csaleinvoicebid;
+                //    var b = squareinvbData.FirstOrDefault(f => f.csquarebillbid == a);
+                //    detailItem.销售发票子表id = b.csalesquaredid;
+                //}
+
+                var results_应收单 = NCImportFunc.NCImport(KP_SyncServiceModel.ImportXml_应收单.TemplateHeade(), KP_SyncServiceModel.ImportXml_应收单.Header(dataSource, item), _NCApiUrl + "?account=LY01&groupcode=0");
+
+                LogHelper.WriteLog(JsonConvert.SerializeObject(results_应收单), "results_应收单");
+
+                XElement xE_应收单 = XElement.Parse(results_应收单);
+                string resultcode_应收单 = xE_应收单.Element("sendresult").Element("resultcode").Value;
+                string resultdescription_应收单 = xE_应收单.Element("sendresult").Element("resultdescription")?.Value;
+
+                if (resultcode_应收单 == "1")
+                {
+                    ncResData.Add(new YiDaResDto()
+                    {
+                        bSuccess = true,
+                        ncNo = xE_应收单.Element("sendresult").Element("content").Value,
+                        log = "同步成功!"
+                    });
+                }
+                else
+                {
+                    ncResData.Add(new YiDaResDto()
+                    {
+                        bSuccess = false,
+                        ncNo = "",
+                        log = "同步失败!原因为【" + resultdescription_应收单 + "】!"
+                    });
+                }
+
+                var finalResData = new YiDaResDto();
+
+                if (ncResData.FirstOrDefault(f => !f.bSuccess) != null)
+                {
+                    finalResData.bSuccess = false;
+                    finalResData.syncTime = DateTime.Now;
+                    finalResData.ncNo = xE_销售订单.Element("sendresult").Element("content").Value;
+                    finalResData.log = string.Join(" || ", ncResData.Select(s => s.log));
+                }
+                else
+                {
+                    finalResData.bSuccess = true;
+                    finalResData.syncTime = DateTime.Now;
+                    finalResData.ncNo = xE_销售订单.Element("sendresult").Element("content").Value;
+                    finalResData.log = string.Join(" || ", ncResData.Select(s => s.log));
+                }
+
+                var ydRes = _dingTalkService.UpdateFormDataSyncDataById(finalResData, item);
+            }
+
+            #endregion
+        }
+    }
+}

+ 213 - 0
HH.YiDaSyncNC/DataSync/WL_SyncService.cs

@@ -0,0 +1,213 @@
+using HH.YiDaSyncNC.Dtos;
+using HH.YiDaSyncNC.Dtos.NC;
+using HH.YiDaSyncNC.Helper;
+using HH.YiDaSyncNC.Models;
+using Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.DataSync
+{
+    class WL_SyncService
+    {
+        public string _AppType;
+        public string _SystemToken;
+        public string _UserId;
+        public string _FormId;
+        public SqlSugarClient _db;
+        public SqlSugarClient _db_nc;
+        public string _NCApiUrl;
+
+        public static string _Static_PK_xx_idcontrast = ConfigurationManager.AppSettings["xx_idcontrast"];
+        public static string _Static_pk_org_jt = ConfigurationManager.AppSettings["pk_org_jt"];
+
+        public WL_SyncService(string AppType, string SystemToken, string UserId, string FormId, SqlSugarClient db, SqlSugarClient db_nc, string NCApiUrl)
+        {
+            _AppType = AppType;
+            _SystemToken = SystemToken;
+            _UserId = UserId;
+            _FormId = FormId;
+            _db = db;
+            _db_nc = db_nc;
+            _NCApiUrl = NCApiUrl;
+        }
+
+        public class IdCodeModel
+        {
+            public int sourceId { get; set; }
+            public string Id { get; set; }
+        }
+
+        public void DataSync()
+        {
+            DBHelper.WriteLog($"进入程序");
+
+            DingTalkService _dingTalkService = new DingTalkService(_AppType, _SystemToken, _UserId, _FormId);
+
+            // 宜搭全量数据Id
+            var idList = _dingTalkService.GetModifyFormIdList();
+
+            DBHelper.WriteLog(JsonConvert.SerializeObject(idList), "idList");
+
+            // NC ID对照表数据
+            var ncDataIdList = _db_nc.Queryable<xx_idcontrast>().Where(w => w.bill_type == "material").ToList();
+
+            // 获取当前最大Id
+            var newId = 100000001;
+            var maxData = ncDataIdList.OrderByDescending(obd => Convert.ToDateTime(obd.ts)).FirstOrDefault();
+            if (maxData != null && maxData.pk_idcontra.Contains(_Static_PK_xx_idcontrast))
+            {
+                newId = Convert.ToInt32(maxData.pk_idcontra.Replace(_Static_PK_xx_idcontrast, "")) + 1;
+            }
+
+            #region 获取NC中选项数据的Id
+            var pk_marbasclassDic = _db_nc.Queryable<bd_marbasclass>().ToList();
+            var pk_measdocDic = _db_nc.Queryable<bd_measdoc>().ToList();
+            var pk_mattaxesDic = _db_nc.Queryable<bd_mattaxes>().ToList();
+            var pk_brandDic = _db_nc.Queryable<bd_branddoc>().ToList();
+            #endregion
+
+            #region 循环数据处理业务逻辑
+            foreach (var item in idList.Where(w => !ncDataIdList.Select(s => s.file_id).ToList().Contains(w)))
+            {
+
+                DBHelper.WriteLog($"进入程序1");
+
+                // 获取此条数据详情
+                string createTime = "";
+                string modifyTime = "";
+                var ydDataSource = _dingTalkService.GetFormDataById(item, out createTime, out modifyTime);
+
+
+                DBHelper.WriteLog(ydDataSource["radioField_lycrvvtk"].ToString(),"222");
+
+                if (ydDataSource["radioField_lycrvvtk"].ToString() == "Y")
+                {
+                    DBHelper.WriteLog($"进入程序2");
+
+                    #region 构建数据体
+                    var dataSource = new WL_SyncServiceModel.DataModel()
+                    {
+                        pk_group = "0",
+                        pk_org = "0",
+                        code = ydDataSource["textField_lr3axfje"].ToString(),
+                        name = ydDataSource["textField_lr383i4h"].ToString(),
+                        ename = ydDataSource["textField_lwitq6vu"].ToString(),
+
+                        materialshortname = ydDataSource["textField_lwitq6vv"].ToString(),
+                        materialspec = ydDataSource["textField_ltxy3kh3"].ToString(),
+                        materialtype = ydDataSource["textField_ltxy3kh4"].ToString(),
+                        ematerialspec = ydDataSource["textField_lwitq6vw"].ToString(),
+                        materialmnecode = ydDataSource["textField_lwitq6vx"].ToString(),
+                    };
+
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lwitq6w4"].ToString()))
+                    {
+                        var data = pk_marbasclassDic.FirstOrDefault(f => f.name.Trim() == ydDataSource["selectField_lwitq6w4"].ToString());
+                        if (data != null)
+                        {
+                            dataSource.pk_marbasclass = data.code; // 分类
+                        }
+                    }
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lwitq6w5"].ToString()))
+                    {
+                        dataSource.pk_measdoc = pk_measdocDic.FirstOrDefault(f => f.name == ydDataSource["selectField_lwitq6w5"].ToString()).code; // 主计量单位
+                    }
+
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lwitq6w6"].ToString()))
+                    {
+                        dataSource.pk_mattaxes = pk_mattaxesDic.FirstOrDefault(f => f.mattaxesname == ydDataSource["selectField_lwitq6w6"].ToString()).mattaxescode; // 税类
+                    }
+                    //if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lwitq6we"].ToString()))
+                    //{
+                    //    dataSource.pk_brand = pk_brandDic.FirstOrDefault(f => f.name == ydDataSource["selectField_lwitq6we"].ToString()).code; // 品牌
+                    //}
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_ltxy3kh6"].ToString()))
+                    {
+
+                        switch (ydDataSource["selectField_ltxy3kh6"].ToString())
+                        {
+                            case "启用":
+                                dataSource.enablestate = ((int)EnumType.enablestate.已启用).ToString();
+                                break;
+                            case "停用":
+                                dataSource.enablestate = ((int)EnumType.enablestate.已停用).ToString();
+                                break;
+                        }
+                    }
+                    #endregion
+
+                    #region 数据传入NC并获取结果
+                    var xmlData = WL_SyncServiceModel.ImportXml.Header(dataSource, item);
+                    XElement tempData = WL_SyncServiceModel.ImportXml.TemplateHeade();
+
+                    var results = NCImportFunc.NCImport(tempData, xmlData, _NCApiUrl + "?account=LY01&groupcode=0");
+
+                    DBHelper.WriteLog($"进入程序3");
+
+                    XElement xE = XElement.Parse(results);
+                    string resultcode = xE.Element("sendresult").Element("resultcode").Value;
+                    string resultdescription = xE.Element("sendresult").Element("resultdescription")?.Value;
+                    #endregion
+
+                    #region 回写状态
+                    var ncResData = new YiDaResDto()
+                    {
+                        syncTime = DateTime.Now,
+                    };
+
+                    if (resultcode == "1")
+                    {
+                        DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作成功!");
+
+                        ncResData.bSuccess = true;
+                        ncResData.ncNo = xE.Element("sendresult").Element("content").Value;
+                        ncResData.log = "同步成功!";
+                    }
+                    else
+                    {
+                        if (resultdescription.Contains("不允许重复"))
+                        {
+                            // 已存在数据,绑定Id
+                            var nowData = _db_nc.Queryable<bd_material>().First(f => f.code == dataSource.code && f.pk_org == _Static_pk_org_jt);
+
+                            var idcData = new xx_idcontrast()
+                            {
+                                bill_type = "material",
+                                dr = 0,
+                                file_id = item,
+                                pk_bill = nowData.pk_material,
+                                pk_idcontra = _Static_PK_xx_idcontrast + newId
+                            };
+                            _db_nc.Insertable(idcData).ExecuteCommand();
+
+                            newId++;
+
+                            ncResData.bSuccess = true;
+                            ncResData.ncNo = nowData.pk_material;
+                            ncResData.log = "数据已存在,无需同步,已自动对照!";
+                        }
+                        else
+                        {
+                            DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作失败!" + resultdescription + ";");
+
+                            ncResData.bSuccess = false;
+                            ncResData.ncNo = "";
+                            ncResData.log = "同步失败!原因为【" + resultdescription + "】";
+                        }
+                    }
+
+                    var ydRes = _dingTalkService.UpdateFormDataSyncDataById(ncResData, item);
+                    #endregion
+                }
+            }
+            #endregion
+        }
+    }
+}

+ 163 - 0
HH.YiDaSyncNC/DataSync/XMD_SyncService.cs

@@ -0,0 +1,163 @@
+using HH.YiDaSyncNC.Dtos;
+using HH.YiDaSyncNC.Dtos.NC;
+using HH.YiDaSyncNC.Helper;
+using HH.YiDaSyncNC.Models;
+using Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.DataSync
+{
+    class XMD_SyncService
+    {
+        public string _AppType;
+        public string _SystemToken;
+        public string _UserId;
+        public string _FormId;
+        public SqlSugarClient _db;
+        public SqlSugarClient _db_nc;
+        public string _NCApiUrl;
+
+        public static string _Static_PK_bd_project = ConfigurationManager.AppSettings["bd_project"];
+        public static string _Static_pk_org_jt = ConfigurationManager.AppSettings["pk_org_jt"];
+
+        public XMD_SyncService(string AppType, string SystemToken, string UserId, string FormId, SqlSugarClient db, SqlSugarClient db_nc, string NCApiUrl)
+        {
+            _AppType = AppType;
+            _SystemToken = SystemToken;
+            _UserId = UserId;
+            _FormId = FormId;
+            _db = db;
+            _db_nc = db_nc;
+            _NCApiUrl = NCApiUrl;
+        }
+
+        public class IdCodeModel
+        {
+            public int sourceId { get; set; }
+            public string Id { get; set; }
+        }
+
+        public void DataSync()
+        {
+            DingTalkService _dingTalkService = new DingTalkService(_AppType, _SystemToken, _UserId, _FormId);
+
+            // 宜搭全量数据Id
+            var idList = _dingTalkService.GetModifyFormIdList();
+
+            // 获取当前最大Id
+            var newId = 100000001;
+            var maxData = _db_nc.Queryable<bd_project>().OrderByDescending(obd => obd.pk_project).First();
+            if (maxData != null && maxData.pk_project.Contains(_Static_PK_bd_project))
+            {
+                newId = Convert.ToInt32(maxData.pk_project.Replace(_Static_PK_bd_project, "")) + 1;
+            }
+
+            #region 获取NC中选项数据的Id
+            var bd_projectclassDic = _db_nc.Queryable<bd_projectclass>().ToList();
+            var bd_stordocDic = _db_nc.Queryable<bd_stordoc>().ToList();
+            #endregion
+
+            #region 循环数据处理业务逻辑
+            foreach (var item in idList)
+            {
+                // 获取此条数据详情
+                string createTime = "";
+                string modifyTime = "";
+                var ydDataSource = _dingTalkService.GetFormDataById(item, out createTime, out modifyTime);
+
+                if (ydDataSource["radioField_lycrvvtk"].ToString() == "Y")
+                {
+
+                    #region 构建数据体
+                    var data = new bd_project();
+                    data.begin_flag = "N";
+                    data.bill_type = "4D10";
+                    data.creationtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                    data.ts = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                    data.creator = "1001G1100000000B6553";
+                    data.def6 = ydDataSource["textField_lrim7i38"].ToString(); // 项目地址
+                    data.def7 = ydDataSource["textField_lrn2oy4n"].ToString(); // 体系
+                    data.enablestate = 2;
+
+
+                    data.pk_eps = "";
+                    data.pk_group = _Static_pk_org_jt;
+                    data.pk_org = _Static_pk_org_jt;
+                    // data.pk_projectclass = "";
+
+                    if (ydDataSource.FirstOrDefault(f => f.Key == "selectField_lrhjdu45").Value != null)
+                    {
+                        if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lrhjdu45"].ToString()))
+                        {
+                            var tempData = bd_projectclassDic.FirstOrDefault(f => f.type_name == ydDataSource["selectField_lrhjdu45"].ToString());
+                            if (tempData != null)
+                            {
+                                data.pk_projectclass = tempData.pk_projectclass; // 项目类型
+                            }
+                        }
+                    }
+
+                    //if (ydDataSource.FirstOrDefault(f => f.Key == "selectField_lrn2oy4c").Value != null)
+                    //{
+                    //    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lrn2oy4c"].ToString()))
+                    //    {
+                    //        var tempData = bd_stordocDic.FirstOrDefault(f => f.name == ydDataSource["selectField_lrn2oy4c"].ToString());
+                    //        if (tempData != null)
+                    //        {
+                    //            data.pk_stordoc1 = tempData.pk_stordoc; // 仓库
+                    //        }
+                    //    }
+                    //}
+
+                    data.project_code = ydDataSource["textField_ltxrn8h1"].ToString();
+                    data.project_name = ydDataSource["textField_lrr3rg6i"].ToString();
+                    data.transi_type = "4D10-01";
+
+
+
+                    #endregion
+
+                    #region 数据传入NC并获取结果
+                    var nowData = _db_nc.Queryable<bd_project>().First(f => f.project_code == data.project_code);
+                    if (nowData == null)
+                    {
+                        data.pk_project = _Static_PK_bd_project + newId;
+                        _db_nc.Insertable(data).ExecuteCommand();
+
+                        newId++;
+                    }
+                    else
+                    {
+                        data.pk_project = nowData.pk_project;
+                        _db_nc.Updateable(data).ExecuteCommand();
+                    }
+
+                    #endregion
+
+                    #region 回写状态
+                    var ncResData = new YiDaResDto()
+                    {
+                        syncTime = DateTime.Now,
+                    };
+
+                    DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作成功!");
+
+                    ncResData.bSuccess = true;
+                    ncResData.ncNo = data.pk_project;
+                    ncResData.log = "同步成功!";
+
+                    var ydRes = _dingTalkService.UpdateFormDataSyncDataById(ncResData, item);
+                    #endregion
+                }
+            }
+            #endregion
+        }
+    }
+}

+ 160 - 0
HH.YiDaSyncNC/DataSync/ZC_SyncService.cs

@@ -0,0 +1,160 @@
+using HH.YiDaSyncNC.Dtos;
+using HH.YiDaSyncNC.Dtos.NC;
+using HH.YiDaSyncNC.Helper;
+using HH.YiDaSyncNC.Models;
+using Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.DataSync
+{
+    class ZC_SyncService
+    {
+        public string _AppType;
+        public string _SystemToken;
+        public string _UserId;
+        public string _FormId;
+        public SqlSugarClient _db;
+        public SqlSugarClient _db_nc;
+        public string _NCApiUrl;
+
+        public static string _Static_PK_fa_card = ConfigurationManager.AppSettings["fa_card"];
+        public static string _Static_pk_org_jt = ConfigurationManager.AppSettings["pk_org_jt"];
+
+        public ZC_SyncService(string AppType, string SystemToken, string UserId, string FormId, SqlSugarClient db, SqlSugarClient db_nc, string NCApiUrl)
+        {
+            _AppType = AppType;
+            _SystemToken = SystemToken;
+            _UserId = UserId;
+            _FormId = FormId;
+            _db = db;
+            _db_nc = db_nc;
+            _NCApiUrl = NCApiUrl;
+        }
+
+        public class IdCodeModel
+        {
+            public int sourceId { get; set; }
+            public string Id { get; set; }
+        }
+
+        public void DataSync()
+        {
+            DingTalkService _dingTalkService = new DingTalkService(_AppType, _SystemToken, _UserId, _FormId);
+
+            // 宜搭全量数据Id
+            var idList = _dingTalkService.GetFormIdList().Where(w => w == "FINST-WBD66OB1WGIMQGPBFZAHO794LN2H3GVFOM6YLFK9");
+
+            // 获取当前最大Id
+            var newId = 100000001;
+            var maxData = _db_nc.Queryable<fa_card>().OrderByDescending(obd => Convert.ToDateTime(obd.creationtime)).First();
+            if (maxData != null && maxData.pk_card.Contains(_Static_PK_fa_card))
+            {
+                newId = Convert.ToInt32(maxData.pk_card.Replace(_Static_PK_fa_card, "")) + 1;
+            }
+
+            #region 获取NC中选项数据的Id
+            var pam_addreducestyleDic = _db_nc.Queryable<pam_addreducestyle>().ToList();
+            #endregion
+
+            // 资产部门ID textField_lydsc49c
+            // 管理部门ID textField_lydsc49b
+
+            #region 循环数据处理业务逻辑
+            foreach (var item in idList)
+            {
+                // 获取此条数据详情
+                string createTime = "";
+                string modifyTime = "";
+                var ydDataSource = _dingTalkService.GetFormDataById(item, out createTime, out modifyTime);
+
+                #region 构建数据体
+                var data = new fa_card();
+                data.archarea = 0;
+                data.asset_code = ydDataSource["textField_lty0oyv4"].ToString();
+                data.asset_name = ydDataSource["textField_lty0oyuj"].ToString();
+                data.begin_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                data.bill_source = "handin";
+                data.bill_type = "H1";
+                data.billmaker = "1001G110000000000ADH";
+                data.billmaketime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                data.business_date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                data.creationtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                data.creator = "1001G110000000000ADH";
+                data.currmoney = 0;
+                data.dismant_cost = 0;
+                data.dy_flag = "N";
+                data.install_fee = 0;
+                data.machinepower = 0;
+                data.machinequan = 0;
+                data.nettonnage = 0;
+                data.other_cost = 0;
+                data.pk_group = _Static_pk_org_jt;
+                data.pk_org = "0001G110000000001MVP";
+                data.pk_org_v = "0001G110000000001MVO";
+                data.card_code = "0000001242";
+                data.assetsuit_code = "营运部(项目)0354";
+
+                // 主键
+                data.pk_currency = "1002Z0100000000001K1";
+                data.pk_transitype = "0001G110000000001B48";
+                data.transi_type = "H1-00";
+                data.ts = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+
+
+                if (ydDataSource.FirstOrDefault(f => f.Key == "selectField_lwk48b8s").Value != null)
+                {
+                    if (!string.IsNullOrWhiteSpace(ydDataSource["selectField_lwk48b8s"].ToString()))
+                    {
+                        var tempData = pam_addreducestyleDic.FirstOrDefault(f => f.style_name == ydDataSource["selectField_lwk48b8s"].ToString());
+                        if (tempData != null)
+                        {
+                            data.pk_addreducestyle = tempData.pk_addreducestyle; // 增加方式
+                        }
+                    }
+                }
+
+                #endregion
+
+                #region 数据传入NC并获取结果
+                var nowData = _db_nc.Queryable<fa_card>().First(f => f.asset_code == data.asset_code);
+                if (nowData == null)
+                {
+                    data.pk_card = "DINGTALKFAC100000006"; //_Static_PK_fa_card + newId;
+                    _db_nc.Insertable(data).ExecuteCommand();
+
+                    newId++;
+                }
+                else
+                {
+                    data.pk_card = nowData.pk_card;
+                    _db_nc.Updateable(data).ExecuteCommand();
+                }
+
+                #endregion
+
+                #region 回写状态
+                var ncResData = new YiDaResDto()
+                {
+                    syncTime = DateTime.Now,
+                };
+
+                DBHelper.WriteLog($"Id为【{JsonConvert.SerializeObject(item)}】的单据操作成功!");
+
+                ncResData.bSuccess = true;
+                ncResData.ncNo = data.pk_card;
+                ncResData.log = "同步成功!";
+
+                var ydRes = _dingTalkService.UpdateFormDataSyncDataById(ncResData, item);
+                #endregion
+            }
+            #endregion
+        }
+    }
+}

+ 20 - 0
HH.YiDaSyncNC/Dtos/NC/EnumType.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    public class EnumType
+    {
+        #region 启用/停用
+        public enum enablestate
+        {
+            未启用 = 1,
+            已启用 = 2,
+            已停用 = 3
+        }
+        #endregion
+    }
+}

+ 27 - 0
HH.YiDaSyncNC/Dtos/NC/bd_branddoc.cs

@@ -0,0 +1,27 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_branddoc")]
+    public class bd_branddoc
+    {
+        public bd_branddoc()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public string code { get; set; }
+
+        public string name { get; set; }
+    }
+}

+ 27 - 0
HH.YiDaSyncNC/Dtos/NC/bd_custclass.cs

@@ -0,0 +1,27 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_custclass")]
+    public class bd_custclass
+    {
+        public bd_custclass()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public string code { get; set; }
+
+        public string name { get; set; }
+    }
+}

+ 28 - 0
HH.YiDaSyncNC/Dtos/NC/bd_customer.cs

@@ -0,0 +1,28 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_customer")]
+    public class bd_customer
+    {
+        public bd_customer()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_customer { get; set; }
+
+        public string code { get; set; }
+        public string name { get; set; }
+    }
+}

+ 29 - 0
HH.YiDaSyncNC/Dtos/NC/bd_defdoc.cs

@@ -0,0 +1,29 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_defdoc")]
+    public class bd_defdoc
+    {
+        public bd_defdoc()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_defdoc { get; set; }
+
+        public string code { get; set; }
+        public string name { get; set; }
+        public string pk_defdoclist { get; set; }
+    }
+}

+ 28 - 0
HH.YiDaSyncNC/Dtos/NC/bd_income.cs

@@ -0,0 +1,28 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_income")]
+    public class bd_income
+    {
+        public bd_income()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_income { get; set; }
+
+        public string code { get; set; }
+        public string name { get; set; }
+    }
+}

+ 27 - 0
HH.YiDaSyncNC/Dtos/NC/bd_marbasclass.cs

@@ -0,0 +1,27 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_marbasclass")]
+    public class bd_marbasclass
+    {
+        public bd_marbasclass()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public string code { get; set; }
+
+        public string name { get; set; }
+    }
+}

+ 27 - 0
HH.YiDaSyncNC/Dtos/NC/bd_material.cs

@@ -0,0 +1,27 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_material")]
+    public class bd_material
+    {
+        public bd_material()
+        {
+
+        }
+
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_material { get; set; }
+
+        public string code { get; set; }
+        public string name { get; set; }
+        public string pk_org { get; set; }
+
+        public string pk_measdoc { get; set; }
+    }
+}

+ 27 - 0
HH.YiDaSyncNC/Dtos/NC/bd_mattaxes.cs

@@ -0,0 +1,27 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_mattaxes")]
+    public class bd_mattaxes
+    {
+        public bd_mattaxes()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public string mattaxescode { get; set; }
+
+        public string mattaxesname { get; set; }
+    }
+}

+ 29 - 0
HH.YiDaSyncNC/Dtos/NC/bd_measdoc.cs

@@ -0,0 +1,29 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_measdoc")]
+    public class bd_measdoc
+    {
+        public bd_measdoc()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_measdoc { get; set; }
+
+        public string code { get; set; }
+
+        public string name { get; set; }
+    }
+}

+ 207 - 0
HH.YiDaSyncNC/Dtos/NC/bd_project.cs

@@ -0,0 +1,207 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_project")]
+    public class bd_project
+    {
+        public bd_project()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_project { get; set; }
+
+        public string actu_finish_date { get; set; }
+        public string actu_start_date { get; set; }
+        public int? actuduration { get; set; }
+        public string begin_flag { get; set; }
+        public string bill_type { get; set; }
+        public string check_date { get; set; }
+        public string creationstate { get; set; } = "~";
+        public string creationtime { get; set; }
+        public string creator { get; set; }
+        public string def1 { get; set; } = "~";
+        public string def10 { get; set; } = "~";
+        public string def11 { get; set; } = "~";
+        public string def12 { get; set; } = "~";
+        public string def13 { get; set; } = "~";
+        public string def14 { get; set; } = "~";
+        public string def15 { get; set; } = "~";
+        public string def16 { get; set; } = "~";
+        public string def17 { get; set; } = "~";
+        public string def18 { get; set; } = "~";
+        public string def19 { get; set; } = "~";
+        public string def2 { get; set; } = "~";
+        public string def20 { get; set; } = "~";
+        public string def21 { get; set; } = "~";
+        public string def22 { get; set; } = "~";
+        public string def23 { get; set; } = "~";
+        public string def24 { get; set; } = "~";
+        public string def25 { get; set; } = "~";
+        public string def26 { get; set; } = "~";
+        public string def27 { get; set; } = "~";
+        public string def28 { get; set; } = "~";
+        public string def29 { get; set; } = "~";
+        public string def3 { get; set; } = "~";
+        public string def30 { get; set; } = "~";
+        public string def31 { get; set; } = "~";
+        public string def32 { get; set; } = "~";
+        public string def33 { get; set; } = "~";
+        public string def34 { get; set; } = "~";
+        public string def35 { get; set; } = "~";
+        public string def36 { get; set; } = "~";
+        public string def37 { get; set; } = "~";
+        public string def38 { get; set; } = "~";
+        public string def39 { get; set; } = "~";
+        public string def4 { get; set; } = "~";
+        public string def40 { get; set; } = "~";
+        public string def41 { get; set; } = "~";
+        public string def42 { get; set; } = "~";
+        public string def43 { get; set; } = "~";
+        public string def44 { get; set; } = "~";
+        public string def45 { get; set; } = "~";
+        public string def46 { get; set; } = "~";
+        public string def47 { get; set; } = "~";
+        public string def48 { get; set; } = "~";
+        public string def49 { get; set; } = "~";
+        public string def5 { get; set; } = "~";
+        public string def50 { get; set; } = "~";
+        public string def6 { get; set; }
+        public string def7 { get; set; } = "~";
+        public string def8 { get; set; } = "~";
+        public string def9 { get; set; } = "~";
+        public int? deletestate { get; set; }
+        public string delperson { get; set; } = "~";
+        public string deltime { get; set; }
+        public Int16? dr { get; set; } = 0;
+        public int? enablestate { get; set; }
+        public decimal? estimate_global { get; set; }
+        public decimal? estimate_group { get; set; }
+        public decimal? estimate_mny { get; set; }
+        public string finish_work_date { get; set; }
+        public decimal? general_global { get; set; }
+        public decimal? general_group { get; set; }
+        public decimal? general_mny { get; set; }
+        public string hdef100 { get; set; }  = "~";
+        public string hdef51 { get; set; }   = "~";
+        public string hdef52 { get; set; }   = "~";
+        public string hdef53 { get; set; }   = "~";
+        public string hdef54 { get; set; }   = "~";
+        public string hdef55 { get; set; }   = "~";
+        public string hdef56 { get; set; }   = "~";
+        public string hdef57 { get; set; }   = "~";
+        public string hdef58 { get; set; }   = "~";
+        public string hdef59 { get; set; }   = "~";
+        public string hdef60 { get; set; }   = "~";
+        public string hdef61 { get; set; }   = "~";
+        public string hdef62 { get; set; }   = "~";
+        public string hdef63 { get; set; }   = "~";
+        public string hdef64 { get; set; }   = "~";
+        public string hdef65 { get; set; }   = "~";
+        public string hdef66 { get; set; }   = "~";
+        public string hdef67 { get; set; }   = "~";
+        public string hdef68 { get; set; }   = "~";
+        public string hdef69 { get; set; }   = "~";
+        public string hdef70 { get; set; }   = "~";
+        public string hdef71 { get; set; }   = "~";
+        public string hdef72 { get; set; }   = "~";
+        public string hdef73 { get; set; }   = "~";
+        public string hdef74 { get; set; }   = "~";
+        public string hdef75 { get; set; }   = "~";
+        public string hdef76 { get; set; }   = "~";
+        public string hdef77 { get; set; }   = "~";
+        public string hdef78 { get; set; }   = "~";
+        public string hdef79 { get; set; }   = "~";
+        public string hdef80 { get; set; }   = "~";
+        public string hdef81 { get; set; }   = "~";
+        public string hdef82 { get; set; }   = "~";
+        public string hdef83 { get; set; }   = "~";
+        public string hdef84 { get; set; }   = "~";
+        public string hdef85 { get; set; }   = "~";
+        public string hdef86 { get; set; }   = "~";
+        public string hdef87 { get; set; }   = "~";
+        public string hdef88 { get; set; }   = "~";
+        public string hdef89 { get; set; }   = "~";
+        public string hdef90 { get; set; }   = "~";
+        public string hdef91 { get; set; }   = "~";
+        public string hdef92 { get; set; }   = "~";
+        public string hdef93 { get; set; }   = "~";
+        public string hdef94 { get; set; }   = "~";
+        public string hdef95 { get; set; }   = "~";
+        public string hdef96 { get; set; }   = "~";
+        public string hdef97 { get; set; }   = "~";
+        public string hdef98 { get; set; }   = "~";
+        public string hdef99 { get; set; } = "~";
+        public string memo { get; set; }
+        public string modifiedtime { get; set; }
+        public string modifier { get; set; } = "~";
+        public string order_finish_date { get; set; }
+        public string order_start_date { get; set; }
+        public int? orderduration { get; set; }
+        public int? ordermethod { get; set; }
+        public string pk_busitype { get; set; }      = "~";
+        public string pk_currtype { get; set; }      = "~";
+        public string pk_dutier { get; set; }        = "~";
+        public string pk_duty_dept { get; set; }     = "~";
+        public string pk_duty_dept_v { get; set; }   = "~";
+        public string pk_duty_org { get; set; }      = "~";
+        public string pk_duty_org_v { get; set; }    = "~";
+        public string pk_eps { get; set; }           = "~";
+        public string pk_group { get; set; }         = "~";
+        public string pk_org { get; set; }           = "~";
+        public string pk_org_v { get; set; } = "~";
+        public string pk_parentpro { get; set; } = "~";
+        public string pk_parenttask { get; set; }    = "~";
+        public string pk_planmaker { get; set; }     = "~";
+
+        public string pk_projectclass { get; set; }
+        public string pk_projectstate { get; set; } = "~";
+        public string pk_transitype { get; set; }      = "~";
+        public string pk_wbstemplate { get; set; }     = "~";
+        public string pk_workcalendar { get; set; } = "~";
+        public string pk_yearplan_b { get; set; }
+        public int? plan_auth { get; set; }
+        public string plan_finish_date { get; set; }
+        public string plan_start_date { get; set; }
+        public int? planduration { get; set; }
+        public int? planmodel { get; set; }
+        public int? planpriority { get; set; }
+        public string project_code { get; set; }
+        public string project_name { get; set; }
+        public string project_name2 { get; set; }
+        public string project_name3 { get; set; }
+        public string project_name4 { get; set; }
+        public string project_name5 { get; set; }
+        public string project_name6 { get; set; }
+        public string project_ot_name { get; set; }
+        public string project_sh_name { get; set; }
+        public string req_finish_date { get; set; }
+        public string req_start_date { get; set; }
+        public int? reqduration { get; set; }
+        public string src_bill_code { get; set; }
+        public string src_bill_type { get; set; }
+        public string src_pk_bill { get; set; } = "~";
+        public string src_pk_transitype { get; set; }
+        public string src_transi_type { get; set; }
+        public string start_work_date { get; set; }
+        public string status_date { get; set; }
+        public string tax_flag { get; set; } = "N";
+        public string transi_type { get; set; }
+        public string ts { get; set; }
+        public string upload_flag { get; set; } = "N";
+        public string pk_stordoc1 { get; set; }
+
+
+    }
+}

+ 28 - 0
HH.YiDaSyncNC/Dtos/NC/bd_projectclass.cs

@@ -0,0 +1,28 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_projectclass")]
+    public class bd_projectclass
+    {
+        public bd_projectclass()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_projectclass { get; set; }
+
+        public string type_code { get; set; }
+        public string type_name { get; set; }
+    }
+}

+ 30 - 0
HH.YiDaSyncNC/Dtos/NC/bd_psndoc.cs

@@ -0,0 +1,30 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_psndoc")]
+    public class bd_psndoc
+    {
+        public bd_psndoc()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_psndoc { get; set; }
+
+        public string code { get; set; }
+        public string name { get; set; }
+
+
+    }
+}

+ 28 - 0
HH.YiDaSyncNC/Dtos/NC/bd_stordoc.cs

@@ -0,0 +1,28 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_stordoc")]
+    public class bd_stordoc
+    {
+        public bd_stordoc()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_stordoc { get; set; }
+
+        public string code { get; set; }
+        public string name { get; set; }
+    }
+}

+ 29 - 0
HH.YiDaSyncNC/Dtos/NC/bd_supplier.cs

@@ -0,0 +1,29 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_supplier")]
+    public class bd_supplier
+    {
+        public bd_supplier()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public string pk_supplier { get; set; }
+
+        public string pk_org { get; set; }
+        public string code { get; set; }
+        public string name { get; set; }
+    }
+}

+ 27 - 0
HH.YiDaSyncNC/Dtos/NC/bd_supplierclass.cs

@@ -0,0 +1,27 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("bd_supplierclass")]
+    public class bd_supplierclass
+    {
+        public bd_supplierclass()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public string code { get; set; }
+
+        public string name { get; set; }
+    }
+}

+ 104 - 0
HH.YiDaSyncNC/Dtos/NC/fa_card.cs

@@ -0,0 +1,104 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("fa_card")]
+    public class fa_card
+    {
+        public fa_card()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_card { get; set; }
+
+        public decimal? archarea { get; set; }
+        public string asset_code { get; set; }
+        public string asset_name { get; set; }
+        public string asset_name2 { get; set; }
+        public string asset_name3 { get; set; }
+        public string asset_name4 { get; set; }
+        public string asset_name5 { get; set; }
+        public string asset_name6 { get; set; }
+        public string assetsuit_code { get; set; }
+        public string bar_code { get; set; }
+        public string begin_date { get; set; }
+        public string bill_code_src { get; set; }
+        public string bill_source { get; set; }
+        public string bill_type { get; set; }
+        public string billmaker { get; set; }
+        public string billmaketime { get; set; }
+        public string business_date { get; set; }
+        public string card_code { get; set; }
+        public string card_model { get; set; }
+        public string close_date { get; set; }
+        public string contrator { get; set; }
+        public string creationtime { get; set; }
+        public string creator { get; set; }
+        public decimal? currmoney { get; set; }
+        public string deploy_flag { get; set; }
+        public decimal? dismant_cost { get; set; }
+        public Int16? dr { get; set; } = 0;
+        public string dy_flag { get; set; }
+        public string fundorigin { get; set; }
+        public decimal? install_fee { get; set; }
+        public string leave_date { get; set; }
+        public string license { get; set; }
+        public decimal? machinepower { get; set; }
+        public int machinequan { get; set; }
+        public string measureunit { get; set; } = "~";
+        public string modifiedtime { get; set; } = "~";
+        public string modifier { get; set; } = "~";
+        public decimal? nettonnage { get; set; }
+        public decimal? other_cost { get; set; }
+        public string pk_addreducestyle { get; set; }
+        public string pk_assetgroup { get; set; } = "~";
+        public string pk_assetuser { get; set; } = "~";
+        public string pk_bill_b_src { get; set; } = "~";
+        public string pk_bill_source { get; set; } = "~";
+        public string pk_bill_src { get; set; } = "~";
+
+        public string pk_currency { get; set; }
+        public string pk_equip { get; set; } = "~";
+        public string pk_equip_usedept { get; set; } = "~";
+        public string pk_equip_usedept_v { get; set; } = "~";
+        public string pk_group { get; set; }
+        public string pk_org { get; set; }
+        public string pk_org_v { get; set; }
+        public string pk_raorg { get; set; } = "~";
+        public string pk_raorg_v { get; set; } = "~";
+        public string pk_receipt { get; set; } = "~";
+        public string pk_transitype { get; set; }
+        public string pk_user { get; set; } = "~";
+        public string position { get; set; }
+        public string position2 { get; set; }
+        public string position3 { get; set; }
+        public string position4 { get; set; }
+        public string position5 { get; set; }
+        public string position6 { get; set; }
+        public string producer { get; set; }
+        public string provider { get; set; } = "~";
+        public int quantity { get; set; } = 0;
+        public decimal? revalued_amount { get; set; } = 0;
+        public decimal? soilarea { get; set; } = 0;
+        public string soillevel { get; set; }
+        public string spec { get; set; }
+        public decimal? tax_cost { get; set; } = 0;
+        public string transi_type { get; set; }
+        public string ts { get; set; }
+        public string workcenter { get; set; } = "~";
+
+
+
+    }
+}

+ 30 - 0
HH.YiDaSyncNC/Dtos/NC/org_dept.cs

@@ -0,0 +1,30 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("org_dept")]
+    public class org_dept
+    {
+        public org_dept()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_dept { get; set; }
+
+        public string code { get; set; }
+        public string name { get; set; }
+
+
+    }
+}

+ 28 - 0
HH.YiDaSyncNC/Dtos/NC/org_orgs.cs

@@ -0,0 +1,28 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("org_orgs")]
+    public class org_orgs
+    {
+        public org_orgs()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_org { get; set; }
+
+        public string code { get; set; }
+        public string name { get; set; }
+    }
+}

+ 28 - 0
HH.YiDaSyncNC/Dtos/NC/pam_addreducestyle.cs

@@ -0,0 +1,28 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("pam_addreducestyle")]
+    public class pam_addreducestyle
+    {
+        public pam_addreducestyle()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_addreducestyle { get; set; }
+
+        public string style_code { get; set; }
+        public string style_name { get; set; }
+    }
+}

+ 29 - 0
HH.YiDaSyncNC/Dtos/NC/po_order.cs

@@ -0,0 +1,29 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("po_order")]
+    public class po_order
+    {
+        public po_order()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_order { get; set; }
+
+        public string approver { get; set; } = "~";
+        public string forderstatus { get; set; }
+        public string taudittime { get; set; }
+    }
+}

+ 35 - 0
HH.YiDaSyncNC/Dtos/NC/po_order_b.cs

@@ -0,0 +1,35 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("po_order_b")]
+    public class po_order_b
+    {
+        public po_order_b()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_order_b { get; set; }
+
+        public string pk_order { get; set; } = "~";
+
+        public string pk_group { get; set; } = "~";
+        public string pk_org { get; set; } = "~";
+        public string pk_org_v { get; set; } = "~";
+
+        public decimal? nastnum { get; set; }
+
+        public string dplanarrvdate { get; set; }
+    }
+}

+ 131 - 0
HH.YiDaSyncNC/Dtos/NC/po_order_bb.cs

@@ -0,0 +1,131 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("po_order_bb")]
+    public class po_order_bb
+    {
+        public po_order_bb()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_order_bb { get; set; }
+
+        public string ccarrier { get; set; } = "~";
+        public string ccasecode { get; set; }
+        public string clandport { get; set; } = "~";
+        public string cloadport { get; set; } = "~";
+        public string cshipline { get; set; } = "~";
+        public string cshipname { get; set; }
+        public string dbilldate { get; set; }
+        public string dplanarrvdate { get; set; }
+        public string dplanfreightdate { get; set; }
+        public Int16? dr { get; set; } = 0;
+        public int? fonwaystatus { get; set; } = 8;
+        public string isoperated { get; set; } = "N";
+
+        public decimal? nmaxhandlenum { get; set; }
+        public decimal? nonwaynum { get; set; }
+        public string pk_group { get; set; }
+        public string pk_order { get; set; }
+        public string pk_order_b { get; set; }
+        public string pk_org { get; set; }
+        public string pk_org_v { get; set; }
+        public string ts { get; set; }
+
+        public string vbdef1 { get; set; } = "~";
+        public string vbdef10 { get; set; } = "~";
+        public string vbdef11 { get; set; } = "~";
+        public string vbdef12 { get; set; } = "~";
+        public string vbdef13 { get; set; } = "~";
+        public string vbdef14 { get; set; } = "~";
+        public string vbdef15 { get; set; } = "~";
+        public string vbdef16 { get; set; } = "~";
+        public string vbdef17 { get; set; } = "~";
+        public string vbdef18 { get; set; } = "~";
+        public string vbdef19 { get; set; } = "~";
+        public string vbdef2 { get; set; } = "~";
+        public string vbdef20 { get; set; } = "~";
+        public string vbdef21 { get; set; } = "~";
+        public string vbdef22 { get; set; } = "~";
+        public string vbdef23 { get; set; } = "~";
+        public string vbdef24 { get; set; } = "~";
+        public string vbdef25 { get; set; } = "~";
+        public string vbdef26 { get; set; } = "~";
+        public string vbdef27 { get; set; } = "~";
+        public string vbdef28 { get; set; } = "~";
+        public string vbdef29 { get; set; } = "~";
+        public string vbdef3 { get; set; } = "~";
+        public string vbdef30 { get; set; } = "~";
+        public string vbdef31 { get; set; } = "~";
+        public string vbdef32 { get; set; } = "~";
+        public string vbdef33 { get; set; } = "~";
+        public string vbdef34 { get; set; } = "~";
+        public string vbdef35 { get; set; } = "~";
+        public string vbdef36 { get; set; } = "~";
+        public string vbdef37 { get; set; } = "~";
+        public string vbdef38 { get; set; } = "~";
+        public string vbdef39 { get; set; } = "~";
+        public string vbdef4 { get; set; } = "~";
+        public string vbdef40 { get; set; } = "~";
+        public string vbdef5 { get; set; } = "~";
+        public string vbdef6 { get; set; } = "~";
+        public string vbdef7 { get; set; } = "~";
+        public string vbdef8 { get; set; } = "~";
+        public string vbdef9 { get; set; } = "~";
+        public string vbillcode { get; set; }
+        public string vhdef1 { get; set; } = "~";
+        public string vhdef10 { get; set; } = "~";
+        public string vhdef11 { get; set; } = "~";
+        public string vhdef12 { get; set; } = "~";
+        public string vhdef13 { get; set; } = "~";
+        public string vhdef14 { get; set; } = "~";
+        public string vhdef15 { get; set; } = "~";
+        public string vhdef16 { get; set; } = "~";
+        public string vhdef17 { get; set; } = "~";
+        public string vhdef18 { get; set; } = "~";
+        public string vhdef19 { get; set; } = "~";
+        public string vhdef2 { get; set; } = "~";
+        public string vhdef20 { get; set; } = "~";
+        public string vhdef21 { get; set; } = "~";
+        public string vhdef22 { get; set; } = "~";
+        public string vhdef23 { get; set; } = "~";
+        public string vhdef24 { get; set; } = "~";
+        public string vhdef25 { get; set; } = "~";
+        public string vhdef26 { get; set; } = "~";
+        public string vhdef27 { get; set; } = "~";
+        public string vhdef28 { get; set; } = "~";
+        public string vhdef29 { get; set; } = "~";
+        public string vhdef3 { get; set; } = "~";
+        public string vhdef30 { get; set; } = "~";
+        public string vhdef31 { get; set; } = "~";
+        public string vhdef32 { get; set; } = "~";
+        public string vhdef33 { get; set; } = "~";
+        public string vhdef34 { get; set; } = "~";
+        public string vhdef35 { get; set; } = "~";
+        public string vhdef36 { get; set; } = "~";
+        public string vhdef37 { get; set; } = "~";
+        public string vhdef38 { get; set; } = "~";
+        public string vhdef39 { get; set; } = "~";
+        public string vhdef4 { get; set; } = "~";
+        public string vhdef40 { get; set; } = "~";
+        public string vhdef5 { get; set; } = "~";
+        public string vhdef6 { get; set; } = "~";
+        public string vhdef7 { get; set; } = "~";
+        public string vhdef8 { get; set; } = "~";
+        public string vhdef9 { get; set; } = "~";
+        public string vvendororderrow { get; set; }
+
+    }
+}

+ 30 - 0
HH.YiDaSyncNC/Dtos/NC/sm_user.cs

@@ -0,0 +1,30 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("sm_user")]
+    public class sm_user
+    {
+        public sm_user()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string cuserid { get; set; }
+
+        public string user_code { get; set; }
+        public string user_name { get; set; }
+
+
+    }
+}

+ 25 - 0
HH.YiDaSyncNC/Dtos/NC/so_saleinvoice.cs

@@ -0,0 +1,25 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("so_saleinvoice")]
+    public class so_saleinvoice
+    {
+        public so_saleinvoice()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string csaleinvoiceid { get; set; }
+    }
+}

+ 48 - 0
HH.YiDaSyncNC/Dtos/NC/so_saleinvoice_b.cs

@@ -0,0 +1,48 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("so_saleinvoice_b")]
+    public class so_saleinvoice_b
+    {
+        public so_saleinvoice_b()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string csaleinvoicebid { get; set; }
+
+        public string csaleinvoiceid { get; set; }
+
+        public string vbdef1 { get; set; } = "~";
+        public string vbdef10 { get; set; } = "~";
+        public string vbdef11 { get; set; } = "~";
+        public string vbdef12 { get; set; } = "~";
+        public string vbdef13 { get; set; } = "~";
+        public string vbdef14 { get; set; } = "~";
+        public string vbdef15 { get; set; } = "~";
+        public string vbdef16 { get; set; } = "~";
+        public string vbdef17 { get; set; } = "~";
+        public string vbdef18 { get; set; } = "~";
+        public string vbdef19 { get; set; } = "~";
+        public string vbdef2 { get; set; } = "~";
+        public string vbdef20 { get; set; } = "~";
+        public string vbdef3 { get; set; } = "~";
+        public string vbdef4 { get; set; } = "~";
+        public string vbdef5 { get; set; } = "~";
+        public string vbdef6 { get; set; } = "~";
+        public string vbdef7 { get; set; } = "~";
+        public string vbdef8 { get; set; } = "~";
+        public string vbdef9 { get; set; } = "~";
+    }
+}

+ 117 - 0
HH.YiDaSyncNC/Dtos/NC/so_saleorder.cs

@@ -0,0 +1,117 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("so_saleorder")]
+    public class so_saleorder
+    {
+        public so_saleorder()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string csaleorderid { get; set; }
+
+        public string approver { get; set; } = "~";
+        public string badvfeeflag { get; set; }
+        public string barsettleflag { get; set; }
+        public string bcooptopoflag { get; set; }
+        public string bcostsettleflag { get; set; }
+        public string bfreecustflag { get; set; }
+        public string billmaker { get; set; }
+        public string binvoicendflag { get; set; }
+        public string boffsetflag { get; set; }
+        public string boutendflag { get; set; }
+        public string bpocooptomeflag { get; set; }
+        public string bpreceiveflag { get; set; }
+        public string bsendendflag { get; set; }
+        public string carsubtypeid { get; set; } = "~";
+        public string cbalancetypeid { get; set; } = "~";
+        public string cbillsrcid { get; set; } = "~";
+        public string cbiztypeid { get; set; }
+        public string cchanneltypeid { get; set; } = "~";
+        public string ccustbankaccid { get; set; } = "~";
+        public string ccustbankid { get; set; } = "~";
+        public string ccustomerid { get; set; }
+        public string cdeptid { get; set; }
+        public string cdeptvid { get; set; }
+        public string cemployeeid { get; set; } = "~";
+        public string cfreecustid { get; set; } = "~";
+        public string chreceiveaddid { get; set; } = "~";
+        public string chreceivecustid { get; set; }
+        public string cinvoicecustid { get; set; }
+        public string corigcurrencyid { get; set; }
+        public string cpaytermid { get; set; }
+        public string creationtime { get; set; }
+        public string creator { get; set; }
+        public string creviserid { get; set; } = "~";
+        public string ctradewordid { get; set; } = "~";
+        public string ctransporttypeid { get; set; } = "~";
+        public string ctrantypeid { get; set; }
+        public string dbilldate { get; set; }
+        public string dmakedate { get; set; }
+        public Int16? dr { get; set; }
+        public Int16? fpfstatusflag { get; set; }
+        public Int16? fstatusflag { get; set; }
+        public int? iprintcount { get; set; }
+        public int? iversion { get; set; }
+        public string modifiedtime { get; set; }
+        public string modifier { get; set; } = "~";
+        public decimal? ndiscountrate { get; set; }
+        public decimal? nlrgtotalorigmny { get; set; }
+        public decimal? npreceivemny { get; set; }
+        public decimal? npreceivequota { get; set; }
+        public decimal? npreceiverate { get; set; }
+        public decimal? nreceivedmny { get; set; }
+        public decimal? ntotalnum { get; set; }
+        public decimal? ntotalorigmny { get; set; }
+        public decimal? ntotalorigsubmny { get; set; }
+        public decimal? ntotalpiece { get; set; }
+        public decimal? ntotalvolume { get; set; }
+        public decimal? ntotalweight { get; set; }
+        public string pk_group { get; set; }
+        public string pk_org { get; set; }
+        public string pk_org_v { get; set; }
+        public string taudittime { get; set; }
+        public string trevisetime { get; set; }
+        public string ts { get; set; }
+        public string vbillcode { get; set; }
+        public string vbillsrctype { get; set; } = "~";
+        public string vcooppohcode { get; set; }
+        public string vcreditnum { get; set; } = "~";
+        public string vdef1 { get; set; }
+        public string vdef10 { get; set; }   = "~";
+        public string vdef11 { get; set; }   = "~";
+        public string vdef12 { get; set; }   = "~";
+        public string vdef13 { get; set; }   = "~";
+        public string vdef14 { get; set; }   = "~";
+        public string vdef15 { get; set; }   = "~";
+        public string vdef16 { get; set; }   = "~";
+        public string vdef17 { get; set; }   = "~";
+        public string vdef18 { get; set; }   = "~";
+        public string vdef19 { get; set; }   = "~";
+        public string vdef2 { get; set; }    = "~";
+        public string vdef20 { get; set; }   = "~";
+        public string vdef3 { get; set; } = "~";
+        public string vdef4 { get; set; }
+        public string vdef5 { get; set; }
+        public string vdef6 { get; set; } = "~";
+        public string vdef7 { get; set; } = "~";
+        public string vdef8 { get; set; }
+        public string vdef9 { get; set; } = "~";
+        public string vnote { get; set; }
+        public string vrevisereason { get; set; }
+        public string vtrantypecode { get; set; }
+
+    }
+}

+ 210 - 0
HH.YiDaSyncNC/Dtos/NC/so_saleorder_b.cs

@@ -0,0 +1,210 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("so_saleorder_b")]
+    public class so_saleorder_b
+    {
+        public so_saleorder_b()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string csaleorderbid { get; set; }
+
+        public string barrangedflag { get; set; } = "~";
+        public string bbarsettleflag { get; set; } = "~";
+        public string bbcostsettleflag { get; set; } = "~";
+        public string bbindflag { get; set; } = "~";
+        public string bbinvoicendflag { get; set; } = "~";
+        public string bboutendflag { get; set; } = "~";
+        public string bbsendendflag { get; set; } = "~";
+        public string bdiscountflag { get; set; } = "~";
+        public string bjczxsflag { get; set; } = "~";
+        public string blaborflag { get; set; } = "~";
+        public string blargessflag { get; set; } = "~";
+        public string blrgcashflag { get; set; } = "~";
+        public string btriatradeflag { get; set; } = "~";
+        public string carorgid { get; set; } = "~";
+        public string carorgvid { get; set; } = "~";
+        public string carrangepersonid { get; set; } = "~";
+        public string castunitid { get; set; } = "~";
+        public string cbindsrcid { get; set; } = "~";
+        public string cbuylargessactid { get; set; } = "~";
+        public string cbuylargessid { get; set; } = "~";
+        public string cbuypromottypeid { get; set; } = "~";
+        public string cctmanagebid { get; set; } = "~";
+        public string cctmanageid { get; set; } = "~";
+        public string ccurrencyid { get; set; } = "~";
+        public string ccustmaterialid { get; set; } = "~";
+        public string cexchangesrcretid { get; set; } = "~";
+        public string cfactoryid { get; set; } = "~";
+        public string cfirstbid { get; set; } = "~";
+        public string cfirstid { get; set; } = "~";
+        public string clargesssrcid { get; set; } = "~";
+        public string cmaterialid { get; set; } = "~";
+        public string cmaterialvid { get; set; } = "~";
+        public string cmffileid { get; set; } = "~";
+        public string corigareaid { get; set; } = "~";
+        public string corigcountryid { get; set; } = "~";
+        public string cprcpromottypeid { get; set; } = "~";
+        public string cpriceformid { get; set; } = "~";
+        public string cpriceitemid { get; set; } = "~";
+        public string cpriceitemtableid { get; set; } = "~";
+        public string cpricepolicyid { get; set; } = "~";
+        public string cpricepromtactid { get; set; } = "~";
+        public string cprodlineid { get; set; } = "~";
+        public string cproductorid { get; set; } = "~";
+        public string cprofitcenterid { get; set; } = "~";
+        public string cprofitcentervid { get; set; } = "~";
+        public string cprojectid { get; set; } = "~";
+        public string cpromotpriceid { get; set; } = "~";
+        public string cqtunitid { get; set; } = "~";
+        public string cqualitylevelid { get; set; } = "~";
+        public string crececountryid { get; set; } = "~";
+        public string creceiveadddocid { get; set; } = "~";
+        public string creceiveaddrid { get; set; } = "~";
+        public string creceiveareaid { get; set; } = "~";
+        public string creceivecustid { get; set; } = "~";
+        public string cretpolicyid { get; set; } = "~";
+        public string cretreasonid { get; set; } = "~";
+        public string crowno { get; set; } = "~";
+                                                            
+        public string csaleorderid { get; set; } = "~";
+        public string csendcountryid { get; set; } = "~";
+        public string csendstockorgid { get; set; } = "~";
+        public string csendstockorgvid { get; set; } = "~";
+        public string csendstordocid { get; set; } = "~";
+        public string csettleorgid { get; set; } = "~";
+        public string csettleorgvid { get; set; } = "~";
+        public string csprofitcenterid { get; set; } = "~";
+        public string csprofitcentervid { get; set; } = "~";
+        public string csrcbid { get; set; } = "~";
+        public string csrcid { get; set; } = "~";
+        public string ctaxcodeid { get; set; } = "~";
+        public string ctaxcountryid { get; set; } = "~";
+        public string ctrafficorgid { get; set; } = "~";
+        public string ctrafficorgvid { get; set; } = "~";
+        public string cunitid { get; set; } = "~";
+        public string cvendorid { get; set; } = "~";
+        public string dbilldate { get; set; } = "~";
+        public Int16? dr { get; set; } = 0;
+        public string dreceivedate { get; set; } = "~";
+        public string dsenddate { get; set; } = "~";
+        public int? fbuysellflag { get; set; }
+        public int? flargesstypeflag { get; set; }
+        public int? fretexchange { get; set; } = 0;
+        public int? frowstatus { get; set; } = 1;
+        public int? ftaxtypeflag { get; set; }
+        public decimal? naccprice { get; set; }
+        public decimal? naskqtorignetprice { get; set; }
+        public decimal? naskqtorigprice { get; set; }
+        public decimal? naskqtorigtaxprc { get; set; }
+        public decimal? naskqtorigtxntprc { get; set; }
+        public decimal? nastnum { get; set; }
+        public decimal? ncaltaxmny { get; set; }
+        public decimal? ndiscount { get; set; }
+        public decimal? ndiscountrate { get; set; }
+        public decimal? nexchangerate { get; set; }
+        public decimal? nglobalexchgrate { get; set; }
+        public decimal? nglobalmny { get; set; }
+        public decimal? nglobaltaxmny { get; set; }
+        public decimal? ngroupexchgrate { get; set; }
+        public decimal? ngroupmny { get; set; }
+        public decimal? ngrouptaxmny { get; set; }
+        public decimal? nitemdiscountrate { get; set; }
+        public decimal? nlargessmny { get; set; }
+        public decimal? nlargesstaxmny { get; set; }
+        public decimal? nmffileprice { get; set; }
+        public decimal? nmny { get; set; }
+        public decimal? nnetprice { get; set; }
+        public decimal? nnum { get; set; }
+        public decimal? norigdiscount { get; set; }
+        public decimal? norigmny { get; set; }
+        public decimal? norignetprice { get; set; }
+        public decimal? norigprice { get; set; }
+        public decimal? norigtaxmny { get; set; }
+        public decimal? norigtaxnetprice { get; set; }
+        public decimal? norigtaxprice { get; set; }
+        public decimal? npiece { get; set; }
+        public decimal? nprice { get; set; }
+        public decimal? nqtnetprice { get; set; }
+        public decimal? nqtorignetprice { get; set; }
+        public decimal? nqtorigprice { get; set; }
+        public decimal? nqtorigtaxnetprc { get; set; }
+        public decimal? nqtorigtaxprice { get; set; }
+        public decimal? nqtprice { get; set; }
+        public decimal? nqttaxnetprice { get; set; }
+        public decimal? nqttaxprice { get; set; }
+        public decimal? nqtunitnum { get; set; }
+        public decimal? ntax { get; set; }
+        public decimal? ntaxmny { get; set; }
+        public decimal? ntaxnetprice { get; set; }
+        public decimal? ntaxprice { get; set; }
+        public decimal? ntaxrate { get; set; }
+        public decimal? nvolume { get; set; }
+        public decimal? nweight { get; set; }
+        public string pk_batchcode { get; set; } = "~";
+        public string pk_group { get; set; } = "~";
+        public string pk_org { get; set; } = "~";
+        public string tlastarrangetime { get; set; }
+        public string ts { get; set; }
+        public string vbatchcode { get; set; }
+        public string vbdef1 { get; set; } = "~";
+        public string vbdef10 { get; set; } = "~";
+        public string vbdef11 { get; set; } = "~";
+        public string vbdef12 { get; set; } = "~";
+        public string vbdef13 { get; set; } = "~";
+        public string vbdef14 { get; set; } = "~";
+        public string vbdef15 { get; set; } = "~";
+        public string vbdef16 { get; set; } = "~";
+        public string vbdef17 { get; set; } = "~";
+        public string vbdef18 { get; set; } = "~";
+        public string vbdef19 { get; set; } = "~";
+        public string vbdef2 { get; set; } = "~";
+        public string vbdef20 { get; set; } = "~";
+        public string vbdef3 { get; set; } = "~";
+        public string vbdef4 { get; set; } = "~";
+        public string vbdef5 { get; set; } = "~";
+        public string vbdef6 { get; set; } = "~";
+        public string vbdef7 { get; set; } = "~";
+        public string vbdef8 { get; set; } = "~";
+        public string vbdef9 { get; set; } = "~";
+        public string vbrevisereason { get; set; }
+        public string vchangerate { get; set; } = "~";
+        public string vclosereason { get; set; }
+        public string vctcode { get; set; } 
+        public string vcustombillcode { get; set; } 
+        public string vfirstcode { get; set; } 
+        public string vfirstrowno { get; set; } = "~";
+        public string vfirsttrantype { get; set; } = "~";
+        public string vfirsttype { get; set; } = "~";
+        public string vfree1 { get; set; } = "~";
+        public string vfree10 { get; set; } = "~";
+        public string vfree2 { get; set; } = "~";
+        public string vfree3 { get; set; } = "~";
+        public string vfree4 { get; set; } = "~";
+        public string vfree5 { get; set; } = "~";
+        public string vfree6 { get; set; } = "~";
+        public string vfree7 { get; set; } = "~";
+        public string vfree8 { get; set; } = "~";
+        public string vfree9 { get; set; } = "~";
+        public string vqtunitrate { get; set; } = "~";
+        public string vreturnmode { get; set; } 
+        public string vrownote { get; set; } = "~";
+        public string vsrccode { get; set; } 
+        public string vsrcrowno { get; set; } = "~";
+        public string vsrctrantype { get; set; } = "~";
+        public string vsrctype { get; set; } = "~";
+    }
+}

+ 22 - 0
HH.YiDaSyncNC/Dtos/NC/so_saleorder_exe.cs

@@ -0,0 +1,22 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("so_saleorder_exe")]
+    public class so_saleorder_exe
+    {
+        public so_saleorder_exe()
+        {
+
+        }
+
+        public string csaleorderbid { get; set; } = "~";
+        public Int16? dr { get; set; } = 0;
+        public string ts { get; set; } = "~";
+    }
+}

+ 29 - 0
HH.YiDaSyncNC/Dtos/NC/so_squareinv_d.cs

@@ -0,0 +1,29 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    [SugarTable("so_squareinv_d")]
+    public class so_squareinv_d
+    {
+        public so_squareinv_d()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string csalesquaredid { get; set; }
+
+        public string csquarebillbid { get; set; }
+
+        public string csquarebillid { get; set; }
+    }
+}

+ 39 - 0
HH.YiDaSyncNC/Dtos/NC/xx_idcontrast.cs

@@ -0,0 +1,39 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos.NC
+{
+    /// <summary>
+    /// ID对照表
+    /// </summary>
+    [SugarTable("xx_idcontrast")]
+    public class xx_idcontrast
+    {
+        public xx_idcontrast()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true)]
+        public string pk_idcontra { get; set; }
+
+        public string bill_type { get; set; }
+        public Int16? dr { get; set; } = 0;
+        public string file_id { get; set; }
+        public string isdelete { get; set; }
+        public string pk_bill { get; set; }
+
+        public string sub_mark { get; set; }
+        public string sub_mark_b { get; set; }
+        public string ts { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+
+    }
+}

+ 36 - 0
HH.YiDaSyncNC/Dtos/SyncRecord_CGDD.cs

@@ -0,0 +1,36 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos
+{
+    ///<summary>
+    ///
+    ///</summary>
+    [SugarTable("SyncRecord_CGDD")]
+    public partial class SyncRecord_CGDD
+    {
+        public SyncRecord_CGDD()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public int Id { get; set; }
+
+        public string DataId { get; set; }
+        public string DataJson { get; set; }
+        public string CreateTime { get; set; }
+        public string ModifyTime { get; set; }
+        public bool Ps { get; set; }
+
+
+    }
+}

+ 36 - 0
HH.YiDaSyncNC/Dtos/SyncRecord_GYS.cs

@@ -0,0 +1,36 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos
+{
+    ///<summary>
+    ///
+    ///</summary>
+    [SugarTable("SyncRecord_GYS")]
+    public partial class SyncRecord_GYS
+    {
+        public SyncRecord_GYS()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public int Id { get; set; }
+
+        public string DataId { get; set; }
+        public string DataJson { get; set; }
+        public string CreateTime { get; set; }
+        public string ModifyTime { get; set; }
+        public bool Ps { get; set; }
+
+
+    }
+}

+ 36 - 0
HH.YiDaSyncNC/Dtos/SyncRecord_KH.cs

@@ -0,0 +1,36 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos
+{
+    ///<summary>
+    ///
+    ///</summary>
+    [SugarTable("SyncRecord_KH")]
+    public partial class SyncRecord_KH
+    {
+        public SyncRecord_KH()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public int Id { get; set; }
+
+        public string DataId { get; set; }
+        public string DataJson { get; set; }
+        public string CreateTime { get; set; }
+        public string ModifyTime { get; set; }
+        public bool Ps { get; set; }
+
+
+    }
+}

+ 36 - 0
HH.YiDaSyncNC/Dtos/SyncRecord_WL.cs

@@ -0,0 +1,36 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos
+{
+    ///<summary>
+    ///
+    ///</summary>
+    [SugarTable("SyncRecord_WL")]
+    public partial class SyncRecord_WL
+    {
+        public SyncRecord_WL()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public int Id { get; set; }
+
+        public string DataId { get; set; }
+        public string DataJson { get; set; }
+        public string CreateTime { get; set; }
+        public string ModifyTime { get; set; }
+        public bool Ps { get; set; }
+
+
+    }
+}

+ 36 - 0
HH.YiDaSyncNC/Dtos/SyncRecord_XMD.cs

@@ -0,0 +1,36 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos
+{
+    ///<summary>
+    ///
+    ///</summary>
+    [SugarTable("SyncRecord_XMD")]
+    public partial class SyncRecord_XMD
+    {
+        public SyncRecord_XMD()
+        {
+
+        }
+        /// <summary>
+        /// Desc:
+        /// Default:
+        /// Nullable:False
+        /// </summary>           
+        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
+        public int Id { get; set; }
+
+        public string DataId { get; set; }
+        public string DataJson { get; set; }
+        public string CreateTime { get; set; }
+        public string ModifyTime { get; set; }
+        public bool Ps { get; set; }
+
+
+    }
+}

+ 16 - 0
HH.YiDaSyncNC/Dtos/YiDaResDto.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Dtos
+{
+    public class YiDaResDto
+    {
+        public bool bSuccess { get; set; }
+        public DateTime syncTime { get; set; }
+        public string ncNo { get; set; }
+        public string log { get; set; }
+    }
+}

+ 207 - 0
HH.YiDaSyncNC/HH.YiDaSyncNC.csproj

@@ -0,0 +1,207 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{0C9830B2-D208-41CC-966B-E3509B3B3FC6}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <RootNamespace>HH.YiDaSyncNC</RootNamespace>
+    <AssemblyName>HH.YiDaSyncNC</AssemblyName>
+    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
+    <Deterministic>true</Deterministic>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="AlibabaCloud.EndpointUtil, Version=0.1.1.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\AlibabaCloud.EndpointUtil.0.1.1\lib\net45\AlibabaCloud.EndpointUtil.dll</HintPath>
+    </Reference>
+    <Reference Include="AlibabaCloud.GatewayDingTalk, Version=1.0.2.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\AlibabaCloud.GatewayDingTalk.1.0.2\lib\net45\AlibabaCloud.GatewayDingTalk.dll</HintPath>
+    </Reference>
+    <Reference Include="AlibabaCloud.GatewaySpi, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\AlibabaCloud.GatewaySpi.0.0.2\lib\net45\AlibabaCloud.GatewaySpi.dll</HintPath>
+    </Reference>
+    <Reference Include="AlibabaCloud.OpenApiClient, Version=0.1.5.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\AlibabaCloud.OpenApiClient.0.1.6\lib\net45\AlibabaCloud.OpenApiClient.dll</HintPath>
+    </Reference>
+    <Reference Include="AlibabaCloud.OpenApiUtil, Version=1.1.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\AlibabaCloud.OpenApiUtil.1.1.1\lib\net45\AlibabaCloud.OpenApiUtil.dll</HintPath>
+    </Reference>
+    <Reference Include="AlibabaCloud.SDK.Dingtalk, Version=0.0.1.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\AlibabaCloud.SDK.Dingtalk.2.0.27\lib\net45\AlibabaCloud.SDK.Dingtalk.dll</HintPath>
+    </Reference>
+    <Reference Include="AlibabaCloud.TeaUtil, Version=0.1.14.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\AlibabaCloud.TeaUtil.0.1.17\lib\net45\AlibabaCloud.TeaUtil.dll</HintPath>
+    </Reference>
+    <Reference Include="AlibabaCloud.TeaXML, Version=0.0.3.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\AlibabaCloud.TeaXML.0.0.3\lib\net45\AlibabaCloud.TeaXML.dll</HintPath>
+    </Reference>
+    <Reference Include="Aliyun.Credentials, Version=1.3.1.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\Aliyun.Credentials.1.3.1\lib\net45\Aliyun.Credentials.dll</HintPath>
+    </Reference>
+    <Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
+    </Reference>
+    <Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="RestSharp, Version=110.2.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75, processorArchitecture=MSIL">
+      <HintPath>..\packages\RestSharp.110.2.0\lib\net471\RestSharp.dll</HintPath>
+    </Reference>
+    <Reference Include="SqlSugar, Version=5.1.4.67, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\SqlSugar.5.1.4.67\lib\SqlSugar.dll</HintPath>
+    </Reference>
+    <Reference Include="System" />
+    <Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Configuration" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Net.Http.Extensions, Version=2.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Extensions.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Net.Http.Primitives, Version=4.2.29.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\Microsoft.Net.Http.2.2.29\lib\net45\System.Net.Http.Primitives.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Net.Http.WebRequest" />
+    <Reference Include="System.Numerics" />
+    <Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Security" />
+    <Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Text.Json, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Text.Json.7.0.2\lib\net462\System.Text.Json.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
+    </Reference>
+    <Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
+      <HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
+    </Reference>
+    <Reference Include="System.Web" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Net.Http" />
+    <Reference Include="System.Xml" />
+    <Reference Include="Tea, Version=1.1.2.0, Culture=neutral, processorArchitecture=MSIL">
+      <HintPath>..\packages\Tea.1.1.2\lib\net45\Tea.dll</HintPath>
+    </Reference>
+    <Reference Include="TopSdk">
+      <HintPath>lib\TopSdk.dll</HintPath>
+    </Reference>
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="DataSync\CGDD_SyncService.cs" />
+    <Compile Include="DataSync\FK_SyncService.cs" />
+    <Compile Include="DataSync\KH_SyncService.cs" />
+    <Compile Include="DataSync\GYS_SyncService.cs" />
+    <Compile Include="DataSync\KP_SyncService.cs" />
+    <Compile Include="DataSync\ZC_SyncService.cs" />
+    <Compile Include="DataSync\XMD_SyncService.cs" />
+    <Compile Include="DataSync\WL_SyncService.cs" />
+    <Compile Include="Dtos\NC\bd_defdoc.cs" />
+    <Compile Include="Dtos\NC\bd_income.cs" />
+    <Compile Include="Dtos\NC\bd_customer.cs" />
+    <Compile Include="Dtos\NC\po_order_bb.cs" />
+    <Compile Include="Dtos\NC\po_order_b.cs" />
+    <Compile Include="Dtos\NC\sm_user.cs" />
+    <Compile Include="Dtos\NC\bd_psndoc.cs" />
+    <Compile Include="Dtos\NC\org_dept.cs" />
+    <Compile Include="Dtos\NC\org_orgs.cs" />
+    <Compile Include="Dtos\NC\pam_addreducestyle.cs" />
+    <Compile Include="Dtos\NC\bd_material.cs" />
+    <Compile Include="Dtos\NC\fa_card.cs" />
+    <Compile Include="Dtos\NC\bd_stordoc.cs" />
+    <Compile Include="Dtos\NC\bd_projectclass.cs" />
+    <Compile Include="Dtos\NC\so_saleinvoice.cs" />
+    <Compile Include="Dtos\NC\po_order.cs" />
+    <Compile Include="Dtos\NC\so_squareinv_d.cs" />
+    <Compile Include="Dtos\NC\so_saleinvoice_b.cs" />
+    <Compile Include="Dtos\NC\xx_idcontrast.cs" />
+    <Compile Include="Dtos\NC\bd_project.cs" />
+    <Compile Include="Dtos\NC\bd_supplier.cs" />
+    <Compile Include="Dtos\NC\bd_custclass.cs" />
+    <Compile Include="Dtos\NC\bd_supplierclass.cs" />
+    <Compile Include="Dtos\NC\bd_branddoc.cs" />
+    <Compile Include="Dtos\NC\bd_mattaxes.cs" />
+    <Compile Include="Dtos\NC\bd_measdoc.cs" />
+    <Compile Include="Dtos\NC\bd_marbasclass.cs" />
+    <Compile Include="Dtos\NC\EnumType.cs" />
+    <Compile Include="Dtos\NC\so_saleorder.cs" />
+    <Compile Include="Dtos\NC\so_saleorder_b.cs" />
+    <Compile Include="Dtos\NC\so_saleorder_exe.cs" />
+    <Compile Include="Dtos\SyncRecord_CGDD.cs" />
+    <Compile Include="Dtos\SyncRecord_KH.cs" />
+    <Compile Include="Dtos\SyncRecord_GYS.cs" />
+    <Compile Include="Dtos\SyncRecord_XMD.cs" />
+    <Compile Include="Dtos\SyncRecord_WL.cs" />
+    <Compile Include="Dtos\YiDaResDto.cs" />
+    <Compile Include="Helper\AbPrivoder.cs" />
+    <Compile Include="Helper\CommHelper.cs" />
+    <Compile Include="Helper\DBHelper.cs" />
+    <Compile Include="Helper\DingTalkService.cs" />
+    <Compile Include="Helper\DocDicHelper.cs" />
+    <Compile Include="Helper\LogHelper.cs" />
+    <Compile Include="Helper\NCImportFunc.cs" />
+    <Compile Include="Helper\UnixTimeHelper.cs" />
+    <Compile Include="Models\FK_SyncServiceModel.cs" />
+    <Compile Include="Models\XSFP_SyncServiceModel.cs" />
+    <Compile Include="Models\KP_SyncServiceModel.cs" />
+    <Compile Include="Models\CGDD_SyncServiceModel.cs" />
+    <Compile Include="Models\KH_SyncServiceModel.cs" />
+    <Compile Include="Models\GYS_SyncServiceModel.cs" />
+    <Compile Include="Models\XMD_SyncServiceModel.cs" />
+    <Compile Include="Models\WL_SyncServiceModel.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="App.config" />
+    <None Include="packages.config" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Context\" />
+  </ItemGroup>
+  <ItemGroup>
+    <WCFMetadata Include="Connected Services\" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
+  <Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
+    <Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=317567." HelpKeyword="BCLBUILD2001" />
+    <Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
+  </Target>
+</Project>

+ 22 - 0
HH.YiDaSyncNC/Helper/AbPrivoder.cs

@@ -0,0 +1,22 @@
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Helper
+{
+    public class AbPrivoder
+    {
+        protected SqlSugarClient db = new SqlSugarClient(
+        new ConnectionConfig()
+        {
+            ConnectionString = ConfigurationManager.AppSettings["conn"].ToString(),
+            DbType = DbType.SqlServer,
+            IsAutoCloseConnection = true,
+            InitKeyType = InitKeyType.Attribute
+        });
+    }
+}

+ 101 - 0
HH.YiDaSyncNC/Helper/CommHelper.cs

@@ -0,0 +1,101 @@
+using DingTalk.Api;
+using DingTalk.Api.Request;
+using DingTalk.Api.Response;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web;
+using System.Web.Caching;
+
+namespace HH.YiDaSyncNC.Helper
+{
+    class CommHelper
+    {
+        private static readonly string appKey = ConfigurationManager.AppSettings["AppKey"];
+        private static readonly string appSecret = ConfigurationManager.AppSettings["AppSecret"];
+
+        /// <summary>
+        /// 时间转时间戳(秒)
+        /// </summary>
+        /// <param name="date">时间</param>
+        /// <returns></returns>
+        public static long GetTimeStamp(DateTime date)
+        {
+            //var unix = date.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+            //TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+            //return Convert.ToInt64(unix.TotalSeconds * 1000);
+            var epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            return Convert.ToInt64((date.ToUniversalTime() - epoch).TotalSeconds);
+        }
+
+        /// <summary>
+        /// 时间转时间戳(毫秒)
+        /// </summary>
+        /// <param name="date">日期</param>
+        /// <returns></returns>
+        public static long GetTimeStamps(DateTime date)
+        {
+            var unix = date.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+            TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+            return Convert.ToInt64(unix.TotalSeconds * 1000);
+        }
+
+        /// <summary>
+        /// 时间戳转时间(毫秒)
+        /// </summary>
+        /// <param name="timestamp"></param>
+        /// <returns></returns>
+        public static DateTime GetDateTime(long timestamp)
+        {
+            System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));//当地时区  
+            var time = startTime.AddMilliseconds(timestamp);
+            return time;
+        }
+
+        #region 获取AccessToken
+        public static string GetAccessToken()
+        {
+            // 将AccessToken存储至缓存
+            SetAccessToken(new CacheItemRemovedReason());
+            // 输出缓存中存储的AccessToken
+            return HttpRuntime.Cache.Get("Dingtalk_AccessToken").ToString();
+        }
+        #endregion
+
+        #region 设置AccessToken(企业内部开发)
+        public static void SetAccessToken(CacheItemRemovedReason reason)
+        {
+            //企业内部开发
+            var accessToken = HttpRuntime.Cache.Get("Dingtalk_AccessToken");
+            if (accessToken == null)
+            {
+                //var time = GetTimeStamp(DateTime.Now);
+                //var CorpId = corpid;
+                //var AgentId = agentid;
+                //var CustomKey = customkey;
+                //var CustomSecret = customsecret;
+
+                //string stringToSign = time+"\n"+"suiteTicket";
+                //var signature = getSHA256(CustomSecret, stringToSign);
+
+                //DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/service/get_corp_token");
+                //OapiServiceGetCorpTokenRequest req = new OapiServiceGetCorpTokenRequest();
+                //req.AuthCorpid = CorpId;
+                //OapiServiceGetCorpTokenResponse response = client.Execute(req, CustomKey, CustomSecret, "suiteTicket");
+                //HttpRuntime.Cache.Insert("Dingtalk_AccessToken", response.AccessToken, null, DateTime.Now.AddSeconds(3600), Cache.NoSlidingExpiration);
+
+                IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/gettoken");
+                OapiGettokenRequest request = new OapiGettokenRequest();
+                request.Appkey = appKey;
+                request.Appsecret = appSecret;
+                request.SetHttpMethod("GET");
+                OapiGettokenResponse response = client.Execute(request);
+                HttpRuntime.Cache.Insert("Dingtalk_AccessToken", response.AccessToken, null, DateTime.Now.AddSeconds(3600), Cache.NoSlidingExpiration);
+            }
+        }
+        #endregion
+    }
+}

+ 106 - 0
HH.YiDaSyncNC/Helper/DBHelper.cs

@@ -0,0 +1,106 @@
+using RestSharp;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.Helper
+{
+    class DBHelper
+    {
+        #region 写日志
+        /// <summary>
+        /// 写入日志
+        /// </summary>
+        /// <param name="sLog">内容</param>
+        /// <param name="sOption">标题</param>
+        /// <param name="sSrc">路径</param>
+        public static void WriteLog(string sLog, string sOption = "OP", string sSrc = "/Logs/")
+        {
+            var now = DateTime.Now;
+            StreamWriter sr = null;
+
+            var filePath = AppDomain.CurrentDomain.BaseDirectory + sSrc; // 文件路径
+            var file = filePath + "Log_" + DateTime.Now.ToString("yyyy_MM_dd") + ".log"; // 文件
+
+            if (!Directory.Exists(filePath)) Directory.CreateDirectory(filePath); // 判断是否存在目录,不存在则创建
+
+            if (!File.Exists(file))
+            {
+                sr = File.CreateText(file);//创建日志文件
+            }
+            else
+            {
+                sr = File.AppendText(file);//追加日志文件
+            }
+            sr.WriteLine($"{DateTime.Now}:【{sOption}】:{sLog}");//日志格式
+            if (sr != null) sr.Close();     //关闭文件流
+        }
+        #endregion
+
+        #region 生成报文数据方法
+        /// <summary>
+        /// 生成报文数据方法
+        /// </summary>
+        public static XmlElement ToXmlElementMethod(XElement xElement)
+        {
+            if (xElement == null) return null;
+
+            XmlElement xmlElement = null;
+            XmlReader xmlReader = null;
+            try
+            {
+                xmlReader = xElement.CreateReader();
+                var doc = new XmlDocument();
+                xmlElement = doc.ReadNode(xElement.CreateReader()) as XmlElement;
+            }
+            catch (Exception ex)
+            {
+                throw new Exception(ex.Message);
+            }
+            finally
+            {
+                if (xmlReader != null) xmlReader.Close();
+            }
+
+            return xmlElement;
+        }
+        #endregion
+
+        #region 调用传输凭证接口
+        /// <summary>
+        /// 调用传输凭证接口
+        /// </summary>
+        /// <param name="xmlstring">xml字符串参数</param>
+        /// <param name="url">接口地址</param>
+        /// <returns></returns>
+        public static string SendNsg(string xmlstring, string url)
+        {
+            string responseMsg = "";
+            try
+            {
+                var options = new RestClientOptions(url)
+                {
+                    MaxTimeout = -1,
+                };
+                var client = new RestClient(options);
+                var request = new RestRequest(url, Method.Post);
+                request.AddHeader("Content-Type", "application/xml");
+                var body = xmlstring;
+                request.AddParameter("application/xml", body, ParameterType.RequestBody);
+                RestResponse response = client.Execute(request);
+                responseMsg = response.Content;//获取返回Response消息
+            }
+            catch (Exception ex)
+            {
+                throw new Exception(ex.Message);
+            }
+            return responseMsg;
+        }
+        #endregion
+    }
+}

+ 273 - 0
HH.YiDaSyncNC/Helper/DingTalkService.cs

@@ -0,0 +1,273 @@
+using AlibabaCloud.SDK.Dingtalkyida_1_0.Models;
+using HH.YiDaSyncNC.Dtos;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tea;
+
+namespace HH.YiDaSyncNC.Helper
+{
+    class DingTalkService
+    {
+        public string _AppType;
+        public string _SystemToken;
+        public string _UserId;
+        public string _FormId;
+
+        public DingTalkService(string AppType, string SystemToken, string UserId, string FormId)
+        {
+            _AppType = AppType;
+            _SystemToken = SystemToken;
+            _UserId = UserId;
+            _FormId = FormId;
+        }
+
+        #region 封装后的宜搭接口
+
+        #region 获取表单Id集合
+        public List<string> GetFormIdList()
+        {
+            var pageIndex = 1;
+            var pageSize = 50;
+
+            var bFinish = false;
+
+            var resIdList = new List<string>();
+
+            while (!bFinish)
+            {
+                var resData = GetFormIdListFunc("", "", "", "", "", pageIndex, pageSize);
+                if (resData.StatusCode == 200)
+                {
+                    if (resData.Body.Data.Count == 0)
+                    {
+                        bFinish = true;
+                    }
+                    else
+                    {
+                        resIdList.AddRange(resData.Body.Data);
+                    }
+                }
+                else
+                {
+                    throw new Exception(JsonConvert.SerializeObject(resData));
+                }
+
+                pageIndex++;
+            }
+
+            return resIdList;
+        }
+        #endregion
+
+        #region 获取表单Id集合
+        public List<string> GetFormIdList(string search)
+        {
+            var pageIndex = 1;
+            var pageSize = 50;
+
+            var bFinish = false;
+
+            var resIdList = new List<string>();
+
+            while (!bFinish)
+            {
+                var resData = GetFormIdListFunc("", "", "", "", search, pageIndex, pageSize);
+                if (resData.StatusCode == 200)
+                {
+                    if (resData.Body.Data.Count == 0)
+                    {
+                        bFinish = true;
+                    }
+                    else
+                    {
+                        resIdList.AddRange(resData.Body.Data);
+                    }
+                }
+                else
+                {
+                    throw new Exception(JsonConvert.SerializeObject(resData));
+                }
+
+                pageIndex++;
+            }
+
+            return resIdList;
+        }
+        #endregion
+
+        #region 获取表单Id集合(24小时内更新过的数据)
+        public List<string> GetModifyFormIdList()
+        {
+            var pageIndex = 1;
+            var pageSize = 50;
+
+            var bFinish = false;
+
+            var resIdList = new List<string>();
+
+            var modifyFromTime = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd");
+            var modifyToTime = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd");
+
+            while (!bFinish)
+            {
+                var resData = GetFormIdListFunc(modifyFromTime, modifyToTime, modifyFromTime, modifyToTime, "", pageIndex, pageSize);
+                if (resData.StatusCode == 200)
+                {
+                    if (resData.Body.Data.Count == 0)
+                    {
+                        bFinish = true;
+                    }
+                    else
+                    {
+                        resIdList.AddRange(resData.Body.Data);
+                    }
+                }
+                else
+                {
+                    throw new Exception(JsonConvert.SerializeObject(resData));
+                }
+
+                pageIndex++;
+            }
+
+            return resIdList;
+        }
+        #endregion
+
+        #region 通过数据Id获取数据详情(单条)
+        public Dictionary<string, object> GetFormDataById(string id, out string createTime, out string modifyTime)
+        {
+            var resData = GetFormDataByIdsFunc(new List<string>() { id });
+            if (resData.StatusCode == 200)
+            {
+                createTime = resData.Body.Result[0].CreateTimeGMT;
+                modifyTime = resData.Body.Result[0].ModifiedTimeGMT;
+                return resData.Body.Result[0].FormData;
+            }
+            else
+            {
+                throw new Exception(JsonConvert.SerializeObject(resData));
+            }
+        }
+        #endregion
+
+        #region 更新同步标识信息
+        public UpdateFormDataResponse UpdateFormDataSyncDataById(YiDaResDto resData, string FormInstanceId)
+        {
+            var data = new Dictionary<string, string>();
+            data.Add("textField_ltxyt75i", resData.bSuccess ? "同步成功" : "同步失败");
+            data.Add("dateField_ltxyt75l", UnixTimeHelper.ConvertToMilliseconds(resData.syncTime).ToString());
+            data.Add("textField_ltxyt75m", resData.ncNo);
+            data.Add("textField_ltxyt75n", resData.log);
+            data.Add("radioField_lycrvvtk", "N");
+
+            return UpdateFormDataByIdFunc(JsonConvert.SerializeObject(data), FormInstanceId);
+        }
+        #endregion
+        #endregion
+
+        #region 宜搭接原始口
+        public AlibabaCloud.SDK.Dingtalkyida_1_0.Client CreateClient()
+        {
+            AlibabaCloud.OpenApiClient.Models.Config config = new AlibabaCloud.OpenApiClient.Models.Config();
+            config.Protocol = "https";
+            config.RegionId = "central";
+            return new AlibabaCloud.SDK.Dingtalkyida_1_0.Client(config);
+        }
+
+        #region 获取多个表单实例ID
+        public SearchFormDataIdListResponse GetFormIdListFunc(string CreateFromTime, string CreateToTime, string ModifiedFromTime, string ModifiedToTime, string SearchFieldJson, int CurrentPage, int PageSize)
+        {
+            AlibabaCloud.SDK.Dingtalkyida_1_0.Client client = CreateClient();
+            SearchFormDataIdListHeaders searchFormDatasHeaders = new SearchFormDataIdListHeaders();
+            searchFormDatasHeaders.XAcsDingtalkAccessToken = CommHelper.GetAccessToken();
+
+            SearchFormDataIdListRequest searchFormDatasRequest = new SearchFormDataIdListRequest
+            {
+                ModifiedToTimeGMT = ModifiedToTime,
+                SystemToken = _SystemToken,
+                ModifiedFromTimeGMT = ModifiedFromTime,
+                SearchFieldJson = SearchFieldJson,
+                UserId = _UserId,
+                CreateToTimeGMT = CreateToTime,
+                CreateFromTimeGMT = CreateFromTime,
+                PageNumber = CurrentPage,
+                PageSize = PageSize
+            };
+            var rsp = client.SearchFormDataIdListWithOptions(_AppType, _FormId, searchFormDatasRequest, searchFormDatasHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
+            return rsp;
+        }
+        #endregion
+
+        #region 批量获取表单实例数据
+        public BatchGetFormDataByIdListResponse GetFormDataByIdsFunc(List<string> IdList)
+        {
+            AlibabaCloud.SDK.Dingtalkyida_1_0.Client client = CreateClient();
+            AlibabaCloud.SDK.Dingtalkyida_1_0.Models.BatchGetFormDataByIdListHeaders batchGetFormDataByIdListHeaders = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.BatchGetFormDataByIdListHeaders();
+            batchGetFormDataByIdListHeaders.XAcsDingtalkAccessToken = CommHelper.GetAccessToken();
+            AlibabaCloud.SDK.Dingtalkyida_1_0.Models.BatchGetFormDataByIdListRequest batchGetFormDataByIdListRequest = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.BatchGetFormDataByIdListRequest
+            {
+                FormUuid = _FormId,
+                AppType = _AppType,
+                SystemToken = _SystemToken,
+                FormInstanceIdList = IdList,
+                NeedFormInstanceValue = true,
+                UserId = _UserId,
+            };
+            var rsp = client.BatchGetFormDataByIdListWithOptions(batchGetFormDataByIdListRequest, batchGetFormDataByIdListHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
+            return rsp;
+        }
+        #endregion
+
+        #region 更新表单实例数据
+        public UpdateFormDataResponse UpdateFormDataByIdFunc(string UpdateFormDataJson, string FormInstanceId)
+        {
+            AlibabaCloud.SDK.Dingtalkyida_1_0.Client client = CreateClient();
+            AlibabaCloud.SDK.Dingtalkyida_1_0.Models.UpdateFormDataHeaders updateFormDataHeaders = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.UpdateFormDataHeaders();
+            updateFormDataHeaders.XAcsDingtalkAccessToken = CommHelper.GetAccessToken();
+            AlibabaCloud.SDK.Dingtalkyida_1_0.Models.UpdateFormDataRequest updateFormDataRequest = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.UpdateFormDataRequest
+            {
+                AppType = _AppType,
+                SystemToken = _SystemToken,
+                UserId = _UserId,
+                Language = "zh_CN",
+                FormInstanceId = FormInstanceId,
+                UseLatestVersion = true,
+                UpdateFormDataJson = UpdateFormDataJson,
+            };
+            try
+            {
+                var rsp = client.UpdateFormDataWithOptions(updateFormDataRequest, updateFormDataHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
+                return rsp;
+            }
+            catch (TeaException err)
+            {
+                if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
+                {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+
+                }
+            }
+            catch (Exception _err)
+            {
+                TeaException err = new TeaException(new Dictionary<string, object>
+                {
+                    { "message", _err.Message }
+                });
+                if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
+                {
+                    // err 中含有 code 和 message 属性,可帮助开发定位问题
+                }
+            }
+
+            return null;
+        }
+        #endregion
+
+        #endregion
+    }
+}

+ 30 - 0
HH.YiDaSyncNC/Helper/DocDicHelper.cs

@@ -0,0 +1,30 @@
+using HH.YiDaSyncNC.Dtos.NC;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Helper
+{
+    public class DocDicHelper
+    {
+        public Dictionary<string,string> _AppType;
+
+        public string ContrastDoc(List<org_orgs> dataDic, string value)
+        {
+            var resData = "";
+
+            if (!string.IsNullOrWhiteSpace(value))
+            {
+                var tempData = dataDic.FirstOrDefault(f => f.name == value);
+                if (tempData != null)
+                {
+                    resData = tempData.code;
+                }
+            }
+
+            return resData;
+        }
+    }
+}

+ 42 - 0
HH.YiDaSyncNC/Helper/LogHelper.cs

@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Helper
+{
+    class LogHelper
+    {
+        #region 写入日志
+        /// <summary>
+        /// 写入日志
+        /// </summary>
+        /// <param name="sLog">内容</param>
+        /// <param name="sOption">标题</param>
+        /// <param name="sSrc">路径</param>
+        public static void WriteLog(string sLog, string sOption = "OP", string sSrc = "/Logs/")
+        {
+            var now = DateTime.Now;
+            StreamWriter sr = null;
+
+            var filePath = AppDomain.CurrentDomain.BaseDirectory + sSrc; // 文件路径
+            var file = filePath + "Log_" + DateTime.Now.ToString("yyyy_MM_dd") + ".log"; // 文件
+
+            if (!Directory.Exists(filePath)) Directory.CreateDirectory(filePath); // 判断是否存在目录,不存在则创建
+
+            if (!File.Exists(file))
+            {
+                sr = File.CreateText(file);//创建日志文件
+            }
+            else
+            {
+                sr = File.AppendText(file);//追加日志文件
+            }
+            sr.WriteLine($"{DateTime.Now}:【{sOption}】:{sLog}");//日志格式
+            if (sr != null) sr.Close();     //关闭文件流
+        }
+        #endregion
+    }
+}

+ 42 - 0
HH.YiDaSyncNC/Helper/NCImportFunc.cs

@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.Helper
+{
+    class NCImportFunc
+    {
+        public static string NCImport(XElement tempHeader, XElement xElement, string url)
+        {
+            try
+            {
+                tempHeader.Add(xElement);
+
+                //xElement.Element("voucher").Element("voucher_head").Element("details").Add(Bodydebit(body));//表体没有记录
+
+                string xmlString = DBHelper.ToXmlElementMethod(tempHeader).OuterXml;//变成xml字符串
+
+                xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" + xmlString;
+
+                DBHelper.WriteLog("传入参数:" + xmlString);
+
+                string resultMsg = DBHelper.SendNsg(xmlString, url);//接收返回的数据
+
+                DBHelper.WriteLog("返回参数:" + resultMsg);
+
+                XElement xE = XElement.Parse(resultMsg);
+
+                string resultcode = xE.Element("sendresult").Element("resultcode").Value;
+
+                return resultMsg;//返回错误信息
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
+    }
+}

+ 30 - 0
HH.YiDaSyncNC/Helper/UnixTimeHelper.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HH.YiDaSyncNC.Helper
+{
+    class UnixTimeHelper
+    {
+        public static DateTime ConvertMillisecondsToDateTime(long milliseconds)
+        {
+            // 毫秒数需要转换为秒
+            double seconds = milliseconds / 1000.0;
+            // Unix时间起始时间1970-01-01 00:00:00
+            DateTime unixStartTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
+            // 将秒数转换为TimeSpan,然后添加到Unix起始时间
+            TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
+            // 返回结果的UTC时间
+            return unixStartTime.Add(timeSpan).ToLocalTime();
+        }
+
+        public static long ConvertToMilliseconds(DateTime dateTime)
+        {
+            DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
+            TimeSpan timeSpan = dateTime.ToUniversalTime() - epoch;
+            return (long)timeSpan.TotalMilliseconds;
+        }
+    }
+}

+ 244 - 0
HH.YiDaSyncNC/Models/CGDD_SyncServiceModel.cs

@@ -0,0 +1,244 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.Models
+{
+    class CGDD_SyncServiceModel
+    {
+        public class DataModel
+        {
+            public string 集团 { get; set; }
+            public string 组织 { get; set; }
+
+            public string 部门 { get; set; } = "06";
+
+            public string 订单编号 { get; set; }
+            public string 订单日期 { get; set; }
+            public string 供应商 { get; set; }
+            public string 订单类型 { get; set; } = "21-Cxx-02";
+            public string 单据状态 { get; set; } = "0";
+
+            public string 审批人 { get; set; }
+            public string 审批时间 { get; set; }
+            public string 制单人 { get; set; }
+            public string 制单时间 { get; set; }
+            public string 创建人 { get; set; }
+            public string 创建时间 { get; set; }
+
+            public string 换算率 { get; set; } = "1.00/1.00";
+            public string 折扣 { get; set; } = "100";
+
+            public string 数量 { get; set; }
+            public string 价税合计 { get; set; }
+            public string 业务流程 { get; set; } = "Cxx-CG-02";
+            public string 币种 { get; set; } = "CNY";
+
+            public List<OrderB> pk_order_b { get; set; }
+
+            public class OrderB
+            {
+                public string 物料编码 { get; set; }
+                public string 物料名称 { get; set; }
+                public string 计量单位 { get; set; }
+                public string 项目 { get; set; }
+                public string 数量 { get; set; }
+                public string 无税单价 { get; set; }
+                public string 含税单价 { get; set; }
+                public string 无税金额 { get; set; }
+                public string 税额 { get; set; }
+                public string 税率 { get; set; } = "13";
+                public string 税码 { get; set; } = "CN15";
+                public string 价税合计 { get; set; }
+                public string 联系人 { get; set; }
+                public string 收货地址 { get; set; }
+            }
+        }
+
+        public class ImportXml
+        {
+            /// <summary>
+            /// 模板头部份
+            /// </summary>
+            /// <returns></returns>
+            public static XElement TemplateHeade()
+            {
+
+                return new XElement(new XElement("ufinterface", new object[]
+                {
+                new XAttribute("sender","dingding"),
+                new XAttribute("roottag",""),
+                new XAttribute("replace","Y"),
+                new XAttribute("isexchange","Y"),
+                new XAttribute("groupcode","0"),
+                new XAttribute("filename",""),
+                new XAttribute("billtype","21"),
+                new XAttribute("account","develop")
+                }));
+            }
+
+            /// <summary>
+            /// 组建表头xml
+            /// </summary>
+            /// <param name="item">表头参数</param>
+            /// <returns></returns>
+            public static XElement Header(DataModel item, string id)
+            {
+                var pk_order_b = new List<XElement>();
+
+                if (item.pk_order_b != null && item.pk_order_b.Count > 0)
+                {
+                    var crowno = 10; // 行号
+
+                    foreach (var itemData in item.pk_order_b)
+                    {
+                        pk_order_b.Add(new XElement("item", new object[] {
+                            new XElement("pk_group",item.集团),
+                            new XElement("pk_org",item.组织),
+                            new XElement("pk_org_v",item.组织),
+                            new XElement("pk_reqcorp",item.组织),
+                            new XElement("pk_reqstoorg",item.组织),
+                            new XElement("pk_reqstoorg_v",item.组织),
+                            new XElement("pk_arrvstoorg",item.组织),
+                            new XElement("pk_arrvstoorg_v",item.组织),
+                            new XElement("pk_psfinanceorg",item.组织),
+                            new XElement("pk_psfinanceorg_v",item.组织),
+                            new XElement("pk_apfinanceorg",item.组织),
+                            new XElement("pk_apfinanceorg_v",item.组织),
+
+                            new XElement("crowno",crowno.ToString()),
+
+                            new XElement("pk_material",itemData.物料编码),
+                            new XElement("pk_srcmaterial",itemData.物料编码),
+                            new XElement("vvendinventorycode",itemData.物料编码),
+                            new XElement("vvendinventoryname",itemData.物料名称),
+                            new XElement("cunitid",itemData.计量单位),
+                            new XElement("castunitid",itemData.计量单位),
+                            new XElement("cqtunitid",itemData.计量单位),
+
+                            new XElement("cprojectid",itemData.项目),
+                            new XElement("dbilldate",item.订单日期),
+                            new XElement("pk_supplier",item.供应商),
+                            new XElement("dsenddate",Convert.ToDateTime(item.订单日期).AddDays(1).ToString("yyyy-MM-dd HH:mm:ss")),
+
+                            new XElement("nnum",itemData.数量),
+                            new XElement("nastnum",itemData.数量),
+                            new XElement("vchangerate",item.换算率),
+                            new XElement("nqtunitnum",itemData.数量),
+                            new XElement("vqtunitrate",item.换算率),
+
+                            new XElement("nqtorigprice",itemData.无税单价),
+                            new XElement("nqtorignetprice",itemData.无税单价),
+                            new XElement("nqtnetprice",itemData.无税单价),
+                            new XElement("norigprice",itemData.无税单价),
+                            new XElement("norignetprice",itemData.无税单价),
+                            new XElement("nnetprice",itemData.无税单价),
+                            new XElement("nqtprice",itemData.无税单价),
+                            new XElement("nprice",itemData.无税单价),
+
+                            new XElement("nqtorigtaxprice",itemData.含税单价),
+                            new XElement("nqtorigtaxnetprc",itemData.含税单价),
+                            new XElement("nqttaxnetprice",itemData.含税单价),
+                            new XElement("norigtaxprice",itemData.含税单价),
+                            new XElement("norigtaxnetprice",itemData.含税单价),
+                            new XElement("ntaxnetprice",itemData.含税单价),
+                            new XElement("nqttaxprice",itemData.含税单价),
+                            new XElement("ntaxprice",itemData.含税单价),
+
+                            new XElement("norigmny",itemData.无税金额),
+                            new XElement("nmny",itemData.无税金额),
+                            new XElement("ncaltaxmny",itemData.无税金额),
+                            new XElement("ncalcostmny",itemData.无税金额),
+
+                            new XElement("ntax",itemData.税额),
+                            new XElement("ntaxrate",itemData.税率),
+                            new XElement("ctaxcodeid",itemData.税码),
+
+                            new XElement("norigtaxmny",itemData.价税合计),
+                            new XElement("ntaxmny",itemData.价税合计),
+
+                            new XElement("nitemdiscountrate","100"),
+                            new XElement("breceiveplan","N"),
+                            new XElement("blargess","N"),
+                            new XElement("btransclosed","N"),
+                            new XElement("bborrowpur","N"),
+
+                            new XElement("bstockclose","N"),
+                            new XElement("binvoiceclose","N"),
+                            new XElement("barriveclose","N"),
+                            new XElement("bpayclose","N"),
+                            new XElement("ftaxtypeflag","1"),
+
+                            new XElement("vbdef3",itemData.联系人),
+                            new XElement("vbdef4",itemData.收货地址),
+
+                            new XElement("ccurrencyid",item.币种),
+                            new XElement("nexchangerate","1"),
+
+                            new XElement("corigcurrencyid",item.币种),
+
+                            new XElement("csendcountryid","CN"),
+                            new XElement("crececountryid","CN"),
+                            new XElement("ctaxcountryid","CN"),
+
+                            new XElement("fbuysellflag","2"),
+                            new XElement("btriatradeflag","N"),
+
+                        }));
+
+                        crowno = crowno + 10;
+                    }
+                }
+
+                return new XElement("bill", new object[]
+                {
+                    "",
+                    new XAttribute("id",id),
+                    new XElement("billhead", new object[]
+                    {
+                        new XElement("pk_group",item.集团),
+                        new XElement("pk_org",item.组织),
+                        new XElement("pk_org_v",item.组织),
+                        new XElement("vbillcode",item.订单编号),
+                        new XElement("dbilldate",item.订单日期),
+
+                        new XElement("pk_supplier",item.供应商),
+                        new XElement("pk_invcsupllier",item.供应商),
+
+                        new XElement("vtrantypecode",item.订单类型),
+                        new XElement("ctrantypeid",item.订单类型),
+
+                        new XElement("pk_dept",item.部门),
+                        new XElement("pk_dept_v",item.部门),
+
+                        new XElement("approver",item.审批人),
+                        new XElement("taudittime",item.审批时间),
+                        new XElement("billmaker",item.制单人),
+                        new XElement("dmakedate",item.制单时间),
+                        new XElement("creator",item.创建人),
+                        new XElement("creationtime",item.创建时间),
+
+
+                        new XElement("forderstatus",item.单据状态),
+                        new XElement("nversion","1"),
+                        new XElement("bislatest","Y"),
+                        new XElement("vdef10",item.订单编号),
+                    
+                        new XElement("ntotalastnum",item.数量),
+                        new XElement("ntotalorigmny",item.价税合计),
+
+                        new XElement("pk_busitype",item.业务流程),
+                        new XElement("fhtaxtypeflag","1"),
+
+                        new XElement("corigcurrencyid",item.币种),
+
+                        new XElement("pk_order_b",pk_order_b),
+                    }),
+                });
+            }
+        }
+    }
+}

+ 106 - 0
HH.YiDaSyncNC/Models/FK_SyncServiceModel.cs

@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.Models
+{
+    class FK_SyncServiceModel
+    {
+        public class DataModel
+        {
+            public string pk_group { get; set; }
+            public string pk_org { get; set; }
+
+            public string code { get; set; }
+            public string name { get; set; }
+            public string pk_custclass { get; set; }
+            public string taxpayerid { get; set; }
+            public string custprop { get; set; }
+
+            public List<SuplinkmanItem> suplinkman { get; set; }
+
+            public class SuplinkmanItem
+            {
+                public string name { get; set; }
+                public string cell { get; set; }
+                public string vjob { get; set; }
+            }
+        }
+
+        public class ImportXml
+        {
+            /// <summary>
+            /// 模板头部份
+            /// </summary>
+            /// <returns></returns>
+            public static XElement TemplateHeade()
+            {
+
+                return new XElement(new XElement("ufinterface", new object[]
+                {
+                new XAttribute("sender","dingding"),
+                new XAttribute("roottag",""),
+                new XAttribute("replace","Y"),
+                new XAttribute("isexchange","Y"),
+                new XAttribute("groupcode","0"),
+                new XAttribute("filename",""),
+                new XAttribute("billtype","customer"),
+                new XAttribute("proc","add"),
+                new XAttribute("account","develop")
+                }));
+            }
+
+            /// <summary>
+            /// 组建表头xml
+            /// </summary>
+            /// <param name="item">表头参数</param>
+            /// <returns></returns>
+            public static XElement Header(DataModel item, string id)
+            {
+                var suplinkmanList = new List<XElement>();
+
+                if (item.suplinkman != null && item.suplinkman.Count > 0)
+                {
+                    foreach (var itemData in item.suplinkman)
+                    {
+                        suplinkmanList.Add(new XElement("item", new object[] {
+                            new XElement("linkmanvo",new object[]{
+                                new XElement("name",itemData.name),
+                                new XElement("cell",itemData.cell),
+                                new XElement("vjob",itemData.vjob),
+                            }),
+                            new XElement("pk_linkman",""),
+                            new XElement("isdefault","N"),
+                        }));
+                    }
+                }
+
+                return new XElement("bill", new object[]
+                {
+                "",
+                new XAttribute("id",id),
+                new XElement("billhead", new object[]
+                {
+                    new XElement("pk_group",item.pk_group),
+                    new XElement("pk_org",item.pk_org),
+
+                    new XElement("code",item.code),
+                    new XElement("name",item.name),
+                    new XElement("pk_custclass",item.pk_custclass),
+                    new XElement("taxpayerid",item.taxpayerid),
+                    new XElement("custprop",item.custprop),
+
+                    new XElement("custcontacts",suplinkmanList),
+
+                    new XElement("pk_country","CN"),
+                    new XElement("pk_timezone","P0800"),
+                    new XElement("pk_format","ZH-CN"),
+                }),
+                });
+            }
+        }
+    }
+}

+ 102 - 0
HH.YiDaSyncNC/Models/GYS_SyncServiceModel.cs

@@ -0,0 +1,102 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.Models
+{
+    class GYS_SyncServiceModel
+    {
+        public class DataModel
+        {
+            public string pk_group { get; set; }
+            public string pk_org { get; set; }
+            public string code { get; set; }
+            public string name { get; set; }
+            public string pk_supplierclass { get; set; }
+            public string enablestate { get; set; }
+            public string taxpayerid { get; set; }
+
+            public List<SuplinkmanItem> suplinkman { get; set; }
+
+            public class SuplinkmanItem
+            {
+                public string name { get; set; }
+                public string cell { get; set; }
+            }
+        }
+
+        public class ImportXml
+        {
+            /// <summary>
+            /// 模板头部份
+            /// </summary>
+            /// <returns></returns>
+            public static XElement TemplateHeade()
+            {
+
+                return new XElement(new XElement("ufinterface", new object[]
+                {
+                new XAttribute("sender","dingding"),
+                new XAttribute("roottag",""),
+                new XAttribute("replace","Y"),
+                new XAttribute("isexchange","Y"),
+                new XAttribute("groupcode","0"),
+                new XAttribute("filename",""),
+                new XAttribute("billtype","supplier"),
+                new XAttribute("proc","add"),
+                new XAttribute("account","develop")
+                }));
+            }
+
+            /// <summary>
+            /// 组建表头xml
+            /// </summary>
+            /// <param name="item">表头参数</param>
+            /// <returns></returns>
+            public static XElement Header(DataModel item, string id)
+            {
+                var suplinkmanList = new List<XElement>();
+
+                if (item.suplinkman != null && item.suplinkman.Count > 0)
+                {
+                    foreach (var itemData in item.suplinkman)
+                    {
+                        suplinkmanList.Add(new XElement("item", new object[] {
+                            new XElement("linkmanvo",new object[]{
+                                new XElement("name",itemData.name),
+                                new XElement("cell",itemData.cell),
+                            }),
+                            new XElement("pk_linkman",""),
+                            new XElement("isdefault","N"),
+                        }));
+                    }
+                }
+
+                return new XElement("bill", new object[]
+                {
+                "",
+                new XAttribute("id",id),
+                new XElement("billhead", new object[]
+                {
+                    new XElement("pk_group",item.pk_group),
+                    new XElement("pk_org",item.pk_org),
+                    new XElement("code",item.code),
+                    new XElement("name",item.name),
+                    new XElement("pk_supplierclass",item.pk_supplierclass),
+                    new XElement("enablestate",item.enablestate),
+                    new XElement("taxpayerid",item.taxpayerid),
+
+                    new XElement("suplinkman",suplinkmanList),
+
+                    new XElement("pk_country","CN"),
+                    new XElement("pk_timezone","P0800"),
+                    new XElement("pk_format","ZH-CN"),
+                }),
+                });
+            }
+        }
+    }
+}

+ 106 - 0
HH.YiDaSyncNC/Models/KH_SyncServiceModel.cs

@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.Models
+{
+    class KH_SyncServiceModel
+    {
+        public class DataModel
+        {
+            public string pk_group { get; set; }
+            public string pk_org { get; set; }
+
+            public string code { get; set; }
+            public string name { get; set; }
+            public string pk_custclass { get; set; }
+            public string taxpayerid { get; set; }
+            public string custprop { get; set; }
+
+            public List<SuplinkmanItem> suplinkman { get; set; }
+
+            public class SuplinkmanItem
+            {
+                public string name { get; set; }
+                public string cell { get; set; }
+                public string vjob { get; set; }
+            }
+        }
+
+        public class ImportXml
+        {
+            /// <summary>
+            /// 模板头部份
+            /// </summary>
+            /// <returns></returns>
+            public static XElement TemplateHeade()
+            {
+
+                return new XElement(new XElement("ufinterface", new object[]
+                {
+                new XAttribute("sender","dingding"),
+                new XAttribute("roottag",""),
+                new XAttribute("replace","Y"),
+                new XAttribute("isexchange","Y"),
+                new XAttribute("groupcode","0"),
+                new XAttribute("filename",""),
+                new XAttribute("billtype","customer"),
+                new XAttribute("proc","add"),
+                new XAttribute("account","develop")
+                }));
+            }
+
+            /// <summary>
+            /// 组建表头xml
+            /// </summary>
+            /// <param name="item">表头参数</param>
+            /// <returns></returns>
+            public static XElement Header(DataModel item, string id)
+            {
+                var suplinkmanList = new List<XElement>();
+
+                if (item.suplinkman != null && item.suplinkman.Count > 0)
+                {
+                    foreach (var itemData in item.suplinkman)
+                    {
+                        suplinkmanList.Add(new XElement("item", new object[] {
+                            new XElement("linkmanvo",new object[]{
+                                new XElement("name",itemData.name),
+                                new XElement("cell",itemData.cell),
+                                new XElement("vjob",itemData.vjob),
+                            }),
+                            new XElement("pk_linkman",""),
+                            new XElement("isdefault","N"),
+                        }));
+                    }
+                }
+
+                return new XElement("bill", new object[]
+                {
+                "",
+                new XAttribute("id",id),
+                new XElement("billhead", new object[]
+                {
+                    new XElement("pk_group",item.pk_group),
+                    new XElement("pk_org",item.pk_org),
+
+                    new XElement("code",item.code),
+                    new XElement("name",item.name),
+                    new XElement("pk_custclass",item.pk_custclass),
+                    new XElement("taxpayerid",item.taxpayerid),
+                    new XElement("custprop",item.custprop),
+
+                    new XElement("custcontacts",suplinkmanList),
+
+                    new XElement("pk_country","CN"),
+                    new XElement("pk_timezone","P0800"),
+                    new XElement("pk_format","ZH-CN"),
+                }),
+                });
+            }
+        }
+    }
+}

+ 728 - 0
HH.YiDaSyncNC/Models/KP_SyncServiceModel.cs

@@ -0,0 +1,728 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.Models
+{
+    class KP_SyncServiceModel
+    {
+        public class DataModel
+        {
+            public string 集团 { get; set; } = "0";
+            public string 组织 { get; set; }
+
+            public string 销售订单单据类型 { get; set; } = "30-Cxx-02";
+            public string 销售订单单据大类 { get; set; } = "30";
+
+            public string 销售发票单据类型 { get; set; } = "32-01";
+            public string 销售发票单据大类 { get; set; } = "32";
+
+            public string 应收单单据类型 { get; set; } = "F0";
+            public string 应收类型 { get; set; } = "D0";
+            public string 应收单单据大类 { get; set; } = "ys";
+
+            public string 业务流程 { get; set; } = "Cxx-xs-03";
+            public string 单据号 { get; set; } // 不传
+            public string 单据日期 { get; set; }
+
+            public string 客户 { get; set; }
+            public string 部门 { get; set; }
+            public string 业务员 { get; set; }
+            public string 币种 { get; set; } = "CNY";
+            public string 收款协议 { get; set; }
+            public string 审批人 { get; set; }
+            public string 审批时间 { get; set; }
+            public string 制单人 { get; set; }
+            public string 制单时间 { get; set; }
+            public string 创建人 { get; set; }
+            public string 创建时间 { get; set; }
+
+            public string 国家 { get; set; } = "CN";
+            public string 项目 { get; set; }
+
+            public string 数量 { get; set; }
+            public string 价税合计 { get; set; }
+
+            // ----------------------------------------------------------------------
+            public string 发票号 { get; set; }
+            public string 发票类型 { get; set; } = "32-01";
+            public string 客户打印名称 { get; set; }
+
+            public string 开票类型 { get; set; }
+            public string OA单据号 { get; set; }
+            public string 合同业务类型 { get; set; }
+
+            public string 扣税类别 { get; set; } = "1";
+            public string 汇率 { get; set; } = "1";
+            public string 折扣 { get; set; } = "100";
+
+            public string 销售订单单据号 { get; set; } // ---------
+            public string 销售订单主表id { get; set; } // ---------
+
+            public string 销售发票主表id { get; set; } // ---------
+
+            public string 年份 { get; set; }
+            public string 月份 { get; set; }
+
+
+            public List<OrderB> 明细 { get; set; }
+
+            public class OrderB
+            {
+                public string 物料 { get; set; }
+                public string 计量单位 { get; set; }
+
+                public string 换算率 { get; set; } = "1.00/1.00";
+                public string 数量 { get; set; }
+                public string 税码 { get; set; }
+                public string 税率 { get; set; }
+
+                public string 含税单价 { get; set; }
+                public string 无税单价 { get; set; }
+                public string 含税净价 { get; set; }
+                public string 无税净价 { get; set; }
+                public string 税额 { get; set; }
+                public string 无税金额 { get; set; }
+                public string 价税合计 { get; set; }
+
+                // ----------------------------------------------
+                public string 开票内容 { get; set; }
+                public string 行id { get; set; }
+
+                public string 销售订单子表id { get; set; } // ---------
+
+                public string 销售发票子表id { get; set; } // ---------
+            }
+        }
+
+        public class ImportXml_销售订单
+        {
+            /// <summary>
+            /// 模板头部份
+            /// </summary>
+            /// <returns></returns>
+            public static XElement TemplateHeade()
+            {
+
+                return new XElement(new XElement("ufinterface", new object[]
+                {
+                new XAttribute("sender","dingding"),
+                new XAttribute("roottag",""),
+                new XAttribute("replace","Y"),
+                new XAttribute("isexchange","Y"),
+                new XAttribute("groupcode","0"),
+                new XAttribute("filename",""),
+                new XAttribute("billtype","30"),
+                new XAttribute("account","develop")
+                }));
+            }
+
+            /// <summary>
+            /// 组建表头xml
+            /// </summary>
+            /// <param name="item">表头参数</param>
+            /// <returns></returns>
+            public static XElement Header(DataModel item, string id)
+            {
+                var so_saleorder_b = new List<XElement>();
+
+                if (item.明细 != null && item.明细.Count > 0)
+                {
+                    var crowno = 10; // 行号
+
+                    foreach (var itemData in item.明细)
+                    {
+                        so_saleorder_b.Add(new XElement("item", new object[] {
+                            new XElement("carorgvid",item.组织),
+                            new XElement("carorgid",item.组织),
+                            new XElement("csettleorgvid",item.组织),
+                            new XElement("csettleorgid",item.组织),
+                            new XElement("csendstockorgvid",item.组织),
+                            new XElement("csendstockorgid",item.组织),
+
+                            new XElement("creceivecustid",item.客户),
+                            new XElement("crececountryid",item.国家),
+                            new XElement("csendcountryid",item.国家),
+                            new XElement("ctaxcountryid",item.国家),
+
+                            new XElement("pk_group",item.集团),
+                            new XElement("pk_org",item.组织),
+                            new XElement("dbilldate",item.单据日期),
+                            new XElement("dreceivedate",Convert.ToDateTime(item.单据日期).AddDays(1).ToString("yyyy-MM-dd HH:mm:ss")),
+                            new XElement("dsenddate",Convert.ToDateTime(item.单据日期).AddDays(1).ToString("yyyy-MM-dd HH:mm:ss")),
+
+                            new XElement("crowno",crowno.ToString()),
+                            new XElement("cprojectid",item.项目),
+                            new XElement("fbuysellflag","1"),
+                            new XElement("flargesstypeflag","1"),
+
+                            new XElement("cmaterialvid",itemData.物料),
+                            new XElement("cmaterialid",itemData.物料),
+                            new XElement("cunitid",itemData.计量单位),
+                            new XElement("castunitid",itemData.计量单位),
+                            new XElement("cqtunitid",itemData.计量单位),
+
+                            new XElement("nastnum",itemData.数量),
+                            new XElement("vchangerate",itemData.换算率),
+                            new XElement("nqtunitnum",itemData.数量),
+                            new XElement("nnum",itemData.数量),
+                            new XElement("vqtunitrate",itemData.换算率),
+                            new XElement("ctaxcodeid",itemData.税码),
+                            new XElement("ntaxrate",itemData.税率),
+                            new XElement("ftaxtypeflag","1"),
+                            new XElement("ccurrencyid",item.币种),
+                            new XElement("nexchangerate","1"),
+                            new XElement("ndiscount","0"),
+                            new XElement("ndiscountrate","100"),
+                            new XElement("nitemdiscountrate","100"),
+
+                            new XElement("norigtaxprice",itemData.含税单价),
+                            new XElement("nqtorigtaxprice",itemData.含税单价),
+                            new XElement("nqttaxprice",itemData.含税单价),
+                            new XElement("ntaxprice",itemData.含税单价),
+
+                            new XElement("nqtorigprice",itemData.无税单价),
+                            new XElement("nqtorignetprice",itemData.无税单价),
+                            new XElement("norigprice",itemData.无税单价),
+                            new XElement("nprice",itemData.无税单价),
+                            new XElement("nqtprice",itemData.无税单价),
+
+                            new XElement("nqtorigtaxnetprc",itemData.含税净价),
+                            new XElement("norigtaxnetprice",itemData.含税净价),
+                            new XElement("nqttaxnetprice",itemData.含税净价),
+                            new XElement("ntaxnetprice",itemData.含税净价),
+
+                            new XElement("norignetprice",itemData.无税净价),
+                            new XElement("nnetprice",itemData.无税净价),
+                            new XElement("nqtnetprice",itemData.无税净价),
+
+                            new XElement("ntax",itemData.税额),
+
+                            new XElement("ncaltaxmny",itemData.无税金额),
+                            new XElement("norigmny",itemData.无税金额),
+                            new XElement("nmny",itemData.无税金额),
+
+                            new XElement("norigtaxmny",itemData.价税合计),
+                            new XElement("ntaxmny",itemData.价税合计),
+
+                            new XElement("norigdiscount","0"),
+
+                            new XElement("vbdef1",itemData.开票内容),
+                            new XElement("vbdef10",itemData.行id),
+                        }));
+
+                        crowno = crowno + 10;
+                    }
+                }
+
+                return new XElement("bill", new object[]
+                {
+                    "",
+                    new XAttribute("id",id),
+                    new XElement("billhead", new object[]
+                    {
+                        new XElement("pk_group",item.集团),
+                        new XElement("pk_org",item.组织),
+                        new XElement("pk_org_v",item.组织),
+                        new XElement("ctrantypeid",item.销售订单单据类型),
+                        new XElement("vtrantypecode",item.销售订单单据类型),
+                        new XElement("cbiztypeid",item.业务流程),
+                        new XElement("vbillcode",""),
+
+                        new XElement("dbilldate",item.单据日期),
+                        new XElement("ccustomerid",item.客户),
+                        new XElement("cdeptvid",item.部门),
+                        new XElement("cdeptid",item.部门),
+                        new XElement("cemployeeid",""),
+                        new XElement("corigcurrencyid",item.币种),
+                        new XElement("cinvoicecustid",item.客户),
+                        new XElement("cpaytermid","01"),
+
+                        new XElement("ntotalnum",item.数量),
+                        new XElement("ntotalinvoicenum","1"),
+                        new XElement("ntotalweight","0"),
+                        new XElement("ntotalvolume","0"),
+                        new XElement("ntotalpiece",""),
+                        new XElement("ntotalorigmny",item.价税合计),
+                        new XElement("bcooptopoflag","N"),
+                        new XElement("fstatusflag","2"),
+                        new XElement("fpfstatusflag","1"),
+                        new XElement("approver",item.审批人),
+                        new XElement("taudittime",item.审批时间),
+                        new XElement("billmaker",item.制单人),
+                        new XElement("dmakedate",item.制单时间),
+                        new XElement("creator",item.创建人),
+                        new XElement("creationtime",item.创建时间),
+                        new XElement("modifier",""),
+                        new XElement("modifiedtime",""),
+                        new XElement("vdef4",item.开票类型),
+                        new XElement("vdef1",item.OA单据号),
+                        new XElement("vdef5",item.合同业务类型),
+                        new XElement("vdef8",item.客户打印名称),
+
+                        new XElement("so_saleorder_b",so_saleorder_b),
+                    }),
+                });
+            }
+        }
+
+        public class ImportXml_销售发票
+        {
+            /// <summary>
+            /// 模板头部份
+            /// </summary>
+            /// <returns></returns>
+            public static XElement TemplateHeade()
+            {
+
+                return new XElement(new XElement("ufinterface", new object[]
+                {
+                new XAttribute("sender","dingding"),
+                new XAttribute("roottag",""),
+                new XAttribute("replace","Y"),
+                new XAttribute("isexchange","Y"),
+                new XAttribute("groupcode","0"),
+                new XAttribute("filename",""),
+                new XAttribute("billtype","32"),
+                new XAttribute("account","develop")
+                }));
+            }
+
+            /// <summary>
+            /// 组建表头xml
+            /// </summary>
+            /// <param name="item">表头参数</param>
+            /// <returns></returns>
+            public static XElement Header(DataModel item, string id)
+            {
+                var csaleinvoicebid = new List<XElement>();
+
+                if (item.明细 != null && item.明细.Count > 0)
+                {
+                    var crowno = 10; // 行号
+
+                    foreach (var itemData in item.明细)
+                    {
+                        csaleinvoicebid.Add(new XElement("item", new object[] {
+                            new XElement("pk_group",item.集团),
+                            new XElement("pk_org",item.组织),
+                            new XElement("dbilldate",item.单据日期),
+                            new XElement("crowno",crowno.ToString()),
+
+                            new XElement("cmaterialvid",itemData.物料),
+                            new XElement("cmaterialid",itemData.物料),
+                            new XElement("cvendorid",""),
+                            new XElement("cprojectid",item.项目),
+                            new XElement("cproductorid",""),
+                            new XElement("castunitid",itemData.计量单位),
+                            new XElement("nastnum",itemData.数量),
+                            new XElement("cunitid",itemData.计量单位),
+                            new XElement("nnum",itemData.数量),
+                            new XElement("vchangerate",itemData.换算率),
+                            new XElement("cqtunitid",itemData.计量单位),
+                            new XElement("vqtunitrate",itemData.换算率),
+                            new XElement("nqtunitnum",itemData.数量),
+
+                            new XElement("bdiscountflag","N"),
+                            new XElement("blaborflag","N"),
+                            new XElement("blargessflag","N"),
+                            new XElement("pk_batchcode",""),
+                            new XElement("vbatchcode",""),
+
+                            new XElement("ctaxcodeid",itemData.税码),
+                            new XElement("ntaxrate",itemData.税率),
+                            new XElement("ftaxtypeflag","1"),
+                            new XElement("ndiscountrate",item.折扣),
+                            new XElement("nitemdiscountrate",item.折扣),
+                            new XElement("ninvoicedisrate",item.折扣),
+
+                            new XElement("norigtaxprice",itemData.含税单价),
+                            new XElement("nqtorigtaxprice",itemData.含税单价),
+                            new XElement("nqttaxprice",itemData.含税单价),
+                            new XElement("ntaxprice",itemData.含税单价),
+
+                            new XElement("nqtorigprice",itemData.无税单价),
+                            new XElement("nqtorignetprice",itemData.无税单价),
+                            new XElement("norigprice",itemData.无税单价),
+                            new XElement("nprice",itemData.无税单价),
+                            new XElement("nqtprice",itemData.无税单价),
+
+                            new XElement("nqtorigtaxnetprc",itemData.含税净价),
+                            new XElement("norigtaxnetprice",itemData.含税净价),
+                            new XElement("nqttaxnetprice",itemData.含税净价),
+                            new XElement("ntaxnetprice",itemData.含税净价),
+
+                            new XElement("norignetprice",itemData.无税净价),
+                            new XElement("nnetprice",itemData.无税净价),
+                            new XElement("nqtnetprice",itemData.无税净价),
+
+                            new XElement("ntax",itemData.税额),
+
+                            new XElement("ncaltaxmny",itemData.无税金额),
+                            new XElement("norigmny",itemData.无税金额),
+                            new XElement("nmny",itemData.无税金额),
+
+                            new XElement("norigtaxmny",itemData.价税合计),
+                            new XElement("ntaxmny",itemData.价税合计),
+
+                            new XElement("norigdiscount","0"),
+                            new XElement("ndiscount","0"),
+                            new XElement("norigsubmny","0"),
+                            new XElement("ngroupmny","0"),
+                            new XElement("ngrouptaxmny","0"),
+                            new XElement("nglobalmny","0"),
+                            new XElement("nglobaltaxmny","0"),
+
+                            new XElement("vfirsttype",item.销售订单单据类型),
+                            new XElement("vfirstcode",item.销售订单单据号),
+                            new XElement("vfirsttrantype",item.销售订单单据类型),
+                            new XElement("vfirstrowno",crowno.ToString()),
+                            new XElement("cfirstid",item.销售订单主表id),
+                            new XElement("cfirstbid",itemData.销售订单子表id),
+
+                            new XElement("vsrctype",item.销售订单单据大类),
+                            new XElement("vsrccode",item.销售订单单据号),
+                            new XElement("vsrctrantype",item.销售订单单据大类),
+                            new XElement("vsrcrowno",crowno.ToString()),
+                            new XElement("csrcid",item.销售订单主表id),
+                            new XElement("csrcbid",itemData.销售订单子表id),
+
+                            new XElement("copposesrcbid",""),
+
+                            new XElement("csaleorgid",item.组织),
+                            new XElement("csaleorgvid",item.组织),
+                            new XElement("carorgid",item.组织),
+                            new XElement("carorgvid",item.组织),
+                            new XElement("cordercustid",item.客户),
+                            new XElement("bfreecustflag","N"),
+                            new XElement("cfreecustid",""),
+
+                            new XElement("cdeptid",""),
+                            new XElement("cdeptvid",""),
+                            new XElement("cemployeeid",""),
+                            new XElement("cchanneltypeid",""),
+
+                            new XElement("creceivecustid",item.客户),
+                            new XElement("creceiveaddrid",""),
+                            new XElement("ctransporttypeid",""),
+
+                            new XElement("csendstockorgid",item.组织),
+                            new XElement("csendstockorgvid",item.组织),
+
+                            new XElement("csendstordocid",""),
+                            new XElement("cprodlineid",""),
+                            new XElement("ccostsubjid",""),
+                            new XElement("cctmanageid",""),
+                            new XElement("cvmivenderid",""),
+                            new XElement("vsumcode",""),
+
+                            new XElement("nshouldoutnum",""),
+                            new XElement("ntotaloutnum",""),
+                            new XElement("ntotalincomenum",""),
+                            new XElement("ntotalincomemny",""),
+                            new XElement("ntotalcostnum",""),
+                            new XElement("ntotalpaymny",""),
+                            new XElement("vrownote",""),
+
+                            new XElement("vbdef1",itemData.开票内容),
+                            new XElement("vbdef10",itemData.行id),
+
+                            new XElement("srcts",""),
+                            new XElement("srcbts",""),
+                            new XElement("ncanoutnum",""),
+                            new XElement("nsrcnum","1"),
+                            new XElement("cmarbascalssid",""),
+                        }));
+
+                        crowno = crowno + 10;
+                    }
+                }
+
+                return new XElement("bill", new object[]
+                {
+                    "",
+                    new XAttribute("id",id),
+                    new XElement("billhead", new object[]
+                    {
+                        new XElement("pk_group",item.集团),
+                        new XElement("pk_org",item.组织),
+                        new XElement("pk_org_v",item.组织),
+
+                        new XElement("ctrantypeid",item.销售发票单据类型),
+                        new XElement("vtrantypecode",item.销售发票单据类型),
+                        new XElement("cbiztypeid",item.业务流程),
+
+                        new XElement("vbillcode",item.发票号),
+
+                        new XElement("dbilldate",item.单据日期),
+                        new XElement("cinvoicecustid",item.客户),
+                        new XElement("vprintcustname",item.客户打印名称),
+                        new XElement("ccustbankid",""),
+                        new XElement("ccustbankaccid",""),
+                        new XElement("cpaytermid","01"),
+                        new XElement("vcreditnum",""),
+                        new XElement("vgoldtaxcode",""),
+                        new XElement("btogoldtaxflag","Y"),
+                        new XElement("tgoldtaxtime",item.创建时间),
+
+                        new XElement("corigcurrencyid",item.币种),
+                        new XElement("nexchangerate","1"),
+                        new XElement("ccurrencyid",item.币种),
+
+                        new XElement("ngroupexchgrate",""),
+                        new XElement("nglobalexchgrate",""),
+                        new XElement("nhvoicedisrate",""),
+
+                        new XElement("ntotalastnum",item.数量),
+                        new XElement("ntotalorigsubmny",""),
+                        new XElement("ntotalorigmny",item.价税合计),
+
+                        new XElement("csendcountryid",item.国家),
+                        new XElement("crececountryid",item.国家),
+                        new XElement("ctaxcountryid",item.国家),
+
+                        new XElement("fbuysellflag","1"),
+                        new XElement("btriatradeflag","N"),
+                        new XElement("vvatcode",""),
+                        new XElement("vcustvatcode",""),
+                        new XElement("ctradewordid",""),
+                        new XElement("bsubunitflag","N"),
+                        new XElement("fopposeflag",""),
+                        new XElement("vopposesrccode",""),
+                        new XElement("copposesrcid",""),
+                        new XElement("vnote",""),
+
+                        new XElement("fstatusflag","2"),
+
+                        new XElement("approver",item.审批人),
+                        new XElement("taudittime",item.审批时间),
+                        new XElement("billmaker",item.制单人),
+                        new XElement("dmakedate",item.制单时间),
+                        new XElement("creator",item.创建人),
+                        new XElement("creationtime",item.创建时间),
+                        new XElement("modifier",""),
+                        new XElement("modifiedtime",""),
+                        new XElement("iprintcount",""),
+
+                        new XElement("vdef1",item.OA单据号),
+                        new XElement("vdef2",item.发票号),
+                        new XElement("vdef4",item.开票类型),
+                        new XElement("vdef5",item.合同业务类型),
+
+                        new XElement("csaleinvoicebid",csaleinvoicebid),
+                    }),
+                });
+            }
+        }
+
+        public class ImportXml_应收单
+        {
+            /// <summary>
+            /// 模板头部份
+            /// </summary>
+            /// <returns></returns>
+            public static XElement TemplateHeade()
+            {
+
+                return new XElement(new XElement("ufinterface", new object[]
+                {
+                new XAttribute("sender","dingding"),
+                new XAttribute("roottag",""),
+                new XAttribute("replace","Y"),
+                new XAttribute("isexchange","Y"),
+                new XAttribute("groupcode","0"),
+                new XAttribute("filename",""),
+                new XAttribute("billtype","F0"),
+                new XAttribute("account","develop")
+                }));
+            }
+
+            /// <summary>
+            /// 组建表头xml
+            /// </summary>
+            /// <param name="item">表头参数</param>
+            /// <returns></returns>
+            public static XElement Header(DataModel item, string id)
+            {
+                var bodys = new List<XElement>();
+
+                if (item.明细 != null && item.明细.Count > 0)
+                {
+                    var crowno = 10; // 行号
+
+                    foreach (var itemData in item.明细)
+                    {
+                        bodys.Add(new XElement("item", new object[] {
+                            new XElement("pk_group",item.集团),
+                            new XElement("pk_org",item.组织),
+                            new XElement("pk_pcorg",""),
+                            new XElement("pk_fiorg",item.组织),
+                            new XElement("sett_org",item.组织),
+                            new XElement("so_org",item.组织),
+
+                            new XElement("material",itemData.物料),
+                            new XElement("customer",item.客户),
+                            new XElement("postunit",itemData.计量单位),
+
+                            new XElement("postpricenotax",itemData.无税单价),
+                            new XElement("postquantity",itemData.数量),
+                            new XElement("postprice",itemData.含税单价),
+
+                            new XElement("pausetransact","N"),
+
+                            new XElement("billdate",item.单据日期),
+                            new XElement("pk_billtype",item.应收单单据类型),
+                            new XElement("billclass",item.应收单单据大类),
+                            new XElement("pk_tradetype",item.应收类型),
+                            new XElement("busidate",item.单据日期),
+
+                            new XElement("objtype","0"),
+                            new XElement("rowno",crowno.ToString()),
+                            new XElement("rowtype","0"),
+                            new XElement("direction","1"),
+
+                            new XElement("pk_currtype",item.币种),
+                            new XElement("rate",item.汇率),
+
+                            new XElement("money_de",itemData.价税合计),
+                            new XElement("local_money_de",itemData.价税合计),
+                            new XElement("quantity_de",itemData.数量),
+                            new XElement("money_bal",itemData.价税合计),
+                            new XElement("local_money_bal",itemData.价税合计),
+                            new XElement("quantity_bal",itemData.数量),
+
+                            new XElement("local_tax_de",itemData.税额),
+
+                            new XElement("notax_de",itemData.无税金额),
+                            new XElement("local_notax_de",itemData.无税金额),
+
+                            new XElement("price",itemData.无税单价),
+                            new XElement("taxprice",itemData.含税单价),
+                            new XElement("taxrate",itemData.税率),
+
+                            new XElement("top_billid",item.销售发票主表id),
+                            // new XElement("top_itemid",itemData.销售发票子表id),
+                            new XElement("top_billtype",item.销售发票单据大类),
+                            new XElement("top_tradetype",item.销售发票单据类型),
+
+                            new XElement("src_billid",item.销售订单主表id),
+                            new XElement("src_itemid",itemData.销售订单子表id),
+                            new XElement("src_billtype",item.销售订单单据大类),
+                            new XElement("src_tradetype",item.销售订单单据类型),
+
+                            new XElement("taxtype","1"),
+                            new XElement("pk_payterm",item.收款协议),
+                            new XElement("ordercubasdoc",item.客户),
+
+                            new XElement("purchaseorder",item.销售订单单据号),
+                            new XElement("invoiceno",item.发票号),
+
+                            new XElement("vbdef1",itemData.开票内容),
+                            new XElement("vbdef10",itemData.行id),
+
+                            new XElement("grouprate","0"),
+                            new XElement("globalrate","0"),
+                            new XElement("groupdebit","0"),
+                            new XElement("globaldebit","0"),
+                            new XElement("groupbalance","0"),
+                            new XElement("globalbalance","0"),
+                            new XElement("groupnotax_de","0"),
+                            new XElement("globalnotax_de","0"),
+                            new XElement("occupationmny","0"),
+
+                            new XElement("project",item.项目),
+
+                            new XElement("rececountryid",item.国家),
+                            new XElement("buysellflag","1"),
+                            new XElement("taxcodeid",itemData.税码),
+                            new XElement("caltaxmny",itemData.无税金额),
+                        }));
+
+                        crowno = crowno + 10;
+                    }
+                }
+
+                return new XElement("bill", new object[]
+                {
+                    "",
+                    new XAttribute("id",id),
+                    new XElement("billhead", new object[]
+                    {
+                        new XElement("pk_group",item.集团),
+                        new XElement("pk_org",item.组织),
+                        new XElement("pk_fiorg",item.组织),
+                        new XElement("pk_pcorg",""),
+                        new XElement("sett_org",item.组织),
+
+                        new XElement("isreded","N"),
+                        new XElement("outbusitype",""),
+                        new XElement("officialprintuser",""),
+                        new XElement("officialprintdate",""),
+
+                        new XElement("approver",""),
+                        new XElement("taudittime",""),
+                        new XElement("billmaker",item.制单人),
+                        new XElement("dmakedate",item.制单时间),
+                        new XElement("creator",item.创建人),
+                        new XElement("creationtime",item.创建时间),
+                        new XElement("modifier",""),
+                        new XElement("modifiedtime",""),
+
+                        new XElement("pk_billtype",item.应收单单据类型),
+                        new XElement("custdelegate",""),
+                        new XElement("pk_corp",""),
+                        new XElement("pk_tradetype",item.应收类型),
+                        new XElement("pk_tradetype",item.应收类型),
+
+                        new XElement("ctrantypeid",item.销售发票单据类型),
+                        new XElement("vtrantypecode",item.销售发票单据类型),
+                        new XElement("pk_busitype",item.业务流程),
+                        new XElement("billclass",item.应收单单据大类),
+
+                        new XElement("accessorynum","0"),
+                        new XElement("subjcode",""),
+                        new XElement("isflowbill","N"),
+                        new XElement("confirmuser",""),
+                        new XElement("isinit","N"),
+
+                        new XElement("billno",item.OA单据号),
+                        new XElement("billdate",item.单据日期),
+
+                        new XElement("syscode","0"),
+                        new XElement("src_syscode","3"),
+                        new XElement("billstatus","-1"),
+                        new XElement("lastadjustuser",""),
+
+                        new XElement("money",item.价税合计),
+                        new XElement("local_money",item.价税合计),
+                        new XElement("rate",""),
+                        new XElement("billyear",item.年份),
+                        new XElement("billperiod",item.月份),
+
+                        new XElement("scomment",""),
+                        new XElement("effectstatus","10"),
+                        new XElement("effectuser",""),
+                        new XElement("effectdate",""),
+                        new XElement("lastapproveid",""),
+
+                        new XElement("so_org",item.组织),
+                        new XElement("customer",item.客户),
+                        new XElement("pk_currtype",item.币种),
+
+                        new XElement("sendcountryid",item.国家),
+                        new XElement("taxcountryid",item.国家),
+
+                        new XElement("coordflag",""),
+                        new XElement("inner_effect_date",""),
+                        new XElement("busidate",""),
+
+                        new XElement("bodys",bodys),
+                    }),
+                });
+            }
+        }
+    }
+}

+ 98 - 0
HH.YiDaSyncNC/Models/WL_SyncServiceModel.cs

@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.Models
+{
+    class WL_SyncServiceModel
+    {
+        public class DataModel
+        {
+            public string pk_group { get; set; }
+            public string pk_org { get; set; }
+            public string code { get; set; }
+            public string name { get; set; }
+            public string ename { get; set; }
+            public string pk_marbasclass { get; set; }
+            public string pk_measdoc { get; set; }
+
+            public string pk_mattaxes { get; set; }
+            public string materialshortname { get; set; }
+            public string materialspec { get; set; }
+            public string materialtype { get; set; }
+            public string ematerialspec { get; set; }
+            public string pk_brand { get; set; }
+            public string materialmnecode { get; set; }
+
+            public string enablestate { get; set; }
+        }
+
+        public class ImportXml
+        {
+            /// <summary>
+            /// 模板头部份
+            /// </summary>
+            /// <returns></returns>
+            public static XElement TemplateHeade()
+            {
+
+                return new XElement(new XElement("ufinterface", new object[]
+                {
+                new XAttribute("sender","dingding"),
+                new XAttribute("roottag",""),
+                new XAttribute("replace","Y"),
+                new XAttribute("isexchange","Y"),
+                new XAttribute("groupcode","0"),
+                new XAttribute("filename",""),
+                new XAttribute("billtype","material"),
+                new XAttribute("proc","add"),
+                new XAttribute("account","develop")
+                }));
+            }
+
+            /// <summary>
+            /// 组建表头xml
+            /// </summary>
+            /// <param name="item">表头参数</param>
+            /// <returns></returns>
+            public static XElement Header(DataModel item, string id)
+            {
+                return new XElement("bill", new object[]
+                {
+                "",
+                new XAttribute("id",id),
+                new XElement("billhead", new object[]
+                {
+                    new XElement("pk_group",item.pk_group),
+                    new XElement("pk_org",item.pk_org),
+                    //new XElement("pk_source",item.pk_source),
+                    new XElement("code",item.code),
+                    new XElement("name",item.name),
+                    new XElement("ename",item.ename),
+                    new XElement("pk_marbasclass",item.pk_marbasclass),
+                    new XElement("pk_measdoc",item.pk_measdoc),
+
+                    new XElement("pk_mattaxes",item.pk_mattaxes),
+                    new XElement("materialshortname",item.materialshortname),
+                    new XElement("materialspec",item.materialspec),
+                    new XElement("materialtype",item.materialtype),
+                    new XElement("ematerialspec",item.ematerialspec),
+                    new XElement("pk_brand",item.pk_brand),
+                    new XElement("materialmnecode",item.materialmnecode),
+
+                    new XElement("productfamily","N"),
+                    new XElement("intolerance","0"),
+                    new XElement("outtolerance","0"),
+                    new XElement("outcloselowerlimit","0"),
+                    new XElement("enablestate",item.enablestate),
+                    //new XElement("materialconvert",new object[]{ }),
+                    //new XElement("materialtaxtype",new object[]{ }),
+                }),
+                });
+            }
+        }
+    }
+}

+ 86 - 0
HH.YiDaSyncNC/Models/XMD_SyncServiceModel.cs

@@ -0,0 +1,86 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.Models
+{
+    class XMD_SyncServiceModel
+    {
+        public class DataModel
+        {
+            public string pk_group { get; set; }
+            public string pk_org { get; set; }
+            public string code { get; set; }
+            public string name { get; set; }
+            public string pk_marbasclass { get; set; }
+            public string pk_measdoc { get; set; }
+            public string pk_mattaxes { get; set; }
+            public string materialspec { get; set; }
+            public string materialtype { get; set; }
+            public string pk_brand { get; set; }
+            public string enablestate { get; set; }
+        }
+
+        public class ImportXml
+        {
+            /// <summary>
+            /// 模板头部份
+            /// </summary>
+            /// <returns></returns>
+            public static XElement TemplateHeade()
+            {
+
+                return new XElement(new XElement("ufinterface", new object[]
+                {
+                new XAttribute("sender","dingding"),
+                new XAttribute("roottag",""),
+                new XAttribute("replace","Y"),
+                new XAttribute("isexchange","Y"),
+                new XAttribute("groupcode","0"),
+                new XAttribute("filename",""),
+                new XAttribute("billtype","material"),
+                new XAttribute("proc","add"),
+                new XAttribute("account","develop")
+                }));
+            }
+
+            /// <summary>
+            /// 组建表头xml
+            /// </summary>
+            /// <param name="item">表头参数</param>
+            /// <returns></returns>
+            public static XElement Header(DataModel item, string id)
+            {
+                return new XElement("bill", new object[]
+                {
+                "",
+                new XAttribute("id",id),
+                new XElement("billhead", new object[]
+                {
+                    new XElement("pk_group",item.pk_group),
+                    new XElement("pk_org",item.pk_org),
+                    //new XElement("pk_source",item.pk_source),
+                    new XElement("code",item.code),
+                    new XElement("name",item.name),
+                    new XElement("pk_marbasclass",item.pk_marbasclass),
+                    new XElement("pk_measdoc",item.pk_measdoc),
+                    new XElement("pk_mattaxes",item.pk_mattaxes),
+                    new XElement("materialspec",item.materialspec),
+                    new XElement("materialtype",item.materialtype),
+                    new XElement("pk_brand",item.pk_brand),
+                    new XElement("productfamily","N"),
+                    new XElement("intolerance","0"),
+                    new XElement("outtolerance","0"),
+                    new XElement("outcloselowerlimit","0"),
+                    new XElement("enablestate",item.enablestate),
+                    //new XElement("materialconvert",new object[]{ }),
+                    //new XElement("materialtaxtype",new object[]{ }),
+                }),
+                });
+            }
+        }
+    }
+}

+ 278 - 0
HH.YiDaSyncNC/Models/XSFP_SyncServiceModel.cs

@@ -0,0 +1,278 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC.Models
+{
+    class XSFP_SyncServiceModel
+    {
+        public class DataModel
+        {
+            public string pk_group { get; set; }
+            public string pk_org { get; set; }
+            public string pk_org_v { get; set; }
+
+            public string ctrantypeid { get; set; }
+            public string vtrantypecode { get; set; }
+            public string cbiztypeid { get; set; }
+
+            public string vbillcode { get; set; }
+            public string dbilldate { get; set; }
+
+            public string vprintcustname { get; set; }
+            public string ccustbankid { get; set; }
+            public string ccustbankaccid { get; set; }
+
+            public string cdeptvid { get; set; }
+            public string cdeptid { get; set; }
+            public string cemployeeid { get; set; }
+            public string corigcurrencyid { get; set; }
+            public string cinvoicecustid { get; set; }
+
+            public string cpaytermid { get; set; }
+            public string approver { get; set; }
+            public string taudittime { get; set; }
+
+            public string billmaker { get; set; }
+            public string dmakedate { get; set; }
+            public string creator { get; set; }
+            public string creationtime { get; set; }
+
+            public string ntotalnum { get; set; }
+            public string ntotalorigmny { get; set; }
+
+            public List<OrderB> so_saleorder_b { get; set; }
+
+            public class OrderB
+            {
+                public string carorgvid { get; set; }
+                public string carorgid { get; set; }
+                public string csendstockorgvid { get; set; }
+                public string csendstockorgid { get; set; }
+
+                public string creceivecustid { get; set; }
+                public string crececountryid { get; set; }
+                public string csendcountryid { get; set; }
+                public string ctaxcountryid { get; set; }
+
+                public string pk_group { get; set; }
+                public string pk_org { get; set; }
+                public string dbilldate { get; set; }
+
+                public string crowno { get; set; }
+                public string cprojectid { get; set; }
+
+                public string cmaterialvid { get; set; }
+                public string cmaterialid { get; set; }
+                public string cunitid { get; set; }
+                public string castunitid { get; set; }
+
+                public string nastnum { get; set; }
+                public string vchangerate { get; set; }
+                public string cqtunitid { get; set; }
+                public string nqtunitnum { get; set; }
+                public string nnum { get; set; }
+                public string vqtunitrate { get; set; }
+                public string ctaxcodeid { get; set; }
+                public string ntaxrate { get; set; }
+                public string ccurrencyid { get; set; }
+
+                public string norigtaxprice { get; set; }
+                public string nqtorigtaxprice { get; set; }
+                public string nqttaxprice { get; set; }
+                public string ntaxprice { get; set; }
+
+                public string nqtorigprice { get; set; }
+                public string nqtorignetprice { get; set; }
+                public string norigprice { get; set; }
+                public string nprice { get; set; }
+                public string nqtprice { get; set; }
+
+                public string nqtorigtaxnetprc { get; set; }
+                public string norigtaxnetprice { get; set; }
+                public string nqttaxnetprice { get; set; }
+                public string ntaxnetprice { get; set; }
+
+                public string norignetprice { get; set; }
+                public string nnetprice { get; set; }
+                public string nqtnetprice { get; set; }
+
+                public string ntax { get; set; }
+
+                public string ncaltaxmny { get; set; }
+                public string norigmny { get; set; }
+                public string nmny { get; set; }
+
+                public string norigtaxmny { get; set; }
+                public string ntaxmny { get; set; }
+
+                public string vsrctype { get; set; }
+                public string vsrccode { get; set; }
+                public string vsrctrantype { get; set; }
+                public string vsrcrowno { get; set; }
+            }
+        }
+
+        public class ImportXml
+        {
+            /// <summary>
+            /// 模板头部份
+            /// </summary>
+            /// <returns></returns>
+            public static XElement TemplateHeade()
+            {
+
+                return new XElement(new XElement("ufinterface", new object[]
+                {
+                new XAttribute("sender","dingding"),
+                new XAttribute("roottag",""),
+                new XAttribute("replace","Y"),
+                new XAttribute("isexchange","Y"),
+                new XAttribute("groupcode","0"),
+                new XAttribute("filename",""),
+                new XAttribute("billtype","32"),
+                new XAttribute("account","develop")
+                }));
+            }
+
+            /// <summary>
+            /// 组建表头xml
+            /// </summary>
+            /// <param name="item">表头参数</param>
+            /// <returns></returns>
+            public static XElement Header(DataModel item, string id)
+            {
+                var so_saleorder_b = new List<XElement>();
+
+                if (item.so_saleorder_b != null && item.so_saleorder_b.Count > 0)
+                {
+                    foreach (var itemData in item.so_saleorder_b)
+                    {
+                        so_saleorder_b.Add(new XElement("item", new object[] {
+                            new XElement("carorgvid",itemData.carorgvid),
+                            new XElement("carorgid",itemData.carorgid),
+                            new XElement("csendstockorgvid",itemData.csendstockorgvid),
+                            new XElement("csendstockorgid",itemData.csendstockorgid),
+
+                            new XElement("creceivecustid",itemData.creceivecustid),
+                            new XElement("crececountryid",itemData.crececountryid),
+                            new XElement("csendcountryid",itemData.csendcountryid),
+                            new XElement("ctaxcountryid",itemData.ctaxcountryid),
+
+                            new XElement("pk_group",itemData.pk_group),
+                            new XElement("pk_org",itemData.pk_org),
+                            new XElement("dbilldate",itemData.dbilldate),
+
+                            new XElement("crowno",itemData.crowno),
+                            new XElement("cprojectid",itemData.cprojectid),
+                            new XElement("fbuysellflag","1"),
+
+                            new XElement("cmaterialvid",itemData.cmaterialvid),
+                            new XElement("cmaterialid",itemData.cmaterialid),
+                            new XElement("cunitid",itemData.cunitid),
+                            new XElement("castunitid",itemData.castunitid),
+
+                            new XElement("nastnum",itemData.nastnum),
+                            new XElement("vchangerate",itemData.vchangerate),
+                            new XElement("cqtunitid",itemData.cqtunitid),
+                            new XElement("nqtunitnum",itemData.nqtunitnum),
+                            new XElement("nnum",itemData.nnum),
+                            new XElement("vqtunitrate",itemData.vqtunitrate),
+                            new XElement("ctaxcodeid",itemData.ctaxcodeid),
+                            new XElement("ntaxrate",itemData.ntaxrate),
+                            new XElement("ftaxtypeflag","1"),
+                            new XElement("ccurrencyid",itemData.ccurrencyid),
+                            new XElement("nexchangerate","1"),
+                            new XElement("ndiscount","0"),
+                            new XElement("ndiscountrate","100"),
+                            new XElement("nitemdiscountrate","100"),
+
+                            new XElement("norigtaxprice",itemData.norigtaxprice),
+                            new XElement("nqtorigtaxprice",itemData.nqtorigtaxprice),
+                            new XElement("nqttaxprice",itemData.nqttaxprice),
+                            new XElement("ntaxprice",itemData.ntaxprice),
+
+                            new XElement("nqtorigprice",itemData.nqtorigprice),
+                            new XElement("nqtorignetprice",itemData.nqtorignetprice),
+                            new XElement("norigprice",itemData.norigprice),
+                            new XElement("nprice",itemData.nprice),
+                            new XElement("nqtprice",itemData.nqtprice),
+
+                            new XElement("nqtorigtaxnetprc",itemData.nqtorigtaxnetprc),
+                            new XElement("norigtaxnetprice",itemData.norigtaxnetprice),
+                            new XElement("nqttaxnetprice",itemData.nqttaxnetprice),
+                            new XElement("ntaxnetprice",itemData.ntaxnetprice),
+
+                            new XElement("norignetprice",itemData.norignetprice),
+                            new XElement("nnetprice",itemData.nnetprice),
+                            new XElement("nqtnetprice",itemData.nqtnetprice),
+
+                            new XElement("ntax",itemData.ntax),
+
+                            new XElement("ncaltaxmny",itemData.ncaltaxmny),
+                            new XElement("norigmny",itemData.norigmny),
+                            new XElement("nmny",itemData.nmny),
+
+                            new XElement("norigtaxmny",itemData.norigtaxmny),
+                            new XElement("ntaxmny",itemData.ntaxmny),
+
+                            new XElement("norigdiscount","0"),
+
+                            new XElement("vsrctype",itemData.vsrctype),
+                            new XElement("vsrccode",itemData.vsrccode),
+                            new XElement("vsrctrantype",itemData.vsrctrantype),
+                            new XElement("vsrcrowno",itemData.vsrcrowno),
+                        }));
+                    }
+                }
+
+                return new XElement("bill", new object[]
+                {
+                "",
+                new XAttribute("id",id),
+                new XElement("billhead", new object[]
+                {
+                    new XElement("pk_group",item.pk_group),
+                    new XElement("pk_org",item.pk_org),
+                    new XElement("pk_org_v",item.pk_org_v),
+
+                    new XElement("ctrantypeid",item.ctrantypeid),
+                    new XElement("vtrantypecode",item.vtrantypecode),
+                    new XElement("cbiztypeid",item.cbiztypeid),
+
+                    new XElement("vbillcode",item.vbillcode),
+                    new XElement("dbilldate",item.dbilldate),
+
+                    new XElement("vprintcustname",item.vprintcustname),
+                    new XElement("ccustbankid",item.ccustbankid),
+                    new XElement("ccustbankaccid",item.ccustbankaccid),
+
+                    new XElement("cdeptvid",item.cdeptvid),
+                    new XElement("cdeptid",item.cdeptid),
+                    new XElement("cemployeeid",item.cemployeeid),
+                    new XElement("corigcurrencyid",item.corigcurrencyid),
+                    new XElement("cinvoicecustid",item.cinvoicecustid),
+
+                    new XElement("cpaytermid",item.cpaytermid),
+                    new XElement("fstatusflag","1"),
+                    new XElement("approver",item.approver),
+                    new XElement("taudittime",item.taudittime),
+
+                    new XElement("billmaker",item.billmaker),
+                    new XElement("dmakedate",item.dmakedate),
+                    new XElement("creator",item.creator),
+                    new XElement("creationtime",item.creationtime),
+
+                    new XElement("ntotalnum",item.ntotalnum),
+                    new XElement("ntotalorigmny",item.ntotalorigmny),
+
+                    new XElement("csaleinvoicebid",so_saleorder_b),
+                }),
+                });
+            }
+        }
+    }
+}

+ 89 - 0
HH.YiDaSyncNC/Program.cs

@@ -0,0 +1,89 @@
+using HH.YiDaSyncNC.DataSync;
+using HH.YiDaSyncNC.Helper;
+using Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Linq;
+
+namespace HH.YiDaSyncNC
+{
+    class Program
+    {
+        #region 数据库对象
+        public static SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
+        {
+            ConnectionString = ConfigurationManager.AppSettings["Conn_NC"].ToString(),
+            DbType = DbType.SqlServer,
+            IsAutoCloseConnection = true
+        });
+
+        public static SqlSugarClient db_nc = new SqlSugarClient(new ConnectionConfig()
+        {
+            ConnectionString = ConfigurationManager.AppSettings["Conn_NC"].ToString(),
+            DbType = DbType.SqlServer,
+            IsAutoCloseConnection = true
+        });
+        #endregion
+
+        public static string _Static_AppType = ConfigurationManager.AppSettings["AppType"];
+        public static string _Static_SystemToken = ConfigurationManager.AppSettings["SystemToken"];
+        public static string _Static_UserId = ConfigurationManager.AppSettings["UserId"];
+        public static string _Static_FormId_WL = ConfigurationManager.AppSettings["FormId_WL"];
+        public static string _Static_FormId_XMD = ConfigurationManager.AppSettings["FormId_XMD"];
+        public static string _Static_FormId_GYS = ConfigurationManager.AppSettings["FormId_GYS"];
+        public static string _Static_FormId_KH = ConfigurationManager.AppSettings["FormId_KH"];
+        public static string _Static_FormId_ZC = ConfigurationManager.AppSettings["FormId_ZC"];
+        public static string _Static_FormId_CGDD = ConfigurationManager.AppSettings["FormId_CGDD"];
+        public static string _Static_FormId_KP = ConfigurationManager.AppSettings["FormId_KP"];
+        public static string _Static_FormId_FK = ConfigurationManager.AppSettings["FormId_FK"];
+
+        public static string _Static_NCApiUrl = ConfigurationManager.AppSettings["NCApiUrl"];
+
+        static void Main(string[] args)
+        {
+            try
+            {
+
+                //WL_SyncService wL_SyncService = new WL_SyncService(_Static_AppType, _Static_SystemToken, _Static_UserId, _Static_FormId_WL, db, db_nc, _Static_NCApiUrl);
+                //wL_SyncService.DataSync();
+
+                //XMD_SyncService xMD_SyncService = new XMD_SyncService(_Static_AppType, _Static_SystemToken, _Static_UserId, _Static_FormId_XMD, db, db_nc, _Static_NCApiUrl);
+                //xMD_SyncService.DataSync();
+
+                //ZC_SyncService zc_SyncService = new ZC_SyncService(_Static_AppType, _Static_SystemToken, _Static_UserId, _Static_FormId_ZC, db, db_nc, _Static_NCApiUrl);
+                //zc_SyncService.DataSync();
+
+                //GYS_SyncService gYS_SyncService = new GYS_SyncService(_Static_AppType, _Static_SystemToken, _Static_UserId, _Static_FormId_GYS, db, db_nc, _Static_NCApiUrl);
+                //gYS_SyncService.DataSync();
+
+                //KH_SyncService kh_SyncService = new KH_SyncService(_Static_AppType, _Static_SystemToken, _Static_UserId, _Static_FormId_KH, db, db_nc, _Static_NCApiUrl);
+                //kh_SyncService.DataSync();
+
+                //KP_SyncService kp_SyncService = new KP_SyncService(_Static_AppType, _Static_SystemToken, _Static_UserId, _Static_FormId_KP, db, db_nc, _Static_NCApiUrl);
+                //kp_SyncService.DataSync();
+
+                CGDD_SyncService cgdd_SyncService = new CGDD_SyncService(_Static_AppType, _Static_SystemToken, _Static_UserId, _Static_FormId_CGDD, db, db_nc, _Static_NCApiUrl);
+                cgdd_SyncService.DataSync();
+
+                // 付款单
+                //FK_SyncService fk_SyncService = new FK_SyncService(_Static_AppType, _Static_SystemToken, _Static_UserId, _Static_FormId_FK, db, db_nc, _Static_NCApiUrl);
+                //fk_SyncService.DataSync();
+
+                Environment.Exit(0);
+            }
+            catch (Exception ex)
+            {
+                LogHelper.WriteLog(JsonConvert.SerializeObject(ex), "同步异常");
+                Console.WriteLine($@"结束同步:{DateTime.Now}");
+                Environment.Exit(0);
+            }
+        }
+    }
+}

+ 36 - 0
HH.YiDaSyncNC/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("HH.YiDaSyncNC")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HH.YiDaSyncNC")]
+[assembly: AssemblyCopyright("Copyright ©  2024")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("0c9830b2-d208-41cc-966b-e3509b3b3fc6")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

BIN
HH.YiDaSyncNC/lib/RestSharp.dll


BIN
HH.YiDaSyncNC/lib/TopSdk.dll


+ 28 - 0
HH.YiDaSyncNC/packages.config

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="AlibabaCloud.EndpointUtil" version="0.1.1" targetFramework="net472" />
+  <package id="AlibabaCloud.GatewayDingTalk" version="1.0.2" targetFramework="net472" />
+  <package id="AlibabaCloud.GatewaySpi" version="0.0.2" targetFramework="net472" />
+  <package id="AlibabaCloud.OpenApiClient" version="0.1.6" targetFramework="net472" />
+  <package id="AlibabaCloud.OpenApiUtil" version="1.1.1" targetFramework="net472" />
+  <package id="AlibabaCloud.SDK.Dingtalk" version="2.0.27" targetFramework="net472" />
+  <package id="AlibabaCloud.TeaUtil" version="0.1.17" targetFramework="net472" />
+  <package id="AlibabaCloud.TeaXML" version="0.0.3" targetFramework="net472" />
+  <package id="Aliyun.Credentials" version="1.3.1" targetFramework="net472" />
+  <package id="Microsoft.Bcl" version="1.1.10" targetFramework="net472" />
+  <package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
+  <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net472" />
+  <package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net472" />
+  <package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
+  <package id="RestSharp" version="110.2.0" targetFramework="net472" />
+  <package id="SqlSugar" version="5.1.4.67" targetFramework="net472" />
+  <package id="System.Buffers" version="4.5.1" targetFramework="net472" />
+  <package id="System.Memory" version="4.5.5" targetFramework="net472" />
+  <package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
+  <package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
+  <package id="System.Text.Encodings.Web" version="7.0.0" targetFramework="net472" />
+  <package id="System.Text.Json" version="7.0.2" targetFramework="net472" />
+  <package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
+  <package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
+  <package id="Tea" version="1.1.2" targetFramework="net472" />
+</packages>