改了排序
This commit is contained in:
@@ -85,5 +85,8 @@ namespace WMS.Web.Core.Dto.OutStockTask
|
||||
/// 出库单对应箱明细Id
|
||||
/// </summary>
|
||||
public int OutStockBoxDetailsId { get; set; } = 0;
|
||||
|
||||
public int MaterialCount { get; set; } = 0;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ using WMS.Web.Domain.Values.Single;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using NPOI.HSSF.Record.Chart;
|
||||
|
||||
namespace WMS.Web.Domain.Services
|
||||
{
|
||||
@@ -555,6 +556,35 @@ namespace WMS.Web.Domain.Services
|
||||
|
||||
return Result.ReSuccess();
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// 得到物料个数
|
||||
///// </summary>
|
||||
///// <param name="entitys"></param>
|
||||
///// <param name="SuitNumber"></param>
|
||||
//public string GetMaterialCount(List<SerialNumbers> entitys, string SuitNumber)
|
||||
//{
|
||||
// string strReturn = "";
|
||||
// foreach (var item in entitys)
|
||||
// {
|
||||
|
||||
// if (item.SuitNumber == SuitNumber)
|
||||
// {
|
||||
// if (strReturn == "")
|
||||
// {
|
||||
// strReturn = item.SerialNumber;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// strReturn = strReturn + "," + item.SerialNumber;
|
||||
// }
|
||||
|
||||
// }
|
||||
// }
|
||||
// return strReturn;
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取出库任务单详情
|
||||
/// </summary>
|
||||
@@ -670,12 +700,68 @@ namespace WMS.Web.Domain.Services
|
||||
|
||||
//排序和加序号值以下为最先的
|
||||
|
||||
response.Details = response.Details.OrderByDescending(s => s.Specifications)
|
||||
|
||||
var groupedByTwoColumns = response.Details
|
||||
.GroupBy(
|
||||
keySelector: p => new { p.BoxBillNo, p.Specifications } // 复合分组键(匿名类型)
|
||||
// elementSelector: p => new { p.BoxBillNo, p.Specifications,p.Qty } // 可选:指定分组后每组包含的元素(此处只保留Price)
|
||||
)
|
||||
// 对分组结果进行投影,提取关键信息
|
||||
.Select(g => new
|
||||
{
|
||||
BoxBillNo = g.Key.BoxBillNo, // 第一分组列
|
||||
Specifications = g.Key.Specifications, // 第二分组列
|
||||
ProductCount = g.Count() // 每组商品数量
|
||||
});
|
||||
var hunzhuang = groupedByTwoColumns.GroupBy(p => p.BoxBillNo)
|
||||
.Select(group => new
|
||||
{
|
||||
BoxBillNo = group.Key,
|
||||
Count = group.Count()
|
||||
});
|
||||
|
||||
|
||||
foreach (var item in response.Details)
|
||||
{
|
||||
|
||||
var eList = hunzhuang.Where(f => f.BoxBillNo == item.BoxBillNo ).ToList();
|
||||
item.MaterialCount = eList[0].Count;
|
||||
}
|
||||
|
||||
//for (int i = 0; i < response.Details.Count(); i++)
|
||||
//{
|
||||
// var infoDetail = response.Details[i];
|
||||
//}
|
||||
|
||||
|
||||
var detailsA = response.Details.Where(f=>f.MaterialCount==1).OrderByDescending(s => s.Specifications)
|
||||
//.ThenByDescending(s => s.Method)
|
||||
|
||||
//.ThenByDescending(s => s.BoxBillNo).ThenBy(s => s.BoxLength)
|
||||
.ThenByDescending(s => s.Qty).ThenByDescending(s => s.BoxBillNo).ThenByDescending(s => s.Method).ToList();
|
||||
|
||||
//for (int i = 0; i < response.Details.Count(); i++)
|
||||
//{
|
||||
// if (i == 0)
|
||||
// response.Details[0].IndexNumber = 1;
|
||||
// else
|
||||
// {
|
||||
// //和上一个箱子比 如果是相同的箱子序号一样
|
||||
// if (response.Details[i].BoxBillNo == response.Details[i - 1].BoxBillNo && response.Details[i].Method == "按箱" && response.Details[i - 1].Method== "按箱")
|
||||
// response.Details[i].IndexNumber = response.Details[i - 1].IndexNumber;
|
||||
// else
|
||||
// response.Details[i].IndexNumber = response.Details[i - 1].IndexNumber + 1;
|
||||
// }
|
||||
//}
|
||||
|
||||
var detailsB = response.Details.Where(f => f.MaterialCount > 1).OrderByDescending(s => s.Specifications)
|
||||
//.ThenByDescending(s => s.Method)
|
||||
|
||||
//.ThenByDescending(s => s.BoxBillNo).ThenBy(s => s.BoxLength)
|
||||
.ThenByDescending(s => s.Qty).ThenByDescending(s => s.BoxBillNo).ThenByDescending(s => s.Method).ToList();
|
||||
|
||||
detailsA.AddRange(detailsB);
|
||||
response.Details=detailsA;
|
||||
for (int i = 0; i < response.Details.Count(); i++)
|
||||
{
|
||||
if (i == 0)
|
||||
@@ -689,6 +775,10 @@ namespace WMS.Web.Domain.Services
|
||||
response.Details[i].IndexNumber = response.Details[i - 1].IndexNumber + 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//结束最先的
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user