From 30743623cd8781a5e757b9364ea6b2b2a0b5a944 Mon Sep 17 00:00:00 2001 From: "yang.lee" Date: Mon, 13 Nov 2023 10:49:29 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=9B=98=E7=82=B9?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=EF=BC=8C=E6=A0=B9=E6=8D=AE=E7=9B=98=E7=82=B9?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=8E=B7=E5=8F=96=E4=BB=BB=E5=8A=A1=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/WmsWareHouseConst.cs | 4 ++ .../Dto/Outputs/CheckTaskDetailOutput.cs | 44 ++++++++++++ .../Dto/Queries/CheckDetailQuery.cs | 34 +++++++++ .../Entity/WmsCheckstockH.cs | 9 ++- .../Tnb.WarehouseMgr/WmsCheckTaskService.cs | 70 +++++++++++++++++-- 5 files changed, 153 insertions(+), 8 deletions(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/CheckTaskDetailOutput.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/CheckDetailQuery.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index 0dc16b62..bec5a1b3 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -261,5 +261,9 @@ /// 组织Id(天益4厂) /// public const string AdministratorOrgId = "25193668006933"; + /// + /// 盘点任务计算状态-未结算 + /// + public const string CLOSINGSTATUS_WJS_ID = "27674058079509"; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/CheckTaskDetailOutput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/CheckTaskDetailOutput.cs new file mode 100644 index 00000000..bc7f2dd2 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Outputs/CheckTaskDetailOutput.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Dto.Outputs +{ + /// + /// 盘点任务明细输出类 + /// + public class CheckTaskDetailOutput + { + /// + /// 物料编号 + /// + public string material_code { get; set; } + /// + /// 批次 + /// + public string code_batch { get; set; } + /// + /// 库位编号 + /// + public string location_code { get; set; } + /// + ///载具编号 + /// + public string carry_code { get; set; } + /// + /// 理论库存数量 + /// + public decimal? pr_qty { get; set; } + /// + /// 结算状态 + /// + public string closing_status { get; set; } + /// + /// 已盘点数量 + /// + public decimal? qty { get; set; } + + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/CheckDetailQuery.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/CheckDetailQuery.cs new file mode 100644 index 00000000..62cb8db6 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Queries/CheckDetailQuery.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.DirectoryServices.Protocols; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tnb.WarehouseMgr.Entities.Enums; + +namespace Tnb.WarehouseMgr.Entities.Dto.Queries +{ + /// + /// 根据盘点类型获取任务明细查询参数 + /// + public class CheckDetailQuery + { + /// + /// 仓库Id + /// + public string warehouse_id { get; set; } + /// + /// 盘点类型 + /// + public EnumCheckType CheckType { get; set; } + /// + /// 物料Id + /// + public string material_id { get; set; } + /// + /// 区域ID列表 + /// + public List regionIds { get; set; } + } +} + diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockH.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockH.cs index ba095aa0..4d93f685 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockH.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsCheckstockH.cs @@ -103,5 +103,12 @@ public partial class WmsCheckstockH : BaseEntity /// 流程引擎Id /// public string? f_flowid { get; set; } - + /// + /// 物料ID + /// + public string? material_id { get; set; } + /// + /// 区域ID + /// + public string area_id { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs index 1a5a4593..170faaf5 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs @@ -11,12 +11,15 @@ using JNPF.VisualDev; using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Interfaces; using Mapster; +using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto; +using Tnb.WarehouseMgr.Entities.Dto.Outputs; +using Tnb.WarehouseMgr.Entities.Dto.Queries; using Tnb.WarehouseMgr.Entities.Enums; using Tnb.WarehouseMgr.Interfaces; @@ -122,6 +125,7 @@ namespace Tnb.WarehouseMgr _ = await _db.Insertable(details).ExecuteCommandAsync(); break; case EnumCheckType.物料盘点: + break; case EnumCheckType.批次盘点: break; @@ -129,14 +133,15 @@ namespace Tnb.WarehouseMgr //生成预任务信息 if (details.Count > 0 && carryCodes.Count > 0) { - // 判断当前仓库是否有盘点签收配置 + // 判断当前仓库是否有盘点签收配置 var wcsConf = await _db.Queryable().Where(it => it.warehouse_id == input.data[nameof(WmsCheckstockH.warehouse_id)].ToString() && it.enabled == 1) .FirstAsync(); BasLocation[] endLocs = Array.Empty(); int randomIndex = 0; if (wcsConf != null) { - if (wcsConf.location_id == null) { + if (wcsConf.location_id == null) + { throw new AppFriendlyException("盘点签收配置库位为空,请查看配置!", 500); } JArray? jsonArr = null; @@ -147,17 +152,19 @@ namespace Tnb.WarehouseMgr endLocs = await _db.Queryable().Where(it => it.wh_id == input.data[nameof(WmsCheckstockH.warehouse_id)].ToString() && locArr.Contains(it.id)).ToArrayAsync(); randomIndex = new Random().Next(0, endLocs.GetUpperBound(0)); } - else { + else + { throw new AppFriendlyException("盘点签收配置有误,请查看配置!", 500); } - + } - else { + else + { string[] locTypes = new[] { ((int)EnumLocationType.出库库位).ToString(), ((int)EnumLocationType.出入库位).ToString() }; - endLocs = await _db.Queryable().Where(it => it.wh_id == input.data[nameof(WmsCheckstockH.warehouse_id)].ToString() && locTypes.Contains(it.is_type)).ToArrayAsync(); + endLocs = await _db.Queryable().Where(it => it.wh_id == input.data[nameof(WmsCheckstockH.warehouse_id)].ToString() && locTypes.Contains(it.is_type)).ToArrayAsync(); randomIndex = new Random().Next(0, endLocs.GetUpperBound(0)); } - + List carrys = await _db.Queryable().Where(it => carryCodes.Select(x => x.carry_id).Distinct().Contains(it.id)).ToListAsync(); List curDetails = details.DistinctBy(x => x.carry_id).ToList(); List curCarryCodes = carryCodes.FindAll(x => curDetails.Select(d => d.carry_id).Contains(x.carry_id)); @@ -266,5 +273,54 @@ namespace Tnb.WarehouseMgr { return _db.Queryable().InnerJoin(joinExp).Where(whereExp).Select().ToListAsync(); } + /// + /// 根据盘点类型获取任务明细 + /// + /// + ///
{ + ///
warehouse_id:仓库ID + ///
CheckType:盘点类型 0 全库盘点、1 物料盘点 2 区域盘点 + ///
material_id:物料ID + ///
regionIds: 区域ID列表 + ///
} + /// + /// + [HttpGet] + public async Task GetTaskDetailByCheckType([FromQuery] CheckDetailQuery input) + { + var filterExpable = Expressionable.Create() + .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) + { + 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; + } + 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(); + var carryIds = carryCodes?.Select(x => x.carry_id) ?? Enumerable.Empty(); + var checkStockDs = await _db.Queryable().Where(it => carryIds.Contains(it.carry_id)).ToListAsync(); + List outputs = checkStockDs.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_code }).Select(x => new CheckTaskDetailOutput + { + material_code = x.Key.material_code, + code_batch = x.Key.code_batch, + location_code = x.Key.location_code, + carry_code = x.Key.carry_code, + pr_qty = x.Sum(d => d.pr_qty), + closing_status = WmsWareHouseConst.CLOSINGSTATUS_WJS_ID, + qty = x.Sum(d => d.qty), + }) + .ToList(); + return outputs; + } } } From 3c4147c963378494d61e4a393bbe37623b162fa3 Mon Sep 17 00:00:00 2001 From: hlb <894797954@qq.com> Date: Mon, 13 Nov 2023 11:15:25 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=9C=AA=E4=B8=8B=E5=8F=91=E9=A2=84=E4=BB=BB=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E9=94=81=E5=AE=9A=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index b31742e3..bfc3d27c 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -252,7 +252,7 @@ namespace Tnb.WarehouseMgr //获取所有未下发的预任务申请 List preTasks = await db.Queryable().InnerJoin((a, b) => a.startlocation_id == b.location_id && a.carry_id == b.id) .InnerJoin((a, b, c) => a.area_id == c.id) - .InnerJoin((a, b, c, d) => a.endlocation_id == d.id && d.is_use == "0" && d.is_lock == 0) + .InnerJoin((a, b, c, d) => a.endlocation_id == d.id && d.is_use == "0" ) .Where(a => a.status == WmsWareHouseConst.PRETASK_BILL_STATUS_DXF_ID && !string.IsNullOrWhiteSpace(a.startlocation_id)) .OrderBy(a => new { priority = SqlFunc.Desc(a.priority), a.bill_code }) .Select((a, b, c, d) => new WmsPretaskH From 149402ac439140cdde05e0886af6ace4e7c69b95 Mon Sep 17 00:00:00 2001 From: "yang.lee" Date: Mon, 13 Nov 2023 12:02:52 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E7=9B=98=E7=82=B9=E7=B1=BB=E5=9E=8B=E8=8E=B7=E5=8F=96=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=98=8E=E7=BB=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.WarehouseMgr/WmsCheckTaskService.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs index 170faaf5..6116d81e 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs @@ -37,6 +37,8 @@ namespace Tnb.WarehouseMgr private readonly IVisualDevService _visualDevService; private readonly IRunService _runService; private readonly IBillRullService _billRullService; + private static Dictionary _carryMap = new(); + public WmsCheckTaskService( ISqlSugarRepository repository, IWareHouseService wareHouseService, @@ -288,6 +290,11 @@ namespace Tnb.WarehouseMgr [HttpGet] public async Task GetTaskDetailByCheckType([FromQuery] CheckDetailQuery input) { + if(_carryMap.Count == 0) + { + _carryMap = await _db.Queryable().ToDictionaryAsync(x => x.id, x => x.carry_code); + } + var filterExpable = Expressionable.Create() .And((a, b, c) => a.wh_id == input.warehouse_id) .And((a, b, c) => a.is_type == ((int)EnumLocationType.存储库位).ToString()) @@ -307,17 +314,18 @@ namespace Tnb.WarehouseMgr .Where(filterExpable.ToExpression()) .Select() .ToListAsync(); - var carryIds = carryCodes?.Select(x => x.carry_id) ?? Enumerable.Empty(); - var checkStockDs = await _db.Queryable().Where(it => carryIds.Contains(it.carry_id)).ToListAsync(); - List outputs = checkStockDs.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_code }).Select(x => new CheckTaskDetailOutput + //var carryIds = carryCodes?.Select(x => x.carry_id) ?? Enumerable.Empty(); + //var checkStockDs = await _db.Queryable().Where(it => carryIds.Contains(it.carry_id)).ToListAsync(); + + 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_code = x.Key.carry_code, + carry_code = _carryMap[x.Key.carry_id]?.ToString() ?? string.Empty, pr_qty = x.Sum(d => d.pr_qty), closing_status = WmsWareHouseConst.CLOSINGSTATUS_WJS_ID, - qty = x.Sum(d => d.qty), + qty = 0, }) .ToList(); return outputs; From 18c3eb7183cc572ce150ed52522d5eaa75ff43b9 Mon Sep 17 00:00:00 2001 From: "yang.lee" Date: Mon, 13 Nov 2023 12:06:33 +0800 Subject: [PATCH 4/5] +1 --- WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs index 6116d81e..59ba69b9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs @@ -317,13 +317,13 @@ namespace Tnb.WarehouseMgr //var carryIds = carryCodes?.Select(x => x.carry_id) ?? Enumerable.Empty(); //var checkStockDs = await _db.Queryable().Where(it => carryIds.Contains(it.carry_id)).ToListAsync(); - List outputs = carryCodes.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_id }).Select(x => new WmsCheckstockD + List outputs = carryCodes.GroupBy(g => new { g.material_code, g.code_batch, g.location_code, g.carry_id }).Select(x => new CheckTaskDetailOutput { material_code = x.Key.material_code, code_batch = x.Key.code_batch, location_code = x.Key.location_code, carry_code = _carryMap[x.Key.carry_id]?.ToString() ?? string.Empty, - pr_qty = x.Sum(d => d.pr_qty), + pr_qty = x.Sum(d => d.codeqty), closing_status = WmsWareHouseConst.CLOSINGSTATUS_WJS_ID, qty = 0, }) From c86ad9d8722d031c18e9c6a741d07904695c0ba5 Mon Sep 17 00:00:00 2001 From: "yang.lee" Date: Mon, 13 Nov 2023 13:51:09 +0800 Subject: [PATCH 5/5] =?UTF-8?q?RedisBackGround=20=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E6=9A=82=E6=97=B6=E6=B3=A8=E6=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apihost/Tnb.API.Entry/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apihost/Tnb.API.Entry/Startup.cs b/apihost/Tnb.API.Entry/Startup.cs index 3dbfefd2..1efe0fb4 100644 --- a/apihost/Tnb.API.Entry/Startup.cs +++ b/apihost/Tnb.API.Entry/Startup.cs @@ -57,7 +57,7 @@ public class Startup : AppStartup //定时任务 services.AddHostedService(); - services.AddHostedService(); + //services.AddHostedService(); }