From 57caad11d92771dcaa7d76d871daa3e4a538c2be Mon Sep 17 00:00:00 2001
From: xwt <2740516069@qq.com>
Date: 星期一, 25 八月 2025 12:39:32 +0800
Subject: [PATCH] 来料检逻辑修改

---
 StandardInterface/MES.Service/service/QC/LljService.cs |  555 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 523 insertions(+), 32 deletions(-)

diff --git a/StandardInterface/MES.Service/service/QC/LljService.cs b/StandardInterface/MES.Service/service/QC/LljService.cs
index e07051c..78dc03b 100644
--- a/StandardInterface/MES.Service/service/QC/LljService.cs
+++ b/StandardInterface/MES.Service/service/QC/LljService.cs
@@ -1,10 +1,12 @@
 锘縰sing System.Data;
+using System.Xml;
 using Masuit.Tools;
 using MES.Service.DB;
 using MES.Service.Dto.service;
 using MES.Service.Modes;
 using MES.Service.util;
 using SqlSugar;
+using Tea.Utils;
 using DbType = System.Data.DbType;
 
 
@@ -22,39 +24,128 @@
 
         var totalCount = 0;
 
-        //var itemIds = GetQaItem(db, queryObj.createUser);
-
-        var pageList = db.Queryable<LtsLlj>()
+        var pageList = db.Queryable<LtsLlj, V_LljUser>((a, v) =>
+                new JoinQueryInfos(JoinType.Left, a.ItemNo == v.ItemNo))
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 "鏈畬鎴�".Equals(queryObj.result),
-                a => a.FcheckResu == null)
+                (a, v) => a.FcheckResu == null)
             .WhereIF(
                 StringUtil.IsNotNullOrEmpty(queryObj.result) &&
                 !"鏈畬鎴�".Equals(queryObj.result),
-                a => a.FcheckResu != null)
-            .WhereIF(id > 0, a => a.Id == id)
+                (a, v) => a.FcheckResu != null)
+            .WhereIF(id > 0, (a, v) => a.Id == id)
+            // 鏉冮檺鎺у埗锛歅L017銆丠MLYY銆丠MCS 鍙互鐪嬪埌鎵�鏈夊崟鎹紝鍏朵粬鐢ㄦ埛闇�瑕佹牴鎹墿鏂欑淮鎶ゆ儏鍐靛垽鏂�
+            .WhereIF(queryObj.createUser != "PL017" && queryObj.createUser != "HMLYY" && queryObj.createUser != "HMCS" && queryObj.UserIndex == "0", 
+                (a, v) => 
+                    // 濡傛灉鐗╂枡琚淮鎶わ紝鍙湁缁存姢浜哄憳鍙互鐪嬪埌
+                    (v.Fcode != null && v.Fcode == queryObj.createUser) ||
+                    // 濡傛灉鐗╂枡鏈缁存姢锛屾墍鏈変汉閮藉彲浠ョ湅鍒�
+                    (v.Fcode == null))
 
