From 634c9e4a9e16077795233cf460c949e396b943ec Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期一, 02 九月 2024 13:05:09 +0800
Subject: [PATCH] 钉钉数据同步:宜搭单据 同步 实例状态、审批结果

---
 sdk_dingding/TopSdk/bin/Debug/TopSdk.dll                         |    0 
 sdk_dingding/TopSdk/obj/Debug/TopSdk.pdb                         |    0 
 sdk_dingding/TopSdk/obj/Debug/TopSdk.dll                         |    0 
 WebAPI/Controllers/数据同步/钉钉同步/DD_DataSynchronizationController.cs |  177 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 sdk_dingding/TopSdk/bin/Debug/TopSdk.pdb                         |    0 
 5 files changed, 169 insertions(+), 8 deletions(-)

diff --git "a/WebAPI/Controllers/\346\225\260\346\215\256\345\220\214\346\255\245/\351\222\211\351\222\211\345\220\214\346\255\245/DD_DataSynchronizationController.cs" "b/WebAPI/Controllers/\346\225\260\346\215\256\345\220\214\346\255\245/\351\222\211\351\222\211\345\220\214\346\255\245/DD_DataSynchronizationController.cs"
index 0aec613..93ec4aa 100644
--- "a/WebAPI/Controllers/\346\225\260\346\215\256\345\220\214\346\255\245/\351\222\211\351\222\211\345\220\214\346\255\245/DD_DataSynchronizationController.cs"
+++ "b/WebAPI/Controllers/\346\225\260\346\215\256\345\220\214\346\255\245/\351\222\211\351\222\211\345\220\214\346\255\245/DD_DataSynchronizationController.cs"
@@ -100,6 +100,8 @@
             public string HOriginator;                          //鍙戣捣浜�
             public string HTitle;                               //鍗曟嵁鏍囬
 
+            public string HInstanceStatus;                      //瀹炰緥鐘舵��
+            public string HApprovedResult;                      //瀹℃壒缁撴灉
 
             //鍗曟嵁鍐呭
             public string HDate;                                //鏃ユ湡
@@ -124,6 +126,8 @@
             public string HOriginator;                          //鍙戣捣浜�
             public string HTitle;                               //鍗曟嵁鏍囬
 
+            public string HInstanceStatus;                      //瀹炰緥鐘舵��
+            public string HApprovedResult;                      //瀹℃壒缁撴灉
 
             //鍗曟嵁鍐呭
             public string HDate;                                //鏃ユ湡
@@ -155,6 +159,7 @@
             public string HTitle;                               //鍗曟嵁鏍囬
 
             public string HInstanceStatus;                      //瀹炰緥鐘舵��
+            public string HApprovedResult;                      //瀹℃壒缁撴灉
 
             //鍗曟嵁鍐呭
             public string HEmployeeID;                          //鎴愬憳ID
@@ -192,6 +197,8 @@
             public string HOriginator;                          //鍙戣捣浜�
             public string HTitle;                               //鍗曟嵁鏍囬
 
+            public string HInstanceStatus;                      //瀹炰緥鐘舵��
+            public string HApprovedResult;                      //瀹℃壒缁撴灉
 
             //鍗曟嵁鍐呭
             public string HQuestionType;                        //闂鍒嗙被
@@ -398,7 +405,7 @@
                 //OriginatorId = "12",                                                                                          //鏍规嵁娴佺▼鍙戣捣浜哄伐鍙锋煡璇€��
 
                 //TaskId = "12",                                                                                                //浠诲姟ID銆�
-                CreateFromTimeGMT = DateTime.Now.ToString("dd") == "01"?"2022-01-01":DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd"),                                          //鍒涘缓鏃堕棿璧峰鍊笺��
+                CreateFromTimeGMT = DateTime.Now.ToString("dd") == "01" ? "2022-01-01" : DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd"),                                          //鍒涘缓鏃堕棿璧峰鍊笺��
                 CreateToTimeGMT = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),                                               //鍒涘缓鏃堕棿缁堟鍊笺��
 
                 PageSize = pageSize,                                                  //鍒嗛〉澶у皬銆�
@@ -699,6 +706,49 @@
                                 oItem.HEmployeeID = ((List<object>)response.Body.Result[i].FormData["employeeField_ls9ma7h5_id"])[0].ToString().Replace("'", "");
                             }
 
