学 赵 1 year ago
parent
commit
238698a6fb
  1. 58
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
  2. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  3. 26
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  4. 4
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs
  5. 3
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  6. 5824
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230918060007_20230918-1.Designer.cs
  7. 208
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230918060007_20230918-1.cs
  8. 28
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs
  9. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs
  10. 34
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs

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

@ -128,8 +128,8 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
Site = bbacSaImportRequestDto.Site; Site = bbacSaImportRequestDto.Site;
Version = bbacSaImportRequestDto.Version; Version = bbacSaImportRequestDto.Version;
#region 导入数据转换、数据校验 #region 导入数据转换、数据校验
ExportImporter _exportImporter = new ExportImporter(); var exportImporter = new ExportImporter();
var importDtos = await _exportImporter.UploadExcelImport<BBAC_SA_DETAIL_IMPORT_DTO>(bbacSaImportRequestDto.Files, _excelImportService).ConfigureAwait(false); var importDtos = await exportImporter.UploadExcelImport<BBAC_SA_DETAIL_IMPORT_DTO>(bbacSaImportRequestDto.Files, _excelImportService).ConfigureAwait(false);
importDtos.ForEach(importDto => importDtos.ForEach(importDto =>
{ {
@ -146,6 +146,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
{ {
importBBACSaDetail.Version = Version; importBBACSaDetail.Version = Version;
importBBACSaDetail.Site = Site; importBBACSaDetail.Site = Site;
importBBACSaDetail.BusinessType = importBBACSaDetail.PN.Contains("R0") ? EnumBusinessType.MaiDanJianBBAC : EnumBusinessType.JisBBAC;
}); });
//数据校验 //数据校验
@ -165,23 +166,23 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
if (!checkList.Any()) if (!checkList.Any())
{ {
//验证客户对应厂内零件号是否存在 //验证客户对应厂内零件号是否存在
//导入的零件号集合
var importPubSaLUs = importBBACSaDetails.Select(t => t.LU).Distinct(); var jisSaDetails = importBBACSaDetails.FindAll(t => t.BusinessType == EnumBusinessType.JisBBAC);
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); var maiDanSaDetails = importBBACSaDetails.FindAll(t => t.BusinessType == EnumBusinessType.MaiDanJianHBPO);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); if (jisSaDetails.Any())
//不存在的客户零件号(差集)
var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes);
noExistSettleMaterialCodes.ForEach(t =>
{ {
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"客户零件号【{t}】对应厂内零件号系统中不存在", string.Empty)); checkList.AddRange(await CheckAsync(jisSaDetails, EnumBusinessType.JisBBAC).ConfigureAwait(false));
}); }
if (maiDanSaDetails.Any())
{
checkList.AddRange(await CheckAsync(maiDanSaDetails, EnumBusinessType.MaiDanJianBBAC).ConfigureAwait(false));
}
} }
if (checkList.Count > 0) if (checkList.Count > 0)
{ {
string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false); string fileName = await ExportErrorReportAsync(checkList).ConfigureAwait(false);
return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message= "错误提示文件已下载,请打开文件查看", fileName = fileName }); return new JsonResult(new { Code = ApplicationConsts.ImportFailCode, Message = "错误提示文件已下载,请打开文件查看", fileName = fileName });
} }
#endregion #endregion
@ -192,6 +193,32 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
return new JsonResult(new { Code = 200, Message = "导入成功" }); return new JsonResult(new { Code = 200, Message = "导入成功" });
} }
/// <summary>
/// 数据校验
/// </summary>
private async Task<List<ErrorExportDto>> CheckAsync(List<BBAC_SA_DETAIL> saDetails, EnumBusinessType businessType)
{
#region 数据校验
//数据校验
var checkList = new List<ErrorExportDto>();
//验证客户对应厂内零件号是否存在
//导入的零件号集合
var saLus = saDetails.Select(t => t.LU).Distinct();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => t.BusinessType == businessType && saLus.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var settleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
//不存在的客户零件号(差集)
var noExistSettleMaterialCodes = saLus.Except(settleMaterialCodes);
noExistSettleMaterialCodes.ForEach(t =>
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, $"客户零件号【{t}】对应厂内零件号系统中不存在", string.Empty));
});
return checkList;
#endregion
}
#endregion #endregion
#region CURD #region CURD
@ -400,7 +427,6 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
bbacSaDetail.BillNum = bbacSaBillNum; bbacSaDetail.BillNum = bbacSaBillNum;
bbacSaDetail.KeyCode = bbacSaDetail.PN + bbacSaDetail.LU; bbacSaDetail.KeyCode = bbacSaDetail.PN + bbacSaDetail.LU;
bbacSaDetail.CustomerPartCodeNoSpace = bbacSaDetail.LU.Replace(" ", ""); bbacSaDetail.CustomerPartCodeNoSpace = bbacSaDetail.LU.Replace(" ", "");
bbacSaDetail.BusinessType = bbacSaDetail.PN.Contains("R0") ? EnumBusinessType.MaiDanJianBBAC : _businessType;
}); });
//导入的零件号集合 //导入的零件号集合
@ -408,7 +434,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
//销售价格 //销售价格
var priceListEntitys = GetPriceListEntitys(importPubSaLUs); var priceListEntitys = GetPriceListEntitys(importPubSaLUs);
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => new List<EnumBusinessType> { EnumBusinessType.JisBBAC, EnumBusinessType.MaiDanJianBBAC }.Contains(t.BusinessType) && importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
bbacSaDetails.ForEach(bbacSaDetail => bbacSaDetails.ForEach(bbacSaDetail =>
{ {
//根据物料号、结算日期获取价格 //根据物料号、结算日期获取价格
@ -420,7 +446,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
.FirstOrDefault(); .FirstOrDefault();
bbacSaDetail.Price = priceListEntity?.Price ?? 0; bbacSaDetail.Price = priceListEntity?.Price ?? 0;
bbacSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == bbacSaDetail.LU)?.ErpMaterialCode; bbacSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.BusinessType == bbacSaDetail.BusinessType && t.SettleMaterialCode == bbacSaDetail.LU)?.ErpMaterialCode;
}); });
#endregion #endregion

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs

@ -371,7 +371,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
var priceListEntitys = _priceListRepository.Where(t => t.IsCancel == false) var priceListEntitys = _priceListRepository.Where(t => t.IsCancel == false)
.Where(t => t.ClientCode == "104T") .Where(t => t.ClientCode == "104T")
.Where(t => importPubSaLUs.Contains(t.LU)).ToList(); .Where(t => importPubSaLUs.Contains(t.LU)).ToList();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => t.BusinessType == BusinessType && importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
hbpoSaDetails.ForEach(hbpoSaDetail => hbpoSaDetails.ForEach(hbpoSaDetail =>
{ {
//根据物料号、结算日期获取价格 //根据物料号、结算日期获取价格
@ -485,7 +485,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
//验证客户对应厂内零件号是否存在 //验证客户对应厂内零件号是否存在
//导入的零件号集合 //导入的零件号集合
var importSaLUs = hbpoSaDetails.Select(t => t.LU).Distinct(); var importSaLUs = hbpoSaDetails.Select(t => t.LU).Distinct();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => t.BusinessType == BusinessType && importSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
//不存在的客户零件号(差集) //不存在的客户零件号(差集)

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

@ -36,6 +36,10 @@ namespace Win.Sfs.SettleAccount.Entities.BQ;
[Route("api/settleaccount/[controller]/[action]")] [Route("api/settleaccount/[controller]/[action]")]
public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA> public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
{ {
/// <summary>
/// DbContext
/// </summary>
public SettleAccountDbContext _settleAccountDbContext;
/// <summary> /// <summary>
/// PUB结算仓储 /// PUB结算仓储
/// </summary> /// </summary>
@ -76,7 +80,8 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
/// <summary> /// <summary>
/// 构造 /// 构造
/// </summary> /// </summary>
public PUB_SA_SERVICE(INormalEfCoreRepository<PUB_SA, Guid> repository, public PUB_SA_SERVICE(SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<PUB_SA, Guid> repository,
INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository, INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository,
INormalEfCoreRepository<PUB_CAN_SA, Guid> pubCanSaRepository, INormalEfCoreRepository<PUB_CAN_SA, Guid> pubCanSaRepository,
INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> pubCanSaDetailRepository, INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> pubCanSaDetailRepository,
@ -91,6 +96,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
ICommonManager commonManager ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{ {
_settleAccountDbContext = settleAccountDbContext;
_repository = repository; _repository = repository;
_pubSaDetailRepository = pubSaDetailRepository; _pubSaDetailRepository = pubSaDetailRepository;
_pubCanSaRepository = pubCanSaRepository; _pubCanSaRepository = pubCanSaRepository;
@ -105,7 +111,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
/// <summary> /// <summary>
/// 期间 /// 期间
/// </summary> /// </summary>
private int _version; private int version;
/// <summary> /// <summary>
/// 业务类别 /// 业务类别
/// </summary> /// </summary>
@ -123,7 +129,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
public async Task<IActionResult> ImportAsync([FromForm] PUB_SAImportRequestDto pubSaImportRequestDto) public async Task<IActionResult> ImportAsync([FromForm] PUB_SAImportRequestDto pubSaImportRequestDto)
{ {
IActionResult result = new JsonResult(new { Code = 400 }); IActionResult result = new JsonResult(new { Code = 400 });
_version = pubSaImportRequestDto.Version; version = pubSaImportRequestDto.Version;
businessType = pubSaImportRequestDto.BusinessType; businessType = pubSaImportRequestDto.BusinessType;
site = pubSaImportRequestDto.Site; site = pubSaImportRequestDto.Site;
switch (pubSaImportRequestDto.BusinessType) switch (pubSaImportRequestDto.BusinessType)
@ -376,7 +382,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
//验证客户对应厂内零件号是否存在 //验证客户对应厂内零件号是否存在
//导入的零件号集合 //导入的零件号集合
var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct(); var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => t.BusinessType == businessType && importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct(); var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
//不存在的客户零件号(差集) //不存在的客户零件号(差集)
@ -429,9 +435,6 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
/// </summary> /// </summary>
private async Task<IActionResult> InsertSaDataAsync(List<PUB_SA_DETAIL> pubSaDetails, EnumBusinessType businessType) private async Task<IActionResult> InsertSaDataAsync(List<PUB_SA_DETAIL> pubSaDetails, EnumBusinessType businessType)
{ {
//客户零件关系
var materialRelationships = new List<MaterialRelationship>();
#region 处理结算数据 #region 处理结算数据
for (var i = 0; i < pubSaDetails.Count; i++) for (var i = 0; i < pubSaDetails.Count; i++)
{ {
@ -439,7 +442,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
pubSaDetail.SetId(GuidGenerator.Create()); pubSaDetail.SetId(GuidGenerator.Create());
pubSaDetail.CustomerPartCodeNoSpace = pubSaDetail.LU.Replace(" ", ""); pubSaDetail.CustomerPartCodeNoSpace = pubSaDetail.LU.Replace(" ", "");
pubSaDetail.KeyCode = pubSaDetail.PN + pubSaDetail.LU; pubSaDetail.KeyCode = pubSaDetail.PN + pubSaDetail.LU;
pubSaDetail.Version = _version; pubSaDetail.Version = version;
pubSaDetail.BusinessType = businessType; pubSaDetail.BusinessType = businessType;
pubSaDetail.IndexNum = i; pubSaDetail.IndexNum = i;
} }
@ -494,9 +497,8 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
//导入的零件号集合 //导入的零件号集合
var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct(); var importPubSaLUs = pubSaDetails.Select(t => t.LU).Distinct();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false); var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => t.BusinessType == businessType && importPubSaLUs.Contains(t.SettleMaterialCode)).ConfigureAwait(false);
var seAllMaterialRelationships = materialRelationshipEntitys.Union(materialRelationships);
pubSaDetails.ForEach(pubSaDetail => pubSaDetails.ForEach(pubSaDetail =>
{ {
pubSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == pubSaDetail.LU)?.ErpMaterialCode; pubSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == pubSaDetail.LU)?.ErpMaterialCode;
@ -505,10 +507,6 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
#region 添加入库 #region 添加入库
await SeDataEntryAsync(pubSaDetails).ConfigureAwait(false); await SeDataEntryAsync(pubSaDetails).ConfigureAwait(false);
if (materialRelationships.Count > 0)
{
await _materialRelationshipRepository.InsertManyAsync(materialRelationships).ConfigureAwait(false);
}
#endregion #endregion
return new JsonResult(new { Code = 200, Message = "导入成功" }); return new JsonResult(new { Code = 200, Message = "导入成功" });

4
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs

@ -63,13 +63,13 @@ public class MaterialRelationshipAppService : SettleAccountApplicationBase<Mater
if (_ls.Count > 0) if (_ls.Count > 0)
{ {
var query = from arc in _ls var query = from arc in _ls
group arc by new { arc.ErpMaterialCode } group arc by new { arc.SettleMaterialCode }
into g into g
where g.Count() > 1 where g.Count() > 1
select g; select g;
foreach (var itm in query) foreach (var itm in query)
{ {
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("厂内物料号{0}有重复", itm.Key.ErpMaterialCode), string.Empty)); checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("客户物料号{0}有重复", itm.Key.SettleMaterialCode), string.Empty));
} }
} }
if (checkList.Count > 0) if (checkList.Count > 0)

3
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs

@ -242,7 +242,8 @@ namespace Win.Sfs.SettleAccount
b.ToTable($"{options.TablePrefix}_relationship", options.Schema); b.ToTable($"{options.TablePrefix}_relationship", options.Schema);
b.ConfigureByConvention(); b.ConfigureByConvention();
b.Property(x => x.ErpMaterialCode).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength); b.Property(x => x.ErpMaterialCode).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength);
b.HasIndex(x => new { x.ErpMaterialCode, x.BusinessType }).IsUnique(); b.Property(x => x.SettleMaterialCode).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength);
b.HasIndex(x => new { x.ErpMaterialCode, x.SettleMaterialCode, x.BusinessType }).IsUnique();
}); });
} }

5824
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230918060007_20230918-1.Designer.cs

File diff suppressed because it is too large

208
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230918060007_20230918-1.cs

@ -0,0 +1,208 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202309181 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Set_relationship_ErpMaterialCode_BusinessType",
table: "Set_relationship");
migrationBuilder.AlterColumn<string>(
name: "SettleMaterialCode",
table: "Set_relationship",
type: "nvarchar(36)",
maxLength: 36,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
column: "ConcurrencyStamp",
value: "74b5f640459d4fb4af7e663ad318a7e8");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
column: "ConcurrencyStamp",
value: "3741a2331a464353932a67e49726504e");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"),
column: "ConcurrencyStamp",
value: "efbcbfc8ff684d41a932181e7deec6b2");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
column: "ConcurrencyStamp",
value: "abfcd02d9de44e678d983d5aa842c92d");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"),
column: "ConcurrencyStamp",
value: "6e2c96f0817e47e6a70dc07633f92365");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"),
column: "ConcurrencyStamp",
value: "626ba1e106b34594980d8d21abe54f2b");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
column: "ConcurrencyStamp",
value: "06c84c84594341a0b7dd108a11ed4b13");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"),
column: "ConcurrencyStamp",
value: "0750f96fa58c4452be0f0ccd7d304953");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"),
column: "ConcurrencyStamp",
value: "654ad9973c87451ca057551e0ced4822");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
column: "ConcurrencyStamp",
value: "92d9e39172c2463e9a06b09252533b94");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"),
column: "ConcurrencyStamp",
value: "621689c5c9ff4ae198f99abcec3fedb9");
migrationBuilder.CreateIndex(
name: "IX_Set_relationship_ErpMaterialCode_SettleMaterialCode_BusinessType",
table: "Set_relationship",
columns: new[] { "ErpMaterialCode", "SettleMaterialCode", "BusinessType" },
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Set_relationship_ErpMaterialCode_SettleMaterialCode_BusinessType",
table: "Set_relationship");
migrationBuilder.AlterColumn<string>(
name: "SettleMaterialCode",
table: "Set_relationship",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(36)",
oldMaxLength: 36);
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
column: "ConcurrencyStamp",
value: "d58d671303b941739e1f15175d2885fa");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
column: "ConcurrencyStamp",
value: "11cb239191164161b43fe11f01e15ff1");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"),
column: "ConcurrencyStamp",
value: "cad1d2b24dfa40af9cef675a1483033e");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
column: "ConcurrencyStamp",
value: "757f9afcb2b0452e80903f64435c50e0");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"),
column: "ConcurrencyStamp",
value: "59396a1080ba4af7ab4d644f2db85992");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"),
column: "ConcurrencyStamp",
value: "8cb7e348ae5645748e52c3fd998fe792");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
column: "ConcurrencyStamp",
value: "1d37186ccfcf423b963303847322dacf");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"),
column: "ConcurrencyStamp",
value: "8cfaa28a391b4092a54c3e6bc038c96e");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"),
column: "ConcurrencyStamp",
value: "69697dd7feb94adc94f47e761b14be51");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
column: "ConcurrencyStamp",
value: "eb45100def7f4621bc511c4fb779d500");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"),
column: "ConcurrencyStamp",
value: "1efb2d30d2a34d929b10ad04ef3daaf9");
migrationBuilder.CreateIndex(
name: "IX_Set_relationship_ErpMaterialCode_BusinessType",
table: "Set_relationship",
columns: new[] { "ErpMaterialCode", "BusinessType" },
unique: true);
}
}
}