-            //鍔犵瓫閫夋潯浠�,鏍规嵁渚涘簲鍟嗭紝鐗╂枡缂栫爜锛岀墿鏂欏悕绉版悳绱�
-            //.WhereIF(queryObj.SearchValue!=null && queryObj.SearchValue!="", (a) => a.SuppName == queryObj.SearchValue|| a.ItemName == queryObj.SearchValue || a.ItemNo == queryObj.SearchValue )
-            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue),
-                a => a.SuppName.ToLower()
-                         .Contains(queryObj.SearchValue.ToLower())
-                     || a.ItemName.ToLower()
-                         .Contains(queryObj.SearchValue.ToLower())
-                     || a.ItemNo.ToLower()
-                         .Contains(queryObj.SearchValue.ToLower())
-                     || a.LotNo.ToLower()
-                        .Contains(queryObj.SearchValue.ToLower())
-                     || a.ReleaseNo.ToLower()
-                        .Contains(queryObj.SearchValue.ToLower())
-                     || a.ItemModel.ToLower()
-                        .Contains(queryObj.SearchValue.ToLower()))
-            .OrderByDescending(a => a.Id)
+            //鍔犵瓫閫夋潯浠�,鏍规嵁閫夋嫨鐨勬悳绱㈠瓧娈佃繘琛岀簿纭悳绱�
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 1, // 鐗╂枡缂栧彿鎼滅储
+                (a, v) => a.ItemNo != null && a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 2, // 鐗╂枡鍚嶇О鎼滅储
+                (a, v) => a.ItemName != null && a.ItemName.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 3, // 渚涘簲鍟嗘悳绱�
+                (a, v) => a.SuppName != null && a.SuppName.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 4, // 鍒拌揣鍗曞彿鎼滅储
+                (a, v) => a.LotNo != null && a.LotNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 5, // 妫�楠屽崟鍙锋悳绱�
+                (a, v) => a.ReleaseNo != null && a.ReleaseNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 6, // 鐗╂枡瑙勬牸鎼滅储
+                (a, v) => a.ItemModel != null && a.ItemModel.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .Select((a, v) => new LtsLlj
+            {
+                Id = a.Id,
+                ItemNo = a.ItemNo,
+                ItemId = a.ItemId,
+                ItemName = a.ItemName,
+                ItemModel = a.ItemModel,
+                SuppName = a.SuppName,
+                LotNo = a.LotNo,
+                ReleaseNo = a.ReleaseNo,
+                FcheckResu = a.FcheckResu,
+                CreateDate = a.CreateDate,
+                FcovertQty = a.FcovertQty,
+                DEPARTMENTNAME = a.DEPARTMENTNAME,
+                FngDesc = a.FngDesc,
+                UrgentFlag = a.UrgentFlag,
+                Ftype = a.Ftype,
+                LotNo1 = a.LotNo1,
+                EMERGENCY = a.EMERGENCY,
+                Status = a.Status,
+                IqcDate = a.IqcDate,
+                // 娣诲姞缁存姢浜哄憳淇℃伅
+                Fcode = v.Fcode,
+                // 娣诲姞鐮村潖瀹為獙鏁伴噺
+                PHSY = a.PHSY,
+                // 娣诲姞涓嶈壇鍘熷洜
+                BLYY = a.BLYY,
+                // 娣诲姞鎵�灞炶溅闂�
+                SSCJ = a.SSCJ,
+                // 娣诲姞璇勫鐘舵��
+                PSZT = a.PSZT
+            })
+            .OrderBy("CASE WHEN EMERGENCY = 1 THEN 0 ELSE 1 END, CASE WHEN STATUS = '宸叉彁浜�' THEN 0 ELSE 1 END, IQC_DATE desc, ID asc")
             .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount);
 
-
-        return (pageList, totalCount);
+        // 鎵归噺鑾峰彇妫�楠岄」鐩暟閲忥紝閬垮厤N+1鏌ヨ闂
+        if (pageList.Any())
+        {
+            var releaseNos = pageList.Select(x => x.ReleaseNo).Distinct().ToList();
+            
+            // 涓烘瘡涓楠屽崟璁剧疆妫�楠岄」鐩暟閲忓拰NewFngDesc瀛楁
+            foreach (var item in pageList)
+            {
+                var count = db.Queryable<MesQaItemsDetectDetail5>()
+                    .Where(x => x.ReleaseNo == item.ReleaseNo)
+                    .Count();
+                item.InspectionItemCount = count;
+                
+                item.NewFngDesc = item.FngDesc; 
+            }
+        }
+        
+        // 璁$畻鎵�鏈夋暟鎹殑鍘婚噸鎬绘暟锛堜笉鏄綋鍓嶉〉鐨勫幓閲嶆暟锛�
+        var allDataQuery = db.Queryable<LtsLlj, V_LljUser>((a, v) =>
+                new JoinQueryInfos(JoinType.Left, a.ItemNo == v.ItemNo))
+            .WhereIF(
+                StringUtil.IsNotNullOrEmpty(queryObj.result) &&
+                "鏈畬鎴�".Equals(queryObj.result),
+                (a, v) => a.FcheckResu == null)
+            .WhereIF(
+                StringUtil.IsNotNullOrEmpty(queryObj.result) &&
+                !"鏈畬鎴�".Equals(queryObj.result),
+                (a, v) => a.FcheckResu != null)
+            .WhereIF(id > 0, (a, v) => a.Id == id)
+            // 鏉冮檺鎺у埗锛歅L017銆丠MLYY銆丠MCS 鍙互鐪嬪埌鎵�鏈夊崟鎹紝鍏朵粬鐢ㄦ埛闇�瑕佹牴鎹墿鏂欑淮鎶ゆ儏鍐靛垽鏂�
+            .WhereIF(queryObj.createUser != "PL017" && queryObj.createUser != "HMLYY" && queryObj.createUser != "HMCS" && queryObj.UserIndex == "0", 
+                (a, v) => 
+                    // 濡傛灉鐗╂枡琚淮鎶わ紝鍙湁缁存姢浜哄憳鍙互鐪嬪埌
+                    (v.Fcode != null && v.Fcode == queryObj.createUser) ||
+                    // 濡傛灉鐗╂枡鏈缁存姢锛屾墍鏈変汉閮藉彲浠ョ湅鍒�
+                    (v.Fcode == null))
+            //鍔犵瓫閫夋潯浠�,鏍规嵁閫夋嫨鐨勬悳绱㈠瓧娈佃繘琛岀簿纭悳绱�
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 1, // 鐗╂枡缂栧彿鎼滅储
+                (a, v) => a.ItemNo != null && a.ItemNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 2, // 鐗╂枡鍚嶇О鎼滅储
+                (a, v) => a.ItemName != null && a.ItemName.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 3, // 渚涘簲鍟嗘悳绱�
+                (a, v) => a.SuppName != null && a.SuppName.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 4, // 鍒拌揣鍗曞彿鎼滅储
+                (a, v) => a.LotNo != null && a.LotNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 5, // 妫�楠屽崟鍙锋悳绱�
+                (a, v) => a.ReleaseNo != null && a.ReleaseNo.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .WhereIF(!string.IsNullOrEmpty(queryObj.SearchValue) && queryObj.selectedIndex == 6, // 鐗╂枡瑙勬牸鎼滅储
+                (a, v) => a.ItemModel != null && a.ItemModel.ToLower().Contains(queryObj.SearchValue.ToLower()))
+            .Select((a, v) => a.ReleaseNo)
+            .Distinct()
+            .Count();
+        
+        var emergencyValues = pageList.Select(item => item.EMERGENCY).ToList(); 
+        return (pageList, allDataQuery);
     }
 
     //鏍规嵁妫�楠屾爣鍑嗘潵璁$畻妫�楠屼釜鏁�
@@ -102,6 +193,182 @@
         return msg;
 
     }
