From 553f7744bedee0685635ed070a4a0e18b796238f Mon Sep 17 00:00:00 2001 From: lss <2538410689@qq.com> Date: 星期四, 24 七月 2025 17:30:36 +0800 Subject: [PATCH] 1111 --- HH.WCS.Mobox3 - 大车间/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs | 407 +++++++++++++++++++++++---------------------------------- 1 files changed, 165 insertions(+), 242 deletions(-) diff --git "a/HH.WCS.Mobox3 - \345\244\247\350\275\246\351\227\264/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs" "b/HH.WCS.Mobox3 - \345\244\247\350\275\246\351\227\264/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs" index 5acf75e..627207b 100644 --- "a/HH.WCS.Mobox3 - \345\244\247\350\275\246\351\227\264/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs" +++ "b/HH.WCS.Mobox3 - \345\244\247\350\275\246\351\227\264/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs" @@ -1,9 +1,9 @@ -锘縰sing HH.WCS.JiaTong.device; -using HH.WCS.JiaTong.dispatch; -using HH.WCS.JiaTong.LISTA.models; -using HH.WCS.JiaTong.process; -using HH.WCS.JiaTong.util; -using HH.WCS.JiaTong.wms; +锘縰sing HH.WCS.JiaTong_DCJ.device; +using HH.WCS.JiaTong_DCJ.dispatch; +using HH.WCS.JiaTong_DCJ.LISTA.models; +using HH.WCS.JiaTong_DCJ.process; +using HH.WCS.JiaTong_DCJ.util; +using HH.WCS.JiaTong_DCJ.wms; using Newtonsoft.Json; using NLog.Fluent; using S7.Net; @@ -17,12 +17,12 @@ 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; -using static HH.WCS.JiaTong.util.Settings; +using static HH.WCS.JiaTong_DCJ.api.ApiModel; +using static HH.WCS.JiaTong_DCJ.api.OtherModel; +using static HH.WCS.JiaTong_DCJ.LISTA.process.HttpModel; +using static HH.WCS.JiaTong_DCJ.util.Settings; -namespace HH.WCS.JiaTong.api +namespace HH.WCS.JiaTong_DCJ.api { /// <summary> /// api鎺ュ彛杈呭姪绫�@@ -92,7 +92,7 @@ // AddErrorInfo("瀵绘壘鍑哄簱鍖哄け璐�, result.msg); // return result; //} - + string state = "绛夊緟"; int n_type = 0; //浠诲姟鏉ユ簮 1.瀵嗙偧绔嬪簱 3.棰勫搴�,4.鍘熸潗鏂欏簱 string Source = ""; switch (taskData.source) @@ -104,8 +104,9 @@ case "YBK": n_type = 2; Source = "棰勫搴�; + state = "绛夊緟鎺ㄩ�"; break; - + } Console.WriteLine($"Createtask==>浠诲姟鏉ユ簮:{n_type}"); if (n_type == 0) @@ -123,222 +124,101 @@ Location startloc = null; lock (_lockCreateTask) { - if (taskData.taskType == 1) //鍑哄簱娴佺▼锛岄�杩囩墿鏂欐満鍙拌绠楃嚎杈硅揣浣�+ note = "鍑哄簱"; + //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅 + startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); + if (startloc != null) { - note = "鍑哄簱"; - startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); - if (startloc != null) - { - //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅 - Start = taskData.pickStation; - if (CreateCntrIteminfo(partData, taskData)) - { - endloc = Computeloc(CntrCode, taskData.dropStation, taskData.carrierType); - if (endloc != null) - { - End = endloc.S_CODE; - } - else - { - result.code = "1"; - result.msg = $"鏈哄彴缂栫爜:{taskData.dropStation}锛屾湭鎵惧埌鍙敤璐т綅"; - 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; - //} - } - else - { - result.code = "1"; - result.msg = "鍒涘缓鎵樼洏鐗╂枡淇℃伅澶辫触"; - AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg, Source); - return result; - } - - - } - else - { - - result.code = "1"; - result.msg = $"Putin==> 浠诲姟璧风偣:{taskData.pickStation}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; - LogHelper.Info($"Putin==> {result.msg}"); - AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); - return result; - } + Start = taskData.pickStation; } - else if (taskData.taskType == 2)//鍏ュ簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟锛岃捣鐐归渶瑕佹湁鎵樼洏 - { - note = "鍏ュ簱"; - startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); - if (startloc != null) - { - Start = startloc.S_CODE; - var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).OrderBy(a => a.T_CREATE).FirstOrDefault(); - if (CntrRel != null) - { - if (CntrRel.S_CNTR_CODE != partData.rfid) - { - result.code = "1"; - result.msg = $"鏍规嵁璧风偣锛歿Start}鑾峰彇鎵樼洏:{CntrRel.S_CNTR_CODE}涓庝笅鍙戞墭鐩橈細{partData.rfid}涓嶄竴鑷达紝璇锋鏌ユ墭鐩樼爜鏄惁姝g‘"; - AddErrorInfo("鎵樼洏鐮佹牎妫�け璐�, result.msg, Source); - return result; - } - else - { - CntrCode = CntrRel.S_CNTR_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; - } - } - 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 { - LogHelper.Info($"Createtask==> 浠诲姟绫诲瀷鏈夎"); result.code = "1"; - result.msg = "浠诲姟绫诲瀷锛歿taskData.taskType}涓嶅湪瑙勫畾鑼冨洿鍐�; - AddErrorInfo("浠诲姟绫诲瀷閿欒", result.msg, Source); + result.msg = $"鏍规嵁璧风偣{taskData.pickStation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); + return result; } - - if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) - { - if (startloc.N_LOCK_STATE != 0) - { - result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐箋Start}鏈夐攣"; - AddErrorInfo("璐т綅鏈夐攣", result.msg); - return result; - } - var startArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == startloc.S_AREA_CODE.Trim()).First(); - var endArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == endloc.S_AREA_CODE.Trim()).First(); - if (startArea == null || endArea == null) - { - LogHelper.Info($"璧风偣锛歿JsonConvert.SerializeObject(startArea)}"); - LogHelper.Info($"缁堢偣锛歿JsonConvert.SerializeObject(endArea)}"); - result.code = "1"; - result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐�{startloc.S_AREA_CODE},缁堢偣{endloc.S_AREA_CODE}鏈壘鍒板搴斿簱鍖�; - AddErrorInfo("搴撳尯鏌ユ壘澶辫触", result.msg); - return result; - } - int pri = 1; - var area = Settings.wareLoc.Where(a => a.AreaCode == endloc.S_WH_CODE).First(); - if (area != null) - { - if (area.XbAreaCodes.Contains(endloc.S_AREA_CODE)) - { - pri = 2; - } - } - //鍒涘缓wcs浠诲姟 - var wcsTask = new WCSTask - { - S_CODE = WCSHelper.GenerateTaskNo(), - S_TYPE = startArea.S_NAME + "->" + endArea.S_NAME, - S_EQ_NO = taskData.taskNum, - S_START_LOC = Start, - S_END_LOC = End, - N_CNTR_COUNT = 1, - S_START_WH = startloc.S_WH_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 = pri, - Z_TYPE = n_type, - N_START_LAYER = 1, - N_END_LAYER = 1, - S_WMS_NO = taskData.wmsTaskNo, - S_NOTE = note, - S_MES_NO = taskData.mesTaskNo + 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; + } - }; - LogHelper.Info("鍒涘缓浠诲姟锛� + JsonConvert.SerializeObject(wcsTask), "CreateTask"); - if (WCSHelper.CreateTask(wcsTask)) - { - // LocationHelper.LockLoc(Start, 2); - //LocationHelper.LockLoc(End, 1); - LogHelper.Info("鍒涘缓浠诲姟鎴愬姛"); - } - else - { - result.code = "1"; - result.msg = $"浠诲姟鍒涘缓澶辫触"; - AddErrorInfo("浠诲姟鍒涘缓澶辫触", result.msg, Source); - return result; - } + if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) + { + if (startloc.N_LOCK_STATE != 0) + { + result.code = "1"; + result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐箋Start}鏈夐攣"; + AddErrorInfo("璐т綅鏈夐攣", result.msg); + return result; + } + var startArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == startloc.S_AREA_CODE.Trim()).First(); + var endArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == endloc.S_AREA_CODE.Trim()).First(); + if (startArea == null || endArea == null) + { + LogHelper.Info($"璧风偣锛歿JsonConvert.SerializeObject(startArea)}"); + LogHelper.Info($"缁堢偣锛歿JsonConvert.SerializeObject(endArea)}"); + result.code = "1"; + result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐�{startloc.S_AREA_CODE},缁堢偣{endloc.S_AREA_CODE}鏈壘鍒板搴斿簱鍖�; + AddErrorInfo("搴撳尯鏌ユ壘澶辫触", result.msg); + return result; + } + + //鍒涘缓wcs浠诲姟 + var wcsTask = new WCSTask + { + S_CODE = WCSHelper.GenerateTaskNo(), + S_TYPE = startArea.S_NAME + "->" + endArea.S_NAME, + S_EQ_NO = taskData.taskNum, + S_START_LOC = Start, + S_END_LOC = End, + N_CNTR_COUNT = 1, + S_START_WH = startloc.S_WH_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 = 1, + Z_TYPE = n_type, + N_START_LAYER = 1, + N_END_LAYER = 1, + S_WMS_NO = taskData.wmsTaskNo, + S_NOTE = note, + S_B_STATE = state, + S_MES_NO = taskData.mesTaskNo + + }; + LogHelper.Info("鍒涘缓浠诲姟锛� + JsonConvert.SerializeObject(wcsTask), "CreateTask"); + if (WCSHelper.CreateTask(wcsTask)) + { + // LocationHelper.LockLoc(Start, 2); + //LocationHelper.LockLoc(End, 1); + LogHelper.Info("鍒涘缓浠诲姟鎴愬姛"); } else { result.code = "1"; - result.msg = "鍒涘缓浠诲姟澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勫彇璐х偣鎴栧嵏璐х偣"; + result.msg = $"浠诲姟鍒涘缓澶辫触"; + AddErrorInfo("浠诲姟鍒涘缓澶辫触", result.msg, Source); return result; } - - } + } + else + { + result.code = "1"; + result.msg = "鍒涘缓浠诲姟澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勫彇璐х偣鎴栧嵏璐х偣"; + return result; + } + } return result; } @@ -355,7 +235,50 @@ } + /// <summary> + /// 棰勫搴撲换鍔$姸鎬佷笅鍙�+ /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static Result MstStateInquire(MstStateInquire model) + { + Result result = new Result() { code = "200", msg = "鐘舵�涓嬪彂鎴愬姛" }; + var db = new SqlHelper<object>().GetInstance(); + if (model == null) + { + LogHelper.Info($"MstStateInquire==> 鍙傛暟涓簄ull"); + result.code = "1"; + result.msg = "鍙傛暟涓簄ull鍊硷紝璇锋鏌ュ弬鏁版牸寮�; + AddErrorInfo("鍙傛暟涓虹┖", result.msg); + return result; + } + try + { + //鎵惧埌浠诲姟锛屼慨鏀逛换鍔$姸鎬�+ var task = db.Queryable<WCSTask>().Where(a => a.S_EQ_NO.Trim() == model.taskNum).First(); + if (task != null) + { + task.S_B_STATE ="绛夊緟"; + db.Updateable(task).UpdateColumns(a => new { a.S_B_STATE}).ExecuteCommand(); + } + else + { + result.code = "1"; + result.msg = $"鏍规嵁涓嬪彂浠诲姟鍙穥model.taskNum}鏈壘鍒板搴斾换鍔�; + AddErrorInfo("鏈壘鍒颁换鍔�, result.msg); + return result; + } + return result; + } + catch (Exception ex) + { + result.code = "1"; + result.msg = ex.ToString(); + LogHelper.Error("TrayItembind Error锛� + ex.ToString(), ex); + return result; + } + } public static object _Point = new object(); @@ -366,7 +289,7 @@ /// <returns></returns> internal static Result Point(PointModel model) { - Result result = new Result() { code = "200", msg = "鍏ュ钩搴撲换鍔′笅鍙戞垚鍔� }; + Result result = new Result() { code = "200", msg = "浠诲姟涓嬪彂鎴愬姛" }; string Source = "Mes"; if (model == null) @@ -419,25 +342,25 @@ AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); return result; } - else - { - //鍒ゆ柇璧风偣鏄惁缁戝畾鍏朵粬鎵樼洏 - var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).OrderBy(a => a.T_CREATE).FirstOrDefault(); - if (CntrRel != null) - { - if (CntrRel.S_CNTR_CODE != model.Rfid) - { - result.code = "1"; - result.msg = $"鏍规嵁璧风偣锛歿model.InitialLocation}鑾峰彇鎵樼洏:{CntrRel.S_CNTR_CODE}涓庝笅鍙戞墭鐩橈細{model.Rfid}涓嶄竴鑷达紝璇锋鏌ユ墭鐩樼爜鏄惁姝g‘"; - AddErrorInfo("鎵樼洏鐮佹牎妫�け璐�, result.msg, Source); - return result; - } - } - else - { - LocationHelper.BindingLoc(startloc.S_CODE, new List<string> { model.Rfid }); - } - } + //else + //{ + // //鍒ゆ柇璧风偣鏄惁缁戝畾鍏朵粬鎵樼洏 + // var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).OrderBy(a => a.T_CREATE).FirstOrDefault(); + // if (CntrRel != null) + // { + // if (CntrRel.S_CNTR_CODE != model.Rfid) + // { + // result.code = "1"; + // result.msg = $"鏍规嵁璧风偣锛歿model.InitialLocation}鑾峰彇鎵樼洏:{CntrRel.S_CNTR_CODE}涓庝笅鍙戞墭鐩橈細{model.Rfid}涓嶄竴鑷达紝璇锋鏌ユ墭鐩樼爜鏄惁姝g‘"; + // AddErrorInfo("鎵樼洏鐮佹牎妫�け璐�, result.msg, Source); + // return result; + // } + // } + // else + // { + // LocationHelper.BindingLoc(startloc.S_CODE, new List<string> { model.Rfid }); + // } + //} endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.TargetLocation).First(); if (endloc == null) { @@ -528,7 +451,7 @@ } } - + /// <summary> /// 璐т綅淇℃伅涓婁紶 /// </summary> @@ -554,7 +477,7 @@ result1.UseToken = "iFQ5fExGrLYLXliHYWzs"; upload.LocationNum = loc.S_CODE; upload.Type = loc.S_TYPE; - upload.LockState =loc.S_LOCK_STATE; + upload.LockState = loc.S_LOCK_STATE; upload.WorkCenter = loc.S_AREA_CODE; upload.Warehouse = loc.S_AREA_CODE; listuploadloc.Add(upload); @@ -574,7 +497,7 @@ var url = Settings.tableUrls.Find(a => a.id == 3); if (url != null) { - LogHelper.Info($"璐т綅涓婃姤涓婃姤锛氬湴鍧�{url}锛屽唴瀹癸細{date}"); + LogHelper.Info($"璐т綅涓婃姤涓婃姤锛氬湴鍧�{url.url}锛屽唴瀹癸細{date}"); var r = httpHelper.MesWebPost(url.url, date); result = JsonConvert.DeserializeObject<Result>(r); if (result.code == "200") @@ -609,8 +532,8 @@ var db = new SqlHelper<HangChaAGV>().GetInstance(); DeviceInfoModel device = new DeviceInfoModel(); - // List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//鍙犵洏鏈烘姤閿欎俊鎭�- // List<AgvInfos> agvInfos = new List<AgvInfos>();//agv鎶ラ敊淇℃伅 + // List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//鍙犵洏鏈烘姤閿欎俊鎭�+ // List<AgvInfos> agvInfos = new List<AgvInfos>();//agv鎶ラ敊淇℃伅 //鑾峰彇鍐呭瓨涓彔鐩樻満鐨勬姤閿欎俊鎭� //foreach (var dpjInfo in DeviceProcess.DpjInfoDirectory) @@ -632,7 +555,7 @@ // deviceInfos.Add(new DeviceInfos() { AgvNo = agv.agvNo, AgvInfo = agvErrorInfo }); //} } - // device.DeviceInfos = deviceInfos; + // device.DeviceInfos = deviceInfos; return device; } @@ -854,7 +777,7 @@ return result; } - + //internal static bool CreateCntrLoc(taskData taskData) //{ -- Gitblit v1.9.1