From 174f05a6e0f2312f3bdcafcf837f2534ecdaea15 Mon Sep 17 00:00:00 2001 From: payne <bzrlw2012@163.com> Date: 周二, 23 4月 2024 17:22:02 +0800 Subject: [PATCH] 增加库区 --- iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsPlace/WmsPlaceService.cs | 532 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 266 insertions(+), 266 deletions(-) diff --git a/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsPlace/WmsPlaceService.cs b/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsPlace/WmsPlaceService.cs index 872fe09..0580390 100644 --- a/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsPlace/WmsPlaceService.cs +++ b/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsPlace/WmsPlaceService.cs @@ -1,282 +1,282 @@ -锘縰sing Furion.DatabaseAccessor; -using Furion.DependencyInjection; -using Furion.DynamicApiController; -using Furion.FriendlyException; -using Mapster; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using System.Linq.Dynamic.Core; -using Admin.NET.Core; +锘�//using Furion.DatabaseAccessor; +//using Furion.DependencyInjection; +//using Furion.DynamicApiController; +//using Furion.FriendlyException; +//using Mapster; +//using Microsoft.AspNetCore.Authorization; +//using Microsoft.AspNetCore.Mvc; +//using Microsoft.EntityFrameworkCore; +//using System.Linq.Dynamic.Core; +//using Admin.NET.Core; -namespace Admin.NET.Application -{ - /// <summary> - /// 搴撲綅淇℃伅鏈嶅姟 - /// </summary> - [ApiDescriptionSettings("鑷繁鐨勪笟鍔�", Name = "WmsPlace", Order = 100)] - [Route("api/[Controller]")] - public class WmsPlaceService : IDynamicApiController, ITransient - { - private readonly IRepository<WmsPlace, MasterDbContextLocator> _wmsPlaceRep; - private readonly IRepository<WmsArea> _wmsAreaRep; +//namespace Admin.NET.Application +//{ +// /// <summary> +// /// 搴撲綅淇℃伅鏈嶅姟 +// /// </summary> +// [ApiDescriptionSettings("鑷繁鐨勪笟鍔�", Name = "WmsPlace", Order = 100)] +// [Route("api/[Controller]")] +// public class WmsPlaceService : IDynamicApiController, ITransient +// { +// private readonly IRepository<WmsPlace, MasterDbContextLocator> _wmsPlaceRep; +// private readonly IRepository<WmsArea> _wmsAreaRep; - /// <summary> - /// 鏋勯�犲嚱鏁� - /// </summary> - public WmsPlaceService( - IRepository<WmsArea> wmsAreaRep, - IRepository<WmsPlace, MasterDbContextLocator> wmsPlaceRep - ) - { - _wmsAreaRep = wmsAreaRep; - _wmsPlaceRep = wmsPlaceRep; - } +// /// <summary> +// /// 鏋勯�犲嚱鏁� +// /// </summary> +// public WmsPlaceService( +// IRepository<WmsArea> wmsAreaRep, +// IRepository<WmsPlace, MasterDbContextLocator> wmsPlaceRep +// ) +// { +// _wmsAreaRep = wmsAreaRep; +// _wmsPlaceRep = wmsPlaceRep; +// } - /// <summary> - /// 鍒嗛〉鏌ヨ搴撲綅淇℃伅 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpGet("page")] - public async Task<PageResult<WmsPlaceOutput>> Page([FromQuery] WmsPlaceSearch input) - { - var wmsPlaces = await _wmsPlaceRep.DetachedEntities - .Where(!string.IsNullOrEmpty(input.Placecode), u => EF.Functions.Like(u.PlaceCode, $"%{input.Placecode.Trim()}%")) - .Where(input.Placestatus != null, u => u.PlaceStatus == input.Placestatus) - .Where(input.Areaid > 0, u => u.AreaId == input.Areaid) - .Where(input.Rowno != null, u => u.RowNo == input.Rowno) - .Where(input.Columnno != null, u => u.ColumnNo == input.Columnno) - .Where(input.Layerno != null, u => u.LayerNo == input.Layerno) - .Where(input.Aisle != null, u => u.Aisle == input.Aisle) - .Where(input.Islock != null, u => u.Islock == input.Islock) - .OrderBy(PageInputOrder.OrderBuilder<WmsPlaceSearch>(input)) - .ProjectToType<WmsPlaceOutput>() - .ToADPagedListAsync(input.PageNo, input.PageSize); - return wmsPlaces; - } +// /// <summary> +// /// 鍒嗛〉鏌ヨ搴撲綅淇℃伅 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpGet("page")] +// public async Task<PageResult<WmsPlaceOutput>> Page([FromQuery] WmsPlaceSearch input) +// { +// var wmsPlaces = await _wmsPlaceRep.DetachedEntities +// .Where(!string.IsNullOrEmpty(input.Placecode), u => EF.Functions.Like(u.PlaceCode, $"%{input.Placecode.Trim()}%")) +// .Where(input.Placestatus != null, u => u.PlaceStatus == input.Placestatus) +// .Where(input.Areaid > 0, u => u.AreaId == input.Areaid) +// .Where(input.Rowno != null, u => u.RowNo == input.Rowno) +// .Where(input.Columnno != null, u => u.ColumnNo == input.Columnno) +// .Where(input.Layerno != null, u => u.LayerNo == input.Layerno) +// .Where(input.Aisle != null, u => u.Aisle == input.Aisle) +// .Where(input.Islock != null, u => u.Islock == input.Islock) +// .OrderBy(PageInputOrder.OrderBuilder<WmsPlaceSearch>(input)) +// .ProjectToType<WmsPlaceOutput>() +// .ToADPagedListAsync(input.PageNo, input.PageSize); +// return wmsPlaces; +// } - /// <summary> - /// 澧炲姞搴撲綅淇℃伅 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - //[HttpPost("add")] - //public async Task Add(AddWmsPlaceInput input) - //{ - // //鑾峰彇搴撳尯淇℃伅 - // var wmsArea = await _wmsAreaRep.FirstOrDefaultAsync(u => u.Id == input.Areaid); - // if (wmsArea.AreaType == AreaType.LITIKU) - // { - // var wmsPlace = input.Adapt<WmsPlace>(); - // for (int a = 1; a == 1; a++) - // { - // for (int t = 1; t <= wmsPlace.RowNo; t++) //寰幆鎺� - // { - // for (int i = 1; i <= wmsPlace.ColumnNo; i++) //寰幆鍒� - // { - // for (int j = 1; j <= wmsPlace.LayerNo; j++) //寰幆灞� - // { - // var model = new WmsPlace(); - // model.PlaceStatus = PlaceStatus.KONGXIAN; - // model.AreaId = wmsPlace.AreaId; - // model.RowNo = t; - // model.ColumnNo = i; - // model.LayerNo = j; - // model.DeepcellNo = 1; - // model.Aisle = a; - // model.Islock = YesOrNot.N; - // model.Length = new decimal(1.2); - // model.Width = new decimal(1.5); - // model.Height = new decimal(1.8); - // model.MaxWeight = new decimal(2.8); - // model.HeightLevel = Heightlevel.DI; - // model.Priority = 0; - // model.AgvCode = ""; - // model.PlaceCode = String.Format("{0}{1}{2}{3}{4}", wmsArea.AreaDesc, a.ToString("00"), t.ToString("00"), i.ToString("00"), j.ToString("00")); - // var isExit = await _wmsPlaceRep.AnyAsync(n => n.PlaceCode == model.PlaceCode); - // if (!isExit) await _wmsPlaceRep.InsertAsync(model); - // } - // } - // } - // } - // } - // else - // { - // var wmsPlace = input.Adapt<WmsPlace>(); - // for (int t = 1; t <= wmsPlace.RowNo; t++) //寰幆鎺� - // { - // for (int i = 1; i <= wmsPlace.ColumnNo; i++) //寰幆鍒� - // { - // for (int j = 1; j <= wmsPlace.LayerNo; j++) //寰幆灞� - // { - // var model = new WmsPlace(); - // model.PlaceStatus = PlaceStatus.KONGXIAN; - // model.AreaId = wmsPlace.AreaId; - // model.RowNo = t; - // model.ColumnNo = i; - // model.LayerNo = j; - // model.DeepcellNo = 1; - // model.Aisle = wmsPlace.Aisle; - // model.Islock = YesOrNot.N; - // model.Length = new decimal(1.2); - // model.Width = new decimal(1.5); - // model.Height = new decimal(1.8); - // model.MaxWeight = new decimal(2.8); - // model.HeightLevel = Heightlevel.DI; - // model.Priority = 0; - // model.AgvCode = ""; - // model.PlaceCode = String.Format("{0}{1}{2}{3}", wmsArea.AreaDesc, t.ToString("00"), i.ToString("00"), j.ToString("00")); - // var isExit = await _wmsPlaceRep.AnyAsync(n => n.PlaceCode == model.PlaceCode); - // if (!isExit) await _wmsPlaceRep.InsertAsync(model); - // } - // } - // } - // } +// /// <summary> +// /// 澧炲姞搴撲綅淇℃伅 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// //[HttpPost("add")] +// //public async Task Add(AddWmsPlaceInput input) +// //{ +// // //鑾峰彇搴撳尯淇℃伅 +// // var wmsArea = await _wmsAreaRep.FirstOrDefaultAsync(u => u.Id == input.Areaid); +// // if (wmsArea.AreaType == AreaType.LITIKU) +// // { +// // var wmsPlace = input.Adapt<WmsPlace>(); +// // for (int a = 1; a == 1; a++) +// // { +// // for (int t = 1; t <= wmsPlace.RowNo; t++) //寰幆鎺� +// // { +// // for (int i = 1; i <= wmsPlace.ColumnNo; i++) //寰幆鍒� +// // { +// // for (int j = 1; j <= wmsPlace.LayerNo; j++) //寰幆灞� +// // { +// // var model = new WmsPlace(); +// // model.PlaceStatus = PlaceStatus.KONGXIAN; +// // model.AreaId = wmsPlace.AreaId; +// // model.RowNo = t; +// // model.ColumnNo = i; +// // model.LayerNo = j; +// // model.DeepcellNo = 1; +// // model.Aisle = a; +// // model.Islock = YesOrNot.N; +// // model.Length = new decimal(1.2); +// // model.Width = new decimal(1.5); +// // model.Height = new decimal(1.8); +// // model.MaxWeight = new decimal(2.8); +// // model.HeightLevel = Heightlevel.DI; +// // model.Priority = 0; +// // model.AgvCode = ""; +// // model.PlaceCode = String.Format("{0}{1}{2}{3}{4}", wmsArea.AreaDesc, a.ToString("00"), t.ToString("00"), i.ToString("00"), j.ToString("00")); +// // var isExit = await _wmsPlaceRep.AnyAsync(n => n.PlaceCode == model.PlaceCode); +// // if (!isExit) await _wmsPlaceRep.InsertAsync(model); +// // } +// // } +// // } +// // } +// // } +// // else +// // { +// // var wmsPlace = input.Adapt<WmsPlace>(); +// // for (int t = 1; t <= wmsPlace.RowNo; t++) //寰幆鎺� +// // { +// // for (int i = 1; i <= wmsPlace.ColumnNo; i++) //寰幆鍒� +// // { +// // for (int j = 1; j <= wmsPlace.LayerNo; j++) //寰幆灞� +// // { +// // var model = new WmsPlace(); +// // model.PlaceStatus = PlaceStatus.KONGXIAN; +// // model.AreaId = wmsPlace.AreaId; +// // model.RowNo = t; +// // model.ColumnNo = i; +// // model.LayerNo = j; +// // model.DeepcellNo = 1; +// // model.Aisle = wmsPlace.Aisle; +// // model.Islock = YesOrNot.N; +// // model.Length = new decimal(1.2); +// // model.Width = new decimal(1.5); +// // model.Height = new decimal(1.8); +// // model.MaxWeight = new decimal(2.8); +// // model.HeightLevel = Heightlevel.DI; +// // model.Priority = 0; +// // model.AgvCode = ""; +// // model.PlaceCode = String.Format("{0}{1}{2}{3}", wmsArea.AreaDesc, t.ToString("00"), i.ToString("00"), j.ToString("00")); +// // var isExit = await _wmsPlaceRep.AnyAsync(n => n.PlaceCode == model.PlaceCode); +// // if (!isExit) await _wmsPlaceRep.InsertAsync(model); +// // } +// // } +// // } +// // } - //} +// //} - /// <summary> - /// 澧炲姞搴撲綅淇℃伅 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpPost("add")] - public async Task AddNew(AddWmsPlaceInput input) - { - var isExit = await _wmsPlaceRep.AnyAsync(n => n.PlaceCode == input.Placecode); - if (isExit) throw Oops.Oh("瀛樺湪鐨勭浉鍚岀殑搴撲綅缂栫爜锛�"); - var wmsPlace = input.Adapt<WmsPlace>(); - wmsPlace.AgvCode = "Y/N"; - wmsPlace.PlaceStatus = PlaceStatus.KONGXIAN; - wmsPlace.Islock = YesOrNot.N; - wmsPlace.EmptyContainer = YesOrNot.N; - if (input.Heightlevel==0) { - wmsPlace.HeightLevel = Heightlevel.DI; - } - await _wmsPlaceRep.InsertAsync(wmsPlace); - } +// /// <summary> +// /// 澧炲姞搴撲綅淇℃伅 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpPost("add")] +// public async Task AddNew(AddWmsPlaceInput input) +// { +// var isExit = await _wmsPlaceRep.AnyAsync(n => n.PlaceCode == input.Placecode); +// if (isExit) throw Oops.Oh("瀛樺湪鐨勭浉鍚岀殑搴撲綅缂栫爜锛�"); +// var wmsPlace = input.Adapt<WmsPlace>(); +// wmsPlace.AgvCode = "Y/N"; +// wmsPlace.PlaceStatus = PlaceStatus.KONGXIAN; +// wmsPlace.Islock = YesOrNot.N; +// wmsPlace.EmptyContainer = YesOrNot.N; +// if (input.Heightlevel==0) { +// wmsPlace.HeightLevel = Heightlevel.DI; +// } +// await _wmsPlaceRep.InsertAsync(wmsPlace); +// } - /// <summary> - /// 鍒犻櫎搴撲綅淇℃伅 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpPost("delete")] - public async Task Delete(DeleteWmsPlaceInput input) - { - var wmsPlace = await _wmsPlaceRep.FirstOrDefaultAsync(u => u.Id == input.Id); - await _wmsPlaceRep.DeleteAsync(wmsPlace); - } +// /// <summary> +// /// 鍒犻櫎搴撲綅淇℃伅 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpPost("delete")] +// public async Task Delete(DeleteWmsPlaceInput input) +// { +// var wmsPlace = await _wmsPlaceRep.FirstOrDefaultAsync(u => u.Id == input.Id); +// await _wmsPlaceRep.DeleteAsync(wmsPlace); +// } - /// <summary> - /// 鎵归噺閿佸畾 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpPost("MoreLock")] - public async Task MoreLock(MoreLockInput input) - { - if (input.Id.Count <= 0) throw Oops.Oh("id涓嶈兘涓虹┖锛�"); - foreach (var item in input.Id) - { - var wmsPlace = await _wmsPlaceRep.FirstOrDefaultAsync(u => u.Id == item); - if (wmsPlace == null) throw Oops.Oh("搴撲綅淇℃伅涓嶅瓨鍦�!"); - wmsPlace.Islock = YesOrNot.Y; - await _wmsPlaceRep.UpdateAsync(wmsPlace, ignoreNullValues: true); - } - } +// /// <summary> +// /// 鎵归噺閿佸畾 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpPost("MoreLock")] +// public async Task MoreLock(MoreLockInput input) +// { +// if (input.Id.Count <= 0) throw Oops.Oh("id涓嶈兘涓虹┖锛�"); +// foreach (var item in input.Id) +// { +// var wmsPlace = await _wmsPlaceRep.FirstOrDefaultAsync(u => u.Id == item); +// if (wmsPlace == null) throw Oops.Oh("搴撲綅淇℃伅涓嶅瓨鍦�!"); +// wmsPlace.Islock = YesOrNot.Y; +// await _wmsPlaceRep.UpdateAsync(wmsPlace, ignoreNullValues: true); +// } +// } - /// <summary> - /// 鎵归噺瑙i攣 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpPost("MoreUnlock")] - public async Task MoreUnlock(MoreLockInput input) - { - if (input.Id.Count <= 0) throw Oops.Oh("id涓嶈兘涓虹┖锛�"); - foreach (var item in input.Id) - { - var wmsPlace = await _wmsPlaceRep.FirstOrDefaultAsync(u => u.Id == item); - if (wmsPlace == null) throw Oops.Oh("搴撲綅淇℃伅涓嶅瓨鍦�!"); - wmsPlace.Islock = YesOrNot.N; - await _wmsPlaceRep.UpdateAsync(wmsPlace, ignoreNullValues: true); - } - } +// /// <summary> +// /// 鎵归噺瑙i攣 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpPost("MoreUnlock")] +// public async Task MoreUnlock(MoreLockInput input) +// { +// if (input.Id.Count <= 0) throw Oops.Oh("id涓嶈兘涓虹┖锛�"); +// foreach (var item in input.Id) +// { +// var wmsPlace = await _wmsPlaceRep.FirstOrDefaultAsync(u => u.Id == item); +// if (wmsPlace == null) throw Oops.Oh("搴撲綅淇℃伅涓嶅瓨鍦�!"); +// wmsPlace.Islock = YesOrNot.N; +// await _wmsPlaceRep.UpdateAsync(wmsPlace, ignoreNullValues: true); +// } +// } - /// <summary> - /// 鏇存柊搴撲綅淇℃伅 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpPost("edit")] - public async Task Update(UpdateWmsPlaceInput input) - { - var isExist = await _wmsPlaceRep.AnyAsync(u => u.Id == input.Id, false); - if (!isExist) throw Oops.Oh(ErrorCode.D3000); +// /// <summary> +// /// 鏇存柊搴撲綅淇℃伅 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpPost("edit")] +// public async Task Update(UpdateWmsPlaceInput input) +// { +// var isExist = await _wmsPlaceRep.AnyAsync(u => u.Id == input.Id, false); +// if (!isExist) throw Oops.Oh(ErrorCode.D3000); - var wmsPlace = input.Adapt<WmsPlace>(); - await _wmsPlaceRep.UpdateAsync(wmsPlace, ignoreNullValues: true); - } +// var wmsPlace = input.Adapt<WmsPlace>(); +// await _wmsPlaceRep.UpdateAsync(wmsPlace, ignoreNullValues: true); +// } - /// <summary> - /// 鑾峰彇搴撲綅淇℃伅 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpGet("detail")] - public async Task<WmsPlaceOutput> Get([FromQuery] QueryeWmsPlaceInput input) - { - return (await _wmsPlaceRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id)).Adapt<WmsPlaceOutput>(); - } +// /// <summary> +// /// 鑾峰彇搴撲綅淇℃伅 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpGet("detail")] +// public async Task<WmsPlaceOutput> Get([FromQuery] QueryeWmsPlaceInput input) +// { +// return (await _wmsPlaceRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id)).Adapt<WmsPlaceOutput>(); +// } - /// <summary> - /// 鑾峰彇搴撲綅淇℃伅鍒楄〃 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpGet("list")] - public async Task<List<WmsPlaceOutput>> List([FromQuery] WmsPlaceInput input) - { - return await _wmsPlaceRep.DetachedEntities.ProjectToType<WmsPlaceOutput>().ToListAsync(); - } +// /// <summary> +// /// 鑾峰彇搴撲綅淇℃伅鍒楄〃 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpGet("list")] +// public async Task<List<WmsPlaceOutput>> List([FromQuery] WmsPlaceInput input) +// { +// return await _wmsPlaceRep.DetachedEntities.ProjectToType<WmsPlaceOutput>().ToListAsync(); +// } - /// <summary> - /// 鑾峰彇WmsArea鍒楄〃 - /// </summary> - /// <returns></returns> - [HttpGet("fkWmsArea")] - public async Task<dynamic> FkWmsAreaList() - { - var list = await _wmsAreaRep.DetachedEntities.ToListAsync(); - return list.Select(e => new { Code = e.Id, Name = e.AreaName }); - } +// /// <summary> +// /// 鑾峰彇WmsArea鍒楄〃 +// /// </summary> +// /// <returns></returns> +// [HttpGet("fkWmsArea")] +// public async Task<dynamic> FkWmsAreaList() +// { +// var list = await _wmsAreaRep.DetachedEntities.ToListAsync(); +// return list.Select(e => new { Code = e.Id, Name = e.AreaName }); +// } - /// <summary> - /// 鑾峰彇鐔熷寲搴撳贩閬� - /// </summary> - /// <returns></returns> - [HttpGet("GetFAisle")] - public async Task<object> GetFAisle() - { - var area = await _wmsAreaRep.FirstOrDefaultAsync(n => n.AreaStatus == CommonStatus.ENABLE && n.WorkShopType == LesWorkShopType.FAPAOCHEJIAN && n.AreaType == AreaType.LITIKU); - var objList = await _wmsPlaceRep.Where(n => n.AreaId == area.Id).OrderBy(n => n.Aisle).Select(n => n.Aisle).Distinct().ToArrayAsync(); - for (int i = 0; i < objList.Length - 1; i++) - { - for (int j = 0; j < objList.Length - 1; j++) - { - int k = j + 1; - if (objList[j] > objList[k]) - { - var temp = objList[k]; - objList[k] = objList[j]; - objList[j] = temp; - } - } - } - return objList; - } - } +// /// <summary> +// /// 鑾峰彇鐔熷寲搴撳贩閬� +// /// </summary> +// /// <returns></returns> +// [HttpGet("GetFAisle")] +// public async Task<object> GetFAisle() +// { +// var area = await _wmsAreaRep.FirstOrDefaultAsync(n => n.AreaStatus == CommonStatus.ENABLE && n.WorkShopType == LesWorkShopType.FAPAOCHEJIAN && n.AreaType == AreaType.LITIKU); +// var objList = await _wmsPlaceRep.Where(n => n.AreaId == area.Id).OrderBy(n => n.Aisle).Select(n => n.Aisle).Distinct().ToArrayAsync(); +// for (int i = 0; i < objList.Length - 1; i++) +// { +// for (int j = 0; j < objList.Length - 1; j++) +// { +// int k = j + 1; +// if (objList[j] > objList[k]) +// { +// var temp = objList[k]; +// objList[k] = objList[j]; +// objList[j] = temp; +// } +// } +// } +// return objList; +// } +// } -} +//} -- Gitblit v1.9.3