Browse Source

销售价格、备件价格

pull/1/head
mahao 1 year ago
parent
commit
50a26ff27c
  1. 7
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json
  2. 21
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Bases/RequestInputBase.cs
  3. 354
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs
  4. 150
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CurdBaseAppService.cs
  5. 41
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Prices/PriceListAppService.cs
  6. 271
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs
  7. 506
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs
  8. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj
  9. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  10. 35
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs
  11. 3750
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230711014038_20230711-1.Designer.cs
  12. 33
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230711014038_20230711-1.cs
  13. 6
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs
  14. 6
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountNormalEfCoreRepository.cs

7
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json

@ -3,13 +3,8 @@
"CorsOrigins": "https://*.abc.com,http://localhost:9528,http://149.223.116.5:8088" "CorsOrigins": "https://*.abc.com,http://localhost:9528,http://149.223.116.5:8088"
}, },
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True", "Default": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True",
"SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;" "SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;"
}, },
"Serilog": { "Serilog": {

21
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Bases/RequestInputBase.cs

@ -0,0 +1,21 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Application.Dtos;
using Win.Sfs.Shared.Filter;
namespace Win.Sfs.SettleAccount.Bases
{
public class RequestInputBase: PagedAndSortedResultRequestDto
{
/// <summary>
/// 导出文件类型
/// </summary>
public int FileType { get; set; }
/// <summary>
/// 高级检索
/// </summary>
[Display(Name = "高级检索")]
public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>();
}
}

354
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs

@ -2,10 +2,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.Filter;
namespace Win.Sfs.SettleAccount.Entities.Prices namespace Win.Sfs.SettleAccount.Entities.Prices
@ -50,81 +48,221 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
} }
/// <summary>
/// 销售价格单导出
/// </summary>
public class PriceListExportDto public class PriceListExportDto
{ {
/// <summary> /// <summary>
/// 版本 /// 零件号
/// </summary> /// </summary>
[Display(Name = "版本")] [Display(Name = "零件号")]
[ExporterHeader(DisplayName = "版本",IsIgnore =true)] [ExporterHeader(DisplayName = "零件号")]
public string Version { set; get; } public string LU { get; set; }
[ExporterHeader(DisplayName = "有效从")]
public DateTime BeginDate { get; set; }
/// <summary> /// <summary>
///结算时间 /// 价格
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "有效到")] [Display(Name = "价格")]
public DateTime EndDate { get; set; } [ExporterHeader(DisplayName = "价格")]
public Decimal Price { set; get; }
/// <summary> /// <summary>
///价格 /// 开始时间
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "*金额")] [Display(Name = "开始时间")]
public decimal Price { get; set; } [ExporterHeader(DisplayName = "开始时间")]
public DateTime BeginTime { set; get; }
/// <summary> /// <summary>
///物料编号 /// 结束时间
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "*物料编码")] [Display(Name = "结束时间")]
public string MaterialCode { get; set; } [ExporterHeader(DisplayName = "结束时间")]
public DateTime EndTime { set; get; }
/// <summary> /// <summary>
///价格类型 /// 客户编码
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "*分销渠道",IsIgnore =true)] [Display(Name = "客户编码")]
public int Type { get; set; } [ExporterHeader(DisplayName = "客户编码")]
[ExporterHeader(DisplayName = "*客户")] public string ClientCode { get; set; }
public string CustomerCode { get; set; }
} }
/// <summary>
/// 销售价格导入
/// </summary>
[ImportProject(Name = SettleAccountModuleName.PriceList)] [ImportProject(Name = SettleAccountModuleName.PriceList)]
public class PriceListImportDto public class PriceListImportDto
{ {
///// <summary> ///// <summary>
///// 版本 ///// ItemNo
///// </summary> ///// </summary>
//[Display(Name = "版本")] //[ImporterHeader(Name = "ItemNo")]
//public string Version { set; get; } //public string ItemNo { get; set; }
/// <summary> /// <summary>
///开始时间 /// 零件号
/// </summary> /// </summary>
[ImporterHeader(Name = "有效从")] [ImporterHeader(Name = "Part No.")]
public DateTime BeginDate { get; set; } public string PartNo { get; set; }
///// <summary>
///// PartDescription
///// </summary>
//[ImporterHeader(Name = "PartDescription")]
//public string PartDescription { get; set; }
///// <summary>
///// ES1
///// </summary>
//[ImporterHeader(Name = "ES1")]
//public string ES1 { get; set; }
///// <summary>
///// ES2
///// </summary>
//[ImporterHeader(Name = "ES2")]
//public string ES2 { get; set; }
///// <summary>
///// ZGS
///// </summary>
//[ImporterHeader(Name = "ZGS")]
//public string ZGS { get; set; }
///// <summary>
///// UnitOfMeasure
///// </summary>
//[ImporterHeader(Name = "UnitOfMeasure")]
//public string UnitOfMeasure { get; set; }
///// <summary>
///// Currency
///// </summary>
//[ImporterHeader(Name = "Currency")]
//public string Currency { get; set; }
///// <summary>
///// PriceType
///// </summary>
//[ImporterHeader(Name = "PriceType")]
//public string PriceType { get; set; }
/// <summary> /// <summary>
///结算时间 /// 价格
/// </summary> /// </summary>
[ImporterHeader(Name = "有效到")] [ImporterHeader(Name = "Total Price")]
public DateTime EndDate { get; set; } public string TotalPrice { get; set; }
///// <summary>
///// Base Price(Old)
///// </summary>
//[ImporterHeader(Name = "Base Price(Old)")]
//public string BasePriceOld { get; set; }
///// <summary>
///// UnitOfOrder
///// </summary>
//[ImporterHeader(Name = "Unit of Order")]
//public string UnitOfOrder { get; set; }
///// <summary>
///// 11000 - BBAC JIS
///// </summary>
//[ImporterHeader(Name = "11000 - BBAC JIS")]
//public string BBACJIS { get; set; }
/// <summary> /// <summary>
///价格 /// 开始时间
/// </summary> /// </summary>
[ImporterHeader(Name = "*金额")] [ImporterHeader(Name = "Valid From")]
public decimal Price { get; set; } public string ValidFrom { get; set; }
/// <summary> /// <summary>
///物料编号 /// 结束时间
/// </summary> /// </summary>
[ImporterHeader(Name = "*物料编码")] [ImporterHeader(Name = "Valid To")]
public string MaterialCode { get; set; } public string ValidTo { get; set; }
///// <summary>
///// ProductionCountry
///// </summary>
//[ImporterHeader(Name = "Production Country")]
//public string ProductionCountry { get; set; }
/// <summary> /// <summary>
///价格类型 /// 客户编码
/// </summary> /// </summary>
[ImporterHeader(Name = "*分销渠道")] [ImporterHeader(Name = "Plant")]
public int Type { get; set; } public string Plant { get; set; }
[ImporterHeader(Name = "*客户")]
public string CustomerCode { get; set; }
} ///// <summary>
///// Transport Term
///// </summary>
//[ImporterHeader(Name = "Transport Term")]
//public string TransportTerm { get; set; }
///// <summary>
///// Transport Term City
///// </summary>
//[ImporterHeader(Name = "Transport Term City")]
//public string TransportTermCity { get; set; }
///// <summary>
///// Transport Term Country
///// </summary>
//[ImporterHeader(Name = "Transport Term Country")]
//public string TransportTermCountry { get; set; }
///// <summary>
///// Shipping Location
///// </summary>
//[ImporterHeader(Name = "Shipping Location")]
//public string ShippingLocation { get; set; }
///// <summary>
///// Production Location
///// </summary>
//[ImporterHeader(Name = "Production Location")]
//public string ProductionLocation { get; set; }
///// <summary>
///// VAT Shipping Country
///// </summary>
//[ImporterHeader(Name = "VAT Shipping Country")]
//public string VATShippingCountry { get; set; }
///// <summary>
///// Minimum Order Quantity
///// </summary>
//[ImporterHeader(Name = "Minimum Order Quantity")]
//public string MinimumOrderQuantity { get; set; }
///// <summary>
///// Payment
///// </summary>
//[ImporterHeader(Name = "Payment")]
//public string Payment { get; set; }
///// <summary>
///// Packaging
///// </summary>
//[ImporterHeader(Name = "Packaging")]
//public string Packaging { get; set; }
///// <summary>
///// Return
///// </summary>
//[ImporterHeader(Name = "Return")]
//public string Return { get; set; }
///// <summary>
///// 3YP
///// </summary>
//[ImporterHeader(Name = "3YP")]
//public string YP3 { get; set; }
}
public class PriceListRequestDto : PagedAndSortedResultRequestDto public class PriceListRequestDto : PagedAndSortedResultRequestDto
{ {
@ -149,126 +287,76 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>(); public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>();
} }
#region 备件价格
public class PriceListBJDto : EntityDto<Guid> public class PriceListBJDto : EntityDto<Guid>
{ {
/// <summary> /// <summary>
/// 版本 /// 零件号
/// </summary>
[Display(Name = "版本")]
public string Version { set; get; }
/// <summary>
///开始时间
/// </summary>
[Display(Name = "开始时间")]
public DateTime BeginDate { get; set; }
/// <summary>
///结算时间
/// </summary> /// </summary>
[Display(Name = "结算时间")] [Display(Name = "零件号")]
public DateTime EndDate { get; set; } public string LU { get; set; }
/// <summary> /// <summary>
///价格 /// 价格
/// </summary> /// </summary>
[Display(Name = "价格")] [Display(Name = "价格")]
public decimal Price { get; set; } public Decimal Price { set; get; }
/// <summary>
///物料编号
/// </summary>
[Display(Name = "物料编号")]
public string MaterialCode { get; set; }
/// <summary> /// <summary>
///价格类型 /// 客户编码
/// </summary> /// </summary>
[Display(Name = "价格类型")] [Display(Name = "客户编码")]
public int Type { get; set; } public string ClientCode { get; set; }
public Guid ParentId { set; get; }
[Display(Name = "客户")]
public string CustomerCode { get; set; }
} }
[Display(Name = "备件价格")]
public class PriceListBJExportDto public class PriceListBJExportDto
{ {
/// <summary> /// <summary>
/// 版本 /// 零件号
/// </summary>
[Display(Name = "版本")]
[ExporterHeader(DisplayName = "版本")]
public string Version { set; get; }
[ImporterHeader(Name = "有效从")]
public DateTime BeginDate { get; set; }
/// <summary>
///结算时间
/// </summary> /// </summary>
[ImporterHeader(Name = "有效到")] [ExporterHeader(DisplayName = "零件号")]
public DateTime EndDate { get; set; } public string LU { get; set; }
/// <summary> /// <summary>
///价格 /// 价格
/// </summary> /// </summary>
[ImporterHeader(Name = "*金额")] [ExporterHeader(DisplayName = "价格")]
public decimal Price { get; set; } public decimal Price { get; set; }
/// <summary> /// <summary>
///物料编号 ///客户编码
/// </summary> /// </summary>
[ImporterHeader(Name = "*物料编码")] [ExporterHeader(DisplayName = "客户编码")]
public string MaterialCode { get; set; } public string ClientCode { get; set; }
/// <summary>
///价格类型
/// </summary>
[ImporterHeader(Name = "*分销渠道")]
public int Type { get; set; }
[ImporterHeader(Name = "*客户")]
public string CustomerCode { get; set; }
} }
public class PriceListBJImportDto public class PriceListBJImportDto
{ {
///// <summary>
///// 版本
///// </summary>
//[Display(Name = "版本")]
//public string Version { set; get; }
/// <summary> /// <summary>
///开始时间 /// 零件号
/// </summary>
[ImporterHeader(Name = "有效从")]
public DateTime BeginDate { get; set; }
/// <summary>
///结算时间
/// </summary> /// </summary>
[ImporterHeader(Name = "有效到")] [ImporterHeader(Name = "零件号")]
public DateTime EndDate { get; set; } public string LU { get; set; }
/// <summary> /// <summary>
///价格 /// 价格
/// </summary> /// </summary>
[ImporterHeader(Name = "*金额")] [ImporterHeader(Name = "价格")]
public decimal Price { get; set; } public decimal Price { get; set; }
/// <summary> /// <summary>
///物料编号 ///客户编码
/// </summary>
[ImporterHeader(Name = "*物料编码")]
public string MaterialCode { get; set; }
/// <summary>
///价格类型
/// </summary> /// </summary>
[ImporterHeader(Name = "*分销渠道")] [ImporterHeader(Name = "客户编码")]
public int Type { get; set; } public string ClientCode { get; set; }
[ImporterHeader(Name = "*客户")]
public string CustomerCode { get; set; }
} }
public class PriceListBJRequestDto : PagedAndSortedResultRequestDto public class PriceListBJRequestDto : RequestInputBase
{ {
[Display(Name = "开始时间")] [Display(Name = "开始时间")]
public DateTime BeginDate { get; set; } public DateTime BeginDate { get; set; }
[Display(Name = "结算时间")] [Display(Name = "结算时间")]
@ -288,6 +376,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>(); public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>();
} }
#endregion
/// <summary> /// <summary>
/// 列表 /// 列表
@ -389,6 +478,11 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
/// </summary> /// </summary>
[Display(Name = "高级检索")] [Display(Name = "高级检索")]
public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>(); public virtual List<FilterCondition> Filters { get; set; } = new List<FilterCondition>();
/// <summary>
/// 导出文件类型
/// </summary>
public int FileType { set; get; }
} }
} }

