From e122d5b720a9415ba655c93eecd96aaa4d0b8287 Mon Sep 17 00:00:00 2001
From: hao <1836460075@qq.com>
Date: 星期三, 15 十月 2025 16:22:53 +0800
Subject: [PATCH] 模具号删除修改

---
 StandardInterface/MESApplication/Controllers/QC/SJController.cs |  187 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 183 insertions(+), 4 deletions(-)

diff --git a/StandardInterface/MESApplication/Controllers/QC/SJController.cs b/StandardInterface/MESApplication/Controllers/QC/SJController.cs
index 107d6b9..83e6a80 100644
--- a/StandardInterface/MESApplication/Controllers/QC/SJController.cs
+++ b/StandardInterface/MESApplication/Controllers/QC/SJController.cs
@@ -41,14 +41,14 @@
         try
         {
             dynamic resultInfos = new ExpandoObject();
-            var tbBillList =
-                new SJService().getPage(queryObj);
-            resultInfos.tbBillList = tbBillList;
+            var (items, totalCount) = new SJService().getPage(queryObj);
+            resultInfos.tbBillList = items;
             return new ResponseResult
             {
                 status = 0,
                 message = "OK",
-                data = resultInfos
+                data = resultInfos,
+                TotalCount = totalCount
             };
         }
         catch (Exception ex)
@@ -319,4 +319,183 @@
             return ResponseResult.ResponseError(ex);
         }
     }
+
+    //鍒锋柊妫�楠岄」鐩�
+    [HttpPost("GenUpdate")]
+    public ResponseResult GenUpdate([FromBody] JObject data)
+    {
+        try
+        {
+            decimal? id = data["id"]?.ToObject<decimal>();
+            string? no = data["no"]?.ToString();
+            string? user = data["user"]?.ToString();
+            decimal? mnum = data["mnum"]?.ToObject<decimal?>();
+            string? dnum = data["dnum"]?.ToString();
+
+            var (result, message) = new SJService().GenUpdate(id, no, user, mnum, dnum);
+
+            dynamic resultInfos = new ExpandoObject();
+            resultInfos.result = result;
+            resultInfos.message = message;
+
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+    //鎻愪氦妫�楠�
+    [HttpPost("SjSubmit")]
+    public ResponseResult SjSubmit([FromBody] SJDto sjDto)
+    {
+        try
+        {
+            dynamic resultInfos = new ExpandoObject();
+            var tbBillList = new SJService().SjSubmit(sjDto);
+            resultInfos.tbBillList = tbBillList;
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    /// 鑾峰彇闄勪欢淇℃伅
+    /// </summary>
+    /// <param name="data">鍖呭惈itemNo鍜宲rojName鐨凧SON瀵硅薄</param>
+    /// <returns>闄勪欢鍒楄〃</returns>
+    [HttpPost("getAttachments")]
+    public ResponseResult GetAttachments([FromBody] JObject data)
+    {
+        var itemNo = data["itemNo"]?.ToString();
+        var projName = data["projName"]?.ToString();
+        var fromPage = data["fromPage"]?.ToString();
+        
+        // 鏍规嵁鏉ユ簮椤甸潰鍐冲畾鏄惁杩囨护
+        string filterProjName = null;
+        if (fromPage == "Detail" && !string.IsNullOrEmpty(projName))
+        {
+            filterProjName = projName;  // Detail椤甸潰闇�瑕佽繃婊�
+        }
+        // Add椤甸潰涓嶄紶閫抐ilterProjName锛屾樉绀烘墍鏈夐檮浠�
+        
+        try
+        {
+            dynamic resultInfos = new System.Dynamic.ExpandoObject();
+            var tbBillList = new SJService().GetAttachments(itemNo, filterProjName);
+            if (tbBillList == null || tbBillList.Count == 0)
+            {
+                return new ResponseResult
+                {
+                    status = 1,
+                    message = "璇ユ楠屽崟鏈笂浼犻檮浠朵俊鎭紒",
+                    data = null
+                };
+            }
+            resultInfos.tbBillList = tbBillList;
+            return new ResponseResult
+            {
+                status = 0,
+                message = "OK",
+                data = resultInfos
+            };
+        }
+        catch (Exception ex)
+        {
+            return ResponseResult.ResponseError(ex);
+        }
+    }
+
+    /// <summary>
+    /// 棰勮FTP鏂囦欢
+    /// </summary>
+    /// <param name="itemNo">鐗╂枡缂栫爜</param>
+    /// <param name="fileName">鏂囦欢鍚�</param>
+    /// <param name="ftpServer">FTP鏈嶅姟鍣ㄥ湴鍧�</param>
+    /// <param name="projName">椤圭洰鍚嶇О</param>
+    /// <returns>鏂囦欢鍐呭</returns>
+    [HttpGet("PreviewFtpFile")]
+    public IActionResult PreviewFtpFile([FromQuery] string itemNo, [FromQuery] string fileName, [FromQuery] string ftpServer, [FromQuery] string projName = null)
+    {
+        try
+        {
+            var fileBytes = new SJService().GetFtpFile(itemNo, fileName, ftpServer, projName);
+            if (fileBytes == null)
+            {
+                return NotFound(new ResponseResult
+                {
+                    status = 1,
+                    message = "鏂囦欢涓嶅瓨鍦ㄦ垨鏃犳硶璁块棶",
+                    data = null
+                });
+            }
+
+            var contentType = new SJService().GetContentType(fileName);
+            return File(fileBytes, contentType, fileName);
+        }
+        catch (Exception ex)
+        {
+            return StatusCode(500, new ResponseResult
+            {
+                status = 1,
+                message = ex.Message,
+                data = null
+            });
+        }
+    }
+
+    /// <summary>
+    /// 涓嬭浇FTP鏂囦欢
+    /// </summary>
+    /// <param name="itemNo">鐗╂枡缂栫爜</param>
+    /// <param name="fileName">鏂囦欢鍚�</param>
+    /// <param name="ftpServer">FTP鏈嶅姟鍣ㄥ湴鍧�</param>
+    /// <param name="projName">椤圭洰鍚嶇О</param>
+    /// <returns>鏂囦欢涓嬭浇</returns>
+    [HttpGet("DownloadFtpFile")]
+    public IActionResult DownloadFtpFile([FromQuery] string itemNo, [FromQuery] string fileName, [FromQuery] string ftpServer, [FromQuery] string projName = null)
+    {
+        try
+        {
+            var fileBytes = new SJService().GetFtpFile(itemNo, fileName, ftpServer, projName);
+            if (fileBytes == null)
+            {
+                return NotFound(new ResponseResult
+                {
+                    status = 1,
+                    message = "鏂囦欢涓嶅瓨鍦ㄦ垨鏃犳硶璁块棶",
+                    data = null
+                });
+            }
+
+            var contentType = new SJService().GetContentType(fileName);
+            
+            // 璁剧疆涓嬭浇鍝嶅簲澶�
+            Response.Headers.Add("Content-Disposition", $"attachment; filename=\"{fileName}\"");
+            
+            return File(fileBytes, contentType, fileName);
+        }
+        catch (Exception ex)
+        {
+            return StatusCode(500, new ResponseResult
+            {
+                status = 1,
+                message = ex.Message,
+                data = null
+            });
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3