调整根据盘点类型获取任务明细代码

This commit is contained in:
yang.lee
2023-11-13 12:02:52 +08:00
parent 30743623cd
commit 149402ac43

View File

@@ -37,6 +37,8 @@ namespace Tnb.WarehouseMgr
private readonly IVisualDevService _visualDevService; private readonly IVisualDevService _visualDevService;
private readonly IRunService _runService; private readonly IRunService _runService;
private readonly IBillRullService _billRullService; private readonly IBillRullService _billRullService;
private static Dictionary<string, object> _carryMap = new();
public WmsCheckTaskService( public WmsCheckTaskService(
ISqlSugarRepository<WmsCheckstockH> repository, ISqlSugarRepository<WmsCheckstockH> repository,
IWareHouseService wareHouseService, IWareHouseService wareHouseService,
@@ -288,6 +290,11 @@ namespace Tnb.WarehouseMgr
[HttpGet] [HttpGet]
public async Task<dynamic> GetTaskDetailByCheckType([FromQuery] CheckDetailQuery input) public async Task<dynamic> GetTaskDetailByCheckType([FromQuery] CheckDetailQuery input)
{ {
if(_carryMap.Count == 0)
{
_carryMap = await _db.Queryable<WmsCarryH>().ToDictionaryAsync(x => x.id, x => x.carry_code);
}
var filterExpable = Expressionable.Create<BasLocation, WmsCarryCode, WmsCarryH>() var filterExpable = Expressionable.Create<BasLocation, WmsCarryCode, WmsCarryH>()
.And((a, b, c) => a.wh_id == input.warehouse_id) .And((a, b, c) => a.wh_id == input.warehouse_id)
.And((a, b, c) => a.is_type == ((int)EnumLocationType.).ToString()) .And((a, b, c) => a.is_type == ((int)EnumLocationType.).ToString())
@@ -307,17 +314,18 @@ namespace Tnb.WarehouseMgr
.Where(filterExpable.ToExpression()) .Where(filterExpable.ToExpression())
.Select<WmsCarryCode>() .Select<WmsCarryCode>()
.ToListAsync(); .ToListAsync();
var carryIds = carryCodes?.Select(x => x.carry_id) ?? Enumerable.Empty<string>(); //var carryIds = carryCodes?.Select(x => x.carry_id) ?? Enumerable.Empty<string>();
var checkStockDs = await _db.Queryable<WmsCheckstockD>().Where(it => carryIds.Contains(it.carry_id)).ToListAsync(); //var checkStockDs = await _db.Queryable<WmsCheckstockD>().Where(it => carryIds.Contains(it.carry_id)).ToListAsync();
List<CheckTaskDetailOutput> outputs = checkStockDs.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_code }).Select(x => new CheckTaskDetailOutput
List<WmsCheckstockD> outputs = carryCodes.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_id }).Select(x => new WmsCheckstockD
{ {
material_code = x.Key.material_code, material_code = x.Key.material_code,
code_batch = x.Key.code_batch, code_batch = x.Key.code_batch,
location_code = x.Key.location_code, location_code = x.Key.location_code,
carry_code = x.Key.carry_code, carry_code = _carryMap[x.Key.carry_id]?.ToString() ?? string.Empty,
pr_qty = x.Sum(d => d.pr_qty), pr_qty = x.Sum(d => d.pr_qty),
closing_status = WmsWareHouseConst.CLOSINGSTATUS_WJS_ID, closing_status = WmsWareHouseConst.CLOSINGSTATUS_WJS_ID,
qty = x.Sum(d => d.qty), qty = 0,
}) })
.ToList(); .ToList();
return outputs; return outputs;