From 1f41e51bfa04d8c324dace8ae16d166fdfa90866 Mon Sep 17 00:00:00 2001
From: hao <1836460075@qq.com>
Date: 星期二, 25 十一月 2025 11:08:27 +0800
Subject: [PATCH] 分布式调拨新表
---
StandardInterface/MESApplication/Controllers/QC/SJController.cs | 250 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 249 insertions(+), 1 deletions(-)
diff --git a/StandardInterface/MESApplication/Controllers/QC/SJController.cs b/StandardInterface/MESApplication/Controllers/QC/SJController.cs
index 87a2a52..7591679 100644
--- a/StandardInterface/MESApplication/Controllers/QC/SJController.cs
+++ b/StandardInterface/MESApplication/Controllers/QC/SJController.cs
@@ -329,8 +329,10 @@
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);
+ var (result, message) = new SJService().GenUpdate(id, no, user, mnum, dnum);
dynamic resultInfos = new ExpandoObject();
resultInfos.result = result;
@@ -369,4 +371,250 @@
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
+ });
+ }
+ }
+
+ /// <summary>
+ /// 涓婁紶鍥剧墖鍒版楠岄」鐩殑PICTURE瀛楁
+ /// </summary>
+ /// <param name="file">涓婁紶鐨勫浘鐗囨枃浠�</param>
+ /// <param name="id">妫�楠岄」鐩甀D</param>
+ /// <param name="gid">妫�楠屽崟ID</param>
+ /// <param name="billNo">宸ュ崟鍙�</param>
+ /// <param name="createBy">鍒涘缓浜�</param>
+ /// <returns>涓婁紶缁撴灉</returns>
+ [HttpPost("UploadImageToPicture")]
+ public ResponseResult UploadImageToPicture(IFormFile file, [FromForm] string id, [FromForm] string gid, [FromForm] string billNo, [FromForm] string createBy)
+ {
+ try
+ {
+ // 鍙傛暟楠岃瘉
+ if (file == null || file.Length == 0)
+ {
+ return new ResponseResult
+ {
+ status = 1,
+ message = "璇烽�夋嫨瑕佷笂浼犵殑鍥剧墖鏂囦欢",
+ data = null
+ };
+ }
+
+ if (string.IsNullOrEmpty(id))
+ {
+ return new ResponseResult
+ {
+ status = 1,
+ message = "妫�楠岄」鐩甀D涓嶈兘涓虹┖",
+ data = null
+ };
+ }
+
+ if (string.IsNullOrEmpty(createBy))
+ {
+ return new ResponseResult
+ {
+ status = 1,
+ message = "鍒涘缓浜轰笉鑳戒负绌�",
+ data = null
+ };
+ }
+
+ // 璇诲彇鏂囦欢瀛楄妭鏁扮粍
+ byte[] imageBytes;
+ using (var memoryStream = new MemoryStream())
+ {
+ file.CopyTo(memoryStream);
+ imageBytes = memoryStream.ToArray();
+ }
+
+ // 璋冪敤鏈嶅姟鏂规硶淇濆瓨鍥剧墖
+ var service = new SJService();
+ var (status, message) = service.UploadImageToPicture(Convert.ToDecimal(id), imageBytes, file.FileName, createBy);
+
+ return new ResponseResult
+ {
+ status = status,
+ message = message,
+ data = null
+ };
+ }
+ catch (Exception ex)
+ {
+ return new ResponseResult
+ {
+ status = 1,
+ message = $"涓婁紶鍥剧墖澶辫触锛歿ex.Message}",
+ data = null
+ };
+ }
+ }
+
+ /// <summary>
+ /// 鍒犻櫎妫�楠岄」鐩殑鍥剧墖
+ /// </summary>
+ /// <param name="data">鍖呭惈妫�楠岄」鐩甀D鐨凧SON鏁版嵁</param>
+ /// <returns>鍒犻櫎缁撴灉</returns>
+ [HttpPost("DeleteImageFromPicture")]
+ public ResponseResult DeleteImageFromPicture([FromBody] JObject data)
+ {
+ try
+ {
+ if (data["id"] == null)
+ {
+ return new ResponseResult
+ {
+ status = 1,
+ message = "妫�楠岄」鐩甀D涓嶈兘涓虹┖",
+ data = null
+ };
+ }
+
+ var id = Convert.ToDecimal(data["id"].ToString());
+
+ // 璋冪敤鏈嶅姟鏂规硶鍒犻櫎鍥剧墖
+ var service = new SJService();
+ var (status, message) = service.DeleteImageFromPicture(id);
+
+ return new ResponseResult
+ {
+ status = status,
+ message = message,
+ data = null
+ };
+ }
+ catch (Exception ex)
+ {
+ return new ResponseResult
+ {
+ status = 1,
+ message = $"鍒犻櫎鍥剧墖澶辫触锛歿ex.Message}",
+ data = null
+ };
+ }
+ }
}
\ No newline at end of file
--
Gitblit v1.9.3