+    //绱ф�ユ斁琛�
+    //public string[] EmergencyRelease(int id)
+    //{
+    //    var db = SqlSugarHelper.GetInstance();
+         
+        
+    //    int emergencyStatus = db.Queryable<MesQaItemsDetect01>() 
+    //                            .Where(t => t.Id == id)
+    //                            .Select(t => t.EMERGENCY) 
+    //                            .First();
+
+    //    if (emergencyStatus != 0)
+    //    {
+    //        return new string[] { "1", "闈炵揣鎬ョ姸鎬侊紝鏃犳硶鎵ц绱ф�ユ斁琛�" };
+    //    }
+
+        
+    //    var outputResult = new SugarParameter("PO_RESULT", null,
+    //        DbType.Int32, ParameterDirection.Output, 4000);
+
+    //    var outputMessage = new SugarParameter("PO_MSG", null,
+    //        DbType.String, ParameterDirection.Output, 4000);
+
+    //    var parameters = new List<SugarParameter>
+    //{
+    //    new("P_ID", id, DbType.Int32, ParameterDirection.Input),
+    //    outputResult,
+    //    outputMessage
+    //};
+
+    //    db.Ado.ExecuteCommand(
+    //        "BEGIN prc_MES_QA_ITEMS_update1(:P_ID, :PO_RESULT, :PO_MSG); END;",
+    //        parameters.ToArray());
+
+    //    var lotNo1 = db.Queryable<MesQaItemsDetect01>()
+    //               .Where(t => t.Id == id)
+    //               .Select(t => t.LotNo1)
+    //               .First();
+
+    //    var resultValue = outputResult.Value?.ToString();
+    //    var messageValue = outputMessage.Value?.ToString();
+    //    return new string[] { resultValue, messageValue, lotNo1?.ToString() ?? "" };
+    //}
+
+    //public string[] WithdrawEmergencyRelease(int id)
+    //{
+    //    var db = SqlSugarHelper.GetInstance();
+
+      
+    //    int emergencyStatus = db.Queryable<MesQaItemsDetect01>() 
+    //                            .Where(t => t.Id == id)
+    //                            .Select(t => t.EMERGENCY) 
+    //                            .First();
+
+    //    if (emergencyStatus != 0)
+    //    {
+    //        return new string[] { "1", "闈炵揣鎬ョ姸鎬侊紝鏃犻渶鎾ゅ洖" };
+    //    }
+
+    //    var outputResult = new SugarParameter("PO_RESULT", null,
+    //        DbType.Int32, ParameterDirection.Output, 4000);
+
+    //    var outputMessage = new SugarParameter("PO_MSG", null,
+    //        DbType.String, ParameterDirection.Output, 4000);
+
+    //    var parameters = new List<SugarParameter>
+    //{
+    //    new("P_ID", id, DbType.Int32, ParameterDirection.Input),
+    //    outputResult,
+    //    outputMessage
+    //};
+
+    //    db.Ado.ExecuteCommand(
+    //        "BEGIN prc_MES_QA_ITEMS_update2(:P_ID, :PO_RESULT, :PO_MSG); END;",
+    //        parameters.ToArray());
+
+    //    var lotNo1 = db.Queryable<MesQaItemsDetect01>()
+    //               .Where(t => t.Id == id)
+    //               .Select(t => t.LotNo1)
+    //               .First();
+        
+
+    //    var resultValue = outputResult.Value?.ToString();
+    //    var messageValue = outputMessage.Value?.ToString();
+    //    return new string[] { resultValue, messageValue, lotNo1?.ToString() ?? "" };
+    //}
+
+
+
+
+     
+    public string[] EmergencyRelease(int id)
+    {
+        var db = SqlSugarHelper.GetInstance();
+
+
+        int emergencyStatus = db.Queryable<MesQaItemsDetect01>()
+                                .Where(t => t.Id == id)
+                                .Select(t => t.EMERGENCY)
+                                .First();
+
+        if (emergencyStatus != 0)
+        {
+            return new string[] { "1", "闈炵揣鎬ョ姸鎬侊紝鏃犳硶鎵ц绱ф�ユ斁琛�" };
+        }
+
+
+        var outputResult = new SugarParameter("PO_RESULT", null,
+            DbType.Int32, ParameterDirection.Output, 4000);
+
+        var outputMessage = new SugarParameter("PO_MSG", null,
+            DbType.String, ParameterDirection.Output, 4000);
+
+        var parameters = new List<SugarParameter>
+    {
+        new("P_ID", id, DbType.Int32, ParameterDirection.Input),
+        outputResult,
+        outputMessage
+    };
+
+        db.Ado.ExecuteCommand(
+            "BEGIN prc_MES_QA_ITEMS_update1(:P_ID, :PO_RESULT, :PO_MSG); END;",
+            parameters.ToArray());
+
+        var lotNo1 = db.Queryable<MesQaItemsDetect01>()
+                   .Where(t => t.Id == id)
+                   .Select(t => t.LotNo1)
+                   .First();
+
+        var resultValue = outputResult.Value?.ToString();
+        var messageValue = outputMessage.Value?.ToString();
+        return new string[] { resultValue, messageValue, lotNo1?.ToString() ?? "" };
+    }
+
+    public string[] WithdrawEmergencyRelease(int id)
+    {
+        var db = SqlSugarHelper.GetInstance();
+
+
+        int emergencyStatus = db.Queryable<MesQaItemsDetect01>()
+                                .Where(t => t.Id == id)
+                                .Select(t => t.EMERGENCY)
+                                .First();
+
+        if (emergencyStatus != 0)
+        {
+            return new string[] { "1", "闈炵揣鎬ョ姸鎬侊紝鏃犻渶鎾ゅ洖" };
+        }
+
+        var outputResult = new SugarParameter("PO_RESULT", null,
+            DbType.Int32, ParameterDirection.Output, 4000);
+
+        var outputMessage = new SugarParameter("PO_MSG", null,
+            DbType.String, ParameterDirection.Output, 4000);
+
+        var parameters = new List<SugarParameter>
+    {
+        new("P_ID", id, DbType.Int32, ParameterDirection.Input),
+        outputResult,
+        outputMessage
+    };
+
+        db.Ado.ExecuteCommand(
+            "BEGIN prc_MES_QA_ITEMS_update2(:P_ID, :PO_RESULT, :PO_MSG); END;",
+            parameters.ToArray());
+
+        var lotNo1 = db.Queryable<MesQaItemsDetect01>()
+                   .Where(t => t.Id == id)
+                   .Select(t => t.LotNo1)
+                   .First();
+
+
+        var resultValue = outputResult.Value?.ToString();
+        var messageValue = outputMessage.Value?.ToString();
+        return new string[] { resultValue, messageValue, lotNo1?.ToString() ?? "" };
+    } 
 
     private string ExtractSubstring(string input, char startChar, char endChar)
     {
@@ -118,6 +385,201 @@
         return input.Substring(startIndex + 1, length);
     }
 
