From 57c8c6628ce921c88a6efd49ba78f37f6ec26ed1 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 21 Jun 2022 09:31:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entities/Materials/MaterialDtoBase.cs | 85 ++++- .../ErrorListBill/ErrorBillAppService.cs | 354 ++++++++++++++++++ ...ttleAccountApplicationAutoMapperProfile.cs | 12 +- .../Entities/ErrorBillNum/ErrorBillNum.cs | 31 ++ 4 files changed, 478 insertions(+), 4 deletions(-) create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Application/Entities/ErrorListBill/ErrorBillAppService.cs create mode 100644 src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ErrorBillNum/ErrorBillNum.cs diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Materials/MaterialDtoBase.cs b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Materials/MaterialDtoBase.cs index 671f842a..5cce368d 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Materials/MaterialDtoBase.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Materials/MaterialDtoBase.cs @@ -9,9 +9,92 @@ using Win.Sfs.Shared; using Win.Sfs.Shared.Constant; using Win.Sfs.Shared.DtoBase; -namespace Win.Sfs.SettleAccount.Entities.Materials + +namespace Win.Sfs.SettleAccount.Entities.Errors { + public class ErrorBillDto + { + /// + ///错误单据号 + /// + public string BillNum { get; protected set; } + + /// + /// 物料号 + /// + public string MaterialCode { set; get; } + + /// + /// 发货单号 + /// + public string WmsBillNum { set; get; } + + + } + public class ErrorBillImportDto + { + /// + ///错误单据号 + /// + public string BillNum { get; protected set; } + + /// + /// 物料号 + /// + public string MaterialCode { set; get; } + + /// + /// 发货单号 + /// + public string WmsBillNum { set; get; } + + } + + public class ErrorBillExportDto + { + /// + ///错误单据号 + /// + public string BillNum { get; protected set; } + + /// + /// 物料号 + /// + public string MaterialCode { set; get; } + + /// + /// 发货单号 + /// + public string WmsBillNum { set; get; } + + } + + + + public class ErrorBillRequestDto : RequestDtoBase, IBranch + { + ///错误单据号 + /// + public string BillNum { get; protected set; } + + /// + /// 物料号 + /// + public string MaterialCode { set; get; } + + /// + /// 发货单号 + /// + public string WmsBillNum { set; get; } + public Guid BranchId { get; set; } + } +} + + + +namespace Win.Sfs.SettleAccount.Entities.Materials +{ public class MaterialImportDtoTH { [ImporterHeader(Name= "PART NUMBER COMP")] diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/ErrorListBill/ErrorBillAppService.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/ErrorListBill/ErrorBillAppService.cs new file mode 100644 index 00000000..3b5e31a0 --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/ErrorListBill/ErrorBillAppService.cs @@ -0,0 +1,354 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using EFCore.BulkExtensions; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Caching.Distributed; +using Shouldly; +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.BackgroundJobs; +using Volo.Abp.Caching; +using Volo.Abp.Domain.Repositories; +using Volo.Abp.Guids; +using Volo.Abp.ObjectMapping; +using Volo.Abp.Uow; +using Win.Abp.Snowflakes; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.Boms; +using Win.Sfs.SettleAccount.CommonManagers; +using Win.Sfs.SettleAccount.Constant; +using Win.Sfs.SettleAccount.Entities.Boms; +using Win.Sfs.SettleAccount.Entities.Errors; +using Win.Sfs.SettleAccount.Entities.EstimatedInventories; +using Win.Sfs.SettleAccount.Entities.ImportMap; +using Win.Sfs.SettleAccount.Entities.Prices; +using Win.Sfs.SettleAccount.Entities.TaskJobs; +using Win.Sfs.SettleAccount.Errors; +using Win.Sfs.SettleAccount.EstimatedInventories; +using Win.Sfs.SettleAccount.ExcelImporter; +using Win.Sfs.SettleAccount.ExportReports; + + +using Win.Sfs.Shared.CacheBase; +using Win.Utils; +namespace Win.Sfs.SettleAccount.Entities.ErrorBills +{ + + /// + /// 物料主数据应用服务 + /// + // [Authorize(SettleAccountPermissions.ErrorBills.Default)] + //[AllowAnonymous] + [Route("api/settleaccount/ErrorBill")] + public class ErrorBillAppService : SettleAccountApplicationBase + { + + + private readonly IExcelImportAppService _excelImportService; + private readonly ISettleAccountBranchEfCoreRepository _repository; + private readonly ISettleAccountBranchEfCoreRepository _bomRepository; + private readonly ISettleAccountBranchEfCoreRepository _bomversionRepository; + private readonly ISettleAccountBranchEfCoreRepository _priceRepository; + private readonly ISettleAccountBranchEfCoreRepository _priceversionRepository; + private readonly ISettleAccountBranchEfCoreRepository _mapRepository; + //private readonly ISettleAccountBranchEfCoreRepository _relationshipRepository; + /// + /// 构建方法 + /// + /// 构建UID + /// 自动map + /// 仓储接口 + /// 缓存 + public ErrorBillAppService( + + ISettleAccountBranchEfCoreRepository repository, + ISettleAccountBranchEfCoreRepository mapRepository, + ISettleAccountBranchEfCoreRepository bomRepository, + ISettleAccountBranchEfCoreRepository bomversionRepository, + TaskJobService service, + //ISettleAccountBranchEfCoreRepository relationshipRepository, + ISettleAccountBranchEfCoreRepository priceRepository, + ISettleAccountBranchEfCoreRepository priceversionRepository, + + IDistributedCache cache, + IExcelImportAppService excelImportService, + ISnowflakeIdGenerator snowflakeIdGenerator, + ICommonManager commonManager + + ) : base(cache,excelImportService,snowflakeIdGenerator,commonManager) + { + _priceRepository = priceRepository; + _priceversionRepository = priceversionRepository; + _bomRepository = bomRepository; + _excelImportService = excelImportService; + _repository = repository; + //_relationshipRepository = relationshipRepository; + _mapRepository = mapRepository; + _bomversionRepository = bomversionRepository; + + } + + + /// + /// 导入功能 + /// + /// 上传的文件(前端已经限制只能上传一个附件) + /// + [HttpPost] + [Route("ExcelImport")] + [DisableRequestSizeLimit] + + public async Task ErrorBillUploadExcelImportMap([FromForm] IFormFileCollection files,string version) + { + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.ExtendExcelImport(files, _excelImportService); + return ApplicationConsts.SuccessStr; + } + + + + + + + + + /// + /// 导入功能 + /// + /// 上传的文件(前端已经限制只能上传一个附件) + /// + [HttpPost] + [Route("ExcelImport")] + [DisableRequestSizeLimit] + + public async Task ErrorBillUploadExcelImport([FromForm] IFormFileCollection files) + { + ExportImporter _exportImporter = new ExportImporter(); + var result = await _exportImporter.UploadExcelImport(files, _excelImportService); + var _ls = ObjectMapper.Map, List>(result); + var checkList = new List(); + foreach (var itm in _ls) + { + + + + //var _first = await _repository.FirstOrDefaultAsync(p => p.ErrorBillCode == itm.ErrorBillCode); + //if (_first == null) + //{ + //var entity = new ErrorBill( + // GuidGenerator.Create(), + // GuidGenerator.Create(), + // itm.Factory, + // itm.ErrorBillCode, + // itm.ErrorBillDesc, + // itm.Unit, + // itm.EstimateType, + // itm.EstimateTypeDesc + // ); + // await _repository.InsertAsync(entity); + //} + //else + //{ + //_first.Update(itm.ErrorBillDesc, itm.Unit, itm.EstimateType, itm.EstimateTypeDesc, itm.Factory + // ); + //await _repository.UpdateAsync(_first); + //} + //var _f = await _relationshipRepository.FirstOrDefaultAsync(p => p.ErpErrorBillCode == itm.ErrorBillCode); + //if (_f != null) + //{ + // _f.Update(itm.ErrorBillDesc, _f.ErrorBillProperty, _f.SettleErrorBillCode, _f.ShipMaterailCode); + // await _relationshipRepository.UpdateAsync(_f); + //} + //else + //{ + // var _r = new ErrorBillRelationship(GuidGenerator.Create(), GuidGenerator.Create(), itm.ErrorBillCode, itm.ErrorBillDesc, string.Empty, string.Empty, string.Empty, itm.EstimateType); + // await _relationshipRepository.InsertAsync(_r); + //} + + + + + } + return ApplicationConsts.SuccessStr; + } + + + + /// + /// 按ID获取唯一实体 + /// + /// + /// 返回实体全部属性 + /// + /// ID + /// 实体DTO + [HttpGet] + [Route("{id}")] + + virtual public async Task GetAsync(Guid id) + { + + + var result = await GetFromCacheAsync(id); + var dto = ObjectMapper.Map(result); + return dto; + } + + + private async Task GetFromCacheAsync(Guid id) + { + var result = await _repository.GetAsync(id); + + return result; + } + + + private async Task GetCountAsync(ErrorBillRequestDto input) + { + return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); + } + + + + + ///// + + /// + /// 根据筛选条件获取实体列表 + /// + /// + /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码 + /// + /// 请求条件 + /// 实体DTO列表 + [HttpPost] + [Route("list")] + + virtual public async Task> GetListAsync(ErrorBillRequestDto input) + { + var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount, + input.SkipCount, true); + + var totalCount = await GetCountAsync(input); + var dtos = ObjectMapper.Map, List>(entities); + + return new PagedResultDto(totalCount, dtos); + } + + + /// + /// 获取实体总数 + /// + /// 实体总数 + [HttpGet] + [Route("count")] + + virtual public async Task GetTotalCountAsync(Guid branchId) + { + return await _repository.GetCountAsync(branchId); + } + + /// + /// 获取全部实体列表 + /// + /// 实体DTO列表 + [HttpGet] + [Route("all")] + + virtual public async Task> GetAllAsync(Guid branchId) + { + var entities = await _repository.GetAllAsync(branchId, true); + var dtos = ObjectMapper.Map, List>(entities); + return new ListResultDto(dtos); + } + + + + + + /// + /// 新增实体 + /// + /// 新增实体DTO + /// 实体DTO + + + + + /// + /// 删除实体 + /// + /// ID + /// + [HttpDelete] + [Route("{id}")] + + virtual public async Task DeleteAsync(Guid id) + { + var entity = await GetFromCacheAsync(id); + await Cache.DeleteAsync(id.ToString()); + await _repository.DeleteAsync(id); + } + + /// + /// 按IDs删除实体列表 + /// + /// IDs + /// 是否执行成功 + [HttpPost] + [Route("delete")] + + virtual public async Task DeleteListAsync(List ids) + { + var _query = _repository.Where(p => ids.Contains(p.Id)); + int i = await _query.BatchDeleteAsync(); + + if (i == 0) + { + return false; + } + return true; + } + [HttpPost] + [Route("Export")] + + virtual public async Task ExportAsync(ErrorBillRequestDto input) + { + string _fileName = string.Format("错误单据_{0}.xlsx", DateTime.Now.ToString("yyyyMMdd")); + var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, + 0, true); + + var dtoDetails = ObjectMapper.Map, List>(entities); + + //声明导出容器 + ExportImporter _exportImporter = new ExportImporter(); + + var result = await _exportImporter.ExcelExporter(dtoDetails); + + result.ShouldNotBeNull(); + + //保存导出文件到服务器存成二进制 + await _excelImportService.SaveBlobAsync( + new SaveExcelImportInputDto + { + Name = _fileName, + Content = result + } + ); + return _fileName; + } + + + + + + } +} diff --git a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs index 9a051ac7..89d2927d 100644 --- a/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs +++ b/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs @@ -91,6 +91,8 @@ using Win.Sfs.SettleAccount.Entities.WMS; using Win.Sfs.SettleAccount.Entities; using Win.Sfs.SettleAccount.Entities.UnHQSettleAccounts; using Win.Sfs.SettleAccount.Entities.Wms.WmsSumOutput; +using Win.Sfs.SettleAccount.Errors; +using Win.Sfs.SettleAccount.Entities.Errors; namespace Win.Sfs.SettleAccount { @@ -137,9 +139,6 @@ namespace Win.Sfs.SettleAccount CreateMapSecondaryPriceRatioVersion(); CreateMapSecondaryAdjustmentVersion(); - - - CreateMapEstimatedStockDiffReport(); CreateMapSendUnsettledDiffReport(); CreateMapStockSettledDiffReport(); @@ -268,12 +267,19 @@ namespace Win.Sfs.SettleAccount CreateMapWMSDiffOutputSum(); CreateMapWMSWithCodeOutputSum(); CreateMapWMSCacelOutputSum(); + CreateMapWMSErrorBill(); #endregion } #region 派格出库单 + private void CreateMapWMSErrorBill() + { + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + } + private void CreateMapWMSOutputSum() { CreateMap().ReverseMap(); diff --git a/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ErrorBillNum/ErrorBillNum.cs b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ErrorBillNum/ErrorBillNum.cs new file mode 100644 index 00000000..9cc5b4bb --- /dev/null +++ b/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/ErrorBillNum/ErrorBillNum.cs @@ -0,0 +1,31 @@ +using System; +using System.ComponentModel.DataAnnotations; +using Win.Sfs.Shared.DomainBase; + +using Win.Sfs.Shared.Constant; + +namespace Win.Sfs.SettleAccount.Errors +{ + /// + /// 错误单据 + /// + public class ErrorBill : FullAuditedAggregateRootBase + { + /// + ///错误单据号 + /// + public string BillNum { get; set; } + + /// + /// 物料号 + /// + public string MaterialCode { set; get; } + + /// + /// 发货单号 + /// + public string WmsBillNum { set; get; } + + + } +} \ No newline at end of file