From 0a430c14f3e3ceb4ba63462c4f2c92768fc79e87 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期三, 12 三月 2025 19:04:26 +0800
Subject: [PATCH] 美型

---
 项目代码/WIDESEAWCS_Server 正式/SerialPortService/ProcessServer.cs |  114 ++++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 73 insertions(+), 41 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 a17ae45..3ebbded 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"
@@ -6,6 +6,7 @@
 using System.Threading.Tasks;
 using SqlSugar;
 using WIDESEA_ISerialPortRepository;
+using WIDESEA_SerialPortRepository;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.BaseRepository;
 using WIDESEAWCS_Core.BaseServices;
@@ -16,15 +17,25 @@
 namespace WIDESEAWCS_TaskInfoService
 {
     public class ProcessServer : ServiceBase<Dt_Process, IProcessRepository>, IProcessServer
-    { 
-        
+    {
+        private IPutakeRepository _putakeRepository;
         private IUnitOfWorkManage _unitOfWorkManage;
-        public ProcessServer(IProcessRepository BaseDal, IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
+        private ITorqueOpRepository _torqueOpRepository;
+        public ProcessServer(IProcessRepository BaseDal, IUnitOfWorkManage unitOfWorkManage, IPutakeRepository putakeRepository, ITorqueOpRepository torqueOpRepository) : base(BaseDal)
         {
-            _unitOfWorkManage=unitOfWorkManage;
+            _putakeRepository = putakeRepository;
+            _unitOfWorkManage = unitOfWorkManage;
+            _torqueOpRepository = torqueOpRepository;
         }
 
-     
+        public override PageGridData<Dt_Process> GetPageData(PageDataOptions options)
+        {
+            OrderByParameters = new Dictionary<string, OrderByType> 
+            { 
+                { nameof(Dt_Process.ArticleOne), OrderByType.Asc },//鎸変粈涔堝瓧娈垫帓搴�
+            };
+            return base.GetPageData(options);
+        }
 
         public WebResponseContent GetProcess(string gruop)
         {
@@ -41,7 +52,7 @@
                 }
                 else
                 {
-                    return new WebResponseContent{ Status = false, Message = "鏁版嵁涓虹┖"};
+                    return new WebResponseContent { Status = false, Message = "鏁版嵁涓虹┖" };
                 }
 
             }
@@ -61,10 +72,10 @@
                     .GroupBy(x => x.CraftType) // 鎸� CraftType 鍒嗙粍
                     .Select(g => new
                     {
-                       maxNodal = g.Max(a=>a.Nodal),
-                        sumTorqueSum = g.Sum(a=>a.TorqueSum)
+                        maxNodal = g.Max(a => a.Nodal),
+                        sumTorqueSum = g.Sum(a => a.TorqueSum)
                     }).ToList();
-                _unitOfWorkManage.CommitTran() ;
+                _unitOfWorkManage.CommitTran();
                 return new WebResponseContent { Status = true, Data = result };
             }
             catch (Exception ex)
@@ -80,20 +91,20 @@
             try
             {
                 var proces = new Dt_Process();
-                proces.Nodal=addProcessDTO.nodal;
-                proces.CraftType=addProcessDTO.craftstype;
-                proces.CraftsStep=addProcessDTO.craftsstep;
-                proces.CraftContent=addProcessDTO.craftcontent;
+                proces.Nodal = addProcessDTO.nodal;
+                proces.CraftType = addProcessDTO.craftstype;
+                proces.CraftsStep = addProcessDTO.craftsstep;
+                proces.CraftContent = addProcessDTO.craftcontent;
                 proces.TorqueSum = addProcessDTO.sleeveNum;
-                proces.Tools=addProcessDTO.tools;
-                _unitOfWorkManage.BeginTran() ;
+                proces.Tools = addProcessDTO.tools;
+                _unitOfWorkManage.BeginTran();
                 BaseDal.AddData(proces);
                 _unitOfWorkManage.CommitTran();
-                return new WebResponseContent { Status = true,Data=proces};
+                return new WebResponseContent { Status = true, Data = proces };
             }
             catch (Exception ex)
             {
-                _unitOfWorkManage.RollbackTran() ;
+                _unitOfWorkManage.RollbackTran();
                 return new WebResponseContent { Status = false, Message = "鏌ヨ澶辫触锛�" + ex.Message };
             }
         }
@@ -103,9 +114,9 @@
             try
             {
                 var proces = BaseDal.QueryData(x => x.CraftID == addProcessDTO.id).FirstOrDefault();
-                    if (proces == null)
+                if (proces == null)
                 {
-                    return new WebResponseContent { Status = false,Message="娌℃湁鎵惧埌"};
+                    return new WebResponseContent { Status = false, Message = "娌℃湁鎵惧埌" };
                 }
                 proces.Nodal = addProcessDTO.nodal;
                 proces.CraftType = addProcessDTO.craftstype;
@@ -125,41 +136,62 @@
             }
         }
 
