From 9a1125cc4d934a701e2505e367732a40e14c48b0 Mon Sep 17 00:00:00 2001 From: Ben Lin <maobin001@msn.com> Date: 星期四, 02 一月 2025 10:47:28 +0800 Subject: [PATCH] 生成箱号批次不能为空 --- Tiger.Business.MES/Common/WorkBatch.cs | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Tiger.Business.MES/Common/WorkBatch.cs b/Tiger.Business.MES/Common/WorkBatch.cs index 0259371..0d1811e 100644 --- a/Tiger.Business.MES/Common/WorkBatch.cs +++ b/Tiger.Business.MES/Common/WorkBatch.cs @@ -10,7 +10,6 @@ using Tiger.IBusiness; using Tiger.Model.Entitys.MES.Position; using Tiger.Business.MES; -using static Microsoft.CodeAnalysis.CSharp.SyntaxTokenParser; using Org.BouncyCastle.Ocsp; using System.IO; @@ -50,7 +49,7 @@ #region Functions /// <summary> - /// 鍒濆鍖栧伐鍗曡祫鏂� + /// 鍒濆鍖栧伐鍗曟壒娆¤祫鏂� /// </summary> /// <returns></returns> public WorkBatch Init(string lineCode) @@ -63,6 +62,10 @@ return this; } + /// <summary> + /// 鏇存柊宸ュ崟鎵规璧勬枡 + /// </summary> + /// <param name="updateAll"></param> public void Update(bool updateAll = false) { var strat = DateTime.Now; @@ -149,6 +152,7 @@ Update(); + var woSNs = Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => q.WORK_ORDER == OrderNo).ToList(); //宸ュ崟鎵规鐘舵�佷笉鏄凡涓嬪彂鎴栬�呯敓浜т腑锛屽垯涓嶅厑璁哥敓浜� if (Batch.STATUS != BIZ_MES_WO_BATCH.STATUSs.Release.GetValue() && Batch.STATUS != BIZ_MES_WO_BATCH.STATUSs.Working.GetValue()) { @@ -166,24 +170,25 @@ action.LocaleMsg = new("MES.WorkBatch.WoStatusCanNotWork", WO.ORDER_NO, Batch.STATUS.GetEnumDesc<BIZ_MES_WO.STATUSs>()); } //宸ュ崟鎵规鎶曞叆鏁伴噺鍑忓幓鎶ュ簾鏁伴噺濡傛灉澶т簬绛変簬璁″垝鏁伴噺锛屽垯涓嶅厑璁哥敓浜� - var batchInput = WoSNs.Where(q => q.BATCH_NO == Batch.BATCH_NO && BIZ_MES_WO_SN.STATUSs.NotInput.GetValue() < q.STATUS && q.STATUS <= BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY); + var batchInput = woSNs.Where(q => q.BATCH_NO == Batch.BATCH_NO && BIZ_MES_WO_SN.STATUSs.NotInput.GetValue() < q.STATUS && q.STATUS <= BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY); if (curNode.IS_FIRST_NODE == "Y" && batchInput >= Batch.PLAN_QTY) { action.IsSuccessed = false; action.Data.SetValue(this, null); //action.LocaleMsg = new($"宸ュ崟鎵规[{0}]宸叉姇鍏� {1}锛屽叾涓姤搴� {2}锛屼互婊¤冻璁″垝鏁伴噺[{3}]锛屾棤闇�缁х画鎶曞叆"); - action.LocaleMsg = new("MES.WorkBatch.BatchInputEnough", Batch.BATCH_NO, batchInput, WoSNs.Where(q => q.BATCH_NO == Batch.BATCH_NO && q.STATUS > BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY), Batch.PLAN_QTY); + action.LocaleMsg = new("MES.WorkBatch.BatchInputEnough", Batch.BATCH_NO, batchInput, woSNs.Where(q => q.BATCH_NO == Batch.BATCH_NO && q.STATUS > BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY), Batch.PLAN_QTY); } //宸ュ崟鎶曞叆鏁伴噺鍑忓幓鎶ュ簾鏁伴噺濡傛灉澶т簬绛変簬璁″垝鏁伴噺锛屽垯涓嶅厑璁哥敓浜� - var woInput = WoSNs.Where(q => q.WORK_ORDER == WO.ORDER_NO && BIZ_MES_WO_SN.STATUSs.NotInput.GetValue() < q.STATUS && q.STATUS <= BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY); + var woInput = woSNs.Where(q => q.WORK_ORDER == WO.ORDER_NO && BIZ_MES_WO_SN.STATUSs.NotInput.GetValue() < q.STATUS && q.STATUS <= BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY); if (curNode.IS_FIRST_NODE == "Y" && woInput >= WO.PLAN_QTY) { action.IsSuccessed = false; action.Data.SetValue(this, null); //action.LocaleMsg = new($"宸ュ崟[{0}]宸叉姇鍏� {1}锛屽叾涓姤搴� {2}锛屼互婊¤冻璁″垝鏁伴噺[{3}]锛屾棤闇�缁х画鎶曞叆"); - action.LocaleMsg = new("MES.WorkBatch.WoInputEnough", WO.ORDER_NO, woInput, WoSNs.Where(q => q.WORK_ORDER == WO.ORDER_NO && q.STATUS > BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY), WO.PLAN_QTY); + action.LocaleMsg = new("MES.WorkBatch.WoInputEnough", WO.ORDER_NO, woInput, woSNs.Where(q => q.WORK_ORDER == WO.ORDER_NO && q.STATUS > BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).DistinctBy(q => q.WIP_ID).Sum(q => q.QTY), WO.PLAN_QTY); } + WoSNs = woSNs; return action; } @@ -199,7 +204,7 @@ WO.STATUS = BIZ_MES_WO.STATUSs.Working.GetValue(); WO.ACT_START_TIME = WO.ACT_START_TIME < new DateTime(2000, 1, 1) ? DateTime.Now : WO.ACT_START_TIME; Batch.STATUS = BIZ_MES_WO_BATCH.STATUSs.Working.GetValue(); - Batch.ACT_START_TIME = WO.ACT_START_TIME < new DateTime(2000, 1, 1) ? DateTime.Now : WO.ACT_START_TIME; + Batch.ACT_START_TIME = Batch.ACT_START_TIME < new DateTime(2000, 1, 1) ? DateTime.Now : Batch.ACT_START_TIME; //淇濆瓨鏁版嵁搴� var db = Biz.Db; var dbTran = db.UseTran(() => @@ -254,7 +259,7 @@ //鍒ゆ柇褰撳墠宸ュ崟鎵规鏄惁宸插畬宸� if (!woSNs.Any(q => q.BATCH_NO == Batch.BATCH_NO && q.STATUS < BIZ_MES_WO_SN.STATUSs.Finished.GetValue()) && - woSNs.Count(q => q.BATCH_NO == Batch.BATCH_NO && q.STATUS == BIZ_MES_WO_SN.STATUSs.Finished.GetValue()) == Batch.PLAN_QTY) + woSNs.Where(q => q.BATCH_NO == Batch.BATCH_NO && q.STATUS == BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).Sum(q=>q.QTY) == Batch.PLAN_QTY) { Batch.STATUS = BIZ_MES_WO_BATCH.STATUSs.Closed.GetValue(); Batch.ACT_END_TIME = DateTime.Now; @@ -262,7 +267,7 @@ //鍒ゆ柇褰撳墠宸ュ崟鏄惁宸插畬宸� if (!woSNs.Any(q => q.STATUS < BIZ_MES_WO_SN.STATUSs.Finished.GetValue()) && - woSNs.Count(q => q.STATUS == BIZ_MES_WO_SN.STATUSs.Finished.GetValue()) == WO.PLAN_QTY) + woSNs.Where(q => q.STATUS == BIZ_MES_WO_SN.STATUSs.Finished.GetValue()).Sum(q => q.QTY) == WO.PLAN_QTY) { WO.STATUS = BIZ_MES_WO.STATUSs.Closed.GetValue(); WO.ACT_END_TIME = DateTime.Now; -- Gitblit v1.9.3