| New file |
| | |
| | | using Model; |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using Pub_Class; |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Data; |
| | | using System.Data.SqlClient; |
| | | using System.Web.Http; |
| | | using WebAPI.Models; |
| | | using Tea; |
| | | using AlibabaCloud.SDK.Dingtalkyida_1_0.Models; |
| | | using AlibabaCloud.SDK.Dingtalkoauth2_1_0.Models; |
| | | using DingTalk.Api.Request; |
| | | using DingTalk.Api; |
| | | using DingTalk.Api.Response; |
| | | using System.Globalization; |
| | | using System.Linq; |
| | | using AlibabaCloud.SDK.Dingtalkworkflow_1_0.Models; |
| | | using System.Text.RegularExpressions; |
| | | using System.Net.Http; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Net.Http; |
| | | using System.Threading.Tasks; |
| | | using System.Text; |
| | | using System.Security.Cryptography; |
| | | using System.Net.Http.Headers; |
| | | using System.Web; |
| | | |
| | | namespace WebAPI.Controllers |
| | | { |
| | | #region 模åç±» |
| | | #region æå¡å°åè¿åç±» |
| | | public class ServerAddressResponse |
| | | { |
| | | public string res; |
| | | public string msg; |
| | | public ServerAddressResponse_Data data; |
| | | } |
| | | public class ServerAddressResponse_Data |
| | | { |
| | | public string gofServerAdd; |
| | | } |
| | | #endregion |
| | | |
| | | #region éªè¯ç è¿åç±» |
| | | public class VerificationCodeResponse |
| | | { |
| | | public string res; |
| | | public string msg; |
| | | public VerificationCodeResponse_Data data; |
| | | } |
| | | public class VerificationCodeResponse_Data |
| | | { |
| | | public string VerificationCode; |
| | | } |
| | | #endregion |
| | | |
| | | #region Tokenè¿åç±» |
| | | public class TokenResponse |
| | | { |
| | | public string res; |
| | | public string msg; |
| | | public TokenResponse_Data data; |
| | | } |
| | | public class TokenResponse_Data |
| | | { |
| | | public string key; |
| | | } |
| | | #endregion |
| | | |
| | | #region äº§åæ¡£æ¡ |
| | | #region ç©æå表 |
| | | public class MaterListResponse |
| | | { |
| | | public string code; |
| | | public string msg; |
| | | public MaterListResponse_Data data; |
| | | } |
| | | public class MaterListResponse_Data |
| | | { |
| | | public MaterListResponse_Data_Product[] product; |
| | | public string updateTime; |
| | | public string totalNumber; |
| | | public string totalPage; |
| | | public string pageIndex; |
| | | } |
| | | public class MaterListResponse_Data_Product |
| | | { |
| | | public string productName; //产ååç§° |
| | | public string productId; //产åID |
| | | public string partnum; //产åç¼å· |
| | | public string cycleTime; //循ç¯å¨æ |
| | | public string spec; //è§æ ¼åå· |
| | | public string weight; //产åéé |
| | | public string headWeight; //æå¤´éé |
| | | public string colorName; //é¢è²åç§° |
| | | public string comments; // 夿³¨ |
| | | public string lastUpdateTime; //ä¿®æ¹æ¥æ |
| | | } |
| | | #endregion |
| | | |
| | | #region ç©æè¯¦ç»ä¿¡æ¯ |
| | | public class MaterDetailResponse |
| | | { |
| | | public string code; |
| | | public string msg; |
| | | public MaterDetailResponse_Data data; |
| | | } |
| | | public class MaterDetailResponse_Data |
| | | { |
| | | public MaterDetailResponse_Data_Detail details; |
| | | public string updateTime; //æ´æ°æ¶é´ |
| | | public string totalNumber; |
| | | public string totalPage; |
| | | public string pageIndex; |
| | | } |
| | | public class MaterDetailResponse_Data_Detail |
| | | { |
| | | public string productName; //产ååç§° |
| | | public string partNum; //产åç¼å· |
| | | public string weight; //产åéé |
| | | public string headWeight; //æå¤´éé |
| | | public string cycleTime; //循ç¯å¨æ |
| | | public string comments; // 夿³¨ |
| | | public string materialNo; //ææç¼å· |
| | | public string cpNo; //è²ç²ç¼å· |
| | | public string cpName; //è²ç²åç§° |
| | | public string color; //é¢è²ID |
| | | public string colorName; //é¢è²åç§° |
| | | public string unit; //åä½ |
| | | public string partId; //产åID |
| | | public string productType; //产åç±»å |
| | | public string processWay; //ç产è¿åº¦ç»è®¡æ¹å¼:0:æ°é 1:æ¶é¿ |
| | | public string spec; //è§æ ¼åå· |
| | | public string option1; //èªå®ä¹å段1ï¼ç¨äºè®°å½éè¶äº ä¿®æ¹æ¶é´ |
| | | } |
| | | #endregion |
| | | |
| | | #region æ°å¢äº§åä¿¡æ¯ |
| | | public class MaterialResponse |
| | | { |
| | | public string code; |
| | | public string msg; |
| | | public MaterialResponse_Data data; |
| | | public string productId; |
| | | } |
| | | public class MaterialResponse_Data |
| | | { |
| | | public string partId; //产åID |
| | | public string productName; //产ååç§° |
| | | public string partNum; //产åç¼ç |
| | | public string sepc; //è§æ ¼åå· |
| | | public string weight; //产åéé |
| | | public string comments; //夿³¨ |
| | | public string cycleTime; //卿 |
| | | public string headWeight; //æå¤´éé |
| | | public string createDate; //åå»ºæ¥æ |
| | | public string color; //é¢è²ID |
| | | public string colorName; //é¢è²åç§° |
| | | public string pieceWage; //åä»· |
| | | } |
| | | |
| | | |
| | | public class Material |
| | | { |
| | | public string key; //å¯é¥ |
| | | public string productName; //产ååç§° |
| | | public string partNum; //产åç¼ç |
| | | public string sepc; //è§æ ¼åå· |
| | | public string weight; //产åéé |
| | | public string headWeight; //æå¤´éé |
| | | public string cycleTime; //卿 |
| | | public string flightsPartnum; |
| | | public string comments; //夿³¨ |
| | | public string colorName; //é¢è²åç§° |
| | | public string pieceWage; //åä»· |
| | | public string unit; //åä½ |
| | | public string systemType; //ç³»ç»ç±»å(IMM:æ³¨å¡ ,CNC:ç²¾å å·¥),ä¸ä¼ é»è®¤æ³¨å¡ |
| | | public string tdDocNo; //å·¥èºè·¯çº¿ç¼å·,å¤ä¸ªä½¿ç¨,è¿è¡åå¼(CNC) |
| | | public string progressWay; //ç产è¿åº¦ç»è®¡æ¹å¼:0:æ°é 1:æ¶é¿(CNC) |
| | | public string groupId; //åç»id |
| | | |
| | | public string option1; //èªå®ä¹å段1ï¼ç¨äºè®°å½éè¶äº ä¿®æ¹æ¶é´ |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ç¼è¾äº§åä¿¡æ¯ |
| | | public class MaterialEditResponse |
| | | { |
| | | public string code; |
| | | public string msg; |
| | | public MaterialEditReponse_Data data; |
| | | public string productId; |
| | | } |
| | | public class MaterialEditReponse_Data |
| | | { |
| | | public string partId; //产åID |
| | | public string partNum; //产åç¼ç |
| | | public string productName; //产ååç§° |
| | | public string sepc; //è§æ ¼åå· |
| | | public string weight; //产åéé |
| | | public string comments; //夿³¨ |
| | | public string cycleTime; //卿 |
| | | public string headWeight; //æå¤´éé |
| | | public string lastUpdateTime; //æåæ´æ°æ¶é´ |
| | | public string productType; //产åç±»å |
| | | public string createDate; //åå»ºæ¥æ |
| | | public string colorName; //é¢è²åç§° |
| | | public string unit; //åä½ |
| | | public string systemType; //ç³»ç»ç±»å |
| | | } |
| | | |
| | | |
| | | public class MaterialEdit |
| | | { |
| | | public string key; //å¯é¥ |
| | | public string productId; //产åID |
| | | public string productName; //产ååç§° |
| | | public string partNum; //产åç¼ç |
| | | public string sepc; //è§æ ¼åå· |
| | | public string weight; //产åéé |
| | | public string headWeight; //æå¤´éé |
| | | public string cycleTime; //卿 |
| | | public string flightsPartnum; |
| | | public string comments; //夿³¨ |
| | | public string colorName; //é¢è²åç§° |
| | | public string pieceWage; //åä»· |
| | | public string unit; //åä½ |
| | | public string systemType; //ç³»ç»ç±»å(IMM:æ³¨å¡ ,CNC:ç²¾å å·¥),ä¸ä¼ é»è®¤æ³¨å¡ |
| | | public string tdDocNo; //å·¥èºè·¯çº¿ç¼å·,å¤ä¸ªä½¿ç¨,è¿è¡åå¼(CNC) |
| | | public string progressWay; //ç产è¿åº¦ç»è®¡æ¹å¼:0:æ°é 1:æ¶é¿(CNC) |
| | | public string groupId; //åç»id |
| | | |
| | | public string option1; //èªå®ä¹å段1ï¼ç¨äºè®°å½éè¶äº ä¿®æ¹æ¶é´ |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region ç产订å |
| | | #region ç产订åå表 |
| | | public class ICMOListResponse |
| | | { |
| | | public string code; |
| | | public string msg; |
| | | public ICMOListResponse_Data data; |
| | | } |
| | | public class ICMOListResponse_Data |
| | | { |
| | | public ICMOListResponse_Data_Plan[] plan; |
| | | public string pageIndex; |
| | | public string pageCount; |
| | | } |
| | | public class ICMOListResponse_Data_Plan |
| | | { |
| | | public string planId; //计ååID |
| | | public string leave_qty; //å©ä½æ°é |
| | | public string productName; //产ååç§° |
| | | public string planNumber; //计ååå· |
| | | public string planQty; //è®¡åæ°é |
| | | public string taskNo; //ä»»å¡åå· |
| | | public string materialId; //ææç¼å· |
| | | public string materialName; //ææåç§° |
| | | public string cpId; //è²ç²ç¼å· |
| | | public string cpName; //è²ç²åç§° |
| | | public string partId; //产åid |
| | | public string partNum; //产åç¼å· |
| | | public string qty; //æ°é |
| | | public string allotQty; //åé
æ°é |
| | | public string planStartDate; //计åå¼å§æ¶é´ |
| | | public string planFinishDate; //计å宿æ¶é´ |
| | | public string comments; //夿³¨ |
| | | public string createDate; //åå»ºæ¥æ |
| | | public string spec; //è§æ ¼åå· |
| | | public string urgent; //æ¯å¦ç´§æ¥ |
| | | |
| | | public string partnum; //产åç¼å· |
| | | public string cycleTime; //循ç¯å¨æ |
| | | } |
| | | #endregion |
| | | |
| | | #region ç产订å详ç»ä¿¡æ¯ |
| | | public class ICMODetailResponse |
| | | { |
| | | public string code; |
| | | public string msg; |
| | | public ICMODetailResponse_Data[] data; |
| | | } |
| | | public class ICMODetailResponse_Data |
| | | { |
| | | public string planProductName; //产ååç§° |
| | | public string planNumber; //计ååå· |
| | | public string planQty; //è®¡åæ°é |
| | | public string planStartTime; //计åå¼å§æ¶é´ |
| | | public string planEndTime; //计å宿æ¶é´ |
| | | public string allottedQty; //åé
æ°é |
| | | public string planProductId; //产åid |
| | | public string finishPercentage; //宿è¿åº¦ |
| | | public string colorName; //é¢è² |
| | | public string color; //é¢è²id |
| | | public string levQty; //å©ä½æ°é |
| | | public string planId; //计ååid |
| | | public string createUserId; //å建人 |
| | | public string createUserName; //å建人åç§° |
| | | public string customerName; //客æ·åç§° |
| | | public string comments; //夿³¨ |
| | | public string productName; //产ååç§° |
| | | public string partNum; //产åç¼å·(partNumæè
productIdäºéä¸) |
| | | public string urgent; //æ¯å¦ç´§æ¥ 1:ç´§æ¥ |
| | | public string productRemark; //产å夿³¨ |
| | | public string option1; //èªå®ä¹å段1ï¼ç¨äºè®°å½éè¶äº ä¿®æ¹æ¶é´ |
| | | } |
| | | #endregion |
| | | |
| | | #region æ°å¢ç产订åä¿¡æ¯ |
| | | public class ICMOResponse |
| | | { |
| | | public string code; |
| | | public string msg; |
| | | public ICMOResponse_Data data; |
| | | } |
| | | public class ICMOResponse_Data |
| | | { |
| | | public string planId; //计ååid |
| | | public string companyId; //å
¬å¸çid |
| | | public string planNo; //计ååå· |
| | | public string partId; //产åID |
| | | public string qty; //è®¡åæ°é |
| | | public string customerName; //客æ·åç§° |
| | | public string planStartTime; //计åå¼å§æ¶é´ |
| | | public string planFinishDate; //计å宿æ¶é´ |
| | | public string allotQty; //åé
æ°é |
| | | public string finishQty; //宿æ°é |
| | | public string comments; //夿³¨ |
| | | public string createDate; //åå»ºæ¥æ |
| | | public string createUserId; //å建人 |
| | | public string createUserName; //å建人åç§° |
| | | public string colorName; //é¢è² |
| | | public string color; //é¢è²id |
| | | public string productName; //产ååç§° |
| | | public string partNum; //产åç¼å· |
| | | public string status; //ç¶æ |
| | | public string urgent; //æ¯å¦ç´§æ¥ 1:ç´§æ¥ |
| | | public string option1; //èªå®ä¹å段1ï¼ç¨äºè®°å½éè¶äº ä¿®æ¹æ¶é´ |
| | | } |
| | | public class ICMO |
| | | { |
| | | public string key; //å¯é¥ |
| | | public string planNumber; //计ååå· |
| | | public string planQty; //è®¡åæ°é |
| | | public string partNum; //产åç¼å· |
| | | public string planStartDate; //计åå¼å§æ¶é´ |
| | | public string planEndDate; //计åç»ææ¶é´ |
| | | public string comments; //夿³¨ |
| | | public string customerName; //客æ·åç§° |
| | | public string colorName; //é¢è²åç§° |
| | | public string spec; //åå·è§æ ¼ |
| | | public string cpNo; //è²ç²ç¼å· |
| | | public string cpName; //è²ç²åç§° |
| | | public string materialNo; //ææç¼å· |
| | | public string materialName; //ææåç§° |
| | | public string orderNumber; //订åç¼å· |
| | | |
| | | public string option1; //èªå®ä¹å段1ï¼ç¨äºè®°å½éè¶äº ä¿®æ¹æ¶é´ |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region ç¼è¾ç产订åä¿¡æ¯ |
| | | public class ICMOEditResponse |
| | | { |
| | | public string code; |
| | | public string msg; |
| | | public ICMOEditReponse_Data data; |
| | | } |
| | | public class ICMOEditReponse_Data |
| | | { |
| | | public string planId; //计ååid |
| | | //public string companyId; //å
¬å¸çid |
| | | public string planNo; //计ååå· |
| | | public string partId; //产åID |
| | | public string qty; //è®¡åæ°é |
| | | public string customerName; //客æ·åç§° |
| | | public string planStartTime; //计åå¼å§æ¶é´ |
| | | public string planFinishDate; //计å宿æ¶é´ |
| | | public string allotQty; //åé
æ°é |
| | | public string finishQty; //宿æ°é |
| | | public string comments; //夿³¨ |
| | | public string createDate; //åå»ºæ¥æ |
| | | public string createUserId; //å建人 |
| | | public string createUserName; //å建人åç§° |
| | | public string colorName; //é¢è² |
| | | public string color; //é¢è²id |
| | | public string productName; //产ååç§° |
| | | public string partNum; //产åç¼å· |
| | | public string status; //ç¶æ |
| | | public string urgent; //æ¯å¦ç´§æ¥ 1:ç´§æ¥ |
| | | public string option1; //èªå®ä¹å段1ï¼ç¨äºè®°å½éè¶äº ä¿®æ¹æ¶é´ |
| | | } |
| | | |
| | | |
| | | public class ICMOEdit |
| | | { |
| | | public string key; //å¯é¥ |
| | | public string planId; //计ååID |
| | | public string planNumber; //计ååå· |
| | | public string planQty; //è®¡åæ°é |
| | | public string partNum; //产åç¼å· |
| | | public string planStartDate; //计åå¼å§æ¶é´ |
| | | public string planEndDate; //计åç»ææ¶é´ |
| | | public string comments; //夿³¨ |
| | | public string customerName; //客æ·åç§° |
| | | public string colorName; //é¢è²åç§° |
| | | public string spec; //åå·è§æ ¼ |
| | | public string cpNo; //è²ç²ç¼å· |
| | | public string cpName; //è²ç²åç§° |
| | | public string materialNo; //ææç¼å· |
| | | public string materialName; //ææåç§° |
| | | public string orderNumber; //订åç¼å· |
| | | |
| | | public string option1; //èªå®ä¹å段1ï¼ç¨äºè®°å½éè¶äº ä¿®æ¹æ¶é´ |
| | | } |
| | | |
| | | #endregion |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region å°è¯¸èæ°æ®åæ¥ |
| | | public class XZG_DataSynchronizationController : ApiController |
| | | { |
| | | //è·åç³»ç»åæ° |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | public DBUtility.ClsPub.Enum_BillStatus BillStatus; |
| | | private json objJsonResult = new json(); |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | DataSet ds; |
| | | |
| | | #region å°è¯¸èæ°æ®åæ¥å¯é¥ |
| | | string APPID = "1f2e019a-ff51-f115-ce59-205606c72853"; |
| | | string APPPWD = "YYLM01A"; |
| | | #endregion |
| | | |
| | | #region è·åæå¡å°å |
| | | public async Task<string> getServerAddressAsync() |
| | | { |
| | | //请æ±å°å |
| | | string url = "https://js1.gomake.cn/kq_highnet_gof_connect/gof1.0/authorize"; |
| | | //请æ±åæ° |
| | | Dictionary<string, string> queryParams = new Dictionary<string, string> |
| | | { |
| | | {"appid", APPID}, |
| | | {"ver", "1.0"}, |
| | | {"seq",DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc) + "" } |
| | | }; |
| | | |
| | | //è¿åç»æ |
| | | string responseBody = await DefinedRequestSendMethod.GetDataAsyncByGetRequest(url, queryParams); |
| | | |
| | | //å°å符串转æ¢ä¸ºå¯¹è±¡ |
| | | ServerAddressResponse serverAddressResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<ServerAddressResponse>(responseBody); |
| | | |
| | | //è·å对象ä¸çæ°æ® |
| | | string res = serverAddressResponse.data.gofServerAdd; |
| | | |
| | | return res; |
| | | } |
| | | #endregion |
| | | |
| | | #region è·åéªè¯ç |
| | | public async Task<string> getVerificationCodeAsync() |
| | | { |
| | | //请æ±å°å |
| | | string url = await getServerAddressAsync() + "/gof1.0/verify"; |
| | | //请æ±åæ° |
| | | Dictionary<string, string> queryParams = new Dictionary<string, string> |
| | | { |
| | | {"appid", APPID}, |
| | | {"ver", "1.0"}, |
| | | {"seq",DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc) + "" } |
| | | }; |
| | | |
| | | //è¿åç»æ |
| | | string responseBody = await DefinedRequestSendMethod.GetDataAsyncByGetRequest(url, queryParams); |
| | | |
| | | //å°å符串转æ¢ä¸ºå¯¹è±¡ |
| | | VerificationCodeResponse verificationCodeResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<VerificationCodeResponse>(responseBody); |
| | | |
| | | //è·å对象ä¸çæ°æ® |
| | | string res = verificationCodeResponse.data.VerificationCode; |
| | | |
| | | return res; |
| | | } |
| | | #endregion |
| | | |
| | | #region è·åToken |
| | | public async Task<string> getTokenAsync() |
| | | { |
| | | //请æ±å°å |
| | | string url = await getServerAddressAsync() + "/gof1.0/key"; |
| | | string verificationCode = await getVerificationCodeAsync(); |
| | | //请æ±åæ° |
| | | Dictionary<string, string> queryParams = new Dictionary<string, string> |
| | | { |
| | | {"appid", APPID}, |
| | | {"ver", "1.0"}, |
| | | {"seq",DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc) + "" }, |
| | | {"pwd", DefinedRequestSendMethod.GetMD5( DefinedRequestSendMethod.GetMD5(verificationCode) + DefinedRequestSendMethod.GetMD5(APPPWD))} |
| | | }; |
| | | |
| | | //è¿åç»æ |
| | | string responseBody = await DefinedRequestSendMethod.GetDataAsyncByGetRequest(url, queryParams); |
| | | |
| | | //å°å符串转æ¢ä¸ºå¯¹è±¡ |
| | | TokenResponse tokenResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<TokenResponse>(responseBody); |
| | | |
| | | //è·å对象ä¸çæ°æ® |
| | | string res = tokenResponse.data.key; |
| | | |
| | | return res; |
| | | } |
| | | #endregion |
| | | |
| | | #region äº§åæ¡£æ¡ |
| | | #region è·å产ååè¡¨ä¿¡æ¯ |
| | | public async Task<MaterListResponse> getMaterListAsync() |
| | | { |
| | | //请æ±å°å |
| | | string url = await getServerAddressAsync() + "/v2/GET/getProductAll"; |
| | | string token = await getTokenAsync(); |
| | | //请æ±åæ° |
| | | Dictionary<string, string> queryParams = new Dictionary<string, string> |
| | | { |
| | | {"key", token}, |
| | | {"page", "1"}, |
| | | {"sidx", "lastUpdateTime"}, |
| | | {"sord", "desc"}, |
| | | {"systemType","IMM" } |
| | | }; |
| | | |
| | | //è¿åç»æ |
| | | string responseBody = await DefinedRequestSendMethod.GetDataAsyncByGetRequest(url, queryParams); |
| | | |
| | | //å°å符串转æ¢ä¸ºå¯¹è±¡ |
| | | MaterListResponse materListResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<MaterListResponse>(responseBody); |
| | | |
| | | return materListResponse; |
| | | } |
| | | #endregion |
| | | |
| | | #region è·å产å详ç»ä¿¡æ¯ |
| | | public async Task<MaterDetailResponse> getMaterDetailAsync(string url, string key, string partNum) |
| | | { |
| | | //请æ±å°å |
| | | url = url + "/v2/GET/getProductDetails"; |
| | | //请æ±åæ° |
| | | Dictionary<string, string> queryParams = new Dictionary<string, string> |
| | | { |
| | | {"key", key}, |
| | | {"partNum",partNum } |
| | | }; |
| | | |
| | | //è¿åç»æ |
| | | string responseBody = await DefinedRequestSendMethod.GetDataAsyncByGetRequest(url, queryParams); |
| | | |
| | | //å°å符串转æ¢ä¸ºå¯¹è±¡ |
| | | MaterDetailResponse materDetailResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<MaterDetailResponse>(responseBody); |
| | | |
| | | return materDetailResponse; |
| | | } |
| | | #endregion |
| | | |
| | | #region æ°å¢äº§å |
| | | public async Task<MaterialResponse> getAddMaterAsync(string url, Material material) |
| | | { |
| | | |
| | | //请æ±å°å |
| | | url = url + "/v2/POST/AddProduct"; |
| | | |
| | | //POST请æ±åæ° |
| | | Dictionary<string, string> queryParams = new Dictionary<string, string> |
| | | { |
| | | {"key", DBUtility.ClsPub.isStrNull(material.key)}, |
| | | {"productName", DBUtility.ClsPub.isStrNull(material.productName)}, |
| | | {"partNum",DBUtility.ClsPub.isStrNull(material.partNum)}, |
| | | {"sepc", DBUtility.ClsPub.isStrNull(material.sepc)}, |
| | | {"weight", DBUtility.ClsPub.isStrNull(material.weight)}, |
| | | {"headWeight", DBUtility.ClsPub.isStrNull(material.headWeight)}, |
| | | {"cycletime", DBUtility.ClsPub.isStrNull(material.cycleTime)}, |
| | | {"fightsPartnum", DBUtility.ClsPub.isStrNull(material.flightsPartnum)}, |
| | | {"comments", DBUtility.ClsPub.isStrNull(material.comments)}, |
| | | {"colorName", DBUtility.ClsPub.isStrNull(material.colorName)}, |
| | | {"pieceWage", DBUtility.ClsPub.isStrNull(material.pieceWage)}, |
| | | {"unit", DBUtility.ClsPub.isStrNull(material.unit)}, |
| | | {"systemType", DBUtility.ClsPub.isStrNull(material.systemType)}, |
| | | {"tdDocNo", DBUtility.ClsPub.isStrNull(material.tdDocNo)}, |
| | | {"progressWay", DBUtility.ClsPub.isStrNull(material.progressWay)}, |
| | | {"groupId", DBUtility.ClsPub.isStrNull(material.groupId)}, |
| | | |
| | | {"option1", DBUtility.ClsPub.isStrNull(material.option1)} |
| | | }; |
| | | |
| | | //POST请æ±Bodyæ°æ® |
| | | var postData = new { }; |
| | | string json = Newtonsoft.Json.JsonConvert.SerializeObject(postData); |
| | | |
| | | //è¿åç»æ |
| | | string responseBody = await DefinedRequestSendMethod.GetDataAsyncByPOSTRequest(url, queryParams, json); |
| | | |
| | | //å°å符串转æ¢ä¸ºå¯¹è±¡ |
| | | MaterialResponse materialResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<MaterialResponse>(responseBody); |
| | | |
| | | return materialResponse; |
| | | } |
| | | #endregion |
| | | |
| | | #region ç¼è¾äº§å |
| | | public async Task<MaterialEditResponse> getAddMaterEditAsync(string url, MaterialEdit material) |
| | | { |
| | | |
| | | //请æ±å°å |
| | | url = url + "/v2/POST/UpdateProduct"; |
| | | |
| | | //POST请æ±åæ° |
| | | Dictionary<string, string> queryParams = new Dictionary<string, string> |
| | | { |
| | | {"key", DBUtility.ClsPub.isStrNull(material.key)}, |
| | | {"productId", DBUtility.ClsPub.isStrNull(material.productId)}, |
| | | {"productName", DBUtility.ClsPub.isStrNull(material.productName)}, |
| | | {"partNum",DBUtility.ClsPub.isStrNull(material.partNum)}, |
| | | {"cycletime", DBUtility.ClsPub.isStrNull(material.cycleTime)}, |
| | | {"sepc", DBUtility.ClsPub.isStrNull(material.sepc)}, |
| | | {"weight", DBUtility.ClsPub.isStrNull(material.weight)}, |
| | | {"headWeight", DBUtility.ClsPub.isStrNull(material.headWeight)}, |
| | | {"fightsPartnum", DBUtility.ClsPub.isStrNull(material.flightsPartnum)}, |
| | | {"comments", DBUtility.ClsPub.isStrNull(material.comments)}, |
| | | {"colorName", DBUtility.ClsPub.isStrNull(material.colorName)}, |
| | | {"unit", DBUtility.ClsPub.isStrNull(material.unit)}, |
| | | {"systemType", DBUtility.ClsPub.isStrNull(material.systemType)}, |
| | | {"tdDocNo", DBUtility.ClsPub.isStrNull(material.tdDocNo)}, |
| | | {"progressWay", DBUtility.ClsPub.isStrNull(material.progressWay)}, |
| | | {"groupId", DBUtility.ClsPub.isStrNull(material.groupId)}, |
| | | |
| | | {"option1", DBUtility.ClsPub.isStrNull(material.option1)} |
| | | }; |
| | | |
| | | //POST请æ±Bodyæ°æ® |
| | | var postData = new { }; |
| | | string json = Newtonsoft.Json.JsonConvert.SerializeObject(postData); |
| | | |
| | | //è¿åç»æ |
| | | string responseBody = await DefinedRequestSendMethod.GetDataAsyncByPOSTRequest(url, queryParams, json); |
| | | |
| | | //å°å符串转æ¢ä¸ºå¯¹è±¡ |
| | | MaterialEditResponse materialEditResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<MaterialEditResponse>(responseBody); |
| | | |
| | | return materialEditResponse; |
| | | } |
| | | #endregion |
| | | |
| | | #region äº§åæ¡£æ¡å®æ¶åæ¥_ä»ERPå°å°è¯¸è |
| | | public async Task<json> productInfoSyncFromERPToXZG() |
| | | { |
| | | try |
| | | { |
| | | //请æ±å°å |
| | | string url = await getServerAddressAsync(); |
| | | string token = await getTokenAsync(); |
| | | |
| | | //è·åéè¶äºç©ææ°æ® |
| | | List<Material> materials = new List<Material>(); |
| | | string sql = @"select |
| | | a.FNUMBER HNumber |
| | | ,l.FNAME HName |
| | | ,isnull(l.FSPECIFICATION,'') HModel |
| | | ,'CLD-ERP导å
¥' HRemark |
| | | ,unit.FNAME HUnitName |
| | | ,convert(varchar(100),a.FMODIFYDATE,20) HUpdateDate |
| | | from AIS20210811135644..T_BD_MATERIAL a with(nolock) |
| | | inner join AIS20210811135644..T_BD_MATERIAL_L l with(nolock) on a.FMATERIALID=l.FMATERIALID |
| | | inner join AIS20210811135644..T_BD_MATERIALSTOCK s with(nolock) on a.FMATERIALID=s.FMATERIALID |
| | | inner join AIS20210811135644..T_BD_Unit_L unit with(nolock) on isnull(s.FSTOREUNITID,0) = unit.FUNITID |
| | | Where l.FLOCALEID=2052 |
| | | and unit.FLOCALEID = 2052 |
| | | and a.FFORBIDSTATUS='A' |
| | | and |
| | | ( |
| | | convert(varchar(100),a.FCREATEDATE,23) >= convert(varchar(100),DATEADD(day,-7,getdate()),23) |
| | | or |
| | | convert(varchar(100),a.FMODIFYDATE,23) >= convert(varchar(100),DATEADD(day,-7,getdate()),23) |
| | | )"; |
| | | DataSet ds = oCN.RunProcReturn(sql, "AIS20210811135644..T_BD_MATERIAL"); |
| | | if (ds != null && ds.Tables.Count > 0) |
| | | { |
| | | for(int i = 0; i < ds.Tables[0].Rows.Count; i++) |
| | | { |
| | | Material material = new Material(); |
| | | material.key = token; |
| | | material.productName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HName"]); |
| | | material.partNum = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HNumber"]); |
| | | material.sepc = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HModel"]); |
| | | //material.weight = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i][""]); |
| | | //material.headWeight = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i][""]); |
| | | material.cycleTime = "1"; |
| | | //material.flightsPartnum = ""; |
| | | material.comments = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HRemark"]); |
| | | //material.colorName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i][""]); |
| | | //material.pieceWage = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i][""]); |
| | | material.unit = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HUnitName"]); |
| | | material.systemType = "IMM"; |
| | | material.tdDocNo = ""; |
| | | //material.progressWay = "0"; |
| | | //material.groupId = ""; |
| | | |
| | | material.option1 = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["HUpdateDate"]); |
| | | |
| | | materials.Add(material); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "éè¶äºç©ææ°æ®è·å失败!"; |
| | | objJsonResult.data = null; |
| | | } |
| | | |
| | | //å¤æç©æå表ä¸çæ°æ®æ¯å¦å¨å°è¯¸èä¸å·²ç»åå¨ä¸å·²ç»æ¯ææ°æ°æ®ã妿å°è¯¸èä¸ä¸åå¨å忥å°å°è¯¸èã妿å°è¯¸èä¸åå¨ï¼åè¦çæ°æ®ã |
| | | string errMsg = ""; |
| | | List<Material> materials_waitSync = new List<Material>(); |
| | | for(int i = 0; i < materials.Count; i++) |
| | | { |
| | | string HMaterNumber = materials[i].partNum; |
| | | MaterDetailResponse materDetailResponse = await getMaterDetailAsync(url, token, HMaterNumber); |
| | | if (materDetailResponse.code == "1") |
| | | { |
| | | if (materDetailResponse.data.details.option1 != materials[i].option1) |
| | | { |
| | | MaterialEdit materialEdit = new MaterialEdit(); |
| | | materialEdit.key = token; |
| | | materialEdit.productId = materDetailResponse.data.details.partId; |
| | | materialEdit.productName = DBUtility.ClsPub.isStrNull(materials[i].productName); |
| | | materialEdit.partNum = DBUtility.ClsPub.isStrNull(materials[i].partNum); |
| | | materialEdit.sepc = DBUtility.ClsPub.isStrNull(materials[i].sepc); |
| | | //materialEdit.weight = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i][""]); |
| | | //materialEdit.headWeight = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i][""]); |
| | | materialEdit.cycleTime = "1"; |
| | | //materialEdit.flightsPartnum = ""; |
| | | materialEdit.comments = DBUtility.ClsPub.isStrNull(materials[i].comments); |
| | | //materialEdit.colorName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i][""]); |
| | | //materialEdit.pieceWage = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i][""]); |
| | | materialEdit.unit = DBUtility.ClsPub.isStrNull(materials[i].unit); |
| | | materialEdit.systemType = "IMM"; |
| | | materialEdit.tdDocNo = ""; |
| | | //materialEdit.progressWay = ""; |
| | | //materialEdit.groupId = ""; |
| | | |
| | | materialEdit.option1 = DBUtility.ClsPub.isStrNull(materials[i].option1); |
| | | MaterialEditResponse materialEditResponse = await getAddMaterEditAsync(url, materialEdit); |
| | | if (materialEditResponse.code == "0") |
| | | { |
| | | errMsg += "ã" + HMaterNumber + "ã" + materialEditResponse.msg + "ï¼"; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | MaterialResponse materialResponse = await getAddMaterAsync(url, materials[i]); |
| | | if (materialResponse.code == "0") |
| | | { |
| | | errMsg += "ã" + HMaterNumber + "ã" + materialResponse.msg + "ï¼"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (errMsg.Length > 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ¥å¤±è´¥!" + errMsg; |
| | | objJsonResult.data = null; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "忥æå!" + errMsg; |
| | | objJsonResult.data = null; |
| | | |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ¥å¤±è´¥!" + e.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region ç产订å |
| | | #region è·åç产订ååè¡¨ä¿¡æ¯ |
| | | public async Task<ICMOListResponse> getICMOListAsync() |
| | | { |
| | | //请æ±å°å |
| | | string url = await getServerAddressAsync() + "/v2/GET/getPlanOrder"; |
| | | string token = await getTokenAsync(); |
| | | //请æ±åæ° |
| | | Dictionary<string, string> queryParams = new Dictionary<string, string> |
| | | { |
| | | {"key", token}, |
| | | {"indexPage", "1"}, |
| | | {"planStartDate", DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd")}, |
| | | {"planEndDate", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} |
| | | }; |
| | | |
| | | //è¿åç»æ |
| | | string responseBody = await DefinedRequestSendMethod.GetDataAsyncByGetRequest(url, queryParams); |
| | | |
| | | //å°å符串转æ¢ä¸ºå¯¹è±¡ |
| | | ICMOListResponse icmoListResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<ICMOListResponse>(responseBody); |
| | | |
| | | return icmoListResponse; |
| | | } |
| | | #endregion |
| | | |
| | | #region è·åç产订å详ç»ä¿¡æ¯ |
| | | public async Task<ICMODetailResponse> getICMODetailAsync(string url, string key, string planNum) |
| | | { |
| | | try |
| | | { |
| | | //请æ±å°å |
| | | url = url + "/v2/GET/getPlanOrderDetail"; |
| | | //请æ±åæ° |
| | | Dictionary<string, string> queryParams = new Dictionary<string, string> |
| | | { |
| | | {"key", key}, |
| | | {"planNum",planNum } |
| | | }; |
| | | |
| | | //è¿åç»æ |
| | | string responseBody = await DefinedRequestSendMethod.GetDataAsyncByGetRequest(url, queryParams); |
| | | |
| | | //å°å符串转æ¢ä¸ºå¯¹è±¡ |
| | | ICMODetailResponse icmoDetailResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<ICMODetailResponse>(responseBody); |
| | | |
| | | return icmoDetailResponse; |
| | | }catch(Exception e) |
| | | { |
| | | return new ICMODetailResponse(); |
| | | } |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region æ°å¢ç产订å |
| | | public async Task<ICMOResponse> getAddICMOAsync(string url, ICMO icmo) |
| | | { |
| | | |
| | | //请æ±å°å |
| | | url = url + "/v2/POST/addPlan"; |
| | | |
| | | //POST请æ±åæ° |
| | | Dictionary<string, string> queryParams = new Dictionary<string, string> |
| | | { |
| | | {"key", DBUtility.ClsPub.isStrNull(icmo.key)}, |
| | | {"planNumber", DBUtility.ClsPub.isStrNull(icmo.planNumber)}, |
| | | {"planQty",DBUtility.ClsPub.isStrNull(icmo.planQty)}, |
| | | {"partNum", DBUtility.ClsPub.isStrNull(icmo.partNum)}, |
| | | {"planStartDate", DBUtility.ClsPub.isStrNull(icmo.planStartDate)}, |
| | | {"planEndDate", DBUtility.ClsPub.isStrNull(icmo.planEndDate)}, |
| | | {"comments", DBUtility.ClsPub.isStrNull(icmo.comments)}, |
| | | {"customerName", DBUtility.ClsPub.isStrNull(icmo.customerName)}, |
| | | {"colorName", DBUtility.ClsPub.isStrNull(icmo.colorName)}, |
| | | {"spec", DBUtility.ClsPub.isStrNull(icmo.spec)}, |
| | | {"cpNo", DBUtility.ClsPub.isStrNull(icmo.cpNo)}, |
| | | {"cpName", DBUtility.ClsPub.isStrNull(icmo.cpName)}, |
| | | {"materialNo", DBUtility.ClsPub.isStrNull(icmo.materialNo)}, |
| | | {"materialName", DBUtility.ClsPub.isStrNull(icmo.materialName)}, |
| | | {"orderNumber", DBUtility.ClsPub.isStrNull(icmo.orderNumber)}, |
| | | {"option1", DBUtility.ClsPub.isStrNull(icmo.option1)} |
| | | }; |
| | | |
| | | //POST请æ±Bodyæ°æ® |
| | | var postData = new { }; |
| | | string json = Newtonsoft.Json.JsonConvert.SerializeObject(postData); |
| | | |
| | | //è¿åç»æ |
| | | string responseBody = await DefinedRequestSendMethod.GetDataAsyncByPOSTRequest(url, queryParams, json); |
| | | |
| | | //å°å符串转æ¢ä¸ºå¯¹è±¡ |
| | | ICMOResponse icmoResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<ICMOResponse>(responseBody); |
| | | |
| | | return icmoResponse; |
| | | } |
| | | #endregion |
| | | |
| | | #region ç¼è¾ç产订å |
| | | public async Task<ICMOEditResponse> getAddICMOEditAsync(string url, ICMOEdit icmo) |
| | | { |
| | | |
| | | //请æ±å°å |
| | | url = url + "/v2/POST/updatePlanInfo"; |
| | | |
| | | //POST请æ±åæ° |
| | | Dictionary<string, string> queryParams = new Dictionary<string, string> |
| | | { |
| | | {"key", DBUtility.ClsPub.isStrNull(icmo.key)}, |
| | | {"planId", DBUtility.ClsPub.isStrNull(icmo.planId)}, |
| | | {"planNumber", DBUtility.ClsPub.isStrNull(icmo.planNumber)}, |
| | | {"planQty",DBUtility.ClsPub.isStrNull(icmo.planQty)}, |
| | | {"partNum", DBUtility.ClsPub.isStrNull(icmo.partNum)}, |
| | | {"planStartDate", DBUtility.ClsPub.isStrNull(icmo.planStartDate)}, |
| | | {"planEndDate", DBUtility.ClsPub.isStrNull(icmo.planEndDate)}, |
| | | {"comments", DBUtility.ClsPub.isStrNull(icmo.comments)}, |
| | | {"customerName", DBUtility.ClsPub.isStrNull(icmo.customerName)}, |
| | | {"colorName", DBUtility.ClsPub.isStrNull(icmo.colorName)}, |
| | | {"spec", DBUtility.ClsPub.isStrNull(icmo.spec)}, |
| | | {"cpNo", DBUtility.ClsPub.isStrNull(icmo.cpNo)}, |
| | | {"cpName", DBUtility.ClsPub.isStrNull(icmo.cpName)}, |
| | | {"materialNo", DBUtility.ClsPub.isStrNull(icmo.materialNo)}, |
| | | {"materialName", DBUtility.ClsPub.isStrNull(icmo.materialName)}, |
| | | {"orderNumber", DBUtility.ClsPub.isStrNull(icmo.orderNumber)}, |
| | | {"option1", DBUtility.ClsPub.isStrNull(icmo.option1)} |
| | | }; |
| | | |
| | | //POST请æ±Bodyæ°æ® |
| | | var postData = new { }; |
| | | string json = Newtonsoft.Json.JsonConvert.SerializeObject(postData); |
| | | |
| | | //è¿åç»æ |
| | | string responseBody = await DefinedRequestSendMethod.GetDataAsyncByPOSTRequest(url, queryParams, json); |
| | | |
| | | //å°å符串转æ¢ä¸ºå¯¹è±¡ |
| | | ICMOEditResponse icmoEditResponse = Newtonsoft.Json.JsonConvert.DeserializeObject<ICMOEditResponse>(responseBody); |
| | | |
| | | return icmoEditResponse; |
| | | } |
| | | #endregion |
| | | |
| | | #region ç产订å宿¶åæ¥_ä»ERPå°å°è¯¸è |
| | | public async Task<json> icmoInfoSyncFromERPToXZG() |
| | | { |
| | | try |
| | | { |
| | | //请æ±å°å |
| | | string url = await getServerAddressAsync(); |
| | | string token = await getTokenAsync(); |
| | | |
| | | //è·åéè¶äºçäº§è®¢åæ°æ® |
| | | List<ICMO> icmos = new List<ICMO>(); |
| | | string sql = @"select |
| | | cast(a.FBILLNO as varchar(100)) + '_' + cast(b.FSEQ as varchar(10)) 计ååå· |
| | | ,cast(b.FQTY as int) è®¡åæ°é |
| | | ,m.FNUMBER 产åç¼å· |
| | | ,convert(varchar(100),b.FPLANSTARTDATE,20) 计åå¼å·¥æ¥æ |
| | | ,convert(varchar(100),b.FPLANFINISHDATE,20) 计åå®å·¥æ¥æ |
| | | ,'ERP导å
¥' 夿³¨ |
| | | ,'' 客æ·åç§° |
| | | ,'' é¢è² |
| | | ,isnull(m_l.FSPECIFICATION,'') åå·è§æ ¼ |
| | | ,'' è²ç²ç¼å· |
| | | ,'' è²ç²åç§° |
| | | ,'' ææç¼å· |
| | | ,'' ææåç§° |
| | | ,a.FBILLNO 订åç¼å· |
| | | ,ISNULL(convert(varchar(100),c.FSTARTDATE ,20),'') å¼å·¥æ¥æ |
| | | ,convert(varchar(100),a.FMODIFYDATE,20) ä¿®æ¹æ¥æ |
| | | from AIS20210811135644..T_PRD_MO as a |
| | | inner join AIS20210811135644..T_PRD_MOENTRY as b with(nolock) on a.FID = b.FID |
| | | inner join AIS20210811135644..T_PRD_MOENTRY_A as c with(nolock) on b.FID = c.FID and b.FEntryID = c.FEntryID |
| | | inner join AIS20210811135644..T_BD_MATERIAL as m with(nolock) on b.FMATERIALID = m.FMATERIALID |
| | | inner join AIS20210811135644..T_BD_MATERIAL_L as m_l with(nolock) on m.FMATERIALID=m_l.FMATERIALID |
| | | where m_l.FLOCALEID=2052 |
| | | and isnull(a.FAPPROVERID,0)<> 0 --å·²ç»å®¡æ ¸ |
| | | and isnull(c.fstatus,0) in (4) --ä¸å¡ç¶æï¼1:计åï¼2:计å确认ï¼3:ä¸è¾¾ï¼4:å¼å·¥ï¼5:å®å·¥ï¼6:ç»æ¡ï¼ |
| | | and |
| | | ( |
| | | convert(varchar(100),a.fmodifydate,23) >= convert(varchar(100),dateadd(day,-7,getdate()),23) |
| | | or |
| | | convert(varchar(100),c.fstartdate ,23) >= convert(varchar(100),dateadd(day,-7,getdate()),23) |
| | | ) |
| | | and cast(a.FBILLNO as varchar(100)) + '_' + cast(b.FSEQ as varchar(10)) = 'MO000269_1'"; |
| | | DataSet ds = oCN.RunProcReturn(sql, "AIS20210811135644..T_PRD_MO"); |
| | | if (ds != null && ds.Tables.Count > 0) |
| | | { |
| | | for (int i = 0; i < ds.Tables[0].Rows.Count; i++) |
| | | { |
| | | ICMO icmo = new ICMO(); |
| | | icmo.key = token; |
| | | icmo.planNumber = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["计ååå·"]); |
| | | icmo.planQty = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["è®¡åæ°é"]); |
| | | icmo.partNum = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["产åç¼å·"]); |
| | | icmo.planStartDate = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["计åå¼å·¥æ¥æ"]); |
| | | icmo.planEndDate = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["计åå®å·¥æ¥æ"]); |
| | | icmo.comments = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["夿³¨"]); |
| | | icmo.customerName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["客æ·åç§°"]); |
| | | icmo.colorName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["é¢è²"]); |
| | | icmo.spec = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["åå·è§æ ¼"]); |
| | | icmo.cpNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["è²ç²ç¼å·"]); |
| | | icmo.cpName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["è²ç²åç§°"]); |
| | | icmo.materialNo = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["ææç¼å·"]); |
| | | icmo.materialName = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["ææåç§°"]); |
| | | icmo.orderNumber = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["订åç¼å·"]); |
| | | icmo.option1 = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[i]["ä¿®æ¹æ¥æ"]); |
| | | |
| | | icmos.Add(icmo); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "éè¶äºçäº§è®¢åæ°æ®è·å失败!"; |
| | | objJsonResult.data = null; |
| | | } |
| | | |
| | | //夿ç产订åå表ä¸çæ°æ®æ¯å¦å¨å°è¯¸èä¸å·²ç»åå¨ä¸å·²ç»æ¯ææ°æ°æ®ã妿å°è¯¸èä¸ä¸åå¨å忥å°å°è¯¸èã妿å°è¯¸èä¸åå¨ï¼åè¦çæ°æ®ã |
| | | string errMsg = ""; |
| | | for (int i = 0; i < icmos.Count; i++) |
| | | { |
| | | string HPlanNumber = icmos[i].planNumber; |
| | | ICMODetailResponse icmoDetailResponse = await getICMODetailAsync(url, token, HPlanNumber); |
| | | if (icmoDetailResponse.code == "1") |
| | | { |
| | | if (icmoDetailResponse.data[0].option1 != icmos[i].option1) |
| | | { |
| | | ICMOEdit icmoEdit = new ICMOEdit(); |
| | | icmoEdit.key = token; |
| | | icmoEdit.planId = icmoDetailResponse.data[0].planId; |
| | | icmoEdit.planNumber = DBUtility.ClsPub.isStrNull(icmos[i].planNumber); |
| | | icmoEdit.planQty = DBUtility.ClsPub.isStrNull(icmos[i].planQty); |
| | | icmoEdit.partNum = DBUtility.ClsPub.isStrNull(icmos[i].partNum); |
| | | icmoEdit.planStartDate = DBUtility.ClsPub.isStrNull(icmos[i].planStartDate); |
| | | icmoEdit.planEndDate = DBUtility.ClsPub.isStrNull(icmos[i].planEndDate); |
| | | icmoEdit.comments = DBUtility.ClsPub.isStrNull(icmos[i].comments); |
| | | icmoEdit.customerName = DBUtility.ClsPub.isStrNull(icmos[i].customerName); |
| | | icmoEdit.colorName = DBUtility.ClsPub.isStrNull(icmos[i].colorName); |
| | | icmoEdit.spec = DBUtility.ClsPub.isStrNull(icmos[i].spec); |
| | | icmoEdit.cpName = DBUtility.ClsPub.isStrNull(icmos[i].cpName); |
| | | icmoEdit.materialNo = DBUtility.ClsPub.isStrNull(icmos[i].materialNo); |
| | | icmoEdit.materialName = DBUtility.ClsPub.isStrNull(icmos[i].materialName); |
| | | icmoEdit.orderNumber = DBUtility.ClsPub.isStrNull(icmos[i].orderNumber); |
| | | icmoEdit.option1 = DBUtility.ClsPub.isStrNull(icmos[i].option1); |
| | | ICMOEditResponse icmoEditResponse = await getAddICMOEditAsync(url, icmoEdit); |
| | | if (icmoEditResponse.code == "0") |
| | | { |
| | | errMsg += "ã" + HPlanNumber + "ã" + icmoEditResponse.msg + "ï¼"; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ICMOResponse icmoResponse = await getAddICMOAsync(url, icmos[i]); |
| | | if (icmoResponse.code == "0") |
| | | { |
| | | errMsg += "ã" + HPlanNumber + "ã" + icmoResponse.msg + "ï¼"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (errMsg.Length > 0) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ¥å¤±è´¥!" + errMsg; |
| | | objJsonResult.data = null; |
| | | } |
| | | |
| | | objJsonResult.code = "1"; |
| | | objJsonResult.count = 1; |
| | | objJsonResult.Message = "忥æå!" + errMsg; |
| | | objJsonResult.data = null; |
| | | |
| | | return objJsonResult; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | objJsonResult.code = "0"; |
| | | objJsonResult.count = 0; |
| | | objJsonResult.Message = "åæ¥å¤±è´¥!" + e.Message; |
| | | objJsonResult.data = null; |
| | | return objJsonResult; |
| | | } |
| | | } |
| | | #endregion |
| | | #endregion |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | #region HTTP请æ±ç±» |
| | | class DefinedRequestSendMethod |
| | | { |
| | | |
| | | #region Getè¯·æ± |
| | | public static async Task<string> GetDataAsyncByGetRequest(string url, Dictionary<string, string> queryParams) |
| | | { |
| | | //è¿åå符串 |
| | | string responseBody = ""; |
| | | |
| | | using (HttpClient client = new HttpClient()) |
| | | { |
| | | string apiUrl = url + ToQueryString(queryParams); |
| | | |
| | | HttpResponseMessage response = await client.GetAsync(apiUrl); |
| | | response.EnsureSuccessStatusCode(); |
| | | |
| | | responseBody = await response.Content.ReadAsStringAsync(); |
| | | } |
| | | |
| | | return responseBody; |
| | | } |
| | | #endregion |
| | | |
| | | #region POSTè¯·æ± |
| | | public static async Task<string> GetDataAsyncByPOSTRequest(string url, Dictionary<string, string> queryParams, string json) |
| | | { |
| | | //è¿åå符串 |
| | | string responseBody = ""; |
| | | |
| | | using (HttpClient client = new HttpClient()) |
| | | { |
| | | //åå¤é¾æ¥ |
| | | url = url + ToQueryString(queryParams); |
| | | |
| | | // åå¤POSTæ°æ® |
| | | var content = new StringContent(json, Encoding.UTF8, "application/json"); |
| | | |
| | | // åéPOSTè¯·æ± |
| | | HttpResponseMessage response = await client.PostAsync(url, content); |
| | | response.EnsureSuccessStatusCode(); |
| | | |
| | | responseBody = await response.Content.ReadAsStringAsync(); |
| | | } |
| | | |
| | | return responseBody; |
| | | } |
| | | #endregion |
| | | |
| | | #region åæ°å¤ç |
| | | static string ToQueryString(Dictionary<string, string> parameters) |
| | | { |
| | | string paramsStr = ""; |
| | | foreach (var param in parameters) |
| | | { |
| | | if (paramsStr.Length == 0) |
| | | { |
| | | paramsStr += param.Key + "=" + param.Value; |
| | | } |
| | | else |
| | | { |
| | | paramsStr += "&" + param.Key + "=" + param.Value; |
| | | } |
| | | } |
| | | return "?" + paramsStr; |
| | | |
| | | //var query = System.Web.HttpUtility.ParseQueryString(string.Empty); |
| | | //foreach (var param in parameters) |
| | | //{ |
| | | // query[param.Key] = param.Value; |
| | | //} |
| | | //return "?" + query.ToString(); |
| | | } |
| | | #endregion |
| | | |
| | | #region MD5å å¯ |
| | | public static string GetMD5(string input) |
| | | { |
| | | using (MD5 md5 = MD5.Create()) |
| | | { |
| | | byte[] inputBytes = Encoding.UTF8.GetBytes(input); |
| | | byte[] hashBytes = md5.ComputeHash(inputBytes); |
| | | |
| | | StringBuilder sb = new StringBuilder(); |
| | | for (int i = 0; i < hashBytes.Length; i++) |
| | | { |
| | | sb.Append(hashBytes[i].ToString("x2")); // "x2"表示å°åç16è¿å¶æ ¼å¼ |
| | | } |
| | | return sb.ToString(); |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | #endregion |