Browse Source

EF迁移TaskJob

master
mahao 1 year ago
parent
commit
eed261e2f9
  1. 40
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  2. 38
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_DETAIL_SERVICE.cs
  3. 48
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  4. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  5. 15
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  6. 4147
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719053130_20230719-3.Designer.cs
  7. 53
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719053130_20230719-3.cs
  8. 109
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs
  9. 24
      code/src/Modules/SettleAccount/src/SettleAccount.Job/Services/Report/PubSaSeCompareExportService.cs
  10. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

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

@ -120,7 +120,47 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary> /// </summary>
public class PUB_SA_DETAIL_EXPORT_DTO public class PUB_SA_DETAIL_EXPORT_DTO
{ {
/// <summary>
/// 结算单号
/// </summary>
[Display(Name = "结算单号")]
[ExporterHeader(DisplayName = "结算单号")]
public string BillNum { set; get; }
/// <summary>
/// 结算日期(收货日期)
/// </summary>
[Display(Name = "结算日期(收货日期)")]
[ExporterHeader(DisplayName = "Pstng Date")]
public DateTime SettleDate { set; get; }
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[ExporterHeader(DisplayName = "Material")]
public string LU { get; set; }
/// <summary>
/// 数量
/// </summary>
[Display(Name = "数量")]
[ExporterHeader(DisplayName = "Quantity")]
public decimal Qty { get; set; }
/// <summary>
/// 发货单号
/// </summary>
[Display(Name = "发货单号")]
[ExporterHeader(DisplayName = "External Delivery ID")]
public string PN { get; set; }
/// <summary>
/// 结算分组
/// </summary>
[Display(Name = "结算分组")]
[ExporterHeader(DisplayName = "Delivery")]
public string GroupNum { get; set; }
} }
} }

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

