From 5648a24be5fa8b8981c399c09a5d5a306bae1d5e Mon Sep 17 00:00:00 2001 From: hao <1836460075@qq.com> Date: 星期三, 16 七月 2025 08:33:57 +0800 Subject: [PATCH] 工单备料测试 --- StandardInterface/MES.Service/Dto/service/GDBLQRRequest.cs | 26 ++++++ StandardInterface/MESApplication/Controllers/QC/GDBLQRController.cs | 77 +++++++++++++++++++ StandardInterface/MES.Service/service/QC/GDBLQRService.cs | 98 ++++++++++++++++++++++++ StandardInterface/MES.Service/service/WomcaaManager.cs | 1 StandardInterface/MESApplication/appsettings.json | 2 5 files changed, 203 insertions(+), 1 deletions(-) diff --git a/StandardInterface/MES.Service/Dto/service/GDBLQRRequest.cs b/StandardInterface/MES.Service/Dto/service/GDBLQRRequest.cs new file mode 100644 index 0000000..9597a49 --- /dev/null +++ b/StandardInterface/MES.Service/Dto/service/GDBLQRRequest.cs @@ -0,0 +1,26 @@ +锘縰sing System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace MES.Service.Dto.service +{ + public class GDBLQRConfirmRequest + { + public string MoNo { get; set; } + public string User { get; set; } + } + + public class MoRequest + { + public string MoNo { get; set; } + } + + public class BarcodeScanRequest + { + public string MoNo { get; set; } + public string Barcode { get; set; } + } +} + diff --git a/StandardInterface/MES.Service/service/QC/GDBLQRService.cs b/StandardInterface/MES.Service/service/QC/GDBLQRService.cs new file mode 100644 index 0000000..4ea073a --- /dev/null +++ b/StandardInterface/MES.Service/service/QC/GDBLQRService.cs @@ -0,0 +1,98 @@ +锘縰sing MES.Service.DB; +using MES.Service.Dto.service; +using MES.Service.util; +using SqlSugar; +using System.Data; + +namespace MES.Service.service.QC; + +public class GDBLQRService +{ + /// <summary> + /// 鑾峰彇宸ュ崟澶翠俊鎭拰澶囨枡鏄庣粏鍒楄〃锛堝弻娓告爣锛� + /// </summary> + public (dynamic Header, List<dynamic> Details, string Msg) GetMoFullInfo(string moNo) + { + var db = SqlSugarHelper.GetInstance(); + + var parameters = new List<SugarParameter> + { + new("pi_mo_no", moNo), + new("po_header", null) { Direction = ParameterDirection.Output }, + new("po_details", null) { Direction = ParameterDirection.Output }, + new("po_msg", null) + { + Direction = ParameterDirection.Output, + DbType = System.Data.DbType.String, + Size = 200 + } + }; + + DataSet resultSets = db.Ado.UseStoredProcedure().GetDataSetAll("PRC_PREPARE_GET_MO_FULL_INFO", parameters); + + var msg = parameters.First(p => p.ParameterName == "po_msg").Value?.ToString() ?? "OK"; + + if (msg != "OK") + return (null, null, msg); // 鉂� 鐘舵�佸紓甯革紝涓嶈繑鍥炰换浣曟暟鎹� + + var header = resultSets.Tables[0].ToDynamic().FirstOrDefault(); + var details = resultSets.Tables[1].ToDynamic(); + return (header, details, msg); + } + + /// <summary> + /// 鎵爜鏇存柊鐗╂枡鎵弿鏁伴噺 + /// </summary> + public string ScanBarcode(string moNo, string barcode) + { + var db = SqlSugarHelper.GetInstance(); + + var parameters = new List<SugarParameter> + { + new("pi_mo_no", moNo), + new("pi_barcode", barcode), + new("po_msg", null) + { + Direction = ParameterDirection.Output, + DbType = System.Data.DbType.String, // 鉁� 鏄惧紡鎸囧畾 System.Data.DbType 閬垮厤姝т箟 + Size = 200 + } + }; + + db.Ado.UseStoredProcedure().ExecuteCommand("PRC_PREPARE_SCAN_BARCODE", parameters); + + return parameters.First(p => p.ParameterName == "po_msg").Value?.ToString() ?? ""; + } + + /// <summary> + /// 宸ュ崟鐢熶骇纭锛堟墦鏍囩‘璁や汉鍜屾椂闂达級 + /// </summary> + public void ConfirmPrepare(string moNo, string user) + { + var db = SqlSugarHelper.GetInstance(); + + var parameters = new List<SugarParameter> + { + new("pi_mo_no", moNo), + new("pi_user", user) + }; + + db.Ado.UseStoredProcedure().ExecuteCommand("PRC_PREPARE_PRODUCTION_CONFIRM", parameters); + } + + /// <summary> + /// 宸ュ崟鍝佽川澶嶆牳纭锛堟墦鏍囩‘璁や汉鍜屾椂闂达級 + /// </summary> + public void ReviewPrepare(string moNo, string user) + { + var db = SqlSugarHelper.GetInstance(); + + var parameters = new List<SugarParameter> + { + new("pi_mo_no", moNo), + new("pi_user", user) + }; + + db.Ado.UseStoredProcedure().ExecuteCommand("PRC_PREPARE_QUALITY_REVIEW", parameters); + } +} diff --git a/StandardInterface/MES.Service/service/WomcaaManager.cs b/StandardInterface/MES.Service/service/WomcaaManager.cs index 2c03d6f..c1584c4 100644 --- a/StandardInterface/MES.Service/service/WomcaaManager.cs +++ b/StandardInterface/MES.Service/service/WomcaaManager.cs @@ -294,6 +294,7 @@ // Db.Deleteable<Womcab>().Where(s => s.Erpid == womcab.Erpid).ExecuteCommand(); womcab.Id = entity.Id; } + womcabList.Add(womcab); } diff --git a/StandardInterface/MESApplication/Controllers/QC/GDBLQRController.cs b/StandardInterface/MESApplication/Controllers/QC/GDBLQRController.cs new file mode 100644 index 0000000..4d3a222 --- /dev/null +++ b/StandardInterface/MESApplication/Controllers/QC/GDBLQRController.cs @@ -0,0 +1,77 @@ +锘縰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 GDBLQRController : ControllerBase +{ + private readonly GDBLQRService _service = new(); + + [HttpPost("GetMoFullInfo")] + public ResponseResult GetMoFullInfo([FromBody] MoRequest req) + { + try + { + var (header, details, msg) = _service.GetMoFullInfo(req.MoNo); + + if (msg != "OK") + return new ResponseResult { status = -1, message = msg }; + + return new ResponseResult + { + status = 0, + message = "OK", + data = new { header, details } + }; + } + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } + [HttpPost("ScanBarcode")] + public ResponseResult ScanBarcode([FromBody] BarcodeScanRequest req) + { + try + { + var result = _service.ScanBarcode(req.MoNo, req.Barcode); + return new ResponseResult { status = 0, message = result }; + } + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } + + [HttpPost("Confirm")] + public ResponseResult Confirm([FromBody] GDBLQRConfirmRequest req) + { + try + { + _service.ConfirmPrepare(req.MoNo, req.User); + return new ResponseResult { status = 0, message = "鐢熶骇纭鎴愬姛" }; + } + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } + + [HttpPost("Review")] + public ResponseResult Review([FromBody] GDBLQRConfirmRequest req) + { + try + { + _service.ReviewPrepare(req.MoNo, req.User); + return new ResponseResult { status = 0, message = "鍝佽川澶嶆牳鎴愬姛" }; + } + catch (Exception ex) + { + return ResponseResult.ResponseError(ex); + } + } +} diff --git a/StandardInterface/MESApplication/appsettings.json b/StandardInterface/MESApplication/appsettings.json index 59a3601..28cfc2a 100644 --- a/StandardInterface/MESApplication/appsettings.json +++ b/StandardInterface/MESApplication/appsettings.json @@ -10,6 +10,6 @@ "AppSettings": { "TestErpUrl": "http://192.168.11.120:8098/WebService1.asmx/mesToErpinfo", "ProductionErpUrl": "http://192.168.11.120:8098/WebService1.asmx/mesToErpinfoFormal", - "DataBaseConn": "Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ORCL))); Persist Security Info=True;User ID = test_dev; Password=hmprd" + "DataBaseConn": "Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.22)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ORCL))); Persist Security Info=True;User ID = hm_prd; Password=hmprd" } } -- Gitblit v1.9.3