From c4bcf24d506bdcd2e2b78bca63f0fbf08c356a86 Mon Sep 17 00:00:00 2001 From: lss <Lss@HanInfo> Date: 星期三, 04 六月 2025 17:26:59 +0800 Subject: [PATCH] 合肥佳通优化 --- HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs | 1125 ++++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 692 insertions(+), 433 deletions(-) diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs index 9f1fc00..6a1287d 100644 --- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs +++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs @@ -11,8 +11,11 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection.Emit; +using System.ServiceModel; using System.Threading; using System.Threading.Tasks; +using System.Web.UI.WebControls; using static HH.WCS.JiaTong.api.ApiModel; using static HH.WCS.JiaTong.api.OtherModel; using static HH.WCS.JiaTong.LISTA.process.HttpModel; @@ -53,62 +56,61 @@ try { var db = new SqlHelper<object>().GetInstance(); + string CntrCode = "";//鎵樼洏缂栫爜 + string ItemCode = "";//鐗╂枡缂栫爜 + if (partData != null) + { + CntrCode = partData.rfid;//鎵樼洏缂栫爜 + ItemCode = partData.partNumber;//鐗╂枡缂栫爜 + } string Start = ""; //鍙栬揣鐐�- string CntrCode = partData.rfid;//鎵樼洏缂栫爜 - string ItemCode = partData.partNumber;//鐗╂枡缂栫爜 string End = ""; - string areacode = ""; string note = ""; //绔嬪簱涓嬪彂浠诲姟闇�閫氱煡mes鎺ュ彛鐗╂枡鍒颁綅锛岀敤澶囨敞鑷姩杩涜鍖哄垎 //鏍规嵁鐗╂枡鑾峰彇瀵瑰簲搴撳尯 - #region 鏍规嵁鐗╂枡纭鍑哄簱鏉ユ簮 - var iteminfo = db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE.Trim() == ItemCode).First(); - if (iteminfo != null) - { - //LogHelper.Info($"Createtask==>鐗╂枡鏁版嵁:{JsonConvert.SerializeObject(iteminfo)}"); - areacode = iteminfo.S_WH_CODE; - } - - if (string.IsNullOrEmpty(areacode)) - { - LogHelper.Info($"Createtask==>鏍规嵁鐗╂枡缂栫爜:{ItemCode}鏈兘鎵惧埌鐗╂枡鏉ユ簮锛岄渶鍚屾鐗╂枡鏁版嵁"); - result.code = "1"; - result.msg = $"鏍规嵁鐗╂枡缂栫爜:{ItemCode}鏈兘鎵惧埌鐗╂枡鏉ユ簮锛岄渶鍚屾鐗╂枡鏁版嵁"; - AddErrorInfo("瀵绘壘鍑哄簱鍖哄け璐�, result.msg); - return result; - } - //var task = db.Queryable<WCSTask>().Where(a => a.S_EQ_NO.Trim() == taskData.taskNum).First(); - //if (task != null) + #region 鏍规嵁浠诲姟鏉ユ簮瀛楁鍒ゆ柇搴撳尯鏉ユ簮鏉ユ簮 + //var iteminfo = db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE.Trim() == ItemCode).First(); + //if (iteminfo != null) //{ - // LogHelper.Info($"Createtask==> 浠诲姟鍙穥taskData.taskNum},璇ヤ换鍔″凡缁忓瓨鍦紝涓嶅厑璁稿垱寤轰换鍔�); + // //LogHelper.Info($"Createtask==>鐗╂枡鏁版嵁:{JsonConvert.SerializeObject(iteminfo)}"); + // areacode = iteminfo.S_WH_CODE; + //} + + //if (string.IsNullOrEmpty(areacode)) + //{ + // LogHelper.Info($"Createtask==>鏍规嵁鐗╂枡缂栫爜:{ItemCode}鏈兘鎵惧埌鐗╂枡鏉ユ簮锛岄渶鍚屾鐗╂枡鏁版嵁"); // result.code = "1"; - // result.msg = $"浠诲姟鍙穥taskData.taskNum},璇ヤ换鍔″凡缁忓瓨鍦紝涓嶅厑璁稿垱寤轰换鍔�; + // result.msg = $"鏍规嵁鐗╂枡缂栫爜:{ItemCode}鏈兘鎵惧埌鐗╂枡鏉ユ簮锛岄渶鍚屾鐗╂枡鏁版嵁"; + // AddErrorInfo("瀵绘壘鍑哄簱鍖哄け璐�, result.msg); // return result; //} - int n_type = 0; //浠诲姟鏉ユ簮 1.閽笣绔嬪簱 2.鑳剁墖搴� 3.棰勫搴�,4.鍘熸潗鏂欏簱,閫氳繃鐗╂枡纭浠诲姟鏉ユ簮 - switch (areacode) + int n_type = 0; //浠诲姟鏉ユ簮 1.瀵嗙偧绔嬪簱 3.棰勫搴�,4.鍘熸潗鏂欏簱 + string Source = ""; + switch (taskData.source) { case "ML": n_type = 1; - break; - case "JP": - n_type = 2; + Source = "瀵嗙偧"; break; case "YBK": n_type = 3; + Source = "棰勫搴�; break; - case "wmwhse1": + case "YCL": n_type = 4; + Source = "鍘熸潗鏂�; break; } - LogHelper.Info($"Createtask==>浠诲姟绫诲瀷:{n_type}"); + Console.WriteLine($"Createtask==>浠诲姟鏉ユ簮:{n_type}"); if (n_type == 0) { result.code = "1"; - result.msg = $"鐗╂枡搴撳尯:{areacode}灞炰簬鏈畾涔夊簱鍖猴紝璇锋鏌ョ墿鏂欒〃閲嶆柊瀹氫箟鐗╂枡搴撳尯"; - AddErrorInfo("鐗╂枡搴撳尯鏈畾涔�, result.msg); + result.msg = $"浠诲姟鏉ユ簮:{taskData.source}灞炰簬鏈畾涔夊簱鍖猴紝璇锋鏌ョ墿鏂欐潵婧愭槸鍚﹀睘浜庣害瀹氬瓧娈�; + AddErrorInfo("浠诲姟鏉ユ簮鏈畾涔�, result.msg); return result; } + + #endregion Location endloc = new Location(); @@ -122,7 +124,7 @@ { //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅 Start = taskData.pickStation; - if (CreateCntrIteminfo(Start, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade)) + if (CreateCntrIteminfo(partData, taskData)) { endloc = Computeloc(CntrCode, taskData.dropStation, taskData.carrierType); if (endloc != null) @@ -133,7 +135,7 @@ { result.code = "1"; result.msg = $"鏈哄彴缂栫爜:{taskData.dropStation}锛屾湭鎵惧埌鍙敤璐т綅"; - AddErrorInfo("瀵绘壘鍑哄簱璐т綅澶辫触", result.msg); + AddErrorInfo("瀵绘壘鍑哄簱璐т綅澶辫触", result.msg, Source); return result; } } @@ -141,20 +143,22 @@ { result.code = "1"; result.msg = "鍒涘缓鎵樼洏鐗╂枡淇℃伅澶辫触"; - AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg); + AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg, Source); return result; } } else { - LogHelper.Info($"Putin==> 浠诲姟璧风偣:{taskData.pickStation}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"); + result.code = "1"; result.msg = $"Putin==> 浠诲姟璧风偣:{taskData.pickStation}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; - AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg); + LogHelper.Info($"Putin==> {result.msg}"); + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); } } - else if (taskData.taskType == 2)//鍏ュ簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟 + else if (taskData.taskType == 2)//鍏ュ簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟锛岃捣鐐归渶瑕佹湁鎵樼洏 { + note = "鍏ュ簱"; startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); if (startloc != null) { @@ -168,11 +172,12 @@ { result.code = "1"; result.msg = $"鏍规嵁璧风偣{Start},鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�; - AddErrorInfo("鎵樼洏鏌ユ壘澶辫触", result.msg); + AddErrorInfo("鎵樼洏鏌ユ壘澶辫触", result.msg, Source); return result; } } + endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); if (endloc != null) { @@ -182,23 +187,37 @@ { result.code = "1"; result.msg = $"鏍规嵁缁堢偣{End},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; - AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg); + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); return result; } } else if (taskData.taskType == 3)//绉诲簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟锛� { + note = "鍑哄簱"; //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅 - startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); if (startloc != null) { Start = taskData.pickStation; } + else + { + result.code = "1"; + result.msg = $"鏍规嵁璧风偣{taskData.pickStation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); + return result; + } endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); if (endloc != null) { End = taskData.dropStation; + } + else + { + result.code = "1"; + result.msg = $"鏍规嵁缁堢偣{taskData.dropStation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); + return result; } } else if (taskData.taskType == 4)//鍘熸潗鏂欏簱闇�鍒ゆ柇鏄惁闇�鍒嗛厤鐢垫浠诲姟,鍒涘缓鍒嗘。浠诲姟 @@ -223,7 +242,7 @@ { result.code = "1"; result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐�{startloc.S_AREA_CODE},缁堢偣锛歿endloc.S_AREA_CODE}鏈壘鍒板搴斿簱鍖�; - AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg); + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); return result; } if (startArea.N_FLOOR == endArea.N_FLOOR) @@ -247,12 +266,14 @@ N_START_LAYER = 1, N_END_LAYER = 1, S_WMS_NO = taskData.wmsTaskNo, - Z_TYPE = n_type + Z_TYPE = n_type, + + }; LogHelper.Info("鍒涘缓浠诲姟锛� + JsonConvert.SerializeObject(wcsTask), "CreateTask"); if (WCSHelper.CreateTask(wcsTask)) { - LocationHelper.LockLoc(Start, 2); + LocationHelper.LockLoc(End, 2); LogHelper.Info("鍒涘缓浠诲姟鎴愬姛"); } @@ -260,60 +281,65 @@ else if (startArea.N_FLOOR != endArea.N_FLOOR) { //妤煎眰鐢垫鍒嗛厤 - var endloc1 = Settings.elevatorLoc.Find(a => a.Floor == startArea.N_FLOOR); - var startloc1 = Settings.elevatorLoc.Find(a => a.Floor == endArea.N_FLOOR); + var elevatorLoc = LocationHelper.GetElevatorLoc(); - //鍒涘缓wcs鍒嗘浠诲姟 - var wcsTask = new WCSTask - { - S_CODE = WCSHelper.GenerateTaskNo(), - S_TYPE = "鐢垫1", - S_EQ_NO = taskData.taskNum, - S_START_LOC = Start, - S_END_LOC = endloc1.Location[0], - N_CNTR_COUNT = 1, - S_START_WH = startloc.S_WH_CODE, - S_START_AREA = startloc.S_AREA_CODE, - S_END_WH = endloc.S_WH_CODE, - S_END_AREA = endloc.S_AREA_CODE, - N_SCHEDULE_TYPE = 1, - S_CNTR_CODE = CntrCode, - N_PRIORITY = taskData.priority, - N_START_LAYER = 1, - N_END_LAYER = 1, - S_WMS_NO = taskData.wmsTaskNo, - Z_TYPE = n_type - }; - var wcsTask1 = new WCSTask - { - S_CODE = WCSHelper.GenerateTaskNo(), - S_TYPE = "鐢垫2", - S_EQ_NO = taskData.taskNum, - S_START_LOC = startloc1.Location[0], - S_END_LOC = End, - N_CNTR_COUNT = 1, - S_START_WH = startloc.S_WH_CODE, - S_START_AREA = startloc.S_AREA_CODE, - S_END_WH = endloc.S_WH_CODE, - S_END_AREA = endloc.S_AREA_CODE, - N_SCHEDULE_TYPE = 1, - S_CNTR_CODE = CntrCode, - N_PRIORITY = taskData.priority, - S_WMS_NO = taskData.wmsTaskNo, - N_START_LAYER = 1, - N_END_LAYER = 1, - Z_TYPE = n_type + if (elevatorLoc != null) + { //鍒涘缓wcs鍒嗘浠诲姟 + var wcsTask = new WCSTask + { + S_CODE = WCSHelper.GenerateTaskNo(), + S_TYPE = "鐢垫1", + S_EQ_NO = taskData.taskNum, + S_START_LOC = Start, + S_END_LOC = elevatorLoc.S_CODE, + N_CNTR_COUNT = 1, + S_START_WH = startloc.S_WH_CODE, + S_START_AREA = startloc.S_AREA_CODE, + S_END_WH = elevatorLoc.S_WH_CODE, + S_END_AREA = elevatorLoc.S_AREA_CODE, + N_SCHEDULE_TYPE = 1, + S_CNTR_CODE = CntrCode, + N_PRIORITY = taskData.priority, + N_START_LAYER = 1, + N_END_LAYER = 1, + S_WMS_NO = taskData.wmsTaskNo, + Z_TYPE = n_type, + S_MES_NO = taskData.mesTaskNo + }; + var wcsTask1 = new WCSTask + { + S_CODE = WCSHelper.GenerateTaskNo(), + S_TYPE = "鐢垫2", + S_EQ_NO = taskData.taskNum, + S_START_LOC = elevatorLoc.S_CODE, + S_END_LOC = End, + N_CNTR_COUNT = 1, + S_START_WH = elevatorLoc.S_WH_CODE, + S_START_AREA = elevatorLoc.S_AREA_CODE, + S_END_WH = endloc.S_WH_CODE, + S_END_AREA = endloc.S_AREA_CODE, + N_SCHEDULE_TYPE = 1, + S_CNTR_CODE = CntrCode, + N_PRIORITY = taskData.priority, + S_WMS_NO = taskData.wmsTaskNo, + N_START_LAYER = 1, + N_END_LAYER = 1, + Z_TYPE = n_type, + S_MES_NO = taskData.mesTaskNo + }; + LogHelper.Info("鍒涘缓浠诲姟锛� + JsonConvert.SerializeObject(wcsTask), "CreateTask"); + if (WCSHelper.CreateTask(wcsTask) && WCSHelper.CreateTask(wcsTask1)) + { - }; - - LogHelper.Info("鍒涘缓浠诲姟锛� + JsonConvert.SerializeObject(wcsTask), "CreateTask"); - if (WCSHelper.CreateTask(wcsTask) && WCSHelper.CreateTask(wcsTask1)) - { - - LocationHelper.LockLoc(endloc.S_CODE, 1); - LogHelper.Info("鍒涘缓浠诲姟鎴愬姛"); + // LocationHelper.LockLoc(Start, 1); + LocationHelper.LockLoc(End, 2); + LogHelper.Info("鍒涘缓浠诲姟鎴愬姛"); + } } + + + } } else @@ -323,27 +349,42 @@ return result; } } - else if (taskData.taskType == 5)//绉诲簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟锛�+ else if (taskData.taskType == 5)//绉诲簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟锛屽苟缁戝畾鎵樼洏 { + note = "鍑哄簱"; //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅 - if (CreateCntrIteminfo(taskData.pickStation, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade)) + if (CreateCntrIteminfo(partData, taskData)) { startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); if (startloc != null) { Start = taskData.pickStation; } + else + { + result.code = "1"; + result.msg = $"鏍规嵁璧风偣{taskData.pickStation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); + return result; + } endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); if (endloc != null) { End = taskData.dropStation; + } + else + { + result.code = "1"; + result.msg = $"鏍规嵁缁堢偣{taskData.dropStation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); + return result; } } else { result.code = "1"; result.msg = "鍒涘缓鎵樼洏鐗╂枡淇℃伅澶辫触"; - AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg); + AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg, Source); return result; } @@ -351,6 +392,7 @@ //鏆傚瓨浣嶅洖搴� else if (taskData.taskType == 6)//鍏ュ簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟 { + note = "鍏ュ簱"; //鏍规嵁鎵樼洏鍙锋壘璐т綅 var CntrRel = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == partData.rfid).First(); if (CntrRel != null) @@ -365,7 +407,7 @@ { result.code = "1"; result.msg = $"鏍规嵁鎵樼洏{partData.rfid},鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�; - AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg); + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); return result; } } @@ -378,7 +420,7 @@ { result.code = "1"; result.msg = $"鏍规嵁缁堢偣{End},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; - AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg); + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); return result; } } @@ -387,7 +429,7 @@ { note = "寮傚父搴撳尯鍏ュ簱"; //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅 - if (CreateCntrIteminfo(taskData.pickStation, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade)) + if (CreateCntrIteminfo(partData, taskData)) { startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); if (startloc != null) @@ -406,7 +448,7 @@ { result.code = "1"; result.msg = $"缁堢偣搴撳尯锛歿taskData.dropStation}鏃犲彲鐢ㄨ揣浣�; - AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); return result; } @@ -415,7 +457,7 @@ { result.code = "1"; result.msg = $"鏍规嵁缁堢偣搴撳尯锛歿taskData.dropStation},鏈壘鍒板搴旇揣浣�; - AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); return result; } } @@ -423,7 +465,35 @@ { result.code = "1"; result.msg = "鍒涘缓鎵樼洏鐗╂枡淇℃伅澶辫触"; - AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg); + AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg, Source); + return result; + } + } + else if (taskData.taskType == 8)//鍙犵洏鏈虹┖鎵樺洖搴�+ { + note = "绌烘墭鍥炲簱";//浜曟澗绌烘墭鍥炲簱锛岄渶瑕佷笌鍙犵洏鏈哄畨鍏ㄤ氦浜�+ startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); + if (startloc != null) + { + Start = startloc.S_CODE; + } + else + { + result.code = "1"; + result.msg = $"鏍规嵁璧风偣:{taskData.pickStation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); + return result; + } + endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); + if (endloc != null) + { + End = taskData.dropStation; + } + else + { + result.code = "1"; + result.msg = $"鏍规嵁缁堢偣:{End},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); return result; } } @@ -432,7 +502,7 @@ LogHelper.Info($"Createtask==> 浠诲姟绫诲瀷鏈夎"); result.code = "1"; result.msg = "浠诲姟绫诲瀷锛歿taskData.taskType}涓嶅湪瑙勫畾鑼冨洿鍐�; - AddErrorInfo("浠诲姟绫诲瀷閿欒", result.msg); + AddErrorInfo("浠诲姟绫诲瀷閿欒", result.msg, Source); } if (taskData.taskType != 4) { @@ -475,7 +545,8 @@ N_START_LAYER = 1, N_END_LAYER = 1, S_WMS_NO = taskData.wmsTaskNo, - S_NOTE = note + S_NOTE = note, + S_MES_NO = taskData.mesTaskNo }; LogHelper.Info("鍒涘缓浠诲姟锛� + JsonConvert.SerializeObject(wcsTask), "CreateTask"); @@ -566,7 +637,7 @@ LogHelper.Info($"AllowThrough==> 鍙傛暟涓簄ull"); result.code = "1"; result.msg = "鍙傛暟涓簄ull鍊硷紝璇锋鏌ュ弬鏁版牸寮�; - AddErrorInfo("鍙傛暟涓虹┖", result.msg); + AddErrorInfo("鍙傛暟涓虹┖", result.msg, "", model.task_no); return result; } @@ -588,7 +659,7 @@ { result.code = "1"; result.msg = $"鏍规嵁涓嬪彂浠诲姟鍙穥model.task_no}鏈壘鍒板搴斾换鍔�; - AddErrorInfo("鏈壘鍒颁换鍔�, result.msg); + AddErrorInfo("鏈壘鍒颁换鍔�, result.msg, "", model.task_no); return result; } return result; @@ -621,7 +692,7 @@ try { //鍒涘缓鎵樼洏鏁版嵁缁戝畾鍏崇郴 - if (ContainerHelper.CreateCntrItem(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight)) + if (ContainerHelper.CreateCntrItem(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight, model.Qty, model.ProductionTime, model.MaturityTime)) { //鍒涘缓鎴愬姛娴佺▼ } @@ -629,7 +700,7 @@ { result.code = "1"; result.msg = "浜у嚭淇℃伅涓嬪彂澶辫触锛屾墭鐩樼墿鏂欑粦瀹氬叧绯诲垱寤哄け璐�; - AddErrorInfo("鍒涘缓缁戝畾鍏崇郴澶辫触", result.msg); + AddErrorInfo("鍒涘缓缁戝畾鍏崇郴澶辫触", result.msg, "Mes"); return result; } return result; @@ -654,40 +725,61 @@ internal static Result Putin(Putin model, int n_type) { Result result = new Result() { code = "200", msg = "鍏ュ钩搴撲换鍔′笅鍙戞垚鍔� }; + string Source = "Mes"; + if (n_type == 0) + { + Source = "PDA"; + } if (model == null) { result.code = "1"; result.msg = "鍙傛暟涓簄ull"; - AddErrorInfo("鍙傛暟涓虹┖", result.msg); + AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source); return result; } var db = new SqlHelper<object>().GetInstance(); Location loc = new Location(); + string Start = model.InitialLocation; //璧风偣璐т綅 string itemcode = model.PartNumber; //鐗╂枡缂栫爜 string areacode = ""; try { - #region 鍒ゆ柇鎵樼洏缁戝畾璐т綅鏄惁鍜屼笅鍙戠粦瀹氳捣鐐圭浉鍚�+ + #region 鍏ュ簱妫�煡鎵樼洏鐗╂枡琛ㄦ湁鏃犳暟鎹�+ var cntritem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); + if (cntritem == null) + { + result.code = "1"; + result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}鏃犵粦瀹氱墿鏂欐暟鎹�; + LogHelper.Info($"ItemBack锛歿result.msg}"); + AddErrorInfo("鎵樼洏缁戝畾鐗╂枡鏁版嵁涓虹┖", result.msg, Source); + return result; + } + #endregion + + #region 鍒ゆ柇鎵樼洏缁戝畾璐т綅鏄惁鍜屼笅鍙戠粦瀹氳捣鐐圭浉鍚�濡傛灉娌$粦瀹氭墭鐩樺垯缁戝畾鎵樼洏 var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); if (CntrLoc != null) { if (CntrLoc.S_LOC_CODE != Start) { - LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}"); + result.code = "1"; result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}"; - AddErrorInfo("鎵樼洏缁戝畾浣嶇疆涓嶅悓", result.msg); + LogHelper.Info($"ItemBack锛歿result.msg}"); + AddErrorInfo("鎵樼洏缁戝畾浣嶇疆涓嶅悓", result.msg, Source); return result; } } else { - LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�); - result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�; - AddErrorInfo("鏌ユ壘鎵樼洏璐т綅澶辫触", result.msg); - return result; + LocationHelper.BindingLoc(Start, new List<string> { model.Rfid }); + //LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�); + //result.code = "1"; + //result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�; + //AddErrorInfo("鏌ユ壘鎵樼洏璐т綅澶辫触", result.msg); + //return result; } // Console.WriteLine("鏌ヨ璐т綅缁戝畾鍏崇郴"); //鍒ゆ柇鎵樼洏涓庤揣浣嶆槸鍚︽湁缁戝畾鍏崇郴锛屽鏋滄病鏈夊垯杩涜缁戝畾 @@ -714,48 +806,55 @@ //} #endregion - #region 鏍规嵁璧风偣璐т綅鐨勪粨搴撶紪鐮�鑾峰彇骞冲簱缂栫爜,骞惰绠楀叆搴撹揣浣� string End = ""; var startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == Start).First(); if (startloc != null) { //鏍规嵁浠撳簱 璁$畻搴撳尯 - if (startloc.S_WH_CODE == "101") + var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault(); + if (whcode != null) { - areacode = "PMGQ"; + areacode = whcode.PMK; } else { - areacode = "PK2"; + result.code = "1"; + result.msg = $"鏍规嵁璧风偣浠撳簱缂栫爜锛歿startloc.S_WH_CODE}鏈壘鍒板搴旈厤缃枃浠�; + LogHelper.Info($"Putin==> {result.msg}"); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); + return result; } - areacode = "FLPK"; //鍒ゆ柇鏈夋棤鐩稿悓鐗╂枡鎺� loc = StorageCompute(itemcode, areacode); - if (loc == null) - { - //鏃犵浉鍚岀墿鏂欐帓鎵剧┖鎺�- loc = emptyRow(areacode); - } + //if (loc == null) + //{ + // //鏃犵浉鍚岀墿鏂欐帓鎵剧┖鎺�+ // loc = emptyRow(areacode); + //} if (loc != null) { End = loc.S_CODE; } else { - LogHelper.Info($"Putin==>搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�); + result.code = "1"; result.msg = $"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�; - AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg); + LogHelper.Info($"Putin==> {result.msg}"); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); + return result; } } else { - LogHelper.Info($"Putin==> 浠诲姟璧风偣:{Start}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"); + result.code = "1"; result.msg = $"浠诲姟璧风偣:{Start}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; - AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg); + LogHelper.Info($"Putin==> {result.msg}"); + AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source); + return result; } #endregion @@ -766,7 +865,7 @@ { result.code = "1"; result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐�{Start}鏈夐攣"; - AddErrorInfo("璐т綅鏈夐攣", result.msg); + AddErrorInfo("璐т綅鏈夐攣", result.msg, Source); return result; } //鍒涘缓wcs浠诲姟 @@ -803,6 +902,7 @@ return result; } #endregion + return result; } catch (Exception ex) @@ -812,7 +912,6 @@ LogHelper.Error("Putin Error锛� + ex.ToString(), ex); return result; } - } /// <summary> @@ -824,11 +923,16 @@ internal static Result PutOut(PutOut model, int n_type) { Result result = new Result() { code = "200", msg = "鍑哄钩搴撲换鍔′笅鍙戞垚鍔� }; + string Source = "Mes"; + if (n_type == 0) + { + Source = "PDA"; + } if (model == null) { result.code = "1"; result.msg = "鍙傛暟涓簄ull"; - AddErrorInfo("鍙傛暟涓虹┖", result.msg); + AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source); return result; } @@ -836,6 +940,7 @@ string Start = ""; string End = ""; string CntrCode = ""; + string itemcode = model.PartNumber; string cntrType = ""; string areacode = ""; @@ -847,46 +952,50 @@ #region 鏍规嵁鐗╂枡缂栫爜瑙勫垯 璁$畻鍑哄簱搴撳尯 //绮夋枡浠庡钩搴撳嚭搴擄紝鍏朵粬鐗╂枡闇�浠庢殏瀛樺尯鍑哄簱 - if (model.PartNumber.StartsWith("4X")) + var locJt = db.Queryable<Location>().Where(a => a.S_AREA_CODE == model.WorkCenter).First(); + if (locJt == null) { - areacode = "FLPK"; - cntrType = "PM"; + result.code = "1"; + result.msg = $"鏍规嵁鏈哄彴缂栫爜锛歿model.WorkCenter}鏈壘鍒板搴旇揣浣�; + LogHelper.Info($"Putin==> {result.msg}"); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); + return result; } - else + //鏍规嵁浠撳簱 璁$畻搴撳尯 + var whcode = Settings.wareLoc.Where(a => a.AreaCode == locJt.S_WH_CODE).FirstOrDefault(); + if (whcode != null) { - - if (model.PartNumber.StartsWith("3")) + if (model.PartNumber.StartsWith("4X")) { - cntrType = "RC"; - areacode = "KJZCW"; + areacode = whcode.PMK; + cntrType = "PM"; } else { - LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鐗╂枡鍙穥model.PartNumber}涓嶅睘浜庤瀹氱墿鏂�); - result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛岀墿鏂欏彿{model.PartNumber}涓嶅睘浜庤瀹氱墿鏂�; - AddErrorInfo("鐗╂枡缂栫爜鏍煎紡閿欒", result.msg); - return result; + if (model.PartNumber.StartsWith("3")) + { + cntrType = "RC"; + areacode = whcode.ZCW; + } + else + { + + result.code = "1"; + result.msg = $"鍒涘缓浠诲姟澶辫触锛岀墿鏂欏彿{model.PartNumber}涓嶅睘浜庤瀹氱墿鏂�; + LogHelper.Info($"ItemBack锛歿result.msg}"); + AddErrorInfo("鐗╂枡缂栫爜鏍煎紡閿欒", result.msg, Source); + return result; + } } } - //鏍规嵁鐗╂枡鑾峰彇瀵瑰簲搴撳尯 - // var iteminfo = db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE.Trim() == itemcode).First(); - //if (iteminfo != null) - //{ - // areacode = iteminfo.S_WH_CODE; - //} - //areacode = computeArea(itemcode); - //if (string.IsNullOrEmpty(areacode)) - //{ - // LogHelper.Info($"PutOut==> 鏍规嵁鐗╂枡缂栫爜:{itemcode}鎵句笉鍒板搴斿簱鍖猴紝璇锋鏌ラ厤缃枃浠�); - // result.code = "1"; - // result.msg = $"鏍规嵁鐗╂枡缂栫爜:{itemcode}鎵句笉鍒板搴斿簱鍖猴紝鐗╂枡琛ㄩ厤缃�; - // AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg); - //} - //if (itemcode == "娴嬭瘯1") - //{ - // areacode = "PMJP"; - //} + else + { + result.code = "1"; + result.msg = $"鏍规嵁缁堢偣搴撳尯浠撳簱缂栫爜锛歿locJt.S_WH_CODE}鏈壘鍒板搴旈厤缃枃浠�; + LogHelper.Info($"Putin==> {result.msg}"); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); + return result; + } #endregion #region 鏍规嵁鐗╂枡缂栫爜璁$畻鍑哄簱璐т綅锛岄�寰�嚎杈逛綅缃�@@ -904,13 +1013,23 @@ { End = Endloc.S_CODE; } + else + { + result.code = "1"; + result.msg = $"Computeloc==銆嬫牴鎹満鍙扮紪鐮侊細{model.WorkCenter},宸ヨ绫诲瀷锛歿cntrType} 鏈壘鍒扮┖璐т綅鏁版嵁锛岃妫�煡璐т綅琛�; + LogHelper.Info($"ItemBack锛歿result.msg}"); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); + return result; + } } else { - LogHelper.Info($"PutOut==> 浠诲姟鐗╂枡:{itemcode}鎵句笉鍒板搴斿簱瀛�); + result.code = "1"; result.msg = $"浠诲姟鐗╂枡:{itemcode}鎵句笉鍒板搴斿簱瀛�; - AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg); + LogHelper.Info($"ItemBack锛歿result.msg}"); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); + return result; } #endregion @@ -921,7 +1040,7 @@ { result.code = "1"; result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐箋Start}鏈夐攣"; - AddErrorInfo("璐т綅鏈夐攣", result.msg); + AddErrorInfo("璐т綅鏈夐攣", result.msg, Source); return result; } //鍒涘缓wcs浠诲姟 @@ -979,11 +1098,12 @@ internal static Result Empty(Empty model) { Result result = new Result() { code = "200", msg = "绌哄伐瑁呭洖搴撲换鍔′笅鍙戞垚鍔� }; + string Source = "MES"; if (model == null) { result.code = "1"; result.msg = "鍙傛暟涓簄ull"; - AddErrorInfo("鍙傛暟涓虹┖", result.msg); + AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source); return result; } @@ -1001,26 +1121,26 @@ try { #region 鍒ゆ柇鎵樼洏缁戝畾璐т綅鏄惁鍜屼笅鍙戠粦瀹氳捣鐐圭浉鍚�- var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); - if (CntrLoc != null) - { - if (CntrLoc.S_LOC_CODE != Start) - { - LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}"); - result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}"; - AddErrorInfo("鎵樼洏缁戝畾浣嶇疆涓嶅悓", result.msg); - return result; - } - } - else - { - LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�); - result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�; - AddErrorInfo("鏌ユ壘鎵樼洏璐т綅澶辫触", result.msg); - return result; - } + //var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); + //if (CntrLoc != null) + //{ + // if (CntrLoc.S_LOC_CODE != Start) + // { + // LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}"); + // result.code = "1"; + // result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}"; + // AddErrorInfo("鎵樼洏缁戝畾浣嶇疆涓嶅悓", result.msg); + // return result; + // } + //} + //else + //{ + // LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�); + // result.code = "1"; + // result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�; + // AddErrorInfo("鏌ユ壘鎵樼洏璐т綅澶辫触", result.msg); + // return result; + //} #endregion #region 鏍规嵁璐т綅妤煎眰鍒ゆ柇锛�妤煎幓寰�彔鐩樹綅 鍏朵粬鐨勫洖搴�@@ -1033,13 +1153,13 @@ var dploc = db.Queryable<Location>().Where(a => a.S_NOTE.Trim() == "鍙犵洏" && a.N_LAYER == startloc.N_LAYER && a.S_WH_CODE.Trim() == startloc.S_WH_CODE).ToList(); if (dploc.Count > 0) { - // LogHelper.Info($"鑾峰彇鍙犵洏璐т綅:{JsonConvert.SerializeObject(dploc)}"); + // LogHelper.Info($"鑾峰彇鍙犵洏璐т綅:{JsonConvert.SerializeObject(dploc)}"); loc = dploc.FindAll(a => a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM < 6).OrderByDescending(a => a.N_CURRENT_NUM).FirstOrDefault(); if (loc == null) { result.code = "1"; result.msg = $"鍙犵洏璐т綅涓嶅彲鐢�; - AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); return result; } else @@ -1049,14 +1169,15 @@ } else { - LogHelper.Info($"鏍规嵁璐т綅澶囨敞锛氬彔鐩橈紝璐т綅妤煎眰:{startloc.N_LAYER},璐т綅浠撳簱:{startloc.S_WH_CODE}锛屾壘涓嶅埌鍙犵洏璐т綅"); + result.code = "1"; result.msg = $"鍙犵洏璐т綅涓嶅彲鐢�; - AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg); + LogHelper.Info($"鏍规嵁璐т綅澶囨敞锛氬彔鐩橈紝璐т綅妤煎眰:{startloc.N_LAYER},璐т綅浠撳簱:{startloc.S_WH_CODE}锛屾壘涓嶅埌鍙犵洏璐т綅"); + AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source); return result; } } - else if (startloc.S_NOTE == "PM") + else if (startloc.S_NOTE == "PB") { //鎵惧潡鑳跺爢鍙犲尯 var KjDploc = db.Queryable<Location>().Where(a => a.S_NOTE.Trim() == "鐗囪兌鍫嗗彔浣� && a.S_WH_CODE.Trim() == startloc.S_WH_CODE).ToList(); @@ -1067,7 +1188,7 @@ { result.code = "1"; result.msg = $"鍙犵洏璐т綅涓嶅彲鐢�; - AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); return result; } else @@ -1080,80 +1201,72 @@ LogHelper.Info($"鏍规嵁璐т綅澶囨敞锛氱墖鑳跺爢鍙犱綅,璐т綅浠撳簱:{startloc.S_WH_CODE}锛屾壘涓嶅埌鍙犵洏璐т綅"); result.code = "1"; result.msg = $"鍙犵洏璐т綅涓嶅彲鐢�; - AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg); + AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source); return result; } } else { - #region 鏍规嵁鎵樼洏鎵惧懠鍙┖鎵樹换鍔★紝骞惰幏寰楀嚭搴撳簱鍖�- msts = WCSHelper.GetTaskBycntrcode(model.Rfid.Trim()); - if (msts.Count() > 0) + #region 鏍规嵁璧风偣璐т綅绫诲瀷锛岃幏寰楀洖搴撳簱鍖�+ //鏍规嵁浠撳簱 璁$畻搴撳尯 + var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault(); + if (whcode != null) { - msts.RemoveAll(a => string.IsNullOrEmpty(a.S_CNTR_CODE)); - mst = msts.OrderByDescending(a => a.T_CREATE).FirstOrDefault(); - } - if (mst != null) - { - LogHelper.Info($"鎵惧埌鍑哄簱浠诲姟锛歿JsonConvert.SerializeObject(mst)}"); - areacode = mst.S_START_AREA; + if ( string.IsNullOrEmpty(startloc.S_NOTE)) + { + areacode = whcode.PMK; + } } else { - LogHelper.Info($"鍒涘缓浠诲姟澶辫触锛屾牴鎹墭鐩樼紪鐮亄model.Rfid}鏈壘鍒版墭鐩樺嚭搴撲换鍔�); result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛屾牴鎹墭鐩樼紪鐮亄model.Rfid}鏈壘鍒版墭鐩樺嚭搴撲换鍔�; - AddErrorInfo("鏌ユ壘浠诲姟澶辫触", result.msg); - return result; - } - if (string.IsNullOrEmpty(areacode)) - { - LogHelper.Info($"鍒涘缓浠诲姟澶辫触锛屾牴鎹墭鐩樼紪鐮亄model.Rfid}鎵惧埌鍑哄簱浠诲姟{mst.S_CODE}鐨勮捣鐐瑰簱鍖轰负绌�); - result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛屾牴鎹墭鐩樼紪鐮亄model.Rfid}鎵惧埌鍑哄簱浠诲姟{mst.S_CODE}鐨勮捣鐐瑰簱鍖轰负绌�; - AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg); + result.msg = $"鏍规嵁璧风偣浠撳簱缂栫爜锛歿startloc.S_WH_CODE}鏈壘鍒板搴旈厤缃枃浠�; + LogHelper.Info($"Putin==> {result.msg}"); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); return result; } #endregion //鍥炲簱璐т綅璁$畻搴撳尯璐т綅 loc = StorageCompute(itemcode, areacode); - if (loc == null) - { - loc = emptyRow(areacode); - if (loc == null) - { - LogHelper.Info($"搴撳尯锛歿areacode}娌℃湁绌烘帓"); - } - } - else - { - LogHelper.Info($"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�); - result.code = "1"; - result.msg = $"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�; - AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg); - return result; - } + //if (loc == null) + //{ + // loc = emptyRow(areacode); + // if (loc == null) + // { + // LogHelper.Info($"搴撳尯锛歿areacode}娌℃湁绌烘帓"); + // } + //} + //else + //{ + + // result.code = "1"; + // result.msg = $"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�; + // LogHelper.Info($"{result.msg}"); + // AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source); + // return result; + //} } } else { - LogHelper.Info($"Empty==> 浠诲姟璧风偣:{Start}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"); + result.code = "1"; result.msg = $"Empty==> 浠诲姟璧风偣:{Start}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; - AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg); + LogHelper.Info($"{result.msg}"); + AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source); return result; } #endregion #region 鍒涘缓浠诲姟 - if (!string.IsNullOrEmpty(Start) && loc != null) + if (startloc != null && loc != null) { - if (startloc.N_LOCK_STATE != 0) + if (startloc.N_LOCK_STATE != 0 && loc.N_LOCK_STATE != 0) { result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐箋Start}鏈夐攣"; + result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐硅揣浣嶇姸鎬亄startloc.N_LOCK_STATE},璧风偣璐т綅鐘舵�锛歿loc.N_LOCK_STATE}"; AddErrorInfo("璐т綅鏈夐攣", result.msg); return result; } @@ -1163,7 +1276,7 @@ S_CODE = WCSHelper.GenerateTaskNo(), S_TYPE = "绌哄伐瑁呭洖搴�, S_EQ_NO = model.TaskNumber, - S_START_LOC = Start, + S_START_LOC = startloc.S_CODE, S_END_LOC = loc.S_CODE, S_START_WH = startloc.S_WH_CODE, S_START_AREA = startloc.S_AREA_CODE, @@ -1179,7 +1292,7 @@ LogHelper.Info("鍒涘缓鍑哄钩搴撲换鍔★細" + JsonConvert.SerializeObject(wcsTask)); if (WCSHelper.CreateTask(wcsTask)) { - LocationHelper.LockLoc(Start, 2); + LocationHelper.LockLoc(startloc.S_CODE, 2); LocationHelper.LockLoc(loc.S_CODE, 1); // 绌烘墭鍥炲簱鍒ゆ柇鎵樼洏鏈夋棤缁戝畾鐗╂枡淇℃伅 濡傛灉鏈夊垯鍒犻櫎 var itemcntr = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); @@ -1215,11 +1328,12 @@ { var db = new SqlHelper<object>().GetInstance(); Result result = new Result() { code = "200", msg = "绌哄伐瑁呭懠鍙换鍔′笅鍙戞垚鍔� }; + string Source = "MES"; if (model == null) { result.code = "1"; result.msg = "鍙傛暟涓簄ull"; - AddErrorInfo("鍙傛暟涓虹┖", result.msg); + AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source); return result; } @@ -1236,21 +1350,27 @@ { #region 鏍规嵁浠撳簱缂栫爜鍒ゆ柇搴撳尯 骞惰绠楀嚭搴撹揣浣� var endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == End).First(); + //鏍规嵁浠撳簱 璁$畻搴撳尯 + if (endloc != null) { - if (endloc.S_WH_CODE == "101") + var whcode = Settings.wareLoc.Where(a => a.AreaCode == endloc.S_WH_CODE).FirstOrDefault(); + if (whcode != null) { - // itemcode = "TP"; - areacode = "PMGQ"; + areacode = whcode.PMK; } else { - //itemcode = "TP"; - areacode = "PK2"; + result.code = "1"; + result.msg = $"鏍规嵁璧风偣浠撳簱缂栫爜锛歿endloc.S_WH_CODE}鏈壘鍒板搴旈厤缃枃浠�; + LogHelper.Info($"Putin==> {result.msg}"); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); + return result; } - areacode = "FLPK"; + + //璁$畻鍑哄簱鎵樼洏 - startloc = airlift(areacode, itemcode); + startloc = LocationHelper.GetLocByAreacode(areacode); if (startloc != null) { var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == startloc.S_CODE).First(); @@ -1261,10 +1381,10 @@ } else { - LogHelper.Info($"callfixture:鍒涘缓绌哄伐瑁呭懠鍙换鍔�=>鏍规嵁璐т綅{endloc.S_CODE}鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�); result.code = "1"; result.msg = $"鍒涘缓绌哄伐瑁呭懠鍙换鍔�=>鏍规嵁璐т綅{endloc.S_CODE}鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�; - AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg); + LogHelper.Info($"callfixture:{result.msg}"); + AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg, Source); return result; } @@ -1273,11 +1393,12 @@ } else { - LogHelper.Info($"callfixture==> 浠诲姟璧风偣:{End}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"); + result.code = "1"; result.msg = $"浠诲姟璧风偣:{End}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; - AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg); - + LogHelper.Info($"callfixture:{result.msg}"); + AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source); + return result; } #endregion @@ -1311,7 +1432,7 @@ Z_TYPE = 5 }; - LogHelper.Info("鍒涘缓鍑哄钩搴撲换鍔★細" + JsonConvert.SerializeObject(wcsTask)); + LogHelper.Info("鍒涘缓鍛煎彨绌烘墭浠诲姟锛� + JsonConvert.SerializeObject(wcsTask)); if (WCSHelper.CreateTask(wcsTask)) { LocationHelper.LockLoc(Start, 2); @@ -1349,11 +1470,12 @@ internal static Result ItemBack(ItemBack model) { Result result = new Result() { code = "200", msg = "浣欐枡杩斿洖浠诲姟涓嬪彂鎴愬姛" }; + string Source = "MES"; if (model == null) { result.code = "1"; result.msg = "鍙傛暟涓簄ull"; - AddErrorInfo("鍙傛暟涓虹┖", result.msg); + AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source); return result; } @@ -1371,29 +1493,6 @@ try { - #region 鍒ゆ柇鎵樼洏缁戝畾璐т綅鏄惁鍜屼笅鍙戠粦瀹氳捣鐐圭浉鍚�- var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); - if (CntrLoc != null) - { - if (CntrLoc.S_LOC_CODE != Start) - { - LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}"); - result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}"; - AddErrorInfo("鎵樼洏缁戝畾浣嶇疆涓嶅悓", result.msg); - return result; - } - } - else - { - LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�); - result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�; - AddErrorInfo("鏌ユ壘鎵樼洏璐т綅澶辫触", result.msg); - return result; - } - #endregion - #region 浣欐枡杩斿洖鏍规嵁鎵樼洏鎵惧嚭搴撲换鍔� //浣欐枡杩斿洖鏍规嵁鎵樼洏鎵惧嚭搴撲换鍔� //msts = WCSHelper.GetTaskBycntrcode(model.Rfid); @@ -1427,79 +1526,113 @@ var startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == Start).First(); if (startloc != null) { - //绮夋枡鐩存帴鍥炲簱锛屽叾浠栫墿鏂欓渶瑕佸幓瀵瑰簲鐨勬殏瀛樺尯 - if (model.PartNumber.StartsWith("4X")) + var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault(); + if (whcode != null) { - areacode = "FLPK"; - loc = StorageCompute(itemcode, areacode); - if (loc == null) + //绮夋枡鐩存帴鍥炲簱锛屽叾浠栫墿鏂欓渶瑕佸幓瀵瑰簲鐨勬殏瀛樺尯 + #region 鏍规嵁鐗╂枡鍒ゆ柇鍥炲簱搴撳尯 + if (model.PartNumber.StartsWith("4X")) { - loc = emptyRow(areacode); - } - } - else - { - if (model.PartNumber.StartsWith("3")) - { - areacode = "KJYLZCW"; + areacode = whcode.PMK; + //loc = StorageCompute(itemcode, areacode); + //if (loc == null) + //{ + // loc = emptyRow(areacode); + //} } else { - LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鐗╂枡鍙穥model.PartNumber}涓嶅睘浜庤瀹氱墿鏂�); - result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛岀墿鏂欏彿{model.PartNumber}涓嶅睘浜庤瀹氱墿鏂�; - AddErrorInfo("鐗╂枡缂栫爜鏍煎紡閿欒", result.msg); - return result; - } - var EndLocs = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == areacode).ToList(); - if (EndLocs.Count > 0) - { - loc = EndLocs.Find(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0); - if (loc != null) + #region 鍒ゆ柇鎵樼洏缁戝畾璐т綅鏄惁鍜屼笅鍙戠粦瀹氳捣鐐圭浉鍚�+ var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); + if (CntrLoc != null) { - End = loc.S_CODE; + if (CntrLoc.S_LOC_CODE != Start) + { + + result.code = "1"; + result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}"; + LogHelper.Info($"ItemBack锛歿result.msg}"); + AddErrorInfo("鎵樼洏缁戝畾浣嶇疆涓嶅悓", result.msg, Source); + return result; + } } else { + result.code = "1"; - result.msg = $"缁堢偣搴撳尯锛歿areacode}鏃犲彲鐢ㄨ揣浣�; - AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg); + result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�; + LogHelper.Info($"ItemBack锛歿result.msg}"); + AddErrorInfo("鏌ユ壘鎵樼洏璐т綅澶辫触", result.msg, Source); return result; } + #endregion + + if (model.PartNumber.StartsWith("3")) + { + areacode = whcode.ZCW; + } + else + { + + result.code = "1"; + result.msg = $"鍒涘缓浠诲姟澶辫触锛岀墿鏂欏彿{model.PartNumber}涓嶅睘浜庤瀹氱墿鏂�; + LogHelper.Info($"ItemBack锛歿result.msg}"); + AddErrorInfo("鐗╂枡缂栫爜鏍煎紡閿欒", result.msg, Source); + return result; + } + + + } + #endregion + + + var EndLocs = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == areacode).ToList(); + //鏌ユ壘璐т綅搴撳尯 + if (EndLocs.Count > 0) + { + //loc = EndLocs.Find(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0); + loc = FindEndcolByLocList(EndLocs); + } else { result.code = "1"; result.msg = $"鏍规嵁缁堢偣搴撳尯锛歿areacode},鏈壘鍒板搴旇揣浣�; - AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); return result; } - //loc = StorageCompute(itemcode, areacode); - //if (loc == null) - //{ - // loc = emptyRow(areacode); - //} - } - if (loc != null) - { - End = loc.S_CODE; + + if (loc != null) + { + End = loc.S_CODE; + } + else + { + result.code = "1"; + result.msg = $"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�; + AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source); + return result; + } + } else { - LogHelper.Info($"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�); + result.code = "1"; - result.msg = $"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�; - AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg); + result.msg = $"鏍规嵁璧风偣浠撳簱缂栫爜锛歿startloc.S_WH_CODE}鏈壘鍒板搴旈厤缃枃浠�; + LogHelper.Info($"Putin==> {result.msg}"); + AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source); return result; } + } else { - LogHelper.Info($"璐т綅:{Start}鎵句笉鍒板搴旇揣浣�); + result.code = "1"; result.msg = $"璐т綅:{Start}鎵句笉鍒板搴旇揣浣�; - AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg); + AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source); return result; } @@ -1589,11 +1722,12 @@ msg = "绾胯竟搴撳瓨鏌ヨ鎴愬姛" }; + string Source = "MES"; if (model == null) { result.code = "1"; result.msg = "鍙傛暟涓簄ull"; - AddErrorInfo("鍙傛暟涓虹┖", result.msg); + AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source); return result; } @@ -1640,11 +1774,12 @@ internal static Result add(add model) { Result result = new Result() { code = "200", msg = "鐗╂枡涓绘暟鎹垱寤烘垚鍔� }; + string Source = "MES"; if (model == null) { result.code = "1"; result.msg = "鍙傛暟涓簄ull"; - AddErrorInfo("鍙傛暟涓虹┖", result.msg); + AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source); return result; } try @@ -1653,24 +1788,27 @@ if (db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE == model.PartNumber).Count() > 0) { result.code = "1"; - result.msg = "鐗╂枡涓绘暟鎹凡瀛樺湪"; - AddErrorInfo("鐗╂枡涓绘暟鎹凡瀛樺湪", result.msg); + result.msg = $"鐗╂枡缂栫爜:{model.PartNumber}鐨勭墿鏂欎富鏁版嵁宸插瓨鍦�; + // AddErrorInfo("鐗╂枡涓绘暟鎹凡瀛樺湪", result.msg, Source); + LogHelper.Info($"add:{result.msg}"); return result; } TN_Material itemInfo = new TN_Material(); itemInfo.S_ITEM_CODE = model.PartNumber; itemInfo.ITEM_TYPE = model.PartClass; itemInfo.S_ITEM_NAME = model.PartDesc; - itemInfo.REMARK1 = model.StewingTime.ToString("yyyy-MM-dd"); - itemInfo.REMARK2 = model.OverdueTime.ToString("yyyy-MM-dd"); + itemInfo.REMARK1 = model.StewingTime; + itemInfo.REMARK2 = model.OverdueTime; itemInfo.S_MP_TYPE = model.Unit; - - db.Insertable<TN_Material>(itemInfo).ExecuteCommand(); + if (db.Insertable<TN_Material>(itemInfo).ExecuteCommand() > 0) + { + LogHelper.Info($"add:鐗╂枡缂栫爜:{model.PartNumber}鐨勭墿鏂欎富鏁版嵁宸插悓姝�); + } + ; return result; } catch (Exception ex) { - result.code = "1"; result.msg = $"鐗╂枡涓绘暟鎹垱寤哄け璐�閿欒淇℃伅锛歿ex}"; LogHelper.Error("add Error锛� + ex.ToString(), ex); @@ -1686,11 +1824,12 @@ internal static Result CreatTask(CreatTask model) { Result result = new Result() { code = "200", msg = "鐐瑰鐐逛换鍔″垱寤烘垚鍔� }; + string Source = "MES"; if (model == null) { result.code = "1"; result.msg = "鍙傛暟涓簄ull"; - AddErrorInfo("鍙傛暟涓虹┖", result.msg); + AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source); return result; } string Start = ""; //鍙栬揣鐐�@@ -1716,7 +1855,7 @@ { result.code = "1"; result.msg = $"鍒涘缓浠诲姟澶辫触锛屾牴鎹捣鐐箋model.InitialLocation}鏈壘鍒板搴旇揣浣嶇粦瀹氭墭鐩樻墭鐩�; - AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg); + AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg, Source); return result; } } @@ -1794,11 +1933,12 @@ internal static Result CreatelevatorTask(Elevator model) { Result result = new Result() { code = "200", msg = "鐐瑰鐐逛换鍔″垱寤烘垚鍔� }; + string Source = "MES"; if (model == null) { result.code = "1"; result.msg = "鍙傛暟涓簄ull"; - AddErrorInfo("鍙傛暟涓虹┖", result.msg); + AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source); return result; } @@ -1818,35 +1958,37 @@ { result.code = "1"; result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐箋startloc.S_CODE}鏈夐攣"; - AddErrorInfo("璐т綅鏈夐攣", result.msg); + AddErrorInfo("璐т綅鏈夐攣", result.msg, Source); return result; } var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == startloc.S_CODE).First(); if (cntr == null) { - LogHelper.Info($"callfixture:鍒涘缓绌哄伐瑁呭懠鍙换鍔�=>鏍规嵁璐т綅{endloc.S_CODE}鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�); + result.code = "1"; result.msg = $"璧风偣{model.Data.start_loc_code}鏈煡璇㈢粦瀹氭墭鐩�; - AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg); + LogHelper.Info($"callfixture:鍒涘缓绌哄伐瑁呭懠鍙换鍔�=>{result.msg}"); + AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg, Source); return result; } // var startArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == startloc.S_AREA_CODE).First(); //var endArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == endloc.S_AREA_CODE).First(); - string dtcode = "DT-01"; - //妤煎眰鐢垫鍒嗛厤 - var Diantiloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == dtcode).First(); - if (Diantiloc == null) - { - result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛屾牴鎹揣浣嶇紪鐮�{dtcode}鏈壘鍒扮數姊揣浣�; - AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg); - return result; - } + //string dtcode = "DT-01"; + ////妤煎眰鐢垫鍒嗛厤 + //var Diantiloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == dtcode).First(); + //if (Diantiloc == null) + //{ + // result.code = "1"; + // result.msg = $"鍒涘缓浠诲姟澶辫触锛屾牴鎹揣浣嶇紪鐮�{dtcode}鏈壘鍒扮數姊揣浣�; + // AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source); + // return result; + //} - //鏍规嵁鐢垫鏁伴噺鍒ゆ柇閫佸線鍝釜鐢垫 锛堝叿浣撶數姊祦绋嬫牴鎹幇鍦虹數姊暟閲忥級 + //鏍规嵁浠诲姟鏁伴噺鍒ゆ柇閫佸線鍝釜鐢垫 锛堝叿浣撶數姊祦绋嬫牴鎹幇鍦虹數姊暟閲忥級 + var elevatorLoc = LocationHelper.GetElevatorLoc(); //鍒涘缓wcs鍒嗘浠诲姟 var wcsTask = new WCSTask @@ -1856,12 +1998,12 @@ S_TYPE = "鐢垫1", S_EQ_NO = model.Data.task_no, S_START_LOC = startloc.S_CODE, - S_END_LOC = Diantiloc.S_CODE, + S_END_LOC = elevatorLoc.S_CODE, N_CNTR_COUNT = 1, S_START_WH = startloc.S_WH_CODE, S_START_AREA = startloc.S_AREA_CODE, - S_END_WH = endloc.S_WH_CODE, - S_END_AREA = endloc.S_AREA_CODE, + S_END_WH = elevatorLoc.S_WH_CODE, + S_END_AREA = elevatorLoc.S_AREA_CODE, N_SCHEDULE_TYPE = 1, S_CNTR_CODE = cntr.S_CNTR_CODE, N_END_LAYER = 1, @@ -1872,11 +2014,11 @@ S_CODE = WCSHelper.GenerateTaskNo(), S_TYPE = "鐢垫2", S_EQ_NO = model.Data.task_no, - S_START_LOC = Diantiloc.S_CODE, + S_START_LOC = elevatorLoc.S_CODE, S_END_LOC = endloc.S_CODE, N_CNTR_COUNT = 1, - S_START_WH = startloc.S_WH_CODE, - S_START_AREA = startloc.S_AREA_CODE, + S_START_WH = elevatorLoc.S_WH_CODE, + S_START_AREA = elevatorLoc.S_AREA_CODE, S_END_WH = endloc.S_WH_CODE, S_END_AREA = endloc.S_AREA_CODE, N_SCHEDULE_TYPE = 1, @@ -1915,8 +2057,6 @@ } - - /// <summary> /// 璐т綅淇℃伅涓婁紶 /// </summary> @@ -1926,6 +2066,7 @@ { Result result = new Result() { code = "200", msg = "璐т綅淇℃伅涓婁紶鎴愬姛" }; + String Source = "MES"; RequestList<UploadLoc> result1 = new RequestList<UploadLoc>(); List<UploadLoc> listuploadloc = new List<UploadLoc>(); var db = new SqlHelper<object>().GetInstance(); @@ -1949,7 +2090,7 @@ { result.code = "1"; result.msg = $"璐т綅涓婁紶澶辫触锛屾牴鎹揣浣嶇紪鐮亄item.Location}鏈壘鍒板搴旂殑璐т綅淇℃伅"; - AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg); + AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source); return result; } } @@ -1980,11 +2121,10 @@ LogHelper.Info($"鐗╂枡鍒颁綅鍥炴姤澶辫触=>鍥炴姤鍦板潃娌℃湁閰嶇疆"); result.code = "1"; result.msg = $"鐗╂枡鍒颁綅鍥炴姤澶辫触=>鍥炴姤鍦板潃娌℃湁閰嶇疆"; - AddErrorInfo("鍦板潃閿欒", result.msg); + AddErrorInfo("鍦板潃閿欒", result.msg, Source); } return result; } - /// <summary> /// 搴撲綅娓呯┖ @@ -1994,11 +2134,12 @@ internal static Result ClearLoc(ClearTask model) { Result result = new Result() { code = "200", msg = "搴撲綅娓呴櫎鎴愬姛" }; + string Source = "MES"; if (model == null) { result.code = "1"; result.msg = "鍙傛暟涓簄ull"; - AddErrorInfo("鍙傛暟涓虹┖", result.msg); + AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source); return result; } string loc = model.LocationNum; @@ -2018,9 +2159,20 @@ if (CntrItem != null) { - LocationHelper.UnBindingLoc(loc, new List<string>() { "cntrcode" }); - // db.Deleteable<LocCntrRel>().Where(it => it.S_LOC_CODE.Trim() == loc).ExecuteCommand(); - db.Deleteable<CntrItemDetail>().Where(it => it.S_CNTR_CODE.Trim() == cntrcode).ExecuteCommand(); + LocationHelper.UnBindingLoc(loc, new List<string>() { cntrcode }); + // db.Deleteable<LocCntrRel>().Where(it => it.S_LOC_CODE.Trim() == loc).ExecuteCommand(); + if (db.Deleteable<CntrItemDetail>().Where(it => it.S_CNTR_CODE == cntrcode).ExecuteCommand() > 0) + { + LogHelper.Info($"ClearLoc 搴撲綅娓呴櫎鎴愬姛"); + } + else + { + LogHelper.Info($"ClearLoc 搴撲綅娓呴櫎澶辫触"); + result.code = "1"; + result.msg = "搴撲綅娓呴櫎澶辫触"; + AddErrorInfo("搴撲綅娓呴櫎澶辫触", result.msg, Source); + return result; + } } else @@ -2038,7 +2190,7 @@ { result.code = "1"; result.msg = $"鏍规嵁璐т綅:{loc}鎵句笉鍒拌揣浣嶅叧绯�; - AddErrorInfo("璐т綅涓虹┖", result.msg); + AddErrorInfo("璐т綅涓虹┖", result.msg, Source); return result; } } @@ -2054,7 +2206,99 @@ return result; } + /// <summary> + /// 璁惧鐘舵�涓婃姤 + /// </summary> + /// <returns></returns> + internal static DeviceInfoModel Device() + { + var db = new SqlHelper<HangChaAGV>().GetInstance(); + DeviceInfoModel device = new DeviceInfoModel(); + List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//鍙犵洏鏈烘姤閿欎俊鎭�+ List<AgvInfos> agvInfos = new List<AgvInfos>();//agv鎶ラ敊淇℃伅 + + //鑾峰彇鍐呭瓨涓彔鐩樻満鐨勬姤閿欎俊鎭�+ foreach (var dpjInfo in DeviceProcess.DpjInfoDirectory) + { + deviceInfos.Add(new DeviceInfos() { Device = dpjInfo.Value.DeviceName, DeviceInfo = dpjInfo.Value.ErrorInfo }); + } + device.DeviceInfos = deviceInfos; + //鑾峰彇杞﹁締鎶ヨ淇℃伅 + var agvDeviceInfo = db.Queryable<HangChaAGV>().ToList(); + if (agvDeviceInfo.Count > 0) + { + device.AgvQty = agvDeviceInfo.Count; + device.AgvErrorQty = agvDeviceInfo.FindAll(a => a.agvErrCode != "0" || a.agvErrCode != "0" || a.faildCode != "0").Count; + device.AgvChargeQty = agvDeviceInfo.FindAll(a => a.agvErrCode == "1").Count; + device.AgvRunQty = agvDeviceInfo.FindAll(a => a.agvErrCode == "1").Count; + foreach (var agv in agvDeviceInfo) + { + string agvErrorInfo = GetAgvAlarmSendCodeTwo(agv.agvErrCode, agv.errCode2, agv.faildCode); + agvInfos.Add(new AgvInfos() { AgvNo = agv.agvNo, AgvInfo = agvErrorInfo }); + } + } + device.AgvInfos = agvInfos; + + return device; + } + + /// <summary> + /// agv灏忚溅鏁呴殰鐮佸鐞�+ /// </summary> + /// <param name="errCode1">閿欒鐮�</param> + /// <param name="errCode2">閿欒鐮�</param> + /// <param name="faildCode">閿欒鐮�</param> + /// <returns></returns> + private static string GetAgvAlarmSendCodeTwo(string errCode1, string errCode2, string faildCode) + { + string result = ""; + //灏嗘姤璀︿俊鎭暣鍚�+ string binSW1 = Convert.ToString(int.Parse(errCode1), 2).PadLeft(22, '0'); + string binSW2 = Convert.ToString(int.Parse(errCode1), 2).PadLeft(20, '0'); + string binFc = Convert.ToString(int.Parse(errCode1), 2).PadLeft(16, '0'); + var arr1 = binSW1.ToArray(); + var arr2 = binSW2.ToArray(); + var arr3 = binFc.ToArray(); + + for (int i = 0; i <= arr1.Length; i++) + { + if (arr1[i] == '1') + { + var ErrorInfo = Settings.agvErrorCode1.Where(a => a.ErrorCode == i).FirstOrDefault(); + if (ErrorInfo != null) + { + result = result + "," + $"{ErrorInfo.ErrorInfo}"; + } + + } + } + for (int i = 0; i <= arr2.Length; i++) + { + if (arr1[i] == '1') + { + var ErrorInfo = Settings.agvErrorCode2.Where(a => a.ErrorCode == i).FirstOrDefault(); + if (ErrorInfo != null) + { + result = result + "," + $"{ErrorInfo.ErrorInfo}"; + } + + } + } + for (int i = 0; i <= arr3.Length; i++) + { + if (arr1[i] == '1') + { + var ErrorInfo = Settings.agvFaildCode.Where(a => a.ErrorCode == i).FirstOrDefault(); + if (ErrorInfo != null) + { + result = result + "," + $"{ErrorInfo.ErrorInfo}"; + } + + } + } + return result; + } #endregion #region 鍚堣偉浣抽�涓氬姟鏂规硶 @@ -2067,51 +2311,52 @@ internal static Location StorageCompute(string itemcode, string areacode) { var db = new SqlHelper<object>().GetInstance(); - Location result = null; - //鏌ヨ鎵�湁鏈夋墭鐩樼殑鎺�- var list = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM > 0 && a.S_AREA_CODE.Trim() == areacode).OrderByDescending(a => a.N_COL).Take(1).PartitionBy(a => a.N_ROW).ToList(); - if (list.Count > 0) - { - for (int i = 0; i < list.Count; i++) - { - LogHelper.Info($"鏈夋墭鐩樻帓鍙穥list[i].N_ROW}锛岀墿鏂欑紪鐮亄itemcode},搴撳尯{areacode}"); - //鍒ゆ柇鎵樼洏鐗╂枡鏄惁鐩稿悓鐗╂枡淇℃伅鐩稿悓 - var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == list[i].S_CODE).First(); - if (cntr != null) - { - if (string.IsNullOrEmpty(itemcode))//绌烘墭鍏ュ簱 - { - var iteminfo = ContainerHelper.GetCntrItemRel(cntr.S_CNTR_CODE).FirstOrDefault(); - if (iteminfo == null) - { - //鐗╂枡鐩稿悓鍏ヨ揣浣嶅悗涓�綅璐т綅 - result = db.Queryable<Location>().OrderBy(a => a.N_COL).Where(a => a.S_AREA_CODE.Trim() == areacode && a.N_ROW == list[i].N_ROW && a.N_COL > list[i].N_COL).First(); - } - } - else//婊℃嫋鍏ュ簱 - { - var iteminfo = ContainerHelper.GetCntrItemRel(cntr.S_CNTR_CODE).FirstOrDefault(); - if (iteminfo != null) - { - if (iteminfo.S_ITEM_CODE == itemcode) - { - //鐗╂枡鐩稿悓鍏ヨ揣浣嶅悗涓�綅璐т綅 - result = db.Queryable<Location>().OrderBy(a => a.N_COL).Where(a => a.S_AREA_CODE.Trim() == areacode && a.N_ROW == list[i].N_ROW && a.N_COL > list[i].N_COL).First(); + Location result = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM == 0 && a.S_AREA_CODE.Trim() == areacode && a.N_LOCK_STATE == 0).First(); + //鏌ヨ鎵�湁鏈夋墭鐩樼殑鎺掓病閿佺殑鎺�+ // var list = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM > 0 && a.S_AREA_CODE.Trim() == areacode && a.N_LOCK_STATE == 0).OrderByDescending(a => a.N_COL).Take(1).PartitionBy(a => a.N_ROW).ToList(); + // if (list.Count > 0) + //{ + // for (int i = 0; i < list.Count; i++) + // { + // LogHelper.Info($"鏈夋墭鐩樻帓鍙穥list[i].N_ROW}锛岀墿鏂欑紪鐮亄itemcode},搴撳尯{areacode}"); + // //鏌ヨ璐т綅缁戝畾鎵樼洏 + // var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == list[i].S_CODE).First(); + // if (cntr != null) + // { + // //鏌ヨ鎵樼洏鐗╂枡淇℃伅 + // var iteminfo = ContainerHelper.GetCntrItemRel(cntr.S_CNTR_CODE).FirstOrDefault(); - } - } - } - if (result != null) - { - return result; - } - } - else - { - LogHelper.Info($"鏍规嵁璐х墿缂栫爜{list[i].S_CODE}鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�); - } - } - } + // if (string.IsNullOrEmpty(itemcode))//绌烘墭鍏ュ簱 + // { + // if (iteminfo == null) + // { + // //鐗╂枡鐩稿悓鍏ヨ揣浣嶅悗涓�綅璐т綅 + // result = db.Queryable<Location>().OrderBy(a => a.N_COL).Where(a => a.S_AREA_CODE.Trim() == areacode && a.N_ROW == list[i].N_ROW && a.N_COL > list[i].N_COL && a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM == 0).First(); + // } + // } + // else//婊℃嫋鍏ュ簱 + // { + // if (iteminfo != null) + // { + // if (iteminfo.S_ITEM_CODE == itemcode) + // { + // //鐗╂枡鐩稿悓鍏ヨ揣浣嶅悗涓�綅璐т綅 + // result = db.Queryable<Location>().OrderBy(a => a.N_COL).Where(a => a.S_AREA_CODE.Trim() == areacode && a.N_ROW == list[i].N_ROW && a.N_COL > list[i].N_COL && a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM == 0).First(); + + // } + // } + // } + // if (result != null) + // { + // return result; + // } + // } + // else + // { + // LogHelper.Info($"鏍规嵁璐х墿缂栫爜{list[i].S_CODE}鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�); + // } + // } + //} return result; } @@ -2180,7 +2425,14 @@ #endregion var loc = LocationHelper.GetLocByItemCode(areacode, itemcode, level); - result = FindStartcolByLoclist(loc); + LogHelper.Info($"airlift=>鏍规嵁搴撳尯缂栫爜:{areacode}锛岀墿鏂欑紪鐮�{itemcode},鐗╂枡绛夌骇璁$畻鍑烘湁鎵樼洏璐т綅{JsonConvert.SerializeObject(loc)}"); + // result = FindStartcolByLoclist(loc); + if (loc.Count > 0) + { + result = loc.OrderByDescending(a => a.N_COL).First(); + } + + LogHelper.Info($"airlift=>鍙敤璐т綅涓猴細{JsonConvert.SerializeObject(result)}"); return result; } @@ -2204,26 +2456,31 @@ } return result; } + /// <summary> - /// 鍒涘缓鎵樼洏鐗╂枡缁戝畾鍏崇郴 + /// 绔嬪簱浠诲姟涓嬪彂鍒涘缓鎵樼洏鐗╂枡缁戝畾鍏崇郴 /// </summary> - /// <param name="loc">璐т綅缂栫爜</param> - /// <param name="cntr">鎵樼洏缂栫爜</param> - /// <param name="partNumber">鐗╂枡缂栫爜</param> - /// <param name="partDesc">鐗╂枡鎻忚堪</param> - /// <param name="partType">鐗╂枡绫诲瀷</param> - /// <param name="cntrtype">鎵樼洏绫诲瀷</param> - /// <param name="unit">鐗╂枡鍗曚綅</param> - /// <param name="weight">鐗╂枡閲嶉噺</param> - internal static bool CreateCntrIteminfo(string loc, string cntr, string partNumber, string partDesc, string partType, string batch, string unit, string weight, string cntrtype = "1", string level = "") + internal static bool CreateCntrIteminfo(partData partData, taskData taskData) { - return ContainerHelper.CreateCntrItem(loc, cntr, partNumber, partDesc, partType, cntrtype, batch, weight, unit, level); + if (partData == null && taskData == null) + { + LogHelper.Info($"CreateCntrIteminfo==> 绔嬪簱浠诲姟涓嬪彂鍙傛暟鏈夌┖锛屽垱寤虹墿鏂欐墭鐩樼粦瀹氬叧绯诲け璐�); + return false; + } + else + { + return ContainerHelper.CreateCntrItem(taskData.pickStation, partData.rfid, partData.partNumber, partData.partDesc, partData.partType, taskData.carrierType, partData.lotNumber, taskData.wmsLot, partData.weight, partData.unit, + taskData.tyreType, taskData.supplier, taskData.receiveLot, taskData.subpool, partData.productionTime, partData.maturityTime, taskData.level); + } + } + private static object _lockLocation = new object(); /// <summary> /// 鏍规嵁鎵樼洏缂栫爜锛屾満鍙扮紪鐮侊紝宸ヨ绫诲瀷璁$畻鏈哄彴绾胯竟鍖哄煙 /// </summary> /// <param name="cntrcode">鎵樼洏缂栫爜</param> /// <param name="jtcode">鏈哄彴缂栫爜</param> + /// <param name="cntrType">鎵樼洏绫诲瀷</param> /// <returns></returns> internal static Location Computeloc(string cntrcode, string jtcode, string cntrType) { @@ -2233,17 +2490,19 @@ // var location = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == cntrcode).First(); - - var loc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).First(); - if (loc != null) + lock (_lockLocation) { - End = loc; - } - else - { - LogHelper.Info($"Computeloc==銆嬫牴鎹満鍙板垎缁勶細{jtcode},宸ヨ绫诲瀷锛歿cntrType} 鏈壘鍒扮┖璐т綅鏁版嵁锛岃妫�煡璐т綅琛�); - } + var loc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).First(); + if (loc != null) + { + End = loc; + } + else + { + LogHelper.Info($"Computeloc==銆嬫牴鎹満鍙板垎缁勶細{jtcode},宸ヨ绫诲瀷锛歿cntrType} 鏈壘鍒扮┖璐т綅鏁版嵁锛岃妫�煡璐т綅琛�); + } + } return End; } @@ -2263,7 +2522,7 @@ { var error = new ErrorInfo { - EEEORMESSAGE = errorInfo, + ERRORMESSAGE = errorInfo, TASKNO = taskno, AREACODE = areacode, REMAKE = remake, @@ -2290,7 +2549,7 @@ /// </summary> /// <param name="locations"></param> /// <returns></returns> - internal static Location FindEndcolByLocList(List<Location> locations, string itemcode) + internal static Location FindEndcolByLocList(List<Location> locations) { try { @@ -2306,7 +2565,7 @@ Location other = null; //褰撳墠鎺掓病鏈夐攣骞朵笖鏈夌┖浣嶇疆 //鍏堟壘婊′綅锛岀劧鍚庡悗闈竴灞傝涔堟槸绌猴紝瑕佷箞涓嶅瓨鍦�- other = rowList.OrderByDescending(a => a.N_COL).Where(a => a.N_CURRENT_NUM == 0).FirstOrDefault(); + other = rowList.OrderBy(a => a.N_COL).Where(a => a.N_CURRENT_NUM == 0).FirstOrDefault(); //if (full == null) //{ // //娌℃湁婊′綅锛岄偅灏辨壘鏈�皬鐨勭┖浣�@@ -2383,9 +2642,9 @@ } } + + #endregion - - internal static CodeInfo GetCodeInfo(string code, string org) { -- Gitblit v1.9.1