From f2900f2e7a9fef2e536c34e8d8406ac60c0f06ba Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期四, 17 七月 2025 23:36:32 +0800 Subject: [PATCH] 添加首检的查询条件,添加首检,巡检返回总行数 --- StandardInterface/MESApplication/Controllers/QC/SJController.cs | 8 ++-- StandardInterface/MES.Service/service/QC/XJService.cs | 9 +++- StandardInterface/MES.Service/Dto/service/SJPageResult.cs | 8 ++++ StandardInterface/MESApplication/Controllers/QC/XJController.cs | 8 ++-- StandardInterface/MES.Service/service/QC/SJService.cs | 59 ++++++++++++++++++++++++++--- 5 files changed, 74 insertions(+), 18 deletions(-) diff --git a/StandardInterface/MES.Service/Dto/service/SJPageResult.cs b/StandardInterface/MES.Service/Dto/service/SJPageResult.cs index 5aa2d22..f662c90 100644 --- a/StandardInterface/MES.Service/Dto/service/SJPageResult.cs +++ b/StandardInterface/MES.Service/Dto/service/SJPageResult.cs @@ -91,4 +91,12 @@ [SugarColumn(ColumnName = "SJ_MJ")] public string? SJ_MJ { get; set; } + + [SugarColumn(IsIgnore = true)] + // 鏂板鍙傛暟鐢ㄤ簬鍔ㄦ�佹悳绱� + public int? selectedIndex { get; set; } // 鎼滅储鏉′欢绱㈠紩 + [SugarColumn(IsIgnore = true)] + public string? searchField { get; set; } // 鎼滅储瀛楁鍚� + [SugarColumn(IsIgnore = true)] + public string? SearchValue { get; set; } // 鎼滅储鍊� } \ No newline at end of file diff --git a/StandardInterface/MES.Service/service/QC/SJService.cs b/StandardInterface/MES.Service/service/QC/SJService.cs index ed68577..cdd8865 100644 --- a/StandardInterface/MES.Service/service/QC/SJService.cs +++ b/StandardInterface/MES.Service/service/QC/SJService.cs @@ -34,7 +34,7 @@ } //鑾峰彇鎵�鏈夋暟鎹垎椤� - public List<SJPageResult> getPage(SJPageResult queryObj) + public (List<SJPageResult> item, int TotalCount) getPage(SJPageResult queryObj) { var db = SqlSugarHelper.GetInstance(); @@ -43,7 +43,7 @@ if (StringUtil.IsNotNullOrEmpty(queryObj.StatusUser)) lineNo = _baseService.getUserLineNo(queryObj.StatusUser); - var data = db.Queryable<SJPageResult>() + var query = db.Queryable<SJPageResult>() .WhereIF(lineNo != null && lineNo.Length > 0, a => lineNo.Contains(a.line)) .WhereIF(queryObj.Id != null, a => a.Id == queryObj.Id) @@ -56,11 +56,56 @@ .WhereIF( StringUtil.IsNotNullOrEmpty(queryObj.Result) && !"鏈畬鎴�".Equals(queryObj.Result), - a => a.Result != "鏈畬鎴�") - .OrderBy(a => a.BillNo, OrderByType.Desc) - .ToPageList(queryObj.PageIndex, queryObj.Limit); + a => a.Result != "鏈畬鎴�"); - return data; + // 鏂板鐨勫姩鎬佹悳绱㈤�昏緫 + if (!string.IsNullOrEmpty(queryObj.SearchValue) && !string.IsNullOrEmpty(queryObj.searchField)) + { + switch (queryObj.searchField) + { + case "daa001": // 宸ュ崟 + query = query.Where(x => x.daa001.Contains(queryObj.SearchValue)); + break; + case "billNo": // 妫�楠屽崟鍙� + query = query.Where(x => x.BillNo.Contains(queryObj.SearchValue)); + break; + case "line": // 浜х嚎 + query = query.Where(x => x.line.Contains(queryObj.SearchValue)); + break; + case "itemNo": // 鐗╂枡缂栫爜 + query = query.Where(x => x.ItemNo.Contains(queryObj.SearchValue)); + break; + case "daa003": // 鐗╂枡鍚嶇О + query = query.Where(x => x.Daa003.Contains(queryObj.SearchValue)); + break; + default: + // 濡傛灉娌℃湁鎸囧畾瀛楁鎴栧瓧娈典笉鍖归厤锛屼娇鐢ㄥ師鏈夌殑妯$硦鏌ヨ閫昏緫浣滀负鍏滃簳鏂规 + query = query.Where(x => + x.ItemNo.Contains(queryObj.SearchValue) || + x.Daa003.Contains(queryObj.SearchValue) || + x.daa001.Contains(queryObj.SearchValue) || + x.BillNo.Contains(queryObj.SearchValue) || + x.line.Contains(queryObj.SearchValue)); + break; + } + } + // 涓轰簡鍏煎鏃х増鏈紝濡傛灉娌℃湁浼犻�� searchField锛屼娇鐢ㄥ師鏉ョ殑鏌ヨ閫昏緫 + else if (string.IsNullOrEmpty(queryObj.searchField) && !string.IsNullOrEmpty(queryObj.SearchValue)) + { + // 淇濇寔鍘熸湁鐨勫瀛楁妯$硦鏌ヨ閫昏緫 + query = query.Where(x => + x.ItemNo.Contains(queryObj.SearchValue) || + x.Daa003.Contains(queryObj.SearchValue) || + x.daa001.Contains(queryObj.SearchValue) || + x.BillNo.Contains(queryObj.SearchValue) || + x.line.Contains(queryObj.SearchValue)); + } + + var totalCount = 0; + var data = query.OrderBy(a => a.BillNo, OrderByType.Desc) + .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount); + + return (data, totalCount); } @@ -224,7 +269,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).item[0]; return item; } diff --git a/StandardInterface/MES.Service/service/QC/XJService.cs b/StandardInterface/MES.Service/service/QC/XJService.cs index 9e9aa40..b94657d 100644 --- a/StandardInterface/MES.Service/service/QC/XJService.cs +++ b/StandardInterface/MES.Service/service/QC/XJService.cs @@ -106,7 +106,7 @@ }).ToList(); } - public List<QsQaItemXj> getPage(XJPageResult queryObj) + public (List<QsQaItemXj> item, int TotalCount) getPage(XJPageResult queryObj) { var db = SqlSugarHelper.GetInstance(); @@ -117,7 +117,8 @@ if (StringUtil.IsNotNullOrEmpty(queryObj.createUser)) lineNo = _baseService.getUserLineNo(queryObj.createUser); - return db + var totalCount = 0; + var data = db .Queryable<QsQaItemXj, Womdaa, MesLine, MesItems>((s, a, c, b) => new JoinQueryInfos( @@ -153,7 +154,9 @@ FcheckResu = s.FcheckResu, Remarks = s.Remarks }).OrderBy(s => s.CreateDate, OrderByType.Desc) - .ToPageList(queryObj.PageIndex, queryObj.Limit); + .ToPageList(queryObj.PageIndex, queryObj.Limit, ref totalCount); + + return (data, totalCount); } diff --git a/StandardInterface/MESApplication/Controllers/QC/SJController.cs b/StandardInterface/MESApplication/Controllers/QC/SJController.cs index 107d6b9..7ad79b1 100644 --- a/StandardInterface/MESApplication/Controllers/QC/SJController.cs +++ b/StandardInterface/MESApplication/Controllers/QC/SJController.cs @@ -41,14 +41,14 @@ try { dynamic resultInfos = new ExpandoObject(); - var tbBillList = - new SJService().getPage(queryObj); - resultInfos.tbBillList = tbBillList; + var (items, totalCount) = new SJService().getPage(queryObj); + resultInfos.tbBillList = items; return new ResponseResult { status = 0, message = "OK", - data = resultInfos + data = resultInfos, + TotalCount = totalCount }; } catch (Exception ex) diff --git a/StandardInterface/MESApplication/Controllers/QC/XJController.cs b/StandardInterface/MESApplication/Controllers/QC/XJController.cs index ef25d6b..25228a3 100644 --- a/StandardInterface/MESApplication/Controllers/QC/XJController.cs +++ b/StandardInterface/MESApplication/Controllers/QC/XJController.cs @@ -236,14 +236,14 @@ try { dynamic resultInfos = new ExpandoObject(); - var tbBillList = - new XJService().getPage(queryObj); - resultInfos.tbBillList = tbBillList; + var (item, totalCount) = new XJService().getPage(queryObj); + resultInfos.tbBillList = item; return new ResponseResult { status = 0, message = "OK", - data = resultInfos + data = resultInfos, + TotalCount = totalCount }; } catch (Exception ex) -- Gitblit v1.9.3