Browse Source

解决测试问题

master
mahao 1 year ago
parent
commit
8c1098fcca
  1. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs
  2. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs
  3. 45
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs
  4. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs
  5. 71
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs
  6. 1
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs
  7. 196
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  8. 2
      code/src/Shared/Win.Sfs.Shared/Filter/FilterExtensions.cs

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs

@ -40,7 +40,7 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
{
var seDetailGroup = db.Set<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU });
var ediDetailGroup = db.Set<BBAC_SE_EDI>().Where(t => t.IsDeleted == false && t.IsHaveSeData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU });
var keyCodes = seDetailGroup.Join(ediDetailGroup, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (se, edi) => new { se.PN, se.LU });
var keyCodes = seDetailGroup.Join(ediDetailGroup, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (se, edi) => new { se.PN, se.LU }).Take(10000).ToList();
if (keyCodes.Any())
{
var seDetails = db.Set<BBAC_SE_DETAIL>().Join(keyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a);

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs

@ -57,7 +57,7 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
{
var seDetailGroup = db.Set<HBPO_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU });
var ediDetailGroup = db.Set<HBPO_SE_EDI>().Where(t => t.IsDeleted == false && t.IsHaveSeData == false).GroupBy(t => new { t.PN, t.LU }).Select(t => new { t.Key.PN, t.Key.LU });
var keyCodes = seDetailGroup.Join(ediDetailGroup, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (se, edi) => new { se.PN, se.LU });
var keyCodes = seDetailGroup.Join(ediDetailGroup, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (se, edi) => new { se.PN, se.LU }).Take(10000).ToList();
if (keyCodes.Any())
{
var seDetails = db.Set<HBPO_SE_DETAIL>().Join(keyCodes, a => new { a.PN, a.LU }, b => new { b.PN, b.LU }, (a, b) => a);

45
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs

@ -1,13 +1,13 @@
using DocumentFormat.OpenXml.Spreadsheet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic.Core;
using System.Threading.Tasks;
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;
@ -15,7 +15,6 @@ 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.Entities.Prices;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.MaterialRelationships;
@ -61,37 +60,37 @@ public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase<TB_Re
public async Task<IActionResult> ImportAsync([FromForm] IFormFileCollection files)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<TB_RePartsRelationship_IMPORT_DTO>(files, _excelImportService);
var result = await _exportImporter.UploadExcelImport<TB_RePartsRelationship_IMPORT_DTO>(files, _excelImportService).ConfigureAwait(false);
var _ls = ObjectMapper.Map<List<TB_RePartsRelationship_IMPORT_DTO>, List<TB_RePartsRelationship>>(result);
List<string> _errorList = new List<string>();
var checkList = new List<ErrorExportDto>();
if (_ls.Count > 0)
{
//导入的替换零件号
var tbRePartsRelationshipLus = _ls.Select(t => t.LU);
var haveLu = (await _materialRelationshipRepository.GetListAsync(t => tbRePartsRelationshipLus.Contains(t.SettleMaterialCode) == false)).Select(t => t.SettleMaterialCode);
//导入不存在的零件号
var exceptLus = tbRePartsRelationshipLus.Except(haveLu).ToList();
//导入文件中的厂内零件号
var tbRePartsRelationshipLus = _ls.Select(t => new { lu = new List<string> { t.LU, t.RepLU } }).SelectMany(t => t.lu).Distinct();
var haveLus = _materialRelationshipRepository.Where(t => tbRePartsRelationshipLus.Contains(t.ErpMaterialCode)).Select(t => t.ErpMaterialCode).Distinct().ToList();
//导入不存在的厂内零件号
var exceptLus = tbRePartsRelationshipLus.Except(haveLus);
exceptLus.ForEach(exceptLu =>
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("客户物料号{0}不存在,无法替换", exceptLu), string.Empty));
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("厂内零件号{0}不存在", exceptLu), string.Empty));
});
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));
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("厂内零件号{0}有重复", itm.Key.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 });
}
foreach (var itm in _ls)
@ -100,11 +99,11 @@ public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase<TB_Re
if (_first != null)
{
_first.Update(itm.LU, itm.RepLU, itm.ClientCode, itm.BusinessType);
await _repository.UpdateAsync(_first);
await _repository.UpdateAsync(_first).ConfigureAwait(false);
}
else
{
await _repository.InsertAsync(itm);
await _repository.InsertAsync(itm).ConfigureAwait(false);
}
}
return new JsonResult(new { Code = 200, Message = "导入成功" });
@ -117,14 +116,14 @@ public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase<TB_Re
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 entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<TB_RePartsRelationship>, List<TB_RePartsRelationship_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
@ -136,8 +135,8 @@ public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase<TB_Re
[HttpPost]
public async Task<PagedResultDto<TB_RePartsRelationship_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 entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<TB_RePartsRelationship>, List<TB_RePartsRelationship_DTO>>(entities);
return new PagedResultDto<TB_RePartsRelationship_DTO>(totalCount, dtos);
}

