Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -17,12 +17,12 @@ namespace Tnb.WarehouseMgr.Interfaces
|
||||
/// 齐套出库(新增状态)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
Task KittingOutByAdd(CancellationToken? ct = default);
|
||||
Task KittingOutByAdd();
|
||||
/// <summary>
|
||||
/// 齐套出库,(待配送状态)
|
||||
/// </summary>
|
||||
/// <param name="cts"></param>
|
||||
/// <returns></returns>
|
||||
Task KittingOutByIsToBeShipped(CancellationToken? ct = default);
|
||||
Task KittingOutByIsToBeShipped();
|
||||
}
|
||||
}
|
||||
|
||||
130
WarehouseMgr/Tnb.WarehouseMgr/BuildPreTaskHelper.cs
Normal file
130
WarehouseMgr/Tnb.WarehouseMgr/BuildPreTaskHelper.cs
Normal file
@@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成预任务通用帮助类
|
||||
/// </summary>
|
||||
public class BuildPreTaskHelper
|
||||
{
|
||||
private static Lazy<(IUserManager userManager, IBillRullService billRullService, IWareHouseService wareHouseService, ISqlSugarRepository<WmsInstockH> repository)> lazy;
|
||||
|
||||
static BuildPreTaskHelper()
|
||||
{
|
||||
lazy = new Lazy<(IUserManager userManager, IBillRullService billRullService, IWareHouseService wareHouseService, ISqlSugarRepository<WmsInstockH> repository)>(() =>
|
||||
{
|
||||
var userManager = App.GetRequiredService<IUserManager>();
|
||||
var billRullService = App.GetRequiredService<IBillRullService>();
|
||||
var warehouseService = App.GetRequiredService<IWareHouseService>();
|
||||
var repository = App.GetRequiredService<ISqlSugarRepository<WmsInstockH>>();
|
||||
return (userManager, billRullService, warehouseService, repository);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public static Func<WmsCarryH, WmsPointH, WmsPointH, Task< GenPreTaskUpInput>> GenPretaskCurried<TEntity>(TEntity? entity, string bizType, string taskType, List<WmsPretaskCode>? codes = default)
|
||||
where TEntity : BaseEntity<string>, 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<WmsPretaskH>() { 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<string> { preTask.startlocation_id, preTask.endlocation_id };
|
||||
preTaskUpInput.PreTaskRecords = preTasks.Adapt<List<WmsHandleH>>();
|
||||
preTaskUpInput.PreTaskRecords.ForEach(x => x.id = SnowflakeIdHelper.NextId());
|
||||
|
||||
WmsHandleH handleH = preTask.Adapt<WmsHandleH>();
|
||||
handleH.id = SnowflakeIdHelper.NextId();
|
||||
handleH.create_time = DateTime.Now;
|
||||
preTaskUpInput.PreTaskRecord = handleH;
|
||||
|
||||
if (codes?.Count > 0)
|
||||
{
|
||||
var handleCodes = codes.Adapt<List<WmsHandleCode>>();
|
||||
handleCodes.ForEach(c =>
|
||||
{
|
||||
c.id = SnowflakeIdHelper.NextId();
|
||||
c.bill_id = handleH.id;
|
||||
c.create_time = DateTime.Now;
|
||||
});
|
||||
preTaskUpInput.PreTaskHandleCodes = handleCodes;
|
||||
}
|
||||
}
|
||||
return preTaskUpInput;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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<WmsElevatorD> curEleDs = await _db.Queryable<WmsElevatorD>().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<WmsElevatorH>().SingleAsync(it => it.id == curEleDs.First().bill_id && it.enabled == 1);
|
||||
|
||||
Logger.Debug($"档期电梯信息:{JsonConvert.SerializeObject(curEle)}");
|
||||
|
||||
//同电梯组电梯
|
||||
List<WmsElevatorH> sGpEle = await _db.Queryable<WmsElevatorH>().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);
|
||||
|
||||
@@ -481,7 +481,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
ePoint = await _db.Queryable<WmsPointH>().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<WmsPointH> 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<WmsCheckstockH>(null, WmsWareHouseConst.BIZTYPE_CARRYMOVEINSTOCK_ID, WmsWareHouseConst.WMS_PRETASK_INSTOCK_TYPE_ID);
|
||||
var genPreTaskUpInput = await genPreTask(carry, sPoint, ePoint);
|
||||
*/
|
||||
List<WmsPretaskH> 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)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// 采购收货、销售发货,通用业务类
|
||||
/// </summary>
|
||||
/// <typeparam name="TSubEntity"></typeparam>
|
||||
public class WmsPurchaseAndSaleCommonService<TSubEntity> : BaseWareHouseService where TSubEntity : BaseEntity<string>, IPurchaseAndSaleEntity, IPurchaseAndSaleQueryEntity,new()
|
||||
public class WmsPurchaseAndSaleCommonService<TSubEntity> : BaseWareHouseService where TSubEntity : BaseEntity<string>, 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<TSubEntity>().ToList();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task KittingOutByAdd(CancellationToken? ct = default)
|
||||
public async Task KittingOutByAdd()
|
||||
{
|
||||
//if (ct?.IsCancellationRequested ?? false)
|
||||
//{
|
||||
@@ -173,7 +173,7 @@ namespace Tnb.WarehouseMgr
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task KittingOutByIsToBeShipped(CancellationToken? ct = default)
|
||||
public async Task KittingOutByIsToBeShipped()
|
||||
{
|
||||
//if (UserManager.AsscessToken.IsNullOrWhiteSpace()) return;
|
||||
//var curUser = await GetUserIdentity();
|
||||
|
||||
@@ -24,6 +24,15 @@ namespace JNPF.Common.Extension
|
||||
setAction(instance, value);
|
||||
}
|
||||
|
||||
public static object GetPropertyValue<T>(this T obj, string propertyName)
|
||||
{
|
||||
if (!ProperyGet<T>.ValueFactories.TryGetValue(propertyName, out var getDateValue))
|
||||
{
|
||||
getDateValue = ProperyGet<T>.PropertyGetValue(propertyName);
|
||||
ProperyGet<T>.ValueFactories.Add(propertyName, getDateValue);
|
||||
}
|
||||
return getDateValue(obj);
|
||||
}
|
||||
/// <summary>
|
||||
/// Lambda表达式拼接
|
||||
/// </summary>
|
||||
@@ -144,4 +153,17 @@ namespace JNPF.Common.Extension
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ProperyGet<T> //where T : class, new()
|
||||
{
|
||||
public static Dictionary<string, Func<T, object>> ValueFactories = new Dictionary<string, Func<T, object>>(StringComparer.OrdinalIgnoreCase);
|
||||
public static Func<T, Object> 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<Func<T, object>>(castExp, parameterExp);
|
||||
return lambda.Compile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
19
common/Tnb.Common/Utils/ObjectPropertyChecker.cs
Normal file
19
common/Tnb.Common/Utils/ObjectPropertyChecker.cs
Normal file
@@ -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>(T obj, string propertyName)
|
||||
{
|
||||
Type type = typeof(T);
|
||||
var propertyInfo = type.GetProperty(propertyName);
|
||||
return propertyInfo != null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user