From e937af660a22640ace71147853cb70078673928f Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期二, 12 八月 2025 16:17:30 +0800 Subject: [PATCH] 111 --- MES.Service/service/QC/XJService.cs | 136 ++++++++++++++++++++++++++------------------- 1 files changed, 79 insertions(+), 57 deletions(-) diff --git a/MES.Service/service/QC/XJService.cs b/MES.Service/service/QC/XJService.cs index d4c8dc3..deed3d0 100644 --- a/MES.Service/service/QC/XJService.cs +++ b/MES.Service/service/QC/XJService.cs @@ -107,7 +107,8 @@ }).ToList(); } - public (List<QsQaItemXj> items, int totalCount) getPage(XJPageResult queryObj) + public (List<QsQaItemXj> items, int totalCount) getPage( + XJPageResult queryObj) { var db = SqlSugarHelper.GetInstance(); @@ -120,13 +121,14 @@ //if (StringUtil.IsNotNullOrEmpty(queryObj.createUser)) // lineNo = _baseService.getUserLineNo(queryObj.createUser); - var query= db + var query = db .Queryable<QsQaItemXj, Womdaa, MesLine, - MesItems>((s, a, c, b) => + MesItems, SysUser>((s, a, c, b, us) => new JoinQueryInfos( JoinType.Inner, s.BillNo == a.Daa001, JoinType.Left, a.Daa015 == c.LineNo, - JoinType.Left, s.ItemId == b.Id + JoinType.Left, s.ItemId == b.Id, + JoinType.Left, us.Fcode == s.CreateBy ) ) //.WhereIF(lineNo != null && lineNo.Length > 0, @@ -134,17 +136,20 @@ .WhereIF( StringUtil.IsNotNullOrEmpty(queryObj.result) && "鏈畬鎴�".Equals(queryObj.result), - (s, a, c, b) => s.SubmitStatus == 0 || s.SubmitStatus == null) + (s, a, c, b, us) => + s.SubmitStatus == 0 || s.SubmitStatus == null) .WhereIF( StringUtil.IsNotNullOrEmpty(queryObj.result) && !"鏈畬鎴�".Equals(queryObj.result), - (s, a, c, b) => s.SubmitStatus == 1) - .WhereIF(id > 0, (s, a, c, b) => s.Id == id) - .Select((s, a, c, b) => new QsQaItemXj + (s, a, c, b, us) => s.SubmitStatus == 1) + .WhereIF(id > 0, (s, a, c, b, us) => s.Id == id) + .Select((s, a, c, b, us) => new QsQaItemXj { Daa020 = c.LineNo, Id = s.Id, PlanQty = a.Daa008, + LineName = c.LineName, + CreateUser = us.Fname, CreateBy = s.CreateBy, CreateDate = s.CreateDate, ReleaseNo = s.ReleaseNo, @@ -156,7 +161,8 @@ CheckResult = s.CheckResult, Remarks = s.Remarks }).OrderBy(s => s.CreateDate, OrderByType.Desc); - var items = query.ToPageList(queryObj.PageIndex, queryObj.Limit,ref totalCount); + var items = query.ToPageList(queryObj.PageIndex, queryObj.Limit, + ref totalCount); return (items, totalCount); } @@ -174,29 +180,28 @@ return db .Queryable<MesQualityStandard>() .Where(b => b.QsType == "2" - && b.ItemNo == itemNo).Select( - b => new QsQaItemXj01 - { - ProjName = b.ProjName, - ItemMod = b.ItemMod, - InspectionMethod = b.InspectionMethod, - UsingInstruments = b.UsingInstruments, - LevelNum = SqlFunc.IsNull( - SqlFunc.IsNull(b.LevelNum * b.InspectionLevel, 1), - b.InspectionLevel), - MaxValue = b.MaxValue, - StandardValue = b.StandardValue, - MinValue = b.MinValue, - Notes = b.Notes, - FcheckLevel = b.FcheckLevel, - FacLevel = b.FacLevel, - QsCode = b.QsCode, - QsName = b.QsName, - result = "鏈娴�", - isCheck = 0, - Picture = b.Picture, - Picturename = b.Picturename - }).ToList(); + && b.ItemNo == itemNo).Select(b => new QsQaItemXj01 + { + ProjName = b.ProjName, + ItemMod = b.ItemMod, + InspectionMethod = b.InspectionMethod, + UsingInstruments = b.UsingInstruments, + LevelNum = SqlFunc.IsNull( + SqlFunc.IsNull(b.LevelNum * b.InspectionLevel, 1), + b.InspectionLevel), + MaxValue = b.MaxValue, + StandardValue = b.StandardValue, + MinValue = b.MinValue, + Notes = b.Notes, + FcheckLevel = b.FcheckLevel, + FacLevel = b.FacLevel, + QsCode = b.QsCode, + QsName = b.QsName, + result = "鏈娴�", + isCheck = 0, + Picture = b.Picture, + Picturename = b.Picturename + }).ToList(); } public List<QsQaItemXj01> getJYItem(decimal? pid, decimal? id) @@ -292,7 +297,7 @@ return Convert.ToInt32(xj.Id); } - + public bool XJQaSubmit(LLJDto rkjDto) { var useTransactionWithOracle = @@ -357,20 +362,22 @@ // 鑾峰彇妫�楠岄」鐩暟鎹� var jyItems = getJYItemOptimized(db, xjDto.gid.Value); - + if (jyItems.Any()) { // 澶勭悊涓氬姟閫昏緫璁$畻 - var allDetails = PrepareDetailsData(jyItems, xjDto.gid.Value, userNo); + var allDetails = + PrepareDetailsData(jyItems, xjDto.gid.Value, userNo); if (allDetails.Count > 0) { // 鎵归噺鎻掑叆妫�楠岃鎯� db.Insertable(allDetails).ExecuteCommand(); - + // 璁$畻缁撴灉 - var (pidResults, fcheckResu) = CalculateResults(allDetails, jyItems); - + var (pidResults, fcheckResu) = + CalculateResults(allDetails, jyItems); + // 鎵归噺鏇存柊妫�楠岄」鐩粨鏋� foreach (var (pidValue, result) in pidResults) { @@ -381,7 +388,9 @@ } // 鏇存柊涓昏〃妫�楠岀粨鏋� - var totalSum = jyItems.Where(x => x.MaxValue == null && x.StandardValue == null && x.MinValue == null) + var totalSum = jyItems.Where(x => + x.MaxValue == null && x.StandardValue == null && + x.MinValue == null) .Sum(x => x.LevelNum); if (totalSum == allDetails.Count) { @@ -400,33 +409,39 @@ return Convert.ToInt32(xjDto.gid); }); } - - private List<QsQaItemXj01> getJYItemOptimized(ISqlSugarClient db, decimal xjId) + + private List<QsQaItemXj01> getJYItemOptimized(ISqlSugarClient db, + decimal xjId) { return db.Queryable<QsQaItemXj01>() .Where(a => a.Pid == xjId) .ToList(); } - - private (bool isValid, string errorMsg) ValidateItemsData(List<QsQaItemXj01> items) + + private (bool isValid, string errorMsg) ValidateItemsData( + List<QsQaItemXj01> items) { if (items == null || !items.Any()) return (false, "妫�楠岄」鐩笉鑳戒负绌�"); - - var invalidItems = items.Where(x => x.LevelNum <= 0 || string.IsNullOrEmpty(x.ProjName)).ToList(); - if (invalidItems.Any()) + + var invalidItems = items + .Where(x => x.LevelNum <= 0 || string.IsNullOrEmpty(x.ProjName)) + .ToList(); + if (invalidItems.Any()) return (false, $"瀛樺湪{invalidItems.Count}涓棤鏁堢殑妫�楠岄」鐩�"); - + return (true, ""); } - private List<QsQaItemXj02> PrepareDetailsData(List<QsQaItemXj01> jyItems, decimal gid, string userNo) + private List<QsQaItemXj02> PrepareDetailsData(List<QsQaItemXj01> jyItems, + decimal gid, string userNo) { var allDetails = new List<QsQaItemXj02>(); var now = DateTime.Now; - + foreach (var s in jyItems) { - if (s.MaxValue != null || s.StandardValue != null || s.MinValue != null) + if (s.MaxValue != null || s.StandardValue != null || + s.MinValue != null) continue; for (var i = 0; i < s.LevelNum; i++) @@ -442,15 +457,17 @@ }); } } + return allDetails; } - private (List<(decimal pid, int result)> pidResults, string fcheckResu) CalculateResults( - List<QsQaItemXj02> allDetails, List<QsQaItemXj01> jyItems) + private (List<(decimal pid, int result)> pidResults, string fcheckResu) + CalculateResults( + List<QsQaItemXj02> allDetails, List<QsQaItemXj01> jyItems) { var pidGroups = allDetails.GroupBy(x => x.Pid).ToList(); var pidResults = new List<(decimal pid, int result)>(); - + foreach (var group in pidGroups) { var count = group.Count(); @@ -459,11 +476,16 @@ pidResults.Add((group.Key.Value, result)); } - var totalSum = jyItems.Where(x => x.MaxValue == null && x.StandardValue == null && x.MinValue == null) + var totalSum = jyItems.Where(x => + x.MaxValue == null && x.StandardValue == null && + x.MinValue == null) .Sum(x => x.LevelNum); var totalCount = allDetails.Count; var totalPassCount = allDetails.Count(x => x.Fstand == "鈭�"); - var fcheckResu = (totalSum == totalCount && totalCount == totalPassCount) ? "鍚堟牸" : "涓嶅悎鏍�"; + var fcheckResu = + (totalSum == totalCount && totalCount == totalPassCount) + ? "鍚堟牸" + : "涓嶅悎鏍�"; return (pidResults, fcheckResu); } @@ -547,8 +569,8 @@ if (count == passCount) result = 1; - var useTransactionWithOracle = SqlSugarHelper.UseTransactionWithOracle( - db => + var useTransactionWithOracle = + SqlSugarHelper.UseTransactionWithOracle(db => { var commit = 0; commit += db.Updateable<QsQaItemXj01>() -- Gitblit v1.9.3