Browse Source

客户替换件关系迁移

master
mahao 1 year ago
parent
commit
168208e377
  1. 71
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SE_DETAIL_DTO.cs
  2. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PURCHASE_PRICE_DTO.cs
  3. 104
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs
  4. 77
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SE_DETAIL_Service.cs
  5. 135
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs
  6. 21
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs
  7. 17
      code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TB_RePartsRelationship.cs
  8. 21
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/EntityFrameworkCore/SettleAccountDbContextModelCreatingExtensions.cs
  9. 3870
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230712032712_20230712-1.Designer.cs
  10. 41
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230712032712_20230712-1.cs
  11. 63
      code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/SettleAccountDbContextModelSnapshot.cs

71
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/BBAC_SE_DETAIL_DTO.cs

@ -0,0 +1,71 @@
using Magicodes.ExporterAndImporter.Core;
using System;
using System.ComponentModel.DataAnnotations;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
{
/// <summary>
/// BBAC发运
/// </summary>
public class BBAC_SE_DETAIL_DTO
{
/// <summary>
/// 日顺序号
/// </summary>
[Display(Name = "日顺序号")]
public string SeqNumber { get; set; }
/// <summary>
/// 小总成号
/// </summary>
[Display(Name = "小总成号")]
public string AssemblyCode { get; set; }
/// <summary>
/// 注塑码
/// </summary>
[Display(Name = "注塑码")]
public string InjectionCode { get; set; }
/// <summary>
/// 订单时间
/// </summary>
[Display(Name = "订单时间")]
public DateTime BeginDate { get; set; }
}
/// <summary>
/// 导出
/// </summary>
public class BBAC_SE_DETAIL_EXPORT_DTO
{
/// <summary>
/// 日顺序号
/// </summary>
[Display(Name = "日顺序号")]
[ExporterHeader(DisplayName = "日顺序号")]
public string SeqNumber { get; set; }
/// <summary>
/// 小总成号
/// </summary>
[Display(Name = "小总成号")]
[ExporterHeader(DisplayName = "小总成号")]
public string AssemblyCode { get; set; }
/// <summary>
/// 注塑码
/// </summary>
[Display(Name = "注塑码")]
[ExporterHeader(DisplayName = "注塑码")]
public string InjectionCode { get; set; }
/// <summary>
/// 订单时间
/// </summary>
[Display(Name = "订单时间")]
[ExporterHeader(DisplayName = "订单时间")]
public DateTime BeginDate { get; set; }
}
}

8
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PURCHASE_PRICE_DTO.cs

@ -22,6 +22,9 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public decimal Price { get; set; }
}
/// <summary>
/// 导入
/// </summary>
public class PURCHASE_PRICE_IMPORT_DTO
{
/// <summary>
@ -39,11 +42,6 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
public decimal Price { get; set; }
}
public class PURCHASE_PRICE_REQUEST_DTO : RequestDtoBase
{
}
/// <summary>
/// 导出
/// </summary>

104
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/TB_RePartsRelationship_DTO.cs

@ -0,0 +1,104 @@
using Magicodes.ExporterAndImporter.Core;
using System.ComponentModel.DataAnnotations;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
{
/// <summary>
/// 客户替换件关系
/// </summary>
public class TB_RePartsRelationship_DTO
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
public string LU { set; get; }
/// <summary>
/// 替换零件号
/// </summary>
[Display(Name = "替换零件号")]
public string RepLU { set; get; }
/// <summary>
/// 客户编码
/// </summary>
[Display(Name = "客户编码")]
public string ClientCode { set; get; }
/// <summary>
/// 业务类型
/// </summary>
[Display(Name = "业务类型")]
public string BusinessType { set; get; }
}
/// <summary>
/// 导入
/// </summary>
public class TB_RePartsRelationship_IMPORT_DTO
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[ImporterHeader(Name = "零件号")]
public string LU { set; get; }
/// <summary>
/// 替换零件号
/// </summary>
[Display(Name = "替换零件号")]
[ImporterHeader(Name = "替换零件号")]
public string RepLU { set; get; }
/// <summary>
/// 客户编码
/// </summary>
[Display(Name = "客户编码")]
[ImporterHeader(Name = "客户编码")]
public string ClientCode { set; get; }
/// <summary>
/// 业务类型
/// </summary>
[Display(Name = "业务类型")]
[ImporterHeader(Name = "业务类型")]
public string BusinessType { set; get; }
}
/// <summary>
/// 导出
/// </summary>
public class TB_RePartsRelationship_EXPORT_DTO
{
/// <summary>
/// 零件号
/// </summary>
[Display(Name = "零件号")]
[ExporterHeader(DisplayName = "零件号")]
public string LU { set; get; }
/// <summary>
/// 替换零件号
/// </summary>
[Display(Name = "替换零件号")]
[ExporterHeader(DisplayName = "替换零件号")]
public string RepLU { set; get; }
/// <summary>
/// 客户编码
/// </summary>
[Display(Name = "客户编码")]
[ExporterHeader(DisplayName = "客户编码")]
public string ClientCode { set; get; }
/// <summary>
/// 业务类型
/// </summary>
[Display(Name = "业务类型")]
[ExporterHeader(DisplayName = "业务类型")]
public string BusinessType { set; get; }
}
}

