Browse Source

修改备件不同客户零件号对应一个厂内零件号对比问题

master
mahao 1 year ago
parent
commit
92151b743b
  1. 43
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  2. 38
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TED_SAS_INVOICE.cs
  3. 1
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs
  4. 162
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  5. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs

43
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs

@ -49,6 +49,7 @@ using static Dm.parser.LVal;
using static LinqToDB.Sql; using static LinqToDB.Sql;
using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.Filter;
using Polly; using Polly;
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
namespace Win.Sfs.SettleAccount.Entities.BQ namespace Win.Sfs.SettleAccount.Entities.BQ
{ {
@ -145,7 +146,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
GUID = taskId, GUID = taskId,
TaskState = 0, TaskState = 0,
TaskID = taskId, TaskID = taskId,
TableName = "TED_SA_INV", TableName = "TED_SAS_INVOICE",
Creator = "SAS", Creator = "SAS",
Subscriber = "QAD", Subscriber = "QAD",
Domain = "BJBMPT", Domain = "BJBMPT",
@ -156,12 +157,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var tedSaInvs = invoiceGrpDetails.Join(invoiceGrps, x => x.InvbillNum, y => y.InvbillNum, (x, y) => var tedSaInvs = invoiceGrpDetails.Join(invoiceGrps, x => x.InvbillNum, y => y.InvbillNum, (x, y) =>
{ {
return new TED_SA_INV() return new TED_SAS_INVOICE()
{ {
GUID = GuidGenerator.Create(), GUID = GuidGenerator.Create(),
TaskID = taskId, Dataid = GuidGenerator.Create(),
InvoiceNumber = y.RealnvBillNum, Taskid = taskId,
SASInvoiceNumber = y.InvbillNum, invoiceNumber = y.RealnvBillNum,
sasInvoiceNumber = y.InvbillNum,
Customer = y.ClientCode, Customer = y.ClientCode,
BillTo = y.ClientCode, BillTo = y.ClientCode,
InvoiceDate = y.CreationTime, InvoiceDate = y.CreationTime,
@ -175,26 +177,26 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
Location = $"C{y.ClientCode}", Location = $"C{y.ClientCode}",
begintime = x.BeginDate, begintime = x.BeginDate,
endtime = x.EndDate, endtime = x.EndDate,
Domain = "BJBMPT" domain = "BJBMPT"
}; };
}).ToList(); }).ToList();
var invoiceGrpTedSaInvs = invoiceGrps.Select(t => var invoiceGrpTedSaInvs = invoiceGrps.Select(t =>
{ {
return new TED_SA_INV() return new TED_SAS_INVOICE()
{ {
GUID = GuidGenerator.Create(), GUID = GuidGenerator.Create(),
TaskID = taskId, Taskid = taskId,
InvoiceNumber = t.RealnvBillNum, invoiceNumber = t.RealnvBillNum,
SASInvoiceNumber = t.InvbillNum, sasInvoiceNumber = t.InvbillNum,
Customer = t.ClientCode, Customer = t.ClientCode,
BillTo = t.ClientCode, BillTo = t.ClientCode,
InvoiceDate = t.CreationTime, InvoiceDate = t.CreationTime,
Site = "BJ02", Site = "BJ02",
TaxRate = 0.13m, TaxRate = 0.13m,
Location = $"C{t.ClientCode}", Location = $"C{t.ClientCode}",
InvoiceTax = t.Amt, InvoiceTax = t.TaxDiff,
Domain = "BJBMPT" domain = "BJBMPT"
}; };
}); });
@ -205,7 +207,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
await SubmitToQadHongChong(invoiceGrps.Select(t => t.ParentInvbillNum).ToList()).ConfigureAwait(false); await SubmitToQadHongChong(invoiceGrps.Select(t => t.ParentInvbillNum).ToList()).ConfigureAwait(false);
await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false); await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
await _exChangeCenterDbContext.Set<TED_SA_INV>().AddRangeAsync(tedSaInvs).ConfigureAwait(false); await _exChangeCenterDbContext.Set<TED_SAS_INVOICE>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
invoiceGrps.ForEach(t => t.State = SettleBillState.QAD); invoiceGrps.ForEach(t => t.State = SettleBillState.QAD);
await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false); await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
@ -252,7 +254,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
GUID = taskId, GUID = taskId,
TaskState = 0, TaskState = 0,
TaskID = taskId, TaskID = taskId,
TableName = "TED_SA_INV", TableName = "TED_SAS_INVOICE",
Creator = "SAS", Creator = "SAS",
Subscriber = "QAD", Subscriber = "QAD",
Domain = "BJBMPT", Domain = "BJBMPT",
@ -263,12 +265,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var tedSaInvs = invoiceGrpDetails.Join(invoiceGrps, x => x.InvbillNum, y => y.InvbillNum, (x, y) => var tedSaInvs = invoiceGrpDetails.Join(invoiceGrps, x => x.InvbillNum, y => y.InvbillNum, (x, y) =>
{ {
return new TED_SA_INV() return new TED_SAS_INVOICE()
{ {
GUID = GuidGenerator.Create(), GUID = GuidGenerator.Create(),
TaskID = taskId, Dataid = GuidGenerator.Create(),
InvoiceNumber = y.RealnvBillNum, Taskid = taskId,
SASInvoiceNumber = y.InvbillNum, invoiceNumber = y.RealnvBillNum,
sasInvoiceNumber = y.InvbillNum,
Customer = y.ClientCode, Customer = y.ClientCode,
BillTo = y.ClientCode, BillTo = y.ClientCode,
InvoiceDate = y.CreationTime, InvoiceDate = y.CreationTime,
@ -282,14 +285,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
Location = $"C{y.ClientCode}", Location = $"C{y.ClientCode}",
begintime = x.BeginDate, begintime = x.BeginDate,
endtime = x.EndDate, endtime = x.EndDate,
Domain = "BJBMPT" domain = "BJBMPT"
}; };
}).ToList(); }).ToList();
if (tedSaInvs.Any()) if (tedSaInvs.Any())
{ {
await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false); await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
await _exChangeCenterDbContext.Set<TED_SA_INV>().AddRangeAsync(tedSaInvs).ConfigureAwait(false); await _exChangeCenterDbContext.Set<TED_SAS_INVOICE>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
} }
} }

