Browse Source

EF迁移厂内零件号与客户零件号关系

master
mahao 1 year ago
parent
commit
8a86a4343e
  1. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SA_DTO.cs
  2. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/HBPO_SA_DTO.cs
  3. 14
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  4. 5
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs
  5. 17
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SA_SERVICE.cs
  6. 19
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/HBPO_SA_SERVICE.cs
  7. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  8. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncAppService.cs
  9. 49
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs
  10. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncAppService.cs
  11. 51
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs
  12. 24
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs
  13. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MaiDanBBACSeSyncAppService.cs
  14. 3
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MaiDanHBPOSeSyncAppService.cs
  15. 569
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/FISes/FISAppService.cs
  16. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs
  17. 580
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/SettleAccounts/SettleAccountAppService.cs
  18. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  19. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_SE_DETAIL.cs
  20. 142
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/MaterialRelationships/MaterialRelationship.cs
  21. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/CommonManagers/CommonManager.cs
  22. 6
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  23. 5521
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230818070358_20230818-1.Designer.cs
  24. 191
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230818070358_20230818-1.cs
  25. 46
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

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

@ -1,6 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using Magicodes.ExporterAndImporter.Core;
using Microsoft.AspNetCore.Http;
using Volo.Abp.Application.Dtos;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos;
@ -96,6 +97,23 @@ public class BBAC_SA_DETAIL_DTO : EntityDto<Guid>
public string PartCode { get; set; }
}
/// <summary>
/// BBAC结算导入请求
/// </summary>
public class BBACSaImportRequestDto
{
/// <summary>
/// 文件
/// </summary>
public IFormFileCollection Files { get; set; }
/// <summary>
/// 期间
/// </summary>
[Display(Name = "期间")]
public int Version { get; set; }
}
/// <summary>
/// BBAC结算明细导入
/// </summary>

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

@ -1,6 +1,7 @@
using System;
using System.ComponentModel.DataAnnotations;
using Magicodes.ExporterAndImporter.Core;
using Microsoft.AspNetCore.Http;
using Volo.Abp.Application.Dtos;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos;
@ -96,6 +97,23 @@ public class HBPO_SA_DETAIL_DTO : EntityDto<Guid>
public string PartCode { get; set; }
}
/// <summary>
/// HBPO结算导入请求
/// </summary>
public class HBPOSaImportRequestDto
{
/// <summary>
/// 文件
/// </summary>
public IFormFileCollection Files { get; set; }
/// <summary>
/// 期间
/// </summary>
[Display(Name = "期间")]
public int Version { get; set; }
}
/// <summary>
/// HBPO结算明细导入
/// </summary>

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

@ -244,6 +244,13 @@ public class BeiJianImportDto : BeiJianExtraImportDto
[ImporterHeader(Name = "凭证号")]
[Required(ErrorMessage = "{0}不能为空")]
public string GroupNum { get; set; }
/// <summary>
/// 采购订单号
/// </summary>
[Display(Name = "采购订单号")]
[ImporterHeader(Name = "采购订单号")]
public string Extend3 { get; set; }
}
/// <summary>
@ -286,13 +293,6 @@ public class BeiJianExtraImportDto
[ImporterHeader(Name = "供应商名称")]
public string VendorName { set; get; }
/// <summary>
/// 采购订单号
/// </summary>
[Display(Name = "采购订单号")]
[ImporterHeader(Name = "采购订单号")]
public string PurchaseOrderNumber { set; get; }
/// <summary>
/// 交付索引号
/// </summary>

5
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs

@ -126,11 +126,6 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
/// 文件
/// </summary>
public IFormFileCollection Files { get; set; }
/// <summary>
/// 是否是备件
/// </summary>
public bool IsBj { get; set; }
}
/// <summary>

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

@ -111,11 +111,11 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
/// 导入
/// </summary>
[HttpPost]
public async Task<IActionResult> ImportAsync([FromForm] IFormFileCollection files)
public async Task<IActionResult> ImportAsync([FromForm] BBACSaImportRequestDto bbacSaImportRequestDto)
{
#region 导入数据转换、数据校验
ExportImporter _exportImporter = new ExportImporter();
var importDtos = await _exportImporter.UploadExcelImport<BBAC_SA_DETAIL_IMPORT_DTO>(files, _excelImportService).ConfigureAwait(false);
var importDtos = await _exportImporter.UploadExcelImport<BBAC_SA_DETAIL_IMPORT_DTO>(bbacSaImportRequestDto.Files, _excelImportService).ConfigureAwait(false);
importDtos.ForEach(importDto =>
{
@ -127,6 +127,11 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
var importBBACSaDetails = ObjectMapper.Map<List<BBAC_SA_DETAIL_IMPORT_DTO>, List<BBAC_SA_DETAIL>>(importDtos);
importBBACSaDetails.ForEach(importBBACSaDetail =>
{
importBBACSaDetail.Version = bbacSaImportRequestDto.Version;
});
//数据校验
var checkList = new List<ErrorExportDto>();
//结算分组号
@ -269,7 +274,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
}
if (bbacSaDetails.Any())
{
await _bbacSaDetailRepository.DeleteManyAsync(bbacSaDetails);
await _bbacSaDetailRepository.DbContext.BulkDeleteAsync(bbacSaDetails);
}
if (bbacCanSas.Any())
{
@ -277,11 +282,11 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
}
if (bbacCanSaDetails.Any())
{
await _bbacCanSaDetailRepository.DeleteManyAsync(bbacCanSaDetails);
await _bbacCanSaDetailRepository.DbContext.BulkDeleteAsync(bbacCanSaDetails);
}
if (bbacNotSaDetails.Any())
{
await _bbacNotSaDetailRepository.DeleteManyAsync(bbacNotSaDetails);
await _bbacNotSaDetailRepository.DbContext.BulkDeleteAsync(bbacNotSaDetails);
}
}
#endregion
@ -358,7 +363,7 @@ public class BBAC_SA_SERVICE : SettleAccountApplicationBase<BBAC_SA>
noExistSettleMaterialCodes.ForEach(t =>
{
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, _businessType.ToString());
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, _businessType);
materialRelationships.Add(materialRelationship);
});

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

@ -109,13 +109,18 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
/// 导入
/// </summary>
[HttpPost]
public async Task<IActionResult> ImportAsync([FromForm] IFormFileCollection files)
public async Task<IActionResult> ImportAsync([FromForm] HBPOSaImportRequestDto hbpoSaImportRequestDto)
{
#region 导入数据转换、数据校验
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<HBPO_SA_DETAIL_IMPORT_DTO>(files, _excelImportService);
var result = await _exportImporter.UploadExcelImport<HBPO_SA_DETAIL_IMPORT_DTO>(hbpoSaImportRequestDto.Files, _excelImportService).ConfigureAwait(false);
var importHBOPSaDetails = ObjectMapper.Map<List<HBPO_SA_DETAIL_IMPORT_DTO>, List<HBPO_SA_DETAIL>>(result);
importHBOPSaDetails.ForEach(importHBOPSaDetail =>
{
importHBOPSaDetail.Version = hbpoSaImportRequestDto.Version;
});
//Site包含CN1 亦庄
//Site包含CN5 顺义
var importCN1HBOPSaDetails = importHBOPSaDetails.FindAll(t => t.Site.Contains("CN1"));
@ -267,7 +272,7 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
}
if (hbpoSaDetails.Any())
{
await _hbpoSaDetailRepository.DeleteManyAsync(hbpoSaDetails);
await _hbpoSaDetailRepository.DbContext.BulkDeleteAsync(hbpoSaDetails);
}
if (hbpoCanSas.Any())
{
@ -275,11 +280,11 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
}
if (hbpoCanSaDetails.Any())
{
await _hbpoCanSaDetailRepository.DeleteManyAsync(hbpoCanSaDetails);
await _hbpoCanSaDetailRepository.DbContext.BulkDeleteAsync(hbpoCanSaDetails);
}
if (hbpoNotSaDetails.Any())
{
await _hbpoNotSaDetailRepository.DeleteManyAsync(hbpoNotSaDetails);
await _hbpoNotSaDetailRepository.DbContext.BulkDeleteAsync(hbpoNotSaDetails);
}
}
#endregion
@ -358,14 +363,14 @@ public class HBPO_SA_SERVICE : SettleAccountApplicationBase<HBPO_SA>
noExistSettleMaterialCodes.ForEach(t =>
{
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, _businessType.ToString());
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, _businessType);
materialRelationships.Add(materialRelationship);
});
var seAllMaterialRelationships = materialRelationshipEntitys.Union(materialRelationships);
hbpoSaDetails.ForEach(hbpoSaDetail =>
{
hbpoSaDetail.PartCode = seAllMaterialRelationships.FirstOrDefault(t => t.SettleMaterialCode == hbpoSaDetail.LU)?.ErpMaterialCode ?? hbpoSaDetail.LU.Replace(" ", "-");
hbpoSaDetail.PartCode = materialRelationshipEntitys.FirstOrDefault(t => t.SettleMaterialCode == hbpoSaDetail.LU)?.ErpMaterialCode ?? hbpoSaDetail.LU.Replace(" ", "-");
});
#endregion

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

