From 3f6deb42044640e88b02656da36545f7e7c2b2f6 Mon Sep 17 00:00:00 2001 From: "yang.lee" Date: Tue, 14 Nov 2023 15:21:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=8E=B7=E5=8F=96=E9=9A=8F?= =?UTF-8?q?=E6=9C=BA=E6=95=B0=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsCheckTaskService.cs | 24 +++++++++---------- .../Tnb.WarehouseMgr/WmsOutStockService.cs | 4 ++-- .../WmsPurchaseAndSaleCommonService.cs | 6 ++--- .../Tnb.WarehouseMgr/WmsPurchaseService.cs | 3 ++- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs index 545a4c9c..04e6b6dc 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs @@ -290,7 +290,7 @@ namespace Tnb.WarehouseMgr [HttpGet] public async Task GetTaskDetailByCheckType([FromQuery] CheckDetailQuery input) { - if(_carryMap.Count == 0) + if (_carryMap.Count == 0) { _carryMap = await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.carry_code); } @@ -299,28 +299,26 @@ namespace Tnb.WarehouseMgr .And((a, b, c) => a.wh_id == input.warehouse_id) .And((a, b, c) => a.is_type == ((int)EnumLocationType.存储库位).ToString()) .And((a, b, c) => c.is_lock == 0); - - switch (input.CheckType) + filterExpable = input.CheckType switch { - case EnumCheckType.物料盘点: - filterExpable.AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id); - break; - case EnumCheckType.批次盘点: - filterExpable.AndIF(input.regionIds?.Count> 0, (a, b, c) => input.regionIds.Contains(a.region_id)); - break; - } + EnumCheckType.物料盘点 => filterExpable.AndIF(!string.IsNullOrEmpty(input.material_id), (a, b, c) => b.material_id == input.material_id), + EnumCheckType.批次盘点 => filterExpable.AndIF(input.regionIds?.Count > 0, (a, b, c) => input.regionIds.Contains(a.region_id)), + _ => filterExpable, + }; var carryCodes = await _db.Queryable().InnerJoin((a, b) => a.id == b.location_id) .InnerJoin((a, b, c) => b.carry_id == c.id) .Where(filterExpable.ToExpression()) .Select() .ToListAsync(); - - List outputs = carryCodes.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_id }).Select(x => new CheckTaskDetailOutput + + List outputs = carryCodes.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_id }).Select(x => new WmsCheckstockD { material_code = x.Key.material_code, code_batch = x.Key.code_batch, - location_code = x.Key.location_code, + carry_id = x.Key.carry_id, carry_code = _carryMap[x.Key.carry_id]?.ToString() ?? string.Empty, + location_id = x.FirstOrDefault(y => y.location_code == x.Key.location_code)?.location_id ?? string.Empty, + location_code = x.Key.location_code, pr_qty = x.Sum(d => d.codeqty), closing_status = WmsWareHouseConst.CLOSINGSTATUS_WJS_ID, qty = 0, diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs index aeeae4be..0fe26b25 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsOutStockService.cs @@ -114,7 +114,7 @@ namespace Tnb.WarehouseMgr List freeLocIds = fLocIds.Except(minTaskNumLocs.Select(x => x.endlocation_id)).ToList(); if (freeLocIds?.Count > 0) { - int rIdx = new Random().Next(0, freeLocIds.Count); + int rIdx = Random.Shared.Next(0, freeLocIds.Count); loc = await _db.Queryable().SingleAsync(it => it.id == freeLocIds[rIdx]); } else @@ -125,7 +125,7 @@ namespace Tnb.WarehouseMgr } else if (minTaskNumLocs?.Count < 1) { - int rIdx = new Random().Next(0, fLocIds.Count); + int rIdx = Random.Shared.Next(0, fLocIds.Count); loc = await _db.Queryable().SingleAsync(it => it.id == fLocIds[rIdx]); } input.data[nameof(WmsOutstockH.location_id)] = loc.id; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseAndSaleCommonService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseAndSaleCommonService.cs index 50ddc332..4359cf20 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseAndSaleCommonService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseAndSaleCommonService.cs @@ -28,7 +28,7 @@ namespace Tnb.WarehouseMgr /// 采购收货、销售发货,通用业务类 /// /// - public class WmsPurchaseAndSaleCommonService : BaseWareHouseService where TSubEntity : BaseEntity, IPurchaseAndSaleEntity, IPurchaseAndSaleQueryEntity + public class WmsPurchaseAndSaleCommonService : BaseWareHouseService where TSubEntity : BaseEntity, IPurchaseAndSaleEntity, IPurchaseAndSaleQueryEntity,new() { private readonly ISqlSugarClient _db; private readonly IUserManager _userManager; @@ -86,7 +86,7 @@ namespace Tnb.WarehouseMgr x.modify_time = DateTime.Now; }); - await _db.Updateable(purchaseDs).ExecuteCommandAsync(); + await _db.Updateable(purchaseDs).UpdateColumns(it => new { it.purchase_prqty, it.line_status }).ExecuteCommandAsync(); if (purchaseDs.All(x => x.line_status == WmsWareHouseConst.BILLSTATUS_COMPLETE_ID)) { @@ -125,7 +125,7 @@ namespace Tnb.WarehouseMgr return await _db.Updateable().SetColumns(it => it.audit_status == (int)input.auditType).Where(it => input.ids.Contains(it.id)).ExecuteCommandHasChangeAsync(); } - protected Task SyncMesData(string maintableId,List materialIds,EnumTriggerEvent triggerEvent) + protected Task SyncMesData(string maintableId, List materialIds, EnumTriggerEvent triggerEvent) { CreateTaskEntity ctEntity = new(); ctEntity.maintableid = maintableId; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs index ba36e7ce..ec412960 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPurchaseService.cs @@ -80,6 +80,7 @@ namespace Tnb.WarehouseMgr instockDs = purchaseDs.Adapt>(); instockDs.ForEach(instockD => { + instockD.bill_id =instock.id; instockD.create_id = _userManager.UserId; instockD.create_time = DateTime.Now; instockD.org_id = _userManager.User.OrganizeId; @@ -87,7 +88,7 @@ namespace Tnb.WarehouseMgr await _db.Insertable(instockDs).ExecuteCommandAsync(); } //通知Mes接口 - _ = SyncMesData(instock.id, instockDs.Select(x => x.material_id).ToList(), EnumTriggerEvent.入厂检按物料编号); + //_ = SyncMesData(instock.id, instockDs.Select(x => x.material_id).ToList(), EnumTriggerEvent.入厂检按物料编号); await _db.Ado.CommitTranAsync(); } catch (Exception ex)