150
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CurdBaseAppService.cs

@ -0,0 +1,150 @@
using Castle.Core.Internal;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Shouldly;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
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.Constant;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Bases
{
public abstract class CurdBaseAppService<TEntity, TEntityDto, TRequestInput, TCreateInput, TImportInput, TExportDto> : ApplicationService
where TEntity : class, IEntity<Guid>
where TEntityDto : class, IEntityDto<Guid>, new()
where TRequestInput : RequestInputBase
where TImportInput : class, new()
where TExportDto : class, new()
{
private readonly INormalEfCoreRepository<TEntity, Guid> _repository;
private readonly IExcelImportAppService _excelImportService;
protected CurdBaseAppService(INormalEfCoreRepository<TEntity, Guid> repository, IExcelImportAppService excelImportService)
{
_repository = repository;
_excelImportService = excelImportService;
}
#region 导入、导出
/// <summary>
/// 获取导入模板
/// </summary>
[HttpPost("import-template")]
public virtual async Task<IActionResult> ImportTemplateAsync()
{
await Task.CompletedTask;
return new Microsoft.AspNetCore.Mvc.OkResult();
}
/// <summary>
/// 导入
/// </summary>
[HttpPost]
[Route("Import")]
public virtual async Task<string> ImportAsync([FromForm] IFormFileCollection files, string version)
{
await Task.CompletedTask;
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 导出
/// </summary>
[HttpPost]
[Route("Export")]
public virtual async Task<string> ExportAsync(TRequestInput input)
{
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
var dtoDetails = ObjectMapper.Map<List<TEntity>, List<TExportDto>>(entities);
var classDisplayName = typeof(TExportDto).GetCustomAttribute<DisplayAttribute>()?.Name ?? typeof(TExportDto).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;
}
#endregion
#region CURD
/// <summary>
/// 新增
/// </summary>
[HttpPost("")]
public virtual async Task<TEntityDto> CreateAsync(TCreateInput input)
{
var entity = ObjectMapper.Map<TCreateInput, TEntity>(input);
await _repository.InsertAsync(entity, autoSave: true).ConfigureAwait(continueOnCapturedContext: false);
return ObjectMapper.Map<TEntity, TEntityDto > (entity);
}
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
[Route("list")]
public virtual async Task<PagedResultDto<TEntityDto>> GetListAsync(TRequestInput 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);
}
/// <summary>
/// 删除
/// </summary>
[HttpDelete]
[Route("{id}")]
virtual public async Task DeleteAsync(Guid id)
{
await _repository.DeleteAsync(id);
}
/// <summary>
/// 批量删除
/// </summary>
[HttpPost]
[Route("delete")]
virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
{
return await _repository.DeleteListAsync(ids);
}
#endregion
}
}

