| | |
| | | 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; |
| | |
| | | var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).FirstOrDefault(); |
| | | if (CntrRel != null) |
| | | { |
| | | CntrCode = CntrRel.S_CNTR_CODE; |
| | | 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 |
| | | //{ |
| | |
| | | #endregion |
| | | |
| | | #region 任务创建 |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | if (string.IsNullOrEmpty(Start)) |
| | | { |
| | | if (loc.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 = loc.S_WH_CODE, |
| | | S_START_AREA = loc.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 = n_type |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点"; |
| | | return result; |
| | | } |
| | | if (string.IsNullOrEmpty(End)) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的卸货点"; |
| | | return result; |
| | | } |
| | | if (loc.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 = loc.S_WH_CODE, |
| | | S_START_AREA = loc.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 = n_type |
| | | |
| | | }; |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LogHelper.Info("创建任务成功"); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | }; |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LogHelper.Info("创建任务成功"); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return result; |
| | |
| | | #region 根据仓库编码判断库区 并计算出库货位 |
| | | var endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == End).First(); |
| | | //根据仓库 计算库区 |
| | | |
| | | if (endloc != null) |
| | | { |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == endloc.S_WH_CODE).FirstOrDefault(); |
| | |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | //计算出库托盘 |
| | | startloc = LocationHelper.GetLocByAreacode(areacode, model.CarrierType); |
| | |
| | | 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; |
| | | } |
| | | |
| | | } |
| | |
| | | /// </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 (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) |
| | | { |
| | | if (LocationHelper.UnBindingLoc(loc, new List<string>() { cntrcode })) |
| | | { |
| | | LogHelper.Info($"清除托盘货位关系成功"); |
| | | } |
| | | //清除托盘物料绑定关系 |
| | | 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($"清除托盘货位关系成功"); |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | //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> |
| | | /// 根据托盘编码,机台编码,工装类型计算机台线边区域 |