From 3fe3da69ed76cc71d92198c6f0aea9f5bb4b6e77 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期五, 27 十二月 2024 10:16:19 +0800
Subject: [PATCH] 1
---
WebAPI/Controllers/数据同步/钉钉同步/DD_DataSynchronizationController.cs | 1977 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 1,946 insertions(+), 31 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 cc3e713..ac770ab 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,9 @@
using DingTalk.Api;
using DingTalk.Api.Response;
using System.Globalization;
+using System.Linq;
+using AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models;
+using System.Text.RegularExpressions;
namespace WebAPI.Controllers
{
@@ -74,7 +77,7 @@
private string AppKey = "dingiokapm2dvjrhzl2g"; //宸插垱寤虹殑浼佷笟鍐呴儴搴旂敤鐨凙ppKey銆�
private string AppSecret = "dPUD7tN3BGVYAC4lDzhpcBH7O4FWFDdjLJWa6cVRBQj5U7GJ4Gwr7Vohnv0oPBOr"; //宸插垱寤虹殑浼佷笟鍐呴儴搴旂敤鐨凙ppSecret銆�
private long AgentID = 3188176952; //搴旂敤鐨凙gentId
- private string accessToken = ""; //璋冪敤璇ユ帴鍙g殑璁块棶鍑瘉銆�
+ public string accessToken = ""; //璋冪敤璇ユ帴鍙g殑璁块棶鍑瘉銆�
private string ProcessInstanceId = ""; //瀹℃壒瀹炰緥ID銆�
#endregion
@@ -84,6 +87,13 @@
public long? TotalCount;
public long? PageNumber;
public List<string> Data;
+ }
+ //oa瀹℃壒杩斿洖绫�
+ public class OA_GetInstanceIDListResponse
+ {
+ public List<string> list;//鑾峰彇鐨刬d鍒楄〃
+ public string nextToken;
+ public bool? success;
}
#region 鍒嗗眰瀹℃牳绛惧埌琛�
@@ -100,6 +110,8 @@
public string HOriginator; //鍙戣捣浜�
public string HTitle; //鍗曟嵁鏍囬
+ public string HInstanceStatus; //瀹炰緥鐘舵��
+ public string HApprovedResult; //瀹℃壒缁撴灉
//鍗曟嵁鍐呭
public string HDate; //鏃ユ湡
@@ -124,6 +136,8 @@
public string HOriginator; //鍙戣捣浜�
public string HTitle; //鍗曟嵁鏍囬
+ public string HInstanceStatus; //瀹炰緥鐘舵��
+ public string HApprovedResult; //瀹℃壒缁撴灉
//鍗曟嵁鍐呭
public string HDate; //鏃ユ湡
@@ -154,6 +168,8 @@
public string HOriginator; //鍙戣捣浜�
public string HTitle; //鍗曟嵁鏍囬
+ public string HInstanceStatus; //瀹炰緥鐘舵��
+ public string HApprovedResult; //瀹℃壒缁撴灉
//鍗曟嵁鍐呭
public string HEmployeeID; //鎴愬憳ID
@@ -191,6 +207,8 @@
public string HOriginator; //鍙戣捣浜�
public string HTitle; //鍗曟嵁鏍囬
+ public string HInstanceStatus; //瀹炰緥鐘舵��
+ public string HApprovedResult; //瀹℃壒缁撴灉
//鍗曟嵁鍐呭
public string HQuestionType; //闂鍒嗙被
@@ -231,6 +249,201 @@
}
#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
+
+ #region 寮傚父宸ユ椂鐢宠鍗�
+
+ #region 涓昏〃+瀛愯〃
+ public class Pay_ErrWorkTimesRequestBill
+ {
+ public int HInterID;
+ public string HBillNo;
+ public string HDate;
+ public string HInnerBillNo;
+ public int HDeptID;
+ public string HDeptName;
+ public int HGroupID;
+ public string HGroupName;
+ public int HMangerID;
+ public string HManagerName;
+ public int HICMOInterID;
+ public string HICMOBillNo;
+ public string HExplanation;
+ public double HSumRequestTimes;
+ public int HMaterID;
+ public string HMaterName;
+ public int HUnitID;
+ public string HUnitName;
+ public double HPlanQty;
+ public string HBatchNo;
+ public string HRemark;
+
+ public string HMaker;
+ public string HMakerDate;
+ public string HUpdater;
+ public string HUpdaterDate;
+ public string HChecker;
+ public string HCheckerDate;
+ public string HCloseMan;
+ public string HCloseManDate;
+ public string HDeleteMan;
+ public string HDeleteManDate;
+ public string HBacker;
+ public string HBackerDate;
+ public string HBackRemark;
+ public List<Pay_ErrWorkTimesRequestBillSub> Pay_ErrWorkTimesRequestBillSub = new List<Pay_ErrWorkTimesRequestBillSub>();
+ }
+ #endregion
+
+ #region 瀛愯〃
+ public class Pay_ErrWorkTimesRequestBillSub
+ {
+ public int HEmpID;
+ public string HEmpNumber;
+ public string HEmpName;
+ public int HWorkTypeID;
+ public string HWorkTypeNumber;
+ public string HWorkTypeName;
+ public double HPayMoney;
+ public string HBTimes;
+ public string HETimes;
+ public double HTimes;
+ public double HRelTimes;
+ public double HRelPay;
+ public string HRemark;
+
+ public int HSourceInterID;
+ public int HSourceEntryID;
+ public string HSourceBillNo;
+ public string HSourceBillType;
+ public double HRelationQty;
+ public double HRelationMoney;
+ public string HCloseMan;
+ public string HEntryCloseDate;
+ }
+ #endregion
+
+ #endregion
+
#endregion
#region 閽夐拤 閫氱敤鎿嶄綔鏂规硶
@@ -323,25 +536,29 @@
#region 鑾峰彇 閽夐拤-鏅鸿兘浜轰簨 鑾峰彇鍦ㄨ亴鍛樺伐ID鍒楄〃
public bool getEmployeeIDList_DingDing(long offset, long size, ref List<string> IDList, ref string msg)
{
+ LogService.Write("鏌ョ湅5-1-1");
OapiSmartworkHrmEmployeeQueryonjobResponse response = new OapiSmartworkHrmEmployeeQueryonjobResponse();
do
{
if (getEmployeeIDList_Page_DingDing(offset, size, ref response, ref msg) == false)
{
+ LogService.Write("鏌ョ湅5-1-2");
return false;
}
-
+ LogService.Write("鏌ョ湅5-1-3");
for (int i = 0; i < response.Result.DataList.Count; i++)
{
IDList.Add(response.Result.DataList[i]);
}
-
+ LogService.Write("鏌ョ湅5-1-4");
if (response.Result.NextCursor != 0)
{
+ LogService.Write("鏌ョ湅5-1-4-1");
offset = response.Result.NextCursor;
}
else
{
+ LogService.Write("鏌ョ湅5-1-5");
break;
}
} while (true);
@@ -397,8 +614,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 +766,189 @@
}
}
#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 oa 閫氱敤鎿嶄綔鏂规硶
+
+ #region OA 鑾峰彇瀹℃壒瀹炰緥ID鍒楄〃(鍗曢〉)
+ public bool getInstanceIDList_Page_OA(string processCode,DateTime startTime, DateTime endTime,long nextToken, int maxResult, List<string> statuses, ref OA_GetInstanceIDListResponse response, ref string msg)
+ {
+ AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client client = CreateClient1();
+ AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.ListProcessInstanceIdsHeaders listProcessInstanceIdsHeaders = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.ListProcessInstanceIdsHeaders();
+ listProcessInstanceIdsHeaders.XAcsDingtalkAccessToken = this.accessToken;
+ AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.ListProcessInstanceIdsRequest listProcessInstanceIdsRequest = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.ListProcessInstanceIdsRequest
+ {
+ Statuses = statuses,
+ StartTime = getTimeMillions(startTime),
+ EndTime = getTimeMillions(endTime),
+ ProcessCode = processCode,
+ NextToken = nextToken,
+ MaxResults = maxResult,
+ };
+ try
+ {
+ ListProcessInstanceIdsResponse listProcessInstanceIdsResponse = client.ListProcessInstanceIdsWithOptions(listProcessInstanceIdsRequest, listProcessInstanceIdsHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
+ response.success = listProcessInstanceIdsResponse.Body.Success;
+ response.list = listProcessInstanceIdsResponse.Body.Result.List;
+ response.nextToken = listProcessInstanceIdsResponse.Body.Result.NextToken;
+ return true;
+ }
+ catch (TeaException err)
+ {
+ if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
+ {
+ // err 涓惈鏈� code 鍜� message 灞炴�э紝鍙府鍔╁紑鍙戝畾浣嶉棶棰�
+ }
+ msg = "閿欒浠g爜" + err.Code + "锛�" + 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 = "閿欒浠g爜" + err.Code + "锛�" + err.Message;
+ return false;
+ }
+ }
+ #endregion
+
+ #region 鑾峰彇 OA鎸囧畾鍗曟嵁鐨勫疄渚婭D鍒楄〃(鍏ㄩ儴)
+ public bool getInstanceIDList_OA(string processCode, DateTime startTime, DateTime endTime, long nextToken, int maxResult, List<string> statuses, ref List<string> IDList, ref string msg)
+ {
+ OA_GetInstanceIDListResponse response = new OA_GetInstanceIDListResponse();
+ response.nextToken = nextToken.ToString();//璧嬪�煎垵濮嬪��
+ do
+ {
+ nextToken = long.Parse(response.nextToken);
+ if (getInstanceIDList_Page_OA(processCode, startTime, endTime, nextToken, maxResult, statuses,ref response, ref msg) == false)
+ {
+ return false;
+ }
+
+ for (int i = 0; i < response.list.Count; i++)
+ {
+ IDList.Add(response.list[i]);
+ }
+
+ } while (response.nextToken!=null);
+ return true;
+ }
+ #endregion
+
+ #region 鑾峰彇 OA 鏍规嵁瀹炰緥ID鑾峰彇瀹炰緥璇︽儏
+ public bool getInstanceDetailByInstanceID_OA(string processinstanceID,ref GetProcessInstanceResponse response, ref string msg)
+ {
+ AlibabaCloud.SDK.Dingtalkworkflow_1_0.Client client = CreateClient1();
+ AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetProcessInstanceHeaders getProcessInstanceHeaders = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetProcessInstanceHeaders();
+ getProcessInstanceHeaders.XAcsDingtalkAccessToken = this.accessToken;
+ AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetProcessInstanceRequest getProcessInstanceRequest = new AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models.GetProcessInstanceRequest
+ {
+ ProcessInstanceId = processinstanceID,
+ };
+ try
+ {
+ response = client.GetProcessInstanceWithOptions(getProcessInstanceRequest, getProcessInstanceHeaders, new AlibabaCloud.TeaUtil.Models.RuntimeOptions());
+ return true;
+ }
+ catch (TeaException err)
+ {
+ if (!AlibabaCloud.TeaUtil.Common.Empty(err.Code) && !AlibabaCloud.TeaUtil.Common.Empty(err.Message))
+ {
+ // err 涓惈鏈� code 鍜� message 灞炴�э紝鍙府鍔╁紑鍙戝畾浣嶉棶棰�
+ }
+ msg = "閿欒浠g爜" + err.Code + "锛�" + 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 = "閿欒浠g爜" + err.Code + "锛�" + err.Message;
+ return false;
+ }
+ }
+ #endregion
+
+ #region 鑾峰彇 OA 鏍规嵁瀹炰緥ID鍒楄〃鑾峰彇瀹炰緥璇︽儏鍒楄〃
+ public bool getInstanceDetailListByInstanceIDList_OA(List<string> processinstanceIDList, ref List<GetProcessInstanceResponse> responseList, ref string msg)
+ {
+ GetProcessInstanceResponse getProcessInstanceResponse = new GetProcessInstanceResponse();
+ try
+ {
+ foreach(string processinstanceID in processinstanceIDList)
+ {
+ if(!getInstanceDetailByInstanceID_OA(processinstanceID,ref getProcessInstanceResponse,ref msg))
+ {
+ return false;
+ }
+ responseList.Add(getProcessInstanceResponse);
+ }
+ return true;
+ }
+ catch (Exception e)
+ {
+ msg = e.Message;
+ return false;
+ }
+ }
+ #endregion
+
#endregion
#region 鏁版嵁鍚屾鏂规硶
@@ -599,35 +1001,108 @@
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)
{
+ LogService.Write("鏌ョ湅1" + e.Message);
continue;
}
}
@@ -660,10 +1135,11 @@
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;
-
+ LogService.Write("鏌ョ湅1");
//鑾峰彇鍒嗗眰瀹℃牳琛ㄧ殑瀹炰緥ID鍒楄〃
List<string> IDList = new List<string>();
if (getInstanceIDList_YiDa(appType, systemToken, userID, formUuid, pageNumber, pageSize, ref IDList, ref msg) == false)
@@ -680,7 +1156,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 +1170,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 +1187,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,10 +1299,54 @@
{
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)
{
+ LogService.Write("鏌ョ湅2"+e.Message);
continue;
}
}
@@ -855,7 +1378,7 @@
string formUuid = "FORM-E3DFC12364514330A836DD3056C15668UGG7";
int pageNumber = 1;
int pageSize = 100;
-
+ LogService.Write("鏌ョ湅2");
//鑾峰彇瀹炰緥ID鍒楄〃
List<string> IDList = new List<string>();
if (getInstanceIDList_YiDa(appType, systemToken, userID, formUuid, pageNumber, pageSize, ref IDList, ref msg) == false)
@@ -886,7 +1409,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 +1432,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,10 +1575,48 @@
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)
{
+ LogService.Write("鏌ョ湅3"+e.Message);
continue;
}
}
@@ -1084,7 +1648,7 @@
string formUuid = "FORM-K5766HA1CKZB4E1L64Y1KBWCJTQF2HWJ3NDJL4";
int pageNumber = 1;
int pageSize = 100;
-
+ LogService.Write("鏌ョ湅3");
//鑾峰彇瀹炰緥ID鍒楄〃
List<string> IDList = new List<string>();
if (getInstanceIDList_YiDa(appType, systemToken, userID, formUuid, pageNumber, pageSize, ref IDList, ref msg) == false)
@@ -1118,7 +1682,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 +1712,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 +1789,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"))
@@ -1316,6 +1920,7 @@
}
catch (Exception e)
{
+ LogService.Write("鏌ョ湅4"+e.Message);
continue;
}
}
@@ -1347,7 +1952,7 @@
string formUuid = "FORM-65AD77453E7F44EA847166C3AB5A1F04IPSS";
int pageNumber = 1;
int pageSize = 100;
-
+ LogService.Write("鏌ョ湅4");
//鑾峰彇瀹炰緥ID鍒楄〃
List<string> IDList = new List<string>();
if (getInstanceIDList_YiDa(appType, systemToken, userID, formUuid, pageNumber, pageSize, ref IDList, ref msg) == false)
@@ -1367,6 +1972,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 +1993,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 +2007,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 +2106,9 @@
return false;
}
+ string[] studyLevelList = new string[] {"","楂樹腑","涓笓","澶т笓","鏈","","","鍏朵粬","鍒濅腑","灏忓" };
+
+
for (int i = 0; i < response.Result.Count; i++)
{
List<string> fieldNameList = new List<string>();
@@ -1522,6 +2139,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)
@@ -1540,6 +2166,7 @@
}
catch (Exception e)
{
+ LogService.Write("鏌ョ湅5"+e.Message);
continue;
}
}
@@ -1571,14 +2198,16 @@
{
long offset = 0;
long size = 50;
-
+ LogService.Write("鏌ョ湅5");
+ LogService.Write("鏌ョ湅5.1");
//鑾峰彇鑺卞悕鍐岃亴鍛業D鍒楄〃
List<string> IDList = new List<string>();
if (getEmployeeIDList_DingDing(offset, size, ref IDList, ref msg) == false)
{
+ LogService.Write("鏌ョ湅5-1"+ msg);
return false;
}
-
+ LogService.Write("鏌ョ湅5-2");
//鑾峰彇璇︾粏淇℃伅骞堕檮鍔犲埌鍒楄〃lsmain涓�
List<DD_HuaMingCe> lsmain = new List<DD_HuaMingCe>();
if (getEmployeeDetailList_HuaMingCe__DingDing(IDList, ref lsmain, ref msg) == false)
@@ -1587,6 +2216,7 @@
}
try
{
+ LogService.Write("鏌ョ湅5-3");
oCN.BeginTran();
foreach (DD_HuaMingCe oItem in lsmain)
{
@@ -1611,11 +2241,570 @@
oCN.RunProc(sql_main);
}
+ LogService.Write("鏌ョ湅5-4");
oCN.Commit();
return true;
}
catch (Exception e)
{
+ msg = e.Message;
+ LogService.Write("鏌ョ湅5鎶ラ敊:" + e.Message);
+ oCN.RollBack();
+ return false;
+ }
+ }
+ #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;
+ }
+ string HStaus = "";
+
+ switch (getInstanceByIdResponse.Body.InstanceStatus)
+ {
+ case "COMPLETED":
+ HStaus = "缁翠慨缁撴潫";
+ break;
+ case "RUNNING":
+ HStaus = "缁翠慨杩涜涓�";
+ break;
+ case "TERMINATED":
+ HStaus = "缁翠慨缁堟";
+ break;
+ }
+
+ LogService.Write("鐘舵��:" + HStaus);
+
+ if (getInstanceByIdResponse.Body.InstanceStatus != "COMPLETED")
+ {
+ //妯″叿缂栫爜
+ if (keys.Contains("selectField_lq3idkvg"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["selectField_lq3idkvg"].ToString();
+ LogService.Write("妯″叿:" + HDate_Temp);
+ DataSet ds = oCN.RunProcReturn("select * from Gy_MouldFileMain with(nolock) where HMouldNo='" + HDate_Temp + "'", "Gy_MouldFileMain");
+ string HMouldID = "0";
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ LogService.Write("娴嬭瘯1:" + ds.Tables[0].Rows[0]["HCloseDate"].ToString());
+ string HUpdateDate = ds.Tables[0].Rows[0]["HCloseDate"].ToString() == "" ? "1900-01-01 00:00:00" : ds.Tables[0].Rows[0]["HCloseDate"].ToString();
+ string HMouldStaus = ds.Tables[0].Rows[0]["HMouldStatus"].ToString();
+ LogService.Write("妯″叿:" + HDate_Temp + ",鐘舵��:" + HMouldStaus + ",鏃堕棿:" + HUpdateDate);
+ HMouldID = ds.Tables[0].Rows[0]["HInterID"].ToString();
+ if (HMouldStaus != HStaus && DateTime.Parse(HUpdateDate) <= DateTime.Parse(oItem.HUpdateDate)) {
+ //淇敼妯″叿鐨勭姸鎬佸拰鏃堕棿
+ oCN.RunProc("update Gy_MouldFileMain set HMouldUseStatus='" + HStaus + "',HCloseDate='" + oItem.HUpdateDate + "' WHERE HInterID =" + HMouldID);
+ }
+ }
+ }
+
+ continue;
+ }
+
+ //妯″叿缂栫爜
+ if (keys.Contains("selectField_lq3idkvg"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["selectField_lq3idkvg"].ToString();
+ LogService.Write("妯″叿:" + HDate_Temp);
+ DataSet ds = oCN.RunProcReturn("select * from Gy_MouldFileMain with(nolock) where HMouldNo='" + HDate_Temp + "'", "Gy_MouldFileMain");
+ string HMouldID = "0";
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ LogService.Write("娴嬭瘯2:" + ds.Tables[0].Rows[0]["HCloseDate"].ToString());
+ HMouldID = ds.Tables[0].Rows[0]["HInterID"].ToString();
+ string HUpdateDate = ds.Tables[0].Rows[0]["HCloseDate"].ToString() == "" ? "1900-01-01 00:00:00" : ds.Tables[0].Rows[0]["HCloseDate"].ToString();
+
+ string HMouldStaus = ds.Tables[0].Rows[0]["HMouldStatus"].ToString();
+
+ LogService.Write("妯″叿:" + HDate_Temp+ ",鐘舵��:" + HMouldStaus + ",鏃堕棿:" + HUpdateDate);
+ if (HMouldStaus != HStaus && DateTime.Parse(HUpdateDate) <= DateTime.Parse(oItem.HUpdateDate))
+ {
+ //淇敼妯″叿鐨勭姸鎬佸拰鏃堕棿
+ oCN.RunProc("update Gy_MouldFileMain set HMouldUseStatus='" + HStaus + "',HCloseDate='" + oItem.HUpdateDate + "' WHERE HInterID =" + HMouldID);
+ }
+ }
+ oItem.HMouldID = long.Parse(HMouldID);
+ oItem.HRemark = HDate_Temp;
+ //LogService.Write("娴嬭瘯3:" + HMouldID);
+
+ //鏌ヨ淇濆吇璁″垝
+ 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+ " order by a.HMakeDate desc", "Sc_MouldMaintainPlanBillMain");
+ //LogService.Write("娴嬭瘯4:");
+ oItem.HPlanInterID = "";
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ oItem.HPlanInterID = ds.Tables[0].Rows[0]["HInterID"].ToString();
+ oItem.HPlanNo = ds.Tables[0].Rows[0]["HBillNo"].ToString();
+ }
+ }
+ LogService.Write("妯″叿缂栫爜:" + oItem.HMouldID);
+
+ //寮�鍗曟棩鏈�
+ 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");
+ }
+ LogService.Write("寮�鍗曟棩鏈�:" + oItem.HDate);
+
+ //妯″叿淇濆吇绾у埆
+ 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;
+ }
+ LogService.Write("妯″叿淇濆吇绾у埆:" + oItem.HMaintainLevID);
+
+ //淇ā寮�濮嬫椂闂�
+ 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"));
+ }
+ LogService.Write("淇ā寮�濮嬫椂闂�:" + oItem.HRepairBeginDate);
+
+ //淇ā缁撴潫鏃堕棿
+ 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"));
+ }
+ LogService.Write("淇ā缁撴潫鏃堕棿:" + oItem.HRepairEndDate);
+
+ //妯″叿鍗曟嵁鍙�
+ if (keys.Contains("serialNumberField_lqaak4ts"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["serialNumberField_lqaak4ts"].ToString();
+ oItem.HBillNo = HDate_Temp;
+ }
+ LogService.Write("妯″叿鍗曟嵁鍙�:" + oItem.HBillNo);
+
+ //瑕佹眰瀹屾垚鏃ユ湡
+ 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"));
+ }
+ LogService.Write("瑕佹眰瀹屾垚鏃ユ湡:" + oItem.HRequestComDate);
+
+ //缁翠慨鍙楃悊鏃ユ湡
+ 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"));
+ }
+ LogService.Write("缁翠慨鍙楃悊鏃ユ湡:" + oItem.HRepairAccepDate);
+
+ //鏈�杩戜繚鍏绘ā鏁�
+ if (keys.Contains("numberField_lq3idkvi"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["numberField_lq3idkvi"].ToString();
+ oItem.HRecentMainModule = double.Parse(HDate_Temp);
+ }
+ LogService.Write("鏈�杩戜繚鍏绘ā鏁�:" + oItem.HRecentMainModule);
+
+ //绱妯℃暟
+ if (keys.Contains("numberField_lq3idkvj"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["numberField_lq3idkvj"].ToString();
+ oItem.HCumulativeModule = double.Parse(HDate_Temp);
+ }
+ LogService.Write("绱妯℃暟:" + oItem.HCumulativeModule);
+
+ //鏈鐢熶骇妯℃暟
+ if (keys.Contains("textField_lq4vdvgh"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["textField_lq4vdvgh"].ToString();
+ oItem.HProductionModule = double.Parse(HDate_Temp);
+ }
+ LogService.Write("绱妯℃暟:" + oItem.HProductionModule);
+
+ //缁翠慨閮ㄩ棬
+ 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);
+ }
+ LogService.Write("缁翠慨閮ㄩ棬:" + oItem.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);
+ }
+ LogService.Write("缁翠慨浜�:" + oItem.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);
+ }
+ LogService.Write("缁翠慨鏃堕棿:" + oItem.HTimes);
+
+ //瀛愯〃 缁翠慨瑕佹眰 缁翠慨澶囨敞(闂鎻忚堪)
+ 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();
+ }
+ LogService.Write("缁翠慨瑕佹眰:" + oItemSub.HRepairExplanation);
+
+ //澶囨敞
+ if (keys_Sub.Contains("textField_lq3ixr9d"))
+ {
+ oItemSub.HRemark = dic[ij]["textField_lq3ixr9d"].ToString();
+ }
+ LogService.Write("澶囨敞:" + oItemSub.HRemark);
+
+ 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);
+ LogService.Write("鍏蜂綋瑕佹眰:" + oItemSub.HClaim);
+ }
+ }
+
+
+ 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);
+ 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;
+ LogService.Write("鏌ョ湅7");
+ //鑾峰彇妯″叿缁翠慨淇濆吇琛ㄧ殑瀹炰緥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" +
+ ",HMouldID,HBeginDate" +
+ ",HEndDate" +
+ ",HInnerBillNo,HExplanation,HMouldMaintainRuleInterID,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 + "'" +
+ ",'" + oItem.HMouldID + "','" + oItem.HRepairBeginDate + "'" +
+ ",'" + oItem.HRepairEndDate + "'" +
+ ",'" + oItem.HInstanceID + "','',"+ HMouldMaintainRuleInterID + ",'OK'" +
+ ",'"+ oItem.HRequestComDate + "'," + oItem.HRecentMainModule + "," + oItem.HCumulativeModule + "," + oItem.HProductionModule + "" +
+ "," + (oItem.HPlanInterID == "" ? "0" : 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;
@@ -1623,6 +2812,698 @@
}
#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;
+ }
+
+ string HStaus = "";
+
+ switch (getInstanceByIdResponse.Body.InstanceStatus)
+ {
+ case "COMPLETED":
+ HStaus = "缁翠慨缁撴潫";
+ break;
+ case "RUNNING":
+ HStaus = "缁翠慨杩涜涓�";
+ break;
+ case "TERMINATED":
+ HStaus = "缁翠慨缁堟";
+ break;
+ }
+ LogService.Write("鐘舵��:" + HStaus);
+ if (getInstanceByIdResponse.Body.InstanceStatus != "COMPLETED")
+ {
+ //璁惧缂栫爜
+ 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;
+
+ string HUpdateDate = ds.Tables[0].Rows[0]["HCloseDate"].ToString()==""?"1900-01-01 00:00:00": ds.Tables[0].Rows[0]["HCloseDate"].ToString();
+ string HMouldStaus = ds.Tables[0].Rows[0]["HStatus"].ToString();
+ LogService.Write("璁惧:" + HDate_Temp + ",鐘舵��:" + HMouldStaus + ",鏃堕棿:" + HUpdateDate);
+ if (HMouldStaus != HStaus && DateTime.Parse(HUpdateDate) <= DateTime.Parse(oItem.HUpdateDate))
+ {
+ //淇敼璁惧鐨勭姸鎬佸拰鏃堕棿
+ oCN.RunProc("update Gy_EquipFileBillMain set HStatus='" + HStaus + "',HCloseDate='" + oItem.HUpdateDate + "' WHERE HInterID =" + HEquipID);
+ }
+ }
+ }
+ 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");
+ LogService.Write("璁惧鏃�:" + HDate_Temp);
+ 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;
+ string HUpdateDate = ds.Tables[0].Rows[0]["HCloseDate"].ToString() == "" ? "1900-01-01 00:00:00" : ds.Tables[0].Rows[0]["HCloseDate"].ToString();
+ string HMouldStaus = ds.Tables[0].Rows[0]["HStatus"].ToString();
+ LogService.Write("璁惧:" + HDate_Temp + ",鐘舵��:" + HMouldStaus + ",鏃堕棿:" + HUpdateDate);
+ if (HMouldStaus != HStaus && DateTime.Parse(HUpdateDate) <= DateTime.Parse(oItem.HUpdateDate))
+ {
+ //淇敼璁惧鐨勭姸鎬佸拰鏃堕棿
+ oCN.RunProc("update Gy_EquipFileBillMain set HStatus='" + HStaus + "',HCloseDate='" + oItem.HUpdateDate + "' WHERE HInterID =" + HEquipID);
+ }
+ }
+ else
+ {
+ continue;
+ }
+ }
+ LogService.Write("璁惧:" + oItem.HEquipID);
+
+ //缁翠慨閮ㄩ棬
+ 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;
+ }
+
+ }
+ LogService.Write("缁翠慨閮ㄩ棬:" + oItem.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 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;
+ }
+
+ }
+ LogService.Write("缁翠慨浜�:" + oItem.HEmpID);
+
+ //缁翠慨鍐呭
+ if (keys.Contains("textField_l2r9bvwk"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["textField_l2r9bvwk"].ToString();
+
+ oItem.HRepairContent = HDate_Temp;
+ }
+ LogService.Write("缁翠慨鍐呭:" + oItem.HRepairContent);
+
+ //鎶ヤ慨绫诲埆
+ 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];
+ }
+ LogService.Write("鎶ヤ慨绫诲埆:" + oItem.HRepairCategory);
+ //绱ф�ョ▼搴�
+ if (keys.Contains("radioField_kzgkw10c"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["radioField_kzgkw10c"].ToString();
+
+ oItem.HUrgenLevel = HDate_Temp;
+ }
+ LogService.Write("绱ф�ョ▼搴�:" + oItem.HUrgenLevel);
+
+ //鎶ヤ慨浜�
+ 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];
+ }
+ LogService.Write("鎶ヤ慨浜�:" + oItem.HRepairer);
+
+ //鏄惁鏈変骇鑳藉奖鍝�
+ if (keys.Contains("textField_lyjddw0r"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["textField_lyjddw0r"].ToString();
+
+ oItem.HIsCapacityImpact = HDate_Temp;
+ }
+ LogService.Write("鏄惁鏈変骇鑳藉奖鍝�:" + oItem.HIsCapacityImpact);
+
+ //缁翠慨鏃堕棿
+ 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()));
+ }
+ LogService.Write("缁翠慨鏃堕棿:" + oItem.HTimes);
+
+
+ //瀛愯〃 缁翠慨瑕佹眰 缁翠慨澶囨敞(闂鎻忚堪)
+
+ 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;
+ }
+ LogService.Write("缁翠慨瑕佹眰:" + oItem.HExplanation);
+
+ //澶囨敞
+ if (keys.Contains("textField_l2r95oo0"))
+ {
+ string HDate_Temp = response.Body.Result[i].FormData["textField_l2r95oo0"].ToString();
+
+ sub.HRemark = HDate_Temp;
+ }
+ LogService.Write("澶囨敞:" + oItem.HRemark);
+
+ 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;
+ LogService.Write("鏌ョ湅6");
+ //鑾峰彇璁惧缁翠慨淇濆吇琛ㄧ殑瀹炰緥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
+
+ #region 鏁版嵁鍚屾-寮傚父宸ユ椂鍗昈A閲岃幏鍙�
+
+ #region 绫诲瀷杞崲鎻愬彇response涓殑value瀵硅薄
+ public class StatValue
+ {
+ public string Id { get; set; }
+ public string Label { get; set; }
+ public string Upper { get; set; }
+ public string Num { get; set; }
+ }
+
+ public class ExtValue
+ {
+ public List<StatValue> StatValue { get; set; }
+ public string ComponentName { get; set; }
+ }
+ public class RowValue
+ {
+ public string Label { get; set; }
+ public object Value { get; set; }
+ public string Key { get; set; }
+ // 娉ㄦ剰锛氳繖閲屼笉瀹氫箟extendValue灞炴�э紝鍥犱负鎴戜滑涓嶉渶瑕佸畠
+ // public SomeType ExtendValue { get; set; } // 濡傛灉闇�瑕侊紝鍙互娉ㄩ噴鎺夋垨鍒犻櫎杩欒
+ }
+ public class Row
+ {
+ public List<RowValue> RowValue { get; set; }
+ public string RowNumber { get; set; }
+ // 娉ㄦ剰锛氳繖閲屽亣璁句綘涓嶉渶瑕乧omponentName锛屽洜涓篔SON绀轰緥涓病鏈夌洿鎺ュ寘鍚畠
+ // 浣嗗鏋滀綘鐨勫疄闄匤SON鎴栭渶姹備腑鍖呭惈锛屼綘搴旇娣诲姞杩欎釜灞炴��
+ // public string ComponentName { get; set; }
+ }
+ #endregion
+
+
+ #region OA寮傚父宸ユ椂鐢宠鍗� 瀹炰緥ID鍒楄〃瀵瑰簲鐨勫疄渚嬭鎯�
+ public bool getInstanceDetailList___ErrWorkTimesRequest_OA(List<string> processinstanceIDList, DateTime startTime, DateTime endTime, ref List<Pay_ErrWorkTimesRequestBill> lsmain,ref string msg)
+ {
+ try
+ {
+ List<GetProcessInstanceResponse> getProcessInstanceResponses = new List<GetProcessInstanceResponse>();
+ //鑾峰彇閽夐拤response
+ if (getInstanceDetailListByInstanceIDList_OA(processinstanceIDList,ref getProcessInstanceResponses,ref msg)==false)
+ {
+ return false;
+ }
+ foreach(GetProcessInstanceResponse getProcessInstanceResponse in getProcessInstanceResponses)
+ {
+ Pay_ErrWorkTimesRequestBill oItem = new Pay_ErrWorkTimesRequestBill();
+ //涓昏〃
+ oItem.HDate = getProcessInstanceResponse.Body.Result.FormComponentValues[1].Value;//鍗曟嵁鏃ユ湡璁℃椂鏃堕棿
+ DateTime dateTime1 = DateTime.ParseExact(oItem.HDate + " 00:00:00", "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture);
+ if (!(DateTime.Compare(dateTime1, startTime)>=0&& DateTime.Compare(dateTime1, endTime) <= 0))//鎺у埗鏃堕棿
+ {
+ continue;
+ }
+ string result = getProcessInstanceResponse.Body.Result.Result.ToString();
+ if (result != "agree")
+ {
+ continue;
+ }
+ string[] deptNameAndGroupName = getProcessInstanceResponse.Body.Result.OriginatorDeptName.Split('-');//鑾峰彇閮ㄩ棬鎷兼帴瀛楃涓叉暟缁�
+ oItem.HDeptName = deptNameAndGroupName[1];
+ oItem.HGroupName = deptNameAndGroupName[deptNameAndGroupName.Length-1];
+ //涓荤-璐熻矗浜�
+ string HManagerValue = getProcessInstanceResponse.Body.Result.FormComponentValues[9].Value;//鑾峰彇鐨勫悕瀛楀惈鍚庣紑鑻辨枃
+ string pattern = @"[\u4e00-\u9fff]+"; // 涓枃瀛楃鐨刄nicode鑼冨洿
+
+ MatchCollection matches = Regex.Matches(HManagerValue, pattern);
+
+ // 鍒涘缓涓�涓猄tringBuilder鏉ユ嫾鎺ユ墍鏈夊尮閰嶇殑涓枃瀛楃
+ System.Text.StringBuilder chineseChars = new System.Text.StringBuilder();
+ foreach (Match match in matches)
+ {
+ chineseChars.Append(match.Value);
+ }
+ string HManagerName = chineseChars.ToString();
+ DataSet ds = oCN.RunProcReturn("select * from Gy_Employee with(nolock) where HName='" + HManagerName + "'", "Gy_Employee");
+ string HMangerID = "0";
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ HMangerID = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ oItem.HMangerID = int.Parse(HMangerID);
+ //澶勭悊閮ㄩ棬鍜岀彮缁勫悕绉癷d
+ ds = oCN.RunProcReturn("select * from h_v_GroupList with(nolock) where 鐝粍鍚嶇О='" + oItem.HGroupName + "'", "h_v_GroupList");
+ string HDeptID = "0";
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ HDeptID = ds.Tables[0].Rows[0]["HDeptID"].ToString();
+ }
+ oItem.HDeptID = int.Parse(HDeptID);
+ ds = oCN.RunProcReturn("select * from Gy_Group with(nolock) where HName='" + oItem.HGroupName + "'", "Gy_Group");
+ string HGroupID = "0";
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ HGroupID = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ oItem.HGroupID = int.Parse(HGroupID);
+
+ //鍙嶅簭鍒楀寲鏄庣粏鍐呭
+ string tableFieldValue = getProcessInstanceResponse.Body.Result.FormComponentValues[11].Value;
+ List<Row> rows = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Row>>(tableFieldValue);
+ ExtValue extValue = Newtonsoft.Json.JsonConvert.DeserializeObject<ExtValue>(getProcessInstanceResponse.Body.Result.FormComponentValues[11].ExtValue);
+ oItem.HBatchNo = rows[0].RowValue[1].Value.ToString();//鎵规鍙�-璁㈠崟鍙风爜
+ //浠诲姟鎻忚堪-浠诲姟绫诲瀷+宸ヤ綔鍐呭
+ oItem.HExplanation = getProcessInstanceResponse.Body.Result.FormComponentValues[2].Value + "-" + rows[0].RowValue[0].Value;
+ oItem.HSumRequestTimes = double.Parse(extValue.StatValue[1].Num);//鎬绘椂闀�
+ oItem.HPlanQty = 0;//璁″垝鏁伴噺
+ oItem.HRemark = "閽夐拤瀵煎叆" + getProcessInstanceResponse.Body.Result.Title;//澶囨敞
+ //寰幆閬嶅巻鑾峰彇鑱屽憳鍚嶇Оid锛屽伐鏃�
+ for (int i = 0; i < rows.Count; i++)
+ {
+ if (rows[i].RowValue.Count<10)
+ {
+ continue;
+ }
+ string[] nameArray = rows[i].RowValue[4].Value.ToString().Split(',');//鑾峰彇姣忎釜浜虹殑浜哄悕
+ oItem.HPlanQty += double.Parse(rows[i].RowValue[2].Value.ToString());//璁″垝鏁伴噺
+ for (int j = 0; j < int.Parse(rows[i].RowValue[5].Value.ToString()); j++)
+ {
+ if (nameArray.Length < j + 1)//闃叉鍑虹幇浜虹鑱屼簡璁℃椂鍗曠敵璇峰畬浜嗗鑷存妧鏈汉鍛樹笌璁℃椂浜烘暟涓嶄竴鑷寸殑闂
+ {
+ continue;
+ }
+ Pay_ErrWorkTimesRequestBillSub pay_ErrWorkTimesRequestBillSub = new Pay_ErrWorkTimesRequestBillSub();
+ ds = oCN.RunProcReturn("select * from Gy_Employee with(nolock) where HName='" + nameArray[j] + "'", "Gy_Employee");
+ string HEmpID = "0";
+ //璁剧疆瀛愯〃鑱屽憳id鍚嶇О
+ if (ds.Tables[0].Rows.Count > 0)
+ {
+ HEmpID = ds.Tables[0].Rows[0]["HItemID"].ToString();
+ }
+ pay_ErrWorkTimesRequestBillSub.HEmpName = nameArray[j];
+ pay_ErrWorkTimesRequestBillSub.HEmpID = int.Parse(HEmpID);
+ pay_ErrWorkTimesRequestBillSub.HRelTimes = double.Parse(rows[i].RowValue[6].Value.ToString());
+ pay_ErrWorkTimesRequestBillSub.HTimes = double.Parse(rows[i].RowValue[6].Value.ToString());
+ pay_ErrWorkTimesRequestBillSub.HRelPay = double.Parse(rows[i].RowValue[10].Value.ToString());
+ pay_ErrWorkTimesRequestBillSub.HPayMoney = pay_ErrWorkTimesRequestBillSub.HRelPay / pay_ErrWorkTimesRequestBillSub.HTimes;
+ pay_ErrWorkTimesRequestBillSub.HRemark = "閽夐拤瀵煎叆";
+ oItem.Pay_ErrWorkTimesRequestBillSub.Add(pay_ErrWorkTimesRequestBillSub);
+
+ }
+ }
+ lsmain.Add(oItem);
+ }
+ return true;
+ }catch(Exception e)
+ {
+ msg = e.Message;
+ return false;
+ }
+
+ }
+ #endregion
+
+ #region 鏁版嵁鍚屾
+ public bool getData_ErrWorkTimesRequest(DateTime startTime, DateTime endTime,ref string msg)
+ {
+ string processCode = "PROC-21371550-FEF1-4EDD-A827-639746E22E43";
+ long nextToken = 1;
+ int maxResult = 20;//鏈�澶�20
+ List<string> statues = new List<string>{"COMPLETED"};
+ this.AppKey = "ding7miekiaqn4rc2ert";
+ this.AppSecret = "81qMrC5SvkgjT9t2A3wUyEEENzyl9jJLeXOpjv2SNULc_HSlFZF4NE21YFCXik4K";
+ getAccessToken();//璁剧疆accessToken
+ //鑾峰彇宸ユ椂鐢宠鐨勫疄渚婭D鍒楄〃
+ List<string> IDList = new List<string>();
+ if (getInstanceIDList_OA(processCode,startTime,endTime,nextToken,maxResult,statues,ref IDList, ref msg) == false)
+ {
+ return false;
+ }
+ //鑾峰彇璇︾粏淇℃伅骞堕檮鍔犲埌鍒楄〃lsmain涓�
+ List<Pay_ErrWorkTimesRequestBill> lsmain = new List<Pay_ErrWorkTimesRequestBill>();
+ if (getInstanceDetailList___ErrWorkTimesRequest_OA(IDList,startTime,endTime, ref lsmain, ref msg) == false)
+ {
+ return false;
+ }
+ try
+ {
+ oCN.BeginTran();
+ //鍒犻櫎鏃堕棿鑼冨洿鍐呯殑瀵煎叆鍗曟嵁
+ DataSet dataSet = oCN.RunProcReturn(@"select HInterID from Pay_ErrWorkTimesRequestBillMain a with(nolock) where a.HRemark like '%閽夐拤瀵煎叆%' and a.HIsImport = 1 and HDate >= '" + startTime + "' and HDate<='" + endTime + "'", "Pay_ErrWorkTimesRequestBillMain");
+ if(dataSet != null && dataSet.Tables[0].Rows.Count > 0)
+ {
+ foreach (DataRow row in dataSet.Tables[0].Rows)
+ {
+ int HInterID = row.Field<int>("HInterID");
+ oCN.RunProc(@"Delete From Pay_ErrWorkTimesRequestBillMain where HInterID = " + HInterID);
+ oCN.RunProc(@"Delete From Pay_ErrWorkTimesRequestBillSub where HInterID = " + HInterID);
+ }
+ }
+ //鎻掑叆鏁版嵁
+ foreach(Pay_ErrWorkTimesRequestBill oItem in lsmain)
+ {
+ if (oItem.Pay_ErrWorkTimesRequestBillSub.Count != 0)
+ {
+ string HBillType = "2231";
+ long HInterID = DBUtility.ClsPub.CreateBillID(HBillType, ref DBUtility.ClsPub.sExeReturnInfo);
+ string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(HBillType, ref DBUtility.ClsPub.sExeReturnInfo, true);
+ int HYear = int.Parse(oItem.HDate.Split('-')[0]);
+ int HPeriod = int.Parse(oItem.HDate.Split('-')[1]);
+ //涓昏〃
+ string sql = "insert into Pay_ErrWorkTimesRequestBillMain" +
+ "(HYear,HPeriod,HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate,HInnerBillNo,HDeptID,HGroupID,HMangerID,HICMOInterID,HICMOBillNo,HExplanation,HSumRequestTimes,HMaterID,HUnitID,HPlanQty,HBatchNo,HRemark,HMaker,HMakeDate,HChecker,HCheckDate,HIsImport) " +
+ "values(" +
+ "" + HYear +
+ "," + HPeriod +
+ ",'" + HBillType +
+ "','" + " " +
+ "'," + 2 +
+ "," + HInterID +
+ ",'" + HBillNo +
+ "','" + oItem.HDate +
+ "','" + " " +
+ "'," + oItem.HDeptID +
+ "," + oItem.HGroupID +
+ "," + oItem.HMangerID +
+ "," + "0" +
+ ",'" + " " +
+ "','" + oItem.HExplanation +
+ "'," + oItem.HSumRequestTimes +
+ "," + 0 +
+ "," + 0 +
+ "," + oItem.HPlanQty +
+ ",'" + oItem.HBatchNo +
+ "','" + oItem.HRemark +
+ "','" + "System" +
+ "'," + "GETDATE()" +
+ ",'" + "System" +
+ "'," + "GETDATE()" +
+ "," + "1" +
+ ")";
+ //涓昏〃
+ LogService.Write(sql);
+ oCN.RunProc(sql);
+ int i = 1;
+ foreach (Pay_ErrWorkTimesRequestBillSub oItem_Detail in oItem.Pay_ErrWorkTimesRequestBillSub)
+ {
+ sql = "insert into Pay_ErrWorkTimesRequestBillSub" +
+ "(HInterID,HEntryID,HEmpID,HWorkTypeID,HPayMoney,HBTimes,HETimes,HTimes,HRelTimes,HRelPay,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo" +
+ ",HSourceBillType,HRelationQty,HRelationMoney) " +
+ "values(" +
+ "" + HInterID +
+ "," + i +
+ "," + oItem_Detail.HEmpID +
+ "," + 0 +
+ "," + oItem_Detail.HPayMoney +
+ ",'" + "" +
+ "','" + "" +
+ "'," + oItem_Detail.HTimes +
+ "," + oItem_Detail.HRelTimes +
+ "," + oItem_Detail.HRelPay +
+ ",'" + oItem_Detail.HRemark +
+ "'," + 0 +
+ "," + 0 +
+ ",'" + " " +
+ "','" + " " +
+ "'," + 0 +
+ "," + 0 +
+ ")";
+ LogService.Write(sql);
+ oCN.RunProc(sql);
+ i += 1;
+ }
+ }
+ }
+ oCN.Commit();
+ return true;
+ }
+ catch (Exception e)
+ {
+ LogService.Write(e.Message);
+ msg = e.Message;
+ oCN.RollBack();
+ return false;
+ }
+ }
+ #endregion
+
+ #endregion
+
#endregion
@@ -1698,5 +3579,39 @@
}
#endregion
+ #region 閽夐拤鏁版嵁鍚屾OA
+ [Route("DD_DataSynchronization/DataSynchronization_DingDing_OA")]
+ [HttpGet]
+ public object DataSynchronization_DingDing_OA(DateTime startTime, DateTime endTime, string user)
+ {
+ string msg = "";
+ try
+ {
+ //if (getData_ErrWorkTimesRequest(startTime,endTime,ref msg) == false)
+ //{
+ // objJsonResult.code = "0";
+ // objJsonResult.count = 0;
+ // objJsonResult.Message = "Exception锛�" + msg;
+ // objJsonResult.data = null;
+ // return objJsonResult;
+ //}
+
+ objJsonResult.code = "1";
+ objJsonResult.count = 1;
+ objJsonResult.Message = "Sucess锛�";
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ catch (Exception e)
+ {
+ objJsonResult.code = "0";
+ objJsonResult.count = 0;
+ objJsonResult.Message = "Exception锛�" + e.ToString();
+ objJsonResult.data = null;
+ return objJsonResult;
+ }
+ }
+ #endregion
+
}
}
\ No newline at end of file
--
Gitblit v1.9.1