1
This commit is contained in:
@@ -12,6 +12,7 @@ using JNPF.Common.Enums;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.DependencyInjection;
|
||||
using JNPF.DynamicApiController;
|
||||
using JNPF.Systems.Interfaces.System;
|
||||
using JNPF.VisualDev;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using SqlSugar;
|
||||
@@ -46,7 +47,8 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[NonAction]
|
||||
protected async Task DoUpdate(WareHouseUpInput input)
|
||||
{
|
||||
|
||||
@@ -92,7 +92,7 @@ namespace Tnb.WarehouseMgr
|
||||
warehouse_name = c.whname,
|
||||
})
|
||||
.ToListAsync();
|
||||
return items;
|
||||
return items ?? Enumerable.Empty<dynamic>();
|
||||
}
|
||||
/// <summary>
|
||||
/// 库房业务,入库、出库申请新增修改功能
|
||||
@@ -139,27 +139,10 @@ namespace Tnb.WarehouseMgr
|
||||
[HttpGet]
|
||||
public async Task<dynamic?> GetInOutStockCodesById([FromQuery] InOutStockDetailQuery input)
|
||||
{
|
||||
async Task<dynamic?> _fetchInOutStockCodesById<TStockD, TOutput, TStockCode>(string billDId)
|
||||
where TStockD : BaseEntity<string>, new()
|
||||
where TOutput : IInOutStockDetail<TStockCode>, new()
|
||||
where TStockCode : BaseEntity<string>, IInOutStockCode, new()
|
||||
{
|
||||
var dic = await _dictionaryDataService.GetDictionaryByTypeId(WmsWareHouseConst.WMS_INSTOCK_D_BILL_STATUS_TYPEID);
|
||||
var data = await _db.Queryable<TStockD>()
|
||||
.Where(a => a.id == billDId)
|
||||
.Select(a => new TOutput
|
||||
{
|
||||
CodeDetails = SqlFunc.Subqueryable<TStockCode>().Where(it => it.bill_d_id == a.id).ToList(),
|
||||
}, true)
|
||||
.Mapper(it => it.line_status = it.line_status != null && dic.ContainsKey(key: it.line_status) ? dic[it.line_status]?.ToString() : "")
|
||||
.ToListAsync();
|
||||
return data;
|
||||
}
|
||||
|
||||
dynamic? result = input.inoutStockType switch
|
||||
{
|
||||
EnumInOutStockType.In => await _fetchInOutStockCodesById<WmsInstockD, InStockDetailOutput, WmsInstockCode>(input.bill_d_id),
|
||||
EnumInOutStockType.Out => await _fetchInOutStockCodesById<WmsOutstockD, OutStockDetailOutput, WmsOutstockCode>(input.bill_d_id),
|
||||
EnumInOutStockType.In => await FetchInOutStockCodesById<WmsInstockD, InStockDetailOutput, WmsInstockCode>(input.bill_d_id),
|
||||
EnumInOutStockType.Out => await FetchInOutStockCodesById<WmsOutstockD, OutStockDetailOutput, WmsOutstockCode>(input.bill_d_id),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(input.inoutStockType), $"Not expected EnumInOutStockType value: {input.inoutStockType}"),
|
||||
};
|
||||
return result ?? Enumerable.Empty<dynamic>();
|
||||
@@ -737,7 +720,30 @@ namespace Tnb.WarehouseMgr
|
||||
return isOk;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据明细Id获取出入库明细信息
|
||||
/// </summary>
|
||||
/// <typeparam name="TStockD">出入库明细</typeparam>
|
||||
/// <typeparam name="TOutput">明细输出类</typeparam>
|
||||
/// <typeparam name="TStockCode">出入库条码</typeparam>
|
||||
/// <param name="billDId">明细Id</param>
|
||||
/// <returns></returns>
|
||||
private async Task<dynamic?> FetchInOutStockCodesById<TStockD, TOutput, TStockCode>(string billDId)
|
||||
where TStockD : BaseEntity<string>, new()
|
||||
where TOutput : IInOutStockDetail<TStockCode>, new()
|
||||
where TStockCode : BaseEntity<string>, IInOutStockCode, new()
|
||||
{
|
||||
var dic = await _dictionaryDataService.GetDictionaryByTypeId(WmsWareHouseConst.WMS_INSTOCK_D_BILL_STATUS_TYPEID);
|
||||
var data = await _db.Queryable<TStockD>()
|
||||
.Where(a => a.id == billDId)
|
||||
.Select(a => new TOutput
|
||||
{
|
||||
CodeDetails = SqlFunc.Subqueryable<TStockCode>().Where(it => it.bill_d_id == a.id).ToList(),
|
||||
}, true)
|
||||
.Mapper(it => it.line_status = it.line_status != null && dic.ContainsKey(key: it.line_status) ? dic[it.line_status]?.ToString() : "")
|
||||
.ToListAsync();
|
||||
return data;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user