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>
[Display(Name = "期间")]
public int Version { get; set; }
/// <summary>
/// 地点
/// </summary>
[Display(Name = "地点")]
public string Site { get; set; }
}
/// <summary>

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

@ -65,42 +65,36 @@ public class PriceListExportDto
[Display(Name = "零件号")]
[ExporterHeader(DisplayName = "客户零件号")]
public string LU { get; set; }
/// <summary>
/// 价格
/// </summary>
[Display(Name = "价格")]
[ExporterHeader(DisplayName = "价格")]
public Decimal Price { set; get; }
/// <summary>
/// 开始时间
/// </summary>
[Display(Name = "开始时间")]
[ExporterHeader(DisplayName = "开始时间")]
public DateTime BeginTime { set; get; }
/// <summary>
/// 结束时间
/// </summary>
[Display(Name = "结束时间")]
[ExporterHeader(DisplayName = "结束时间")]
public DateTime EndTime { set; get; }
/// <summary>
/// 客户编码
/// </summary>
[Display(Name = "客户编码")]
[ExporterHeader(DisplayName = "客户编码")]
public string ClientCode { get; set; }
/// <summary>
/// 合同签订时间
/// </summary>
[Display(Name = "合同签订时间")]
[ExporterHeader(DisplayName = "合同签订时间")]
public DateTime Date { get; set; }
/// <summary>
/// 合同号
/// </summary>
@ -112,8 +106,7 @@ public class PriceListExportDto
/// <summary>
/// 销售价格导入
/// </summary>
[ImportProject(Name = SettleAccountModuleName.PriceList)]
[Importer(HeaderRowIndex = 21)]
[Importer(HeaderRowIndex = 22)]
public class PriceListImportDto
{
/// <summary>
@ -138,7 +131,7 @@ public class PriceListImportDto
/// <summary>
/// 价格
/// </summary>
[ImporterHeader(Name = "Total Price (Old)")]
[ImporterHeader(Name = "Total Price")]
public decimal TotalPrice { get; set; }
/// <summary>
/// 开始时间
@ -297,56 +290,58 @@ public class PriceListBJExportDto
/// <summary>
/// 客户备件价格导入
/// </summary>
[Importer(HeaderRowIndex = 22)]
public class PriceListBJImportDto
{
/// <summary>
/// 客户零件号
/// 合同签订时间
/// </summary>
[Display(Name = "客户零件号")]
[ImporterHeader(Name = "客户零件号")]
public string LU { get; set; }
[ImporterHeader(IsIgnore = true)]
[ExcelImporterHeadDesc(Row = 1, Cell = 1)]
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>
[Display(Name = "价格")]
[ImporterHeader(Name = "价格")]
public decimal Price { get; set; }
[ImporterHeader(Name = "Total Price")]
public decimal TotalPrice { get; set; }
/// <summary>
/// 开始时间
/// </summary>
[Display(Name = "开始时间")]
[ImporterHeader(Name = "开始时间")]
public DateTime BeginDate { set; get; }
[ImporterHeader(Name = "Valid From")]
public DateTime ValidFrom { get; set; }
/// <summary>
/// 结束时间
/// </summary>
[Display(Name = "结束时间")]
[ImporterHeader(Name = "结束时间")]
public DateTime EndDate { set; get; }
[ImporterHeader(Name = "Valid To")]
public DateTime ValidTo { get; set; }
/// <summary>
/// 客户编码
/// </summary>
[Display(Name = "客户编码")]
[ImporterHeader(Name = "客户编码")]
public string ClientCode { get; set; }
[ImporterHeader(Name = "Plant")]
public string Plant { get; set; }
/// <summary>
/// 合同签订时间
/// ES1
/// </summary>
[Display(Name = "合同签订时间")]
[ImporterHeader(Name = "合同签订时间")]
public DateTime Date { get; set; }
[ImporterHeader(Name = "ES1")]
public string ES1 { get; set; }
/// <summary>
/// 合同号
/// ES2
/// </summary>
[Display(Name = "合同号")]
[ImporterHeader(Name = "合同号")]
public string ContractNo { get; set; }
[ImporterHeader(Name = "ES2")]
public string ES2 { get; set; }
}
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]")]
public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
{
/// <summary>
/// DbContext
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
/// <summary>
/// BBAC结算仓储
/// </summary>
@ -79,7 +83,8 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
/// <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_CAN_SA, Guid> bbacCanSaRepository,
INormalEfCoreRepository<BBAC_CAN_SA_DETAIL, Guid> bbacCanSaDetailRepository,
@ -93,6 +98,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_settleAccountDbContext = settleAccountDbContext;
_bbacSaRepository = bbacSaRepository;
_bbacSaDetailRepository = bbacSaDetailRepository;
_bbacCanSaRepository = bbacCanSaRepository;
@ -400,7 +406,8 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
//导入的零件号集合
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);
bbacSaDetails.ForEach(bbacSaDetail =>
{
@ -507,5 +514,18 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
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
}

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 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);
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结算仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_SA, Guid> _repository;
/// <summary>
/// PUB结算明细仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_SA_DETAIL, Guid> _pubSaDetailRepository;
/// <summary>
/// PUB可结算仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_CAN_SA, Guid> _pubCanSaRepository;
/// <summary>
/// PUB可结算明细仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> _pubCanSaDetailRepository;
/// <summary>
/// PUB不可结算明细仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> _pubNotSaDetailRepository;
/// <summary>
/// 销售价格仓储
/// </summary>
private readonly INormalEfCoreRepository<PriceList, Guid> _priceListRepository;
/// <summary>
/// 备件价格仓储
/// </summary>
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _priceBjListRepository;
/// <summary>
/// 客户零件关系仓储
/// </summary>
private readonly INormalEfCoreRepository<MaterialRelationship, Guid> _materialRelationshipRepository;
/// <summary>
/// 替换件关系仓储
/// </summary>
@ -113,6 +105,14 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
/// 期间
/// </summary>
private int _version;
/// <summary>
/// 业务类别
/// </summary>
private EnumBusinessType businessType;
/// <summary>
/// 地点
/// </summary>
private string site;
#region 导入、导出
/// <summary>
@ -123,6 +123,8 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
{
IActionResult result = new JsonResult(new { Code = 400 });
_version = pubSaImportRequestDto.Version;
businessType = pubSaImportRequestDto.BusinessType;
site = pubSaImportRequestDto.Site;
switch (pubSaImportRequestDto.BusinessType)
{
case EnumBusinessType.ZhiGongJianBBAC:
@ -440,10 +442,21 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
importPubSaDetail.BusinessType = businessType;
});
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)
{
//备件销售价格
var priceListEntitys = _priceBjListRepository.Where(t => t.IsCancel == false)
.Where(t => t.ClientCode == clientCode)
.Where(t => lus.Contains(t.LU)).ToList();
pubSaDetails.ForEach(importPubSaDetail =>
{
@ -461,6 +474,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
{
//销售价格
var priceListEntitys = _priceListRepository.Where(t => t.IsCancel == false)
.Where(t => t.ClientCode == clientCode)
.Where(t => lus.Contains(t.LU)).ToList();
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.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;
@ -29,7 +30,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices;
public class PriceListAppService : SettleAccountApplicationBase<PriceList>
{
/// <summary>
/// 数据上下文
/// DbContext
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
/// <summary>
@ -78,8 +79,29 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
};
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);
var entityList = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result);
var newPrice = entityList.GroupBy(p => p.LU).Select(p => p.FirstOrDefault()).ToList();
var newPrice = ObjectMapper.Map<List<PriceListImportDto>, List<PriceList>>(result);
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 oldPrices = _settleAccountDbContext.Set<PriceList>()
@ -87,14 +109,14 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
.Where(t => importLus.Contains(t.LU))
.ToList();
//系统中合同日期比导入文件中的合同日期晚
var oldpriceNewDate = from oldprice in oldPrices
var oldPriceNewDate = from oldprice in oldPrices
from newprice in newPrice
where oldprice.LU == newprice.LU && oldprice.Date > newprice.Date
select oldprice;
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();
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.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;
@ -57,13 +58,33 @@ public class PriceListAppServiceBJ : SettleAccountApplicationBase<PriceListBJ>
var result = await _exportImporter.UploadExcelImportByHeadDesc<PriceListBJImportDto>(files, _excelImportService).ConfigureAwait(false);
var filter = new List<string>
{
"1040",
"1046",
"104T"
"1040"
};
result = result.Where(p => filter.Contains(p.ClientCode)).ToList();
var entityList = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result);
var newPrice = entityList.GroupBy(p => p.LU).Select(p => p.FirstOrDefault()).ToList();
result = result.Where(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);
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 oldPrices = _settleAccountDbContext.Set<PriceListBJ>()
@ -71,14 +92,14 @@ public class PriceListAppServiceBJ : SettleAccountApplicationBase<PriceListBJ>
.Where(t => importLus.Contains(t.LU))
.ToList();
//系统中合同日期比导入文件中的合同日期晚
var oldpriceNewDate = from oldprice in oldPrices
var oldPriceNewDate = from oldprice in oldPrices
from newprice in newPrice
where oldprice.LU == newprice.LU && oldprice.Date > newprice.Date
select oldprice;
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();
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>
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, PriceListBJRequestDto>().ReverseMap();

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

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

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

@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Drawing;
using System.Linq;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR;
using Microsoft.OpenApi.Extensions;
using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR;
using ShardingCore.Extensions;
using Shouldly;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
@ -178,7 +180,8 @@ namespace SettleAccount.Job.Services.Report
/// <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对比
if (businessType == EnumBusinessType.YinDuJian)
@ -264,7 +267,122 @@ namespace SettleAccount.Job.Services.Report
/// <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>()
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,
_ => default,
};
o.ExtraProperties.Add("MappingType", mappingType);
o.MappingType = mappingType;
return o;
}).ToList();
_settleAccountDbContext.BulkUpdate(saDetailsUpdate);
_settleAccountDbContext.Set<BBAC_SA_DETAIL>().FromSqlInterpolated($"SELECT * FROM dbo.Blogs");
_settleAccountDbContext.Database.ExecuteSqlInterpolated($"SELECT * FROM dbo.Blogs");
}
}
}

Loading…
Cancel
Save