From 0c56e4a7cb18d9a38ec336b839bc26d73342722f Mon Sep 17 00:00:00 2001 From: Rodney Chen <rodney.chen@hotmail.com> Date: 星期六, 10 八月 2024 19:17:26 +0800 Subject: [PATCH] Merge branch 'master' of http://47.115.28.255:8110/r/TigerClouds-Tech/Server/TigerApi6_2024 --- Tiger.Business/MES/WoContext.cs | 60 ++++++++++++++++++++++++++--- Tiger.Business.MES/BIZ_MES_WO.cs | 1 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/Tiger.Business.MES/BIZ_MES_WO.cs b/Tiger.Business.MES/BIZ_MES_WO.cs index c4f57de..31296b5 100644 --- a/Tiger.Business.MES/BIZ_MES_WO.cs +++ b/Tiger.Business.MES/BIZ_MES_WO.cs @@ -103,6 +103,7 @@ var result = new ApiAction(); try { + WoContext.RemoveBatch(); //淇濆瓨鍓嶇殑鍒ゆ柇,骞剁敓鎴愭壒娆″彿 var _wo = await Biz.Db.Queryable<BIZ_MES_WO>().Where(x => x.ORDER_NO == input.Wo.ORDER_NO).FirstAsync(); //if (_wo.STATUS > (int)BIZ_MES_WO.STATUSs.Init) diff --git a/Tiger.Business/MES/WoContext.cs b/Tiger.Business/MES/WoContext.cs index feb5542..1781174 100644 --- a/Tiger.Business/MES/WoContext.cs +++ b/Tiger.Business/MES/WoContext.cs @@ -1,4 +1,5 @@ 锘縰sing Microsoft.AspNetCore.Http; +using Rhea.Common; using System; using System.Collections.Generic; using System.Linq; @@ -16,30 +17,75 @@ { #region 宸ュ崟绠$悊 /// <summary> - /// 宸ュ崟鎵规瀛楀吀 + /// /// </summary> public static Dictionary<string, WorkBatch> WoBatchDic { get; set; } = new Dictionary<string, WorkBatch>(); /// <summary> /// 浠庡伐鍗曟壒娆″瓧鍏镐腑鑾峰彇涓�涓伐鍗曟壒娆″璞� /// </summary> - /// <param name="workOrder"></param> + /// <param name="batchNo"></param> /// <param name="lineCode"></param> /// <returns></returns> - public static WorkBatch GetBatch(string workOrder, string lineCode) + public static WorkBatch GetBatch(string batchNo, string lineCode = null) { - return WoBatchDic.FirstOrDefault(q => q.Value.Batch.ORDER_NO == workOrder && q.Value.Batch.ACT_LINE == lineCode).Value; + return WoBatchDic.FirstOrDefault(q => q.Value.Batch.BATCH_NO == batchNo && (lineCode.IsNullOrEmpty() || q.Value.Batch.ACT_LINE == lineCode)).Value; } /// <summary> /// 鍒ゆ柇宸ュ崟鎵规鏄惁瀛樺湪浜庡伐鍗曟壒娆″瓧鍏镐腑 /// </summary> - /// <param name="workOrder"></param> + /// <param name="batchNo"></param> /// <param name="lineCode"></param> /// <returns></returns> - public static bool ExistsBatch(string workOrder, string lineCode) + public static bool ExistsBatch(string batchNo, string lineCode = null) { - return WoBatchDic.Any(q => q.Value.Batch.ORDER_NO == workOrder && q.Value.Batch.ACT_LINE == lineCode); + return WoBatchDic.Any(q => q.Value.Batch.BATCH_NO == batchNo && (lineCode.IsNullOrEmpty() || q.Value.Batch.ACT_LINE == lineCode)); + } + + /// 浠庡伐鍗曟壒娆″瓧鍏镐腑鍒犻櫎涓�涓伐鍗曟壒娆″璞� + /// </summary> + /// <param name="batchNo"></param> + /// <param name="lineCode"></param> + /// <returns></returns> + public static bool RemoveWo(string workorder) + { + try + { + var list = WoBatchDic.Keys.ToList().Where(q => q.Contains(workorder)); + foreach (var batch in list) + { + WoBatchDic.Remove(batch); + } + return true; + } + catch (Exception ex) + { + Logger.Default.Fatal(ex, $"浠庡伐鍗曟壒娆″瓧鍏镐腑鍒犻櫎涓�涓伐鍗昜{workorder}]瀵硅薄寮傚父"); + return false; + } + } + + /// 浠庡伐鍗曟壒娆″瓧鍏镐腑鍒犻櫎涓�涓伐鍗曟壒娆″璞� + /// </summary> + /// <param name="batchNo"></param> + /// <param name="lineCode"></param> + /// <returns></returns> + public static bool RemoveBatch(string batchNo) + { + try + { + if (WoBatchDic.ContainsKey(batchNo)) + { + WoBatchDic.Remove(batchNo); + } + return true; + } + catch (Exception ex) + { + Logger.Default.Fatal(ex, $"浠庡伐鍗曟壒娆″瓧鍏镐腑鍒犻櫎涓�涓伐鍗曟壒娆{batchNo}]瀵硅薄寮傚父"); + return false; + } } #endregion } -- Gitblit v1.9.3