From f656805650f0024d30ede19d8c32070f319ed507 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期日, 21 七月 2024 21:56:41 +0800
Subject: [PATCH] MES逻辑增加组织的判断和保存

---
 Tiger.Business.MES/Transaction/Position.cs |   27 ++++++++++++++++++++++++++-
 1 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/Tiger.Business.MES/Transaction/Position.cs b/Tiger.Business.MES/Transaction/Position.cs
index fd494ab..b217619 100644
--- a/Tiger.Business.MES/Transaction/Position.cs
+++ b/Tiger.Business.MES/Transaction/Position.cs
@@ -39,6 +39,9 @@
             //if (CurFactory.IsNullOrEmpty()) throw new InvalidDataException($"MES.Transaction.Position.FactoryNotExistsException", new Exception($"{postCode}|{CurWorkshop.FTY_CODE}"));
             if (CurFactory.IsNullOrEmpty()) throw new InvalidDataException($"宀椾綅[{postCode}]鎵�灞炵殑宸ュ巶[{CurWorkshop.FTY_CODE}]涓嶅瓨鍦紝璇峰厛璁剧疆鎵�灞炲伐鍘�", new Exception($"{postCode}|{CurWorkshop.FTY_CODE}"));
 
+            //鍔犺浇褰撳墠浜х嚎鐨勭彮鍒�
+            CurShiftSys = Biz.Db.Queryable<MES_SHIFT_SYS>().Where(q => q.SFTS_CODE == CurLine.SFTS_CODE).IncludesAllFirstLayer().IncludesAllSecondLayer(q => q.Shifts).First();
+
             return this;
         }
 
@@ -49,6 +52,7 @@
         public MES_WORKSHOP CurWorkshop { get; set; }
         public MES_LINE CurLine { get; set; }
         public MES_POSITION CurPosition { get; set; }
+        public MES_SHIFT_SYS CurShiftSys { get; set; }
         public WorkBatch CurBatch { get; set; }
         public IWorkBatch WorkBatch => CurBatch;
         public MES_WIP_DATA CurWipSN { get; set; }
@@ -118,6 +122,27 @@
                 action.CatchExceptionWithLog(ex, $"閲囬泦宸ュ簭锛氶�夋嫨宸ュ崟寮傚父");
             }
             return action;
+        }
+
+        /// <summary>
+        /// 鑾峰彇褰撳墠鏃堕棿鎵�灞炵殑鐝埗鐝鏃舵
+        /// </summary>
+        public ShiftPeriod GetShiftPeriodForNow()
+        {
+            var time = DateTime.Now.ToString("HHmm").ToInt32();
+            foreach (var shift in CurShiftSys.Shifts)
+            {
+                var period = shift.Periods.Where(q => q.PRD_BEGIN <= time && time <= q.PRD_END).FirstOrDefault();
+                if (!period.IsNullOrEmpty())
+                {
+                    var result = new ShiftPeriod();
+                    result.ShiftSys = CurShiftSys;
+                    result.Shift = shift;
+                    result.Period = period;
+                    return result;
+                }
+            }
+            return null;
         }
 
         /// <summary>
@@ -279,7 +304,7 @@
             }
             return result;
         }
-
+        
         #endregion Functions
 
         public override bool Close(bool needSaveHistoryLog = false)

--
Gitblit v1.9.3