From 255f307c8d12ba551e1920dcd3bc9d925dafd0f3 Mon Sep 17 00:00:00 2001 From: "yang.lee" Date: Thu, 16 Nov 2023 15:15:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20=20=E7=9B=98=E7=82=B9?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Constraints/IUpdateEnabledEntity.cs | 13 ++++++++++ .../Entity/WmsElevatorH.part.cs | 5 ++-- .../IWmsBasicDataBaseService.cs | 13 ++++++++++ .../Tnb.WarehouseMgr/WareHouseService.cs | 8 +++--- .../Tnb.WarehouseMgr/WmsBasicDataBase`1.cs | 25 +++++++++---------- .../Tnb.WarehouseMgr/WmsCheckTaskService.cs | 17 ++++++------- .../Tnb.WarehouseMgr/WmsElevatorService.cs | 21 ++++++++++++++++ 7 files changed, 74 insertions(+), 28 deletions(-) create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/IUpdateEnabledEntity.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsBasicDataBaseService.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsElevatorService.cs diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/IUpdateEnabledEntity.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/IUpdateEnabledEntity.cs new file mode 100644 index 00000000..27dd0d89 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/Constraints/IUpdateEnabledEntity.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.Entity.Constraints +{ + public interface IUpdateEnabledEntity + { + public int enabled { get; set; } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsElevatorH.part.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsElevatorH.part.cs index 4709864f..8aab7106 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsElevatorH.part.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsElevatorH.part.cs @@ -1,4 +1,5 @@ using SqlSugar; +using Tnb.WarehouseMgr.Entities.Entity.Constraints; namespace Tnb.WarehouseMgr.Entities; @@ -6,7 +7,7 @@ namespace Tnb.WarehouseMgr.Entities; /// WMS电梯设定主表 /// -public partial class WmsElevatorH +public partial class WmsElevatorH : IUpdateEnabledEntity { [SugarColumn(IsIgnore = true)] public int end_floor { get; set; } @@ -64,6 +65,6 @@ public partial class WmsElevatorH /// 状态 /// [SugarColumn(ColumnName = "status")] - public int enable_mark { get; set; } + public int enabled { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsBasicDataBaseService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsBasicDataBaseService.cs new file mode 100644 index 00000000..da13df07 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsBasicDataBaseService.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Interfaces +{ + public interface IWmsBasicDataBaseService + { + Task IsEnabledMark(IEnumerable ids, int status); + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index c9c64737..a3598ce1 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -977,9 +977,9 @@ namespace Tnb.WarehouseMgr if (curEleDs?.Count > 0) { //当前电梯 - WmsElevatorH curEle = await _db.Queryable().SingleAsync(it => it.id == curEleDs.First().bill_id && it.enable_mark == 1); + WmsElevatorH curEle = await _db.Queryable().SingleAsync(it => it.id == curEleDs.First().bill_id && it.enabled == 1); //同电梯组电梯 - List sGpEle = await _db.Queryable().Where(it => it.elevator_group == curEle.elevator_group && it.id != curEle.id && it.enable_mark == 1).ToListAsync(); + List sGpEle = await _db.Queryable().Where(it => it.elevator_group == curEle.elevator_group && it.id != curEle.id && it.enabled == 1).ToListAsync(); if (curEle == null && sGpEle?.Count > 0) { @@ -1048,9 +1048,9 @@ namespace Tnb.WarehouseMgr if (curEleDs?.Count > 0) { //当前电梯 - WmsElevatorH curEle = await _db.Queryable().SingleAsync(it => it.id == curEleDs.First().bill_id && it.enable_mark == 1); + WmsElevatorH curEle = await _db.Queryable().SingleAsync(it => it.id == curEleDs.First().bill_id && it.enabled == 1); //同电梯组电梯 - List sGpEle = await _db.Queryable().Where(it => it.elevator_group == curEle.elevator_group && it.id != curEle.id && it.enable_mark == 1).ToListAsync(); + List sGpEle = await _db.Queryable().Where(it => it.elevator_group == curEle.elevator_group && it.id != curEle.id && it.enabled == 1).ToListAsync(); if (curEle == null && sGpEle?.Count > 0) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsBasicDataBase`1.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsBasicDataBase`1.cs index d9be1169..8a959749 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsBasicDataBase`1.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsBasicDataBase`1.cs @@ -3,9 +3,12 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Aop.Api.Domain; using JNPF.Common.Contracts; using Microsoft.AspNetCore.Mvc; using SqlSugar; +using Tnb.WarehouseMgr.Entities.Entity.Constraints; +using Tnb.WarehouseMgr.Interfaces; namespace Tnb.WarehouseMgr { @@ -13,17 +16,13 @@ namespace Tnb.WarehouseMgr /// Wms基础数据基类 /// /// - //public class WmsBasicDataBase : BaseWareHouseService where TEntity : BaseEntity, new() - //{ - // private readonly ISqlSugarClient _db; - // public WmsBasicDataBase() - // { - - // } - // [HttpPost] - // public async Task IsEnabledMark(IEnumerable ids,int status) - // { - - // } - //} + public class WmsBasicDataBase : BaseWareHouseService where TEntity : BaseEntity, IUpdateEnabledEntity, new() + { + protected ISqlSugarClient DbContext { get; set; } + [HttpPost] + public async Task IsEnabledMark(IEnumerable ids, int status) + { + return await DbContext.Updateable().SetColumns(it => it.enabled == status).ExecuteCommandHasChangeAsync(); + } + } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs index 04ed8495..3ed41882 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCheckTaskService.cs @@ -129,7 +129,7 @@ namespace Tnb.WarehouseMgr } } break; - case EnumCheckType.批次盘点: + case EnumCheckType.区域盘点: { if (areaIds?.Length > 0) { @@ -341,6 +341,11 @@ namespace Tnb.WarehouseMgr } Expression> filterExp = (a, b, c) => false; + + Expression> defaultFilterExp = (a, b, c) => a.wh_id == input.warehouse_id + && a.is_type == ((int)EnumLocationType.存储库位).ToString() + && c.is_lock == 0; + switch (input.CheckType) { case EnumCheckType.全库盘点: @@ -354,10 +359,7 @@ namespace Tnb.WarehouseMgr { if (!input.material_id.IsNullOrWhiteSpace()) { - filterExp = (a, b, c) => a.wh_id == input.warehouse_id - && b.material_id == input.material_id - && a.is_type == ((int)EnumLocationType.存储库位).ToString() - && c.is_lock == 0; + filterExp = defaultFilterExp.And((a, b, c) => b.material_id == input.material_id); } } break; @@ -365,10 +367,7 @@ namespace Tnb.WarehouseMgr { if (input.regionIds?.Count > 0) { - filterExp = (a, b, c) => a.wh_id == input.warehouse_id - && input.regionIds.Contains(a.region_id) - && a.is_type == ((int)EnumLocationType.存储库位).ToString() - && c.is_lock == 0; + filterExp = defaultFilterExp.And((a, b, c) => input.regionIds.Contains(a.region_id)); } } break; diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsElevatorService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsElevatorService.cs new file mode 100644 index 00000000..0231fd80 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsElevatorService.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SqlSugar; +using Tnb.WarehouseMgr.Entities; + +namespace Tnb.WarehouseMgr +{ + /// + /// 电梯业务类 + /// + public class WmsElevatorService : WmsBasicDataBase + { + public WmsElevatorService(ISqlSugarRepository repo) + { + DbContext = repo.AsSugarClient(); + } + } +}