From 37454e625df68d40897112b2e8c2e3cf4d7163e3 Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期三, 25 三月 2026 11:43:10 +0800
Subject: [PATCH] 1
---
项目代码/WMS无仓储版/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoDetailService.cs | 226 +++++++++++++++++++++++++++++++++++++++-----------------
1 files changed, 158 insertions(+), 68 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 4371f76..2c85ebd 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"
@@ -1,8 +1,13 @@
锘縰sing SqlSugar;
+using WIDESEA_Common.StockEnum;
+using System.Collections.Generic;
using WIDESEA_Core;
using WIDESEA_Core.BaseRepository;
using WIDESEA_Core.BaseServices;
+using WIDESEA_Core.Enums;
+using WIDESEA_Core.Helper;
using WIDESEA_Core.HttpContextUser;
+using WIDESEA_Core.Utilities;
using WIDESEA_DTO.Stock;
using WIDESEA_IStockService;
using WIDESEA_Model.Models;
@@ -31,83 +36,168 @@
public PageGridData<StockInfoDetailWithPalletDto> GetPageData2(PageDataOptions options)
{
- PageGridData<Dt_StockInfoDetail> lists = base.GetPageData (options);
- List<int> stockIds = lists.Rows.Select(detail => detail.StockId).Distinct().ToList();
- var stocks= _stockinfoRepository.QueryData(x => stockIds.Contains(x.Id)).ToList();
-
+ var sugarQueryable = Db.Queryable<Dt_StockInfoDetail>().InnerJoin<Dt_StockInfo>((detail, item) => detail.StockId == item.Id)
+ .Where((detail, item) => item.StockStatus == StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt() || item.StockStatus == StockStatusEmun.鍑哄簱瀹屾垚.ObjToInt());
- List<StockInfoDetailWithPalletDto> dtoList = lists.Rows
- .Select(detail => new StockInfoDetailWithPalletDto
+ Dictionary<string, SqlSugar.OrderByType> orderbyDic = GetPageDataSort(options, TProperties);
+ List<OrderByModel> orderByModels = new List<OrderByModel>();
+ foreach (var item in orderbyDic)
+ {
+ if (item.Key.ToLower() == "id")
{
-
- 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= stocks
- .FirstOrDefault(stock => stock.Id == detail.StockId)?
- .PalletCode ?? "鏃犳墭鐩樼紪鍙�"
- })
- .ToList();
+ OrderByModel orderByModel = new()
+ {
+ FieldName = "detail." + item.Key,
+ OrderByType = item.Value
+ };
+ orderByModels.Add(orderByModel);
+ }
+ else
+ {
+ OrderByModel orderByModel = new()
+ {
+ FieldName = item.Key,
+ OrderByType = item.Value
+ };
+ orderByModels.Add(orderByModel);
+ }
- return new PageGridData<StockInfoDetailWithPalletDto> { Rows = dtoList, Total = lists.Total, Summary = lists.Summary };
+ }
+ int totalCount = 0;
+ List<SearchParameters> searchParametersList = new List<SearchParameters>();
+
+
+ if (!string.IsNullOrEmpty(options.Wheres))
+ {
+ try
+ {
+ searchParametersList = options.Wheres.DeserializeObject<List<SearchParameters>>();
+ if (searchParametersList != null && searchParametersList.Any())
+ {
+ foreach (var param in searchParametersList)
+ {
+ if (param.Name.Equals(nameof(Dt_StockInfo.PalletCode).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase)
+ && !string.IsNullOrEmpty(param.Value?.ToString()))
+ {
+ sugarQueryable = sugarQueryable.Where((detail, item) => item.PalletCode.Contains(param.Value));
+ }
+ if (param.Name.Equals(nameof(Dt_StockInfoDetail.MaterielCode).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase)
+ && !string.IsNullOrEmpty(param.Value?.ToString()))
+ {
+ string queryValue = param.Value.ToString().Trim();
+ sugarQueryable = sugarQueryable.Where((detail, item) => detail.MaterielCode.Contains(queryValue));
+ }
+ if (param.Name.Equals(nameof(Dt_StockInfoDetail.MaterielName).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase)
+ && !string.IsNullOrEmpty(param.Value?.ToString()))
+ {
+ string queryValue = param.Value.ToString().Trim();
+ sugarQueryable = sugarQueryable.Where((detail, item) => detail.MaterielName.Contains(queryValue));
+ }
+ if (param.Name.Equals(nameof(Dt_StockInfoDetail.OrderNo).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase)
+ && !string.IsNullOrEmpty(param.Value?.ToString()))
+ {
+ string queryValue = param.Value.ToString().Trim();
+ sugarQueryable = sugarQueryable.Where((detail, item) => detail.OrderNo.Contains(queryValue));
+ }
+ if (param.Name.Equals(nameof(Dt_StockInfoDetail.BatchNo).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase)
+ && !string.IsNullOrEmpty(param.Value?.ToString()))
+ {
+ string queryValue = param.Value.ToString().Trim();
+ sugarQueryable = sugarQueryable.Where((detail, item) => detail.BatchNo.Contains(queryValue));
+ }
+ if (param.Name.Equals(nameof(Dt_StockInfoDetail.Barcode).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase)
+ && !string.IsNullOrEmpty(param.Value?.ToString()))
+ {
+ string queryValue = param.Value.ToString().Trim();
+ sugarQueryable = sugarQueryable.Where((detail, item) => detail.Barcode.Contains(queryValue));
+ }
+ if (param.Name.Equals(nameof(Dt_StockInfoDetail.MaterielCode).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase)
+ && !string.IsNullOrEmpty(param.Value?.ToString()))
+ {
+ string queryValue = param.Value.ToString().Trim();
+ sugarQueryable = sugarQueryable.Where((detail, item) => detail.MaterielCode.Contains(queryValue));
+ }
+ if (param.Name.Equals(nameof(Dt_StockInfoDetail.Status).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase)
+ && !string.IsNullOrEmpty(param.Value?.ToString()))
+ {
+ string queryValue = param.Value.ToString().Trim();
+ sugarQueryable = sugarQueryable.Where((detail, item) => detail.Status.Equals(queryValue));
+ }
+ if (param.Name.Equals(nameof(Dt_StockInfoDetail.WarehouseCode).FirstLetterToLower(), StringComparison.OrdinalIgnoreCase)
+ && !string.IsNullOrEmpty(param.Value?.ToString()))
+ {
+ string queryValue = param.Value.ToString().Trim();
+ sugarQueryable = sugarQueryable.Where((detail, item) => detail.WarehouseCode.Equals(queryValue));
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+ var data = sugarQueryable
+ .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,
+ LocationCode = item.LocationCode,
+ ValidDate = detail.ValidDate,
+
+
+ })
+ .ToPageList(options.Page, options.Rows, ref totalCount);
+
+
+ return new PageGridData<StockInfoDetailWithPalletDto>(totalCount, data);
+
}
- public PageGridData<StockDetailDtO> GetPageDataByMateriel(PageDataOptions options)
+
+ public async Task<WebResponseContent> LockOrUpLockStockDetail(SaveModel saveModel)
{
- PageGridData<Dt_StockInfoDetail> lists = base.GetPageData(options);
-
- List<StockDetailDtO> dtoList = lists.Rows.GroupBy(detail => new { detail.MaterielCode, detail.BatchNo, detail.SupplyCode }).Select(group =>
+ WebResponseContent content = new WebResponseContent();
+ try
{
- var firstItem = group.First();
- return new StockDetailDtO
- {
- Id = firstItem.Id,
- StockId = firstItem.StockId,
- MaterielCode = group.Key.MaterielCode,
- MaterielName = firstItem.MaterielName,
- OrderNo = firstItem.OrderNo,
- BatchNo = group.Key.BatchNo,
- ProductionDate = firstItem.ProductionDate,
- EffectiveDate = firstItem.EffectiveDate,
- SerialNumber = firstItem.SerialNumber,
- // 鏍稿績锛氬褰撳墠鍒嗙粍鐨凷tockQuantity姹傚拰
- StockQuantity = group.Sum(item => item.StockQuantity),
- OutboundQuantity = firstItem.OutboundQuantity,
- Status = firstItem.Status,
- Unit = firstItem.Unit,
- InboundOrderRowNo = firstItem.InboundOrderRowNo,
- SupplyCode = group.Key.SupplyCode,
- WarehouseCode = firstItem.WarehouseCode,
- Barcode = firstItem.Barcode,
- BusinessType = firstItem.BusinessType,
- Remark = firstItem.Remark
- };
- }).ToList();
-
+ var details = await BaseDal.QueryDataAsync(x => saveModel.DelKeys.Contains(x.Id));
- return new PageGridData<StockDetailDtO> { Rows = dtoList, Total = lists.Total, Summary = lists.Summary };
+ bool flag = Convert.ToBoolean(saveModel.Extra);
+
+ details.ForEach(x => x.Status = flag ? StockStatusEmun.鎵嬪姩鍐荤粨.ObjToInt(): StockStatusEmun.鎵嬪姩瑙i攣.ObjToInt());
+
+ await BaseDal.UpdateDataAsync(details);
+
+ return content.OK(flag ? "鍐荤粨鎴愬姛!" : "瑙i攣鎴愬姛!");
+ }
+ catch (Exception ex)
+ {
+ return content.Error(ex.Message);
+ }
}
}
- }
+}
--
Gitblit v1.9.3