From bf780b6c83012b5beb3d7515b8fb61753c5fb736 Mon Sep 17 00:00:00 2001
From: sjz <1240968267@qq.com>
Date: 星期四, 26 六月 2025 08:48:37 +0800
Subject: [PATCH] 采购承诺交期改string类型

---
 MESApplication/Controllers/PLM/PLMController.cs |   91 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 90 insertions(+), 1 deletions(-)

diff --git a/MESApplication/Controllers/PLM/PLMController.cs b/MESApplication/Controllers/PLM/PLMController.cs
index 102d88b..a20d80b 100644
--- a/MESApplication/Controllers/PLM/PLMController.cs
+++ b/MESApplication/Controllers/PLM/PLMController.cs
@@ -1,7 +1,9 @@
-锘縰sing MES.Service.service.PLM;
+锘縰sing ConsoleApp1;
+using MES.Service.service.PLM;
 using MES.Service.util;
 using Microsoft.AspNetCore.Mvc;
 using System.Dynamic;
+using System.IO;
 
 namespace MESApplication.Controllers.PLM;
 
@@ -11,6 +13,7 @@
 public class PLMController : ControllerBase
 {
     private readonly PLMManager m = new();
+    private readonly WarehouseDownloadDoc wdd = new();
 
     //RetrieveDrawings  璋冨彇鍥剧焊
     [HttpPost("RetrieveDrawings")]
@@ -33,4 +36,90 @@
             return ResponseResult.ResponseError(ex);
         }
     }
+
+    //RetrieveImageFile  璋冨彇涓婁紶鍒版湇鍔″櫒鐨勬媿鎽勬枃浠�
+    [HttpGet("GetImageNames")]
+    public IActionResult GetImageNames(string releaseNo)
+    {
+        // 鎷兼帴鏈湴鏂囦欢绯荤粺璺緞
+        string basePath = @"D:\MES_FTP\IQC\"; // 鏈嶅姟鍣―鐩樹笅鐨勫熀纭�璺緞
+        string folderPath = Path.Combine(basePath, releaseNo); // 鍔ㄦ�佹嫾鎺ュ崟鍙峰搴旂殑鏂囦欢澶硅矾寰�
+
+        // 妫�鏌ユ枃浠跺す鏄惁瀛樺湪
+        if (!Directory.Exists(folderPath))
+        {
+            return NotFound($"鏂囦欢澶� {folderPath} 涓嶅瓨鍦ㄣ�傝妫�鏌ヨ矾寰勬槸鍚︽纭��");
+        }
+
+        // 鑾峰彇鏂囦欢澶逛腑鐨勬墍鏈夊浘鐗囨枃浠跺悕绉�
+        string[] imageExtensions = { ".jpg", ".jpeg", ".png", ".gif", ".bmp" };
+        // 鑾峰彇鏂囦欢鐨勫畬鏁磋矾寰勶紝骞惰繑鍥炰竴涓寘鍚枃浠跺悕鍜屽畬鏁磋矾寰勭殑瀵硅薄
+        var imageFiles = Directory.GetFiles(folderPath)
+            .Where(file => imageExtensions.Any(ext => file.ToLower().EndsWith(ext)))
+            .Select(file => new
+            {
+                FileName = Path.GetFileName(file), // 鏂囦欢鍚�
+                FilePath = file,
+                FileBasePath = ConvertFileToBase64(file) // 鏂囦欢鐨� Base64 鏁版嵁 // 鏂囦欢鐨勫畬鏁磋矾寰�
+            });
+
+        return Ok(new { success = true, data = imageFiles });
+    }
+    private string ConvertFileToBase64(string filePath)
+    {
+        byte[] fileBytes = System.IO.File.ReadAllBytes(filePath);
+        return Convert.ToBase64String(fileBytes);
+    }
+
+    [HttpPost("DeleteImageFile")]
+    public IActionResult DeleteImageFile([FromQuery] string filePath)
+    {
+        // 妫�鏌ユ枃浠惰矾寰勬槸鍚︿负绌�
+        if (string.IsNullOrWhiteSpace(filePath))
+        {
+            return BadRequest("鏂囦欢璺緞涓嶈兘涓虹┖");
+        }
+
+        // 纭繚璺緞鏄粷瀵硅矾寰勶紙鍙互鏍规嵁闇�瑕佽皟鏁达級
+        filePath = Path.GetFullPath(filePath);
+
+        // 妫�鏌ユ枃浠舵槸鍚﹀瓨鍦�
+        if (!System.IO.File.Exists(filePath))
+        {
+            return NotFound("鏂囦欢涓嶅瓨鍦�");
+        }
+
+        try
+        {
+            // 鍒犻櫎鏂囦欢
+            System.IO.File.Delete(filePath);
+            return Ok("鏂囦欢鍒犻櫎鎴愬姛");
+        }
+        catch (System.Exception ex)
+        {
+            // 鎹曡幏寮傚父骞惰繑鍥為敊璇俊鎭�
+            return StatusCode(500, $"鍒犻櫎鏂囦欢鏃跺彂鐢熼敊璇�: {ex.Message}");
+        }
+    }
+
+    //RetrieveDrawings  璋冨彇鍥剧焊
+    [HttpPost("OpenDrawings")]
+    public IActionResult OpenDrawings(string fileId,string fName)
+    {
+        try
+        {
+            var resultInfos = wdd.SendRequest("Download", fileId);
+
+            return File(resultInfos, "application/octet-stream", fName);
+        }
+        catch (Exception ex)
+        {
+            return StatusCode(500, new ResponseResult
+            {
+                status = 1,
+                message = ex.Message,
+                data = null
+            });
+        }
+    }
 }

--
Gitblit v1.9.3