From 461ccbda1d9d3fef42f250771c2fd30702755c16 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期四, 24 四月 2025 17:18:35 +0800
Subject: [PATCH] PLC

---
 项目代码/WIDESEAWCS_Server 正式/SerialPortService/ArticleInfomServer.cs |  102 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 99 insertions(+), 3 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/ArticleInfomServer.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortService/ArticleInfomServer.cs"
index 4f189e5..2bf28af 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortService/ArticleInfomServer.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEAWCS_Server \346\255\243\345\274\217/SerialPortService/ArticleInfomServer.cs"
@@ -1,4 +1,5 @@
-锘縰sing System;
+锘縰sing OfficeOpenXml.Style;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -6,6 +7,7 @@
 using WIDESEA_ISerialPortRepository;
 using WIDESEAWCS_Core;
 using WIDESEAWCS_Core.BaseServices;
+using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
 
@@ -13,9 +15,12 @@
 {
     public class ArticleInfomServer : ServiceBase<Dt_ArticleInfom, IArticleInfomRepository>, IArticleInfomServer
     {
-        public ArticleInfomServer(IArticleInfomRepository BaseDal) : base(BaseDal)
+        private readonly IProcessRepository _processRepository;
+        private readonly IPutakeRepository _ptakeRepository;
+        public ArticleInfomServer(IArticleInfomRepository BaseDal, IProcessRepository processRepository, IPutakeRepository ptakeRepository) : base(BaseDal)
         {
-
+            _processRepository = processRepository;
+            _ptakeRepository = ptakeRepository;
         }
         public override PageGridData<Dt_ArticleInfom> GetPageData(PageDataOptions options)
         {
@@ -26,5 +31,96 @@
         }
 
 
+
+        //public WebResponseContent PutPossorArticl()
+        //{
+        //    try
+        //    {
+        //        var articl = BaseDal.QueryData();
+        //        var process = _processRepository.QueryData();
+        //        var putake = _ptakeRepository.QueryData();
+
+        //        // 鍏堣幏鍙栧熀纭�鏌ヨ缁撴灉
+        //        var query = from a in articl
+        //                    from p in process
+        //                    from t in putake
+        //                    where (a.ID == p.ArticleTowid || a.ID == p.ArticleOneid)
+        //                      && (t.Pustatus == 0 || t.Pustatus == 2)
+        //                    orderby p.CraftType
+        //                    select new
+        //                    {
+        //                        t.Njtakeid,
+        //                        t.Pustatus,
+        //                        t.Grouptype,
+        //                        a.ArticleName,
+        //                        a.ArticleType
+        //                    };
+
+        //        // 鎸� ArticleType 鍜� Pustatus 缁勫悎鍘婚噸
+        //        var result = query
+        //            .GroupBy(x => new { x.ArticleType, x.Pustatus }) // 鎸夌被鍨嬪拰鐘舵�佸垎缁�
+        //            .Select(g => g.First()) // 姣忕粍鍙栫涓�鏉�
+        //            .OrderBy(x => x.Grouptype) // 鍙互淇濇寔鍘熸湁鎺掑簭
+        //            .ToList();
+        //        return new WebResponseContent { Status = true, Data = result };
+        //    }
+        //    catch (Exception ex)
+        //    {
+
+        //        return new WebResponseContent { Status = false, Message = "閿欒锛�" + ex.Message };
+        //    }
+
+        //}
+        public WebResponseContent PutPossorArticl()
+        {
+            try
+            {
+                var articl = BaseDal.QueryData();
+                var process = _processRepository.QueryData();
+                var putake = _ptakeRepository.QueryData();
+
+                // 鍏堣幏鍙栧熀纭�鏌ヨ缁撴灉
+                var query = (
+                 from t in putake
+                 join p in process on t.Grouptype equals p.CraftType
+                 join a in articl on p.ArticleOneid equals a.ID
+                 where t.Pustatus == 0 || t.Pustatus == 2
+                 select new
+                 {
+                     t.Njtakeid,
+                     t.Pustatus,
+                     t.Grouptype,
+                     a.ArticleName,
+                     a.ArticleType
+                 })
+                 .Union(
+                 from t in putake
+                 join p in process on t.Grouptype equals p.CraftType
+                 join a in articl on p.ArticleTowid equals a.ID
+                 where t.Pustatus == 0 || t.Pustatus == 2
+                 select new
+                 {
+                     t.Njtakeid,
+                     t.Pustatus,
+                     t.Grouptype,
+                     a.ArticleName,
+                     a.ArticleType
+                 });
+
+                var result = query
+                    .GroupBy(x => new { x.ArticleType, x.Pustatus, x.Grouptype,x.Njtakeid }) // 鏍规嵁濂楃瓛绫诲瀷鍜屼换鍔$姸鎬侊紝浠ュ強缁勫埆鍒嗙粍
+                    .Select(g => g.First()) // 姣忕粍鍙栫涓�鏉�
+                    .OrderBy(x => x.Grouptype)
+                    .ToList();
+
+                return new WebResponseContent { Status = true, Data = result };
+            }
+            catch (Exception ex)
+            {
+
+                return new WebResponseContent { Status = false, Message = "閿欒锛�" + ex.Message };
+            }
+
+        }
     }
 }

--
Gitblit v1.9.3