From e81ea21af671db1c213d6ffc32d2f0a354afffc9 Mon Sep 17 00:00:00 2001 From: "DEVICE8\\12494" Date: Tue, 6 Jun 2023 08:33:07 +0800 Subject: [PATCH] =?UTF-8?q?wms=E5=BA=93=E6=88=BF=E4=B8=9A=E5=8A=A1?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/BasLocation.cs | 7 +- .../Enums/EnumLocationType.cs | 20 +++ .../IBasLocationService.cs | 22 +++ BasicData/Tnb.BasicData/BasLocationService.cs | 50 ++++++ .../Enums/EnumLocationType.cs | 20 +++ .../IWareHouseService.cs | 15 ++ .../IWmsDeliveryService.cs | 15 ++ .../Tnb.WarehouseMgr/WareHouseService.cs | 163 ++++++++++++++++++ .../Tnb.WarehouseMgr/WmsDeliveryService.cs | 102 +++++++++++ 9 files changed, 412 insertions(+), 2 deletions(-) create mode 100644 BasicData/Tnb.BasicData.Entities/Enums/EnumLocationType.cs create mode 100644 BasicData/Tnb.BasicData.Interfaces/IBasLocationService.cs create mode 100644 BasicData/Tnb.BasicData/BasLocationService.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumLocationType.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsDeliveryService.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs create mode 100644 WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs index f7be7566..39844def 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasLocation.cs @@ -57,7 +57,7 @@ public partial class BasLocation : BaseEntity /// /// 位置序号 /// - public int seq { get; set; } + public int loc_line { get; set; } /// /// 创建用户 @@ -113,5 +113,8 @@ public partial class BasLocation : BaseEntity /// 库位名称 /// public string? location_name { get; set; } - + /// + /// 列 + /// + public int loc_column { get; set; } } diff --git a/BasicData/Tnb.BasicData.Entities/Enums/EnumLocationType.cs b/BasicData/Tnb.BasicData.Entities/Enums/EnumLocationType.cs new file mode 100644 index 00000000..785a10fb --- /dev/null +++ b/BasicData/Tnb.BasicData.Entities/Enums/EnumLocationType.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.BasicData.Entities.Enums +{ + /// + /// 库位类型 + /// + public enum EnumLocationType + { + 存储库位 = 0, + 入库库位, + 出库库位, + 出入库位, + 分拣库位, + } +} diff --git a/BasicData/Tnb.BasicData.Interfaces/IBasLocationService.cs b/BasicData/Tnb.BasicData.Interfaces/IBasLocationService.cs new file mode 100644 index 00000000..f3ddd99c --- /dev/null +++ b/BasicData/Tnb.BasicData.Interfaces/IBasLocationService.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tnb.BasicData.Entities; + +namespace Tnb.BasicData.Interfaces +{ + /// + /// 库位服务接口 + /// + public interface IBasLocationService + { + /// + /// 根据库位id获取库位信息 + /// + /// 库位Ids + /// + Task> GetLocationInfobyIds(IEnumerable locIds); + } +} diff --git a/BasicData/Tnb.BasicData/BasLocationService.cs b/BasicData/Tnb.BasicData/BasLocationService.cs new file mode 100644 index 00000000..7a71e461 --- /dev/null +++ b/BasicData/Tnb.BasicData/BasLocationService.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Cells.Drawing; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.BasicData.Entities.Enums; +using Tnb.BasicData.Interfaces; + +namespace Tnb.BasicData +{ + /// + /// 库位资料服务 + /// + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 1102)] + [Route("api/[area]/[controller]/[action]")] + public class BasLocationService : IBasLocationService, IDynamicApiController, ITransient + { + private readonly ISqlSugarClient _db; + public BasLocationService(ISqlSugarRepository repository) + { + _db = repository.AsSugarClient(); + } + /// + /// 获取非存储库位载具列表 + /// + /// + [HttpGet] + public async Task GetUnStoreLocationListByCarryId([FromRoute]string carryId) + { + + var items = await _db.Queryable().Where(it => !string.IsNullOrEmpty(it.is_type) && Convert.ToInt32(it.is_type) != (int)EnumLocationType.存储库位).ToListAsync(); + return items; + } + + + public async Task> GetLocationInfobyIds(IEnumerable locIds) + { + if (locIds == null) throw new ArgumentNullException(nameof(locIds)); + if (!locIds.Any()) throw new ArithmeticException($"parameter locIds.Count is not be empty"); + var items = await _db.Queryable().Where(it => locIds.Contains(it.id)).ToListAsync(); + return items; + } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumLocationType.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumLocationType.cs new file mode 100644 index 00000000..68e38397 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Enums/EnumLocationType.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Entities.Enums +{ + /// + /// 库位类型 + /// + public enum EnumLocationType + { + 存储库位 = 0, + 入库库位, + 出库库位, + 出入库位, + 分拣库位, + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs new file mode 100644 index 00000000..3b7f5f97 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWareHouseService.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Interfaces +{ + /// + /// 库房业务(出入库)接口 + /// + public interface IWareHouseService + { + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsDeliveryService.cs new file mode 100644 index 00000000..ffc91f56 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsDeliveryService.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tnb.WarehouseMgr.Interfaces +{ + /// + /// Wms配送申请服务接口 + /// + public interface IWmsDeliveryService + { + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs new file mode 100644 index 00000000..6a92fb54 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -0,0 +1,163 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Cells.Drawing; +using JNPF.Common.Extension; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.BasicData.Entities.Enums; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Interfaces; + +namespace Tnb.WarehouseMgr +{ + /// + /// 库房业务类(出入库) + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class WareHouseService : IWareHouseService, IDynamicApiController, ITransient + { + private readonly ISqlSugarClient _db; + public WareHouseService(ISqlSugarRepository repository) + { + _db = repository.AsSugarClient(); + } + /// + /// 根据载具Id带出库位、仓库信息 + /// + /// 载具id + /// + /// returns: + ///
{ + ///
carry_id:载具Id + ///
carry_name:载具名称 + ///
location_id:库位Id + ///
location_name:库位名称 + ///
warehouse_id:库房Id + ///
warehouse_name:库房名称 + ///
} + ///
+ [HttpGet] + public async Task GetLocationAndWorkHouseByCarryId([FromRoute] string carryId) + { + var items = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id) + .LeftJoin((a, b, c) => b.wh_id == c.id) + .Where(a => a.id == carryId) + .Select((a, b, c) => new + { + carry_id = a.id, + carry_name = a.carry_name, + location_id = b.id, + + location_name = b.location_name, + warehouse_id = c.id, + warehouse_name = c.whname, + }) + .ToListAsync(); + return items; + } + /// + /// 获取载具信息(入库业务) 当前载具启用;未锁定;如果有库位信息,库位不能为存储库位,出库库位,分拣库位; + /// + /// + /// returns: + ///
{ + ///
carry_id:载具Id + ///
carry_code:载具编号 + ///
carry_name:载具名称 + ///
location_id:库位id + ///
location_code:库位编码 + ///
location_name:库位名称 + ///
} + ///
+ [HttpGet] + public async Task GetCarryInfo() + { + var locationTypes = new[] { (int)EnumLocationType.存储库位, (int)EnumLocationType.出库库位, (int)EnumLocationType.分拣库位 }; + var items = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id) + .Where((a, b) => a.status == 0 && a.is_lock == 0 && !locationTypes.Contains(Convert.ToInt32(b.is_type))) + .Select((a, b) => new + { + carry_id = a.id, + carry_code = a.carry_code, + carry_name = a.carry_name, + location_id = b.id, + location_code = b.location_code, + location_name = b.location_name, + }) + .ToListAsync(); + return items; + } + /// + /// 获取库位信息(入库业务) 库位不能为存储库位,出库库位,分拣库位;未锁定 + /// + /// + /// returns + ///
{ + ///
location_id:库位Id + ///
location_code:库位编号 + ///
location_name:库位名称 + ///
layers:楼层 + ///
} + ///
+ [HttpGet] + public async Task GetLocationInfo() + { + var locationTypes = new[] { (int)EnumLocationType.存储库位, (int)EnumLocationType.出库库位, (int)EnumLocationType.分拣库位 }; + var items = await _db.Queryable().Where(it => it.is_lock == 0 && !locationTypes.Contains(Convert.ToInt32(it.is_type))) + .Select(it => new + { + location_id = it.id, + location_code = it.location_code, + location_name = it.location_name, + layers = it.layers, + }) + .ToListAsync(); + return items; + } + /// + /// 出库查询目标库位信息,覆盖过滤条件 + /// + /// + [HttpGet] + public async Task GetOutStoreDestLocation() + { + var locationTypes = new[] { (int)EnumLocationType.存储库位, (int)EnumLocationType.入库库位 }; + var items = await _db.Queryable().Where(it => it.is_lock == 0 && !locationTypes.Contains(Convert.ToInt32(it.is_type))) + .Select(it => new + { + location_id = it.id, + location_code = it.location_code, + }) + .ToListAsync(); + return items; + } + /// + /// 出库申请-查询载具信息 + /// + /// + [HttpGet] + public async Task GetOutStoreLocation() + { + var items = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id) + .Where((a, b) => a.status == 0 && a.is_lock == 0 && Convert.ToInt32(b.is_type) == (int)EnumLocationType.存储库位) + .Select((a, b) => new + { + carry_id = a.id, + carry_code = a.carry_code, + carry_name = a.carry_name, + location_id = b.id, + location_code = b.location_code, + location_name = b.location_name, + }) + .ToListAsync(); + return items; + } + } +} diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs new file mode 100644 index 00000000..30d87152 --- /dev/null +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsDeliveryService.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Aspose.Cells.Drawing; +using JNPF.Common.Dtos.VisualDev; +using JNPF.Common.Extension; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.VisualDev; +using JNPF.VisualDev.Entitys; +using JNPF.VisualDev.Interfaces; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.BasicData.Entities; +using Tnb.BasicData.Interfaces; +using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Enums; +using Tnb.WarehouseMgr.Interfaces; + +namespace Tnb.WarehouseMgr +{ + /// + /// 配送申请服务 + /// + [ApiDescriptionSettings(Tag = ModuleConsts.Tag, Area = ModuleConsts.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class WmsDeliveryService : IOverideVisualDevService, IWmsDeliveryService, IDynamicApiController, ITransient + { + private const string ModuleId = "26126388337189"; + private readonly ISqlSugarClient _db; + private readonly IRunService _runService; + private readonly IVisualDevService _visualDevService; + private readonly IBasLocationService _basLocationService; + public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc(); + public WmsDeliveryService( + ISqlSugarRepository repository, + IRunService runService, + IVisualDevService visualDevService, + IBasLocationService basLocationService + ) + { + _db = repository.AsSugarClient(); + _runService = runService; + _visualDevService = visualDevService; + _basLocationService = basLocationService; + //OverideFuncs.CreateAsync = Create; + } + /// + /// 根据载具编号获取起始库位点 + /// + /// + /// + [HttpGet] + public async Task GetUnStoreLocationListByCarryId([FromRoute] string carryId) + { + var items = await _db.Queryable().LeftJoin((a, b) => a.location_id == b.id) + .Where(a => a.id == carryId) + .Select((a, b) => new + { + carry_code = a.carry_code, + location_code = b.location_code, + }) + .ToListAsync(); + return items; + } + + private async Task Create(VisualDevModelDataCrInput input) + { + try + { + //startlocation_id + //endlocation_id + string startLocationId = "", endLocationId = ""; + if (input.data.ContainsKey(nameof(WmsDelivery.startlocation_id))) + { + startLocationId = input.data[nameof(WmsDelivery.startlocation_id)]?.ToString()!; + } + if (input.data.ContainsKey(nameof(WmsDelivery.endlocation_id))) + { + endLocationId = input.data[nameof(WmsDelivery.endlocation_id)]?.ToString()!; + } + var locIds = new[] { startLocationId, endLocationId }; + var locs = await _basLocationService.GetLocationInfobyIds(locIds); + if (locs?.Count > 0) + { + var isStoreLoc = locs.Where(x => !x.IsNullOrEmpty()).Select(x => x.is_type.ParseToInt()).Any(x => x == (int)EnumLocationType.存储库位); + if (isStoreLoc) throw new AppFriendlyException("起始库位不能为存储库位", 500); + } + VisualDevEntity? templateEntity = await _visualDevService.GetInfoById(ModuleId, true); + await _runService.Create(templateEntity, input); + } + catch (Exception) + { + return await Task.FromResult(false); + } + return await Task.FromResult(true); + } + } +}