Browse Source

结算导入添加期间参数

master
mahao 1 year ago
parent
commit
47b680c79f
  1. 53
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json
  2. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  3. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
  4. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs
  5. 24
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  6. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PURCHASE_PRICE_SERVICE.cs
  7. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  8. 151
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/PubSaSeCompareDiff.cs
  9. 17
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Repository/SettleAccountJob/Report/PubSaSeCompareDapperRepository.cs
  10. 266
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  11. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobAutoMapperProfile.cs

53
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/appsettings.json

@ -2,12 +2,25 @@
"App": { "App": {
"CorsOrigins": "https://*.abc.com,http://localhost:9527,http://149.223.116.5:8088" "CorsOrigins": "https://*.abc.com,http://localhost:9527,http://149.223.116.5:8088"
}, },
//"ConnectionStrings": {
// "Default": "Server=LAPTOP-V3U07C2O;Database=ABP;user id=sa;Password=1q2w!@#",
// "SettleAccountService": "Server=LAPTOP-V3U07C2O;Database=SettleAccountService1;user id=sa;Password=1q2w!@#;"
//},
"ConnectionStrings": { "ConnectionStrings": {
"Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True", "Default": "Server=dev.ccwin-in.com,13319;Database=BJABP;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True",
"SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;", "SettleAccountService": "Server=dev.ccwin-in.com,13319;Database=BQ_SA;User ID=ccwin-in;Password=Microsoft@2022;Trusted_Connection=False;TrustServerCertificate=True;"
"WMSBJBMPT": "Server=dev.ccwin-in.com,6208;Database=WMS_BJBMPT_2;User ID=sa;Password=ChangkeTec@2021;Trusted_Connection=False;TrustServerCertificate=True;", //"SettleAccountService": "Server=localhost;Database=BQ_SA;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True",
"questdb": "host=dev.ccwin-in.com;port=10580;username=admin;password=quest;database=vmi;ServerCompatibilityMode=NoTypeLoading;" //"Default": "Server=localhost;Database=BJABP;User ID=sa;Password=aA123456!;Trusted_Connection=False;TrustServerCertificate=True"
}, },
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"Serilog": { "Serilog": {
"Using": [], "Using": [],
"MinumumLevel": { "MinumumLevel": {
@ -69,8 +82,15 @@
}, },
"AuthServer": { "AuthServer": {
"Authority": "http://localhost:10582", //"Authority": "http://dev.ccwin-in.com:10580",
"Authority": "http://localhost:44378",
"ClientId": "basic-web", "ClientId": "basic-web",
"ClientSecret": "1q2w3e*" "ClientSecret": "1q2w3e*"
}, },
@ -80,5 +100,28 @@
}, },
"DefaultBranchId": "3FA85F64-5717-4562-B3FC-2C963F66AFA6", "DefaultBranchId": "3FA85F64-5717-4562-B3FC-2C963F66AFA6",
"AllowedHosts": "*" "AllowedHosts": "*",
"ElasticSearch": {
"Url": "http://localhost:9200"
},
"RemoteServices": {
"Default": {
"BaseUrl": "http://149.223.116.5:8091/",
"UseCurrentAccessToken": "true"
}
},
"IdentityClients": {
"Default": {
"GrantType": "client_credentials",
"ClientId": "business-app",
"ClientSecret": "1q2w3e*",
"Authority": "http://149.223.116.5:8066",
"Scope": "InternalGateway IdentityService SettleAccount"
}
}
} }

18
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs

@ -52,9 +52,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public IFormFileCollection Files { get; set; } public IFormFileCollection Files { get; set; }
/// <summary> /// <summary>
/// 是否是备件 /// 业务类别
/// </summary> /// </summary>
public EnumBusinessType BusinessType { get; set; } public EnumBusinessType BusinessType { get; set; }
/// <summary>
/// 期间
/// </summary>
[Display(Name = "期间")]
public int Version { get; set; }
} }
/// <summary> /// <summary>
@ -439,5 +445,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// 业务类型 /// 业务类型
/// </summary> /// </summary>
public EnumBusinessType BusinessType { get; set; } public EnumBusinessType BusinessType { get; set; }
/// <summary>
/// 发运开始时间
/// </summary>
public DateTime? SeStartDateTime { get; set; }
/// <summary>
/// 发运结束时间
/// </summary>
public DateTime? SeEndDateTime { get; set; }
} }
} }

9
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs

@ -115,12 +115,13 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
ExportImporter _exportImporter = new ExportImporter(); ExportImporter _exportImporter = new ExportImporter();
var importDtos = await _exportImporter.UploadExcelImport<BBAC_SA_DETAIL_IMPORT_DTO>(files, _excelImportService); var importDtos = await _exportImporter.UploadExcelImport<BBAC_SA_DETAIL_IMPORT_DTO>(files, _excelImportService);
//买单件BBAC
var importMaiDanJianHBOPDtos = importDtos.FindAll(t => t.PN.Contains("R0"));
//JisBBAC //JisBBAC
var importHBOPDtos = importDtos.FindAll(t => t.PN.Contains("R0") == false); var importHBOPDtos = importDtos.FindAll(t => t.PN.Contains("R0") == false);
//买单件BBAC
var importMaiDanJianHBOPDtos = importDtos.FindAll(t => t.PN.Contains("R0"));
var importBBACSaDetails = ObjectMapper.Map<List<BBAC_SA_DETAIL_IMPORT_DTO>, List<BBAC_SA_DETAIL>>(importHBOPDtos); var importBBACSaDetails = ObjectMapper.Map<List<BBAC_SA_DETAIL_IMPORT_DTO>, List<BBAC_SA_DETAIL>>(importHBOPDtos);
var importMaiDanJianBBACSaDetails = ObjectMapper.Map<List<BBAC_SA_DETAIL_IMPORT_DTO>, List<PUB_SA_DETAIL>>(importHBOPDtos);
//数据校验 //数据校验
var checkList = new List<ErrorExportDto>(); var checkList = new List<ErrorExportDto>();
@ -145,7 +146,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
if (importBBACSaDetails.Any()) if (importBBACSaDetails.Any())
{ {
//await SaDataHandleAsync(importBBACSaDetails); await SaDataHandleAsync(importBBACSaDetails, importMaiDanJianBBACSaDetails);
} }
return new JsonResult(new { Code = 200, Message = "导入成功" }); return new JsonResult(new { Code = 200, Message = "导入成功" });
@ -285,7 +286,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
/// <summary> /// <summary>
/// 结算数据处理 /// 结算数据处理
/// </summary> /// </summary>
private async Task SaDataHandleAsync(List<BBAC_SA_DETAIL> bbacSaDetails) private async Task SaDataHandleAsync(List<BBAC_SA_DETAIL> bbacSaDetails, List<PUB_SA_DETAIL> maiDanJianBBACSaDetails)
{ {
//结算单号 //结算单号
var bbacSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA"); var bbacSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA");

2
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs

@ -120,6 +120,8 @@ public class PUB_SA_DETAIL_SERVICE : SettleAccountApplicationBase<PUB_SA_DETAIL>
customConditionList.Add(new CustomCondition() { Name = "LU", Value = pubSaSeCompareRequestDto.LU }); customConditionList.Add(new CustomCondition() { Name = "LU", Value = pubSaSeCompareRequestDto.LU });
customConditionList.Add(new CustomCondition() { Name = "PN", Value = pubSaSeCompareRequestDto.PN }); customConditionList.Add(new CustomCondition() { Name = "PN", Value = pubSaSeCompareRequestDto.PN });
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = projectName }); customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = projectName });
customConditionList.Add(new CustomCondition() { Name = "SeStartDateTime", Value = pubSaSeCompareRequestDto.SeStartDateTime?.ToString("yyyy-MM-dd") });
customConditionList.Add(new CustomCondition() { Name = "SeEndDateTime", Value = pubSaSeCompareRequestDto.SeEndDateTime?.ToString("yyyy-MM-dd") });
var _taskid = await _taskJobService.ExportEnqueueAsync(projectName, ExportExtentsion.Excel, pubSaSeCompareRequestDto.Version, string.Empty, CurrentUser, typeof(PubSaSeCompareExportService), customConditionList, (rs) => var _taskid = await _taskJobService.ExportEnqueueAsync(projectName, ExportExtentsion.Excel, pubSaSeCompareRequestDto.Version, string.Empty, CurrentUser, typeof(PubSaSeCompareExportService), customConditionList, (rs) =>
{ {

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

@ -102,6 +102,11 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; _tbRePartsRelationshipRepository = tbRePartsRelationshipRepository;
} }
/// <summary>
/// 期间
/// </summary>
private int _version;
#region 导入、导出 #region 导入、导出
/// <summary> /// <summary>
/// 导入 /// 导入
@ -110,6 +115,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
public async Task<IActionResult> ImportByBusinessTypeAsync([FromForm] PUB_SAImportRequestDto pubSaImportRequestDto) public async Task<IActionResult> ImportByBusinessTypeAsync([FromForm] PUB_SAImportRequestDto pubSaImportRequestDto)
{ {
IActionResult result = new JsonResult(null); IActionResult result = new JsonResult(null);
_version = pubSaImportRequestDto.Version;
switch (pubSaImportRequestDto.BusinessType) switch (pubSaImportRequestDto.BusinessType)
{ {
case EnumBusinessType.None: case EnumBusinessType.None:
@ -306,7 +312,6 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
//客户零件关系 //客户零件关系
var materialRelationships = new List<MaterialRelationship>(); var materialRelationships = new List<MaterialRelationship>();
#region 导入数据转换、数据校验 #region 导入数据转换、数据校验
ExportImporter _exportImporter = new ExportImporter(); ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PUB_SA_DETAIL_IMPORT_DTO>(files, _excelImportService); var result = await _exportImporter.UploadExcelImport<PUB_SA_DETAIL_IMPORT_DTO>(files, _excelImportService);
@ -332,7 +337,6 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
} }
#endregion #endregion
#region 处理结算数据 #region 处理结算数据
//销售价格 //销售价格
var priceListEntitys = await _priceListRepository.GetAllAsync(); var priceListEntitys = await _priceListRepository.GetAllAsync();
@ -376,7 +380,6 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
}); });
#endregion #endregion
#region 入库数据赋值 #region 入库数据赋值
//结算明细 //结算明细
pubSaDetails = importPubSaDetails; pubSaDetails = importPubSaDetails;
@ -605,6 +608,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
importPubSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index); importPubSaDetail.LU += luAssemble.Aggregate(" ", (current, index) => current + index);
} }
importPubSaDetail.Version = _version;
importPubSaDetail.BusinessType = businessType; importPubSaDetail.BusinessType = businessType;
importPubSaDetail.Site = "XX工厂"; importPubSaDetail.Site = "XX工厂";
importPubSaDetail.KeyCode = importPubSaDetail.PN + importPubSaDetail.LU; importPubSaDetail.KeyCode = importPubSaDetail.PN + importPubSaDetail.LU;
@ -650,7 +654,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
private async Task SeDataEntryAsync(List<PUB_SA_DETAIL> pubSaDetails) private async Task SeDataEntryAsync(List<PUB_SA_DETAIL> pubSaDetails)
{ {
//业务类型 //业务类型
EnumBusinessType businessType = pubSaDetails.First().BusinessType; var pubSaFirstDetail = pubSaDetails.First();
//结算单号 //结算单号
var pubSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA"); var pubSaBillNum = OrderNumberGenerator.GenerateOrderNumber("SA");
//结算主表 //结算主表
@ -658,7 +662,8 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
{ {
BillNum = pubSaBillNum, BillNum = pubSaBillNum,
State = "1", State = "1",
BusinessType = businessType BusinessType = pubSaFirstDetail.BusinessType,
Version = pubSaFirstDetail.Version
}; };
//可结算单号 //可结算单号
var pubCanSaBillNum = OrderNumberGenerator.GenerateOrderNumber("C"); var pubCanSaBillNum = OrderNumberGenerator.GenerateOrderNumber("C");
@ -668,7 +673,8 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
BillNum = pubCanSaBillNum, BillNum = pubCanSaBillNum,
SettleBillNum = pubSaBillNum, SettleBillNum = pubSaBillNum,
State = SettleBillState., State = SettleBillState.,
BusinessType = businessType BusinessType = pubSa.BusinessType,
Version = pubSa.Version
}; };
#region 入库数据赋值 #region 入库数据赋值
@ -696,7 +702,6 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
pubCanSaDetails.ForEach(pubCanSaDetail => pubCanSaDetails.ForEach(pubCanSaDetail =>
{ {
pubCanSaDetail.BillNum = pubCanSaDetail.InvGroupNum = pubCanSaBillNum; pubCanSaDetail.BillNum = pubCanSaDetail.InvGroupNum = pubCanSaBillNum;
pubCanSaDetail.BusinessType = businessType;
}); });
await _pubCanSaRepository.InsertAsync(pubCanSa); await _pubCanSaRepository.InsertAsync(pubCanSa);
@ -704,11 +709,6 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
} }
if (pubNotSaDetails.Count > 0) if (pubNotSaDetails.Count > 0)
{ {
pubNotSaDetails.ForEach(pubNotSaDetail =>
{
pubNotSaDetail.BusinessType = businessType;
});
await _pubNotSaDetailRepository.InsertManyAsync(pubNotSaDetails); await _pubNotSaDetailRepository.InsertManyAsync(pubNotSaDetails);
} }
#endregion #endregion

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

