From 47271125766d3c1eb1f654c2349fa855ff48ca7c Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周二, 27 8月 2024 14:13:12 +0800
Subject: [PATCH] //这里修复OP10、OP40 因为PLC先推 SPC推出、再推 产品下线问题,导致 产品下线更新数据时,把SPC数据覆盖的问题 【Editby shaocx,2024-08-27】

---
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/WorkPieceProcess.cs               |    3 +++
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/WorkPieceInfoManager.cs        |    9 ++++++++-
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/SystemBussinessHelper.cs     |   39 +++++++++++++++++++++++++++++++++++++++
 DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj |    1 +
 4 files changed, 51 insertions(+), 1 deletions(-)

diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/WorkPieceInfoManager.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/WorkPieceInfoManager.cs
index efac1e6..2f7521a 100644
--- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/WorkPieceInfoManager.cs
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/BLL/WorkPieceInfoManager.cs
@@ -1295,7 +1295,14 @@
                         }
                         else
                         {
-                            info.WorkPieceState = (int)WorkPieceState.WIP;
+                            //杩欓噷淇OP10銆丱P40 鍥犱负PLC鍏堟帹 SPC鎺ㄥ嚭銆佸啀鎺� 浜у搧涓嬬嚎闂锛屽鑷� 浜у搧涓嬬嚎鏇存柊鏁版嵁鏃讹紝鎶奡PC鏁版嵁瑕嗙洊鐨勯棶棰� 銆怑ditby shaocx,2024-08-27銆�
+                            var isAlow = SystemBussinessHelper.IsAllowUpdateWorkPieceStateToWip(info, db, logMiddle);
+                            if (isAlow)
+                            {
+                                info.WorkPieceState = (int)WorkPieceState.WIP;
+                            }
+
+
                             if (info.WorkingProcedurePlan.IndexOf(logMiddle.WorkingProcedure) + 4 <= info.WorkingProcedurePlan.Length)
                             {
                                 info.WorkPieceCurrentPosition = info.WorkingProcedurePlan.Substring(info.WorkingProcedurePlan.IndexOf(logMiddle.WorkingProcedure), 8);
diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/SystemBussinessHelper.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/SystemBussinessHelper.cs
new file mode 100644
index 0000000..25095eb
--- /dev/null
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/Utils/SystemBussinessHelper.cs
@@ -0,0 +1,39 @@
+锘�
+using iWare_SCADA_Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace iWare_SCADA_BusinessLogical.Utils
+{
+    /// <summary>
+    /// 涓氬姟绯荤粺甯姪绫�
+    /// </summary>
+    public class SystemBussinessHelper
+    {
+
+        /// <summary>
+        /// 鏄惁鍏佽淇敼WorkPieceState 涓篧IP
+        /// </summary>
+        /// <param name="info"></param>
+        /// <param name="db"></param>
+        /// <param name="logMiddle"></param>
+        /// <returns></returns>
+        public static bool IsAllowUpdateWorkPieceStateToWip(WorkPieceInfo info, DbModel db, WorkPieceLogMiddle logMiddle)
+        {
+            //杩欓噷淇OP10銆丱P40 鍥犱负PLC鍏堟帹 SPC鎺ㄥ嚭銆佸啀鎺� 浜у搧涓嬬嚎闂锛屽鑷� 浜у搧涓嬬嚎鏇存柊鏁版嵁鏃讹紝鎶奡PC鏁版嵁瑕嗙洊鐨勯棶棰� 銆怑ditby shaocx,2024-08-27銆�
+            if (logMiddle.WorkingProcedure == "OP10" || logMiddle.WorkingProcedure == "OP40")
+            {
+                var curPross = db.WorkPieceProcess.Where(x => x.WorkPieceID == info.WorkPieceID).OrderByDescending(x => x.Id).FirstOrDefault();
+                if (curPross != null && curPross.OperationType == OperationType.SPC.ToString())
+                {
+                    return false;
+                }
+                return true;
+            }
+            return true;
+        }
+    }
+}
diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj
index 247ca55..55705db 100644
--- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_BusinessLogical/iWare_SCADA_BusinessLogical.csproj
@@ -158,6 +158,7 @@
     </Compile>
     <Compile Include="Utils\QualityStateHelper.cs" />
     <Compile Include="Utils\MonitorHelper.cs" />
+    <Compile Include="Utils\SystemBussinessHelper.cs" />
     <Compile Include="Utils\SystemHelper.cs" />
     <Compile Include="Utils\ComboBoxHelper.cs" />
     <Compile Include="Utils\ConfigHelper.cs" />
diff --git a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/WorkPieceProcess.cs b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/WorkPieceProcess.cs
index b5784a1..95a72e4 100644
--- a/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/WorkPieceProcess.cs
+++ b/DataCapture/iWare_SCADA_DataCapture/iWare_SCADA_Model/TableModel/WorkPieceProcess.cs
@@ -58,6 +58,9 @@
         [StringLength(50)]
         public string UpdatedUserName { get; set; }
 
+        /// <summary>
+        /// 操作类型,使用枚举 OperationType
+        /// </summary>
         [StringLength(50)]
         public string OperationType { get; set; }
         [StringLength(255)]

--
Gitblit v1.9.3