| | |
| | | try { |
| | | // 将PDA提供的物料编码与贴标机的信息比对 |
| | | var cgDetail = db.Queryable<TN_CG_Detail>() |
| | | .Where(d => d.S_ITEM_CODE == model.s_item_code && d.S_BATCH_NO == model.s_batch) // 指定:物料编码、批次号 |
| | | .Where(d => d.S_ITEM_CODE == model.ItemCode && d.S_BATCH_NO == model.BatchNo) // 指定:物料编码、批次号 |
| | | .Where(d => d.N_ITEM_STATE == 1 && d.S_ITEM_STATE == "待检") // NOTE 冗余检查:物料状态应该为 1待检 |
| | | .First(); |
| | | |
| | |
| | | } |
| | | |
| | | var startLoc = db.Queryable<TN_Location>() |
| | | .Where(a => a.S_CODE == model.s_start_loc) // 指定:起点货位号 |
| | | .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无" && a.C_ENABLE == "Y") // 筛选:未上锁 |
| | | .Where(l => l.S_CODE == model.StartLoc) // 指定:起点货位号 |
| | | .Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y") // 筛选:未上锁 |
| | | .First(); |
| | | |
| | | if (startLoc == null) { |
| | | info = $"起点位置 '{model.s_start_loc}' 不存在或不具备取货要求"; |
| | | info = $"起点位置 '{model.StartLoc}' 不存在或不具备取货要求"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(3, info); |
| | | } |
| | | |
| | | // 绑定货位和容器号 |
| | | var locCntrRel = new TN_Loc_Container { |
| | | S_LOC_CODE = model.s_start_loc, |
| | | S_LOC_CODE = model.StartLoc, |
| | | S_CNTR_CODE = cgDetail.S_CNTR_CODE, |
| | | S_CNTR_TYPE = "好运箱", |
| | | }; |
| | |
| | | .Where(a => a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "无" && a.C_ENABLE == "Y") // 筛选:未上锁 |
| | | .Where(a => a.N_CURRENT_NUM == 0) // 筛选:空货位 |
| | | .OrderBy(l => l.N_LAYER) |
| | | .OrderBy(l => l.S_AREA_CODE).First(); |
| | | .First(); |
| | | |
| | | if (endLoc == null) { |
| | | info = "满箱入库暂时没有合适的货位可以入库"; |
| | |
| | | var cntId = locCntrRel.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); |
| | | |
| | | LocationHelper.LockLoc(ref startLoc, 1); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 2); // 终点入库锁 |
| | | LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { |
| | |
| | | it.T_MODIFY |
| | | }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | info = $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货位 {endLoc.S_CODE}"; |
| | | info = $"生成任务'{taskName}'失败:更新起点货位{startLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | |
| | | it.S_LOCK_OP, |
| | | it.T_MODIFY |
| | | }).ExecuteCommand() <= 0) { |
| | | |
| | | tran.RollbackTran(); |
| | | info = $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"; |
| | | info = $"生成任务'{taskName}'失败:更新终点货位{endLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | info = $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"; |
| | | info = $"生成任务'{taskName}'失败,容器号{cntId},起点{startLoc.S_CODE},终点货架{endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | info = $"生成 {taskName} 成功,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"; |
| | | info = $"生成任务'{taskName}'成功,容器号{cntId},起点{startLoc.S_CODE},终点货架{endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(0, info); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.Info(info); |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | |
| | | .First(); |
| | | |
| | | if (startLoc == null) { |
| | | return NewSimpleResult(2, $"起点位置 '{model.StartLoc}' 不存在或不具备取货要求"); |
| | | info = $"起点位置{model.StartLoc}不存在或不具备取货要求"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(2, info); |
| | | } |
| | | |
| | | // 查看容器与起点货位是否绑定 |
| | |
| | | .First(); |
| | | |
| | | if (locCntrRel == null) { |
| | | return NewSimpleResult(3, $"起点位置 '{model.StartLoc}' 没有绑定容器 '{model.CntrCode}'"); |
| | | info = $"起点位置{model.StartLoc}没有绑定容器{model.CntrCode}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(3, info); |
| | | } |
| | | |
| | | // TODO 暂定选择最低层按区位顺序入库,后面待修改 |
| | | var endLoc = db.Queryable<TN_Location>() |
| | | .Where(a => Settings.AreaMap[AreaName.空托存放区].Contains(a.S_AREA_CODE)) |
| | | .OrderBy(l => l.N_LAYER) |
| | | .OrderBy(l => l.S_AREA_CODE).First(); |
| | | .First(); |
| | | |
| | | if (endLoc == null) { |
| | | return NewSimpleResult(4, $"暂时没有符合条件的终点放货位"); |
| | | info = $"暂时没有符合条件的终点放货位"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | var cntId = locCntrRel.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); |
| | | |
| | | LocationHelper.LockLoc(ref startLoc, 1); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 2); // 终点入库锁 |
| | | LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { |
| | | it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | it.N_LOCK_STATE, |
| | | it.S_LOCK_STATE, |
| | | it.S_LOCK_OP, |
| | | it.T_MODIFY |
| | | }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货位 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败:更新起点货位{startLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new { |
| | | it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | |
| | | it.N_LOCK_STATE, |
| | | it.S_LOCK_STATE, |
| | | it.S_LOCK_OP, |
| | | it.T_MODIFY |
| | | }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败:更新终点货位{endLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败,容器号{cntId},起点{startLoc.S_CODE},终点货架{endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | return NewSimpleResult(0, |
| | | $"生成 {taskName} 成功,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'成功,容器号{cntId},起点{startLoc.S_CODE},终点货架{endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(0, info); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.Info(info); |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | |
| | | .First(); |
| | | |
| | | if (startLoc == null) { |
| | | return NewSimpleResult(2, $"起点位置 '{model.StartLoc}' 不存在或不具备取货要求"); |
| | | info = $"起点位置{model.StartLoc}不存在或不具备取货要求"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(2, info); |
| | | } |
| | | |
| | | // 查看容器与起点货位是否绑定 |
| | |
| | | .First(); |
| | | |
| | | if (locCntrRel == null) { |
| | | return NewSimpleResult(3, $"起点位置 '{model.StartLoc}' 没有绑定容器 '{model.CntrCode}'"); |
| | | info = $"起点位置{model.StartLoc}没有绑定容器{model.CntrCode}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(3, info); |
| | | } |
| | | |
| | | // TODO 暂定选择最低层按区位顺序入库,后面待修改 |
| | |
| | | var cntId = locCntrRel.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); |
| | | |
| | | LocationHelper.LockLoc(ref startLoc, 1); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 2); // 终点入库锁 |
| | | LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { |
| | | it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | it.N_LOCK_STATE, |
| | | it.S_LOCK_STATE, |
| | | it.S_LOCK_OP, |
| | | it.T_MODIFY |
| | | }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货位 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败:更新起点货位{startLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new { |
| | | it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | |
| | | it.N_LOCK_STATE, |
| | | it.S_LOCK_STATE, |
| | | it.S_LOCK_OP, |
| | | it.T_MODIFY |
| | | }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败:更新终点货位{endLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败,容器号{cntId},起点{startLoc.S_CODE},终点货架{endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | return NewSimpleResult(0, |
| | | $"生成 {taskName} 成功,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'成功,容器号{cntId},起点{startLoc.S_CODE},终点货架{endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(0, info); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | return BuildSimpleEx(ex); |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | | |
| | |
| | | var cntId = locCntrRel.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); |
| | | |
| | | LocationHelper.LockLoc(ref startLoc, 1); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 2); // 终点入库锁 |
| | | LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { |
| | |
| | | it.T_MODIFY |
| | | }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货位 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败:更新起点货位{startLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new { |
| | |
| | | it.S_LOCK_OP, |
| | | it.T_MODIFY |
| | | }).ExecuteCommand() <= 0) { |
| | | |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败:更新终点货位{endLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败,容器号{cntId},起点{startLoc.S_CODE},终点货架{endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | return NewSimpleResult(0, |
| | | $"生成 {taskName} 成功,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'成功,容器号{cntId},起点{startLoc.S_CODE},终点货架{endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(0, info); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | return BuildSimpleEx(ex); |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | | |
| | |
| | | var cntId = locCntrRel.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); |
| | | |
| | | LocationHelper.LockLoc(ref startLoc, 1); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 2); // 终点入库锁 |
| | | LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { |
| | | it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | it.N_LOCK_STATE, |
| | | it.S_LOCK_STATE, |
| | | it.S_LOCK_OP, |
| | | it.T_MODIFY |
| | | }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货位 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败:更新起点货位{startLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | if (db.Updateable<TN_Location>(endLoc).UpdateColumns(it => new { |
| | | it.N_LOCK_STATE, it.S_LOCK_STATE, it.S_LOCK_OP, it.T_MODIFY }).ExecuteCommand() <= 0) { |
| | | |
| | | it.N_LOCK_STATE, |
| | | it.S_LOCK_STATE, |
| | | it.S_LOCK_OP, |
| | | it.T_MODIFY |
| | | }).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败:更新终点货位{endLoc.S_CODE}锁状态失败"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | if (db.Insertable<TN_Task>(task).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | return NewSimpleResult(500, |
| | | $"生成 {taskName} 失败,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'失败,容器号{cntId},起点{startLoc.S_CODE},终点货架{endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(4, info); |
| | | } |
| | | |
| | | tran.CommitTran(); |
| | | return NewSimpleResult(0, |
| | | $"生成 {taskName} 成功,容器号 {cntId} ,起点 {startLoc.S_CODE} ,终点货架 {endLoc.S_CODE}"); |
| | | info = $"生成任务'{taskName}'成功,容器号{cntId},起点{startLoc.S_CODE},终点货架{endLoc.S_CODE}"; |
| | | LogHelper.Info(info); |
| | | return NewSimpleResult(0, info); |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | return BuildSimpleEx(ex); |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | | |
| | |
| | | return NewSimpleResult(0, $"创建 抽检单 成功"); |
| | | } |
| | | catch (Exception ex) { |
| | | return BuildSimpleEx(ex); |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | | /// <summary> |
| | |
| | | var cntId = locCntrRel.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); |
| | | |
| | | LocationHelper.LockLoc(ref startLoc, 1); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 2); // 终点入库锁 |
| | | LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => |
| | |
| | | } |
| | | catch (Exception ex) { |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.Info(info); |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | |
| | | var cntId = locCntrRel.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); |
| | | |
| | | LocationHelper.LockLoc(ref startLoc, 1); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 2); // 终点入库锁 |
| | | LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_CG_Detail>(cgDetail).UpdateColumns(it => |
| | |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | return BuildSimpleEx(ex); |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | var startLoc = db.Queryable<TN_Location>() |
| | | .Where(l => l.S_CODE == model.StartLoc) |
| | | .Where(l => l.N_LOCK_STATE == 0 && l.S_LOCK_STATE == "无" && l.C_ENABLE == "Y") // 筛选:未上锁 |
| | | .First(); |
| | | |
| | | var locCntrRel = db.Queryable<TN_Loc_Container>() |
| | |
| | | var cntId = locCntrRel.S_CNTR_CODE; |
| | | var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, taskName); |
| | | |
| | | LocationHelper.LockLoc(ref startLoc, 1); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 2); // 终点入库锁 |
| | | LocationHelper.LockLoc(ref startLoc, 2); // 起点出库锁 |
| | | LocationHelper.LockLoc(ref endLoc, 1); // 终点入库锁 |
| | | |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Updateable<TN_Location>(startLoc).UpdateColumns(it => new { |
| | |
| | | } |
| | | } |
| | | catch (Exception ex) { |
| | | |
| | | return BuildSimpleEx(ex); |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | | |
| | |
| | | return NewSimpleResult(0, "生成出库单成功"); |
| | | } |
| | | catch (Exception ex) { |
| | | return BuildSimpleEx(ex); |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | | |
| | |
| | | return NewSimpleResult(0, "生成出库单成功"); |
| | | } |
| | | catch (Exception ex) { |
| | | return BuildSimpleEx(ex); |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception ex) { |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.Info(info); |
| | | LogHelper.InfoEx(ex); |
| | | return result; |
| | | } |
| | | } |
| | |
| | | return NewSimpleResult(0, $"创建 抽检单 成功"); |
| | | } |
| | | catch (Exception ex) { |
| | | return BuildSimpleEx(ex); |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.InfoEx(ex); |
| | | return NewSimpleResult(1, info); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | catch (Exception ex) { |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.Info(info); |
| | | LogHelper.InfoEx(ex); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | |
| | | private static string GenerateOrderNo(string snType, string prefix) { |
| | | var id = SYSHelper.GetSerialNumber(snType, prefix); |
| | |
| | | public static WmsResult CgInfoSync(CgInfoSyncInfo model) { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | var random = new Random(); |
| | | var info = ""; |
| | | |
| | | try { |
| | | var detail = new TN_CG_Detail { |
| | | S_ITEM_CODE = model.ItemCode, |
| | | S_ITEM_NAME = model.ItemName, |
| | | S_CNTR_CODE = Guid.NewGuid().ToString("D"), // NOTE 容器号:目前随机(后期可能会指定,或者PDA绑定时再填入) |
| | | S_CNTR_CODE = GenerateOrderNo("容器号", "CN"), // NOTE 容器号:目前随机(后期可能会指定,或者PDA绑定时再填入) |
| | | S_BATCH_NO = model.BatchNo, |
| | | S_STANDARD = model.Standard, |
| | | S_NET_WEIGHT = model.NetWeight, |
| | |
| | | //N_PRODUCT_LINE = random.Next(0, 3), // NOTE 产线号:目前随机(后期可能会指定,或者PDA绑定时再填入) |
| | | }; |
| | | |
| | | // 货位容器绑定的逻辑,在好运箱下线PDA的流程中操作 |
| | | |
| | | //var locCntrRel = new TN_Loc_Container { |
| | | // //S_LOC_CODE = Settings.Config.ProductionLines[detail.N_PRODUCT_LINE].OffLoc[0], // 好运箱的位置是操作区,不是产线 |
| | | // S_CNTR_CODE = detail.S_CNTR_CODE, |
| | | // S_CNTR_TYPE = "好运箱", // 贴标机只针对好运箱 |
| | | //}; |
| | | |
| | | //using (var tran = db.Ado.UseTran()) { |
| | | // if (db.Insertable<TN_CG_Detail>(detail).ExecuteCommand() <= 0 |
| | | // && db.Insertable<TN_Loc_Container>(detail).ExecuteCommand() <= 0) { |
| | | // tran.RollbackTran(); |
| | | // return MesResultBuilder(2, "插入物料信息失败:" + JsonConvert.SerializeObject(detail)); |
| | | // } |
| | | // tran.CommitTran(); |
| | | //} |
| | | using (var tran = db.Ado.UseTran()) { |
| | | if (db.Insertable<TN_CG_Detail>(detail).ExecuteCommand() <= 0) { |
| | | tran.RollbackTran(); |
| | | info = "插入物料信息失败:" + JsonConvert.SerializeObject(detail); |
| | | return NewWmsResult(2, info); |
| | | } |
| | | |
| | | if (db.Insertable<TN_CG_Detail>(detail).ExecuteCommand() <= 0) { |
| | | return MesResultBuilder(2, "插入物料信息失败:" + JsonConvert.SerializeObject(detail)); |
| | | //if (db.Insertable<TN_Loc_Container>(locCntrRel).ExecuteCommand() <= 0) { |
| | | // tran.RollbackTran(); |
| | | // info = "插入物料信息失败:" + JsonConvert.SerializeObject(detail); |
| | | // return NewWmsResult(2, info); |
| | | //} |
| | | |
| | | tran.CommitTran(); |
| | | } |
| | | |
| | | return MesResultBuilder(0, "插入物料信息成功"); |
| | | info = "插入物料信息成功"; |
| | | return NewWmsResult(0, info); |
| | | } |
| | | catch (Exception ex) { |
| | | return MesResultBuilder(1, ex.Message); |
| | | info = $"发生了异常:{ex.Message}"; |
| | | LogHelper.InfoEx(ex); |
| | | return NewWmsResult(1, info); |
| | | } |
| | | } |
| | | } |