| | |
| | | startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First(); |
| | | if (startloc != null) |
| | | { |
| | | Start = startloc.S_CODE; |
| | | var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).FirstOrDefault(); |
| | | if (CntrRel != null) |
| | | { |
| | | Start = startloc.S_CODE; |
| | | CntrCode = CntrRel.S_CNTR_CODE; |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据起点{Start},未找到托盘货位绑定关系"; |
| | | AddErrorInfo("托盘查找失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | //else |
| | | //{ |
| | | // result.code = "1"; |
| | | // result.msg = $"根据起点{Start},未找到托盘货位绑定关系"; |
| | | // AddErrorInfo("托盘查找失败", result.msg, Source); |
| | | // return result; |
| | | //} |
| | | |
| | | } |
| | | |
| | |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(End, 2); |
| | | // LocationHelper.LockLoc(End, 2); |
| | | |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else if (startArea.N_FLOOR != endArea.N_FLOOR) |
| | |
| | | { |
| | | |
| | | // LocationHelper.LockLoc(Start, 1); |
| | | LocationHelper.LockLoc(End, 2); |
| | | //LocationHelper.LockLoc(End, 2); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | // LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | LogHelper.Info("创建入平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LogHelper.Info("创建任务成功"); |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | N_END_LAYER = endlayer, |
| | | Z_TYPE = 5 |
| | | }; |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | LogHelper.Info("创建空托回库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | LocationHelper.LockLoc(loc.S_CODE, 1); |
| | | //LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | //LocationHelper.LockLoc(loc.S_CODE, 1); |
| | | // 空托回库判断托盘有无绑定物料信息 如果有则删除 |
| | | 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(); } |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | LogHelper.Info("创建呼叫空托任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | LogHelper.Info("创建出平库任务:" + JsonConvert.SerializeObject(wcsTask)); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | //创建任务成功 更新余料信息 |
| | | var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First(); |
| | | if (CntrItem != null) |
| | |
| | | db.Updateable(CntrItem).UpdateColumns(a => new { a.F_WEIGHT, a.S_BS_TYPE }).ExecuteCommand(); |
| | | } |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | LogHelper.Info("创建任务:" + JsonConvert.SerializeObject(wcsTask), "CreateTask"); |
| | | if (WCSHelper.CreateTask(wcsTask)) |
| | | { |
| | | LocationHelper.LockLoc(Start, 2); |
| | | LocationHelper.LockLoc(End, 1); |
| | | //LocationHelper.LockLoc(Start, 2); |
| | | //LocationHelper.LockLoc(End, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | |
| | | if (WCSHelper.CreateTask(wcsTask) && WCSHelper.CreateTask(wcsTask1)) |
| | | { |
| | | |
| | | LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | //LocationHelper.LockLoc(startloc.S_CODE, 2); |
| | | //LocationHelper.LockLoc(endloc.S_CODE, 1); |
| | | LogHelper.Info("创建任务成功"); |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"任务创建失败"; |
| | | AddErrorInfo("任务创建失败", result.msg, Source); |
| | | return result; |
| | | } |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 库位清空 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static Result ClearLocCntr(ClearTask model) |
| | | { |
| | | Result result = new Result() { code = "200", msg = "库位清除成功" }; |
| | | string Source = "MES"; |
| | | if (model == null) |
| | | { |
| | | result.code = "1"; |
| | | result.msg = "参数为null"; |
| | | AddErrorInfo("参数为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | string loc = model.LocationNum; |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | try |
| | | { |
| | | var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First(); |
| | | if (location != null) |
| | | { |
| | | var loccntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc).First(); |
| | | |
| | | 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($"清除托盘货位关系成功"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLocCntr 托盘{cntrcode}无物料绑定关系"); |
| | | } |
| | | |
| | | } |
| | | else |
| | | { |
| | | LogHelper.Info($"ClearLocCntr 货位{loc}无托盘货位绑定关系"); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | result.code = "1"; |
| | | result.msg = $"根据货位:{loc}找不到货位关系"; |
| | | AddErrorInfo("货位为空", result.msg, Source); |
| | | return result; |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Info($"ClearLocCntr Error:{ex}"); |
| | | db.Ado.CommitTran(); |
| | | result.code = "1"; |
| | | result.msg = $"Error:{ex}"; |
| | | return result; |
| | | |
| | | } |
| | | |
| | | return result; |
| | | } /// <summary> |
| | | /// 库位清空 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | |
| | | |
| | | lock (_lockLocation) |
| | | { |
| | | var loc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).First(); |
| | | var loc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0&&a.S_LOCK_STATE=="无").First(); |
| | | if (loc != null) |
| | | { |
| | | End = loc; |