From f12084241b438c025550d4f9337935abf9a52c81 Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期六, 10 八月 2024 19:17:25 +0800 Subject: [PATCH] 在制品的生产信息的关联使用在制品的ID来关联,优化生产信息保存逻辑 --- Tiger.Business.MES/WorkAction/PackingAction.cs | 84 +++++++++++++++++++++++------------------- 1 files changed, 46 insertions(+), 38 deletions(-) diff --git a/Tiger.Business.MES/WorkAction/PackingAction.cs b/Tiger.Business.MES/WorkAction/PackingAction.cs index 1c37fa8..2c0b098 100644 --- a/Tiger.Business.MES/WorkAction/PackingAction.cs +++ b/Tiger.Business.MES/WorkAction/PackingAction.cs @@ -194,15 +194,8 @@ case "Scan": if (CurCmd.IsNullOrEmpty() || CurCmd.ExecCode == "Scan" || (CurCmd.ExecCode == "Print" && CurCmd.PkgLevel == pInput.PkgLevel)) { - //瀹㈡埛绔壂鎻忔垚鍔� - if (pInput.IsFinish) - { - CurCmd = null; - PrintTimes = 0; - action = SavePkgData(input, action); - } //瀹㈡埛绔壂鎻忓け璐� - else + if (!pInput.IsFinish || pInput.PkgSN.IsNullOrEmpty()) { var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); action.IsSuccessed = false; @@ -210,6 +203,19 @@ action.LocaleMsg = new("MES.WorkAction.PackingAction.ScanFail", dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); return action; } + //楠岃瘉褰撳墠鍖呰鏉$爜鏄惁宸茬粡琚壂鎻忚繃 + if (GetPackageList(CurPkg.Item).Any(q => q.SN == pInput.PkgSN)) + { + var dtl = PkgRule.Details.First(q => q.PKG_LEVEL == pInput.PkgLevel); + action.IsSuccessed = false; + //action.LocaleMsg = new($"鏉$爜[{pInput.PkgSN}]鏃犻渶閲嶅鎵弿锛岃鎵弿绗瑊dtl.PKG_LEVEL}灞傚寘瑁匸{dtl.PkgType.PKG_NAME}]鐨勬爣绛炬潯鐮�"); + action.LocaleMsg = new("MES.WorkAction.PackingAction.ScanRepeat", pInput.PkgSN, dtl.PKG_LEVEL, dtl.PkgType.PKG_NAME); + return action; + } + //瀹㈡埛绔壂鎻忔垚鍔� + CurCmd = null; + PrintTimes = 0; + action = SavePkgData(input, action); } break; //Print锛氭墦鍗帮紝鎵撳嵃褰撳墠鍖呰灞傜骇鐨勬爣绛� @@ -344,6 +350,7 @@ AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, AUTH_PROD = CurPosition.CurLine.LINE_CODE, SN = pInput.PkgSN, + WIP_ID = CurPosition.CurWipSNs.Count == 1 ? CurPosition.CurWipSNs.First().ID : null, PKG_TYPE = dtl.PkgType.PKG_NAME, ITEM_CODE = CurPosition.CurWipSNs.First().ITEM_CODE, QTY = CurPosition.CurWipSNs.First().QTY, @@ -402,7 +409,7 @@ //鏈�澶栧眰鍖呰宸茬粡瀹屾垚鍖呰锛屼繚瀛樺寘瑁呮暟鎹埌鏁版嵁搴� else { - action = SaveToDB(); + action = CompletePkg(); } } //褰撳墠澶勭悊鐨勫寘瑁呭眰绾у凡缁忓鐞嗗畬锛岀户缁線涓婁繚瀛� @@ -506,36 +513,9 @@ return list; } - public ApiAction<SubmitOutput> SaveToDB() + public ApiAction<SubmitOutput> CompletePkg() { var action = new ApiAction<SubmitOutput>(new SubmitOutput()); - - var pkgList = GetPackageList(CurPkg.Item); - - //鍖呰淇℃伅淇濆瓨鍒板湪鍒跺搧淇℃伅琛� - foreach (var wipSN in CurPosition.CurWipSNs) - { - wipSN.TRAY_SN = CurPkg.Item.Package.SN; - wipSN.CARTON_SN = CurPkg.Item.Package.SN; - } - //鍖呰淇℃伅淇濆瓨鍒板伐鍗曟潯鐮佹槑缁嗚〃 - var woSNs = CurPosition.WorkBatch.WoSNs.Where(q => CurPosition.CurWipSNs.Any(w => q.SN == w.SN)).ToList(); - foreach (var woSN in woSNs) - { - woSN.TRAY_SN = CurPkg.Item.Package.SN; - woSN.OUTER_SN = CurPkg.Item.Package.SN; - } - - //淇濆瓨鏁版嵁搴� - var db = Biz.Db; - var dbTran = db.UseTran(() => - { - db.Insertable(pkgList, CurPosition.UserCode).ExecuteCommand(); - }); - if (!dbTran.IsSuccess) - { - throw dbTran.ErrorException; - } var data = new PackingActionOutput() { PkgInfo = CurPkg }; data.ExecCode = "Complete"; @@ -570,6 +550,7 @@ { AUTH_ORG = CurPosition.WorkBatch.WO.AUTH_ORG, AUTH_PROD = CurPosition.CurLine.LINE_CODE, + WIP_ID = wipSn.ID, HIS_ID = CurPosition.CurWipSNHiss.First(q => q.SN == wipSn.SN).ID, SN = wipSn.SN, STATUS = wipSn.STATUS, @@ -587,7 +568,11 @@ POST_CODE = wipSn.POST_CODE, OPER_CODE = wipSn.OPER_CODE, SEGMENT = wipSn.SEGMENT, + FLOW_SN = wipSn.FLOW_SN, TRAY_SN = wipSn.TRAY_SN, + INNER_SN = wipSn.INNER_SN, + CARTON_SN = wipSn.CARTON_SN, + PALLET_SN = wipSn.PALLET_SN, OPERATION_TIME = DateTime.Now, SFTS_CODE = wipSn.SFTS_CODE, SFT_CODE = wipSn.SFT_CODE, @@ -600,11 +585,34 @@ wipActs.Add(wipAct); } + //鍒涘缓鍙橀噺鍏嬮殕瀵硅薄鐢ㄤ簬浼犲叆DBSubmitAction涓繚瀛樺綋鍓嶉渶瑕佹殏瀛樼殑鏁版嵁鍊� + var _wipActs = wipActs.Clone(); + var _pkgList = CurPkg.IsFinished ? GetPackageList(CurPkg.Item) : new(); //淇濆瓨鏁版嵁 CurStep.DBSubmitAction = () => { var db = CurPosition.GetCommitDB(); - db.Storageable(wipActs, CurPosition.UserCode).ExecuteCommand(); + db.Storageable(_wipActs, CurPosition.UserCode).ExecuteCommand(); + if (_pkgList.Any()) + { + db.Insertable(_pkgList, CurPosition.UserCode).ExecuteCommand(); + foreach (var pkg in _pkgList) + { + //鍖呰淇℃伅淇濆瓨鍒板湪鍒跺搧淇℃伅琛� + db.Updateable<MES_WIP_DATA>() + .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN) + .SetColumns(q => q.INNER_SN == q.CARTON_SN) + .SetColumns(q => q.CARTON_SN == CurPkg.Item.Package.SN) + .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.SN == pkg.SN) + .ExecuteCommand(); + //鍖呰淇℃伅淇濆瓨鍒板伐鍗曟潯鐮佹槑缁嗚〃 + db.Updateable<BIZ_MES_WO_SN>() + .SetColumns(q => q.TRAY_SN == CurPkg.Item.Package.SN) + .SetColumns(q => q.OUTER_SN == CurPkg.Item.Package.SN) + .Where(q => q.WORK_ORDER == pkg.WORK_ORDER && q.SN == pkg.SN) + .ExecuteCommand(); + } + } }; if (CurPkg.IsFinished) -- Gitblit v1.9.3