28
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

@ -4506,7 +4506,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new new
{ {
Id = new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"), Id = new Guid("ef3d8e8a-a88e-ca1f-e615-714c6bc48824"),
ConcurrencyStamp = "eb45100def7f4621bc511c4fb779d500", ConcurrencyStamp = "92d9e39172c2463e9a06b09252533b94",
Cron = "0 0 8 26 *", Cron = "0 0 8 26 *",
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
@ -4516,7 +4516,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new new
{ {
Id = new Guid("185c5968-e02b-267e-db2f-225fccfc9716"), Id = new Guid("185c5968-e02b-267e-db2f-225fccfc9716"),
ConcurrencyStamp = "d58d671303b941739e1f15175d2885fa", ConcurrencyStamp = "74b5f640459d4fb4af7e663ad318a7e8",
Cron = "0 0/1 * * * ?", Cron = "0 0/1 * * * ?",
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
@ -4526,7 +4526,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new new
{ {
Id = new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"), Id = new Guid("1bb02f67-ed05-6cc1-1507-502e8f6c7a31"),
ConcurrencyStamp = "11cb239191164161b43fe11f01e15ff1", ConcurrencyStamp = "3741a2331a464353932a67e49726504e",
Cron = "0 0/1 * * * ?", Cron = "0 0/1 * * * ?",
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
@ -4536,7 +4536,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new new
{ {
Id = new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"), Id = new Guid("b9b9c79f-4894-474b-4f67-b1ec121c41e5"),
ConcurrencyStamp = "1d37186ccfcf423b963303847322dacf", ConcurrencyStamp = "06c84c84594341a0b7dd108a11ed4b13",
Cron = "0 0/30 * * * ? ", Cron = "0 0/30 * * * ? ",
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
@ -4546,7 +4546,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new new
{ {
Id = new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"), Id = new Guid("49b1da12-418c-544d-fe8b-be7e5b572452"),
ConcurrencyStamp = "cad1d2b24dfa40af9cef675a1483033e", ConcurrencyStamp = "efbcbfc8ff684d41a932181e7deec6b2",
Cron = "0 0/30 * * * ? ", Cron = "0 0/30 * * * ? ",
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
@ -4556,7 +4556,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new new
{ {
Id = new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"), Id = new Guid("7a0dc087-a859-5863-eb6e-56f588bd779e"),
ConcurrencyStamp = "59396a1080ba4af7ab4d644f2db85992", ConcurrencyStamp = "6e2c96f0817e47e6a70dc07633f92365",
Cron = "0 0/30 * * * ? ", Cron = "0 0/30 * * * ? ",
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
@ -4566,7 +4566,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new new
{ {
Id = new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"), Id = new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
ConcurrencyStamp = "757f9afcb2b0452e80903f64435c50e0", ConcurrencyStamp = "abfcd02d9de44e678d983d5aa842c92d",
Cron = "0 0/30 * * * ? ", Cron = "0 0/30 * * * ? ",
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
@ -4576,7 +4576,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new new
{ {
Id = new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"), Id = new Guid("f306b380-47e5-5c01-b902-67ca4113a8f4"),
ConcurrencyStamp = "1efb2d30d2a34d929b10ad04ef3daaf9", ConcurrencyStamp = "621689c5c9ff4ae198f99abcec3fedb9",
Cron = "0 0/30 * * * ? ", Cron = "0 0/30 * * * ? ",
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
@ -4586,7 +4586,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new new
{ {
Id = new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"), Id = new Guid("8f7dc23d-e2e9-3691-cfe9-545bb958e3f2"),
ConcurrencyStamp = "8cb7e348ae5645748e52c3fd998fe792", ConcurrencyStamp = "626ba1e106b34594980d8d21abe54f2b",
Cron = "0 0/30 * * * ? ", Cron = "0 0/30 * * * ? ",
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
@ -4596,7 +4596,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new new
{ {
Id = new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"), Id = new Guid("c1f71240-1b81-0107-8b23-ddc9811a3efe"),
ConcurrencyStamp = "69697dd7feb94adc94f47e761b14be51", ConcurrencyStamp = "654ad9973c87451ca057551e0ced4822",
Cron = "0 0/30 * * * ? ", Cron = "0 0/30 * * * ? ",
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
@ -4606,7 +4606,7 @@ namespace Win.Sfs.SettleAccount.Migrations
new new
{ {
Id = new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"), Id = new Guid("c09c23ea-815f-1b43-4476-2365a8d9a60b"),
ConcurrencyStamp = "8cfaa28a391b4092a54c3e6bc038c96e", ConcurrencyStamp = "0750f96fa58c4452be0f0ccd7d304953",
Cron = "0 0/30 * * * ? ", Cron = "0 0/30 * * * ? ",
IsDisabled = false, IsDisabled = false,
IsRunning = false, IsRunning = false,
@ -5794,11 +5794,13 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<string>("SettleMaterialCode") b.Property<string>("SettleMaterialCode")
.HasColumnType("nvarchar(max)"); .IsRequired()
.HasMaxLength(36)
.HasColumnType("nvarchar(36)");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ErpMaterialCode", "BusinessType") b.HasIndex("ErpMaterialCode", "SettleMaterialCode", "BusinessType")
.IsUnique(); .IsUnique();
b.ToTable("Set_relationship"); b.ToTable("Set_relationship");

5
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeCompareExportBaseService.cs

@ -5,7 +5,6 @@ using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core.Extension; using Magicodes.ExporterAndImporter.Core.Extension;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.SignalR; using Microsoft.AspNetCore.SignalR;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using SettleAccount.Bases; using SettleAccount.Bases;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR; using SettleAccount.Job.SignalR;
@ -276,7 +275,7 @@ namespace SettleAccount.Job.Services.Report
/// <summary> /// <summary>
/// 结算数据处理 /// 结算数据处理
/// 写入库位、替换零件号 /// 结算详情表写入库位、替换零件号
/// </summary> /// </summary>
public virtual void HandleSaDetails<TCanSa, TNotSa>(List<SaSeCompareDiff> saSeCompareDiffs, EnumBusinessType businessType, int version) public virtual void HandleSaDetails<TCanSa, TNotSa>(List<SaSeCompareDiff> saSeCompareDiffs, EnumBusinessType businessType, int version)
where TCanSa : SA_CAN_BASE where TCanSa : SA_CAN_BASE
@ -320,7 +319,7 @@ namespace SettleAccount.Job.Services.Report
/// <summary> /// <summary>
/// 处理结算数据 /// 处理结算数据
/// 结算、发运对比上的数据修改结算数据状态 /// 结算、发运对比上的数据修改结算详情表匹配类型
/// </summary> /// </summary>
public virtual void HandleSaDetailsMain<T>(List<SaSeCompareDiff> saSeCompareDiffs, EnumBusinessType businessType, int version) where T : SA_BASE public virtual void HandleSaDetailsMain<T>(List<SaSeCompareDiff> saSeCompareDiffs, EnumBusinessType businessType, int version) where T : SA_BASE
{ {

34
code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/SaSeEdiCompareExportBaseService.cs

@ -9,7 +9,6 @@ using SettleAccount.Domain.BQ;
using SettleAccount.Job.SignalR; using SettleAccount.Job.SignalR;
using Win.Sfs.SettleAccount; using Win.Sfs.SettleAccount;
using Win.Sfs.SettleAccount.Consts; using Win.Sfs.SettleAccount.Consts;
using Win.Sfs.SettleAccount.Entities.SettleAccountDomain;
using Win.Sfs.SettleAccount.Enums; using Win.Sfs.SettleAccount.Enums;
using Win.Sfs.SettleAccount.Reports; using Win.Sfs.SettleAccount.Reports;
@ -176,6 +175,39 @@ namespace SettleAccount.Job.Services.Report
} }
} }
/// <summary>
/// 处理结算数据
/// 结算、发运对比上的数据修改结算详情表匹配类型
/// </summary>
public virtual void HandleSaDetailsMain<T>(List<SaSeEdiCompareDiff> saSeEdiCompareDiff, EnumBusinessType businessType, int version) where T : SA_BASE
{
var haveSaHaveSes = saSeEdiCompareDiff.FindAll(t => t.Category == EnumSaSeEdiCompareCategory.HaveSaHaveSeHaveEdi || t.Category == EnumSaSeEdiCompareCategory.HaveSaHaveSeNotHaveEdi);
if (haveSaHaveSes.Any())
{
//结算详情
var saDetails = _settleAccountDbContext.Set<T>()
.Where(t => t.BusinessType == businessType)
.Where(t => t.MappingType == EnumMappingType.None)
.Where(t => t.Version == version)
.ToList();
if (saDetails.Any())
{
var saDetailsUpdate = saDetails.Join(haveSaHaveSes, o => new { o.PN, o.LU }, i => new { i.PN, LU = i.CustomerPartCode }, (o, i) =>
{
var mappingType = (i.SAQty - i.SEQty) switch
{
0 => EnumMappingType.PerfectMatch,
> 0 or < 0 => EnumMappingType.PartialMatch,
_ => default,
};
o.MappingType = mappingType;
return o;
}).ToList();
_settleAccountDbContext.BulkUpdate(saDetailsUpdate);
}
}
}
/// <summary> /// <summary>
/// 创建导出文件结构 /// 创建导出文件结构
/// </summary> /// </summary>

Loading…
Cancel
Save