@ -522,7 +522,7 @@ public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
noExistSettleMaterialCodes.ForEach(t =>
{
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, businessType.ToString());
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t, businessType);
materialRelationships.Add(materialRelationship);
});

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncAppService.cs

@ -23,11 +23,12 @@ public class JisBBACSeSyncAppService : JisBBACSeSyncBaseAppService, IJobService
/// </summary>
public JisBBACSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<BBAC_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
VmiAppService vmiService
) : base(wmsBJBMPTContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, vmiService)
) : base(wmsBJBMPTContext, settleAccountDbContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, vmiService)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{

49
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisBBACSeSyncBaseAppService.cs

@ -26,6 +26,11 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
/// </summary>
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext;
/// <summary>
/// 数据上下文
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
/// <summary>
/// 同步位置标记
/// </summary>
@ -48,12 +53,14 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
/// </summary>
public JisBBACSeSyncBaseAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<BBAC_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
VmiAppService vmiService)
{
_wmsBJBMPTContext = wmsBJBMPTContext;
_settleAccountDbContext = settleAccountDbContext;
_syncPositionFlagRepository = syncPositionFlagRepository;
_jisSeDetailRepository = jisSeDetailRepository;
_materialRelationshipManager = materialRelationshipManager;
@ -73,7 +80,7 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
return;
}
await SyncJitRecordAsync().ConfigureAwait(false);
await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false);
await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false);
await SyncJisRecordAsync().ConfigureAwait(false);
}
@ -107,8 +114,8 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType.ToString()));
await _materialRelationshipManager.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType));
await this.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
}
jisSeDetails.ForEach(t =>
@ -116,8 +123,12 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
t.SetId(GuidGenerator.Create());
t.BusinessType = businessType;
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
await _jisSeDetailRepository.DbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
await _settleAccountDbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
if (syncPositionFlag != null)
{
@ -166,8 +177,8 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType.ToString()));
await _materialRelationshipManager.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType));
await this.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
}
jisSeDetails.ForEach(t =>
@ -175,8 +186,12 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
t.SetId(GuidGenerator.Create());
t.BusinessType = businessType;
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
await _jisSeDetailRepository.DbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
await _settleAccountDbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
if (syncPositionFlag != null)
{
@ -194,4 +209,24 @@ public class JisBBACSeSyncBaseAppService : ApplicationService, IInvocable
}
}
}
/// <summary>
/// 添加零件关系
/// </summary>
public async Task AddNewMaterialRelationships(IEnumerable<MaterialRelationship> materialRelationships)
{
//新客户零件号和厂内零件号
var noHaveLuRePartCodes = from item1 in materialRelationships
join item2 in _settleAccountDbContext.Set<MaterialRelationship>()
on new { item1.ErpMaterialCode, item1.SettleMaterialCode } equals new { item2.ErpMaterialCode, item2.SettleMaterialCode }
into temp
from item3 in temp.DefaultIfEmpty()
where item3 == null
select item1;
if (noHaveLuRePartCodes.Any())
{
await _settleAccountDbContext.BulkInsertAsync(noHaveLuRePartCodes.ToList()).ConfigureAwait(false);
}
}
}

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncAppService.cs

@ -23,11 +23,12 @@ public class JisHBPOSeSyncAppService : JisHBPOSeSyncBaseAppService, IJobService
/// </summary>
public JisHBPOSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
VmiAppService vmiService
) : base(wmsBJBMPTContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, vmiService)
) : base(wmsBJBMPTContext, settleAccountDbContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, vmiService)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{

51
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JisHBPOSeSyncBaseAppService.cs

@ -27,6 +27,11 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
/// </summary>
private readonly WMSBJBMPTDbContext _wmsBJBMPTContext;
/// <summary>
/// 数据上下文
/// </summary>
private readonly SettleAccountDbContext _settleAccountDbContext;
/// <summary>
/// 同步位置标记
/// </summary>
@ -49,12 +54,14 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
/// </summary>
public JisHBPOSeSyncBaseAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
VmiAppService vmiService)
{
_wmsBJBMPTContext = wmsBJBMPTContext;
_settleAccountDbContext = settleAccountDbContext;
_syncPositionFlagRepository = syncPositionFlagRepository;
_jisSeDetailRepository = jisSeDetailRepository;
_materialRelationshipManager = materialRelationshipManager;
@ -74,7 +81,7 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
return;
}
await SyncJitRecordAsync().ConfigureAwait(false);
await CurrentUnitOfWork.SaveChangesAsync().ConfigureAwait(false);
await _settleAccountDbContext.SaveChangesAsync().ConfigureAwait(false);
await SyncJisRecordAsync().ConfigureAwait(false);
}
@ -109,8 +116,8 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType.ToString()));
await _materialRelationshipManager.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType));
await this.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
}
jisSeDetails.ForEach(t =>
@ -118,8 +125,12 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
t.SetId(GuidGenerator.Create());
t.BusinessType = businessType;
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
t.Version = int.Parse(t.BillTime?.ToString("YYYYMM"));
}
});
await _jisSeDetailRepository.DbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
await _settleAccountDbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
if (syncPositionFlag != null)
{
@ -169,8 +180,8 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
var luRePartCodes = jisSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType.ToString()));
await _materialRelationshipManager.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType));
await this.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
}
jisSeDetails.ForEach(t =>
@ -178,8 +189,12 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
t.SetId(GuidGenerator.Create());
t.BusinessType = businessType;
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
await _jisSeDetailRepository.DbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
await _settleAccountDbContext.BulkInsertAsync(jisSeDetails).ConfigureAwait(false);
if (syncPositionFlag != null)
{
@ -193,8 +208,28 @@ public class JisHBPOSeSyncBaseAppService : ApplicationService, IInvocable
TableName = syncTableName,
Position = wmsRecords.Last().UID.ToString()
};
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag).ConfigureAwait(false); ;
await _syncPositionFlagRepository.InsertAsync(syncPositionFlag).ConfigureAwait(false);
}
}
}
/// <summary>
/// 添加零件关系
/// </summary>
public async Task AddNewMaterialRelationships(IEnumerable<MaterialRelationship> materialRelationships)
{
//新客户零件号和厂内零件号
var noHaveLuRePartCodes = from item1 in materialRelationships
join item2 in _settleAccountDbContext.Set<MaterialRelationship>()
on new { item1.ErpMaterialCode, item1.SettleMaterialCode } equals new { item2.ErpMaterialCode, item2.SettleMaterialCode }
into temp
from item3 in temp.DefaultIfEmpty()
where item3 == null
select item1;
if (noHaveLuRePartCodes.Any())
{
await _settleAccountDbContext.BulkInsertAsync(noHaveLuRePartCodes.ToList()).ConfigureAwait(false);
}
}
}

24
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/JitSeSyncAppService.cs

@ -103,13 +103,17 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
var pubSeDetails = ObjectMapper.Map<List<TM_BJBMPT_OTHER_RECORD>, List<PUB_SE_DETAIL>>(wmsSeRecords);
if (pubSeDetails.Any())
{
//客户零件号和厂内零件号
var luRePartCodes = pubSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
if (businessType != EnumBusinessType.BeiJian)
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType.ToString()));
await this.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
//await _materialRelationshipManager.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
//备件以外其他业务添加客户零件号与厂内零件号关系
//客户零件号和厂内零件号
var luRePartCodes = pubSeDetails.Where(t => !string.IsNullOrEmpty(t.LU) && !string.IsNullOrEmpty(t.FactoryPartCode)).Select(t => new { t.LU, t.FactoryPartCode }).Distinct().ToList();
if (luRePartCodes.Any())
{
var materialRelationships = luRePartCodes.Select(t => new MaterialRelationship(GuidGenerator.Create(), t.LU, "", t.FactoryPartCode, businessType));
await this.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
//await _materialRelationshipManager.AddNewMaterialRelationships(materialRelationships).ConfigureAwait(false);
}
}
pubSeDetails.ForEach(t =>
@ -117,6 +121,10 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
t.SetId(GuidGenerator.Create());
t.BusinessType = businessType;
t.KeyCode = t.PN + t.LU;
if (t.BillTime != null)
{
t.Version = int.Parse(t.BillTime?.ToString("yyyyMM"));
}
});
await _settleAccountDbContext.BulkInsertAsync(pubSeDetails).ConfigureAwait(false);
@ -147,7 +155,7 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
CodeType = default,
BillType = pubSeDetail.DeliverBillType,
Qty = pubSeDetail.Qty,
BillTime = pubSeDetail.BillTime,
BillTime = pubSeDetail.BillTime ?? new DateTime(),
DeliverTime = pubSeDetail.AssembleData,
ErpToLoc = pubSeDetail.ToErpLocCode,
Seq = default,
@ -173,7 +181,7 @@ public class JitSeSyncAppService : ApplicationService, IInvocable
CodeType = default,
BillType = pubSeDetail.DeliverBillType,
Qty = pubSeDetail.Qty,
BillTime = pubSeDetail.BillTime,
BillTime = pubSeDetail.BillTime ?? new DateTime(),
DeliverTime = pubSeDetail.DnBillTime,
ErpToLoc = pubSeDetail.ToErpLocCode,
Seq = default,

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MaiDanBBACSeSyncAppService.cs

