wanggang 1 year ago
parent
commit
a4ad9f0828
  1. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_PD_DTO.cs
  2. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs
  3. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs
  4. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs
  5. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs
  6. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs
  7. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs
  8. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs
  9. 57
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs
  10. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs
  11. 240
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs
  12. 1
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs
  13. 207
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs
  14. 208
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs
  15. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  16. 136
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs
  17. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs
  18. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

18
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_PD_DTO.cs

@ -136,22 +136,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// 替换生产码
/// </summary>
public string REPN { get; set; }
/// <summary>
/// 键值
/// </summary>
public string KeyCode { get; set; }
/// <summary>
/// 扩展字段1
/// </summary>
public string Extend1 { get; set; }
/// <summary>
/// 扩展字段2
/// </summary>
public string Extend2 { get; set; }
/// <summary>
/// 扩展字段3
/// </summary>
public string Extend3 { get; set; }
/// <summary>
/// 客户零件号
/// </summary>

4
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/INVOICE_GRP_DTO.cs

@ -255,13 +255,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// <summary>
///零件号
/// </summary>
[Display(Name = "零件号")]
[Display(Name = "客户零件号")]
public string LU { get; set; }
/// <summary>
///零件号
/// </summary>
[Display(Name = "客户零件号")]
[Display(Name = "零件号")]
public string PartCode { get; set; }

5
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_CAN_SA_SERVICE.cs

