Browse Source

更新接口

master
学 赵 11 months ago
parent
commit
ca35c4c824
  1. 233
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/INVOICE_SERVICE.cs
  2. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BalanceSumService .cs
  3. 129
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs
  4. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/InvoiceSyncQad.cs
  5. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TED_SAS_INVOICE.cs

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

@ -5,6 +5,8 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using DocumentFormat.OpenXml.Office2013.Word;
using DocumentFormat.OpenXml.Presentation;
using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv;
@ -12,8 +14,10 @@ using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Newtonsoft.Json;
using Omu.ValueInjecter;
using Polly;
using SettleAccount.Domain.BQ;
@ -112,6 +116,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// * 成功提交后修改状态为已提交QAD
/// </remarks>
[HttpPost]
[UnitOfWork(false)]
public virtual async Task<IActionResult> SubmitToQad(List<string> invbillNums)
{
_globalConfigOptions.IsSyncInvoiceQadState = true;
@ -121,7 +126,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
}
return new OkResult();
}
[UnitOfWork(false)]
/// <summary>
/// 提交到QAD
/// </summary>
@ -135,7 +140,7 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
var _detail = await _bbacMng.GetDetailAsync(invbillNum, EnumBusinessType.MaiDanJianBBAC).ConfigureAwait(false);//查出买单数量
var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>()
var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>().AsNoTracking()
.Where(t => t.InvbillNum == invbillNum)
.ToList();
if (invoiceGrpDetails.Any())
@ -156,32 +161,38 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
UpdateTime = DateTime.Now,
};
List<INVOICE_WAIT_DETAIL> invdetials = new List<INVOICE_WAIT_DETAIL>();
foreach (var itm in invoiceGrpDetails)
var invoiceGrpDetails1 = JsonConvert.DeserializeObject<List<INVOICE_WAIT_DETAIL>>(JsonConvert.SerializeObject(invoiceGrpDetails));
foreach (var itm in invoiceGrpDetails1)
{
itm.SetProperty("ErpToLoc",$"C{invoiceGrp.ClientCode}");
invdetials.Add(itm);//添加发票明细
var first = _detail.FirstOrDefault(p => p.ContractDocID == itm.Extend1 && p.PartCode == itm.PartCode );
if (first == null)
{
continue;
}
itm.Qty = itm.Qty - first.Qty;//发票总数中去除
itm.Amt = Math.Round(itm.Qty * itm.PRICE, 2);
var inv = new INVOICE_WAIT_DETAIL();//添加买单件
inv.InjectFrom(itm);
inv.Qty= first.Qty;
inv.Amt = Math.Round(first.Qty * itm.PRICE, 2);
inv.BussiessType = EnumBusinessType.MaiDanJianBBAC;
if (invoiceGrp.Site == "1046")
var first = _detail.FirstOrDefault(p => p.ContractDocID == itm.Extend1 && p.PartCode == itm.PartCode);
if (first == null)
{
inv.SetProperty("ErpToLoc", "CC16");
inv.SetProperty("ErpToLoc", $"C{invoiceGrp.ClientCode}");
invdetials.Add(itm);//添加发票明细
continue;
}
if (invoiceGrp.Site == "1040")
else
{
inv.SetProperty("ErpToLoc", "CC11");
if (itm.Qty > first.Qty)
{
inv.Qty = itm.Qty - first.Qty;//发票总数中去除
inv.Amt = Math.Round(itm.Qty * itm.PRICE, 2);
}
inv.BussiessType = EnumBusinessType.MaiDanJianBBAC;
if (invoiceGrp.Site == "1046")
{
inv.SetProperty("ErpToLoc", "CC16");
}
if (invoiceGrp.Site == "1040")
{
inv.SetProperty("ErpToLoc", "CC11");
}
invdetials.Add(inv);
}
invdetials.Add(inv);
}
for (var i = 0; i < invdetials.Count; i++)
{
@ -212,50 +223,39 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
});
}
var invbefore = invoiceGrp.TaxAmt + invoiceGrp.TaxDiff;
var invafter=tedSaInvs.Sum(p => p.InvoiceNetAmount) + tedSaInvs.Sum(p => p.InvoiceTaxAmount);
var tedsaInvs1 = JsonConvert.DeserializeObject<List<TED_SAS_INVOICE>>(JsonConvert.SerializeObject(tedSaInvs));
var invbefore = invoiceGrp.TaxAmt + invoiceGrp.TaxDiff;
var invafter = tedsaInvs1.Sum(p => p.InvoiceNetAmount) + tedsaInvs1.Sum(p => p.InvoiceTaxAmount);
var invdiff = invbefore - invafter;
tedSaInvs.FirstOrDefault(p => p.LINE == "2").InvoiceTaxAmount +=invdiff;
tedSaInvs.FirstOrDefault(p => p.LINE == "1").InvoiceTaxAmount += invoiceGrp.TaxDiff;
var line1 = tedsaInvs1.FirstOrDefault(p => p.LINE == "1");
var line2 = tedsaInvs1.FirstOrDefault(p => p.LINE == "2");
line2.InvoiceTaxAmount += invdiff;
line1.InvoiceTaxAmount += invoiceGrp.TaxDiff;
//红冲发票提交QAD
if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum))
{
await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum).ConfigureAwait(false);
}
await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
await _exChangeCenterDbContext.Set<TED_SAS_INVOICE>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false);
await _exChangeCenterDbContext.BulkInsertAsync(tedsaInvs1).ConfigureAwait(false);
invoiceGrp.State = SettleBillState.QAD;
//构建发票同步Qad状态表数据
_repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp });
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false);
await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
var retryPolicyAsync = Policy.Handle<Exception>().WaitAndRetryAsync(new[] {
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5)
}, (exception, timeSpan, retryCount, context) =>
{
_logger.LogError($"提交到QAD,修改发票状态执行失败,第 {retryCount} 次重试");
});
await retryPolicyAsync.ExecuteAsync(async () => await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false)).ConfigureAwait(false);
//await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
// var retryPolicyAsync = Policy.Handle<Exception>().WaitAndRetryAsync(new[] {
// TimeSpan.FromSeconds(1),
// TimeSpan.FromSeconds(5),
// TimeSpan.FromSeconds(5),
// TimeSpan.FromSeconds(5)
//}, (exception, timeSpan, retryCount, context) =>
//{
// _logger.LogError($"提交到QAD,修改发票状态执行失败,第 {retryCount} 次重试");
//});
// await retryPolicyAsync.ExecuteAsync(async () => await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false)).ConfigureAwait(false);
}
}
else
{
@ -279,9 +279,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
CreateTime = DateTime.Now,
UpdateTime = DateTime.Now,
};
for (var i = 0; i < invoiceGrpDetails.Count; i++)
{
var invoiceGrpDetail = invoiceGrpDetails[i];
@ -316,118 +313,42 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum).ConfigureAwait(false);
}
await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
await _exChangeCenterDbContext.Set<TED_SAS_INVOICE>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
//await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
//await _exChangeCenterDbContext.Set<TED_SAS_INVOICE>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
//invoiceGrp.State = SettleBillState.已提交QAD;
////构建发票同步Qad状态表数据
//await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false);
await _exChangeCenterDbContext.BulkInsertAsync(new List<TEA_TASK_SUB>() { teaTaskSub }).ConfigureAwait(false);
await _exChangeCenterDbContext.BulkInsertAsync(tedSaInvs).ConfigureAwait(false);
invoiceGrp.State = SettleBillState.QAD;
//构建发票同步Qad状态表数据
_repository.DbContext.BulkUpdateAsync(new List<INVOICE_GRP>() { invoiceGrp });
await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false);
await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
var retryPolicyAsync = Policy.Handle<Exception>().WaitAndRetryAsync(new[] {
TimeSpan.FromSeconds(1),
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5),
TimeSpan.FromSeconds(5)
}, (exception, timeSpan, retryCount, context) =>
{
_logger.LogError($"提交到QAD,修改发票状态执行失败,第 {retryCount} 次重试");
});
await retryPolicyAsync.ExecuteAsync(async () => await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false)).ConfigureAwait(false);
}
}
// await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
// var retryPolicyAsync = Policy.Handle<Exception>().WaitAndRetryAsync(new[] {
// TimeSpan.FromSeconds(1),
// TimeSpan.FromSeconds(5),
// TimeSpan.FromSeconds(5),
// TimeSpan.FromSeconds(5)
//}, (exception, timeSpan, retryCount, context) =>
//{
// _logger.LogError($"提交到QAD,修改发票状态执行失败,第 {retryCount} 次重试");
//});
// await retryPolicyAsync.ExecuteAsync(async () => await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false)).ConfigureAwait(false);
}
}
//if (invoiceGrp == null)
//{
// return;
//}
//var invoiceGrpDetails = _settleAccountDbContext.Set<INVOICE_WAIT_DETAIL>()
// .Where(t => t.InvbillNum == invbillNum)
// .ToList();
//if (invoiceGrpDetails.Any())
//{
// var tedSaInvs = new List<TED_SAS_INVOICE>();
// var taskId = GuidGenerator.Create();
// var teaTaskSub = new TEA_TASK_SUB()
// {
// GUID = taskId,
// TaskState = 0,
// TaskID = taskId,
// TableName = "TED_SAS_INVOICE",
// Creator = "SAS",
// Subscriber = "QAD",
// Domain = "BJBMPT",
// Site = "BJ02",
// CreateTime = DateTime.Now,
// UpdateTime = DateTime.Now,
// };
// for (var i = 0; i < invoiceGrpDetails.Count; i++)
// {
// var invoiceGrpDetail = invoiceGrpDetails[i];
}
// tedSaInvs.Add(new TED_SAS_INVOICE()
// {
// GUID = GuidGenerator.Create(),
// Dataid = GuidGenerator.Create(),
// Taskid = taskId,
// invoiceNumber = invoiceGrp.RealnvBillNum,
// sasInvoiceNumber = invoiceGrp.InvbillNum,
// Customer = invoiceGrp.ClientCode,
// BillTo = invoiceGrp.ClientCode,
// InvoiceDate = invoiceGrp.CreationTime,
// Site = "BJ02",
// PartNumber = invoiceGrpDetail.PartCode,
// InvoiceQuatity = invoiceGrpDetail.Qty,
// Price = invoiceGrpDetail.PRICE,
// InvoiceNetAmount = invoiceGrpDetail.Amt,
// InvoiceTaxAmount = Math.Round(invoiceGrpDetail.Amt * 0.13m, 2),
// TaxRate = 0.13m,
// Location = invoiceGrp.GetProperty("ErpToLoc",string.Empty),
// begintime = invoiceGrpDetail.BeginDate,
// endtime = invoiceGrpDetail.EndDate,
// domain = "BJBMPT",
// LINE = (i + 1).ToString()
// });
// }
// tedSaInvs.FirstOrDefault().InvoiceTaxAmount += invoiceGrp.TaxDiff;
// //红冲发票提交QAD
// if (!string.IsNullOrEmpty(invoiceGrp.ParentInvbillNum))
// {
// await SubmitToQadHongChongAsync(invoiceGrp.ParentInvbillNum).ConfigureAwait(false);
// }
// await _exChangeCenterDbContext.Set<TEA_TASK_SUB>().AddAsync(teaTaskSub).ConfigureAwait(false);
// await _exChangeCenterDbContext.Set<TED_SAS_INVOICE>().AddRangeAsync(tedSaInvs).ConfigureAwait(false);
// invoiceGrp.State = SettleBillState.已提交QAD;
// //构建发票同步Qad状态表数据
// await BindInvoiceSyncQadAsync(teaTaskSub, invoiceGrp.RealnvBillNum, invoiceGrp.InvbillNum, invoiceGrp.ClientCode).ConfigureAwait(false);
// await _exChangeCenterDbContext.SaveChangesAsync().ConfigureAwait(false);
// var retryPolicyAsync = Policy.Handle<Exception>().WaitAndRetryAsync(new[] {
// TimeSpan.FromSeconds(1),
// TimeSpan.FromSeconds(5),
// TimeSpan.FromSeconds(5),
// TimeSpan.FromSeconds(5)
// }, (exception, timeSpan, retryCount, context) =>
// {
// _logger.LogError($"提交到QAD,修改发票状态执行失败,第 {retryCount} 次重试");
// });
// await retryPolicyAsync.ExecuteAsync(async () => await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false)).ConfigureAwait(false);
//}
}
/// <summary>
/// 红冲发票提交到QAD
@ -505,12 +426,14 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
{
var invoiceSyncQad = new InvoiceSyncQad(teaTaskSub.TaskID, invoiceNumber, sasInvoiceNumber)
{
TableName = teaTaskSub.TableName,
Domain = teaTaskSub.Domain,
Site = teaTaskSub.Site,
Customer = customer
};
await _settleAccountDbContext.Set<InvoiceSyncQad>().AddAsync(invoiceSyncQad).ConfigureAwait(false);
await _settleAccountDbContext.BulkInsertAsync(new List<InvoiceSyncQad>() { invoiceSyncQad });
}
/// <summary>

