学 赵 1 year ago
parent
commit
df0d08508e
  1. 14
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  2. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs
  3. 62
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
  4. 47
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  5. 47
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  6. 15
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SE_DETAIL_SERVICE.cs
  7. 55
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HomeAppService.cs
  8. 24
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs
  9. 25
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs

14
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs

@ -551,3 +551,17 @@ public class PubSaSeCompareRequestDto
/// </summary>
public DateTime? SeEndDateTime { get; set; }
}
public class JobRequestDto
{
/// <summary>
/// 业务类别
/// </summary>
public EnumBusinessType BusinessType { get; set; }
//public Guid Id { get; set; }
//public List<string> ExportName { get; set; }
//public List<CustomCondition> Propert { get; set; }
}

1
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs

@ -146,7 +146,6 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
/// 厂内物料描述
/// </summary>
[ImporterHeader(Name = "厂内物料描述")]
[Required(ErrorMessage = "{0}是必填项")]
[MaxLength(CommonConsts.MaxNameLength, ErrorMessage = "{0}最多输入{1}个字符")]
public string MaterialDesc { get; set; }

62
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs

@ -5,6 +5,7 @@ using System.LinqAsync;
using System.Security.Policy;
using System.Threading.Tasks;
using AutoMapper;
using DocumentFormat.OpenXml.Drawing.Charts;
using EFCore.BulkExtensions;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
@ -146,6 +147,22 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
}
}
if (!checkList.Any())
{
//验证客户对应厂内零件号是否存在
//导入的零件号集合
var importPubSaLUs = importBBACSaDetails.Select(t => t.LU).Distinct();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
//不存在的客户零件号(差集)
var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes);
noExistSettleMaterialCodes.ForEach(t =>
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"客户零件号【{t}】对应厂内零件号系统中不存在", string.Empty));
});
}
if (checkList.Count > 0)
{
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
@ -253,7 +270,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
{
try
{
var bbacSaDelItems = await GetBBACSaDelItemsAsync(id);
var bbacSaDelItems = await GetBBACSaDelItemsAsync(id).ConfigureAwait(false);
bbacSas.AddRange(bbacSaDelItems.bbacSas);
bbacSaDetails.AddRange(bbacSaDelItems.bbacSaDetails);
@ -325,9 +342,6 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
var materialRelationships = new List<MaterialRelationship>();
#region 处理结算数据
//销售价格
var priceListEntitys = await _priceListRepository.GetAllAsync();
bbacSaDetails.ForEach(bbacSaDetail =>
{
bbacSaDetail.SetId(GuidGenerator.Create());
@ -342,35 +356,21 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
bbacSaDetail.BillNum = bbacSaBillNum;
bbacSaDetail.KeyCode = bbacSaDetail.PN + bbacSaDetail.LU;
//根据物料号、结算日期获取价格
var priceListEntity = priceListEntitys.Find(t => t.LU == bbacSaDetail.LU && bbacSaDetail.SettleDate > t.BeginTime && bbacSaDetail.SettleDate < t.EndTime);
bbacSaDetail.Price = priceListEntity?.Price ?? default;
bbacSaDetail.BusinessType = bbacSaDetail.PN.Contains("R0") ? EnumBusinessType.MaiDanJianBBAC : _businessType;
});
//导入的零件号集合
var importPubSaLUs = bbacSaDetails.Select(t => t.LU).Distinct();
//销售价格
var priceListEntitys = _priceListRepository.Where(t => importPubSaLUs.Contains(t.LU)).ToList();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode));
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
/*
* ()
*
* 6-
*/
var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes);
noExistSettleMaterialCodes.ForEach(t =>
{
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, _businessType);
materialRelationships.Add(materialRelationship);
});
var seAllMaterialRelationships = materialRelationshipEntitys.Union(materialRelationships);
bbacSaDetails.ForEach(bbacSaDetail =>
{
bbacSaDetail.PartCode = seAllMaterialRelationships.FirstOrDefault(t => t.SettleMaterialCode == bbacSaDetail.LU)?.ErpMaterialCode ?? bbacSaDetail.LU.Replace(" ", "-");
//根据物料号、结算日期获取价格
var priceListEntity = priceListEntitys.FirstOrDefault(t => t.LU == bbacSaDetail.LU && bbacSaDetail.SettleDate >= t.BeginTime && bbacSaDetail.SettleDate <= t.EndTime);
bbacSaDetail.Price = priceListEntity?.Price ?? 0;
bbacSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == bbacSaDetail.LU)?.ErpMaterialCode ?? bbacSaDetail.LU.Replace(" ", "-");
});
#endregion
@ -430,14 +430,14 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
List<BBAC_CAN_SA_DETAIL> bbacCanSaDetails = new List<BBAC_CAN_SA_DETAIL>();
//不可结算
List<BBAC_NOT_SA_DETAIL> bbacNotSaDetails = new List<BBAC_NOT_SA_DETAIL>();
var bbacSaEntity = await _bbacSaRepository.FirstOrDefaultAsync(t => t.Id.Equals(id));
var bbacSaEntity = await _bbacSaRepository.FirstOrDefaultAsync(t => t.Id.Equals(id)).ConfigureAwait(false);
//var bbacSaEntity = await _bbacSaRepository.FindAsync(id).ConfigureAwait(false);
if (bbacSaEntity != null)
{
//结算单据
string bbacSaBillNum = bbacSaEntity.BillNum;
bbacCanSas = await _bbacCanSaRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum);
bbacCanSas = await _bbacCanSaRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum).ConfigureAwait(false);
//验证可结算主表状态
if (bbacCanSas.Any() && bbacCanSas.Any(t => t.State != SettleBillState.))
{
@ -445,9 +445,9 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
}
bbacSas.Add(bbacSaEntity);
bbacSaDetails = await _bbacSaDetailRepository.GetListAsync(t => t.BillNum == bbacSaBillNum);
bbacCanSaDetails = await _bbacCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum);
bbacNotSaDetails = await _bbacNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum);
bbacSaDetails = await _bbacSaDetailRepository.GetListAsync(t => t.BillNum == bbacSaBillNum).ConfigureAwait(false);
bbacCanSaDetails = await _bbacCanSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum).ConfigureAwait(false);
bbacNotSaDetails = await _bbacNotSaDetailRepository.GetListAsync(t => t.SettleBillNum == bbacSaBillNum).ConfigureAwait(false);
}
return (bbacSas, bbacSaDetails, bbacCanSas, bbacCanSaDetails, bbacNotSaDetails);

