mahao
1 year ago
11 changed files with 4416 additions and 12 deletions
@ -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; } |
|||
} |
|||
|
|||
} |
@ -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; } |
|||
} |
|||
|
|||
} |
@ -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
|
|||
|
|||
} |
|||
} |
@ -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
|
|||
|
|||
} |
|||
} |
File diff suppressed because it is too large
@ -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"); |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue