From 6b9801e47304eac1640cf737ef6bc039ff104dd1 Mon Sep 17 00:00:00 2001 From: kazelee <1847801760@qq.com> Date: 星期一, 23 六月 2025 17:17:39 +0800 Subject: [PATCH] 删除冗余的注释和功能,优化部分代码 --- core/Monitor.cs | 176 +++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 112 insertions(+), 64 deletions(-) diff --git a/core/Monitor.cs b/core/Monitor.cs index 23f9962..b24ff54 100644 --- a/core/Monitor.cs +++ b/core/Monitor.cs @@ -4,11 +4,11 @@ using System.Text; using System.Threading.Tasks; +using HH.WCS.Mobox3.DSZSH.api; using HH.WCS.Mobox3.DSZSH.device; using HH.WCS.Mobox3.DSZSH.models; using HH.WCS.Mobox3.DSZSH.util; using HH.WCS.Mobox3.DSZSH.wms; -using Microsoft.Win32; using Newtonsoft.Json; @@ -65,41 +65,6 @@ var startLocCode = prod.OffLoc[0]; // 鐢ㄤ簬娴嬭瘯 //var startLocCode = "CX01"; // 鐢ㄤ簬娴嬭瘯 - //var cgDetail = new TN_CG_Detail { // 绌烘墭涓婄嚎鏃跺氨缁戝畾濂戒簡 - // S_ITEM_CODE = itemCode, - // S_BATCH_NO = batchNo, - // S_CNTR_CODE = cntrCode, - //}; - - //var needInsertContainer = false; - //var needUpdateContainer = false; - - // TEMP 鑷姩瑙﹀彂鐨勬墭鐩樹笅绾挎殏鏃朵笉鑰冭檻鍒ゆ柇锛岄粯璁ゆ病鏈夋椂鍐欏叆 - // 鏌ュ鍣ㄤ俊鎭〃鏄惁宸茬粡鏈夎繖涓鍣�- //var cntr = db.Queryable<TN_Container>() - // .Where(c => c.S_CODE == cntrCode).First(); - // 濡傛灉鎵句笉鍒拌瀹瑰櫒锛岄渶瑕佹坊鍔狅紝骞朵笖灏嗗鍣ㄦ潵婧愯缃负浠诲姟鍚嶇О - //if (cntr == null) { - // needInsertContainer = true; - // LogHelper.Info($"杞锛歿taskName}锛氬鍣細{cntrCode}锛屽湪瀹瑰櫒琛ㄤ腑娌℃湁鐧昏锛岀櫥璁板苟璁剧疆瀹瑰櫒鏉ユ簮涓猴細{taskName}"); - - // cntr = new TN_Container { - // S_CODE = cntrCode, - // S_TYPE = cntrType, - // S_SPEC = itemCode, - // }; - //} - //else { - // 濡傛灉鎵惧埌璇ュ鍣紝浣嗗鍣ㄧ墿鏂欑被鍨嬩笌涓嬬嚎鐗╂枡涓嶇锛岃褰曞苟鐩存帴瑕嗙洊锛堝緟瀹氾級 - // if (!string.IsNullOrEmpty(cntr.S_SPEC) && cntr.S_SPEC != itemCode) { - // needUpdateContainer = true; - // LogHelper.Info($"杞锛歿taskName}锛氬鍣ㄨ〃涓鍣▄cntrCode}瀵瑰簲鐨勭墿鏂欎俊鎭細{cntr.S_SPEC}锛� + - // $"涓庢墍闇�鐨勭墿鏂欎俊鎭瘂itemCode}涓嶇锛岀洿鎺ヨ鐩栫粨鏋�); - - // cntr.S_SPEC = itemCode; - // } - //} - var startLoc = db.Queryable<TN_Location>() .Where(l => l.S_CODE == startLocCode) .Where(l => Settings.AreaMap[startAreaName].Contains(l.S_AREA_CODE)) @@ -142,9 +107,6 @@ LocationHelper.LockStartLoc(ref startLoc); // 璧风偣鍑哄簱閿� LocationHelper.LockEndLoc(ref endLoc); // 缁堢偣鍏ュ簱閿� - //cntr.S_SOURCE = task.S_CODE; - //cntr.T_MODIFY = DateTime.Now; - using (var tran = db.Ado.UseTran()) { if (locCntrRelOld != null) { if (db.Deleteable<TN_Loc_Container>(locCntrRelOld).ExecuteCommand() <= 0 && @@ -155,30 +117,6 @@ continue; } } - //if (needInsertContainer) { - // if (db.Insertable<TN_Container>(cntr).ExecuteCommand() <= 0) { - // info = $"鎻掑叆瀹瑰櫒琛ㄥけ璐ワ細" + JsonConvert.SerializeObject(cntr); - // tran.RollbackTran(); - // LogHelper.Info(info); - // continue; - // } - //} - //else if (needUpdateContainer) { - // if (db.Updateable<TN_Container>(cntr) - // .UpdateColumns(c => new { c.S_SPEC, c.S_SOURCE, c.T_MODIFY }).ExecuteCommand() <= 0) { - // info = $"鏇存柊瀹瑰櫒琛ㄥけ璐ワ細" + JsonConvert.SerializeObject(cntr); - // tran.RollbackTran(); - // LogHelper.Info(info); - // continue; - // } - //} - - //if (db.Insertable<TN_CG_Detail>(cgDetail).ExecuteCommand() <= 0) { - // tran.RollbackTran(); - // info = $"鎻掑叆瀹瑰櫒璐у搧淇℃伅琛ㄥけ璐ワ細鐗╂枡缂栫爜{cgDetail.S_ITEM_CODE}锛屽鍣ㄧ紪鐮亄cgDetail.S_CNTR_CODE}"; - // LogHelper.Info(info); - // continue; - //} if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() <= 0) { tran.RollbackTran(); @@ -250,6 +188,8 @@ LogHelper.Info(info); return; } + + Console.WriteLine(JsonConvert.SerializeObject(orderList)); // TEST var detailList = new List<TN_Outbound_Detail>(); foreach (var order in orderList) { @@ -372,8 +312,17 @@ tran.CommitTran(); info = $"鐢熸垚浠诲姟'{taskName}'鎴愬姛锛屼换鍔″彿={task.S_CODE}锛屽鍣ㄥ彿={cntId}锛岃捣鐐�{startLoc.S_CODE}锛岀粓鐐�{endLoc.S_CODE}"; LogHelper.Info(info); - continue; + //continue; } + + // 濡傛灉褰撳墠鍑哄簱鍗曟槑缁嗘槸ERP涓嬪彂鐨勶紝浠诲姟鍒涘缓瀹屾垚鍙嶉璐т綅淇℃伅 + if (detail.S_BS_TYPE == "ERP") { + //var createTaskReturnErpTask = Task.Run(() => { + // CreateTaskReturnErp(task); + //}); + CreateTaskReturnErp(task); + } + } @@ -667,5 +616,104 @@ LogHelper.InfoEx(ex); } } + + public static void CreateTaskReturnErp(TN_Task task) { + var db = new SqlHelper<object>().GetInstance(); + var info = ""; + var httpH = new HttpHelper(); + + try { + var plan = db.Queryable<TN_Outbound_Plan>() + .Where(p => p.JHDH == task.S_BS_NO) + .First(); + + if (plan == null) { + info = $"璁″垝鍗曞彿{task.S_BS_NO}涓嶅瓨鍦紒"; + LogHelper.Info(info); + } + + var cgDetail = db.Queryable<TN_CG_Detail>() + .Where(d => d.S_CNTR_CODE == task.S_CNTR_CODE) + .First(); + + if (cgDetail == null) { + info = $"鐗╂枡缂栫爜涓嶅瓨鍦紒"; + LogHelper.Info(info); + } + + var model = new OtherModel.CreateTaskReturnErpInfo { + jhdh = plan.JHDH , // 璁″垝鍗曞彿锛堝敮涓�爣璇嗭級 + ckzt = plan.CKZT , // 鍑哄簱鐘舵�锛堥渶瑕佽繑鍥烇級 + jhlb = plan.JHLB , // 璁″垝绫诲埆 + ckdh = plan.CKDH , // 鍙傝�鍗曞彿 + cph = plan.CPH , // 杞︾墝鍙�+ ysfs = plan.YSFS , // 杩愯緭鏂瑰紡 + cpzt = plan.CPZT , // 浜у搧鐘舵� + mddw = plan.MDDW , // 涔版柇鍗曚綅 + cpdm = plan.CPDM , // 浜у搧浠g爜 + cplb = plan.CPLB , // 浜у搧绫诲埆 + cplbmx = plan.CPLBMX , // 浜у搧绫诲埆鏄庣粏 + pp = plan.PP , // 鍝佺墝 + dj = plan.DJ , // 绛夌骇锛堥渶瑕佽繑鍥烇級 + gh = plan.GH , // 缃愬彿 + ph = plan.PH , // 鎵瑰彿锛堥渶瑕佽繑鍥烇級 + bzlx = plan.BZLX , // 鍖呰绫诲瀷 + pzdh = plan.PZDH , // 娲捐鍗曞彿 + pzd_dw = plan.PZD_DW , // 娲捐鍗曞崟浣�+ pzd_dybh = plan.PZD_DYBH , // 娲捐鍗曡皟杩愮紪鍙�+ pzjs = plan.PZJS , // 娲捐浠舵暟 + pzsl = plan.PZSL , // 娲捐鏁伴噺 + pz_rq = plan.PZ_RQ , // 娲捐鏃ユ湡(yyyy-mm-dd) + pz_czrq = plan.PZ_CZRQ , // 娲捐鎿嶄綔鏃ユ湡 + pz_zfbj = plan.PZ_ZFBJ , // 娲捐浣滃簾鏍囪 + pz_zfrq = plan.PZ_ZFRQ , // 娲捐浣滃簾鏃ユ湡 + pz_bz = plan.PZ_BZ , // 娲捐澶囨敞 + ckdbh = plan.CKDBH , // 鍑哄簱鍗曠紪鍙�+ //sfjs = plan.SFJS , // 瀹炲彂浠舵暟锛堥渶瑕佽繑鍥烇級 + //sfsl = plan.SFSL , // 瀹炲彂鏁伴噺锛堥渶瑕佽繑鍥烇級 + //sfcs = plan.SFCS , // 瀹炲彂杞︽暟锛堥渶瑕佽繑鍥烇級 + //zcsj = plan.ZCSJ , // 瑁呰溅鏃堕棿锛堥渶瑕佽繑鍥烇級 + //jldw = plan.JLDW , // 璁¢噺鍗曚綅锛堥渶瑕佽繑鍥烇級 + //fhrq = plan.FHRQ , // 鍙戣揣鏃ユ湡锛堥渶瑕佽繑鍥烇級 + //ckdm = plan.CKDM , // 浠撳簱浠g爜锛堥渶瑕佽繑鍥烇級 + //fhr = plan.FHR , // 鍙戣揣浜猴紙闇�杩斿洖锛�+ //czydm = plan.CZYDM , // 鎿嶄綔鍛橈紙闇�杩斿洖锛�+ shr_username = plan.SHR_USERNAME , // 瀹℃牳浜�+ shrq = plan.SHRQ , // 瀹℃牳鏃ユ湡 + zfbj = plan.ZFBJ , // 浣滃簾鏍囪 + zfrq = plan.ZFRQ , // 浣滃簾鏃ユ湡 + jsdw = plan.JSDW , // 缁撶畻鍗曚綅 + shdw = plan.SHDW , // 鏀惰揣鍗曚綅 + ysdw = plan.YSDW , // 杩愯緭鍗曚綅 + lxr = plan.LXR , // 鑱旂郴浜�+ //ry_zxg = plan.RY_ZXG , // 瑁呭嵏宸ワ紙闇�杩斿洖锛�+ //ry_ccsj = plan.RY_CCSJ , // 鍙夎溅鍙告満锛堥渶瑕佽繑鍥烇級 + erphx_jhdh = plan.ERPHX_JHDH , // erp浜よ揣鍗曞彿 + erphx_wlbm = plan.ERPHX_WLBM , // erp鐗╂枡缂栫爜 + erphx_wlmc = plan.ERPHX_WLMC , // erp鐗╂枡鍚嶇О + erphx_cjrq = plan.ERPHX_CJRQ , // erp鍒涘缓鏃ユ湡 + hw = plan.HW , // 璐т綅锛堥渶瑕佽繑鍥烇級 + hwzt = plan.HWZT // 璐т綅鐘舵�锛堥渶瑕佽繑鍥烇級 + }; + model.hw = task.S_START_LOC; + model.hwzt = "寰呭嚭搴�; + model.ph = cgDetail.S_BATCH_NO; + + var jsonInfo = JsonConvert.SerializeObject(model); + var result = httpH.WebPost(Settings.ErpApiUrl + "CreateTaskReturn", jsonInfo); + + LogHelper.InfoApi($"鍒涘缓浠诲姟瀹屾垚鍙嶉ERP鎺ュ彛锛岀粨鏋�{result}锛岃皟鐢ㄥ弬鏁帮細", model); + + plan.HW = model.hw; + plan.HWZT = model.hwzt; + plan.PH = model.ph; + var success = db.Updateable<TN_Outbound_Plan>(plan).UpdateColumns(p => new { p.HW, p.HWZT, p.PH }).ExecuteCommand() > 0; + info = "鏇存柊鍑哄簱璁″垝鍗曡褰曡〃" + (success ? "鎴愬姛" : "澶辫触"); + LogHelper.Info(info); + } + catch (Exception ex) { + LogHelper.InfoEx(ex); + } + } } } -- Gitblit v1.9.1