优化列表接口数据

This commit is contained in:
tongfei
2024-02-20 11:03:38 +08:00
parent 6e5f39c120
commit 12e2ca1070
4 changed files with 86 additions and 4 deletions

View File

@@ -450,6 +450,11 @@
产品数量 产品数量
</summary> </summary>
</member> </member>
<member name="P:WMS.Web.Core.Dto.BoxMarkQueryResponse.Sort">
<summary>
排序
</summary>
</member>
<member name="T:WMS.Web.Core.Dto.GenerateBoxMarkDto"> <member name="T:WMS.Web.Core.Dto.GenerateBoxMarkDto">
<summary> <summary>
生成箱唛dto 生成箱唛dto

View File

@@ -107,5 +107,10 @@ namespace WMS.Web.Core.Dto
/// 产品数量 /// 产品数量
/// </summary> /// </summary>
public decimal ProductQty { get; set; } public decimal ProductQty { get; set; }
/// <summary>
/// 排序
/// </summary>
public int Sort { get; set; }
} }
} }

View File

@@ -1,6 +1,7 @@
using AutoMapper; using AutoMapper;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using WMS.Web.Core.Dto; using WMS.Web.Core.Dto;
@@ -59,7 +60,44 @@ namespace WMS.Web.Domain.Services
//返回列表-对应刚刚生成的数据和编号集合 //返回列表-对应刚刚生成的数据和编号集合
var list= await _boxMarkRepositories.GetListInfoBy(model.Id, loginInfo.UserInfo.CompanyId); var list= await _boxMarkRepositories.GetListInfoBy(model.Id, loginInfo.UserInfo.CompanyId);
return ResultList<BoxMarkQueryResponse>.ReSuccess(list);
//处理-批次生成的排序和总数量
var resultList = new List<BoxMarkQueryResponse>();
if (list != null && list.Count != 0)
{
list.ForEach(x =>
{
x.BoxSortCount = this.GetSortCount(x.ProductQty, x.CratingQty);
});
var ids = list.GroupBy(x => x.Id).Select(x => x.Key).ToList();
foreach (var id in ids)
{
var itemDetailId = 0;
foreach (var item in list)
{
if (id == item.Id)
{
var current = resultList.Where(x => x.DetailId == itemDetailId).FirstOrDefault();
var newItem = item;
if (current == null)
newItem.Sort = 1;
else
newItem.Sort = current.Sort + 1;
resultList.Add(newItem);
itemDetailId = item.DetailId;
}
}
}
}
return ResultList<BoxMarkQueryResponse>.ReSuccess(resultList);
} }
/// <summary> /// <summary>
@@ -72,15 +110,43 @@ namespace WMS.Web.Domain.Services
{ {
var (list, count) = await _boxMarkRepositories.GetPagedList(dto, companyId); var (list, count) = await _boxMarkRepositories.GetPagedList(dto, companyId);
var resultList = new List<BoxMarkQueryResponse>();
if (list != null && list.Count != 0) if (list != null && list.Count != 0)
{ {
list.ForEach(x => list.ForEach(x =>
{ {
x.BoxSortCount = this.GetSortCount(x.ProductQty, x.CratingQty); x.BoxSortCount = this.GetSortCount(x.ProductQty, x.CratingQty);
}); });
var ids = list.GroupBy(x => x.Id).Select(x => x.Key).ToList();
foreach (var id in ids)
{
var itemDetailId = 0;
foreach (var item in list)
{
if (id == item.Id)
{
var current= resultList.Where(x => x.DetailId == itemDetailId).FirstOrDefault();
var newItem = item;
if (current == null)
newItem.Sort =1;
else
newItem.Sort = current.Sort+ 1;
resultList.Add(newItem);
itemDetailId = item.DetailId;
}
}
} }
return (list, count);
}
return (resultList, count);
} }
/// <summary> /// <summary>
@@ -102,5 +168,7 @@ namespace WMS.Web.Domain.Services
boxCount = Convert.ToInt32(Math.Ceiling(boxCount_tag)); boxCount = Convert.ToInt32(Math.Ceiling(boxCount_tag));
return boxCount; return boxCount;
} }
} }
} }

View File

@@ -218,6 +218,7 @@ namespace WMS.Web.Repositories
var query = _context.BoxMarkBillNo var query = _context.BoxMarkBillNo
.GroupJoin(_context.BoxMark, detail => detail.Fid, order => order.Id, (detail, orders) => new { detail, orders }) .GroupJoin(_context.BoxMark, 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 })
.OrderByDescending(x => x.detail.Id).ThenByDescending(x => x.detail.FirstBillNo).ThenByDescending(x => x.detail.LastBillNo)
.Where(adv => adv.order.Id == id); .Where(adv => adv.order.Id == id);
var list = await query.Select(s => new BoxMarkQueryResponse() var list = await query.Select(s => new BoxMarkQueryResponse()
{ {
@@ -229,17 +230,20 @@ namespace WMS.Web.Repositories
MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.order.MaterialId), MaterialNumber = _erpBasicDataExtendService.GetMaterialNumber(materials, s.order.MaterialId),
Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.order.MaterialId), Specifications = _erpBasicDataExtendService.GetMaterialSpecifications(materials, s.order.MaterialId),
BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.order.MaterialId), BarCode = _erpBasicDataExtendService.GetMaterialBarCode(materials, s.order.MaterialId),
CratingQty = s.order.CratingQty, CratingQty = s.order.CratingQty,
CratingNetWeightQty = s.order.CratingNetWeightQty, CratingNetWeightQty = s.order.CratingNetWeightQty,
CratingGrossWeightQty = s.order.CratingGrossWeightQty, CratingGrossWeightQty = s.order.CratingGrossWeightQty,
TailboxQty = s.order.TailboxQty, TailboxQty = s.order.TailboxQty,
TailboxNetWeightQty = s.order.TailboxNetWeightQty, TailboxNetWeightQty = s.order.TailboxNetWeightQty,
TailboxGrossWeightQty = s.order.TailboxGrossWeightQty, TailboxGrossWeightQty = s.order.TailboxGrossWeightQty,
IsTail = s.detail.IsTail, IsTail = s.detail.IsTail,
Creator = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, s.order.CreatorId), Creator = _singleDataService.GetSingleData(SingleAction.Staffs, companyId, s.order.CreatorId),
CreateTime = s.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"), CreateTime = s.order.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
Remark = s.order.Remark Remark = s.order.Remark,
}).OrderByDescending(x => x.DetailId).ToListAsync(); ProductQty = s.order.ProductQty,
}).ToListAsync();
return list; return list;
} }