回退保存请求对象优化

This commit is contained in:
tongfei
2023-11-13 16:13:18 +08:00
parent 42f8a6c049
commit 2eb5a89cf6
2 changed files with 19 additions and 13 deletions

View File

@@ -35,6 +35,6 @@ namespace WMS.Web.Core.Dto.BackRecord
/// 序列号集 /// 序列号集
/// </summary> /// </summary>
[Required(ErrorMessage = "序列号不能为空")] [Required(ErrorMessage = "序列号不能为空")]
public string SerialNumbers { get; set; } public List<string> SerialNumbers { get; set; } = new List<string>();
} }
} }

View File

@@ -13,6 +13,7 @@ using WMS.Web.Core.Internal.Results;
using WMS.Web.Domain.Entitys; using WMS.Web.Domain.Entitys;
using WMS.Web.Domain.Infrastructure; using WMS.Web.Domain.Infrastructure;
using WMS.Web.Domain.IService.Public; using WMS.Web.Domain.IService.Public;
using WMS.Web.Domain.Values.Single;
using WMS.Web.Repositories.Configuration; using WMS.Web.Repositories.Configuration;
namespace WMS.Web.Repositories namespace WMS.Web.Repositories
@@ -26,15 +27,20 @@ namespace WMS.Web.Repositories
private readonly IServiceProvider _serviceProvider; private readonly IServiceProvider _serviceProvider;
private readonly ILoginRepositories _loginRepositories; private readonly ILoginRepositories _loginRepositories;
private readonly RepositoryDbContext _context; private readonly RepositoryDbContext _context;
private readonly IErpService _erpService;
private readonly ISingleDataService _singleDataService; private readonly ISingleDataService _singleDataService;
private readonly IErpBasicDataExtendService _erpBasicDataExtendService;
public BackRecordRepositories(RepositoryDbContext context, public BackRecordRepositories(RepositoryDbContext context,
IMapper mapper, IMapper mapper,
IErpService erpService,
ILoginRepositories loginRepositories, ILoginRepositories loginRepositories,
IServiceProvider serviceProvider, IServiceProvider serviceProvider,
ISingleDataService singleDataService) ISingleDataService singleDataService,
IErpBasicDataExtendService erpBasicDataExtendService)
{ {
_erpService = erpService;
_context = context; _context = context;
_mapper = mapper; _mapper = mapper;
_serviceProvider = serviceProvider; _serviceProvider = serviceProvider;
@@ -49,17 +55,17 @@ namespace WMS.Web.Repositories
/// <returns></returns> /// <returns></returns>
public async Task<ResultPagedList<BackRecordQueryResponse>> GetPagedList(BackRecordQueryRequest dto) public async Task<ResultPagedList<BackRecordQueryResponse>> GetPagedList(BackRecordQueryRequest dto)
{ {
//1.获取物料集合和组织集合和供应商的集合
var materials_result = await _erpService.BillQueryForMaterial();
if (!materials_result.IsSuccess)
return ResultPagedList<BackRecordQueryResponse>.ReFailure(materials_result);
var materials = materials_result.Data.ToList();
var query = _context.BackRecordDetails var query = _context.BackRecordDetails
.GroupJoin(_context.BackRecord, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders }) .GroupJoin(_context.BackRecord, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders })
.SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order }) .SelectMany(x => x.orders.DefaultIfEmpty(), (p, order) => new { p.detail, order })
.Where(adv => 1 == 1); .Where(adv => 1 == 1);
//if (!string.IsNullOrEmpty(dto.BoxBillNo))
// query = query.Where(w => EF.Functions.Like(w.order.BoxBillNo, "%" + dto.BoxBillNo + "%"));
//if (!string.IsNullOrEmpty(dto.MaterialNumber))
// query = query.Where(w => EF.Functions.Like(w.detail.BillNo, "%" + dto.BillNo + "%"));
if (dto.SubStockId.HasValue) if (dto.SubStockId.HasValue)
query = query.Where(w => w.detail.SubStockId == dto.SubStockId.Value); query = query.Where(w => w.detail.SubStockId == dto.SubStockId.Value);
@@ -79,11 +85,11 @@ namespace WMS.Web.Repositories
BillNo=s.order.BillNo, BillNo=s.order.BillNo,
BoxBillNo ="", BoxBillNo ="",
Type = s.order.Type.GetRemark(), Type = s.order.Type.GetRemark(),
Creator = "", Creator = _singleDataService.GetSingleData(SingleAction.Staffs, _loginRepositories.CompanyId, s.order.CreatorId),
CreateTime =s.order.CreateTime, CreateTime =s.order.CreateTime,
MaterialName = "", MaterialName = _erpBasicDataExtendService.GetMaterialName(materials, s.detail.MaterialId),
MaterialNumber = "", MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.detail.MaterialId),
Specifications = "", Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.detail.MaterialId),
Qty = s.detail.Qty, Qty = s.detail.Qty,
SubStock = "", SubStock = "",
SerialNumbers = JsonConvert.SerializeObject(s.detail.SerialNumbers), SerialNumbers = JsonConvert.SerializeObject(s.detail.SerialNumbers),