+
+
+                            //鑾峰彇瀹炰緥鐘舵��
+                            GetInstanceByIdResponse response1 = new GetInstanceByIdResponse();
+                            if (getInstanceStatusByInstanceID__YiDa(appType, systemToken, userID, oItem.HInstanceID, ref response1, ref msg) == false)
+                            {
+                                return false;
+                            }
+
+                            oItem.HInstanceStatus = response1.Body.InstanceStatus;
+                            if (oItem.HInstanceStatus == "RUNNING")
+                            {
+                                oItem.HInstanceStatus = "杩愯涓�";
+                            }
+                            else if (oItem.HInstanceStatus == "TERMINATED")
+                            {
+                                oItem.HInstanceStatus = "宸茬粓姝�";
+                            }
+                            else if (oItem.HInstanceStatus == "COMPLETED")
+                            {
+                                oItem.HInstanceStatus = "宸插畬鎴�";
+                            }
+                            else if (oItem.HInstanceStatus == "ERROR")
+                            {
+                                oItem.HInstanceStatus = "寮傚父";
+                            }
+
+                            oItem.HApprovedResult = response1.Body.ApprovedResult;
+                            if (oItem.HApprovedResult == "agree")
+                            {
+                                oItem.HApprovedResult = "鍚屾剰";
+                            }
+                            else if (oItem.HApprovedResult == "disagree")
+                            {
+                                oItem.HApprovedResult = "鎷掔粷";
+                            }
+                            else
+                            {
+                                oItem.HApprovedResult = "";
+                            }
+
+
+
                             lsmain.Add(oItem);
                         }catch(Exception e)
                         {
@@ -755,7 +805,7 @@
 
             try
             {
-                oCN.BeginTran();
+              oCN.BeginTran();
                 foreach (YD_FenCengShenHeQianDaoBiao oItem in lsmain)
                 {
                     string sql_searchRepeat = "select * from DD_FenCengShenHeQianDaoBiao where HInstanceID = '" + oItem.HInstanceID + "'";
@@ -769,7 +819,8 @@
                     string sql_main = "insert into DD_FenCengShenHeQianDaoBiao" +
                         "(HMakerID,HMakeDate,HUpdaterID,HUpdater,HUpdateDate,HInstanceID,HOriginator,HTitle" +
                         ",HDate" +
-                        ",HCheckLevel,HArea,HEmployeeID,HEmplpyee) " +
+                        ",HCheckLevel,HArea,HEmployeeID,HEmplpyee" +
+                        ",HInstanceStatus,HApprovedResult) " +
                         "values(" +
                         "'" + oItem.HMakerID + "'" +
                         ",'" + oItem.HMakeDate + "'" +
@@ -785,6 +836,8 @@
                         ",'" + (oItem.HArea==null?"": oItem.HArea) + "'" +
                         ",'" + (oItem.HEmployeeID==null?"": oItem.HEmployeeID) + "'" +
                         ",'" + (oItem.HEmplpyee==null?"": oItem.HEmplpyee) + "'" +
+                        ",'" + (oItem.HInstanceStatus == null ? "" : oItem.HInstanceStatus) + "'" +
+                        ",'" + (oItem.HApprovedResult == null ? "" : oItem.HApprovedResult) + "'" +
                         ")";
 
                     oCN.RunProc(sql_main);
@@ -895,7 +948,50 @@
                             {
                                 oItem.HRiskRemak_Result = response.Body.Result[i].FormData["textareaField_lxblb9xa"].ToString().Replace("'", "");
                             }
-                            
+
+
+                            //鑾峰彇瀹炰緥鐘舵��
+                            GetInstanceByIdResponse response1 = new GetInstanceByIdResponse();
+                            if (getInstanceStatusByInstanceID__YiDa(appType, systemToken, userID, oItem.HInstanceID, ref response1, ref msg) == false)
+                            {
+                                return false;
+                            }
+
+                            oItem.HInstanceStatus = response1.Body.InstanceStatus;
+                            if (oItem.HInstanceStatus == "RUNNING")
+                            {
+                                oItem.HInstanceStatus = "杩愯涓�";
+                            }
+                            else if (oItem.HInstanceStatus == "TERMINATED")
+                            {
+                                oItem.HInstanceStatus = "宸茬粓姝�";
+                            }
+                            else if (oItem.HInstanceStatus == "COMPLETED")
+                            {
+                                oItem.HInstanceStatus = "宸插畬鎴�";
+                            }
+                            else if (oItem.HInstanceStatus == "ERROR")
+                            {
+                                oItem.HInstanceStatus = "寮傚父";
+                            }
+
+                            oItem.HApprovedResult = response1.Body.ApprovedResult;
+                            if (oItem.HApprovedResult == "agree")
+                            {
+                                oItem.HApprovedResult = "鍚屾剰";
+                            }
+                            else if (oItem.HApprovedResult == "disagree")
+                            {
+                                oItem.HApprovedResult = "鎷掔粷";
+                            }
+                            else
+                            {
+                                oItem.HApprovedResult = "";
+                            }
+
+
+
+
                             lsmain.Add(oItem);
                         }catch(Exception e)
                         {
@@ -961,7 +1057,8 @@
                     string sql_main = "insert into DD_XianChangBianHuaDianPingShenDan" +
                         "(HMakerID,HMakeDate,HUpdaterID,HUpdater,HUpdateDate,HInstanceID,HOriginator,HTitle" +
                         ",HDate" +
-                        ",HDept,HChangeType,HRiskLevel,HChangeContent,HRiskRemark_Safe,HRiskRemark_Study,HRiskRemark_Quality,HRiskRemark_Equipment,HRiskRemark_Product,HRiskRemark_Result) " +
+                        ",HDept,HChangeType,HRiskLevel,HChangeContent,HRiskRemark_Safe,HRiskRemark_Study,HRiskRemark_Quality,HRiskRemark_Equipment,HRiskRemark_Product,HRiskRemark_Result" +
+                        ",HInstanceStatus,HApprovedResult) " +
                         "values(" +
                         "'" + oItem.HMakerID + "'" +
                         ",'" + oItem.HMakeDate + "'" +
@@ -983,6 +1080,8 @@
                         ",'" + (oItem.HRiskRemark_Equipment==null?"": oItem.HRiskRemark_Equipment) + "'" +
                         ",'" + (oItem.HRiskRemark_Product==null?"": oItem.HRiskRemark_Product) + "'" +
                         ",'" + (oItem.HRiskRemak_Result==null?"": oItem.HRiskRemak_Result) + "'" +
+                        ",'" + (oItem.HInstanceStatus == null ? "" : oItem.HInstanceStatus) + "'" +
+                        ",'" + (oItem.HApprovedResult == null ? "" : oItem.HApprovedResult) + "'" +
                         ")";
 
                     oCN.RunProc(sql_main);
@@ -1148,6 +1247,19 @@
                                 oItem.HInstanceStatus = "寮傚父";
                             }
 
+                            oItem.HApprovedResult = response1.Body.ApprovedResult;
+                            if (oItem.HApprovedResult== "agree")
+                            {
+                                oItem.HApprovedResult = "鍚屾剰";
+                            }else if(oItem.HApprovedResult== "disagree")
+                            {
+                                oItem.HApprovedResult = "鎷掔粷";
+                            }
+                            else
+                            {
+                                oItem.HApprovedResult = "";
+                            }
+
                             lsmain.Add(oItem);
                         }
                         catch (Exception e)
@@ -1217,7 +1329,7 @@
                         ",HCheckLevel,HCheckArea,HPhoto_NoSatisfyRequire,HDescription_NoSatisfyRequire,HQuestionType,HRequire_ModifyDate,HEmployeeID_Duty,HEmployee_Duty" +
                         ",HQuestionIsNoModify" +
                         ",HReason_NoModify,HReasonAnalysis,HMethod_Modify" +
-                        ",HDate_Achieve,HFile_Evidence,HCloseConfirm,HInstanceStatus" +
+                        ",HDate_Achieve,HFile_Evidence,HCloseConfirm,HInstanceStatus,HApprovedResult" +
                         ") " +
                         "values(" +
                         "'" + oItem.HMakerID + "'" +
@@ -1248,6 +1360,7 @@
                         ",'" + (oItem.HFile_Evidence==null?"": oItem.HFile_Evidence) + "'" +
                         ",'" + (oItem.HCloseConfirm==null?"": oItem.HCloseConfirm) + "'" +
                         ",'" + (oItem.HInstanceStatus==null?"":oItem.HInstanceStatus) + "'" +
+                        ",'" + (oItem.HApprovedResult==null?"":oItem.HApprovedResult) + "'" +
                         ")";
 
                     oCN.RunProc(sql_main);
@@ -1323,7 +1436,46 @@
                                 oItem.HDept_Duty = response.Body.Result[i].FormData["selectField_lxcunmsu"].ToString().Replace("'", "");
                             }
 
