From 349f2f66fdac1a2d64e0c99201b7f09579470714 Mon Sep 17 00:00:00 2001
From: xwt <2740516069@qq.com>
Date: 星期四, 16 十月 2025 14:26:31 +0800
Subject: [PATCH] SJ,XJ,RKJ检验项单独拍照+提交限制
---
StandardInterface/MESApplication/Controllers/QC/XJController.cs | 448 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 437 insertions(+), 11 deletions(-)
diff --git a/StandardInterface/MESApplication/Controllers/QC/XJController.cs b/StandardInterface/MESApplication/Controllers/QC/XJController.cs
index 25228a3..18c4299 100644
--- a/StandardInterface/MESApplication/Controllers/QC/XJController.cs
+++ b/StandardInterface/MESApplication/Controllers/QC/XJController.cs
@@ -5,6 +5,7 @@
using MES.Service.util;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
+using System.Web;
namespace MESApplication.Controllers.QC;
@@ -15,7 +16,7 @@
[HttpPost("getAll")]
public ResponseResult getAll([FromBody] JObject data)
{
- var modify1Flag = Convert.ToInt32(data["modify1Flag"].ToString());
+ var modify1Flag = Convert.ToInt32(data["modify1Flag"]?.ToString() ?? "0");
try
{
dynamic resultInfos = new ExpandoObject();
@@ -88,13 +89,36 @@
[HttpPost("getDaa001")]
public ResponseResult getDaa001([FromBody] JObject data)
{
- var daa020 = data["daa020"].ToString();
- var item = data["item"].ToString();
+ var daa020 = data["daa020"]?.ToString() ?? "";
try
{
dynamic resultInfos = new ExpandoObject();
- var tbBillList =
- new XJService().getDaa001(daa020, item);
+ var tbBillList = new XJService().getDaa001(daa020);
+ resultInfos.tbBillList = tbBillList;
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇宸ュ崟璇︾粏淇℃伅锛堝寘鍚墿鏂欎俊鎭級
+ /// </summary>
+ [HttpPost("getWorkOrderWithItem")]
+ public ResponseResult getWorkOrderWithItem([FromBody] JObject data)
+ {
+ var daa020 = data["daa020"]?.ToString() ?? "";
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ var tbBillList = new XJService().getWorkOrderWithItem(daa020);
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
@@ -116,12 +140,14 @@
[HttpPost("getBoardItem")]
public ResponseResult getBoardItem([FromBody] JObject data)
{
- var lineNo = data["lineNo"].ToString();
+ var lineNo = data["lineNo"]?.ToString() ?? "";
try
{
dynamic resultInfos = new ExpandoObject();
var tbBillList =
new XJService().getBoardItem(lineNo);
+ // 鎸� itemNo 鍘婚噸
+ tbBillList = tbBillList.GroupBy(x => x.ItemNo).Select(g => g.First()).ToList();
resultInfos.tbBillList = tbBillList;
return new ResponseResult
{
@@ -140,7 +166,7 @@
[HttpPost("getItem")]
public ResponseResult getItem([FromBody] JObject data)
{
- var daa001 = data["daa001"].ToString();
+ var daa001 = data["daa001"]?.ToString() ?? "";
try
{
dynamic resultInfos = new ExpandoObject();
@@ -164,7 +190,7 @@
[HttpPost("setJYItem")]
public ResponseResult setJYItem([FromBody] JObject data)
{
- var itemNo = data["itemNo"].ToString();
+ var itemNo = data["itemNo"]?.ToString() ?? "";
try
{
dynamic resultInfos = new ExpandoObject();
@@ -191,9 +217,12 @@
try
{
dynamic resultInfos = new ExpandoObject();
- var tbBillList =
- new XJService().save(xjDto);
- resultInfos.tbBillList = tbBillList;
+ var result = new XJService().save(xjDto);
+
+ // 杩斿洖瀹屾暣鐨刋JDto瀵硅薄锛屽寘鍚洿鏂板悗鐨刬tems
+ resultInfos.tbBillList = result;
+ resultInfos.xjDto = xjDto; // 鍖呭惈瀹屾暣鐨勬楠岄」鐩俊鎭�
+
return new ResponseResult
{
status = 0,
@@ -442,4 +471,401 @@
return ResponseResult.ResponseError(ex);
}
}
+
+ //鍒锋柊妫�楠岄」鐩�
+ [HttpPost("GenUpdate")]
+ public ResponseResult GenUpdate([FromBody] JObject data)
+ {
+ try
+ {
+ decimal? id = data["id"]?.ToObject<decimal>();
+ string? no = data["no"]?.ToString();
+ string? user = data["user"]?.ToString();
+
+ var (result, message) = new XJService().GenUpdate(id, no, user);
+
+ dynamic resultInfos = new ExpandoObject();
+ resultInfos.result = result;
+ resultInfos.message = message;
+
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ //鎻愪氦妫�楠�
+ [HttpPost("SjSubmit")]
+ public ResponseResult SjSubmit([FromBody] SJDto sjDto)
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ var tbBillList = new XJService().SjSubmit(sjDto);
+ resultInfos.tbBillList = tbBillList;
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇鏈夌嚎浣撶殑閮ㄩ棬鍒楄〃
+ /// </summary>
+ [HttpPost("getDepartmentsWithLines")]
+ public ResponseResult GetDepartmentsWithLines()
+ {
+ try
+ {
+ dynamic resultInfos = new ExpandoObject();
+ var tbBillList = new XJService().GetDepartmentsWithLines();
+ resultInfos.tbBillList = tbBillList;
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ /// <summary>
+ /// 淇濆瓨閮ㄩ棬閫夋嫨
+ /// </summary>
+ [HttpPost("saveDepartmentSelection")]
+ public ResponseResult SaveDepartmentSelection([FromBody] JObject data)
+ {
+ try
+ {
+ var id = Convert.ToDecimal(data["id"]);
+ var departmentId = data["departmentId"]?.ToString() ?? "";
+ var departmentName = data["departmentName"]?.ToString() ?? "";
+
+ dynamic resultInfos = new ExpandoObject();
+ var result = new XJService().SaveDepartmentSelection(id, departmentId, departmentName);
+ resultInfos.tbBillList = result;
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ /// <summary>
+ /// 鏍规嵁閮ㄩ棬ID鑾峰彇璇ラ儴闂ㄤ笅鐨勭嚎浣撳垪琛�
+ /// </summary>
+ [HttpPost("getLinesByDepartment")]
+ public ResponseResult GetLinesByDepartment([FromBody] JObject data)
+ {
+ try
+ {
+ var departmentId = data["departmentId"]?.ToString() ?? "";
+
+ dynamic resultInfos = new ExpandoObject();
+ var tbBillList = new XJService().GetLinesByDepartment(departmentId);
+ resultInfos.tbBillList = tbBillList;
+ return new ResponseResult
+ {
+ status = 0,
+ message = "OK",
+ data = resultInfos
+ };
+ }
+ catch (Exception ex)
+ {
+ return ResponseResult.ResponseError(ex);
+ }
+ }
+
+ /// <summary>
+ /// 鑾峰彇闄勪欢淇℃伅
+ /// </summary>
+ /// <param name="data">鍖呭惈itemNo鐨凧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(); // 鏂板鍙傛暟
+
+ // 璋冭瘯鏃ュ織
+ Console.WriteLine($"XJController.GetAttachments 鎺ユ敹鍙傛暟: itemNo='{itemNo}', projName='{projName}', fromPage='{fromPage}'");
+
+ // 鏉′欢杩囨护閫昏緫锛氭牴鎹甪romPage鍐冲畾鏄惁杩囨护
+ string filterProjName = null;
+ if (fromPage == "Detail" && !string.IsNullOrEmpty(projName))
+ {
+ filterProjName = projName; // Detail椤甸潰闇�瑕佽繃婊�
+ }
+ // Add椤甸潰涓嶄紶閫抐ilterProjName锛屾樉绀烘墍鏈夐檮浠�
+
+ try
+ {
+ dynamic resultInfos = new System.Dynamic.ExpandoObject();
+ var tbBillList = new XJService().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
+ {
+ // 娣诲姞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 XJService();
+ var fileBytes = service.GetFtpFile(itemNo, fileName, ftpServer, projName);
+
+ 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}");
+ }
+ }
+
+ /// <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
+ {
+ // 娣诲姞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 XJService();
+ var fileBytes = service.GetFtpFile(itemNo, fileName, ftpServer, projName);
+
+ 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()
+ {
+ 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-Max-Age", "86400");
+ return Ok();
+ }
+
+ /// <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 XJService();
+ 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
+ {
+ var id = data["id"]?.ToString();
+
+ if (string.IsNullOrEmpty(id))
+ {
+ return new ResponseResult
+ {
+ status = 1,
+ message = "妫�楠岄」鐩甀D涓嶈兘涓虹┖",
+ data = null
+ };
+ }
+
+ // 璋冪敤鏈嶅姟鏂规硶鍒犻櫎鍥剧墖
+ var service = new XJService();
+ var (status, message) = service.DeleteImageFromPicture(Convert.ToDecimal(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