1、调整盘点任务动态生成查询条件
2、LambdaExpressionExtensions 新增表达式树扩展
This commit is contained in:
@@ -13,7 +13,6 @@ using JNPF.VisualDev.Interfaces;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
@@ -112,12 +111,33 @@ namespace Tnb.WarehouseMgr
|
||||
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()),
|
||||
EnumCheckType.批次盘点 => filterExpable.AndIF(areaIds?.Length > 0, (a, b, c) => areaIds.Contains(a.region_id)),
|
||||
_ => filterExpable,
|
||||
};
|
||||
case EnumCheckType.全库盘点:
|
||||
{
|
||||
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)
|
||||
.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);
|
||||
}
|
||||
|
||||
//var filterExpable = Expressionable.Create<BasLocation, WmsCarryCode, WmsCarryH>();
|
||||
Expression<Func<BasLocation, WmsCarryCode, WmsCarryH, bool>> filterExp = (a, b, c) => false;
|
||||
switch (input.CheckType)
|
||||
{
|
||||
case EnumCheckType.全库盘点:
|
||||
{
|
||||
filterExp.And((a, b, c) => a.wh_id == input.warehouse_id)
|
||||
.And((a, b, c) => a.is_type == ((int)EnumLocationType.存储库位).ToString())
|
||||
.And((a, b, c) => c.is_lock == 0);
|
||||
filterExp = (a, b, c) => a.wh_id == input.warehouse_id
|
||||
&& a.is_type == ((int)EnumLocationType.存储库位).ToString()
|
||||
&& c.is_lock == 0;
|
||||
}
|
||||
break;
|
||||
case EnumCheckType.物料盘点:
|
||||
{
|
||||
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;
|
||||
@@ -343,7 +362,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -59,6 +59,23 @@ namespace JNPF.Common.Extension
|
||||
|
||||
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