From 6f89acbf74c6838db518a9f2b6c83f0ab0d97e7f Mon Sep 17 00:00:00 2001 From: 杨张扬 <634643841@qq.com> Date: 星期二, 29 七月 2025 18:13:31 +0800 Subject: [PATCH] 余料回库流程增加绑定和解绑,RFID校验必须校验开头 --- api/ApiHelper.cs | 328 ++++++++++++++++++++++++++---------------------------- 1 files changed, 156 insertions(+), 172 deletions(-) diff --git a/api/ApiHelper.cs b/api/ApiHelper.cs index ef52fbb..ba574df 100644 --- a/api/ApiHelper.cs +++ b/api/ApiHelper.cs @@ -326,6 +326,162 @@ } /// <summary> + /// 浣欐枡瑙g粦鍑哄簱 + /// </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> @@ -628,178 +784,6 @@ { 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; } -- Gitblit v1.9.1