47
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs

@ -140,6 +140,22 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
}
}
if (!checkList.Any())
{
//验证客户对应厂内零件号是否存在
//导入的零件号集合
var importPubSaLUs = (importCN1HBOPSaDetails.Select(t => t.LU).Union(importCN5HBOPSaDetails.Select(t => t.LU))).Distinct();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
//不存在的客户零件号(差集)
var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes);
noExistSettleMaterialCodes.ForEach(t =>
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"客户零件号【{t}】对应厂内零件号系统中不存在", string.Empty));
});
}
if (checkList.Count > 0)
{
string fileName = await ExportErrorReportAsync(checkList);
@ -325,9 +341,6 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
var materialRelationships = new List<MaterialRelationship>();
#region 处理结算数据
//销售价格
var priceListEntitys = await _priceListRepository.GetAllAsync().ConfigureAwait(false);
hbpoSaDetails.ForEach(hbpoSaDetail =>
{
hbpoSaDetail.SetId(GuidGenerator.Create());
@ -342,34 +355,20 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
hbpoSaDetail.BillNum = hbpoSaBillNum;
hbpoSaDetail.KeyCode = hbpoSaDetail.PN + hbpoSaDetail.LU;
//根据物料号、结算日期获取价格
var priceListEntity = priceListEntitys.Find(t => t.LU == hbpoSaDetail.LU && hbpoSaDetail.SettleDate > t.BeginTime && hbpoSaDetail.SettleDate < t.EndTime);
hbpoSaDetail.Price = priceListEntity?.Price ?? default;
hbpoSaDetail.BusinessType = _businessType;
});
//导入的零件号集合
var importPubSaLUs = hbpoSaDetails.Select(t => t.LU).Distinct();
//销售价格
var priceListEntitys = _priceListRepository.Where(t => importPubSaLUs.Contains(t.LU)).ToList();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
/*
* ()
*
* 6-
*/
var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes);
noExistSettleMaterialCodes.ForEach(t =>
{
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, _businessType);
materialRelationships.Add(materialRelationship);
});
var seAllMaterialRelationships = materialRelationshipEntitys.Union(materialRelationships);
hbpoSaDetails.ForEach(hbpoSaDetail =>
{
//根据物料号、结算日期获取价格
var priceListEntity = priceListEntitys.FirstOrDefault(t => t.LU == hbpoSaDetail.LU && hbpoSaDetail.SettleDate >= t.BeginTime && hbpoSaDetail.SettleDate <= t.EndTime);
hbpoSaDetail.Price = priceListEntity?.Price ?? 0;
hbpoSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == hbpoSaDetail.LU)?.ErpMaterialCode ?? hbpoSaDetail.LU.Replace(" ", "-");
});
#endregion
@ -425,7 +424,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
//不可结算
List<HBPO_NOT_SA_DETAIL> hbpoNotSaDetails = new List<HBPO_NOT_SA_DETAIL>();
var hbpoSaEntity = await _hbpoSaRepository.FirstOrDefaultAsync(t => t.Id.Equals(id));
var hbpoSaEntity = await _hbpoSaRepository.FirstOrDefaultAsync(t => t.Id.Equals(id)).ConfigureAwait(false);
if (hbpoSaEntity != null)
{
//结算单据

47
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

@ -454,6 +454,23 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"结算分组号{item}已存在", string.Empty));
}
}
if (!checkList.Any())
{
//验证客户对应厂内零件号是否存在
//导入的零件号集合
var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
//不存在的客户零件号(差集)
var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes);
noExistSettleMaterialCodes.ForEach(t =>
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"客户零件号【{t}】对应厂内零件号系统中不存在", string.Empty));
});
}
return checkList;
#endregion
}
@ -499,11 +516,11 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
else
{
//销售价格
var priceListEntitys = _priceListRepository.Join(lus, a => a.LU, b => b, (a, b) => a).ToList();
var priceListEntitys = _priceListRepository.Where(t => lus.Contains(t.LU)).ToList();
pubSaDetails.ForEach(importPubSaDetail =>
{
//根据物料号、结算日期获取价格
var priceListEntity = priceListEntitys.Find(t => t.LU == importPubSaDetail.LU && importPubSaDetail.SettleDate >= t.BeginTime && importPubSaDetail.SettleDate <= t.EndTime);
var priceListEntity = priceListEntitys.FirstOrDefault(t => t.LU == importPubSaDetail.LU && importPubSaDetail.SettleDate >= t.BeginTime && importPubSaDetail.SettleDate <= t.EndTime);
importPubSaDetail.Price = priceListEntity?.Price ?? 0;
});
}
@ -511,25 +528,25 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
//导入的零件号集合
var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
//var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
/*
* ()
*
* 6-
*/
var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes);
///*
// * (不存在的客户零件号)差集
// * 转换为厂内零件号
// * 转换规则6个空格替换成“-”
// */
//var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes);
noExistSettleMaterialCodes.ForEach(t =>
{
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, businessType);
materialRelationships.Add(materialRelationship);
});
//noExistSettleMaterialCodes.ForEach(t =>
//{
// var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, businessType);
// materialRelationships.Add(materialRelationship);
//});
var seAllMaterialRelationships = materialRelationshipEntitys.Union(materialRelationships);
pubSaDetails.ForEach(pubSaDetail =>
{
pubSaDetail.PartCode = seAllMaterialRelationships.FirstOrDefault(t => t.SettleMaterialCode == pubSaDetail.LU)?.ErpMaterialCode ?? pubSaDetail.LU.Replace(" ", "-");
pubSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == pubSaDetail.LU)?.ErpMaterialCode ?? pubSaDetail.LU.Replace(" ", "-");
});
#endregion

