| | |
| | | |
| | | |
| | | public static object _lockCreateTask = new object(); |
| | | public static object _lockCreateItem = new object(); |
| | | /// <summary> |
| | | /// 立库任务下发=》创建任务 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | |
| | | internal static Result Createtask(CreateTask model) |
| | | { |
| | | Result result = new Result() { code = "0", msg = "创建成功" }; |
| | |
| | | if (startloc != null) |
| | | { |
| | | Start = startloc.S_CODE; |
| | | var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).FirstOrDefault(); |
| | | var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).OrderBy(a => a.T_CREATE).FirstOrDefault(); |
| | | if (CntrRel != null) |
| | | { |
| | | if (CntrRel.S_CNTR_CODE!= partData.rfid) |
| | | if (CntrRel.S_CNTR_CODE != partData.rfid) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据起点:{Start}获取托盘:{CntrRel.S_CNTR_CODE}与下发托盘:{partData.rfid}不一致,请检查托盘码是否正确"; |
| | |
| | | { |
| | | CntrCode = CntrRel.S_CNTR_CODE; |
| | | } |
| | | |
| | | |
| | | } |
| | | //else |
| | | //{ |
| | |
| | | /// <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, model.ProductionTime, model.MaturityTime)) |
| | | try |
| | | { |
| | | //创建成功流程 |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "产出信息下发失败,托盘物料绑定关系创建失败"; |
| | | AddErrorInfo("创建绑定关系失败", result.msg, "Mes"); |
| | | |
| | | //创建托盘数据绑定关系 |
| | | if (ContainerHelper.CreateCntrItem(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight, model.Qty, model.ProductionTime, model.MaturityTime)) |
| | | { |
| | | //创建成功流程 |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "产出信息下发失败,托盘物料绑定关系创建失败"; |
| | | AddErrorInfo("创建绑定关系失败", result.msg, "Mes"); |
| | | return result; |
| | | } |
| | | return result; |
| | | } |
| | | return result; |
| | | catch (Exception ex) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = ex.ToString(); |
| | | LogHelper.Error("TrayItembind Error:" + ex.ToString(), ex); |
| | | return result; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = ex.ToString(); |
| | | LogHelper.Error("TrayItembind Error:" + ex.ToString(), ex); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | //判断有无相同物料排 |
| | | |
| | | loc = StorageCompute(itemcode, areacode); |
| | | //if (loc == null) |
| | | //{ |
| | | // //无相同物料排找空排 |
| | | // loc = emptyRow(areacode); |
| | | //} |
| | | |
| | | if (loc != null) |
| | | { |
| | | End = loc.S_CODE; |
| | |
| | | { |
| | | areacode = whcode.PMK; |
| | | cntrType = "PM"; |
| | | } |
| | | else if (model.PartNumber.StartsWith("32")) |
| | | { |
| | | areacode = whcode.ZCW2; |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | lock (_lockEmpty) |
| | | { |
| | | #region 判断托盘绑定货位是否和下发绑定起点相同 |
| | | //var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | //if (CntrLoc != null) |
| | | //{ |
| | | // if (CntrLoc.S_LOC_CODE != Start) |
| | | // { |
| | | // LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}"); |
| | | // result.code = "1"; |
| | | // result.msg = $"创建任务失败,托盘:{model.Rfid}绑定位置不是起点:{Start}"; |
| | | // AddErrorInfo("托盘绑定位置不同", result.msg); |
| | | // return result; |
| | | // } |
| | | //} |
| | | //else |
| | | //{ |
| | | // LogHelper.Info($"ItemBack:创建任务失败,托盘:{model.Rfid}未找到绑定货位"); |
| | | // result.code = "1"; |
| | | // result.msg = $"创建任务失败,托盘:{model.Rfid}未找到绑定货位"; |
| | | // AddErrorInfo("查找托盘货位失败", result.msg); |
| | | // return result; |
| | | //} |
| | | #endregion |
| | | |
| | | |
| | | #region 根据货位楼层判断,3楼去往叠盘位 其他的回库 |
| | | var startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == Start).First(); |
| | | if (startloc != null) |
| | | { |
| | | if (startloc.N_LAYER == 3) |
| | | 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) |
| | | { |
| | |
| | | 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) |
| | | { |
| | |
| | | // 空托回库判断托盘有无绑定物料信息 如果有则删除 |
| | | 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) |
| | | { |
| | | container = new Container { S_CODE = model.Rfid }; |
| | | db.Insertable<Container>(container).ExecuteCommand(); |
| | | } |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | |
| | | { |
| | | lock (_lockcallfixture) |
| | | { |
| | | |
| | | |
| | | #region 根据仓库编码判断库区 并计算出库货位 |
| | | var endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == End).First(); |
| | | //根据仓库 计算库区 |
| | | if (endloc != null) |
| | | { |
| | | #region 校验终点是否可送 |
| | | if (endloc.N_CURRENT_NUM >= 1 || endloc.N_LOCK_STATE != 0) |
| | | { |
| | | 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) |
| | | { |
| | |
| | | { |
| | | lock (_lockItemBack) |
| | | { |
| | | #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 CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | |
| | | } |
| | | else |
| | | { |
| | | if (db.Updateable(new LocCntrRel() { S_CNTR_CODE = model.Rfid, S_LOC_CODE = Start }).UpdateColumns().ExecuteCommand() <= 0) |
| | | if (db.Insertable(new LocCntrRel() { S_CNTR_CODE = model.Rfid, S_LOC_CODE = Start }).ExecuteCommand() <= 0) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}绑定货位{Start}失败"; |
| | |
| | | // 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}"); |
| | |
| | | { |
| | | //loc = EndLocs.Find(a => a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0); |
| | | loc = FindEndcolByLocList(EndLocs); |
| | | |
| | | |
| | | } |
| | | else |
| | |
| | | } |
| | | #endregion |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | return result; |
| | | } |
| | |
| | | /// <returns></returns> |
| | | 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) |
| | | { |
| | |
| | | //根据任务数量判断送往哪个电梯 (具体电梯流程根据现场电梯数量) |
| | | var elevatorLoc = LocationHelper.GetElevatorLoc(); |
| | | |
| | | //创建wcs分段任务 |
| | | var wcsTask = new WCSTask |
| | | { |
| | | |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "电梯1", |
| | | S_EQ_NO = model.Data.task_no, |
| | | S_START_LOC = startloc.S_CODE, |
| | | 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 = cntr.S_CNTR_CODE, |
| | | N_END_LAYER = 1, |
| | | Z_TYPE = 6 |
| | | }; |
| | | var wcsTask1 = new WCSTask |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_TYPE = "电梯2", |
| | |
| | | Z_TYPE = 6 |
| | | }; |
| | | |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask) && WCSHelper.CreateTask(wcsTask1)) |
| | | |
| | | 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); |
| | | LogHelper.Info("创建任务成功"); |
| | | |
| | | } |
| | | else |
| | | { |
| | |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"物料主数据创建失败 错误信息:{ex}"; |
| | | result.msg = $"电梯搬运任务创建失败 错误信息:{ex}"; |
| | | LogHelper.Error("点对点任务 Error:" + ex.ToString(), ex); |
| | | return result; |
| | | } |
| | |
| | | } |
| | | string loc = model.LocationNum; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try |
| | | lock (_lockCreateItem) |
| | | { |
| | | var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First(); |
| | | if (location != null) |
| | | try |
| | | { |
| | | 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).First(); |
| | | |
| | | if (loccntr != null) |
| | | { |
| | | //清除托盘物料绑定关系 |
| | | db.Deleteable<CntrItemDetail>().Where(it => it.S_CNTR_CODE.Trim() == CntrItem.S_CNTR_CODE).ExecuteCommand(); |
| | | 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 托盘{cntrcode}无物料绑定关系"); |
| | | LogHelper.Info($"ClearLocCntr 货位{loc}无托盘货位绑定关系"); |
| | | } |
| | | if (LocationHelper.UnBindingLoc(loc, new List<string>() { cntrcode })) |
| | | { |
| | | LogHelper.Info($"清除托盘货位关系成功"); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLocCntr 货位{loc}无托盘货位绑定关系"); |
| | | result.code = "1"; |
| | | result.msg = $"根据货位:{loc}找不到货位关系"; |
| | | AddErrorInfo("货位为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"ClearLocCntr Error:{ex}"); |
| | | db.Ado.CommitTran(); |
| | | result.code = "1"; |
| | | result.msg = $"根据货位:{loc}找不到货位关系"; |
| | | AddErrorInfo("货位为空", result.msg, Source); |
| | | result.msg = $"Error:{ex}"; |
| | | return result; |
| | | |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"ClearLocCntr Error:{ex}"); |
| | | db.Ado.CommitTran(); |
| | | result.code = "1"; |
| | | result.msg = $"Error:{ex}"; |
| | | return result; |
| | | |
| | | } |
| | | |
| | | |
| | | return result; |
| | | } |
| | |
| | | /// <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 = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM == 0 && a.S_AREA_CODE.Trim() == areacode && a.N_LOCK_STATE == 0).First(); |
| | | Location result = new Location(); |
| | | var list = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM == 0 && a.S_AREA_CODE.Trim() == areacode && a.N_LOCK_STATE == 0).ToList(); |
| | | if (list.Count > 0) |
| | | { |
| | | result= FindEndcolByLocList(list); |
| | | } |
| | | //查询所有有托盘的排没锁的排 |
| | | // var list = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM > 0 && a.S_AREA_CODE.Trim() == areacode && a.N_LOCK_STATE == 0).OrderByDescending(a => a.N_COL).Take(1).PartitionBy(a => a.N_ROW).ToList(); |
| | | // if (list.Count > 0) |
| | | |
| | | // var list = db.Queryable<Location>().Where(a => a.N_CURRENT_NUM == 0 && a.S_AREA_CODE.Trim() == areacode && a.N_LOCK_STATE == 0).OrderByDescending(a => a.N_COL).Take(1).PartitionBy(a => a.N_ROW).ToList(); |
| | | //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(); |
| | |
| | | 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.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) |
| | | //{ |
| | |
| | | } |
| | | |
| | | /// <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; |
| | | break; |
| | | |
| | | } |
| | | |
| | | } |
| | | } |
| | | return end; |
| | | } |
| | | catch (Exception) |
| | | { |
| | | |
| | | throw; |
| | | } |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 找起点满货位 |
| | | /// </summary> |
| | | /// <param name="locations"></param> |