diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/IHBPO_CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/IHBPO_CAN_SA_SERVICE.cs index a5de7ba5..6c43009e 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/IHBPO_CAN_SA_SERVICE.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/IHBPO_CAN_SA_SERVICE.cs @@ -1,13 +1,40 @@ -using System; +using SettleAccount.Bases; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Volo.Abp.Application.Dtos; +using Volo.Abp.Domain.Entities; +using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Entities.BQ.Dtos; namespace Win.Sfs.SettleAccount.Entities.BQ { + public interface ICAN_SA_SERVICE + where TEntity : SA_CAN_BASE + where TEntityDto : class, IEntityDto, new() + where TEntityDetailDto : class, IEntityDto, new() + where TRequestMainInput : PagedAndSortedResultRequestDto + where TRequestDetailInput : PagedAndSortedResultRequestDto + + { + + Task GenerateInvoice(TRequestMainInput input); + Task> MainQueryAsync(TRequestMainInput input); + Task> DetailQueryAsync(TRequestDetailInput input); + Task ExportAsync(TRequestMainInput input); + + + + // List ISettlementOrderCheckRule(List p_list, Configuation config) where TEntity : ISABASE + //bList ISettlementOrderCheckState(List p_list) where TEntity:ISABASE + + + + + } + public interface IHBPO_CAN_SA_SERVICE { Task GenerateInvoice(HBPO_CAN_SA_REQ_DTO input); diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs new file mode 100644 index 00000000..206cd4a6 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs @@ -0,0 +1,121 @@ +using AutoMapper; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Csv; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Mvc; +using SettleAccount.Bases; +using Shouldly; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Entities; +using Volo.Abp.ObjectMapping; +using Volo.Abp.TenantManagement.EntityFrameworkCore; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.Entities.BQ; +using Win.Sfs.SettleAccount.Entities.BQ.Dtos; +using Win.Sfs.Shared.RepositoryBase; + +namespace Win.Sfs.SettleAccount.Bases +{ + public class CAN_SA_SERVICE :ApplicationService + where TEntity : class, IEntity + where TEntityDetail:SA_CAN_BASE + where TEntityDto : class, IEntityDto, new() + where TEntityDetailDto : class, IEntityDto, new() + where TRequestMainInput : RequestInputBase + where TRequestDetailInput : RequestInputBase + where TEntityDetailExportDto : class, new() + { + + private readonly INormalEfCoreRepository _repository; + private readonly INormalEfCoreRepository _detailRepository; + private readonly IExcelImportAppService _excelImportService; + + protected CAN_SA_SERVICE( + INormalEfCoreRepository repository, + IExcelImportAppService excelImportService, + INormalEfCoreRepository detailRepository + + ) + { + _excelImportService = excelImportService; + _repository = repository; + _detailRepository = detailRepository; + + + } + + [HttpPost] + //[Route("detailquery")] + public virtual async Task> DetailQueryAsync(TRequestDetailInput input) + { + + var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); + var totalCount = await _detailRepository.GetCountByFilterAsync(input.Filters); + var dtos = ObjectMapper.Map, List>(entitys); + return new PagedResultDto(totalCount, dtos); + + } + [HttpPost] + //[Route("export")] + public virtual async Task ExportAsync(TRequestDetailInput input) + { + IExporter _csv = new CsvExporter(); + IExporter _excel = new ExcelExporter(); + + var entities = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); + var dtoDetails = ObjectMapper.Map, List>(entities); + + var classDisplayName = typeof(TEntityDetailExportDto).GetCustomAttribute()?.Name ?? typeof(TEntityDetailExportDto).Name; + string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; + byte[] result = null; + + switch (input.FileType) + { + case 0: + result = await _csv.ExportAsByteArray(dtoDetails); + break; + case 1: + result = await _excel.ExportAsByteArray(dtoDetails); + break; + } + result.ShouldNotBeNull(); + + //保存导出文件到服务器存成二进制 + await _excelImportService.SaveBlobAsync( + new SaveExcelImportInputDto + { + Name = _fileName, + Content = result + } + ); + return _fileName; + } + [HttpPost] + //[Route("generateinvoice")] + public Task GenerateInvoice(TRequestMainInput input) + { + throw new NotImplementedException(); + } + [HttpPost] + //[Route("mainquery")] + public virtual async Task> MainQueryAsync(TRequestMainInput input) + { + var entitys = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); + var totalCount = await _repository.GetCountByFilterAsync(input.Filters); + var dtos = ObjectMapper.Map, List>(entitys); + return new PagedResultDto(totalCount, dtos); + } + + + + + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs new file mode 100644 index 00000000..f1b76d6c --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs @@ -0,0 +1,107 @@ +using AutoMapper; +using Magicodes.ExporterAndImporter.Core; +using Magicodes.ExporterAndImporter.Csv; +using Magicodes.ExporterAndImporter.Excel; +using Microsoft.AspNetCore.Mvc; +using SettleAccount.Bases; +using Shouldly; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.Domain.Entities; +using Win.Sfs.BaseData.ImportExcelCommon; +using Win.Sfs.SettleAccount.Entities.BQ.Dtos; +using Win.Sfs.Shared.RepositoryBase; + +namespace Win.Sfs.SettleAccount.Bases +{ + internal class NOT_SA_SERVICE : ApplicationService + + where TEntityDetail : SA_CAN_BASE + + where TEntityDetailDto : class, IEntityDto, new() + + where TRequestDetailInput : RequestInputBase + where TEntityDetailExportDto : class, new() + { + + + private readonly INormalEfCoreRepository _detailRepository; + private readonly IExcelImportAppService _excelImportService; + + protected NOT_SA_SERVICE( + + IExcelImportAppService excelImportService, + INormalEfCoreRepository detailRepository + + ) + { + _excelImportService = excelImportService; + _detailRepository = detailRepository; + } + + [HttpPost] + //[Route("detailquery")] + public virtual async Task> DetailQueryAsync(TRequestDetailInput input) + { + + var entitys = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); + var totalCount = await _detailRepository.GetCountByFilterAsync(input.Filters); + var dtos = ObjectMapper.Map, List>(entitys); + return new PagedResultDto(totalCount, dtos); + + } + [HttpPost] + //[Route("export")] + public virtual async Task ExportAsync(TRequestDetailInput input) + { + IExporter _csv = new CsvExporter(); + IExporter _excel = new ExcelExporter(); + + var entities = await _detailRepository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); + var dtoDetails = ObjectMapper.Map, List>(entities); + + var classDisplayName = typeof(TEntityDetailExportDto).GetCustomAttribute()?.Name ?? typeof(TEntityDetailExportDto).Name; + string _fileName = $"{classDisplayName}_{Guid.NewGuid().ToString()}.xlsx"; + byte[] result = null; + + switch (input.FileType) + { + case 0: + result = await _csv.ExportAsByteArray(dtoDetails); + break; + case 1: + result = await _excel.ExportAsByteArray(dtoDetails); + break; + } + result.ShouldNotBeNull(); + + //保存导出文件到服务器存成二进制 + await _excelImportService.SaveBlobAsync( + new SaveExcelImportInputDto + { + Name = _fileName, + Content = result + } + ); + return _fileName; + } + } + + + + + + + + + + + +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/OrderNumberGenerator.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/OrderNumberGenerator.cs new file mode 100644 index 00000000..8d5338d0 --- /dev/null +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/OrderNumberGenerator.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace Win.Sfs.SettleAccount.Bases +{ + public class OrderNumberGenerator + { + private static readonly object lockObject = new object(); + private static int sequence = 0; + + /// + /// 如无类别 + /// + /// + /// + public static string GenerateOrderNumber(string p_OrderType) + { + lock (lockObject) + { + // 获取当前时间和日期部分 + string currentDate = DateTime.Now.ToString("yyMMddHHmmss"); + + // 获取序列号部分 + string sequenceNumber = Interlocked.Increment(ref sequence).ToString().PadLeft(6, '0'); + + // 拼接单号 + string orderNumber = $"{p_OrderType}-{currentDate}-{sequenceNumber}"; + + return orderNumber; + } + } + } +} diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Boms/BomAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Boms/BomAppService.cs index 934e28f6..0ed42b08 100644 --- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Boms/BomAppService.cs +++ b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Boms/BomAppService.cs @@ -1,4 +1,4 @@ -using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Shouldly; using System; @@ -27,12 +27,12 @@ namespace Win.Sfs.SettleAccount.Boms public class BomAppService : SettleAccountApplicationBase { /// - /// BOMִ + /// BOM�ִ� /// private readonly INormalEfCoreRepository _repository; /// - /// + /// ���� /// public BomAppService( INormalEfCoreRepository repository, @@ -45,9 +45,9 @@ namespace Win.Sfs.SettleAccount.Boms _repository = repository; } - #region + #region ���� /// - /// + /// ���� /// [HttpPost] public virtual async Task ExportAsync(BomRequestDto input) @@ -57,14 +57,14 @@ namespace Win.Sfs.SettleAccount.Boms 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 { @@ -78,7 +78,7 @@ namespace Win.Sfs.SettleAccount.Boms #region CURD /// - /// ȡб + /// ��ȡ�б� /// [HttpPost] public async Task> GetListAsync(BomRequestDto input) @@ -90,13 +90,13 @@ namespace Win.Sfs.SettleAccount.Boms } #endregion - #region ԭ - // #region 뵼 + #region ԭ������������ + // #region ���뵼������ // /// - // /// 빦 + // /// ���빦�� // /// - // /// ϴļ(ǰѾֻϴһ) + // /// �ϴ����ļ�(ǰ���Ѿ�����ֻ���ϴ�һ������) // /// // [HttpPost] // [Route("ExcelImport-Map")] @@ -121,7 +121,7 @@ namespace Win.Sfs.SettleAccount.Boms // { // if (itm.Count > 1) // { - // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ܵ븸{0},ӱ{1}ظ", itm.ParentItmeCode, itm.ChildItemCode), string.Empty)); + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("���ܵ��븸����{0},�ӱ���{1}���ظ�����", itm.ParentItmeCode, itm.ChildItemCode), string.Empty)); // } // } // var _id = GuidGenerator.Create(); @@ -131,7 +131,7 @@ namespace Win.Sfs.SettleAccount.Boms // { // if (!_matList.Any(p => p.MaterialCode == itm.ParentItemCode)) // { - // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("ݲϺ{0}", itm.ParentItemCode), string.Empty)); + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("���������ݲ��������Ϻ�{0}��", itm.ParentItemCode), string.Empty)); // continue; // } // itm.SetValue(GuidGenerator.Create(), branchId, year, period, version, _id, factory); @@ -150,9 +150,9 @@ namespace Win.Sfs.SettleAccount.Boms // /// - // /// 빦 + // /// ���빦�� // /// - // /// ϴļ(ǰѾֻϴһ) + // /// �ϴ����ļ�(ǰ���Ѿ�����ֻ���ϴ�һ������) // /// // [HttpPost] // [Route("ExcelImport")] @@ -176,7 +176,7 @@ namespace Win.Sfs.SettleAccount.Boms // { // if (itm.Count > 1) // { - // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ܵ븸{0},ӱ{1}ظ", itm.ParentItmeCode, itm.ChildItemCode), string.Empty)); + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("���ܵ��븸����{0},�ӱ���{1}���ظ�����", itm.ParentItmeCode, itm.ChildItemCode), string.Empty)); // } // } // var _id = GuidGenerator.Create(); @@ -186,7 +186,7 @@ namespace Win.Sfs.SettleAccount.Boms // { // if (!_matList.Any(p => p.MaterialCode == itm.ParentItemCode)) // { - // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("ݲϺ{0}", itm.ParentItemCode), string.Empty)); + // checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("���������ݲ��������Ϻ�{0}��", itm.ParentItemCode), string.Empty)); // continue; // } // itm.SetValue(GuidGenerator.Create(),branchId,year,period,version,_id,factory); @@ -201,7 +201,7 @@ namespace Win.Sfs.SettleAccount.Boms // return ApplicationConsts.SuccessStr; // } // /// - // /// ļ + // /// �����ļ� // /// // /// // /// @@ -212,7 +212,7 @@ namespace Win.Sfs.SettleAccount.Boms // { // IExporter _csv = new CsvExporter(); // IExporter _excel = new ExcelExporter(); - // //ϰ汾ȫ + // //�������ϰ汾��������������ȫ���� // if (input.ParentId != Guid.Empty) // { // input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() }); @@ -225,23 +225,23 @@ namespace Win.Sfs.SettleAccount.Boms // 0, true); // var dtoDetails = ObjectMapper.Map, List>(entities); // string _fileName = string.Empty; - // // + // //������������ // byte[] result = null; // switch (input.FileType) // { // case 0: - // _fileName = string.Format("Ʒṹ_{0}.csv", input.UserId.ToString()); + // _fileName = string.Format("��Ʒ�ṹ_{0}.csv", input.UserId.ToString()); // result = await _csv.ExportAsByteArray(dtoDetails); // break; // case 1: - // _fileName = string.Format("Ʒṹ_{0}.xlsx", input.UserId.ToString()); + // _fileName = string.Format("��Ʒ�ṹ_{0}.xlsx", input.UserId.ToString()); // result = await _excel.ExportAsByteArray(dtoDetails); // break; // } // result.ShouldNotBeNull(); - // //浼ļɶ + // //���浼���ļ�����������ɶ����� // await _excelImportService.SaveBlobAsync( // new SaveExcelImportInputDto // { @@ -254,13 +254,13 @@ namespace Win.Sfs.SettleAccount.Boms // #endregion // /// - // /// IDȡΨһʵ + // /// ��ID��ȡΨһʵ�� // /// // /// - // /// ʵȫ + // /// ����ʵ��ȫ������ // /// // /// ID - // /// ʵDTO + // /// ʵ��DTO // [HttpGet] // [Route("{id}")] //[Authorize(SettleAccountPermissions.Boms.Default)] @@ -291,9 +291,9 @@ namespace Win.Sfs.SettleAccount.Boms // } // /// - // /// ȡʵ + // /// ��ȡʵ������ // /// - // /// ʵ + // /// ʵ������ // [HttpGet] // [Route("count")] //[Authorize(SettleAccountPermissions.Boms.Default)] @@ -305,10 +305,10 @@ namespace Win.Sfs.SettleAccount.Boms // /// - // /// ɾʵ + // /// ɾ��ʵ�� // /// // /// ID - // /// + // /// �� // [HttpDelete] // [Route("{id}")] //[Authorize(SettleAccountPermissions.Boms.Delete)] @@ -320,10 +320,10 @@ namespace Win.Sfs.SettleAccount.Boms // } // /// - // /// IDsɾʵб + // /// ��IDsɾ��ʵ���б� // /// // /// IDs - // /// Ƿִгɹ + // /// �Ƿ�ִ�гɹ� // [HttpPost] // [Route("delete")] //[Authorize(SettleAccountPermissions.Boms.Delete)] @@ -342,13 +342,13 @@ namespace Win.Sfs.SettleAccount.Boms // ///// // /// - // /// ɸѡȡʵб + // /// ����ɸѡ������ȡʵ���б� // /// // /// - // /// :ɸѡб,,,ҳ + // /// ������������:ɸѡ�����б�,��������,��������,ҳ�� // /// - // /// - // /// ʵDTOб + // /// �������� + // /// ʵ��DTO�б� // [HttpPost] // [Route("list")] // [Authorize(SettleAccountPermissions.Boms.Default)] @@ -372,13 +372,13 @@ namespace Win.Sfs.SettleAccount.Boms // ///// // /// - // /// ɸѡȡʵб + // /// ����ɸѡ������ȡʵ���б� // /// // /// - // /// :ɸѡб,,,ҳ + // /// ������������:ɸѡ�����б�,��������,��������,ҳ�� // /// - // /// - // /// ʵDTOб + // /// �������� + // /// ʵ��DTO�б� // [HttpPost] // [Route("listVersion")] // [Authorize(SettleAccountPermissions.Boms.Default)]