15
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SE_DETAIL_SERVICE.cs

@ -3,9 +3,11 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.OpenApi.Extensions;
using SettleAccount.Domain.BQ;
using Shouldly;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
@ -49,22 +51,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[HttpPost]
public async Task<string> ExportAsync(PUB_SE_DETAIL_RequestDto input)
{
input.Filters.Add(new FilterCondition("BusinessType", input.BusinessType.ToString(), EnumFilterAction.Equal, EnumFilterLogic.And));
var businessTypeDisplayName = input.BusinessType.ToString();
DisplayAttribute attributeOfType = input.BusinessType.GetAttributeOfType<DisplayAttribute>();
var businessTypeDisplayName = string.Empty;
var strBusinessType = input.Filters.FirstOrDefault(t => t.Column == "businessType")?.Value;
var businessType = (EnumBusinessType)Enum.Parse(typeof(EnumBusinessType), strBusinessType);
DisplayAttribute attributeOfType = businessType.GetAttributeOfType<DisplayAttribute>();
if (attributeOfType != null)
{
businessTypeDisplayName = attributeOfType.Name;
}
string fileName = $"{businessTypeDisplayName}发运数据_{Guid.NewGuid()}.xlsx";
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<PUB_SE_DETAIL>, List<PUB_SE_DETAIL_EXPORT_DTO>>(entities);
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtos);
var result = await _exportImporter.ExcelExporter(dtos).ConfigureAwait(false);
result.ShouldNotBeNull();
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result });
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }).ConfigureAwait(false);
return fileName;
}
#endregion