6
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs

@ -101,14 +101,14 @@ public class MaterialRelationshipAppService : SettleAccountApplicationBase<Mater
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 entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true).ConfigureAwait(false);
var dtos = ObjectMapper.Map<List<MaterialRelationship>, List<MaterialRelationshipExportDto>>(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

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

@ -47,16 +47,6 @@ public class PubSaSeCompareDiff
[Display(Name = "发货数量")]
public decimal SEQty { get; set; }
/// <summary>
/// 差异数量
/// </summary>
[Display(Name = "差异数量")]
public decimal DiffQty => SAQty - SEQty;
/// <summary>
/// 匹配类型
/// </summary>
[Display(Name = "匹配类型")]
public string MateType { get; set; }
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
@ -121,6 +111,10 @@ public class PubSaSeCompareDiff
/// 是否已经移除
/// </summary>
public bool IsRemove { get; set; }
/// <summary>
/// 是否替换了厂内零件号
/// </summary>
public bool IsReplace { get; set; }
}
/// <summary>
@ -207,55 +201,49 @@ public class PubSaSeCompareDetailExport2
[Display(Name = "结算数量")]
[ExporterHeader(DisplayName = "结算数量")]
public decimal SAQty { get; set; }
/// <summary>
/// 发货数量
/// </summary>
[Display(Name = "发货数量")]
[ExporterHeader(DisplayName = "WMS发货数量")]
public decimal SEQty { get; set; }
/// <summary>
/// 差异数量
/// </summary>
[ExporterHeader(DisplayName = "差异数量")]
public decimal DiffQty { set; get; }
/// <summary>
/// 匹配类型
/// </summary>
[Display(Name = "匹配类型")]
[ExporterHeader(DisplayName = "是否完全匹配")]
public string MateType { get; set; }
[ValueMapping("是", true)]
[ValueMapping("否", false)]
public bool MateType => DiffQty == 0;
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
[ExporterHeader(DisplayName = "定价")]
public decimal FixPrice { get; set; }
/// <summary>
/// 日顺序号
/// </summary>
[Display(Name = "日顺序号")]
[ExporterHeader(DisplayName = "日顺序号")]
public string SeqNumber { get; set; }
/// <summary>
/// PJIS日顺序号
/// </summary>
[Display(Name = "PJIS日顺序号")]
[ExporterHeader(DisplayName = "PJIS日顺序号")]
public string PJISSeqNumber { get; set; }
/// <summary>
/// WMS目标库位
/// </summary>
[Display(Name = "WMS目标库位")]
[ExporterHeader(DisplayName = "WMS目标库位")]
public string ToLocCode { get; set; }
/// <summary>
/// ERP目标库位
/// </summary>
@ -432,34 +420,31 @@ public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExp
[Display(Name = "发货数量")]
[ExporterHeader(DisplayName = "WMS发货数量")]
public decimal SEQty { get; set; }
/// <summary>
/// 差异数量
/// </summary>
[ExporterHeader(DisplayName = "差异数量")]
public decimal DiffQty => SAQty - SEQty;
/// <summary>
/// 匹配类型
/// </summary>
[Display(Name = "匹配类型")]
[ExporterHeader(DisplayName = "是否完全匹配")]
public string MateType { get; set; }
[ValueMapping("是", true)]
[ValueMapping("否", false)]
public bool MateType => DiffQty == 0;
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
[ExporterHeader(DisplayName = "定价")]
public decimal FixPrice { get; set; }
/// <summary>
/// WMS目标库位
/// </summary>
[Display(Name = "WMS目标库位")]
[ExporterHeader(DisplayName = "WMS目标库位")]
public string ToLocCode { get; set; }
/// <summary>
/// ERP目标库位
/// </summary>
@ -486,14 +471,12 @@ public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExp
[ValueMapping("有结算无发运", 2)]
[ValueMapping("无结算有发运", 3)]
public EnumPubSaSeCompareCategory Category { get; set; }
/// <summary>
/// Wms发货单号
/// </summary>
[Display(Name = "Wms发货单号")]
[ExporterHeader(DisplayName = "交货单号")]
public string WmsBillNum { get; set; }
/// <summary>
/// 发货日期
/// </summary>
@ -537,48 +520,43 @@ public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExp
[Display(Name = "客户下线时间")]
[ExporterHeader(DisplayName = "客户下线时间")]
public DateTime CustomerOfflineTime { get; set; }
/// <summary>
/// 结算数量
/// </summary>
[Display(Name = "结算数量")]
[ExporterHeader(DisplayName = "结算数量")]
public decimal SAQty { get; set; }
/// <summary>
/// 发货数量
/// </summary>
[Display(Name = "发货数量")]
[ExporterHeader(DisplayName = "WMS发货数量")]
public decimal SEQty { get; set; }
/// <summary>
/// 差异数量
/// </summary>
[ExporterHeader(DisplayName = "差异数量")]
public decimal DiffQty => SAQty - SEQty;
/// <summary>
/// 匹配类型
/// </summary>
[Display(Name = "匹配类型")]
[ExporterHeader(DisplayName = "是否完全匹配")]
public string MateType { get; set; }
[ValueMapping("是", true)]
[ValueMapping("否", false)]
public bool MateType => DiffQty == 0;
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
[ExporterHeader(DisplayName = "定价")]
public decimal FixPrice { get; set; }
/// <summary>
/// WMS目标库位
/// </summary>
[Display(Name = "WMS目标库位")]
[ExporterHeader(DisplayName = "WMS目标库位")]
public string ToLocCode { get; set; }
/// <summary>
/// ERP目标库位
/// </summary>
@ -670,34 +648,31 @@ public class PubSaSeCompareDetailExportMaiDanJianHBPO : PubSaSeCompareDetailExpo
[Display(Name = "发货数量")]
[ExporterHeader(DisplayName = "WMS发货数量")]
public decimal SEQty { get; set; }
/// <summary>
/// 差异数量
/// </summary>
[ExporterHeader(DisplayName = "差异数量")]
public decimal DiffQty => SAQty - SEQty;
/// <summary>
/// 匹配类型
/// </summary>
[Display(Name = "匹配类型")]
[ExporterHeader(DisplayName = "是否完全匹配")]
public string MateType { get; set; }
[ValueMapping("是", true)]
[ValueMapping("否", false)]
public bool MateType => DiffQty == 0;
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
[ExporterHeader(DisplayName = "定价")]
public decimal FixPrice { get; set; }
/// <summary>
/// WMS目标库位
/// </summary>
[Display(Name = "WMS目标库位")]
[ExporterHeader(DisplayName = "WMS目标库位")]
public string ToLocCode { get; set; }
/// <summary>
/// ERP目标库位
/// </summary>
@ -782,41 +757,37 @@ public class PubSaSeCompareDetailExportBeiJian : PubSaSeCompareDetailExport, IPu
[Display(Name = "结算数量")]
[ExporterHeader(DisplayName = "结算数量")]
public decimal SAQty { get; set; }
/// <summary>
/// 发货数量
/// </summary>
[Display(Name = "发货数量")]
[ExporterHeader(DisplayName = "WMS发货数量")]
public decimal SEQty { get; set; }
/// <summary>
/// 差异数量
/// </summary>
[ExporterHeader(DisplayName = "差异数量")]
public decimal DiffQty => SAQty - SEQty;
/// <summary>
/// 匹配类型
/// </summary>
[Display(Name = "匹配类型")]
[ExporterHeader(DisplayName = "是否完全匹配")]
public string MateType { get; set; }
[ValueMapping("是", true)]
[ValueMapping("否", false)]
public bool MateType => DiffQty == 0;
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
[ExporterHeader(DisplayName = "定价")]
public decimal FixPrice { get; set; }
/// <summary>
/// WMS目标库位
/// </summary>
[Display(Name = "WMS目标库位")]
[ExporterHeader(DisplayName = "WMS目标库位")]
public string ToLocCode { get; set; }
/// <summary>
/// ERP目标库位
/// </summary>
@ -916,7 +887,9 @@ public class PubSaSeCompareDetailExportYinDuJian : PubSaSeCompareDetailExport, I
/// </summary>
[Display(Name = "匹配类型")]
[ExporterHeader(DisplayName = "是否完全匹配")]
public string MateType { get; set; }
[ValueMapping("是", true)]
[ValueMapping("否", false)]
public bool MateType => DiffQty == 0;
/// <summary>
/// 定价
/// </summary>

