diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index c6fa8973..218d355b 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -124,6 +124,10 @@ namespace Tnb.WarehouseMgr.Entities.Consts /// 预任务生成业务类型-配送申请 /// public const string BIZTYPE_WMSDELIVERY_ID = "26585291847957"; + /// + /// 条码打印状态-已完成 + /// + public const string BARCODE_PRINT_STATUS_COMPLETE_ID = "26191372853541"; } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/BarCodePrintInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/BarCodePrintInput.cs new file mode 100644 index 00000000..bae70e4a --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/BarCodePrintInput.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.Inputs +{ + /// + /// 条码打印输入参数 + /// + public class BarCodePrintInput + { + /// + /// 入库申请单Id列表 + /// + public List BillIds { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/SacnBarCodeInStockInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/SacnBarCodeInStockInput.cs new file mode 100644 index 00000000..f27031ce --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/SacnBarCodeInStockInput.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.Inputs +{ + /// + /// 扫码入库输入参数 + /// + public class SacnBarCodeInStockInput + { + /// + /// 入库单ID + /// + public string bill_id { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsTempCode.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsTempCode.cs new file mode 100644 index 00000000..edc9cfd4 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsTempCode.cs @@ -0,0 +1,107 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.WarehouseMgr.Entities; + +/// +/// 条码临时表 +/// +[SugarTable("wms_temp_code")] +public partial class WmsTempCode : BaseEntity +{ + public WmsTempCode() + { + id = SnowflakeIdHelper.NextId(); + } + /// + /// 所属组织 + /// + public string? org_id { get; set; } + + /// + /// 物料ID + /// + public string? material_id { get; set; } + + /// + /// 物料编号 + /// + public string? material_code { get; set; } + + /// + /// 条码编号 + /// + public string? barcode { get; set; } + + /// + /// 批次 + /// + public string? code_batch { get; set; } + + /// + /// 条码数量 + /// + public int? codeqty { get; set; } + + /// + /// 单位ID + /// + public string? unit_id { get; set; } + + /// + /// 是否锁定 + /// + public int? is_lock { get; set; } + + /// + /// 是否结束 + /// + public string? is_end { get; set; } + + /// + /// 需求单据ID + /// + public string? require_id { get; set; } + + /// + /// 需求单据代码 + /// + public string? require_code { get; set; } + + /// + /// 备注 + /// + public string? remark { get; set; } + + /// + /// 扩展 + /// + public string? extras { get; set; } + + /// + /// 创建用户 + /// + public string? create_id { get; set; } + + /// + /// 创建时间 + /// + public DateTime? create_time { get; set; } + + /// + /// 修改用户 + /// + public string? modify_id { get; set; } + + /// + /// 修改时间 + /// + public DateTime? modify_time { get; set; } + + /// + /// 时间戳 + /// + public DateTime? time_stamp { get; set; } + +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs index 530b0994..4b3db4c6 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsInStockService.cs @@ -3,11 +3,15 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using JNPF.Common.Core.Manager; using JNPF.Systems.Interfaces.System; using Microsoft.AspNetCore.Mvc; +using Minio.DataModel; using SqlSugar; +using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Consts; +using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.WarehouseMgr.Interfaces; namespace Tnb.WarehouseMgr @@ -19,10 +23,12 @@ namespace Tnb.WarehouseMgr { private readonly ISqlSugarClient _db; private readonly IDictionaryDataService _dictionaryDataService; - public WmsInStockService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService) + private readonly IUserManager _userManager; + public WmsInStockService(ISqlSugarRepository repository, IDictionaryDataService dictionaryDataService, IUserManager userManager) { _db = repository.AsSugarClient(); _dictionaryDataService = dictionaryDataService; + _userManager = userManager; } /// /// 根据入库申请单ID获取申请单明细信息 @@ -41,9 +47,66 @@ namespace Tnb.WarehouseMgr /// /// 条码打印 /// + /// + ///
{ + ///
BillIds:入库申请单Id列表 + ///
} + /// + /// + /// + /// + [HttpPost] + public async Task BarCodePrint(BarCodePrintInput input) + { + if (input == null) throw new ArgumentNullException("input"); + if (input.BillIds == null || input.BillIds.Count == 0) throw new ArgumentException($"parameter {nameof(input.BillIds)} not be null or zero"); + try + { + await _db.Ado.BeginTranAsync(); + + var inStockDetails = await _db.Queryable().Where(it => input.BillIds.Contains(it.bill_id)).ToListAsync(); + if (inStockDetails?.Count > 0) + { + List wmsTempCodes = new(); + for (int i = 0; i < inStockDetails.Count; i++) + { + WmsTempCode barCode = new(); + barCode.org_id = inStockDetails[i].org_id; + barCode.material_id = inStockDetails[i].material_id; + barCode.material_code = inStockDetails[i].material_code; + var code = $"{inStockDetails[i].material_code}{inStockDetails[i].code_batch}{(i + 1).ToString().PadLeft(4, '0')}"; + barCode.barcode = code; + barCode.code_batch = inStockDetails[i].code_batch; + barCode.codeqty = (int?)(await _db.Queryable().FirstAsync(it => it.id == inStockDetails[i].material_id))?.minpacking; + barCode.unit_id = inStockDetails[i].unit_id; + barCode.is_lock = 0; + barCode.is_end = "0"; + barCode.require_id = input.BillIds[i]; + barCode.require_code = (await _db.Queryable().SingleAsync(it => it.id == input.BillIds[i])).bill_code; + barCode.create_id = _userManager.UserId; + barCode.create_time = DateTime.Now; + wmsTempCodes.Add(barCode); + } + var row = await _db.Insertable(wmsTempCodes).ExecuteCommandAsync(); + if (row > 0) + { + await _db.Updateable().SetColumns(it => new WmsInstockH { print_status = WmsWareHouseConst.BARCODE_PRINT_STATUS_COMPLETE_ID }).Where(it => input.BillIds.Contains(it.id)).ExecuteCommandAsync(); + } + } + + await _db.Ado.CommitTranAsync(); + } + catch (Exception) + { + await _db.Ado.RollbackTranAsync(); + } + } + /// + /// 扫码入库 + /// /// [HttpPost] - public async Task BarCodePrint() + public async Task SacnBarCodeInStock() { }