Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -191,4 +191,8 @@ public class ModuleConsts
|
|||||||
/// 模块标识-采购收货
|
/// 模块标识-采购收货
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string MODULE_WMSPURCHASE_ID = "29975280336405";
|
public const string MODULE_WMSPURCHASE_ID = "29975280336405";
|
||||||
|
/// <summary>
|
||||||
|
/// 模块标识-在库物料维护
|
||||||
|
/// </summary>
|
||||||
|
public const string MODULE_WMSINSTKMIN_ID = "27124095468309";
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,6 @@ using JNPF.VisualDev.Interfaces;
|
|||||||
using Mapster;
|
using Mapster;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using NPOI.SS.Formula.Functions;
|
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
using Tnb.WarehouseMgr.Entities;
|
using Tnb.WarehouseMgr.Entities;
|
||||||
@@ -112,12 +111,33 @@ namespace Tnb.WarehouseMgr
|
|||||||
areaIds = input.data[nameof(WmsCheckstockH.area_id)].ToObject<string[]>();
|
areaIds = input.data[nameof(WmsCheckstockH.area_id)].ToObject<string[]>();
|
||||||
}
|
}
|
||||||
|
|
||||||
filterExpable = checkType!.ToEnum<EnumCheckType>() switch
|
Expression<Func<BasLocation, WmsCarryCode, WmsCarryH, bool>> filterExp = (a, b, c) => false;
|
||||||
|
switch (checkType?.ToEnum<EnumCheckType>())
|
||||||
{
|
{
|
||||||
EnumCheckType.物料盘点 => filterExpable.AndIF(input.data.ContainsKey(nameof(WmsCarryCode.material_id)) && input.data[nameof(WmsCarryCode.material_id)] != null, (a, b, c) => b.material_id == input.data[nameof(WmsCarryCode.material_id)].ToString()),
|
case EnumCheckType.全库盘点:
|
||||||
EnumCheckType.批次盘点 => filterExpable.AndIF(areaIds?.Length > 0, (a, b, c) => areaIds.Contains(a.region_id)),
|
{
|
||||||
_ => filterExpable,
|
filterExp = (a, b, c) => a.wh_id == input.data[nameof(WmsCheckstockH.warehouse_id)].ToString()
|
||||||
};
|
&& a.is_type == ((int)EnumLocationType.存储库位).ToString()
|
||||||
|
&& c.is_lock == 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EnumCheckType.物料盘点:
|
||||||
|
{
|
||||||
|
if (!input.data.ContainsKey(nameof(WmsCarryCode.material_id)) && input.data[nameof(WmsCarryCode.material_id)] != null)
|
||||||
|
{
|
||||||
|
filterExp = (a, b, c) => b.material_id == input.data[nameof(WmsCarryCode.material_id)].ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case EnumCheckType.批次盘点:
|
||||||
|
{
|
||||||
|
if (areaIds?.Length > 0)
|
||||||
|
{
|
||||||
|
filterExp = (a, b, c) => areaIds.Contains(a.region_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
var carryCodes = await _db.Queryable<BasLocation>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.location_id)
|
var carryCodes = await _db.Queryable<BasLocation>().InnerJoin<WmsCarryCode>((a, b) => a.id == b.location_id)
|
||||||
.InnerJoin<WmsCarryH>((a, b, c) => b.carry_id == c.id)
|
.InnerJoin<WmsCarryH>((a, b, c) => b.carry_id == c.id)
|
||||||
@@ -320,22 +340,21 @@ namespace Tnb.WarehouseMgr
|
|||||||
_carryMap = await _db.Queryable<WmsCarryH>().ToDictionaryAsync(x => x.id, x => x.carry_code);
|
_carryMap = await _db.Queryable<WmsCarryH>().ToDictionaryAsync(x => x.id, x => x.carry_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
//var filterExpable = Expressionable.Create<BasLocation, WmsCarryCode, WmsCarryH>();
|
|
||||||
Expression<Func<BasLocation, WmsCarryCode, WmsCarryH, bool>> filterExp = (a, b, c) => false;
|
Expression<Func<BasLocation, WmsCarryCode, WmsCarryH, bool>> filterExp = (a, b, c) => false;
|
||||||
switch (input.CheckType)
|
switch (input.CheckType)
|
||||||
{
|
{
|
||||||
case EnumCheckType.全库盘点:
|
case EnumCheckType.全库盘点:
|
||||||
{
|
{
|
||||||
filterExp.And((a, b, c) => a.wh_id == input.warehouse_id)
|
filterExp = (a, b, c) => a.wh_id == input.warehouse_id
|
||||||
.And((a, b, c) => a.is_type == ((int)EnumLocationType.存储库位).ToString())
|
&& a.is_type == ((int)EnumLocationType.存储库位).ToString()
|
||||||
.And((a, b, c) => c.is_lock == 0);
|
&& c.is_lock == 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case EnumCheckType.物料盘点:
|
case EnumCheckType.物料盘点:
|
||||||
{
|
{
|
||||||
if (!input.material_id.IsNullOrWhiteSpace())
|
if (!input.material_id.IsNullOrWhiteSpace())
|
||||||
{
|
{
|
||||||
filterExp.And((a, b, c) => b.material_id == input.material_id);
|
filterExp = (a, b, c) => b.material_id == input.material_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -343,7 +362,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
{
|
{
|
||||||
if (input.regionIds?.Count > 0)
|
if (input.regionIds?.Count > 0)
|
||||||
{
|
{
|
||||||
filterExp.And((a, b, c) => input.regionIds.Contains(a.region_id));
|
filterExp = (a, b, c) => input.regionIds.Contains(a.region_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
106
WarehouseMgr/Tnb.WarehouseMgr/WmsInStkMinService.cs
Normal file
106
WarehouseMgr/Tnb.WarehouseMgr/WmsInStkMinService.cs
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using JNPF.Common.Dtos.VisualDev;
|
||||||
|
using JNPF.Common.Extension;
|
||||||
|
using JNPF.EventBus;
|
||||||
|
using JNPF.Systems.Interfaces.System;
|
||||||
|
using JNPF.VisualDev;
|
||||||
|
using JNPF.VisualDev.Interfaces;
|
||||||
|
using SqlSugar;
|
||||||
|
using Tnb.BasicData.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Consts;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Enums;
|
||||||
|
using Tnb.WarehouseMgr.Interfaces;
|
||||||
|
|
||||||
|
namespace Tnb.WarehouseMgr
|
||||||
|
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 在库物料维护
|
||||||
|
/// </summary>
|
||||||
|
[OverideVisualDev(ModuleConsts.MODULE_WMSINSTKMIN_ID)]
|
||||||
|
|
||||||
|
public class WmsInStkMinService : BaseWareHouseService
|
||||||
|
{
|
||||||
|
private readonly ISqlSugarClient _db;
|
||||||
|
private readonly IRunService _runService;
|
||||||
|
private readonly IVisualDevService _visualDevService;
|
||||||
|
private readonly IWareHouseService _wareHouseService;
|
||||||
|
private readonly IBillRullService _billRullService;
|
||||||
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly IEventPublisher _eventPublisher;
|
||||||
|
public WmsInStkMinService(
|
||||||
|
ISqlSugarRepository<WmsCarryH> repository,
|
||||||
|
IRunService runService,
|
||||||
|
IVisualDevService visualDevService,
|
||||||
|
IWareHouseService wareHouseService,
|
||||||
|
IUserManager userManager,
|
||||||
|
IBillRullService billRullService,
|
||||||
|
IEventPublisher eventPublisher
|
||||||
|
)
|
||||||
|
{
|
||||||
|
_db = repository.AsSugarClient();
|
||||||
|
_runService = runService;
|
||||||
|
_visualDevService = visualDevService;
|
||||||
|
_wareHouseService = wareHouseService;
|
||||||
|
_userManager = userManager;
|
||||||
|
_billRullService = billRullService;
|
||||||
|
_eventPublisher = eventPublisher;
|
||||||
|
OverideFuncs.CreateAsync = WmsInStkMin;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private async Task<dynamic> WmsInStkMin(VisualDevModelDataCrInput input)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _db.Ado.BeginTranAsync();
|
||||||
|
//更新载具条码及状态
|
||||||
|
WmsCarryCode wmsCarryCode = new()
|
||||||
|
{
|
||||||
|
org_id = _userManager.User.OrganizeId,
|
||||||
|
barcode = input.data[nameof(WmsCarryCode.barcode)]?.ToString(),
|
||||||
|
carry_id = input.data[nameof(WmsCarryCode.carry_id)]?.ToString(),
|
||||||
|
material_id = input.data[nameof(WmsCarryCode.material_id)]?.ToString(),
|
||||||
|
material_code = input.data[nameof(WmsCarryCode.material_code)]?.ToString(),
|
||||||
|
code_batch = input.data[nameof(WmsCarryCode.code_batch)]?.ToString(),
|
||||||
|
codeqty =input.data[nameof(WmsCarryCode.codeqty)].ParseToDecimal(),
|
||||||
|
is_out = 0,
|
||||||
|
location_id = input.data[nameof(WmsCarryCode.location_id)]?.ToString(),
|
||||||
|
location_code = input.data[nameof(WmsCarryCode.location_code)]?.ToString(),
|
||||||
|
unit_id = input.data[nameof(WmsCarryCode.unit_id)]?.ToString(),
|
||||||
|
warehouse_id = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
|
||||||
|
create_id = _userManager.UserId,
|
||||||
|
create_time = DateTime.Now
|
||||||
|
};
|
||||||
|
if (wmsCarryCode.carry_id != null && wmsCarryCode.location_id != null)
|
||||||
|
{
|
||||||
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { carry_status = ((int)EnumCarryStatus.占用).ToString(), location_id = wmsCarryCode.location_id, location_code = wmsCarryCode.location_code }).Where(it => it.id == wmsCarryCode.carry_id).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { carry_status = ((int)EnumCarryStatus.占用).ToString()}).Where(it => it.id == wmsCarryCode.carry_id).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
await _db.Insertable(wmsCarryCode).ExecuteCommandAsync();
|
||||||
|
//更新库位数据
|
||||||
|
if (wmsCarryCode.location_id != null)
|
||||||
|
{
|
||||||
|
await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_use = ((int)EnumCarryStatus.占用).ToString() }).Where(it => it.id == wmsCarryCode.location_id).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
await _db.Ado.CommitTranAsync();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
await _db.Ado.RollbackTranAsync();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
// 用JNPF的发布订阅模式发布消息
|
||||||
|
await InvokeGenPretaskExcute();
|
||||||
|
}
|
||||||
|
return Task.FromResult(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -59,6 +59,23 @@ namespace JNPF.Common.Extension
|
|||||||
|
|
||||||
return first.Compose(second, Expression.And);
|
return first.Compose(second, Expression.And);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// or扩展
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="first"></param>
|
||||||
|
/// <param name="second"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static Expression<Func<T1, T2, T3, bool>> Or<T1, T2, T3>(this Expression<Func<T1, T2, T3, bool>> first, Expression<Func<T1, T2, T3, bool>> second)
|
||||||
|
{
|
||||||
|
if (first.IsNull())
|
||||||
|
{
|
||||||
|
first = second;
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
return first.Compose(second, Expression.Or);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user