41
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Prices/PriceListAppService.cs

@ -1,41 +0,0 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Entities.ImportMap;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.Entities.TaskJobs;
namespace Win.Sfs.SettleAccount.Entities.BQ.Prices
{
/// <summary>
/// 标准价格单-相关应用服务
/// </summary>
[Authorize(SettleAccountPermissions.PriceLists.Default)]
[Route("api/SettleAccount/TB_PRICE_LIST_Service")]
public class PriceListAppService : ApplicationService
{
private readonly PriceListManager _mng;
private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository;
private readonly TaskJobService _service;
public PriceListAppService(
IExcelImportAppService excelImportService,
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository,
PriceListManager mng,
TaskJobService service
)
{
_mapRepository = mapRepository;
_excelImportService = excelImportService;
_mng = mng;
_service = service;
}
}
}

271
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs

@ -4,11 +4,16 @@ using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.OpenApi.Extensions;
using NPOI.SS.UserModel;
using SettleAccount.Job.Services.Report; using SettleAccount.Job.Services.Report;
using Shouldly; using Shouldly;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TaskJob.EventArgs; using TaskJob.EventArgs;
@ -33,31 +38,116 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public class PriceListAppService : ApplicationService public class PriceListAppService : ApplicationService
/*, IPriceListAppService*/ /*, IPriceListAppService*/
{ {
private readonly PriceListManager _mng; private readonly PriceListManager _priceListManager;
private readonly IExcelImportAppService _excelImportService; private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository; private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository;
private readonly TaskJobService _service; private readonly TaskJobService _service;
public PriceListAppService( public PriceListAppService(
IExcelImportAppService excelImportService, IExcelImportAppService excelImportService,
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository, ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository,
PriceListManager mng, PriceListManager priceListManager,
TaskJobService service TaskJobService service
) )
{ {
_mapRepository = mapRepository; _mapRepository = mapRepository;
_excelImportService = excelImportService; _excelImportService = excelImportService;
_mng = mng; _priceListManager = priceListManager;
_service = service; _service = service;
} }
#region 导入、导出
/// <summary> /// <summary>
/// 根据筛选条件获取实体列表 /// 获取导入模板
/// </summary>
[HttpPost("import-template")]
public virtual async Task<IActionResult> ImportTemplateAsync()
{
await Task.CompletedTask;
return new Microsoft.AspNetCore.Mvc.OkResult();
}
/// <summary>
/// 导入
/// </summary>
[HttpPost]
[Route("Import")]
//[Authorize(SettleAccountPermissions.PriceLists.Create)]
public virtual async Task<string> ImportAsync([FromForm] IFormFileCollection files, string version)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PriceListImportDto>(files, _excelImportService);
List<string> _checkls = new List<string>();
_checkls.Add("1040");
_checkls.Add("1046");
_checkls.Add("104T");
result = result.Where(p => _checkls.Contains(p.Plant)).ToList();
var entityList = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result);
var _ls = entityList.OrderByDescending(p => p.BeginTime).GroupBy(p => new { p.LU, p.ClientCode }).Select(p => p.FirstOrDefault());
foreach (var itm in _ls)
{
itm.Update(GuidGenerator.Create(), version);
}
await _priceListManager.ImportAsync(_ls.ToList(), version);
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 导出
/// </summary>
[HttpPost]
[Route("Export")]
//[Authorize(SettleAccountPermissions.PriceLists.Default)]
public virtual async Task<string> ExportAsync(TB_PRICE_LIST_RequestDto input)
{
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
var entities = await _priceListManager.GetListAsync(input.Filters, input.Sorting, int.MaxValue,
0, true);
var dtoDetails = ObjectMapper.Map<List<PriceList>, List<PriceListExportDto>>(entities);
string _fileName = string.Empty;
//声明导出容器
byte[] result = null;
switch (input.FileType)
{
case 0:
_fileName = string.Format("销售价格单_{0}.xlsx", Guid.NewGuid().ToString());
result = await _csv.ExportAsByteArray(dtoDetails);
break;
case 1:
_fileName = string.Format("销售价格单_{0}.xlsx", Guid.NewGuid().ToString());
result = await _excel.ExportAsByteArray(dtoDetails);
break;
}
result.ShouldNotBeNull();
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
);
return _fileName;
}
#endregion
#region CURD
/// <summary>
/// 获取列表
/// </summary> /// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost] [HttpPost]
[Route("list")] [Route("list")]
//[Authorize(SettleAccountPermissions.PriceLists.Default)] //[Authorize(SettleAccountPermissions.PriceLists.Default)]
@ -67,26 +157,55 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
{ {
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version }); input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version });
} }
var entitys = await _mng.GetListAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount); var entitys = await _priceListManager.GetListAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount);
var totalCount = await GetCountAsync(input); var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<PriceList>, List<TB_PRICE_LISTDto>>(entitys); var dtos = ObjectMapper.Map<List<PriceList>, List<TB_PRICE_LISTDto>>(entitys);
return new PagedResultDto<TB_PRICE_LISTDto>(totalCount, dtos); return new PagedResultDto<TB_PRICE_LISTDto>(totalCount, dtos);
} }
/// <summary>
/// 删除
/// </summary>
[HttpDelete]
[Route("{id}")]
//[Authorize(SettleAccountPermissions.PriceLists.Delete)]
virtual public async Task DeleteAsync(Guid id)
{
await _priceListManager.DeleteAsync(id);
}
/// <summary>
/// 批量删除
/// </summary>
[HttpPost]
[Route("delete")]
//[Authorize(SettleAccountPermissions.PriceLists.Delete)]
virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
{
return await _priceListManager.DeleteListAsync(ids);
}
#endregion
#region 私有方法
/// <summary> /// <summary>
/// 获取总数 /// 获取总数
/// </summary> /// </summary>
private async Task<long> GetCountAsync(TB_PRICE_LIST_RequestDto input) private async Task<long> GetCountAsync(TB_PRICE_LIST_RequestDto input)
{ {
return await _mng.GetCountAsync(input.Filters, GuidGenerator.Create()); return await _priceListManager.GetCountAsync(input.Filters, GuidGenerator.Create());
} }
#endregion
/// <summary> /// <summary>
/// 获取总数 /// 获取总数
/// </summary> /// </summary>
private async Task<long> GetCountAsync(PriceListRequestDto input) private async Task<long> GetCountAsync(PriceListRequestDto input)
{ {
return await _mng.GetCountAsync(input.Filters, GuidGenerator.Create()); return await _priceListManager.GetCountAsync(input.Filters, GuidGenerator.Create());
} }
@ -139,7 +258,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
/// [Authorize(SettleAccountPermissions.PriceLists.Default)] /// [Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<PriceListDto> GetAsync(Guid id) virtual public async Task<PriceListDto> GetAsync(Guid id)
{ {
var result = await _mng.GetAsync(id); ; var result = await _priceListManager.GetAsync(id); ;
var dto = ObjectMapper.Map<PriceList, PriceListDto>(result); var dto = ObjectMapper.Map<PriceList, PriceListDto>(result);
return dto; return dto;
@ -164,7 +283,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
{ {
var entities = await _mng.GetVersionListAsync(input.Filters, input.Sorting, input.MaxResultCount,input.SkipCount); var entities = await _priceListManager.GetVersionListAsync(input.Filters, input.Sorting, input.MaxResultCount,input.SkipCount);
var totalCount = await GetCountAsync(input); var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<PriceListVersion>, List<PriceListVersionDto>>(entities); var dtos = ObjectMapper.Map<List<PriceListVersion>, List<PriceListVersionDto>>(entities);
return new PagedResultDto<PriceListVersionDto>(totalCount, dtos); return new PagedResultDto<PriceListVersionDto>(totalCount, dtos);
@ -184,7 +303,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
//[Authorize(SettleAccountPermissions.PriceLists.Default)] //[Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<long> GetTotalCountAsync(Guid branchId) virtual public async Task<long> GetTotalCountAsync(Guid branchId)
{ {
return await _mng.GetCountAsync(new List<FilterCondition>(), branchId); return await _priceListManager.GetCountAsync(new List<FilterCondition>(), branchId);
} }
/// <summary> /// <summary>
@ -196,50 +315,11 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
//[Authorize(SettleAccountPermissions.PriceLists.Default)] //[Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<ListResultDto<PriceListDto>> GetAllAsync(Guid branchId) virtual public async Task<ListResultDto<PriceListDto>> GetAllAsync(Guid branchId)
{ {
var entities = await _mng.GetAllAsync(branchId); var entities = await _priceListManager.GetAllAsync(branchId);
var dtos = ObjectMapper.Map<List<PriceList>, List<PriceListDto>>(entities); var dtos = ObjectMapper.Map<List<PriceList>, List<PriceListDto>>(entities);
return new ListResultDto<PriceListDto>(dtos); return new ListResultDto<PriceListDto>(dtos);
} }
/// <summary>
/// 批量导入实体列表
/// </summary>
/// <remarks>
/// 以ID为依据,数据库中找不到ID的实体会新增,已有ID的实体会修改
/// </remarks>
/// <param name="entities">实体列表</param>
/// <returns>是否导入成功</returns>
[HttpPost]
[Route("ExcelImport-Map")]
//[Authorize(SettleAccountPermissions.PriceLists.Create)]
virtual public async Task<string> ImportAsync([FromForm] IFormFileCollection files,string version)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PriceListImportDto>(files, _excelImportService);
List<string> _checkls = new List<string>();
_checkls.Add("100001");
_checkls.Add("100053");
_checkls.Add("100113");
result = result.Where(p => _checkls.Contains(p.CustomerCode)).ToList();
var entityList = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result);
var _ls = entityList.Where(p=>p.EndTime.ToString().Contains("9999")).OrderByDescending(p => p.BeginTime).GroupBy(p => new { p.MaterialCode, p.CustomerCode,p.Type }).Select(p=>p.FirstOrDefault());
foreach (var itm in _ls)
{
itm.Update(GuidGenerator.Create(),version);
}
await _mng.ImportAsync(_ls.ToList(), version);
return ApplicationConsts.SuccessStr;
}
/// <summary> /// <summary>
/// 修改实体 /// 修改实体
@ -256,92 +336,13 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
); );
var _ent = await _mng.UpdateAsync(id, entity); var _ent = await _priceListManager.UpdateAsync(id, entity);
var dto = ObjectMapper.Map<PriceList, PriceListDto>(_ent); var dto = ObjectMapper.Map<PriceList, PriceListDto>(_ent);
return dto; return dto;
} }
/// <summary>
/// 删除实体
/// </summary>
/// <param name="id">ID</param>
/// <returns>无</returns>
[HttpDelete]
[Route("{id}")]
//[Authorize(SettleAccountPermissions.PriceLists.Delete)]
virtual public async Task DeleteAsync(Guid id)
{
await _mng.DeleteAsync(id);
}
/// <summary>
/// 按IDs删除实体列表
/// </summary>
/// <param name="ids">ID列表</param>
/// <returns>是否执行成功</returns>
[HttpPost]
[Route("delete")]
//[Authorize(SettleAccountPermissions.PriceLists.Delete)]
virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
{
return await _mng.DeleteListAsync(ids);
}
/// <summary>
/// 导出文件
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("Export")]
//[Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<string> ExportAsync(PriceListRequestDto input)
{
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
var entities = await _mng.GetListAsync(input.Filters, input.Sorting, int.MaxValue,
0, true);
var dtoDetails = ObjectMapper.Map<List<PriceList>, List<PriceListExportDto>>(entities);
string _fileName = string.Empty;
//声明导出容器
byte[] result = null;
switch (input.FileType)
{
case 0:
_fileName = string.Format("标准价格单_{0}.xlsx", Guid.NewGuid().ToString());
result = await _csv.ExportAsByteArray(dtoDetails);
break;
case 1:
_fileName = string.Format("标准价格单_{0}.xlsx", Guid.NewGuid().ToString());
result = await _excel.ExportAsByteArray(dtoDetails);
break;
}
result.ShouldNotBeNull();
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
);
return _fileName;
}
} }
} }

