Browse Source

修改对比

master
mahao 1 year ago
parent
commit
febaa64623
  1. 25
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeEdiCompareAppService.cs
  2. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeEdiCompareAppService.cs
  3. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs
  4. 216
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs
  5. 93
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs
  6. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs
  7. 97
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs
  8. 12
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs
  9. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs

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

@ -69,31 +69,6 @@ public class JisBBACSeEdiCompareAppService : ApplicationService, IInvocable
db.BulkUpdate<BBAC_SE_EDI>(ediDetails);
}
db.SaveChanges();
//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(1000).ToList();
//if (keyCodes.Any())
//{
// var pnLus = keyCodes.GroupBy(t => t.PN).Select(t => new { t.Key, Lus = t.Where(p => p.PN == t.Key).Select(t => t.LU) });
// pnLus.ForEach(pnLu =>
// {
// var pn = pnLu.Key;
// var lus = pnLu.Lus;
// var seDetails = db.Set<BBAC_SE_DETAIL>().Where(t => t.PN == pn && lus.Contains(t.CustomerPartCodeNoSpace));
// var ediDetails = db.Set<BBAC_SE_EDI>().Where(t => t.PN == pn && lus.Contains(t.LU));
// if (seDetails.Any())
// {
// seDetails.ForEach(t => t.IsHaveEdiData = true);
// db.Set<BBAC_SE_DETAIL>().UpdateRange(seDetails);
// }
// if (ediDetails.Any())
// {
// ediDetails.ForEach(t => t.IsHaveSeData = true);
// db.Set<BBAC_SE_EDI>().UpdateRange(ediDetails);
// }
// });
// db.SaveChanges();
//}
}
}
catch (Exception)

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

@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using SettleAccount.Domain.BQ;
using Volo.Abp.Application.Services;
using Volo.Abp.Uow;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs;
@ -28,19 +29,25 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
/// HBPO发运数据仓储
/// </summary>
private readonly INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> _hbpoSeDetailRepository;
/// <summary>
/// HBPOEDI数据仓储
/// </summary>
private readonly INormalEfCoreRepository<HBPO_SE_EDI, Guid> _hbpoSeEdiRepository;
/// <summary>
/// UnitOfWork
/// </summary>
private readonly IUnitOfWorkManager _unitOfWorkManager;
public JisHBPOSeEdiCompareAppService(
IServiceProvider serviceProvider,
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> hbpoSeDetailRepository, INormalEfCoreRepository<HBPO_SE_EDI, Guid> hbpoSeEdiRepository)
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> hbpoSeDetailRepository,
INormalEfCoreRepository<HBPO_SE_EDI, Guid> hbpoSeEdiRepository,
IUnitOfWorkManager unitOfWorkManager)
{
_serviceProvider = serviceProvider;
_hbpoSeDetailRepository = hbpoSeDetailRepository;
_hbpoSeEdiRepository = hbpoSeEdiRepository;
_unitOfWorkManager = unitOfWorkManager;
}
/// <summary>
@ -54,7 +61,8 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
var db = serviceScope.ServiceProvider.GetRequiredService<SettleAccountDbContext>();
await HandDelEdiDataAsync().ConfigureAwait(false);
lock (_lockObj)
using (var uow = _unitOfWorkManager.Begin(requiresNew: true, isTransactional: false))
{
var seDetailGroup = db.Set<HBPO_SE_DETAIL>().Where(t => t.IsHaveEdiData == false).GroupBy(t => new { t.PN, t.CustomerPartCodeNoSpace }).Select(t => new { t.Key.PN, LU = t.Key.CustomerPartCodeNoSpace });
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 });
@ -74,7 +82,6 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
var seDetails = seDetailsQuery.Take(5000).ToList();
var ediDetails = ediDetailsQuery.Take(5000).ToList();
if (seDetails.Any())
{
seDetails.ForEach(t => t.IsHaveEdiData = true);
@ -85,7 +92,8 @@ public class JisHBPOSeEdiCompareAppService : ApplicationService, IInvocable
ediDetails.ForEach(t => t.IsHaveSeData = true);
db.BulkUpdate<HBPO_SE_EDI>(ediDetails);
}
db.SaveChanges();
await uow.SaveChangesAsync().ConfigureAwait(false);
//db.SaveChanges();
}
}
catch (Exception)

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

