Browse Source

Merge remote-tracking branch 'origin/master-mahao'

master
mahao 1 year ago
parent
commit
6696f8ac38
  1. 67
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PURCHASE_PRICE_DTO.cs
  2. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/RequestDto.cs
  3. 131
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs
  4. 14
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  5. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PURCHASE_PRICE.cs

67
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PURCHASE_PRICE_DTO.cs

@ -0,0 +1,67 @@
using Magicodes.ExporterAndImporter.Core;
using System.ComponentModel.DataAnnotations;
using Win.Sfs.Shared.DtoBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
{
/// <summary>
/// 采购价格单
/// </summary>
public class PURCHASE_PRICE_DTO
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
public string LU { get; set; }
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
public decimal Price { get; set; }
}
public class PURCHASE_PRICE_IMPORT_DTO
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[ImporterHeader(Name = "零件号")]
public string LU { get; set; }
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
[ImporterHeader(Name = "价格")]
public decimal Price { get; set; }
}
public class PURCHASE_PRICE_REQUEST_DTO : RequestDtoBase
{
}
/// <summary>
/// 导出
/// </summary>
public class PURCHASE_PRICE_EXPORT_DTO
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[ExporterHeader(DisplayName = "零件号")]
public string LU { get; set; }
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
[ExporterHeader(DisplayName = "价格")]
public decimal Price { get; set; }
}
}

8
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/RequestDto.cs

@ -0,0 +1,8 @@
using Win.Sfs.Shared.DtoBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
{
public class RequestDto : RequestDtoBase
{
}
}

131
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs

@ -0,0 +1,131 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.DtoBase;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
/// <summary>
/// 采购价格单
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/PURCHASE_PRICE_SERVICE")]
public class PURCHASE_PRICE_SERVICE : SettleAccountApplicationBase<PURCHASE_PRICE>
{
/// <summary>
/// 采购价格单仓储
/// </summary>
private readonly INormalEfCoreRepository<PURCHASE_PRICE, Guid> _repository;
public PURCHASE_PRICE_SERVICE(
INormalEfCoreRepository<PURCHASE_PRICE, Guid> repository,
IDistributedCache<PURCHASE_PRICE> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_repository = repository;
}
#region 导入、导出
/// <summary>
/// 导入
/// </summary>
[HttpPost]
[Route("Import")]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PURCHASE_PRICE_IMPORT_DTO>(files, _excelImportService);
var _ls = ObjectMapper.Map<List<PURCHASE_PRICE_IMPORT_DTO>, List<PURCHASE_PRICE>>(result);
List<string> _errorList = new List<string>();
var checkList = new List<ErrorExportDto>();
if (_ls.Count > 0)
{
var query = from arc in _ls
group arc by new { arc.LU }
into g
where g.Count() > 1
select g;
foreach (var itm in query)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("物料号{0}有重复", itm.Key.LU), string.Empty));
}
}
foreach (var itm in _ls)
{
var _first = _repository.FirstOrDefault(p => p.LU == itm.LU);
if (_first != null)
{
_first.Update(itm.Price);
await _repository.UpdateAsync(_first);
}
else
{
await _repository.InsertAsync(itm);
}
}
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 导出
/// </summary>
[HttpPost]
[Route("Export")]
public async Task<string> ExportAsync(RequestDto input)
{
string fileName = $"采购价格单_{Guid.NewGuid()}.xlsx";
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
var dtos = ObjectMapper.Map<List<PURCHASE_PRICE>, List<PURCHASE_PRICE_EXPORT_DTO>>(entities);
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtos);
result.ShouldNotBeNull();
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result });
return fileName;
}
#endregion
#region CURD
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
[Route("list")]
public async Task<PagedResultDto<PURCHASE_PRICE_DTO>> GetListAsync(RequestDto input)
{
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters);
var dtos = ObjectMapper.Map<List<PURCHASE_PRICE>, List<PURCHASE_PRICE_DTO>>(entities);
return new PagedResultDto<PURCHASE_PRICE_DTO>(totalCount, dtos);
}
#endregion
}
}

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

@ -54,6 +54,8 @@ using Win.Sfs.SettleAccount.Entities.UnHQSettleAccounts;
using Win.Sfs.SettleAccount.Entities.Wms.WmsSumOutput;
using Win.Sfs.SettleAccount.Errors;
using Win.Sfs.SettleAccount.Entities.Errors;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using SettleAccount.Domain.BQ;
namespace Win.Sfs.SettleAccount
{
@ -132,6 +134,7 @@ namespace Win.Sfs.SettleAccount
#endregion
CreateMapPURCHASE_PRICE();
}
#region 北汽
@ -732,5 +735,16 @@ namespace Win.Sfs.SettleAccount
}
#endregion
/// <summary>
/// 采购价格单
/// </summary>
private void CreateMapPURCHASE_PRICE()
{
CreateMap<PURCHASE_PRICE, PURCHASE_PRICE_DTO>();
CreateMap<PURCHASE_PRICE, PURCHASE_PRICE_EXPORT_DTO>();
CreateMap<PURCHASE_PRICE_IMPORT_DTO, PURCHASE_PRICE>();
}
}
}

9
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PURCHASE_PRICE.cs

@ -21,4 +21,13 @@ public class PURCHASE_PRICE : FullAuditedAggregateRoot<Guid>
/// </summary>
[Display(Name = "价格")]
public decimal Price { get; set; }
/// <summary>
/// 更新
/// </summary>
public void Update(decimal price)
{
Price = price;
}
}

Loading…
Cancel
Save