506
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs

@ -13,277 +13,313 @@ using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.ImportMap; using Win.Sfs.SettleAccount.Entities.ImportMap;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.Repository;
using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.Prices namespace Win.Sfs.SettleAccount.Entities.Prices
{ {
/// <summary> /// <summary>
/// 标准价格单-相关应用服务 /// 备件价格
/// </summary> /// </summary>
//[Authorize(SettleAccountPermissions.PriceLists.Default)] //[Authorize(SettleAccountPermissions.PriceLists.Default)]
[AllowAnonymous] [AllowAnonymous]
[Route("api/SettleAccount/PriceListBJ")] [Route("api/SettleAccount/PriceListBJ")]
public class PriceListAppServiceBJ : ApplicationService public class PriceListAppServiceBJ : CurdBaseAppService<PriceListBJ, PriceListBJDto, PriceListBJRequestDto, PriceListBJ, PriceListBJExportDto, PriceListBJExportDto>
/*, IPriceListAppService*/
{ {
private readonly PriceListManagerBJ _mng; private readonly INormalEfCoreRepository<PriceListBJ, Guid> _repository;
private readonly PriceListManagerBJ _priceListManagerBJ;
private readonly IExcelImportAppService _excelImportService; private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository; private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository;
public PriceListAppServiceBJ(
IExcelImportAppService excelImportService,
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository,
PriceListManagerBJ mng
)
{
_mapRepository = mapRepository;
_excelImportService = excelImportService;
_mng = mng;
}
/// <summary>
/// 按ID获取唯一实体
/// </summary>
/// <remarks>
/// 返回实体全部属性
/// </remarks>
/// <param name="id">ID</param>
/// <returns>实体DTO</returns>
[HttpGet]
[Route("{id}")]
/// [Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<PriceListBJDto> GetAsync(Guid id)
{
var result = await _mng.GetAsync(id); ;
var dto = ObjectMapper.Map<PriceListBJ, PriceListBJDto>(result);
return dto;
}
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("list")]
//[Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<PagedResultDto<PriceListBJDto>> GetListAsync(PriceListRequestDto input)
{
if (!string.IsNullOrEmpty(input.Version))
{
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version });
}
var entities = await _mng.GetListAsync(input.Filters, input.Sorting, input.MaxResultCount,
input.SkipCount);
var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<PriceListBJ>, List<PriceListBJDto>>(entities);
return new PagedResultDto<PriceListBJDto>(totalCount, dtos);
}
/// <summary> public PriceListAppServiceBJ(
/// 根据筛选条件获取实体列表 INormalEfCoreRepository<PriceListBJ, Guid> repository,
/// </summary> PriceListManagerBJ priceListManagerBJ,
/// <remarks> IExcelImportAppService excelImportService,
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码 ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("versionlist")]
// [Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<PagedResultDto<PriceListVersionBJDto>> GetVersionListAsync(PriceListRequestDto input)
{
var entities = await _mng.GetVersionListAsync(input.Filters, input.Sorting, input.MaxResultCount,input.SkipCount);
var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<PriceListVersionBJ>, List<PriceListVersionBJDto>>(entities);
return new PagedResultDto<PriceListVersionBJDto>(totalCount, dtos);
}
private async Task<long> GetCountAsync(PriceListRequestDto input)
{
return await _mng.GetCountAsync(input.Filters, GuidGenerator.Create());
}
/// <summary> ) :base(repository: repository, excelImportService: excelImportService)
/// 获取实体总数
/// </summary>
/// <returns>实体总数</returns>
[HttpGet]
[Route("count")]
//[Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<long> GetTotalCountAsync(Guid branchId)
{ {
return await _mng.GetCountAsync(new List<FilterCondition>(), branchId); _repository = repository;
} _priceListManagerBJ = priceListManagerBJ;
_excelImportService = excelImportService;
/// <summary> _mapRepository = mapRepository;
/// 获取全部实体列表
/// </summary>
/// <returns>实体DTO列表</returns>
[HttpGet]
[Route("all")]
//[Authorize(SettleAccountPermissions.PriceLists.Default)]
virtual public async Task<ListResultDto<PriceListBJDto>> GetAllAsync(Guid branchId)
{
var entities = await _mng.GetAllAsync(branchId);
var dtos = ObjectMapper.Map<List<PriceListBJ>, List<PriceListBJDto>>(entities);
return new ListResultDto<PriceListBJDto>(dtos);
} }
#region 导入、导出
/// <summary> /// <summary>
/// 批量导入实体列表 /// 导入
/// </summary> /// </summary>
/// <remarks>
/// 以ID为依据,数据库中找不到ID的实体会新增,已有ID的实体会修改
/// </remarks>
/// <param name="entities">实体列表</param>
/// <returns>是否导入成功</returns>
[HttpPost] [HttpPost]
[Route("ExcelImport-Map")] [Route("Import")]
//[Authorize(SettleAccountPermissions.PriceLists.Create)] public override async Task<string> ImportAsync([FromForm] IFormFileCollection files, string version)
virtual public async Task<string> ImportAsync([FromForm] IFormFileCollection files,string version)
{ {
ExportImporter _exportImporter = new ExportImporter(); ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PriceListBJImportDto>(files, _excelImportService); var result = await _exportImporter.UploadExcelImport<PriceListBJImportDto>(files, _excelImportService);
List<string> _checkls = new List<string>(); List<string> _checkls = new List<string>();
_checkls.Add("100001"); _checkls.Add("1040");
_checkls.Add("100053"); _checkls.Add("1046");
_checkls.Add("100113"); _checkls.Add("104T");
// _checkls.Add("200067"); result = result.Where(p => _checkls.Contains(p.ClientCode)).ToList();
result = result.Where(p => _checkls.Contains(p.CustomerCode)).ToList();
var entityList = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result); var entityList = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result);
var _ls = entityList.Where(p=>p.EndDate.ToString().Contains("9999")).OrderByDescending(p => p.BeginDate).GroupBy(p => new { p.MaterialCode, p.CustomerCode,p.Type }).Select(p=>p.FirstOrDefault()); var _ls = entityList.GroupBy(p => new { p.LU, p.ClientCode }).Select(p => p.FirstOrDefault());
foreach (var itm in _ls) foreach (var itm in _ls)
{ {
itm.Update(GuidGenerator.Create(),version); itm.Update(GuidGenerator.Create(), version);
} }
_ls=_ls.Where(p => p.Type == 20).ToList();
await _mng.ImportAsync(_ls.ToList(), version); await _priceListManagerBJ.ImportAsync(_ls.ToList(), version);
return ApplicationConsts.SuccessStr; return ApplicationConsts.SuccessStr;
} }
#endregion
#region 原有的方法之后废弃删除
// /// <summary>
/// <summary> // /// 按ID获取唯一实体
/// 修改实体 // /// </summary>
/// </summary> // /// <remarks>
/// <param name="id">ID</param> // /// 返回实体全部属性
/// <param name="input">修改实体DTO</param> // /// </remarks>
/// <returns>实体DTO</returns> // /// <param name="id">ID</param>
[HttpPut] // /// <returns>实体DTO</returns>
[Route("{id}")]
[Authorize(SettleAccountPermissions.PriceLists.Update)] // [HttpGet]
virtual public async Task<PriceListBJDto> UpdateAsync(Guid id, PriceListBJDto input) // [Route("{id}")]
{ // /// [Authorize(SettleAccountPermissions.PriceLists.Default)]
var entity = new PriceListBJ( // virtual public async Task<PriceListBJDto> GetAsync(Guid id)
// {
); // var result = await _mng.GetAsync(id); ;
// var dto = ObjectMapper.Map<PriceListBJ, PriceListBJDto>(result);
var _ent = await _mng.UpdateAsync(id, entity); // return dto;
// }
var dto = ObjectMapper.Map<PriceListBJ, PriceListBJDto>(_ent);
return dto;
}
// /// <summary>
/// <summary> // /// 根据筛选条件获取实体列表
/// 删除实体 // /// </summary>
/// </summary> // /// <remarks>
/// <param name="id">ID</param> // /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// <returns>无</returns> // /// </remarks>
[HttpDelete] // /// <param name="input">请求条件</param>
[Route("{id}")] // /// <returns>实体DTO列表</returns>
//[Authorize(SettleAccountPermissions.PriceLists.Delete)] // [HttpPost]
virtual public async Task DeleteAsync(Guid id) // [Route("list")]
{ // //[Authorize(SettleAccountPermissions.PriceLists.Default)]
// virtual public async Task<PagedResultDto<PriceListBJDto>> GetListAsync(PriceListRequestDto input)
await _mng.DeleteAsync(id); // {
}
// if (!string.IsNullOrEmpty(input.Version))
/// <summary> // {
/// 按IDs删除实体列表 // input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version });
/// </summary> // }
/// <param name="ids">ID列表</param> // var entities = await _mng.GetListAsync(input.Filters, input.Sorting, input.MaxResultCount,
/// <returns>是否执行成功</returns> //input.SkipCount);
[HttpPost] // var totalCount = await GetCountAsync(input);
[Route("delete")] // var dtos = ObjectMapper.Map<List<PriceListBJ>, List<PriceListBJDto>>(entities);
//[Authorize(SettleAccountPermissions.PriceLists.Delete)] // return new PagedResultDto<PriceListBJDto>(totalCount, dtos);
virtual public async Task<bool> DeleteListAsync(List<Guid> ids) // }
{
// /// <summary>
return await _mng.DeleteListAsync(ids); // /// 根据筛选条件获取实体列表
} // /// </summary>
// /// <remarks>
/// <summary> // /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// 导出文件 // /// </remarks>
/// </summary> // /// <param name="input">请求条件</param>
/// <param name="input"></param> // /// <returns>实体DTO列表</returns>
/// <returns></returns> // [HttpPost]
[HttpPost] // [Route("versionlist")]
[Route("Export")] // // [Authorize(SettleAccountPermissions.PriceLists.Default)]
//[Authorize(SettleAccountPermissions.PriceLists.Default)] // virtual public async Task<PagedResultDto<PriceListVersionBJDto>> GetVersionListAsync(PriceListRequestDto input)
virtual public async Task<string> ExportAsync(PriceListRequestDto input) // {
{ // var entities = await _mng.GetVersionListAsync(input.Filters, input.Sorting, input.MaxResultCount,input.SkipCount);
// var totalCount = await GetCountAsync(input);
IExporter _csv = new CsvExporter(); // var dtos = ObjectMapper.Map<List<PriceListVersionBJ>, List<PriceListVersionBJDto>>(entities);
IExporter _excel = new ExcelExporter(); // return new PagedResultDto<PriceListVersionBJDto>(totalCount, dtos);
var entities = await _mng.GetListAsync(input.Filters, input.Sorting, int.MaxValue, // }
0, true);
var dtoDetails = ObjectMapper.Map<List<PriceListBJ>, List<PriceListBJExportDto>>(entities);
string _fileName = string.Empty;
//声明导出容器
byte[] result = null; // private async Task<long> GetCountAsync(PriceListRequestDto input)
switch (input.FileType) // {
{ // return await _mng.GetCountAsync(input.Filters, GuidGenerator.Create());
case 0: // }
_fileName = string.Format("备件标准价格单_{0}.xlsx", Guid.NewGuid().ToString());
result = await _csv.ExportAsByteArray(dtoDetails); // /// <summary>
break; // /// 获取实体总数
case 1: // /// </summary>
_fileName = string.Format("备件标准价格单_{0}.xlsx", Guid.NewGuid().ToString()); // /// <returns>实体总数</returns>
result = await _excel.ExportAsByteArray(dtoDetails); // [HttpGet]
break; // [Route("count")]
} // //[Authorize(SettleAccountPermissions.PriceLists.Default)]
result.ShouldNotBeNull(); // virtual public async Task<long> GetTotalCountAsync(Guid branchId)
// {
//保存导出文件到服务器存成二进制 // return await _mng.GetCountAsync(new List<FilterCondition>(), branchId);
await _excelImportService.SaveBlobAsync( // }
new SaveExcelImportInputDto
{ // /// <summary>
Name = _fileName, // /// 获取全部实体列表
Content = result // /// </summary>
} // /// <returns>实体DTO列表</returns>
); // [HttpGet]
return _fileName; // [Route("all")]
} // //[Authorize(SettleAccountPermissions.PriceLists.Default)]
// virtual public async Task<ListResultDto<PriceListBJDto>> GetAllAsync(Guid branchId)
// {
// var entities = await _mng.GetAllAsync(branchId);
// var dtos = ObjectMapper.Map<List<PriceListBJ>, List<PriceListBJDto>>(entities);
// return new ListResultDto<PriceListBJDto>(dtos);
// }
// /// <summary>
// /// 批量导入实体列表
// /// </summary>
// /// <remarks>
// /// 以ID为依据,数据库中找不到ID的实体会新增,已有ID的实体会修改
// /// </remarks>
// /// <param name="entities">实体列表</param>
// /// <returns>是否导入成功</returns>
// [HttpPost]
// [Route("ExcelImport-Map")]
// //[Authorize(SettleAccountPermissions.PriceLists.Create)]
// virtual public async Task<string> ImportAsync([FromForm] IFormFileCollection files,string version)
// {
// ExportImporter _exportImporter = new ExportImporter();
// var result = await _exportImporter.UploadExcelImport<PriceListBJImportDto>(files, _excelImportService);
// List<string> _checkls = new List<string>();
// _checkls.Add("100001");
// _checkls.Add("100053");
// _checkls.Add("100113");
// // _checkls.Add("200067");
// result = result.Where(p => _checkls.Contains(p.CustomerCode)).ToList();
// var entityList = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result);
// var _ls = entityList.Where(p=>p.EndDate.ToString().Contains("9999")).OrderByDescending(p => p.BeginDate).GroupBy(p => new { p.MaterialCode, p.CustomerCode,p.Type }).Select(p=>p.FirstOrDefault());
// foreach (var itm in _ls)
// {
// itm.Update(GuidGenerator.Create(),version);
// }
// _ls=_ls.Where(p => p.Type == 20).ToList();
// await _mng.ImportAsync(_ls.ToList(), version);
// return ApplicationConsts.SuccessStr;
// }
// /// <summary>
// /// 修改实体
// /// </summary>
// /// <param name="id">ID</param>
// /// <param name="input">修改实体DTO</param>
// /// <returns>实体DTO</returns>
// [HttpPut]
// [Route("{id}")]
// [Authorize(SettleAccountPermissions.PriceLists.Update)]
// virtual public async Task<PriceListBJDto> UpdateAsync(Guid id, PriceListBJDto input)
// {
// var entity = new PriceListBJ(
// );
// var _ent = await _mng.UpdateAsync(id, entity);
// var dto = ObjectMapper.Map<PriceListBJ, PriceListBJDto>(_ent);
// return dto;
// }
// /// <summary>
// /// 删除实体
// /// </summary>
// /// <param name="id">ID</param>
// /// <returns>无</returns>
// [HttpDelete]
// [Route("{id}")]
// //[Authorize(SettleAccountPermissions.PriceLists.Delete)]
// virtual public async Task DeleteAsync(Guid id)
// {
// await _mng.DeleteAsync(id);
// }
// /// <summary>
// /// 按IDs删除实体列表
// /// </summary>
// /// <param name="ids">ID列表</param>
// /// <returns>是否执行成功</returns>
// [HttpPost]
// [Route("delete")]
// //[Authorize(SettleAccountPermissions.PriceLists.Delete)]
// virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
// {
// return await _mng.DeleteListAsync(ids);
// }
// /// <summary>
// /// 导出文件
// /// </summary>
// /// <param name="input"></param>
// /// <returns></returns>
// [HttpPost]
// [Route("Export")]
// //[Authorize(SettleAccountPermissions.PriceLists.Default)]
// virtual public async Task<string> ExportAsync(PriceListRequestDto input)
// {
// IExporter _csv = new CsvExporter();
// IExporter _excel = new ExcelExporter();
// var entities = await _mng.GetListAsync(input.Filters, input.Sorting, int.MaxValue,
// 0, true);
// var dtoDetails = ObjectMapper.Map<List<PriceListBJ>, List<PriceListBJExportDto>>(entities);
// string _fileName = string.Empty;
// //声明导出容器
// byte[] result = null;
// switch (input.FileType)
// {
// case 0:
// _fileName = string.Format("备件标准价格单_{0}.xlsx", Guid.NewGuid().ToString());
// result = await _csv.ExportAsByteArray(dtoDetails);
// break;
// case 1:
// _fileName = string.Format("备件标准价格单_{0}.xlsx", Guid.NewGuid().ToString());
// result = await _excel.ExportAsByteArray(dtoDetails);
// break;
// }
// result.ShouldNotBeNull();
// //保存导出文件到服务器存成二进制
// await _excelImportService.SaveBlobAsync(
// new SaveExcelImportInputDto
// {
// Name = _fileName,
// Content = result
// }
// );
// return _fileName;
// }
#endregion
} }
} }

