| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Reflection.Emit; |
| | | using System.Runtime.CompilerServices; |
| | | 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; |
| | | using static HH.WCS.JiaTong.util.Settings; |
| | | |
| | | namespace HH.WCS.JiaTong.api |
| | | { |
| | |
| | | |
| | | |
| | | #region 佳通合肥接口业务 |
| | | |
| | | |
| | | public static object _lockCreateTask = new object(); |
| | | public static object _lockCreateItem = new object(); |
| | | /// <summary> |
| | | /// 立库任务下发=》创建任务 |
| | | /// </summary> |
| | |
| | | /// <returns></returns> |
| | | internal static Result Createtask(CreateTask model) |
| | | { |
| | | |
| | | Result result = new Result() { code = "0", msg = "创建成功" }; |
| | | if (model == null) |
| | | { |
| | |
| | | } |
| | | string Start = ""; //取货点 |
| | | 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.原材料库,通过物料确认任务来源 |
| | | |
| | | int n_type = 0; //任务来源 1.密炼立库 3.预备库 ,4.原材料库 |
| | | string Source = ""; |
| | | switch (areacode) |
| | | switch (taskData.source) |
| | | { |
| | | case "ML": |
| | | n_type = 1; |
| | | Source = "密炼"; |
| | | 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(); |
| | | Location startloc = new Location(); |
| | | |
| | | if (taskData.taskType == 1) //出库流程,通过物料机台计算线边货位 |
| | | Location endloc = null; |
| | | Location startloc = null; |
| | | lock (_lockCreateTask) |
| | | { |
| | | note = "出库"; |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | if (taskData.taskType == 1) //出库流程,通过物料机台计算线边货位 |
| | | { |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | Start = taskData.pickStation; |
| | | if (CreateCntrIteminfo(partData, taskData)) |
| | | note = "出库"; |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | endloc = Computeloc(CntrCode, taskData.dropStation, taskData.carrierType); |
| | | if (endloc != null) |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | Start = taskData.pickStation; |
| | | if (CreateCntrIteminfo(partData, taskData)) |
| | | { |
| | | End = endloc.S_CODE; |
| | | 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; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"机台编码:{taskData.dropStation},未找到可用货位"; |
| | | AddErrorInfo("寻找出库货位失败", result.msg, Source); |
| | | result.msg = "创建托盘物料信息失败"; |
| | | AddErrorInfo("创建托盘失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = "创建托盘物料信息失败"; |
| | | AddErrorInfo("创建托盘失败", result.msg, Source); |
| | | result.msg = $"Putin==> 任务起点:{taskData.pickStation}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("货位查找失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | else if (taskData.taskType == 2)//入库流程,直接使用起点货位和终点货位生成任务,起点需要有托盘 |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"Putin==> 任务起点:{taskData.pickStation}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("货位查找失败", result.msg, Source); |
| | | } |
| | | } |
| | | else if (taskData.taskType == 2)//入库流程,直接使用起点货位和终点货位生成任务,起点需要有托盘 |
| | | { |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).FirstOrDefault(); |
| | | if (CntrRel != null) |
| | | note = "入库"; |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | Start = startloc.S_CODE; |
| | | CntrCode = CntrRel.S_CNTR_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}不一致,请检查托盘码是否正确"; |
| | | AddErrorInfo("托盘码校检失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | CntrCode = CntrRel.S_CNTR_CODE; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据起点{Start},未找到托盘货位绑定关系"; |
| | | AddErrorInfo("托盘查找失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | //判断是否是空托回库 |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == CntrCode).First(); |
| | | if (CntrItem == null) |
| | | { |
| | | note = "空托回库";//井松空托回库,需要与叠盘机安全交互 |
| | | } |
| | | 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)//移库流程,直接使用起点货位和终点货位生成任务, |
| | | { |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | |
| | | 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)//原材料库需要判断是否需要分配电梯任务,创建分档任务 |
| | | { |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | Start = taskData.pickStation; |
| | | } |
| | | endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); |
| | | if (endloc != null) |
| | | { |
| | | End = taskData.dropStation; |
| | | } |
| | | |
| | | //判断楼层是否相等,如果不相同需要生成分段任务进行电梯调用 |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | 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(); |
| | | if (startArea == null || endArea == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,起点:{startloc.S_AREA_CODE},终点:{endloc.S_AREA_CODE}未找到对应库区"; |
| | | result.msg = $"根据起点{taskData.pickStation},找不到对应货位,请检查货位表"; |
| | | AddErrorInfo("货位查找失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | if (startArea.N_FLOOR == endArea.N_FLOOR) |
| | | { |
| | | //创建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_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 |
| | | }; |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); |
| | | if (endloc != null) |
| | | { |
| | | End = taskData.dropStation; |
| | | } |
| | | else if (startArea.N_FLOOR != endArea.N_FLOOR) |
| | | else |
| | | { |
| | | //楼层电梯分配 |
| | | var endloc1 = Settings.elevatorLoc.Find(a => a.Floor == startArea.N_FLOOR); |
| | | var startloc1 = Settings.elevatorLoc.Find(a => a.Floor == endArea.N_FLOOR); |
| | | |
| | | //创建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 |
| | | |
| | | |
| | | }; |
| | | |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask) && WCSHelper.CreateTask(wcsTask1)) |
| | | { |
| | | |
| | | LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | result.code = "1"; |
| | | result.msg = $"根据终点{End},找不到对应货位,请检查货位表"; |
| | | AddErrorInfo("货位查找失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | else if (taskData.taskType == 3)//移库流程,直接使用起点货位和终点货位生成任务, |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | } |
| | | else if (taskData.taskType == 5)//移库流程,直接使用起点货位和终点货位生成任务,并绑定托盘 |
| | | { |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | if (CreateCntrIteminfo(partData, taskData)) |
| | | { |
| | | note = "出库"; |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建托盘物料信息失败"; |
| | | AddErrorInfo("创建托盘失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | //暂存位回库 |
| | | else if (taskData.taskType == 6)//入库流程,直接使用起点货位和终点货位生成任务 |
| | | { |
| | | //根据托盘号找货位 |
| | | var CntrRel = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == partData.rfid).First(); |
| | | if (CntrRel != null) |
| | | { |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == CntrRel.S_LOC_CODE).First(); |
| | | if (startloc != null) |
| | | { |
| | | Start = startloc.S_CODE; |
| | | CntrCode = CntrRel.S_CNTR_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据托盘{partData.rfid},未找到托盘货位绑定关系"; |
| | | 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 == 7)//异常位 |
| | | { |
| | | note = "异常库区入库"; |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | if (CreateCntrIteminfo(partData, taskData)) |
| | | else if (taskData.taskType == 4)//原材料库需要判断是否需要分配电梯任务,创建分档任务 |
| | | { |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | Start = taskData.pickStation; |
| | | } |
| | | var EndLocs = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == taskData.dropStation).ToList(); |
| | | if (EndLocs.Count > 0) |
| | | endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First(); |
| | | if (endloc != null) |
| | | { |
| | | endloc = EndLocs.Find(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0); |
| | | if (endloc != null) |
| | | { |
| | | End = endloc.S_CODE; |
| | | } |
| | | else |
| | | End = taskData.dropStation; |
| | | } |
| | | |
| | | //判断楼层是否相等,如果不相同需要生成分段任务进行电梯调用 |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | 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(); |
| | | if (startArea == null || endArea == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"终点库区:{taskData.dropStation}无可用货位"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | result.msg = $"创建任务失败,起点:{startloc.S_AREA_CODE},终点:{endloc.S_AREA_CODE}未找到对应库区"; |
| | | AddErrorInfo("货位查找失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | if (startArea.N_FLOOR == endArea.N_FLOOR) |
| | | { |
| | | //创建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_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, |
| | | |
| | | |
| | | }; |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | // LocationHelper.LockLoc(End, 2); |
| | | |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else if (startArea.N_FLOOR != endArea.N_FLOOR) |
| | | { |
| | | string deviceName = "电梯1"; |
| | | if (startloc.S_WH_CODE == "103") |
| | | { |
| | | deviceName = "电梯2"; |
| | | } |
| | | var eleLoc = Settings.deviceInfos.Where(a => a.deviceName.Trim() == deviceName).FirstOrDefault(); |
| | | if (eleLoc == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"未找到仓库{startloc.S_WH_CODE}所对应的电梯,请检查配置文件"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | //根据任务数量判断送往哪个电梯 (具体电梯流程根据现场电梯数量) |
| | | string[] state = new string[] { "执行中", "开始取货", "取货完成", "开始卸货", "卸货完成" }; |
| | | |
| | | |
| | | var elevatorLoc = db.Queryable<Location>().Where(a => a.S_CODE == eleLoc.TN_Location).First(); |
| | | if (elevatorLoc == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据电梯配置文件货位:{eleLoc.TN_Location}未找到对于货位数据,请检查货位表"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | 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)) |
| | | { |
| | | |
| | | // LocationHelper.LockLoc(Start, 1); |
| | | //LocationHelper.LockLoc(End, 2); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据终点库区:{taskData.dropStation},未找到对应货位"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | else if (taskData.taskType == 5)//移库流程,直接使用起点货位和终点货位生成任务,并绑定托盘 |
| | | { |
| | | result.code = "1"; |
| | | 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; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"Createtask==> 任务类型有误"); |
| | | result.code = "1"; |
| | | result.msg = "任务类型:{taskData.taskType}不在规定范围内"; |
| | | AddErrorInfo("任务类型错误", result.msg, Source); |
| | | } |
| | | if (taskData.taskType != 4) |
| | | { |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | note = "出库"; |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | 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 = $"创建任务失败,起点{Start}有锁"; |
| | | AddErrorInfo("货位有锁", result.msg); |
| | | result.msg = "创建托盘物料信息失败"; |
| | | AddErrorInfo("创建托盘失败", result.msg, Source); |
| | | 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 = taskData.priority, |
| | | Z_TYPE = n_type, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | S_WMS_NO = taskData.wmsTaskNo, |
| | | S_NOTE = note |
| | | |
| | | }; |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | } |
| | | //暂存位回库 |
| | | else if (taskData.taskType == 6)//入库流程,直接使用起点货位和终点货位生成任务 |
| | | { |
| | | note = "入库"; |
| | | //根据托盘号找货位 |
| | | var CntrRel = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == partData.rfid).First(); |
| | | if (CntrRel != null) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == CntrRel.S_LOC_CODE).First(); |
| | | if (startloc != null) |
| | | { |
| | | Start = startloc.S_CODE; |
| | | CntrCode = CntrRel.S_CNTR_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据托盘{partData.rfid},未找到托盘货位绑定关系"; |
| | | 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 == 7)//异常位 |
| | | { |
| | | note = "异常库区入库"; |
| | | //创建托盘物料绑定信息,并计算终点货位 |
| | | if (CreateCntrIteminfo(partData, taskData)) |
| | | { |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | Start = taskData.pickStation; |
| | | } |
| | | var EndLocs = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == taskData.dropStation).ToList(); |
| | | if (EndLocs.Count > 0) |
| | | { |
| | | endloc = EndLocs.Find(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0); |
| | | if (endloc != null) |
| | | { |
| | | End = endloc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"终点库区:{taskData.dropStation}无可用货位"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据终点库区:{taskData.dropStation},未找到对应货位"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | 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; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"Createtask==> 任务类型有误"); |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | result.msg = "任务类型:{taskData.taskType}不在规定范围内"; |
| | | AddErrorInfo("任务类型错误", result.msg, Source); |
| | | } |
| | | if (taskData.taskType != 4) |
| | | { |
| | | 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 |
| | | |
| | | }; |
| | | 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; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | return result; |
| | | } |
| | |
| | | /// <returns></returns> |
| | | internal static Result TrayItembind(TrayItembind model) |
| | | { |
| | | |
| | | Result result = new Result() { code = "200", msg = "产出信息下发成功" }; |
| | | if (model == null) |
| | | { |
| | |
| | | AddErrorInfo("参数为空", result.msg); |
| | | return result; |
| | | } |
| | | try |
| | | lock (_lockCreateItem) |
| | | { |
| | | //创建托盘数据绑定关系 |
| | | if (ContainerHelper.CreateCntrItem(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight, model.Qty)) |
| | | try |
| | | { |
| | | //创建成功流程 |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "产出信息下发失败,托盘物料绑定关系创建失败"; |
| | | AddErrorInfo("创建绑定关系失败", result.msg, "Mes"); |
| | | |
| | | //创建托盘数据绑定关系 |
| | | if (ContainerHelper.CreateCntrItemTray(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight, model.Qty, model.ProductionTime, model.MaturityTime, model.PowderType)) |
| | | { |
| | | //创建成功流程 |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "产出信息下发失败,托盘物料绑定关系创建失败"; |
| | | AddErrorInfo("创建绑定关系失败", result.msg, "Mes"); |
| | | 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(); |
| | | /// <summary> |
| | | /// 点对点接口 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result Point(PointModel model) |
| | | { |
| | | Result result = new Result() { code = "200", msg = "入平库任务下发成功" }; |
| | | string Source = "Mes"; |
| | | |
| | | if (model == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "参数为null"; |
| | | AddErrorInfo("参数为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | //1.出平库,2入平库,3平库空工装呼叫,4平库余料回库,5粉料空托返回。 |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | string type = ""; |
| | | Location startloc = null; |
| | | Location endloc = null; |
| | | switch (model.Status) |
| | | { |
| | | case "1": |
| | | type = "出平库"; |
| | | break; |
| | | case "2": |
| | | type = "入平库"; |
| | | break; |
| | | case "3": |
| | | type = "平库空工装呼叫"; |
| | | break; |
| | | case "4": |
| | | type = "平库余料回库"; |
| | | break; |
| | | case "5": |
| | | type = "粉料空托返回"; |
| | | break; |
| | | } |
| | | if (string.IsNullOrEmpty(type)) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务类型{model.Status},不在规定范围"; |
| | | AddErrorInfo("任务类型错误", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | try |
| | | { |
| | | lock (_Point) |
| | | { |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.InitialLocation).First(); |
| | | if (startloc == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据起点{model.InitialLocation},找不到对应货位,请检查货位表"; |
| | | 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}不一致,请检查托盘码是否正确"; |
| | | 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) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据终点{model.TargetLocation},找不到对应货位,请检查货位表"; |
| | | AddErrorInfo("货位查找失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | #region 创建任务 |
| | | if (endloc != null && startloc != null) |
| | | { |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,起点:{startloc.S_CODE}有锁"; |
| | | AddErrorInfo("货位有锁", result.msg, Source); |
| | | return result; |
| | | } |
| | | //创建wcs任务 |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = type, |
| | | S_EQ_NO = model.TaskNumber, |
| | | S_START_LOC = startloc.S_CODE, |
| | | S_END_LOC = endloc.S_CODE, |
| | | 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_CNTR_COUNT = 1, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = model.Rfid, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | N_PRIORITY = 1, |
| | | Z_TYPE = 5 |
| | | }; |
| | | LogHelper.Info("创建点对点任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | if (type == "平库余料回库") |
| | | { //创建任务成功 更新余料信息 |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrItem != null) |
| | | { |
| | | CntrItem.F_WEIGHT = model.Weight.ToString(); |
| | | CntrItem.S_BS_TYPE = "余料"; |
| | | //CntrItem.F_QTY = float.Parse(model.qty); |
| | | //CntrItem.S_ITEM_STATE = model..QualityStatus; |
| | | |
| | | db.Updateable(CntrItem).UpdateColumns(a => new { a.F_WEIGHT, a.S_BS_TYPE }).ExecuteCommand(); |
| | | } |
| | | } |
| | | |
| | | LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | 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.ToString(); |
| | | LogHelper.Error("TrayItembind Error:" + ex.ToString(), ex); |
| | | LogHelper.Error("Putin Error:" + ex.ToString(), ex); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | public static object _Putin = new object(); |
| | | /// <summary> |
| | | /// 入平库 |
| | | /// </summary> |
| | |
| | | return result; |
| | | } |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | Location loc = new Location(); |
| | | Location loc = null; |
| | | |
| | | string Start = model.InitialLocation; //起点货位 |
| | | string itemcode = model.PartNumber; //物料编码 |
| | | string areacode = ""; |
| | | try |
| | | { |
| | | |
| | | #region 判断托盘绑定货位是否和下发绑定起点相同,如果没绑定托盘则绑定托盘 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrLoc != null) |
| | | lock (_Putin) |
| | | { |
| | | if (CntrLoc.S_LOC_CODE != Start) |
| | | #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}绑定位置不是起点:{Start}"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}无绑定物料数据"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("托盘绑定位置不同", result.msg, Source); |
| | | AddErrorInfo("托盘绑定物料数据为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | 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("查询货位绑定关系"); |
| | | //判断托盘与货位是否有绑定关系,如果没有则进行绑定 |
| | | // var cntrloc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | // Console.WriteLine($"获取绑定关系:{JsonConvert.SerializeObject(cntrloc)}"); |
| | | //if (cntrloc == null) |
| | | //{ |
| | | // // Console.WriteLine("绑定托盘"); |
| | | // List<string> cntrs = new List<string>() { model.Rfid }; |
| | | #endregion |
| | | |
| | | // LocationHelper.BindingLoc(Start, cntrs); |
| | | //} |
| | | //else |
| | | //{ |
| | | |
| | | // if (cntrloc.S_LOC_CODE != Start) |
| | | // { |
| | | |
| | | // LogHelper.Info($"Putin==>托盘:{model.Rfid}已和货位{cntrloc.S_LOC_CODE}有绑定关系"); |
| | | // result.code = "1"; |
| | | // result.msg = $"托盘:{model.Rfid}已和货位{cntrloc.S_LOC_CODE}有绑定关系"; |
| | | // } |
| | | |
| | | //} |
| | | #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") |
| | | #region 判断托盘绑定货位是否和下发绑定起点相同,如果没绑定托盘则绑定托盘 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrLoc != null) |
| | | { |
| | | areacode = "PMGQ"; |
| | | 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 |
| | | { |
| | | areacode = "PK2"; |
| | | 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; |
| | | } |
| | | areacode = "FLPK"; |
| | | // Console.WriteLine("查询货位绑定关系"); |
| | | //判断托盘与货位是否有绑定关系,如果没有则进行绑定 |
| | | // var cntrloc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | // Console.WriteLine($"获取绑定关系:{JsonConvert.SerializeObject(cntrloc)}"); |
| | | //if (cntrloc == null) |
| | | //{ |
| | | // // Console.WriteLine("绑定托盘"); |
| | | // List<string> cntrs = new List<string>() { model.Rfid }; |
| | | |
| | | //判断有无相同物料排 |
| | | loc = StorageCompute(itemcode, areacode); |
| | | if (loc == null) |
| | | // LocationHelper.BindingLoc(Start, cntrs); |
| | | //} |
| | | //else |
| | | //{ |
| | | |
| | | // if (cntrloc.S_LOC_CODE != Start) |
| | | // { |
| | | |
| | | // LogHelper.Info($"Putin==>托盘:{model.Rfid}已和货位{cntrloc.S_LOC_CODE}有绑定关系"); |
| | | // result.code = "1"; |
| | | // result.msg = $"托盘:{model.Rfid}已和货位{cntrloc.S_LOC_CODE}有绑定关系"; |
| | | // } |
| | | |
| | | //} |
| | | #endregion |
| | | |
| | | #region 根据起点货位的仓库编码 获取平库编码,并计算入库货位 |
| | | string End = ""; |
| | | var startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == Start).First(); |
| | | if (startloc != null) |
| | | { |
| | | //无相同物料排找空排 |
| | | loc = emptyRow(areacode); |
| | | } |
| | | if (loc != null) |
| | | { |
| | | End = loc.S_CODE; |
| | | //根据仓库 计算库区 |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | areacode = whcode.PMK; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | loc = StorageCompute(itemcode, areacode); |
| | | |
| | | if (loc != null) |
| | | { |
| | | End = loc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"库区:{areacode}无可用货位"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"库区:{areacode}无可用货位"; |
| | | result.msg = $"任务起点:{Start}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"任务起点:{Start}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | } |
| | | #endregion |
| | | |
| | | #region 创建任务 |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,起点:{Start}有锁"; |
| | | AddErrorInfo("货位有锁", result.msg, Source); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | //创建wcs任务 |
| | | var wcsTask = new WCSTask |
| | | #endregion |
| | | |
| | | #region 创建任务 |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "入平库", |
| | | S_EQ_NO = model.TaskNumber, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = End, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_END_WH = loc.S_WH_CODE, |
| | | S_END_AREA = loc.S_AREA_CODE, |
| | | N_CNTR_COUNT = 1, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = model.Rfid, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | Z_TYPE = n_type |
| | | }; |
| | | LogHelper.Info("创建入平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,起点:{Start}有锁"; |
| | | AddErrorInfo("货位有锁", result.msg, Source); |
| | | return result; |
| | | } |
| | | //创建wcs任务 |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "入平库", |
| | | S_EQ_NO = model.TaskNumber, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = End, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_END_WH = loc.S_WH_CODE, |
| | | S_END_AREA = loc.S_AREA_CODE, |
| | | N_CNTR_COUNT = 1, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = model.Rfid, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | N_PRIORITY = 1, |
| | | Z_TYPE = n_type |
| | | }; |
| | | LogHelper.Info("创建入平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | 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; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | return result; |
| | | } |
| | |
| | | LogHelper.Error("Putin Error:" + ex.ToString(), ex); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | |
| | | public static object _PutOut = new object(); |
| | | /// <summary> |
| | | /// 出平库 |
| | | /// </summary> |
| | |
| | | string Start = ""; |
| | | string End = ""; |
| | | string CntrCode = ""; |
| | | |
| | | string itemcode = model.PartNumber; |
| | | string cntrType = ""; |
| | | string areacode = ""; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | #endregion |
| | | |
| | | try |
| | | { |
| | | |
| | | #region 根据物料编码规则 计算出库库区 |
| | | //粉料从平库出库,其他物料需要从暂存区出库 |
| | | if (model.PartNumber.StartsWith("4X")) |
| | | lock (_PutOut) |
| | | { |
| | | areacode = "FLPK"; |
| | | cntrType = "PM"; |
| | | } |
| | | else |
| | | { |
| | | |
| | | if (model.PartNumber.StartsWith("3")) |
| | | #region 根据物料编码规则 计算出库库区 |
| | | //粉料从平库出库,其他物料需要从暂存区出库 |
| | | var locJt = db.Queryable<Location>().Where(a => a.S_AREA_CODE == model.WorkCenter).First(); |
| | | if (locJt == null) |
| | | { |
| | | cntrType = "RC"; |
| | | areacode = "KJZCW"; |
| | | result.code = "1"; |
| | | result.msg = $"根据机台编码:{model.WorkCenter}未找到对应货位"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | //根据仓库 计算库区 |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == locJt.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | if (model.PartNumber.StartsWith("4X")) |
| | | { |
| | | areacode = whcode.PMK; |
| | | cntrType = "PM"; |
| | | } |
| | | else if (model.PartNumber.StartsWith("32")) |
| | | { |
| | | areacode = whcode.ZCW2; |
| | | } |
| | | else |
| | | { |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据终点库区仓库编码:{locJt.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 根据物料编码计算出库货位,送往线边位置 |
| | | Location Endloc = null; |
| | | |
| | | //根据物料编码计算出库货位 |
| | | var loc = airlift(areacode, itemcode, model.PartLevel, model.PowderType); |
| | | if (loc != null) |
| | | { |
| | | Start = loc.S_CODE; |
| | | |
| | | var CntrRel = LocationHelper.GetLocCntrRel(loc.S_CODE).FirstOrDefault(); |
| | | CntrCode = CntrRel.S_CNTR_CODE; |
| | | //给终点用终点,没给终点用机台库区计算货位 |
| | | if (string.IsNullOrEmpty(model.TargetLocation)) |
| | | { |
| | | |
| | | Endloc = Computeloc(CntrCode, model.WorkCenter, cntrType); |
| | | if (Endloc != null) |
| | | { |
| | | 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 |
| | | { |
| | | |
| | | Endloc = db.Queryable<Location>().Where(a => a.S_CODE == model.TargetLocation).First(); |
| | | if (Endloc != null) |
| | | { |
| | | End = Endloc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"Computeloc==》根据终点货位:{model.TargetLocation} 未找到货位数据,请检查货位表"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,物料号{model.PartNumber}不属于规定物料"; |
| | | result.msg = $"任务物料:{itemcode}找不到对应库存"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("物料编码格式错误", result.msg, Source); |
| | | 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"; |
| | | //} |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 根据物料编码计算出库货位,送往线边位置 |
| | | var Endloc = new Location(); |
| | | //根据物料编码计算出库货位 |
| | | var loc = airlift(areacode, itemcode, model.PartLevel); |
| | | if (loc != null) |
| | | { |
| | | Start = loc.S_CODE; |
| | | //根据出库货位找到绑定托盘,获取入机台货位 |
| | | var CntrRel = LocationHelper.GetLocCntrRel(loc.S_CODE).FirstOrDefault(); |
| | | CntrCode = CntrRel.S_CNTR_CODE; |
| | | Endloc = Computeloc(CntrCode, model.WorkCenter, cntrType); |
| | | if (Endloc != null) |
| | | #region 任务创建 |
| | | if (string.IsNullOrEmpty(Start)) |
| | | { |
| | | End = Endloc.S_CODE; |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点"; |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"任务物料:{itemcode}找不到对应库存"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | } |
| | | #endregion |
| | | |
| | | #region 任务创建 |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | if (string.IsNullOrEmpty(End)) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的卸货点"; |
| | | return result; |
| | | } |
| | | if (loc.N_LOCK_STATE != 0) |
| | | { |
| | | result.code = "1"; |
| | |
| | | S_CNTR_CODE = CntrCode, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | N_PRIORITY = 1, |
| | | Z_TYPE = n_type |
| | | |
| | | }; |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LogHelper.Info("创建任务成功"); |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | return result; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | |
| | | } |
| | | |
| | | public static object _lockEmpty = new object(); |
| | | /// <summary> |
| | | /// 空工装回库 |
| | | /// </summary> |
| | |
| | | string Start = model.InitialLocation; |
| | | string itemcode = ""; |
| | | int endlayer = 1; |
| | | Location loc = new Location(); |
| | | Location loc = null; |
| | | string areacode = ""; |
| | | WCSTask mst = new WCSTask(); |
| | | List<WCSTask> msts = new List<WCSTask>(); |
| | | #endregion |
| | | |
| | | try |
| | | { |
| | | #region 判断托盘绑定货位是否和下发绑定起点相同 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrLoc != null) |
| | | lock (_lockEmpty) |
| | | { |
| | | if (CntrLoc.S_LOC_CODE != Start) |
| | | |
| | | |
| | | #region 根据货位楼层判断,3楼去往叠盘位 其他的回库 |
| | | var startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == Start).First(); |
| | | if (startloc != null) |
| | | { |
| | | LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}"); |
| | | if (!string.IsNullOrEmpty(startloc.S_NOTE1)) |
| | | { |
| | | //叠盘货位计算叠盘货位 |
| | | // 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 && a.C_ENABLE == "Y").ToList(); |
| | | var dploc = db.Queryable<Location>().Where(a => a.S_NOTE1.Trim() == startloc.S_NOTE1 + "叠盘" && a.S_WH_CODE.Trim() == startloc.S_WH_CODE).ToList(); |
| | | if (dploc.Count > 0) |
| | | { |
| | | // 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) |
| | | { |
| | | LogHelper.Info($"{startloc.S_NOTE1}叠盘位,都已经有锁或者已经叠满,请检查货位状态"); |
| | | result.code = "1"; |
| | | result.msg = $"{startloc.S_NOTE1}叠盘货位不可用,终点库区没有可用货位,请检查锁状态和数量"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | endlayer = loc.N_CURRENT_NUM + 1; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // LogHelper.Info($"根据货位楼层:{startloc.N_LAYER},仓库编码:{startloc.S_WH_CODE},货位备注:叠盘,未找到叠盘货位"); |
| | | result.code = "1"; |
| | | result.msg = $"{startloc.S_NOTE1}叠盘货位不可用,未找到可叠盘货位"; |
| | | LogHelper.Info($"根据货位备注:{startloc.S_NOTE1}叠盘,货位仓库:{startloc.S_WH_CODE},找不到叠盘货位"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else if (startloc.N_LAYER == 3) |
| | | { |
| | | //叠盘货位计算叠盘货位 |
| | | // 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 && a.C_ENABLE == "Y").ToList(); |
| | | 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)}"); |
| | | loc = dploc.FindAll(a => a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM < 6).OrderByDescending(a => a.N_CURRENT_NUM).FirstOrDefault(); |
| | | if (loc == null) |
| | | { |
| | | LogHelper.Info($"三楼货位叠盘位,都已经有锁或者已经叠满,请检查货位状态"); |
| | | result.code = "1"; |
| | | result.msg = $"叠盘货位不可用,终点库区没有可用货位,请检查锁状态和数量"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | endlayer = loc.N_CURRENT_NUM + 1; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | // LogHelper.Info($"根据货位楼层:{startloc.N_LAYER},仓库编码:{startloc.S_WH_CODE},货位备注:叠盘,未找到叠盘货位"); |
| | | result.code = "1"; |
| | | result.msg = $"叠盘货位不可用,未找到可叠盘货位"; |
| | | LogHelper.Info($"根据货位备注:叠盘,货位楼层:{startloc.N_LAYER},货位仓库:{startloc.S_WH_CODE},找不到叠盘货位"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | 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 && a.C_ENABLE == "Y").ToList(); |
| | | var KjDploc = db.Queryable<Location>().Where(a => a.S_NOTE.Trim() == "片胶堆叠位" && a.S_WH_CODE.Trim() == startloc.S_WH_CODE).ToList(); |
| | | if (KjDploc.Count > 0) |
| | | { |
| | | loc = KjDploc.FindAll(a => a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM < 6).OrderByDescending(a => a.N_CURRENT_NUM).FirstOrDefault(); |
| | | if (loc == null) |
| | | { |
| | | LogHelper.Info($"片胶堆叠位,都已经有锁或者已经叠满,请检查货位状态"); |
| | | result.code = "1"; |
| | | result.msg = $"叠盘货位不可用,终点库区没有可用货位,请检查锁状态和数量"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | endlayer = loc.N_CURRENT_NUM + 1; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"根据货位备注:片胶堆叠位,货位仓库:{startloc.S_WH_CODE},找不到叠盘货位"); |
| | | result.code = "1"; |
| | | result.msg = $"叠盘货位不可用"; |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | #region 根据起点货位类型,获得回库库区 |
| | | //根据仓库 计算库区 |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | if (string.IsNullOrEmpty(startloc.S_NOTE)) |
| | | { |
| | | areacode = whcode.PMK; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($" {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | //回库货位计算库区货位 |
| | | if (string.IsNullOrEmpty(areacode)) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"起点货位{startloc.S_CODE}无法找到回库库区,请检查起点货位"; |
| | | LogHelper.Info($" {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | loc = StorageCompute(itemcode, areacode); |
| | | if (loc == null) |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"库区:{areacode}没有可用货位"; |
| | | LogHelper.Info($" {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | // LogHelper.Info($"库区:{areacode}没有可用货位"); |
| | | |
| | | } |
| | | //else |
| | | //{ |
| | | |
| | | // result.code = "1"; |
| | | // result.msg = $"库区:{areacode}无可用货位"; |
| | | // LogHelper.Info($"{result.msg}"); |
| | | // AddErrorInfo("查找货位失败", result.msg, Source); |
| | | // return result; |
| | | //} |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}"; |
| | | AddErrorInfo("托盘绑定位置不同", result.msg); |
| | | result.msg = $"Empty==> 任务起点:{Start}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"{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; |
| | | } |
| | | #endregion |
| | | #endregion |
| | | |
| | | #region 根据货位楼层判断,3楼去往叠盘位 其他的回库 |
| | | var startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == Start).First(); |
| | | if (startloc != null) |
| | | { |
| | | if (startloc.N_LAYER == 3) |
| | | #region 创建任务 |
| | | if (startloc != null && loc != null) |
| | | { |
| | | //叠盘货位计算叠盘货位 |
| | | 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) |
| | | if (startloc.N_LOCK_STATE != 0 && loc.N_LOCK_STATE != 0) |
| | | { |
| | | // 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, Source); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | endlayer = loc.N_CURRENT_NUM + 1; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"叠盘货位不可用"; |
| | | LogHelper.Info($"根据货位备注:叠盘,货位楼层:{startloc.N_LAYER},货位仓库:{startloc.S_WH_CODE},找不到叠盘货位"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | result.msg = $"创建任务失败,起点货位状态{startloc.N_LOCK_STATE},起点货位状态:{loc.N_LOCK_STATE}"; |
| | | AddErrorInfo("货位有锁", result.msg); |
| | | return result; |
| | | } |
| | | } |
| | | else if (startloc.S_NOTE == "PM") |
| | | { |
| | | //找块胶堆叠区 |
| | | var KjDploc = db.Queryable<Location>().Where(a => a.S_NOTE.Trim() == "片胶堆叠位" && a.S_WH_CODE.Trim() == startloc.S_WH_CODE).ToList(); |
| | | if (KjDploc.Count > 0) |
| | | LogHelper.Info("创建空托回库任务,终点货位为空:" + JsonConvert.SerializeObject(loc)); |
| | | //创建wcs任务 |
| | | var wcsTask = new WCSTask |
| | | { |
| | | loc = KjDploc.FindAll(a => a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM < 6).OrderByDescending(a => a.N_CURRENT_NUM).FirstOrDefault(); |
| | | if (loc == null) |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "空工装回库", |
| | | S_EQ_NO = model.TaskNumber, |
| | | 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, |
| | | S_END_WH = loc.S_WH_CODE, |
| | | S_END_AREA = loc.S_AREA_CODE, |
| | | N_CNTR_COUNT = 1, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = model.Rfid, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = endlayer, |
| | | N_PRIORITY = 1, |
| | | S_B_STATE = "等待推送", |
| | | Z_TYPE = 5 |
| | | }; |
| | | LogHelper.Info("创建空托回库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | //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(); |
| | | if (itemcntr != null) { db.Deleteable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).ExecuteCommand(); } |
| | | var container = db.Queryable<Container>().Where(a => a.S_CODE.Trim() == model.Rfid).First(); |
| | | if (container == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"叠盘货位不可用"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | container = new Container { S_CODE = model.Rfid }; |
| | | db.Insertable<Container>(container).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | endlayer = loc.N_CURRENT_NUM + 1; |
| | | } |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"根据货位备注:片胶堆叠位,货位仓库:{startloc.S_WH_CODE},找不到叠盘货位"); |
| | | result.code = "1"; |
| | | result.msg = $"叠盘货位不可用"; |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | result.msg = $"任务创建失败,请检查起点货位状态后重新下发"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | #region 根据托盘找呼叫空托任务,并获得出库库区 |
| | | msts = WCSHelper.GetTaskBycntrcode(model.Rfid.Trim()); |
| | | if (msts.Count() > 0) |
| | | { |
| | | 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; |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,根据托盘编码{model.Rfid}未找到托盘出库任务"; |
| | | LogHelper.Info($"{result.msg}"); |
| | | AddErrorInfo("查找任务失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | if (string.IsNullOrEmpty(areacode)) |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,根据托盘编码{model.Rfid}找到出库任务{mst.S_CODE}的起点库区为空"; |
| | | LogHelper.Info($"{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 |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"库区:{areacode}无可用货位"; |
| | | LogHelper.Info($"{result.msg}"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"Empty==> 任务起点:{Start}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"{result.msg}"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 创建任务 |
| | | if (!string.IsNullOrEmpty(Start) && loc != null) |
| | | { |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,起点{Start}有锁"; |
| | | AddErrorInfo("货位有锁", result.msg); |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | //创建wcs任务 |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "空工装回库", |
| | | S_EQ_NO = model.TaskNumber, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = loc.S_CODE, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_END_WH = loc.S_WH_CODE, |
| | | S_END_AREA = loc.S_AREA_CODE, |
| | | N_CNTR_COUNT = 1, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = model.Rfid, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = endlayer, |
| | | Z_TYPE = 5 |
| | | }; |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(loc.S_CODE, 1); |
| | | // 空托回库判断托盘有无绑定物料信息 如果有则删除 |
| | | var itemcntr = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (itemcntr != null) { db.Deleteable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).ExecuteCommand(); } |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public static object _lockcallfixture = new object(); |
| | | |
| | | /// <summary> |
| | | /// 空工装呼叫 |
| | |
| | | #region 变量 |
| | | string Start = ""; |
| | | string End = model.TargetLocation; |
| | | string itemcode = ""; |
| | | |
| | | string areacode = ""; |
| | | string cntrcode = ""; |
| | | Location startloc = new Location(); |
| | | Location startloc = null; |
| | | // startloc = LocationHelper.GetLocByAreacode(areacode, model.CarrierType); |
| | | #endregion |
| | | |
| | | try |
| | | { |
| | | #region 根据仓库编码判断库区 并计算出库货位 |
| | | var endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == End).First(); |
| | | if (endloc != null) |
| | | lock (_lockcallfixture) |
| | | { |
| | | if (endloc.S_WH_CODE == "101") |
| | | #region 根据仓库编码判断库区 并计算出库货位 |
| | | var endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == End).First(); |
| | | //根据仓库 计算库区 |
| | | if (endloc != null) |
| | | { |
| | | // itemcode = "TP"; |
| | | areacode = "PMGQ"; |
| | | } |
| | | else |
| | | { |
| | | //itemcode = "TP"; |
| | | areacode = "PK2"; |
| | | } |
| | | areacode = "FLPK"; |
| | | //计算出库托盘 |
| | | startloc = airlift(areacode, itemcode); |
| | | if (startloc != null) |
| | | { |
| | | var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == startloc.S_CODE).First(); |
| | | if (cntr != null) |
| | | #region 校验终点是否可送 |
| | | if (endloc.N_CURRENT_NUM >= 1 || endloc.N_LOCK_STATE != 0) |
| | | { |
| | | Start = cntr.S_LOC_CODE; |
| | | cntrcode = cntr.S_CNTR_CODE; |
| | | result.code = "1"; |
| | | result.msg = $"终点货位:{End}不可用"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("货位不可用", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == endloc.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | areacode = whcode.PMK; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建空工装呼叫任务==>根据货位{endloc.S_CODE}未找到托盘货位绑定关系"; |
| | | result.msg = $"根据起点仓库编码:{endloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | //计算出库托盘 |
| | | startloc = LocationHelper.GetLocByAreacode(areacode, model.CarrierType); |
| | | if (startloc != null) |
| | | { |
| | | var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == startloc.S_CODE).First(); |
| | | if (cntr != null) |
| | | { |
| | | Start = cntr.S_LOC_CODE; |
| | | cntrcode = cntr.S_CNTR_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建空工装呼叫任务==>根据货位{endloc.S_CODE}未找到托盘货位绑定关系"; |
| | | LogHelper.Info($"callfixture:{result.msg}"); |
| | | AddErrorInfo("查找托盘失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建空工装呼叫任务==>根据库区:{areacode},托盘类型:{model.CarrierType}找不到对应空托"; |
| | | LogHelper.Info($"callfixture:{result.msg}"); |
| | | AddErrorInfo("查找托盘失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"任务起点:{End}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"callfixture:{result.msg}"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region 创建任务 |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,起点{Start}有锁"; |
| | | AddErrorInfo("货位有锁", result.msg); |
| | | result.msg = $"任务起点:{End}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"callfixture:{result.msg}"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | //创建wcs任务 |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "空工装呼叫", |
| | | S_EQ_NO = model.TaskNumber, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = End, |
| | | 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_CNTR_COUNT = 1, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = cntrcode, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | Z_TYPE = 5 |
| | | #endregion |
| | | |
| | | }; |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | #region 创建任务 |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | 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 = "空工装呼叫", |
| | | S_EQ_NO = model.TaskNumber, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = End, |
| | | 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_CNTR_COUNT = 1, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = cntrcode, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | Z_TYPE = 5, |
| | | N_PRIORITY = 1, |
| | | S_NOTE = "粉料" |
| | | }; |
| | | LogHelper.Info("创建呼叫空托任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | 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; |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | return result; |
| | | #endregion |
| | | } |
| | | return result; |
| | | #endregion |
| | | |
| | | |
| | | } |
| | | catch (Exception ex) |
| | |
| | | |
| | | } |
| | | |
| | | public static object _lockItemBack = new object(); |
| | | /// <summary> |
| | | /// 余料返回 |
| | | /// </summary> |
| | |
| | | string Start = model.InitialLocation; |
| | | string End = ""; |
| | | string itemcode = model.PartNumber; |
| | | Location loc = new Location(); |
| | | Location loc = null; |
| | | string areacode = ""; |
| | | WCSTask mst = new WCSTask(); |
| | | List<WCSTask> msts = new List<WCSTask>(); |
| | | #endregion |
| | | |
| | | try |
| | | { |
| | | #region 判断托盘绑定货位是否和下发绑定起点相同 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrLoc != null) |
| | | lock (_lockItemBack) |
| | | { |
| | | if (CntrLoc.S_LOC_CODE != Start) |
| | | |
| | | |
| | | #region 判断托盘绑定货位是否和下发绑定起点相同 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrLoc != null) |
| | | { |
| | | |
| | | 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 = $"创建任务失败,托盘:{model.Rfid}未找到绑定货位"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("查找托盘货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 余料返回根据托盘找出库任务 |
| | | //余料返回根据托盘找出库任务 |
| | | //msts = WCSHelper.GetTaskBycntrcode(model.Rfid); |
| | | //if (msts.Count() > 0) |
| | | //{ |
| | | // msts.RemoveAll(a => string.IsNullOrEmpty(a.S_CNTR_CODE)); |
| | | // mst = msts.OrderByDescending(a => a.T_CREATE).FirstOrDefault(); |
| | | //} |
| | | //if (mst != null) |
| | | //{ |
| | | // areacode = mst.S_START_AREA; |
| | | //} |
| | | //else |
| | | //{ |
| | | // 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); |
| | | // return result; |
| | | //} |
| | | #endregion |
| | | |
| | | #region 根据物料编码 判断回库还是回到对应暂存区 |
| | | var startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == Start).First(); |
| | | if (startloc != null) |
| | | { |
| | | //粉料直接回库,其他物料需要去对应的暂存区 |
| | | if (model.PartNumber.StartsWith("4X")) |
| | | { |
| | | areacode = "FLPK"; |
| | | loc = StorageCompute(itemcode, areacode); |
| | | if (loc == null) |
| | | if (CntrLoc.S_LOC_CODE != Start) |
| | | { |
| | | loc = emptyRow(areacode); |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("托盘绑定位置不同", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (model.PartNumber.StartsWith("3")) |
| | | if (db.Insertable(new LocCntrRel() { S_CNTR_CODE = model.Rfid, S_LOC_CODE = Start }).ExecuteCommand() <= 0) |
| | | { |
| | | areacode = "KJYLZCW"; |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,物料号{model.PartNumber}不属于规定物料"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}绑定货位{Start}失败"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("物料编码格式错误", result.msg, Source); |
| | | AddErrorInfo("托盘绑定货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | var EndLocs = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == areacode).ToList(); |
| | | if (EndLocs.Count > 0) |
| | | |
| | | } |
| | | #endregion |
| | | |
| | | #region 根据物料编码 判断回库还是回到对应暂存区 |
| | | var startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == Start).First(); |
| | | if (startloc != null) |
| | | { |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | loc = EndLocs.Find(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0); |
| | | //粉料直接回库,其他物料需要去对应的暂存区 |
| | | #region 根据物料判断回库库区 |
| | | if (model.PartNumber.StartsWith("4X")) |
| | | { |
| | | areacode = whcode.PMK; |
| | | //loc = StorageCompute(itemcode, areacode); |
| | | //if (loc == null) |
| | | //{ |
| | | // loc = emptyRow(areacode); |
| | | //} |
| | | } |
| | | else if (model.PartNumber.StartsWith("32")) |
| | | { |
| | | areacode = whcode.ZCW2; |
| | | } |
| | | else |
| | | { |
| | | 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, Source); |
| | | return result; |
| | | } |
| | | |
| | | if (loc != null) |
| | | { |
| | | End = loc.S_CODE; |
| | |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"终点库区:{areacode}无可用货位"; |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | result.msg = $"库区:{areacode}无可用货位"; |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"根据终点库区:{areacode},未找到对应货位"; |
| | | result.msg = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件"; |
| | | LogHelper.Info($"Putin==> {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; |
| | | |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"库区:{areacode}无可用货位"; |
| | | result.msg = $"货位:{Start}找不到对应货位"; |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"货位:{Start}找不到对应货位"; |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #endregion |
| | | #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 = "余料返回", |
| | | S_EQ_NO = model.TaskNumber, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = End, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_END_WH = loc.S_WH_CODE, |
| | | S_END_AREA = loc.S_AREA_CODE, |
| | | N_CNTR_COUNT = 1, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = model.Rfid, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | N_PRIORITY = 1, |
| | | Z_TYPE = 5 |
| | | |
| | | #region 创建任务 |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | }; |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | //创建任务成功 更新余料信息 |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrItem != null) |
| | | { |
| | | CntrItem.F_WEIGHT = model.LotList[0].Weight.ToString(); |
| | | CntrItem.S_BS_TYPE = "余料"; |
| | | CntrItem.F_QTY = float.Parse(model.LotList[0].qty); |
| | | CntrItem.S_ITEM_STATE = model.LotList[0].QualityStatus; |
| | | |
| | | db.Updateable(CntrItem).UpdateColumns(a => new { a.F_WEIGHT, a.S_BS_TYPE }).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | var cir = new CntrItemDetail |
| | | { |
| | | S_CNTR_CODE = model.Rfid, |
| | | S_ITEM_CODE = itemcode, |
| | | S_ITEM_NAME = model.PartNumber, |
| | | S_ITEM_SPEC = model.PartDesc, |
| | | F_QTY = float.Parse(model.LotList[0].qty), |
| | | S_BS_TYPE = "余料", |
| | | F_WEIGHT = model.LotList[0].Weight.ToString(), |
| | | S_ITEM_STATE = model.LotList[0].QualityStatus, |
| | | D_EXP_DATE = model.LotList[0].MaturityTime, |
| | | D_PRD_DATE = model.LotList[0].ProductionTime |
| | | }; |
| | | db.Insertable<CntrItemDetail>(cir).ExecuteCommand(); |
| | | } |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,起点{Start}有锁"; |
| | | AddErrorInfo("货位有锁", result.msg); |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | //创建wcs任务 |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "余料返回", |
| | | S_EQ_NO = model.TaskNumber, |
| | | S_START_LOC = Start, |
| | | S_END_LOC = End, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_END_WH = loc.S_WH_CODE, |
| | | S_END_AREA = loc.S_AREA_CODE, |
| | | N_CNTR_COUNT = 1, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = model.Rfid, |
| | | N_START_LAYER = 1, |
| | | N_END_LAYER = 1, |
| | | Z_TYPE = 5 |
| | | |
| | | }; |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //创建任务成功 更新余料信息 |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrItem != null) |
| | | { |
| | | CntrItem.F_WEIGHT = model.LotList[0].Weight.ToString(); |
| | | CntrItem.S_BS_TYPE = "余料"; |
| | | CntrItem.F_QTY = float.Parse(model.LotList[0].qty); |
| | | CntrItem.S_ITEM_STATE = model.LotList[0].QualityStatus; |
| | | |
| | | db.Updateable(CntrItem).UpdateColumns(a => new { a.F_WEIGHT, a.S_BS_TYPE }).ExecuteCommand(); |
| | | } |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | return result; |
| | | } |
| | |
| | | itemInfo.REMARK1 = model.StewingTime; |
| | | itemInfo.REMARK2 = model.OverdueTime; |
| | | itemInfo.S_MP_TYPE = model.Unit; |
| | | if (db.Insertable<TN_Material>(itemInfo).ExecuteCommand()>0) |
| | | if (db.Insertable<TN_Material>(itemInfo).ExecuteCommand() > 0) |
| | | { |
| | | LogHelper.Info($"add:物料编码:{model.PartNumber}的物料主数据已同步"); |
| | | } ; |
| | | } |
| | | ; |
| | | return result; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | 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); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result CreatelevatorTask(Elevator model) |
| | | internal static Result CreatelevatorTask(ElevatorModel model) |
| | | { |
| | | Result result = new Result() { code = "200", msg = "点对点任务创建成功" }; |
| | | string Source = "MES"; |
| | | if (model == null) |
| | | Result result = new Result() { code = "200", msg = "电梯搬运任务创建成功" }; |
| | | string Source = "WMS"; |
| | | if (model.Data == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "参数为null"; |
| | |
| | | |
| | | var startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.Data.start_loc_code).First(); |
| | | |
| | | // var endloc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == model.Data.end_loc_code && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.C_ENABLE == "Y").First(); |
| | | var endloc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == model.Data.end_loc_code && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).First(); |
| | | |
| | | |
| | |
| | | if (startloc.N_LOCK_STATE != 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,起点{startloc.S_CODE}有锁"; |
| | | result.msg = $"创建任务失败,起点{startloc.S_CODE}有锁,电梯有其他任务,请等待电梯任务完成"; |
| | | 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) |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"起点{model.Data.start_loc_code}未查询绑定托盘"; |
| | | 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) |
| | | string deviceName = "电梯1"; |
| | | if (startloc.S_WH_CODE == "103") |
| | | { |
| | | deviceName = "电梯2"; |
| | | } |
| | | var eleLoc = Settings.deviceInfos.Where(a => a.deviceName.Trim() == deviceName).FirstOrDefault(); |
| | | if (eleLoc == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,根据货位编码:{dtcode}未找到电梯货位"; |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | result.msg = $"未找到仓库{startloc.S_WH_CODE}所对应的电梯,请检查配置文件"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | //根据任务数量判断送往哪个电梯 (具体电梯流程根据现场电梯数量) |
| | | string[] state = new string[] { "执行中", "开始取货", "取货完成", "开始卸货", "卸货完成" }; |
| | | |
| | | //根据电梯数量判断送往哪个电梯 (具体电梯流程根据现场电梯数量) |
| | | |
| | | //创建wcs分段任务 |
| | | var elevatorLoc = db.Queryable<Location>().Where(a => a.S_CODE == eleLoc.TN_Location).First(); |
| | | if (elevatorLoc == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据电梯配置文件货位:{eleLoc.TN_Location}未找到对于货位数据,请检查货位表"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | int mst = db.Queryable<WCSTask>().Where(a => a.S_TYPE.Contains("电梯") && state.Contains(a.S_B_STATE) && (a.S_END_LOC == elevatorLoc.S_CODE || a.S_START_LOC == elevatorLoc.S_CODE)).Count(); |
| | | if (mst > 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"电梯存在任务,不允许创建电梯任务"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | var wcsTask = new WCSTask |
| | | { |
| | | |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "电梯1", |
| | | S_TYPE = "1楼电梯搬运", |
| | | S_EQ_NO = model.Data.task_no, |
| | | S_START_LOC = startloc.S_CODE, |
| | | S_END_LOC = Diantiloc.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, |
| | | N_SCHEDULE_TYPE = 1, |
| | | S_CNTR_CODE = cntr.S_CNTR_CODE, |
| | | N_END_LAYER = 1, |
| | | Z_TYPE = 6 |
| | | }; |
| | | var wcsTask1 = new WCSTask |
| | | { |
| | | 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, |
| | | S_CNTR_CODE = cntr.S_CNTR_CODE, |
| | | N_END_LAYER = 1, |
| | | Z_TYPE = 6 |
| | | Z_TYPE = 6, |
| | | N_PRIORITY = 1, |
| | | S_B_STATE = "电梯推送" |
| | | }; |
| | | |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask) && WCSHelper.CreateTask(wcsTask1)) |
| | | { |
| | | |
| | | LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LogHelper.Info("创建任务成功"); |
| | | var device = Settings.deviceInfos.Where(a => a.TN_Location == startloc.S_CODE).FirstOrDefault(); |
| | | var loc = LocationHelper.GetLocByLoc(endloc.S_CODE); |
| | | if (device == null) |
| | | { |
| | | LogHelper.Info($"根据任务起点:{startloc.S_CODE},未找到对应电梯配置文件"); |
| | | } |
| | | if (loc == null) |
| | | { |
| | | LogHelper.Info($"根据任务起点:{endloc.S_CODE},未找到对应货位"); |
| | | } |
| | | if (device != null && loc != null) |
| | | { |
| | | int value = 0; |
| | | if (loc.N_LAYER == 1) value = 1; |
| | | else if (loc.N_LAYER == 2) value = 3; |
| | | else if (loc.N_LAYER == 3) value = 5; |
| | | |
| | | ModbusHelper.WriteSingleRegister(40089, value, device.address, 1024); |
| | | ModbusHelper.WriteSingleRegister(40102, 1, device.address, 1024); |
| | | } |
| | | |
| | | //LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | //LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"物料主数据创建失败 错误信息:{ex}"; |
| | | result.msg = $"电梯搬运任务创建失败 错误信息:{ex}"; |
| | | LogHelper.Error("点对点任务 Error:" + ex.ToString(), ex); |
| | | return result; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 电梯任务推送 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result DT(DTModel model) |
| | | { |
| | | Result result = new Result() { code = "200", msg = "电梯任务推送成功" }; |
| | | string Source = "WMS"; |
| | | if (model == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "参数为null"; |
| | | AddErrorInfo("参数为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | try |
| | | { |
| | | if (model.prepare == "1") |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | //修改对应电梯任务进行推送 |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"一楼电梯搬运任务推送失败 prepare{model.prepare}不为1"; |
| | | LogHelper.Info(result.msg); |
| | | return result; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"电梯任务推送失败 错误信息:{ex}"; |
| | | LogHelper.Error("点对点任务 Error:" + ex.ToString(), ex); |
| | | return result; |
| | | } |
| | | } |
| | | /// <summary> |
| | | /// 货位信息上传 |
| | | /// </summary> |
| | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 库位清空 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result ClearLocCntr(ClearTask model) |
| | | { |
| | | Result result = new Result() { code = "200", msg = "库位清除成功" }; |
| | | string Source = "MES"; |
| | | if (model == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "参数为null"; |
| | | AddErrorInfo("参数为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | string loc = model.LocationNum; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | lock (_lockCreateItem) |
| | | { |
| | | try |
| | | { |
| | | var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First(); |
| | | if (location != null) |
| | | { |
| | | var loccntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc).First(); |
| | | |
| | | if (loccntr != null) |
| | | { |
| | | string cntrcode = loccntr.S_CNTR_CODE; |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == cntrcode).First(); |
| | | if (CntrItem != null) |
| | | { |
| | | //清除托盘物料绑定关系 |
| | | db.Deleteable<CntrItemDetail>().Where(it => it.S_CNTR_CODE.Trim() == CntrItem.S_CNTR_CODE).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLocCntr 托盘{cntrcode}无物料绑定关系"); |
| | | } |
| | | if (LocationHelper.UnBindingLoc(loc, new List<string>() { cntrcode })) |
| | | { |
| | | LogHelper.Info($"清除托盘货位关系成功"); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLocCntr 货位{loc}无托盘货位绑定关系"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据货位:{loc}找不到货位关系"; |
| | | AddErrorInfo("货位为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"ClearLocCntr Error:{ex}"); |
| | | db.Ado.CommitTran(); |
| | | result.code = "1"; |
| | | result.msg = $"Error:{ex}"; |
| | | return result; |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | return result; |
| | | } |
| | | /// <summary> |
| | | /// 库位清空 |
| | | /// </summary> |
| | |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try |
| | | { |
| | | var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First(); |
| | | if (location != null) |
| | | lock (_lockCreateItem) |
| | | { |
| | | var loccntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc).First(); |
| | | |
| | | if (loccntr != null) |
| | | var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First(); |
| | | if (location != null) |
| | | { |
| | | |
| | | string cntrcode = loccntr.S_CNTR_CODE; |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == cntrcode).First(); |
| | | if (CntrItem != null) |
| | | var loccntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc.Trim()).ToList(); |
| | | if (loccntr.Count > 0) |
| | | { |
| | | |
| | | 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(); |
| | | var cntrcodes = loccntr.Select(a => a.S_CNTR_CODE.Trim()).ToList(); |
| | | if (LocationHelper.Clear(loc, cntrcodes)) |
| | | { |
| | | LogHelper.Info($"ClearLoc 库位清除成功"); |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLoc 库位清除失败"); |
| | | result.code = "1"; |
| | | result.msg = "库位清除失败"; |
| | | AddErrorInfo("库位清除失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLoc 托盘{cntrcode}无物料绑定关系"); |
| | | result.code = "1"; |
| | | result.msg = $" ClearLoc 货位{loc}无托盘货位绑定关系"; |
| | | AddErrorInfo("库位清除失败", result.msg, Source); |
| | | return result; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLoc 货位{loc}无托盘货位绑定关系"); |
| | | result.code = "1"; |
| | | result.msg = $"根据货位:{loc}找不到货位关系"; |
| | | AddErrorInfo("货位为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据货位:{loc}找不到货位关系"; |
| | | AddErrorInfo("货位为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | |
| | | |
| | | 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" || int.Parse(a.errCode2) > 1 || int.Parse(a.faildCode) > 1).Count; |
| | | device.AgvChargeQty = agvDeviceInfo.FindAll(a => a.errCode2 == "1").Count; |
| | | device.AgvRunQty = agvDeviceInfo.FindAll(a => a.agvErrCode == "0" && a.errCode2 == "0" && a.faildCode == "1").Count; |
| | | //foreach (var agv in agvDeviceInfo) |
| | | //{ |
| | | // string agvErrorInfo = GetAgvAlarmSendCodeTwo(agv.agvNo, agv.agvErrCode, agv.errCode2, agv.faildCode); |
| | | // deviceInfos.Add(new DeviceInfos() { AgvNo = agv.agvNo, AgvInfo = agvErrorInfo }); |
| | | //} |
| | | } |
| | | // device.DeviceInfos = deviceInfos; |
| | | |
| | | return device; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// agv小车故障码处理 |
| | | /// </summary> |
| | | ///<param name="agvNo">车号</param> |
| | | /// <param name="errCode1">错误码1</param> |
| | | /// <param name="errCode2">错误码2</param> |
| | | /// <param name="faildCode">错误码3</param> |
| | | /// <returns></returns> |
| | | private static string GetAgvAlarmSendCodeTwo(string agvNo, string errCode1, string errCode2, string faildCode) |
| | | { |
| | | string result = ""; |
| | | //将报警信息整合 |
| | | string binSW1 = Convert.ToString(int.Parse(errCode1), 2).PadLeft(25, '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(); |
| | | |
| | | var AgvError = Settings.agvError.Where(a => a.agvNo.Contains(agvNo)).FirstOrDefault(); |
| | | if (AgvError != null) |
| | | { |
| | | for (int i = 0; i <= arr1.Length; i++) |
| | | { |
| | | if (arr1[i] == '1') |
| | | { |
| | | var ErrorInfo = AgvError.AgvErrorCode1.Find(a => a.ErrorCode == i); |
| | | if (ErrorInfo != null) |
| | | { |
| | | result = result + "," + $"{ErrorInfo.ErrorInfo}"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | for (int i = 0; i <= arr2.Length; i++) |
| | | { |
| | | if (arr1[i] == '1') |
| | | { |
| | | var ErrorInfo = AgvError.AgvErrorCode2.Find(a => a.ErrorCode == i); |
| | | if (ErrorInfo != null) |
| | | { |
| | | result = result + "," + $"{ErrorInfo.ErrorInfo}"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | for (int i = 0; i <= arr3.Length; i++) |
| | | { |
| | | if (arr1[i] == '1') |
| | | { |
| | | var ErrorInfo = AgvError.AgvFaildCode.Find(a => a.ErrorCode == i); |
| | | if (ErrorInfo != null) |
| | | { |
| | | result = result + "," + $"{ErrorInfo.ErrorInfo}"; |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | |
| | | } |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 合肥佳通业务方法 |
| | | |
| | | |
| | | /// <summary> |
| | | /// 托盘入库算法 |
| | | /// </summary> |
| | |
| | | /// <returns></returns> |
| | | internal static Location StorageCompute(string itemcode, string areacode) |
| | | { |
| | | //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 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(); |
| | | // 867C567A-183C-413B-9891-15D8F6DE1620 |
| | | |
| | | // var aaa = db.Deleteable<Location>(a => a.S_ID == "867C567A-183C-413B-9891-15D8F6DE1620").ExecuteCommand(); |
| | | // var aaa = db.Deleteable<Location>(a => a.S_ID.Trim() == "867C567A-183C-413B-9891-15D8F6DE1620").ExecuteCommand(); |
| | | |
| | | //LogHelper.Info($"方法:StorageCompute"); |
| | | var list = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM == 0 && a.S_AREA_CODE == areacode && a.N_LOCK_STATE == 0).ToList(); |
| | | // LogHelper.Info($"创建空托回库任务,终点货位集合:根据库区编码:{areacode}" + list.Count); |
| | | //list.RemoveAll(a => string.IsNullOrEmpty(a.S_CODE.Trim()) || a.S_CODE == null || string.IsNullOrWhiteSpace(a.S_CODE.Trim())); |
| | | // list = list.FindAll(a => a.N_ROW > 0 && a.N_COL > 0); |
| | | //LogHelper.Info("创建空托回库任务,终点货位集合过滤:" + list.Count); |
| | | |
| | | 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(); |
| | | |
| | | } |
| | | } |
| | | } |
| | | if (result != null) |
| | | { |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"根据货物编码{list[i].S_CODE}未找到托盘货位绑定关系"); |
| | | } |
| | | } |
| | | result = FindEndcolByLocList(list); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 根据物料计算托盘出库 |
| | |
| | | /// <param name="areacode"></param> |
| | | /// <param name="itemcode"></param> |
| | | /// <param name="level">物料等级</param> |
| | | /// <param name="powderType">机型</param> |
| | | /// <returns></returns> |
| | | internal static Location airlift(string areacode, string itemcode, string level = "") |
| | | internal static Location |
| | | airlift(string areacode, string itemcode, string level, string powderType) |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | Location result = null; |
| | |
| | | //} |
| | | |
| | | #endregion |
| | | var loc = LocationHelper.GetLocByItemCode(areacode, itemcode, level); |
| | | result = FindStartcolByLoclist(loc); |
| | | var loc = LocationHelper.GetLocByItemCode(areacode, itemcode, level, powderType); |
| | | LogHelper.Info($"airlift=>根据库区编码:{areacode},物料编码:{itemcode},机型{powderType},物料等级计算出有托盘货位{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; |
| | | } |
| | | |
| | |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 立库任务下发创建托盘物料绑定关系 |
| | | /// </summary> |
| | |
| | | } |
| | | else |
| | | { |
| | | return ContainerHelper.CreateCntrItem(taskData.pickStation, partData.rfid, partData.partNumber, partData.partDesc, partData.partType, taskData.carrierType, partData.lotNumber, partData.weight, partData.unit, |
| | | taskData.tyreType, taskData.supplier, taskData.receiveLot, taskData.subpool, partData.productionTime, partData.maturityTime, taskData.grade); |
| | | 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, partData.qty, partData.qtyCfg); |
| | | } |
| | | |
| | | } |
| | | |
| | | //internal static bool CreateCntrLoc(taskData taskData) |
| | | //{ |
| | | // if ( taskData == null) |
| | | // { |
| | | // LogHelper.Info($"CreateCntrIteminfo==> 立库任务下发参数有空,创建物料托盘绑定关系失败"); |
| | | // return false; |
| | | // } |
| | | // else |
| | | // { |
| | | // LocationHelper.BindingLoc(taskData.pickStation,new List<string>() { taskData.rfid }); |
| | | |
| | | // } |
| | | |
| | | //} |
| | | private static object _lockLocation = new object(); |
| | | /// <summary> |
| | | /// 根据托盘编码,机台编码,工装类型计算机台线边区域 |
| | | /// </summary> |
| | |
| | | /// <returns></returns> |
| | | internal static Location Computeloc(string cntrcode, string jtcode, string cntrType) |
| | | { |
| | | Location End = new Location(); |
| | | Location End = null; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | |
| | | // 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} 未找到空货位数据,请检查货位表"); |
| | | } |
| | | if (string.IsNullOrEmpty(cntrType)) |
| | | { |
| | | End = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无").First(); |
| | | } |
| | | else |
| | | { |
| | | End = 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 && a.S_LOCK_STATE == "无").First(); |
| | | } |
| | | |
| | | if (End == null) |
| | | { |
| | | LogHelper.Info($"Computeloc==》根据机台分组:{jtcode},工装类型:{cntrType} 未找到空货位数据,请检查货位表"); |
| | | } |
| | | |
| | | } |
| | | return End; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 合肥佳通接口调用信息 |
| | | /// </summary> |
| | | /// <param name="source">系统来源</param> |
| | | /// <param name="name">接口名称</param> |
| | | /// <param name="type">请求地址类型</param> |
| | | /// <param name="body">请求参数</param> |
| | | /// <param name="url">请求地址</param> |
| | | /// <param name="err">错误信息</param> |
| | | /// <returns></returns> |
| | | public static bool AddInfo(string source, string name, string body, string err, string type, string url) |
| | | { |
| | | bool result = false; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try |
| | | { |
| | | var error = new GT_Interface_Exc |
| | | { |
| | | S_SOURCE = source, |
| | | S_NAME = name, |
| | | S_TYPE = type, |
| | | S_URL = url, |
| | | S_BODY = body, |
| | | S_ERR = err |
| | | }; |
| | | if (result = db.Insertable<GT_Interface_Exc>(error).ExecuteCommand() > 0) |
| | | { |
| | | |
| | | } |
| | | //else |
| | | //{ |
| | | // //添加失败重新添加 |
| | | // AddErrorInfo(errorInfo, remake, areacode, taskno); |
| | | //} |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"AddInfo Error:{ex.Message}"); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 找终点空货位 |
| | | /// </summary> |
| | | /// <param name="locations"></param> |
| | | /// <returns></returns> |
| | | internal static Location FindEndcolByLocList(List<Location> locations, string itemcode) |
| | | internal static Location FindEndcolByLocList(List<Location> locations) |
| | | { |
| | | try |
| | | { |
| | |
| | | var rows = locations.Select(a => a.N_ROW).Distinct().ToList(); |
| | | for (int i = 0; i < rows.Count; i++) |
| | | { |
| | | |
| | | var rowList = locations.Where(r => r.N_ROW == rows[i]).ToList(); |
| | | // LogHelper.Info($"当前排:{rows[i]},获得货位{JsonConvert.SerializeObject(rowList)}"); |
| | | if (rowList.Count(a => a.N_CURRENT_NUM == 0) > 0) |
| | | { |
| | | 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 && a.N_LOCK_STATE == 0 && a.C_ENABLE == "Y").FirstOrDefault(); |
| | | other = rowList.OrderBy(a => a.N_COL).Where(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).FirstOrDefault(); |
| | | //if (full == null) |
| | | //{ |
| | | // //没有满位,那就找最小的空位 |
| | |
| | | // other = db.Queryable<Location>().OrderBy(a => a.N_LAYER).Where(a => (string.IsNullOrEmpty(a.C_ENABLE) || a.C_ENABLE.Trim() != "禁用") && a.S_AREA_CODE == other.S_AREA_CODE && a.N_ROW == other.N_ROW && a.N_COL > other.N_COL).First(); |
| | | // //LogHelper.Info($"禁用选择后一个货位{result}", "成品"); |
| | | //} |
| | | |
| | | if (other != null) |
| | | { |
| | | if (other.S_CODE != null && !string.IsNullOrEmpty(other.S_CODE)) |
| | | { |
| | | end = other; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return end; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 找终点空货位计算排锁 |
| | | /// </summary> |
| | | /// <param name="locations"></param> |
| | | /// <returns></returns> |
| | | internal static Location FindEndcolByLocListLock(List<Location> locations) |
| | | { |
| | | try |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | Location end = null; |
| | | //根据终点货位找空闲货位 |
| | | var rows = locations.Select(a => a.N_ROW).Distinct().ToList(); |
| | | for (int i = 0; i < rows.Count; i++) |
| | | { |
| | | var rowList = locations.Where(r => r.N_ROW == rows[i]).ToList(); |
| | | if (rowList.Count(a => a.S_LOCK_STATE != "无") == 0 && rowList.Count(a => a.N_CURRENT_NUM == 0) > 0) |
| | | { |
| | | Location other = null; |
| | | //当前排没有锁并且有空位置 |
| | | //先找满位,然后后面一位要么是空,要么不存在 |
| | | var full = rowList.OrderByDescending(a => a.N_COL).Where(a => a.N_CURRENT_NUM == 1).FirstOrDefault(); |
| | | if (full == null) |
| | | { |
| | | //没有满位,那就找最小的空位 |
| | | other = rowList.OrderBy(a => a.N_COL).FirstOrDefault(); |
| | | } |
| | | else |
| | | { |
| | | other = rowList.OrderBy(a => a.N_COL).Where(a => a.N_COL > full.N_COL).FirstOrDefault(); |
| | | } |
| | | |
| | | if (other != null) |
| | | { |
| | | end = other; |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | |
| | | |
| | | |
| | | internal static CodeInfo GetCodeInfo(string code, string org) |
| | | { |
| | |
| | | { |
| | | lock (AGVDeviceReceiveLock) |
| | | { |
| | | |
| | | var db = new SqlHelper<HangChaAGV>().GetInstance(); |
| | | var agvDeviceInfo = db.Queryable<HangChaAGV>().Where(a => a.agvNo.Trim() == forkliftNo).First(); |
| | | if (agvDeviceInfo == null) |