From ff982948331200f951a486a7b38c11c009da19b2 Mon Sep 17 00:00:00 2001 From: xwt <2740516069@qq.com> Date: 星期四, 17 七月 2025 14:29:49 +0800 Subject: [PATCH] 来料检获取附件信息 --- StandardInterface/MESApplication/Controllers/QC/LljController.cs | 64 ++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 0 deletions(-) diff --git a/StandardInterface/MESApplication/Controllers/QC/LljController.cs b/StandardInterface/MESApplication/Controllers/QC/LljController.cs index 8112f51..576e5c6 100644 --- a/StandardInterface/MESApplication/Controllers/QC/LljController.cs +++ b/StandardInterface/MESApplication/Controllers/QC/LljController.cs @@ -316,4 +316,68 @@ return ResponseResult.ResponseError(ex); } } + + [HttpPost("getAttachments")] + public ResponseResult GetAttachments([FromBody] JObject data) + { + var releaseNo = data["releaseNo"]?.ToString(); + try + { + dynamic resultInfos = new System.Dynamic.ExpandoObject(); + var tbBillList = new LljService().GetAttachments(releaseNo); + 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("DownloadFtpFile")] + public IActionResult DownloadFtpFile([FromQuery] string itemNo, [FromQuery] string fileName) + { + // FTP鏈嶅姟鍣ㄤ俊鎭紙璇锋浛鎹负瀹為檯淇℃伅锛� + string ftpServer = "ftp://36.26.21.214"; + string ftpUser = "hm_ftp"; + string ftpPwd = "dell_123"; // 宸叉洿鏂颁负鐪熷疄瀵嗙爜 + string ftpPath = $"{ftpServer}/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 = true; + using (var response = (System.Net.FtpWebResponse)request.GetResponse()) + using (var ftpStream = response.GetResponseStream()) + using (var ms = new System.IO.MemoryStream()) + { + ftpStream.CopyTo(ms); + ms.Position = 0; + string contentType = "application/octet-stream"; + // 闃插尽鎬у鐞嗭紝鍘婚櫎fileName涓殑鍥炶溅鎹㈣鍜岀┖鏍� + fileName = fileName?.Trim().Replace("\r", "").Replace("\n", ""); + return File(ms.ToArray(), contentType, fileName); + } + } + catch (Exception ex) + { + return BadRequest($"FTP涓嬭浇澶辫触锛歿ex.Message}锛宖tpPath={ftpPath}锛宖ileName={fileName}"); + } + } } \ No newline at end of file -- Gitblit v1.9.3