From 3b9d0ef535563fff2102a76a59581301037a2b84 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期四, 19 九月 2024 08:47:02 +0800
Subject: [PATCH] 设备维修记录单 模具维修记录单 保养记录单
---
WebAPI/Controllers/数据同步/钉钉同步/DD_DataSynchronizationController.cs | 811 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 810 insertions(+), 1 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 a1561f5..9f73025 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"
@@ -231,6 +231,111 @@
}
#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 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 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 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
#region 閽夐拤 閫氱敤鎿嶄綔鏂规硶
@@ -397,7 +502,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(-14).ToString("yyyy-MM-dd"), //鍒涘缓鏃堕棿璧峰鍊笺��
CreateToTimeGMT = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), //鍒涘缓鏃堕棿缁堟鍊笺��
PageSize = pageSize, //鍒嗛〉澶у皬銆�
@@ -547,6 +652,51 @@
}
}
#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 鏁版嵁鍚屾鏂规硶
@@ -1635,6 +1785,665 @@
}
#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_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.HRemark = HDate_Temp;
+ }
+
+ //妯″叿缂栫爜
+ if (keys.Contains("dateField_lq4gf2ii"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["dateField_lq4gf2ii"].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);
+ }
+
+
+ //缁翠慨閮ㄩ棬
+ 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 HNumber='" + 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)
+ {
+ 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();
+ 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" +
+ ")values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "',getdate(),'" + oItem.HOriginator + "','" + oItem.HMakeDate + "'" +
+ ",'" + DateTime.Now.Year + "','" + DateTime.Now.Month + "','"+ oItem.HRemark + "','" + oItem.HUpdateDate + "'" +
+ ",'','0','" + oItem.HMouldID + "','" + oItem.HRepairBeginDate + "'" +
+ ",'" + oItem.HRepairEndDate + "'" +
+ ",'" + oItem.HInstanceID + "','',0,0,'OK')";
+ 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 + ",0,'" + oItem_Detail.HClaim + "'" +
+ ",'','" + oItem_Detail.HClaim + "'" +
+ ",'" + oItem.HEmpID + "'" +
+ ",'','','" + oItem_Detail.HMaintainResult + "'" +
+ ",'0','0','','',0,0,'')";
+ 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" +
+ ")values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "',getdate()" +
+ ",'" + DateTime.Now.Year + "','" + DateTime.Now.Month + "','','" + oItem.HOriginator + "','" + oItem.HMakeDate + "'" +
+ ",'0','0','" + oItem.HRepairBeginDate + "','" + oItem.HUpdateDate + "',''" +
+ ",'灏忔椂','" + oItem.HPlanTimes + "','" + oItem.HTimes + "','" + oItem.HEmpID + "',0" +
+ ",'" + oItem.HDeptID + "','','" + oItem.HInstanceID + "','" + oItem.HMouldID + "'" +
+ ",'0','鍐呴儴缁翠慨','','" + oItem.HNewDesignLife + "','',0,0)";
+
+ 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" +
+ ",0,'" + oItem_Detail.HRepairExplanation + "','" + oItem.HEmpID + "',0)";
+ oCN.RunProc(sql_sub);
+ i += 1;
+ }
+
+ }
+ }
+
+
+ }
+ oCN.Commit();
+ return true;
+ }
+ catch (Exception e)
+ {
+ 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)
+ {
+
+ 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 (keys.Contains("textField_lfg9hgys"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["textField_lfg9hgys"].ToString();
+ DataSet ds = oCN.RunProcReturn("select * from Gy_MouldFileMain with(nolock) where HNumber='" + HDate_Temp + "'", "Gy_MouldFileMain");
+ 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;
+ }
+
+
+ //缁翠慨閮ㄩ棬
+ 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);
+ }
+
+
+ //缁翠慨浜�
+ 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 HNumber='" + 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("textField_l2r95oo2"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["textField_l2r95oo2"].ToString();
+
+ oItem.HTimes = long.Parse(HDate_Temp);
+ oItem.HPlanTimes = long.Parse(HDate_Temp);
+ }
+
+ //缁翠慨鍐呭
+ if (keys.Contains("textField_l2r9bvwk"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["textField_l2r9bvwk"].ToString();
+
+ oItem.HRepairContent = HDate_Temp;
+ }
+
+
+ //瀛愯〃 缁翠慨瑕佹眰 缁翠慨澶囨敞(闂鎻忚堪)
+
+ Sc_MouldRepairWorkBillSub sub = new Sc_MouldRepairWorkBillSub();
+
+ //缁翠慨瑕佹眰
+ if (keys.Contains("textareaField_lthwo99r"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["textareaField_lthwo99r"].ToString();
+
+ 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)
+ {
+ 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();
+ 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" +
+ ")values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "',getdate()" +
+ ",'" + DateTime.Now.Year + "','" + DateTime.Now.Month + "','"+ oItem.HRemark2 + "','" + oItem.HOriginator + "','" + oItem.HMakeDate + "'" +
+ ",'" + oItem.HEquipID + "','0','" + oItem.HTimes + "','" + oItem.HEmpID + "','" + oItem.HEmpID + "','" + oItem.HTimes + "'" +
+ ",'" + oItem.HDeptID + "','" + oItem.HExplanation + "','" + oItem.HInstanceID + "','',''" +
+ ",'" + oItem.HRepairContent + "','灏忔椂','','0',0)";
+
+ 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" +
+ ",0,'" + oItem.HEmpID + "','" + oItem_Detail.HRepairExplanation + "','" + oItem.HEmpID + "')";
+ oCN.RunProc(sql_sub);
+ i += 1;
+ }
+
+ }
+ }
+
+
+ }
+ oCN.Commit();
+ return true;
+ }
+ catch (Exception e)
+ {
+ msg = e.Message;
+ oCN.RollBack();
+ return false;
+ }
+ }
+ #endregion
+ #endregion
+
#endregion
--
Gitblit v1.9.1