diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMinstrategyD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMinstrategyD.cs
new file mode 100644
index 00000000..00722c37
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMinstrategyD.cs
@@ -0,0 +1,72 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.WarehouseMgr.Entities;
+
+///
+/// 最低库存策略明细表
+///
+[SugarTable("wms_minstrategy_d")]
+public partial class WmsMinstrategyD : BaseEntity
+{
+ public WmsMinstrategyD()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 主表ID
+ ///
+ public string? bill_id { get; set; }
+
+ ///
+ /// 物料ID
+ ///
+ public string? material_id { get; set; }
+
+ ///
+ /// 物料编号
+ ///
+ public string? material_code { get; set; }
+
+ ///
+ /// 单位ID
+ ///
+ public string? unit_id { get; set; }
+
+ ///
+ /// 单次配送箱数
+ ///
+ public int? box_num { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 修改时间
+ ///
+ public DateTime? modify_time { get; set; }
+
+ ///
+ /// 扩展
+ ///
+ public string? extras { get; set; }
+
+ ///
+ /// 时间戳
+ ///
+ public DateTime? timestamp { get; set; }
+
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMinstrategyH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMinstrategyH.cs
new file mode 100644
index 00000000..09d93a79
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMinstrategyH.cs
@@ -0,0 +1,67 @@
+using JNPF.Common.Contracts;
+using JNPF.Common.Security;
+using SqlSugar;
+
+namespace Tnb.WarehouseMgr.Entities;
+
+///
+/// 最低库存策略
+///
+[SugarTable("wms_minstrategy_h")]
+public partial class WmsMinstrategyH : BaseEntity
+{
+ public WmsMinstrategyH()
+ {
+ id = SnowflakeIdHelper.NextId();
+ }
+ ///
+ /// 所属组织
+ ///
+ public string? org_id { get; set; }
+
+ ///
+ /// 单号
+ ///
+ public string bill_code { get; set; } = string.Empty;
+
+ ///
+ /// 发出仓库
+ ///
+ public string? sendwh_id { get; set; }
+
+ ///
+ /// 接收仓库
+ ///
+ public string? receivewh_id { get; set; }
+
+ ///
+ /// 创建用户
+ ///
+ public string? create_id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime? create_time { get; set; }
+
+ ///
+ /// 修改用户
+ ///
+ public string? modify_id { get; set; }
+
+ ///
+ /// 删除时间
+ ///
+ public DateTime? delete_time { get; set; }
+
+ ///
+ /// 扩展
+ ///
+ public string? extras { get; set; }
+
+ ///
+ /// 时间戳
+ ///
+ public string? timestamp { get; set; }
+
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsPDATransferSignService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsPDATransferSignService.cs
new file mode 100644
index 00000000..bc9a6a31
--- /dev/null
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsPDATransferSignService.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tnb.WarehouseMgr.Interfaces
+{
+ ///
+ /// 转运签收服务接口类
+ ///
+ public interface IWmsPDATransferSignService
+ {
+ Task IsMinStorage(CancellationTokenSource? cts = default);
+ }
+}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs b/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs
index c5915b60..30f22cd2 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs
@@ -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 _dicBizType = new();
private readonly IUserManager _userManager;
private readonly IWmsOutStockService _outstockService;
- public PDATransferSignService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService,IUserManager userManager,IWmsOutStockService outStockService)
+ public PDATransferSignService(ISqlSugarRepository 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();
+ cCode = dCode.Adapt();
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;
}
}
+
///
/// 库存是否抵达最小库存
///
///
- public async Task IsMinStorage()
+ [HttpPost]
+ public async Task IsMinStorage(CancellationTokenSource? cts = default)
{
try
{
- List> mats = new List>();
+ List> dics = new List>();
+ var sgs = await _db.Queryable().LeftJoin((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()
- .LeftJoin((a, b) => a.material_id == b.id)
- .LeftJoin((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((a, b) => a.material_id == b.id)
+ .LeftJoin((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 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().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().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)
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs b/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs
index b38bfb7f..9ed682ae 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/TimedTaskBackgroundService.cs
@@ -77,9 +77,12 @@ namespace Tnb.WarehouseMgr
#region 定时
//_eventPublisher = App.GetRequiredService();
- CancellationTokenSource kittingOutAddCts = new();
- CancellationTokenSource kittingOutShippedCts = new();
- CancellationTokenSource setSortingCts = new();
+ //List toUserIds = new List() { "25398501929509" };
+ ////生成任务执行
+ //CancellationTokenSource genTaskCTS = new();
+ //CancellationTokenSource kittingOutAddCts = new();
+ //CancellationTokenSource kittingOutShippedCts = new();
+ //CancellationTokenSource setSortingCts = new();
//var wareHouseService = App.GetRequiredService();
//TimedTask(cts => wareHouseService.GenTaskExecute(cts), genTaskCTS);
@@ -119,8 +122,7 @@ namespace Tnb.WarehouseMgr
}));
}
});
-
- await GetDelayTask(timeType, interval);
+ await Task.Delay(1000);
}
}, token);
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs
index a6318045..64342d1d 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsEmptyOutstockService .cs
@@ -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().FirstAsync(it => it.bill_code == input.data[nameof(WmsEmptyOutstockH.bill_code)].ToString());
WmsPointH? sPoint = null;