| | |
| | | public (List<SJPageResult> item, int TotalCount) getPage(SJPageResult queryObj) |
| | | { |
| | | var db = SqlSugarHelper.GetInstance(); |
| | | int totalCount = 0; |
| | | |
| | | string[]? lineNo = null; |
| | | |
| | | // if (StringUtil.IsNotNullOrEmpty(queryObj.StatusUser)) |
| | | // lineNo = _baseService.getUserLineNo(queryObj.StatusUser); |
| | | |
| | | var totalCount = 0; |
| | | string searchValue = queryObj.searchValue?.Trim(); |
| | | |
| | | var query = db.Queryable<SJPageResult>(); |
| | | // ========= 构建基础 query ========= |
| | | 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) |
| | | .WhereIF(StringUtil.IsNotNullOrEmpty(queryObj.BillNo), |
| | | a => a.BillNo == queryObj.BillNo) |
| | | // 未完成 |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.Result) && |
| | | "未完成".Equals(queryObj.Result), |
| | | a => a.FSubmit == 0 || a.FSubmit == null) |
| | | // 已完成 |
| | | .WhereIF( |
| | | StringUtil.IsNotNullOrEmpty(queryObj.Result) && |
| | | !"未完成".Equals(queryObj.Result), |
| | | a => a.FSubmit == 1); |
| | | |
| | | // 1️⃣ 如果 SearchValue 为空 → 查询全部 |
| | | // ========= SearchValue 判断 ========= |
| | | |
| | | // SearchValue 为空:返回全部 |
| | | if (string.IsNullOrWhiteSpace(searchValue)) |
| | | { |
| | | var allData = query |
| | |
| | | .ToPageList( |
| | | Math.Max(queryObj.PageIndex, 1), |
| | | Math.Max(queryObj.Limit, 1), |
| | | ref totalCount); |
| | | ref totalCount |
| | | ); |
| | | |
| | | return (allData, totalCount); |
| | | } |
| | | |
| | | // 2️⃣ SearchValue 非空 → 模糊匹配 BILL_NO 或 ITEM_NO |
| | | // SearchValue 不为空:模糊查 BILL_NO / ITEM_NO |
| | | query = query.Where(a => |
| | | SqlFunc.Like(SqlFunc.Trim(a.BillNo).ToLower(), $"%{searchValue.ToLower()}%") || |
| | | SqlFunc.Like(SqlFunc.Trim(a.ItemNo).ToLower(), $"%{searchValue.ToLower()}%") |
| | | ); |
| | | |
| | | // ========= 执行分页 ========= |
| | | var data = query |
| | | .OrderBy(a => a.BillNo, OrderByType.Desc) |
| | | .ToPageList( |
| | | Math.Max(queryObj.PageIndex, 1), |
| | | Math.Max(queryObj.Limit, 1), |
| | | ref totalCount); |
| | | |
| | | // 3️⃣ 如果没有匹配数据 → 返回空列表 |
| | | if (totalCount == 0) |
| | | return (new List<SJPageResult>(), 0); |
| | | ref totalCount |
| | | ); |
| | | |
| | | return (data, totalCount); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | //SetQSItem |
| | | // public List<QsItemIpiItem> SetQSItems(string itemNo) |
| | | // { |