在库物料导入

This commit is contained in:
2023-12-02 22:05:35 +08:00
parent 2d47e18d45
commit e9f773e5e5
3 changed files with 153 additions and 1 deletions

View File

@@ -0,0 +1,57 @@
using JNPF.Common.Contracts;
using JNPF.Common.Security;
using SqlSugar;
namespace Tnb.WarehouseMgr.Entities;
/// <summary>
/// 在库物料导入
/// </summary>
[SugarTable("wms_stk_temp")]
public partial class WmsStkTemp : BaseEntity<string>
{
public WmsStkTemp()
{
id = SnowflakeIdHelper.NextId();
}
/// <summary>
/// 库位
/// </summary>
public string? location_code { get; set; }
/// <summary>
/// 物料
/// </summary>
public string? material_code { get; set; }
/// <summary>
/// 规格型号
/// </summary>
public string? material_specification { get; set; }
/// <summary>
/// 批次
/// </summary>
public string? code_batch { get; set; }
/// <summary>
/// 箱号
/// </summary>
public string? container_no { get; set; }
/// <summary>
/// 数量
/// </summary>
public decimal codeqty { get; set; }
/// <summary>
/// 载具编号
/// </summary>
public string? carry_code { get; set; }
/// <summary>
/// 载具ID
/// </summary>
public string? carry_id { get; set; }
}

View File

@@ -0,0 +1,32 @@
using SqlSugar;
using Tnb.WarehouseMgr.Entities.Entity.Constraints;
namespace Tnb.WarehouseMgr.Entities;
/// <summary>
/// 在库物料导入
/// </summary>
public partial class WmsStkTemp
{
/// <summary>
/// 物料ID
/// </summary>
[SugarColumn(IsIgnore = true)]
public string material_id { get; set; } = string.Empty;
/// <summary>
/// 库位ID
/// </summary>
[SugarColumn(IsIgnore = true)]
public string location_id { get; set; } = string.Empty;
/// <summary>
/// 单位
/// </summary>
[SugarColumn(IsIgnore = true)]
public string unit_id { get; set; } = string.Empty;
}

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using JNPF.Common.Core.Manager;
using JNPF.Common.Extension;
using Microsoft.AspNetCore.Mvc;
using NPOI.SS.Formula.Functions;
@@ -10,12 +11,16 @@ using Org.BouncyCastle.Crypto;
using SqlSugar;
using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Entity;
using Tnb.WarehouseMgr.Entities.Enums;
namespace Tnb.WarehouseMgr
{
public class WmsInternalTempTestService : BaseWareHouseService
{
private readonly ISqlSugarClient _db;
private readonly IUserManager _userManager;
public WmsInternalTempTestService(ISqlSugarRepository<BasLocation> repo)
{
_db = repo.AsSugarClient();
@@ -27,7 +32,7 @@ namespace Tnb.WarehouseMgr
[HttpPost]
public async Task UpdateColAsync()
{
List<BasLocation> list = await _db.Queryable<BasLocation>().Where(it => it.location_code.StartsWith("CP-A", StringComparison.OrdinalIgnoreCase)).OrderBy(i => i.location_code).ToListAsync();
List<BasLocation> list = await _db.Queryable<BasLocation>().Where(it => it.location_code.StartsWith("CP-B", StringComparison.OrdinalIgnoreCase)).OrderBy(i => i.location_code).ToListAsync();
foreach (var loc in list)
{
var input = loc.location_code.Substring(loc.location_code.Length - 2);
@@ -36,5 +41,63 @@ namespace Tnb.WarehouseMgr
}
}
/// <summary>
/// 在库物料维护
/// </summary>
/// <returns></returns>
public async Task UpdateStkMinsync()
{
await _db.Ado.BeginTranAsync();
List<WmsStkTemp> list = await _db.Queryable<WmsStkTemp>().InnerJoin<BasMaterial>((a, b) => a.material_code==b.code)
.InnerJoin<BasLocation>((a, b, c) => a.location_code == c.location_code)
.Select((a, b, c) => new WmsStkTemp
{
material_id = b.id,
location_id = c.id,
unit_id = b.unit_id
}, true).ToListAsync();
foreach (var carrycode in list)
{
//更新载具条码及状态
WmsCarryCode wmsCarryCode = new();
wmsCarryCode.org_id = "24755469898005";
wmsCarryCode.barcode = carrycode.carry_code;
wmsCarryCode.carry_id = carrycode.carry_id;
wmsCarryCode.material_id = carrycode.material_id;
wmsCarryCode.material_code = carrycode.material_code;
wmsCarryCode.code_batch = carrycode.code_batch;
wmsCarryCode.codeqty = carrycode.codeqty;
wmsCarryCode.is_out = 0;
wmsCarryCode.location_id = carrycode.location_id;
wmsCarryCode.location_code = carrycode.location_code;
wmsCarryCode.unit_id = carrycode.unit_id;
wmsCarryCode.warehouse_id = WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID;
wmsCarryCode.create_id = "25241349546773";
wmsCarryCode.material_specification = carrycode.material_specification;
wmsCarryCode.container_no = carrycode.container_no;
wmsCarryCode.create_time = DateTime.Now;
if (wmsCarryCode.carry_id != null && wmsCarryCode.location_id != null)
{
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { carry_status = ((int)EnumCarryStatus.).ToString(), location_id = wmsCarryCode.location_id, location_code = wmsCarryCode.location_code }).Where(it => it.id == wmsCarryCode.carry_id).ExecuteCommandAsync();
}
else
{
await _db.Updateable<WmsCarryH>().SetColumns(it => new WmsCarryH { carry_status = ((int)EnumCarryStatus.).ToString() }).Where(it => it.id == wmsCarryCode.carry_id).ExecuteCommandAsync();
}
await _db.Insertable(wmsCarryCode).ExecuteCommandAsync();
//更新库位数据
if (wmsCarryCode.location_id != null)
{
await _db.Updateable<BasLocation>().SetColumns(it => new BasLocation { is_use = ((int)EnumCarryStatus.).ToString() }).Where(it => it.id == wmsCarryCode.location_id).ExecuteCommandAsync();
}
}
await _db.Ado.CommitTranAsync();
}
}
}