Merge branch 'dev' of https://git.tuotong-tech.com/tnb/tnb.server into dev
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Tnb.WarehouseMgr.Entities.Dto.Inputs;
|
||||||
|
|
||||||
namespace Tnb.WarehouseMgr.Interfaces
|
namespace Tnb.WarehouseMgr.Interfaces
|
||||||
{
|
{
|
||||||
@@ -11,5 +12,11 @@ namespace Tnb.WarehouseMgr.Interfaces
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IWmsOutStockService
|
public interface IWmsOutStockService
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// MES申请出库
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task<dynamic> MESCreateOutstock(MESCreateOutstockInput input);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ using Tnb.WarehouseMgr.Entities.Enums;
|
|||||||
using Mapster;
|
using Mapster;
|
||||||
using JNPF.Common.Security;
|
using JNPF.Common.Security;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
|
using JNPF.Common.Core.Manager;
|
||||||
|
using Tnb.WarehouseMgr.Interfaces;
|
||||||
//using JNPF.Extras.CollectiveOAuth.Utils;
|
//using JNPF.Extras.CollectiveOAuth.Utils;
|
||||||
|
|
||||||
namespace Tnb.WarehouseMgr
|
namespace Tnb.WarehouseMgr
|
||||||
@@ -25,10 +27,14 @@ namespace Tnb.WarehouseMgr
|
|||||||
private readonly ISqlSugarClient _db;
|
private readonly ISqlSugarClient _db;
|
||||||
private readonly IDictionaryDataService _dictionaryDataService;
|
private readonly IDictionaryDataService _dictionaryDataService;
|
||||||
private static Dictionary<string, object> _dicBizType = new();
|
private static Dictionary<string, object> _dicBizType = new();
|
||||||
public PDATransferSignService(ISqlSugarRepository<WmsDistaskH> repository, IDictionaryDataService dictionaryDataService)
|
private readonly IUserManager _userManager;
|
||||||
|
private readonly IWmsOutStockService _outstockService;
|
||||||
|
public PDATransferSignService(ISqlSugarRepository<WmsDistaskH> repository, IDictionaryDataService dictionaryDataService,IUserManager userManager,IWmsOutStockService outStockService)
|
||||||
{
|
{
|
||||||
_db = repository.AsSugarClient();
|
_db = repository.AsSugarClient();
|
||||||
_dictionaryDataService = dictionaryDataService;
|
_dictionaryDataService = dictionaryDataService;
|
||||||
|
_userManager = userManager;
|
||||||
|
_outstockService = outStockService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -133,5 +139,67 @@ namespace Tnb.WarehouseMgr
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 库存是否抵达最小库存
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task IsMinStorage()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<Dictionary<string, object>> mats = new List<Dictionary<string, object>>();
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
Dictionary<string, object> 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<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()
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ using Senparc.NeuChar.Helpers;
|
|||||||
using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen;
|
using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen;
|
||||||
using Spire.Pdf.Widget;
|
using Spire.Pdf.Widget;
|
||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
using Tnb.BasicData.Entities;
|
using Tnb.BasicData.Entities;
|
||||||
using Tnb.BasicData.Entities.Enums;
|
using Tnb.BasicData.Entities.Enums;
|
||||||
using Tnb.Common.Extension;
|
using Tnb.Common.Extension;
|
||||||
@@ -74,6 +75,7 @@ namespace Tnb.WarehouseMgr
|
|||||||
_cacheManager = cacheManager;
|
_cacheManager = cacheManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 根据载具Id带出库位、仓库信息
|
/// 根据载具Id带出库位、仓库信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user