-        public WebResponseContent Getcircuit(string groups)
+        public WebResponseContent Getcircuit(string group, string takeid)
         {
             try
             {
-                List<Dt_Process> results = new List<Dt_Process>();
-                int step = 1;
+                ///濡傛灉杩欎釜瀛樺�艰〃涓病鏈夋楠や竴杩欎箞鎼烇紵鎴戣繖涔堟樉绀虹粰鍓嶇鐪�
+              
 
-                while (true)
+                // 鍏堟煡鍒拌繖鏉′换鍔�
+                var putake = _putakeRepository.QueryData(x => x.Njtakeid == takeid && x.Grouptype == group).OrderBy(x => x.Dispatchtime).FirstOrDefault();
+                if (putake==null)
                 {
-                    // 鏌ヨ褰撳墠姝ラ鐨勬暟鎹�
-                    var circuit = BaseDal.QueryData(x => x.CraftType == groups && x.SetpNum == step)
-                                         .FirstOrDefault();
-
-                    // 濡傛灉鏌ヨ缁撴灉涓虹┖锛屽垯鍋滄寰幆
-                    if (circuit == null)
-                    {
-                        break;
-                    }
-
-                    // 鍔犲叆缁撴灉鍒楄〃
-                    results.Add(circuit);
-
-                    // 閫掑 step锛岀户缁煡璇笅涓�涓楠�
-                    step++;
+                    return new WebResponseContent { Status = false, Message = "娌℃湁鎵惧埌" };
                 }
+                //鑾峰彇鍒板綋鍓嶅畬鎴愮殑姝ラ
+                var nowNum = _torqueOpRepository.QueryData(x => x.GroupOp == group && x.TakeId == takeid).Max(x => x.ProcessSte);
 
-                return new WebResponseContent { Status = true, Data = results };
+               
+
+                //鏍规嵁鍒嗙粍鍜屾楠ゆ壘鍒拌鏉℃暟鎹�
+                var process = BaseDal.QueryData(x => x.CraftType == group&&x.SetpNum== nowNum).FirstOrDefault();
+
+
+                //杩斿洖褰撳墠宸ヨ壓鐨勬渶澶ф楠�
+                var maxproce = BaseDal.QueryData(x => x.CraftType == group).Max(x => x.SetpNum);
+
+                //涓�鍏辫鏈夊灏戞潯鏁版嵁锛堢洰鏍囨暟閲忥級
+                int TargetCount = process.TorqueOneQuantity + process.TorqueTwoQuantity;
+
+
+
+                // 鏌ヨ褰撳墠姝ラ鐨� TorqueOp 璁板綍锛屽尮閰� ProcessSte鍜岀粍锛屼换鍔″彿锛屾鏌ユ槸鍚﹁揪鍒拌姹傦紙瀹為檯鏁伴噺锛�
+                int practiceCount = _torqueOpRepository.QueryData(x =>  x.GroupOp == group&&x.TakeId== takeid).Count();
+
+
+
+                if (practiceCount < TargetCount)
+                {
+                    return new WebResponseContent { Status = false, Message = "娌℃湁瀹屾垚褰撳墠姝ラ",Data= process };
+                }
+                if (maxproce== nowNum)
+                {
+                    return new WebResponseContent { Status = false, Message = "浣犲畬鎴愪簡褰撳墠浣滀笟" };
+                }
+                int num = nowNum + 1;
+
+                var nex = BaseDal.QueryFirst(x => x.CraftType == group && x.SetpNum == num);
+
+                return new WebResponseContent { Status = true, Data = nex };
             }
             catch (Exception ex)
             {
                 return new WebResponseContent { Status = false, Message = "鏌ヨ澶辫触锛�" + ex.Message };
             }
         }
-
+    }
        
 
     }
-}
+

--
Gitblit v1.9.3