优化根据明细ID获取出入库明细代码
This commit is contained in:
@@ -9,7 +9,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto
|
||||
/// <summary>
|
||||
/// 入库单据物料明细信息
|
||||
/// </summary>
|
||||
public class InStockDetailOutput
|
||||
public class InStockDetailOutput : IInOutStockDetail<WmsInstockCode>
|
||||
{
|
||||
/// <summary>
|
||||
/// 入库单明细Id
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Tnb.WarehouseMgr.Entities.Dto
|
||||
/// <summary>
|
||||
/// 出库库单据物料明细信息
|
||||
/// </summary>
|
||||
public class OutStockDetailOutput
|
||||
public class OutStockDetailOutput : IInOutStockDetail<WmsOutstockCode>
|
||||
{
|
||||
/// <summary>
|
||||
/// 出库单明细Id
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities
|
||||
{
|
||||
public interface IInOutStockCode
|
||||
{
|
||||
string bill_d_id { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Contracts;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities
|
||||
{
|
||||
public interface IInOutStockDetail<TStockCode> where TStockCode : BaseEntity<string>, new()
|
||||
{
|
||||
string? line_status { get; set; }
|
||||
List<TStockCode> CodeDetails { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ using JNPF;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities;
|
||||
|
||||
@@ -10,7 +11,7 @@ namespace Tnb.WarehouseMgr.Entities;
|
||||
/// 入库申请条码表
|
||||
/// </summary>
|
||||
[SugarTable("wms_instock_code")]
|
||||
public partial class WmsInstockCode : BaseEntity<string>
|
||||
public partial class WmsInstockCode : BaseEntity<string>, IInOutStockCode
|
||||
{
|
||||
public WmsInstockCode()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
using JNPF.Common.Const;
|
||||
using JNPF;
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 入库申请条码表
|
||||
/// </summary>
|
||||
public partial class WmsInstockCode
|
||||
{
|
||||
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace Tnb.WarehouseMgr.Entities;
|
||||
/// 出库申请条码表
|
||||
/// </summary>
|
||||
[SugarTable("wms_outstock_code")]
|
||||
public partial class WmsOutstockCode : BaseEntity<string>
|
||||
public partial class WmsOutstockCode : BaseEntity<string>, IInOutStockCode
|
||||
{
|
||||
public WmsOutstockCode()
|
||||
{
|
||||
|
||||
@@ -149,55 +149,30 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
dynamic? result = null;
|
||||
var dic = await _dictionaryDataService.GetDictionaryByTypeId(WmsWareHouseConst.WMS_INSTOCK_D_BILL_STATUS_TYPEID);
|
||||
|
||||
async Task<dynamic?> _fetchInOutStockCodesById<TEntity, TOut, TStockCode>(string billDId)
|
||||
where TEntity : BaseEntity<string>, new()
|
||||
where TOut : IInOutStockDetail<TStockCode>, new()
|
||||
where TStockCode : BaseEntity<string>, IInOutStockCode, new()
|
||||
{
|
||||
var data = await _db.Queryable<TEntity>()
|
||||
.Where(a => a.id == billDId)
|
||||
.Select(a => new TOut
|
||||
{
|
||||
CodeDetails = SqlFunc.Subqueryable<TStockCode>().Where(it => it.bill_d_id == a.id).ToList(),
|
||||
}, true)
|
||||
.Mapper(it => it.line_status = dic.ContainsKey(it.line_status!) ? dic[it.line_status!]?.ToString()! : "")
|
||||
.ToListAsync();
|
||||
return data;
|
||||
}
|
||||
|
||||
switch (input.inoutStockType)
|
||||
{
|
||||
case EnumInOutStockType.In:
|
||||
result = await _db.Queryable<WmsInstockD>()
|
||||
.Where(a => a.id == input.bill_d_id)
|
||||
.Select(a => new InStockDetailOutput
|
||||
{
|
||||
id = a.id,
|
||||
bill_id = a.bill_id,
|
||||
unit_id = a.unit_id,
|
||||
code_batch = a.code_batch,
|
||||
warehouse_id = a.warehouse_id,
|
||||
line_status = a.line_status,
|
||||
reason = a.reason,
|
||||
pr_qty = a.pr_qty,
|
||||
qty = a.qty,
|
||||
price = a.price,
|
||||
tax_price = a.tax_price,
|
||||
print_qty = a.print_qty,
|
||||
scan_qty = a.scan_qty,
|
||||
material_code = a.material_code,
|
||||
amount = a.amount,
|
||||
all_amount = a.all_amount,
|
||||
CodeDetails = SqlFunc.Subqueryable<WmsInstockCode>().Where(it => it.bill_d_id == a.id).ToList(),
|
||||
})
|
||||
.Mapper(it => it.line_status = dic.ContainsKey(it.line_status!) ? dic[it.line_status!]?.ToString()! : "")
|
||||
.ToListAsync();
|
||||
|
||||
result = await _fetchInOutStockCodesById<WmsInstockD, InStockDetailOutput, WmsInstockCode>(input.bill_d_id);
|
||||
break;
|
||||
case EnumInOutStockType.Out:
|
||||
result = await _db.Queryable<WmsOutstockD>()
|
||||
.Where(a => a.id == input.bill_d_id)
|
||||
.Select(a => new OutStockDetailOutput
|
||||
{
|
||||
id = a.id,
|
||||
bill_id = a.bill_id,
|
||||
unit_id = a.unit_id,
|
||||
code_batch = a.code_batch,
|
||||
warehouse_id = a.warehouse_id,
|
||||
line_status = a.line_status,
|
||||
price = a.price,
|
||||
tax_price = a.tax_price,
|
||||
material_code = a.material_code,
|
||||
amount = a.amount,
|
||||
all_amount = a.all_amount,
|
||||
CodeDetails = SqlFunc.Subqueryable<WmsOutstockCode>().Where(it => it.bill_d_id == a.id).ToList(),
|
||||
})
|
||||
.Mapper(it => it.line_status = dic.ContainsKey(it.line_status) ? dic[it.line_status]?.ToString()! : "")
|
||||
.ToListAsync();
|
||||
result = await _fetchInOutStockCodesById<WmsOutstockD, OutStockDetailOutput, WmsOutstockCode>(input.bill_d_id);
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user