From 0c7322109660b80e359118de04c0b9cc16a030e3 Mon Sep 17 00:00:00 2001
From: xwt <2740516069@qq.com>
Date: 星期五, 10 十月 2025 15:45:31 +0800
Subject: [PATCH] SJ,XJ,RKJ调用FTP附件

---
 StandardInterface/MES.Service/service/QC/RKJService.cs |   68 ++++++++++++++++++++++++++++-----
 1 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/StandardInterface/MES.Service/service/QC/RKJService.cs b/StandardInterface/MES.Service/service/QC/RKJService.cs
index 92353cc..dc5c9a7 100644
--- a/StandardInterface/MES.Service/service/QC/RKJService.cs
+++ b/StandardInterface/MES.Service/service/QC/RKJService.cs
@@ -710,8 +710,36 @@
         var rkjDto = new RKJDto();
 
         var db = SqlSugarHelper.GetInstance();
-        var qsItemOqcItem =
-            db.Queryable<QsItemOqcItem>().Single(s => s.Id == id);
+        
+        // 浣跨敤JOIN鏌ヨ鑾峰彇瀛愯〃鏁版嵁鍜屼富琛ㄧ殑ItemNo瀛楁
+        var qsItemOqcItem = db
+            .Queryable<QsItemOqcItem, QsItemOqcReq>((a, b) => new JoinQueryInfos(JoinType.Left, a.Pid == b.Id))
+            .Where((a, b) => a.Id == id)
+            .Select((a, b) => new QsItemOqcItem
+            {
+                Id = a.Id,
+                Pid = a.Pid,
+                ProjName = a.ProjName,
+                ItemMod = a.ItemMod,
+                InspectionMethod = a.InspectionMethod,
+                UsingInstruments = a.UsingInstruments,
+                LevelNum = a.LevelNum,
+                MaxValue = a.MaxValue,
+                StandardValue = a.StandardValue,
+                MinValue = a.MinValue,
+                Notes = a.Notes,
+                FcheckLevel = a.FcheckLevel,
+                FacLevel = a.FacLevel,
+                QsCode = a.QsCode,
+                QsName = a.QsName,
+                Picture = a.Picture,
+                Picturename = a.Picturename,
+                IsPass = a.IsPass,
+                Remarks = a.Remarks,
+                FreQty = a.FreQty,
+                // 娣诲姞涓昏〃鐨処temNo瀛楁
+                ItemNo = b.ItemNo
+            }).Single();
 
         if (qsItemOqcItem.IsPass == 0)
             qsItemOqcItem.Result = "涓嶅悎鏍�";
@@ -731,7 +759,6 @@
         qsItemOqcItem.Unqualified = count;
 
         rkjDto.ItemXj01 = qsItemOqcItem;
-
 
         rkjDto.ItemXj02s = db.Queryable<QsItemOqcItemDetail>()
             .Where(s => s.Pid == id)
@@ -960,14 +987,24 @@
     /// 鑾峰彇闄勪欢淇℃伅
     /// </summary>
     /// <param name="ItemNo">鐗╂枡缂栫爜</param>
+    /// <param name="projName">椤圭洰鍚嶇О锛堢敤浜庤繃婊わ級</param>
     /// <returns>闄勪欢鍒楄〃</returns>
-    public List<QamftpDto> GetAttachments(string ItemNo)
+    public List<QamftpDto> GetAttachments(string ItemNo, string projName = null)
     {
         var db = SqlSugarHelper.GetInstance();
         try
         {
-            return db.Queryable<MesQamftp>()
+            var query = db.Queryable<MesQamftp>()
                 .Where(x => x.ItemNo == ItemNo)
+                .Where(x => x.Ftype == "鍏ュ簱妫�");  // 娣诲姞FTYPE = '鍏ュ簱妫�'鐨勯檺鍒�
+            
+            // 濡傛灉浼犲叆浜唒rojName锛屽垯鎸塅version杩囨护
+            if (!string.IsNullOrEmpty(projName))
+            {
+                query = query.Where(x => x.Fversion == projName);
+            }
+            
+            return query
                 .OrderBy(x => x.Fdate, OrderByType.Desc)
                 .Select(x => new QamftpDto
                 {
@@ -998,24 +1035,33 @@
     /// </summary>
     /// <param name="itemNo">鐗╂枡缂栫爜</param>
     /// <param name="fileName">鏂囦欢鍚�</param>
-    /// <param name="ftpServer">FTP鏈嶅姟鍣ㄥ湴鍧�</param>
+    /// <param name="projName">椤圭洰鍚嶇О</param>
     /// <returns>鏂囦欢瀛楄妭鏁扮粍</returns>
-    public byte[] GetFtpFile(string itemNo, string fileName, string ftpServer)
+    public byte[] GetFtpFile(string itemNo, string fileName, string projName = null)
     {
         // 鍙傛暟楠岃瘉
-        if (string.IsNullOrEmpty(itemNo) || string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(ftpServer))
+        if (string.IsNullOrEmpty(itemNo) || string.IsNullOrEmpty(fileName))
         {
-            throw new ArgumentException("鍙傛暟涓嶈兘涓虹┖: itemNo, fileName, ftpServer");
+            throw new ArgumentException("鍙傛暟涓嶈兘涓虹┖: itemNo, fileName");
         }
         
         string ftpUser = "hm_ftp";
         string ftpPwd = "dell_123";
+        string ftpServer = "ftp://192.168.1.100"; // 榛樿FTP鏈嶅姟鍣ㄥ湴鍧�
         
         // 鏍囧噯鍖朏TP鏈嶅姟鍣ㄥ湴鍧�
         string normalizedServer = NormalizeFtpServer(ftpServer);
         
-        // 鏋勫缓FTP鏂囦欢璺緞 - RKJ浣跨敤FQC鏂囦欢澶�
-        string ftpPath = $"{normalizedServer}/FQC/{itemNo}/{fileName}";
+        // 鏋勫缓FTP鏂囦欢璺緞 - RKJ浣跨敤FQC鏂囦欢澶癸紝濡傛灉鏈塸rojName鍒欎娇鐢╬rojName浣滀负璺緞鐨勬渶鍚庝竴娈�
+        string ftpPath;
+        if (!string.IsNullOrEmpty(projName))
+        {
+            ftpPath = $"{normalizedServer}/FQC/{itemNo}/{projName}/{fileName}";
+        }
+        else
+        {
+            ftpPath = $"{normalizedServer}/FQC/{itemNo}/{fileName}";
+        }
         
         try
         {

--
Gitblit v1.9.3