1
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccount.Application.csproj

@ -125,6 +125,7 @@
<PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="4.3.3" /> <PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="4.3.3" />
<PackageReference Include="Volo.Abp.BackgroundWorkers" Version="4.3.3" /> <PackageReference Include="Volo.Abp.BackgroundWorkers" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Dapper" Version="4.3.3" /> <PackageReference Include="Volo.Abp.Dapper" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Ddd.Application" Version="4.3.3" />
<PackageReference Include="Volo.Abp.EventBus.RabbitMQ" Version="4.3.3" /> <PackageReference Include="Volo.Abp.EventBus.RabbitMQ" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="4.3.3" /> <PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="4.3.3" />
<PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="4.3.3" /> <PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="4.3.3" />

15
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

@ -306,12 +306,19 @@ namespace Win.Sfs.SettleAccount
/// </summary> /// </summary>
private void CreateMapPriceList() private void CreateMapPriceList()
{ {
CreateMap<PriceList, TB_PRICE_LISTDto>().ReverseMap(); CreateMap<PriceList, TB_PRICE_LISTDto>();
CreateMap<PriceListImportDto, PriceList>()
.ForMember(x => x.LU, y => y.MapFrom(y => y.PartNo))
.ForMember(x => x.Price, y => y.MapFrom(y => y.TotalPrice))
.ForMember(x => x.BeginTime, y => y.MapFrom(y => y.ValidFrom))
.ForMember(x => x.EndTime, y => y.MapFrom(y => y.ValidTo))
.ForMember(x => x.ClientCode, y => y.MapFrom(y => y.Plant));
CreateMap<PriceList, PriceListExportDto>();
CreateMap<PriceList, PriceListDto>().ReverseMap(); CreateMap<PriceList, PriceListDto>().ReverseMap();
CreateMap<PriceList, PriceListRequestDto>().ReverseMap(); CreateMap<PriceList, PriceListRequestDto>().ReverseMap();
CreateMap<PriceList, PriceListImportDto>().ReverseMap();
CreateMap<PriceList, PriceListExportDto>().ReverseMap();
} }
private void CreateMapPriceListBJ() private void CreateMapPriceListBJ()
@ -699,7 +706,7 @@ namespace Win.Sfs.SettleAccount
CreateMap<HQNotConsignReportDetailDto, HQNotConsignReportDetailExportDto>(); CreateMap<HQNotConsignReportDetailDto, HQNotConsignReportDetailExportDto>();
} }
private void CreateMapHQSPNotConsignReport() private void CreateMapHQSPNotConsignReport()
{ {
CreateMap<HQSPNotConsignReport, HQSPNotConsignReportDto>().ReverseMap(); CreateMap<HQSPNotConsignReport, HQSPNotConsignReportDto>().ReverseMap();
CreateMap<HQSPNotConsignReport, HQSPNotConsignReportCreateDto>().ReverseMap(); CreateMap<HQSPNotConsignReport, HQSPNotConsignReportCreateDto>().ReverseMap();

35
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/Prices/PriceList.cs

@ -119,6 +119,10 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
public Guid ParentId { set; get; } public Guid ParentId { set; get; }
} }
/// <summary>
/// 备件价格
/// </summary>
public class PriceListBJ : FullAuditedAggregateRootBase<Guid> public class PriceListBJ : FullAuditedAggregateRootBase<Guid>
{ {
public PriceListBJ() public PriceListBJ()
@ -149,6 +153,31 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
Id = id; Id = id;
Version = version; Version = version;
} }
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
public string LU { get; set; }
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
public Decimal Price { set; get; }
/// <summary>
/// 客户编码
/// </summary>
[Display(Name = "客户编码")]
public string ClientCode { get; set; }
[Display(Name = "客户")] [Display(Name = "客户")]
public string CustomerCode { get; set; } public string CustomerCode { get; set; }
@ -169,11 +198,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
/// </summary> /// </summary>
[Display(Name = "结算时间")] [Display(Name = "结算时间")]
public DateTime EndDate { set; get; } public DateTime EndDate { set; get; }
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
public Decimal Price { set; get; }
/// <summary> /// <summary>
/// 物料编号 /// 物料编号

