Browse Source

直供件比对

master
mahao 1 year ago
parent
commit
88de8897fd
  1. 16
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  2. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs
  3. 6
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs
  4. 338
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs
  5. 14
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs
  6. 56
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs

16
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs

@ -245,7 +245,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
{
try
{
var pubSaDelItems = await GetPubSaDelItemsAsync(id);
var pubSaDelItems = await GetPubSaDelItemsAsync(id).ConfigureAwait(false);
pubSas.AddRange(pubSaDelItems.pubSas);
pubSaDetails.AddRange(pubSaDelItems.pubSaDetails);
@ -460,6 +460,19 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
//验证客户对应厂内零件号是否存在
//导入的零件号集合
var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct();
importPubSaLUs.ForEach(importPubSaLU =>
{
List<string> lus = importPubSaLU.Split(" ").ToList();
importPubSaLU = lus[0].Replace(" ", "");
if (lus.Count > 1)
{
lus.RemoveAt(0);
var luAssemble = lus.Select(t => t.Replace(" ", ""));
importPubSaLU += luAssemble.Aggregate(" ", (current, index) => current + index);
}
});
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
@ -646,6 +659,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
List<PUB_NOT_SA_DETAIL> pubNotSaDetails = new List<PUB_NOT_SA_DETAIL>();
var pubSaEntity = await _repository.FirstOrDefaultAsync(t => t.Id.Equals(id)).ConfigureAwait(false);
//var pubSaEntity = await _repository.FindAsync(id).ConfigureAwait(false);
if (pubSaEntity != null)
{
//结算单据

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppService.cs

@ -103,8 +103,8 @@ public class PriceListAppService : SettleAccountApplicationBase<PriceList>
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName });
}
#endregion
var lus = entityList.Select(p => new { p.LU, p.ContractNo });
var priceListModelEntitys = _priceListRepository.Where(t => lus.Contains(new { t.LU, t.ContractNo })).ToList();
var lus = entityList.Select(p => p.LU);
var priceListModelEntitys = _priceListRepository.Where(t => t.ContractNo == contractNo && lus.Contains(t.ContractNo)).ToList();
if (priceListModelEntitys.Any())
{
await _priceListRepository.DeleteManyAsync(priceListModelEntitys).ConfigureAwait(false);

6
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
@ -61,6 +62,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
var entityList = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result);
entityList = entityList.GroupBy(p => new { p.LU, p.ClientCode, p.BeginDate, p.EndDate }).Select(p => p.FirstOrDefault()).ToList();
var contractNo = entityList.FirstOrDefault().ContractNo;
#region 校验
if (entityList.Any())
@ -81,8 +83,8 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName });
}
#endregion
var lus = entityList.Select(p => new { p.LU, p.ContractNo });
var priceListModelEntitys = _repository.Where(t => lus.Contains(new { t.LU, t.ContractNo })).ToList();
var lus = entityList.Select(p => p.LU);
var priceListModelEntitys = _repository.Where(t => t.ContractNo == contractNo && lus.Contains(t.ContractNo)).ToList();
if (priceListModelEntitys.Any())
{
await _repository.DeleteManyAsync(priceListModelEntitys).ConfigureAwait(false);

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

@ -16,109 +16,107 @@ public class PubSaSeCompareDiff
/// </summary>
[Display(Name = "Wms发货单号")]
public string WmsBillNum { get; set; }
/// <summary>
/// 发货日期
/// </summary>
[Display(Name = "发货日期")]
public DateTime ShippingDate { get; set; }
/// <summary>
/// 日顺序号
/// </summary>
[Display(Name = "日顺序号")]
public string SeqNumber { get; set; }
/// <summary>
/// PJIS日顺序号
/// </summary>
[Display(Name = "PJIS日顺序号")]
public string PJISSeqNumber { get; set; }
/// <summary>
/// 物料号
/// </summary>
[Display(Name = "物料号")]
public string MaterialNumber { get; set; }
/// <summary>
/// 物料描述
/// </summary>
[Display(Name = "物料描述")]
public string MaterialDes { get; set; }
/// <summary>
/// 结算数据中的过账日期
/// </summary>
[Display(Name = "客户下线时间")]
public DateTime CustomerOfflineTime { get; set; }
/// <summary>
/// 结算数量
/// </summary>
[Display(Name = "结算数量")]
public decimal SAQty { get; set; }
/// <summary>
/// 发货数量
/// </summary>
[Display(Name = "发货数量")]
public decimal SEQty { get; set; }
/// <summary>
/// 差异数量
/// </summary>
[Display(Name = "差异数量")]
public decimal DiffQty => SAQty - SEQty;
/// <summary>
/// 匹配类型
/// </summary>
[Display(Name = "匹配类型")]
public string MateType { get; set; }
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
public decimal FixPrice { get; set; }
/// <summary>
/// 原始零件
/// 生产
/// </summary>
[Display(Name = "原始零件号")]
public string PrimitiveLU { get; set; }
[Display(Name = "生产号")]
public string PN { set; get; }
/// <summary>
/// 替换零件号
/// WMS目标库位
/// </summary>
[Display(Name = "替换零件号")]
public string ReplaceLU { get; set; }
[Display(Name = "WMS目标库位")]
public string ToLocCode { get; set; }
/// <summary>
/// 零件号
/// ERP目标库位
/// </summary>
[Display(Name = "零件号")]
public string SeLU { set; get; }
[Display(Name = "ERP目标库位")]
public string ToErpLocCode { get; set; }
/// <summary>
/// 零件号
/// 类型
/// </summary>
[Display(Name = "零件号")]
public string SaLU { set; get; }
[Display(Name = "类型")]
public EnumPubSaSeCompareCategory Category { get; set; }
/// <summary>
/// 生产
/// 发运客户物料
/// </summary>
[Display(Name = "生产号")]
public string PN { set; get; }
public string SeCustomerPartCode { get; set; }
/// <summary>
/// 类型
/// 发运厂内物料号
/// </summary>
[Display(Name = "类型")]
public EnumPubSaSeCompareCategory Category { get; set; }
public string SeFactoryPartCode { get; set; }
/// <summary>
/// 结算客户物料号
/// </summary>
public string SaCustomerPartCode { get; set; }
/// <summary>
/// 结算厂内物料号
/// </summary>
public string SaFactoryPartCode { get; set; }
/// <summary>
/// 客户物料号
/// </summary>
[Display(Name = "客户物料号")]
public string CustomerPartCode { get; set; }
/// <summary>
/// 物料描述
/// </summary>
[Display(Name = "物料描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 厂内物料号
/// </summary>
[Display(Name = "厂内物料号")]
public string FactoryPartCode { get; set; }
/// <summary>
/// 替换厂内物料号
/// </summary>
[Display(Name = "替换厂内物料号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 是否已经移除
/// </summary>
@ -172,35 +170,30 @@ public class PubSaSeCompareDetailExport2
[Display(Name = "生产码")]
[ExporterHeader(DisplayName = "ASN发货单号")]
public string PN { get; set; }
/// <summary>
/// 物料
/// 客户零件
/// </summary>
[Display(Name = "物料号")]
[ExporterHeader(DisplayName = "厂内物料号")]
public string MaterialNumber { get; set; }
[Display(Name = "客户零件号")]
[ExporterHeader(DisplayName = "客户零件号")]
public string CustomerPartCode { get; set; }
/// <summary>
/// 物料描述
/// 零件描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string MaterialDes { get; set; }
[Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "零件描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 原始LU
/// 厂内零件号
/// </summary>
[Display(Name = "原始LU")]
[ExporterHeader(DisplayName = "原始LU")]
public string PrimitiveLU { get; set; }
[Display(Name = "厂内零件号")]
[ExporterHeader(DisplayName = "厂内零件号")]
public string FactoryPartCode { get; set; }
/// <summary>
///替换LU
/// 替换厂内零件号
/// </summary>
[Display(Name = "替换LU")]
[ExporterHeader(DisplayName = "替换LU")]
public string ReplaceLU { get; set; }
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 结算数据中的过账日期
/// </summary>
@ -288,21 +281,18 @@ public interface IPubSaSeCompareDetailExport
[ValueMapping("有结算无发运", 2)]
[ValueMapping("无结算有发运", 3)]
public EnumPubSaSeCompareCategory Category { get; set; }
/// <summary>
/// 物料描述
/// 零件描述
/// </summary>
[Display(Name = "物料描述")]
[Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string MaterialDes { get; set; }
public string PartCodeDesc { get; set; }
/// <summary>
///替换LU
/// 替换厂内零件号
/// </summary>
[Display(Name = "替换LU")]
[ExporterHeader(DisplayName = "替换LU")]
public string ReplaceLU { get; set; }
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 结算数量
/// </summary>
@ -325,18 +315,18 @@ public interface IPubSaSeCompareDetailExport
public class PubSaSeCompareSumExport
{
/// <summary>
/// LU
/// 厂内物料号
/// </summary>
[Display(Name = "LU")]
[Display(Name = "厂内物料号")]
[ExporterHeader(DisplayName = "LU")]
public string LU { get; set; }
public string FactoryPartCode { get; set; }
/// <summary>
/// 物料描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string MaterialDes { get; set; }
public string PartCodeDesc { get; set; }
/// <summary>
/// 结算数量
@ -398,35 +388,30 @@ public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExp
[Display(Name = "生产码")]
[ExporterHeader(DisplayName = "ASN发货单号")]
public string PN { get; set; }
/// <summary>
/// 物料
/// 客户零件
/// </summary>
[Display(Name = "物料号")]
[ExporterHeader(DisplayName = "厂内物料号")]
public string MaterialNumber { get; set; }
[Display(Name = "客户零件号")]
[ExporterHeader(DisplayName = "客户零件号")]
public string CustomerPartCode { get; set; }
/// <summary>
/// 物料描述
/// 零件描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string MaterialDes { get; set; }
[Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "零件描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 原始LU
/// 厂内零件号
/// </summary>
[Display(Name = "原始LU")]
[ExporterHeader(DisplayName = "原始LU")]
public string PrimitiveLU { get; set; }
[Display(Name = "厂内零件号")]
[ExporterHeader(DisplayName = "厂内零件号")]
public string FactoryPartCode { get; set; }
/// <summary>
///替换LU
/// 替换厂内零件号
/// </summary>
[Display(Name = "替换LU")]
[ExporterHeader(DisplayName = "替换LU")]
public string ReplaceLU { get; set; }
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 结算数据中的过账日期
/// </summary>
@ -522,35 +507,30 @@ public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExp
[Display(Name = "生产码")]
[ExporterHeader(DisplayName = "ASN发货单号")]
public string PN { get; set; }
/// <summary>
/// 物料
/// 客户零件
/// </summary>
[Display(Name = "物料号")]
[ExporterHeader(DisplayName = "厂内物料号")]
public string MaterialNumber { get; set; }
[Display(Name = "客户零件号")]
[ExporterHeader(DisplayName = "客户零件号")]
public string CustomerPartCode { get; set; }
/// <summary>
/// 物料描述
/// 零件描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string MaterialDes { get; set; }
[Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "零件描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 原始LU
/// 厂内零件号
/// </summary>
[Display(Name = "原始LU")]
[ExporterHeader(DisplayName = "原始LU")]
public string PrimitiveLU { get; set; }
[Display(Name = "厂内零件号")]
[ExporterHeader(DisplayName = "厂内零件号")]
public string FactoryPartCode { get; set; }
/// <summary>
///替换LU
/// 替换厂内零件号
/// </summary>
[Display(Name = "替换LU")]
[ExporterHeader(DisplayName = "替换LU")]
public string ReplaceLU { get; set; }
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 结算数据中的过账日期
/// </summary>
@ -646,35 +626,30 @@ public class PubSaSeCompareDetailExportMaiDanJianHBPO : PubSaSeCompareDetailExpo
[Display(Name = "生产码")]
[ExporterHeader(DisplayName = "索引号")]
public string PN { get; set; }
/// <summary>
/// 物料
/// 客户零件
/// </summary>
[Display(Name = "物料号")]
[ExporterHeader(DisplayName = "厂内物料号")]
public string MaterialNumber { get; set; }
[Display(Name = "客户零件号")]
[ExporterHeader(DisplayName = "客户零件号")]
public string CustomerPartCode { get; set; }
/// <summary>
/// 物料描述
/// 零件描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string MaterialDes { get; set; }
[Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "零件描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 原始LU
/// 厂内零件号
/// </summary>
[Display(Name = "原始LU")]
[ExporterHeader(DisplayName = "原始LU")]
public string PrimitiveLU { get; set; }
[Display(Name = "厂内零件号")]
[ExporterHeader(DisplayName = "厂内零件号")]
public string FactoryPartCode { get; set; }
/// <summary>
///替换LU
/// 替换厂内零件号
/// </summary>
[Display(Name = "替换LU")]
[ExporterHeader(DisplayName = "替换LU")]
public string ReplaceLU { get; set; }
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 结算数据中的过账日期
/// </summary>
@ -770,35 +745,30 @@ public class PubSaSeCompareDetailExportBeiJian : PubSaSeCompareDetailExport, IPu
[Display(Name = "生产码")]
[ExporterHeader(DisplayName = "索引号")]
public string PN { get; set; }
/// <summary>
/// 物料
/// 客户零件
/// </summary>
[Display(Name = "物料号")]
[ExporterHeader(DisplayName = "厂内物料号")]
public string MaterialNumber { get; set; }
[Display(Name = "客户零件号")]
[ExporterHeader(DisplayName = "客户零件号")]
public string CustomerPartCode { get; set; }
/// <summary>
/// 物料描述
/// 零件描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string MaterialDes { get; set; }
[Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "零件描述")]
public string PartCodeDesc { get; set; }
/// <summary>
/// 原始LU
/// 厂内零件号
/// </summary>
[Display(Name = "原始LU")]
[ExporterHeader(DisplayName = "原始LU")]
public string PrimitiveLU { get; set; }
[Display(Name = "厂内零件号")]
[ExporterHeader(DisplayName = "厂内零件号")]
public string FactoryPartCode { get; set; }
/// <summary>
///替换LU
/// 替换厂内零件号
/// </summary>
[Display(Name = "替换LU")]
[ExporterHeader(DisplayName = "替换LU")]
public string ReplaceLU { get; set; }
[Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 结算数据中的过账日期
/// </summary>
@ -894,83 +864,71 @@ public class PubSaSeCompareDetailExportYinDuJian : PubSaSeCompareDetailExport, I
[Display(Name = "生产码")]
[ExporterHeader(DisplayName = "ASN发货单号")]
public string PN { get; set; }
/// <summary>
/// 物料号
/// 客户物料号
/// </summary>
[Display(Name = "物料号")]
[ExporterHeader(DisplayName = "厂内物料号")]
public string MaterialNumber { get; set; }
[Display(Name = "客户物料号")]
[ExporterHeader(DisplayName = "客户物料号")]
public string CustomerPartCode { get; set; }
/// <summary>
/// 物料描述
/// </summary>
[Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")]
public string MaterialDes { get; set; }
public string PartCodeDesc { get; set; }
/// <summary>
/// 原始LU
/// 厂内物料号
/// </summary>
[Display(Name = "原始LU")]
[ExporterHeader(DisplayName = "原始LU")]
public string PrimitiveLU { get; set; }
[Display(Name = "厂内物料号")]
[ExporterHeader(DisplayName = "厂内物料号")]
public string FactoryPartCode { get; set; }
/// <summary>
///替换LU
/// 替换厂内物料号
/// </summary>
[Display(Name = "替换LU")]
[ExporterHeader(DisplayName = "替换LU")]
public string ReplaceLU { get; set; }
[Display(Name = "替换厂内物料号")]
[ExporterHeader(DisplayName = "替换厂内物料号")]
public string ReplaceFactoryPartCode { get; set; }
/// <summary>
/// 结算数据中的过账日期
/// </summary>
[Display(Name = "客户下线时间")]
[ExporterHeader(DisplayName = "客户下线时间")]
public DateTime CustomerOfflineTime { 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>
/// 匹配类型
/// </summary>
[Display(Name = "匹配类型")]
[ExporterHeader(DisplayName = "是否完全匹配")]
public string MateType { get; set; }
/// <summary>
/// 定价
/// </summary>
[Display(Name = "定价")]
[ExporterHeader(DisplayName = "定价")]
public decimal FixPrice { get; set; }
/// <summary>
/// WMS目标库位
/// </summary>
[Display(Name = "WMS目标库位")]
[ExporterHeader(DisplayName = "WMS目标库位")]
public string ToLocCode { get; set; }
/// <summary>
/// ERP目标库位
/// </summary>

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

@ -35,15 +35,13 @@ public class PubSaSeCompareDapperRepository : DapperRepository<SettleAccountDbCo
}
string strSqlText = @$"
SELECT
A.LU AS SeCustomerPartCode,
A.FactoryPartCode AS SeFactoryPartCode,
B.LU AS SaCustomerPartCode,
B.PartCode AS SaFactoryPartCode,
A.WmsBillNum,
A.ShippingDate,
A.LU AS MaterialNumber,
A.FactoryPartCode AS PrimitiveLU,
A.FactoryPartCode AS ReplaceLU,
'' MaterialDes,
B.SettleDate CustomerOfflineTime,
A.LU SeLU,
B.LU SaLU,
ISNULL(A.PN,B.PN) PN,
A.SEQty,
B.SAQty,
@ -52,8 +50,8 @@ public class PubSaSeCompareDapperRepository : DapperRepository<SettleAccountDbCo
A.ToLocCode,
A.ToErpLocCode
FROM
(SELECT SUM(QTY) SEQty,LU,PN,FactoryPartCode,MAX(WmsBillNum) WmsBillNum,MAX(ShippingDate) ShippingDate,MAX(PartCode) PartCode, MAX(ToLocCode) ToLocCode, MAX(ToErpLocCode) ToErpLocCode FROM Set_PUB_SE_DETAIL WHERE BusinessType = {businessType} {strSeWhere} GROUP BY LU,PN,FactoryPartCode) A
FULL JOIN (SELECT SUM(QTY) SAQty,LU,PN,MAX(Price) Price,MAX(SettleDate) SettleDate FROM Set_PUB_SA_DETAIL WHERE BusinessType = {businessType} AND Version = {version} GROUP BY LU,PN) B ON A.LU= B.LU AND A.PN= B.PN
(SELECT SUM(QTY) SEQty,LU,PN,MAX(WmsBillNum) WmsBillNum,MAX(ShippingDate) ShippingDate,MAX(FactoryPartCode) FactoryPartCode, MAX(ToLocCode) ToLocCode, MAX(ToErpLocCode) ToErpLocCode FROM Set_PUB_SE_DETAIL WHERE BusinessType={businessType} {strSeWhere} GROUP BY LU,PN) A
FULL JOIN (SELECT SUM(QTY) SAQty,LU,PN,MAX(Price) Price,MAX(SettleDate) SettleDate,MAX(PartCode) PartCode FROM Set_PUB_SA_DETAIL WHERE BusinessType={businessType} AND Version={version} 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();

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

@ -108,13 +108,41 @@ namespace SettleAccount.Job.Services.Report
pubSaSeCompareDiffs.ForEach(p =>
{
p.Category = (string.IsNullOrEmpty(p.SaLU), string.IsNullOrEmpty(p.SeLU)) switch
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;
}
});
//有结算有发运
@ -187,7 +215,7 @@ namespace SettleAccount.Job.Services.Report
if (string.IsNullOrEmpty(lu) == false)
{
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.SaLU == lu || p.SeLU == lu);
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.CustomerPartCode == lu);
}
if (string.IsNullOrEmpty(pn) == false)
{
@ -247,10 +275,10 @@ namespace SettleAccount.Job.Services.Report
public ExcelExporter BindExcelExporter<T>(List<T> pubSaSeCompareDetailExports, string businessTypeDisplayName) where T : PubSaSeCompareDetailExport, IPubSaSeCompareDetailExport, new()
{
//结算核对汇总
var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport()
var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport()
{
LU = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes,
FactoryPartCode = p.Key,
PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty)
}).ToList();
@ -258,30 +286,30 @@ namespace SettleAccount.Job.Services.Report
//有结算有发运
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.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport()
{
LU = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes,
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 = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport()
var haveSaNotHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport()
{
LU = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes,
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 = haveSaHaveSeExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport()
var notHaveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport()
{
LU = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes,
FactoryPartCode = p.Key,
PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty)
}).ToList();

Loading…
Cancel
Save