From ec69ec14439c3d79dc951a093bb5b698ff424a40 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期一, 28 十月 2024 13:41:31 +0800
Subject: [PATCH] 添康工资车间报表添加,异常工时申请单修改

---
 WebAPI/Controllers/数据同步/钉钉同步/DD_DataSynchronizationController.cs | 1282 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 1,258 insertions(+), 24 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 e9993f7..4bb6860 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"
@@ -16,6 +16,7 @@
 using DingTalk.Api;
 using DingTalk.Api.Response;
 using System.Globalization;
+using System.Linq;
 
 namespace WebAPI.Controllers
 {
@@ -100,6 +101,8 @@
             public string HOriginator;                          //鍙戣捣浜�
             public string HTitle;                               //鍗曟嵁鏍囬
 
+            public string HInstanceStatus;                      //瀹炰緥鐘舵��
+            public string HApprovedResult;                      //瀹℃壒缁撴灉
 
             //鍗曟嵁鍐呭
             public string HDate;                                //鏃ユ湡
@@ -124,6 +127,8 @@
             public string HOriginator;                          //鍙戣捣浜�
             public string HTitle;                               //鍗曟嵁鏍囬
 
+            public string HInstanceStatus;                      //瀹炰緥鐘舵��
+            public string HApprovedResult;                      //瀹℃壒缁撴灉
 
             //鍗曟嵁鍐呭
             public string HDate;                                //鏃ユ湡
@@ -154,6 +159,8 @@
             public string HOriginator;                          //鍙戣捣浜�
             public string HTitle;                               //鍗曟嵁鏍囬
 
+            public string HInstanceStatus;                      //瀹炰緥鐘舵��
+            public string HApprovedResult;                      //瀹℃壒缁撴灉
 
             //鍗曟嵁鍐呭
             public string HEmployeeID;                          //鎴愬憳ID
@@ -191,6 +198,8 @@
             public string HOriginator;                          //鍙戣捣浜�
             public string HTitle;                               //鍗曟嵁鏍囬
 
+            public string HInstanceStatus;                      //瀹炰緥鐘舵��
+            public string HApprovedResult;                      //瀹℃壒缁撴灉
 
             //鍗曟嵁鍐呭
             public string HQuestionType;                        //闂鍒嗙被
@@ -230,6 +239,126 @@
             public string HWorkAge;
 
         }
+        #endregion
+
+        #region 妯″叿淇濆吇缁翠慨琛�
+        public class MouldFileWeiXiuBaoYang
+        {
+            //ClsSb_MouldRepairWorkBillSub
+            //鍗曟嵁淇℃伅
+            public string HMakerID;                             //鍒涘缓浜篒D
+            public string HMaker;                               //鍒涘缓浜哄悕绉�
+            public string HMakeDate;                            //鍒涘缓鏃ユ湡
+            public string HUpdaterID;                           //淇敼浜篒D
+            public string HUpdater;                             //淇敼浜哄悕绉�
+            public string HUpdateDate;                          //淇敼鏃ユ湡
+            public string HInstanceID;                          //鍗曟嵁瀹炰緥ID
+            public string HOriginator;                          //鍙戣捣浜�
+            public string HTitle;                               //鍗曟嵁鏍囬
+            public Int64 HEquipID;//              --璁惧ID(Gy_EquipMent)
+            public Int64 HRepairID;//	--缁翠慨椤圭洰(Gy_Repair)
+            public DateTime HRepairBeginDate;//  --缁翠慨寮�濮嬫棩鏈�
+            public DateTime HRepairEndDate;//  --缁翠慨缁撴潫鏃ユ湡
+            public string HRepairContent;//   --缁翠慨鍐呭
+            public string HCycleUnit;//   varchar(10)	--鏃堕棿鍗曚綅(灏忔椂锛屽ぉ)
+            public double HPlanTimes;//  money         --璁″垝缁翠慨宸ユ椂
+            public double HTimes;//      money       --瀹為檯缁翠慨宸ユ椂
+            public Int64 HEmpID;//    int    --缁翠慨浜�(Gy_Employee)
+            public Int64 HManagerID;//   int       --璐熻矗浜�(Gy_Employee)
+            public Int64 HDeptID;//    int    --缁翠慨閮ㄩ棬(Gy_Department)
+            public string HExplanation;//   varchar(500)    --缁翠慨瑕佹眰        
+            public string HInnerBillNo;//   varchar(50)   --鍐呴儴鍗曟嵁鍙�
+            public Int64 HMouldID;
+            public Int64 HMouldMaintainRuleInterID;
+            public Int64 HMaintainItemID;
+            public Int64 HSupID;//		int	--渚涘簲鍟嗭紙Gy_Supplier锛�					addnew
+            public string HRepairType;//	varchar(10)		--缁翠慨绫诲瀷锛堝唴閮ㄧ淮淇紝濮斿缁翠慨锛�   	addnew
+            public string HNewModel;//	varchar(100)		--缁翠慨鍚庢柊瑙勬牸				addnew
+            public Single HNewDesignLife;//	money			--鏂拌璁″鍛�
+            public string HRemark;
+            public string HPlanNo;
+            public string HPlanInterID;
+            public DateTime HRequestComDate;
+            public double HRecentMainModule;
+            public double HCumulativeModule;
+            public double HProductionModule;
+            public DateTime HRepairAccepDate;
+            public string HMaintainLevID;
+
+
+
+            //鍗曟嵁鍐呭
+            public string HBillNo;                                //鍗曟嵁鍙�
+            public string HDate;                                //鏃ユ湡
+            public string HCheckLevel;                          //瀹℃牳绛夌骇
+            public string HArea;                                //鍖哄煙
+            public string HEmployeeID;                          //鎴愬憳ID
+            public string HEmplpyee;                            //鎴愬憳鍚嶇О
+
+            public List<Sc_MouldRepairWorkBillSub> DetailColMouldRepair = new List<Sc_MouldRepairWorkBillSub>();
+            public List<Sc_MouldMaintainBillSub> DetailColMouldMaintain = new List<Sc_MouldMaintainBillSub>();
+        }
+
+        //缁翠慨瀛愯〃
+        public class Sc_MouldRepairWorkBillSub
+        {
+            public string HRepairExplanation;
+            public string HRemark;
+        }
+
+        //淇濆吇瀛愯〃
+        public class Sc_MouldMaintainBillSub
+        {
+            public string HClaim;
+            public string HMaintainResult;
+        }
+        #endregion
+
+        #region 璁惧缁翠慨璁板綍琛�
+        public class EquipRepairWeiXiu
+        {
+            //鍗曟嵁淇℃伅
+            public string HMakerID;                             //鍒涘缓浜篒D
+            public string HMaker;                               //鍒涘缓浜哄悕绉�
+            public string HMakeDate;                            //鍒涘缓鏃ユ湡
+            public string HUpdaterID;                           //淇敼浜篒D
+            public string HUpdater;                             //淇敼浜哄悕绉�
+            public string HUpdateDate;                          //淇敼鏃ユ湡
+            public string HInstanceID;                          //鍗曟嵁瀹炰緥ID
+            public string HOriginator;                          //鍙戣捣浜�
+            public string HTitle;                               //鍗曟嵁鏍囬
+            public Int64 HEmpID;//    int        		--缁翠慨浜�
+            public Int64 HManagerID;//   int    		--璐熻矗浜�
+            public Int64 HSecManagerID;//  int   		--楠屾敹       
+            public Int64 HDeptID;//     int     		--缁翠慨閮ㄩ棬
+            public string HExplanation;//   varchar(200)    	--缁翠慨瑕佹眰
+            public string HInnerBillNo;//  varchar(50)     	--鍐呴儴鍗曟嵁鍙�
+            public string HRemark; //鍔犲伐瑕佹眰
+
+            public Int64 HEquipID;//     int       --璁惧ID(Gy_EquipMent)
+            public Int64 HRepairID;//int  --缁翠慨椤圭洰(Gy_Repair)
+            public DateTime HRepairBeginDate;// datetime --缁翠慨寮�濮嬫棩鏈�
+            public DateTime HRepairEndDate;//datetime --缁翠慨缁撴潫鏃ユ湡
+            public string HRepairContent;//varchar(500) --缁翠慨鍐呭
+            public string HCycleUnit;//varchar(10)	--鏃堕棿鍗曚綅(灏忔椂锛屽ぉ)
+            public Single HPlanTimes;// money         --璁″垝缁翠慨宸ユ椂
+            public Single HTimes;// money       --瀹為檯缁翠慨宸ユ椂
+            public string HRemark2;//澶囨敞
+            public string HRepairCategory;
+            public string HUrgenLevel;
+            public string HRepairer;
+            public string HIsCapacityImpact;
+
+            //鍗曟嵁鍐呭
+            public string HDate;                                //鏃ユ湡
+            public string HCheckLevel;                          //瀹℃牳绛夌骇
+            public string HArea;                                //鍖哄煙
+            public string HEmployeeID;                          //鎴愬憳ID
+            public string HEmplpyee;                            //鎴愬憳鍚嶇О
+
+            public List<Sc_MouldRepairWorkBillSub> DetailColMouldRepair = new List<Sc_MouldRepairWorkBillSub>();
+        }
+       
         #endregion
         #endregion
 
