下升降机扫码优化 八工位入库优化 库存报表

This commit is contained in:
2024-08-09 14:08:14 +08:00
parent e95000f004
commit 00f01db950
7 changed files with 286 additions and 146 deletions

View File

@@ -946,6 +946,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
{
var strs = dic.Where(p => p.Key == key).First().Value;
JObject reObj = await GetObjectTag(key, strs[0]);
if (reObj == null)
continue;
@@ -981,9 +982,9 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
result = "LX" + result.Replace("\r", "");
}
if (timestamp_judgeCode > timestamp_code)
if (timestamp_judgeCode < timestamp_code)
{
LoggerSSX.LogInformation($"【定时任务SSXcode】下升降机入中储仓 判定料箱{result}的条码判断请求信号时间{timestamp_judgeCode.ToString("yyyy-MM-dd HH:mm:ss")} 于条码更新的时间{timestamp_code.ToString("yyyy-MM-dd HH:mm:ss")},将跳过此次执行");
LoggerSSX.LogInformation($"【定时任务SSXcode】下升降机入中储仓 判定料箱{result}的条码判断请求信号时间{timestamp_judgeCode.ToString("yyyy-MM-dd HH:mm:ss")} 于条码更新的时间{timestamp_code.ToString("yyyy-MM-dd HH:mm:ss")},将跳过此次执行");
continue;
}
@@ -2579,41 +2580,41 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA
public Task StartAsync(CancellationToken cancellationToken)
{
//CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
//Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
SSXcodetimer = new Timer(SSXcode, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
//// 八工位缓存区补充空托盘
//BGWCarrySupplementtimer = new Timer(BGWCarrySupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
CheckGettimer = new Timer(CheckGet, null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
Scantimer = new Timer(ScanInStock, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
SSXcodetimer = new Timer(SSXcode, null, TimeSpan.Zero, TimeSpan.FromSeconds(5));
// 八工位缓存区补充空托盘
BGWCarrySupplementtimer = new Timer(BGWCarrySupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
//// 供料叠盘机空托盘自动入库
//YCLGLDPJInstocktimer = new Timer(YCLGLDPJInstock, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(30));
// 供料叠盘机空托盘自动入库
YCLGLDPJInstocktimer = new Timer(YCLGLDPJInstock, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(30));
//// 外协叠盘机空托盘自动入库
//YCLWXDPJInstocktimer = new Timer(YCLWXDPJInstock, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(30));
// 外协叠盘机空托盘自动入库
YCLWXDPJInstocktimer = new Timer(YCLWXDPJInstock, null, TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(30));
//// 二楼上升降机
//Floor2UpMachinecodetimer = new Timer(Floor2UpMachinecode, null, TimeSpan.Zero, TimeSpan.FromSeconds(20));
// 二楼上升降机
Floor2UpMachinecodetimer = new Timer(Floor2UpMachinecode, null, TimeSpan.Zero, TimeSpan.FromSeconds(20));
//// 二楼料架配送
//Floor2timer送空托到上升降区 = new Timer(送空托到上升降区, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
//Floor2timer送满托到下升降区 = new Timer(送满托到下升降区, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(30));
//Floor2timer移走上升降区未生成预任务且满托的料架 = new Timer(移走上升降区未生成预任务且满托的料架, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
//Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(移走下升降区未生成预任务且空托的料架, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(30));
// 二楼料架配送
Floor2timer送空托到上升降区 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
Floor2timer送满托到下升降区 = new Timer(, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(30));
Floor2timer移走上升降区未生成预任务且满托的料架 = new Timer(, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
Floor2timer移走下升降区未生成预任务且空托的料架 = new Timer(, null, TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(30));
//GenTaskExecutetimer = new Timer(GenTaskExecute, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
GenTaskExecutetimer = new Timer(GenTaskExecute, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
//// 停用
////PackOutstockServicetimer = new Timer(PackOutstockService, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
// 停用
//PackOutstockServicetimer = new Timer(PackOutstockService, null, TimeSpan.Zero, TimeSpan.FromSeconds(60));
//ElevatorTaskExceptionHandleThread = new Thread(ElevatorTaskExceptionHandle);
//ElevatorTaskExceptionHandleThread.Start();
ElevatorTaskExceptionHandleThread = new Thread(ElevatorTaskExceptionHandle);
ElevatorTaskExceptionHandleThread.Start();
//Floor4DMJ2MJXtimer = new Timer(Floor4DMJ2MJX, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
//Floor4MJX2MJCtimer = new Timer(Floor4MJX2MJC, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
//Floor4DMC2CPKtimer = new Timer(Floor4DMC2CPK, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
Floor4DMJ2MJXtimer = new Timer(Floor4DMJ2MJX, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
Floor4MJX2MJCtimer = new Timer(Floor4MJX2MJC, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
Floor4DMC2CPKtimer = new Timer(Floor4DMC2CPK, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
//F2KTPsupplementtimer = new Timer(F2KTPsupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
//YCLInternalTransfertimer = new Timer(YCLInternalTransfer, null, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(185));
F2KTPsupplementtimer = new Timer(F2KTPsupplement, null, TimeSpan.Zero, TimeSpan.FromSeconds(30));
YCLInternalTransfertimer = new Timer(YCLInternalTransfer, null, TimeSpan.FromSeconds(15), TimeSpan.FromSeconds(185));
return Task.CompletedTask;
}

View File

@@ -19,15 +19,15 @@ public partial class WmsStockReportCode : BaseEntity<string>
/// </summary>
public string? report_id { get; set; }
/// <summary>
/// 载具ID
/// </summary>
public string? carry_id { get; set; }
///// <summary>
///// 载具ID
///// </summary>
//public string? carry_id { get; set; }
/// <summary>
/// 载具编号
/// </summary>
public string? carry_code { get; set; }
///// <summary>
///// 载具编号
///// </summary>
//public string? carry_code { get; set; }
/// <summary>
/// 物料ID
@@ -52,7 +52,7 @@ public partial class WmsStockReportCode : BaseEntity<string>
/// <summary>
/// 条码数量
/// </summary>
public decimal? codeqty { get; set; }
public decimal codeqty { get; set; }
/// <summary>
/// 单位ID
@@ -84,4 +84,36 @@ public partial class WmsStockReportCode : BaseEntity<string>
/// </summary>
public DateTime? time_stamp { get; set; }
/// <summary>
/// 规格型号
/// </summary>
public string? material_specification { get; set; }
/// <summary>
/// 箱号
/// </summary>
public string? container_no { get; set; }
/// <summary>
/// 供应商编码
/// </summary>
public string? supplier_code { get; set; }
/// <summary>
/// 供应商名称
/// </summary>
public string? supplier_name { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
public string? warehouse_id { get; set; }
/// <summary>
/// 仓库编码
/// </summary>
public string? warehouse_code { get; set; }
/// <summary>
/// 仓库名称
/// </summary>
public string? warehouse_name { get; set; }
}

View File

@@ -29,45 +29,86 @@ public partial class WmsStockReportH : BaseEntity<string>
/// </summary>
public string? material_code { get; set; }
/// <summary>
/// 规格型号
/// </summary>
public string? material_specification { get; set; }
/// <summary>
/// 箱号
/// </summary>
public string? container_no { get; set; }
/// <summary>
/// 供应商编码
/// </summary>
public string? supplier_code { get; set; }
/// <summary>
/// 供应商名称
/// </summary>
public string? supplier_name { get; set; }
/// <summary>
/// 仓库ID
/// </summary>
public string? warehouse_id { get; set; }
/// <summary>
/// 现有库存
/// 仓库编码
/// </summary>
public decimal? existing_stock_qty { get; set; }
public string? warehouse_code { get; set; }
/// <summary>
/// 最大库存
/// 仓库名称
/// </summary>
public int? max_stock { get; set; }
public string? warehouse_name { get; set; }
/// <summary>
/// 安全库存
/// 单位ID
/// </summary>
public int? safe_stock { get; set; }
public string unit_id { get; set; } = string.Empty;
/// <summary>
/// 最小库存
/// 单位代码
/// </summary>
public int? min_stock { get; set; }
public string unit_code { get; set; } = string.Empty;
/// <summary>
/// 库存有效期(天)
/// 批次
/// </summary>
public int? storage_valid_day { get; set; }
public string code_batch { get; set; } = string.Empty;
/// <summary>
/// 预警提前期(天)
/// </summary>
public int? early_warn_day { get; set; }
///// <summary>
///// 现有库存
///// </summary>
//public decimal? existing_stock_qty { get; set; }
/// <summary>
/// 过期预警数量
/// </summary>
public decimal? expired_warning_qty { get; set; }
///// <summary>
///// 最大库存
///// </summary>
//public int? max_stock { get; set; }
///// <summary>
///// 安全库存
///// </summary>
//public int? safe_stock { get; set; }
///// <summary>
///// 最小库存
///// </summary>
//public int? min_stock { get; set; }
///// <summary>
///// 库存有效期(天)
///// </summary>
//public int? storage_valid_day { get; set; }
///// <summary>
///// 预警提前期(天)
///// </summary>
//public int? early_warn_day { get; set; }
///// <summary>
///// 过期预警数量
///// </summary>
//public decimal? expired_warning_qty { get; set; }
/// <summary>
/// 创建用户
@@ -79,35 +120,35 @@ public partial class WmsStockReportH : BaseEntity<string>
/// </summary>
public DateTime? create_time { get; set; }
/// <summary>
/// 修改用户
/// </summary>
public string? modify_id { get; set; }
///// <summary>
///// 修改用户
///// </summary>
//public string? modify_id { get; set; }
/// <summary>
/// 修改时间
/// </summary>
public DateTime? modify_time { get; set; }
///// <summary>
///// 修改时间
///// </summary>
//public DateTime? modify_time { get; set; }
/// <summary>
/// 扩展
/// </summary>
public string? extras { get; set; }
///// <summary>
///// 扩展
///// </summary>
//public string? extras { get; set; }
/// <summary>
/// 时间戳
/// </summary>
public DateTime? timestamp { get; set; }
///// <summary>
///// 时间戳
///// </summary>
//public DateTime? timestamp { get; set; }
/// <summary>
/// 流程任务Id
/// </summary>
public string? f_flowtaskid { get; set; }
///// <summary>
///// 流程任务Id
///// </summary>
//public string? f_flowtaskid { get; set; }
/// <summary>
/// 流程引擎Id
/// </summary>
public string? f_flowid { get; set; }
///// <summary>
///// 流程引擎Id
///// </summary>
//public string? f_flowid { get; set; }
}

View File

@@ -11,13 +11,13 @@ public partial class WmsStockReportH
/// 物料名称
/// </summary>
[SugarColumn(IsIgnore = true)]
public string mater_name { get; set; }
/// <summary>
/// 明细列表
/// </summary>
[SugarColumn(IsIgnore = true)]
public List<WmsStockReportCode> Details { get; set; }
[SugarColumn(IsIgnore = true)]
public string material_name { get; set; }
///// <summary>
///// 明细列表
///// </summary>
//[SugarColumn(IsIgnore = true)]
//public List<WmsStockReportCode> Details { get; set; }
//[SugarColumn(IsIgnore = true)]
public decimal codeqty { get; set; }
}

View File

@@ -16,6 +16,7 @@ using Newtonsoft.Json;
using Npgsql;
using Senparc.Weixin.MP.AdvancedAPIs.Card;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto;
@@ -145,7 +146,6 @@ namespace Tnb.WarehouseMgr
[HttpPost]
public async Task<dynamic> GetInfoByCode(string code)
{
var data = await _db.Queryable<WmsTempCode>().Where(p => p.barcode == code).FirstAsync();
if (data == null)
throw new AppFriendlyException("没有条码信息", 500);
@@ -169,6 +169,11 @@ namespace Tnb.WarehouseMgr
{
throw new Exception($"托盘{input.carrycode}不存在!");
}
BasLocation carrryLoc = await _db.Queryable<BasLocation>().Where(r => r.id == carry.location_id).FirstAsync();
if (carrryLoc != null && carrryLoc.is_type == "0")
{
throw new Exception($"托盘{carry.carry_code}在存储库位中,不能绑定!");
}
var _WmsCarryCode = _db.Queryable<WmsCarryCode>().Where(it => it.carry_id == carry.id).OrderByDescending(it => it.id).First();
if (_WmsCarryCode != null)
@@ -230,7 +235,13 @@ namespace Tnb.WarehouseMgr
db = dbConn;
try
{
WmsCarryH? carry = await db.Queryable<WmsCarryH>().SingleAsync(it => it.carry_code == input.carrycode);
if (carry == null)
{
throw new Exception($"托盘{carry.carry_code}不存在!");
}
List<WmsCarryCode> WmsCarryCodes = new List<WmsCarryCode>();
foreach (var detail in input.details)
{

View File

@@ -71,7 +71,7 @@ namespace Tnb.WarehouseMgr
carry_type = d.carrystd_name,
location_code = a.location_code,
location_name = a.location_name,
location_status = b.is_lock == 1 ? "锁定" : "未锁定",
location_status = a.is_lock == 1 ? "锁定" : "未锁定",
instock_time = b.instock_time != null ? b.instock_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
barcode = e.barcode,
code_batch = e.code_batch,
@@ -111,7 +111,7 @@ namespace Tnb.WarehouseMgr
carry_type = d.carrystd_name,
location_code = a.location_code,
location_name = a.location_name,
location_status = b.is_lock == 1 ? "锁定" : "未锁定",
location_status = a.is_lock == 1 ? "锁定" : "未锁定",
instock_time = b.instock_time != null ? b.instock_time.Value.ToString("yyyy-MM-dd HH:mm:ss") : "",
barcode = f.barcode,
code_batch = f.code_batch,

View File

@@ -5,10 +5,12 @@ using JNPF.Common.Security;
using JNPF.VisualDev;
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Enums;
namespace Tnb.WarehouseMgr
@@ -26,72 +28,125 @@ namespace Tnb.WarehouseMgr
{
_db = repository.AsSugarClient();
_userManager = userManager;
OverideFuncs.GetListAsync = GetListAsync;
}
private async Task<dynamic> GetListAsync(VisualDevModelListQueryInput input)
[HttpPost]
public async Task<dynamic> MaterialStock(VisualDevModelListQueryInput input)
{
var materialCode = "";
var supplier_code = "";
var code_batch = "";
var material_specification = "";
if (!input.queryJson.IsNullOrWhiteSpace())
{
materialCode = JObject.Parse(input.queryJson).Value<string>(nameof(WmsCarryCode.material_code));
supplier_code = JObject.Parse(input.queryJson).Value<string>("supplier_code");
code_batch = JObject.Parse(input.queryJson).Value<string>(nameof(WmsCarryCode.code_batch));
material_specification = JObject.Parse(input.queryJson).Value<string>(nameof(WmsCarryCode.material_specification));
}
List<WmsStockReportH> items = await _db.Queryable<WmsCarryCode>().InnerJoin<BasMaterial>((a, b) => a.material_id == b.id)
.InnerJoin<BasMaterialSendWarehouse>((a, b, c) => b.id == c.material_id)
.InnerJoin<WmsCarryH>((a, b, c, d) => a.carry_id == d.id)
.InnerJoin<BasLocation>((a, b, c, d, e) => d.location_id == e.id)
.Where((a, b, c, d, e) => e.is_type == ((int)EnumLocationType.).ToString())
.WhereIF(!string.IsNullOrEmpty(materialCode), (a, b, c, d, e) => a.material_code.Contains(materialCode))
.Select((a, b, c, d, e) => new WmsStockReportH
{
warehouse_id = a.warehouse_id,
mater_name = b.name,
create_time = a.create_time,
create_id = a.create_id,
}, true)
.ToListAsync();
List<WmsCarryCode> carryCodes = await _db.Queryable<WmsCarryCode>().ToListAsync();
var storeMap = items.DistinctBy(x => new { x.warehouse_id, x.material_id }).ToDictionary(x => new { x.warehouse_id, x.material_id }, x => x);
IEnumerable<WmsStockReportH> result = items.GroupBy(g => new { g.warehouse_id, g.material_id }).Select(itGroup =>
IEnumerable<WmsStockReportH?> result;
if (string.IsNullOrEmpty(supplier_code))
{
_ = storeMap.TryGetValue(itGroup.Key, out WmsStockReportH? report);
WmsStockReportH stockReport = new()
List<WmsStockReportH> items = await _db.Queryable<WmsCarryCode>().InnerJoin<WmsCarryH>((a, b) => a.carry_id == b.id)
.InnerJoin<BasLocation>((a, b, c) => b.location_id == c.id).InnerJoin<BasWarehouse>((a, b, c, d) => c.wh_id == d.id)
.InnerJoin<WmsTempCode>((a, b, c, d, e) => e.barcode == a.barcode)
.InnerJoin<BasMaterial>((a, b, c, d, e, f) => f.id == e.material_id)
.LeftJoin<WmsPurchaseD>((a, b, c, d, e, f, g) => e.require_id == g.id)
.LeftJoin<WmsPurchaseH>((a, b, c, d, e, f, g, h) => h.id == g.bill_id)
.WhereIF(!string.IsNullOrEmpty(material_specification), (a, b, c, d, e, f) => f.material_specification.Contains(material_specification))
.WhereIF(!string.IsNullOrEmpty(code_batch), (a, b, c, d, e, f) => a.code_batch.Contains(code_batch))
.Select((a, b, c, d, e, f, g, h) => new WmsStockReportH
{
material_code = report?.material_code ?? "",
mater_name = report?.mater_name ?? "",
existing_stock_qty = itGroup.Sum(d => d.codeqty),
max_stock = report?.max_stock ?? 0,
safe_stock = report?.safe_stock ?? 0,
min_stock = report?.min_stock ?? 0,
storage_valid_day = items.Find(t => t.material_id == itGroup.Key.material_id)?.storage_valid_day,
early_warn_day = items.Find(t => t.material_id == itGroup.Key.material_id)?.early_warn_day,
create_id = _userManager.UserId,
create_time = DateTime.Now
};
if (stockReport.storage_valid_day.HasValue)
{
decimal expired_warning_qty = 0;
foreach (WmsStockReportH? item in itGroup)
{
if (DateTime.Now.Subtract(item.create_time.Value).TotalDays >= (item.storage_valid_day - item.early_warn_day))
{
expired_warning_qty += item.codeqty;
}
}
stockReport.expired_warning_qty = expired_warning_qty;
}
List<WmsCarryCode> curCarryCodes = carryCodes.FindAll(x => x.warehouse_id == itGroup.Key.warehouse_id && x.material_id == itGroup.Key.material_id);
stockReport.Details = curCarryCodes.Adapt<List<WmsStockReportCode>>();
stockReport.Details.ForEach(x =>
{
x.id = SnowflakeIdHelper.NextId();
x.report_id = stockReport.id;
});
return stockReport;
});
org_id = e.org_id,
warehouse_id = a.warehouse_id,
warehouse_code = d.whcode,
warehouse_name = d.whname,
material_name = f.name,
material_specification = f.material_specification,
container_no = f.container_no,
create_time = a.create_time,
create_id = a.create_id,
code_batch = a.code_batch,
supplier_code = "",
supplier_name = "",
}, true).ToListAsync();
List<WmsCarryCode> carryCodes = await _db.Queryable<WmsCarryCode>().ToListAsync();
var storeMap = items.DistinctBy(x => new { x.warehouse_id, x.material_id, x.code_batch }).ToDictionary(x => new { x.warehouse_id, x.material_id, x.code_batch }, x => x);
result = items.GroupBy(g => new { g.warehouse_id, g.material_id, g.code_batch }).Select(itGroup =>
{
_ = storeMap.TryGetValue(itGroup.Key, out WmsStockReportH? stockReport);
List<WmsCarryCode> curCarryCodes = carryCodes.FindAll(x => x.warehouse_id == itGroup.Key.warehouse_id && x.material_id == itGroup.Key.material_id
&& x.code_batch == itGroup.Key.code_batch);
curCarryCodes.ForEach(x =>
{
stockReport.codeqty += x.codeqty;
});
//stockReport.Details = curCarryCodes.Adapt<List<WmsStockReportCode>>();
//stockReport.codeqty = 0;
//stockReport.Details.ForEach(x =>
//{
// x.id = SnowflakeIdHelper.NextId();
// x.report_id = stockReport.id;
// x.warehouse_id = stockReport.warehouse_id;
// x.warehouse_code = stockReport.warehouse_code;
// x.warehouse_name = stockReport.warehouse_name;
// x.material_specification = stockReport.material_specification;
// x.container_no = stockReport.container_no;
// stockReport.codeqty += x.codeqty;
//});
return stockReport;
});
}
else
{
List<WmsStockReportH> items = await _db.Queryable<WmsCarryCode>().InnerJoin<WmsCarryH>((a, b) => a.carry_id == b.id)
.InnerJoin<BasLocation>((a, b, c) => b.location_id == c.id).InnerJoin<BasWarehouse>((a, b, c, d) => c.wh_id == d.id)
.InnerJoin<WmsTempCode>((a, b, c, d, e) => e.barcode == a.barcode)
.InnerJoin<BasMaterial>((a, b, c, d, e, f) => f.id == e.material_id)
.LeftJoin<WmsPurchaseD>((a, b, c, d, e, f, g) => e.require_id == g.id)
.LeftJoin<WmsPurchaseH>((a, b, c, d, e, f, g, h) => h.id == g.bill_id)
.WhereIF(!string.IsNullOrEmpty(material_specification), (a, b, c, d, e, f) => f.material_specification.Contains(material_specification))
.WhereIF(!string.IsNullOrEmpty(code_batch), (a, b, c, d, e, f) => a.code_batch.Contains(code_batch))
.WhereIF(!string.IsNullOrEmpty(supplier_code), (a, b, c, d, e, f, g, h) => h.supplier_code.Contains(supplier_code))
.Select((a, b, c, d, e, f, g, h) => new WmsStockReportH
{
org_id = e.org_id,
warehouse_id = a.warehouse_id,
warehouse_code = d.whcode,
warehouse_name = d.whname,
material_name = f.name,
material_specification = f.material_specification,
container_no = f.container_no,
create_time = a.create_time,
create_id = a.create_id,
code_batch = a.code_batch,
supplier_code = h.supplier_code,
supplier_name = h.supplier_name,
}, true).ToListAsync();
List<WmsCarryCode> carryCodes = await _db.Queryable<WmsCarryCode>().ToListAsync();
var storeMap = items.DistinctBy(x => new { x.warehouse_id, x.material_id, x.code_batch, x.supplier_code }).ToDictionary(x => new { x.warehouse_id, x.material_id, x.code_batch, x.supplier_code }, x => x);
result = items.GroupBy(g => new { g.warehouse_id, g.material_id, g.code_batch, g.supplier_code }).Select(itGroup =>
{
_ = storeMap.TryGetValue(itGroup.Key, out WmsStockReportH? stockReport);
List<WmsStockReportCode> curCarryCodes = carryCodes.Adapt<List<WmsStockReportCode>>().FindAll(x => x.warehouse_id == itGroup.Key.warehouse_id && x.material_id == itGroup.Key.material_id
&& x.code_batch == itGroup.Key.code_batch && x.supplier_code == itGroup.Key.supplier_code);
curCarryCodes.ForEach(x =>
{
stockReport.codeqty += x.codeqty;
});
return stockReport;
});
}
List<WmsStockReportH> pages = result.Skip((input.currentPage - 1) * input.pageSize).Take(input.pageSize).ToList();
SqlSugarPagedList<WmsStockReportH> pagedList = new()