diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmskittingOutService.cs
index a974b4c3..cc64267a 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmskittingOutService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmskittingOutService.cs
@@ -17,12 +17,12 @@ namespace Tnb.WarehouseMgr.Interfaces
/// 齐套出库(新增状态)
///
///
- Task KittingOutByAdd(CancellationToken? ct = default);
+ Task KittingOutByAdd();
///
/// 齐套出库,(待配送状态)
///
///
///
- Task KittingOutByIsToBeShipped(CancellationToken? ct = default);
+ Task KittingOutByIsToBeShipped();
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/BuildPreTaskHelper.cs b/WarehouseMgr/Tnb.WarehouseMgr/BuildPreTaskHelper.cs
new file mode 100644
index 00000000..a38eeaa0
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr/BuildPreTaskHelper.cs
@@ -0,0 +1,130 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tnb.WarehouseMgr.Entities.Consts;
+using Tnb.WarehouseMgr.Entities;
+using Tnb.WarehouseMgr.Interfaces;
+using JNPF.Common.Core.Manager;
+using JNPF.Systems.Interfaces.System;
+using JNPF.Common.Contracts;
+using JNPF.Common.Extension;
+using Tnb.Common.Utils;
+using Microsoft.Extensions.DependencyInjection;
+using JNPF;
+using Tnb.WarehouseMgr.Entities.Dto;
+using Mapster;
+using JNPF.Common.Security;
+using NPOI.OpenXmlFormats;
+using SqlSugar;
+using Tnb.BasicData.Entities;
+using Microsoft.AspNetCore.Mvc;
+using Spire.Doc;
+
+namespace Tnb.WarehouseMgr
+{
+ ///
+ /// 生成预任务通用帮助类
+ ///
+ public class BuildPreTaskHelper
+ {
+ private static Lazy<(IUserManager userManager, IBillRullService billRullService, IWareHouseService wareHouseService, ISqlSugarRepository repository)> lazy;
+
+ static BuildPreTaskHelper()
+ {
+ lazy = new Lazy<(IUserManager userManager, IBillRullService billRullService, IWareHouseService wareHouseService, ISqlSugarRepository repository)>(() =>
+ {
+ var userManager = App.GetRequiredService();
+ var billRullService = App.GetRequiredService();
+ var warehouseService = App.GetRequiredService();
+ var repository = App.GetRequiredService>();
+ return (userManager, billRullService, warehouseService, repository);
+ });
+
+ }
+
+ public static Func> GenPretaskCurried(TEntity? entity, string bizType, string taskType, List? codes = default)
+ where TEntity : BaseEntity, new()
+ {
+
+ return async (carry, sPoint, ePoint) =>
+ {
+ var _db = lazy.Value.repository.AsSugarClient();
+
+ WmsPretaskH preTask = new()
+ {
+ org_id = lazy.Value.userManager.User.OrganizeId,
+ startlocation_id = sPoint?.location_id!,
+ startlocation_code = sPoint?.location_code!,
+ endlocation_id = ePoint?.location_id!,
+ endlocation_code = ePoint?.location_code!,
+ start_floor = sPoint?.floor.ToString(),
+ end_floor = ePoint?.floor.ToString(),
+ startpoint_id = sPoint?.id!,
+ startpoint_code = sPoint?.point_code!,
+ endpoint_id = ePoint?.id!,
+ endpoint_code = ePoint?.point_code!,
+ bill_code = lazy.Value.billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
+ status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
+ biz_type = bizType,
+ task_type = taskType,
+ carry_id = carry.id,
+ carry_code = carry.carry_code,
+ area_id = sPoint?.area_id!,
+ area_code = sPoint!.area_code,
+ source_id = entity != null && ObjectPropertyChecker.HasProperty(entity, "source_id") ? entity.GetPropertyValue("source_id")?.ToString() : string.Empty,
+ source_code = entity != null && ObjectPropertyChecker.HasProperty(entity, "source_code") ? entity.GetPropertyValue("source_code")?.ToString() : string.Empty,
+ require_id = entity != null && ObjectPropertyChecker.HasProperty(entity, "id") ? entity.GetPropertyValue("id")?.ToString() : string.Empty,
+ require_code = entity != null && ObjectPropertyChecker.HasProperty(entity, "bill_code") ? entity.GetPropertyValue("bill_code")?.ToString() : string.Empty,
+ create_id = lazy.Value.userManager.UserId,
+ create_time = DateTime.Now,
+ };
+
+ if (codes?.Count > 0)
+ {
+ codes.ForEach(c =>
+ {
+ c.bill_id = preTask.id;
+ c.create_time = DateTime.Now;
+ });
+ }
+ var preTasks = new List() { preTask };
+ var isOk = await lazy.Value.wareHouseService.GenPreTask(preTasks, codes);
+
+ var preTaskUpInput = new GenPreTaskUpInput();
+ if (isOk)
+ {
+ preTaskUpInput.RquireId = entity?.id ?? string.Empty;
+ preTaskUpInput.CarryId = carry.id;
+ preTaskUpInput.CarryStartLocationId = preTask.startlocation_id;
+ preTaskUpInput.CarryStartLocationCode = preTask.startlocation_code;
+ preTaskUpInput.LocationIds = new List { preTask.startlocation_id, preTask.endlocation_id };
+ preTaskUpInput.PreTaskRecords = preTasks.Adapt>();
+ preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId());
+
+ WmsHandleH handleH = preTask.Adapt();
+ handleH.id = SnowflakeIdHelper.NextId();
+ handleH.create_time = DateTime.Now;
+ preTaskUpInput.PreTaskRecord = handleH;
+
+ if (codes?.Count > 0)
+ {
+ var handleCodes = codes.Adapt>();
+ handleCodes.ForEach(c =>
+ {
+ c.id = SnowflakeIdHelper.NextId();
+ c.bill_id = handleH.id;
+ c.create_time = DateTime.Now;
+ });
+ preTaskUpInput.PreTaskHandleCodes = handleCodes;
+ }
+ }
+ return preTaskUpInput;
+ };
+
+ }
+
+ }
+
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index 1e68aef0..3ea2ec4f 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -1041,16 +1041,23 @@ namespace Tnb.WarehouseMgr
{
if (points.FindAll(x => x.location_code != null && x.location_code.Contains("dt", StringComparison.OrdinalIgnoreCase))?.Count > 0)
{
+ Logger.Information("获取当前电梯点");
//查询当前电梯点
List curEleDs = await _db.Queryable().Where(it => points.Select(x => x.id).Contains(it.point_id)).ToListAsync();
+ Logger.Information($"当前电梯点:{string.Join(",",curEleDs.Select(x=>x.point_code))}");
//如果有电梯点,则会进行电梯的均匀分配
if (curEleDs?.Count > 0)
{
//当前电梯
WmsElevatorH curEle = await _db.Queryable().SingleAsync(it => it.id == curEleDs.First().bill_id && it.enabled == 1);
+
+ Logger.Debug($"档期电梯信息:{JsonConvert.SerializeObject(curEle)}");
+
//同电梯组电梯
List sGpEle = await _db.Queryable().Where(it => it.elevator_group == curEle.elevator_group && it.id != curEle.id && it.enabled == 1).ToListAsync();
+ Logger.Debug($"同电梯组电梯:{JsonConvert.SerializeObject(sGpEle)}");
+
if (curEle == null && sGpEle?.Count > 0)
{
throw new AppFriendlyException("电梯被禁用或未配置", 500);
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs
index 185b8835..f31161e9 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs
@@ -481,7 +481,7 @@ namespace Tnb.WarehouseMgr
{
ePoint = await _db.Queryable().FirstAsync(it => it.location_id == endLocs[0].id);
}
- if (sPoint == null || ePoint == null) throw new AppFriendlyException("路径无效", 500);
+ if (sPoint == null || ePoint == null) throw new AppFriendlyException("起点或终点不能为空", 500);
List points = await _warehouseService.PathAlgorithms(sPoint.id, ePoint.id);
//根据获取的路径点生成预任务,生成顺序必须预路径算法返回的起终点的顺序一致(预任务顺序)
if (points?.Count > 0)
@@ -491,38 +491,41 @@ namespace Tnb.WarehouseMgr
throw new AppFriendlyException("该路径不存在", 500);
}
+ /* var genPreTask = BuildPreTaskHelper.GenPretaskCurried(null, WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID, WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID);
+ var genPreTaskUpInput = await genPreTask(carry, sPoint, ePoint);
+ */
List preTasks = points.Where(it => !it.location_id.IsNullOrEmpty()).GroupBy(g => g.area_code).Select(it =>
- {
- WmsPointH? sPoint = it.FirstOrDefault();
- WmsPointH? ePoint = it.LastOrDefault();
+ {
+ WmsPointH? sPoint = it.FirstOrDefault();
+ WmsPointH? ePoint = it.LastOrDefault();
- WmsPretaskH preTask = new()
- {
- org_id = _userManager.User.OrganizeId!,
- startlocation_id = sPoint?.location_id!,
- startlocation_code = sPoint?.location_code!,
- endlocation_id = ePoint?.location_id!,
- endlocation_code = ePoint?.location_code!,
- start_floor = sPoint?.floor.ToString(),
- end_floor = ePoint?.floor.ToString(),
- startpoint_id = sPoint?.id!,
- startpoint_code = sPoint?.point_code!,
- endpoint_id = ePoint?.id!,
- endpoint_code = ePoint?.point_code!,
- bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
- status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
- biz_type = WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID,
- task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID,
- carry_id = carry?.id ?? string.Empty,
- carry_code = carry?.carry_code ?? string.Empty,
- area_id = sPoint?.area_id!,
- area_code = it.Key,
- create_id = _userManager.UserId,
- create_time = DateTime.Now
- };
+ WmsPretaskH preTask = new()
+ {
+ org_id = _userManager.User.OrganizeId!,
+ startlocation_id = sPoint?.location_id!,
+ startlocation_code = sPoint?.location_code!,
+ endlocation_id = ePoint?.location_id!,
+ endlocation_code = ePoint?.location_code!,
+ start_floor = sPoint?.floor.ToString(),
+ end_floor = ePoint?.floor.ToString(),
+ startpoint_id = sPoint?.id!,
+ startpoint_code = sPoint?.point_code!,
+ endpoint_id = ePoint?.id!,
+ endpoint_code = ePoint?.point_code!,
+ bill_code = _billRullService.GetBillNumber(WmsWareHouseConst.WMS_PRETASK_H_ENCODE).GetAwaiter().GetResult(),
+ status = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID,
+ biz_type = WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID,
+ task_type = WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID,
+ carry_id = carry?.id ?? string.Empty,
+ carry_code = carry?.carry_code ?? string.Empty,
+ area_id = sPoint?.area_id!,
+ area_code = it.Key,
+ create_id = _userManager.UserId,
+ create_time = DateTime.Now
+ };
- return preTask;
- }).ToList();
+ return preTask;
+ }).ToList();
bool isOk = await _warehouseService.GenPreTask(preTasks, null!);
if (isOk)
{
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseAndSaleCommonService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseAndSaleCommonService.cs
index 6f727973..9ec854e7 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseAndSaleCommonService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseAndSaleCommonService.cs
@@ -28,7 +28,7 @@ namespace Tnb.WarehouseMgr
/// 采购收货、销售发货,通用业务类
///
///
- public class WmsPurchaseAndSaleCommonService : BaseWareHouseService where TSubEntity : BaseEntity, IPurchaseAndSaleEntity, IPurchaseAndSaleQueryEntity,new()
+ public class WmsPurchaseAndSaleCommonService : BaseWareHouseService where TSubEntity : BaseEntity, IPurchaseAndSaleEntity, IPurchaseAndSaleQueryEntity, new()
{
private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager;
@@ -103,8 +103,7 @@ namespace Tnb.WarehouseMgr
}
}
}
-
- return await Task.FromResult(purchaseDs);
+ return purchaseDs ?? Enumerable.Empty().ToList();
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
index c0c22bc8..8708d84a 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmskittingOutService.cs
@@ -63,7 +63,7 @@ namespace Tnb.WarehouseMgr
///
///
[HttpPost]
- public async Task KittingOutByAdd(CancellationToken? ct = default)
+ public async Task KittingOutByAdd()
{
//if (ct?.IsCancellationRequested ?? false)
//{
@@ -173,7 +173,7 @@ namespace Tnb.WarehouseMgr
///
///
[HttpPost]
- public async Task KittingOutByIsToBeShipped(CancellationToken? ct = default)
+ public async Task KittingOutByIsToBeShipped()
{
//if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
//var curUser = await GetUserIdentity();
diff --git a/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs b/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs
index 04ab917b..7b43b92a 100644
--- a/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs
+++ b/common/Tnb.Common/Extension/LambdaExpressionExtensions.cs
@@ -24,6 +24,15 @@ namespace JNPF.Common.Extension
setAction(instance, value);
}
+ public static object GetPropertyValue(this T obj, string propertyName)
+ {
+ if (!ProperyGet.ValueFactories.TryGetValue(propertyName, out var getDateValue))
+ {
+ getDateValue = ProperyGet.PropertyGetValue(propertyName);
+ ProperyGet.ValueFactories.Add(propertyName, getDateValue);
+ }
+ return getDateValue(obj);
+ }
///
/// Lambda表达式拼接
///
@@ -144,4 +153,17 @@ namespace JNPF.Common.Extension
}
}
+
+ public class ProperyGet //where T : class, new()
+ {
+ public static Dictionary> ValueFactories = new Dictionary>(StringComparer.OrdinalIgnoreCase);
+ public static Func PropertyGetValue(string name)
+ {
+ var parameterExp = Expression.Parameter(typeof(T), "entity");
+ var propertyExp = Expression.Property(parameterExp, name);
+ var castExp = Expression.Convert(propertyExp, typeof(object));
+ var lambda = Expression.Lambda>(castExp, parameterExp);
+ return lambda.Compile();
+ }
+ }
}
diff --git a/common/Tnb.Common/Utils/ObjectPropertyChecker.cs b/common/Tnb.Common/Utils/ObjectPropertyChecker.cs
new file mode 100644
index 00000000..842844b5
--- /dev/null
+++ b/common/Tnb.Common/Utils/ObjectPropertyChecker.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.Common.Utils
+{
+ public static class ObjectPropertyChecker
+ {
+ public static bool HasProperty(T obj, string propertyName)
+ {
+ Type type = typeof(T);
+ var propertyInfo = type.GetProperty(propertyName);
+ return propertyInfo != null;
+ }
+ }
+
+}