| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 余料解绑出库 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static SimpleResult SurplusUnBind(SurplusUnBindInfo model) |
| | | { |
| | | LogHelper.Info("触发API:余料绑定入库" + JsonConvert.SerializeObject(model), "API"); |
| | | var result = new SimpleResult();//返回结果 |
| | | try |
| | | { |
| | | if (string.IsNullOrWhiteSpace(model.spec)) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"规格参数不能为空,也不能为空字符串"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | |
| | | if (string.IsNullOrWhiteSpace(model.loc)) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"货位参数不能为空,也不能为空字符串"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | |
| | | if (model.weight <= 0) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"重量参数必须大于0"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | |
| | | var cgDetail = db.Queryable<TN_CG_Detail>() |
| | | .First(a => a.S_LOC_CODE == model.loc |
| | | && a.S_USE_TYPE == "余料" |
| | | &&(a.S_ITEM_SPEC == model.spec || a.S_SPE == model.spec) |
| | | && a.F_QTY == model.weight); |
| | | |
| | | if (cgDetail == null) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"库位{model.loc}对应的物料明细不存在,无需出库"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | |
| | | using (var trans = db.Ado.UseTran()) |
| | | { |
| | | if (db.Deleteable<TN_CG_Detail>(cgDetail).ExecuteCommand() > 0 ) |
| | | { |
| | | trans.CommitTran(); |
| | | result.resultCode = 0; |
| | | result.resultMsg = $"出库成功,货位:{model.loc},解绑的货品为:{JsonConvert.SerializeObject(cgDetail)}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | trans.RollbackTran(); |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"出库失败,货位:{model.loc}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"PDA满托复检判断,发生了异常:{ex.Message}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 余料绑定入库 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | internal static SimpleResult SurplusBind(SurplusBindInfo model) |
| | | { |
| | | LogHelper.Info("触发API:余料绑定入库" + JsonConvert.SerializeObject(model), "API"); |
| | | var result = new SimpleResult();//返回结果 |
| | | try |
| | | { |
| | | if (string.IsNullOrWhiteSpace(model.spec)) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"规格参数不能为空,也不能为空字符串"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | |
| | | if (string.IsNullOrWhiteSpace(model.loc)) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"货位参数不能为空,也不能为空字符串"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | |
| | | if (model.weight <= 0) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"重量参数必须大于0"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | |
| | | var db = new SqlHelper<object>().GetInstance(); |
| | | |
| | | var cgDetail = new TN_CG_Detail() |
| | | { |
| | | S_ITEM_SPEC = model.spec, |
| | | S_SPE = model.spec, |
| | | F_QTY = model.weight, |
| | | S_LOC_CODE = model.loc, |
| | | S_USE_TYPE = "余料", |
| | | }; |
| | | |
| | | using (var trans = db.Ado.UseTran()) |
| | | { |
| | | if (db.Insertable<TN_CG_Detail>(cgDetail).ExecuteCommand() > 0 ) |
| | | { |
| | | trans.CommitTran(); |
| | | result.resultCode = 0; |
| | | result.resultMsg = $"入库成功,货位:{model.loc},已绑定货品,{JsonConvert.SerializeObject(cgDetail)}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | else |
| | | { |
| | | trans.RollbackTran(); |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"入库失败,货位:{model.loc}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"PDA满托复检判断,发生了异常:{ex.Message}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 线边空托到空托堆叠区 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | |
| | | { |
| | | result.resultCode = -1; |
| | | result.resultMsg = $"PDA满托复检判断,发生了异常:{ex.Message}"; |
| | | LogHelper.Info(result.resultMsg); |
| | | return result; |
| | | } |
| | | } |
| | | |
| | | /// <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; |
| | | } |