+    public List<QamftpDto> GetAttachments(string ItemNo)
+    {
+        //if (string.IsNullOrEmpty(ItemNo))
+        //{
+           // throw new ArgumentException("妫�楠屽崟鍙蜂笉鑳戒负绌�");
+        //}
+        
+        var db = SqlSugarHelper.GetInstance();
+        try
+        {
+            return db.Queryable<MesQamftp>()
+                .Where(x => x.ItemNo == ItemNo)
+                .OrderBy(x => x.Fdate, OrderByType.Desc)
+                // .ThenBy(x => x.CreateDate, OrderByType.Desc)
+                .Select(x => new QamftpDto
+                {
+                    Id = x.Id,
+                    itemNo = x.ItemNo,
+                    Ftype = x.Ftype,
+                    Fattach = x.Fattach,
+                    Fversion = x.Fversion,
+                    Fdate = x.Fdate,
+                    CreateBy = x.CreateBy,
+                    CreateDate = x.CreateDate,
+                    Company = x.Company,
+                    Factory = x.Factory,
+                    
+                    F_type = x.F_type,
+                    LastupdateBy = x.LastupdateBy,
+                    LastupdateDate = x.LastupdateDate,
+                    ItemId = x.ItemId
+                }).ToList();
+        }
+        catch (Exception ex)
+        {
+            throw new Exception($"鏌ヨ闄勪欢淇℃伅澶辫触: {ex.Message}");
+        }
+    }
+
+    public byte[] GetFtpFile(string itemNo, string fileName, string ftpServer)
+    {
+        // 鍙傛暟楠岃瘉
+        if (string.IsNullOrEmpty(itemNo) || string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(ftpServer))
+        {
+            throw new ArgumentException("鍙傛暟涓嶈兘涓虹┖: itemNo, fileName, ftpServer");
+        }
+        
+        string ftpUser = "hm_ftp";
+        string ftpPwd = "dell_123";
+        
+        // 鏍囧噯鍖朏TP鏈嶅姟鍣ㄥ湴鍧�
+        string normalizedServer = NormalizeFtpServer(ftpServer);
+        
+        // 鏋勫缓FTP鏂囦欢璺緞
+        string ftpPath = $"{normalizedServer}/IQC/{itemNo}/{fileName}";
+        
+        try
+        {
+            var request = (System.Net.FtpWebRequest)System.Net.WebRequest.Create(ftpPath);
+            request.Method = System.Net.WebRequestMethods.Ftp.DownloadFile;
+            request.Credentials = new System.Net.NetworkCredential(ftpUser, ftpPwd);
+            request.UseBinary = true;
+            request.UsePassive = false;
+            request.Timeout = 30000; // 30绉掕秴鏃�
+            request.ReadWriteTimeout = 30000;
+            
+            using (var response = (System.Net.FtpWebResponse)request.GetResponse())
+            using (var ftpStream = response.GetResponseStream())
+            using (var ms = new System.IO.MemoryStream())
+            {
+                if (ftpStream == null)
+                {
+                    throw new Exception("FTP鍝嶅簲娴佷负绌�");
+                }
+                
+                ftpStream.CopyTo(ms);
+                var fileBytes = ms.ToArray();
+                
+                if (fileBytes.Length == 0)
+                {
+                    return null; // 鏂囦欢涓虹┖鎴栦笉瀛樺湪
+                }
+                
+                return fileBytes;
+            }
+        }
+        catch (System.Net.WebException ex)
+        {
+            if (ex.Response is System.Net.FtpWebResponse ftpResponse)
+            {
+                switch (ftpResponse.StatusCode)
+                {
+                    case System.Net.FtpStatusCode.ActionNotTakenFileUnavailable:
+                        return null; // 鏂囦欢涓嶅瓨鍦�
+                    case System.Net.FtpStatusCode.NotLoggedIn:
+                        throw new Exception("FTP璁よ瘉澶辫触锛岃妫�鏌ョ敤鎴峰悕鍜屽瘑鐮�");
+                    case System.Net.FtpStatusCode.ActionNotTakenFilenameNotAllowed:
+                        throw new Exception("鏂囦欢鍚嶄笉琚厑璁告垨璺緞鏃犳晥");
+                    default:
+                        throw new Exception($"FTP閿欒 ({ftpResponse.StatusCode}): {ftpResponse.StatusDescription}");
+                }
+            }
+            
+            // 澶勭悊瓒呮椂鍜岀綉缁滈敊璇�
+            if (ex.Status == System.Net.WebExceptionStatus.Timeout)
+            {
+                throw new Exception("FTP杩炴帴瓒呮椂锛岃绋嶅悗閲嶈瘯");
+            }
+            
+            throw new Exception($"FTP杩炴帴澶辫触: {ex.Message}");
+        }
+        catch (Exception ex)
+        {
+            throw new Exception($"鑾峰彇鏂囦欢澶辫触: {ex.Message}");
+        }
+    }
+    
+    private string NormalizeFtpServer(string ftpServer)
+    {
+        if (string.IsNullOrEmpty(ftpServer))
+        {
+            throw new ArgumentException("FTP鏈嶅姟鍣ㄥ湴鍧�涓嶈兘涓虹┖");
+        }
+        
+        // 纭繚浠tp://寮�澶�
+        string normalizedServer = ftpServer.StartsWith("ftp://") ? ftpServer : $"ftp://{ftpServer}";
+        
+        // 鐗规畩澶勭悊宸茬煡鏈嶅姟鍣ㄥ湴鍧�
+        if (normalizedServer == "ftp://36.26.21.214")
+        {
+            normalizedServer = "ftp://36.26.21.214:21";
+        }
+        else if (!normalizedServer.Contains(":") && normalizedServer.StartsWith("ftp://"))
+        {
+            normalizedServer += ":21"; // 榛樿FTP绔彛
+        }
+        
+        // 寮�鍙戠幆澧冧娇鐢ㄦ湰鍦版湇鍔″櫒
+        normalizedServer = "ftp://192.168.1.22:21";
+        
+        return normalizedServer;
+    }
+
+    public string GetContentType(string fileName)
+    {
+        if (string.IsNullOrEmpty(fileName))
+            return "application/octet-stream";
+            
+        var extension = System.IO.Path.GetExtension(fileName).ToLower();
+        
+        return extension switch
+        {
+            // PDF鏂囦欢
+            ".pdf" => "application/pdf",
+            
+            // 鍥剧墖鏂囦欢
+            ".jpg" or ".jpeg" => "image/jpeg",
+            ".png" => "image/png",
+            ".gif" => "image/gif",
+            ".bmp" => "image/bmp",
+            ".webp" => "image/webp",
+            ".svg" => "image/svg+xml",
+            ".ico" => "image/x-icon",
+            
+            // 鏂囨湰鏂囦欢
+            ".txt" => "text/plain; charset=utf-8",
+            ".log" => "text/plain; charset=utf-8",
+            ".md" => "text/markdown; charset=utf-8",
+            ".csv" => "text/csv; charset=utf-8",
+            ".xml" => "text/xml; charset=utf-8",
+            ".json" => "application/json; charset=utf-8",
+            
+            // Office鏂囨。
+            ".doc" => "application/msword",
+            ".docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
+            ".xls" => "application/vnd.ms-excel",
+            ".xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
+            ".ppt" => "application/vnd.ms-powerpoint",
+            ".pptx" => "application/vnd.openxmlformats-officedocument.presentationml.presentation",
+            
+            // 鍘嬬缉鏂囦欢
+            ".zip" => "application/zip",
+            ".rar" => "application/x-rar-compressed",
+            ".7z" => "application/x-7z-compressed",
+            
+            // 鍏朵粬甯歌鏍煎紡
+            ".dwg" => "application/acad",
+            ".dxf" => "application/dxf",
+            ".step" or ".stp" => "application/step",
+            ".iges" or ".igs" => "application/iges",
+            
+            // 榛樿浜岃繘鍒舵祦
+            _ => "application/octet-stream"
+        };
+    }
     public int saveItem(LLJDto rkjDto)
     {
         var items = rkjDto.items;
@@ -194,7 +656,9 @@
                 a.FreQty,
                 a.CheckQyt,
                 a.FcheckResu,
-                a.FcheckItemDesc
+                a.FcheckItemDesc,
+                a.Funit,
+                a.Meom
             }).Select((a, b) => new MesQaItemsDetectDetail5
             {
                 Id = a.Id,
@@ -215,7 +679,9 @@
                 FenterQty = SqlFunc.AggregateCount(b.Id),
                 FcheckResu = a.FcheckResu,
                 // FcheckItemDesc = a.FcheckItemDesc
-                FcheckItemDesc = a.FspecRequ
+                FcheckItemDesc = a.FspecRequ,
+                Funit = a.Funit,
+                Meom = a.Meom,
             }).ToList();
     }
 