@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq.Dynamic.Core; using System.Linq.Dynamic.Core;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@ -7,13 +8,17 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Extensions;
using SettleAccount.Domain.BQ; using SettleAccount.Domain.BQ;
using SettleAccount.Job.Services;
using SettleAccount.Job.Services.Report;
using Shouldly; using Shouldly;
using TaskJob.EventArgs;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Win.Abp.Snowflakes; using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos; using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
@ -37,11 +42,14 @@ public class PUB_SA_DETAIL_SERVICE : SettleAccountApplicationBase<PUB_SA_DETAIL>
/// </summary> /// </summary>
private readonly INormalEfCoreRepository<PUB_SA, Guid> _pubSaRepository; private readonly INormalEfCoreRepository<PUB_SA, Guid> _pubSaRepository;
private readonly TaskJobService _taskJobService;
/// <summary> /// <summary>
/// 构造 /// 构造
/// </summary> /// </summary>
public PUB_SA_DETAIL_SERVICE(INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository, public PUB_SA_DETAIL_SERVICE(INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository,
INormalEfCoreRepository<PUB_SA, Guid> pubSaRepository, INormalEfCoreRepository<PUB_SA, Guid> pubSaRepository,
TaskJobService taskJobService,
IDistributedCache<PUB_SA_DETAIL> cache, IDistributedCache<PUB_SA_DETAIL> cache,
IExcelImportAppService excelImportService, IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator, ISnowflakeIdGenerator snowflakeIdGenerator,
@ -50,6 +58,7 @@ public class PUB_SA_DETAIL_SERVICE : SettleAccountApplicationBase<PUB_SA_DETAIL>
{ {
_pubSaDetailRepository = pubSaDetailRepository; _pubSaDetailRepository = pubSaDetailRepository;
_pubSaRepository = pubSaRepository; _pubSaRepository = pubSaRepository;
_taskJobService = taskJobService;
} }
#region 导出 #region 导出
@ -59,13 +68,21 @@ public class PUB_SA_DETAIL_SERVICE : SettleAccountApplicationBase<PUB_SA_DETAIL>
[HttpPost] [HttpPost]
public async Task<string> ExportAsync(PUB_SA_DETAIL_EXPORT_REQUEST_DTO input) public async Task<string> ExportAsync(PUB_SA_DETAIL_EXPORT_REQUEST_DTO input)
{ {
var pubSaEntity = await _pubSaRepository.FirstOrDefaultAsync(t=>t.BillNum == input.BillNum); var pubSaEntity = await _pubSaRepository.FirstOrDefaultAsync(t => t.BillNum == input.BillNum);
if (pubSaEntity == null) if (pubSaEntity == null)
{ {
throw new UserFriendlyException($"导出失败,结算单号不存在!", "400"); throw new UserFriendlyException($"导出失败,结算单号不存在!", "400");
} }
var businessType = pubSaEntity.BusinessType; var businessType = pubSaEntity.BusinessType;
string fileName = $"{businessType.GetDisplayName()}结算数据_{Guid.NewGuid()}.xlsx";
var displayName = businessType.ToString();
DisplayAttribute attributeOfType = businessType.GetAttributeOfType<DisplayAttribute>();
if (attributeOfType != null)
{
displayName = attributeOfType.Name;
}
string fileName = $"{displayName}的结算数据_{Guid.NewGuid()}.xlsx";
List<FilterCondition> filters = new List<FilterCondition>(); List<FilterCondition> filters = new List<FilterCondition>();
filters.Add(new FilterCondition("BillNum", input.BillNum, EnumFilterAction.Equal, EnumFilterLogic.And)); filters.Add(new FilterCondition("BillNum", input.BillNum, EnumFilterAction.Equal, EnumFilterLogic.And));
@ -81,4 +98,21 @@ public class PUB_SA_DETAIL_SERVICE : SettleAccountApplicationBase<PUB_SA_DETAIL>
} }
#endregion #endregion
#region 对比
/// <summary>
/// Pub结算与发运比对
/// </summary>
[HttpPost]
public async Task<string> PubSaSeCompare(string version)
{
List<CustomCondition> customConditionList = new List<CustomCondition>();
customConditionList.Add(new CustomCondition() { Name = "Version", Value = version ?? string.Empty });
customConditionList.Add(new CustomCondition() { Name = "ProjectName", Value = "结算与开票数据对比" });
var _taskid = await _taskJobService.ExportEnqueueAsync("Pub结算与发运核对汇总表", ExportExtentsion.Excel, version, string.Empty, CurrentUser, typeof(PubSaSeCompareExportService), customConditionList, (rs) =>
{
Console.WriteLine("TaskJob 回调了");
});
return _taskid;
}
#endregion
} }

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

@ -102,59 +102,15 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository; _tbRePartsRelationshipRepository = tbRePartsRelationshipRepository;
} }
#region 直供件 #region 导入、导出
#region 导入
/// <summary> /// <summary>
/// 导入(直供件) /// 导入
/// </summary> /// </summary>
[HttpPost] [HttpPost]
public async Task<string> ImportByBusinessTypeAsync([FromForm] IFormFileCollection files, EnumBusinessType businessType) public async Task<string> ImportByBusinessTypeAsync([FromForm] IFormFileCollection files, EnumBusinessType businessType)
{ {
return await ImportAsync(files, businessType); return await ImportAsync(files, businessType);
} }
///// <summary>
///// 导入(直供件)
///// </summary>
//[HttpPost]
//public async Task<string> ZhiGongJianImportAsync([FromForm] IFormFileCollection files)
//{
// return await ImportAsync(files, EnumBusinessType.ZhiGongJian);
//}
///// <summary>
///// 导入(备件)
///// </summary>
//[HttpPost]
//public async Task<string> BeiJianImportAsync([FromForm] IFormFileCollection files)
//{
// return await ImportAsync(files, EnumBusinessType.BeiJian);
//}
///// <summary>
///// 导入(备件)
///// </summary>
//[HttpPost]
//public async Task<string> BeiJianImportAsync([FromForm] IFormFileCollection files)
//{
// return await ImportAsync(files, EnumBusinessType.BeiJian);
//}
///// <summary>
///// 导入(备件)
///// </summary>
//[HttpPost]
//public async Task<string> BeiJianImportAsync([FromForm] IFormFileCollection files)
//{
// return await ImportAsync(files, EnumBusinessType.BeiJian);
//}
#endregion
#endregion
#region 导入、导出
#endregion #endregion
#region CURD #region CURD

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