@ -23,11 +23,12 @@ public class MaiDanBBACSeSyncAppService : JisBBACSeSyncBaseAppService, IJobServi
/// </summary>
public MaiDanBBACSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<BBAC_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
VmiAppService vmiService
) : base(wmsBJBMPTContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, vmiService)
) : base(wmsBJBMPTContext, settleAccountDbContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, vmiService)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{

3
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/Syncs/MaiDanHBPOSeSyncAppService.cs

@ -23,11 +23,12 @@ public class MaiDanHBPOSeSyncAppService : JisHBPOSeSyncBaseAppService, IJobServi
/// </summary>
public MaiDanHBPOSeSyncAppService(
WMSBJBMPTDbContext wmsBJBMPTContext,
SettleAccountDbContext settleAccountDbContext,
INormalEfCoreRepository<SyncPositionFlag, Guid> syncPositionFlagRepository,
INormalEfCoreRepository<HBPO_SE_DETAIL, Guid> jisSeDetailRepository,
MaterialRelationshipManager materialRelationshipManager,
VmiAppService vmiService
) : base(wmsBJBMPTContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, vmiService)
) : base(wmsBJBMPTContext, settleAccountDbContext, syncPositionFlagRepository, jisSeDetailRepository, materialRelationshipManager, vmiService)
{
base.SeSyncConfigInfo = new SeSyncConfig()
{

569
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/FISes/FISAppService.cs

@ -1,569 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Caching.Distributed;
using Shouldly;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.Caching;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.CodeSettings;
using Win.Sfs.SettleAccount.Entities.ImportMap;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.CacheBase;
using Win.Sfs.Shared.Enums.SettleAccount;
using Win.Sfs.Shared.Filter;
using Win.Utils;
namespace Win.Sfs.SettleAccount.FISes
{
/// <summary>
/// 区域相关应用服务
/// </summary>
//[Authorize(SettleAccountPermissions.FISs.Default)]
//[AllowAnonymous]
[ApiExplorerSettings(IgnoreApi = true)]
[Route("api/settleaccount/fis")]
public class FISAppService : SettleAccountApplicationBase<FIS>, IFISAppService
{
private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<FIS, Guid> _repository;
private readonly ISettleAccountBranchEfCoreRepository<Prebatches.Prebatch, Guid> _preBatchRepository;
private readonly ISettleAccountBranchEfCoreRepository<FISExtend, Guid> _extendRepository;
private readonly ISettleAccountBranchEfCoreRepository<FISVersion, Guid> _versionRepository;
private readonly ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> _relrepository;
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _importRepository;
/// <summary>
///
/// </summary>
/// <param name="guidGenerator"></param>
/// <param name="objectMapper"></param>
/// <param name="repository"></param>
/// <param name="versionRepository"></param>
/// <param name="extendRepository"></param>
/// <param name="preBatchRepository"></param>
/// <param name="cache"></param>
/// <param name="excelImportService"></param>
/// <param name="snowflakeIdGenerator"></param>
/// <param name="commonManager"></param>
/// <param name="relrepository"></param>
public FISAppService(IGuidGenerator guidGenerator,
IObjectMapper objectMapper,
ISettleAccountBranchEfCoreRepository<FIS, Guid> repository,
ISettleAccountBranchEfCoreRepository<FISVersion, Guid> versionRepository,
ISettleAccountBranchEfCoreRepository<FISExtend, Guid> extendRepository,
ISettleAccountBranchEfCoreRepository<Prebatches.Prebatch, Guid> preBatchRepository,
IDistributedCache<FIS> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> relrepository,
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> importRepository
) : base(cache,excelImportService,snowflakeIdGenerator,commonManager)
{
_versionRepository = versionRepository;
_repository = repository;
_excelImportService = excelImportService;
_extendRepository = extendRepository;
_preBatchRepository = preBatchRepository;
_relrepository = relrepository;
_importRepository = importRepository;
}
/// <summary>
/// 导入功能
/// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
[HttpPost]
[Route("ExcelImport")]
[DisableRequestSizeLimit]
public async Task<string> FISUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode, string factory, string model, DateTime? beginDate, DateTime? endDate)
{
// List<string> _errorList = new List<string>();
if (string.IsNullOrEmpty(model) || beginDate == null || endDate == null)
{
throw new BusinessException("8989", "产线、开始时间和结束时间、不能为空!");
}
List<FIS> _setls = new List<FIS>();
List<FISExtend> _extendls = new List<FISExtend>();
var _id = GuidGenerator.Create();
var _prelist = await _preBatchRepository.GetAllAsync(GuidGenerator.Create());
var _chList= await _relrepository.GetAllAsync(GuidGenerator.Create(), true);
var _chls= _chList.Select(p => p.ShipMaterailCode).Distinct();
var checkList = new List<ErrorExportDto>();
foreach (var file in files)
{
using (TextReader textReader = new StreamReader(file.OpenReadStream()))
{
int i = 0;
while (true)
{
string str = await textReader.ReadLineAsync();
if (string.IsNullOrEmpty(str))
{
break;
}
else
{
try
{
var _lst = str.Split(new char[] { ';' }).ToList();
var orderBillNum = _lst[0];
var materialCode = _lst[1];
var qty = decimal.Parse(_lst[2]);
var cp5 = DateTime.Parse(_lst[3]);
var fisYear = cp5.Year.ToString();
var extend1 = model;
var sequenceNumber = _lst[6];
var chassisNumber = _lst[7];
var kenncode = string.Empty;
var chassisNumber2 = string.Empty;
EnumSettleStatus state = EnumSettleStatus.;
if (orderBillNum.Length == 10)
{
kenncode = orderBillNum.Substring(2 , 7);
}
if (chassisNumber.Length != 18)
{
chassisNumber2 = chassisNumber.Substring(9, 8);
}
var kenn = _prelist.Where(p => p.KENNCode == kenncode).FirstOrDefault();
if (kenn != null)
{
if ((int)EnumSettleStatus. == kenn.State)
{
state = EnumSettleStatus.;
}
}
if (beginDate.Value < cp5 && cp5 < endDate.Value)
{
var _fisId = GuidGenerator.Create();
var fis = new FIS(
_fisId,
branchId,
year,
period,
extend1,
chassisNumber,
qty,
cp5,
sequenceNumber,
orderBillNum,
materialCode,
fisYear,
_id,
kenncode,
chassisNumber2,
state,
DateTime.Now,
0,
version,
DateTime.Now,
GuidGenerator.Create(),
beginDate == null ? DateTime.Now : beginDate.Value,
endDate == null ? DateTime.Now : endDate.Value,
string.Empty
);
fis.SetModel(model);
_setls.Add(fis);
}
}
catch
{
}
}
i++;
}
textReader.Close();
}
}
var _copyls= _setls.GroupBy(x =>new { x.ChassisNumber2, x.Version, x.Model, x.ItemCode }).Select(y => y.First()).ToList();
var _l = _copyls.Select(p => p.ItemCode).Distinct();
var _notls= _l.Where(p=>!_chls.Contains(p)).ToList();
foreach (var itm in _notls)
{
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm, string.Empty, string.Format("关系表中不存在发运物料号{0}!", itm), string.Empty));
}
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
if (_copyls != null && _copyls.Count > 0)
{
foreach (var itm in _copyls)
{
var fisextend = new FISExtend(
itm.Id,
branchId,
year,
period,
itm.Extend1,
itm.ChassisNumber,
itm.Qty,
itm.CP5Time,
itm.SequenceNumber,
itm.OrderBillNum,
itm.ItemCode,
itm.FISYear,
itm.ParentId,
itm.KENNCode,
itm.ChassisNumber2,
itm.State,
DateTime.Now,
0,
version,
DateTime.Now,
GuidGenerator.Create(),
beginDate == null ? DateTime.Now : beginDate.Value,
endDate == null ? DateTime.Now : endDate.Value,
string.Empty
);
fisextend.SetModel(model);
_extendls.Add(fisextend);
}
}
var _versionQuery = _versionRepository.Where(p => p.Version == version && p.Model == model);
await _versionQuery.BatchDeleteAsync();
var _query = _repository.Where(p => p.Version == version && p.Model == model);
await _query.BatchDeleteAsync();
var _extendQuery = _extendRepository.Where(p => p.Version == version && p.Model == model);
await _extendQuery.BatchDeleteAsync();
await _repository.GetDbContext().BulkInsertAsync(_copyls);
await _extendRepository.GetDbContext().BulkInsertAsync(_extendls);
FISVersion _version = new FISVersion(_id, branchId, year, period, version, customerCode, factory, model, beginDate.Value, endDate.Value);
var _ls = new List<FISVersion>();
_ls.Add(_version);
await _versionRepository.GetDbContext().BulkInsertAsync(_ls);
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 按ID获取唯一实体
/// </summary>
/// <remarks>
/// 返回实体全部属性
/// </remarks>
/// <param name="id">ID</param>
/// <returns>实体DTO</returns>
[HttpGet]
[Route("{id}")]
virtual public async Task<FISDto> GetAsync(Guid id)
{
var result = await GetFromCacheAsync(id);
var dto = ObjectMapper.Map<FIS, FISDto>(result);
return dto;
}
private async Task<FIS> GetFromCacheAsync(Guid id)
{
var result = await _repository.GetAsync(id);
return result;
}
private async Task<long> GetCountAsync(FISRequestDto input)
{
return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters);
}
private async Task<long> GetCountAsync(FISVersionRequestDto input)
{
return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters);
}
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("list")]
// [Authorize(SettleAccountPermissions.FISs.Default)]
virtual public async Task<PagedResultDto<FISDto>> GetListAsync(Guid parendid,FISRequestDto input)
{
//if (input.ParentId != Guid.Empty)
//{
// input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.Version.ToString() });
//}
//else
//{
// return new PagedResultDto<FISDto>(0, new List<FISDto>());
//}
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount,input.SkipCount, true);
var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<FIS>, List<FISDto>>(entities);
return new PagedResultDto<FISDto>(totalCount, dtos);
}
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("list_th")]
// [Authorize(SettleAccountPermissions.FISs.Default)]
virtual public async Task<PagedResultDto<FISDto>> GetListTHAsync(Guid parendid, FISRequestDto input)
{
//if (input.ParentId != Guid.Empty)
//{
// input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() });
//}
//else
//{
// return new PagedResultDto<FISDto>(0, new List<FISDto>());
//}
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true);
var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<FIS>, List<FISDto>>(entities);
return new PagedResultDto<FISDto>(totalCount, dtos);
}
/// <summary>
/// 获取实体总数
/// </summary>
/// <returns>实体总数</returns>
[HttpGet]
[Route("count")]
virtual public async Task<long> GetTotalCountAsync(Guid branchId)
{
return await _repository.GetCountAsync(branchId);
}
/// <summary>
/// 获取全部实体列表
/// </summary>
/// <returns>实体DTO列表</returns>
[HttpGet]
[Route("all")]
virtual public async Task<ListResultDto<FISDto>> GetAllAsync(Guid branchId)
{
var entities = await _repository.GetAllAsync(branchId, true);
var dtos = ObjectMapper.Map<List<FIS>, List<FISDto>>(entities);
return new ListResultDto<FISDto>(dtos);
}
/// <summary>
/// 删除实体
/// </summary>
/// <param name="id">ID</param>
/// <returns>无</returns>
[HttpDelete]
[Route("{id}")]
virtual public async Task DeleteAsync(Guid id)
{
var entity = await GetFromCacheAsync(id);
await Cache.DeleteAsync<FIS>(id.ToString());
await _repository.DeleteAsync(id);
}
/// <summary>
/// 按IDs删除实体列表
/// </summary>
/// <param name="ids">IDs</param>
/// <returns>是否执行成功</returns>
[HttpPost]
[Route("delete")]
virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
{
foreach (var id in ids)
{
var entity = await GetFromCacheAsync(id);
await Cache.DeleteAsync<FIS>(id.ToString());
}
return await _repository.DeleteListAsync(ids);
}
/// <summary>
/// 版本列表
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("listversion")]
public async Task<PagedResultDto<FISVersionDto>> GetVersionListAsync(FISVersionRequestDto input)
{
var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue,
input.SkipCount, true);
var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<FISVersion>, List<FISVersionDto>>(entities);
foreach (var itm in dtos)
{
itm.Version = itm.Version + string.Format("({0})", itm.Model);
}
return new PagedResultDto<FISVersionDto>(totalCount, dtos);
}
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("duplicate")]
[UnitOfWork(isTransactional: false)]
public async Task<bool> UPdateFisAsync()
{
await _repository.GetDbContext().Database.ExecuteSqlRawAsync(
"EXEC sp_fis_remove_duplicate"
);
return true;
}
/// <summary>
/// 导出文件
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("Export")]
virtual public async Task<string> ExportAsync(FISRequestDto input)
{
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
if (input.ParentId != Guid.Empty)
{
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() });
}
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue,
0, true);
var dtoDetails = ObjectMapper.Map<List<FIS>, List<FISExportDto>>(entities);
string _fileName = string.Empty;
//声明导出容器
byte[] result = null;
switch (input.FileType)
{
case 0:
_fileName = string.Format("大众FIS_{0}.csv", input.UserId.ToString());
result = await _csv.ExportAsByteArray(dtoDetails);
break;
case 1:
_fileName = string.Format("大众FIS_{0}.xlsx", input.UserId.ToString());
result = await _excel.ExportAsByteArray(dtoDetails);
break;
}
result.ShouldNotBeNull();
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
);
return _fileName;
}
//[HttpPost]
//[Route("ExportJob")]
//[Authorize(SettleAccountPermissions.FISs.Default)]
//public Task ExportFile(string taskid,string fileName)
//{
// return Task.CompletedTask;
//}
//[HttpPost]
//[Route("NotifyJob")]
//[Authorize(SettleAccountPermissions.FISs.Default)]
//public async Task<string> SendNotify(string taskid,string fileName, string realFileName)
//{
// return "str";
//}
//[HttpPost]
//[Route("ImportJob")]
//[Authorize(SettleAccountPermissions.Materials.Default)]
//public async Task<string> ImportFile(string taskid,string fileName,string realFileName)
//{
// IExcelImporter _importer = new Magicodes.ExporterAndImporter.Excel.ExcelImporter();
// //await _importer.Import<MaterialDto>(path);
// return string.Empty;
//}
}
}

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