55
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/HomeAppService.cs

@ -0,0 +1,55 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Wordprocessing;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SettleAccount.Job.Services.Report;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp.Application.Services;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
/// <summary>
/// 手动同步
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class HomeAppService : ApplicationService
{
private readonly IServiceProvider _applicationServices;
public HomeAppService(IHost host)
{
_applicationServices = host.Services;
}
/// <summary>
/// 同步
/// </summary>
[HttpPost]
public async Task<string> SyncAsync(JobRequestDto jobRequestDto)
{
await Task.CompletedTask.ConfigureAwait(false);
return "ddd";
//using var scope = this._applicationServices.CreateScope();
//IExportJob exportJob = jobDto.businessType switch
//{
// EnumBusinessType.JisBBAC => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.JisHBPO => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.MaiDanJianBBAC => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.MaiDanJianHBPO => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.ZhiGongJianBBAC => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.ZhiGongJianHBPO => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.BeiJian => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// EnumBusinessType.YinDuJian => scope.ServiceProvider.GetRequiredService<JisBBACEdiSeCompareExportService>(),
// _ => throw new ArgumentOutOfRangeException(nameof(jobDto.businessType), $"Not expected direction value: {jobDto.businessType}"),
//};
//exportJob.ExportFile(jobDto.Id, jobDto.ExportName, jobDto.Propert);
}
}

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

