From da3fd4520a4656ee7ae889595f5361562ef909e3 Mon Sep 17 00:00:00 2001
From: qiuyao <qiuyao@hnkhzn.com>
Date: 星期一, 24 三月 2025 09:03:19 +0800
Subject: [PATCH] 修改工艺表

---
 项目代码/WIDESEAWCS_Server 正式/SerialPortService/ProcessServer.cs |   64 +++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 14 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortService/ProcessServer.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortService/ProcessServer.cs"
index 3934275..f50bfb3 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortService/ProcessServer.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortService/ProcessServer.cs"
@@ -7,6 +7,7 @@
 using System.Threading.Tasks;
 using AutoMapper;
 using AutoMapper.Configuration.Conventions;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
 using SqlSugar;
 using WIDESEA_ISerialPortRepository;
 using WIDESEA_SerialPortRepository;
@@ -324,12 +325,13 @@
         {
             try
             {
-                //鏍规嵁缁勫拰浠诲姟鍙疯幏寰梩op琛ㄥ叏閮ㄦ暟鎹�
+                Dt_Process proNow = new Dt_Process();
+                //鏍规嵁缁勫拰浠诲姟鍙疯幏寰梩orqueOp琛ㄥ叏閮ㄦ暟鎹�
                 var torp = _torqueOpRepository.QueryData(x => x.GroupOp == group && x.TakeId == takeid);
 
 
                 //鑾峰彇Modifier  ="true"  琛ㄧず鏄己鍒舵墽琛�
-                var Mod = torp.Select(x => x.Modifier).FirstOrDefault();
+                //var Mod = torp.Select(x => x.Modifier).FirstOrDefault();
 
                 //鏌ュ嚭宸ヨ壓琛�
                 var process = BaseDal.QueryData(x => x.CraftType == group);
@@ -339,28 +341,55 @@
 
 
                 //鎷垮埌宸ヨ壓琛ㄤ腑姝ラ涓�1鐨�
-                var proNoe = process.Where(x => x.SetpNum == 1);//鑾峰緱宸ヨ壓琛ㄤ腑鐨勭涓�姝�
+                //var proNoe = process.Where(x => x.SetpNum == 1);//鑾峰緱宸ヨ壓琛ㄤ腑鐨勭涓�姝�
                 if (torp.Count == 0)
                 {
-                    return new WebResponseContent { Status = true, Message = "杩斿洖宸ヨ壓琛ㄤ腑鐨勭涓�鏉�", Data = new { proNoe, maxproce } };
+                    proNow = process.Where(x => x.SetpNum == 1).First();
+                    return new WebResponseContent { Status = true, Message = "杩斿洖宸ヨ壓琛ㄤ腑鐨勭涓�鏉�", Data = new { proNow, maxproce } };
                 }
 
                 var nowNum = torp.Max(x => x.ProcessSte);//鑾峰緱褰撳墠鏈�澶ф楠�
-
+                var flag = torp.Where(a => a.ProcessSte == nowNum && a.Modifier == "true").FirstOrDefault();
                 //op.Modifier="true"  琛ㄧず鏄己鍒舵墽琛岋紝灏变笉闇�瑕佸垽鏂簲鎵殑娆℃暟锛岀洿鎺ヨ繑鍥� op.ProcessSte+1
-                if (Mod == "true")
+                //if (Mod == "true")
+                //{
+                //    var now = maxproce + 1;
+                //    return new WebResponseContent { Status = true, Data = new { proNoe, maxproce, now } };
+                //}
+                if (flag != null)
                 {
                     var now = maxproce + 1;
-                    return new WebResponseContent { Status = true, Data = new { proNoe, maxproce, now } };
+                    proNow = process.Where(x => x.SetpNum == now).First();
+                    var finish= process.Where(x => x.SetpNum > now);
+                    return new WebResponseContent { Status = true, Data = new { proNow, maxproce, now, finish } };
                 }
 
                 //濡傛灉瀛樺�艰〃涓湁鏁版嵁灏辫繑鍥炵粰浠栧綋鍓嶅伐鑹烘楠�
-                var maxpro = process.Where(x => x.SetpNum == nowNum);
-
+                var maxpro = process.Where(x => x.SetpNum == nowNum).FirstOrDefault();
+                if (maxpro != null)
+                {
+                    if (maxpro.TorqueOneQuantity + maxpro.TorqueTwoQuantity > torp.Where(a => a.ProcessSte == nowNum).Count())
+                    {
+                        proNow = maxpro;
+                        var finish = process.Where(x => x.SetpNum < nowNum);
+                        return new WebResponseContent { Status = true, Message = "杩斿洖褰撳墠浠诲姟鍋氬埌鐨勫ぇ姝ラ", Data = new { proNow, maxproce, finish } };
+                    }
+                    else
+                    {
+                        var now = nowNum + 1;
+                        proNow = process.Where(x => x.SetpNum == now).First();
+                        var finish = process.Where(x => x.SetpNum < now);
+                        return new WebResponseContent { Status = true, Message = "杩斿洖褰撳墠浠诲姟鍋氬埌鐨勫ぇ姝ラ", Data = new { proNow, maxproce, finish } };
+                    }
+                }
+                else
+                {
+                    return new WebResponseContent { Status = false, Message = "宸ヨ壓鏁版嵁鏈夎"};
+                }
 
                 //鍒ゆ柇褰撳墠姝ラ鐨勬壄鍔涙鏁版槸鍚﹀畬鎴愶紝娌″畬鎴愯繑鍥炲綋鍓嶆楠わ紝瀹屾垚杩斿洖op.ProcessSte+1锛岀姸鎬佸�肩粰false   
 
-                return new WebResponseContent { Status = true, Message = "杩斿洖褰撳墠浠诲姟鍋氬埌鐨勫ぇ姝ラ", Data = new { maxpro, maxproce } };
+                //return new WebResponseContent { Status = true, Message = "杩斿洖褰撳墠浠诲姟鍋氬埌鐨勫ぇ姝ラ", Data = new { maxpro, maxproce } };
 
             }
             catch (Exception ex)
@@ -369,6 +398,12 @@
             }
         }
 