38
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TED_SAS_INVOICE.cs

@ -0,0 +1,38 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
public class TED_SAS_INVOICE
{
public int UID { get; set; }
public string invoiceNumber { get; set; }
public string sasInvoiceNumber { get; set; }
public string Customer { get; set; }
public string BillTo { get; set; }
public DateTime InvoiceDate { get; set; }
public string Site { get; set; }
public string TYPE { get; set; }
public string PartNumber { get; set; }
public decimal InvoiceQuatity { get; set; }
public decimal Price { get; set; }
public string Supplier { get; set; }
public string Remark { get; set; }
public decimal InvoiceNetAmount { get; set; }
public decimal InvoiceTaxAmount { get; set; }
public decimal TaxRate { get; set; }
public string Location { get; set; }
public decimal InvoiceNet { get; set; }
public decimal InvoiceTax { get; set; }
public DateTime begintime { get; set; }
public DateTime endtime { get; set; }
public string commandtype { get; set; }
public string domain { get; set; }
public string LINE { get; set; }
public Guid Taskid { get; set; }
public Guid Dataid { get; set; }
[Key]
public Guid GUID { get; set; }
}
}

1
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/ExChangeCenterDbContext.cs

@ -10,6 +10,7 @@ namespace Win.Sfs.SettleAccount.EntityFrameworkCore
public class ExChangeCenterDbContext : DbContext public class ExChangeCenterDbContext : DbContext
{ {
public DbSet<TEA_TASK_SUB> TEA_TASK_SUB { get; set; } public DbSet<TEA_TASK_SUB> TEA_TASK_SUB { get; set; }
public DbSet<TED_SAS_INVOICE> TED_SAS_INVOICE { set; get; }
public DbSet<TED_SA_INV> TED_SA_INV { set; get; } public DbSet<TED_SA_INV> TED_SA_INV { set; get; }
public ExChangeCenterDbContext(DbContextOptions<ExChangeCenterDbContext> options) : base(options) public ExChangeCenterDbContext(DbContextOptions<ExChangeCenterDbContext> options) : base(options)

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

@ -176,6 +176,11 @@ namespace SettleAccount.Job.Services.Report
{ {
return GetSaSeCompareDataYinDu(version); return GetSaSeCompareDataYinDu(version);
} }
//备件对比
if (businessType == EnumBusinessType.BeiJian)
{
return GetSaSeCompareDataBeiJian(version);
}
//结算 //结算
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>() var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == businessType where sa.BusinessType == businessType
@ -412,6 +417,163 @@ namespace SettleAccount.Job.Services.Report
}).ToList(); }).ToList();
return haveSaHaveSeList.Union(haveSaNotHaveSeList).Union(notHaveSaHaveSeList).ToList(); return haveSaHaveSeList.Union(haveSaNotHaveSeList).Union(notHaveSaHaveSeList).ToList();
} }
/// <summary>
/// 获取比对数据备件
/// </summary>
private List<SaSeCompareDiff> GetSaSeCompareDataBeiJian(int version)
{
var businessType = EnumBusinessType.BeiJian;
//结算
var saGroup = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == businessType
group sa by new { sa.PN, sa.PartCode } into groupItem
select new
{
groupItem.Key.PN,
FactoryPartCode = groupItem.Key.PartCode,
Qty = groupItem.Sum(t => t.Qty),
Version = groupItem.Max(t => t.Version),
LU = groupItem.Max(t => t.LU),
SettleDate = groupItem.Max(t => t.SettleDate)
};
var saGroupByMappingType = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == businessType && sa.MappingType == EnumMappingType.None
group sa by new { sa.PN, sa.PartCode } into groupItem
select new
{
groupItem.Key.PN,
FactoryPartCode = groupItem.Key.PartCode,
Qty = groupItem.Sum(t => t.Qty),
Version = groupItem.Max(t => t.Version),
LU = groupItem.Max(t => t.LU),
SettleDate = groupItem.Max(t => t.SettleDate)
};
var saGroupByVersion = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
group sa by new { sa.PN, sa.PartCode } into groupItem
select new
{
groupItem.Key.PN,
FactoryPartCode = groupItem.Key.PartCode,
Qty = groupItem.Sum(t => t.Qty),
Version = groupItem.Max(t => t.Version),
LU = groupItem.Max(t => t.LU),
SettleDate = groupItem.Max(t => t.SettleDate)
};
//发运
var seGroup = from se in _settleAccountDbContext.Set<PUB_SE_DETAIL>()
where se.BusinessType == businessType
group se by new { se.PN, se.FactoryPartCode } into groupItem
select new
{
groupItem.Key.PN,
groupItem.Key.FactoryPartCode,
Qty = groupItem.Sum(t => t.Qty),
LU = groupItem.Max(t => t.LU),
WmsBillNum = groupItem.Max(t => t.WmsBillNum),
ShippingDate = groupItem.Max(t => t.ShippingDate),
ToLocCode = groupItem.Max(t => t.ToLocCode),
ToErpLocCode = groupItem.Max(t => t.ToErpLocCode)
};
//有结算无发运
var haveSaNotHaveSeList = (from sa in saGroupByMappingType
join se in seGroup
on new { sa.PN, sa.FactoryPartCode } equals new { se.PN, se.FactoryPartCode }
into temp
from se in temp.DefaultIfEmpty()
where se.PN == null
select new SaSeCompareDiff()
{
Version = sa.Version,
CustomerOfflineTime = sa.SettleDate,
PN = sa.PN,
SAQty = sa.Qty,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.FactoryPartCode,
CustomerPartCode = sa.LU
}).ToList();
//无结算有发运
var notHaveSaHaveSeList = (from se in seGroup
join sa in saGroup
on new { se.PN, se.FactoryPartCode } equals new { sa.PN, sa.FactoryPartCode }
into temp
from sa in temp.DefaultIfEmpty()
where sa.PN == null
select new SaSeCompareDiff()
{
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
PN = se.PN,
SEQty = se.Qty,
ToLocCode = se.ToLocCode,
ToErpLocCode = se.ToErpLocCode,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
CustomerPartCode = se.LU
}).ToList();
//有结算有发运
var haveSaHaveSeList = (from sa in saGroupByVersion
from se in seGroup
where sa.PN == se.PN && sa.FactoryPartCode == se.FactoryPartCode
select new SaSeCompareDiff()
{
Version = sa.Version,
WmsBillNum = se.WmsBillNum,
ShippingDate = se.ShippingDate,
CustomerOfflineTime = sa.SettleDate,
PN = sa.PN,
SAQty = sa.Qty,
SEQty = se.Qty,
ToLocCode = se.ToLocCode,
ToErpLocCode = se.ToErpLocCode,
SeCustomerPartCode = se.LU,
SeFactoryPartCode = se.FactoryPartCode,
SaCustomerPartCode = sa.LU,
SaFactoryPartCode = sa.FactoryPartCode,
CustomerPartCode = sa.LU
}).ToList();
var saGroupByPnPartCodeLu = from sa in _settleAccountDbContext.Set<PUB_SA_DETAIL>()
where sa.BusinessType == businessType && sa.Version == version
group sa by new { sa.PN, sa.PartCode, sa.LU } into groupItem
select new
{
groupItem.Key.PN,
FactoryPartCode = groupItem.Key.PartCode,
groupItem.Key.LU,
Qty = groupItem.Sum(t => t.Qty),
Version = groupItem.Max(t => t.Version),
SettleDate = groupItem.Max(t => t.SettleDate)
};
var replaceLus = saGroupByPnPartCodeLu.ToList().GroupBy(t => new { t.PN, t.FactoryPartCode }).Select(t =>
{
return new
{
t.Key.PN,
t.Key.FactoryPartCode,
LU = t.Select(t => t.LU).Distinct()
};
}).Where(t => t.LU.Count() > 1);
if (replaceLus.Any())
{
haveSaHaveSeList.ForEach(haveSaHaveSe =>
{
var replaceLu = replaceLus.FirstOrDefault(t => t.PN == haveSaHaveSe.PN && t.FactoryPartCode == haveSaHaveSe.SaFactoryPartCode);
if (replaceLu != null)
{
haveSaHaveSe.SaCustomerPartCode = string.Join(",", replaceLu.LU);
}
});
}
return haveSaHaveSeList.Union(haveSaNotHaveSeList).Union(notHaveSaHaveSeList).ToList();
}
#endregion #endregion
} }
} }

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