@ -30,6 +30,7 @@ using Win.Abp.Snowflakes;
using Win.Sfs.SettleAccount.CommonManagers;
using Volo.Abp;
using Win.Sfs.SettleAccount.Entities.BQ.Temp;
using Volo.Abp.Uow;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
@ -81,15 +82,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[UnitOfWork(false)]
public async override Task<IActionResult> GenerateInvoice([FromBody] string invbillNum)
{
var main =await _bbacMng.GetMainAsync(invbillNum);
if (main != null)
{
if (main.State != SettleBillState.)
{
return new JsonResult(new { Code = 400, Message = "已创建发票不能重复创建" });

16
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationModule.cs

@ -63,10 +63,6 @@ namespace Win.Sfs.SettleAccount
{
Func<string, IExportJob> accesor = key =>
{
if (key.Equals(typeof(PubSaSeCompareExportService).FullName))
{
return implementationFactory.GetService<PubSaSeCompareExportService>();
}
if (key.Equals(typeof(JisBBACEdiSeCompareExportService).FullName))
{
return implementationFactory.GetService<JisBBACEdiSeCompareExportService>();
@ -75,6 +71,18 @@ namespace Win.Sfs.SettleAccount
{
return implementationFactory.GetService<JisHBPOEdiSeCompareExportService>();
}
if (key.Equals(typeof(MaiDanBBACSaSeCompareExportService).FullName))
{
return implementationFactory.GetService<MaiDanBBACSaSeCompareExportService>();
}
if (key.Equals(typeof(MaiDanHBPOSaSeCompareExportService).FullName))
{
return implementationFactory.GetService<MaiDanHBPOSaSeCompareExportService>();
}
if (key.Equals(typeof(PubSaSeCompareExportService).FullName))
{
return implementationFactory.GetService<PubSaSeCompareExportService>();
}
if (key.Equals(typeof(PendingDeductionService).FullName))
{
return implementationFactory.GetService<PendingDeductionService>();

7
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Bases/EntityBase.cs

@ -70,6 +70,13 @@ namespace SettleAccount.Bases
public virtual string Site { get; set; }
public virtual void SetId(Guid guid)
{
Id = guid;
}
}

3
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/BBAC_CAN_SA.cs

@ -46,6 +46,9 @@ public class BBAC_CAN_SA : SA_CAN_BASE_MAIN
Site = site;
BusinessType = businessType;
}
}
[Display(Name = "BBAC可结算导入明细")]

1
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/BBAC_NOT_SA_MNG.cs

@ -64,6 +64,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var _entity = new BBAC_CAN_SA();
_entity.SetId(Guid.NewGuid());
_entity.BillNum = billNumber;
_entity.InvGroupNum = billNumber;
_entity.Version = DateTime.Now.Year + DateTime.Now.Month;

1
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/HBPO_NOT_SA_MNG.cs

@ -76,6 +76,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
_entity.State = SettleBillState.;
_entity.SettleBillNum = string.Empty;
_entity.BusinessType = p_list.FirstOrDefault().BusinessType;
_entity.SetId(Guid.NewGuid());
var _entityList = new List<HBPO_CAN_SA_DETAIL>();
foreach (var itm in p_list)
{

57
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/INV_MNG.cs

@ -1282,14 +1282,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
if (invoiceMap.Keys.Count > 0)
{
var groupList = new List<INVOICE_MAP_GROUP>();
var notDetialList = new List<INVOICE_NOT_SETTLE>();
var detailList = new List<INVOICE_WAIT_DETAIL>();
var invlist = new List<INVOICE_GRP>();
var salist = new List<TDetail>();
var adjlist = new List<PUB_ADJ_DETAIL>();
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
@ -1311,21 +1309,19 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
adjdetails.Add(detail);
}
}
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID })
var detailDtos = dtos.Where(p => ls.Contains(p.GroupNum)).GroupBy(p => new { p.InvGroupNum, p.PartCode, p.Price, p.BeginDate, p.EndDate, p.ContractDocID,p.LU })
.Select(itm => new
{
PartCode = itm.Key.PartCode,
InvGroupNum = itm.Key.InvGroupNum,
LU = itm.Key.PartCode,
LU = itm.Key.LU,
ContactDocID = itm.Key.ContractDocID,
Price = itm.Key.Price,
Amt = Math.Round(itm.Sum(k => k.Qty) * itm.Key.Price, 2),
Qty = itm.Sum(k => k.Qty),
BeginDate = itm.Key.BeginDate,
EndDate = itm.Key.EndDate
})
.ToList();
}).ToList();
decimal amt = detailDtos.Sum(k => k.Amt);
decimal txtAmt = Math.Round(detailDtos.Sum(k => k.Amt), 2);
var mapList = new List<INVOICE_MAP_GROUP>();
@ -1373,10 +1369,29 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
detailList.AddRange(_entityDetailList);
}
var innotls = new List<INVOICE_NOT_SETTLE>();
var sq = dtos.Where(p => itm.Value.Contains(p.GroupNum)).GroupBy(p => new { p.LU, p.GroupNum })
.Select(p => new { version = p_version, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = itm.Key, GroupNum = p.Key.GroupNum });
foreach (var sitm in sq)
{
innotls.Add(new INVOICE_NOT_SETTLE(
guid: GuidGenerator.Create(),
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: sitm.GroupNum,
lU: sitm.LU,
lU1: sitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: sitm.Qty,
p_invbillnum: itm.Key
));
}
if (p_notlist != null && p_notlist.Count > 0)
{
var groupnum = itm.Value;
var notls = p_notlist.Where(p=>groupnum.Contains(p.GroupNum)).GroupBy(p => new { p.GroupNum, p.LU }).Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty) });
var notls = p_notlist.Where(p => groupnum.Contains(p.GroupNum)).GroupBy(p => new { p.GroupNum, p.LU })
.Select(p => new { GroupNum = p.Key.GroupNum, LU = p.Key.LU, Qty = p.Sum(itm => itm.Qty), InvBillNum = itm.Key });
foreach (var nitm in notls)
{
innotls.Add(new INVOICE_NOT_SETTLE(
@ -1384,12 +1399,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
version: p_version,
invGroupNum: p_InvGroupNum,
settleGroupNum: nitm.GroupNum,
lU: string.Empty,
lU: nitm.LU,
lU1: nitm.LU,
extend1: string.Empty,
extend2: string.Empty,
qty: nitm.Qty,
p_invbillnum:itm.Key
p_invbillnum: itm.Key
));
}
if (innotls.Count > 0)
@ -1408,9 +1423,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
invGroupNum: p_InvGroupNum,
state: SettleBillState.,
invoiceBillState: InvoiceBillState.,
tax: 0,
parent: string.Empty,
preTaxDiff: 0,
tax: 0,
parent: string.Empty,
preTaxDiff: 0,
taxDiff: 0,
clientCode: string.Empty,
realAmt: 0
@ -1418,18 +1433,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
invlist.Add(invbill);
}
if (salist.Count > 0)
{
foreach (var itm in invoiceMap)//分组影响和
{
var key = itm.Key;//发票票号
var ls = itm.Value;//结算分组号列表
string str = $" EXEC [p_Invoice_generation_change] @invbillnum = {"'" + key + "'"},@groupNum = {"'" + string.Join(",", ls) + "'"},@businessType = NULL";
await _repository.DbContext.Database.ExecuteSqlRawAsync(str);
}
// await _repository.DbContext.BulkUpdateAsync(salist,new BulkConfig() { BatchSize=10000 });
}
await _repository.DbContext.BulkInsertAsync(invlist);
await _repository.DbContext.BulkInsertAsync(groupList);
await _repository.DbContext.BulkInsertAsync(detailList);
if (salist.Count > 0)
{
await _repository.DbContext.BulkUpdateAsync(salist);
}
if (adjlist.Count > 0)
{
await _repository.DbContext.BulkUpdateAsync(adjlist);

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/Managers/PUB_NOT_SA_MNG.cs

@ -95,6 +95,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
}
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var _entity = new PUB_CAN_SA();
_entity.SetId(Guid.NewGuid());
_entity.BillNum = billNumber;
_entity.InvGroupNum = billNumber;
_entity.Version = DateTime.Now.Year + DateTime.Now.Month;
@ -134,6 +135,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Managers
{
var billNumber = OrderNumberGenerator.GenerateOrderNumber("N");
var _entity = new PUB_CAN_SA();
_entity.SetId(Guid.NewGuid());
_entity.BillNum = billNumber;
_entity.InvGroupNum = billNumber;
_entity.Version = DateTime.Now.Year + DateTime.Now.Month;

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

@ -128,14 +128,10 @@ public class PubSaSeCompareDetailExport
/// <summary>
/// PUB结算与发运对比明细
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
public class PubSaSeCompareDetailExport2
public interface IPubSaSeCompareDetailExport
{
/// <summary>
/// 类别
/// 有结算有发运
/// 有结算无发运
/// 无结算有发运
/// </summary>
[Display(Name = "类别")]
[ExporterHeader(DisplayName = "类别")]
@ -143,21 +139,101 @@ public class PubSaSeCompareDetailExport2
[ValueMapping("有结算无发运", 2)]
[ValueMapping("无结算有发运", 3)]
public EnumPubSaSeCompareCategory Category { get; set; }
/// <summary>
/// 零件描述
/// </summary>
[Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 替换厂内零件号
/// </summary>
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceFactoryPartCode { 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>
/// PUB结算与发运对比汇总
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
public class PubSaSeCompareSumExport
{
/// <summary>
/// 厂内物料号
/// </summary>
[Display(Name = "厂内物料号")]
[ExporterHeader(DisplayName = "LU")]
public string FactoryPartCode { get; set; }
/// <summary>
/// 物料描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string PartCodeDesc { 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>
/// 直供件BBAC结算与发运对比明细
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport
{
/// <summary>
/// 类别
/// </summary>
[Display(Name = "类别")]
[ExporterHeader(DisplayName = "类别")]
[ValueMapping("有结算有发运", 1)]
[ValueMapping("有结算无发运", 2)]
[ValueMapping("无结算有发运", 3)]
public EnumPubSaSeCompareCategory Category { get; set; }
/// <summary>
/// Wms发货单号
/// </summary>
[Display(Name = "Wms发货单号")]
[ExporterHeader(DisplayName = "交货单号")]
public string WmsBillNum { get; set; }
/// <summary>
/// 发货日期
/// </summary>
[Display(Name = "发货日期")]
[ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")]
public DateTime ShippingDate { get; set; }
public DateTime? ShippingDate { get; set; }
/// <summary>
/// 生产码
/// </summary>
@ -193,7 +269,7 @@ public class PubSaSeCompareDetailExport2
/// </summary>
[Display(Name = "客户下线时间")]
[ExporterHeader(DisplayName = "客户下线时间")]
public DateTime CustomerOfflineTime { get; set; }
public DateTime? CustomerOfflineTime { get; set; }
/// <summary>
/// 结算数量
@ -201,6 +277,7 @@ public class PubSaSeCompareDetailExport2
[Display(Name = "结算数量")]
[ExporterHeader(DisplayName = "结算数量")]
public decimal SAQty { get; set; }
/// <summary>
/// 发货数量
/// </summary>
@ -211,7 +288,7 @@ public class PubSaSeCompareDetailExport2
/// 差异数量
/// </summary>
[ExporterHeader(DisplayName = "差异数量")]
public decimal DiffQty { set; get; }
public decimal DiffQty => SAQty - SEQty;
/// <summary>
/// 匹配类型
/// </summary>
@ -225,19 +302,7 @@ public class PubSaSeCompareDetailExport2
/// </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; }
public decimal? FixPrice { get; set; }
/// <summary>
/// WMS目标库位
/// </summary>
@ -253,101 +318,13 @@ public class PubSaSeCompareDetailExport2
}
/// <summary>
/// PUB结算与发运对比明细
/// </summary>
public interface IPubSaSeCompareDetailExport
{
/// <summary>
/// 类别
/// 有结算有发运
/// 有结算无发运
/// 无结算有发运
/// </summary>
[Display(Name = "类别")]
[ExporterHeader(DisplayName = "类别")]
[ValueMapping("有结算有发运", 1)]
[ValueMapping("有结算无发运", 2)]
[ValueMapping("无结算有发运", 3)]
public EnumPubSaSeCompareCategory Category { get; set; }
/// <summary>
/// 零件描述
/// </summary>
[Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 替换厂内零件号
/// </summary>
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceFactoryPartCode { 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>
/// PUB结算与发运对比汇总
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
public class PubSaSeCompareSumExport
{
/// <summary>
/// 厂内物料号
/// </summary>
[Display(Name = "厂内物料号")]
[ExporterHeader(DisplayName = "LU")]
public string FactoryPartCode { get; set; }
/// <summary>
/// 物料描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string PartCodeDesc { 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>
/// 直供件BBAC结算与发运对比明细
/// 直供件HBPO结算与发运对比明细
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport
public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport
{
/// <summary>
/// 类别
/// 有结算有发运
/// 有结算无发运
/// 无结算有发运
/// </summary>
[Display(Name = "类别")]
[ExporterHeader(DisplayName = "类别")]
@ -355,21 +332,18 @@ public class PubSaSeCompareDetailExportZhiGongJianBBAC : 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>
[Display(Name = "发货日期")]
[ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")]
public DateTime? ShippingDate { get; set; }
/// <summary>
/// 生产码
/// </summary>
@ -406,14 +380,12 @@ public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExp
[Display(Name = "客户下线时间")]
[ExporterHeader(DisplayName = "客户下线时间")]
public DateTime? CustomerOfflineTime { get; set; }
/// <summary>
/// 结算数量
/// </summary>
[Display(Name = "结算数量")]
[ExporterHeader(DisplayName = "结算数量")]
public decimal SAQty { get; set; }
/// <summary>
/// 发货数量
/// </summary>
@ -454,16 +426,13 @@ public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExp
}
/// <summary>
/// 直供件HBPO结算与发运对比明细
/// 买单件BBAC结算与发运对比明细
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport
public class PubSaSeCompareDetailExportMaiDanJianBBAC : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport
{
/// <summary>
/// 类别
/// 有结算有发运
/// 有结算无发运
/// 无结算有发运
/// </summary>
[Display(Name = "类别")]
[ExporterHeader(DisplayName = "类别")]
@ -483,12 +452,11 @@ public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExp
[Display(Name = "发货日期")]
[ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")]
public DateTime? ShippingDate { get; set; }
/// <summary>
/// 生产码
/// </summary>
[Display(Name = "生产码")]
[ExporterHeader(DisplayName = "ASN发货单号")]
[ExporterHeader(DisplayName = "索引号")]
public string PN { get; set; }
/// <summary>
/// 客户零件号
@ -520,12 +488,14 @@ 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>
@ -569,13 +539,10 @@ public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExp
/// 买单件HBPO结算与发运对比明细
/// </summary>
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
public class PubSaSeCompareDetailExportMaiDanJianHBPO : PubSaSeCompareDetailExport
public class PubSaSeCompareDetailExportMaiDanJianHBPO : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport
{
/// <summary>
/// 类别
/// 有结算有发运
/// 有结算无发运
/// 无结算有发运
/// </summary>
[Display(Name = "类别")]
[ExporterHeader(DisplayName = "类别")]
@ -583,21 +550,18 @@ public class PubSaSeCompareDetailExportMaiDanJianHBPO : PubSaSeCompareDetailExpo
[ValueMapping("有结算无发运", 2)]
[ValueMapping("无结算有发运", 3)]
public EnumPubSaSeCompareCategory Category { get; set; }
/// <summary>
/// Wms发货单号
/// </summary>
[Display(Name = "Wms发货单号")]
[ExporterHeader(DisplayName = "交货单号")]
public string WmsBillNum { get; set; }
/// <summary>
/// 发货日期
/// </summary>
[Display(Name = "发货日期")]
[ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")]
public DateTime? ShippingDate { get; set; }
/// <summary>
/// 生产码
/// </summary>
@ -689,9 +653,6 @@ public class PubSaSeCompareDetailExportBeiJian : PubSaSeCompareDetailExport, IPu
{
/// <summary>
/// 类别
/// 有结算有发运
/// 有结算无发运
/// 无结算有发运
/// </summary>
[Display(Name = "类别")]
[ExporterHeader(DisplayName = "类别")]
@ -699,21 +660,18 @@ public class PubSaSeCompareDetailExportBeiJian : PubSaSeCompareDetailExport, IPu
[ValueMapping("有结算无发运", 2)]
[ValueMapping("无结算有发运", 3)]
public EnumPubSaSeCompareCategory Category { get; set; }
/// <summary>
/// Wms发货单号
/// </summary>
[Display(Name = "Wms发货单号")]
[ExporterHeader(DisplayName = "交货单号")]
public string WmsBillNum { get; set; }
/// <summary>
/// 发货日期
/// </summary>
[Display(Name = "发货日期")]
[ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")]
public DateTime? ShippingDate { get; set; }
/// <summary>
/// 生产码
/// </summary>
@ -804,9 +762,6 @@ public class PubSaSeCompareDetailExportYinDuJian : PubSaSeCompareDetailExport, I
{
/// <summary>
/// 类别
/// 有结算有发运
/// 有结算无发运
/// 无结算有发运
/// </summary>
[Display(Name = "类别")]
[ExporterHeader(DisplayName = "类别")]
@ -814,21 +769,18 @@ public class PubSaSeCompareDetailExportYinDuJian : PubSaSeCompareDetailExport, I
[ValueMapping("有结算无发运", 2)]
[ValueMapping("无结算有发运", 3)]
public EnumPubSaSeCompareCategory Category { get; set; }
/// <summary>
/// Wms发货单号
/// </summary>
[Display(Name = "Wms发货单号")]
[ExporterHeader(DisplayName = "交货单号")]
public string WmsBillNum { get; set; }
/// <summary>
/// 发货日期
/// </summary>
[Display(Name = "发货日期")]
[ExporterHeader(DisplayName = "发货日期", Format = "yyyy-MM-dd")]
public DateTime? ShippingDate { get; set; }
/// <summary>
/// 生产码
/// </summary>

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

@ -42,6 +42,7 @@ public class PubSaSeCompareDapperRepository : DapperRepository<SettleAccountDbCo
A.WmsBillNum,
A.ShippingDate,
B.SettleDate CustomerOfflineTime,
ISNULL(A.PN,B.PN) PN,
A.SEQty,
B.SAQty,
B.Price FixPrice,

207
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanBBACSaSeCompareExportService.cs

@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Linq.Dynamic.Core;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR;
using Microsoft.OpenApi.Extensions;
using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR;
using Shouldly;
@ -21,17 +22,21 @@ namespace SettleAccount.Job.Services.Report
/// <summary>
/// 买单件BBAC结算、发运对比导出服务
/// </summary>
public class MaiDanBBACSaSeCompareExportService : ITransientDependency, IExportJob
public class MaiDanBBACSaSeCompareExportService : SaSeCompareExportBaseService, ITransientDependency, IExportJob
{
/// <summary>
/// HubContext
/// 业务类型
/// </summary>
private readonly IHubContext<PageHub> _hubContext;
private readonly EnumBusinessType businessType = EnumBusinessType.MaiDanJianBBAC;
/// <summary>
/// 文件容器
/// </summary>
private readonly IBlobContainer<MyFileContainer> _fileContainer;
/// <summary>
/// AutoMapper
/// </summary>
private readonly IObjectMapper _objectMapper;
/// <summary>
/// DbContext
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
@ -43,10 +48,10 @@ namespace SettleAccount.Job.Services.Report
IHubContext<PageHub> hubContext,
IBlobContainer<MyFileContainer> fileContainer,
IObjectMapper objectMapper,
SettleAccountDbContext settleAccountDbContext)
SettleAccountDbContext settleAccountDbContext) : base(hubContext)
{
_hubContext = hubContext;
_fileContainer = fileContainer;
_objectMapper = objectMapper;
_settleAccountDbContext = settleAccountDbContext;
}
@ -61,109 +66,27 @@ namespace SettleAccount.Job.Services.Report
var strSeStartDateTime = property.Where(p => p.Name == "SeStartDateTime").FirstOrDefault().Value;
var strSeEndDateTime = property.Where(p => p.Name == "SeEndDateTime").FirstOrDefault().Value;
var businessTypeDisplayName = businessType.GetAttributeOfType<DisplayAttribute>()?.Name ?? businessType.ToString();
var seStartDateTime = DateTime.Parse(strSeStartDateTime);
var seEndDateTime = DateTime.Parse(strSeEndDateTime);
var filename = exportName.FirstOrDefault();
//有EDI无发运
var haveEdiNotHaveSeList = _settleAccountDbContext.Set<BBAC_SE_EDI>().Where(t => t.IsHaveSeData == false)
.GroupBy(t => new { t.LU, t.PN })
.Select(t => new JisBBACEidSeCompareExport()
{
Category = "JIS",
CarModeCode = default,
LineStationcode = default,
SequenceNumber = t.Max(t => t.SeqNumber),
ParType = "01",
EdiQty = t.Sum(t => t.Qty),
AssemblyDate = default,
MatchNumber = default,
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 })
.Select(t => new JisBBACEidSeCompareExport()
{
Category = "JIS",
WmsBillNum = t.Max(t => t.BillNum),
MESConfigCode = t.Max(t => t.MESConfigCode),
ShippingDate = t.Max(t => t.BillTime),
PN = t.Max(t => t.PN),
Seq = t.Max(t => t.Seq),
PjsNum = t.Max(t => t.PjsNum),
MaterialNumber = t.Max(t => t.CustPartCode),
MaterialDes = t.Max(t => t.PartDesc),
SEQty = t.Sum(t => t.Qty),
InjectionCode = t.Max(t => t.InjectionCode),
MateType = "否",
DiffDesc = "WMS有发货EDI无订单"
}).ToList();
//有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),
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
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty),
BillNum = groupItem.Max(t => t.BillNum),
MESConfigCode = groupItem.Max(t => t.MESConfigCode),
BillTime = groupItem.Max(t => t.BillTime),
Seq = groupItem.Max(t => t.Seq),
PjsNum = groupItem.Max(t => t.PjsNum),
CustPartCode = groupItem.Max(t => t.CustPartCode),
PartDesc = groupItem.Max(t => t.PartDesc),
InjectionCode = groupItem.Max(t => t.InjectionCode)
};
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
select new JisBBACEidSeCompareExport()
{
Category = "JIS",
WmsBillNum = se.BillNum,
CarModeCode = default,
LineStationcode = default,
SequenceNumber = edi.SeqNumber,
ParType = "01",
MESConfigCode = se.MESConfigCode,
ShippingDate = se.BillTime,
PN = se.PN,
Seq = se.Seq,
PjsNum = se.PjsNum,
MaterialNumber = se.CustPartCode,
MaterialDes = se.PartDesc,
SEQty = se.Qty,
EdiQty = edi.Qty,
AssemblyDate = default,
MatchNumber = default,
InjectionCode = se.InjectionCode,
MateType = se.Qty == edi.Qty ? "是" : "否",
DiffDesc = "WMS有发货EDI有订单"
}).ToList();
var pubSaSeCompareDiffs = GetSaSeCompareData(int.Parse(version), seStartDateTime, seEndDateTime);
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs);
haveEdiNotHaveSeList.AddRange(haveEdiHaveSeList);
notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList);
if (string.IsNullOrEmpty(lu) == false)
{
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.CustomerPartCode == lu);
}
if (string.IsNullOrEmpty(pn) == false)
{
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.PN == pn);
}
pubSaSeCompareDiffs = pubSaSeCompareDiffs.OrderBy(t => t.Category).ToList();
ExcelExporter excelExporter = new ExcelExporter();
excelExporter
.Append(haveEdiNotHaveSeList, $"BBACEDI数据和发货对比")
.SeparateBySheet()
.Append(notHaveEdiHaveSeList, $"BBAC发货和EDI数据对比");
var items = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PubSaSeCompareDetailExportMaiDanJianBBAC>>(pubSaSeCompareDiffs);
var excelExporter = BindExcelExporter<PubSaSeCompareDetailExportMaiDanJianBBAC>(items, businessTypeDisplayName);
var result = excelExporter.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
@ -174,9 +97,83 @@ namespace SettleAccount.Job.Services.Report
}
#region 私有方法
private void Notify()
/// <summary>
/// 获取结算与发运比对数据
/// </summary>
public List<PubSaSeCompareDiff> GetSaSeCompareData(int version, DateTime seStartDateTime, DateTime seEndDateTime)
{
this._hubContext.Clients.All.ServerToClient("SaSeCompare", "refresh", "");
//结算
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
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<BBAC_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),
ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc)
};
var saSeCompareLeft = (from sa in saGroup
join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
into temp
from se in temp.DefaultIfEmpty()
select new PubSaSeCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = sa.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
});
var saSeCompareRight = (from se in seGroup
join sa in saGroup
on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp
from sa in temp.DefaultIfEmpty()
select new PubSaSeCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = se.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
});
var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList();
return saSeCompareFullJoin;
}
#endregion
}

208
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/MaiDanHBPOSaSeCompareExportService.cs

@ -1,9 +1,10 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Linq.Dynamic.Core;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR;
using Microsoft.OpenApi.Extensions;
using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR;
using Shouldly;
@ -15,23 +16,28 @@ using Volo.Abp.ObjectMapping;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Reports;
using static NPOI.HSSF.Util.HSSFColor;
namespace SettleAccount.Job.Services.Report
{
/// <summary>
/// 买单件HBPO结算、发运对比导出服务
/// </summary>
public class MaiDanHBPOSaSeCompareExportService : ITransientDependency, IExportJob
public class MaiDanHBPOSaSeCompareExportService : SaSeCompareExportBaseService, ITransientDependency, IExportJob
{
/// <summary>
/// HubContext
/// 业务类型
/// </summary>
private readonly IHubContext<PageHub> _hubContext;
private readonly EnumBusinessType businessType = EnumBusinessType.MaiDanJianHBPO;
/// <summary>
/// 文件容器
/// </summary>
private readonly IBlobContainer<MyFileContainer> _fileContainer;
/// <summary>
/// AutoMapper
/// </summary>
private readonly IObjectMapper _objectMapper;
/// <summary>
/// DbContext
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
@ -43,10 +49,10 @@ namespace SettleAccount.Job.Services.Report
IHubContext<PageHub> hubContext,
IBlobContainer<MyFileContainer> fileContainer,
IObjectMapper objectMapper,
SettleAccountDbContext settleAccountDbContext)
SettleAccountDbContext settleAccountDbContext) : base(hubContext)
{
_hubContext = hubContext;
_fileContainer = fileContainer;
_objectMapper = objectMapper;
_settleAccountDbContext = settleAccountDbContext;
}
@ -61,109 +67,27 @@ namespace SettleAccount.Job.Services.Report
var strSeStartDateTime = property.Where(p => p.Name == "SeStartDateTime").FirstOrDefault().Value;
var strSeEndDateTime = property.Where(p => p.Name == "SeEndDateTime").FirstOrDefault().Value;
var businessTypeDisplayName = businessType.GetAttributeOfType<DisplayAttribute>()?.Name ?? businessType.ToString();
var seStartDateTime = DateTime.Parse(strSeStartDateTime);
var seEndDateTime = DateTime.Parse(strSeEndDateTime);
var filename = exportName.FirstOrDefault();
//有EDI无发运
var haveEdiNotHaveSeList = _settleAccountDbContext.Set<BBAC_SE_EDI>().Where(t => t.IsHaveSeData == false)
.GroupBy(t => new { t.LU, t.PN })
.Select(t => new JisBBACEidSeCompareExport()
{
Category = "JIS",
CarModeCode = default,
LineStationcode = default,
SequenceNumber = t.Max(t => t.SeqNumber),
ParType = "01",
EdiQty = t.Sum(t => t.Qty),
AssemblyDate = default,
MatchNumber = default,
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 })
.Select(t => new JisBBACEidSeCompareExport()
{
Category = "JIS",
WmsBillNum = t.Max(t => t.BillNum),
MESConfigCode = t.Max(t => t.MESConfigCode),
ShippingDate = t.Max(t => t.BillTime),
PN = t.Max(t => t.PN),
Seq = t.Max(t => t.Seq),
PjsNum = t.Max(t => t.PjsNum),
MaterialNumber = t.Max(t => t.CustPartCode),
MaterialDes = t.Max(t => t.PartDesc),
SEQty = t.Sum(t => t.Qty),
InjectionCode = t.Max(t => t.InjectionCode),
MateType = "否",
DiffDesc = "WMS有发货EDI无订单"
}).ToList();
//有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),
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
select new
{
groupItem.Key.PN,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty),
BillNum = groupItem.Max(t => t.BillNum),
MESConfigCode = groupItem.Max(t => t.MESConfigCode),
BillTime = groupItem.Max(t => t.BillTime),
Seq = groupItem.Max(t => t.Seq),
PjsNum = groupItem.Max(t => t.PjsNum),
CustPartCode = groupItem.Max(t => t.CustPartCode),
PartDesc = groupItem.Max(t => t.PartDesc),
InjectionCode = groupItem.Max(t => t.InjectionCode)
};
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
select new JisBBACEidSeCompareExport()
{
Category = "JIS",
WmsBillNum = se.BillNum,
CarModeCode = default,
LineStationcode = default,
SequenceNumber = edi.SeqNumber,
ParType = "01",
MESConfigCode = se.MESConfigCode,
ShippingDate = se.BillTime,
PN = se.PN,
Seq = se.Seq,
PjsNum = se.PjsNum,
MaterialNumber = se.CustPartCode,
MaterialDes = se.PartDesc,
SEQty = se.Qty,
EdiQty = edi.Qty,
AssemblyDate = default,
MatchNumber = default,
InjectionCode = se.InjectionCode,
MateType = se.Qty == edi.Qty ? "是" : "否",
DiffDesc = "WMS有发货EDI有订单"
}).ToList();
var pubSaSeCompareDiffs = GetSaSeCompareData(int.Parse(version), seStartDateTime, seEndDateTime);
HandlePubSaSeCompareDiffList(pubSaSeCompareDiffs);
haveEdiNotHaveSeList.AddRange(haveEdiHaveSeList);
notHaveEdiHaveSeList.AddRange(haveEdiHaveSeList);
if (string.IsNullOrEmpty(lu) == false)
{
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.CustomerPartCode == lu);
}
if (string.IsNullOrEmpty(pn) == false)
{
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.PN == pn);
}
pubSaSeCompareDiffs = pubSaSeCompareDiffs.OrderBy(t => t.Category).ToList();
ExcelExporter excelExporter = new ExcelExporter();
excelExporter
.Append(haveEdiNotHaveSeList, $"BBACEDI数据和发货对比")
.SeparateBySheet()
.Append(notHaveEdiHaveSeList, $"BBAC发货和EDI数据对比");
var items = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PubSaSeCompareDetailExportMaiDanJianHBPO>>(pubSaSeCompareDiffs);
var excelExporter = BindExcelExporter<PubSaSeCompareDetailExportMaiDanJianHBPO>(items, businessTypeDisplayName);
var result = excelExporter.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
@ -174,9 +98,83 @@ namespace SettleAccount.Job.Services.Report
}
#region 私有方法
private void Notify()
/// <summary>
/// 获取结算与发运比对数据
/// </summary>
public List<PubSaSeCompareDiff> GetSaSeCompareData(int version, DateTime seStartDateTime, DateTime seEndDateTime)
{
this._hubContext.Clients.All.ServerToClient("SaSeCompare", "refresh", "");
//结算
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
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<HBPO_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),
ToLoc = groupItem.Max(t => t.ToLoc),
ErpToLoc = groupItem.Max(t => t.ErpToLoc)
};
var saSeCompareLeft = (from sa in saGroup
join se in seGroup
on new { sa.PN, sa.LU } equals new { se.PN, se.LU }
into temp
from se in temp.DefaultIfEmpty()
select new PubSaSeCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = sa.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
});
var saSeCompareRight = (from se in seGroup
join sa in saGroup
on new { se.PN, se.LU } equals new { sa.PN, sa.LU }
into temp
from sa in temp.DefaultIfEmpty()
select new PubSaSeCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = se.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
ToLocCode = se.ToLoc,
ToErpLocCode = se.ErpToLoc,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
});
var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList();
return saSeCompareFullJoin;
}
#endregion
}

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