@ -79,16 +79,15 @@ public class MaterialRelationshipAppService : SettleAccountApplicationBase<Mater
}
foreach (var itm in _ls)
{
var _first = _repository.FirstOrDefault(p => p.ErpMaterialCode == itm.ErpMaterialCode);
var _first = _repository.FirstOrDefault(p => p.ErpMaterialCode == itm.ErpMaterialCode && p.BusinessType == EnumBusinessType.BeiJian);
if (_first != null)
{
_first.Update(itm.MaterialDesc, itm.MaterialProperty, itm.SettleMaterialCode, itm.ShipMaterailCode);
_first.Remark = materialRelationshipImportRequestDto.IsBj ? "BJ" : "";
_first.Update(itm.MaterialDesc, itm.SettleMaterialCode);
await _repository.UpdateAsync(_first);
}
else
{
itm.Remark = materialRelationshipImportRequestDto.IsBj ? "BJ" : "";
itm.BusinessType = EnumBusinessType.BeiJian;
await _repository.InsertAsync(itm);
}
}

580
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/SettleAccounts/SettleAccountAppService.cs

@ -1,580 +0,0 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Distributed;
using AutoMapper;
using System.Linq;
using System.Text;
using Volo.Abp.Guids;
using Volo.Abp.Application.Services;
using Volo.Abp.Caching;
using Volo.Abp.ObjectMapping;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.Shared.CacheBase;
using Win.Utils;
using Volo.Abp.Application.Dtos;
using Win.Sfs.BaseData.ImportExcelCommon;
using Volo.Abp.Domain.Repositories;
using EFCore.BulkExtensions;
using System.IO;
using Microsoft.EntityFrameworkCore;
using Win.Sfs.SettleAccount.Entities.SettleAccountVersion;
using Win.Sfs.SettleAccount.FISes;
using Win.Sfs.Shared.Enums.SettleAccount;
using Win.Sfs.Shared.Filter;
using Shouldly;
using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using System.Data.Common;
using Volo.Abp.Uow;
using Volo.Abp;
using Win.Abp.Snowflakes;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Magicodes.ExporterAndImporter.Core.Models;
using TaskJob.Services;
using TaskJob.EventArgs;
using Win.Sfs.SettleAccount.Entities.Wms;
using Win.Sfs.SettleAccount.Repository;
namespace Win.Sfs.SettleAccount.Entities.SettleAccounts
{
/// <summary>
/// 大众准时化结算明细导入-R3已结
/// </summary>
[ApiExplorerSettings(IgnoreApi = true)]
[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
//[AllowAnonymous]
[Route("api/settleaccount/SettleAccount")]
public class SettleAccountAppService : SettleAccountApplicationBase<SettleAccount>, ISettleAccountAppService
{
private readonly IGuidGenerator _guidGenerator;
private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<Prebatches.Prebatch, Guid> _preBatchRepository;
private readonly ISettleAccountBranchEfCoreRepository<SettleAccount, Guid> _repository;
private readonly ISettleAccountBranchEfCoreRepository<SettleAccountVersion, Guid> _versionRepository;
private readonly ISettleAccountBranchEfCoreRepository<FIS, Guid> _fisRepository;
private readonly ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> _relrepository;
private readonly TaskJobService _service;
/// <summary>
/// 构建方法
/// </summary>
/// <param name="guidGenerator">构建UID</param>
/// <param name="repository">仓储接口</param>
/// <param name="cache">缓存</param>
public SettleAccountAppService(IGuidGenerator guidGenerator,
ISettleAccountBranchEfCoreRepository<SettleAccountVersion, Guid> versionRepository,
ISettleAccountBranchEfCoreRepository<SettleAccount, Guid> repository,
IDistributedCache<SettleAccount> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager,
TaskJobService service,
ISettleAccountBranchEfCoreRepository<FIS, Guid> fisRepository,
ISettleAccountBranchEfCoreRepository<Prebatches.Prebatch, Guid> preBatchRepository,
ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> relrepository
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_service = service;
_fisRepository = fisRepository;
_versionRepository = versionRepository;
_guidGenerator = guidGenerator;
_excelImportService = excelImportService;
_repository = repository;
_preBatchRepository = preBatchRepository;
_relrepository = relrepository;
}
/// <summary>
/// 导入功能
/// </summary>
/// <param name="files"></param>
/// <param name="branchId"></param>
/// <param name="year"></param>
/// <param name="period"></param>
/// <param name="version"></param>
/// <param name="customerCode"></param>
/// <param name="factory"></param>
/// <returns></returns>
[HttpPost]
[Route("ExcelImport-PG")]
[DisableRequestSizeLimit]
[Authorize(SettleAccountPermissions.SettleAccounts.Create)]
[UnitOfWork(false)]
public async Task<string> SettleAccountUploadExcelImportTH([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode, string factory)
{
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value = version??string.Empty });
customConditionList.Add(new CustomCondition() { Name = "CustomerCode", Value = customerCode ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "Year", Value = year ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "Period", Value = period ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "Factory", Value = factory ?? string.Empty });
var _versionQuery = _versionRepository.Where(p => p.Version == version);
if (_versionQuery.Count() > 0)
{
_versionQuery.BatchDelete();
}
var _query = _repository.Where(p => p.Version == version);
if (_query.Count() > 0)
{
await _query.BatchDeleteAsync();
}
var _taskid = await _service.ImportEnqueueAsync<ImportTaskArgs>(files, "结算数据", CurrentUser, typeof(SettleAccountImportService), customConditionList, (rs) =>
{
});
return _taskid;
}
/// <summary>
/// 导入功能
/// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
[HttpPost]
[Route("ExcelImport")]
[DisableRequestSizeLimit]
[Authorize(SettleAccountPermissions.SettleAccounts.Create)]
public async Task<string> SettleAccountUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode, string factory)
{
List<SettleAccount> _setls = new List<SettleAccount>();
List<string> _errorList = new List<string>();
var _id = GuidGenerator.Create();
var checkList = new List<ErrorExportDto>();
var _chList = await _relrepository.GetAllAsync(GuidGenerator.Create(), true);
var _chls = _chList.Select(p => p.SettleMaterialCode).Distinct();
List<string> _precodeList = new List<string>();//
using (TextReader textReader = new StreamReader(files[0].OpenReadStream()))
{
var _preList = _preBatchRepository.Where(p => p.State == 3).ToList();
var _versionQuery = _versionRepository.Where(p => p.Version == version);
await _versionQuery.BatchDeleteAsync();
var _query = _repository.Where(p => p.Version == version);
await _query.BatchDeleteAsync();
int i = 0;
//var _userId = CurrentUser.Id.Value;
while (true)
{
string str = await textReader.ReadLineAsync();
if (string.IsNullOrEmpty(str))
{
break;
}
else
{
//if (i > headerNumber)
//{
try
{
var _lst = str.Split(new char[] { '|' }).ToList();
string _settleyear = _lst[1].Trim();
string _kENNCode = _lst[2].Trim();
string _chassisNumber = _lst[3].Trim();
string _model = _lst[4].Trim();
DateTime _cP5A = DateTime.Parse(_lst[5].Trim());
DateTime _cP7 = DateTime.Parse(_lst[6].Trim());
string _materialCode = _lst[7].Trim();
decimal _qty = decimal.Parse(_lst[8].Trim());
string _settlementID = _lst[9].Trim();
string _settlementSupplier = _lst[10].Trim();
if (_preList.Any(p => p.KENNCode == _kENNCode))
{
_precodeList.Add(_kENNCode);
}
_setls.Add(new SettleAccount(
GuidGenerator.Create(),
branchId,
_settleyear,
_kENNCode,
_chassisNumber,
_model,
_cP5A,
_cP7,
_materialCode,
_qty,
_settlementID,
_settlementSupplier,
period,
year,
_id,
version,
DateTime.Now,
GuidGenerator.Create()
// _userId
));
}
catch
{
}
//}
}
i++;
}
textReader.Close();
}
var _ls = _setls;
var query = from arc in _ls
group arc by new { arc.ChassisNumber, arc.MaterialCode }
into g
where g.Count() > 1
select g;
var _l = _setls.Select(p => p.MaterialCode).Distinct();
var _notls = _l.Where(p => !_chls.Contains(p)).ToList();
foreach (var itm in _notls)
{
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm, string.Empty, string.Format("关系表中不存在结算物料号{0}!", itm), string.Empty));
}
foreach (var itm in query)
{
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ERP物料号{0}底盘号 {1}有重复", itm.Key.MaterialCode, itm.Key.ChassisNumber), string.Empty));
}
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
var _existls = _preBatchRepository.Where(p => _precodeList.Contains(p.KENNCode)).ToList();
if (_existls.Count > 0)
{
foreach (var itm in _existls)
{
itm.Update(string.Format("结算修改预批量{0}", DateTime.Now.ToString("yyyyMMdd")), 0,string.Empty,string.Empty,string.Empty);
}
}
await _preBatchRepository.GetDbContext().BulkUpdateAsync(_existls);
await _repository.GetDbContext().BulkInsertAsync(_setls);
await _versionRepository.InsertAsync(new SettleAccountVersion(_id, branchId, year, period, version, customerCode, factory));
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 按ID获取唯一实体
/// </summary>
/// <remarks>
/// 返回实体全部属性
/// </remarks>
/// <param name="id">ID</param>
/// <returns>实体DTO</returns>
[HttpGet]
[Route("{id}")]
[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
virtual public async Task<SettleAccountDto> GetAsync(Guid id)
{
var result = await GetFromCacheAsync(id);
var dto = ObjectMapper.Map<SettleAccount, SettleAccountDto>(result);
return dto;
}
private async Task<SettleAccount> GetFromCacheAsync(Guid id)
{
var result = await _repository.GetAsync(id);
return result;
}
private async Task<long> GetCountAsync(SettleAccountRequestDto input)
{
return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters);
}
private async Task<long> GetCountAsync(SettleAccountVersionRequestDto input)
{
return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters);
}
/// <summary>
/// 导出预批量
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpGet]
[Route("ExportPreBatch")]
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
virtual public async Task<string> ExportPreBatchAsync(string version)
{
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
var _query = from itm1 in _preBatchRepository join itm2 in _repository on new { itm1.KENNCode, itm1.Year } equals new { itm2.KENNCode, itm2.Year } where itm2.Version == version select itm2;
var _ls=await _query.ToListAsync();
foreach (var itm in _ls)
{
itm.state = 3;
}
var dtoDetails = ObjectMapper.Map<List<SettleAccount>, List<SettleAccountExportDto>>(_ls);
string _fileName = string.Empty;
//声明导出容器
byte[] result = null;
//switch (input.FileType)
//{
// case 0:
// _fileName = string.Format("结算数据(预批量)_{0}.csv", Guid.NewGuid().ToString());
// result = await _csv.ExportAsByteArray(dtoDetails);
// break;
// case 1:
// _fileName = string.Format("结算数据_{0}.xlsx", Guid.NewGuid().ToString());
// result = await _excel.ExportAsByteArray(dtoDetails);
// break;
//}
_fileName = string.Format("结算数据(预批量)_{0}.xlsx", Guid.NewGuid().ToString());
result = await _excel.ExportAsByteArray(dtoDetails);
result.ShouldNotBeNull();
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
);
return _fileName;
}
/// <summary>
/// 导出文件
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost]
[Route("Export")]
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
virtual public async Task<string> ExportAsync(SettleAccountRequestDto input)
{
IExporter _csv = new CsvExporter();
IExporter _excel = new ExcelExporter();
if (input.ParentId != Guid.Empty)
{
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() });
}
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue,
0, true);
var dtoDetails = ObjectMapper.Map<List<SettleAccount>, List<SettleAccountExportDto>>(entities);
string _fileName = string.Empty;
//声明导出容器
byte[] result = null;
switch (input.FileType)
{
case 0:
_fileName = string.Format("结算数据_{0}.csv", input.UserId.ToString());
result = await _csv.ExportAsByteArray(dtoDetails);
break;
case 1:
_fileName = string.Format("结算数据_{0}.xlsx", input.UserId.ToString());
result = await _excel.ExportAsByteArray(dtoDetails);
break;
}
result.ShouldNotBeNull();
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
);
return _fileName;
}
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("list")]
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
virtual public async Task<PagedResultDto<SettleAccountDto>> GetListAsync(Guid id, SettleAccountRequestDto input)
{
if (input.ParentId != Guid.Empty)
{
// var _entity = await _versionRepository.GetAsync(input.ParentId);
// input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "Version", Logic = EnumFilterLogic.And, Value = _entity.Version });
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() });
}
else
{
return new PagedResultDto<SettleAccountDto>(0, new List<SettleAccountDto>());
}
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount,
input.SkipCount, true);
var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<SettleAccount>, List<SettleAccountDto>>(entities);
return new PagedResultDto<SettleAccountDto>(totalCount, dtos);
}
/// <summary>
/// 获取实体总数
/// </summary>
/// <returns>实体总数</returns>
[HttpGet]
[Route("count")]
[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
virtual public async Task<long> GetTotalCountAsync(Guid branchId)
{
return await _repository.GetCountAsync(branchId);
}
/// <summary>
/// 获取全部实体列表
/// </summary>
/// <returns>实体DTO列表</returns>
[HttpGet]
[Route("all")]
//[Authorize(SettleAccountPermissions.SettleAccounts.Default)]
virtual public async Task<ListResultDto<SettleAccountDto>> GetAllAsync(Guid branchId)
{
var entities = await _repository.GetAllAsync(branchId, true);
var dtos = ObjectMapper.Map<List<SettleAccount>, List<SettleAccountDto>>(entities);
return new ListResultDto<SettleAccountDto>(dtos);
}
/// <summary>
/// 删除实体
/// </summary>
/// <param name="id">ID</param>
/// <returns>无</returns>
[HttpDelete]
[Route("{id}")]
/// [Authorize(SettleAccountPermissions.SettleAccounts.Delete)]
virtual public async Task DeleteAsync(Guid id)
{
var entity = await GetFromCacheAsync(id);
await Cache.DeleteAsync<SettleAccount>(id.ToString());
await _repository.DeleteAsync(id);
}
/// <summary>
/// 按IDs删除实体列表
/// </summary>
/// <param name="ids">IDs</param>
/// <returns>是否执行成功</returns>
[HttpPost]
[Route("delete")]
// [Authorize(SettleAccountPermissions.SettleAccounts.Delete)]
virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
{
foreach (var id in ids)
{
var entity = await GetFromCacheAsync(id);
//await Cache.DeleteAsync<SettleAccount>(id.ToString());
}
return await _repository.DeleteListAsync(ids);
}
/// <summary>
///调用存储
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("listversion")]
public async Task<PagedResultDto<SettleAccountVersionDto>> GetVersionListAsync(SettleAccountVersionRequestDto input)
{
var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue,
input.SkipCount, true);
var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<SettleAccountVersion>, List<SettleAccountVersionDto>>(entities);
return new PagedResultDto<SettleAccountVersionDto>(totalCount, dtos);
}
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("updateFis")]
[UnitOfWork(isTransactional: false)]
public async Task<bool> UPdateFisAsync()
{
_repository.GetDbContext().Database.SetCommandTimeout(300000);
await _repository.GetDbContext().Database.ExecuteSqlRawAsync(
"EXEC sp_settle_fis_update"
);
return true;
}
}
}

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

