库房业务,入出库申请,根据入出库明细Id获取匹配信息

This commit is contained in:
DEVICE8\12494
2023-06-07 17:46:14 +08:00
parent fc23384325
commit 4b818980de
5 changed files with 421 additions and 85 deletions

View File

@@ -1,15 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Aspose.Cells.Drawing;
using JNPF.Common.Contracts;
using JNPF.Common.Enums;
using JNPF.Common.Extension;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController;
using JNPF.Extras.CollectiveOAuth.Config;
using JNPF.FriendlyException;
using Mapster;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis;
using NPOI.OpenXmlFormats.Wordprocessing;
using Polly.Timeout;
using Spire.Pdf.Widget;
@@ -18,6 +25,8 @@ using Tnb.BasicData.Entities;
using Tnb.BasicData.Entities.Enums;
using Tnb.Common.Utils;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Dto;
using Tnb.WarehouseMgr.Entities.Enums;
using Tnb.WarehouseMgr.Interfaces;
namespace Tnb.WarehouseMgr
@@ -69,102 +78,101 @@ namespace Tnb.WarehouseMgr
return items;
}
/// <summary>
/// 获取载具信息(入库业务) 当前载具启用;未锁定;如果有库位信息,库位不能为存储库位,出库库位,分拣库位;
/// 库房业务,入库、出库申请新增修改功能
/// </summary>
/// <remarks>
/// returns:
/// <br/>{
/// <br/> carry_id:载具Id
/// <br/> carry_code:载具编号
/// <br/> carry_name:载具名称
/// <br/> location_id:库位id
/// <br/> location_code:库位编码
/// <br/> location_name:库位名称
/// <br/>}
/// </remarks>
[HttpGet]
public async Task<dynamic> GetCarryInfo()
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
public async Task ApplyFor(InOutStockApplyforUpInput input)
{
var locationTypes = new[] { (int)EnumLocationType., (int)EnumLocationType., (int)EnumLocationType. };
var items = await _db.Queryable<WmsCarryH>().LeftJoin<BasLocation>((a, b) => a.location_id == b.id)
.Where((a, b) => a.status == 0 && a.is_lock == 0 && !locationTypes.Contains(Convert.ToInt32(b.is_type)))
.Select((a, b) => new
{
carry_id = a.id,
carry_code = a.carry_code,
carry_name = a.carry_name,
location_id = b.id,
location_code = b.location_code,
location_name = b.location_name,
})
.ToListAsync();
return items;
// bill_line,location_id,delivery_date,carry_id,carry_code
if (input == null) throw new ArgumentNullException("input");
var isOk = false;
switch (input.inoutStockType)
{
case EnumInOutStockType.In:
var wmsInstockD = input.Adapt<WmsInstockD>();
var wmsInstockCodes = input.InstockCodes.Adapt<List<WmsInstockCode>>();
wmsInstockCodes.ForEach(x =>
{
if (x.id.IsNullOrWhiteSpace())
{
x.id = SnowflakeIdHelper.NextId();
}
});
isOk = await _update<WmsInstockD, WmsInstockCode>(wmsInstockD, wmsInstockCodes);
break;
case EnumInOutStockType.Out:
var wmsOutstockD = input.Adapt<WmsOutstockD>();
var wmsOutstockCodes = input.InstockCodes.Adapt<List<WmsOutstockCode>>();
wmsOutstockCodes.ForEach(x =>
{
if (x.id.IsNullOrWhiteSpace())
{
x.id = SnowflakeIdHelper.NextId();
}
});
isOk = await _update<WmsOutstockD, WmsOutstockCode>(wmsOutstockD, wmsOutstockCodes);
break;
}
if (!isOk) throw Oops.Oh(ErrorCode.COM1001);
}
/// <summary>
/// 获取库位信息(入库业务) 库位不能为存储库位,出库库位,分拣库位;未锁定
/// </summary>
/// <remarks>
/// returns
/// <br/>{
/// <br/> location_id:库位Id
/// <br/> location_code库位编号
/// <br/> location_name:库位名称
/// <br/> layers:楼层
/// <br/>}
/// </remarks>
[HttpGet]
public async Task<dynamic> GetLocationInfo()
{
var locationTypes = new[] { (int)EnumLocationType., (int)EnumLocationType., (int)EnumLocationType. };
var items = await _db.Queryable<BasLocation>().Where(it => it.is_lock == 0 && !locationTypes.Contains(Convert.ToInt32(it.is_type)))
.Select(it => new
{
location_id = it.id,
location_code = it.location_code,
location_name = it.location_name,
layers = it.layers,
})
.ToListAsync();
return items;
}
/// <summary>
/// 出库查询目标库位信息,覆盖过滤条件
/// 根据明细Id获取出入库明细信息
/// </summary>
/// <param name="billDId"></param>
/// <returns></returns>
[HttpGet]
public async Task<dynamic> GetOutStoreDestLocation()
public async Task<dynamic> GetInOutStockCodesById([FromQuery] InOutStockDetailQuery input)
{
var locationTypes = new[] { (int)EnumLocationType., (int)EnumLocationType. };
var items = await _db.Queryable<BasLocation>().Where(it => it.is_lock == 0 && !locationTypes.Contains(Convert.ToInt32(it.is_type)))
.Select(it => new
{
location_id = it.id,
location_code = it.location_code,
})
.ToListAsync();
return items;
dynamic result = null;
switch (input.inoutStockType)
{
case EnumInOutStockType.In:
result = await _db.Queryable<WmsInstockD>()
.Where(a => a.id == input.bill_d_id)
.Select(a => new InStockDetailOutput
{
bill_id = a.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,
CodeDetails = SqlFunc.Subqueryable<WmsInstockCode>().Where(it => it.bill_d_id == a.id).ToList(),
}).ToListAsync();
break;
case EnumInOutStockType.Out:
result = await _db.Queryable<WmsOutstockCode>().Where(it => it.bill_d_id == input.bill_d_id).ToListAsync();
break;
}
return result;
}
/// <summary>
/// 出库申请-查询载具信息
/// </summary>
/// <returns></returns>
[HttpGet]
public async Task<dynamic> GetOutStoreLocation()
private async Task<bool> _update<T1, T2>(T1 entity, List<T2> entities) where T1 : BaseEntity<string>, new() where T2 : BaseEntity<string>, new()
{
var items = await _db.Queryable<WmsCarryH>().LeftJoin<BasLocation>((a, b) => a.location_id == b.id)
.Where((a, b) => a.status == 0 && a.is_lock == 0 && Convert.ToInt32(b.is_type) == (int)EnumLocationType.)
.Select((a, b) => new
{
carry_id = a.id,
carry_code = a.carry_code,
carry_name = a.carry_name,
location_id = b.id,
location_code = b.location_code,
location_name = b.location_name,
})
.ToListAsync();
return items;
var isOk = false;
try
{
await _db.Ado.BeginTranAsync();
isOk = await _db.Updateable(entity).ExecuteCommandHasChangeAsync();
isOk = await _db.Updateable(entities).ExecuteCommandHasChangeAsync();
await _db.Ado.CommitTranAsync();
}
catch (Exception)
{
await _db.Ado.RollbackTranAsync();
}
return isOk;
}
/// <summary>
/// 路径算法
/// </summary>