| | |
| | | |
| | | |
| | | private static object lockObj = new object(); |
| | | |
| | | /// <summary> |
| | | /// 创建任务 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result createtask(CreateTaskModel model) |
| | | internal static Result<Empty> createtask(CreateTaskModel model) |
| | | { |
| | | Result result = new Result { resultCode = 0, resultMsg = "创建成功" }; |
| | | Result<Empty> result = new Result<Empty> { Code = 0, Msg = "创建成功" }; |
| | | if (model == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = "入参为空"; |
| | | result.Code = -1; |
| | | result.Msg = "入参为空"; |
| | | return result; |
| | | } |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | |
| | | { |
| | | try |
| | | { |
| | | |
| | | // 1 空托回库 |
| | | if (model.TaskType == "1") |
| | | { |
| | |
| | | startloc = LocationHelper.GetLoc(model.startBit); |
| | | if (startloc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据起点:{model.startBit}未找到货位信息"; |
| | | LogHelper.Info($"creattask:根据起点:{model.startBit}未找到货位信息"); |
| | | result.Code = -1; |
| | | result.Msg = $"根据起点:{model.startBit}未找到货位信息"; |
| | | LogHelper.Info($"creattask:{result.Msg}"); |
| | | return result; |
| | | } |
| | | else |
| | |
| | | var cntr = LocationHelper.GetLocCntrRel(endloc.S_CODE).FirstOrDefault(); |
| | | if (cntr == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据起点:{model.startBit}未找到绑定托盘"; |
| | | LogHelper.Info($"creattask:根据起点:{model.startBit}未找到绑定托盘"); |
| | | result.Code = -1; |
| | | result.Msg = $"根据起点:{model.startBit}未找到绑定托盘"; |
| | | LogHelper.Info($"creattask:{result.Msg}"); |
| | | return result; |
| | | } |
| | | else |
| | |
| | | endloc = LocationHelper.InStorage(startloc); |
| | | if (endloc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"未计算到立库终点货位,请检查货位情况"; |
| | | LogHelper.Info($"creattask:未计算到立库终点货位,请检查货位情况"); |
| | | result.Code = -1; |
| | | result.Msg = $"未计算到立库终点货位,请检查货位情况"; |
| | | LogHelper.Info($"creattask:{result.Msg}"); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 创建作业 |
| | | if (startloc != null && endloc != null) |
| | | { |
| | | //创建作业 |
| | | var wcsTask = new WMSTask |
| | | { |
| | | S_CODE = WMSHelper.GenerateTaskNo(), |
| | | S_TYPE = Type, |
| | | N_TYPE = int.Parse(model.TaskType), |
| | | S_START_LOC = start, |
| | | S_END_LOC = endloc.S_CODE, |
| | | S_CNTR_CODE = cntrcode, |
| | | S_END_WH = endloc.S_WH_CODE, |
| | | S_START_WH = startloc.S_WH_CODE, |
| | | S_START_AREA = startloc.S_AREA_CODE, |
| | | S_END_AREA = endloc.S_AREA_CODE, |
| | | |
| | | }; |
| | | LogHelper.Info("创建作业:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WMSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | LogHelper.Info("创建作业成功"); |
| | | //空托回库成功,如果存在物料数据,删除 |
| | | var itemcntr = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == cntrcode).First(); |
| | | if (itemcntr != null) { db.Deleteable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == cntrcode).ExecuteCommand(); } |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | // 2 出库 |
| | | if (model.TaskType == "2") |
| | | { |
| | | Type = "出库"; |
| | | |
| | | #region 获取终点信息 |
| | | startloc = LocationHelper.GetLoc(model.endBit); |
| | | if (startloc == null) |
| | | { |
| | | result.Code = -1; |
| | | result.Msg = $"根据终点:{model.startBit}未找到货位信息"; |
| | | LogHelper.Info($"creattask:{result.Msg}"); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 根据物料计算出库托盘,先进先出,优先出外侧 |
| | | //先计算内侧货位,判断是否有单组托盘 |
| | | var locations = LocationHelper.GetLocByItemCodeOrderyTime("", model.ItemCode); |
| | | if (locations.Count > 0) |
| | | { |
| | | endloc = locations.OrderBy(a => a.N_COL).First(); |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 创建作业 |
| | |
| | | } |
| | | else |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"任务类型有误,{model.TaskType}任务类型不是规定任务类型"; |
| | | LogHelper.Info($"creattask:任务类型有误,{model.TaskType}任务类型不是规定任务类型"); |
| | | result.Code = -1; |
| | | result.Msg = $"任务类型有误,{model.TaskType}任务类型不是规定任务类型"; |
| | | LogHelper.Info($"creattask:{result.Msg}"); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | return result; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"{ex.ToString()}"; |
| | | result.Code = -1; |
| | | result.Msg = $"{ex.ToString()}"; |
| | | return result; |
| | | |
| | | } |
| | |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result NotifyDeviceSignal(NotifyDeviceSignalModel model) |
| | | internal static Result<Empty> NotifyDeviceSignal(NotifyDeviceSignalModel model) |
| | | { |
| | | Result result = new Result { resultCode = 0, resultMsg = "创建成功" }; |
| | | Result<Empty> result = new Result<Empty> { Code = 0, Msg = "创建成功" }; |
| | | if (model == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = "入参为空"; |
| | | result.Code = -1; |
| | | result.Msg = "入参为空"; |
| | | return result; |
| | | } |
| | | Location endloc = new Location(); |
| | |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE == model.Loc).ToList(); |
| | | if (CntrLoc.Count < 4) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据货位:{model.Loc}获取托盘数量小于4"; |
| | | LogHelper.Info($"EquipmentInfo:根据货位:{model.Loc}获取托盘数量小于4"); |
| | | result.Code = -1; |
| | | result.Msg = $"根据货位:{model.Loc}获取托盘数量小于4"; |
| | | LogHelper.Info($"EquipmentInfo:{result.Msg}"); |
| | | return result; |
| | | } |
| | | else |
| | |
| | | startloc = LocationHelper.GetLoc(model.Loc); |
| | | if (startloc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据起点:{model.Loc}未找到货位信息"; |
| | | LogHelper.Info($"EquipmentInfo:根据起点:{model.Loc}未找到货位信息"); |
| | | result.Code = -1; |
| | | result.Msg = $"根据起点:{model.Loc}未找到货位信息"; |
| | | LogHelper.Info($"EquipmentInfo:{result.Msg}"); |
| | | return result; |
| | | } |
| | | |
| | |
| | | endloc = LocationHelper.InStorage(startloc); |
| | | if (endloc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"未计算到立库终点货位,请检查货位情况"; |
| | | LogHelper.Info($"EquipmentInfo:未计算到立库终点货位,请检查货位情况"); |
| | | result.Code = -1; |
| | | result.Msg = $"未计算到立库终点货位,请检查货位情况"; |
| | | LogHelper.Info($"EquipmentInfo:{result.Msg}"); |
| | | return result; |
| | | } |
| | | |
| | |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == cntrcode).First(); |
| | | if (CntrLoc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据托盘:{cntrcode}未找到绑定托盘"; |
| | | LogHelper.Info($"EquipmentInfo:根据托盘:{cntrcode}未找到绑定托盘"); |
| | | result.Code = -1; |
| | | result.Msg = $"根据托盘:{cntrcode}未找到绑定托盘"; |
| | | LogHelper.Info($"EquipmentInfo:{result.Msg}"); |
| | | return result; |
| | | } |
| | | startloc = LocationHelper.GetLoc(CntrLoc.S_LOC_CODE); |
| | | if (startloc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据起点:{CntrLoc.S_LOC_CODE}未找到货位信息"; |
| | | LogHelper.Info($"EquipmentInfo:根据起点:{CntrLoc.S_LOC_CODE}未找到货位信息"); |
| | | result.Code = -1; |
| | | result.Msg = $"根据起点:{CntrLoc.S_LOC_CODE}未找到货位信息"; |
| | | LogHelper.Info($"EquipmentInfo:{result.Msg}"); |
| | | return result; |
| | | } |
| | | |
| | |
| | | endloc = LocationHelper.InStorage(startloc); |
| | | if (endloc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"未计算到立库终点货位,请检查货位情况"; |
| | | result.Code = -1; |
| | | result.Msg = $"未计算到立库终点货位,请检查货位情况"; |
| | | LogHelper.Info($"EquipmentInfo:未计算到立库终点货位,请检查货位情况"); |
| | | return result; |
| | | } |
| | |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == cntrcode).First(); |
| | | if (CntrLoc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据托盘:{cntrcode}未找到绑定托盘"; |
| | | LogHelper.Info($"EquipmentInfo:根据托盘:{cntrcode}未找到绑定托盘"); |
| | | result.Code = -1; |
| | | result.Msg = $"根据托盘:{cntrcode}未找到绑定托盘"; |
| | | LogHelper.Info($"EquipmentInfo:{result.Msg}"); |
| | | return result; |
| | | } |
| | | startloc = LocationHelper.GetLoc(CntrLoc.S_LOC_CODE); |
| | | if (startloc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据起点:{CntrLoc.S_LOC_CODE}未找到货位信息"; |
| | | LogHelper.Info($"EquipmentInfo:根据起点:{CntrLoc.S_LOC_CODE}未找到货位信息"); |
| | | result.Code = -1; |
| | | result.Msg = $"根据起点:{CntrLoc.S_LOC_CODE}未找到货位信息"; |
| | | LogHelper.Info($"EquipmentInfo:{result.Msg}"); |
| | | return result; |
| | | } |
| | | |
| | |
| | | endloc = db.Queryable<Location>().Where(a => a.S_CODE == DiePanLoc).First(); |
| | | if (endloc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据货位编码:{DiePanLoc}未找到叠盘货位"; |
| | | LogHelper.Info($"EquipmentInfo:根据货位编码:{DiePanLoc}未找到叠盘货位"); |
| | | result.Code = -1; |
| | | result.Msg = $"根据货位编码:{DiePanLoc}未找到叠盘货位"; |
| | | LogHelper.Info($"EquipmentInfo:{result.Msg}"); |
| | | return result; |
| | | } |
| | | #endregion |
| | |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | } |
| | | |
| | | |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"当前叠盘机状态不属于叠盘状态,不允许空托叠托"; |
| | | LogHelper.Info($"EquipmentInfo:当前叠盘机状态不属于叠盘状态,不允许空托叠托"); |
| | | result.Code = -1; |
| | | result.Msg = $"当前叠盘机状态不属于叠盘状态,不允许空托叠托"; |
| | | LogHelper.Info($"EquipmentInfo:{result.Msg}"); |
| | | return result; |
| | | } |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | internal static Result<Empty> ApplyDest(ApplyDestModel model) |
| | | { |
| | | Result<Empty> result = new Result<Empty> { Code = 0, Msg = "创建成功" }; |
| | | if (model == null) |
| | | { |
| | | result.Code = -1; |
| | | result.Msg = "入参为空"; |
| | | return result; |
| | | } |
| | | |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 获取托盘物料信息 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result<Empty> GetCntrInfo(GetCntrInfoModel model) |
| | | { |
| | | Result<Empty> result = new Result<Empty> { Code = 0, Msg = "创建成功" }; |
| | | if (model == null) |
| | | { |
| | | result.Code = -1; |
| | | result.Msg = "入参为空"; |
| | | return result; |
| | | } |
| | | |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | string cntrCode = model.CntrNo; |
| | | |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE == cntrCode).ToList(); |
| | | if (CntrItem.Count > 0) |
| | | { |
| | | |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 绑定托盘物料 |