| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | private static object lockObj = new object(); |
| | | /// <summary> |
| | |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result EquipmentInfo(EquipmentInfoModel model) |
| | | internal static Result NotifyDeviceSignal(NotifyDeviceSignalModel model) |
| | | { |
| | | Result result = new Result { resultCode = 0, resultMsg = "创建成功" }; |
| | | if (model == null) |
| | |
| | | string cntrcode = model.CntrNo; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | if (model.DeviceNo=="1")//叠盘机 |
| | | if (model.DeviceNo == "1")//叠盘机 |
| | | { |
| | | |
| | | } |
| | | else //入库空 |
| | | { |
| | | #region 获取起点信息 |
| | | //根据托盘获取起点信息 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == cntrcode).First(); |
| | | if (CntrLoc == null) |
| | | #region 获取起点信息,并判断空托是否叠满 |
| | | //根据起点 获取绑定托盘数量 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE == model.Loc).ToList(); |
| | | if (CntrLoc.Count < 4) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据托盘:{cntrcode}未找到绑定托盘"; |
| | | LogHelper.Info($"creattask:根据托盘:{cntrcode}未找到绑定托盘"); |
| | | result.resultMsg = $"根据货位:{model.Loc}获取托盘数量小于4"; |
| | | LogHelper.Info($"EquipmentInfo:根据货位:{model.Loc}获取托盘数量小于4"); |
| | | return result; |
| | | } |
| | | startloc = LocationHelper.GetLoc(CntrLoc.S_LOC_CODE); |
| | | else |
| | | { |
| | | //拼接托盘号 |
| | | cntrcode = CntrLoc.Select(a => a.S_CNTR_CODE).ToString(); |
| | | } |
| | | startloc = LocationHelper.GetLoc(model.Loc); |
| | | if (startloc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据起点:{CntrLoc.S_LOC_CODE}未找到货位信息"; |
| | | LogHelper.Info($"creattask:根据起点:{CntrLoc.S_LOC_CODE}未找到货位信息"); |
| | | result.resultMsg = $"根据起点:{model.Loc}未找到货位信息"; |
| | | LogHelper.Info($"EquipmentInfo:根据起点:{model.Loc}未找到货位信息"); |
| | | return result; |
| | | } |
| | | |
| | |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"未计算到立库终点货位,请检查货位情况"; |
| | | LogHelper.Info($"creattask:未计算到立库终点货位,请检查货位情况"); |
| | | LogHelper.Info($"EquipmentInfo:未计算到立库终点货位,请检查货位情况"); |
| | | return result; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 创建任务 |
| | |
| | | } |
| | | #endregion |
| | | } |
| | | else //入库空 |
| | | { |
| | | //入库口申请入库 |
| | | if (model.SignalType == 1) |
| | | { |
| | | #region 获取起点信息 |
| | | //根据托盘获取起点信息 |
| | | 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}未找到绑定托盘"); |
| | | 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}未找到货位信息"); |
| | | return result; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 计算立库终点 |
| | | endloc = LocationHelper.InStorage(startloc); |
| | | if (endloc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"未计算到立库终点货位,请检查货位情况"; |
| | | LogHelper.Info($"EquipmentInfo:未计算到立库终点货位,请检查货位情况"); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 创建任务 |
| | | if (startloc != null && endloc != null) |
| | | { |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "入库", |
| | | 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 = 2, |
| | | S_CNTR_CODE = cntrcode |
| | | }; |
| | | LogHelper.Info("创建入平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | } |
| | | #endregion |
| | | } |
| | | //入库空申请叠盘 |
| | | else |
| | | { |
| | | //判断设备状态是否属于叠盘状态 |
| | | var DeviceStatu = db.Queryable<EquipmentStatus>().Where(a => a.deviceNo == model.DeviceNo).First(); |
| | | if (DeviceStatu != null && DeviceStatu.Status == "1") |
| | | { |
| | | #region 获取起点信息 |
| | | //根据托盘获取起点信息 |
| | | 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}未找到绑定托盘"); |
| | | 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}未找到货位信息"); |
| | | return result; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | #region 获取终点信息 |
| | | string DiePanLoc = ""; |
| | | //根据托盘获取起点信息 |
| | | endloc = db.Queryable<Location>().Where(a => a.S_CODE == DiePanLoc).First(); |
| | | if (endloc == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"根据货位编码:{DiePanLoc}未找到叠盘货位"; |
| | | LogHelper.Info($"EquipmentInfo:根据货位编码:{DiePanLoc}未找到叠盘货位"); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #region 创建任务 |
| | | if (startloc != null && endloc != null) |
| | | { |
| | | var wcsTask = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "入库", |
| | | 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 = 2, |
| | | S_CNTR_CODE = cntrcode |
| | | }; |
| | | LogHelper.Info("创建入平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | else |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"当前叠盘机状态不属于叠盘状态,不允许空托叠托"; |
| | | LogHelper.Info($"EquipmentInfo:当前叠盘机状态不属于叠盘状态,不允许空托叠托"); |
| | | return result; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | return result; |