| | |
| | | |
| | | private static void RecordTaskTable(TN_Task task) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var info = ""; |
| | | |
| | | try { |
| | | var cgDetail = new TN_CG_Detail(); // 如果没有信息,默认就是空值,可以直接填入,不需要判断 |
| | |
| | | .First(); |
| | | |
| | | if (cgDetail == null) { |
| | | info = $"任务{task.S_CODE}完成,记录出入库存在问题:无法在容器货品明细表中找到托盘{task.S_CNTR_CODE}对应的物料"; |
| | | LogHelper.Info(info); |
| | | LogHelper.Info($"任务{task.S_CODE}完成,记录出入库存在问题:无法在容器货品明细表中找到托盘{task.S_CNTR_CODE}对应的物料"); |
| | | //return; |
| | | cgDetail = new TN_CG_Detail() ; |
| | | cgDetail.S_ITEM_CODE = "异常"; |
| | |
| | | .Where(r => r.S_TASK_NO == task.S_CODE).First(); |
| | | if (record != null) { |
| | | //needUpdateRecordTable = true; |
| | | info = $"出入库记录表中已经存在任务号{task.S_CODE}"; // 防止测试时反复调用134562导致重复记录 |
| | | LogHelper.Info(info); |
| | | LogHelper.Info($"出入库记录表中已经存在任务号{task.S_CODE}"); // 防止测试时反复调用134562导致重复记录 |
| | | return; |
| | | } |
| | | |
| | |
| | | |
| | | // 数据库操作 |
| | | if (db.Insertable(record).ExecuteCommand() <= 0) { |
| | | info = "插入出入库记录表失败:" + JsonConvert.SerializeObject(record); |
| | | LogHelper.Info(info); |
| | | LogHelper.Info("插入出入库记录表失败:" + JsonConvert.SerializeObject(record)); |
| | | return; |
| | | } |
| | | |
| | | info = "插入出入库记录表成功"; |
| | | LogHelper.Info(info); |
| | | LogHelper.Info("插入出入库记录表成功"); |
| | | } |
| | | catch (Exception ex) { |
| | | LogHelper.InfoEx(ex); |
| | |
| | | |
| | | public static void PickUpReturnErp(TN_Task task) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var info = ""; |
| | | var httpH = new HttpHelper(); |
| | | |
| | | try { |
| | |
| | | .First(); |
| | | |
| | | if (plan == null) { |
| | | info = $"计划单号{task.S_BS_NO}不存在!"; |
| | | LogHelper.Info(info); |
| | | LogHelper.Info($"计划单号{task.S_BS_NO}不存在!"); |
| | | } |
| | | |
| | | var cgDetail = db.Queryable<TN_CG_Detail>() |
| | |
| | | .First(); |
| | | |
| | | if (cgDetail == null) { |
| | | info = $"物料编码不存在!"; |
| | | LogHelper.Info(info); |
| | | LogHelper.Info($"物料编码不存在!"); |
| | | } |
| | | |
| | | var model = new OtherModel.PickUpReturnErpInfo { |
| | |
| | | plan.SFSL = model.sfsl; |
| | | plan.HWZT = model.hwzt; |
| | | var success = db.Updateable(plan).UpdateColumns(p => new { p.SFJS, p.SFSL, p.HWZT }).ExecuteCommand() > 0; |
| | | info = "更新出库计划单记录表" + (success ? "成功" : "失败"); |
| | | LogHelper.Info(info); |
| | | LogHelper.Info("更新出库计划单记录表" + (success ? "成功" : "失败")); |
| | | } |
| | | catch (Exception ex) { |
| | | LogHelper.InfoEx(ex); |
| | |
| | | /// <returns></returns> |
| | | public static Result<bool> CreateInboundTask(string startLocCode, string cntrCode) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var info = ""; |
| | | |
| | | var taskInfo = Settings.GetTaskInfo(ETask.M满托下线入库); |
| | | var taskName = taskInfo.TaskName; |
| | |
| | | .First(); |
| | | |
| | | if (startLoc == null) { |
| | | info = $"没有找到起点货位'{startLocCode}',或不满足要求:未上锁,当前容器数量=0"; |
| | | LogHelper.Info(info); |
| | | return new Result<bool>(false, info); |
| | | return NewResult(false, $"没有找到起点货位'{startLocCode}',或不满足要求:未上锁,当前容器数量=0"); |
| | | } |
| | | |
| | | var locCntrRelOld = db.Queryable<TN_Loc_Container>() |
| | |
| | | .First(); |
| | | |
| | | if (endLoc == null) { |
| | | info = $"没有找到合适的【终点货位】,需要满足要求:未上锁,当前容器数量=0"; |
| | | LogHelper.Info(info); |
| | | return new Result<bool>(false, info); |
| | | return NewResult(false, $"没有找到合适的【终点货位】,需要满足要求:未上锁,当前容器数量=0"); |
| | | } |
| | | |
| | | var cntId = locCntrRel.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); |
| | | |
| | | WCSHelper.LockStartLoc(ref startLoc); // 起点出库锁 |
| | | WCSHelper.LockEndLoc(ref endLoc); // 终点入库锁 |
| | | WCSHelper.LockStartLoc(startLoc); // 起点出库锁 |
| | | WCSHelper.LockEndLoc(endLoc); // 终点入库锁 |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (locCntrRelOld != null) { |
| | | if (db.Deleteable(locCntrRelOld).ExecuteCommand() <= 0 && |
| | | db.Updateable<TN_Location>().SetColumns(l => l.N_CURRENT_NUM == 0).Where(l => l.S_CODE == locCntrRelOld.S_LOC_CODE).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | info = $"删除旧货位容器关系表失败:货位编码{locCntrRelOld.S_LOC_CODE},容器编码{locCntrRelOld.S_CNTR_CODE}"; |
| | | LogHelper.Info(info); |
| | | return new Result<bool>(false, info); |
| | | return NewResult(false, $"删除旧货位容器关系表失败:货位编码{locCntrRelOld.S_LOC_CODE},容器编码{locCntrRelOld.S_CNTR_CODE}"); |
| | | } |
| | | } |
| | | |
| | | if (db.Insertable(locCntrRel).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | info = $"插入货位容器关系表失败:货位编码{locCntrRel.S_LOC_CODE},容器编码{locCntrRel.S_CNTR_CODE}"; |
| | | LogHelper.Info(info); |
| | | return new Result<bool>(false, info); |
| | | return NewResult(false, $"插入货位容器关系表失败:货位编码{locCntrRel.S_LOC_CODE},容器编码{locCntrRel.S_CNTR_CODE}"); |
| | | } |
| | | |
| | | if (db.Updateable(startLoc).UpdateColumns(it => new { |
| | | it.N_LOCK_STATE, |
| | | it.S_LOCK_STATE, |
| | | it.S_LOCK_OP, |
| | | it.T_MODIFY, |
| | | it.N_CURRENT_NUM, // 起点货位绑定后,将货位状态更新 |
| | | }).ExecuteCommand() <= 0) { |
| | | if (db.Updateable(startLoc).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY, it.N_CURRENT_NUM, }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | info = $"生成任务'{taskName}'失败:更新起点货位{startLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return new Result<bool>(false, info); |
| | | return NewResult(false, $"生成任务'{taskName}'失败:更新起点货位{startLoc.S_CODE}锁状态失败"); |
| | | } |
| | | |
| | | if (db.Updateable(endLoc).UpdateColumns(it => new { |
| | | it.N_LOCK_STATE, |
| | | it.S_LOCK_STATE, |
| | | it.S_LOCK_OP, |
| | | it.T_MODIFY, |
| | | }).ExecuteCommand() <= 0) { |
| | | if (db.Updateable(endLoc).UpdateColumns(it => new { it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY, }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | info = $"生成任务'{taskName}'失败:更新终点货位{endLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return new Result<bool>(false, info); |
| | | return NewResult(false, $"生成任务'{taskName}'失败:更新终点货位{endLoc.S_CODE}锁状态失败"); |
| | | } |
| | | |
| | | if (db.Insertable(task).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | info = $"生成任务'{taskName}'失败,任务号={task.S_CODE},容器号={cntId},起点={startLoc.S_CODE},终点={endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return new Result<bool>(false, info); |
| | | return NewResult(false, $"生成任务'{taskName}'失败,任务号={task.S_CODE},容器号={cntId},起点={startLoc.S_CODE},终点={endLoc.S_CODE}"); |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | info = $"生成任务'{taskName}'成功,任务号={task.S_CODE},容器号={cntId},起点={startLoc.S_CODE},终点={endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return new Result<bool>(true, info); |
| | | return NewResult(true, $"生成任务'{taskName}'成功,任务号={task.S_CODE},容器号={cntId},起点={startLoc.S_CODE},终点={endLoc.S_CODE}"); |
| | | } |
| | | } |
| | | catch (Exception ex) { |