@@ -397,8 +526,10 @@
                 //OriginatorId = "12",                                                                                          //鏍规嵁娴佺▼鍙戣捣浜哄伐鍙锋煡璇€��
 
                 //TaskId = "12",                                                                                                //浠诲姟ID銆�
-                CreateFromTimeGMT = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd"),                                          //鍒涘缓鏃堕棿璧峰鍊笺��
-                CreateToTimeGMT = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),                                               //鍒涘缓鏃堕棿缁堟鍊笺��
+                //CreateFromTimeGMT = DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd"),                                          //鍒涘缓鏃堕棿璧峰鍊笺��
+                //CreateToTimeGMT = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd hh:mm:ss"),                                               //鍒涘缓鏃堕棿缁堟鍊笺��
+                ModifiedFromTimeGMT = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"),                                          //淇敼鏃堕棿璧峰鍊笺��
+                ModifiedToTimeGMT = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"),                                               //淇敼鏃堕棿缁堟鍊笺��
 
                 PageSize = pageSize,                                                  //鍒嗛〉澶у皬銆�
                 PageNumber = pageNumber,                                                 //鍒嗛〉椤电爜
@@ -547,6 +678,50 @@
             }
         }
         #endregion
+
+        #region 鑾峰彇 瀹滄惌 鏍规嵁娴佺▼瀹炰緥ID鑾峰彇娴佺▼瀹炰緥
+        public bool getInstanceStatusByInstanceID__YiDa(string appType, string systemToken, string userID, string instanceID, ref GetInstanceByIdResponse response, ref string msg)
+        {
+            AlibabaCloud.SDK.Dingtalkyida_1_0.Client client = CreateClient5();
+            AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetInstanceByIdHeaders getInstanceByIdHeaders = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetInstanceByIdHeaders();
+            getInstanceByIdHeaders.XAcsDingtalkAccessToken = this.accessToken;
+            AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetInstanceByIdRequest getInstanceByIdRequest = new AlibabaCloud.SDK.Dingtalkyida_1_0.Models.GetInstanceByIdRequest
+            {
+                SystemToken = systemToken,
+                Language = "12",
+                UserId = userID,
+                AppType = appType,
+            };
+            try
+            {
+                GetInstanceByIdResponse getInstanceByIdResponse = client.GetInstanceByIdWithOptions(instanceID, getInstanceByIdRequest, getInstanceByIdHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
+                response = getInstanceByIdResponse;
+                return true;
+            }
+            catch (TeaException err)
+            {
+                if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
+                {
+                    // err 涓惈鏈� code 鍜� message 灞炴�э紝鍙府鍔╁紑鍙戝畾浣嶉棶棰�
+                }
+                msg = err.Message;
+                return false;
+            }
+            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 灞炴�э紝鍙府鍔╁紑鍙戝畾浣嶉棶棰�
+                }
+                msg = _err.Message;
+                return false;
+            }
+        }
+        #endregion
         #endregion
 
         #region 鏁版嵁鍚屾鏂规硶
@@ -599,32 +774,104 @@
                             int startindex = response.Body.Result[i].Title.IndexOf("zh_CN") + 8;
                             oItem.HTitle = startIndex + response.Body.Result[i].Title.Substring(startindex).Replace("\"}", "").Replace("'", "");
 
-                            if (keys.Contains("dateField_lo6w37hk"))
+                            //瀹℃牳绛惧埌琛�
+                            //if (keys.Contains("dateField_lo6w37hk"))
+                            //{
+                            //    double HDate_Temp = double.Parse(response.Body.Result[i].FormData["dateField_lo6w37hk"].ToString());
+                            //    oItem.HDate = convertFromMillisecondsToDateString(HDate_Temp, "yyyy-MM-dd");
+                            //}
+
+                            //if (keys.Contains("selectField_lockncvh_id"))
+                            //{
+                            //    oItem.HArea = response.Body.Result[i].FormData["selectField_lockncvh_id"].ToString().Replace("'", "");
+                            //}
+
+                            //if (keys.Contains("selectField_lockncvg_id"))
+                            //{
+                            //    oItem.HCheckLevel = response.Body.Result[i].FormData["selectField_lockncvg_id"].ToString().Replace("'", "");
+                            //}
+
+                            //if (keys.Contains("employeeField_lo6w37hf"))
+                            //{
+                            //    oItem.HEmplpyee = ((List<object>)response.Body.Result[i].FormData["employeeField_lo6w37hf"])[0].ToString().Replace("'","");
+                            //}
+
+                            //if (keys.Contains("employeeField_lo6w37hf_id"))
+                            //{
+                            //    oItem.HEmployeeID = ((List<object>)response.Body.Result[i].FormData["employeeField_lo6w37hf_id"])[0].ToString().Replace("'", "");
+                            //}
+
+
+                            //绛惧埌琛�
+                            if (keys.Contains("dateField_ls9ma7h3"))
                             {
-                                double HDate_Temp = double.Parse(response.Body.Result[i].FormData["dateField_lo6w37hk"].ToString());
+                                double HDate_Temp = double.Parse(response.Body.Result[i].FormData["dateField_ls9ma7h3"].ToString());
                                 oItem.HDate = convertFromMillisecondsToDateString(HDate_Temp, "yyyy-MM-dd");
                             }
 
-                            if (keys.Contains("selectField_lockncvh_id"))
+                            if (keys.Contains("selectField_ls9ma7h9"))
                             {
-                                oItem.HArea = response.Body.Result[i].FormData["selectField_lockncvh_id"].ToString().Replace("'", "");
+                                oItem.HArea = response.Body.Result[i].FormData["selectField_ls9ma7h9"].ToString().Replace("'", "");
                             }
 
-                            if (keys.Contains("selectField_lockncvg_id"))
+                            if (keys.Contains("selectField_ls9ma7h7"))
                             {
-                                oItem.HCheckLevel = response.Body.Result[i].FormData["selectField_lockncvg_id"].ToString().Replace("'", "");
+                                oItem.HCheckLevel = response.Body.Result[i].FormData["selectField_ls9ma7h7"].ToString().Replace("'", "");
                             }
 