8
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/BalanceSumService .cs

@ -48,21 +48,13 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Syncs
var _filename = exportName.FirstOrDefault();
var year = property.Where(p => p.Name == "Year").FirstOrDefault().Value;
var list=_dapper.GetBalanceSum(year);
ExcelExporter _exporter = new ExcelExporter();//导出Excel
var result = _exporter.Append(list.ToList(), "余额表")
//.SeparateBySheet()
//.Append(_reversels.ToList(), "有发货无结算对比")
.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(_filename, result.Result, true);
return id.ToString();
}

129
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/VmiAppService.cs

@ -12,6 +12,7 @@ using System.Text.Json;
using System.Threading.Tasks;
using AutoMapper;
using ClosedXML.Excel;
using Dapper;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Wordprocessing;
using EFCore.BulkExtensions;
@ -197,23 +198,55 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
public async Task<PagedResultDto<VmiBalanceNewDto>> Balance(RequestDto input)
{
string sql = "select * from (\n" +
"SELECT t.VinCode,t.RealPartCode,t.ErptoLoc, ShippingTime, ReceiveTime,(isnull(t.[100],0) + isnull(t.[200],0) + isnull(t.[400],0) + isnull(t.[500],0)+isnull(t.[600],0)) SumQty,\n" +
"isnull(t.[100],0) ShippingQty,isnull(t.[200],0) SettleQty , isnull(t.[400],0) ReturnQty,isnull(t.[500],0) InputQty,isnull(t.[600],0) OutputQty\n" +
"FROM (\n" +
"SELECT VinCode, RealPartCode, ErpToLoc, [100], [200], [400], [500],[600]\n" +
"FROM (\n" +
"SELECT VinCode, RealPartCode, ErpToLoc, ChangedQty, LogType\n" +
"FROM Set_VmiLog\n" +
") AS src\n" +
"PIVOT (\n" +
"SUM(ChangedQty)\n" +
"FOR LogType IN ([100],[200],[400],[500],[600])\n" +
") AS piv\n" +
") AS t\n" +
"left JOIN (\n" +
"SELECT VinCode, RealPartCode, ErpToLoc, MAX(BillTime) shippingtime\n" +
"FROM Set_VmiLog\n" +
"WHERE LogType = 100\n" +
"GROUP BY VinCode, RealPartCode, ErpToLoc\n" +
") AS t1 ON t1.ErpToLoc = t.ErpToLoc AND t1.RealPartCode = t.RealPartCode AND t1.VinCode = t.VinCode\n" +
"left JOIN (\n" +
"SELECT VinCode, RealPartCode, ErpToLoc, MAX(BillTime) receivetime\n" +
"FROM Set_VmiLog\n" +
"WHERE LogType = 200\n" +
"GROUP BY VinCode, RealPartCode, ErpToLoc\n" +
") AS t2 ON t2.ErpToLoc = t.ErpToLoc AND t2.RealPartCode = t.RealPartCode AND t2.VinCode = t1.VinCode) temp55\n" +
"WHERE sumqty <> 0\n";
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var db = new SettleAccountDbContext(options);
var query = db.Set<VmiLog>().FromSqlRaw("select * from Set_VmiLog");
var filters = input.Filters.ToLambda<VmiLog>();
var query = db.Database.GetDbConnection().Query<VmiBalanceNewDto>(sql).AsQueryable();
var filters = input.Filters.ToLambda<VmiBalanceNewDto>();
if (input.Filters.Count > 0)
{
query = query.Where(input.Filters.ToLambda<VmiLog>());
query = query.Where(input.Filters.ToLambda<VmiBalanceNewDto>());
}
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode }).Select(o => new VmiBalanceNewDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), BillTime = o.Max(o => o.BillTime) }).Where(p => p.Qty != 0);
var totalCount = query2.Count();
//query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
//var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode }).Select(o => new VmiBalanceNewDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), BillTime = o.Max(o => o.BillTime) }).Where(p => p.Qty != 0);
var totalCount = query.Count();
//query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
//var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode,o.VinCode }).Select(o => new VmiBalanceDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.Qty),LastTime=o.Max(o=>o.ChangedTime) });
//var totalCount = query2.Count();
var entities = await query2.PageBy(input.SkipCount, input.MaxResultCount).ToListAsync().ConfigureAwait(false);
var entities = query.PageBy(input.SkipCount, input.MaxResultCount).ToList();
//var entities = await _balanceRepository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true).ConfigureAwait(false);
//var totalCount = await _balanceRepository.GetCountByFilterAsync(input.Filters).ConfigureAwait(false);
return new PagedResultDto<VmiBalanceNewDto>(totalCount, entities);
@ -225,26 +258,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[HttpPost]
public async Task<string> BalanceExport(RequestDto input)
{
var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
using var db = new SettleAccountDbContext(options);
var query = db.Set<VmiLog>().FromSqlRaw("select VinCode,ErpToLoc,RealPartCode,ChangedQty ,BillTime from Set_VmiLog");
var filters = input.Filters.ToLambda<VmiLog>();
if (input.Filters.Count > 0)
{
query = query.Where(input.Filters.ToLambda<VmiLog>());
}
query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode }).Select(o => new VmiBalanceNewDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), BillTime = o.Max(o => o.BillTime) }).Where(p => p.Qty != 0);
var entities = query2.ToList();
//var connectionString = this._serviceProvider.GetRequiredService<IConfiguration>().GetConnectionString("SettleAccountService");
//var options = new DbContextOptionsBuilder<SettleAccountDbContext>().UseSqlServer(connectionString).Options;
//using var db = new SettleAccountDbContext(options);
//var query = db.Set<VmiLog>().FromSqlRaw("select VinCode,ErpToLoc,RealPartCode,ChangedQty ,BillTime from Set_VmiLog");
//var filters = input.Filters.ToLambda<VmiLog>();
//if (input.Filters.Count > 0)
//{
// query = query.Where(input.Filters.ToLambda<VmiLog>());
//}
//query = string.IsNullOrEmpty(input.Sorting) ? query : DynamicQueryableExtensions.OrderBy(query, input.Sorting);
//var query2 = query.GroupBy(o => new { o.ErpToLoc, o.RealPartCode, o.VinCode }).Select(o => new VmiBalanceNewDto { VinCode = o.Key.VinCode, ErpToLoc = o.Key.ErpToLoc, RealPartCode = o.Key.RealPartCode, Qty = o.Sum(o => o.ChangedQty), BillTime = o.Max(o => o.BillTime) }).Where(p => p.Qty != 0);
//var entities = query2.ToList();
// var entities = await _balanceRepository.GetListByFilterAsync(input.Filters).ConfigureAwait(false);
var fileName = $"库存余额_{DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss")}.xlsx";
var content = this.GetContent(entities, "库存余额");
await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
//var content = this.GetContent(entities, "库存余额");
//await _fileContainer.SaveAsync(fileName, content, true).ConfigureAwait(false);
return fileName;
}
@ -1335,15 +1365,54 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
[Display(Name = "厂内零件号", Order = 3)]
public string RealPartCode { get; set; }//原始
[Display(Name = "数量", Order = 4)]
public decimal Qty { get; set; }
[Display(Name = "发运时间", Order = 5)]
public DateTime? BillTime { get; set; }
[Display(Name = "最后发运入库时间", Order = 3)]
public DateTime? ShippingTime {set;get;}
[Display(Name = "最后结算出库时间", Order = 3)]
public DateTime? ReceiveTime { set; get; }
[Display(Name = "数量合计", Order = 3)]
public decimal? SumQty {set;get;}
[Display(Name = "发运数量", Order = 3)]
public decimal? ShippingQty {set;get;}
[Display(Name = "结算数量", Order = 3)]
public decimal? SettleQty {set;get;}
[Display(Name = "退货数量", Order = 3)]
public decimal? ReturnQty {set;get;}
[Display(Name = "调整入库", Order = 3)]
public decimal? InputQty {set;get;}
[Display(Name = "调整出库", Order = 3)]
public decimal? OutputQty { set; get; }
}
public class VmiBalanceReqDto
{
[Display(Name = "生产码", Order = 1)]
public string VinCode { get; set; }
[Display(Name = "ERP库位", Order = 2)]
public string ErpToLoc { get; set; }
[Display(Name = "厂内零件号", Order = 3)]
public string RealPartCode { get; set; }//原始
//[Display(Name = "最后发运入库时间", Order = 3)]
//public DateTime? ShippingTime { set; get; }
//[Display(Name = "最后结算出库时间", Order = 3)]
//public DateTime? ReceiveTime { set; get; }
//[Display(Name = "数量合计", Order = 3)]
//public decimal? SumQty { set; get; }
//[Display(Name = "发运数量", Order = 3)]
//public decimal? ShippingQty { set; get; }
//[Display(Name = "结算数量", Order = 3)]
//public decimal? SettleQty { set; get; }
//[Display(Name = "退货数量", Order = 3)]
//public decimal? ReturnQty { set; get; }
//[Display(Name = "调整入库", Order = 3)]
//public decimal? InputQty { set; get; }
//[Display(Name = "调整出库", Order = 3)]
//public decimal? OutputQty { set; get; }
}

4
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/InvoiceSyncQad.cs

@ -80,6 +80,10 @@ namespace SettleAccount.Domain.BQ
SasInvoiceNumber = sasInvoiceNumber;
}
public void SetId(Guid p_id)
{
Id = p_id;
}
public void UpdateTaskState(int taskState)
{
TaskState = taskState;

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

@ -1,12 +1,18 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.DirectoryServices.ActiveDirectory;
using System.Security.Policy;
using System.Threading.Tasks;
using Magicodes.ExporterAndImporter.Core;
using Win.Sfs.Shared;
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; }

Loading…
Cancel
Save