Browse Source

修改销价格单路由

master
mahao 1 year ago
parent
commit
644cfccced
  1. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs
  2. 10
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs
  3. 4
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs
  4. 114
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  5. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs

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

@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
@ -48,7 +48,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// 导入
/// </summary>
[HttpPost]
[Route("Import")]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files)
{
ExportImporter _exportImporter = new ExportImporter();
@ -94,7 +93,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// 导出
/// </summary>
[HttpPost]
[Route("Export")]
public async Task<string> ExportAsync(RequestDto input)
{
string fileName = $"采购价格单_{Guid.NewGuid()}.xlsx";
@ -115,7 +113,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// 获取列表
/// </summary>
[HttpPost]
[Route("list")]
public async Task<PagedResultDto<PURCHASE_PRICE_DTO>> GetListAsync(RequestDto input)
{
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true);

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

@ -80,11 +80,17 @@ public class PubSaSeCompareDiff
[Display(Name = "定价")]
public decimal FixPrice { get; set; }
/// <summary>
/// 原始零件号
/// </summary>
[Display(Name = "原始零件号")]
public string PrimitiveLU { get; set; }
/// <summary>
/// 替换零件号
/// </summary>
[Display(Name = "替换零件号")]
public string RepLU { get; set; }
public string ReplaceLU { get; set; }
/// <summary>
/// 零件号
@ -284,7 +290,7 @@ public class PubSaSeCompareSumExport
/// 差异数量
/// </summary>
[ExporterHeader(DisplayName = "差异数量")]
public decimal DiffQty { set; get; }
public decimal DiffQty => SAQty - SEQty;
}
[ExcelExporter(MaxRowNumberOnASheet = 900000)]

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

@ -47,8 +47,8 @@ public class PubSaSeCompareDapperRepository : DapperRepository<SettleAccountDbCo
'' MateType,
B.Price FixPrice
FROM
(SELECT SUM(QTY) SEQty,LU,PN,WmsBillNum,ShippingDate FROM Set_PUB_SE_DETAIL WHERE BusinessType = {businessType} GROUP BY LU,PN,WmsBillNum,ShippingDate) A
FULL JOIN (SELECT SUM(QTY) SAQty,LU,PN,Price,SettleDate FROM Set_PUB_SA_DETAIL WHERE BusinessType = {businessType} GROUP BY LU,PN,Price,SettleDate) B ON A.LU= B.LU AND A.PN= B.PN
(SELECT SUM(QTY) SEQty,LU,PN,MAX(WmsBillNum) WmsBillNum,MAX(ShippingDate) ShippingDate FROM Set_PUB_SE_DETAIL WHERE BusinessType = {businessType} GROUP BY LU,PN) A
FULL JOIN (SELECT SUM(QTY) SAQty,LU,PN,MAX(Price) Price,MAX(SettleDate) SettleDate FROM Set_PUB_SA_DETAIL WHERE BusinessType = {businessType} GROUP BY LU,PN) B ON A.LU= B.LU AND A.PN= B.PN
ORDER BY B.SettleDate DESC;
";
return DbConnection.Query<PubSaSeCompareDiff>(strSqlText, null, null, true, 1200, null).ToList();

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

@ -2,9 +2,12 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using EmptyFiles;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.OpenApi.Extensions;
using NetTopologySuite.Operation.Buffer;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using SettleAccount.Domain.BQ;
using Shouldly;
using TaskJob.EventArgs;
@ -104,15 +107,15 @@ namespace SettleAccount.Job.Services.Report
});
//有结算有发运
var haveSaHaveSe = new List<PubSaSeCompareDiff>();
var haveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe);
//有结算无发运
var haveSaNotHaveSe = new List<PubSaSeCompareDiff>();
var haveSaNotHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe);
//无结算有发运
var notHaveSaHaveSe = new List<PubSaSeCompareDiff>();
var notHaveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe);
haveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => !string.IsNullOrEmpty(t.SaLU) && !string.IsNullOrEmpty(t.SeLU));
haveSaNotHaveSe = pubSaSeCompareDiffs.FindAll(t => !string.IsNullOrEmpty(t.SaLU) && string.IsNullOrEmpty(t.SeLU));
notHaveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => string.IsNullOrEmpty(t.SaLU) && !string.IsNullOrEmpty(t.SeLU));
haveSaHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU);
haveSaNotHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU);
notHaveSaHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU);
#region 二次对比
//二次对比(替换零件号)
@ -123,10 +126,21 @@ namespace SettleAccount.Job.Services.Report
{
notHaveSaHaveSe.FindAll(t => t.SeLU == tbRePartsRelationship.RepLU).ForEach(t =>
{
t.RepLU = t.SeLU;
t.SeLU = tbRePartsRelationship.LU;
t.ReplaceLU = tbRePartsRelationship.LU;
});
});
var haveSaNotHaveSeReplaceLU = haveSaNotHaveSe.Select(t => t.ReplaceLU);
var notHaveSaHaveSeReplaceLU = notHaveSaHaveSe.Select(t => t.ReplaceLU);
//此次匹配上的零件号
var secondMatchReplaceLU = notHaveSaHaveSeReplaceLU.Intersect(notHaveSaHaveSeReplaceLU);
//if (secondMatchReplaceLU)
//{
//}
#endregion
if (string.IsNullOrEmpty(lu) == false)
@ -138,27 +152,74 @@ namespace SettleAccount.Job.Services.Report
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.SaPN == pn || p.SePN == pn);
}
var pubSaSeCompareDiffExports = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PubSaSeCompareDetailExport>>(pubSaSeCompareDiffs);
//结算核对明细
var pubSaSeCompareDetailExports = _objectMapper.Map<List<PubSaSeCompareDiff>, List<PubSaSeCompareDetailExport>>(pubSaSeCompareDiffs);
//结算核对汇总
var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport()
{
LU = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes,
SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty)
}).ToList();
//有结算有发运
var haveSaHaveSeExports = pubSaSeCompareDiffExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe);
////有结算有发运汇总
//var haveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport()
//{
// LU= p.Key,
// MaterialDes = p.FirstOrDefault().MaterialDes,
// SAQty =
//});
var haveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe);
//有结算有发运汇总
var haveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport()
{
LU = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes,
SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty)
}).ToList();
//有结算无发运
var haveSaNotHaveSeExports = pubSaSeCompareDiffExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe);
var haveSaNotHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaNotHaveSe);
//有结算无发运
var haveSaNotHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport()
{
LU = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes,
SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty)
}).ToList();
//无结算有发运
var notHaveSaHaveSeExports = pubSaSeCompareDiffExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe);
var notHaveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.NotHaveSaHaveSe);
//无结算有发运
var notHaveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport()
{
LU = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes,
SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty)
}).ToList();
#region MyRegion
#endregion
ExcelExporter excelExporter = new ExcelExporter();
var result = excelExporter
.Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出")
.SeparateBySheet()
.Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出")
.SeparateBySheet()
.Append(haveSaHaveSeExports, $"{businessTypeDisplayName}有结算有发货明细输出")
.SeparateBySheet()
.Append(haveSaHaveSeSumExports, $"{businessTypeDisplayName}有结算有发货汇总输出")
.SeparateBySheet()
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出")
.SeparateBySheet()
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出")
.SeparateBySheet()
.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(filename, result.Result, true);
return id.ToString();
//var add = from item1 in pubSaSeCompareDiffs
@ -191,20 +252,7 @@ namespace SettleAccount.Job.Services.Report
//var query = BlobProviderSelectorExtensions
ExcelExporter excelExporter = new ExcelExporter();
var result = excelExporter
.Append(pubSaSeCompareDiffExports, $"{businessTypeDisplayName}汇总表")
.SeparateBySheet()
.Append(haveSaHaveSeExports, $"{businessTypeDisplayName}有结算有发运")
.SeparateBySheet()
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发运")
.SeparateBySheet()
.Append(notHaveSaHaveSeExports, $"{businessTypeDisplayName}无结算有发运")
.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(filename, result.Result, true);
return id.ToString();
//结算

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

@ -15,7 +15,8 @@ namespace SettleAccount.Job
/// </summary>
private void CreateMapPubSaSeCompare()
{
CreateMap<PubSaSeCompareDiff, PubSaSeCompareDetailExport>().ReverseMap();
CreateMap<PubSaSeCompareDiff, PubSaSeCompareDetailExport>()
.ForMember(x => x.ReplaceLU, y => y.MapFrom(y => y.ReplaceLU));
}
}
}

Loading…
Cancel
Save