-                            if (keys.Contains("employeeField_lo6w37hf"))
+                            if (keys.Contains("employeeField_ls9ma7h5"))
                             {
-                                oItem.HEmplpyee = ((List<object>)response.Body.Result[i].FormData["employeeField_lo6w37hf"])[0].ToString().Replace("'","");
+                                oItem.HEmplpyee = ((List<object>)response.Body.Result[i].FormData["employeeField_ls9ma7h5"])[0].ToString().Replace("'", "");
                             }
 
-                            if (keys.Contains("employeeField_lo6w37hf_id"))
+                            if (keys.Contains("employeeField_ls9ma7h5_id"))
                             {
-                                oItem.HEmployeeID = ((List<object>)response.Body.Result[i].FormData["employeeField_lo6w37hf_id"])[0].ToString().Replace("'", "");
+                                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)
                         {
@@ -660,7 +907,8 @@
             string appType = "APP_MMBPP3IFGFBX3VQAIKYX";
             string systemToken = "TP866A81107FVI9LBFQRZ9953YWZ2GYR2W6OL1L";
             string userID = "1933673646699149";
-            string formUuid = "FORM-IQ8666B17ZZE7NQSA01K3DUN78UI3J1Z2W6OLX";
+            //string formUuid = "FORM-IQ8666B17ZZE7NQSA01K3DUN78UI3J1Z2W6OLX";            //鍒嗗眰瀹℃牳绛惧埌琛�
+            string formUuid = "FORM-A01FFB0B63A34F18B7753F695F49190DJEY7";              //绛惧埌琛�
             int pageNumber = 1;
             int pageSize = 100;
 
@@ -680,7 +928,7 @@
 
             try
             {
-                oCN.BeginTran();
+              oCN.BeginTran();
                 foreach (YD_FenCengShenHeQianDaoBiao oItem in lsmain)
                 {
                     string sql_searchRepeat = "select * from DD_FenCengShenHeQianDaoBiao where HInstanceID = '" + oItem.HInstanceID + "'";
@@ -694,7 +942,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 + "'" +
@@ -710,6 +959,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);
@@ -820,7 +1071,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)
                         {
@@ -886,7 +1180,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 + "'" +
@@ -908,6 +1203,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);
@@ -1049,6 +1346,43 @@
                                 oItem.HCloseConfirm = response.Body.Result[i].FormData["selectField_ltpe6mdd"].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)
@@ -1118,7 +1452,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" +
+                        ",HDate_Achieve,HFile_Evidence,HCloseConfirm,HInstanceStatus,HApprovedResult" +
                         ") " +
                         "values(" +
                         "'" + oItem.HMakerID + "'" +
@@ -1148,7 +1482,8 @@
                         "," + (oItem.HDate_Achieve==null?"null":"'"+ oItem.HDate_Achieve+ "'") + "" +
                         ",'" + (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);
@@ -1224,7 +1559,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"))
@@ -1367,6 +1741,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)
@@ -1382,7 +1762,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 + "'" +
@@ -1395,6 +1776,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);
 
@@ -1492,6 +1875,9 @@
                         return false;
                     }
 
+                    string[] studyLevelList = new string[] {"","楂樹腑","涓笓","澶т笓","鏈","","","鍏朵粬","鍒濅腑","灏忓" };
+
+
                     for (int i = 0; i < response.Result.Count; i++)
                     {
                         List<string> fieldNameList = new List<string>();
@@ -1522,6 +1908,15 @@
                             {
                                 int index = fieldNameList.IndexOf("瀛﹀巻");
                                 oItem.HStudyLevel = response.Result[i].FieldDataList[index].FieldValueList[0].Value;
+                                if (oItem.HStudyLevel != null && oItem.HStudyLevel != "")
+                                {
+                                    long studyLevelIndex = DBUtility.ClsPub.isLong(oItem.HStudyLevel);
+                                    if (studyLevelIndex >= studyLevelList.Length)
+                                    {
+                                        studyLevelIndex = 0;
+                                    }
+                                    oItem.HStudyLevel = studyLevelList[studyLevelIndex];
+                                }
                             }
 
                             if (fieldNameList.IndexOf("閮ㄩ棬") >= 0)
@@ -1530,9 +1925,9 @@
                                 oItem.HDept = response.Result[i].FieldDataList[index].FieldValueList[0].Value;
                             }
 
-                            if (fieldNameList.IndexOf("宸ラ緞锛堢郴缁熻绠楋級") >= 0)
+                            if (fieldNameList.IndexOf("鍙搁緞锛堢郴缁熻绠楋級") >= 0)
                             {
-                                int index = fieldNameList.IndexOf("宸ラ緞锛堢郴缁熻绠楋級");
+                                int index = fieldNameList.IndexOf("鍙搁緞锛堢郴缁熻绠楋級");
                                 oItem.HWorkAge = response.Result[i].FieldDataList[index].FieldValueList[0].Value;
                             }
                             
@@ -1623,6 +2018,845 @@
         }
         #endregion
         #endregion
+
+        #region 鏁版嵁鍚屾-妯″叿缁翠慨淇濆吇鍗�
+        #region 鑾峰彇 瀹滄惌-妯″叿缁翠慨淇濆吇鍗� 瀹炰緥ID鍒楄〃瀵瑰簲鐨勫疄渚嬭鎯�
+        public bool getInstanceDetailList___MouldFileWeiXiuBaoYang_YiDa(string appType, string systemToken, string userID, string formUuid, List<string> IDList, ref List<MouldFileWeiXiuBaoYang> lsmain, ref string msg, int size = 500)
+        {
+
+            try
+            {
+                int startIndex = 0;
+                int endIndex = startIndex + size;
+                if (endIndex > IDList.Count)
+                {
+                    endIndex = IDList.Count;
+                }
+
+                while (startIndex < endIndex && endIndex <= IDList.Count)
+                {
+                    List<string> IDList_temp = new List<string>();
+                    for (int i = startIndex; i < endIndex; i++)
+                    {
+                        IDList_temp.Add(IDList[i]);
+                    }
+
+                    BatchGetFormDataByIdListResponse response = new BatchGetFormDataByIdListResponse();
+                    if (getInstanceDetailListByInstanceIDList_YiDa(appType, systemToken, formUuid, userID, IDList_temp, ref response, ref msg) == false)
+                    {
+                        return false;
+                    }
+
+
+                    for (int i = 0; i < response.Body.Result.Count; i++)
+                    {
+                        try
+                        {
+
+
+                            List<string> keys = new List<string>(response.Body.Result[i].FormData.Keys);
+
+                            MouldFileWeiXiuBaoYang oItem = new MouldFileWeiXiuBaoYang();
+                            oItem.HMakerID = response.Body.Result[i].CreatorUserId.Replace("'", "");
+                            oItem.HMaker = response.Body.Result[i].CreatorUserId.Replace("'", "");
+                            oItem.HMakeDate = response.Body.Result[i].CreateTimeGMT.Replace("T", " ").Replace("Z", "").Replace("'", "");
+                            oItem.HUpdaterID = response.Body.Result[i].ModifyUser.UserId.Replace("'", "");
+                            oItem.HUpdater = response.Body.Result[i].ModifyUser.Name.NameInChinese.Replace("'", "");
+                            oItem.HUpdateDate = response.Body.Result[i].ModifiedTimeGMT.Replace("T", " ").Replace("Z", "").Replace("'", "");
+                            oItem.HInstanceID = response.Body.Result[i].FormInstanceId.Replace("'", "");
+                            oItem.HOriginator = response.Body.Result[i].Originator.Name.NameInChinese.Replace("'", "");
+
+                            GetInstanceByIdResponse getInstanceByIdResponse = new GetInstanceByIdResponse(); ;
+                            if (!getInstanceStatusByInstanceID__YiDa(appType, systemToken, userID, oItem.HInstanceID, ref getInstanceByIdResponse, ref msg))
+                            {
+                                continue;
+                            }
+
+                            if (getInstanceByIdResponse.Body.InstanceStatus != "COMPLETED")
+                            {
+                                //continue;
+                            }
+
+                            //寮�鍗曟棩鏈�
+                            if (keys.Contains("dateField_lq0v65sv"))
+                            {
+                                double HDate_Temp = double.Parse(response.Body.Result[i].FormData["dateField_lq0v65sv"].ToString());
+                                oItem.HDate = convertFromMillisecondsToDateString(HDate_Temp, "yyyy-MM-dd HH:mm");
+                            }
+
+                            //妯″叿淇濆吇绾у埆
+                            if (keys.Contains("selectField_m1ip9j31"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["selectField_m1ip9j31"].ToString();
+                                if (!HDate_Temp.Contains("涓夌骇"))
+                                {
+                                    ds = oCN.RunProcReturn("select  * from h_v_Gy_MaintainLev where 淇濆吇绾у埆浠g爜='BY-SE-002'", "h_v_Gy_MaintainLev");
+                                    if (ds.Tables[0].Rows.Count > 0)
+                                    {
+                                        HDate_Temp = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                                    }
+                                }
+                                else if (HDate_Temp.Contains("涓夌骇"))
+                                {
+                                    ds = oCN.RunProcReturn("select  * from h_v_Gy_MaintainLev where 淇濆吇绾у埆浠g爜='BY-SE-003'", "h_v_Gy_MaintainLev");
+                                    if (ds.Tables[0].Rows.Count > 0)
+                                    {
+                                        HDate_Temp = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                                    }
+                                }
+                              
+                                oItem.HMaintainLevID = HDate_Temp;
+                            }
+
+                            //淇ā寮�濮嬫椂闂�
+                            if (keys.Contains("dateField_lq4gf2ih"))
+                            {
+                                double HDate_Temp = double.Parse(response.Body.Result[i].FormData["dateField_lq4gf2ih"].ToString());
+                                oItem.HRepairBeginDate = DateTime.Parse(convertFromMillisecondsToDateString(HDate_Temp, "yyyy-MM-dd HH:mm"));
+                            }
+
+                            //淇ā缁撴潫鏃堕棿
+                            if (keys.Contains("dateField_lq4gf2ii"))
+                            {
+                                double HDate_Temp = double.Parse(response.Body.Result[i].FormData["dateField_lq4gf2ii"].ToString());
+                                oItem.HRepairEndDate = DateTime.Parse(convertFromMillisecondsToDateString(HDate_Temp, "yyyy-MM-dd HH:mm"));
+                            }
+
+                            //妯″叿鍗曟嵁鍙�
+                            if (keys.Contains("serialNumberField_lqaak4ts"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["serialNumberField_lqaak4ts"].ToString();
+                                oItem.HBillNo = HDate_Temp;
+                            }
+
+                            //瑕佹眰瀹屾垚鏃ユ湡
+                            if (keys.Contains("dateField_lq3idkvd"))
+                            {
+                                double HDate_Temp = double.Parse(response.Body.Result[i].FormData["dateField_lq3idkvd"].ToString());
+                                oItem.HRequestComDate = DateTime.Parse(convertFromMillisecondsToDateString(HDate_Temp, "yyyy-MM-dd HH:mm:ss"));
+                            }
+
+                            //缁翠慨鍙楃悊鏃ユ湡
+                            if (keys.Contains("dateField_lq4gf2ih"))
+                            {
+                                double HDate_Temp = double.Parse(response.Body.Result[i].FormData["dateField_lq4gf2ih"].ToString());
+                                oItem.HRepairAccepDate = DateTime.Parse(convertFromMillisecondsToDateString(HDate_Temp, "yyyy-MM-dd HH:mm:ss"));
+                            }
+
+                            //鏈�杩戜繚鍏绘ā鏁�
+                            if (keys.Contains("numberField_lq3idkvi"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["numberField_lq3idkvi"].ToString();
+                                oItem.HRecentMainModule = double.Parse(HDate_Temp);
+                            }
+
+                            //绱妯℃暟
+                            if (keys.Contains("numberField_lq3idkvj"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["numberField_lq3idkvj"].ToString();
+                                oItem.HCumulativeModule = double.Parse(HDate_Temp);
+                            }
+
+                            //鏈鐢熶骇妯℃暟
+                            if (keys.Contains("textField_lq4vdvgh"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["textField_lq4vdvgh"].ToString();
+                                oItem.HProductionModule = double.Parse(HDate_Temp);
+                            }
+                            
+                            //妯″叿缂栫爜
+                            if (keys.Contains("selectField_lq3idkvg"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["selectField_lq3idkvg"].ToString();
+                                DataSet ds = oCN.RunProcReturn("select * from Gy_MouldFileMain with(nolock)  where HNumber='" + HDate_Temp + "'", "Gy_MouldFileMain");
+                                string HMouldID = "0";
+                                if (ds.Tables[0].Rows.Count > 0)
+                                {
+                                    HMouldID = ds.Tables[0].Rows[0]["HInterID"].ToString();
+                                }
+                                oItem.HMouldID = long.Parse(HMouldID);
+                                oItem.HRemark = HDate_Temp;
+
+
+                                //鏌ヨ淇濆吇璁″垝
+                                ds = oCN.RunProcReturn(@"select  a.HInterID,a.HBillNo from  Sc_MouldMaintainPlanBillMain a
+                                    inner join Sc_MouldMaintainPlanBillSub b on a.HInterID = b.HInterID
+                                    where a.HMouldID =" + oItem.HMouldID + " and a.HMaintainLevID = " + oItem.HMaintainLevID, "Sc_MouldMaintainPlanBillMain");
+
+                                if (ds.Tables[0].Rows.Count > 0) {
+                                    oItem.HPlanInterID = ds.Tables[0].Rows[0]["HInterID"].ToString();
+                                    oItem.HPlanNo = ds.Tables[0].Rows[0]["HInterID"].ToString();
+                                }
+                            }
+
+
+                            //缁翠慨閮ㄩ棬
+                            if (keys.Contains("selectField_lq3idkva"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["selectField_lq3idkva"].ToString();
+                                DataSet ds = oCN.RunProcReturn("select * from Gy_Department with(nolock)  where HName='" + HDate_Temp + "'", "Gy_Department");
+                                string HDeptID = "0";
+                                if (ds.Tables[0].Rows.Count > 0)
+                                {
+                                    HDeptID = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                                }
+                                oItem.HDeptID = long.Parse(HDeptID);
+                            }
+
+                            //鏂拌璁″鍛�
+                            oItem.HNewDesignLife = 30000;
+
+                            //缁翠慨浜�
+                            if (keys.Contains("employeeField_lq3idkvh"))
+                            {
+                                string[] HDate_Temp = JsonConvert.DeserializeObject<string[]>(JsonConvert.SerializeObject(response.Body.Result[i].FormData["employeeField_lq3idkvh"]));
+                                DataSet ds = oCN.RunProcReturn("select * from Gy_Employee with(nolock)  where hname='" + HDate_Temp[0] + "'", "Gy_Employee");
+                                string HEmpID = "0";
+                                if (ds.Tables[0].Rows.Count > 0)
+                                {
+                                    HEmpID = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                                }
+                                oItem.HEmpID = long.Parse(HEmpID);
+                            }
+
+                            //缁翠慨鏃堕棿
+                            if (keys.Contains("numberField_lq3ixr9j"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["numberField_lq3ixr9j"].ToString();
+
+                                oItem.HTimes = long.Parse(HDate_Temp);
+                                oItem.HPlanTimes = long.Parse(HDate_Temp);
+                            }
+
+                            //瀛愯〃 缁翠慨瑕佹眰 缁翠慨澶囨敞(闂鎻忚堪)
+                            if (keys.Contains("tableField_lq3ixr9b"))
+                            {
+                                List<Dictionary<string, object>> dic = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(JsonConvert.SerializeObject(response.Body.Result[i].FormData["tableField_lq3ixr9b"]));
+                                for (int ij = 0; ij < dic.Count; ij++)
+                                {
+                                    Sc_MouldRepairWorkBillSub oItemSub = new Sc_MouldRepairWorkBillSub();
+
+                                    List<string> keys_Sub = new List<string>(dic[ij].Keys);
+
+                                    //缁翠慨瑕佹眰
+                                    if (keys_Sub.Contains("textareaField_lq3ixr9e"))
+                                    {
+                                        oItemSub.HRepairExplanation = dic[ij]["textareaField_lq3ixr9e"].ToString();
+                                    }
+
+                                    //澶囨敞
+                                    if (keys_Sub.Contains("textField_lq3ixr9d"))
+                                    {
+                                        oItemSub.HRemark = dic[ij]["textField_lq3ixr9d"].ToString();
+                                    }
+                                    oItem.DetailColMouldRepair.Add(oItemSub);
+                                }
+                            }
+
+                            string HRemark = "";
+                            //瀛愯〃 淇濆吇澶囨敞(闂鎻忚堪)
+                            if (keys.Contains("textareaField_ltpf2wiw"))
+                            {
+                                HRemark = response.Body.Result[i].FormData["textareaField_ltpf2wiw"].ToString();
+
+                            }
+
+                            //瀛愯〃 鍏蜂綋瑕佹眰 淇濆吇椤圭洰
+                            if (keys.Contains("checkboxField_ltpf2wif"))
+                            {
+                                string[] HDate_Temp = JsonConvert.DeserializeObject<string[]>(JsonConvert.SerializeObject(response.Body.Result[i].FormData["checkboxField_ltpf2wif"]));
+
+                                for (int ij = 0; ij < HDate_Temp.Length; ij++)
+                                {
+                                    Sc_MouldMaintainBillSub oItemSub = new Sc_MouldMaintainBillSub();
+
+                                    oItemSub.HClaim = HDate_Temp[ij];
+                                    oItemSub.HMaintainResult = HRemark;
+                                    oItem.DetailColMouldMaintain.Add(oItemSub);
+                                }
+
+                            }
+
+                            int startindex = response.Body.Result[i].Title.IndexOf("zh_CN") + 8;
+                            oItem.HTitle = startIndex + response.Body.Result[i].Title.Substring(startindex).Replace("\"}", "").Replace("'", "");
+
+                            if (keys.Contains("dateField_lo6w37hk"))
+                            {
+                                double HDate_Temp = double.Parse(response.Body.Result[i].FormData["dateField_lo6w37hk"].ToString());
+                                oItem.HDate = convertFromMillisecondsToDateString(HDate_Temp, "yyyy-MM-dd");
+                            }
+
+                            if (keys.Contains("selectField_lockncvh_id"))
+                            {
+                                oItem.HArea = response.Body.Result[i].FormData["selectField_lockncvh_id"].ToString().Replace("'", "");
+                            }
+
+                            if (keys.Contains("selectField_lockncvg_id"))
+                            {
+                                oItem.HCheckLevel = response.Body.Result[i].FormData["selectField_lockncvg_id"].ToString().Replace("'", "");
+                            }
+
+                            if (keys.Contains("employeeField_lo6w37hf"))
+                            {
+                                oItem.HEmplpyee = ((List<object>)response.Body.Result[i].FormData["employeeField_lo6w37hf"])[0].ToString().Replace("'", "");
+                            }
+
+                            if (keys.Contains("employeeField_lo6w37hf_id"))
+                            {
+                                oItem.HEmployeeID = ((List<object>)response.Body.Result[i].FormData["employeeField_lo6w37hf_id"])[0].ToString().Replace("'", "");
+                            }
+
+                            lsmain.Add(oItem);
+                        }
+                        catch (Exception e)
+                        {
+                            continue;
+                        }
+                    }
+
+                    startIndex = endIndex;
+                    endIndex += size;
+                    if (endIndex > IDList.Count)
+                    {
+                        endIndex = IDList.Count;
+                    }
+                }
+
+
+                return true;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e.Message);
+                msg = e.Message;
+                return false;
+            }
+
+        }
+        #endregion
+
+        #region 鏁版嵁鍚屾
+        public bool getData_MouldFileWeiXiuBaoYang(ref string msg)
+        {
+            //鑾峰彇 鍒嗗眰瀹℃牳琛� 瀹炰緥ID鍒楄〃
+            string appType = "APP_CSD7RLFJ3CTU330N3SCV";
+            string systemToken = "9T566BD1NWMGH17C93CKA9M4AS0D233TNU0QL82";
+            string userID = "011113050243860353";
+            string formUuid = "FORM-30C78F46E77E46A9AA8778214CEFE6B5J0AN";
+            int pageNumber = 1;
+            int pageSize = 100;
+
+            //鑾峰彇妯″叿缁翠慨淇濆吇琛ㄧ殑瀹炰緥ID鍒楄〃
+            List<string> IDList = new List<string>();
+            if (getInstanceIDList_YiDa(appType, systemToken, userID, formUuid, pageNumber, pageSize, ref IDList, ref msg) == false)
+            {
+                return false;
+            }
+
+            //鑾峰彇璇︾粏淇℃伅骞堕檮鍔犲埌鍒楄〃lsmain涓�
+            List<MouldFileWeiXiuBaoYang> lsmain = new List<MouldFileWeiXiuBaoYang>();
+            if (getInstanceDetailList___MouldFileWeiXiuBaoYang_YiDa(appType, systemToken, userID, formUuid, IDList, ref lsmain, ref msg) == false)
+            {
+                return false;
+            }
+
+            try
+            {
+                oCN.BeginTran();
+
+                string HMouldMaintainRuleInterID = "0";
+                string HMaintainItemID = "0";
+                string HRepairID = "0";
+                DataSet dataSet = oCN.RunProcReturn(@"select  a.HInterID,item.HMaintainItemID    from Sc_MouldMaintainRuleBillMain a with(nolock)
+inner join Sc_MouldMaintainRuleBillSub_Item item with(nolock) on  a.HInterID = item.HInterID
+where a.HRemark like'%閽夐拤鍚屾%'", "Sc_MouldMaintainRuleBillMain");
+
+                if (dataSet.Tables[0].Rows.Count > 0)
+                {
+                    HMouldMaintainRuleInterID = dataSet.Tables[0].Rows[0]["HInterID"].ToString();
+                    HMaintainItemID = dataSet.Tables[0].Rows[0]["HMaintainItemID"].ToString();
+                }
+
+                dataSet = oCN.RunProcReturn(@"select HItemID from Gy_Repair a with(nolock) where a.HRemark like'%閽夐拤鍚屾%' and HName like'%妯″叿缁翠慨%'", "Gy_Repair");
+
+                if (dataSet.Tables[0].Rows.Count > 0)
+                {
+                    HRepairID = dataSet.Tables[0].Rows[0]["HItemID"].ToString();
+                }
+
+                foreach (MouldFileWeiXiuBaoYang oItem in lsmain)
+                {
+                    //淇濆吇璁板綍
+                    if (oItem.DetailColMouldMaintain.Count != 0)
+                    {
+                       
+                        string BillType = "3819";
+                        string sql = $@"select HInnerBillNo from Sc_MouldMaintainBillMain
+                            where HInnerBillNo = '{oItem.HInstanceID}'";
+                        DataSet ds = oCN.RunProcReturn(sql, "Sc_MouldMaintainBillMain");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            long HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+                            //string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                            //long HInterID = 0;
+                            //string HBillNo = "";
+                            string sql_main = "Insert Into Sc_MouldMaintainBillMain " +
+                "(HBillType,HBillSubType,HInterID,HBillNo,HDate,HMaker,HMakeDate" +
+                ",HYear,HPeriod,HRemark,HUpDateDate" +
+                ",HPlanNo,HPlanInterID,HMouldID,HBeginDate" +
+                ",HEndDate" +
+                ",HInnerBillNo,HExplanation,HMouldMaintainRuleInterID,HMaintainLevID,HLastResult" +
+                ",HRequestComDate,HRecentMainModule,HCumulativeModule,HProductionModule" +
+                ",HPlanInterID,HPlanNo,HMaintainLevID)" +
+                "values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + oItem.HBillNo + "','"+ oItem.HDate + "','" + oItem.HOriginator + "','" + oItem.HMakeDate + "'" +
+                      ",'" + DateTime.Now.Year + "','" + DateTime.Now.Month + "','"+ oItem.HRemark + "','" + oItem.HUpdateDate + "'" +
+                      ",'','0','" + oItem.HMouldID + "','" + oItem.HRepairBeginDate + "'" +
+                      ",'" + oItem.HRepairEndDate + "'" +
+                      ",'" + oItem.HInstanceID + "','',"+ HMouldMaintainRuleInterID + ",0,'OK'" +
+                      ",'"+ oItem.HRequestComDate + "'," + oItem.HRecentMainModule + "," + oItem.HCumulativeModule + "," + oItem.HProductionModule + "" +
+                      "," + oItem.HPlanInterID + "," + oItem.HPlanNo + "," + oItem.HMaintainLevID + ")";
+                            LogService.Write(sql_main);
+                            oCN.RunProc(sql_main);
+                            int i = 1;
+                            foreach (Sc_MouldMaintainBillSub oItem_Detail in oItem.DetailColMouldMaintain)
+                            {
+                                string sql_sub = "Insert into Sc_MouldMaintainBillSub_Item" +
+                          " (HInterID,HEntryID,HMaintainItemID,HMaintainItem" +
+                          ",HMaintainPart,HClaim" +
+                          ",HManagerID" +
+                          ",HCloseMan,HCloseType,HRemark" +
+                          ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney,HMaintainResult" +
+                          ") " +
+                          "values('" + HInterID + "'," + i + ","+ HMaintainItemID + ",'" + oItem_Detail.HClaim + "'" +
+                     ",'','" + oItem_Detail.HClaim + "'" +
+                     ",'" + oItem.HEmpID + "'" +
+                     ",'','','" + oItem_Detail.HMaintainResult + "'" +
+                     ",'0','0','','',0,0,'Y')";
+                                LogService.Write(sql_sub);
+                                oCN.RunProc(sql_sub);
+                                i += 1;
+                            }
+
+                        }
+                    }
+
+                    //缁翠慨璁板綍
+                    if (oItem.DetailColMouldRepair.Count != 0)
+                    {
+                        string BillType = "3807";
+                        string sql = $@"select HInnerBillNo from Sc_MouldRepairWorkBillMain 
+                            where HInnerBillNo = '{oItem.HInstanceID}'";
+                        DataSet ds = oCN.RunProcReturn(sql, "Sc_MouldRepairWorkBillMain");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            long HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+                            //string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                            //long HInterID = 0;
+                            //string HBillNo = "";
+                            string sql_main = "Insert Into Sc_MouldRepairWorkBillMain " +
+                "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
+                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
+                ",HEquipID,HRepairID,HRepairBeginDate,HRepairEndDate,HRepairContent" +
+                ",HCycleUnit,HPlanTimes,HTimes,HEmpID,HManagerID" +
+                ",HDeptID,HExplanation,HInnerBillNo,HMouldID" +
+                ",HSupID,HRepairType,HNewModel,HNewDesignLife,HMainSourceBillType,HMainSourceInterID,HMainSourceEntryID" +
+                ",HRepairAccepDate)values" +
+                "('" + BillType + "','" + BillType + "'," + HInterID + ",'" + oItem.HBillNo + "','"+ oItem .HDate+ "'" +
+                ",'" + DateTime.Now.Year + "','" + DateTime.Now.Month + "','"+ oItem.HRemark + "','" + oItem.HOriginator + "','" + oItem.HMakeDate + "'" +
+                      ",'0','"+ HRepairID + "','" + oItem.HRepairBeginDate + "','" + oItem.HRepairEndDate + "',''" +
+                      ",'灏忔椂','" + oItem.HPlanTimes + "','" + oItem.HTimes + "','" + oItem.HEmpID + "',0" +
+                      ",'" + oItem.HDeptID + "','','" + oItem.HInstanceID + "','" + oItem.HMouldID + "'" +
+                      ",'0','鍐呴儴缁翠慨','','" + oItem.HNewDesignLife + "','1',0,0" +
+                      ",'"+ oItem.HRepairAccepDate + "')";
+                            LogService.Write(sql_main);
+                            oCN.RunProc(sql_main);
+                            int i = 1;
+                            foreach (Sc_MouldRepairWorkBillSub oItem_Detail in oItem.DetailColMouldRepair)
+                            {
+                                string sql_sub = "Insert into Sc_MouldRepairWorkBillSub " +
+                       " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
+                       ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                       ",HRepairID,HRepairExplanation,HManagerID,HMoney) values" +
+                       "('" + HInterID + "'," + i + ",'','','','" + oItem_Detail.HRemark + "'" +
+                          ",0,0,'','',0,0" +
+                          ","+ HRepairID + ",'" + oItem_Detail.HRepairExplanation + "','" + oItem.HEmpID + "',0)";
+                                LogService.Write(sql_sub);
+                                oCN.RunProc(sql_sub);
+                                i += 1;
+                            }
+
+                        }
+                    }
+
+                   
+                }
+                oCN.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e.Message);
+                msg = e.Message;
+                oCN.RollBack();
+                return false;
+            }
+        }
+        #endregion
+        #endregion
+
+        #region 鏁版嵁鍚屾-璁惧缁翠慨璁板綍鍗�
+        #region 鑾峰彇 瀹滄惌-璁惧缁翠慨璁板綍鍗� 瀹炰緥ID鍒楄〃瀵瑰簲鐨勫疄渚嬭鎯�
+        public bool getInstanceDetailList___EquipRepairWeiXiu_YiDa(string appType, string systemToken, string userID, string formUuid, List<string> IDList, ref List<EquipRepairWeiXiu> lsmain, ref string msg, int size = 500)
+        {
+            string a = "";
+            try
+            {
+                int startIndex = 0;
+                int endIndex = startIndex + size;
+                if (endIndex > IDList.Count)
+                {
+                    endIndex = IDList.Count;
+                }
+
+                while (startIndex < endIndex && endIndex <= IDList.Count)
+                {
+                    List<string> IDList_temp = new List<string>();
+                    for (int i = startIndex; i < endIndex; i++)
+                    {
+                        IDList_temp.Add(IDList[i]);
+                    }
+
+                    BatchGetFormDataByIdListResponse response = new BatchGetFormDataByIdListResponse();
+                    if (getInstanceDetailListByInstanceIDList_YiDa(appType, systemToken, formUuid, userID, IDList_temp, ref response, ref msg) == false)
+                    {
+                        return false;
+                    }
+
+
+                    for (int i = 0; i < response.Body.Result.Count; i++)
+                    {
+                        try
+                        {
+                            List<string> keys = new List<string>(response.Body.Result[i].FormData.Keys);
+
+                            EquipRepairWeiXiu oItem = new EquipRepairWeiXiu();
+                            oItem.HMakerID = response.Body.Result[i].CreatorUserId.Replace("'", "");
+                            oItem.HMaker = response.Body.Result[i].CreatorUserId.Replace("'", "");
+                            oItem.HMakeDate = response.Body.Result[i].CreateTimeGMT.Replace("T", " ").Replace("Z", "").Replace("'", "");
+                            oItem.HUpdaterID = response.Body.Result[i].ModifyUser.UserId.Replace("'", "");
+                            oItem.HUpdater = response.Body.Result[i].ModifyUser.Name.NameInChinese.Replace("'", "");
+                            oItem.HUpdateDate = response.Body.Result[i].ModifiedTimeGMT.Replace("T", " ").Replace("Z", "").Replace("'", "");
+                            oItem.HInstanceID = response.Body.Result[i].FormInstanceId.Replace("'", "");
+                            oItem.HOriginator = response.Body.Result[i].Originator.Name.NameInChinese.Replace("'", "");
+
+                            GetInstanceByIdResponse getInstanceByIdResponse = new GetInstanceByIdResponse(); ;
+                            if (!getInstanceStatusByInstanceID__YiDa(appType, systemToken, userID, oItem.HInstanceID, ref getInstanceByIdResponse, ref msg))
+                            {
+                                continue;
+                            }
+
+                            if (getInstanceByIdResponse.Body.InstanceStatus != "COMPLETED")
+                            {
+                                continue;
+                            }
+
+                            if (oItem.HInstanceID != "9b6e108c-b7bf-45e4-910d-5629ac30d4aa") {
+                                continue;
+                            }
+
+                            //璁惧缂栫爜
+                            if (keys.Contains("textField_lfg9hgys"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["textField_lfg9hgys"].ToString();
+                                DataSet ds = oCN.RunProcReturn("select * from Gy_EquipFileBillMain with(nolock)  where HEquipFileNo='" + HDate_Temp + "'", "Gy_EquipFileBillMain");
+                                string HEquipID = "0";
+                                if (ds.Tables[0].Rows.Count > 0)
+                                {
+                                    HEquipID = ds.Tables[0].Rows[0]["HInterID"].ToString();
+                                    oItem.HEquipID = long.Parse(HEquipID);
+                                    oItem.HRemark2 = HDate_Temp;
+                                }
+                                else
+                                {
+                                    continue;
+                                }
+                            }
+
+                            //缁翠慨閮ㄩ棬
+                            if (keys.Contains("selectField_kzgkw10a"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["selectField_kzgkw10a"].ToString();
+                                DataSet ds = oCN.RunProcReturn("select * from Gy_Department with(nolock)  where HName='" + HDate_Temp + "'", "Gy_Department");
+                                string HDeptID = "0";
+                                if (ds.Tables[0].Rows.Count > 0)
+                                {
+                                    HDeptID = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                                    oItem.HDeptID = long.Parse(HDeptID);
+                                }
+                                else
+                                {
+                                    continue;
+                                }
+
+                            }
+
+                            //缁翠慨浜�
+                            if (keys.Contains("employeeField_lthwkdh2"))
+                            {
+                                string[] HDate_Temp = JsonConvert.DeserializeObject<string[]>(JsonConvert.SerializeObject(response.Body.Result[i].FormData["employeeField_lthwkdh2"]));
+                                DataSet ds = oCN.RunProcReturn("select * from Gy_Employee with(nolock)  where HName='" + HDate_Temp[0] + "'", "Gy_Employee");
+                                string HEmpID = "0";
+                                if (ds.Tables[0].Rows.Count > 0)
+                                {
+                                    HEmpID = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                                    oItem.HEmpID = long.Parse(HEmpID);
+                                }
+                                else
+                                {
+                                    continue;
+                                }
+
+                            }
+
+                            //缁翠慨鍐呭
+                            if (keys.Contains("textField_l2r9bvwk"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["textField_l2r9bvwk"].ToString();
+
+                                oItem.HRepairContent = HDate_Temp;
+                            }
+
+                            //鎶ヤ慨绫诲埆
+                            if (keys.Contains("multiSelectField_lfg9hgyv"))
+                            {
+                                string[] HDate_Temp = JsonConvert.DeserializeObject<string[]>(JsonConvert.SerializeObject(response.Body.Result[i].FormData["multiSelectField_lfg9hgyv"]));
+
+                                oItem.HRepairCategory = HDate_Temp[0];
+                            }
+
+                            //绱ф�ョ▼搴�
+                            if (keys.Contains("radioField_kzgkw10c"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["radioField_kzgkw10c"].ToString();
+
+                                oItem.HUrgenLevel = HDate_Temp;
+                            }
+
+                            //鎶ヤ慨浜�
+                            if (keys.Contains("employeeField_lkasesrk"))
+                            {
+                                string[] HDate_Temp = JsonConvert.DeserializeObject<string[]>(JsonConvert.SerializeObject(response.Body.Result[i].FormData["employeeField_lkasesrk"]));
+
+                                oItem.HRepairer = HDate_Temp[0];
+                            }
+
+                            //鏄惁鏈変骇鑳藉奖鍝�
+                            if (keys.Contains("textField_lyjddw0r"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["textField_lyjddw0r"].ToString();
+
+                                oItem.HIsCapacityImpact = HDate_Temp;
+                            }
+                         
+                            //缁翠慨鏃堕棿
+                            if (keys.Contains("textField_l2r95oo2"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["textField_l2r95oo2"].ToString();
+                                bool containsNumber = HDate_Temp.Any(c => char.IsDigit(c));
+                           
+                                if (!containsNumber)
+                                {
+                                    HDate_Temp = "0";
+                                }
+                                //LogService.Write("1:------"+HDate_Temp+ ",2:------" + int.Parse(new string(HDate_Temp.Where(char.IsDigit).ToArray())));
+                                //a = HDate_Temp;
+                                oItem.HTimes = int.Parse(new string(HDate_Temp.Where(char.IsDigit).ToArray()));
+                                oItem.HPlanTimes = int.Parse(new string(HDate_Temp.Where(char.IsDigit).ToArray()));
+                            }
+
+                            //瀛愯〃 缁翠慨瑕佹眰 缁翠慨澶囨敞(闂鎻忚堪)
+
+                            Sc_MouldRepairWorkBillSub sub = new Sc_MouldRepairWorkBillSub();
+
+                            //缁翠慨瑕佹眰
+                            if (keys.Contains("textareaField_lthwo99r"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["textareaField_lthwo99r"].ToString();
+                                oItem.HExplanation = HDate_Temp;
+                                sub.HRepairExplanation = HDate_Temp;
+                            }
+
+                            //澶囨敞
+                            if (keys.Contains("textField_l2r95oo0"))
+                            {
+                                string HDate_Temp = response.Body.Result[i].FormData["textField_l2r95oo0"].ToString();
+
+                                sub.HRemark = HDate_Temp;
+                            }
+                            oItem.DetailColMouldRepair.Add(sub);
+
+                            int startindex = response.Body.Result[i].Title.IndexOf("zh_CN") + 8;
+                            oItem.HTitle = startIndex + response.Body.Result[i].Title.Substring(startindex).Replace("\"}", "").Replace("'", "");
+
+                            if (keys.Contains("dateField_lo6w37hk"))
+                            {
+                                double HDate_Temp = double.Parse(response.Body.Result[i].FormData["dateField_lo6w37hk"].ToString());
+                                oItem.HDate = convertFromMillisecondsToDateString(HDate_Temp, "yyyy-MM-dd");
+                            }
+
+                            if (keys.Contains("selectField_lockncvh_id"))
+                            {
+                                oItem.HArea = response.Body.Result[i].FormData["selectField_lockncvh_id"].ToString().Replace("'", "");
+                            }
+
+                            if (keys.Contains("selectField_lockncvg_id"))
+                            {
+                                oItem.HCheckLevel = response.Body.Result[i].FormData["selectField_lockncvg_id"].ToString().Replace("'", "");
+                            }
+
+                            if (keys.Contains("employeeField_lo6w37hf"))
+                            {
+                                oItem.HEmplpyee = ((List<object>)response.Body.Result[i].FormData["employeeField_lo6w37hf"])[0].ToString().Replace("'", "");
+                            }
+
+                            if (keys.Contains("employeeField_lo6w37hf_id"))
+                            {
+                                oItem.HEmployeeID = ((List<object>)response.Body.Result[i].FormData["employeeField_lo6w37hf_id"])[0].ToString().Replace("'", "");
+                            }
+
+                            lsmain.Add(oItem);
+                        }
+                        catch (Exception e)
+                        {
+                            LogService.Write(e.Message);
+                            a = "";
+                            continue;
+                        }
+                    }
+
+                    startIndex = endIndex;
+                    endIndex += size;
+                    if (endIndex > IDList.Count)
+                    {
+                        endIndex = IDList.Count;
+                    }
+                }
+
+
+                return true;
+            }
+            catch (Exception e)
+            {
+                msg = e.Message;
+                return false;
+            }
+
+        }
+        #endregion
+
+        #region 鏁版嵁鍚屾
+        public bool getData_EquipRepairWeiXiu(ref string msg)
+        {
+            //鑾峰彇 鍒嗗眰瀹℃牳琛� 瀹炰緥ID鍒楄〃
+            string appType = "APP_E2A54CQBDX3TZN51JGBI";
+            string systemToken = "YKB660C1ZPNW58JDZKAP318W5VQE2RRMQL2YKZK";
+            string userID = "011113050243860353";
+            string formUuid = "FORM-OM566O7177LW0ARJ5IMFF63NTFKA34G9RL2YKN1";
+            int pageNumber = 1;
+            int pageSize = 100;
+
+            //鑾峰彇璁惧缁翠慨淇濆吇琛ㄧ殑瀹炰緥ID鍒楄〃
+            List<string> IDList = new List<string>();
+            if (getInstanceIDList_YiDa(appType, systemToken, userID, formUuid, pageNumber, pageSize, ref IDList, ref msg) == false)
+            {
+                return false;
+            }
+
+            //鑾峰彇璇︾粏淇℃伅骞堕檮鍔犲埌鍒楄〃lsmain涓�
+            List<EquipRepairWeiXiu> lsmain = new List<EquipRepairWeiXiu>();
+            if (getInstanceDetailList___EquipRepairWeiXiu_YiDa(appType, systemToken, userID, formUuid, IDList, ref lsmain, ref msg) == false)
+            {
+                return false;
+            }
+
+            try
+            {
+                oCN.BeginTran();
+
+               DataSet dataSet = oCN.RunProcReturn(@"select HItemID from Gy_Repair a with(nolock) where a.HRemark like'%閽夐拤鍚屾%' and HName like'%璁惧缁翠慨%'", "Gy_Repair");
+                string HRepairID = "0";
+                if (dataSet.Tables[0].Rows.Count > 0)
+                {
+                    HRepairID = dataSet.Tables[0].Rows[0]["HItemID"].ToString();
+                }
+
+                foreach (EquipRepairWeiXiu oItem in lsmain)
+                {
+                    //缁翠慨璁板綍
+                    if (oItem.DetailColMouldRepair.Count != 0)
+                    {
+                        string BillType = "3910";
+                        string sql = $@"select HInnerBillNo from Sb_EquipRepairWorkBillMain 
+                            where HInnerBillNo = '{oItem.HInstanceID}'";
+                        DataSet ds = oCN.RunProcReturn(sql, "Sb_EquipRepairWorkBillMain");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            long HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo);
+                            string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+                            //long HInterID = 0;
+                            //string HBillNo = "";
+                            string sql_main = "Insert Into Sb_EquipRepairWorkBillMain " +
+                "(HBillType,HBillSubType,HInterID,HBillNo,HDate" +
+                ",HYear,HPeriod,HRemark,HMaker,HMakeDate" +
+                ",HEquipID,HRepairID,HPlanTimes,HEmpID,HManagerID,HTimes" +
+                ",HDeptID,HExplanation,HInnerBillNo,HRepairBeginDate,HRepairEndDate" +
+                ",HRepairContent,HCycleUnit,HMainSourceBillType,HMainSourceInterID,HMainSourceEntryID" +
+                ",HRepairCategory,HUrgenLevel,HRepairer,HIsCapacityImpact)" +
+                "values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "',getdate()" +
+                ",'" + DateTime.Now.Year + "','" + DateTime.Now.Month + "','"+ oItem.HRemark2 + "','" + oItem.HOriginator + "','" + oItem.HMakeDate + "'" +
+                      ",'" + oItem.HEquipID + "','"+ HRepairID + "','" + oItem.HTimes + "','" + oItem.HEmpID + "','" + oItem.HEmpID + "','" + oItem.HTimes + "'" +
+                      ",'" + oItem.HDeptID + "','"+ oItem.HExplanation + "','" + oItem.HInstanceID + "','"+ oItem.HMakeDate + "','" + oItem.HUpdateDate + "'" +
+                      ",'" + oItem.HRepairContent + "','灏忔椂','鎵嬪伐褰曞叆','0',0" +
+                      ",'"+ oItem.HRepairCategory + "','" + oItem.HUrgenLevel + "','" + oItem.HRepairer + "','" + oItem.HIsCapacityImpact + "')";
+                            LogService.Write(sql_main);
+                            oCN.RunProc(sql_main);
+                            int i = 1;
+                            foreach (Sc_MouldRepairWorkBillSub oItem_Detail in oItem.DetailColMouldRepair)
+                            {
+                                string sql_sub = "Insert into Sb_EquipRepairWorkBillSub " +
+                       " (HInterID,HEntryID,HCloseMan,HEntryCloseDate,HCloseType,HRemark" +
+                       ",HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
+                       ",HRepairID,HManagerID,HRepairExplanation,HEmpID)" +
+                       "values('" + HInterID + "'," + i + ",'','','','" + oItem_Detail.HRemark + "'" +
+                          ",0,0,'','',0,0" +
+                          "," + HRepairID + ",'" + oItem.HEmpID + "','" + oItem_Detail.HRepairExplanation + "','" + oItem.HEmpID + "')";
+                                LogService.Write(sql_sub);
+                                oCN.RunProc(sql_sub);
+                                i += 1;
+                            }
+
+                        }
+                    }
+
+
+                }
+                oCN.Commit();
+                return true;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e.Message);
+                msg = e.Message;
+                oCN.RollBack();
+                return false;
+            }
+        }
+        #endregion
+        #endregion
+
         #endregion
 
 

--
Gitblit v1.9.1