@ -323,7 +323,7 @@ namespace SettleAccount.Job.Services.Report
select sa).ToList(); select sa).ToList();
if (canSaDetails.Any()) if (canSaDetails.Any())
{ {
var canSaDetailsUpdate = canSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) => var canSaDetailsUpdate = canSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.PartCode }, i => new { i.PN, PartCode = i.FactoryPartCode }, (o, i) =>
{ {
o.ErpLoc = i.ToErpLocCode; o.ErpLoc = i.ToErpLocCode;
o.RealPartCode = i.ReplaceFactoryPartCode; o.RealPartCode = i.ReplaceFactoryPartCode;
@ -338,7 +338,7 @@ namespace SettleAccount.Job.Services.Report
select sa).ToList(); select sa).ToList();
if (notSaDetails.Any()) if (notSaDetails.Any())
{ {
var notSaDetailsUpdate = notSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) => var notSaDetailsUpdate = notSaDetails.Join(haveSaHaveSes, o => new { o.PN, o.PartCode }, i => new { i.PN, PartCode = i.FactoryPartCode }, (o, i) =>
{ {
o.ErpLoc = i.ToErpLocCode; o.ErpLoc = i.ToErpLocCode;
o.RealPartCode = i.ReplaceFactoryPartCode; o.RealPartCode = i.ReplaceFactoryPartCode;
@ -368,7 +368,7 @@ namespace SettleAccount.Job.Services.Report
.ToList(); .ToList();
if (saDetails.Any()) if (saDetails.Any())
{ {
var saDetailsUpdate = saDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) => var saDetailsUpdate = saDetails.Join(haveSaHaveSes, o => new { o.PN, o.PartCode }, i => new { i.PN, PartCode = i.FactoryPartCode }, (o, i) =>
{ {
var mappingType = (i.SAQty - i.SEQty) switch var mappingType = (i.SAQty - i.SEQty) switch
{ {

Loading…
Cancel
Save