From e4e304318532574e418bc01b5a45b8836dac3e1a Mon Sep 17 00:00:00 2001
From: pan <antony1029@163.com>
Date: 星期四, 11 十二月 2025 23:26:20 +0800
Subject: [PATCH] 提交
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoDetailService.cs | 124 ++++++++++++++++++++++-------------------
1 files changed, 66 insertions(+), 58 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoDetailService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoDetailService.cs"
index 704f65d..6070052 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoDetailService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS\346\227\240\344\273\223\345\202\250\347\211\210/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoDetailService.cs"
@@ -33,16 +33,42 @@
public PageGridData<StockInfoDetailWithPalletDto> GetPageData2(PageDataOptions options)
{
- // 1. 鑾峰彇鍩虹鍒嗛〉鏁版嵁
- PageGridData<Dt_StockInfoDetail> pageData = base.GetPageData(options);
- List<Dt_StockInfoDetail> filteredDetails = pageData.Rows.ToList(); // 鍏堟嫹璐濆師濮嬫暟鎹�
+ string wheres = ValidatePageOptions(options);
+
+ var sugarQueryable = Db.Queryable<Dt_StockInfoDetail>().InnerJoin<Dt_StockInfo>((detail, item) => detail.StockId == item.Id);
+
+ Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
+ List<OrderByModel> orderByModels = new List<OrderByModel>();
+ foreach (var item in orderbyDic)
+ {
+ if (item.Key.ToLower() == "id")
+ {
+ OrderByModel orderByModel = new()
+ {
+ FieldName = "detail."+item.Key,
+ OrderByType = item.Value
+ };
+ }
+ else
+ {
+ OrderByModel orderByModel = new()
+ {
+ FieldName = item.Key,
+ OrderByType = item.Value
+ };
+ }
+ //orderByModels.Add(orderByModel);
+ }
+ int totalCount = 0;
+ List<SearchParameters> searchParametersList = new List<SearchParameters>();
+
if (!string.IsNullOrEmpty(options.Wheres))
{
try
{
- List<SearchParameters> searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
- if (searchParametersList?.Any() == true)
+ searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
+ if (searchParametersList != null && searchParametersList.Any())
{
foreach (var param in searchParametersList)
{
@@ -50,20 +76,7 @@
if (param.Name.Equals(nameof(Dt_StockInfo.PalletCode).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase)
&& !string.IsNullOrEmpty(param.Value?.ToString()))
{
- // 浼樺寲锛氭壒閲忔煡璇紙濡傛灉鏈夊涓墭鐩樼爜锛岃繖閲屼篃鍙互鎵╁睍锛�
- string palletCode = param.Value.ToString().Trim();
- var targetStock = _stockinfoRepository.QueryFirst(x => x.PalletCode == palletCode);
-
- // 绌哄�兼牎楠岋細鏈壘鍒板搴旀墭鐩樼殑搴撳瓨锛岀洿鎺ヨ繃婊や负绌�
- if (targetStock != null)
- {
- filteredDetails = filteredDetails.Where(x => x.StockId == targetStock.Id).ToList();
- }
- else
- {
- filteredDetails = new List<Dt_StockInfoDetail>();
- }
- break; // 鍗曚釜鎵樼洏鐮佹煡璇紝鍖归厤鍚庨��鍑哄惊鐜�
+ sugarQueryable = sugarQueryable.Where((detail, item) => item.PalletCode.Contains(param.Value));
}
}
}
@@ -73,48 +86,43 @@
}
}
- List<int> stockIds = filteredDetails.Select(detail => detail.StockId).Distinct().ToList();
- var stockDict = _stockinfoRepository.QueryData(x => stockIds.Contains(x.Id))
- .ToDictionary(x => x.Id, x => x.PalletCode ?? "鏃犳墭鐩樼紪鍙�");
+ var data = sugarQueryable
+ .WhereIF(!wheres.IsNullOrEmpty(), wheres)
+ .OrderBy(orderByModels)
+ .Select((detail, item) => new StockInfoDetailWithPalletDto
+ {
+ Id = detail.Id,
+ StockId = detail.StockId,
+ MaterielCode = detail.MaterielCode,
+ MaterielName = detail.MaterielName,
+ OrderNo = detail.OrderNo,
+ BatchNo = detail.BatchNo,
+ ProductionDate = detail.ProductionDate,
+ EffectiveDate = detail.EffectiveDate,
+ SerialNumber = detail.SerialNumber,
+ StockQuantity = detail.StockQuantity,
+ OutboundQuantity = detail.OutboundQuantity,
+ Status = detail.Status,
+ Unit = detail.Unit,
+ InboundOrderRowNo = detail.InboundOrderRowNo,
+ SupplyCode = detail.SupplyCode,
+ WarehouseCode = detail.WarehouseCode,
+ Barcode = detail.Barcode,
+ BusinessType = detail.BusinessType,
+ Remark = detail.Remark,
+ Creater = detail.Creater,
+ CreateDate = detail.CreateDate,
+ Modifier = detail.Modifier,
+ ModifyDate = detail.ModifyDate,
+ PalletCode = item.PalletCode
+ })
+ .ToPageList(options.Page, options.Rows, ref totalCount);
- List<StockInfoDetailWithPalletDto> dtoList = filteredDetails
- .Select(detail => new StockInfoDetailWithPalletDto
- {
- Id = detail.Id,
- StockId = detail.StockId,
- MaterielCode = detail.MaterielCode,
- MaterielName = detail.MaterielName,
- OrderNo = detail.OrderNo,
- BatchNo = detail.BatchNo,
- ProductionDate = detail.ProductionDate,
- EffectiveDate = detail.EffectiveDate,
- SerialNumber = detail.SerialNumber,
- StockQuantity = detail.StockQuantity,
- OutboundQuantity = detail.OutboundQuantity,
- Status = detail.Status,
- Unit = detail.Unit,
- InboundOrderRowNo = detail.InboundOrderRowNo,
- SupplyCode = detail.SupplyCode,
- WarehouseCode = detail.WarehouseCode,
- Barcode = detail.Barcode,
- BusinessType = detail.BusinessType,
- Remark = detail.Remark,
- Creater = detail.Creater,
- CreateDate = detail.CreateDate,
- Modifier = detail.Modifier,
- ModifyDate = detail.ModifyDate,
- PalletCode = stockDict.TryGetValue(detail.StockId, out var palletCode) ? palletCode : "鏃犳墭鐩樼紪鍙�"
- })
- .ToList();
- return new PageGridData<StockInfoDetailWithPalletDto>
- {
- Rows = dtoList.Where(x=>x.PalletCode != "鏃犳墭鐩樼紪鍙�").ToList(),
- Total = pageData.Total,
- Summary = pageData.Summary
- };
+ return new PageGridData<StockInfoDetailWithPalletDto>(totalCount, data);
+
}
}
- }
+}
--
Gitblit v1.9.3