1
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 最低库存策略明细表
|
||||
/// </summary>
|
||||
[SugarTable("wms_minstrategy_d")]
|
||||
public partial class WmsMinstrategyD : BaseEntity<string>
|
||||
{
|
||||
public WmsMinstrategyD()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 主表ID
|
||||
/// </summary>
|
||||
public string? bill_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料ID
|
||||
/// </summary>
|
||||
public string? material_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 物料编号
|
||||
/// </summary>
|
||||
public string? material_code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单位ID
|
||||
/// </summary>
|
||||
public string? unit_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单次配送箱数
|
||||
/// </summary>
|
||||
public int? box_num { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改时间
|
||||
/// </summary>
|
||||
public DateTime? modify_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扩展
|
||||
/// </summary>
|
||||
public string? extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳
|
||||
/// </summary>
|
||||
public DateTime? timestamp { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 最低库存策略
|
||||
/// </summary>
|
||||
[SugarTable("wms_minstrategy_h")]
|
||||
public partial class WmsMinstrategyH : BaseEntity<string>
|
||||
{
|
||||
public WmsMinstrategyH()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 所属组织
|
||||
/// </summary>
|
||||
public string? org_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 单号
|
||||
/// </summary>
|
||||
public string bill_code { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 发出仓库
|
||||
/// </summary>
|
||||
public string? sendwh_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 接收仓库
|
||||
/// </summary>
|
||||
public string? receivewh_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建用户
|
||||
/// </summary>
|
||||
public string? create_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime? create_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户
|
||||
/// </summary>
|
||||
public string? modify_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 删除时间
|
||||
/// </summary>
|
||||
public DateTime? delete_time { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 扩展
|
||||
/// </summary>
|
||||
public string? extras { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间戳
|
||||
/// </summary>
|
||||
public string? timestamp { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Interfaces
|
||||
{
|
||||
/// <summary>
|
||||
/// 转运签收服务接口类
|
||||
/// </summary>
|
||||
public interface IWmsPDATransferSignService
|
||||
{
|
||||
Task IsMinStorage(CancellationTokenSource? cts = default);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ using JNPF.Common.Security;
|
||||
using System.Collections.Immutable;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using Tnb.WarehouseMgr.Interfaces;
|
||||
using Senparc.Weixin.Work.Entities;
|
||||
//using JNPF.Extras.CollectiveOAuth.Utils;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
@@ -29,7 +30,7 @@ namespace Tnb.WarehouseMgr
|
||||
private static Dictionary<string, object> _dicBizType = new();
|
||||
private readonly IUserManager _userManager;
|
||||
private readonly IWmsOutStockService _outstockService;
|
||||
public PDATransferSignService(ISqlSugarRepository<WmsDistaskH> repository, IDictionaryDataService dictionaryDataService,IUserManager userManager,IWmsOutStockService outStockService)
|
||||
public PDATransferSignService(ISqlSugarRepository<WmsDistaskH> repository, IDictionaryDataService dictionaryDataService, IUserManager userManager, IWmsOutStockService outStockService)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_dictionaryDataService = dictionaryDataService;
|
||||
@@ -95,7 +96,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
decimal codeQty = 0;
|
||||
var sMCode = nCCode.Find(x => x.material_id == dCode.material_id && x.codeqty <= dicMin[dCode.material_id].ParseToDecimal());
|
||||
cCode = dCode.Adapt<WmsCarryCode>();
|
||||
cCode = dCode.Adapt<WmsCarryCode>();
|
||||
cCode.carry_id = newCarry.id;
|
||||
cCode.code_batch = $"{DateTime.Today.Year}{DateTime.Today.Month}{DateTime.Today.Day}";
|
||||
if (sMCode != null)
|
||||
@@ -110,8 +111,8 @@ namespace Tnb.WarehouseMgr
|
||||
cCode.id = SnowflakeIdHelper.NextId();
|
||||
iCodes.Add(cCode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
await _db.Insertable(iCodes).ExecuteCommandAsync();
|
||||
await _db.Updateable(uCodes).ExecuteCommandAsync();
|
||||
@@ -139,60 +140,72 @@ namespace Tnb.WarehouseMgr
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 库存是否抵达最小库存
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task IsMinStorage()
|
||||
[HttpPost]
|
||||
public async Task IsMinStorage(CancellationTokenSource? cts = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<Dictionary<string, object>> mats = new List<Dictionary<string, object>>();
|
||||
List<Dictionary<string, object>> dics = new List<Dictionary<string, object>>();
|
||||
var sgs = await _db.Queryable<WmsMinstrategyH>().LeftJoin<WmsMinstrategyD>((a, b) => a.id == b.bill_id)
|
||||
.Select((a, b) => new
|
||||
{
|
||||
sendWh = a.sendwh_id,
|
||||
receiveWh = a.receivewh_id,
|
||||
b.material_id,
|
||||
b.box_num,
|
||||
})
|
||||
.ToListAsync();
|
||||
var items = await _db.Queryable<WmsCarryCode>()
|
||||
.LeftJoin<BasMaterialSendWarehouse>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<BasMaterial>((a, b, c) => b.material_id == c.id)
|
||||
.Where(a => a.warehouse_id == "2")
|
||||
.Select((a, b, c) => new { a.material_id, a.codeqty, b.min_stock, c.code, c.minpacking })
|
||||
.ToListAsync();
|
||||
var itGroups = items.GroupBy(it => it.material_id);
|
||||
foreach (var itGroup in itGroups)
|
||||
.LeftJoin<BasMaterialSendWarehouse>((a, b) => a.material_id == b.id)
|
||||
.LeftJoin<BasMaterial>((a, b, c) => b.material_id == c.id)
|
||||
.Where(a => sgs.Select(x => x.receiveWh).Contains(a.warehouse_id))
|
||||
.Select((a, b, c) => new { a.material_id, a.codeqty, b.min_stock, c.code, c.minpacking, a.warehouse_id })
|
||||
.ToListAsync();
|
||||
foreach (var sg in sgs)
|
||||
{
|
||||
var itGroups = items.FindAll(x => x.material_id == sg.material_id && x.warehouse_id == sg.receiveWh).GroupBy(g => g.material_id);
|
||||
Dictionary<string, object> dic = new();
|
||||
var minStock = itGroup.First().min_stock;
|
||||
if (itGroup.Select(x => x.codeqty).Sum() <= minStock)
|
||||
foreach (var itGroup in itGroups)
|
||||
{
|
||||
foreach (var a in itGroup)
|
||||
var minStock = itGroup.First().min_stock;
|
||||
if (itGroup.Select(x => x.codeqty).Sum() <= minStock)
|
||||
{
|
||||
dic.Add(nameof(a.material_id), a.material_id);
|
||||
dic.Add(nameof(a.code), a.code);
|
||||
dic.Add(nameof(a.minpacking), a.minpacking ?? 0);
|
||||
dic.Add(nameof(WmsCarryCode.material_id), itGroup.Key);
|
||||
dic.Add(nameof(WmsCarryCode.material_code), itGroup.First().code);
|
||||
dic.Add(nameof(BasMaterial.minpacking), itGroup.First().minpacking!);
|
||||
}
|
||||
mats.Add(dic);
|
||||
dics.Add(dic);
|
||||
}
|
||||
}
|
||||
var locs = await _db.Queryable<BasLocation>().Where(it => it.is_type == ((int)EnumLocationType.存储库位).ToString() && it.wh_id == "2" && it.is_lock == 0 && it.is_use == ((int)EnumCarryStatus.空闲).ToString()).ToListAsync();
|
||||
MESCreateOutstockInput input = new()
|
||||
{
|
||||
outstock =
|
||||
{
|
||||
org_id = _userManager.User.OrganizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = "28135837838101",//单据类型:自动补货单
|
||||
warehouse_id = "1",
|
||||
create_id= _userManager.UserId,
|
||||
}
|
||||
};
|
||||
foreach (var mat in mats)
|
||||
{
|
||||
input.outstock.location_code = locs[mats.IndexOf(mat)].location_code;
|
||||
MESWmsOutstockDInput outstockD = new()
|
||||
//查找符合条件的出库库位
|
||||
//var locs = await _db.Queryable<BasLocation>().Where(it => it.is_type == ((int)EnumLocationType.存储库位).ToString() && it.wh_id == "2" && it.is_lock == 0 && it.is_use == ((int)EnumCarryStatus.空闲).ToString()).ToListAsync();
|
||||
MESCreateOutstockInput input = new()
|
||||
{
|
||||
material_id = mat["material_id"].ToString()!,
|
||||
material_code = mat["code"].ToString()!,
|
||||
pr_qty = mat["minpacking"].ParseToDecimal(),
|
||||
outstock =
|
||||
{
|
||||
org_id = _userManager.User.OrganizeId,
|
||||
bill_date = DateTime.Now,
|
||||
bill_type = "28135837838101",//单据类型:自动补货单
|
||||
warehouse_id = "1",
|
||||
create_id= _userManager.UserId,
|
||||
}
|
||||
};
|
||||
input.outstockDs.Add(outstockD);
|
||||
await _outstockService.MESCreateOutstock(input);
|
||||
foreach (var d in dics)
|
||||
{
|
||||
input.outstock.location_code = "YCL03-01-01";
|
||||
MESWmsOutstockDInput outstockD = new()
|
||||
{
|
||||
material_id = d[nameof(WmsCarryCode.material_id)].ToString()!,
|
||||
material_code = d[nameof(WmsCarryCode.material_code)].ToString()!,
|
||||
pr_qty = d[nameof(BasMaterial.minpacking)].ParseToDecimal()
|
||||
};
|
||||
input.outstockDs.Add(outstockD);
|
||||
await _outstockService.MESCreateOutstock(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
||||
@@ -77,9 +77,12 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
#region 定时
|
||||
//_eventPublisher = App.GetRequiredService<IEventPublisher>();
|
||||
CancellationTokenSource kittingOutAddCts = new();
|
||||
CancellationTokenSource kittingOutShippedCts = new();
|
||||
CancellationTokenSource setSortingCts = new();
|
||||
//List<string> toUserIds = new List<string>() { "25398501929509" };
|
||||
////生成任务执行
|
||||
//CancellationTokenSource genTaskCTS = new();
|
||||
//CancellationTokenSource kittingOutAddCts = new();
|
||||
//CancellationTokenSource kittingOutShippedCts = new();
|
||||
//CancellationTokenSource setSortingCts = new();
|
||||
|
||||
//var wareHouseService = App.GetRequiredService<IWareHouseService>();
|
||||
//TimedTask(cts => wareHouseService.GenTaskExecute(cts), genTaskCTS);
|
||||
@@ -119,8 +122,7 @@ namespace Tnb.WarehouseMgr
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
await GetDelayTask(timeType, interval);
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
}, token);
|
||||
}
|
||||
|
||||
@@ -96,10 +96,12 @@ namespace Tnb.WarehouseMgr
|
||||
var curCarry = carrys[^carrys.Count];
|
||||
var isMatch = await IsCarryAndLocationMatchByCarryStd(curCarry, loc);
|
||||
if (!isMatch) throw new AppFriendlyException("该载具无法放置到目标库位", 500);
|
||||
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTK_ID, true);
|
||||
await _runService.Create(templateEntity, input);
|
||||
|
||||
}
|
||||
|
||||
VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleConsts.MODULE_WMSEMPTYOUTSTK_ID, true);
|
||||
await _runService.Create(templateEntity, input);
|
||||
|
||||
var setQty = await _db.Queryable<WmsEmptyOutstockH>().FirstAsync(it => it.bill_code == input.data[nameof(WmsEmptyOutstockH.bill_code)].ToString());
|
||||
WmsPointH? sPoint = null;
|
||||
|
||||
Reference in New Issue
Block a user