@ -1108,7 +1108,6 @@ namespace Win.Sfs.SettleAccount
{ "InvoiceNumber", d.InvoiceNumber},
{ "VendorCode", d.VendorCode},
{ "VendorName", d.VendorName},
{ "PurchaseOrderNumber", d.PurchaseOrderNumber},
{ "DeliveryIndexNumber", d.DeliveryIndexNumber},
{ "PartName", d.PartName},
{ "Price", d.Price},

2
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/PUB_SE_DETAIL.cs

@ -41,7 +41,7 @@ public class PUB_SE_DETAIL :SE_BASE
/// 发货时间
/// </summary>
[Display(Name = "发货时间")]
public DateTime BillTime { get; set; }
public DateTime? BillTime { get; set; }
/// <summary>
/// 订单时间
/// </summary>

142
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/MaterialRelationships/MaterialRelationship.cs

@ -1,108 +1,56 @@
using System;
using Win.Sfs.Shared.DomainBase;
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing;
namespace Win.Sfs.SettleAccount.MaterialRelationships
namespace Win.Sfs.SettleAccount.MaterialRelationships;
/// <summary>
/// 客户零件关系
/// </summary>
public class MaterialRelationship : AuditedAggregateRoot<Guid>
{
/// <summary>
/// 客户零件关系
/// 厂内物料号
/// </summary>
public class MaterialRelationship : FullAuditedAggregateRootBase<Guid>
{
/// <summary>
/// 厂内物料号
/// </summary>
public string ErpMaterialCode { get; set; }
/// <summary>
/// 厂内物料描述
/// </summary>
public string MaterialDesc { get; set; }
/// <summary>
/// 客户物料号
/// </summary>
public string SettleMaterialCode { get; set; }
/// <summary>
/// 物料属性
/// </summary>
public string MaterialProperty { get; set; }
///// <summary>
///// 结算物料号
///// </summary>
//public string SettleMaterialCode { get; set; }
/// <summary>
/// 发货看板物料号
/// </summary>
public string ShipMaterailCode { get; set; }
/// <summary>
/// 估价类
/// </summary>
public string AppraisalCategory { get; set; }
public void SetId(Guid id, Guid branchId)
{
Id = id;
BranchId = branchId;
}
public string ErpMaterialCode { get; set; }
/// <summary>
/// 厂内物料描述
/// </summary>
public string MaterialDesc { get; set; }
/// <summary>
/// 客户物料号
/// </summary>
public string SettleMaterialCode { get; set; }
/// <summary>
/// 业务分类
/// </summary>
[Display(Name = "业务分类")]
public EnumBusinessType BusinessType { get; set; }
protected MaterialRelationship()
{
}
public void Update( string materialDesc, string materialProperty, string settlMaterialCode, string shipMaterailCode)
{
public void SetId(Guid id, Guid branchId)
{
Id = id;
}
MaterialDesc = materialDesc;
MaterialProperty = materialProperty;
SettleMaterialCode = settlMaterialCode;
ShipMaterailCode = shipMaterailCode;
//AppraisalCategory = appraisalCategory;
}
protected MaterialRelationship()
{
}
public void Update(string materialDesc, string settlMaterialCode)
{
MaterialDesc = materialDesc;
SettleMaterialCode = settlMaterialCode;
}
public MaterialRelationship(
Guid id,
Guid branchId,
public MaterialRelationship(Guid id) : base(id)
{
string erpMaterialCode, string materialDesc, string materialProperty, string settlMaterialCode, string shipMaterailCode, string appraisalCategory) :base(id)
{
BranchId = branchId;
ErpMaterialCode = erpMaterialCode;
MaterialDesc = materialDesc;
MaterialProperty = materialProperty;
SettleMaterialCode = settlMaterialCode;
ShipMaterailCode = shipMaterailCode;
AppraisalCategory = appraisalCategory;
}
}
public MaterialRelationship(Guid id, string erpMaterialCode, string materialDesc, string settlMaterialCode, string appraisalCategory) : base(id)
{
ErpMaterialCode = erpMaterialCode;
MaterialDesc = materialDesc;
SettleMaterialCode = settlMaterialCode;
AppraisalCategory = appraisalCategory;
}
public MaterialRelationship(Guid id, string erpMaterialCode, string materialDesc, string settlMaterialCode, EnumBusinessType businessType) : base(id)
{
ErpMaterialCode = erpMaterialCode;
MaterialDesc = materialDesc;
SettleMaterialCode = settlMaterialCode;
BusinessType = businessType;
}
}

7
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Reports/CommonManagers/CommonManager.cs

@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@ -15,6 +15,7 @@ using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.DtoBase.SettleAccount;
using Win.Sfs.Shared.Enums.SettleAccount;
using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.CommonManagers
{
@ -25,7 +26,7 @@ namespace Win.Sfs.SettleAccount.CommonManagers
private readonly ISettleAccountBranchEfCoreRepository<CustomerStorageLocation, Guid> _customerStorageLocationRepository;
private readonly ISettleAccountBranchEfCoreRepository<InventoryDetail, Guid> _inventoryDetailRepository;
private readonly ISettleAccountBranchEfCoreRepository<Entities.SettleAccounts.SettleAccount, Guid> _settleAccountRepository;
private readonly ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> _materialRelationshipRepository;
private readonly INormalEfCoreRepository<MaterialRelationship, Guid> _materialRelationshipRepository;
private readonly ISettleAccountBranchEfCoreRepository<CentralizedControl, Guid> _centralizedControlRepository;
@ -42,7 +43,7 @@ namespace Win.Sfs.SettleAccount.CommonManagers
ISettleAccountBranchEfCoreRepository<Entities.SettleAccounts.SettleAccount, Guid> settleAccountRepository,
ISettleAccountBranchEfCoreRepository<CentralizedControl, Guid> centralizedControlRepository,
ISettleAccountBranchEfCoreRepository<Material, Guid> itemRepository,
ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> materialRelationshipRepository
INormalEfCoreRepository<MaterialRelationship, Guid> materialRelationshipRepository
)
{
_inventoryDetailRepository = inventoryDetailRepository;

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

@ -238,9 +238,7 @@ namespace Win.Sfs.SettleAccount
b.ToTable($"{options.TablePrefix}_relationship", options.Schema);
b.ConfigureByConvention();
b.Property(x => x.ErpMaterialCode).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength);
b.HasIndex(x => new { x.ErpMaterialCode });
b.HasIndex(x => new { x.ErpMaterialCode }).IsUnique().HasFilter(IsDeletedFilter);
b.HasIndex(x => new { x.ErpMaterialCode, x.BusinessType }).IsUnique();
});
}
@ -1345,7 +1343,7 @@ namespace Win.Sfs.SettleAccount
builder.Entity<JobItem>().HasData(new JobItem("JisBBACSeSync".ToGuid()) { Name = "JisBBAC发运数据同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.JisBBACSeSyncAppService" });
builder.Entity<JobItem>().HasData(new JobItem("JisHBPOSeSync".ToGuid()) { Name = "JisHBPO发运数据同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.JisHBPOSeSyncAppService" });
builder.Entity<JobItem>().HasData(new JobItem("MaiDanBBACSeSync".ToGuid()) { Name = "买单件BBAC发运数据同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.MaiDanBBACSeSyncAppService" });
builder.Entity<JobItem>().HasData(new JobItem("MaiDanHBPOSeSync".ToGuid()) { Name = "买单件HBPO发运数据同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.MaiDanBBACSeSyncAppService" });
builder.Entity<JobItem>().HasData(new JobItem("MaiDanHBPOSeSync".ToGuid()) { Name = "买单件HBPO发运数据同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.MaiDanHBPOSeSyncAppService" });
builder.Entity<JobItem>().HasData(new JobItem("ZhiGongBBACSeSync".ToGuid()) { Name = "直供件BBAC发运同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.ZhiGongBBACSeSyncAppService" });
builder.Entity<JobItem>().HasData(new JobItem("ZhiGongHBPOSeSync".ToGuid()) { Name = "直供件HBPO发运同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.ZhiGongHBPOSeSyncAppService" });
builder.Entity<JobItem>().HasData(new JobItem("BeiSeSync".ToGuid()) { Name = "备件发运同步", Cron = "0 0/30 * * * ? ", Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.BeiSeSyncAppService" });

5521
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230818070358_20230818-1.Designer.cs

File diff suppressed because it is too large

191
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230818070358_20230818-1.cs

@ -0,0 +1,191 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202308181 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Set_relationship_ErpMaterialCode",
table: "Set_relationship");
migrationBuilder.DeleteData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("42240e52-f4f4-4e40-b321-2bc395fde07c"));
migrationBuilder.DropColumn(
name: "AppraisalCategory",
table: "Set_relationship");
migrationBuilder.DropColumn(
name: "BranchId",
table: "Set_relationship");
migrationBuilder.DropColumn(
name: "DeleterId",
table: "Set_relationship");
migrationBuilder.DropColumn(
name: "DeletionTime",
table: "Set_relationship");
migrationBuilder.DropColumn(
name: "Enabled",
table: "Set_relationship");
migrationBuilder.DropColumn(
name: "IsDeleted",
table: "Set_relationship");
migrationBuilder.DropColumn(
name: "MaterialProperty",
table: "Set_relationship");
migrationBuilder.DropColumn(
name: "Remark",
table: "Set_relationship");
migrationBuilder.DropColumn(
name: "ShipMaterailCode",
table: "Set_relationship");
migrationBuilder.AddColumn<int>(
name: "BusinessType",
table: "Set_relationship",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AlterColumn<DateTime>(
name: "BillTime",
table: "Set_PUB_SE_DETAIL",
type: "datetime2",
nullable: true,
oldClrType: typeof(DateTime),
oldType: "datetime2");
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
column: "Service",
value: "Win.Sfs.SettleAccount.Entities.BQ.Syncs.MaiDanHBPOSeSyncAppService");
migrationBuilder.InsertData(
table: "Set_VmiBalance",
columns: new[] { "Id", "BackupTime", "BillTime", "BillType", "CodeType", "ConcurrencyStamp", "Configcode", "CustomerPartCode", "DeliverTime", "ErpToLoc", "MatchNumber", "OrderNum", "PartCode", "PjsNum", "Qty", "ReMark", "RealCode", "Seq", "SubBillType", "UniqueCode", "VinCode", "factory" },
values: new object[] { new Guid("ab6a3a74-bb4e-442c-84b5-d148f2cd99f6"), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, null, "6947bb1f686043fcb95d9db67c0ca6c8", null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "ErpToLoc", null, "OrderNum", "PartCode", null, 0m, null, null, null, 0, null, "VinCode", null });
migrationBuilder.CreateIndex(
name: "IX_Set_relationship_ErpMaterialCode_BusinessType",
table: "Set_relationship",
columns: new[] { "ErpMaterialCode", "BusinessType" },
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_Set_relationship_ErpMaterialCode_BusinessType",
table: "Set_relationship");
migrationBuilder.DeleteData(
table: "Set_VmiBalance",
keyColumn: "Id",
keyValue: new Guid("ab6a3a74-bb4e-442c-84b5-d148f2cd99f6"));
migrationBuilder.DropColumn(
name: "BusinessType",
table: "Set_relationship");
migrationBuilder.AddColumn<string>(
name: "AppraisalCategory",
table: "Set_relationship",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<Guid>(
name: "BranchId",
table: "Set_relationship",
type: "uniqueidentifier",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"));
migrationBuilder.AddColumn<Guid>(
name: "DeleterId",
table: "Set_relationship",
type: "uniqueidentifier",
nullable: true);
migrationBuilder.AddColumn<DateTime>(
name: "DeletionTime",
table: "Set_relationship",
type: "datetime2",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "Enabled",
table: "Set_relationship",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<bool>(
name: "IsDeleted",
table: "Set_relationship",
type: "bit",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "MaterialProperty",
table: "Set_relationship",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Remark",
table: "Set_relationship",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "ShipMaterailCode",
table: "Set_relationship",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AlterColumn<DateTime>(
name: "BillTime",
table: "Set_PUB_SE_DETAIL",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
oldClrType: typeof(DateTime),
oldType: "datetime2",
oldNullable: true);
migrationBuilder.UpdateData(
table: "Set_JobItem",
keyColumn: "Id",
keyValue: new Guid("6f68fc8f-b058-c3f4-e07d-722c61f3f7fa"),
column: "Service",
value: "Win.Sfs.SettleAccount.Entities.BQ.Syncs.MaiDanBBACSeSyncAppService");
migrationBuilder.InsertData(
table: "Set_VmiBalance",
columns: new[] { "Id", "BackupTime", "BillTime", "BillType", "CodeType", "ConcurrencyStamp", "Configcode", "CustomerPartCode", "DeliverTime", "ErpToLoc", "MatchNumber", "OrderNum", "PartCode", "PjsNum", "Qty", "ReMark", "RealCode", "Seq", "SubBillType", "UniqueCode", "VinCode", "factory" },
values: new object[] { new Guid("42240e52-f4f4-4e40-b321-2bc395fde07c"), null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), 1, null, "3a0fa479f64a4e84949961ac4a8aed89", null, null, new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), "ErpToLoc", null, "OrderNum", "PartCode", null, 0m, null, null, null, 0, null, "VinCode", null });
migrationBuilder.CreateIndex(
name: "IX_Set_relationship_ErpMaterialCode",
table: "Set_relationship",
column: "ErpMaterialCode",
unique: true,
filter: "IsDeleted=0");
}
}
}

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

