学 赵
1 year ago
16 changed files with 499 additions and 336 deletions
@ -0,0 +1,104 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using EFCore.BulkExtensions; |
||||
|
using Microsoft.AspNetCore.Authorization; |
||||
|
using Microsoft.AspNetCore.Http; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using SettleAccount.Bases; |
||||
|
using SettleAccount.Domain.BQ; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Application.Dtos; |
||||
|
using Win.Abp.Snowflakes; |
||||
|
using Win.Sfs.BaseData.ImportExcelCommon; |
||||
|
using Win.Sfs.SettleAccount.Bases.DomainServices; |
||||
|
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.Shared.RepositoryBase; |
||||
|
|
||||
|
namespace Win.Sfs.SettleAccount.Bases; |
||||
|
/// <summary>
|
||||
|
/// 发票明细调整表
|
||||
|
/// </summary>
|
||||
|
[AllowAnonymous] |
||||
|
[Route("api/settleaccount/[controller]/[action]")]
|
||||
|
public class ADJ_SERVICE : BASE_SERVICE |
||||
|
{ |
||||
|
protected readonly INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> _repository; |
||||
|
protected readonly BaseDomainService _baseDomainService; |
||||
|
public ADJ_SERVICE( |
||||
|
INormalEfCoreRepository<PUB_ADJ_DETAIL, Guid> repository, |
||||
|
BaseDomainService baseDomainService, |
||||
|
IExcelImportAppService excelImportService, |
||||
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
||||
|
ICommonManager commonManager |
||||
|
) |
||||
|
: base(excelImportService, snowflakeIdGenerator, commonManager) |
||||
|
{ |
||||
|
_repository = repository; |
||||
|
_baseDomainService = baseDomainService; |
||||
|
} |
||||
|
/// <summary>
|
||||
|
///查询明细
|
||||
|
/// </summary>
|
||||
|
/// <param name="input">明细查询条件</param>
|
||||
|
/// <returns></returns>
|
||||
|
[HttpPost] |
||||
|
|
||||
|
public virtual async Task<PagedResultDto<PUB_ADJ_DETAIL_DTO>> DetailQueryAsync(PUB_ADJ_DETAIL_REQ_DTO 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<PUB_ADJ_DETAIL>, List<PUB_ADJ_DETAIL_DTO>>(entitys); |
||||
|
return new PagedResultDto<PUB_ADJ_DETAIL_DTO>(totalCount, dtos); |
||||
|
} |
||||
|
/// <summary>
|
||||
|
/// 导入文件
|
||||
|
/// </summary>
|
||||
|
/// <param name="files"></param>
|
||||
|
/// <returns></returns>
|
||||
|
/// <exception cref="BusinessException"></exception>
|
||||
|
[HttpPost] |
||||
|
[DisableRequestSizeLimit] |
||||
|
public async Task<string> ExcelImport([FromForm] IFormFileCollection files) |
||||
|
{ |
||||
|
List<ErrorExportDto> errorList = new List<ErrorExportDto>(); |
||||
|
ExportImporter _exportImporter = new ExportImporter(); |
||||
|
var result = await _exportImporter.UploadExcelImport<PUB_ADJ_DETAIL_IMP_DTO>(files, _excelImportService); |
||||
|
if (result.Count == 0) |
||||
|
{ |
||||
|
throw new BusinessException("8989", "导入数据记录为0条"); |
||||
|
} |
||||
|
var deletels = _repository.Where(p => p.OldInvBillNum == result.FirstOrDefault().OldInvBillNum).ToList(); |
||||
|
var first = deletels.FirstOrDefault(); |
||||
|
if (!string.IsNullOrEmpty(first.InvBillNum)) |
||||
|
{ |
||||
|
throw new BusinessException("8989", $"调整记录已经新发票号:{first.InvBillNum}"); |
||||
|
} |
||||
|
var entityList = ObjectMapper.Map<List<PUB_ADJ_DETAIL_IMP_DTO>, List<PUB_ADJ_DETAIL>>(result); |
||||
|
var codelist = entityList.Select(p => p.LU).ToList(); |
||||
|
var errors = await _baseDomainService.CheckBase(codelist, new BASE_CONF() { IsRelationShip = true }); |
||||
|
foreach (var itm in errors) |
||||
|
{ |
||||
|
errorList.Add( |
||||
|
new ErrorExportDto() { ItemCode = $"{itm}", Message = $"[客户零件关系表]不存在客户零件号{itm}" }); |
||||
|
} |
||||
|
var errorEntitylist = await _baseDomainService.CheckPriceList(entityList); |
||||
|
if (errorEntitylist.Count > 0) |
||||
|
{ |
||||
|
foreach (var itm in errorEntitylist) |
||||
|
{ |
||||
|
errorList.Add(new ErrorExportDto() { ItemCode = $"{itm.LU}", Message = $"客户零件号{itm.LU}标识号{itm.PN}下线日期{itm.SettleDate}不存在价格单记录" }); |
||||
|
} |
||||
|
} |
||||
|
await _repository.DbContext.BulkDeleteAsync(deletels);//删除发票下所有调整明细
|
||||
|
await _repository.DbContext.BulkInsertAsync(entityList); |
||||
|
return ApplicationConsts.SuccessStr; |
||||
|
} |
||||
|
|
||||
|
} |
Loading…
Reference in new issue