@ -145,6 +145,7 @@ namespace Win.Sfs.SettleAccount
CreateMapPUB_SE_DETAIL(); CreateMapPUB_SE_DETAIL();
CreateMapPUB_SA(); CreateMapPUB_SA();
CreateMapPUB_SA_DETAIL();
CreateMapBBAC_CAN_SA(); CreateMapBBAC_CAN_SA();
@ -973,11 +974,18 @@ namespace Win.Sfs.SettleAccount
private void CreateMapPUB_SA() private void CreateMapPUB_SA()
{ {
CreateMap<PUB_SA, PUB_SA_DTO>(); CreateMap<PUB_SA, PUB_SA_DTO>();
}
/// <summary>
/// PUB结算明细
/// </summary>
private void CreateMapPUB_SA_DETAIL()
{
CreateMap<PUB_SA_DETAIL, PUB_CAN_SA_DETAIL>() CreateMap<PUB_SA_DETAIL, PUB_CAN_SA_DETAIL>()
.ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum)); .ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum));
CreateMap<PUB_SA_DETAIL, PUB_NOT_SA_DETAIL>() CreateMap<PUB_SA_DETAIL, PUB_NOT_SA_DETAIL>()
.ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum)); .ForMember(x => x.SettleBillNum, y => y.MapFrom(d => d.BillNum));
CreateMap<PUB_SA_DETAIL, PUB_SA_DETAIL_EXPORT_DTO>();
CreateMap<PUB_SA_DETAIL_IMPORT_DTO, PUB_SA_DETAIL>(); CreateMap<PUB_SA_DETAIL_IMPORT_DTO, PUB_SA_DETAIL>();
} }

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

@ -1,4 +1,4 @@
using System; using System;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Volo.Abp; using Volo.Abp;
using Volo.Abp.EntityFrameworkCore.Modeling; using Volo.Abp.EntityFrameworkCore.Modeling;
@ -90,9 +90,7 @@ namespace Win.Sfs.SettleAccount
#region 北汽结算 #region 北汽结算
builder.ConfigureTaskJob(options);
builder.ConfigureBBAC_CAN_SA(options); builder.ConfigureBBAC_CAN_SA(options);
builder.ConfigureBBAC_CAN_SA_DETAIL(options); builder.ConfigureBBAC_CAN_SA_DETAIL(options);
builder.ConfigureBBAC_NOT_SA_DETAIL(options); builder.ConfigureBBAC_NOT_SA_DETAIL(options);
@ -571,6 +569,15 @@ namespace Win.Sfs.SettleAccount
} }
private static void ConfigureTaskJob(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<TaskJob>(b =>
{
b.ToTable($"{options.TablePrefix}_TaskJob", options.Schema);
b.ConfigureByConvention();
});
}
private static void ConfigureBBAC_CAN_SA(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options) private static void ConfigureBBAC_CAN_SA(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{ {

4147
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719053130_20230719-3.Designer.cs

File diff suppressed because it is too large

53
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230719053130_20230719-3.cs

@ -0,0 +1,53 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202307193 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Set_TaskJob",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Type = table.Column<string>(type: "nvarchar(max)", nullable: true),
State = table.Column<string>(type: "nvarchar(max)", nullable: true),
TaskId = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
Name = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
ActionName = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
Error = table.Column<string>(type: "nvarchar(max)", nullable: true),
Creator = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
Email = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
FileName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
RealFileName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
RealDownFileName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
DownFileName = table.Column<string>(type: "nvarchar(200)", maxLength: 200, nullable: true),
ServiceName = table.Column<string>(type: "nvarchar(300)", maxLength: 300, nullable: true),
ExtraProperties = table.Column<string>(type: "nvarchar(max)", nullable: true),
ConcurrencyStamp = table.Column<string>(type: "nvarchar(40)", maxLength: 40, nullable: true),
CreationTime = table.Column<DateTime>(type: "datetime2", nullable: false),
CreatorId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
LastModificationTime = table.Column<DateTime>(type: "datetime2", nullable: true),
LastModifierId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
IsDeleted = table.Column<bool>(type: "bit", nullable: false, defaultValue: false),
DeleterId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
DeletionTime = table.Column<DateTime>(type: "datetime2", nullable: true),
BranchId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Enabled = table.Column<bool>(type: "bit", nullable: false),
Remark = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_TaskJob", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Set_TaskJob");
}
}
}

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