@ -74,7 +74,7 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
{
var checkList = new List<ErrorExportDto>();
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImportByHeadDesc<PriceListImportDto>(files, _excelImportService);
var result = await _exportImporter.UploadExcelImportByHeadDesc<PriceListImportDto>(files, _excelImportService).ConfigureAwait(false);
List<string> _checkls = new List<string>();
_checkls.Add("1040");
_checkls.Add("1046");
@ -82,35 +82,39 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
result = result.Where(p => _checkls.Contains(p.Plant)).ToList();
var entityList = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result);
entityList = entityList.GroupBy(p => new { p.LU, p.ClientCode, p.BeginTime, p.EndTime }).Select(p => p.FirstOrDefault()).ToList();
var contractNo = entityList.FirstOrDefault().ContractNo;
#region 校验
var lus = entityList.Select(p => p.LU).ToList();
var priceListModelEntitys = await _priceListRepository.GetListAsync(p => lus.Contains(p.LU));
if (priceListModelEntitys.Count > 0)
if (entityList.Any())
{
var query = from item1 in priceListModelEntitys
var query = from item1 in entityList
join item2 in entityList
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode }
on new { item1.LU } equals new { item2.LU }
where (item1.BeginTime > item2.BeginTime && item1.EndTime < item2.EndTime) || (item2.BeginTime > item1.BeginTime && item2.EndTime < item1.EndTime)
select item1;
foreach (var item in query)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"物料号:{item.LU},时间区间{item.BeginTime}-{item.EndTime}与系统数据存在时间交集", string.Empty));
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},时间区间存在交集", string.Empty));
}
}
if (checkList.Count > 0)
{
string fileName = await ExportErrorReportAsync(checkList);
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName });
}
#endregion
var lus = entityList.Select(p => new { p.LU, p.ContractNo });
var priceListModelEntitys = _priceListRepository.Where(t => lus.Contains(new { t.LU, t.ContractNo })).ToList();
if (priceListModelEntitys.Any())
{
await _priceListRepository.DeleteManyAsync(priceListModelEntitys).ConfigureAwait(false);
}
foreach (var item in entityList)
{
item.Update(GuidGenerator.Create());
}
await _priceListManager.ImportAsync(entityList.ToList(), version);
await _priceListRepository.InsertManyAsync(entityList).ConfigureAwait(false);
return new JsonResult(new { Code = 200, Message = "导入成功" });
}

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

@ -52,7 +52,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
{
var checkList = new List<ErrorExportDto>();
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImportByHeadDesc<PriceListBJImportDto>(files, _excelImportService);
var result = await _exportImporter.UploadExcelImportByHeadDesc<PriceListBJImportDto>(files, _excelImportService).ConfigureAwait(false);
List<string> _checkls = new List<string>();
_checkls.Add("1040");
_checkls.Add("1046");
@ -63,33 +63,36 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
entityList = entityList.GroupBy(p => new { p.LU, p.ClientCode, p.BeginDate, p.EndDate }).Select(p => p.FirstOrDefault()).ToList();
#region 校验
var lus = entityList.Select(p => p.LU).ToList();
var priceListBJModelEntitys = await _repository.GetListAsync(p => lus.Contains(p.LU));
if (priceListBJModelEntitys.Count > 0)
if (entityList.Any())
{
var query = from item1 in priceListBJModelEntitys
var query = from item1 in entityList
join item2 in entityList
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode }
where (item1.BeginDate > item2.BeginDate && item1.BeginDate < item2.EndDate) || (item2.BeginDate > item1.BeginDate && item2.BeginDate < item1.EndDate)
on new { item1.LU } equals new { item2.LU }
where (item1.BeginDate > item2.BeginDate && item1.EndDate < item2.EndDate) || (item2.BeginDate > item1.BeginDate && item2.EndDate < item1.EndDate)
select item1;
foreach (var item in query)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"物料号:{item.LU},时间区间{item.BeginDate}-{item.EndDate}与系统数据存在时间交集", string.Empty));
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item.LU},时间区间存在交集", string.Empty));
}
}
if (checkList.Count > 0)
{
string fileName = await ExportErrorReportAsync(checkList);
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName });
}
#endregion
var lus = entityList.Select(p => new { p.LU, p.ContractNo });
var priceListModelEntitys = _repository.Where(t => lus.Contains(new { t.LU, t.ContractNo })).ToList();
if (priceListModelEntitys.Any())
{
await _repository.DeleteManyAsync(priceListModelEntitys).ConfigureAwait(false);
}
foreach (var item in entityList)
{
item.Update(GuidGenerator.Create());
}
await _priceListManagerBJ.ImportAsync(entityList, version);
await _repository.InsertManyAsync(entityList).ConfigureAwait(false);
return new JsonResult(new { Code = 200, Message = "导入成功" });
}

Loading…
Cancel
Save