@ -283,14 +283,6 @@ namespace SettleAccount.Job.Services.Report
excelExporter = BindExcelExporter<PubSaSeCompareDetailExportZhiGongJianHBPO>(items, businessTypeDisplayName);
}
break;
case EnumBusinessType.MaiDanJianBBAC:
break;
case EnumBusinessType.MaiDanJianHBPO:
//{
// var items = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PubSaSeCompareDetailExportMaiDanJianHBPO>>(pubSaSeCompareDiffs);
// excelExporter = BindExcelExporter<PubSaSeCompareDetailExportMaiDanJianHBPO>(items, businessTypeDisplayName);
//}
break;
case EnumBusinessType.BeiJian:
{
var items = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PubSaSeCompareDetailExportBeiJian>>(pubSaSeCompareDiffs);
@ -409,6 +401,7 @@ namespace SettleAccount.Job.Services.Report
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = sa.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
@ -429,6 +422,7 @@ namespace SettleAccount.Job.Services.Report
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = se.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
FixPrice = sa.Price,
@ -439,7 +433,7 @@ namespace SettleAccount.Job.Services.Report
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.PartCode
});
var saSeCompareFullJoin = saSeCompareLeft.Union(saSeCompareRight).ToList();
var saSeCompareFullJoin = saSeCompareLeft.Concat(saSeCompareRight).ToList();
return saSeCompareFullJoin;
}
/// <summary>
@ -503,7 +497,9 @@ namespace SettleAccount.Job.Services.Report
.SeparateBySheet()
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出");
}
/// <summary>
/// 通知
/// </summary>
private void Notify()
{
this._hubContext.Clients.All.ServerToClient("SaSeCompare", "refresh", "");

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

@ -0,0 +1,136 @@
using System.Collections.Generic;
using System.Linq;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR;
using SettleAccount.Job.SignalR;
using Win.Sfs.SettleAccount.Enums;
using Win.Sfs.SettleAccount.Reports;
namespace SettleAccount.Job.Services.Report
{
public class SaSeCompareExportBaseService
{
/// <summary>
/// HubContext
/// </summary>
private readonly IHubContext<PageHub> _hubContext;
public SaSeCompareExportBaseService(IHubContext<PageHub> hubContext)
{
_hubContext = hubContext;
}
public virtual void HandlePubSaSeCompareDiffList(List<PubSaSeCompareDiff> pubSaSeCompareDiffs)
{
pubSaSeCompareDiffs.ForEach(p =>
{
p.Category = (string.IsNullOrEmpty(p.SaCustomerPartCode), string.IsNullOrEmpty(p.SeCustomerPartCode)) switch
{
(false, false) => EnumPubSaSeCompareCategory.HaveSaHaveSe,
(false, true) => EnumPubSaSeCompareCategory.HaveSaNotHaveSe,
(true, false) => EnumPubSaSeCompareCategory.NotHaveSaHaveSe,
_ => EnumPubSaSeCompareCategory.None,
};
switch (p.Category)
{
case EnumPubSaSeCompareCategory.None:
break;
case EnumPubSaSeCompareCategory.HaveSaHaveSe:
{
p.CustomerPartCode = p.SaCustomerPartCode;
p.FactoryPartCode = p.SaFactoryPartCode;
p.ReplaceFactoryPartCode = p.SaFactoryPartCode;
}
break;
case EnumPubSaSeCompareCategory.HaveSaNotHaveSe:
{
p.CustomerPartCode = p.SaCustomerPartCode;
p.FactoryPartCode = p.SaFactoryPartCode;
p.ReplaceFactoryPartCode = p.SaFactoryPartCode;
}
break;
case EnumPubSaSeCompareCategory.NotHaveSaHaveSe:
{
p.CustomerPartCode = p.SeCustomerPartCode;
p.FactoryPartCode = p.SeFactoryPartCode;
p.ReplaceFactoryPartCode = p.SeFactoryPartCode;
}
break;
default:
break;
}
});
}
/// <summary>
/// 创建导出文件结构
/// </summary>
public ExcelExporter BindExcelExporter<T>(List<T> pubSaSeCompareDetailExports, string businessTypeDisplayName) where T : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport, new()
{
//结算核对汇总
var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport()
{
FactoryPartCode = p.Key,
PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty)
}).ToList();
//有结算有发运
var haveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe);
//有结算有发运汇总
var haveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport()
{
FactoryPartCode = p.Key,
PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty)
}).ToList();
//有结算无发运
var haveSaNotHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe);
//有结算无发运
var haveSaNotHaveSeSumExports = haveSaNotHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport()
{
FactoryPartCode = p.Key,
PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty)
}).ToList();
//无结算有发运
var notHaveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe);
//无结算有发运
var notHaveSaHaveSeSumExports = notHaveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport()
{
FactoryPartCode = p.Key,
PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty)
}).ToList();
ExcelExporter excelExporter = new ExcelExporter();
return excelExporter
.Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出")
.SeparateBySheet()
.Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出")
.SeparateBySheet()
.Append(haveSaHaveSeExports, $"{businessTypeDisplayName}有结算有发货明细输出")
.SeparateBySheet()
.Append(haveSaHaveSeSumExports, $"{businessTypeDisplayName}有结算有发货汇总输出")
.SeparateBySheet()
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出")
.SeparateBySheet()
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出");
}
/// <summary>
/// 通知
/// </summary>
public virtual void Notify()
{
_hubContext.Clients.All.ServerToClient("SaSeCompare", "refresh", "");
}
}
}