-                            
+                            //鑾峰彇瀹炰緥鐘舵��
+                            GetInstanceByIdResponse response1 = new GetInstanceByIdResponse();
+                            if (getInstanceStatusByInstanceID__YiDa(appType, systemToken, userID, oItem.HInstanceID, ref response1, ref msg) == false)
+                            {
+                                return false;
+                            }
+
+                            oItem.HInstanceStatus = response1.Body.InstanceStatus;
+                            if (oItem.HInstanceStatus == "RUNNING")
+                            {
+                                oItem.HInstanceStatus = "杩愯涓�";
+                            }
+                            else if (oItem.HInstanceStatus == "TERMINATED")
+                            {
+                                oItem.HInstanceStatus = "宸茬粓姝�";
+                            }
+                            else if (oItem.HInstanceStatus == "COMPLETED")
+                            {
+                                oItem.HInstanceStatus = "宸插畬鎴�";
+                            }
+                            else if (oItem.HInstanceStatus == "ERROR")
+                            {
+                                oItem.HInstanceStatus = "寮傚父";
+                            }
+
+                            oItem.HApprovedResult = response1.Body.ApprovedResult;
+                            if (oItem.HApprovedResult == "agree")
+                            {
+                                oItem.HApprovedResult = "鍚屾剰";
+                            }
+                            else if (oItem.HApprovedResult == "disagree")
+                            {
+                                oItem.HApprovedResult = "鎷掔粷";
+                            }
+                            else
+                            {
+                                oItem.HApprovedResult = "";
+                            }
+
+
 
                             List<YD_QRQCWenTiTiJiaoBiaoSub1> sub1List = new List<YD_QRQCWenTiTiJiaoBiaoSub1>();
                             if (keys_main.Contains("tableField_lx4azand"))
