Browse Source

不能出库和出库基类,单据生成公用类

master
学 赵 1 year ago
parent
commit
4f42a84ad3
  1. 29
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/IHBPO_CAN_SA_SERVICE.cs
  2. 121
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CAN_SA_SERVICE.cs
  3. 107
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/NOT_SA_SERVICE.cs
  4. 37
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/OrderNumberGenerator.cs
  5. 82
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Boms/BomAppService.cs

29
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<TEntity, TEntityDto, TEntityDetailDto, TRequestMainInput, TRequestDetailInput, TExportDto>
where TEntity : SA_CAN_BASE
where TEntityDto : class, IEntityDto<Guid>, new()
where TEntityDetailDto : class, IEntityDto<Guid>, new()
where TRequestMainInput : PagedAndSortedResultRequestDto
where TRequestDetailInput : PagedAndSortedResultRequestDto
{
Task<bool> GenerateInvoice(TRequestMainInput input);
Task<PagedResultDto<TEntityDto>> MainQueryAsync(TRequestMainInput input);
Task<PagedResultDto<TEntityDetailDto>> DetailQueryAsync(TRequestDetailInput input);
Task<string> ExportAsync(TRequestMainInput input);
// List<ErrorData> ISettlementOrderCheckRule<TEntity>(List<TEntity> p_list, Configuation config) where TEntity : ISABASE
//bList<ErrorData> ISettlementOrderCheckState<TEntity>(List<TEntity> p_list) where TEntity:ISABASE
}
public interface IHBPO_CAN_SA_SERVICE
{
Task<bool> GenerateInvoice(HBPO_CAN_SA_REQ_DTO input);

121
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<TEntity, TEntityDto, TEntityDetail, TEntityDetailDto, TRequestMainInput, TRequestDetailInput, TEntityDetailExportDto> :ApplicationService
where TEntity : class, IEntity<Guid>
where TEntityDetail:SA_CAN_BASE
where TEntityDto : class, IEntityDto<Guid>, new()
where TEntityDetailDto : class, IEntityDto<Guid>, new()
where TRequestMainInput : RequestInputBase
where TRequestDetailInput : RequestInputBase
where TEntityDetailExportDto : class, new()
{
private readonly INormalEfCoreRepository<TEntity, Guid> _repository;
private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly IExcelImportAppService _excelImportService;
protected CAN_SA_SERVICE(
INormalEfCoreRepository<TEntity, Guid> repository,
IExcelImportAppService excelImportService,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository
)
{
_excelImportService = excelImportService;
_repository = repository;
_detailRepository = detailRepository;
}
[HttpPost]
//[Route("detailquery")]
public virtual async Task<PagedResultDto<TEntityDetailDto>> 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<TEntityDetail>, List<TEntityDetailDto>>(entitys);
return new PagedResultDto<TEntityDetailDto>(totalCount, dtos);
}
[HttpPost]
//[Route("export")]
public virtual async Task<string> 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<TEntityDetail>, List<TEntityDetailExportDto>>(entities);
var classDisplayName = typeof(TEntityDetailExportDto).GetCustomAttribute<DisplayAttribute>()?.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<bool> GenerateInvoice(TRequestMainInput input)
{
throw new NotImplementedException();
}
[HttpPost]
//[Route("mainquery")]
public virtual async Task<PagedResultDto<TEntityDto>> 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<TEntity>, List<TEntityDto>>(entitys);
return new PagedResultDto<TEntityDto>(totalCount, dtos);
}
}
}

107
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<TEntityDetail, TEntityDetailDto, TRequestDetailInput, TEntityDetailExportDto> : ApplicationService
where TEntityDetail : SA_CAN_BASE
where TEntityDetailDto : class, IEntityDto<Guid>, new()
where TRequestDetailInput : RequestInputBase
where TEntityDetailExportDto : class, new()
{
private readonly INormalEfCoreRepository<TEntityDetail, Guid> _detailRepository;
private readonly IExcelImportAppService _excelImportService;
protected NOT_SA_SERVICE(
IExcelImportAppService excelImportService,
INormalEfCoreRepository<TEntityDetail, Guid> detailRepository
)
{
_excelImportService = excelImportService;
_detailRepository = detailRepository;
}
[HttpPost]
//[Route("detailquery")]
public virtual async Task<PagedResultDto<TEntityDetailDto>> 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<TEntityDetail>, List<TEntityDetailDto>>(entitys);
return new PagedResultDto<TEntityDetailDto>(totalCount, dtos);
}
[HttpPost]
//[Route("export")]
public virtual async Task<string> 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<TEntityDetail>, List<TEntityDetailExportDto>>(entities);
var classDisplayName = typeof(TEntityDetailExportDto).GetCustomAttribute<DisplayAttribute>()?.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;
}
}
}

37
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;
/// <summary>
/// 如无类别
/// </summary>
/// <param name="p_OrderType"></param>
/// <returns></returns>
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;
}
}
}
}

