1
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.BasicData.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 物料入库仓库
|
||||
/// </summary>
|
||||
[SugarTable("bas_material_inbound_wh")]
|
||||
public partial class BasMaterialInboundWh : BaseEntity<string>
|
||||
{
|
||||
public BasMaterialInboundWh()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 物料id
|
||||
/// </summary>
|
||||
public string? material_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仓库id
|
||||
/// </summary>
|
||||
public string? wh_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大库存
|
||||
/// </summary>
|
||||
public int? max_stock { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最小库存
|
||||
/// </summary>
|
||||
public int? min_stock { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 安全库存
|
||||
/// </summary>
|
||||
public int? safe_stock { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.BasicData.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 物料发料仓库
|
||||
/// </summary>
|
||||
[SugarTable("bas_material_send_warehouse")]
|
||||
public partial class BasMaterialSendWarehouse : BaseEntity<string>
|
||||
{
|
||||
public BasMaterialSendWarehouse()
|
||||
{
|
||||
id = SnowflakeIdHelper.NextId();
|
||||
}
|
||||
/// <summary>
|
||||
/// 物料id
|
||||
/// </summary>
|
||||
public string? material_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 仓库id
|
||||
/// </summary>
|
||||
public string? wh_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最大库存
|
||||
/// </summary>
|
||||
public int? max_stock { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最小库存
|
||||
/// </summary>
|
||||
public int? min_stock { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 安全库存
|
||||
/// </summary>
|
||||
public int? safe_stock { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using JNPF.Common.Contracts;
|
||||
using JNPF.Common.Security;
|
||||
using SqlSugar;
|
||||
|
||||
namespace Tnb.WarehouseMgr.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// 库存报表
|
||||
/// </summary>
|
||||
public partial class WmsStockReportH
|
||||
{
|
||||
/// <summary>
|
||||
/// 物料名称
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string mater_name { get; set; }
|
||||
/// <summary>
|
||||
/// 明细列表
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore =true)]
|
||||
public List<WmsStockReportCode> Details { get; set; }
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public decimal codeqty { get; set; }
|
||||
|
||||
}
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.VisualDev;
|
||||
using JNPF.VisualDev.Entitys.Dto.VisualDevModelData;
|
||||
using Mapster;
|
||||
using MimeKit.Cryptography;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
@@ -16,15 +23,68 @@ namespace Tnb.WarehouseMgr
|
||||
[OverideVisualDev(ModuleConsts.MODULE_WMSSTOCKREPORT_ID)]
|
||||
public class WmsStockReportService : BaseWareHouseService
|
||||
{
|
||||
public WmsStockReportService()
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
|
||||
public WmsStockReportService(ISqlSugarRepository<WmsCarryCode> repository, IUserManager userManager)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_userManager = userManager;
|
||||
OverideFuncs.GetListAsync = GetListAsync;
|
||||
}
|
||||
|
||||
private async Task<dynamic> GetListAsync(VisualDevModelListQueryInput input)
|
||||
{
|
||||
|
||||
return null;
|
||||
var items = await _db.Queryable<WmsCarryCode>().InnerJoin<BasMaterial>((a, b) => a.material_id == b.id)
|
||||
.InnerJoin<BasMaterialSendWarehouse>((a, b, c) => b.id == c.material_id)
|
||||
.InnerJoin<WmsCarryH>((a, b, c, d) => a.carry_id == d.id)
|
||||
.InnerJoin<BasLocation>((a, b, c, d, e) => d.location_id == e.id)
|
||||
.Where((a, b, c, d, e) => e.is_type == ((int)EnumLocationType.存储库位).ToString())
|
||||
.Select((a, b, c, d, e) => new WmsStockReportH
|
||||
{
|
||||
warehouse_id = a.warehouse_id,
|
||||
mater_name = b.name,
|
||||
create_time = a.create_time,
|
||||
create_id = a.create_id,
|
||||
}, true)
|
||||
.ToListAsync();
|
||||
var carryCodes = await _db.Queryable<WmsCarryCode>().ToListAsync();
|
||||
var result = items.GroupBy(g => new { g.warehouse_id, g.material_id }).Select(itGroup =>
|
||||
{
|
||||
WmsStockReportH stockReport = new();
|
||||
stockReport.material_code = items.Find(x => x.warehouse_id == itGroup.Key.warehouse_id && x.material_id == itGroup.Key.material_id)?.material_code;
|
||||
stockReport.mater_name = items.Find(x => x.warehouse_id == itGroup.Key.warehouse_id && x.material_id == itGroup.Key.material_id)?.mater_name ?? string.Empty;
|
||||
stockReport.existing_stock_qty = itGroup.Sum(d => d.codeqty);
|
||||
stockReport.max_stock = items.Find(t => t.warehouse_id == itGroup.Key.warehouse_id && t.material_id == itGroup.Key.material_id)?.max_stock;
|
||||
stockReport.safe_stock = items.Find(t => t.warehouse_id == itGroup.Key.warehouse_id && t.material_id == itGroup.Key.material_id)?.safe_stock;
|
||||
stockReport.min_stock = items.Find(t => t.warehouse_id == itGroup.Key.warehouse_id && t.material_id == itGroup.Key.material_id)?.min_stock;
|
||||
stockReport.min_stock = items.Find(t => t.warehouse_id == itGroup.Key.warehouse_id && t.material_id == itGroup.Key.material_id)?.min_stock;
|
||||
stockReport.storage_valid_day = items.Find(t => t.material_id == itGroup.Key.material_id)?.storage_valid_day;
|
||||
stockReport.early_warn_day = items.Find(t => t.material_id == itGroup.Key.material_id)?.early_warn_day;
|
||||
stockReport.create_id = _userManager.UserId;
|
||||
stockReport.create_time = DateTime.Now;
|
||||
if (stockReport.storage_valid_day.HasValue)
|
||||
{
|
||||
decimal expired_warning_qty = 0;
|
||||
foreach (var item in itGroup)
|
||||
{
|
||||
if (DateTime.Now.Subtract(item.create_time.Value).TotalDays >= (item.storage_valid_day - item.early_warn_day))
|
||||
{
|
||||
expired_warning_qty += item.codeqty;
|
||||
}
|
||||
}
|
||||
stockReport.expired_warning_qty = expired_warning_qty;
|
||||
}
|
||||
var curCarryCodes = carryCodes.FindAll(x => x.warehouse_id == itGroup.Key.warehouse_id && x.material_id == itGroup.Key.material_id);
|
||||
stockReport.Details = curCarryCodes.Adapt<List<WmsStockReportCode>>();
|
||||
stockReport.Details.ForEach(x =>
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.report_id = stockReport.id;
|
||||
});
|
||||
return stockReport;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user