@@ -1466,6 +1618,12 @@
                 oCN.BeginTran();
                 foreach (YD_QRQCWenTiTiJiaoBiao oItem in lsmain)
                 {
+                    ////鍒ゆ柇鍗曟嵁 瀹炰緥鐘舵�佹槸鍚︿负"宸插畬鎴�"涓� 瀹℃壒缁撴灉涓�"鍚屾剰",鑻ユ槸鍒欏悓姝ユ暟鎹紝鍚﹀垯涓嶈繘琛屽悓姝ユ暟鎹�
+                    //if (!(oItem.HInstanceStatus == "宸插畬鎴�" && oItem.HApprovedResult == "鍚屾剰"))
+                    //{
+                    //    continue;
+                    //}
+
                     string sql_searchRepeat = "select * from DD_QRQCWenTiTiJiaoBiao where HInstanceID = '" + oItem.HInstanceID + "'";
                     DataSet ds_searchRepeat = oCN.RunProcReturn(sql_searchRepeat, "DD_QRQCWenTiTiJiaoBiao");
                     if (ds_searchRepeat != null && ds_searchRepeat.Tables[0].Rows.Count > 0)
@@ -1481,7 +1639,8 @@
                     }
 
                     string sql_main = "insert into DD_QRQCWenTiTiJiaoBiao" +
-                        "(HMakerID,HMakeDate,HUpdaterID,HUpdater,HUpdateDate,HInstanceID,HOriginator,HTitle,HQuestionType,HDept_Duty) " +
+                        "(HMakerID,HMakeDate,HUpdaterID,HUpdater,HUpdateDate,HInstanceID,HOriginator,HTitle,HQuestionType,HDept_Duty" +
+                        ",HInstanceStatus,HApprovedResult) " +
                         "values(" +
                         "'" + oItem.HMakerID + "'" +
                         ",'" + oItem.HMakeDate + "'" +
@@ -1494,6 +1653,8 @@
 
                         ",'" + (oItem.HQuestionType==null?"": oItem.HQuestionType) + "'" +
                         ",'" + (oItem.HDept_Duty==null?"": oItem.HDept_Duty) + "'" +
+                        ",'" + (oItem.HInstanceStatus == null ? "" : oItem.HInstanceStatus) + "'" +
+                        ",'" + (oItem.HApprovedResult == null ? "" : oItem.HApprovedResult) + "'" +
                         ")";
                     oCN.RunProc(sql_main);
 
diff --git a/sdk_dingding/TopSdk/bin/Debug/TopSdk.dll b/sdk_dingding/TopSdk/bin/Debug/TopSdk.dll
index e088dda..a3c3185 100644
--- a/sdk_dingding/TopSdk/bin/Debug/TopSdk.dll
+++ b/sdk_dingding/TopSdk/bin/Debug/TopSdk.dll
Binary files differ
diff --git a/sdk_dingding/TopSdk/bin/Debug/TopSdk.pdb b/sdk_dingding/TopSdk/bin/Debug/TopSdk.pdb
index 713ebd1..2e4665b 100644
--- a/sdk_dingding/TopSdk/bin/Debug/TopSdk.pdb
+++ b/sdk_dingding/TopSdk/bin/Debug/TopSdk.pdb
Binary files differ
diff --git a/sdk_dingding/TopSdk/obj/Debug/TopSdk.dll b/sdk_dingding/TopSdk/obj/Debug/TopSdk.dll
index e088dda..a3c3185 100644
--- a/sdk_dingding/TopSdk/obj/Debug/TopSdk.dll
+++ b/sdk_dingding/TopSdk/obj/Debug/TopSdk.dll
Binary files differ
diff --git a/sdk_dingding/TopSdk/obj/Debug/TopSdk.pdb b/sdk_dingding/TopSdk/obj/Debug/TopSdk.pdb
index 713ebd1..2e4665b 100644
--- a/sdk_dingding/TopSdk/obj/Debug/TopSdk.pdb
+++ b/sdk_dingding/TopSdk/obj/Debug/TopSdk.pdb
Binary files differ

--
Gitblit v1.9.1