1
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs

@ -45,7 +45,6 @@ public class PubSaSeCompareDapperRepository : DapperRepository<SettleAccountDbCo
ISNULL(A.PN,B.PN) PN,
A.SEQty,
B.SAQty,
(B.SAQty-A.SEQty) DiffQty,
B.Price FixPrice,
A.ToLocCode,
A.ToErpLocCode

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

@ -32,7 +32,10 @@ namespace SettleAccount.Job.Services.Report
/// HubContext
/// </summary>
private readonly IHubContext<PageHub> _hubContext;
/// <summary>
/// DbContext
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
/// <summary>
/// 替换件关系仓储
/// </summary>
@ -63,6 +66,7 @@ namespace SettleAccount.Job.Services.Report
/// </summary>
public PubSaSeCompareExportService(
IHubContext<PageHub> hubContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository,
INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSeCDetailRepository,
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository,
@ -70,6 +74,7 @@ namespace SettleAccount.Job.Services.Report
IObjectMapper objectMapper)
{
_hubContext = hubContext;
_settleAccountDbContext = settleAccountDbContext;
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository;
_pubSeCDetailRepository = pubSeCDetailRepository;
_pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository;
@ -104,7 +109,8 @@ namespace SettleAccount.Job.Services.Report
businessTypeDisplayName = attributeOfType.Name;
}
var filename = exportName.FirstOrDefault();
var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(strBusinessType, version, seStartDateTime, seEndDateTime);
//var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(strBusinessType, version, seStartDateTime, seEndDateTime);
var pubSaSeCompareDiffs = GetSaSeCompareData(businessType, int.Parse(version), DateTime.Parse(seStartDateTime), DateTime.Parse(seEndDateTime));
pubSaSeCompareDiffs.ForEach(p =>
{
@ -155,30 +161,77 @@ namespace SettleAccount.Job.Services.Report
var secondMatchHaveSaHaveSes = new List<PubSaSeCompareDiff>();
#region 二次对比
////二次对比(替换零件号)
//var repLUs = notHaveSaHaveSes.Select(t => t.SeLU).Distinct().ToList();
//var tbRePartsRelationships = _tbRePartsRelationshipRepository.GetListAsync(t => repLUs.Contains(t.RepLU) && t.BusinessType == businessType).Result;
//二次对比(替换无结算有发运数据的厂内零件号)
var repFactoryPartCodes = notHaveSaHaveSes.Select(t => t.FactoryPartCode).Distinct().ToList();
//tbRePartsRelationships.ForEach(tbRePartsRelationship =>
//{
// notHaveSaHaveSes.FindAll(t => t.SeLU == tbRePartsRelationship.RepLU).ForEach(t =>
// {
// t.ReplaceLU = tbRePartsRelationship.LU;
// });
//});
var tbRePartsRelationships = _settleAccountDbContext.Set<TB_RePartsRelationship>().Where(t => repFactoryPartCodes.Contains(t.LU) && t.BusinessType == businessType).ToList();
//var tbRePartsRelationshipsOld = _tbRePartsRelationshipRepository.GetListAsync(t => repFactoryPartCodes.Contains(t.LU) && t.BusinessType == businessType).Result;
tbRePartsRelationships.ForEach(tbRePartsRelationship =>
{
notHaveSaHaveSes.FindAll(t => t.FactoryPartCode == tbRePartsRelationship.LU).ForEach(t =>
{
t.ReplaceFactoryPartCode = tbRePartsRelationship.RepLU;
t.IsReplace = true;
});
});
//var haveSaNotHaveSeLUPNs = haveSaNotHaveSes.Select(t => new { t.ReplaceLU, t.PN });
//var notHaveSaHaveSeLUPNs = notHaveSaHaveSes.Select(t => new { t.ReplaceLU, t.PN });
////二次匹配 匹配上的零件号
//var secondMatchLUPNs = haveSaNotHaveSeLUPNs.Intersect(notHaveSaHaveSeLUPNs);
//if (secondMatchLUPNs.Any() == true)
//获取二次比对上的数据
secondMatchHaveSaHaveSes = (from notHaveSaHaveSe in notHaveSaHaveSes
join haveSaNotHaveSe in haveSaNotHaveSes
on new { notHaveSaHaveSe.PN, notHaveSaHaveSe.ReplaceFactoryPartCode } equals new { haveSaNotHaveSe.PN, haveSaNotHaveSe.ReplaceFactoryPartCode }
where notHaveSaHaveSe.IsReplace == true
select new PubSaSeCompareDiff()
{
WmsBillNum = notHaveSaHaveSe.WmsBillNum,
ShippingDate = notHaveSaHaveSe.ShippingDate,
SeqNumber = notHaveSaHaveSe.SeqNumber,
PJISSeqNumber = notHaveSaHaveSe.PJISSeqNumber,
CustomerOfflineTime = haveSaNotHaveSe.CustomerOfflineTime,
SAQty = haveSaNotHaveSe.SAQty,
SEQty = notHaveSaHaveSe.SEQty,
FixPrice = haveSaNotHaveSe.FixPrice,
PN = haveSaNotHaveSe.PN,
ToLocCode = notHaveSaHaveSe.ToLocCode,
ToErpLocCode = notHaveSaHaveSe.ToErpLocCode,
Category = EnumPubSaSeCompareCategory.HaveSaHaveSe,
SeCustomerPartCode = notHaveSaHaveSe.SeCustomerPartCode,
SeFactoryPartCode = notHaveSaHaveSe.SeFactoryPartCode,
SaCustomerPartCode = haveSaNotHaveSe.SaCustomerPartCode,
SaFactoryPartCode = haveSaNotHaveSe.SaFactoryPartCode,
CustomerPartCode = notHaveSaHaveSe.CustomerPartCode,
PartCodeDesc = notHaveSaHaveSe.PartCodeDesc,
FactoryPartCode = notHaveSaHaveSe.FactoryPartCode,
ReplaceFactoryPartCode = notHaveSaHaveSe.ReplaceFactoryPartCode
}).ToList();
if (secondMatchHaveSaHaveSes.Any())
{
//二次匹配 匹配上的厂内零件号、PN
var secondMatchFPartCodePNs = secondMatchHaveSaHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
pubSaSeCompareDiffs.RemoveAll<PubSaSeCompareDiff>(t => secondMatchFPartCodePNs.Contains(new { t.ReplaceFactoryPartCode, t.PN }));
pubSaSeCompareDiffs.AddRange(secondMatchHaveSaHaveSes);
//二次对比比对上的数据入库
var pubSeCDetailEntitys = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PUB_SEC_DETAIL>>(secondMatchHaveSaHaveSes);
_settleAccountDbContext.Set<PUB_SEC_DETAIL>().AddRange(pubSeCDetailEntitys);
//_pubSeCDetailRepository.InsertManyAsync(pubSeCDetailEntitys);
}
//var haveSaNotHaveSeFPartCodePNs = haveSaNotHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
//var notHaveSaHaveSeFPartCodePNs = notHaveSaHaveSes.Select(t => new { t.ReplaceFactoryPartCode, t.PN });
////二次匹配 匹配上的厂内零件号、PN
//var secondMatchFPartCodePNs = haveSaNotHaveSeFPartCodePNs.Intersect(notHaveSaHaveSeFPartCodePNs);
//if (secondMatchFPartCodePNs.Any() == true)
//{
// pubSaSeCompareDiffs.RemoveAll<PubSaSeCompareDiff>(t => secondMatchLUPNs.Contains(new { t.ReplaceLU, t.PN }));
// pubSaSeCompareDiffs.RemoveAll<PubSaSeCompareDiff>(t => secondMatchFPartCodePNs.Contains(new { t.ReplaceFactoryPartCode, t.PN }));
// foreach (var secondMatchLUPN in secondMatchLUPNs)
// foreach (var secondMatchFPartCodePN in secondMatchFPartCodePNs)
// {
// var haveSaNotHaveSe = haveSaNotHaveSes.FirstOrDefault(t => t.ReplaceLU == secondMatchLUPN.ReplaceLU && t.PN == secondMatchLUPN.PN);
// var notHaveSaHaveSe = notHaveSaHaveSes.FirstOrDefault(t => t.ReplaceLU == secondMatchLUPN.ReplaceLU && t.PN == secondMatchLUPN.PN);
// var haveSaNotHaveSe = haveSaNotHaveSes.FirstOrDefault(t => t.ReplaceFactoryPartCode == secondMatchFPartCodePN.ReplaceFactoryPartCode && t.PN == secondMatchFPartCodePN.PN);
// var notHaveSaHaveSe = notHaveSaHaveSes.FirstOrDefault(t => t.ReplaceFactoryPartCode == secondMatchFPartCodePN.ReplaceFactoryPartCode && t.PN == secondMatchFPartCodePN.PN);
// if (haveSaNotHaveSe != null && notHaveSaHaveSe != null)
// {
// }
// secondMatchHaveSaHaveSes.Add(new PubSaSeCompareDiff()
// {
// WmsBillNum = notHaveSaHaveSe.WmsBillNum,
@ -202,15 +255,6 @@ namespace SettleAccount.Job.Services.Report
// });
// }
//}
////二次对比比对上的数据入库
//if (secondMatchHaveSaHaveSes.Count > 0)
//{
// pubSaSeCompareDiffs.AddRange(secondMatchHaveSaHaveSes);
// var pubSeCDetailEntitys = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PUB_SEC_DETAIL>>(secondMatchHaveSaHaveSes);
// _pubSeCDetailRepository.InsertManyAsync(pubSeCDetailEntitys);
//}
#endregion
if (string.IsNullOrEmpty(lu) == false)
@ -221,6 +265,7 @@ namespace SettleAccount.Job.Services.Report
{
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.PN == pn);
}
pubSaSeCompareDiffs = pubSaSeCompareDiffs.OrderBy(t => t.Category).ToList();
var excelExporter = new ExcelExporter();
#region 根据业务分类转换不同导出Dto
@ -272,6 +317,94 @@ namespace SettleAccount.Job.Services.Report
}
#region 私有方法
/// <summary>
/// 获取结算与发运比对数据
/// </summary>
public List<PubSaSeCompareDiff> GetSaSeCompareData(EnumBusinessType businessType, int version, DateTime seStartDateTime, DateTime seEndDateTime)
{
//结算
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
group sa by new { sa.PN, sa.LU } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty),
Price = groupItem.Max(t => t.Price),
SettleDate = groupItem.Max(t => t.SettleDate),
PartCode = groupItem.Max(t => t.PartCode),
};
//发运
var seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>()
where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
group se by new { se.PN, se.LU } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty),
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)
};
//印度件LU对比
if (businessType == EnumBusinessType.YinDuJian)
{
saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
group sa by new { sa.LU } into groupItem
select new
{
PN = "",
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty),
Price = groupItem.Max(t => t.Price),
SettleDate = groupItem.Max(t => t.SettleDate),
PartCode = groupItem.Max(t => t.PartCode),
};
seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>()
where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
group se by new { se.LU } into groupItem
select new
{
PN = "",
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty),
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 saSeCompareList = (from sa in saGroup
join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
select new PubSaSeCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
ToLocCode = se.ToLocCode,
ToErpLocCode = se.ToErpLocCode,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
}).ToList();
return saSeCompareList;
}
/// <summary>
/// 创建导出文件结构
/// </summary>
public ExcelExporter BindExcelExporter<T>(List<T> pubSaSeCompareDetailExports, string businessTypeDisplayName) where T : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport, new()
{
//结算核对汇总
@ -328,8 +461,7 @@ namespace SettleAccount.Job.Services.Report
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出")
.SeparateBySheet()
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出")
.SeparateBySheet();
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出");
}
private void Notify()

2
code/src/Shared/Win.Sfs.Shared/Filter/FilterExtensions.cs

@ -40,7 +40,7 @@ namespace Win.Sfs.Shared.Filter
{
if (!typeof(T).GetProperties().Any(o => o.Name.ToLowerInvariant() == filterCondition.Column.ToLowerInvariant()))
{
break;
continue;
}
var tempCondition = CreateLambda<T>(filterCondition);
if (condition == null)

Loading…
Cancel
Save