82
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>
{
/// <summary>
/// BOM仓储
/// BOM�ִ�
/// </summary>
private readonly INormalEfCoreRepository<Bom, Guid> _repository;
/// <summary>
/// 构造
/// ����
/// </summary>
public BomAppService(
INormalEfCoreRepository<Bom, Guid> repository,
@ -45,9 +45,9 @@ namespace Win.Sfs.SettleAccount.Boms
_repository = repository;
}
#region 导出
#region ����
/// <summary>
/// 导出
/// ����
/// </summary>
[HttpPost]
public virtual async Task<string> ExportAsync(BomRequestDto input)
@ -57,14 +57,14 @@ namespace Win.Sfs.SettleAccount.Boms
0, true);
var dtoDetails = ObjectMapper.Map<List<Bom>, List<BomExportDto> >(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
/// <summary>
/// 获取列表
/// ��ȡ�б�
/// </summary>
[HttpPost]
public async Task<PagedResultDto<BomDto>> GetListAsync(BomRequestDto input)
@ -90,13 +90,13 @@ namespace Win.Sfs.SettleAccount.Boms
}
#endregion
#region 原方法(废弃)
// #region 导入导出功能
#region ԭ������������
// #region ���뵼������
// /// <summary>
// /// 导入功能
// /// ���빦��
// /// </summary>
// /// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
// /// <param name="files">�ϴ����ļ�(ǰ���Ѿ�����ֻ���ϴ�һ������)</param>
// /// <returns></returns>
// [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
// /// <summary>
// /// 导入功能
// /// ���빦��
// /// </summary>
// /// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
// /// <param name="files">�ϴ����ļ�(ǰ���Ѿ�����ֻ���ϴ�һ������)</param>
// /// <returns></returns>
// [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;
// }
// /// <summary>
// /// 导出文件
// /// �����ļ�
// /// </summary>
// /// <param name="input"></param>
// /// <returns></returns>
@ -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<Bom>, List<BomExportDto>>(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
// /// <summary>
// /// 按ID获取唯一实体
// /// ��ID��ȡΨһʵ��
// /// </summary>
// /// <remarks>
// /// 返回实体全部属性
// /// ����ʵ��ȫ������
// /// </remarks>
// /// <param name="id">ID</param>
// /// <returns>实体DTO</returns>
// /// <returns>ʵ��DTO</returns>
// [HttpGet]
// [Route("{id}")]
//[Authorize(SettleAccountPermissions.Boms.Default)]
@ -291,9 +291,9 @@ namespace Win.Sfs.SettleAccount.Boms
// }
// /// <summary>
// /// 获取实体总数
// /// ��ȡʵ������
// /// </summary>
// /// <returns>实体总数</returns>
// /// <returns>ʵ������</returns>
// [HttpGet]
// [Route("count")]
//[Authorize(SettleAccountPermissions.Boms.Default)]
@ -305,10 +305,10 @@ namespace Win.Sfs.SettleAccount.Boms
// /// <summary>
// /// 删除实体
// /// ɾ��ʵ��
// /// </summary>
// /// <param name="id">ID</param>
// /// <returns></returns>
// /// <returns>��</returns>
// [HttpDelete]
// [Route("{id}")]
//[Authorize(SettleAccountPermissions.Boms.Delete)]
@ -320,10 +320,10 @@ namespace Win.Sfs.SettleAccount.Boms
// }
// /// <summary>
// /// 按IDs删除实体列表
// /// ��IDsɾ��ʵ���б�
// /// </summary>
// /// <param name="ids">IDs</param>
// /// <returns>是否执行成功</returns>
// /// <returns>�Ƿ�ִ�гɹ�</returns>
// [HttpPost]
// [Route("delete")]
//[Authorize(SettleAccountPermissions.Boms.Delete)]
@ -342,13 +342,13 @@ namespace Win.Sfs.SettleAccount.Boms
// ///// <summary>
// /// <summary>
// /// 根据筛选条件获取实体列表
// /// ����ɸѡ������ȡʵ���б�
// /// </summary>
// /// <remarks>
// /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
// /// ������������:ɸѡ�����б�,��������,��������,ҳ��
// /// </remarks>
// /// <param name="input">请求条件</param>
// /// <returns>实体DTO列表</returns>
// /// <param name="input">��������</param>
// /// <returns>ʵ��DTO�б�</returns>
// [HttpPost]
// [Route("list")]
// [Authorize(SettleAccountPermissions.Boms.Default)]
@ -372,13 +372,13 @@ namespace Win.Sfs.SettleAccount.Boms
// ///// <summary>
// /// <summary>
// /// 根据筛选条件获取实体列表
// /// ����ɸѡ������ȡʵ���б�
// /// </summary>
// /// <remarks>
// /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
// /// ������������:ɸѡ�����б�,��������,��������,ҳ��
// /// </remarks>
// /// <param name="input">请求条件</param>
// /// <returns>实体DTO列表</returns>
// /// <param name="input">��������</param>
// /// <returns>ʵ��DTO�б�</returns>
// [HttpPost]
// [Route("listVersion")]
// [Authorize(SettleAccountPermissions.Boms.Default)]

Loading…
Cancel
Save