| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 人工次品回炉 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static SimpleResult PDAReturnReset(PDAReturnResetInfo model) |
| | | { |
| | | LogHelper.Info("触发API:人工次品回炉" + JsonConvert.SerializeObject(model), "API"); |
| | | |
| | | var result = new SimpleResult();//返回结果 |
| | | |
| | | try |
| | | { |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | var startLoc = db.Queryable<TN_Location>().First(o => o.S_CODE == model.startLoc && o.N_CURRENT_NUM ==0 && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE=="无" && o.S_AREA_CODE == Settings.Areas[4]); |
| | | if (startLoc == null) |
| | | { |
| | | result.resultCode = 1; |
| | | result.resultMsg = $"未找到合适的起点信息,要求:o.S_CODE == { model.startLoc} && o.N_CURRENT_NUM ==0 && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == 无 && o.S_AREA_CODE == {Settings.Areas[4]}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | |
| | | var endLoc = db.Queryable<TN_Location>(). |
| | | Where(o =>o.S_AREA_CODE == Settings.Areas[11] |
| | | && o.N_CURRENT_NUM == 0 |
| | | && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == "无" |
| | | && SqlFunc.Subqueryable<TN_Loc_Container>().Where(b => b.S_LOC_CODE == o.S_CODE).NotAny() |
| | | ).First(); |
| | | |
| | | if (endLoc == null) |
| | | { |
| | | result.resultCode = 2; |
| | | result.resultMsg = $"未找到合适的终点信息,要求:o.S_AREA_CODE == {Settings.Areas[11]} && o.N_CURRENT_NUM == 0 && o.N_LOCK_STATE == 0 && o.S_LOCK_STATE == 无"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | |
| | | var cgInfo = db.Queryable<TN_CG_Detail>().First(a=>a.S_CNTR_CODE == model.rfId); |
| | | if (cgInfo == null) |
| | | { |
| | | result.resultCode = 3; |
| | | result.resultMsg = $"未找到对应的物料信息,要求:a.S_CNTR_CODE == {model.rfId}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | |
| | | var task1 = new TN_Task() |
| | | { |
| | | S_CODE = WCSHelper.GenerateTaskNo(), |
| | | S_START_AREA = startLoc.S_AREA_CODE, |
| | | S_END_AREA = endLoc.S_AREA_CODE, |
| | | S_START_LOC = startLoc.S_CODE, |
| | | S_END_LOC = endLoc.S_CODE, |
| | | S_TYPE = "人工次品回炉", |
| | | N_B_STATE = 0, |
| | | S_B_STATE = "等待", |
| | | S_CNTR_CODE = model.rfId, |
| | | S_SPEC = cgInfo.S_ITEM_SPEC, |
| | | }; |
| | | |
| | | startLoc.N_LOCK_STATE = 2; |
| | | startLoc.S_LOCK_STATE = "出库锁"; |
| | | startLoc.N_CURRENT_NUM = 1; |
| | | startLoc.T_MODIFY = System.DateTime.Now; |
| | | |
| | | endLoc.N_LOCK_STATE = 1; |
| | | endLoc.S_LOCK_STATE = "入库锁"; |
| | | endLoc.T_MODIFY = System.DateTime.Now; |
| | | |
| | | using (var tran = db.Ado.UseTran()) |
| | | { |
| | | var locCnt = db.Queryable<TN_Loc_Container>().First(o => o.S_CNTR_CODE == model.rfId && o.S_LOC_CODE != model.startLoc); |
| | | TN_Location locOld = null; |
| | | if (locCnt != null) |
| | | { |
| | | locOld = db.Queryable<TN_Location>().First(o => o.S_CODE == locCnt.S_LOC_CODE); |
| | | if (locOld != null) |
| | | { |
| | | locOld.N_CURRENT_NUM = 0; |
| | | if (db.Updateable<TN_Location>(locOld).UpdateColumns(it => new { it.N_CURRENT_NUM }).ExecuteCommand() <= 0) |
| | | { |
| | | tran.RollbackTran(); |
| | | result.resultCode = 4; |
| | | result.resultMsg = $"更新旧货位失败,{locOld.S_CODE}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | locCnt.S_LOC_CODE = model.startLoc; |
| | | if (db.Updateable<TN_Loc_Container>(locCnt).UpdateColumns(it => new { it.S_LOC_CODE }).ExecuteCommand() <= 0) |
| | | { |
| | | tran.RollbackTran(); |
| | | result.resultCode = 5; |
| | | result.resultMsg = $"更新货位容器关系表(换绑)失败,{model.startLoc}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | locCnt = new TN_Loc_Container() |
| | | { |
| | | S_LOC_CODE = model.startLoc, |
| | | S_CNTR_CODE = model.rfId, |
| | | }; |
| | | if (db.Insertable<TN_Loc_Container>(locCnt).ExecuteCommand() <= 0) |
| | | { |
| | | tran.RollbackTran(); |
| | | result.resultCode = 6; |
| | | result.resultMsg = $"插入货位容器关系表(绑定)失败,{model.startLoc}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | if (db.Insertable<TN_Task>(task1).ExecuteCommand() > 0 && |
| | | db.Updateable<TN_Location>(startLoc).ExecuteCommand() > 0 && |
| | | db.Updateable<TN_Location>(endLoc).ExecuteCommand() > 0) |
| | | { |
| | | |
| | | Task task99 = Task.Run(() => |
| | | { |
| | | WMSHelper.InsertOpInfo(model.staff, "人工次品回炉", locCnt.S_CNTR_CODE); |
| | | }); |
| | | |
| | | Task task2 = Task.Run(() => |
| | | { |
| | | var target = new TN_RemeltDetail() |
| | | { |
| | | TASKNO = task1.S_CODE, |
| | | CNTCODE = model.rfId, |
| | | STARTLOC = model.startLoc, |
| | | LOGINNAME = model.staff, |
| | | ITEMCODE = cgInfo.S_ITEM_CODE, |
| | | SPEC = cgInfo.S_SPE, |
| | | CARCODE = cgInfo.S_CAR_CODE, |
| | | WEIGHT = cgInfo.F_QTY, |
| | | REMELTTIME = DateTime.Now, |
| | | SHIFT = model.shift, |
| | | }; |
| | | SpecHelper.InsertRemeltDetail(target); |
| | | }); |
| | | |
| | | tran.CommitTran(); |
| | | result.resultCode = 0; |
| | | result.resultMsg = "成功"; |
| | | LogHelper.Info($"生成人工次品回炉任务成功,容器:{model.rfId},起点:{model.startLoc},终点:{endLoc.S_CODE}"); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | tran.RollbackTran(); |
| | | result.resultCode = 7; |
| | | result.resultMsg = $"生成人工次品回炉任务失败,容器:{model.rfId},起点:{model.startLoc},终点:{endLoc.S_CODE}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"生成人工次品回炉任务失败,发生了异常:{ex.Message}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 显示满托缓存库当前规格的托盘数量 |
| | | /// </summary> |
| | | /// <param name="model"></param> |