@ -126,7 +126,7 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
t.Version = int.Parse(t.BillTime?.ToString("YYYYMM"));
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
await _settleAccountDbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);

216
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/SaSeEdiCompareDiff.cs

@ -42,6 +42,16 @@ public class SaSeEdiCompareDiff
[Display(Name = "客户下线时间")]
public DateTime? CustomerOfflineTime { get; set; }
/// <summary>
/// 小总成号
/// </summary>
[Display(Name = "小总成号")]
public string AssemblyCode { get; set; }
/// <summary>
/// 注塑码
/// </summary>
[Display(Name = "注塑码")]
public string InjectionCode { get; set; }
/// <summary>
/// 结算数量
/// </summary>
[Display(Name = "结算数量")]
@ -198,18 +208,78 @@ public class SaSeEdiCompareDetailExportJisBBAC : SaSeEdiCompareDetailExport, ISa
[ValueMapping("无结算有发运(无EDI数据)", 6)]
public EnumSaSeEdiCompareCategory Category { get; set; }
/// <summary>
/// 零件描述
/// 交货单号
/// </summary>
[Display(Name = "零件描述")]
[Display(Name = "交货单号")]
[ExporterHeader(DisplayName = "交货单号")]
public string WmsBillNum { get; set; }
/// <summary>
/// 发货日期
/// </summary>
[Display(Name = "发货日期")]
[ExporterHeader(DisplayName = "发货日期")]
public DateTime? ShippingDate { get; set; }
/// <summary>
/// 生产码
/// </summary>
[Display(Name = "生产码")]
[ExporterHeader(DisplayName = "订单生产码")]
public string PN { 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>
/// 客户物料号
/// </summary>
[Display(Name = "客户物料号")]
[ExporterHeader(DisplayName = "客户物料号")]
public string CustomerPartCode { get; set; }
/// <summary>
/// 物料描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 替换厂内零件号
/// 厂内物料
/// </summary>
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
[Display(Name = "厂内物料号")]
[ExporterHeader(DisplayName = "厂内物料号")]
public string FactoryPartCode { get; set; }
/// <summary>
/// 替换厂内物料号
/// </summary>
[Display(Name = "替换厂内物料号")]
[ExporterHeader(DisplayName = "替换厂内物料号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 客户下线时间
/// </summary>
[Display(Name = "客户下线时间")]
[ExporterHeader(DisplayName = "客户下线时间")]
public DateTime? CustomerOfflineTime { get; set; }
/// <summary>
/// 小总成号
/// </summary>
[Display(Name = "小总成号")]
[ExporterHeader(DisplayName = "小总成号")]
public string AssemblyCode { get; set; }
/// <summary>
/// 注塑码
/// </summary>
[Display(Name = "注塑码")]
[ExporterHeader(DisplayName = "注塑码")]
public string InjectionCode { get; set; }
/// <summary>
/// 结算数量
/// </summary>
[Display(Name = "结算数量")]
@ -227,6 +297,39 @@ public class SaSeEdiCompareDetailExportJisBBAC : SaSeEdiCompareDetailExport, ISa
[Display(Name = "Edi数量")]
[ExporterHeader(DisplayName = "Edi数量")]
public decimal EdiQty { get; set; }
/// <summary>
/// 结算与EDI量差
/// </summary>
[ExporterHeader(DisplayName = "结算与EDI量差")]
public decimal SaEdiQty => SAQty - EdiQty;
/// <summary>
/// WMS发货与EDI数量差
/// </summary>
[ExporterHeader(DisplayName = "WMS发货与EDI数量差")]
public decimal SeEdiQty => SEQty - EdiQty;
[Display(Name = "是否完全匹配")]
[ExporterHeader(DisplayName = "是否完全匹配")]
[ValueMapping("是", true)]
[ValueMapping("否", false)]
public bool MateType => SaEdiQty == 0 && SeEdiQty == 0;
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
[ExporterHeader(DisplayName = "定价")]
public decimal? FixPrice { get; set; }
/// <summary>
/// ERP销售库位
/// </summary>
[Display(Name = "ERP销售库位")]
[ExporterHeader(DisplayName = "ERP销售库位")]
public string ToErpLocCode { get; set; }
/// <summary>
/// WMS发货库位
/// </summary>
[Display(Name = "WMS发货库位")]
[ExporterHeader(DisplayName = "WMS发货库位")]
public string ToLocCode { get; set; }
}
/// <summary>
@ -247,18 +350,78 @@ public class SaSeEdiCompareDetailExportJisHBPO : SaSeEdiCompareDetailExport, ISa
[ValueMapping("无结算有发运(无EDI数据)", 6)]
public EnumSaSeEdiCompareCategory Category { get; set; }
/// <summary>
/// 零件描述
/// 交货单号
/// </summary>
[Display(Name = "零件描述")]
[Display(Name = "交货单号")]
[ExporterHeader(DisplayName = "交货单号")]
public string WmsBillNum { get; set; }
/// <summary>
/// 发货日期
/// </summary>
[Display(Name = "发货日期")]
[ExporterHeader(DisplayName = "发货日期")]
public DateTime? ShippingDate { get; set; }
/// <summary>
/// 生产码
/// </summary>
[Display(Name = "生产码")]
[ExporterHeader(DisplayName = "订单生产码")]
public string PN { 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>
/// 客户物料号
/// </summary>
[Display(Name = "客户物料号")]
[ExporterHeader(DisplayName = "客户物料号")]
public string CustomerPartCode { get; set; }
/// <summary>
/// 物料描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 替换厂内零件号
/// 厂内物料
/// </summary>
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
[Display(Name = "厂内物料号")]
[ExporterHeader(DisplayName = "厂内物料号")]
public string FactoryPartCode { get; set; }
/// <summary>
/// 替换厂内物料号
/// </summary>
[Display(Name = "替换厂内物料号")]
[ExporterHeader(DisplayName = "替换厂内物料号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 客户下线时间
/// </summary>
[Display(Name = "客户下线时间")]
[ExporterHeader(DisplayName = "客户下线时间")]
public DateTime? CustomerOfflineTime { get; set; }
/// <summary>
/// 小总成号
/// </summary>
[Display(Name = "小总成号")]
[ExporterHeader(DisplayName = "小总成号")]
public string AssemblyCode { get; set; }
/// <summary>
/// 注塑码
/// </summary>
[Display(Name = "注塑码")]
[ExporterHeader(DisplayName = "注塑码")]
public string InjectionCode { get; set; }
/// <summary>
/// 结算数量
/// </summary>
[Display(Name = "结算数量")]
@ -276,6 +439,39 @@ public class SaSeEdiCompareDetailExportJisHBPO : SaSeEdiCompareDetailExport, ISa
[Display(Name = "Edi数量")]
[ExporterHeader(DisplayName = "Edi数量")]
public decimal EdiQty { get; set; }
/// <summary>
/// 结算与EDI量差
/// </summary>
[ExporterHeader(DisplayName = "结算与EDI量差")]
public decimal SaEdiQty => SAQty - EdiQty;
/// <summary>
/// WMS发货与EDI数量差
/// </summary>
[ExporterHeader(DisplayName = "WMS发货与EDI数量差")]
public decimal SeEdiQty => SEQty - EdiQty;
[Display(Name = "是否完全匹配")]
[ExporterHeader(DisplayName = "是否完全匹配")]
[ValueMapping("是", true)]
[ValueMapping("否", false)]
public bool MateType => SaEdiQty == 0 && SeEdiQty == 0;
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
[ExporterHeader(DisplayName = "定价")]
public decimal? FixPrice { get; set; }
/// <summary>
/// ERP销售库位
/// </summary>
[Display(Name = "ERP销售库位")]
[ExporterHeader(DisplayName = "ERP销售库位")]
public string ToErpLocCode { get; set; }
/// <summary>
/// WMS发货库位
/// </summary>
[Display(Name = "WMS发货库位")]
[ExporterHeader(DisplayName = "WMS发货库位")]
public string ToLocCode { get; set; }
}
/// <summary>

93
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSaSeEdiCompareExportService.cs

@ -105,12 +105,13 @@ namespace SettleAccount.Job.Services.Report
//结算
var saGroup = from sa in _settleAccountDbContext.Set<BBAC_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
group sa by new { sa.PN, sa.LU } into groupItem
group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU),
Price = groupItem.Max(t => t.Price),
SettleDate = groupItem.Max(t => t.SettleDate),
PartCode = groupItem.Max(t => t.PartCode),
@ -118,59 +119,95 @@ namespace SettleAccount.Job.Services.Report
//发运
var seGroup = from se in _settleAccountDbContext.Set<BBAC_SE_DETAIL>()
where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
group se by new { se.PN, se.LU } into groupItem
group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
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),
ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc)
};
//Edi
var ediGroup = from edi in _settleAccountDbContext.Set<BBAC_SE_EDI>()
where edi.IsDeleted == false && edi.IsHaveSeData == true
group edi by new { edi.PN, edi.LU } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty)
};
var seEdiGroup = from se in seGroup
join edi in ediGroup
on new { se.PN, se.CustomerPartCodeNoSpace } equals new { edi.PN, CustomerPartCodeNoSpace = edi.LU }
into ediTemp
from edi in ediTemp.DefaultIfEmpty()
select new
{
se.PN,
se.CustomerPartCodeNoSpace,
se.Qty,
se.LU,
se.WmsBillNum,
se.ShippingDate,
se.FactoryPartCode,
se.ToLoc,
se.ErpToLoc,
EdiQty = edi.Qty,
EdiCustomerPartCode = edi.LU
};
var saSeCompareLeft = from sa in saGroup
join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
join seEdi in seEdiGroup
on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { seEdi.PN, seEdi.CustomerPartCodeNoSpace }
into temp
from se in temp.DefaultIfEmpty()
from seEdi in temp.DefaultIfEmpty()
select new SaSeEdiCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
WmsBillNum = seEdi.WmsBillNum,
ShippingDate = seEdi.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = sa.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
SEQty = seEdi.Qty,
EdiQty = seEdi.EdiQty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
ToLocCode = seEdi.ToLoc,
ToErpLocCode = seEdi.ErpToLoc,
SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace,
SeFactoryPartCode = seEdi.FactoryPartCode,
SaCustomerPartCode = sa.CustomerPartCodeNoSpace,
SaFactoryPartCode = sa.PartCode,
EdiCustomerPartCode = seEdi.EdiCustomerPartCode,
CustomerPartCode = sa.LU
};
var saSeCompareRight = from se in seGroup
var saSeCompareRight = from seEdi in seEdiGroup
join sa in saGroup
on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
on new { seEdi.PN, seEdi.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace }
into temp
from sa in temp.DefaultIfEmpty()
select new SaSeEdiCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
WmsBillNum = seEdi.WmsBillNum,
ShippingDate = seEdi.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = se.PN,
PN = seEdi.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
SEQty = seEdi.Qty,
EdiQty = seEdi.EdiQty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
ToLocCode = seEdi.ToLoc,
ToErpLocCode = seEdi.ErpToLoc,
SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace,
SeFactoryPartCode = seEdi.FactoryPartCode,
SaCustomerPartCode = sa.CustomerPartCodeNoSpace,
SaFactoryPartCode = sa.PartCode,
EdiCustomerPartCode = seEdi.EdiCustomerPartCode,
CustomerPartCode = sa.LU ?? seEdi.LU
};
var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin;

