From 7a4c218909936721fe281737491d10efc7378e09 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 19 七月 2024 17:53:30 +0800
Subject: [PATCH] 优化工单信息页面

---
 代码管理/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs |   55 +++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 43 insertions(+), 12 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs"
index 0829fa3..9c6a951 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/AutoUpdateWork.cs"
@@ -8,6 +8,7 @@
 using WIDESEA_Entity.DomainModels;
 using WIDESEA_WCS.IRepositories;
 using WIDESEA_WCS.IServices;
+using WIDESEA_WCS.Jobs.Task;
 using WIDESEA_WCS.Repositories;
 using WIDESEA_WCS.Services;
 using WIDESEA_WMS.IRepositories;
@@ -60,9 +61,10 @@
             VOLContext context = new VOLContext();
             Idt_mes_headRepository mes_HeadRepository = new dt_mes_headRepository(context);
             Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(context);
+            Idt_management_timeRepository timeRepository = new dt_management_timeRepository(context);
 
-
-            var mes_heads = mes_HeadRepository.Find(x => x.quantity == x.finishNum /*|| x.CreateTime.AddDays(30) < DateTime.Now*/).ToList();
+            var val = timeRepository.Find(x => x.management_name == "FinishMesWork").FirstOrDefault().management_numericalvalue;
+            var mes_heads = mes_HeadRepository.Find(x => x.quantity == x.finishNum || x.CreateTime.AddDays(val) < DateTime.Now).Take(10).ToList();
 
             #region 妫�娴嬬嚎宸ュ崟
             var mes_head_jcxs = mes_heads.Where(x => x.processCode == "28").ToList();
@@ -70,7 +72,24 @@
             {
                 foreach (var mes_head in mes_head_jcxs)
                 {
-                    AddHtyMesWork(mes_head, mes_HeadRepository);
+                    if (mes_head.quantity == mes_head.agv_finishNum)
+                    {
+                        if (mes_head.creator == "MES")
+                        {
+                            var uploadResult = HandleTask_Mes.UploadMESInfo(mes_head.jobID);
+                            if (uploadResult.Status)
+                            {
+                                AddHtyMesWork(mes_head, mes_HeadRepository);
+                            }
+                        }
+                        else
+                        {
+                            AddHtyMesWork(mes_head, mes_HeadRepository);
+                        }
+                        
+                    }
+                        
+                    
                 }
             }
             #endregion
@@ -81,9 +100,23 @@
             {
                 foreach (var mes_head in mes_head_jjgs)
                 {
-                    var inventorys = inventoryRepository.Find(x => x.jobID == mes_head.jobID).ToList();
-                    if (inventorys.Count == mes_head.quantity)
-                        AddHtyMesWork(mes_head, mes_HeadRepository);
+                    if (mes_head.quantity == mes_head.agv_finishNum)
+                    {
+                        if (mes_head.creator == "MES")
+                        {
+                            var uploadResult = HandleTask_Mes.UploadMESInfo(mes_head.jobID);
+                            if (uploadResult.Status)
+                            {
+                                AddHtyMesWork(mes_head, mes_HeadRepository);
+                            }
+                        }
+                        else
+                        {
+                            AddHtyMesWork(mes_head, mes_HeadRepository);
+                        }
+                        
+                    }
+                       
                 }
             }
             #endregion
@@ -115,10 +148,11 @@
                             heatID = mes_Detail.heatID,
                             jobID = mes_Detail.jobID,
                             mes_detail_id = mes_Detail.mes_detail_id,
-                            mes_headID = mes_Detail.mes_headID,
-                            operatetype = operatetype,
+                            mes_headID = mes_Detail.mes_id,
+                            operatetype = string.IsNullOrEmpty(mes_Detail.Status) ? "瓒呮椂娓呯悊" : operatetype,
                             SN = mes_Detail.SN,
                             Status = mes_Detail.Status,
+                            completedate = DateTime.Now,
                         };
                         mes_Details_hty.Add(mes_Detail_Hty);
                         mes_DetailRepository.Delete(mes_Detail, true);
@@ -144,16 +178,13 @@
                     operatetype = operatetype,
                     processCode = mes_Head.processCode,
                     mes_id = mes_Head.mes_id,
-                    skip_op_1 = mes_Head.skip_op_1,
-                    skip_op_2 = mes_Head.skip_op_2,
-                    skip_op_3 = mes_Head.skip_op_3,
-                    stackNoRange = mes_Head.stackNoRange,
                     productDesc = mes_Head.productDesc,
                     productName = mes_Head.productName,
                     reqID = mes_Head.reqID,
                     reqIDLineNo = mes_Head.reqIDLineNo,
                     typeID = mes_Head.typeID,
                     workOrder = mes_Head.workOrder,
+                    completedate = DateTime.Now,
                 };
                 mes_Head_HtyRepository.Add(mes_Head_Hty, true);
                 mes_HeadRepository.Delete(mes_Head, true);

--
Gitblit v1.9.3