From 9cba325e0d7c30644606e63e5df01faba0c42038 Mon Sep 17 00:00:00 2001 From: lss <2538410689@qq.com> Date: 星期三, 06 八月 2025 17:18:41 +0800 Subject: [PATCH] 优化 --- HH.WCS.Mobox3 - 大车间/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs | 145 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 140 insertions(+), 5 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 7c4befb..ce27583 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" @@ -104,7 +104,10 @@ case "YBK": n_type = 2; Source = "棰勫搴�; - state = "绛夊緟鎺ㄩ�"; + if (taskData.taskType == 1) + { + state = "绛夊緟鎺ㄩ�"; + } break; } @@ -242,7 +245,7 @@ /// <returns></returns> internal static Result MstStateInquire(MstStateInquire model) { - Result result = new Result() { code = "200", msg = "鐘舵�涓嬪彂鎴愬姛" }; + Result result = new Result() { code = "0", msg = "鐘舵�涓嬪彂鎴愬姛" }; var db = new SqlHelper<object>().GetInstance(); if (model == null) { @@ -258,8 +261,21 @@ 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(); + if (task.S_B_STATE != "绛夊緟鎺ㄩ�") + { + result.code = "1"; + result.msg = $"鎺ㄩ�澶辫触锛屼换鍔″凡缁忓鐞�; + AddErrorInfo("鎺ㄩ�澶辫触", result.msg); + return result; + } + task.S_B_STATE = "绛夊緟"; + if (db.Updateable(task).UpdateColumns(a => new { a.S_B_STATE }).ExecuteCommand() < 0) + { + result.code = "1"; + result.msg = $"鎺ㄩ�澶辫触锛屼慨鏀逛换鍔$姸鎬佸け璐ワ紝璇烽噸鏂颁笅鍙�; + AddErrorInfo("鎺ㄩ�澶辫触", result.msg); + return result; + } } else { @@ -280,6 +296,125 @@ } + /// <summary> + /// 鐐瑰鐐逛换鍔″垱寤�+ /// </summary> + /// <param name="model"></param> + /// <returns></returns> + internal static Result CreatTask(CreatTask model) + { + Result result = new Result() { code = "0", msg = "鐐瑰鐐逛换鍔″垱寤烘垚鍔� }; + string Source = "MES"; + if (model == null) + { + result.code = "1"; + result.msg = "鍙傛暟涓簄ull"; + AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source); + return result; + } + string Start = ""; //鍙栬揣鐐�+ var db = new SqlHelper<object>().GetInstance(); + // string CntrCode = model.partData.rfid;//鎵樼洏缂栫爜 + // string ItemCode = model.partData.partNumber;//鐗╂枡缂栫爜 + string End = ""; + string CntrCode = ""; + Location endloc = new Location(); + Location startloc = new Location(); + try + { + startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.InitialLocation).First(); + if (startloc != null) + { + Start = model.InitialLocation; + } + else + { + result.code = "1"; + result.msg = $"鏍规嵁璧风偣{model.InitialLocation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); + return result; + } + endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.TargetLocation).First(); + if (endloc != null) + { + End = model.TargetLocation; + } + else + { + result.code = "1"; + result.msg = $"鏍规嵁缁堢偣{model.TargetLocation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃"; + AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source); + return result; + } + #region 鍒涘缓浠诲姟 + if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) + { + if (startloc.N_LOCK_STATE != 0) + { + result.code = "1"; + result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐箋Start}鏈夐攣"; + AddErrorInfo("璐т綅鏈夐攣", result.msg); + return result; + } + //鍒涘缓wcs浠诲姟 + var wcsTask = new WCSTask + { + S_CODE = WCSHelper.GenerateTaskNo(), + // S_TYPE = model.taskData.taskType.ToString(), + // S_EQ_NO = model.taskData.taskNum, + S_START_LOC = Start, + 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_START_LAYER = 1, + N_END_LAYER = 1, + N_PRIORITY = 1, + // N_TYPE = n_type + + + }; + LogHelper.Info("鍒涘缓浠诲姟锛� + JsonConvert.SerializeObject(wcsTask), "CreateTask"); + if (WCSHelper.CreateTask(wcsTask)) + { + //LocationHelper.LockLoc(Start, 2); + //LocationHelper.LockLoc(End, 1); + LogHelper.Info("鍒涘缓浠诲姟鎴愬姛"); + return result; + } + else + { + result.code = "1"; + result.msg = $"浠诲姟鍒涘缓澶辫触"; + AddErrorInfo("浠诲姟鍒涘缓澶辫触", result.msg, Source); + return result; + } + } + else + { + result.code = "1"; + result.msg = "鍒涘缓浠诲姟澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勫彇璐х偣鎴栧嵏璐х偣"; + return result; + } + #endregion + + return result; + + } + catch (Exception ex) + { + + result.code = "1"; + result.msg = $"鐗╂枡涓绘暟鎹垱寤哄け璐�閿欒淇℃伅锛歿ex}"; + LogHelper.Error("鐐瑰鐐逛换鍔�Error锛� + ex.ToString(), ex); + return result; + } + + } public static object _Point = new object(); /// <summary> @@ -475,7 +610,7 @@ if (loc != null) { UploadLoc upload = new UploadLoc(); - + upload.locationNum = loc.S_CODE; upload.type = loc.S_TYPE; upload.lockState = loc.S_LOCK_STATE; -- Gitblit v1.9.1