77
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/BBAC_SE_DETAIL_Service.cs

@ -0,0 +1,77 @@
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
/// <summary>
/// BBAC发运单
/// </summary>
public class BBAC_SE_DETAIL_Service : ApplicationService
{
/// <summary>
/// BBAC发运单仓储
/// </summary>
private readonly INormalEfCoreRepository<BBAC_SE_DETAIL, Guid> _repository;
/// <summary>
/// excel导入服务
/// </summary>
private readonly IExcelImportAppService _excelImportService;
/// <summary>
/// 构造
/// </summary>
public BBAC_SE_DETAIL_Service(INormalEfCoreRepository<BBAC_SE_DETAIL, Guid> repository, IExcelImportAppService excelImportService)
{
_repository = repository;
_excelImportService = excelImportService;
}
#region 导出
/// <summary>
/// 导出
/// </summary>
[HttpPost]
[Route("Export")]
public async Task<string> ExportAsync(RequestDto input)
{
string fileName = $"BBAC发运单_{Guid.NewGuid()}.xlsx";
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
var dtos = ObjectMapper.Map<List<BBAC_SE_DETAIL>, List<BBAC_SE_DETAIL_EXPORT_DTO>>(entities);
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtos);
result.ShouldNotBeNull();
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result });
return fileName;
}
#endregion
#region 查询
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
[Route("list")]
public async Task<PagedResultDto<BBAC_SE_DETAIL_DTO>> GetListAsync(RequestDto input)
{
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters);
var dtos = ObjectMapper.Map<List<BBAC_SE_DETAIL>, List<BBAC_SE_DETAIL_DTO>>(entities);
return new PagedResultDto<BBAC_SE_DETAIL_DTO>(totalCount, dtos);
}
#endregion
}
}

135
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/TB_RePartsRelationship_SERVICE.cs

@ -0,0 +1,135 @@
using AutoMapper;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SettleAccount.Domain.BQ;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids;
using Volo.Abp.ObjectMapping;
using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Boms;
using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.Boms;
using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.Entities.ImportMap;
using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.BQ
{
/// <summary>
/// 客户替换件关系
/// </summary>
public class TB_RePartsRelationship_SERVICE : SettleAccountApplicationBase<TB_RePartsRelationship>
{
/// <summary>
/// 客户替换件关系仓储
/// </summary>
private readonly INormalEfCoreRepository<TB_RePartsRelationship, Guid> _repository;
public TB_RePartsRelationship_SERVICE(
INormalEfCoreRepository<TB_RePartsRelationship, Guid> repository,
IDistributedCache<TB_RePartsRelationship> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_repository = repository;
}
#region 导入、导出
/// <summary>
/// 导入
/// </summary>
[HttpPost]
[Route("Import")]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<TB_RePartsRelationship_IMPORT_DTO>(files, _excelImportService);
var _ls = ObjectMapper.Map<List<TB_RePartsRelationship_IMPORT_DTO>, List<TB_RePartsRelationship>>(result);
List<string> _errorList = new List<string>();
var checkList = new List<ErrorExportDto>();
if (_ls.Count > 0)
{
var query = from arc in _ls
group arc by new { arc.LU }
into g
where g.Count() > 1
select g;
foreach (var itm in query)
{
checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("物料号{0}有重复", itm.Key.LU), string.Empty));
}
}
foreach (var itm in _ls)
{
var _first = _repository.FirstOrDefault(p => p.LU == itm.LU);
if (_first != null)
{
_first.Update(itm.LU, itm.RepLU, itm.ClientCode, itm.BusinessType);
await _repository.UpdateAsync(_first);
}
else
{
await _repository.InsertAsync(itm);
}
}
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 导出
/// </summary>
[HttpPost]
[Route("Export")]
public async Task<string> ExportAsync(RequestDto input)
{
string fileName = $"客户替换件关系_{Guid.NewGuid()}.xlsx";
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true);
var dtos = ObjectMapper.Map<List<TB_RePartsRelationship>, List<TB_RePartsRelationship_EXPORT_DTO>>(entities);
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtos);
result.ShouldNotBeNull();
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result });
return fileName;
}
#endregion
#region CURD
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
[Route("list")]
public async Task<PagedResultDto<TB_RePartsRelationship_DTO>> GetListAsync(RequestDto input)
{
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true);
var totalCount = await _repository.GetCountByFilterAsync(input.Filters);
var dtos = ObjectMapper.Map<List<TB_RePartsRelationship>, List<TB_RePartsRelationship_DTO>>(entities);
return new PagedResultDto<TB_RePartsRelationship_DTO>(totalCount, dtos);
}
#endregion
}
}

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