@@ -469,27 +935,52 @@
         return withOracle;
     }
 
-    //涓昏〃淇敼澶囨敞瀛楁
+    //涓昏〃淇敼瀛楁
     public int saveRemarksGid(LLJDto dto)
     {
         return SqlSugarHelper.UseTransactionWithOracle(db =>
         {
             return db.Updateable<MesQaItemsDetect01>()
-                .SetColumns(it =>
-                    it.FngDesc == dto.Remarks) //SetColumns鏄彲浠ュ彔鍔犵殑 鍐�2涓氨2涓瓧娈佃祴鍊�
+                .SetColumns(it => it.FngDesc == dto.Remarks)
                 .Where(it => it.ReleaseNo == dto.releaseNo)
                 .ExecuteCommand();
         });
     }
-
+    //涓昏〃淇敼鐮村潖瀹為獙
+    public int savePhsyGid(LLJDto dto)
+    {
+        return SqlSugarHelper.UseTransactionWithOracle(db =>
+        {
+            return db.Updateable<MesQaItemsDetect01>()
+                .SetColumns(it => it.PHSY == dto.PHSY)
+                .Where(it => it.ReleaseNo == dto.releaseNo)
+                .ExecuteCommand();
+        });
+    }
+    // 涓昏〃淇敼涓嬫媺妗嗗瓧娈�
+    public int saveDropdownFields(LLJDto dto)
+    {
+        return SqlSugarHelper.UseTransactionWithOracle(db =>
+        {
+            return db.Updateable<MesQaItemsDetect01>()
+                .SetColumns(it => it.BLYY == dto.BLYY)
+                .SetColumns(it => it.PSZT == dto.PSZT)
+                .SetColumns(it => it.SSCJ == dto.SSCJ)
+                .Where(it => it.ReleaseNo == dto.releaseNo)
+                .ExecuteCommand();
+        });
+    }
     //瀛愯〃淇敼澶囨敞瀛楁
     public int saveRemarksPid(LLJDto dto)
     {
         return SqlSugarHelper.UseTransactionWithOracle(db =>
         {
             return db.Updateable<MesQaItemsDetectDetail5>()
-                 .SetColumns(it =>
-                     it.Funit == dto.Remarks) //SetColumns鏄彲浠ュ彔鍔犵殑 鍐�2涓氨2涓瓧娈佃祴鍊�
+                .SetColumns(it => new MesQaItemsDetectDetail5
+                {
+                    Funit = dto.Remarks,
+                    Meom = dto.Meom
+                })
                 .Where(it => it.Id == dto.pid)
                 .ExecuteCommand();
         });

--
Gitblit v1.9.3