From 6abfd27e5b87bd8dd0bfc01839657e07fbde708b Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期三, 13 八月 2025 09:35:55 +0800 Subject: [PATCH] 111 --- MES.Service/service/QC/SJService.cs | 150 +++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 119 insertions(+), 31 deletions(-) diff --git a/MES.Service/service/QC/SJService.cs b/MES.Service/service/QC/SJService.cs index db188ef..c139b94 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,33 +37,35 @@ } //鑾峰彇鎵�鏈夋暟鎹垎椤� - public List<SJPageResult> getPage(SJPageResult queryObj) + public (List<SJPageResult> items, int totalCount) getPage(SJPageResult queryObj) { var db = SqlSugarHelper.GetInstance(); string[]? lineNo = null; - if (StringUtil.IsNotNullOrEmpty(queryObj.StatusUser)) - lineNo = _baseService.getUserLineNo(queryObj.StatusUser); + int totalCount = 0; + + //if (StringUtil.IsNotNullOrEmpty(queryObj.StatusUser)) + // lineNo = _baseService.getUserLineNo(queryObj.StatusUser); var data = db.Queryable<SJPageResult>() - .WhereIF(lineNo != null && lineNo.Length > 0, - a => lineNo.Contains(a.line)) + //.WhereIF(lineNo != null && lineNo.Length > 0, + // a => lineNo.Contains(a.line)) .WhereIF(queryObj.Id != null, a => a.Id == queryObj.Id) .WhereIF(StringUtil.IsNotNullOrEmpty(queryObj.BillNo), a => a.BillNo == queryObj.BillNo) .WhereIF( StringUtil.IsNotNullOrEmpty(queryObj.Result) && "鏈畬鎴�".Equals(queryObj.Result), - a => a.Result == queryObj.Result) + a => a.FSubmit == "0") .WhereIF( StringUtil.IsNotNullOrEmpty(queryObj.Result) && !"鏈畬鎴�".Equals(queryObj.Result), - a => a.Result != "鏈畬鎴�") - .OrderBy(a => a.BillNo, OrderByType.Desc) - .ToPageList(queryObj.PageIndex, queryObj.Limit); + a => a.FSubmit == "1") + .OrderBy(a => a.CreateTime, OrderByType.Desc); + var items = data.ToPageList(queryObj.PageIndex, queryObj.Limit,ref totalCount); - return data; + return (items, totalCount); } @@ -223,7 +228,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 +352,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; } @@ -390,7 +395,7 @@ detail.CreateBy = detail.UpdateBy; - withOracle += autoResult(detail); + // withOracle += autoResult(detail); return withOracle; } @@ -417,6 +422,20 @@ return db.Updateable<QsItemIpiItem>() .SetColumns(it => it.Remarks == dto.Remarks) //SetColumns鏄彲浠ュ彔鍔犵殑 鍐�2涓氨2涓瓧娈佃祴鍊� + .Where(it => it.Id == dto.pid) + .ExecuteCommand(); + }); + } + + + //NOTES + public int saveNotesPid(QsItem dto) + { + return SqlSugarHelper.UseTransactionWithOracle(db => + { + return db.Updateable<QsItemIpiItem>() + .SetColumns(it => + it.Notes == dto.Remarks) //SetColumns鏄彲浠ュ彔鍔犵殑 鍐�2涓氨2涓瓧娈佃祴鍊� .Where(it => it.Id == dto.pid) .ExecuteCommand(); }); @@ -455,4 +474,73 @@ 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); + } + } + + /// <summary> + /// 鏇存柊QsItemIpiItem鐨処sPass鍊� + /// </summary> + /// <param name="id">QsItemIpiItem鐨処D</param> + /// <param name="isPass">IsPass鐨勫��(0琛ㄧず涓嶅悎鏍�,1琛ㄧず鍚堟牸)</param> + /// <returns>鏇存柊褰卞搷鐨勮鏁�</returns> + public int UpdateQsItemIpiItemIsPass(decimal id, decimal isPass) + { + return SqlSugarHelper.UseTransactionWithOracle(db => + { + return db.Updateable<QsItemIpiItem>() + .SetColumns(s => s.IsPass == isPass) + .Where(s => s.Id == id) + .ExecuteCommand(); + }); + } + } \ No newline at end of file -- Gitblit v1.9.3