@ -3947,6 +3947,115 @@ namespace Win.Sfs.SettleAccount.Migrations
b.ToTable("Set_PriceListVersionBJ"); b.ToTable("Set_PriceListVersionBJ");
}); });
modelBuilder.Entity("Win.Sfs.SettleAccount.Entities.TaskJob", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("ActionName")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<Guid>("BranchId")
.HasColumnType("uniqueidentifier");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
b.Property<string>("Creator")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<Guid?>("CreatorId")
.HasColumnType("uniqueidentifier")
.HasColumnName("CreatorId");
b.Property<Guid?>("DeleterId")
.HasColumnType("uniqueidentifier")
.HasColumnName("DeleterId");
b.Property<DateTime?>("DeletionTime")
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("DownFileName")
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Email")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<bool>("Enabled")
.HasColumnType("bit");
b.Property<string>("Error")
.HasColumnType("nvarchar(max)");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<string>("FileName")
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("Name")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("RealDownFileName")
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("RealFileName")
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property<string>("Remark")
.HasColumnType("nvarchar(max)");
b.Property<string>("ServiceName")
.HasMaxLength(300)
.HasColumnType("nvarchar(300)");
b.Property<string>("State")
.HasColumnType("nvarchar(max)");
b.Property<string>("TaskId")
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Type")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Set_TaskJob");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.MaterialRelationships.MaterialRelationship", b => modelBuilder.Entity("Win.Sfs.SettleAccount.MaterialRelationships.MaterialRelationship", b =>
{ {
b.Property<Guid>("Id") b.Property<Guid>("Id")

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

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using TaskJob.EventArgs;
using TaskJob.Interfaces;
using Volo.Abp.DependencyInjection;
namespace SettleAccount.Job.Services.Report
{
/// <summary>
/// Pub结算发运对比导出服务
/// </summary>
public class PubSaSeCompareExportService: ITransientDependency, IExportJob
{
public PubSaSeCompareExportService() { }
/// <summary>
/// 导出
/// </summary>
public string ExportFile(Guid id, List<string> exportName, List<CustomCondition> property)
{
return this.GetType().FullName;
}
}
}

9
code/src/Modules/SettleAccount/src/SettleAccount.Job/SettleAccountJobModule.cs

@ -1,4 +1,4 @@
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.AutoMapper; using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.Application; using Volo.Abp.Application;
@ -38,6 +38,8 @@ namespace Win.Sfs.SettleAccount
{ {
GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute{ Attempts = 0}); GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute{ Attempts = 0});
context.Services.AddTransient<PubSaSeCompareExportService>();
context.Services.AddTransient<SettleAccountImportService>(); context.Services.AddTransient<SettleAccountImportService>();
context.Services.AddTransient<InvoiceImportService>(); context.Services.AddTransient<InvoiceImportService>();
context.Services.AddTransient<InvoiceSettledDiffExportService>(); context.Services.AddTransient<InvoiceSettledDiffExportService>();
@ -79,6 +81,11 @@ namespace Win.Sfs.SettleAccount
{ {
Func<string, IExportJob> accesor = key => Func<string, IExportJob> accesor = key =>
{ {
if (key.Equals(typeof(PubSaSeCompareExportService).FullName))
{
return implementationFactory.GetService<PubSaSeCompareExportService>();
}
if (key.Equals(typeof(InvoiceSettledDiffExportService).FullName)) if (key.Equals(typeof(InvoiceSettledDiffExportService).FullName))
{ {
return implementationFactory.GetService<InvoiceSettledDiffExportService>(); return implementationFactory.GetService<InvoiceSettledDiffExportService>();

Loading…
Cancel
Save