From e8d9f9af81f35c70a14134d02cc76c3a6d0d5c48 Mon Sep 17 00:00:00 2001 From: qianjiawei <1184704771@qq.com> Date: Wed, 20 Dec 2023 16:58:40 +0800 Subject: [PATCH] bug --- .../Tnb.ProductionMgr/RedisBackGround.cs | 4 +- .../Dto/Inputs/BarCodeInput.cs | 13 ++++ .../Entity/WmsPurchaseD.cs | 2 + .../WmsPDAScanInStockService.cs | 14 +++- .../Tnb.WarehouseMgr/WmsPurchaseService.cs | 68 +++++++++++++++++++ 5 files changed, 97 insertions(+), 4 deletions(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/BarCodeInput.cs diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index 991f642f..6674dfa0 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs @@ -157,7 +157,7 @@ namespace Tnb.ProductionMgr //扫码入库 private void ScanInStock(object state) { - var carry_code = "carry_code";//从数采读取 + var carry_code = "TestLX0001";//从数采读取 WmsCarryH? carry = _repository.AsSugarClient().Queryable().Single(it => it.carry_code == carry_code); if (carry != null) { @@ -168,7 +168,7 @@ namespace Tnb.ProductionMgr input.data.Add("barcode", carry_code); input.data.Add("codeqty", WmsCarryCode.codeqty);//条码数量 input.data.Add("material_code", WmsCarryCode.material_code); - input.data.Add("extras", WmsCarryCode.location_code);//location_code + input.data.Add("extras", carry.location_code!);//location_code input.data.Add("warehouse_id", WmsCarryCode.warehouse_id!); input.data.Add("bill_code", "");//采购收货单号 input.data.Add("code_batch", WmsCarryCode.code_batch!);//批次 diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/BarCodeInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/BarCodeInput.cs new file mode 100644 index 00000000..ce299495 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/BarCodeInput.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.Inputs +{ + public class BarCodeInput + { + public string? BillId { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs index 0e09271f..7d721ba0 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsPurchaseD.cs @@ -101,9 +101,11 @@ public partial class WmsPurchaseD : BaseEntity /// /// 规格型号 /// + [SugarColumn(IsIgnore = true)] public string? material_specification { get; set; } /// /// 箱号 /// + [SugarColumn(IsIgnore = true)] public string? container_no { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs index 5ace7920..0e5d6fc8 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs @@ -203,8 +203,18 @@ namespace Tnb.WarehouseMgr if (sPoint != null && ePoint != null) { - List points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); - if (points.Count <= 2) + List points=new List(); + try + { + points = await _wareHouseService.PathAlgorithms(sPoint.id, ePoint.id); + } + catch (Exception) + { + points.Add(sPoint); + points.Add(ePoint); + } + + if (points.Count < 2) { throw new AppFriendlyException("该路径不存在", 500); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index 6c61e35f..230fd054 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -148,5 +148,73 @@ namespace Tnb.WarehouseMgr { return await UpdateChackStatus(input); } + + [HttpPost] + public async Task BarCodePrint(BarCodeInput input) + { + if (input == null) + { + throw new AppFriendlyException(nameof(input), 500); + } + List barcodes = new(); + try + { + await _db.Ado.BeginTranAsync(); + if (_db.Queryable().Where(it => input.BillId == it.require_id).Any()) + { + throw new AppFriendlyException("条码已生成", 500); + }; + WmsPurchaseD WmsPurchaseD = await _db.Queryable().Where(it => input.BillId == it.id).FirstAsync(); + List wmsTempCodes = new(); + decimal? minPacking = (await _db.Queryable().FirstAsync(it => it.id == WmsPurchaseD.material_id))?.minpacking; + int codeNum = 0; + + if (minPacking.HasValue && minPacking.Value > 0) + { + int mod = (int)(WmsPurchaseD.purchase_arriveqty % minPacking.Value); + codeNum = (int)(mod > 0 ? (WmsPurchaseD.purchase_arriveqty / minPacking.Value) + 1 : WmsPurchaseD.purchase_arriveqty / minPacking.Value); + + for (int j = 0; j < codeNum; j++) + { + int index = j + 1; + string code = $"{WmsPurchaseD.material_code}{WmsPurchaseD.code_batch}{index.ToString().PadLeft(4, '0')}"; + WmsTempCode barCode = new() + { + material_id = WmsPurchaseD.material_id, + material_code = WmsPurchaseD.material_code, + barcode = code, + code_batch = WmsPurchaseD.code_batch, + material_specification = WmsPurchaseD.material_specification, + container_no = WmsPurchaseD.container_no, + codeqty = minPacking, + unit_id = WmsPurchaseD.unit_id, + is_lock = 0, + is_end = 0, + require_id = WmsPurchaseD.id, + require_code = WmsPurchaseD.id, + create_id = _userManager.UserId, + create_time = DateTime.Now + }; + if (index == codeNum) + barCode.codeqty = mod == 0 ? minPacking : mod; + wmsTempCodes.Add(barCode); + } + await _db.Insertable(wmsTempCodes).ExecuteCommandAsync(); + } + await _db.Ado.CommitTranAsync(); + barcodes.AddRange(wmsTempCodes.Select(p => p.barcode).ToList()); + if (barcodes?.Count > 0) + { + base.BarCodePrint(barcodes, 1); + } + } + + + catch (Exception) + { + await _db.Ado.RollbackTranAsync(); + throw; + } + } } }