| | |
| | | |
| | | #endregion |
| | | |
| | | Location endloc = new Location(); |
| | | Location startloc = new Location(); |
| | | Location endloc = null; |
| | | Location startloc = null; |
| | | lock (_lockCreateTask) |
| | | { |
| | | if (taskData.taskType == 1) //出库流程,通过物料机台计算线边货位 |
| | |
| | | |
| | | } |
| | | |
| | | public static object _Putin = new object(); |
| | | /// <summary> |
| | | /// 入平库 |
| | | /// </summary> |
| | |
| | | string areacode = ""; |
| | | try |
| | | { |
| | | |
| | | #region 入库检查托盘物料表有无数据 |
| | | var cntritem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (cntritem == null) |
| | | lock (_Putin) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"创建任务失败,托盘:{model.Rfid}无绑定物料数据"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("托盘绑定物料数据为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | #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) |
| | | #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) |
| | | { |
| | | //根据仓库 计算库区 |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | #region 判断托盘绑定货位是否和下发绑定起点相同,如果没绑定托盘则绑定托盘 |
| | | var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrLoc != null) |
| | | { |
| | | areacode = whcode.PMK; |
| | | 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 |
| | | { |
| | | 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 }; |
| | | |
| | | // 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) |
| | | { |
| | | //根据仓库 计算库区 |
| | | 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 = $"根据起点仓库编码:{startloc.S_WH_CODE}未找到对应配置文件"; |
| | | result.msg = $"任务起点:{Start}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | |
| | | loc = StorageCompute(itemcode, areacode); |
| | | |
| | | if (loc != null) |
| | | #region 创建任务 |
| | | if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End)) |
| | | { |
| | | 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 = $"任务起点:{Start}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找货位失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #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); |
| | | 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 = 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, |
| | | 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 = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "创建任务失败,未找到对应的取货点或卸货点"; |
| | | return result; |
| | | } |
| | | #endregion |
| | | |
| | | return result; |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | public static object _PutOut = new object(); |
| | | /// <summary> |
| | | /// 出平库 |
| | | /// </summary> |
| | |
| | | string Start = ""; |
| | | string End = ""; |
| | | string CntrCode = ""; |
| | | |
| | | string itemcode = model.PartNumber; |
| | | string cntrType = ""; |
| | | string areacode = ""; |
| | |
| | | #endregion |
| | | try |
| | | { |
| | | |
| | | #region 根据物料编码规则 计算出库库区 |
| | | //粉料从平库出库,其他物料需要从暂存区出库 |
| | | var locJt = db.Queryable<Location>().Where(a => a.S_AREA_CODE == model.WorkCenter).First(); |
| | | if (locJt == null) |
| | | lock (_PutOut) |
| | | { |
| | | 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")) |
| | | #region 根据物料编码规则 计算出库库区 |
| | | //粉料从平库出库,其他物料需要从暂存区出库 |
| | | var locJt = db.Queryable<Location>().Where(a => a.S_AREA_CODE == model.WorkCenter).First(); |
| | | if (locJt == null) |
| | | { |
| | | areacode = whcode.PMK; |
| | | cntrType = "PM"; |
| | | result.code = "1"; |
| | | result.msg = $"根据机台编码:{model.WorkCenter}未找到对应货位"; |
| | | LogHelper.Info($"Putin==> {result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | else if (model.PartNumber.StartsWith("32")) |
| | | //根据仓库 计算库区 |
| | | var whcode = Settings.wareLoc.Where(a => a.AreaCode == locJt.S_WH_CODE).FirstOrDefault(); |
| | | if (whcode != null) |
| | | { |
| | | areacode = whcode.ZCW2; |
| | | } |
| | | else |
| | | { |
| | | if (model.PartNumber.StartsWith("3")) |
| | | if (model.PartNumber.StartsWith("4X")) |
| | | { |
| | | cntrType = "RC"; |
| | | areacode = whcode.ZCW; |
| | | 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; |
| | | 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 根据物料编码计算出库货位,送往线边位置 |
| | | 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) |
| | | { |
| | | End = Endloc.S_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"Computeloc==》根据机台编码:{model.WorkCenter},工装类型:{cntrType} 未找到空货位数据,请检查货位表"; |
| | | 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); |
| | | 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) |
| | | { |
| | | 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 |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"任务物料:{itemcode}找不到对应库存"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | #endregion |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"任务物料:{itemcode}找不到对应库存"; |
| | | LogHelper.Info($"ItemBack:{result.msg}"); |
| | | AddErrorInfo("查找库区失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | #endregion |
| | | #region 任务创建 |
| | | if (string.IsNullOrEmpty(Start)) |
| | | { |
| | | 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 |
| | | |
| | | #region 任务创建 |
| | | if (string.IsNullOrEmpty(Start)) |
| | | { |
| | | 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 = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | #endregion |
| | | |
| | | return result; |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | return result; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | 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 |
| | | |
| | |
| | | #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) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | |
| | | result.code = "1"; |
| | | result.msg = $"Empty==> 任务起点:{Start}找不到对应货位,请检查货位表"; |
| | | LogHelper.Info($"{result.msg}"); |
| | |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | result.msg = $"任务创建失败,请检查起点货位状态后重新下发"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | |
| | | |
| | | string areacode = ""; |
| | | string cntrcode = ""; |
| | | Location startloc = new Location(); |
| | | Location startloc = null; |
| | | // startloc = LocationHelper.GetLocByAreacode(areacode, model.CarrierType); |
| | | #endregion |
| | | |
| | |
| | | { |
| | | lock (_lockcallfixture) |
| | | { |
| | | |
| | | |
| | | #region 根据仓库编码判断库区 并计算出库货位 |
| | | var endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == End).First(); |
| | | //根据仓库 计算库区 |
| | |
| | | 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 |
| | | |
| | |
| | | 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).ToList(); |
| | | if (loccntr.Count > 0) |
| | | var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First(); |
| | | if (location != null) |
| | | { |
| | | foreach (var item in loccntr) |
| | | var loccntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc).ToList(); |
| | | if (loccntr.Count > 0) |
| | | { |
| | | string cntrcode = item.S_CNTR_CODE; |
| | | LocationHelper.UnBindingLoc(loc, new List<string>() { cntrcode }); |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == cntrcode).First(); |
| | | if (CntrItem != null) |
| | | |
| | | var cntrcodes = loccntr.Select(a => a.S_CNTR_CODE.Trim()).ToList(); |
| | | if (LocationHelper.Clear(loc, cntrcodes)) |
| | | { |
| | | db.Deleteable<Container>().Where(it => it.S_CODE == item.S_CNTR_CODE).ExecuteCommand(); |
| | | // db.Deleteable<LocCntrRel>().Where(it => it.S_LOC_CODE.Trim() == loc).ExecuteCommand(); |
| | | if (db.Deleteable<CntrItemDetail>().Where(it => it.S_CNTR_CODE == cntrcode).ExecuteCommand() > 0) |
| | | { |
| | | LogHelper.Info($"ClearLoc 库位清除成功"); |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLoc 库位清除失败"); |
| | | result.code = "1"; |
| | | result.msg = "库位清除失败"; |
| | | AddErrorInfo("库位清除失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | LogHelper.Info($"ClearLoc 库位清除成功"); |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"库区清空=》托盘:{cntrcode}无物料数据"); |
| | | |
| | | LogHelper.Info($"ClearLoc 库位清除失败"); |
| | | result.code = "1"; |
| | | result.msg = "库位清除失败"; |
| | | AddErrorInfo("库位清除失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $" ClearLoc 货位{loc}无托盘货位绑定关系"; |
| | | AddErrorInfo("库位清除失败", result.msg, Source); |
| | | return result; |
| | | |
| | | } |
| | | |
| | | } |
| | | |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $" ClearLoc 货位{loc}无托盘货位绑定关系"; |
| | | AddErrorInfo("库位清除失败", result.msg, Source); |
| | | 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) |
| | |
| | | /// <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(); |
| | | |
| | | |