@ -5,7 +5,9 @@ using System.Threading.Tasks;
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 Microsoft.AspNetCore.SignalR;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR;
using Shouldly; using Shouldly;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching; using Volo.Abp.Caching;

1
code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

@ -982,6 +982,7 @@ namespace Win.Sfs.SettleAccount
.ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum)); .ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum));
CreateMap<BBAC_SA_DETAIL_IMPORT_DTO, BBAC_SA_DETAIL>(); CreateMap<BBAC_SA_DETAIL_IMPORT_DTO, BBAC_SA_DETAIL>();
CreateMap<BBAC_SA_DETAIL_IMPORT_DTO, PUB_SA_DETAIL>();
} }
/// <summary> /// <summary>

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

@ -1,5 +1,5 @@
using System.ComponentModel.DataAnnotations;
using System; using System;
using System.ComponentModel.DataAnnotations;
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Win.Sfs.SettleAccount.Enums; using Win.Sfs.SettleAccount.Enums;
@ -290,145 +290,34 @@ public class PubSaSeCompareSumExport
public decimal DiffQty => SAQty - SEQty; public decimal DiffQty => SAQty - SEQty;
} }
[ExcelExporter(MaxRowNumberOnASheet = 900000)]
public class PubSaSeCompareDiffExport222
{
/// <summary> /// <summary>
/// 有结算无发货(无EDI数据) /// 直供件BBAC结算与发运对比明细
///有结算无发货(有EDI数据)
///有结算有发货(无EDI数据)
///有结算有发货(无价格信息)
///有结算有发货(有EDI数据)
///无结算有发货(有EDI数据)
///无结算有发货(无EDI数据)
///有结算有发货(有EDI数据)
///有结算有发货(WMS多发)
/// </summary> /// </summary>
[Display(Name = "类别")] [ExcelExporter(MaxRowNumberOnASheet = 900000)]
public string Category { get; set; } public class PubSaSeCompareDetailExportZhiGongJianBBAC : PubSaSeCompareDetailExport
{
[Display(Name = "Wms发货单号")] }
public string WmsBillNum { get; set; }
[Display(Name = "发货日期")]
public DateTime ShippingDate { get; set; }
[Display(Name = "生产码")]
public string PN { get; set; }
[Display(Name = "物料号")]
public string MaterialNumber { get; set; }
[Display(Name = "物料描述")]
public string MaterialDes { get; set; }
[Display(Name = "原始LU")]
public string PrimitiveLU { get; set; }
[Display(Name = "替换LU")]
public string ReplaceLU { get; set; }
/// <summary>
/// 结算数据中的过账日期
/// </summary>
[Display(Name = "客户下线时间")]
public DateTime CustomerOfflineTime { get; set; }
[Display(Name = "结算数量")]
public decimal SAQty { get; set; }
[Display(Name = "发货数量")]
public decimal SEQty { get; set; }
/// <summary>
/// 差异数量
/// </summary>
[ExporterHeader(DisplayName = "差异数量")]
public decimal DiffQty { set; get; }
[Display(Name = "匹配类型")]
public string MateType { get; set; }
[Display(Name = "定价")]
public decimal FixPrice { get; set; }
[Display(Name = "PJIS日顺序号")]
public string PJISSeqNumber { get; set; }
[Display(Name = "日顺序号")]
public string SeqNumber { get; set; }
//[Display(Name = "零件号")]
//public string LU { get; set; } = null!;
[Display(Name = "小总成号")]
public string AssemblyCode { get; set; }
[Display(Name = "注塑码")]
public string InjectionCode { get; set; }
[Display(Name = "期间")]
public int Version { get; set; }
[Display(Name = "替换零件号")]
public string RepLU { get; set; }
/// <summary>
/// 零件号
/// </summary>
[ExporterHeader(DisplayName = "零件号")]
public string SeLU { set; get; }
/// <summary>
/// 生产号
/// </summary>
[ExporterHeader(DisplayName = "生产号")]
public string SePN { set; get; }
/// <summary>
/// 零件号
/// </summary>
[ExporterHeader(DisplayName = "零件号")]
public string SaLU { set; get; }
/// <summary> /// <summary>
/// 生产号 /// 直供件HBPO结算与发运对比明细
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "生产号")] [ExcelExporter(MaxRowNumberOnASheet = 900000)]
public string SaPN { set; get; } public class PubSaSeCompareDetailExportZhiGongJianHBPO : PubSaSeCompareDetailExport
{
}
/// <summary> /// <summary>
/// 结算数量 /// 备件结算与发运对比明细
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "结算数量")] [ExcelExporter(MaxRowNumberOnASheet = 900000)]
public decimal SaQty { set; get; } public class PubSaSeCompareDetailExportBeiJian : PubSaSeCompareDetailExport
{
}
/// <summary> /// <summary>
/// 发运数量 /// 印度件结算与发运对比明细
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "发运数量")] [ExcelExporter(MaxRowNumberOnASheet = 900000)]
public decimal SeQty { set; get; } public class PubSaSeCompareDetailExportYinDuJian : PubSaSeCompareDetailExport
{
} }

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

