From 3b3d2378bd52268dad426c70b853473eccee3b87 Mon Sep 17 00:00:00 2001 From: xwt <2740516069@qq.com> Date: 星期一, 15 九月 2025 09:24:03 +0800 Subject: [PATCH] 首检穴模数 --- StandardInterface/MES.Service/service/QC/SJService.cs | 115 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 112 insertions(+), 3 deletions(-) diff --git a/StandardInterface/MES.Service/service/QC/SJService.cs b/StandardInterface/MES.Service/service/QC/SJService.cs index dcc7beb..e53d43e 100644 --- a/StandardInterface/MES.Service/service/QC/SJService.cs +++ b/StandardInterface/MES.Service/service/QC/SJService.cs @@ -178,10 +178,38 @@ public List<QsItemIpiItem> getQSItems(decimal? pid, decimal? id) { var db = SqlSugarHelper.GetInstance(); + + // 浣跨敤JOIN鏌ヨ鑾峰彇瀛愯〃鏁版嵁鍜屼富琛ㄧ殑MNUM銆丏NUM瀛楁 var qsItemIpiItems = db - .Queryable<QsItemIpiItem>() - .WhereIF(pid > 0, a => a.Pid == pid) - .WhereIF(id > 0, a => a.Id == id).ToList(); + .Queryable<QsItemIpiItem, QsItemIpiReq>((a, b) => new JoinQueryInfos(JoinType.Left, a.Pid == b.Id)) + .WhereIF(pid > 0, (a, b) => a.Pid == pid) + .WhereIF(id > 0, (a, b) => a.Id == id) + .Select((a, b) => new QsItemIpiItem + { + Id = a.Id, + Pid = a.Pid, + ProjName = a.ProjName, + ItemMod = a.ItemMod, + InspectionMethod = a.InspectionMethod, + UsingInstruments = a.UsingInstruments, + LevelNum = a.LevelNum, + MaxValue = a.MaxValue, + StandardValue = a.StandardValue, + MinValue = a.MinValue, + Notes = a.Notes, + FcheckLevel = a.FcheckLevel, + FacLevel = a.FacLevel, + QsCode = a.QsCode, + QsName = a.QsName, + Picture = a.Picture, + Picturename = a.Picturename, + IsPass = a.IsPass, + ItemId = a.ItemId, + Mnum = b.Mnum, // 浠庝富琛ㄨ幏鍙朚NUM + Dnum = b.Dnum, // 浠庝富琛ㄨ幏鍙朌NUM + Snum = a.Snum, // 閫佹鎵规暟 + Remarks = a.Remarks + }).ToList(); var array = qsItemIpiItems.Select(s => s.Id).ToArray(); var qsItemIpiItemDetails = db.Queryable<QsItemIpiItemDetail>() @@ -227,6 +255,16 @@ //鎺掑簭锛屾湭瀹屾垚鐨勬帓鍦ㄥ墠闈� qsItemIpiItems = qsItemIpiItems.OrderBy(s => s.isCheck).ToList(); + + // 涓烘瘡涓楠岄」鐩敓鎴愮┐鍙蜂俊鎭� + qsItemIpiItems.ForEach(item => + { + if (item.Mnum > 0 && item.Snum > 0) + { + // 浣跨敤SNUM浣滀负閫佹鎵规暟鏉ヨ绠楁�荤紪鍙锋暟閲� + item.HoleNumbers = GenerateHoleNumbers(item.Mnum, item.Dnum, item.Snum); + } + }); return qsItemIpiItems; } @@ -313,6 +351,10 @@ var oracle = SqlSugarHelper.UseTransactionWithOracle(db => { List<QsItemIpiItemDetail> result = new(); + + // 鑾峰彇璧峰绱㈠紩锛屽鏋滄病鏈夋寚瀹氬垯浠�0寮�濮� + int startIndex = detail.startIndex ?? 0; + for (var i = 0; i < detail.count; i++) { var item = new QsItemIpiItemDetail(); @@ -322,6 +364,9 @@ item.FcheckResu = detail.FcheckResu; item.CreateBy = detail.UpdateBy; item.CreateDate = DateTime.Now; + + // 濡傛灉鏈夎捣濮嬬储寮曪紝鍙互鍦ㄨ繖閲岃缃浉鍏崇殑绱㈠紩淇℃伅 + // 娉ㄦ剰锛氳繖閲屽彧鏄ず渚嬶紝瀹為檯鍙兘闇�瑕佹牴鎹笟鍔¢渶姹傝皟鏁� result.Add(item); } @@ -571,4 +616,68 @@ throw new Exception(ex.Message); } } + + /// <summary> + /// 鐢熸垚绌村彿淇℃伅 + /// </summary> + /// <param name="mnum">寮�绌存�绘暟</param> + /// <param name="dnum">鍫电┐鍙凤紙閫楀彿鍒嗛殧锛�</param> + /// <param name="snum">閫佹鎵规暟</param> + /// <returns>绌村彿淇℃伅鍒楄〃</returns> + private List<HoleNumberInfo> GenerateHoleNumbers(decimal? mnum, string? dnum, decimal? snum) + { + var result = new List<HoleNumberInfo>(); + + if (mnum == null || mnum <= 0 || snum == null || snum <= 0) + return result; + + // 瑙f瀽鍫电┐鍙� + var blockedHoles = new HashSet<int>(); + if (!string.IsNullOrEmpty(dnum)) + { + var holeNumbers = dnum.Split(',', StringSplitOptions.RemoveEmptyEntries); + foreach (var holeStr in holeNumbers) + { + if (int.TryParse(holeStr.Trim(), out int holeNum)) + { + blockedHoles.Add(holeNum); + } + } + } + + int totalHoles = (int)mnum.Value; + int batchCount = (int)snum.Value; // 閫佹鎵规暟 + + // 璁$畻鎬荤紪鍙锋暟閲忥細寮�绌存�绘暟 脳 閫佹鎵规暟 + int totalIndexes = totalHoles * batchCount; + + for (int i = 1; i <= totalIndexes; i++) + { + // 绌村彿寰幆锛�1-8, 1-8... + int holeNumber = ((i - 1) % totalHoles) + 1; + bool isBlocked = blockedHoles.Contains(holeNumber); + + result.Add(new HoleNumberInfo + { + Index = i, + HoleNumber = holeNumber, + IsBlocked = isBlocked, + RecordValue = isBlocked ? "/" : null, + CheckResult = isBlocked ? "/" : null + }); + } + + // 鎺掑簭锛氬牭绌存帓鏈�鍚庝紭鍏堢骇绗竴锛岀劧鍚庣┐鍙蜂粠灏忓埌澶ф帓锛岀┐鍙风浉鍚岀殑鎺掍竴璧� + result = result.OrderBy(x => x.IsBlocked) // 鍫电┐鎺掓渶鍚庯紙false鍦ㄥ墠锛宼rue鍦ㄥ悗锛� + .ThenBy(x => x.HoleNumber) // 绌村彿浠庡皬鍒板ぇ + .ToList(); + + // 閲嶆柊璁剧疆Index锛屼繚鎸佽繛缁紪鍙� + for (int i = 0; i < result.Count; i++) + { + result[i].Index = i + 1; + } + + return result; + } } \ No newline at end of file -- Gitblit v1.9.3