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.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
@ -48,7 +48,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// 导入 /// 导入
/// </summary> /// </summary>
[HttpPost] [HttpPost]
[Route("Import")]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files) public async Task<string> ImportAsync([FromForm] IFormFileCollection files)
{ {
ExportImporter _exportImporter = new ExportImporter(); ExportImporter _exportImporter = new ExportImporter();
@ -94,7 +93,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// 导出 /// 导出
/// </summary> /// </summary>
[HttpPost] [HttpPost]
[Route("Export")]
public async Task<string> ExportAsync(RequestDto input) public async Task<string> ExportAsync(RequestDto input)
{ {
string fileName = $"采购价格单_{Guid.NewGuid()}.xlsx"; string fileName = $"采购价格单_{Guid.NewGuid()}.xlsx";
@ -115,7 +113,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// 获取列表 /// 获取列表
/// </summary> /// </summary>
[HttpPost] [HttpPost]
[Route("list")]
public async Task<PagedResultDto<PURCHASE_PRICE_DTO>> GetListAsync(RequestDto input) public async Task<PagedResultDto<PURCHASE_PRICE_DTO>> GetListAsync(RequestDto input)
{ {
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true); 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 = "定价")] [Display(Name = "定价")]
public decimal FixPrice { get; set; } public decimal FixPrice { get; set; }
/// <summary>
/// 原始零件号
/// </summary>
[Display(Name = "原始零件号")]
public string PrimitiveLU { get; set; }
/// <summary> /// <summary>
/// 替换零件号 /// 替换零件号
/// </summary> /// </summary>
[Display(Name = "替换零件号")] [Display(Name = "替换零件号")]
public string RepLU { get; set; } public string ReplaceLU { get; set; }
/// <summary> /// <summary>
/// 零件号 /// 零件号
@ -284,7 +290,7 @@ public class PubSaSeCompareSumExport
/// 差异数量 /// 差异数量
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "差异数量")] [ExporterHeader(DisplayName = "差异数量")]
public decimal DiffQty { set; get; } public decimal DiffQty => SAQty - SEQty;
} }
[ExcelExporter(MaxRowNumberOnASheet = 900000)] [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, '' MateType,
B.Price FixPrice B.Price FixPrice
FROM FROM
(SELECT SUM(QTY) SEQty,LU,PN,WmsBillNum,ShippingDate FROM Set_PUB_SE_DETAIL WHERE BusinessType = {businessType} GROUP BY LU,PN,WmsBillNum,ShippingDate) A (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,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 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; ORDER BY B.SettleDate DESC;
"; ";
return DbConnection.Query<PubSaSeCompareDiff>(strSqlText, null, null, true, 1200, null).ToList(); 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.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using EmptyFiles;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Extensions;
using NetTopologySuite.Operation.Buffer; using NetTopologySuite.Operation.Buffer;
using OfficeOpenXml.FormulaParsing.Excel.Functions.DateTime;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using Shouldly; using Shouldly;
using TaskJob.EventArgs; 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)); haveSaHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU);
haveSaNotHaveSe = pubSaSeCompareDiffs.FindAll(t => !string.IsNullOrEmpty(t.SaLU) && string.IsNullOrEmpty(t.SeLU)); haveSaNotHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU);
notHaveSaHaveSe = pubSaSeCompareDiffs.FindAll(t => string.IsNullOrEmpty(t.SaLU) && !string.IsNullOrEmpty(t.SeLU)); notHaveSaHaveSe.ForEach(t => t.PrimitiveLU = t.ReplaceLU = t.SaLU);
#region 二次对比 #region 二次对比
//二次对比(替换零件号) //二次对比(替换零件号)
@ -123,10 +126,21 @@ namespace SettleAccount.Job.Services.Report
{ {
notHaveSaHaveSe.FindAll(t => t.SeLU == tbRePartsRelationship.RepLU).ForEach(t => notHaveSaHaveSe.FindAll(t => t.SeLU == tbRePartsRelationship.RepLU).ForEach(t =>
{ {
t.RepLU = t.SeLU; t.ReplaceLU = tbRePartsRelationship.LU;
t.SeLU = tbRePartsRelationship.LU;
}); });
}); });
var haveSaNotHaveSeReplaceLU = haveSaNotHaveSe.Select(t => t.ReplaceLU);
var notHaveSaHaveSeReplaceLU = notHaveSaHaveSe.Select(t => t.ReplaceLU);
//此次匹配上的零件号
var secondMatchReplaceLU = notHaveSaHaveSeReplaceLU.Intersect(notHaveSaHaveSeReplaceLU);
//if (secondMatchReplaceLU)
//{
//}
#endregion #endregion
if (string.IsNullOrEmpty(lu) == false) if (string.IsNullOrEmpty(lu) == false)
@ -138,27 +152,74 @@ namespace SettleAccount.Job.Services.Report
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.SaPN == pn || p.SePN == pn); 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 haveSaHaveSeExports = pubSaSeCompareDetailExports.FindAll(t => t.Category == EnumPubSaSeCompareCategory.HaveSaHaveSe);
////有结算有发运汇总 //有结算有发运汇总
//var haveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport() var haveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport()
//{ {
// LU= p.Key, LU = p.Key,
// MaterialDes = p.FirstOrDefault().MaterialDes, MaterialDes = p.FirstOrDefault().MaterialDes,
// SAQty = 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 #region MyRegion
#endregion #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 //var add = from item1 in pubSaSeCompareDiffs
@ -191,20 +252,7 @@ namespace SettleAccount.Job.Services.Report
//var query = BlobProviderSelectorExtensions //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> /// </summary>
private void CreateMapPubSaSeCompare() private void CreateMapPubSaSeCompare()
{ {
CreateMap<PubSaSeCompareDiff, PubSaSeCompareDetailExport>().ReverseMap(); CreateMap<PubSaSeCompareDiff, PubSaSeCompareDetailExport>()
.ForMember(x => x.ReplaceLU, y => y.MapFrom(y => y.ReplaceLU));
} }
} }
} }

Loading…
Cancel
Save