@ -1,5 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Dapper; using Dapper;
@ -24,8 +22,17 @@ public class PubSaSeCompareDapperRepository : DapperRepository<SettleAccountDbCo
/// <summary> /// <summary>
/// 获取差异 /// 获取差异
/// </summary> /// </summary>
public virtual List<PubSaSeCompareDiff> GetDetailDiffReportList(string businessType) public virtual List<PubSaSeCompareDiff> GetDetailDiffReportList(string businessType, string version, string seStartDateTime, string seEndDateTime)
{ {
string strSeWhere = string.Empty;
if (!string.IsNullOrWhiteSpace(seStartDateTime))
{
strSeWhere = $" AND BillTime >= {seStartDateTime} ";
}
if (!string.IsNullOrWhiteSpace(seEndDateTime))
{
strSeWhere = $" AND BillTime <= {seEndDateTime} ";
}
string strSqlText = @$" string strSqlText = @$"
SELECT SELECT
A.WmsBillNum, A.WmsBillNum,
@ -46,8 +53,8 @@ public class PubSaSeCompareDapperRepository : DapperRepository<SettleAccountDbCo
'' MateType, '' MateType,
B.Price FixPrice B.Price FixPrice
FROM FROM
(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 (SELECT SUM(QTY) SEQty,LU,PN,MAX(WmsBillNum) WmsBillNum,MAX(ShippingDate) ShippingDate 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} 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 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();

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

@ -2,14 +2,11 @@ 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.Core;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR;
using Microsoft.OpenApi.Extensions; 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 SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR;
using Shouldly; using Shouldly;
using TaskJob.EventArgs; using TaskJob.EventArgs;
using TaskJob.Interfaces; using TaskJob.Interfaces;
@ -19,7 +16,6 @@ using Volo.Abp.ObjectMapping;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Entities.BQ; using Win.Sfs.SettleAccount.Entities.BQ;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Enums; using Win.Sfs.SettleAccount.Enums;
using Win.Sfs.SettleAccount.Reports; using Win.Sfs.SettleAccount.Reports;
using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report; using Win.Sfs.SettleAccount.Repository.SettleAccountJob.Report;
@ -32,6 +28,11 @@ namespace SettleAccount.Job.Services.Report
/// </summary> /// </summary>
public class PubSaSeCompareExportService : ITransientDependency, IExportJob public class PubSaSeCompareExportService : ITransientDependency, IExportJob
{ {
/// <summary>
/// HubContext
/// </summary>
private readonly IHubContext<PageHub> _hubContext;
/// <summary> /// <summary>
/// 替换件关系仓储 /// 替换件关系仓储
/// </summary> /// </summary>
@ -61,12 +62,14 @@ namespace SettleAccount.Job.Services.Report
/// 构造 /// 构造
/// </summary> /// </summary>
public PubSaSeCompareExportService( public PubSaSeCompareExportService(
IHubContext<PageHub> hubContext,
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository, INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository,
INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSeCDetailRepository, INormalEfCoreRepository<PUB_SEC_DETAIL, Guid> pubSeCDetailRepository,
PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository, PubSaSeCompareDapperRepository pubSaSeCompareDapperRepository,
IBlobContainer<MyFileContainer> fileContainer, IBlobContainer<MyFileContainer> fileContainer,
IObjectMapper objectMapper) IObjectMapper objectMapper)
{ {
_hubContext = hubContext;
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; _tbRePartsRelationshipRepository = tbRePartsRelationshipRepository;
_pubSeCDetailRepository = pubSeCDetailRepository; _pubSeCDetailRepository = pubSeCDetailRepository;
_pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository; _pubSaSeCompareDapperRepository = pubSaSeCompareDapperRepository;
@ -87,18 +90,21 @@ namespace SettleAccount.Job.Services.Report
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property) public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property)
{ {
var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value; var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value;
var businessType = property.Where(t => t.Name == "BusinessType").FirstOrDefault().Value; var strBusinessType = property.Where(t => t.Name == "BusinessType").FirstOrDefault().Value;
var lu = property.Where(p => p.Name == "LU").FirstOrDefault().Value; var lu = property.Where(p => p.Name == "LU").FirstOrDefault().Value;
var pn = property.Where(p => p.Name == "PN").FirstOrDefault().Value; var pn = property.Where(p => p.Name == "PN").FirstOrDefault().Value;
var seStartDateTime = property.Where(p => p.Name == "SeStartDateTime").FirstOrDefault().Value;
var seEndDateTime = property.Where(p => p.Name == "SeEndDateTime").FirstOrDefault().Value;
EnumBusinessType businessType = (EnumBusinessType)Enum.Parse(typeof(EnumBusinessType), strBusinessType);
var businessTypeDisplayName = businessType.ToString(); var businessTypeDisplayName = businessType.ToString();
DisplayAttribute attributeOfType = ((EnumBusinessType)Enum.Parse(typeof(EnumBusinessType), businessType)).GetAttributeOfType<DisplayAttribute>(); DisplayAttribute attributeOfType = businessType.GetAttributeOfType<DisplayAttribute>();
if (attributeOfType != null) if (attributeOfType != null)
{ {
businessTypeDisplayName = attributeOfType.Name; businessTypeDisplayName = attributeOfType.Name;
} }
var filename = exportName.FirstOrDefault(); var filename = exportName.FirstOrDefault();
var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(businessType); var pubSaSeCompareDiffs = _pubSaSeCompareDapperRepository.GetDetailDiffReportList(strBusinessType, version, seStartDateTime, seEndDateTime);
pubSaSeCompareDiffs.ForEach(p => pubSaSeCompareDiffs.ForEach(p =>
{ {
@ -127,7 +133,7 @@ namespace SettleAccount.Job.Services.Report
#region 二次对比 #region 二次对比
//二次对比(替换零件号) //二次对比(替换零件号)
var repLUs = notHaveSaHaveSes.Select(t => t.SeLU).Distinct().ToList(); var repLUs = notHaveSaHaveSes.Select(t => t.SeLU).Distinct().ToList();
var tbRePartsRelationships = _tbRePartsRelationshipRepository.GetListAsync(t => repLUs.Contains(t.RepLU) && ((int)t.BusinessType).ToString() == businessType).Result; var tbRePartsRelationships = _tbRePartsRelationshipRepository.GetListAsync(t => repLUs.Contains(t.RepLU) && t.BusinessType == businessType).Result;
tbRePartsRelationships.ForEach(tbRePartsRelationship => tbRePartsRelationships.ForEach(tbRePartsRelationship =>
{ {
@ -192,7 +198,6 @@ namespace SettleAccount.Job.Services.Report
pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.PN == pn); pubSaSeCompareDiffs = pubSaSeCompareDiffs.FindAll(p => p.PN == pn);
} }
//结算核对明细
var pubSaSeCompareDetailExports = _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() var pubSaSeCompareSumExports = pubSaSeCompareDetailExports.GroupBy(p => p.ReplaceLU).Select(p => new PubSaSeCompareSumExport()
@ -234,12 +239,95 @@ namespace SettleAccount.Job.Services.Report
SEQty = p.Sum(t => t.SEQty) SEQty = p.Sum(t => t.SEQty)
}).ToList(); }).ToList();
#region MyRegion ExcelExporter excelExporter = new ExcelExporter();
#endregion switch (businessType)
{
case EnumBusinessType.ZhiGongJianBBAC:
{
var items = _objectMapper.Map<List<PubSaSeCompareDetailExport>, List<PubSaSeCompareDetailExportZhiGongJianBBAC>>(pubSaSeCompareDetailExports);
excelExporter = BindExcelExporter<PubSaSeCompareDetailExportZhiGongJianBBAC>(items, businessTypeDisplayName);
}
break;
case EnumBusinessType.ZhiGongJianHBPO:
{
var items = _objectMapper.Map<List<PubSaSeCompareDetailExport>, List<PubSaSeCompareDetailExportZhiGongJianHBPO>>(pubSaSeCompareDetailExports);
excelExporter = BindExcelExporter<PubSaSeCompareDetailExportZhiGongJianHBPO>(items, businessTypeDisplayName);
}
break;
case EnumBusinessType.MaiDanJianBBAC:
break;
case EnumBusinessType.MaiDanJianHBPO:
break;
case EnumBusinessType.BeiJian:
{
var items = _objectMapper.Map<List<PubSaSeCompareDetailExport>, List<PubSaSeCompareDetailExportBeiJian>>(pubSaSeCompareDetailExports);
excelExporter = BindExcelExporter<PubSaSeCompareDetailExportBeiJian>(items, businessTypeDisplayName);
}
break;
case EnumBusinessType.YinDuJian:
{
var items = _objectMapper.Map<List<PubSaSeCompareDetailExport>, List<PubSaSeCompareDetailExportYinDuJian>>(pubSaSeCompareDetailExports);
excelExporter = BindExcelExporter<PubSaSeCompareDetailExportYinDuJian>(items, businessTypeDisplayName);
}
break;
default:
break;
}
var result = excelExporter.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(filename, result.Result, true);
Notify();
return id.ToString();
}
#region 私有方法
public ExcelExporter BindExcelExporter<T>(List<T> pubSaSeCompareDetailExports, string businessTypeDisplayName) where T : PubSaSeCompareDetailExport, new()
{
//结算核对汇总
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 = 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 = 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 = 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();
ExcelExporter excelExporter = new ExcelExporter(); ExcelExporter excelExporter = new ExcelExporter();
var result = excelExporter return excelExporter
.Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出") .Append(pubSaSeCompareDetailExports, $"{businessTypeDisplayName}结算核对明细输出")
.SeparateBySheet() .SeparateBySheet()
.Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出") .Append(pubSaSeCompareSumExports, $"{businessTypeDisplayName}结算核对汇总输出")
@ -253,155 +341,13 @@ namespace SettleAccount.Job.Services.Report
.Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出") .Append(haveSaNotHaveSeExports, $"{businessTypeDisplayName}有结算无发货明细输出")
.SeparateBySheet() .SeparateBySheet()
.Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出") .Append(haveSaNotHaveSeSumExports, $"{businessTypeDisplayName}有结算无发货汇总输出")
.SeparateBySheet() .SeparateBySheet();
.ExportAppendDataAsByteArray();
result.ShouldNotBeNull();
_fileContainer.SaveAsync(filename, result.Result, true);
return id.ToString();
} }
/// <summary> private void Notify()
/// 导出(废弃)
/// </summary>
public string ExportFile333(Guid id, List<string> exportName, List<CustomCondition> property)
{ {
return ""; this._hubContext.Clients.All.ServerToClient("Compare", "refresh", "");
// var version = property.Where(p => p.Name == "Version").FirstOrDefault().Value;
// var _filename = exportName.FirstOrDefault();
// var _ls = _dapperRepository.GetDetailDiffReportList(version, materialCode, begin, end, cp7begin, cp7end, kenncode, chassisNumber, materialGroup);
// var diffList = _erpdapperRepository.GetSettleInvoiceDiff(version);
// foreach (var itm in _ls)
// {
// itm.InvoiceAmt = Math.Round(itm.InvoiceQty * itm.InvoicePrice, 2);
// itm.DiffPrice = itm.Price - itm.InvoicePrice;
// itm.DiffSettleFisQty = itm.SettledQty;
// }
// _ls = _ls.OrderBy(p => p.ChassisNumber).ThenBy(p => p.KENNCode).ThenBy(p => p.SapMaterialCode).ToList();
// if (!string.IsNullOrEmpty(materialGroup))
// {
// var _groupList = materialGroup.Split(new char[] { ',' }).Distinct().ToList();
// if (_groupList.Count() > 0)
// {
// _ls = _ls.Where(p => _groupList.Contains(p.MaterialGroup)).ToList();
// }
// }
// if (!string.IsNullOrEmpty(kenncode))
// {
// var _groupList = kenncode.Split(new char[] { '\n' }).Distinct().ToList();
// if (_groupList.Count() > 0)
// {
// _ls = _ls.Where(p => _groupList.Contains(p.KENNCode)).ToList();
// }
// }
// if (!string.IsNullOrEmpty(chassisNumber))
// {
// var _groupList = chassisNumber.Split(new char[] { '\n' }).Distinct().ToList();
// if (_groupList.Count() > 0)
// {
// _ls = _ls.Where(p => _groupList.Contains(p.ChassisNumber)).ToList();
// }
// }
// if (!string.IsNullOrEmpty(sapCode))
// {
// var _groupList = sapCode.Split(new char[] { '\n' }).Distinct().ToList();
// if (_groupList.Count() > 0)
// {
// _ls = _ls.Where(p => _groupList.Contains(p.SapMaterialCode)).ToList();
// }
// }
// if (!string.IsNullOrEmpty(materialCode))
// {
// var _groupList = materialCode.Split(new char[] { '\n' }).Distinct().ToList();
// if (_groupList.Count() > 0)
// {
// _ls = _ls.Where(p => _groupList.Contains(p.MaterialCode)).ToList();
// }
// }
// var _checkList = _erpdapperRepository.GetErrorBillList();
// var query = from itm in _ls
// join itm1 in _checkList on new { ChassisNumber = itm.ChassisNumber, MaterialCode = itm.MaterialCode, WmsBillNum = itm.WmsBillNum }
//equals new { ChassisNumber = itm1.BillNum, MaterialCode = itm1.MaterialCode, WmsBillNum = itm1.WmsBillNum } into temp1
// from tm1 in temp1.DefaultIfEmpty()
// where tm1 == null
// select itm;
// _ls = query.ToList();
// var _lsSum = _ls.GroupBy(p => new { p.MaterialCode, p.SapMaterialCode, p.MaterialGroup, p.InvoicePrice }).Select(p => new UnInvoiceSettledDetailSum
// {
// MaterialCode = p.Key.MaterialCode,
// SapMaterailCode = p.Key.SapMaterialCode,
// MaterialGroup = p.Key.MaterialGroup,
// SettleQty = p.Sum(itm => itm.SettledQty),
// FisQty = 0,
// DiffQty = -p.Sum(itm => itm.SettledQty),
// Price = p.Key.InvoicePrice,
// DiffAmt = p.Sum(itm => itm.SettledQty) * p.Key.InvoicePrice
// }).ToList();
// var _sumTotal = new UnInvoiceSettledDetailSum()
// {
// SettleQty = _lsSum.Sum(p => p.SettleQty),
// DiffQty = _lsSum.Sum(p => p.DiffQty),
// Price = _lsSum.Sum(p => p.Price),
// DiffAmt = _lsSum.Sum(p => p.DiffAmt)
// };
// _lsSum.Add(_sumTotal);
// var _ls1 = DiffPrice(id, exportName, p_list);
// var report1List = _ls1.Where(p => p.DiffPrice != 0).GroupBy(p => new { p.MaterialGroup, p.MaterialCode, p.MaterialDesc, p.Price, p.InvoicePrice, p.DiffPrice, p.SapMaterialCode })
// .Select(t => new SettleDoorPanelExport { MaterialGroup = t.FirstOrDefault().MaterialGroup, MaterialCode = t.FirstOrDefault().MaterialCode, MaterialDesc = t.FirstOrDefault().MaterialDesc, Price = t.FirstOrDefault().Price, InvoicePrice = t.FirstOrDefault().InvoicePrice, InvoiceDiffPrice = t.FirstOrDefault().DiffPrice, SAPCode = t.FirstOrDefault().SapMaterialCode }).ToList();
// var report2List = _ls1.Where(p => p.DiffPrice != 0).Select(p => new { p.MaterialGroup, DiffAmt = p.DiffPrice * p.Qty }).GroupBy(p => new { p.MaterialGroup }).Select(p => new SettleDoorPanelSumExport { MaterialGroup = p.Key.MaterialGroup, InvoiceDiffPrice = p.Sum(itm => itm.DiffAmt), Version = version });
// var list1 = LSettleSum(id, exportName, p_list);
// var report1 = report2List.ToList();
// foreach (var itm in list1)
// {
// itm.MaterialGroup = itm.MaterialGroup + "(漏结)";
// }
// report1.AddRange(list1);
// ExcelExporter _exporter = new ExcelExporter();//导出Excel
// var result = _exporter
// .Append(_ls, "差异明细表")
// .SeparateBySheet()
// .Append(_lsSum, "数量差异汇总表")
// .SeparateBySheet()
// .Append(report1List, "按物料价格差异明细表")
// .SeparateBySheet()
// .Append(report1, "差异汇总验证表")
// .ExportAppendDataAsByteArray();
// result.ShouldNotBeNull();
// _fileContainer.SaveAsync(_filename, result.Result, true);
// //_outputService.Export<InvoiceSettledDetailDiff>(id, string.Format("大众结算未发运核对明细表_{0}.xlsx", Guid.NewGuid().ToString()), _ls);
// return id.ToString();
} }
#endregion
} }
} }

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

@ -20,6 +20,11 @@ namespace SettleAccount.Job
.ForMember(x => x.ReplaceLU, y => y.MapFrom(y => y.ReplaceLU)); .ForMember(x => x.ReplaceLU, y => y.MapFrom(y => y.ReplaceLU));
CreateMap<PubSaSeCompareDiff, PUB_SEC_DETAIL>(); CreateMap<PubSaSeCompareDiff, PUB_SEC_DETAIL>();
CreateMap<PubSaSeCompareDetailExport, PubSaSeCompareDetailExportZhiGongJianBBAC>();
CreateMap<PubSaSeCompareDetailExport, PubSaSeCompareDetailExportZhiGongJianHBPO>();
CreateMap<PubSaSeCompareDetailExport, PubSaSeCompareDetailExportBeiJian>();
CreateMap<PubSaSeCompareDetailExport, PubSaSeCompareDetailExportYinDuJian>();
} }
} }
} }

Loading…
Cancel
Save