diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsOutStockService.cs
index 004b2d31..f01d39f0 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsOutStockService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsOutStockService.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tnb.WarehouseMgr.Entities.Dto.Inputs;
namespace Tnb.WarehouseMgr.Interfaces
{
@@ -11,5 +12,11 @@ namespace Tnb.WarehouseMgr.Interfaces
///
public interface IWmsOutStockService
{
+ ///
+ /// MES申请出库
+ ///
+ ///
+ ///
+ Task MESCreateOutstock(MESCreateOutstockInput input);
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs b/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs
index 6e6e2613..c5915b60 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/PDATransferSignService.cs
@@ -16,6 +16,8 @@ using Tnb.WarehouseMgr.Entities.Enums;
using Mapster;
using JNPF.Common.Security;
using System.Collections.Immutable;
+using JNPF.Common.Core.Manager;
+using Tnb.WarehouseMgr.Interfaces;
//using JNPF.Extras.CollectiveOAuth.Utils;
namespace Tnb.WarehouseMgr
@@ -25,10 +27,14 @@ namespace Tnb.WarehouseMgr
private readonly ISqlSugarClient _db;
private readonly IDictionaryDataService _dictionaryDataService;
private static Dictionary _dicBizType = new();
- public PDATransferSignService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService)
+ private readonly IUserManager _userManager;
+ private readonly IWmsOutStockService _outstockService;
+ public PDATransferSignService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService,IUserManager userManager,IWmsOutStockService outStockService)
{
_db = repository.AsSugarClient();
_dictionaryDataService = dictionaryDataService;
+ _userManager = userManager;
+ _outstockService = outStockService;
}
///
@@ -133,5 +139,67 @@ namespace Tnb.WarehouseMgr
throw;
}
}
+ ///
+ /// 库存是否抵达最小库存
+ ///
+ ///
+ public async Task IsMinStorage()
+ {
+ try
+ {
+ List> mats = new List>();
+ 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)
+ {
+ Dictionary dic = new();
+ var minStock = itGroup.First().min_stock;
+ if (itGroup.Select(x => x.codeqty).Sum() <= minStock)
+ {
+ foreach (var a in itGroup)
+ {
+ dic.Add(nameof(a.material_id), a.material_id);
+ dic.Add(nameof(a.code), a.code);
+ dic.Add(nameof(a.minpacking), a.minpacking ?? 0);
+ }
+ mats.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()
+ {
+ material_id = mat["material_id"].ToString()!,
+ material_code = mat["code"].ToString()!,
+ pr_qty = mat["minpacking"].ParseToDecimal(),
+ };
+ input.outstockDs.Add(outstockD);
+ await _outstockService.MESCreateOutstock(input);
+ }
+ }
+ catch (Exception)
+ {
+
+ throw;
+ }
+ }
}
}
diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
index 67d3f20b..110667c6 100644
--- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
+++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs
@@ -37,6 +37,7 @@ using Senparc.NeuChar.Helpers;
using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen;
using Spire.Pdf.Widget;
using SqlSugar;
+using Swashbuckle.AspNetCore.SwaggerGen;
using Tnb.BasicData.Entities;
using Tnb.BasicData.Entities.Enums;
using Tnb.Common.Extension;
@@ -73,6 +74,7 @@ namespace Tnb.WarehouseMgr
_cacheManager = cacheManager;
}
+
///
/// 根据载具Id带出库位、仓库信息
///