From e4f3f20340cdd5ef16cc273eadc72ac559994988 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期五, 26 七月 2024 15:36:08 +0800
Subject: [PATCH] 忘记new

---
 Tiger.Business.MES/Transaction/Position.cs |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/Tiger.Business.MES/Transaction/Position.cs b/Tiger.Business.MES/Transaction/Position.cs
index fd494ab..435eb9f 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; }
@@ -121,6 +125,27 @@
         }
 
         /// <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>
         /// 閲嶇疆褰撳墠宸ユ
         /// </summary>
         public void ResetSteps()
@@ -153,7 +178,7 @@
         /// <summary>
         /// 娣诲姞鑺傜偣鐨勪笅涓�涓涓哄埌宸ユ鍒楄〃
         /// </summary>
-        /// <param name="curNode"></param>
+        /// <param name="parent"></param>
         private void AddNextActToSteps(WorkStep parent)
         {
             var edges = CurBatch.Edges.Where(q => q.SRC_NODE == parent.NodeID && CurBatch.NodeActs.Any(a => a.NODE_ID == parent.Node.ID && a.ID == q.TGT_NODE)).ToList();
@@ -164,6 +189,7 @@
                 {
                     var next = Steps.First(q => q.NodeID == act.ID);
                     next.Sequence = next.Sequence > parent.Sequence ? next.Sequence : (parent.Sequence + 1);
+                    next.PrepNodeIDs.Add(parent.NodeID);
                     next.PrepNodeIDs.AddRange(parent.PrepNodeIDs);
                     next.PrepNodeIDs = next.PrepNodeIDs.Distinct().ToList();
                     AddNextActToSteps(next);
@@ -178,6 +204,7 @@
                         NodeAct = act,
                         Setting = CurBatch.ActionSets.FirstOrDefault(q => q.ACT_ID == act.ID),
                     };
+                    next.PrepNodeIDs.Add(parent.NodeID);
                     next.PrepNodeIDs.AddRange(parent.PrepNodeIDs);
                     next.PrepNodeIDs = next.PrepNodeIDs.Distinct().ToList();
                     Steps.Add(next);
@@ -279,7 +306,7 @@
             }
             return result;
         }
-
+        
         #endregion Functions
 
         public override bool Close(bool needSaveHistoryLog = false)

--
Gitblit v1.9.3