From e9f773e5e58d80e540c1665820890c9902ebf3dd Mon Sep 17 00:00:00 2001 From: hlb <894797954@qq.com> Date: Sat, 2 Dec 2023 22:05:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E5=BA=93=E7=89=A9=E6=96=99=E5=AF=BC?= =?UTF-8?q?=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/WmsStkTemp.cs | 57 ++++++++++++++++ .../Entity/WmsStkTemp.part.cs | 32 +++++++++ .../WmsInternalTempTestService.cs | 65 ++++++++++++++++++- 3 files changed, 153 insertions(+), 1 deletion(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStkTemp.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStkTemp.part.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStkTemp.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStkTemp.cs new file mode 100644 index 00000000..67d4e4f2 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStkTemp.cs @@ -0,0 +1,57 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.WarehouseMgr.Entities; + +/// +/// 在库物料导入 +/// +[SugarTable("wms_stk_temp")] +public partial class WmsStkTemp : BaseEntity +{ + public WmsStkTemp() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 库位 + /// + public string? location_code { get; set; } + + /// + /// 物料 + /// + public string? material_code { get; set; } + + /// + /// 规格型号 + /// + public string? material_specification { get; set; } + + /// + /// 批次 + /// + public string? code_batch { get; set; } + + /// + /// 箱号 + /// + public string? container_no { get; set; } + + /// + /// 数量 + /// + public decimal codeqty { get; set; } + + /// + /// 载具编号 + /// + public string? carry_code { get; set; } + + /// + /// 载具ID + /// + public string? carry_id { get; set; } + +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStkTemp.part.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStkTemp.part.cs new file mode 100644 index 00000000..f96bd255 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsStkTemp.part.cs @@ -0,0 +1,32 @@ +using SqlSugar; +using Tnb.WarehouseMgr.Entities.Entity.Constraints; + +namespace Tnb.WarehouseMgr.Entities; + +/// +/// 在库物料导入 +/// + +public partial class WmsStkTemp +{ + /// + /// 物料ID + /// + [SugarColumn(IsIgnore = true)] + public string material_id { get; set; } = string.Empty; + /// + /// 库位ID + /// + [SugarColumn(IsIgnore = true)] + public string location_id { get; set; } = string.Empty; + + /// + /// 单位 + /// + [SugarColumn(IsIgnore = true)] + + public string unit_id { get; set; } = string.Empty; + + + +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInternalTempTestService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInternalTempTestService.cs index a509541d..581b119a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInternalTempTestService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInternalTempTestService.cs @@ -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 repo) { _db = repo.AsSugarClient(); @@ -27,7 +32,7 @@ namespace Tnb.WarehouseMgr [HttpPost] public async Task UpdateColAsync() { - List list = await _db.Queryable().Where(it => it.location_code.StartsWith("CP-A", StringComparison.OrdinalIgnoreCase)).OrderBy(i => i.location_code).ToListAsync(); + List list = await _db.Queryable().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 } } + /// + /// 在库物料维护 + /// + /// + public async Task UpdateStkMinsync() + { + await _db.Ado.BeginTranAsync(); + List list = await _db.Queryable().InnerJoin((a, b) => a.material_code==b.code) + .InnerJoin((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().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().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().SetColumns(it => new BasLocation { is_use = ((int)EnumCarryStatus.占用).ToString() }).Where(it => it.id == wmsCarryCode.location_id).ExecuteCommandAsync(); + } + + } + await _db.Ado.CommitTranAsync(); + + } } }