mahao 1 year ago
parent
commit
50d57bb725
  1. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  2. 73
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Prices/PriceListDtoBase.cs
  3. 24
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
  4. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  5. 30
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  6. 34
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs
  7. 39
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs
  8. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  9. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs
  10. 122
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  11. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs

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

@ -66,6 +66,11 @@ public class PUB_SAImportRequestDto
/// </summary> /// </summary>
[Display(Name = "期间")] [Display(Name = "期间")]
public int Version { get; set; } public int Version { get; set; }
/// <summary>
/// 地点
/// </summary>
[Display(Name = "地点")]
public string Site { get; set; }
} }
/// <summary> /// <summary>

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

@ -65,42 +65,36 @@ public class PriceListExportDto
[Display(Name = "零件号")] [Display(Name = "零件号")]
[ExporterHeader(DisplayName = "客户零件号")] [ExporterHeader(DisplayName = "客户零件号")]
public string LU { get; set; } public string LU { get; set; }
/// <summary> /// <summary>
/// 价格 /// 价格
/// </summary> /// </summary>
[Display(Name = "价格")] [Display(Name = "价格")]
[ExporterHeader(DisplayName = "价格")] [ExporterHeader(DisplayName = "价格")]
public Decimal Price { set; get; } public Decimal Price { set; get; }
/// <summary> /// <summary>
/// 开始时间 /// 开始时间
/// </summary> /// </summary>
[Display(Name = "开始时间")] [Display(Name = "开始时间")]
[ExporterHeader(DisplayName = "开始时间")] [ExporterHeader(DisplayName = "开始时间")]
public DateTime BeginTime { set; get; } public DateTime BeginTime { set; get; }
/// <summary> /// <summary>
/// 结束时间 /// 结束时间
/// </summary> /// </summary>
[Display(Name = "结束时间")] [Display(Name = "结束时间")]
[ExporterHeader(DisplayName = "结束时间")] [ExporterHeader(DisplayName = "结束时间")]
public DateTime EndTime { set; get; } public DateTime EndTime { set; get; }
/// <summary> /// <summary>
/// 客户编码 /// 客户编码
/// </summary> /// </summary>
[Display(Name = "客户编码")] [Display(Name = "客户编码")]
[ExporterHeader(DisplayName = "客户编码")] [ExporterHeader(DisplayName = "客户编码")]
public string ClientCode { get; set; } public string ClientCode { get; set; }
/// <summary> /// <summary>
/// 合同签订时间 /// 合同签订时间
/// </summary> /// </summary>
[Display(Name = "合同签订时间")] [Display(Name = "合同签订时间")]
[ExporterHeader(DisplayName = "合同签订时间")] [ExporterHeader(DisplayName = "合同签订时间")]
public DateTime Date { get; set; } public DateTime Date { get; set; }
/// <summary> /// <summary>
/// 合同号 /// 合同号
/// </summary> /// </summary>
@ -112,8 +106,7 @@ public class PriceListExportDto
/// <summary> /// <summary>
/// 销售价格导入 /// 销售价格导入
/// </summary> /// </summary>
[ImportProject(Name = SettleAccountModuleName.PriceList)] [Importer(HeaderRowIndex = 22)]
[Importer(HeaderRowIndex = 21)]
public class PriceListImportDto public class PriceListImportDto
{ {
/// <summary> /// <summary>
@ -138,7 +131,7 @@ public class PriceListImportDto
/// <summary> /// <summary>
/// 价格 /// 价格
/// </summary> /// </summary>
[ImporterHeader(Name = "Total Price (Old)")] [ImporterHeader(Name = "Total Price")]
public decimal TotalPrice { get; set; } public decimal TotalPrice { get; set; }
/// <summary> /// <summary>
/// 开始时间 /// 开始时间
@ -297,56 +290,58 @@ public class PriceListBJExportDto
/// <summary> /// <summary>
/// 客户备件价格导入 /// 客户备件价格导入
/// </summary> /// </summary>
[Importer(HeaderRowIndex = 22)]
public class PriceListBJImportDto public class PriceListBJImportDto
{ {
/// <summary> /// <summary>
/// 客户零件号 /// 合同签订时间
/// </summary> /// </summary>
[Display(Name = "客户零件号")] [ImporterHeader(IsIgnore = true)]
[ImporterHeader(Name = "客户零件号")] [ExcelImporterHeadDesc(Row = 1, Cell = 1)]
public string LU { get; set; } public string Date { get; set; }
/// <summary>
/// 合同号
/// </summary>
[ImporterHeader(IsIgnore = true)]
[ExcelImporterHeadDesc(Row = 2, Cell = 1)]
public string ContractNo { get; set; }
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[Required(ErrorMessage = "{0}是必填项")]
[ImporterHeader(Name = "Part No.")]
public string PartNo { get; set; }
/// <summary> /// <summary>
/// 价格 /// 价格
/// </summary> /// </summary>
[Display(Name = "价格")] [ImporterHeader(Name = "Total Price")]
[ImporterHeader(Name = "价格")] public decimal TotalPrice { get; set; }
public decimal Price { get; set; }
/// <summary> /// <summary>
/// 开始时间 /// 开始时间
/// </summary> /// </summary>
[Display(Name = "开始时间")] [ImporterHeader(Name = "Valid From")]
[ImporterHeader(Name = "开始时间")] public DateTime ValidFrom { get; set; }
public DateTime BeginDate { set; get; }
/// <summary> /// <summary>
/// 结束时间 /// 结束时间
/// </summary> /// </summary>
[Display(Name = "结束时间")] [ImporterHeader(Name = "Valid To")]
[ImporterHeader(Name = "结束时间")] public DateTime ValidTo { get; set; }
public DateTime EndDate { set; get; }
/// <summary> /// <summary>
/// 客户编码 /// 客户编码
/// </summary> /// </summary>
[Display(Name = "客户编码")] [ImporterHeader(Name = "Plant")]
[ImporterHeader(Name = "客户编码")] public string Plant { get; set; }
public string ClientCode { get; set; }
/// <summary> /// <summary>
/// 合同签订时间 /// ES1
/// </summary> /// </summary>
[Display(Name = "合同签订时间")] [ImporterHeader(Name = "ES1")]
[ImporterHeader(Name = "合同签订时间")] public string ES1 { get; set; }
public DateTime Date { get; set; }
/// <summary> /// <summary>
/// 合同号 /// ES2
/// </summary> /// </summary>
[Display(Name = "合同号")] [ImporterHeader(Name = "ES2")]
[ImporterHeader(Name = "合同号")] public string ES2 { get; set; }
public string ContractNo { get; set; }
} }
public class PriceListBJRequestDto : RequestInputBase public class PriceListBJRequestDto : RequestInputBase

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

@ -31,6 +31,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ;
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA> public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
{ {
/// <summary>
/// DbContext
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
/// <summary> /// <summary>
/// BBAC结算仓储 /// BBAC结算仓储
/// </summary> /// </summary>
@ -79,7 +83,8 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
/// <summary> /// <summary>
/// 构造 /// 构造
/// </summary> /// </summary>
public BBAC_SA_SERVICE(INormalEfCoreRepository<BBAC_SA, Guid> bbacSaRepository, public BBAC_SA_SERVICE(SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<BBAC_SA, Guid> bbacSaRepository,
INormalEfCoreRepository<BBAC_SA_DETAIL, Guid> bbacSaDetailRepository, INormalEfCoreRepository<BBAC_SA_DETAIL, Guid> bbacSaDetailRepository,
INormalEfCoreRepository<BBAC_CAN_SA, Guid> bbacCanSaRepository, INormalEfCoreRepository<BBAC_CAN_SA, Guid> bbacCanSaRepository,
INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> bbacCanSaDetailRepository, INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> bbacCanSaDetailRepository,
@ -93,6 +98,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
ICommonManager commonManager ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{ {
_settleAccountDbContext = settleAccountDbContext;
_bbacSaRepository = bbacSaRepository; _bbacSaRepository = bbacSaRepository;
_bbacSaDetailRepository = bbacSaDetailRepository; _bbacSaDetailRepository = bbacSaDetailRepository;
_bbacCanSaRepository = bbacCanSaRepository; _bbacCanSaRepository = bbacCanSaRepository;
@ -400,7 +406,8 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
//导入的零件号集合 //导入的零件号集合
var importPubSaLUs = bbacSaDetails.Select(t => t.LU).Distinct(); var importPubSaLUs = bbacSaDetails.Select(t => t.LU).Distinct();
//销售价格 //销售价格
var priceListEntitys = _priceListRepository.Where(t => t.IsCancel == false).Where(t => importPubSaLUs.Contains(t.LU)).ToList();
var priceListEntitys = GetPriceListEntitys(importPubSaLUs);
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
bbacSaDetails.ForEach(bbacSaDetail => bbacSaDetails.ForEach(bbacSaDetail =>
{ {
@ -507,5 +514,18 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
return (bbacSas, bbacSaDetails, bbacCanSas, bbacCanSaDetails, bbacNotSaDetails); return (bbacSas, bbacSaDetails, bbacCanSas, bbacCanSaDetails, bbacNotSaDetails);
} }
/// <summary>
/// 获取价格
/// </summary>
private List<PriceList> GetPriceListEntitys(IEnumerable<string> importSaLus)
{
var clientCode = Site;
return _settleAccountDbContext.Set<PriceList>()
.Where(t => t.IsCancel == false)
.Where(t => t.ClientCode == clientCode)
.Where(t => importSaLus.Contains(t.LU))
.ToList();
}
#endregion #endregion
} }

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

@ -370,7 +370,9 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
//导入的零件号集合 //导入的零件号集合
var importPubSaLUs = hbpoSaDetails.Select(t => t.LU).Distinct(); var importPubSaLUs = hbpoSaDetails.Select(t => t.LU).Distinct();
//销售价格 //销售价格
var priceListEntitys = _priceListRepository.Where(t => t.IsCancel == false).Where(t => importPubSaLUs.Contains(t.LU)).ToList(); var priceListEntitys = _priceListRepository.Where(t => t.IsCancel == false)
.Where(t => t.ClientCode == "104T")
.Where(t => importPubSaLUs.Contains(t.LU)).ToList();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
hbpoSaDetails.ForEach(hbpoSaDetail => hbpoSaDetails.ForEach(hbpoSaDetail =>
{ {

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

@ -39,42 +39,34 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
/// PUB结算仓储 /// PUB结算仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<PUB_SA, Guid> _repository; private readonly INormalEfCoreRepository<PUB_SA, Guid> _repository;
/// <summary> /// <summary>
/// PUB结算明细仓储 /// PUB结算明细仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<PUB_SA_DETAIL, Guid> _pubSaDetailRepository; private readonly INormalEfCoreRepository<PUB_SA_DETAIL, Guid> _pubSaDetailRepository;
/// <summary> /// <summary>
/// PUB可结算仓储 /// PUB可结算仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<PUB_CAN_SA, Guid> _pubCanSaRepository; private readonly INormalEfCoreRepository<PUB_CAN_SA, Guid> _pubCanSaRepository;
/// <summary> /// <summary>
/// PUB可结算明细仓储 /// PUB可结算明细仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> _pubCanSaDetailRepository; private readonly INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> _pubCanSaDetailRepository;
/// <summary> /// <summary>
/// PUB不可结算明细仓储 /// PUB不可结算明细仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> _pubNotSaDetailRepository; private readonly INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> _pubNotSaDetailRepository;
/// <summary> /// <summary>
/// 销售价格仓储 /// 销售价格仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<PriceList, Guid> _priceListRepository; private readonly INormalEfCoreRepository<PriceList, Guid> _priceListRepository;
/// <summary> /// <summary>
/// 备件价格仓储 /// 备件价格仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _priceBjListRepository; private readonly INormalEfCoreRepository<PriceListBJ, Guid> _priceBjListRepository;
/// <summary> /// <summary>
/// 客户零件关系仓储 /// 客户零件关系仓储
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<MaterialRelationship, Guid> _materialRelationshipRepository; private readonly INormalEfCoreRepository<MaterialRelationship, Guid> _materialRelationshipRepository;
/// <summary> /// <summary>
/// 替换件关系仓储 /// 替换件关系仓储
/// </summary> /// </summary>
@ -113,6 +105,14 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
/// 期间 /// 期间
/// </summary> /// </summary>
private int _version; private int _version;
/// <summary>
/// 业务类别
/// </summary>
private EnumBusinessType businessType;
/// <summary>
/// 地点
/// </summary>
private string site;
#region 导入、导出 #region 导入、导出
/// <summary> /// <summary>
@ -123,6 +123,8 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
{ {
IActionResult result = new JsonResult(new { Code = 400 }); IActionResult result = new JsonResult(new { Code = 400 });
_version = pubSaImportRequestDto.Version; _version = pubSaImportRequestDto.Version;
businessType = pubSaImportRequestDto.BusinessType;
site = pubSaImportRequestDto.Site;
switch (pubSaImportRequestDto.BusinessType) switch (pubSaImportRequestDto.BusinessType)
{ {
case EnumBusinessType.ZhiGongJianBBAC: case EnumBusinessType.ZhiGongJianBBAC:
@ -440,10 +442,21 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
importPubSaDetail.BusinessType = businessType; importPubSaDetail.BusinessType = businessType;
}); });
var lus = pubSaDetails.Select(t => t.LU).Distinct().ToList(); var lus = pubSaDetails.Select(t => t.LU).Distinct().ToList();
var clientCode = businessType switch
{
EnumBusinessType.ZhiGongJianBBAC => site,
EnumBusinessType.ZhiGongJianHBPO => "104T",
EnumBusinessType.BeiJian => "1040",
EnumBusinessType.YinDuJian => "1040",
_ => throw new UserFriendlyException($"业务编码错误", "400")
};
if (businessType == EnumBusinessType.BeiJian) if (businessType == EnumBusinessType.BeiJian)
{ {
//备件销售价格 //备件销售价格
var priceListEntitys = _priceBjListRepository.Where(t => t.IsCancel == false) var priceListEntitys = _priceBjListRepository.Where(t => t.IsCancel == false)
.Where(t => t.ClientCode == clientCode)
.Where(t => lus.Contains(t.LU)).ToList(); .Where(t => lus.Contains(t.LU)).ToList();
pubSaDetails.ForEach(importPubSaDetail => pubSaDetails.ForEach(importPubSaDetail =>
{ {
@ -461,6 +474,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
{ {
//销售价格 //销售价格
var priceListEntitys = _priceListRepository.Where(t => t.IsCancel == false) var priceListEntitys = _priceListRepository.Where(t => t.IsCancel == false)
.Where(t => t.ClientCode == clientCode)
.Where(t => lus.Contains(t.LU)).ToList(); .Where(t => lus.Contains(t.LU)).ToList();
pubSaDetails.ForEach(importPubSaDetail => pubSaDetails.ForEach(importPubSaDetail =>
{ {

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

@ -14,6 +14,7 @@ using Volo.Abp.Caching;
using Win.Abp.Snowflakes; using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.SettleAccount.ExportReports;
@ -29,7 +30,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices;
public class PriceListAppService : SettleAccountApplicationBase<PriceList> public class PriceListAppService : SettleAccountApplicationBase<PriceList>
{ {
/// <summary> /// <summary>
/// 数据上下文 /// DbContext
/// </summary> /// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext; private readonly SettleAccountDbContext _settleAccountDbContext;
/// <summary> /// <summary>
@ -78,8 +79,29 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
}; };
result = result.FindAll(p => filter.Contains(p.Plant)).ToList(); result = result.FindAll(p => filter.Contains(p.Plant)).ToList();
result.FindAll(t => !string.IsNullOrEmpty(t.ES1) || !string.IsNullOrEmpty(t.ES2)).ForEach(t => t.PartNo = t.PartNo + new string(' ', 6) + t.ES1 + t.ES2); result.FindAll(t => !string.IsNullOrEmpty(t.ES1) || !string.IsNullOrEmpty(t.ES2)).ForEach(t => t.PartNo = t.PartNo + new string(' ', 6) + t.ES1 + t.ES2);
var entityList = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result); var newPrice = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result);
var newPrice = entityList.GroupBy(p => p.LU).Select(p => p.FirstOrDefault()).ToList(); newPrice = newPrice.GroupBy(p => new { p.LU, p.ClientCode, p.BeginTime, p.EndTime }).Select(p => p.FirstOrDefault()).ToList();
#region 校验
if (newPrice.Any())
{
var query = from item1 in newPrice
join item2 in newPrice
on new { item1.LU, item1.ClientCode } equals new { item2.LU, item2.ClientCode }
where (item1.BeginTime > item2.BeginTime && item1.EndTime < item2.EndTime) || (item2.BeginTime > item1.BeginTime && item2.EndTime < item1.EndTime) || (item1.BeginTime == item2.BeginTime && item1.EndTime != item2.EndTime) || (item1.BeginTime != item2.BeginTime && item1.EndTime == item2.EndTime)
select item1.LU;
var repeat = query.Distinct().ToList();
foreach (var item in repeat)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item},时间区间存在交集", string.Empty));
}
}
if (checkList.Count > 0)
{
var fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { code = ApplicationConsts.ImportFailCode, message = "导入失败", fileName });
}
#endregion
var importLus = newPrice.Select(t => t.LU).Distinct().ToList(); var importLus = newPrice.Select(t => t.LU).Distinct().ToList();
var oldPrices = _settleAccountDbContext.Set<PriceList>() var oldPrices = _settleAccountDbContext.Set<PriceList>()
@ -87,14 +109,14 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
.Where(t => importLus.Contains(t.LU)) .Where(t => importLus.Contains(t.LU))
.ToList(); .ToList();
//系统中合同日期比导入文件中的合同日期晚 //系统中合同日期比导入文件中的合同日期晚
var oldpriceNewDate = from oldprice in oldPrices var oldPriceNewDate = from oldprice in oldPrices
from newprice in newPrice from newprice in newPrice
where oldprice.LU == newprice.LU && oldprice.Date > newprice.Date where oldprice.LU == newprice.LU && oldprice.Date > newprice.Date
select oldprice; select oldprice;
oldPrices.ForEach(t => t.IsCancel = true); oldPrices.ForEach(t => t.IsCancel = true);
if (oldpriceNewDate.Any()) if (oldPriceNewDate.Any())
{ {
oldPrices.FindAll(t => oldpriceNewDate.Contains(t)).ForEach(t => t.IsCancel = false); oldPrices.FindAll(t => oldPriceNewDate.Contains(t)).ForEach(t => t.IsCancel = false);
var importCancelLus = oldPrices.Select(t => t.LU).Distinct(); var importCancelLus = oldPrices.Select(t => t.LU).Distinct();
newPrice.FindAll(t => importCancelLus.Contains(t.LU)).ForEach(t => t.IsCancel = true); newPrice.FindAll(t => importCancelLus.Contains(t.LU)).ForEach(t => t.IsCancel = true);
} }

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

@ -12,6 +12,7 @@ using Volo.Abp.Caching;
using Win.Abp.Snowflakes; using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.SettleAccount.ExportReports;
@ -57,13 +58,33 @@ public class PriceListAppServiceBJ : SettleAccountApplicationBase<PriceListBJ>
var result = await _exportImporter.UploadExcelImportByHeadDesc<PriceListBJImportDto>(files, _excelImportService).ConfigureAwait(false); var result = await _exportImporter.UploadExcelImportByHeadDesc<PriceListBJImportDto>(files, _excelImportService).ConfigureAwait(false);
var filter = new List<string> var filter = new List<string>
{ {
"1040", "1040"
"1046",
"104T"
}; };
result = result.Where(p => filter.Contains(p.ClientCode)).ToList(); result = result.Where(p => filter.Contains(p.Plant)).ToList();
var entityList = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result); result.FindAll(t => !string.IsNullOrEmpty(t.ES1) || !string.IsNullOrEmpty(t.ES2)).ForEach(t => t.PartNo = t.PartNo + new string(' ', 6) + t.ES1 + t.ES2);
var newPrice = entityList.GroupBy(p => p.LU).Select(p => p.FirstOrDefault()).ToList(); var newPrice = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result);
newPrice = newPrice.GroupBy(p => new { p.LU, p.BeginDate, p.EndDate }).Select(p => p.FirstOrDefault()).ToList();
#region 校验
if (newPrice.Any())
{
var query = from item1 in newPrice
join item2 in newPrice
on item1.LU equals item2.LU
where (item1.BeginDate > item2.BeginDate && item1.EndDate < item2.EndDate) || (item2.BeginDate > item1.BeginDate && item2.EndDate < item1.EndDate) || (item1.BeginDate == item2.BeginDate && item1.EndDate != item2.EndDate) || (item1.BeginDate != item2.BeginDate && item1.EndDate == item2.EndDate)
select item1.LU;
var repeat = query.Distinct().ToList();
foreach (var item in repeat)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"导入文件中物料号:{item},时间区间存在交集", string.Empty));
}
}
if (checkList.Count > 0)
{
var fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { code = ApplicationConsts.ImportFailCode, message = "导入失败", fileName });
}
#endregion
var importLus = newPrice.Select(t => t.LU).Distinct().ToList(); var importLus = newPrice.Select(t => t.LU).Distinct().ToList();
var oldPrices = _settleAccountDbContext.Set<PriceListBJ>() var oldPrices = _settleAccountDbContext.Set<PriceListBJ>()
@ -71,14 +92,14 @@ public class PriceListAppServiceBJ : SettleAccountApplicationBase<PriceListBJ>
.Where(t => importLus.Contains(t.LU)) .Where(t => importLus.Contains(t.LU))
.ToList(); .ToList();
//系统中合同日期比导入文件中的合同日期晚 //系统中合同日期比导入文件中的合同日期晚
var oldpriceNewDate = from oldprice in oldPrices var oldPriceNewDate = from oldprice in oldPrices
from newprice in newPrice from newprice in newPrice
where oldprice.LU == newprice.LU && oldprice.Date > newprice.Date where oldprice.LU == newprice.LU && oldprice.Date > newprice.Date
select oldprice; select oldprice;
oldPrices.ForEach(t => t.IsCancel = true); oldPrices.ForEach(t => t.IsCancel = true);
if (oldpriceNewDate.Any()) if (oldPriceNewDate.Any())
{ {
oldPrices.FindAll(t => oldpriceNewDate.Contains(t)).ForEach(t => t.IsCancel = false); oldPrices.FindAll(t => oldPriceNewDate.Contains(t)).ForEach(t => t.IsCancel = false);
var importCancelLus = oldPrices.Select(t => t.LU).Distinct(); var importCancelLus = oldPrices.Select(t => t.LU).Distinct();
newPrice.FindAll(t => importCancelLus.Contains(t.LU)).ForEach(t => t.IsCancel = true); newPrice.FindAll(t => importCancelLus.Contains(t.LU)).ForEach(t => t.IsCancel = true);
} }

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

@ -577,7 +577,13 @@ namespace Win.Sfs.SettleAccount
/// </summary> /// </summary>
private void CreateMapPriceListBJ() private void CreateMapPriceListBJ()
{ {
CreateMap<PriceListBJImportDto, PriceListBJ>(); CreateMap<PriceListBJImportDto, PriceListBJ>()
.ForMember(x => x.LU, y => y.MapFrom(y => y.PartNo))
.ForMember(x => x.Price, y => y.MapFrom(y => y.TotalPrice))
.ForMember(x => x.BeginDate, y => y.MapFrom(y => y.ValidFrom))
.ForMember(x => x.EndDate, y => y.MapFrom(y => y.ValidTo))
.ForMember(x => x.ClientCode, y => y.MapFrom(y => y.Plant))
.ForMember(x => x.Date, y => y.MapFrom(y => DateTime.ParseExact(y.Date, "dd.MM.yyyy", System.Globalization.CultureInfo.CurrentCulture))); ;
CreateMap<PriceListBJ, PriceListBJDto>().ReverseMap(); CreateMap<PriceListBJ, PriceListBJDto>().ReverseMap();
CreateMap<PriceListBJ, PriceListBJRequestDto>().ReverseMap(); CreateMap<PriceListBJ, PriceListBJRequestDto>().ReverseMap();

5
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs

@ -11,6 +11,11 @@ namespace Win.Sfs.SettleAccount.Reports;
/// </summary> /// </summary>
public class PubSaSeCompareDiff public class PubSaSeCompareDiff
{ {
/// <summary>
/// 期间
/// </summary>
[Display(Name = "期间")]
public int Version { get; set; }
/// <summary> /// <summary>
/// Wms发货单号 /// Wms发货单号
/// </summary> /// </summary>

122
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs

@ -1,12 +1,14 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Drawing;
using System.Linq; using System.Linq;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Extensions;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR; using SettleAccount.Job.SignalR;
using ShardingCore.Extensions;
using Shouldly; using Shouldly;
using TaskJob.EventArgs; using TaskJob.EventArgs;
using TaskJob.Interfaces; using TaskJob.Interfaces;
@ -178,7 +180,8 @@ namespace SettleAccount.Job.Services.Report
/// <summary> /// <summary>
/// 获取比对数据 /// 获取比对数据
/// </summary> /// </summary>
public List<PubSaSeCompareDiff> GetSaSeCompareData(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime) [Obsolete]
private List<PubSaSeCompareDiff> GetSaSeCompareData(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime)
{ {
//印度件LU对比 //印度件LU对比
if (businessType == EnumBusinessType.YinDuJian) if (businessType == EnumBusinessType.YinDuJian)
@ -264,7 +267,122 @@ namespace SettleAccount.Job.Services.Report
/// <summary> /// <summary>
/// 获取比对数据 /// 获取比对数据
/// </summary> /// </summary>
public List<PubSaSeCompareDiff> GetSaSeCompareDataYinDu(int version, DateTime seStartDateTime, DateTime seEndDateTime) private List<PubSaSeCompareDiff> GetSaSeCompareDataOld(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime)
{
//印度件LU对比
if (businessType == EnumBusinessType.YinDuJian)
{
return GetSaSeCompareDataYinDu(version, seStartDateTime, seEndDateTime);
}
//结算
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == businessType
group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.CustomerPartCodeNoSpace,
Id = groupItem.Max(t => t.Id),
Qty = groupItem.Sum(t => t.Qty),
Version = groupItem.Max(t => t.Version),
LU = groupItem.Max(t => t.LU),
SettleDate = groupItem.Max(t => t.SettleDate),
PartCode = groupItem.Max(t => t.PartCode),
};
var saGroupByVersion = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
Version = groupItem.Max(t => t.Version),
LU = groupItem.Max(t => t.LU),
SettleDate = groupItem.Max(t => t.SettleDate),
PartCode = groupItem.Max(t => t.PartCode),
};
//发运
var seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>()
group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU),
WmsBillNum = groupItem.Max(t => t.WmsBillNum),
ShippingDate = groupItem.Max(t => t.ShippingDate),
FactoryPartCode = groupItem.Max(t => t.FactoryPartCode),
ToLocCode = groupItem.Max(t => t.ToLocCode),
ToErpLocCode = groupItem.Max(t => t.ToErpLocCode)
};
//有结算无发运
var haveSaNotHaveSeList = (from sa in saGroup
join se in seGroup
on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { se.PN, se.CustomerPartCodeNoSpace }
into temp
from se in temp.DefaultIfEmpty()
where se.PN == null
select new PubSaSeCompareDiff()
{
Version = sa.Version,
CustomerOfflineTime = sa.SettleDate,
PN = sa.PN,
SAQty = sa.Qty,
SaCustomerPartCode = sa.CustomerPartCodeNoSpace,
SaFactoryPartCode = sa.PartCode,
CustomerPartCode = sa.LU
}).ToList();
//无结算有发运
var notHaveSaHaveSeList = (from se in seGroup
join sa in saGroup
on new { se.PN, se.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace }
into temp
from sa in temp.DefaultIfEmpty()
where sa.PN == null
select new PubSaSeCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
PN = se.PN,
SEQty = se.Qty,
ToLocCode = se.ToLocCode,
ToErpLocCode = se.ToErpLocCode,
SeCustomerPartCode = se.CustomerPartCodeNoSpace,
SeFactoryPartCode = se.FactoryPartCode,
CustomerPartCode = se.LU
}).ToList();
//有结算有发运
var haveSaHaveSeList = (from sa in saGroupByVersion
from se in seGroup
where sa.PN == se.PN && sa.CustomerPartCodeNoSpace == se.CustomerPartCodeNoSpace
select new PubSaSeCompareDiff()
{
Version = sa.Version,
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = sa.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
ToLocCode = se.ToLocCode,
ToErpLocCode = se.ToErpLocCode,
SeCustomerPartCode = se.CustomerPartCodeNoSpace,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.CustomerPartCodeNoSpace,
SaFactoryPartCode = sa.PartCode,
CustomerPartCode = sa.LU
}).ToList();
return haveSaHaveSeList.Union(haveSaHaveSeList).Union(notHaveSaHaveSeList).ToList();
}
/// <summary>
/// 获取比对数据
/// </summary>
private List<PubSaSeCompareDiff> GetSaSeCompareDataYinDu(int version, DateTime seStartDateTime, DateTime seEndDateTime)
{ {
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == EnumBusinessType.YinDuJian && sa.Version == version where sa.BusinessType == EnumBusinessType.YinDuJian && sa.Version == version

4
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs

@ -198,12 +198,10 @@ namespace SettleAccount.Job.Services.Report
< 0 => EnumMappingType.None, < 0 => EnumMappingType.None,
_ => default, _ => default,
}; };
o.ExtraProperties.Add("MappingType", mappingType); o.MappingType = mappingType;
return o; return o;
}).ToList(); }).ToList();
_settleAccountDbContext.BulkUpdate(saDetailsUpdate); _settleAccountDbContext.BulkUpdate(saDetailsUpdate);
_settleAccountDbContext.Set<BBAC_SA_DETAIL>().FromSqlInterpolated($"SELECT * FROM dbo.Blogs");
_settleAccountDbContext.Database.ExecuteSqlInterpolated($"SELECT * FROM dbo.Blogs");
} }
} }
} }

Loading…
Cancel
Save