| | |
| | | using HH.WCS.QingXigongchang.dispatch; |
| | | using HH.WCS.QingXigongchang.process; |
| | | using HH.WCS.QingXigongchang.process; |
| | | using HH.WCS.QingXigongchang.util; |
| | | using Newtonsoft.Json; |
| | | using SqlSugar; |
| | |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Linq.Expressions; |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using static HH.WCS.QingXigongchang.dispatch.NDC; |
| | | |
| | | namespace HH.WCS.QingXigongchang.wms |
| | | { |
| | |
| | | var db = new SqlHelper<WMSTask>().GetInstance(); |
| | | return db.Queryable<WMSTask>().Where(a => a.S_TYPE.Trim() == taskType).ToList(); |
| | | } |
| | | internal static bool CreateTask(string no, string from, string to, string taskType, int pri, string cntrInfo, int cntrCount = 1, int startLayer = 1, int endLayer = 1, string note = "", bool lockLoc = false) |
| | | internal static bool CreateTask(string no, string from, string to, string taskType, int pri, string cntrInfo, int cntrCount = 1, int startLayer = 1, int endLayer = 1, string note = "", bool lockLoc = false, string TwoEndLoc = "") |
| | | { |
| | | var fromLoc = LocationHelper.GetLoc(from); |
| | | var endLoc = LocationHelper.GetLoc(to); |
| | | if (fromLoc.S_AREA_CODE == "YWLRGDD") |
| | | { |
| | | //查询任务表 要求是只能生成两个任务 起点库区为YWLRGDD hh_plg 2025年6月9日 |
| | | List<string> TaskState = new List<string>() { "完成", "取消" }; |
| | | var TaskListNum = LocationHelper.GetList<WMSTask>(x => x.S_START_LAREA == "YWLRGDD" && !TaskState.Contains(x.S_B_STATE)); |
| | | if (TaskListNum.Count() >= 2) |
| | | { |
| | | LogHelper.Info($"CreateTransport- CreateTask Error" + $"起点库区为YWLRGDD 则最多只能生成两个任务"); |
| | | return false; |
| | | } |
| | | } |
| | | else if (endLoc.S_AREA_CODE == "YWLWJJB") |
| | | { |
| | | //查询任务表 要求是只能生成两个任务 起点库区为YWLWJJB hh_plg 2025年6月9日 |
| | | List<string> TaskState = new List<string>() { "完成", "取消" }; |
| | | var TaskListNum = LocationHelper.GetList<WMSTask>(x => x.S_END_LAREA == "YWLWJJB" && !TaskState.Contains(x.S_B_STATE)); |
| | | if (TaskListNum.Count() >= 2) |
| | | { |
| | | LogHelper.Info($"CreateTransport- CreateTask Error" + $"终点库区为YWLWJJB 则最多只能生成两个任务"); |
| | | return false; |
| | | } |
| | | } |
| | | if (!taskType.Contains("清溪纸箱")) |
| | | { |
| | | if (fromLoc == null || endLoc == null) |
| | |
| | | LogHelper.Info($"CreateTransport- CreateTask Error" + $"起点或终点货位数据null"); |
| | | return false; |
| | | } |
| | | if (fromLoc.S_LOCK_STATE.Trim() != "无" || endLoc.S_LOCK_STATE.Trim() != "无") |
| | | if (fromLoc.S_AREA_CODE != "YWLWJJB") |
| | | { |
| | | LogHelper.Info($"CreateTransport- CreateTask Error" + $"起点 {fromLoc.S_LOCK_STATE}或终点{endLoc.S_LOCK_STATE}状态不为 无 "); |
| | | return false; |
| | | if (fromLoc.S_LOCK_STATE.Trim() != "无" || endLoc.S_LOCK_STATE.Trim() != "无") |
| | | { |
| | | LogHelper.Info($"CreateTransport- CreateTask Error" + $"起点 {fromLoc.S_LOCK_STATE}或终点{endLoc.S_LOCK_STATE}状态不为 无 "); |
| | | return false; |
| | | } |
| | | } |
| | | } |
| | | WMSTask wmsTask = new WMSTask() |
| | |
| | | S_SRC_NO = no, |
| | | N_PRIORITY = pri, |
| | | S_NOTE = note, |
| | | S_TWO_END_LOC = TwoEndLoc, |
| | | S_WORK_MODE = "agv", |
| | | S_B_STATE = "未执行", |
| | | S_CNTRS = cntrInfo, |
| | |
| | | task.T_END_TIME = DateTime.Now; |
| | | db.Updateable(task).UpdateColumns(it => new { it.S_B_STATE, it.T_END_TIME }).ExecuteCommand(); |
| | | } |
| | | |
| | | //plg 2025年6月13日 10:42:24 |
| | | if (task.S_END_LAREA == "YWLWJJB" && task.S_START_LAREA != "YWLRGDD") |
| | | { |
| | | var model = db.Queryable<Location>().Where(a => a.S_LOC_CODE == task.S_TWO_END_LOC).First(); |
| | | //先解锁终点 在锁定 |
| | | db.Ado.BeginTran(); |
| | | try |
| | | { |
| | | model.S_LOCK_STATE = "无"; |
| | | var res = db.Updateable(model).UpdateColumns(it => new { it.S_LOCK_STATE }).ExecuteCommand() > 0; |
| | | LogHelper.Info(task.S_TWO_END_LOC + "LockLoc:锁结果" + res); |
| | | db.Ado.CommitTran(); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | db.Ado.RollbackTran(); |
| | | LogHelper.Info("CreateTask 失败 " + ex.Message); |
| | | } |
| | | var b = TaskProcess.CreateTransport(task.S_SRC_NO, task.S_END_LOC, task.S_TWO_END_LOC, "原物料搬运-纸箱", task.S_CNTRS.Split(',').ToList(), task.N_START_LAYER, 1, task.N_CNTR_COUNT, task.N_PRIORITY); |
| | | } |
| | | } |
| | | internal static void Fail(WMSTask task) |
| | | { |
| | |
| | | LogHelper.Info(wmsTask.S_START_LOC + "LockLoc:锁结果" + res); |
| | | |
| | | model = db.Queryable<Location>().Where(a => a.S_LOC_CODE == wmsTask.S_END_LOC).First(); |
| | | |
| | | model.S_LOCK_STATE = "入库锁"; |
| | | res = db.Updateable(model).UpdateColumns(it => new { it.S_LOCK_STATE }).ExecuteCommand() > 0; |
| | | LogHelper.Info(wmsTask.S_END_LOC + "LockLoc:锁结果" + res); |
| | | |
| | | } |
| | | db.Insertable(wmsTask).ExecuteCommand(); |
| | | db.Ado.CommitTran(); |
| | |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | //LogHelper.Info(DateTime.Now.ToLongTimeString() + "=====" + ShuiGaiTask.ToString()); |
| | | return db.Queryable<WMSTask>().OrderBy(" N_PRIORITY DESC ").Where(a => a.S_B_STATE.Trim() == state).Take(10).ToList(); |
| | | return db.Queryable<WMSTask>().OrderBy(" N_PRIORITY DESC ").Where(a => a.S_B_STATE.Trim() == state).ToList(); |
| | | |
| | | } |
| | | |