From 82dac540156cb29e58c86f7d7d840e3c7e548c15 Mon Sep 17 00:00:00 2001 From: xwt <2740516069@qq.com> Date: 星期四, 14 八月 2025 19:55:41 +0800 Subject: [PATCH] 来料检,入库检,首检巡检。 --- StandardInterface/MESApplication/Controllers/QC/LljController.cs | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 160 insertions(+), 0 deletions(-) diff --git a/StandardInterface/MESApplication/Controllers/QC/LljController.cs b/StandardInterface/MESApplication/Controllers/QC/LljController.cs index 8112f51..a206bee 100644 --- a/StandardInterface/MESApplication/Controllers/QC/LljController.cs +++ b/StandardInterface/MESApplication/Controllers/QC/LljController.cs @@ -204,6 +204,51 @@ } } + //savePhsyGid 涓昏〃娣诲姞鐮村潖瀹為獙 + [HttpPost("savePhsyGid")] + public ResponseResult savePhsyGid([FromBody] LLJDto rkjDto) + { + try + { + dynamic resultInfos = new ExpandoObject(); + var tbBillList = + new LljService().savePhsyGid(rkjDto); + resultInfos.tbBillList = tbBillList; + return new ResponseResult + { + status = 0, + message = "OK", + data = resultInfos + }; + } + + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } + [HttpPost("saveDropdownFields")] + public ResponseResult saveDropdownFields([FromBody] LLJDto rkjDto) + { + try + { + dynamic resultInfos = new ExpandoObject(); + var tbBillList = + new LljService().saveDropdownFields(rkjDto); + resultInfos.tbBillList = tbBillList; + return new ResponseResult + { + status = 0, + message = "OK", + data = resultInfos + }; + } + + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } //saveRemarksPid 瀛愯〃娣诲姞涓嶅悎鏍兼弿杩� [HttpPost("saveRemarksPid")] public ResponseResult saveRemarksPid([FromBody] LLJDto rkjDto) @@ -316,4 +361,119 @@ return ResponseResult.ResponseError(ex); } } + + [HttpPost("getAttachments")] + public ResponseResult GetAttachments([FromBody] JObject data) + { + var itemNo = data["itemNo"]?.ToString(); + try + { + dynamic resultInfos = new System.Dynamic.ExpandoObject(); + var tbBillList = new LljService().GetAttachments(itemNo); + 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); + } + } + + [HttpGet("PreviewFtpFile")] + public IActionResult PreviewFtpFile([FromQuery] string itemNo, [FromQuery] string fileName, [FromQuery] string ftpServer) + { + try + { + // 娣诲姞CORS鍝嶅簲澶� + Response.Headers.Add("Access-Control-Allow-Origin", "*"); + Response.Headers.Add("Access-Control-Allow-Methods", "GET, OPTIONS"); + Response.Headers.Add("Access-Control-Allow-Headers", "Content-Type"); + Response.Headers.Add("Access-Control-Expose-Headers", "Content-Type, Content-Length"); + + var service = new LljService(); + var fileBytes = service.GetFtpFile(itemNo, fileName, ftpServer); + + if (fileBytes == null || fileBytes.Length == 0) + { + return NotFound("鏂囦欢鍦‵TP鏈嶅姟鍣ㄤ笂涓嶅瓨鍦�"); + } + + var contentType = service.GetContentType(fileName); + fileName = fileName?.Trim().Replace("\r", "").Replace("\n", ""); + + return File(fileBytes, contentType); + } + catch (Exception ex) + { + return StatusCode(500, $"棰勮鏂囦欢澶辫触锛歿ex.Message}"); + } + } + + [HttpGet("DownloadFtpFile")] + public IActionResult DownloadFtpFile([FromQuery] string itemNo, [FromQuery] string fileName, [FromQuery] string ftpServer) + { + try + { + // 娣诲姞CORS鍝嶅簲澶� - 鍏抽敭閰嶇疆鐢ㄤ簬瑙e喅璺ㄥ煙闂 + Response.Headers.Add("Access-Control-Allow-Origin", "*"); + Response.Headers.Add("Access-Control-Allow-Methods", "GET, OPTIONS"); + Response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Authorization"); + Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition, Content-Length, Content-Type"); + + var service = new LljService(); + var fileBytes = service.GetFtpFile(itemNo, fileName, ftpServer); + + if (fileBytes == null || fileBytes.Length == 0) + { + return NotFound("鏂囦欢鍦‵TP鏈嶅姟鍣ㄤ笂涓嶅瓨鍦�"); + } + + var contentType = service.GetContentType(fileName); + fileName = fileName?.Trim().Replace("\r", "").Replace("\n", ""); + + // 璁剧疆姝g‘鐨凜ontent-Disposition鍝嶅簲澶翠互鏀寔鏂囦欢涓嬭浇 + var result = File(fileBytes, "application/octet-stream", fileName); + + // 纭繚Content-Disposition澶存纭缃紝鏀寔涓枃鏂囦欢鍚� + if (!string.IsNullOrEmpty(fileName)) + { + var encodedFileName = System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8); + Response.Headers.Add("Content-Disposition", $"attachment; filename*=UTF-8''{encodedFileName}"); + } + + return result; + } + catch (Exception ex) + { + return StatusCode(500, $"涓嬭浇鏂囦欢澶辫触锛歿ex.Message}"); + } + } + + [HttpOptions("PreviewFtpFile")] + [HttpOptions("DownloadFtpFile")] + public IActionResult HandleOptions() + { + // 澶勭悊CORS棰勬璇锋眰 + Response.Headers.Add("Access-Control-Allow-Origin", "*"); + Response.Headers.Add("Access-Control-Allow-Methods", "GET, OPTIONS"); + Response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Authorization"); + Response.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition, Content-Length, Content-Type"); + Response.Headers.Add("Access-Control-Max-Age", "86400"); + + return Ok(); + } } \ No newline at end of file -- Gitblit v1.9.3