Browse Source

EF迁移

master
mahao 1 year ago
parent
commit
e6a84a52f8
  1. 1
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  2. 34
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  3. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs
  4. 7
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/MaterialRelationships/MaterialRelationship.cs
  5. 9
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  6. 4023
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230718010724_20230718-1.Designer.cs
  7. 163
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230718010724_20230718-1.cs
  8. 43
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

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

@ -54,7 +54,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// </summary>
[Display(Name = "结算日期")]
[ImporterHeader(Name = "Pstng Date")]
[Required(ErrorMessage = "{0}不能为空")]
public DateTime SettleDate { set; get; }
/// <summary>

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

@ -80,10 +80,12 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
public PUB_SA_SERVICE(INormalEfCoreRepository<PUB_SA, Guid> repository,
INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository,
INormalEfCoreRepository<PriceList, Guid> priceListRepository,
INormalEfCoreRepository<PUB_CAN_SA, Guid> pubCanSaRepository,
INormalEfCoreRepository<PUB_CAN_SA_DETAIL, Guid> pubCanSaDetailRepository,
INormalEfCoreRepository<PUB_NOT_SA_DETAIL, Guid> pubNotSaDetailRepository,
INormalEfCoreRepository<PriceList, Guid> priceListRepository,
INormalEfCoreRepository<MaterialRelationship, Guid> materialRelationshipRepository,
INormalEfCoreRepository<TB_RePartsRelationship, Guid> tbRePartsRelationshipRepository,
IDistributedCache<PUB_SA> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
@ -96,6 +98,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
_pubCanSaDetailRepository = pubCanSaDetailRepository;
_pubNotSaDetailRepository = pubNotSaDetailRepository;
_priceListRepository = priceListRepository;
_materialRelationshipRepository = materialRelationshipRepository;
_tbRePartsRelationshipRepository = tbRePartsRelationshipRepository;
}
#region 直供件
@ -137,6 +141,8 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
var pubCanSaDetails = new List<PUB_CAN_SA_DETAIL>();
//不可结算明细
var pubNotSaDetails = new List<PUB_NOT_SA_DETAIL>();
//客户零件关系
var materialRelationships = new List<MaterialRelationship>();
#region 导入数据转换、数据校验
@ -189,10 +195,23 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
importPubSaDetail.Price = priceListEntity?.Price ?? 0;
});
////导入的零件号集合
//var importPubSaLUs = importPubSaDetails.Select(t => t.LU).Distinct();
//_materialRelationshipRepository.GetListAsync(t => t.)
//导入的零件号集合
var importPubSaLUs = importPubSaDetails.Select(t => t.LU).Distinct();
var materialRelationshipEntitys = await _materialRelationshipRepository.GetListAsync(t => importPubSaLUs.Contains(t.SettleMaterialCode));
var materialRelationshipEntitySettleMaterialCodes = materialRelationshipEntitys.Select(t => t.SettleMaterialCode).Distinct();
/*
* ()
*
* 6-
*/
var noExistSettleMaterialCodes = importPubSaLUs.Except(materialRelationshipEntitySettleMaterialCodes);
noExistSettleMaterialCodes.ForEach(t =>
{
var materialRelationship = new MaterialRelationship(GuidGenerator.Create(), t.Replace(" ", "-"), "", t);
materialRelationships.Add(materialRelationship);
});
#endregion
@ -211,7 +230,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
pubNotSaDetails = ObjectMapper.Map<List<PUB_SA_DETAIL>, List<PUB_NOT_SA_DETAIL>>(pubSaDetailsNotCanSes);
#endregion
#region 添加入库
await _repository.InsertAsync(pubSa);
await _pubSaDetailRepository.InsertManyAsync(importPubSaDetails);
@ -236,7 +254,11 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
});
await _pubNotSaDetailRepository.InsertManyAsync(pubNotSaDetails);
}
}
if (materialRelationships.Count > 0)
{
await _materialRelationshipRepository.InsertManyAsync(materialRelationships);
}
#endregion
return ApplicationConsts.SuccessStr;

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

@ -73,6 +73,10 @@ namespace Win.Sfs.SettleAccount.Entities.MaterialRelationships
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("ERP物料号{0}有重复", itm.Key.ErpMaterialCode), string.Empty));
}
}
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
foreach (var itm in _ls)
{
var _first = _repository.FirstOrDefault(p => p.ErpMaterialCode == itm.ErpMaterialCode);
@ -86,10 +90,6 @@ namespace Win.Sfs.SettleAccount.Entities.MaterialRelationships
await _repository.InsertAsync(itm);
}
}
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
return ApplicationConsts.SuccessStr;
}

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

@ -96,5 +96,12 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
ShipMaterailCode = shipMaterailCode;
AppraisalCategory = appraisalCategory;
}
public MaterialRelationship(Guid id, string erpMaterialCode, string materialDesc, string settlMaterialCode) : base(id)
{
ErpMaterialCode = erpMaterialCode;
MaterialDesc = materialDesc;
SettleMaterialCode = settlMaterialCode;
}
}
}

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