1
code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs

@ -29,6 +29,7 @@ namespace SettleAccount.Job
{
CreateMap<PubSaSeCompareDiff, PubSaSeCompareDetailExportZhiGongJianBBAC>();
CreateMap<PubSaSeCompareDiff, PubSaSeCompareDetailExportZhiGongJianHBPO>();
CreateMap<PubSaSeCompareDiff, PubSaSeCompareDetailExportMaiDanJianBBAC>();
CreateMap<PubSaSeCompareDiff, PubSaSeCompareDetailExportMaiDanJianHBPO>();
CreateMap<PubSaSeCompareDiff, PubSaSeCompareDetailExportBeiJian>();
CreateMap<PubSaSeCompareDiff, PubSaSeCompareDetailExportYinDuJian>();

7
code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

@ -39,10 +39,11 @@ namespace Win.Sfs.SettleAccount
ConfigureAutoMapper();
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute{ Attempts = 0});
context.Services.AddTransient<PubSaSeCompareExportService>();
context.Services.AddTransient<JisBBACEdiSeCompareExportService>();
context.Services.AddTransient<JisHBPOEdiSeCompareExportService>();
context.Services.AddTransient<JisHBPOEdiSeCompareExportService>();;
context.Services.AddTransient<MaiDanBBACSaSeCompareExportService>();
context.Services.AddTransient<MaiDanHBPOSaSeCompareExportService>();
context.Services.AddTransient<PubSaSeCompareExportService>();
context.Services.AddTransient<SettleAccountImportService>();
context.Services.AddTransient<InvoiceImportService>();

Loading…
Cancel
Save