From 23a34e600fb4522aec09ad39b8a8ec2e008dcd51 Mon Sep 17 00:00:00 2001 From: hao <1836460075@qq.com> Date: 星期五, 30 五月 2025 13:07:10 +0800 Subject: [PATCH] 退换料品质确认测试 --- StandardInterface/MES.Service/service/QC/RetMatService.cs | 135 +++++++++++++++++++++++++++ StandardInterface/MESApplication/Controllers/QC/RetMatController.cs | 69 +++++++++++++ StandardInterface/MES.Service/Dto/service/ReviewItem.cs | 15 +++ .vs/slnx.sqlite | 0 StandardInterface/MES.Service/Dto/service/DocRequest.cs | 15 +++ StandardInterface/MES.Service/Dto/service/ReviewRequest.cs | 15 +++ StandardInterface/MES.Service/Dto/service/DocNoRequest.cs | 13 ++ StandardInterface/MES.Service/util/DataTableExtension.cs | 29 +++++ 8 files changed, 291 insertions(+), 0 deletions(-) diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite new file mode 100644 index 0000000..0200bd8 --- /dev/null +++ b/.vs/slnx.sqlite Binary files differ diff --git a/StandardInterface/MES.Service/Dto/service/DocNoRequest.cs b/StandardInterface/MES.Service/Dto/service/DocNoRequest.cs new file mode 100644 index 0000000..519b206 --- /dev/null +++ b/StandardInterface/MES.Service/Dto/service/DocNoRequest.cs @@ -0,0 +1,13 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MES.Service.Dto.service +{ + public class DocNoRequest + { + public string DocNo { get; set; } + } +} diff --git a/StandardInterface/MES.Service/Dto/service/DocRequest.cs b/StandardInterface/MES.Service/Dto/service/DocRequest.cs new file mode 100644 index 0000000..fa4de72 --- /dev/null +++ b/StandardInterface/MES.Service/Dto/service/DocRequest.cs @@ -0,0 +1,15 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MES.Service.Dto.service +{ + public class DocRequest + { + public string DocNo { get; set; } + public string User { get; set; } // 鍙�夛紝浠� SaveReview 鐢ㄥ埌 + public List<ReviewItem> Items { get; set; } // 鍙�夛紝浠� SaveReview 鐢ㄥ埌 + } +} diff --git a/StandardInterface/MES.Service/Dto/service/ReviewItem.cs b/StandardInterface/MES.Service/Dto/service/ReviewItem.cs new file mode 100644 index 0000000..059526e --- /dev/null +++ b/StandardInterface/MES.Service/Dto/service/ReviewItem.cs @@ -0,0 +1,15 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MES.Service.Dto.service +{ + public class ReviewItem + { + public string Material { get; set; } + public string Reason { get; set; } + public int ItemId { get; set; } + } +} diff --git a/StandardInterface/MES.Service/Dto/service/ReviewRequest.cs b/StandardInterface/MES.Service/Dto/service/ReviewRequest.cs new file mode 100644 index 0000000..44d2b3b --- /dev/null +++ b/StandardInterface/MES.Service/Dto/service/ReviewRequest.cs @@ -0,0 +1,15 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MES.Service.Dto.service +{ + public class ReviewRequest + { + public string DocNo { get; set; } + public string User { get; set; } + public List<ReviewItem> Items { get; set; } + } +} diff --git a/StandardInterface/MES.Service/service/QC/RetMatService.cs b/StandardInterface/MES.Service/service/QC/RetMatService.cs new file mode 100644 index 0000000..ddf0bee --- /dev/null +++ b/StandardInterface/MES.Service/service/QC/RetMatService.cs @@ -0,0 +1,135 @@ +锘縰sing MES.Service.DB; +using MES.Service.Dto.service; +using MES.Service.util; +using Newtonsoft.Json; +using SqlSugar; +using System.Data; + +namespace MES.Service.service.QC +{ + public class RetMatService + { + public List<dynamic> GetAllDocs() + { + var db = SqlSugarHelper.GetInstance(); + + string sql = @" + SELECT THL_NO + FROM MES_ITEM_THL + -- WHERE JY_BS = 0 AND THL012 = 1 + "; + + var table = db.Ado.GetDataTable(sql); + return table.ToDynamic(); + } + + public List<dynamic> GetHeader(string docNo) + { + var db = SqlSugarHelper.GetInstance(); + + string sql = @" + SELECT + a.THL001 AS moNo, + a.THL004 AS type, + s.ITEM_NO AS productCode, + d.DEPARTMENTNAME AS deptName, + TO_CHAR(a.THL011, 'yyyy-mm-dd hh24:mi:ss') AS createTime + FROM MES_ITEM_THL a + LEFT JOIN MES_ITEMS s ON a.ITEM_ID = s.ID + LEFT JOIN WOMDAA a0 ON a.THL001 = a0.DAA001 + LEFT JOIN SYS_DEPARTMENT d ON a0.daa013 = d.ID + WHERE a.THL_NO = :docNo + "; + + var table = db.Ado.GetDataTable(sql, new SugarParameter("docNo", docNo)); + return table.ToDynamic(); + } + + public List<dynamic> GetDetailList(string docNo) + { + var db = SqlSugarHelper.GetInstance(); + + string sql = @" + SELECT + s.ITEM_NO AS material, + s.ITEM_MODEL AS spec, + a.THLD005 AS qty, + a.THLD014 AS reason, + s.ID AS item_id + FROM MES_ITEM_THL_DETAIL a + LEFT JOIN MES_ITEM_THL b ON a.THLMID = b.ID + LEFT JOIN MES_ITEMS s ON a.ITEM_ID = s.ID + WHERE b.THL_NO = :docNo + "; + + return db.Ado.GetDataTable(sql, new SugarParameter("docNo", docNo)).ToDynamic(); + } + + public void UpdateHeader(string docNo, string user) + { + var db = SqlSugarHelper.GetInstance(); + + string sql = @" + UPDATE MES_ITEM_THL + SET JY_BS = 1, + JY_USER = :user, + JY_TIME = SYSDATE + WHERE THL_NO = :docNo + "; + + db.Ado.ExecuteCommand(sql, + new SugarParameter("docNo", docNo), + new SugarParameter("user", user) + ); + } + +/* public void SaveReviewItem(string docNo, string itemNo, string reason) + { + var db = SqlSugarHelper.GetInstance(); + + string sql = @" + UPDATE MES_ITEM_THL_DETAIL + SET THLD014 = :reason + WHERE THLMID = ( + SELECT ID FROM MES_ITEM_THL WHERE THL_NO = :docNo + ) + AND ITEM_ID = ( + SELECT ID FROM MES_ITEMS WHERE ITEM_NO = :itemNo + ) + "; + + db.Ado.ExecuteCommand(sql, + new SugarParameter("docNo", docNo), + new SugarParameter("itemNo", itemNo), + new SugarParameter("reason", reason) + ); + }*/ + + public void SaveReview(string docNo, string user, List<ReviewItem> items) + { + var db = SqlSugarHelper.GetInstance(); + + string json = JsonConvert.SerializeObject(items); // 搴忓垪鍖栦负 JSON 瀛楃涓� + + + + foreach (ReviewItem item in items) + { + var parameters = new List<SugarParameter> +{ + new SugarParameter("pi_NO", docNo, System.Data.DbType.String), + new SugarParameter("pi_user", user, System.Data.DbType.String), + new SugarParameter("pi_item_ID", item.ItemId, System.Data.DbType.Decimal), + new SugarParameter("pi_reason", item.Reason, System.Data.DbType.String) +}; + + + db.Ado.UseStoredProcedure() + .ExecuteCommand("PRC_RET_MAT_AUDIT_ALL", parameters); + } + + + } + + } +} diff --git a/StandardInterface/MES.Service/util/DataTableExtension.cs b/StandardInterface/MES.Service/util/DataTableExtension.cs new file mode 100644 index 0000000..01ed599 --- /dev/null +++ b/StandardInterface/MES.Service/util/DataTableExtension.cs @@ -0,0 +1,29 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Data; +using System.Dynamic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MES.Service.util +{ + public static class DataTableExtension + { + public static List<dynamic> ToDynamic(this DataTable dt) + { + var list = new List<dynamic>(); + foreach (DataRow row in dt.Rows) + { + dynamic obj = new ExpandoObject(); + var dict = (IDictionary<string, object>)obj; + foreach (DataColumn col in dt.Columns) + dict[col.ColumnName] = row[col]; + list.Add(obj); + } + return list; + } + } + + +} diff --git a/StandardInterface/MESApplication/Controllers/QC/RetMatController.cs b/StandardInterface/MESApplication/Controllers/QC/RetMatController.cs new file mode 100644 index 0000000..fa187d1 --- /dev/null +++ b/StandardInterface/MESApplication/Controllers/QC/RetMatController.cs @@ -0,0 +1,69 @@ +锘縰sing Microsoft.AspNetCore.Mvc; +using MES.Service.Dto.service; +using MES.Service.service.QC; +using MES.Service.util; + +namespace MESApplication.Controllers.QC; + +[Route("api/[controller]")] +[ApiController] +public class RetMatController : ControllerBase +{ + private readonly RetMatService _service = new(); + + [HttpPost("GetAllDocs")] + public ResponseResult GetAllDocs() + { + try + { + var result = _service.GetAllDocs(); + return new ResponseResult { status = 0, message = "OK", data = result }; + } + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } + + [HttpPost("GetHeader")] + public ResponseResult GetHeader([FromBody] DocNoRequest req) + { + try + { + var result = _service.GetHeader(req.DocNo).FirstOrDefault(); + return new ResponseResult { status = 0, message = "OK", data = result }; + } + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } + + [HttpPost("GetList")] + public ResponseResult GetList([FromBody] DocNoRequest req) + { + try + { + var result = _service.GetDetailList(req.DocNo); + return new ResponseResult { status = 0, message = "OK", data = result }; + } + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } + + [HttpPost("SaveReview")] + public ResponseResult SaveReview([FromBody] ReviewRequest req) + { + try + { + _service.SaveReview(req.DocNo, req.User, req.Items); + return new ResponseResult { status = 0, message = "瀹℃牳鎴愬姛" }; + } + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } +} -- Gitblit v1.9.3