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 try
{ {
var pubSaDelItems = await GetPubSaDelItemsAsync(id); var pubSaDelItems = await GetPubSaDelItemsAsync(id).ConfigureAwait(false);
pubSas.AddRange(pubSaDelItems.pubSas); pubSas.AddRange(pubSaDelItems.pubSas);
pubSaDetails.AddRange(pubSaDelItems.pubSaDetails); pubSaDetails.AddRange(pubSaDelItems.pubSaDetails);
@ -460,6 +460,19 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
//验证客户对应厂内零件号是否存在 //验证客户对应厂内零件号是否存在
//导入的零件号集合 //导入的零件号集合
var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct(); 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 materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); 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>(); 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.FirstOrDefaultAsync(t => t.Id.Equals(id)).ConfigureAwait(false);
//var pubSaEntity = await _repository.FindAsync(id).ConfigureAwait(false);
if (pubSaEntity != null) 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 }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName });
} }
#endregion #endregion
var lus = entityList.Select(p => new { p.LU, p.ContractNo }); var lus = entityList.Select(p => p.LU);
var priceListModelEntitys = _priceListRepository.Where(t => lus.Contains(new { t.LU, t.ContractNo })).ToList(); var priceListModelEntitys = _priceListRepository.Where(t => t.ContractNo == contractNo && lus.Contains(t.ContractNo)).ToList();
if (priceListModelEntitys.Any()) if (priceListModelEntitys.Any())
{ {
await _priceListRepository.DeleteManyAsync(priceListModelEntitys).ConfigureAwait(false); 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 Shouldly;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
@ -61,6 +62,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
var entityList = ObjectMapper.Map<List<PriceListBJImportDto>, List<PriceListBJ>>(result); 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(); entityList = entityList.GroupBy(p => new { p.LU, p.ClientCode, p.BeginDate, p.EndDate }).Select(p => p.FirstOrDefault()).ToList();
var contractNo = entityList.FirstOrDefault().ContractNo;
#region 校验 #region 校验
if (entityList.Any()) if (entityList.Any())
@ -81,8 +83,8 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, fileName = fileName });
} }
#endregion #endregion
var lus = entityList.Select(p => new { p.LU, p.ContractNo }); var lus = entityList.Select(p => p.LU);
var priceListModelEntitys = _repository.Where(t => lus.Contains(new { t.LU, t.ContractNo })).ToList(); var priceListModelEntitys = _repository.Where(t => t.ContractNo == contractNo && lus.Contains(t.ContractNo)).ToList();
if (priceListModelEntitys.Any()) if (priceListModelEntitys.Any())
{ {
await _repository.DeleteManyAsync(priceListModelEntitys).ConfigureAwait(false); 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> /// </summary>
[Display(Name = "Wms发货单号")] [Display(Name = "Wms发货单号")]
public string WmsBillNum { get; set; } public string WmsBillNum { get; set; }
/// <summary> /// <summary>
/// 发货日期 /// 发货日期
/// </summary> /// </summary>
[Display(Name = "发货日期")] [Display(Name = "发货日期")]
public DateTime ShippingDate { get; set; } public DateTime ShippingDate { get; set; }
/// <summary> /// <summary>
/// 日顺序号 /// 日顺序号
/// </summary> /// </summary>
[Display(Name = "日顺序号")] [Display(Name = "日顺序号")]
public string SeqNumber { get; set; } public string SeqNumber { get; set; }
/// <summary> /// <summary>
/// PJIS日顺序号 /// PJIS日顺序号
/// </summary> /// </summary>
[Display(Name = "PJIS日顺序号")] [Display(Name = "PJIS日顺序号")]
public string PJISSeqNumber { get; set; } 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>
/// 结算数据中的过账日期 /// 结算数据中的过账日期
/// </summary> /// </summary>
[Display(Name = "客户下线时间")] [Display(Name = "客户下线时间")]
public DateTime CustomerOfflineTime { get; set; } public DateTime CustomerOfflineTime { get; set; }
/// <summary> /// <summary>
/// 结算数量 /// 结算数量
/// </summary> /// </summary>
[Display(Name = "结算数量")] [Display(Name = "结算数量")]
public decimal SAQty { get; set; } public decimal SAQty { get; set; }
/// <summary> /// <summary>
/// 发货数量 /// 发货数量
/// </summary> /// </summary>
[Display(Name = "发货数量")] [Display(Name = "发货数量")]
public decimal SEQty { get; set; } public decimal SEQty { get; set; }
/// <summary> /// <summary>
/// 差异数量 /// 差异数量
/// </summary> /// </summary>
[Display(Name = "差异数量")] [Display(Name = "差异数量")]
public decimal DiffQty => SAQty - SEQty; public decimal DiffQty => SAQty - SEQty;
/// <summary> /// <summary>
/// 匹配类型 /// 匹配类型
/// </summary> /// </summary>
[Display(Name = "匹配类型")] [Display(Name = "匹配类型")]
public string MateType { get; set; } public string MateType { get; set; }
/// <summary> /// <summary>
/// 定价 /// 定价
/// </summary> /// </summary>
[Display(Name = "定价")] [Display(Name = "定价")]
public decimal FixPrice { get; set; } public decimal FixPrice { get; set; }
/// <summary> /// <summary>
/// 原始零件 /// 生产
/// </summary> /// </summary>
[Display(Name = "原始零件号")] [Display(Name = "生产号")]
public string PrimitiveLU { get; set; } public string PN { set; get; }
/// <summary> /// <summary>
/// 替换零件号 /// WMS目标库位
/// </summary> /// </summary>
[Display(Name = "替换零件号")] [Display(Name = "WMS目标库位")]
public string ReplaceLU { get; set; } public string ToLocCode { get; set; }
/// <summary> /// <summary>
/// 零件号 /// ERP目标库位
/// </summary> /// </summary>
[Display(Name = "零件号")] [Display(Name = "ERP目标库位")]
public string SeLU { set; get; } public string ToErpLocCode { get; set; }
/// <summary> /// <summary>
/// 零件号 /// 类型
/// </summary> /// </summary>
[Display(Name = "零件号")] [Display(Name = "类型")]
public string SaLU { set; get; } public EnumPubSaSeCompareCategory Category { get; set; }
/// <summary> /// <summary>
/// 生产 /// 发运客户物料
/// </summary> /// </summary>
[Display(Name = "生产号")] public string SeCustomerPartCode { get; set; }
public string PN { set; get; }
/// <summary> /// <summary>
/// 类型 /// 发运厂内物料号
/// </summary> /// </summary>
[Display(Name = "类型")] public string SeFactoryPartCode { get; set; }
public EnumPubSaSeCompareCategory Category { 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>
/// 是否已经移除 /// 是否已经移除
/// </summary> /// </summary>
@ -172,35 +170,30 @@ public class PubSaSeCompareDetailExport2
[Display(Name = "生产码")] [Display(Name = "生产码")]
[ExporterHeader(DisplayName = "ASN发货单号")] [ExporterHeader(DisplayName = "ASN发货单号")]
public string PN { get; set; } public string PN { get; set; }
/// <summary> /// <summary>
/// 物料 /// 客户零件
/// </summary> /// </summary>
[Display(Name = "物料号")] [Display(Name = "客户零件号")]
[ExporterHeader(DisplayName = "厂内物料号")] [ExporterHeader(DisplayName = "客户零件号")]
public string MaterialNumber { get; set; } public string CustomerPartCode { get; set; }
/// <summary> /// <summary>
/// 物料描述 /// 零件描述
/// </summary> /// </summary>
[Display(Name = "物料描述")] [Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "物料描述")] [ExporterHeader(DisplayName = "零件描述")]
public string MaterialDes { get; set; } public string PartCodeDesc { get; set; }
/// <summary> /// <summary>
/// 原始LU /// 厂内零件号
/// </summary> /// </summary>
[Display(Name = "原始LU")] [Display(Name = "厂内零件号")]
[ExporterHeader(DisplayName = "原始LU")] [ExporterHeader(DisplayName = "厂内零件号")]
public string PrimitiveLU { get; set; } public string FactoryPartCode { get; set; }
/// <summary> /// <summary>
///替换LU /// 替换厂内零件号
/// </summary> /// </summary>
[Display(Name = "替换LU")] [Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换LU")] [ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceLU { get; set; } public string ReplaceFactoryPartCode { get; set; }
/// <summary> /// <summary>
/// 结算数据中的过账日期 /// 结算数据中的过账日期
/// </summary> /// </summary>
@ -288,21 +281,18 @@ public interface IPubSaSeCompareDetailExport
[ValueMapping("有结算无发运", 2)] [ValueMapping("有结算无发运", 2)]
[ValueMapping("无结算有发运", 3)] [ValueMapping("无结算有发运", 3)]
public EnumPubSaSeCompareCategory Category { get; set; } public EnumPubSaSeCompareCategory Category { get; set; }
/// <summary> /// <summary>
/// 物料描述 /// 零件描述
/// </summary> /// </summary>
[Display(Name = "物料描述")] [Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "物料描述")] [ExporterHeader(DisplayName = "物料描述")]
public string MaterialDes { get; set; } public string PartCodeDesc { get; set; }
/// <summary> /// <summary>
///替换LU /// 替换厂内零件号
/// </summary> /// </summary>
[Display(Name = "替换LU")] [Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换LU")] [ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceLU { get; set; } public string ReplaceFactoryPartCode { get; set; }
/// <summary> /// <summary>
/// 结算数量 /// 结算数量
/// </summary> /// </summary>
@ -325,18 +315,18 @@ public interface IPubSaSeCompareDetailExport
public class PubSaSeCompareSumExport public class PubSaSeCompareSumExport
{ {
/// <summary> /// <summary>
/// LU /// 厂内物料号
/// </summary> /// </summary>
[Display(Name = "LU")] [Display(Name = "厂内物料号")]
[ExporterHeader(DisplayName = "LU")] [ExporterHeader(DisplayName = "LU")]
public string LU { get; set; } public string FactoryPartCode { get; set; }
/// <summary> /// <summary>
/// 物料描述 /// 物料描述
/// </summary> /// </summary>
[Display(Name = "物料描述")] [Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")] [ExporterHeader(DisplayName = "物料描述")]
public string MaterialDes { get; set; } public string PartCodeDesc { get; set; }
/// <summary> /// <summary>
/// 结算数量 /// 结算数量
@ -398,35 +388,30 @@ public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExp
[Display(Name = "生产码")] [Display(Name = "生产码")]
[ExporterHeader(DisplayName = "ASN发货单号")] [ExporterHeader(DisplayName = "ASN发货单号")]
public string PN { get; set; } public string PN { get; set; }
/// <summary> /// <summary>
/// 物料 /// 客户零件
/// </summary> /// </summary>
[Display(Name = "物料号")] [Display(Name = "客户零件号")]
[ExporterHeader(DisplayName = "厂内物料号")] [ExporterHeader(DisplayName = "客户零件号")]
public string MaterialNumber { get; set; } public string CustomerPartCode { get; set; }
/// <summary> /// <summary>
/// 物料描述 /// 零件描述
/// </summary> /// </summary>
[Display(Name = "物料描述")] [Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "物料描述")] [ExporterHeader(DisplayName = "零件描述")]
public string MaterialDes { get; set; } public string PartCodeDesc { get; set; }
/// <summary> /// <summary>
/// 原始LU /// 厂内零件号
/// </summary> /// </summary>
[Display(Name = "原始LU")] [Display(Name = "厂内零件号")]
[ExporterHeader(DisplayName = "原始LU")] [ExporterHeader(DisplayName = "厂内零件号")]
public string PrimitiveLU { get; set; } public string FactoryPartCode { get; set; }
/// <summary> /// <summary>
///替换LU /// 替换厂内零件号
/// </summary> /// </summary>
[Display(Name = "替换LU")] [Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换LU")] [ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceLU { get; set; } public string ReplaceFactoryPartCode { get; set; }
/// <summary> /// <summary>
/// 结算数据中的过账日期 /// 结算数据中的过账日期
/// </summary> /// </summary>
@ -522,35 +507,30 @@ public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExp
[Display(Name = "生产码")] [Display(Name = "生产码")]
[ExporterHeader(DisplayName = "ASN发货单号")] [ExporterHeader(DisplayName = "ASN发货单号")]
public string PN { get; set; } public string PN { get; set; }
/// <summary> /// <summary>
/// 物料 /// 客户零件
/// </summary> /// </summary>
[Display(Name = "物料号")] [Display(Name = "客户零件号")]
[ExporterHeader(DisplayName = "厂内物料号")] [ExporterHeader(DisplayName = "客户零件号")]
public string MaterialNumber { get; set; } public string CustomerPartCode { get; set; }
/// <summary> /// <summary>
/// 物料描述 /// 零件描述
/// </summary> /// </summary>
[Display(Name = "物料描述")] [Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "物料描述")] [ExporterHeader(DisplayName = "零件描述")]
public string MaterialDes { get; set; } public string PartCodeDesc { get; set; }
/// <summary> /// <summary>
/// 原始LU /// 厂内零件号
/// </summary> /// </summary>
[Display(Name = "原始LU")] [Display(Name = "厂内零件号")]
[ExporterHeader(DisplayName = "原始LU")] [ExporterHeader(DisplayName = "厂内零件号")]
public string PrimitiveLU { get; set; } public string FactoryPartCode { get; set; }
/// <summary> /// <summary>
///替换LU /// 替换厂内零件号
/// </summary> /// </summary>
[Display(Name = "替换LU")] [Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换LU")] [ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceLU { get; set; } public string ReplaceFactoryPartCode { get; set; }
/// <summary> /// <summary>
/// 结算数据中的过账日期 /// 结算数据中的过账日期
/// </summary> /// </summary>
@ -646,35 +626,30 @@ public class PubSaSeCompareDetailExportMaiDanJianHBPO : PubSaSeCompareDetailExpo
[Display(Name = "生产码")] [Display(Name = "生产码")]
[ExporterHeader(DisplayName = "索引号")] [ExporterHeader(DisplayName = "索引号")]
public string PN { get; set; } public string PN { get; set; }
/// <summary> /// <summary>
/// 物料 /// 客户零件
/// </summary> /// </summary>
[Display(Name = "物料号")] [Display(Name = "客户零件号")]
[ExporterHeader(DisplayName = "厂内物料号")] [ExporterHeader(DisplayName = "客户零件号")]
public string MaterialNumber { get; set; } public string CustomerPartCode { get; set; }
/// <summary> /// <summary>
/// 物料描述 /// 零件描述
/// </summary> /// </summary>
[Display(Name = "物料描述")] [Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "物料描述")] [ExporterHeader(DisplayName = "零件描述")]
public string MaterialDes { get; set; } public string PartCodeDesc { get; set; }
/// <summary> /// <summary>
/// 原始LU /// 厂内零件号
/// </summary> /// </summary>
[Display(Name = "原始LU")] [Display(Name = "厂内零件号")]
[ExporterHeader(DisplayName = "原始LU")] [ExporterHeader(DisplayName = "厂内零件号")]
public string PrimitiveLU { get; set; } public string FactoryPartCode { get; set; }
/// <summary> /// <summary>
///替换LU /// 替换厂内零件号
/// </summary> /// </summary>
[Display(Name = "替换LU")] [Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换LU")] [ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceLU { get; set; } public string ReplaceFactoryPartCode { get; set; }
/// <summary> /// <summary>
/// 结算数据中的过账日期 /// 结算数据中的过账日期
/// </summary> /// </summary>
@ -770,35 +745,30 @@ public class PubSaSeCompareDetailExportBeiJian : PubSaSeCompareDetailExport, IPu
[Display(Name = "生产码")] [Display(Name = "生产码")]
[ExporterHeader(DisplayName = "索引号")] [ExporterHeader(DisplayName = "索引号")]
public string PN { get; set; } public string PN { get; set; }
/// <summary> /// <summary>
/// 物料 /// 客户零件
/// </summary> /// </summary>
[Display(Name = "物料号")] [Display(Name = "客户零件号")]
[ExporterHeader(DisplayName = "厂内物料号")] [ExporterHeader(DisplayName = "客户零件号")]
public string MaterialNumber { get; set; } public string CustomerPartCode { get; set; }
/// <summary> /// <summary>
/// 物料描述 /// 零件描述
/// </summary> /// </summary>
[Display(Name = "物料描述")] [Display(Name = "零件描述")]
[ExporterHeader(DisplayName = "物料描述")] [ExporterHeader(DisplayName = "零件描述")]
public string MaterialDes { get; set; } public string PartCodeDesc { get; set; }
/// <summary> /// <summary>
/// 原始LU /// 厂内零件号
/// </summary> /// </summary>
[Display(Name = "原始LU")] [Display(Name = "厂内零件号")]
[ExporterHeader(DisplayName = "原始LU")] [ExporterHeader(DisplayName = "厂内零件号")]
public string PrimitiveLU { get; set; } public string FactoryPartCode { get; set; }
/// <summary> /// <summary>
///替换LU /// 替换厂内零件号
/// </summary> /// </summary>
[Display(Name = "替换LU")] [Display(Name = "替换厂内零件号")]
[ExporterHeader(DisplayName = "替换LU")] [ExporterHeader(DisplayName = "替换厂内零件号")]
public string ReplaceLU { get; set; } public string ReplaceFactoryPartCode { get; set; }
/// <summary> /// <summary>
/// 结算数据中的过账日期 /// 结算数据中的过账日期
/// </summary> /// </summary>
@ -894,83 +864,71 @@ public class PubSaSeCompareDetailExportYinDuJian : PubSaSeCompareDetailExport, I
[Display(Name = "生产码")] [Display(Name = "生产码")]
[ExporterHeader(DisplayName = "ASN发货单号")] [ExporterHeader(DisplayName = "ASN发货单号")]
public string PN { get; set; } public string PN { get; set; }
/// <summary> /// <summary>
/// 物料号 /// 客户物料号
/// </summary> /// </summary>
[Display(Name = "物料号")] [Display(Name = "客户物料号")]
[ExporterHeader(DisplayName = "厂内物料号")] [ExporterHeader(DisplayName = "客户物料号")]
public string MaterialNumber { get; set; } public string CustomerPartCode { get; set; }
/// <summary> /// <summary>
/// 物料描述 /// 物料描述
/// </summary> /// </summary>
[Display(Name = "物料描述")] [Display(Name = "物料描述")]
[ExporterHeader(DisplayName = "物料描述")] [ExporterHeader(DisplayName = "物料描述")]
public string MaterialDes { get; set; } public string PartCodeDesc { get; set; }
/// <summary> /// <summary>
/// 原始LU /// 厂内物料号
/// </summary> /// </summary>
[Display(Name = "原始LU")] [Display(Name = "厂内物料号")]
[ExporterHeader(DisplayName = "原始LU")] [ExporterHeader(DisplayName = "厂内物料号")]
public string PrimitiveLU { get; set; } public string FactoryPartCode { get; set; }
/// <summary> /// <summary>
///替换LU /// 替换厂内物料号
/// </summary> /// </summary>
[Display(Name = "替换LU")] [Display(Name = "替换厂内物料号")]
[ExporterHeader(DisplayName = "替换LU")] [ExporterHeader(DisplayName = "替换厂内物料号")]
public string ReplaceLU { get; set; } public string ReplaceFactoryPartCode { get; set; }
/// <summary> /// <summary>
/// 结算数据中的过账日期 /// 结算数据中的过账日期
/// </summary> /// </summary>
[Display(Name = "客户下线时间")] [Display(Name = "客户下线时间")]
[ExporterHeader(DisplayName = "客户下线时间")] [ExporterHeader(DisplayName = "客户下线时间")]
public DateTime CustomerOfflineTime { get; set; } public DateTime CustomerOfflineTime { get; set; }
/// <summary> /// <summary>
/// 结算数量 /// 结算数量
/// </summary> /// </summary>
[Display(Name = "结算数量")] [Display(Name = "结算数量")]
[ExporterHeader(DisplayName = "结算数量")] [ExporterHeader(DisplayName = "结算数量")]
public decimal SAQty { get; set; } public decimal SAQty { get; set; }
/// <summary> /// <summary>
/// 发货数量 /// 发货数量
/// </summary> /// </summary>
[Display(Name = "发货数量")] [Display(Name = "发货数量")]
[ExporterHeader(DisplayName = "WMS发货数量")] [ExporterHeader(DisplayName = "WMS发货数量")]
public decimal SEQty { get; set; } public decimal SEQty { get; set; }
/// <summary> /// <summary>
/// 差异数量 /// 差异数量
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "差异数量")] [ExporterHeader(DisplayName = "差异数量")]
public decimal DiffQty => SAQty - SEQty; public decimal DiffQty => SAQty - SEQty;
/// <summary> /// <summary>
/// 匹配类型 /// 匹配类型
/// </summary> /// </summary>
[Display(Name = "匹配类型")] [Display(Name = "匹配类型")]
[ExporterHeader(DisplayName = "是否完全匹配")] [ExporterHeader(DisplayName = "是否完全匹配")]
public string MateType { get; set; } public string MateType { get; set; }
/// <summary> /// <summary>
/// 定价 /// 定价
/// </summary> /// </summary>
[Display(Name = "定价")] [Display(Name = "定价")]
[ExporterHeader(DisplayName = "定价")] [ExporterHeader(DisplayName = "定价")]
public decimal FixPrice { get; set; } public decimal FixPrice { get; set; }
/// <summary> /// <summary>
/// WMS目标库位 /// WMS目标库位
/// </summary> /// </summary>
[Display(Name = "WMS目标库位")] [Display(Name = "WMS目标库位")]
[ExporterHeader(DisplayName = "WMS目标库位")] [ExporterHeader(DisplayName = "WMS目标库位")]
public string ToLocCode { get; set; } public string ToLocCode { get; set; }
/// <summary> /// <summary>
/// ERP目标库位 /// ERP目标库位
/// </summary> /// </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 = @$" string strSqlText = @$"
SELECT SELECT
A.LU AS SeCustomerPartCode,
A.FactoryPartCode AS SeFactoryPartCode,
B.LU AS SaCustomerPartCode,
B.PartCode AS SaFactoryPartCode,
A.WmsBillNum, A.WmsBillNum,
A.ShippingDate, A.ShippingDate,
A.LU AS MaterialNumber,
A.FactoryPartCode AS PrimitiveLU,
A.FactoryPartCode AS ReplaceLU,
'' MaterialDes,
B.SettleDate CustomerOfflineTime, B.SettleDate CustomerOfflineTime,
A.LU SeLU,
B.LU SaLU,
ISNULL(A.PN,B.PN) PN, ISNULL(A.PN,B.PN) PN,
A.SEQty, A.SEQty,
B.SAQty, B.SAQty,
@ -52,8 +50,8 @@ public class PubSaSeCompareDapperRepository : DapperRepository<SettleAccountDbCo
A.ToLocCode, A.ToLocCode,
A.ToErpLocCode A.ToErpLocCode
FROM 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 (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 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 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; 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();

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

@ -108,13 +108,41 @@ namespace SettleAccount.Job.Services.Report
pubSaSeCompareDiffs.ForEach(p => 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, false) => EnumPubSaSeCompareCategory.HaveSaHaveSe,
(false, true) => EnumPubSaSeCompareCategory.HaveSaNotHaveSe, (false, true) => EnumPubSaSeCompareCategory.HaveSaNotHaveSe,
(true, false) => EnumPubSaSeCompareCategory.NotHaveSaHaveSe, (true, false) => EnumPubSaSeCompareCategory.NotHaveSaHaveSe,
_ => EnumPubSaSeCompareCategory.None, _ => 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) 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) 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() 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, FactoryPartCode = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes, PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
SAQty = p.Sum(t => t.SAQty), SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty) SEQty = p.Sum(t => t.SEQty)
}).ToList(); }).ToList();
@ -258,30 +286,30 @@ namespace SettleAccount.Job.Services.Report
//有结算有发运 //有结算有发运
var haveSaHaveSeExports = pubSaSeCompareDetailExports.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.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport()
{ {
LU = p.Key, FactoryPartCode = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes, PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
SAQty = p.Sum(t => t.SAQty), SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty) SEQty = p.Sum(t => t.SEQty)
}).ToList(); }).ToList();
//有结算无发运 //有结算无发运
var haveSaNotHaveSeExports = pubSaSeCompareDetailExports.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() var haveSaNotHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport()
{ {
LU = p.Key, FactoryPartCode = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes, PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
SAQty = p.Sum(t => t.SAQty), SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty) SEQty = p.Sum(t => t.SEQty)
}).ToList(); }).ToList();
//无结算有发运 //无结算有发运
var notHaveSaHaveSeExports = pubSaSeCompareDetailExports.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() var notHaveSaHaveSeSumExports = haveSaHaveSeExports.GroupBy(p => p.ReplaceFactoryPartCode).Select(p => new PubSaSeCompareSumExport()
{ {
LU = p.Key, FactoryPartCode = p.Key,
MaterialDes = p.FirstOrDefault().MaterialDes, PartCodeDesc = p.FirstOrDefault().PartCodeDesc,
SAQty = p.Sum(t => t.SAQty), SAQty = p.Sum(t => t.SAQty),
SEQty = p.Sum(t => t.SEQty) SEQty = p.Sum(t => t.SEQty)
}).ToList(); }).ToList();

Loading…
Cancel
Save