From 8f25fecab6e6a79096b9940ab3432401b9045b39 Mon Sep 17 00:00:00 2001 From: cnf <3200815559@qq.com> Date: 星期四, 10 七月 2025 18:00:14 +0800 Subject: [PATCH] 首检\巡检\入库检适配 --- MES.Service/service/QC/SJService.cs | 108 +++++++++++++++++++++++++++++++++++++++++------------- 1 files changed, 82 insertions(+), 26 deletions(-) diff --git a/MES.Service/service/QC/SJService.cs b/MES.Service/service/QC/SJService.cs index 50e6160..de9da99 100644 --- a/MES.Service/service/QC/SJService.cs +++ b/MES.Service/service/QC/SJService.cs @@ -3,6 +3,9 @@ using MES.Service.Modes; using MES.Service.util; using SqlSugar; +using DbType = System.Data.DbType; +using System.Data; +using static Microsoft.EntityFrameworkCore.DbLoggerCategory; namespace MES.Service.service.QC; @@ -34,7 +37,7 @@ } //鑾峰彇鎵�鏈夋暟鎹垎椤� - public List<SJPageResult> getPage(SJPageResult queryObj) + public (List<SJPageResult> items, int totalCount) getPage(SJPageResult queryObj) { var db = SqlSugarHelper.GetInstance(); @@ -52,15 +55,16 @@ .WhereIF( StringUtil.IsNotNullOrEmpty(queryObj.Result) && "鏈畬鎴�".Equals(queryObj.Result), - a => a.Remarks == queryObj.Result) + a => a.Result == queryObj.Result) .WhereIF( StringUtil.IsNotNullOrEmpty(queryObj.Result) && !"鏈畬鎴�".Equals(queryObj.Result), - a => a.Remarks != "鏈畬鎴�") - .OrderBy(a => a.BillNo, OrderByType.Desc) - .ToPageList(queryObj.PageIndex, queryObj.Limit); + a => a.Result != "鏈畬鎴�") + .OrderBy(a => a.BillNo, OrderByType.Desc); + var totalCount = data.Count(); + var items = data.ToPageList(queryObj.PageIndex, queryObj.Limit); - return data; + return (items, totalCount); } @@ -223,7 +227,7 @@ item.Items = getQSItems(qsItemIpiReq.Id, null); var sjPageResult = new SJPageResult { Id = item.From.Id, Limit = 1, PageIndex = 1 }; - item.Result = getPage(sjPageResult)[0]; + item.Result = getPage(sjPageResult).items[0]; return item; } @@ -347,28 +351,28 @@ if (icount == 0) return 1; //瀹為檯涓暟绛変簬鐞嗚涓暟鏃跺妫�楠屽崟杩涜鍒ゅ畾 - if (sum == icount) - { - result = 0; + //if (sum == icount) + //{ + // result = 0; - //鑾峰彇杩欎釜妫�楠屽崟涓嬬殑鎵�鏈夊悎鏍肩殑妫�楠岀粨鏋� - passCount = db.Queryable<QsItemIpiItemDetail>() - .Where(s => s.Gid == detail.Gid && s.Fstand == "鈭�").Count(); + // //鑾峰彇杩欎釜妫�楠屽崟涓嬬殑鎵�鏈夊悎鏍肩殑妫�楠岀粨鏋� + // passCount = db.Queryable<QsItemIpiItemDetail>() + // .Where(s => s.Gid == detail.Gid && s.Fstand == "鈭�").Count(); - //鍚堟牸鐨勬楠岀粨鏋滅瓑浜庢�绘楠屾暟瑙嗕负鍚堟牸 - if (icount == passCount) result = 1; + // //鍚堟牸鐨勬楠岀粨鏋滅瓑浜庢�绘楠屾暟瑙嗕负鍚堟牸 + // if (icount == passCount) result = 1; - useTransactionWithOracle += SqlSugarHelper.UseTransactionWithOracle( - db => - { - return db.Updateable<QsItemIpiReq>() - .SetColumns(s => s.IsPass == result) - .SetColumns(s => s.StatusUser == detail.CreateBy) - .SetColumns(s => s.CompleteTime == DateTime.Now) - .Where(s => s.Id == detail.Gid) - .ExecuteCommand(); - }); - } + // useTransactionWithOracle += SqlSugarHelper.UseTransactionWithOracle( + // db => + // { + // return db.Updateable<QsItemIpiReq>() + // .SetColumns(s => s.IsPass == result) + // .SetColumns(s => s.StatusUser == detail.CreateBy) + // .SetColumns(s => s.CompleteTime == DateTime.Now) + // .Where(s => s.Id == detail.Gid) + // .ExecuteCommand(); + // }); + //} return useTransactionWithOracle; } @@ -455,4 +459,56 @@ return withOracle; } + + public bool SJQaSubmit(QsItem item) + { + + if (item == null) + throw new ArgumentNullException(nameof(item), "璐ㄦ椤规暟鎹笉鑳戒负绌�"); + + if (string.IsNullOrWhiteSpace(item.userNo)) + throw new ArgumentException("鐢ㄦ埛缂栧彿涓嶈兘涓虹┖", nameof(item.userNo)); + + var (factory, company) = UserUtil.GetFactory(item.userNo); + try + { + // 瀹氫箟杈撳嚭鍙傛暟 + var outputResult = new SugarParameter("o_Result", null, DbType.Int32, ParameterDirection.Output, + 4000); + + var outputMessage = new SugarParameter("o_Msg", null, DbType.String, ParameterDirection.Output, 4000); + + // 瀹氫箟杈撳叆鍙傛暟 + var parameters = new List<SugarParameter> + { + + new("p_Id", item.gid, DbType.Int32,ParameterDirection.Input), + new("p_Flag", 1, DbType.Int32,ParameterDirection.Input), + new("p_User", item.userNo, DbType.String, ParameterDirection.Input), + outputResult, + outputMessage + }; + + var db = SqlSugarHelper.GetInstance(); + + // 浣跨敤 SqlSugar 鎵ц瀛樺偍杩囩▼ + db.Ado.ExecuteCommand( + "BEGIN PRC_WOMDAA_SJ_UPDATE_RES(:p_Id,:p_Flag,:p_User,:o_Result, :o_Msg); END;", + parameters.ToArray()); + + // 鑾峰彇杈撳嚭鍙傛暟鐨勫�� + var resultValue = outputResult.Value?.ToString(); + var messageValue = outputMessage.Value?.ToString(); + + if ("1".Equals(resultValue)) { throw new Exception(messageValue); } + if ("0".Equals(resultValue)) { throw new Exception(messageValue); } + + return true; + } + catch (Exception ex) + { + throw new Exception(ex.Message); + } + } + } \ No newline at end of file -- Gitblit v1.9.3