Browse Source

创建PUBSA Dto

master
mahao 1 year ago
parent
commit
e66b513a0b
  1. 68
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/BQ/Dtos/PUB_SA_DTO.cs
  2. 46
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/BQ/PUB_SA_SERVICE.cs
  3. 2
      code/src/Modules/SettleAccount/src/SettleAccount.Application/SettleAccountApplicationAutoMapperProfile.cs

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

@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using Magicodes.ExporterAndImporter.Core;
using System;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
@ -35,9 +32,66 @@ namespace Win.Sfs.SettleAccount.Entities.BQ.Dtos
/// <summary>
/// 导入
/// </summary>
public class PUB_SA_IMPORT_DTO
public class ZGJ_PUB_SA_DETAIL_IMPORT_DTO
{
///// <summary>
///// 期间
///// </summary>
//public int Version { set; get; }
///// <summary>
///// 单价
///// </summary>
//public decimal Price { set; get; }
///// <summary>
///// 结算单
///// </summary>
//public string BillNum { set; get; }
/// <summary>
/// 结算日期
/// </summary>
[ImporterHeader(Name = "Pstng Date")]
public DateTime SettleDate { set; get; }
/// <summary>
/// 零件号
/// </summary>
[ImporterHeader(Name = "Material")]
public string LU { get; set; }
/// <summary>
/// 生产号
/// </summary>
[ImporterHeader(Name = "External Delivery ID")]
public string PN { get; set; }
///// <summary>
///// 组合键值(LU+PN)
///// </summary>
//public string KeyCode
//{
// get => LU + PN;
//}
///// <summary>
/// 数量
/// </summary>
[ImporterHeader(Name = "Quantity")]
public decimal Qty { get; set; }
/// <summary>
/// 结算分组号
/// </summary>
[ImporterHeader(Name = "Delivery")]
public string GroupNum { get; set; }
/////// <summary>
/////// 工厂地点
/////// </summary>
////[Display(Name = "工厂地点")]
////public string Site { get; set; }
}
/// <summary>

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

@ -1,10 +1,12 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using NPOI.Util;
using SettleAccount.Domain.BQ;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching;
@ -23,37 +25,69 @@ namespace Win.Sfs.SettleAccount.Entities.BQ
/// </summary>
[AllowAnonymous]
[Route("api/settleaccount/[controller]/[action]")]
public class PUB_SA_SERVICE : SettleAccountApplicationBase<TB_RePartsRelationship>
public class PUB_SA_SERVICE : SettleAccountApplicationBase<PUB_SA>
{
/// <summary>
/// PUB结算仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_SA, Guid> _repository;
/// <summary>
/// PUB结算明细仓储
/// </summary>
private readonly INormalEfCoreRepository<PUB_SA_DETAIL, Guid> _pubSaDetailRepository;
/// <summary>
/// 构造
/// </summary>
public PUB_SA_SERVICE(INormalEfCoreRepository<PUB_SA, Guid> repository,
IDistributedCache<TB_RePartsRelationship> cache,
INormalEfCoreRepository<PUB_SA_DETAIL, Guid> pubSaDetailRepository,
IDistributedCache<PUB_SA> cache,
IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{
_repository = repository;
_pubSaDetailRepository = pubSaDetailRepository;
}
#region 直供件
#endregion
#region 导入、导出
/// <summary>
/// 导入
/// </summary>
[HttpPost]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files)
public async Task<string> ZGJImportAsync([FromForm] IFormFileCollection files)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<PUB_SA_IMPORT_DTO>(files, _excelImportService);
var _ls = ObjectMapper.Map<List<PUB_SA_IMPORT_DTO>, List<PUB_SA>>(result);
await _repository.InsertManyAsync(_ls);
var result = await _exportImporter.UploadExcelImport<ZGJ_PUB_SA_DETAIL_IMPORT_DTO>(files, _excelImportService);
var _ls = ObjectMapper.Map<List<ZGJ_PUB_SA_DETAIL_IMPORT_DTO>, List<PUB_SA_DETAIL>>(result);
var billNum = GuidGenerator.Create().ToString();
var pubSa = new PUB_SA()
{
BillNum = billNum,
State = "1"
};
_ls.ForEach(s =>
{
string[] luArr = s.LU.Split(" ");
var lus = luArr.Reverse();
var result = lus.Aggregate(" ", (current, index) => current + index);
//s.LU = s.LU.Replace(" ", "").Replace(" ", " ");
s.BillNum = billNum;
s.Site = "直供件";
s.KeyCode = s.LU + s.PN;
});
//await _repository.InsertAsync(pubSa);
//await _pubSaDetailRepository.InsertManyAsync(_ls);
return ApplicationConsts.SuccessStr;
}

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

@ -819,6 +819,8 @@ namespace Win.Sfs.SettleAccount
private void CreateMapPUB_SA()
{
CreateMap<PUB_SA, PUB_SA_DTO>();
CreateMap<ZGJ_PUB_SA_DETAIL_IMPORT_DTO, PUB_SA_DETAIL>();
}
}

Loading…
Cancel
Save