+        /// <summary>
+        /// 宸ヨ壓涓嬩竴姝ヨ烦杞�
+        /// </summary>
+        /// <param name="setpDTO">褰撳墠鐝粍鐨勪换鍔″綋鍓嶆楠�</param>
+        /// <param name="flag">鏄惁寮哄埗鎵ц锛涙槸true锛屽惁false</param>
+        /// <returns>杩斿洖1銆佸綋鍓嶆楠わ紱2銆佹渶澶ф楠わ紱3銆佸凡瀹屾垚鐨勫伐鑹�</returns>
         public WebResponseContent Nextprocess(SetpDTO setpDTO, bool flag)//寮哄埗鎵ц缁欐垜true
         {
             try
@@ -396,7 +431,7 @@
                 {
                     return new WebResponseContent { Status = true, Message = "娌℃湁瀹屾垚褰撳墠姝ラ", Data = new { nowdate, maxproce } };
                 }
-                else if (practiceCount == TargetCount || (practiceCount != TargetCount && flag))//寮哄埗鎵ц 鍓嶇缁欐垜涓�涓猣lag=ture鏃�
+                else if ((practiceCount == TargetCount && TargetCount == 0) || (practiceCount != TargetCount && flag))//寮哄埗鎵ц 鍓嶇缁欐垜涓�涓猣lag=ture鏃�
                 {
                     //寮哄埗璺宠浆涓嬩竴姝ワ紝鎻掑叆op琛ㄥ綋鍓嶆楠�
                     op.TakeId = setpDTO.takeid;
@@ -414,11 +449,11 @@
                 int num = setpDTO.setnum + 1;
 
                 //杩斿洖涓嬩竴姝ユ楠�
-                var nex = process.Where(x => x.CraftType == setpDTO.group && x.SetpNum == num).FirstOrDefault();
-
+                var nex = process.Where(x => x.SetpNum == num).FirstOrDefault();
+                var finish = process.Where(x => x.SetpNum < num).ToList();
 
                 _torqueOpRepository.AddData(op);
-                return new WebResponseContent { Status = true, Message = $"浣犲凡瀹屾垚褰撳墠绗瑊setpDTO.setnum}锛屽噯澶囩{num}姝ヤ换鍔�", Data = new { nex, maxproce } };
+                return new WebResponseContent { Status = true, Message = $"浣犲凡瀹屾垚褰撳墠绗瑊setpDTO.setnum}锛屽噯澶囩{num}姝ヤ换鍔�", Data = new { nex, maxproce, finish } };
             }
             catch (Exception ex)
             {
@@ -426,6 +461,7 @@
             }
         }
 
+
         public WebResponseContent PreviousProcess(SetpDTO setpDTO)
         {
             try

--
Gitblit v1.9.3