From c8a9ab01f01ffdf522a5f174d684aff7722a9679 Mon Sep 17 00:00:00 2001
From: xwt <2740516069@qq.com>
Date: 星期四, 17 七月 2025 14:32:10 +0800
Subject: [PATCH] 来料检获取附件信息

---
 StandardInterface/MESApplication/Controllers/AttachmentController.cs |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/StandardInterface/MESApplication/Controllers/AttachmentController.cs b/StandardInterface/MESApplication/Controllers/AttachmentController.cs
new file mode 100644
index 0000000..46703f0
--- /dev/null
+++ b/StandardInterface/MESApplication/Controllers/AttachmentController.cs
@@ -0,0 +1,32 @@
+using Microsoft.AspNetCore.Mvc;
+using System.IO;
+
+namespace MESApplication.Controllers
+{
+    [ApiController]
+    [Route("Attachment")]
+    public class AttachmentController : ControllerBase
+    {
+        // 鏍圭洰褰�
+        private readonly string ftpRootPath = @"D:\MES_FTP\IQC";
+
+        [HttpGet("Download")]
+        public IActionResult Download([FromQuery] string itemNo, [FromQuery] string fileName)
+        {
+            if (string.IsNullOrWhiteSpace(itemNo) || string.IsNullOrWhiteSpace(fileName))
+                return BadRequest("鐗╂枡缂栫爜鍜屾枃浠跺悕涓嶈兘涓虹┖");
+
+            // 闃叉璺緞绌胯秺鏀诲嚮
+            var safeItemNo = Path.GetFileName(itemNo.Trim());
+            var safeFileName = Path.GetFileName(fileName.Trim());
+
+            var filePath = Path.Combine(ftpRootPath, safeItemNo, safeFileName);
+
+            if (!System.IO.File.Exists(filePath))
+                return NotFound("鏂囦欢涓嶅瓨鍦�");
+
+            var contentType = "application/octet-stream";
+            return PhysicalFile(filePath, contentType, safeFileName);
+        }
+    }
+} 
\ No newline at end of file

--
Gitblit v1.9.3