@ -135,6 +135,8 @@ namespace Win.Sfs.SettleAccount
#endregion
CreateMapPURCHASE_PRICE();
CreateMapTB_RePartsRelationship();
CreateMapBBAC_SE_DETAIL();
}
#region 北汽
@ -746,5 +748,24 @@ namespace Win.Sfs.SettleAccount
CreateMap<PURCHASE_PRICE_IMPORT_DTO, PURCHASE_PRICE>();
}
/// <summary>
/// 客户替换件关系
/// </summary>
private void CreateMapTB_RePartsRelationship()
{
CreateMap<TB_RePartsRelationship, TB_RePartsRelationship_DTO>();
CreateMap<TB_RePartsRelationship, TB_RePartsRelationship_EXPORT_DTO>();
CreateMap<TB_RePartsRelationship_IMPORT_DTO, TB_RePartsRelationship>();
}
/// <summary>
/// BBAC发运单
/// </summary>
private void CreateMapBBAC_SE_DETAIL()
{
CreateMap<BBAC_SE_DETAIL, BBAC_SE_DETAIL_DTO>();
CreateMap<BBAC_SE_DETAIL, BBAC_SE_DETAIL_EXPORT_DTO>();
}
}
}

17
code/src/Modules/SettleAccount/src/SettleAccount.Domain/Entities/BQ/TB_RePartsRelationship.cs

@ -1,12 +1,12 @@
using System.ComponentModel.DataAnnotations;
using System;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.Domain.Entities.Auditing;
namespace SettleAccount.Domain.BQ;
[Display(Name = "客户替换件关系")]
public class TB_RePartsRelationship
public class TB_RePartsRelationship : FullAuditedAggregateRoot<Guid>
{
/// <summary>
/// 取值字段【零件号】
@ -32,4 +32,13 @@ public class TB_RePartsRelationship
ClientCode = clientCode;
BusinessType = businessType;
}
public void Update(string lU, string repLU, string clientCode, string businessType)
{
LU = lU;
RepLU = repLU;
ClientCode = clientCode;
BusinessType = businessType;
}
}

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

@ -82,6 +82,8 @@ namespace Win.Sfs.SettleAccount
builder.ConfigureCentralizedControl(options);
//采购价格单
builder.ConfigurePURCHASE_PRICE(options);
//客户替换件关系
builder.ConfigureTB_RePartsRelationship(options);
#endregion
@ -335,21 +337,34 @@ namespace Win.Sfs.SettleAccount
b.ConfigureByConvention();
});
}
/// <summary>
/// 客户替换件关系
/// </summary>
private static void ConfigureTB_RePartsRelationship(this ModelBuilder builder, SettleAccountModelBuilderConfigurationOptions options)
{
builder.Entity<TB_RePartsRelationship>(b =>
{
b.ToTable($"{options.TablePrefix}_TB_RePartsRelationship", options.Schema);
b.ConfigureByConvention();
});
}
#endregion
#region 北汽
/// <summary>
/// 一汽轿车平台验收结算明细-导入

3870
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230712032712_20230712-1.Designer.cs

File diff suppressed because it is too large

41
code/src/Modules/SettleAccount/src/SettleAccount.EntityFrameworkCore/Migrations/20230712032712_20230712-1.cs

@ -0,0 +1,41 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Win.Sfs.SettleAccount.Migrations
{
public partial class _202307121 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Set_TB_RePartsRelationship",
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
LU = table.Column<string>(type: "nvarchar(max)", nullable: true),
RepLU = table.Column<string>(type: "nvarchar(max)", nullable: true),
ClientCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
BusinessType = table.Column<string>(type: "nvarchar(max)", 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)
},
constraints: table =>
{
table.PrimaryKey("PK_Set_TB_RePartsRelationship", x => x.Id);
});
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Set_TB_RePartsRelationship");
}
}
}

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

@ -2995,6 +2995,69 @@ namespace Win.Sfs.SettleAccount.Migrations
b.ToTable("Set_PURCHASE_PRICE");
});
modelBuilder.Entity("SettleAccount.Domain.BQ.TB_RePartsRelationship", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property<string>("BusinessType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClientCode")
.HasColumnType("nvarchar(max)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)")
.HasColumnName("ConcurrencyStamp");
b.Property<DateTime>("CreationTime")
.HasColumnType("datetime2")
.HasColumnName("CreationTime");
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>("ExtraProperties")
.HasColumnType("nvarchar(max)")
.HasColumnName("ExtraProperties");
b.Property<bool>("IsDeleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsDeleted");
b.Property<string>("LU")
.HasColumnType("nvarchar(max)");
b.Property<DateTime?>("LastModificationTime")
.HasColumnType("datetime2")
.HasColumnName("LastModificationTime");
b.Property<Guid?>("LastModifierId")
.HasColumnType("uniqueidentifier")
.HasColumnName("LastModifierId");
b.Property<string>("RepLU")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Set_TB_RePartsRelationship");
});
modelBuilder.Entity("Win.Sfs.SettleAccount.Boms.Bom", b =>
{
b.Property<Guid>("Id")

Loading…
Cancel
Save