16
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisBBACSeEdiCompareExportService.cs

@ -77,13 +77,13 @@ namespace SettleAccount.Job.Services.Report
ParType = "01",
EdiQty = t.Sum(t => t.Qty),
AssemblyDate = default,
MatchNumber = default,
MatchNumber = t.Key.LU,
MateType = "否",
DiffDesc = "WMS漏发货EDI有订单"
}).ToList();
//无EDI有发运
var notHaveEdiHaveSeList = _settleAccountDbContext.Set<BBAC_SE_DETAIL>().Where(t => t.IsHaveEdiData == false)
.GroupBy(t => new { t.LU, t.PN })
.GroupBy(t => new { t.CustomerPartCodeNoSpace, t.PN })
.Select(t => new JisBBACEidSeCompareExport()
{
Category = "JIS",
@ -112,13 +112,14 @@ namespace SettleAccount.Job.Services.Report
SeqNumber = groupItem.Max(t => t.SeqNumber)
};
var seGroup = from se in _settleAccountDbContext.Set<BBAC_SE_DETAIL>()
where se.IsHaveEdiData == true && se.AssembleData >= seStartDateTime && se.AssembleData <= seEndDateTime
group se by new { se.PN, se.LU } into groupItem
where se.IsHaveEdiData == true && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU),
BillNum = groupItem.Max(t => t.BillNum),
MESConfigCode = groupItem.Max(t => t.MESConfigCode),
BillTime = groupItem.Max(t => t.BillTime),
@ -130,8 +131,7 @@ namespace SettleAccount.Job.Services.Report
};
var haveEdiHaveSeList = (from edi in ediGroup
join se in seGroup
on new { edi.PN, edi.LU } equals new { se.PN, se.LU }
//where edi.IsDeleted == false && edi.IsHaveSeData == true && se.IsHaveEdiData == true
on new { edi.PN, edi.LU } equals new { se.PN, LU = se.CustomerPartCodeNoSpace }
select new JisBBACEidSeCompareExport()
{
Category = "JIS",
@ -157,7 +157,9 @@ namespace SettleAccount.Job.Services.Report
}).ToList();
haveEdiNotHaveSeList.AddRange(haveEdiHaveSeList);
haveEdiNotHaveSeList.Reverse();
notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList);
notHaveEdiHaveSeList.Reverse();
ExcelExporter excelExporter = new ExcelExporter();
excelExporter

