From 0a4fdc2b4d0f5fb7d16fbd0182bef305105e3eae Mon Sep 17 00:00:00 2001 From: payne <bzrlw2012@163.com> Date: 周二, 23 4月 2024 18:44:36 +0800 Subject: [PATCH] 调整库位实体 新增容器 容器类型实体 --- iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsContainer/WmsContainerService.cs | 570 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 285 insertions(+), 285 deletions(-) diff --git a/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsContainer/WmsContainerService.cs b/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsContainer/WmsContainerService.cs index 28707e3..db83988 100644 --- a/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsContainer/WmsContainerService.cs +++ b/iWare_RawMaterialWarehouse_Wms/Admin.NET.Application/Service/Common/WmsContainer/WmsContainerService.cs @@ -1,303 +1,303 @@ -锘縰sing Furion.DatabaseAccessor; -using Furion.DatabaseAccessor.Extensions; -using Furion.DependencyInjection; -using Furion.DynamicApiController; -using Furion.FriendlyException; -using Admin.NET.Core; -using Mapster; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using System.Linq.Dynamic.Core; -using Microsoft.AspNetCore.Http; -using System.Text; -using System.Web; +锘�//using Furion.DatabaseAccessor; +//using Furion.DatabaseAccessor.Extensions; +//using Furion.DependencyInjection; +//using Furion.DynamicApiController; +//using Furion.FriendlyException; +//using Admin.NET.Core; +//using Mapster; +//using Microsoft.AspNetCore.Mvc; +//using Microsoft.EntityFrameworkCore; +//using System.Linq.Dynamic.Core; +//using Microsoft.AspNetCore.Http; +//using System.Text; +//using System.Web; -namespace Admin.NET.Application -{ - /// <summary> - /// 鎵樼洏淇℃伅鏈嶅姟 - /// </summary> - [ApiDescriptionSettings("鑷繁鐨勪笟鍔�", Name = "WmsContainer", Order = 100)] - [Route("api/[Controller]")] - public class WmsContainerService : IWmsContainerService, IDynamicApiController, ITransient - { - private readonly IRepository<WmsContainer,MasterDbContextLocator> _wmsContainerRep; - private readonly IRepository<SysDictType, MasterDbContextLocator> _sysDictTypeRep; - private readonly IRepository<SysDictData, MasterDbContextLocator> _sysDictDataRep; - private readonly ISysExcelTemplateService _sysExcelTemplateService; - private readonly static object _lock = new(); +//namespace Admin.NET.Application +//{ +// /// <summary> +// /// 鎵樼洏淇℃伅鏈嶅姟 +// /// </summary> +// [ApiDescriptionSettings("鑷繁鐨勪笟鍔�", Name = "WmsContainer", Order = 100)] +// [Route("api/[Controller]")] +// public class WmsContainerService : IWmsContainerService, IDynamicApiController, ITransient +// { +// private readonly IRepository<WmsContainer,MasterDbContextLocator> _wmsContainerRep; +// private readonly IRepository<SysDictType, MasterDbContextLocator> _sysDictTypeRep; +// private readonly IRepository<SysDictData, MasterDbContextLocator> _sysDictDataRep; +// private readonly ISysExcelTemplateService _sysExcelTemplateService; +// private readonly static object _lock = new(); - /// <summary> - /// 鏋勯�犲嚱鏁� - /// </summary> - public WmsContainerService( - IRepository<WmsContainer,MasterDbContextLocator> wmsContainerRep - ,IRepository<SysDictType, MasterDbContextLocator> sysDictTypeRep - ,IRepository<SysDictData, MasterDbContextLocator> sysDictDataRep - ,ISysExcelTemplateService sysExcelTemplateService - ) - { - _wmsContainerRep = wmsContainerRep; - _sysDictTypeRep = sysDictTypeRep; - _sysDictDataRep = sysDictDataRep; - _sysExcelTemplateService = sysExcelTemplateService; - } +// /// <summary> +// /// 鏋勯�犲嚱鏁� +// /// </summary> +// public WmsContainerService( +// IRepository<WmsContainer,MasterDbContextLocator> wmsContainerRep +// ,IRepository<SysDictType, MasterDbContextLocator> sysDictTypeRep +// ,IRepository<SysDictData, MasterDbContextLocator> sysDictDataRep +// ,ISysExcelTemplateService sysExcelTemplateService +// ) +// { +// _wmsContainerRep = wmsContainerRep; +// _sysDictTypeRep = sysDictTypeRep; +// _sysDictDataRep = sysDictDataRep; +// _sysExcelTemplateService = sysExcelTemplateService; +// } - /// <summary> - /// 鍒嗛〉鏌ヨ鎵樼洏淇℃伅 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpGet("page")] - public async Task<PageResult<WmsContainerOutput>> Page([FromQuery] WmsContainerSearch input) - { - var wmsContainers = await _wmsContainerRep.DetachedEntities - .Where(!string.IsNullOrEmpty(input.ContainerCode), u => EF.Functions.Like(u.ContainerCode, $"%{input.ContainerCode.Trim()}%")) - .Where(input.ContainerType != null, u => u.ContainerType == input.ContainerType) - .Where(input.ContainerStatus != null, u => u.ContainerStatus == input.ContainerStatus) - .Where(input.SpecLength != null, u => u.SpecLength == input.SpecLength) - .Where(input.SpecWidth != null, u => u.SpecWidth == input.SpecWidth) - .Where(input.ContainerCategory != null, u => u.ContainerCategory == input.ContainerCategory) - .Where(input.WorkShopType != null, u => u.WorkShopType == input.WorkShopType) - .OrderBy(PageInputOrder.OrderBuilder<WmsContainerSearch>(input)) - .ProjectToType<WmsContainerOutput>() - .ToADPagedListAsync(input.PageNo, input.PageSize); - return wmsContainers; - } +// /// <summary> +// /// 鍒嗛〉鏌ヨ鎵樼洏淇℃伅 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpGet("page")] +// public async Task<PageResult<WmsContainerOutput>> Page([FromQuery] WmsContainerSearch input) +// { +// var wmsContainers = await _wmsContainerRep.DetachedEntities +// .Where(!string.IsNullOrEmpty(input.ContainerCode), u => EF.Functions.Like(u.ContainerCode, $"%{input.ContainerCode.Trim()}%")) +// .Where(input.ContainerType != null, u => u.ContainerType == input.ContainerType) +// .Where(input.ContainerStatus != null, u => u.ContainerStatus == input.ContainerStatus) +// .Where(input.SpecLength != null, u => u.SpecLength == input.SpecLength) +// .Where(input.SpecWidth != null, u => u.SpecWidth == input.SpecWidth) +// .Where(input.ContainerCategory != null, u => u.ContainerCategory == input.ContainerCategory) +// .Where(input.WorkShopType != null, u => u.WorkShopType == input.WorkShopType) +// .OrderBy(PageInputOrder.OrderBuilder<WmsContainerSearch>(input)) +// .ProjectToType<WmsContainerOutput>() +// .ToADPagedListAsync(input.PageNo, input.PageSize); +// return wmsContainers; +// } - /// <summary> - /// 涓嶅垎椤垫煡璇㈡墭鐩樹俊鎭垪琛� - /// </summary> - /// <param name="input">鎵樼洏淇℃伅鏌ヨ鍙傛暟</param> - /// <returns>(鎵樼洏淇℃伅)瀹炰緥鍒楄〃</returns> - [HttpGet("listNonPage")] - public async Task<List<WmsContainerOutput>> ListNonPageAsync([FromQuery] WmsContainerSearchNonPage input) - { - var pContainerCode = input.ContainerCode?.Trim() ?? ""; - var pContainerType = input.ContainerType; - var pContainerStatus = input.ContainerStatus; - var pSpecLength = input.SpecLength; - var pSpecWidth = input.SpecWidth; - var pContainerCategory = input.ContainerCategory; - var pWorkShopType = input.WorkShopType; - var wmsContainers = await _wmsContainerRep.DetachedEntities - .Where(!string.IsNullOrEmpty(pContainerCode), u => EF.Functions.Like(u.ContainerCode, $"%{pContainerCode}%")) - .Where(pContainerType != null, u => u.ContainerType == pContainerType) - .Where(pContainerStatus != null, u => u.ContainerStatus == pContainerStatus) - .Where(pSpecLength != null, u => u.SpecLength == pSpecLength) - .Where(pSpecWidth != null, u => u.SpecWidth == pSpecWidth) - .Where(pContainerCategory != null, u => u.ContainerCategory == pContainerCategory) - .Where(pWorkShopType != null, u => u.WorkShopType == pWorkShopType) - .OrderBy(PageInputOrder.OrderNonPageBuilder(input)) - .ProjectToType<WmsContainerOutput>() - .ToListAsync(); - return wmsContainers; - } +// /// <summary> +// /// 涓嶅垎椤垫煡璇㈡墭鐩樹俊鎭垪琛� +// /// </summary> +// /// <param name="input">鎵樼洏淇℃伅鏌ヨ鍙傛暟</param> +// /// <returns>(鎵樼洏淇℃伅)瀹炰緥鍒楄〃</returns> +// [HttpGet("listNonPage")] +// public async Task<List<WmsContainerOutput>> ListNonPageAsync([FromQuery] WmsContainerSearchNonPage input) +// { +// var pContainerCode = input.ContainerCode?.Trim() ?? ""; +// var pContainerType = input.ContainerType; +// var pContainerStatus = input.ContainerStatus; +// var pSpecLength = input.SpecLength; +// var pSpecWidth = input.SpecWidth; +// var pContainerCategory = input.ContainerCategory; +// var pWorkShopType = input.WorkShopType; +// var wmsContainers = await _wmsContainerRep.DetachedEntities +// .Where(!string.IsNullOrEmpty(pContainerCode), u => EF.Functions.Like(u.ContainerCode, $"%{pContainerCode}%")) +// .Where(pContainerType != null, u => u.ContainerType == pContainerType) +// .Where(pContainerStatus != null, u => u.ContainerStatus == pContainerStatus) +// .Where(pSpecLength != null, u => u.SpecLength == pSpecLength) +// .Where(pSpecWidth != null, u => u.SpecWidth == pSpecWidth) +// .Where(pContainerCategory != null, u => u.ContainerCategory == pContainerCategory) +// .Where(pWorkShopType != null, u => u.WorkShopType == pWorkShopType) +// .OrderBy(PageInputOrder.OrderNonPageBuilder(input)) +// .ProjectToType<WmsContainerOutput>() +// .ToListAsync(); +// return wmsContainers; +// } - /// <summary> - /// 澧炲姞鎵樼洏淇℃伅 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpPost("add")] - public async Task Add(AddWmsContainerInput input) - { - var isExist = await _wmsContainerRep.AnyAsync(u => u.ContainerCode == input.ContainerCode, false); - if (isExist) throw Oops.Oh($"褰撳墠鎵樼洏宸插瓨鍦紝鏂板澶辫触锛�"); +// /// <summary> +// /// 澧炲姞鎵樼洏淇℃伅 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpPost("add")] +// public async Task Add(AddWmsContainerInput input) +// { +// var isExist = await _wmsContainerRep.AnyAsync(u => u.ContainerCode == input.ContainerCode, false); +// if (isExist) throw Oops.Oh($"褰撳墠鎵樼洏宸插瓨鍦紝鏂板澶辫触锛�"); - var ContainerInfo = input.Adapt<WmsContainer>(); - ContainerInfo.ContainerStatus = ContainerStatus.KOUXIAN; - ContainerInfo.AssetNo = "N/A"; - ContainerInfo.ContainerCategory = ContainerCategory.GZP; - ContainerInfo.ErpNo = "N/A"; - ContainerInfo.IsVirtually = YesOrNot.N; - ContainerInfo.WorkShopType = LesWorkShopType.FAPAOCHEJIAN; - await _wmsContainerRep.InsertAsync(ContainerInfo); - //string ContainerCode = "ZHONGTONG"; - //if (input.SpecLength == 1250) - //{ - // ContainerCode = "YKA"; - //} - //else if (input.SpecLength == 1050) - //{ - // ContainerCode = "YKB"; - //} - //else if (input.SpecLength == 800) - //{ - // ContainerCode = "YKC"; - //} - //var wmsContainerModal = await _wmsContainerRep.DetachedEntities.Where(u => u.ContainerCode.Contains(input.ContainerCode)) - // .ProjectToType<WmsContainerOutput>() - // .OrderByDescending(u => u.ContainerCode) - // .FirstOrDefaultAsync(); - //int a = 0; - //if (wmsContainerModal != null) - //{ - // a = Convert.ToInt32(wmsContainerModal.ContainerCode.Substring(wmsContainerModal.ContainerCode.Length - 5)); - //} - //for (int i = a + 1; i <= a + input.Quantity; i++) - //{ - // var wmsContainer = input.Adapt<WmsContainer>(); - // wmsContainer.AssetNo = "N/A"; - // wmsContainer.ErpNo = "N/A"; - // wmsContainer.IsVirtually = YesOrNot.N; - // wmsContainer.IsDeleted = false;; - // wmsContainer.ContainerCode = ContainerCode + i.ToString("00000"); - // await _wmsContainerRep.InsertAsync(wmsContainer); - //} - } +// var ContainerInfo = input.Adapt<WmsContainer>(); +// ContainerInfo.ContainerStatus = ContainerStatus.KOUXIAN; +// ContainerInfo.AssetNo = "N/A"; +// ContainerInfo.ContainerCategory = ContainerCategory.GZP; +// ContainerInfo.ErpNo = "N/A"; +// ContainerInfo.IsVirtually = YesOrNot.N; +// ContainerInfo.WorkShopType = LesWorkShopType.FAPAOCHEJIAN; +// await _wmsContainerRep.InsertAsync(ContainerInfo); +// //string ContainerCode = "ZHONGTONG"; +// //if (input.SpecLength == 1250) +// //{ +// // ContainerCode = "YKA"; +// //} +// //else if (input.SpecLength == 1050) +// //{ +// // ContainerCode = "YKB"; +// //} +// //else if (input.SpecLength == 800) +// //{ +// // ContainerCode = "YKC"; +// //} +// //var wmsContainerModal = await _wmsContainerRep.DetachedEntities.Where(u => u.ContainerCode.Contains(input.ContainerCode)) +// // .ProjectToType<WmsContainerOutput>() +// // .OrderByDescending(u => u.ContainerCode) +// // .FirstOrDefaultAsync(); +// //int a = 0; +// //if (wmsContainerModal != null) +// //{ +// // a = Convert.ToInt32(wmsContainerModal.ContainerCode.Substring(wmsContainerModal.ContainerCode.Length - 5)); +// //} +// //for (int i = a + 1; i <= a + input.Quantity; i++) +// //{ +// // var wmsContainer = input.Adapt<WmsContainer>(); +// // wmsContainer.AssetNo = "N/A"; +// // wmsContainer.ErpNo = "N/A"; +// // wmsContainer.IsVirtually = YesOrNot.N; +// // wmsContainer.IsDeleted = false;; +// // wmsContainer.ContainerCode = ContainerCode + i.ToString("00000"); +// // await _wmsContainerRep.InsertAsync(wmsContainer); +// //} +// } - /// <summary> - /// 鍒犻櫎鎵樼洏淇℃伅 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpPost("delete")] - public async Task Delete(DeleteWmsContainerInput input) - { - var wmsContainer = await _wmsContainerRep.FirstOrDefaultAsync(u => u.Id == input.Id); - await _wmsContainerRep.DeleteAsync(wmsContainer); - } +// /// <summary> +// /// 鍒犻櫎鎵樼洏淇℃伅 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpPost("delete")] +// public async Task Delete(DeleteWmsContainerInput input) +// { +// var wmsContainer = await _wmsContainerRep.FirstOrDefaultAsync(u => u.Id == input.Id); +// await _wmsContainerRep.DeleteAsync(wmsContainer); +// } - /// <summary> - /// 鏇存柊鎵樼洏淇℃伅 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpPost("edit")] - public async Task Update(UpdateWmsContainerInput input) - { - var isExist = await _wmsContainerRep.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(UpdateWmsContainerInput input) +// { +// var isExist = await _wmsContainerRep.AnyAsync(u => u.Id == input.Id, false); +// if (!isExist) throw Oops.Oh(ErrorCode.D3000); - var wmsContainer = input.Adapt<WmsContainer>(); - await _wmsContainerRep.UpdateAsync(wmsContainer,ignoreNullValues:true); - } +// var wmsContainer = input.Adapt<WmsContainer>(); +// await _wmsContainerRep.UpdateAsync(wmsContainer,ignoreNullValues:true); +// } - /// <summary> - /// 鑾峰彇鎵樼洏淇℃伅 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpGet("detail")] - public async Task<WmsContainerOutput> Get([FromQuery] QueryeWmsContainerInput input) - { - return (await _wmsContainerRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id)).Adapt<WmsContainerOutput>(); - } +// /// <summary> +// /// 鑾峰彇鎵樼洏淇℃伅 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpGet("detail")] +// public async Task<WmsContainerOutput> Get([FromQuery] QueryeWmsContainerInput input) +// { +// return (await _wmsContainerRep.DetachedEntities.FirstOrDefaultAsync(u => u.Id == input.Id)).Adapt<WmsContainerOutput>(); +// } - /// <summary> - /// 鑾峰彇鎵樼洏淇℃伅鍒楄〃 - /// </summary> - /// <param name="input"></param> - /// <returns></returns> - [HttpGet("list")] - public async Task<List<WmsContainerOutput>> List([FromQuery] WmsContainerInput input) - { - return await _wmsContainerRep.DetachedEntities.ProjectToType<WmsContainerOutput>().ToListAsync(); - } - /// <summary> - /// Excel妯℃澘瀵煎叆鎵樼洏淇℃伅鍔熻兘 - /// </summary> - /// <param name="file">Excel妯℃澘鏂囦欢</param> - /// <param name="importExcelType">Excel瀵煎叆鏂瑰紡</param> - /// <returns>瀵煎叆鐨勮褰曟暟</returns> - [HttpPost("fromExcel")] - public async Task<int> FromExcelAsync(IFormFile file, [FromQuery] ImportExcelType importExcelType) - { - int size = 200; - var excelTemplate = await _sysExcelTemplateService.GetByAppNameAndClassNameAndVersionAsync("WmsContainer", "v2"); - if (excelTemplate == null) throw Oops.Oh(ErrorCode.Excel002); - var keys = excelTemplate.UnionUniqueFields.Split(",") ?? Array.Empty<string>(); - for (var i = 0; i < keys.Length; i++) - { - keys[i] = keys[i]?.Trim() ?? string.Empty; - } - ExcelUtil.FromExcel(file, excelTemplate.HeadStartLine, excelTemplate.DataStartLine, out List<string> headers, out List<List<object>> data, out string sheetName); - List<WmsContainerOutput> wmsContainerList = DataConvertUtil.ToObjectList(headers, data, sheetName, keys, excelTemplate?.DataStartLine ?? 2, out Dictionary<string, WmsContainerOutput> dict); - List<Dictionary<string, object>> uniqueKeyValueDictList = wmsContainerList.ParseUniqueKeyValueDictList(keys.ToList(), excelTemplate?.DataStartLine ?? 2, sheetName); - var filters = DataConvertUtil.GetExpressionListByUniqueDict<WmsContainer>(keys.ToList(), uniqueKeyValueDictList, size); - var selectKeys = keys.ToList(); - if(!selectKeys.Contains("Id")) selectKeys.Add("Id"); - var selector = DataConvertUtil.GetSelectExpressionListByUniqueDict<WmsContainer, WmsContainerOutput>(selectKeys); - List<WmsContainer> updates = new(); - List<WmsContainer> adds = new(); +// /// <summary> +// /// 鑾峰彇鎵樼洏淇℃伅鍒楄〃 +// /// </summary> +// /// <param name="input"></param> +// /// <returns></returns> +// [HttpGet("list")] +// public async Task<List<WmsContainerOutput>> List([FromQuery] WmsContainerInput input) +// { +// return await _wmsContainerRep.DetachedEntities.ProjectToType<WmsContainerOutput>().ToListAsync(); +// } +// /// <summary> +// /// Excel妯℃澘瀵煎叆鎵樼洏淇℃伅鍔熻兘 +// /// </summary> +// /// <param name="file">Excel妯℃澘鏂囦欢</param> +// /// <param name="importExcelType">Excel瀵煎叆鏂瑰紡</param> +// /// <returns>瀵煎叆鐨勮褰曟暟</returns> +// [HttpPost("fromExcel")] +// public async Task<int> FromExcelAsync(IFormFile file, [FromQuery] ImportExcelType importExcelType) +// { +// int size = 200; +// var excelTemplate = await _sysExcelTemplateService.GetByAppNameAndClassNameAndVersionAsync("WmsContainer", "v2"); +// if (excelTemplate == null) throw Oops.Oh(ErrorCode.Excel002); +// var keys = excelTemplate.UnionUniqueFields.Split(",") ?? Array.Empty<string>(); +// for (var i = 0; i < keys.Length; i++) +// { +// keys[i] = keys[i]?.Trim() ?? string.Empty; +// } +// ExcelUtil.FromExcel(file, excelTemplate.HeadStartLine, excelTemplate.DataStartLine, out List<string> headers, out List<List<object>> data, out string sheetName); +// List<WmsContainerOutput> wmsContainerList = DataConvertUtil.ToObjectList(headers, data, sheetName, keys, excelTemplate?.DataStartLine ?? 2, out Dictionary<string, WmsContainerOutput> dict); +// List<Dictionary<string, object>> uniqueKeyValueDictList = wmsContainerList.ParseUniqueKeyValueDictList(keys.ToList(), excelTemplate?.DataStartLine ?? 2, sheetName); +// var filters = DataConvertUtil.GetExpressionListByUniqueDict<WmsContainer>(keys.ToList(), uniqueKeyValueDictList, size); +// var selectKeys = keys.ToList(); +// if(!selectKeys.Contains("Id")) selectKeys.Add("Id"); +// var selector = DataConvertUtil.GetSelectExpressionListByUniqueDict<WmsContainer, WmsContainerOutput>(selectKeys); +// List<WmsContainer> updates = new(); +// List<WmsContainer> adds = new(); - lock (_lock) - { - foreach (var filter in filters) - { - var wmsContainerExistSubList = _wmsContainerRep.Where(filter).Select(selector).ToList(); - wmsContainerExistSubList.ForEach(x => - { - var k = DataConvertUtil.GetKey(x, keys); - if (dict.ContainsKey(k)) dict[k].Id = x.Id; - }); - } - foreach (var wmsContainer in wmsContainerList) - { - if (wmsContainer.Id > 0) - { - if (importExcelType == ImportExcelType.ADD_AND_UPDATE) updates.Add(wmsContainer.Adapt<WmsContainer>()); - } - else - { - adds.Add(wmsContainer.Adapt<WmsContainer>()); - } - } +// lock (_lock) +// { +// foreach (var filter in filters) +// { +// var wmsContainerExistSubList = _wmsContainerRep.Where(filter).Select(selector).ToList(); +// wmsContainerExistSubList.ForEach(x => +// { +// var k = DataConvertUtil.GetKey(x, keys); +// if (dict.ContainsKey(k)) dict[k].Id = x.Id; +// }); +// } +// foreach (var wmsContainer in wmsContainerList) +// { +// if (wmsContainer.Id > 0) +// { +// if (importExcelType == ImportExcelType.ADD_AND_UPDATE) updates.Add(wmsContainer.Adapt<WmsContainer>()); +// } +// else +// { +// adds.Add(wmsContainer.Adapt<WmsContainer>()); +// } +// } - if (importExcelType == ImportExcelType.ADD_AND_UPDATE) updates.ForEach(x => _wmsContainerRep.Update(x)); +// if (importExcelType == ImportExcelType.ADD_AND_UPDATE) updates.ForEach(x => _wmsContainerRep.Update(x)); - var maxId = _wmsContainerRep.DetachedEntities.OrderByDescending(x => x.Id).Select(x => x.Id).FirstOrDefault(); - adds.ForEach(x => x.Id = ++maxId); - Db.GetDbContext().Set<WmsContainer>().AddRange(adds); - Db.GetDbContext().SaveChanges(); +// var maxId = _wmsContainerRep.DetachedEntities.OrderByDescending(x => x.Id).Select(x => x.Id).FirstOrDefault(); +// adds.ForEach(x => x.Id = ++maxId); +// Db.GetDbContext().Set<WmsContainer>().AddRange(adds); +// Db.GetDbContext().SaveChanges(); - } - await Task.CompletedTask; - return adds.Count; - } +// } +// await Task.CompletedTask; +// return adds.Count; +// } - /// <summary> - /// 鏍规嵁鐗堟湰涓嬭浇鎵樼洏淇℃伅鐨凟xcel瀵煎叆妯℃澘 - /// </summary> - /// <param name="version">妯℃澘鐗堟湰</param> - /// <returns>涓嬭浇鐨勬ā鏉挎枃浠�</returns> - [HttpGet("downloadExcelTemplate")] - public async Task<IActionResult> DownloadExcelTemplate([FromQuery] string version) - { - var excelTemplate = await _sysExcelTemplateService.GetByAppNameAndClassNameAndVersionAsync("WmsContainer", version); - if (excelTemplate == null) throw Oops.Oh(ErrorCode.Excel002); - var path = Path.Combine(@"\", excelTemplate.TemplateFileName); - Stream ms = FileUtil.Download(path, excelTemplate.TemplateFileName); - var fileName = HttpUtility.UrlEncode($"{excelTemplate.Name}瀵煎叆妯℃澘.xlsx", Encoding.GetEncoding("UTF-8")); - return new FileStreamResult(ms, "application/octet-stream") { FileDownloadName = fileName }; - } - /// <summary> - /// 鏍规嵁鎵樼洏淇℃伅鏌ヨ鍙傛暟瀵煎嚭Excel - /// </summary> - /// <param name="input">鎵樼洏淇℃伅鏌ヨ鍙傛暟</param> - /// <returns>瀵煎嚭鐨凟xcel鏂囦欢</returns> - [HttpGet("toExcel")] - public async Task<IActionResult> ToExcelAsync([FromQuery] WmsContainerSearchNonPage input) - { - var wmsContainerList = await ListNonPageAsync(input); - MemoryStream ms = new(); - DataConvertUtil.ToExcelData(wmsContainerList, _sysDictTypeRep, _sysDictDataRep, out List<string> headers, - out List<List<object>> data, out string sheetName); - var excelTemplate = await _sysExcelTemplateService.GetByAppNameAndClassNameAndVersionAsync("WmsContainer", "v1"); - if (excelTemplate != null) - { - ExcelUtil.ToExcel(excelTemplate.TemplateFileName, headers, data, sheetName, excelTemplate.HeadStartLine, excelTemplate.DataStartLine, ms); - } - else - { - ExcelUtil.ToExcel(headers, data, sheetName, ms); - } - ms.Position = 0; - var fileName = HttpUtility.UrlEncode($"{sheetName}[{DateTimeOffset.Now:yyyy-MM-dd}].xlsx", Encoding.GetEncoding("UTF-8")); - return new FileStreamResult(ms, "application/octet-stream") { FileDownloadName = fileName }; - } - } -} +// /// <summary> +// /// 鏍规嵁鐗堟湰涓嬭浇鎵樼洏淇℃伅鐨凟xcel瀵煎叆妯℃澘 +// /// </summary> +// /// <param name="version">妯℃澘鐗堟湰</param> +// /// <returns>涓嬭浇鐨勬ā鏉挎枃浠�</returns> +// [HttpGet("downloadExcelTemplate")] +// public async Task<IActionResult> DownloadExcelTemplate([FromQuery] string version) +// { +// var excelTemplate = await _sysExcelTemplateService.GetByAppNameAndClassNameAndVersionAsync("WmsContainer", version); +// if (excelTemplate == null) throw Oops.Oh(ErrorCode.Excel002); +// var path = Path.Combine(@"\", excelTemplate.TemplateFileName); +// Stream ms = FileUtil.Download(path, excelTemplate.TemplateFileName); +// var fileName = HttpUtility.UrlEncode($"{excelTemplate.Name}瀵煎叆妯℃澘.xlsx", Encoding.GetEncoding("UTF-8")); +// return new FileStreamResult(ms, "application/octet-stream") { FileDownloadName = fileName }; +// } +// /// <summary> +// /// 鏍规嵁鎵樼洏淇℃伅鏌ヨ鍙傛暟瀵煎嚭Excel +// /// </summary> +// /// <param name="input">鎵樼洏淇℃伅鏌ヨ鍙傛暟</param> +// /// <returns>瀵煎嚭鐨凟xcel鏂囦欢</returns> +// [HttpGet("toExcel")] +// public async Task<IActionResult> ToExcelAsync([FromQuery] WmsContainerSearchNonPage input) +// { +// var wmsContainerList = await ListNonPageAsync(input); +// MemoryStream ms = new(); +// DataConvertUtil.ToExcelData(wmsContainerList, _sysDictTypeRep, _sysDictDataRep, out List<string> headers, +// out List<List<object>> data, out string sheetName); +// var excelTemplate = await _sysExcelTemplateService.GetByAppNameAndClassNameAndVersionAsync("WmsContainer", "v1"); +// if (excelTemplate != null) +// { +// ExcelUtil.ToExcel(excelTemplate.TemplateFileName, headers, data, sheetName, excelTemplate.HeadStartLine, excelTemplate.DataStartLine, ms); +// } +// else +// { +// ExcelUtil.ToExcel(headers, data, sheetName, ms); +// } +// ms.Position = 0; +// var fileName = HttpUtility.UrlEncode($"{sheetName}[{DateTimeOffset.Now:yyyy-MM-dd}].xlsx", Encoding.GetEncoding("UTF-8")); +// return new FileStreamResult(ms, "application/octet-stream") { FileDownloadName = fileName }; +// } +// } +//} -- Gitblit v1.9.3