优化列表接口数据

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

@@ -1,6 +1,7 @@
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMS.Web.Core.Dto;
@@ -59,7 +60,44 @@ namespace WMS.Web.Domain.Services
//返回列表-对应刚刚生成的数据和编号集合
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>
@@ -72,15 +110,43 @@ namespace WMS.Web.Domain.Services
{
var (list, count) = await _boxMarkRepositories.GetPagedList(dto, companyId);
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 (list, count);
return (resultList, count);
}
/// <summary>
@@ -102,5 +168,7 @@ namespace WMS.Web.Domain.Services
boxCount = Convert.ToInt32(Math.Ceiling(boxCount_tag));
return boxCount;
}
}
}