3750
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230711014038_20230711-1.Designer.cs

File diff suppressed because it is too large

33
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230711014038_20230711-1.cs

@ -0,0 +1,33 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202307111 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ClientCode",
table: "Set_PriceListBJ",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "LU",
table: "Set_PriceListBJ",
type: "nvarchar(max)",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ClientCode",
table: "Set_PriceListBJ");
migrationBuilder.DropColumn(
name: "LU",
table: "Set_PriceListBJ");
}
}
}

6
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

@ -3425,6 +3425,9 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<Guid>("BranchId") b.Property<Guid>("BranchId")
.HasColumnType("uniqueidentifier"); .HasColumnType("uniqueidentifier");
b.Property<string>("ClientCode")
.HasColumnType("nvarchar(max)");
b.Property<string>("ConcurrencyStamp") b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken() .IsConcurrencyToken()
.HasMaxLength(40) .HasMaxLength(40)
@ -3467,6 +3470,9 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasDefaultValue(false) .HasDefaultValue(false)
.HasColumnName("IsDeleted"); .HasColumnName("IsDeleted");
b.Property<string>("LU")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("LastModificationTime") b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2") .HasColumnType("datetime2")
.HasColumnName("LastModificationTime"); .HasColumnName("LastModificationTime");

6
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountNormalEfCoreRepository.cs

@ -58,12 +58,8 @@ namespace Win.Sfs.SettleAccount.Repository
entities = GetSortingQueryable(entities, sorting); entities = GetSortingQueryable(entities, sorting);
return await entities.PageBy(skipCount, maxResultCount) return await entities.PageBy(skipCount, maxResultCount).ToListAsync(GetCancellationToken(cancellationToken));
.ToListAsync(GetCancellationToken(cancellationToken));
} }
} }
} }

Loading…
Cancel
Save