diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs
index 50089fef..38c79f1b 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/MaterialRelationship/MaterialRelationshipDtoBase.cs
+++ b/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
{
@@ -65,49 +66,37 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
/// 产品结构
///
public class MaterialRelationshipUpdateDto : MaterialRelationshipDtoBase
- {
-
-
-
-
+ {
}
+
///
- /// FIS
+ /// 客户零件关系
///
- public class MaterialRelationshipDto : AuditedEntityDtoBase
+ public class MaterialRelationshipDto : EntityDto
{
-
- [Required(ErrorMessage = "{0}是必填项")]
- [MaxLength(CommonConsts.MaxNameLength, ErrorMessage = "{0}最多输入{1}个字符")]
- public virtual string ErpMaterialCode { get; set; }
///
- /// 物料描述
- ///
- public virtual string MaterialDesc { get; set; }
- ///
- /// 物料属性
+ /// 厂内物料号
///
- public virtual string MaterialProperty { get; set; }
+ [Display(Name = "厂内物料号")]
+ public string ErpMaterialCode { get; set; }
///
- /// 结算物料号
+ /// 厂内物料描述
///
- public virtual string SettleMaterialCode { get; set; }
-
+ [Display(Name = "厂内物料描述")]
+ public string MaterialDesc { get; set; }
///
- /// 发货看板物料号
+ /// 客户物料号
///
- public virtual string ShipMaterailCode { get; set; }
+ [Display(Name = "客户物料号")]
+ public string SettleMaterialCode { get; set; }
- public virtual Guid BranchId { get; set; }
///
- /// 估价类
+ /// 备注
///
- public virtual string AppraisalCategory { get; set; }
-
-
-
+ [Display(Name = "备注")]
+ public string Remark { get; set; }
}
///
@@ -134,6 +123,22 @@ namespace Win.Sfs.SettleAccount.MaterialRelationships
public string SettleMaterialCode { get; set; }
}
+ ///
+ /// 客户零件关系导入请求
+ ///
+ public class MaterialRelationshipImportRequestDto
+ {
+ ///
+ /// 文件
+ ///
+ public IFormFileCollection Files { get; set; }
+
+ ///
+ /// 是否是备件
+ ///
+ public bool IsBj { get; set; }
+ }
+
///
/// 客户零件关系导入
///
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs
index 3d53fbed..2a093dc8 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/MaterialRelationships/MaterialRelationshipAppService.cs
+++ b/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,459 +16,458 @@ 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;
+
+///
+/// 客户零件关系
+///
+[AllowAnonymous]
+[Route("api/settleaccount/[controller]/[action]")]
+public class MaterialRelationshipAppService : SettleAccountApplicationBase
{
///
- /// 客户零件关系
+ /// 客户零件关系仓储
+ ///
+ private readonly INormalEfCoreRepository _repository;
+
+ ///
+ /// 构造
///
- [AllowAnonymous]
- [Route("api/settleaccount/[controller]/[action]")]
- public class MaterialRelationshipAppService : SettleAccountApplicationBase
+ public MaterialRelationshipAppService(
+ INormalEfCoreRepository repository,
+ IDistributedCache cache,
+ IExcelImportAppService excelImportService,
+ ISnowflakeIdGenerator snowflakeIdGenerator,
+ ICommonManager commonManager
+ ) : base(cache,excelImportService,snowflakeIdGenerator,commonManager)
{
- ///
- /// 客户零件关系仓储
- ///
- private readonly INormalEfCoreRepository _repository;
-
- ///
- /// 构造
- ///
- public MaterialRelationshipAppService(
- INormalEfCoreRepository repository,
- IDistributedCache cache,
- IExcelImportAppService excelImportService,
- ISnowflakeIdGenerator snowflakeIdGenerator,
- ICommonManager commonManager
- ) : base(cache,excelImportService,snowflakeIdGenerator,commonManager)
- {
- _repository = repository;
- }
+ _repository = repository;
+ }
- #region 导入、导出
- ///
- /// 导入
- ///
- [HttpPost]
- public async Task ImportAsync([FromForm] IFormFileCollection files)
- {
- ExportImporter _exportImporter = new ExportImporter();
- var result = await _exportImporter.UploadExcelImport(files, _excelImportService);
- var _ls = ObjectMapper.Map, List>(result);
- List _errorList = new List();
- var checkList = new List();
+ #region 导入、导出
+ ///
+ /// 导入
+ ///
+ [HttpPost]
+ public async Task ImportAsync(MaterialRelationshipImportRequestDto materialRelationshipImportRequestDto)
+ {
+ ExportImporter _exportImporter = new ExportImporter();
+ var result = await _exportImporter.UploadExcelImport(materialRelationshipImportRequestDto.Files, _excelImportService);
+ var _ls = ObjectMapper.Map, List>(result);
+ List _errorList = new List();
+ var checkList = new List();
- if (_ls.Count > 0)
+ if (_ls.Count > 0)
+ {
+ var query = from arc in _ls
+ group arc by new { arc.ErpMaterialCode }
+ into g
+ where g.Count() > 1
+ select g;
+ foreach (var itm in query)
{
- var query = from arc in _ls
- group arc by new { arc.ErpMaterialCode }
- 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.ErpMaterialCode), string.Empty));
- }
+ checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("厂内物料号{0}有重复", itm.Key.ErpMaterialCode), string.Empty));
}
- if (checkList.Count > 0)
+ }
+ if (checkList.Count > 0)
+ {
+ return await ExportErrorReportAsync(checkList);
+ }
+ foreach (var itm in _ls)
+ {
+ var _first = _repository.FirstOrDefault(p => p.ErpMaterialCode == itm.ErpMaterialCode);
+ if (_first != null)
{
- return await ExportErrorReportAsync(checkList);
+ _first.Update(itm.MaterialDesc, itm.MaterialProperty, itm.SettleMaterialCode, itm.ShipMaterailCode);
+ _first.Remark = materialRelationshipImportRequestDto.IsBj ? "BJ" : "";
+ await _repository.UpdateAsync(_first);
}
- foreach (var itm in _ls)
+ else
{
- var _first = _repository.FirstOrDefault(p => p.ErpMaterialCode == itm.ErpMaterialCode);
- if (_first != null)
- {
- _first.Update(itm.MaterialDesc, itm.MaterialProperty, itm.SettleMaterialCode, itm.ShipMaterailCode);
- await _repository.UpdateAsync(_first);
- }
- else
- {
- await _repository.InsertAsync(itm);
- }
+ itm.Remark = materialRelationshipImportRequestDto.IsBj ? "BJ" : "";
+ await _repository.InsertAsync(itm);
}
- return ApplicationConsts.SuccessStr;
}
+ return ApplicationConsts.SuccessStr;
+ }
- ///
- /// 导出
- ///
- [HttpPost]
- public async Task 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>(entities);
+ ///
+ /// 导出
+ ///
+ [HttpPost]
+ public async Task 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>(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
- ///
- /// 获取列表
- ///
- [HttpPost]
- public async Task> 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>(entities);
- return new PagedResultDto(totalCount, dtos);
- }
- #endregion
-
- #region 原方法(废弃)
- /////
- ///// 导入功能
- /////
- ///// 上传的文件(前端已经限制只能上传一个附件)
- /////
- //[HttpPost]
- //[Route("ExcelImport-Map")]
- //[DisableRequestSizeLimit]
- //public async Task MaterialRelationshipUploadExcelImportMap([FromForm] IFormFileCollection files)
- //{
- // ExportImporter _exportImporter = new ExportImporter();
- // var mapList = _mapRepository.Where(p => p.ProjectName == SettleAccountModuleName.MaterialRelationship).ToList();
- // var result = await _exportImporter.ExtendExcelImport(files, _excelImportService, mapList);
- // var _ls = ObjectMapper.Map, List>(result);
- // List _errorList = new List();
- // var checkList = new List();
- // if (_ls.Count > 0)
- // {
- // var query = from arc in _ls
- // group arc by new { arc.ErpMaterialCode }
- // 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("ERP物料号{0}有重复", itm.Key.ErpMaterialCode), string.Empty));
- // // _errorList.Add(string.Format("ERP物料号{0}有重复",itm.Key.ErpMaterialCode));
- // }
- // }
- // foreach (var itm in _ls)
- // {
- // var _first = _repository.FirstOrDefault(p => p.ErpMaterialCode == itm.ErpMaterialCode);
- // if (_first != null)
- // {
- // _first.Update(itm.MaterialDesc, itm.MaterialProperty, itm.SettleMaterialCode, itm.ShipMaterailCode);
- // await _repository.UpdateAsync(_first);
- // }
- // else
- // {
- // checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("关系表中不存在ERP物料号{0}!", itm.ErpMaterialCode), string.Empty));
- // //_errorList.Add(string.Format("关系表中不存在ERP物料号{0}!", itm.ErpMaterialCode));
- // //itm.SetId(GuidGenerator.Create(), GuidGenerator.Create());
- // //await _repository.InsertAsync(itm);
- // }
- // //itm.SetId(GuidGenerator.Create(), GuidGenerator.Create());
-
- // }
- // if (checkList.Count > 0)
- // {
- // return await ExportErrorReportAsync(checkList);
- // }
-
- // return ApplicationConsts.SuccessStr;
- //}
-
-
-
- /////
- ///// 导入功能
- /////
- ///// 上传的文件(前端已经限制只能上传一个附件)
- /////
- //[HttpPost]
- //[Route("ExcelImport")]
- //[DisableRequestSizeLimit]
- //public async Task MaterialRelationshipUploadExcelImport([FromForm] IFormFileCollection files)
- //{
-
-
- // ExportImporter _exportImporter = new ExportImporter();
- // var result = await _exportImporter.UploadExcelImport(files, _excelImportService);
- // var _ls = ObjectMapper.Map, List>(result);
- // List _errorList = new List();
- // var checkList = new List();
-
- // if (_ls.Count > 0)
- // {
- // var query = from arc in _ls
- // group arc by new { arc.ErpMaterialCode }
- // 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("ERP物料号{0}有重复", itm.Key.ErpMaterialCode), string.Empty));
- // // _errorList.Add(string.Format("ERP物料号{0}有重复",itm.Key.ErpMaterialCode));
- // }
- // }
- // foreach (var itm in _ls)
- // {
- // var _first = _repository.FirstOrDefault(p => p.ErpMaterialCode == itm.ErpMaterialCode);
- // if (_first != null)
- // {
- // _first.Update(itm.MaterialDesc, itm.MaterialProperty, itm.SettleMaterialCode, itm.ShipMaterailCode);
- // await _repository.UpdateAsync(_first);
- // }
- // else
- // {
- // checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("关系表中不存在ERP物料号{0}!", itm.ErpMaterialCode), string.Empty));
- // //_errorList.Add(string.Format("关系表中不存在ERP物料号{0}!", itm.ErpMaterialCode));
- // //itm.SetId(GuidGenerator.Create(), GuidGenerator.Create());
- // //await _repository.InsertAsync(itm);
- // }
- // //itm.SetId(GuidGenerator.Create(), GuidGenerator.Create());
-
- // }
- // if (checkList.Count > 0)
- // {
- // return await ExportErrorReportAsync(checkList);
- // }
-
- // return ApplicationConsts.SuccessStr;
- //}
-
-
-
- /////
- ///// 按ID获取唯一实体
- /////
- /////
- ///// 返回实体全部属性
- /////
- ///// ID
- ///// 实体DTO
- //[HttpGet]
- //[Route("{id}")]
- //virtual public async Task GetAsync(Guid id)
- //{
- // var result = await GetFromCacheAsync(id);
- // var dto = ObjectMapper.Map(result);
- // return dto;
- //}
-
-
- //private async Task GetFromCacheAsync(Guid id)
- //{
- // var result = await _repository.GetAsync(id);
-
-
- // return result;
- //}
-
-
- //private async Task GetCountAsync(MaterialRelationshipRequestDto input)
- //{
- // return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters);
- //}
+ 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
+ ///
+ /// 获取列表
+ ///
+ [HttpPost]
+ public async Task> 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>(entities);
+ return new PagedResultDto(totalCount, dtos);
+ }
+ #endregion
+
+ #region 原方法(废弃)
+ /////
+ ///// 导入功能
+ /////
+ ///// 上传的文件(前端已经限制只能上传一个附件)
+ /////
+ //[HttpPost]
+ //[Route("ExcelImport-Map")]
+ //[DisableRequestSizeLimit]
+ //public async Task MaterialRelationshipUploadExcelImportMap([FromForm] IFormFileCollection files)
+ //{
+ // ExportImporter _exportImporter = new ExportImporter();
+ // var mapList = _mapRepository.Where(p => p.ProjectName == SettleAccountModuleName.MaterialRelationship).ToList();
+ // var result = await _exportImporter.ExtendExcelImport(files, _excelImportService, mapList);
+ // var _ls = ObjectMapper.Map, List>(result);
+ // List _errorList = new List();
+ // var checkList = new List();
+ // if (_ls.Count > 0)
+ // {
+ // var query = from arc in _ls
+ // group arc by new { arc.ErpMaterialCode }
+ // 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("ERP物料号{0}有重复", itm.Key.ErpMaterialCode), string.Empty));
+ // // _errorList.Add(string.Format("ERP物料号{0}有重复",itm.Key.ErpMaterialCode));
+ // }
+ // }
+ // foreach (var itm in _ls)
+ // {
+ // var _first = _repository.FirstOrDefault(p => p.ErpMaterialCode == itm.ErpMaterialCode);
+ // if (_first != null)
+ // {
+ // _first.Update(itm.MaterialDesc, itm.MaterialProperty, itm.SettleMaterialCode, itm.ShipMaterailCode);
+ // await _repository.UpdateAsync(_first);
+ // }
+ // else
+ // {
+ // checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("关系表中不存在ERP物料号{0}!", itm.ErpMaterialCode), string.Empty));
+ // //_errorList.Add(string.Format("关系表中不存在ERP物料号{0}!", itm.ErpMaterialCode));
+ // //itm.SetId(GuidGenerator.Create(), GuidGenerator.Create());
+ // //await _repository.InsertAsync(itm);
+ // }
+ // //itm.SetId(GuidGenerator.Create(), GuidGenerator.Create());
+
+ // }
+ // if (checkList.Count > 0)
+ // {
+ // return await ExportErrorReportAsync(checkList);
+ // }
+
+ // return ApplicationConsts.SuccessStr;
+ //}
+
+
+
+ /////
+ ///// 导入功能
+ /////
+ ///// 上传的文件(前端已经限制只能上传一个附件)
+ /////
+ //[HttpPost]
+ //[Route("ExcelImport")]
+ //[DisableRequestSizeLimit]
+ //public async Task MaterialRelationshipUploadExcelImport([FromForm] IFormFileCollection files)
+ //{
+
+
+ // ExportImporter _exportImporter = new ExportImporter();
+ // var result = await _exportImporter.UploadExcelImport(files, _excelImportService);
+ // var _ls = ObjectMapper.Map, List>(result);
+ // List _errorList = new List();
+ // var checkList = new List();
+
+ // if (_ls.Count > 0)
+ // {
+ // var query = from arc in _ls
+ // group arc by new { arc.ErpMaterialCode }
+ // 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("ERP物料号{0}有重复", itm.Key.ErpMaterialCode), string.Empty));
+ // // _errorList.Add(string.Format("ERP物料号{0}有重复",itm.Key.ErpMaterialCode));
+ // }
+ // }
+ // foreach (var itm in _ls)
+ // {
+ // var _first = _repository.FirstOrDefault(p => p.ErpMaterialCode == itm.ErpMaterialCode);
+ // if (_first != null)
+ // {
+ // _first.Update(itm.MaterialDesc, itm.MaterialProperty, itm.SettleMaterialCode, itm.ShipMaterailCode);
+ // await _repository.UpdateAsync(_first);
+ // }
+ // else
+ // {
+ // checkList.Add(new ErrorExportDto(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("关系表中不存在ERP物料号{0}!", itm.ErpMaterialCode), string.Empty));
+ // //_errorList.Add(string.Format("关系表中不存在ERP物料号{0}!", itm.ErpMaterialCode));
+ // //itm.SetId(GuidGenerator.Create(), GuidGenerator.Create());
+ // //await _repository.InsertAsync(itm);
+ // }
+ // //itm.SetId(GuidGenerator.Create(), GuidGenerator.Create());
+
+ // }
+ // if (checkList.Count > 0)
+ // {
+ // return await ExportErrorReportAsync(checkList);
+ // }
+
+ // return ApplicationConsts.SuccessStr;
+ //}
+
+
+
+ /////
+ ///// 按ID获取唯一实体
+ /////
+ /////
+ ///// 返回实体全部属性
+ /////
+ ///// ID
+ ///// 实体DTO
+ //[HttpGet]
+ //[Route("{id}")]
+ //virtual public async Task GetAsync(Guid id)
+ //{
+ // var result = await GetFromCacheAsync(id);
+ // var dto = ObjectMapper.Map(result);
+ // return dto;
+ //}
+
+
+ //private async Task GetFromCacheAsync(Guid id)
+ //{
+ // var result = await _repository.GetAsync(id);
+
+
+ // return result;
+ //}
+
+
+ //private async Task GetCountAsync(MaterialRelationshipRequestDto input)
+ //{
+ // return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters);
+ //}
- ///////
-
- /////
- ///// 根据筛选条件获取实体列表
- /////
- /////
- ///// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
- /////
- ///// 请求条件
- ///// 实体DTO列表
- //[HttpPost]
- //[Route("list")]
- //virtual public async Task> GetListAsync(MaterialRelationshipRequestDto input)
- //{
- // var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount,
- // input.SkipCount, true);
-
- // var totalCount = await GetCountAsync(input);
- // var dtos = ObjectMapper.Map, List>(entities);
-
- // return new PagedResultDto(totalCount, dtos);
- //}
-
-
- /////
- ///// 获取实体总数
- /////
- ///// 实体总数
- //[HttpGet]
- //[Route("count")]
- //virtual public async Task GetTotalCountAsync(Guid branchId)
- //{
- // return await _repository.GetCountAsync(branchId);
- //}
-
- /////
- ///// 获取全部实体列表
- /////
- ///// 实体DTO列表
- //[HttpGet]
- //[Route("all")]
- //virtual public async Task> GetAllAsync(Guid branchId)
- //{
- // var entities = await _repository.GetAllAsync(branchId, true);
-
-
- // var dtos = ObjectMapper.Map, List>(entities);
-
-
- // return new ListResultDto(dtos);
- //}
-
+
+ ///////
+
+ /////
+ ///// 根据筛选条件获取实体列表
+ /////
+ /////
+ ///// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
+ /////
+ ///// 请求条件
+ ///// 实体DTO列表
+ //[HttpPost]
+ //[Route("list")]
+ //virtual public async Task> GetListAsync(MaterialRelationshipRequestDto input)
+ //{
+ // var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount,
+ // input.SkipCount, true);
+
+ // var totalCount = await GetCountAsync(input);
+ // var dtos = ObjectMapper.Map, List>(entities);
+
+ // return new PagedResultDto(totalCount, dtos);
+ //}
+
+
+ /////
+ ///// 获取实体总数
+ /////
+ ///// 实体总数
+ //[HttpGet]
+ //[Route("count")]
+ //virtual public async Task GetTotalCountAsync(Guid branchId)
+ //{
+ // return await _repository.GetCountAsync(branchId);
+ //}
+
+ /////
+ ///// 获取全部实体列表
+ /////
+ ///// 实体DTO列表
+ //[HttpGet]
+ //[Route("all")]
+ //virtual public async Task> GetAllAsync(Guid branchId)
+ //{
+ // var entities = await _repository.GetAllAsync(branchId, true);
+
+
+ // var dtos = ObjectMapper.Map, List>(entities);
+
+
+ // return new ListResultDto(dtos);
+ //}
- /////
- ///// 新增实体
- /////
- ///// 新增实体DTO
- ///// 实体DTO
-
- //[HttpPost]
- //[Route("")]
- //virtual public async Task CreateAsync(MaterialRelationshipCreateDto input)
- //{
-
-
- // var _first = _repository.Where(p => p.ErpMaterialCode == input.ErpMaterialCode).FirstOrDefault();
-
- // if (_first != null)
- // {
- // throw new BusinessException("001", "已经存数据请修改后创建");
- // }
-
-
- // var entity = new MaterialRelationship(
- // GuidGenerator.Create(),
- // input.BranchId,
- // input.ErpMaterialCode,
-
- // input.MaterialDesc,
- // input.MaterialProperty,
- // input.SettleMaterialCode,
- // input.ShipMaterailCode,
- // input.AppraisalCategory
-
-
- // );
-
- // await _repository.InsertAsync(entity);
-
- // ////create cache
- // //await Cache.SetAsync(entity.Id.ToString(), entity,
- // // CacheStrategyConst.FIVE_MINUTES);
-
- // var dto = ObjectMapper.Map(entity);
- // return dto;
-
- //}
-
- /////
- ///// 修改实体
- /////
- ///// ID
- ///// 修改实体DTO
- ///// 实体DTO
- //[HttpPut]
- //[Route("{id}")]
- //virtual public async Task UpdateAsync(Guid id, MaterialRelationshipUpdateDto input)
- //{
- // var entity = await _repository.GetAsync(id);
- // if (entity != null)
- // {
- // entity.Update(input.MaterialDesc, input.MaterialProperty, input.SettleMaterialCode, input.ShipMaterailCode);
-
- // await _repository.UpdateAsync(entity);
-
-
- // var dto = ObjectMapper.Map(entity);
- // return dto;
- // }
- // else
- // {
- // return null;
- // }
-
- //}
-
- /////
- ///// 删除实体
- /////
- ///// ID
- ///// 无
- //[HttpDelete]
- //[Route("{id}")]
- //virtual public async Task DeleteAsync(Guid id)
- //{
- // var entity = await GetFromCacheAsync(id);
- // await Cache.DeleteAsync(id.ToString());
- // await _repository.DeleteAsync(id);
- //}
-
- /////
- ///// 按IDs删除实体列表
- /////
- ///// IDs
- ///// 是否执行成功
- //[HttpPost]
- //[Route("delete")]
- //virtual public async Task DeleteListAsync(List ids)
- //{
- // var _query = _repository.Where(p => ids.Contains(p.Id));
- // int i = await _query.BatchDeleteAsync();
-
- // if (i == 0)
- // {
- // return false;
- // }
- // return true;
- //}
- //[HttpPost]
- //[Route("Export")]
- //virtual public async Task ExportAsync(MaterialRelationshipRequestDto input)
- //{
- // //var _userId = CurrentUser.Id.Value.ToString();
- // string _fileName = string.Format("零件关系_{0}.xlsx", Guid.NewGuid().ToString());
- // var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue,
- // 0, true);
-
- // var dtoDetails = ObjectMapper.Map, List>(entities);
-
- // //声明导出容器
- // ExportImporter _exportImporter = new ExportImporter();
-
- // var result = await _exportImporter.ExcelExporter(dtoDetails);
-
- // result.ShouldNotBeNull();
-
- // //保存导出文件到服务器存成二进制
- // await _excelImportService.SaveBlobAsync(
- // new SaveExcelImportInputDto
- // {
- // Name = _fileName,
- // Content = result
- // }
- // );
- // return _fileName;
- //}
- #endregion
- }
+ /////
+ ///// 新增实体
+ /////
+ ///// 新增实体DTO
+ ///// 实体DTO
+
+ //[HttpPost]
+ //[Route("")]
+ //virtual public async Task CreateAsync(MaterialRelationshipCreateDto input)
+ //{
+
+
+ // var _first = _repository.Where(p => p.ErpMaterialCode == input.ErpMaterialCode).FirstOrDefault();
+
+ // if (_first != null)
+ // {
+ // throw new BusinessException("001", "已经存数据请修改后创建");
+ // }
+
+
+ // var entity = new MaterialRelationship(
+ // GuidGenerator.Create(),
+ // input.BranchId,
+ // input.ErpMaterialCode,
+
+ // input.MaterialDesc,
+ // input.MaterialProperty,
+ // input.SettleMaterialCode,
+ // input.ShipMaterailCode,
+ // input.AppraisalCategory
+
+
+ // );
+
+ // await _repository.InsertAsync(entity);
+
+ // ////create cache
+ // //await Cache.SetAsync(entity.Id.ToString(), entity,
+ // // CacheStrategyConst.FIVE_MINUTES);
+
+ // var dto = ObjectMapper.Map(entity);
+ // return dto;
+
+ //}
+
+ /////
+ ///// 修改实体
+ /////
+ ///// ID
+ ///// 修改实体DTO
+ ///// 实体DTO
+ //[HttpPut]
+ //[Route("{id}")]
+ //virtual public async Task UpdateAsync(Guid id, MaterialRelationshipUpdateDto input)
+ //{
+ // var entity = await _repository.GetAsync(id);
+ // if (entity != null)
+ // {
+ // entity.Update(input.MaterialDesc, input.MaterialProperty, input.SettleMaterialCode, input.ShipMaterailCode);
+
+ // await _repository.UpdateAsync(entity);
+
+
+ // var dto = ObjectMapper.Map(entity);
+ // return dto;
+ // }
+ // else
+ // {
+ // return null;
+ // }
+
+ //}
+
+ /////
+ ///// 删除实体
+ /////
+ ///// ID
+ ///// 无
+ //[HttpDelete]
+ //[Route("{id}")]
+ //virtual public async Task DeleteAsync(Guid id)
+ //{
+ // var entity = await GetFromCacheAsync(id);
+ // await Cache.DeleteAsync(id.ToString());
+ // await _repository.DeleteAsync(id);
+ //}
+
+ /////
+ ///// 按IDs删除实体列表
+ /////
+ ///// IDs
+ ///// 是否执行成功
+ //[HttpPost]
+ //[Route("delete")]
+ //virtual public async Task DeleteListAsync(List ids)
+ //{
+ // var _query = _repository.Where(p => ids.Contains(p.Id));
+ // int i = await _query.BatchDeleteAsync();
+
+ // if (i == 0)
+ // {
+ // return false;
+ // }
+ // return true;
+ //}
+ //[HttpPost]
+ //[Route("Export")]
+ //virtual public async Task ExportAsync(MaterialRelationshipRequestDto input)
+ //{
+ // //var _userId = CurrentUser.Id.Value.ToString();
+ // string _fileName = string.Format("零件关系_{0}.xlsx", Guid.NewGuid().ToString());
+ // var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue,
+ // 0, true);
+
+ // var dtoDetails = ObjectMapper.Map, List>(entities);
+
+ // //声明导出容器
+ // ExportImporter _exportImporter = new ExportImporter();
+
+ // var result = await _exportImporter.ExcelExporter(dtoDetails);
+
+ // result.ShouldNotBeNull();
+
+ // //保存导出文件到服务器存成二进制
+ // await _excelImportService.SaveBlobAsync(
+ // new SaveExcelImportInputDto
+ // {
+ // Name = _fileName,
+ // Content = result
+ // }
+ // );
+ // return _fileName;
+ //}
+ #endregion
+
}
diff --git a/code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs b/code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs
index 5c13fabf..8efe2992 100644
--- a/code/src/Modules/SettleAccount/src/SettleAccount.Application/ImportExcelCommon/ExportImporter.cs
+++ b/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”的标注文件到目标位置
@@ -609,4 +604,4 @@ public class ExcelImportResult
/// 返回错误信息
///
public string errMessage { get; set; }
-}
\ No newline at end of file
+}