97
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSaSeEdiCompareExportService.cs

@ -84,8 +84,8 @@ namespace SettleAccount.Job.Services.Report
}
ediSeSaCompareDiffs = ediSeSaCompareDiffs.OrderBy(t => t.Category).ToList();
var items = _objectMapper.Map<List<SaSeEdiCompareDiff>, List<SaSeEdiCompareDetailExportJisBBAC>>(ediSeSaCompareDiffs);
var excelExporter = BindExcelExporter<SaSeEdiCompareDetailExportJisBBAC>(items, businessTypeDisplayName);
var items = _objectMapper.Map<List<SaSeEdiCompareDiff>, List<SaSeEdiCompareDetailExportJisHBPO>>(ediSeSaCompareDiffs);
var excelExporter = BindExcelExporter<SaSeEdiCompareDetailExportJisHBPO>(items, businessTypeDisplayName);
var result = excelExporter.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
@ -104,12 +104,13 @@ namespace SettleAccount.Job.Services.Report
//结算
var saGroup = from sa in _settleAccountDbContext.Set<HBPO_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
group sa by new { sa.PN, sa.LU } into groupItem
group sa by new { sa.PN, sa.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU),
Price = groupItem.Max(t => t.Price),
SettleDate = groupItem.Max(t => t.SettleDate),
PartCode = groupItem.Max(t => t.PartCode),
@ -117,59 +118,95 @@ namespace SettleAccount.Job.Services.Report
//发运
var seGroup = from se in _settleAccountDbContext.Set<HBPO_SE_DETAIL>()
where se.BusinessType == businessType && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
group se by new { se.PN, se.LU } into groupItem
group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
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),
ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc)
};
//Edi
var ediGroup = from edi in _settleAccountDbContext.Set<HBPO_SE_EDI>()
where edi.IsDeleted == false && edi.IsHaveSeData == true
group edi by new { edi.PN, edi.LU } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty)
};
var seEdiGroup = from se in seGroup
join edi in ediGroup
on new { se.PN, se.CustomerPartCodeNoSpace } equals new { edi.PN, CustomerPartCodeNoSpace = edi.LU }
into ediTemp
from edi in ediTemp.DefaultIfEmpty()
select new
{
se.PN,
se.CustomerPartCodeNoSpace,
se.Qty,
se.LU,
se.WmsBillNum,
se.ShippingDate,
se.FactoryPartCode,
se.ToLoc,
se.ErpToLoc,
EdiQty = edi.Qty,
EdiCustomerPartCode = edi.LU
};
var saSeCompareLeft = from sa in saGroup
join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
join seEdi in seEdiGroup
on new { sa.PN, sa.CustomerPartCodeNoSpace } equals new { seEdi.PN, seEdi.CustomerPartCodeNoSpace }
into temp
from se in temp.DefaultIfEmpty()
from seEdi in temp.DefaultIfEmpty()
select new SaSeEdiCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
WmsBillNum = seEdi.WmsBillNum,
ShippingDate = seEdi.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = sa.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
SEQty = seEdi.Qty,
EdiQty = seEdi.EdiQty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
ToLocCode = seEdi.ToLoc,
ToErpLocCode = seEdi.ErpToLoc,
SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace,
SeFactoryPartCode = seEdi.FactoryPartCode,
SaCustomerPartCode = sa.CustomerPartCodeNoSpace,
SaFactoryPartCode = sa.PartCode,
EdiCustomerPartCode = seEdi.EdiCustomerPartCode,
CustomerPartCode = sa.LU
};
var saSeCompareRight = from se in seGroup
var saSeCompareRight = from seEdi in seEdiGroup
join sa in saGroup
on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
on new { seEdi.PN, seEdi.CustomerPartCodeNoSpace } equals new { sa.PN, sa.CustomerPartCodeNoSpace }
into temp
from sa in temp.DefaultIfEmpty()
select new SaSeEdiCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
WmsBillNum = seEdi.WmsBillNum,
ShippingDate = seEdi.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = se.PN,
PN = seEdi.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
SEQty = seEdi.Qty,
EdiQty = seEdi.EdiQty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
ToLocCode = seEdi.ToLoc,
ToErpLocCode = seEdi.ErpToLoc,
SeCustomerPartCode = seEdi.CustomerPartCodeNoSpace,
SeFactoryPartCode = seEdi.FactoryPartCode,
SaCustomerPartCode = sa.CustomerPartCodeNoSpace,
SaFactoryPartCode = sa.PartCode,
EdiCustomerPartCode = seEdi.EdiCustomerPartCode,
CustomerPartCode = sa.LU ?? seEdi.LU
};
var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
return saSeCompareFullJoin;