@ -3516,7 +3516,7 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<string>("BillNum")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("BillTime")
b.Property<DateTime?>("BillTime")
.HasColumnType("datetime2");
b.Property<int>("BillType")
@ -4386,7 +4386,7 @@ namespace Win.Sfs.SettleAccount.Migrations
IsDisabled = false,
IsRunning = false,
Name = "买单件HBPO发运数据同步",
Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.MaiDanBBACSeSyncAppService"
Service = "Win.Sfs.SettleAccount.Entities.BQ.Syncs.MaiDanHBPOSeSyncAppService"
},
new
{
@ -4540,10 +4540,10 @@ namespace Win.Sfs.SettleAccount.Migrations
b.HasData(
new
{
Id = new Guid("42240e52-f4f4-4e40-b321-2bc395fde07c"),
Id = new Guid("ab6a3a74-bb4e-442c-84b5-d148f2cd99f6"),
BillTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
BillType = 1,
ConcurrencyStamp = "3a0fa479f64a4e84949961ac4a8aed89",
ConcurrencyStamp = "6947bb1f686043fcb95d9db67c0ca6c8",
DeliverTime = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
ErpToLoc = "ErpToLoc",
OrderNum = "OrderNum",
@ -5455,11 +5455,8 @@ namespace Win.Sfs.SettleAccount.Migrations
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("AppraisalCategory")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("BranchId")
.HasColumnType("uniqueidentifier");
b.Property<int>("BusinessType")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
@ -5475,17 +5472,6 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("ErpMaterialCode")
.IsRequired()
.HasMaxLength(36)
@ -5495,12 +5481,6 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
@ -5512,23 +5492,13 @@ namespace Win.Sfs.SettleAccount.Migrations
b.Property<string>("MaterialDesc")
.HasColumnType("nvarchar(max)");
b.Property<string>("MaterialProperty")
.HasColumnType("nvarchar(max)");
b.Property<string>("Remark")
.HasColumnType("nvarchar(max)");
b.Property<string>("SettleMaterialCode")
.HasColumnType("nvarchar(max)");
b.Property<string>("ShipMaterailCode")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ErpMaterialCode")
.IsUnique()
.HasFilter("IsDeleted=0");
b.HasIndex("ErpMaterialCode", "BusinessType")
.IsUnique();
b.ToTable("Set_relationship");
});

Loading…
Cancel
Save