@ -280,19 +280,10 @@ namespace Win.Sfs.SettleAccount
{
b.ToTable($"{options.TablePrefix}_relationship", options.Schema);
b.ConfigureByConvention();
//b.Property(x => x.SettleMaterialCode).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength);
b.Property(x => x.MaterialProperty).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength);
//b.Property(x => x.ShipMaterailCode).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength);
b.Property(x => x.ErpMaterialCode).IsRequired().HasMaxLength(CommonConsts.MaxCodeLength);
b.HasIndex(x => new { x.ErpMaterialCode });
b.HasIndex(x => new { x.ErpMaterialCode }).IsUnique().HasFilter(IsDeletedFilter);
});
}

4023
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230718010724_20230718-1.Designer.cs

File diff suppressed because it is too large

163
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230718010724_20230718-1.cs

@ -0,0 +1,163 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202307181 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Site",
table: "Set_BBAC_CAN_SA");
migrationBuilder.AlterColumn<string>(
name: "MaterialProperty",
table: "Set_relationship",
type: "nvarchar(max)",
nullable: true,
oldClrType: typeof(string),
oldType: "nvarchar(36)",
oldMaxLength: 36);
migrationBuilder.AddColumn<string>(
name: "Extend1",
table: "Set_PUB_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend2",
table: "Set_PUB_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend3",
table: "Set_PUB_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend4",
table: "Set_PUB_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend1",
table: "Set_HBPO_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend2",
table: "Set_HBPO_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend3",
table: "Set_HBPO_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend4",
table: "Set_HBPO_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend1",
table: "Set_BBAC_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend2",
table: "Set_BBAC_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend3",
table: "Set_BBAC_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "Extend4",
table: "Set_BBAC_PD_DETAIL",
type: "nvarchar(max)",
nullable: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "Extend1",
table: "Set_PUB_PD_DETAIL");
migrationBuilder.DropColumn(
name: "Extend2",
table: "Set_PUB_PD_DETAIL");
migrationBuilder.DropColumn(
name: "Extend3",
table: "Set_PUB_PD_DETAIL");
migrationBuilder.DropColumn(
name: "Extend4",
table: "Set_PUB_PD_DETAIL");
migrationBuilder.DropColumn(
name: "Extend1",
table: "Set_HBPO_PD_DETAIL");
migrationBuilder.DropColumn(
name: "Extend2",
table: "Set_HBPO_PD_DETAIL");
migrationBuilder.DropColumn(
name: "Extend3",
table: "Set_HBPO_PD_DETAIL");
migrationBuilder.DropColumn(
name: "Extend4",
table: "Set_HBPO_PD_DETAIL");
migrationBuilder.DropColumn(
name: "Extend1",
table: "Set_BBAC_PD_DETAIL");
migrationBuilder.DropColumn(
name: "Extend2",
table: "Set_BBAC_PD_DETAIL");
migrationBuilder.DropColumn(
name: "Extend3",
table: "Set_BBAC_PD_DETAIL");
migrationBuilder.DropColumn(
name: "Extend4",
table: "Set_BBAC_PD_DETAIL");
migrationBuilder.AlterColumn<string>(
name: "MaterialProperty",
table: "Set_relationship",
type: "nvarchar(36)",
maxLength: 36,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "nvarchar(max)",
oldNullable: true);
migrationBuilder.AddColumn<string>(
name: "Site",
table: "Set_BBAC_CAN_SA",
type: "nvarchar(max)",
nullable: true);
}
}
}

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

@ -79,9 +79,6 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasMaxLength(50)
.HasColumnType("nvarchar(50)");
b.Property<string>("Site")
.HasColumnType("nvarchar(max)");
b.Property<int>("State")
.HasMaxLength(50)
.HasColumnType("int");
@ -328,6 +325,18 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("Extend1")
.HasColumnType("nvarchar(max)");
b.Property<string>("Extend2")
.HasColumnType("nvarchar(max)");
b.Property<string>("Extend3")
.HasColumnType("nvarchar(max)");
b.Property<string>("Extend4")
.HasColumnType("nvarchar(max)");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
@ -1258,6 +1267,18 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("Extend1")
.HasColumnType("nvarchar(max)");
b.Property<string>("Extend2")
.HasColumnType("nvarchar(max)");
b.Property<string>("Extend3")
.HasColumnType("nvarchar(max)");
b.Property<string>("Extend4")
.HasColumnType("nvarchar(max)");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
@ -2668,6 +2689,18 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("datetime2")
.HasColumnName("DeletionTime");
b.Property<string>("Extend1")
.HasColumnType("nvarchar(max)");
b.Property<string>("Extend2")
.HasColumnType("nvarchar(max)");
b.Property<string>("Extend3")
.HasColumnType("nvarchar(max)");
b.Property<string>("Extend4")
.HasColumnType("nvarchar(max)");
b.Property<string>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
@ -3963,9 +3996,7 @@ namespace Win.Sfs.SettleAccount.Migrations
.HasColumnType("nvarchar(max)");
b.Property<string>("MaterialProperty")
.IsRequired()
.HasMaxLength(36)
.HasColumnType("nvarchar(36)");
.HasColumnType("nvarchar(max)");
b.Property<string>("Remark")
.HasColumnType("nvarchar(max)");

Loading…
Cancel
Save