12
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/JisHBPOSeEdiCompareExportService.cs

@ -74,13 +74,13 @@ namespace SettleAccount.Job.Services.Report
ParType = "01",
EdiQty = t.Sum(t => t.Qty),
AssemblyDate = default,
MatchNumber = default,
MatchNumber = t.Key.LU,
MateType = "否",
DiffDesc = "WMS漏发货EDI有订单"
}).ToList();
//无EDI有发运
var notHaveEdiHaveSeList = _settleAccountDbContext.Set<HBPO_SE_DETAIL>().Where(t => t.IsHaveEdiData == false)
.GroupBy(t => new { t.LU, t.PN })
.GroupBy(t => new { t.CustomerPartCodeNoSpace, t.PN })
.Select(t => new JisHBPOEidSeCompareExport()
{
Category = "JIS",
@ -111,12 +111,12 @@ namespace SettleAccount.Job.Services.Report
SeqNumber = groupItem.Max(t => t.SeqNumber)
};
var seGroup = from se in _settleAccountDbContext.Set<HBPO_SE_DETAIL>()
where se.IsHaveEdiData == true && se.AssembleData >= seStartDateTime && se.AssembleData <= seEndDateTime
group se by new { se.PN, se.LU } into groupItem
where se.IsHaveEdiData == true && se.BillTime >= seStartDateTime && se.BillTime <= seEndDateTime
group se by new { se.PN, se.CustomerPartCodeNoSpace } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
groupItem.Key.CustomerPartCodeNoSpace,
Qty = groupItem.Sum(t => t.Qty),
BillNum = groupItem.Max(t => t.BillNum),
MESConfigCode = groupItem.Max(t => t.MESConfigCode),
@ -131,7 +131,7 @@ namespace SettleAccount.Job.Services.Report
};
var haveEdiHaveSeList = (from edi in ediGroup
join se in seGroup
on new { edi.PN, edi.LU } equals new { se.PN, se.LU }
on new { edi.PN, edi.LU } equals new { se.PN, LU = se.CustomerPartCodeNoSpace }
select new JisHBPOEidSeCompareExport()
{
Category = "JIS",

2
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs

@ -44,7 +44,6 @@ namespace SettleAccount.Job.Services.Report
case EnumSaSeEdiCompareCategory.HaveSaNotHaveSeHaveEdi:
case EnumSaSeEdiCompareCategory.HaveSaNotHaveSeNotHaveEdi:
{
p.CustomerPartCode = p.SaCustomerPartCode;
p.FactoryPartCode = p.SaFactoryPartCode;
p.ReplaceFactoryPartCode = p.SaFactoryPartCode;
}
@ -52,7 +51,6 @@ namespace SettleAccount.Job.Services.Report
case EnumSaSeEdiCompareCategory.NotHaveSaHaveSeHaveEdi:
case EnumSaSeEdiCompareCategory.NotHaveSaHaveSeNotHaveEdi:
{
p.CustomerPartCode = p.SeCustomerPartCode;
p.FactoryPartCode = p.SeFactoryPartCode;
p.ReplaceFactoryPartCode = p.SeFactoryPartCode;
}

Loading…
Cancel
Save