学 赵 1 year ago
parent
commit
3497e3c49a
  1. 59
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs
  2. 21
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs
  3. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs

59
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs

@ -9,6 +9,7 @@ using Win.Sfs.Shared;
using Volo.Abp.Application.Dtos;
using Win.Sfs.Shared.Filter;
using System.Collections.Generic;
using Microsoft.AspNetCore.Http;
namespace Win.Sfs.SettleAccount.MaterialRelationships
{
@ -66,48 +67,36 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
/// </summary>
public class MaterialRelationshipUpdateDto : MaterialRelationshipDtoBase
{
}
/// <summary>
/// FIS
/// </summary>
public class MaterialRelationshipDto : AuditedEntityDtoBase<Guid>
{
[Required(ErrorMessage = "{0}是必填项")]
[MaxLength(CommonConsts.MaxNameLength, ErrorMessage = "{0}最多输入{1}个字符")]
public virtual string ErpMaterialCode { get; set; }
/// <summary>
/// 物料描述
/// 客户零件关系
/// </summary>
public virtual string MaterialDesc { get; set; }
public class MaterialRelationshipDto : EntityDto<Guid>
{
/// <summary>
/// 物料属性
/// 厂内物料号
/// </summary>
public virtual string MaterialProperty { get; set; }
[Display(Name = "厂内物料号")]
public string ErpMaterialCode { get; set; }
/// <summary>
/// 结算物料号
/// 厂内物料描述
/// </summary>
public virtual string SettleMaterialCode { get; set; }
[Display(Name = "厂内物料描述")]
public string MaterialDesc { get; set; }
/// <summary>
/// 发货看板物料号
/// 客户物料号
/// </summary>
public virtual string ShipMaterailCode { get; set; }
[Display(Name = "客户物料号")]
public string SettleMaterialCode { get; set; }
public virtual Guid BranchId { get; set; }
/// <summary>
/// 估价类
/// 备注
/// </summary>
public virtual string AppraisalCategory { get; set; }
[Display(Name = "备注")]
public string Remark { get; set; }
}
/// <summary>
@ -134,6 +123,22 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
public string SettleMaterialCode { get; set; }
}
/// <summary>
/// 客户零件关系导入请求
/// </summary>
public class MaterialRelationshipImportRequestDto
{
/// <summary>
/// 文件
/// </summary>
public IFormFileCollection Files { get; set; }
/// <summary>
/// 是否是备件
/// </summary>
public bool IsBj { get; set; }
}
/// <summary>
/// 客户零件关系导入
/// </summary>

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

@ -1,11 +1,11 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Shouldly;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Caching;
using Win.Abp.Snowflakes;
@ -16,11 +16,10 @@ using Win.Sfs.SettleAccount.Entities.BQ.Dtos;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.DtoBase;
using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.MaterialRelationships
{
namespace Win.Sfs.SettleAccount.Entities.MaterialRelationships;
/// <summary>
/// 客户零件关系
/// </summary>
@ -52,10 +51,10 @@ namespace Win.Sfs.SettleAccount.Entities.MaterialRelationships
/// 导入
/// </summary>
[HttpPost]
public async Task<string> ImportAsync([FromForm] IFormFileCollection files)
public async Task<string> ImportAsync(MaterialRelationshipImportRequestDto materialRelationshipImportRequestDto)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<MaterialRelationshipImportDto>(files, _excelImportService);
var result = await _exportImporter.UploadExcelImport<MaterialRelationshipImportDto>(materialRelationshipImportRequestDto.Files, _excelImportService);
var _ls = ObjectMapper.Map<List<MaterialRelationshipImportDto>, List<MaterialRelationship>>(result);
List<string> _errorList = new List<string>();
var checkList = new List<ErrorExportDto>();
@ -66,7 +65,6 @@ namespace Win.Sfs.SettleAccount.Entities.MaterialRelationships
group arc by new { arc.ErpMaterialCode }
into g
where g.Count() > 1
select g;
foreach (var itm in query)
{
@ -83,10 +81,12 @@ namespace Win.Sfs.SettleAccount.Entities.MaterialRelationships
if (_first != null)
{
_first.Update(itm.MaterialDesc, itm.MaterialProperty, itm.SettleMaterialCode, itm.ShipMaterailCode);
_first.Remark = materialRelationshipImportRequestDto.IsBj ? "BJ" : "";
await _repository.UpdateAsync(_first);
}
else
{
itm.Remark = materialRelationshipImportRequestDto.IsBj ? "BJ" : "";
await _repository.InsertAsync(itm);
}
}
@ -471,4 +471,3 @@ namespace Win.Sfs.SettleAccount.Entities.MaterialRelationships
#endregion
}
}

9
code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs

@ -1,4 +1,4 @@
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
@ -128,12 +128,7 @@ namespace Win.Sfs.SettleAccount.ExcelImporter
{
foreach (var itm in import.RowErrors)
{
string error = string.Empty;
foreach (var dic in itm.FieldErrors)
{
error += (dic.Key + dic.Value + "|");
}
string error = itm.FieldErrors.Select(t => t.Value).Aggregate((current, index) => current + "|" + index);
_errorList.Add(string.Format("第{0}行{1}", itm.RowIndex.ToString(), error));
}
//自动保存“{ 目标文件名称}_.xlsx”的标注文件到目标位置

Loading…
Cancel
Save