Browse Source

Merge branch 'master-mahao'

master
mahao 1 year ago
parent
commit
efdc91f58f
  1. 18
      code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Properties/launchSettings.json
  2. 9
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomExportDto.cs
  3. 18
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomRequestDto.cs
  4. 23
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Controls/CentralizedControlDtoBase.cs
  5. 80
      code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Materials/MaterialDtoBase.cs
  6. 8
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CurdBaseAppService.cs
  7. 634
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Boms/BomAppService.cs
  8. 533
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Controls/CentralizedControlAppService.cs
  9. 870
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Materials/MaterialAppService.cs
  10. 13
      code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs

18
code/src/Modules/SettleAccount/host/SettleAccount.HttpApi.Host/Properties/launchSettings.json

@ -1,28 +1,12 @@
{ {
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "https://localhost:44378",
"sslPort": 44378
}
},
"profiles": { "profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"SettleAccount.DemoApp": { "SettleAccount.DemoApp": {
"commandName": "Project", "commandName": "Project",
"launchBrowser": true, "launchBrowser": true,
"environmentVariables": { "environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
}, },
"dotnetRunMessages": "true", "applicationUrl": "http://localhost:44379"
"applicationUrl": "http://localhost:44378"
}, },
"Docker": { "Docker": {
"commandName": "Docker", "commandName": "Docker",

9
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomExportDto.cs

@ -1,16 +1,7 @@
using Magicodes.ExporterAndImporter.Core; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core.Filters;
using Magicodes.ExporterAndImporter.Core.Models;
using Magicodes.ExporterAndImporter.Excel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Win.Sfs.SettleAccount.Entities.Boms namespace Win.Sfs.SettleAccount.Entities.Boms
{ {
public class BomExportDto public class BomExportDto
{ {

18
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Boms/BomRequestDto.cs

@ -1,23 +1,9 @@
// 闻荫智慧工厂管理套件 using Win.Sfs.Shared.DtoBase;
// Copyright (c) 闻荫科技 www.ccwin-in.com
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Win.Sfs.Shared;
using Win.Sfs.Shared.DtoBase;
namespace Win.Sfs.SettleAccount.Boms namespace Win.Sfs.SettleAccount.Boms
{ {
public class BomRequestDto : RequestDtoBase,IBranch<Guid> public class BomRequestDto : RequestDtoBase
{ {
public Guid ParentId { set; get; }
public Guid BranchId { get; set; }
public virtual Guid UserId { get; set; }
public virtual int FileType { get; set; }
} }
} }

23
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Controls/CentralizedControlDtoBase.cs

@ -44,29 +44,12 @@ namespace Win.Sfs.SettleAccount.Entities.Controls
public virtual string Remark { set; get; } public virtual string Remark { set; get; }
} }
public class CentralizedControlRequestDto : RequestDtoBase, IBranch<Guid>
{
///年度
/// </summary>
public string Year { get; set; }
/// <summary>
/// 期间
/// </summary>
public string Period { set; get; }
/// <summary>
/// 版本
/// </summary>
public string Version { set; get; }
public class CentralizedControlRequestDto : RequestDtoBase
{
/// <summary>
/// 是否开放状态
/// </summary>
public int State { set; get; }
public Guid BranchId { get; set ; }
} }
public class CentralizedControlDto : AuditedEntityDtoBase<Guid>, IBranch<Guid> public class CentralizedControlDto : AuditedEntityDtoBase<Guid>, IBranch<Guid>
{ {
/// </summary> /// </summary>

80
code/src/Modules/SettleAccount/src/SettleAccount.Application.Contracts/Entities/Materials/MaterialDtoBase.cs

@ -270,39 +270,12 @@ namespace Win.Sfs.SettleAccount.Entities.Materials
{ {
} }
public class MaterialRequestDto : RequestDtoBase, IBranch<Guid>
public class MaterialRequestDto : RequestDtoBase
{ {
/// <summary>
///工厂
/// </summary>
public virtual string Factory { set; get; }
/// <summary>
/// 物料编码
/// </summary>
public virtual string MaterialCode { set; get; }
/// <summary>
///物料描述
/// </summary>
public virtual string MaterialDesc
{
set; get;
}
/// <summary>
/// 基础单位
/// </summary>
public virtual string Unit { set; get; }
/// <summary>
/// 估价类
/// </summary>
public virtual string EstimateType { set; get; }
/// <summary>
/// 估价类描述
/// </summary>
public virtual string EstimateTypeDesc { set; get; }
public Guid BranchId { get ; set ; }
public Guid UserId { get; set; }
} }
public class MaterialDto : AuditedEntityDtoBase<Guid>, IBranch<Guid> public class MaterialDto : AuditedEntityDtoBase<Guid>, IBranch<Guid>
{ {
/// <summary> /// <summary>
@ -387,55 +360,38 @@ namespace Win.Sfs.SettleAccount.Entities.Materials
public virtual string EstimateTypeDesc { set; get; } public virtual string EstimateTypeDesc { set; get; }
} }
public class MaterialExportDto public class MaterialExportDto
{ {
///// <summary>
/////工厂
///// </summary>
//[ExporterHeader(DisplayName = "工厂")]
//public virtual string Factory { set; get; }
/// <summary> /// <summary>
/// 物料编码(物料号) /// 客户物料号
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "ERP物料号")] [ExporterHeader(DisplayName = "客户物料号")]
public string CustomerPartCode { set; get; }
/// <summary>
/// 厂内物料号
/// </summary>
[ExporterHeader(DisplayName = "厂内物料号")]
public string MaterialCode { set; get; }
public virtual string MaterialCode { set; get; }
/// <summary> /// <summary>
///物料描述 /// 物料描述
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "ERP物料描述")] [ExporterHeader(DisplayName = "物料描述")]
public string MaterialDesc { set; get; }
public virtual string MaterialDesc
{
set; get;
}
/// <summary> /// <summary>
/// 基础计量单位 /// 基础计量单位
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "基本计量单位")] [ExporterHeader(DisplayName = "基本计量单位")]
public string Unit { set; get; }
public virtual string Unit { set; get; }
/// <summary> /// <summary>
/// 估价类 /// 产品类型
/// </summary> /// </summary>
[ExporterHeader(DisplayName = "产品类型")] [ExporterHeader(DisplayName = "产品类型")]
public string EstimateType { set; get; }
public virtual string EstimateType { set; get; }
///// <summary>
///// 估价类描述
///// </summary>
//[ExporterHeader(DisplayName = "估价类描述")]
//public virtual string EstimateTypeDesc { set; get; }
////public Guid BranchId { get; set; }
} }
} }

8
code/src/Modules/SettleAccount/src/SettleAccount.Application/Bases/CurdBaseAppService.cs

@ -1,5 +1,4 @@
using Castle.Core.Internal; using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Csv; using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Excel; using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
@ -8,7 +7,6 @@ using Shouldly;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
@ -16,8 +14,6 @@ using Volo.Abp.Application.Services;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Bases namespace Win.Sfs.SettleAccount.Bases
@ -109,7 +105,7 @@ namespace Win.Sfs.SettleAccount.Bases
{ {
var entity = ObjectMapper.Map<TCreateInput, TEntity>(input); var entity = ObjectMapper.Map<TCreateInput, TEntity>(input);
await _repository.InsertAsync(entity, autoSave: true).ConfigureAwait(continueOnCapturedContext: false); await _repository.InsertAsync(entity, autoSave: true).ConfigureAwait(continueOnCapturedContext: false);
return ObjectMapper.Map<TEntity, TEntityDto > (entity); return ObjectMapper.Map<TEntity, TEntityDto>(entity);
} }
/// <summary> /// <summary>

634
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Boms/BomAppService.cs

@ -1,6 +1,3 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
@ -29,216 +26,89 @@ using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.CommonManagers; using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.Boms; using Win.Sfs.SettleAccount.Entities.Boms;
using Win.Sfs.SettleAccount.Entities.Controls;
using Win.Sfs.SettleAccount.Entities.ImportMap; using Win.Sfs.SettleAccount.Entities.ImportMap;
using Win.Sfs.SettleAccount.Entities.Materials; using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.Shared.CacheBase; using Win.Sfs.Shared.CacheBase;
using Win.Sfs.Shared.Filter; using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase;
using Win.Utils; using Win.Utils;
namespace Win.Sfs.SettleAccount.Boms namespace Win.Sfs.SettleAccount.Boms
{ {
/// <summary> /// <summary>
/// 区域相关应用服务 /// BOM
/// </summary> /// </summary>
[Authorize(SettleAccountPermissions.Boms.Default)] //[Authorize(SettleAccountPermissions.Boms.Default)]
//[AllowAnonymous] [AllowAnonymous]
[Route("api/settleaccount/bom")] [Route("api/settleaccount/bom")]
public class BomAppService : SettleAccountApplicationBase<Bom>, IBomAppService public class BomAppService : SettleAccountApplicationBase<Bom>
{ {
/// <summary>
/// BOM仓储
/// </summary>
private readonly INormalEfCoreRepository<Bom, Guid> _repository;
private readonly IGuidGenerator _guidGenerator; private readonly IGuidGenerator _guidGenerator;
private readonly IObjectMapper _objectMapper; private readonly IObjectMapper _objectMapper;
private readonly IExcelImportAppService _excelImportService; private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<Bom, Guid> _repository;
private readonly ISettleAccountBranchEfCoreRepository<Material, Guid> _materialRepository; private readonly ISettleAccountBranchEfCoreRepository<Material, Guid> _materialRepository;
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _importColumnMapRepository; private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _importColumnMapRepository;
private readonly ISettleAccountBranchEfCoreRepository<BomVersion, Guid> _versionRepository; private readonly ISettleAccountBranchEfCoreRepository<BomVersion, Guid> _versionRepository;
/// <summary> /// <summary>
/// 构方法 /// 构方法
/// </summary> /// </summary>
/// <param name="guidGenerator">构建UID</param> public BomAppService(
/// <param name="objectMapper">自动map</param> INormalEfCoreRepository<Bom, Guid> repository,
/// <param name="repository">仓储接口</param> IGuidGenerator guidGenerator,
/// <param name="cache">缓存</param>
public BomAppService(IGuidGenerator guidGenerator,
IObjectMapper objectMapper, IObjectMapper objectMapper,
IExcelImportAppService excelImportService, IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator, ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager, ICommonManager commonManager,
ISettleAccountBranchEfCoreRepository<Bom, Guid> repository,
ISettleAccountBranchEfCoreRepository<BomVersion, Guid> versionRepository, ISettleAccountBranchEfCoreRepository<BomVersion, Guid> versionRepository,
ISettleAccountBranchEfCoreRepository<Material, Guid> materialRepository, ISettleAccountBranchEfCoreRepository<Material, Guid> materialRepository,
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> importColumnMapRepository, ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> importColumnMapRepository,
IDistributedCache<Bom> cache IDistributedCache<Bom> cache
) : base(cache,excelImportService,snowflakeIdGenerator,commonManager) ) : base(cache,excelImportService,snowflakeIdGenerator,commonManager)
{ {
_repository = repository;
_guidGenerator = guidGenerator; _guidGenerator = guidGenerator;
_objectMapper = objectMapper; _objectMapper = objectMapper;
_repository = repository;
_excelImportService = excelImportService; _excelImportService = excelImportService;
_versionRepository = versionRepository; _versionRepository = versionRepository;
_materialRepository = materialRepository; _materialRepository = materialRepository;
_importColumnMapRepository = importColumnMapRepository; _importColumnMapRepository = importColumnMapRepository;
} }
#region 导入导出功能 #region 导入、导出
/// <summary>
/// 导入功能
/// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
[HttpPost]
[Route("ExcelImport-Map")]
[DisableRequestSizeLimit]
[Authorize(SettleAccountPermissions.Boms.Create)]
public async Task<string> BomUploadExcelImportMap([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode, string factory)
{
var _mapList=_importColumnMapRepository.Where(p => p.ProjectName ==SettleAccountModuleName.Bom ).ToList();
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExtendExcelImport<ImportBomDto>(files, _excelImportService,_mapList);
var entityList = ObjectMapper.Map<List<ImportBomDto>, List<Bom>>(result);
var _versionQuery = _versionRepository.Where(p => p.Version == version && p.Factory == factory);
await _versionQuery.BatchDeleteAsync();
var _query = _repository.Where(p => p.Version == version && p.Factory == factory);
await _query.BatchDeleteAsync();
var checkList = new List<ErrorExportDto>();
var _matList = await _materialRepository.GetAllAsync(GuidGenerator.Create());
var _group = entityList.GroupBy(x => new { x.ParentItemCode, x.ChildItemCode, x.Version }).Select(p => new { Count = p.Count(), ParentItmeCode = p.Key.ParentItemCode, ChildItemCode = p.Key.ChildItemCode });
foreach (var itm in _group)
{
if (itm.Count > 1)
{
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("不能导入父编码{0},子编码{1}有重复数据", itm.ParentItmeCode, itm.ChildItemCode), string.Empty));
}
}
var _id = GuidGenerator.Create();
var _bomList = new List<BomVersion>();
_bomList.Add(new BomVersion(_id, branchId, year, period, version, customerCode, factory));
foreach (var itm in entityList)
{
if (!_matList.Any(p => p.MaterialCode == itm.ParentItemCode))
{
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("物料主数据不存在物料号{0}!", itm.ParentItemCode), string.Empty));
continue;
}
itm.SetValue(GuidGenerator.Create(), branchId, year, period, version, _id, factory);
}
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
await _repository.GetDbContext().BulkInsertAsync<Bom>(entityList);
await _versionRepository.GetDbContext().BulkInsertAsync(_bomList);
//st.Stop();
return ApplicationConsts.SuccessStr;
}
/// <summary> /// <summary>
/// 导入功能 /// 导出
/// </summary> /// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
[HttpPost]
[Route("ExcelImport")]
[DisableRequestSizeLimit]
[Authorize(SettleAccountPermissions.Boms.Create)]
public async Task<string> BomUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode,string factory)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<ImportBomDto>(files, _excelImportService);
var entityList = ObjectMapper.Map<List<ImportBomDto>, List<Bom>>(result);
var _versionQuery = _versionRepository.Where(p => p.Version == version && p.Factory==factory );
await _versionQuery.BatchDeleteAsync();
var _query = _repository.Where(p => p.Version == version && p.Factory == factory);
await _query.BatchDeleteAsync();
var checkList = new List<ErrorExportDto>();
var _matList =await _materialRepository.GetAllAsync(GuidGenerator.Create());
var _group = entityList.GroupBy(x => new { x.ParentItemCode, x.ChildItemCode, x.Version }).Select(p => new { Count = p.Count(),ParentItmeCode=p.Key.ParentItemCode, ChildItemCode=p.Key.ChildItemCode });
foreach (var itm in _group)
{
if (itm.Count > 1)
{
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("不能导入父编码{0},子编码{1}有重复数据", itm.ParentItmeCode, itm.ChildItemCode), string.Empty));
}
}
var _id = GuidGenerator.Create();
var _bomList = new List<BomVersion>();
_bomList.Add(new BomVersion(_id, branchId, year, period, version, customerCode,factory));
foreach (var itm in entityList)
{
if (!_matList.Any(p => p.MaterialCode == itm.ParentItemCode))
{
checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("物料主数据不存在物料号{0}!", itm.ParentItemCode), string.Empty));
continue;
}
itm.SetValue(GuidGenerator.Create(),branchId,year,period,version,_id,factory);
}
if (checkList.Count > 0)
{
return await ExportErrorReportAsync(checkList);
}
await _repository.GetDbContext().BulkInsertAsync<Bom>(entityList);
await _versionRepository.GetDbContext().BulkInsertAsync(_bomList);
//st.Stop();
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 导出文件
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost] [HttpPost]
[Route("Export")] [Route("Export")]
[Authorize(SettleAccountPermissions.Boms.Default)] public virtual async Task<string> ExportAsync(BomRequestDto input)
virtual public async Task<string> ExportAsync(BomRequestDto input)
{ {
IExporter _csv = new CsvExporter(); string _fileName = string.Format("BOM_{0}.xlsx", DateTime.Now.ToString("yyyyMMdd"));
IExporter _excel = new ExcelExporter(); var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue,
//导出加上版本过滤条件,不能全导出
if (input.ParentId != Guid.Empty)
{
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() });
}
//else
//{
// return new PagedResultDto<BomDto>(0, new List<BomDto>());
//}
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue,
0, true); 0, true);
var dtoDetails = ObjectMapper.Map<List<Bom>, List<BomExportDto>>(entities); var dtoDetails = ObjectMapper.Map<List<Bom>, List<BomExportDto> >(entities);
string _fileName = string.Empty;
//声明导出容器 //声明导出容器
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtoDetails);
byte[] result = null;
switch (input.FileType)
{
case 0:
_fileName = string.Format("产品结构_{0}.csv", input.UserId.ToString());
result = await _csv.ExportAsByteArray(dtoDetails);
break;
case 1:
_fileName = string.Format("产品结构_{0}.xlsx", input.UserId.ToString());
result = await _excel.ExportAsByteArray(dtoDetails);
break;
}
result.ShouldNotBeNull(); result.ShouldNotBeNull();
//保存导出文件到服务器存成二进制 //保存导出文件到服务器存成二进制
@ -253,147 +123,327 @@ namespace Win.Sfs.SettleAccount.Boms
} }
#endregion #endregion
#region CURD
/// <summary> /// <summary>
/// 按ID获取唯一实体 /// 获取列表
/// </summary>
/// <remarks>
/// 返回实体全部属性
/// </remarks>
/// <param name="id">ID</param>
/// <returns>实体DTO</returns>
[HttpGet]
[Route("{id}")]
[Authorize(SettleAccountPermissions.Boms.Default)]
virtual public async Task<BomDto> GetAsync(Guid id)
{
var result = await _repository.GetAsync(id);
var dto = _objectMapper.Map<Bom, BomDto>(result);
return dto;
}
private async Task<Bom> GetFromCacheAsync(Guid id)
{
var result = await _repository.GetAsync(id);
return result;
}
private async Task<long> GetCountAsync(BomRequestDto input)
{
return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters);
}
private async Task<long> GetCountAsync(BomVersionRequestDto input)
{
return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters);
}
/// <summary>
/// 获取实体总数
/// </summary>
/// <returns>实体总数</returns>
[HttpGet]
[Route("count")]
[Authorize(SettleAccountPermissions.Boms.Default)]
virtual public async Task<long> GetTotalCountAsync(Guid branchId)
{
return await _repository.GetCountAsync(branchId);
}
/// <summary>
/// 删除实体
/// </summary>
/// <param name="id">ID</param>
/// <returns>无</returns>
[HttpDelete]
[Route("{id}")]
[Authorize(SettleAccountPermissions.Boms.Delete)]
virtual public async Task DeleteAsync(Guid id)
{
//var entity = await GetFromCacheAsync(id);
//await Cache.DeleteAsync<Bom>(id.ToString());
await _repository.DeleteAsync(id);
}
/// <summary>
/// 按IDs删除实体列表
/// </summary> /// </summary>
/// <param name="ids">IDs</param>
/// <returns>是否执行成功</returns>
[HttpPost]
[Route("delete")]
[Authorize(SettleAccountPermissions.Boms.Delete)]
virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
{
//foreach (var id in ids)
//{
// var entity = await GetFromCacheAsync(id);
//}
return await _repository.DeleteListAsync(ids);
}
///// <summary>
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost] [HttpPost]
[Route("list")] [Route("list")]
[Authorize(SettleAccountPermissions.Boms.Default)] public async Task<PagedResultDto<BomDto>> GetListAsync(BomRequestDto input)
public async Task<PagedResultDto<BomDto>> GetListAsync(Guid parentId, BomRequestDto input)
{ {
if (input.ParentId != Guid.Empty) var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true);
{ var totalCount = await _repository.GetCountByFilterAsync(input.Filters);
input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() }); var dtos = ObjectMapper.Map<List<Bom>, List<BomDto>>(entities);
}
else
{
return new PagedResultDto<BomDto>(0,new List<BomDto>());
}
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<Bom>, List<BomDto>>(entities);
return new PagedResultDto<BomDto>(totalCount, dtos); return new PagedResultDto<BomDto>(totalCount, dtos);
} }
#endregion
///// <summary> #region 原方法(废弃)
// #region 导入导出功能
// /// <summary>
// /// 导入功能
// /// </summary>
// /// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
// /// <returns></returns>
// [HttpPost]
// [Route("ExcelImport-Map")]
// [DisableRequestSizeLimit]
// [Authorize(SettleAccountPermissions.Boms.Create)]
// public async Task<string> BomUploadExcelImportMap([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode, string factory)
// {
// var _mapList=_importColumnMapRepository.Where(p => p.ProjectName ==SettleAccountModuleName.Bom ).ToList();
// ExportImporter _exportImporter = new ExportImporter();
// var result = await _exportImporter.ExtendExcelImport<ImportBomDto>(files, _excelImportService,_mapList);
// var entityList = ObjectMapper.Map<List<ImportBomDto>, List<Bom>>(result);
// var _versionQuery = _versionRepository.Where(p => p.Version == version && p.Factory == factory);
// await _versionQuery.BatchDeleteAsync();
// var _query = _repository.Where(p => p.Version == version && p.Factory == factory);
// await _query.BatchDeleteAsync();
// var checkList = new List<ErrorExportDto>();
// var _matList = await _materialRepository.GetAllAsync(GuidGenerator.Create());
// var _group = entityList.GroupBy(x => new { x.ParentItemCode, x.ChildItemCode, x.Version }).Select(p => new { Count = p.Count(), ParentItmeCode = p.Key.ParentItemCode, ChildItemCode = p.Key.ChildItemCode });
// foreach (var itm in _group)
// {
// if (itm.Count > 1)
// {
// checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("不能导入父编码{0},子编码{1}有重复数据", itm.ParentItmeCode, itm.ChildItemCode), string.Empty));
// }
// }
// var _id = GuidGenerator.Create();
// var _bomList = new List<BomVersion>();
// _bomList.Add(new BomVersion(_id, branchId, year, period, version, customerCode, factory));
// foreach (var itm in entityList)
// {
// if (!_matList.Any(p => p.MaterialCode == itm.ParentItemCode))
// {
// checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("物料主数据不存在物料号{0}!", itm.ParentItemCode), string.Empty));
// continue;
// }
// itm.SetValue(GuidGenerator.Create(), branchId, year, period, version, _id, factory);
// }
// if (checkList.Count > 0)
// {
// return await ExportErrorReportAsync(checkList);
// }
// await _repository.GetDbContext().BulkInsertAsync<Bom>(entityList);
// await _versionRepository.GetDbContext().BulkInsertAsync(_bomList);
// //st.Stop();
// return ApplicationConsts.SuccessStr;
// }
// /// <summary>
// /// 导入功能
// /// </summary>
// /// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
// /// <returns></returns>
// [HttpPost]
// [Route("ExcelImport")]
// [DisableRequestSizeLimit]
// [Authorize(SettleAccountPermissions.Boms.Create)]
// public async Task<string> BomUploadExcelImport([FromForm] IFormFileCollection files, Guid branchId, string year, string period, string version, string customerCode,string factory)
// {
// ExportImporter _exportImporter = new ExportImporter();
// var result = await _exportImporter.UploadExcelImport<ImportBomDto>(files, _excelImportService);
// var entityList = ObjectMapper.Map<List<ImportBomDto>, List<Bom>>(result);
// var _versionQuery = _versionRepository.Where(p => p.Version == version && p.Factory==factory );
// await _versionQuery.BatchDeleteAsync();
// var _query = _repository.Where(p => p.Version == version && p.Factory == factory);
// await _query.BatchDeleteAsync();
// var checkList = new List<ErrorExportDto>();
// var _matList =await _materialRepository.GetAllAsync(GuidGenerator.Create());
// var _group = entityList.GroupBy(x => new { x.ParentItemCode, x.ChildItemCode, x.Version }).Select(p => new { Count = p.Count(),ParentItmeCode=p.Key.ParentItemCode, ChildItemCode=p.Key.ChildItemCode });
// foreach (var itm in _group)
// {
// if (itm.Count > 1)
// {
// checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("不能导入父编码{0},子编码{1}有重复数据", itm.ParentItmeCode, itm.ChildItemCode), string.Empty));
// }
// }
// var _id = GuidGenerator.Create();
// var _bomList = new List<BomVersion>();
// _bomList.Add(new BomVersion(_id, branchId, year, period, version, customerCode,factory));
// foreach (var itm in entityList)
// {
// if (!_matList.Any(p => p.MaterialCode == itm.ParentItemCode))
// {
// checkList.Add(new ErrorExportDto(version, customerCode, string.Empty, string.Empty, itm.ParentItemCode, string.Empty, string.Format("物料主数据不存在物料号{0}!", itm.ParentItemCode), string.Empty));
// continue;
// }
// itm.SetValue(GuidGenerator.Create(),branchId,year,period,version,_id,factory);
// }
// if (checkList.Count > 0)
// {
// return await ExportErrorReportAsync(checkList);
// }
// await _repository.GetDbContext().BulkInsertAsync<Bom>(entityList);
// await _versionRepository.GetDbContext().BulkInsertAsync(_bomList);
// //st.Stop();
// return ApplicationConsts.SuccessStr;
// }
// /// <summary>
// /// 导出文件
// /// </summary>
// /// <param name="input"></param>
// /// <returns></returns>
// [HttpPost]
// [Route("Export")]
// [Authorize(SettleAccountPermissions.Boms.Default)]
// virtual public async Task<string> ExportAsync(BomRequestDto input)
// {
// IExporter _csv = new CsvExporter();
// IExporter _excel = new ExcelExporter();
// //导出加上版本过滤条件,不能全导出
// if (input.ParentId != Guid.Empty)
// {
// input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() });
// }
// //else
// //{
// // return new PagedResultDto<BomDto>(0, new List<BomDto>());
// //}
// var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue,
// 0, true);
// var dtoDetails = ObjectMapper.Map<List<Bom>, List<BomExportDto>>(entities);
// string _fileName = string.Empty;
// //声明导出容器
// byte[] result = null;
// switch (input.FileType)
// {
// case 0:
// _fileName = string.Format("产品结构_{0}.csv", input.UserId.ToString());
// result = await _csv.ExportAsByteArray(dtoDetails);
// break;
// case 1:
// _fileName = string.Format("产品结构_{0}.xlsx", input.UserId.ToString());
// result = await _excel.ExportAsByteArray(dtoDetails);
// break;
// }
// result.ShouldNotBeNull();
// //保存导出文件到服务器存成二进制
// await _excelImportService.SaveBlobAsync(
// new SaveExcelImportInputDto
// {
// Name = _fileName,
// Content = result
// }
// );
// return _fileName;
// }
// #endregion
// /// <summary>
// /// 按ID获取唯一实体
// /// </summary>
// /// <remarks>
// /// 返回实体全部属性
// /// </remarks>
// /// <param name="id">ID</param>
// /// <returns>实体DTO</returns>
// [HttpGet]
// [Route("{id}")]
//[Authorize(SettleAccountPermissions.Boms.Default)]
// virtual public async Task<BomDto> GetAsync(Guid id)
// {
// var result = await _repository.GetAsync(id);
// var dto = _objectMapper.Map<Bom, BomDto>(result);
// return dto;
// }
// private async Task<Bom> GetFromCacheAsync(Guid id)
// {
// var result = await _repository.GetAsync(id);
// return result;
// }
// private async Task<long> GetCountAsync(BomRequestDto input)
// {
// return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters);
// }
// private async Task<long> GetCountAsync(BomVersionRequestDto input)
// {
// return await _versionRepository.GetCountByFilterAsync(input.BranchId, input.Filters);
// }
// /// <summary>
// /// 获取实体总数
// /// </summary>
// /// <returns>实体总数</returns>
// [HttpGet]
// [Route("count")]
//[Authorize(SettleAccountPermissions.Boms.Default)]
// virtual public async Task<long> GetTotalCountAsync(Guid branchId)
// {
// return await _repository.GetCountAsync(branchId);
// }
// /// <summary>
// /// 删除实体
// /// </summary>
// /// <param name="id">ID</param>
// /// <returns>无</returns>
// [HttpDelete]
// [Route("{id}")]
//[Authorize(SettleAccountPermissions.Boms.Delete)]
// virtual public async Task DeleteAsync(Guid id)
// {
// //var entity = await GetFromCacheAsync(id);
// //await Cache.DeleteAsync<Bom>(id.ToString());
// await _repository.DeleteAsync(id);
// }
// /// <summary>
// /// 按IDs删除实体列表
// /// </summary>
// /// <param name="ids">IDs</param>
// /// <returns>是否执行成功</returns>
// [HttpPost]
// [Route("delete")]
//[Authorize(SettleAccountPermissions.Boms.Delete)]
// virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
// {
// //foreach (var id in ids)
// //{
// // var entity = await GetFromCacheAsync(id);
// //}
// return await _repository.DeleteListAsync(ids);
// }
// ///// <summary>
// /// <summary>
// /// 根据筛选条件获取实体列表
// /// </summary>
// /// <remarks>
// /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
// /// </remarks>
// /// <param name="input">请求条件</param>
// /// <returns>实体DTO列表</returns>
// [HttpPost]
// [Route("list")]
// [Authorize(SettleAccountPermissions.Boms.Default)]
// public async Task<PagedResultDto<BomDto>> GetListAsync(Guid parentId, BomRequestDto input)
// {
// if (input.ParentId != Guid.Empty)
// {
// input.Filters.Add(new FilterCondition() { Action = EnumFilterAction.Equal, Column = "ParentId", Logic = EnumFilterLogic.And, Value = input.ParentId.ToString() });
// }
// else
// {
// return new PagedResultDto<BomDto>(0,new List<BomDto>());
// }
// 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<Bom>, List<BomDto>>(entities);
// return new PagedResultDto<BomDto>(totalCount, dtos);
// }
// ///// <summary>
// /// <summary>
// /// 根据筛选条件获取实体列表
// /// </summary>
// /// <remarks>
// /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
// /// </remarks>
// /// <param name="input">请求条件</param>
// /// <returns>实体DTO列表</returns>
// [HttpPost]
// [Route("listVersion")]
// [Authorize(SettleAccountPermissions.Boms.Default)]
// public async Task<PagedResultDto<BomVersionDto>> GetVersionListAsync(BomVersionRequestDto input)
// {
// var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue,
// input.SkipCount, true);
// var totalCount = await GetCountAsync(input);
// var dtos = _objectMapper.Map<List<BomVersion>, List<BomVersionDto>>(entities);
// //foreach (var itm in dtos)
// //{
// // itm.Version = itm.Version + string.Format("({0})", itm.Factory);
// //}
// return new PagedResultDto<BomVersionDto>(totalCount, dtos);
// }
#endregion
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("listVersion")]
[Authorize(SettleAccountPermissions.Boms.Default)]
public async Task<PagedResultDto<BomVersionDto>> GetVersionListAsync(BomVersionRequestDto input)
{
var entities = await _versionRepository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue,
input.SkipCount, true);
var totalCount = await GetCountAsync(input);
var dtos = _objectMapper.Map<List<BomVersion>, List<BomVersionDto>>(entities);
//foreach (var itm in dtos)
//{
// itm.Version = itm.Version + string.Format("({0})", itm.Factory);
//}
return new PagedResultDto<BomVersionDto>(totalCount, dtos);
}
} }
} }

533
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Controls/CentralizedControlAppService.cs

@ -24,304 +24,349 @@ using Win.Sfs.SettleAccount.CommonManagers;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.CodeSettings; using Win.Sfs.SettleAccount.Entities.CodeSettings;
using Win.Sfs.SettleAccount.Entities.ImportMap; using Win.Sfs.SettleAccount.Entities.ImportMap;
using Win.Sfs.SettleAccount.Entities.Materials;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.Shared.CacheBase; using Win.Sfs.Shared.CacheBase;
using Win.Sfs.Shared.RepositoryBase;
using Win.Utils; using Win.Utils;
namespace Win.Sfs.SettleAccount.Entities.Controls namespace Win.Sfs.SettleAccount.Entities.Controls
{ {
/// <summary> /// <summary>
/// 期间设置 /// 期间设置
/// </summary> /// </summary>
[Authorize(SettleAccountPermissions.CentralizedControls.Default)] //[Authorize(SettleAccountPermissions.CentralizedControls.Default)]
//[AllowAnonymous] [AllowAnonymous]
[Route("api/settleaccount/CentralizedControl")] [Route("api/settleaccount/CentralizedControl")]
public class CentralizedControlAppService : SettleAccountApplicationBase<CentralizedControl>, ICentralizedControlAppService public class CentralizedControlAppService : SettleAccountApplicationBase<CentralizedControl>
{ {
/// <summary>
/// 期间设置仓储
/// </summary>
private readonly INormalEfCoreRepository<CentralizedControl, Guid> _repository;
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository; private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository;
private readonly IExcelImportAppService _excelImportService; private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<CentralizedControl, Guid> _repository;
/// <summary> /// <summary>
/// 构建方法 /// 构建方法
/// </summary> /// </summary>
/// <param name="guidGenerator">构建UID</param> public CentralizedControlAppService(
/// <param name="objectMapper">自动map</param> INormalEfCoreRepository<CentralizedControl, Guid> repository,
/// <param name="repository">仓储接口</param> IGuidGenerator guidGenerator,
/// <param name="cache">缓存</param>
public CentralizedControlAppService(IGuidGenerator guidGenerator,
IObjectMapper objectMapper, IObjectMapper objectMapper,
ISettleAccountBranchEfCoreRepository<CentralizedControl, Guid> repository,
IDistributedCache<CentralizedControl> cache, IDistributedCache<CentralizedControl> cache,
IExcelImportAppService excelImportService, IExcelImportAppService excelImportService,
ISnowflakeIdGenerator snowflakeIdGenerator, ISnowflakeIdGenerator snowflakeIdGenerator,
ICommonManager commonManager ICommonManager commonManager
) : base(cache,excelImportService,snowflakeIdGenerator,commonManager) ) : base(cache, excelImportService, snowflakeIdGenerator, commonManager)
{ {
_repository = repository; _repository = repository;
_excelImportService = excelImportService; _excelImportService = excelImportService;
} }
#region CURD
/// <summary> /// <summary>
/// 导入功能 /// 获取列表
/// </summary> /// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
[HttpPost]
[Route("ExcelImport")]
[DisableRequestSizeLimit]
[Authorize(SettleAccountPermissions.CentralizedControls.Create)]
public async Task<string> CentralizedControlUploadExcelImport([FromForm] IFormFileCollection files,Guid branchId)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<CentralizedControlImportDto>(files, _excelImportService);
var _ls = ObjectMapper.Map<List<CentralizedControlImportDto>, List<CentralizedControl>>(result);
foreach (var itm in _ls)
{
itm.SetValue(GuidGenerator.Create(), branchId);
}
var bulkConfig = new BulkConfig { SetOutputIdentity = true, BatchSize = 10000 };
_repository.GetDbContext().BulkInsert(_ls, bulkConfig);
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 按ID获取唯一实体
/// </summary>
/// <remarks>
/// 返回实体全部属性
/// </remarks>
/// <param name="id">ID</param>
/// <returns>实体DTO</returns>
[HttpGet]
[Route("{id}")]
virtual public async Task<CentralizedControlDto> GetAsync(Guid id)
{
var result = await GetFromCacheAsync(id);
var dto = ObjectMapper.Map<CentralizedControl, CentralizedControlDto>(result);
return dto;
}
private async Task<CentralizedControl> GetFromCacheAsync(Guid id)
{
var result =
await _repository.GetAsync(id);
return result;
}
private async Task<long> GetCountAsync(CentralizedControlRequestDto input)
{
return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters);
}
///// <summary>
/// <summary>
/// 根据筛选条件获取实体列表
/// </summary>
/// <remarks>
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost] [HttpPost]
[Route("list")] [Route("list")]
virtual public async Task<PagedResultDto<CentralizedControlDto>> GetListAsync(CentralizedControlRequestDto input) public async Task<PagedResultDto<CentralizedControlDto>> GetListAsync(CentralizedControlRequestDto input)
{ {
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, input.MaxResultCount, var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount, input.SkipCount, true);
input.SkipCount, true); var totalCount = await _repository.GetCountByFilterAsync(input.Filters);
var totalCount = await GetCountAsync(input);
var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(entities); var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(entities);
return new PagedResultDto<CentralizedControlDto>(totalCount, dtos); return new PagedResultDto<CentralizedControlDto>(totalCount, dtos);
} }
#endregion
#region 开启、关闭
/// <summary>
/// 获取实体总数
/// </summary>
/// <returns>实体总数</returns>
[HttpGet]
[Route("count")]
virtual public async Task<long> GetTotalCountAsync(Guid branchId)
{
return await _repository.GetCountAsync(branchId);
}
/// <summary>
/// 获取全部实体列表
/// </summary>
/// <returns>实体DTO列表</returns>
[HttpGet]
[Route("all")]
virtual public async Task<ListResultDto<CentralizedControlDto>> GetAllAsync(Guid branchId)
{
var entities = await _repository.GetAllAsync(branchId, true);
var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(entities);
return new ListResultDto<CentralizedControlDto>(dtos);
}
/// <summary>
/// 新增实体
/// </summary>
/// <param name="input">新增实体DTO</param>
/// <returns>实体DTO</returns>
[HttpPost]
[Route("")]
[Authorize(SettleAccountPermissions.CentralizedControls.Create)]
virtual public async Task<CentralizedControlDto> CreateAsync(CentralizedControlCreateDto input)
{
var _first= _repository.Where(p => p.Version == input.Version).FirstOrDefault();
if (_first != null)
{
throw new BusinessException("001", "已经存在该期间,不能重复添加!");
}
var entity = new CentralizedControl(
GuidGenerator.Create(),
input.BranchId,
input.Year,
input.Period,
input.Year+input.Period,
input.State
);
await _repository.InsertAsync(entity);
//create cache
//await Cache.SetAsync(entity.Id.ToString(), entity,CacheStrategyConst.FIVE_MINUTES);
var dto = ObjectMapper.Map<CentralizedControl, CentralizedControlDto>(entity);
return dto;
}
/// <summary>
/// 修改实体
/// </summary>
/// <param name="id">ID</param>
/// <param name="input">修改实体DTO</param>
/// <returns>实体DTO</returns>
[HttpPut]
[Route("{id}")]
[Authorize(SettleAccountPermissions.CentralizedControls.Update)]
virtual public async Task<CentralizedControlDto> UpdateAsync(Guid id, CentralizedControlUpdateDto input)
{
var entity = await _repository.GetAsync(id);
entity.Update(input.Remark);
await _repository.UpdateAsync(entity);
//update cache
//await Cache.SetAsync(id.ToString(), entity, CacheStrategyConst.FIVE_MINUTES);
var dto = ObjectMapper.Map<CentralizedControl, CentralizedControlDto>(entity);
return dto;
}
/// <summary>
/// 删除实体
/// </summary>
/// <param name="id">ID</param>
/// <returns>无</returns>
[HttpDelete]
[Route("{id}")]
[Authorize(SettleAccountPermissions.CentralizedControls.Delete)]
virtual public async Task DeleteAsync(Guid id)
{
var entity = await GetFromCacheAsync(id);
await Cache.DeleteAsync<CentralizedControl>(id.ToString());
await _repository.DeleteAsync(id);
}
/// <summary>
/// 按IDs删除实体列表
/// </summary>
/// <param name="ids">IDs</param>
/// <returns>是否执行成功</returns>
[HttpPost]
[Route("delete")]
[Authorize(SettleAccountPermissions.CentralizedControls.Delete)]
virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
{
var _query = _repository.Where(p => ids.Contains(p.Id));
int i = await _query.BatchDeleteAsync();
if (i == 0)
{
return false;
}
return true;
}
[HttpPost] [HttpPost]
[Route("open")] [Route("open")]
[Authorize(SettleAccountPermissions.CentralizedControls.Create)]
public async Task<bool> OpenVersion(List<Guid> ids) public async Task<bool> OpenVersion(List<Guid> ids)
{ {
foreach (var id in ids) var entitys = await _repository.GetListAsync(p => ids.Contains(p.Id));
foreach (var entity in entitys)
{ {
var _entity = await _repository.GetAsync(id); entity.OpenVersion();
_entity.OpenVersion();
} }
return true; return true;
} }
[HttpPost] [HttpPost]
[Route("close")] [Route("close")]
[Authorize(SettleAccountPermissions.CentralizedControls.Create)]
/// <summary> /// <summary>
/// 关闭版本 /// 关闭版本
/// </summary> /// </summary>
/// <param name="ids">选择要关闭的ID</param> public async Task<bool> ClosedVersion(List<Guid> ids)
/// <returns></returns>
public async Task<bool> ClosedVersion(List<Guid> ids)
{ {
foreach (var id in ids) var entitys = await _repository.GetListAsync(p => ids.Contains(p.Id));
foreach (var entity in entitys)
{ {
var _entity = await _repository.GetAsync(id); entity.ClosedVersion();
_entity.ClosedVersion();
} }
return true; return true;
} }
[HttpPost] #endregion
[Route("openlist")]
/// <summary> #region 原方法(废弃)
/// 获得开放的版本列表 // /// <summary>
/// </summary> // /// 导入功能
/// <returns></returns> // /// </summary>
public async Task<List<CentralizedControlDto>> GetOpenVersionList() // /// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
{ // /// <returns></returns>
var _list = await _repository.Where(p => p.State == 0).ToListAsync(); // [HttpPost]
// [Route("ExcelImport")]
var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(_list); // [DisableRequestSizeLimit]
// [Authorize(SettleAccountPermissions.CentralizedControls.Create)]
return dtos; // public async Task<string> CentralizedControlUploadExcelImport([FromForm] IFormFileCollection files,Guid branchId)
} // {
// ExportImporter _exportImporter = new ExportImporter();
// var result = await _exportImporter.UploadExcelImport<CentralizedControlImportDto>(files, _excelImportService);
// var _ls = ObjectMapper.Map<List<CentralizedControlImportDto>, List<CentralizedControl>>(result);
// foreach (var itm in _ls)
// {
// itm.SetValue(GuidGenerator.Create(), branchId);
// }
// var bulkConfig = new BulkConfig { SetOutputIdentity = true, BatchSize = 10000 };
// _repository.GetDbContext().BulkInsert(_ls, bulkConfig);
// return ApplicationConsts.SuccessStr;
// }
// /// <summary>
// /// 按ID获取唯一实体
// /// </summary>
// /// <remarks>
// /// 返回实体全部属性
// /// </remarks>
// /// <param name="id">ID</param>
// /// <returns>实体DTO</returns>
// [HttpGet]
// [Route("{id}")]
// virtual public async Task<CentralizedControlDto> GetAsync(Guid id)
// {
// var result = await GetFromCacheAsync(id);
// var dto = ObjectMapper.Map<CentralizedControl, CentralizedControlDto>(result);
// return dto;
// }
// private async Task<CentralizedControl> GetFromCacheAsync(Guid id)
// {
// var result =
// await _repository.GetAsync(id);
// return result;
// }
// private async Task<long> GetCountAsync(CentralizedControlRequestDto input)
// {
// return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters);
// }
// ///// <summary>
// /// <summary>
// /// 根据筛选条件获取实体列表
// /// </summary>
// /// <remarks>
// /// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
// /// </remarks>
// /// <param name="input">请求条件</param>
// /// <returns>实体DTO列表</returns>
// [HttpPost]
// [Route("list")]
// virtual public async Task<PagedResultDto<CentralizedControlDto>> GetListAsync(CentralizedControlRequestDto 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<CentralizedControl>, List<CentralizedControlDto>>(entities);
// return new PagedResultDto<CentralizedControlDto>(totalCount, dtos);
// }
// /// <summary>
// /// 获取实体总数
// /// </summary>
// /// <returns>实体总数</returns>
// [HttpGet]
// [Route("count")]
// virtual public async Task<long> GetTotalCountAsync(Guid branchId)
// {
// return await _repository.GetCountAsync(branchId);
// }
// /// <summary>
// /// 获取全部实体列表
// /// </summary>
// /// <returns>实体DTO列表</returns>
// [HttpGet]
// [Route("all")]
// virtual public async Task<ListResultDto<CentralizedControlDto>> GetAllAsync(Guid branchId)
// {
// var entities = await _repository.GetAllAsync(branchId, true);
// var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(entities);
// return new ListResultDto<CentralizedControlDto>(dtos);
// }
// /// <summary>
// /// 新增实体
// /// </summary>
// /// <param name="input">新增实体DTO</param>
// /// <returns>实体DTO</returns>
// [HttpPost]
// [Route("")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Create)]
// virtual public async Task<CentralizedControlDto> CreateAsync(CentralizedControlCreateDto input)
// {
// var _first= _repository.Where(p => p.Version == input.Version).FirstOrDefault();
// if (_first != null)
// {
// throw new BusinessException("001", "已经存在该期间,不能重复添加!");
// }
// var entity = new CentralizedControl(
// GuidGenerator.Create(),
// input.BranchId,
// input.Year,
// input.Period,
// input.Year+input.Period,
// input.State
// );
// await _repository.InsertAsync(entity);
// //create cache
// //await Cache.SetAsync(entity.Id.ToString(), entity,CacheStrategyConst.FIVE_MINUTES);
// var dto = ObjectMapper.Map<CentralizedControl, CentralizedControlDto>(entity);
// return dto;
// }
// /// <summary>
// /// 修改实体
// /// </summary>
// /// <param name="id">ID</param>
// /// <param name="input">修改实体DTO</param>
// /// <returns>实体DTO</returns>
// [HttpPut]
// [Route("{id}")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Update)]
// virtual public async Task<CentralizedControlDto> UpdateAsync(Guid id, CentralizedControlUpdateDto input)
// {
// var entity = await _repository.GetAsync(id);
// entity.Update(input.Remark);
// await _repository.UpdateAsync(entity);
// //update cache
// //await Cache.SetAsync(id.ToString(), entity, CacheStrategyConst.FIVE_MINUTES);
// var dto = ObjectMapper.Map<CentralizedControl, CentralizedControlDto>(entity);
// return dto;
// }
// /// <summary>
// /// 删除实体
// /// </summary>
// /// <param name="id">ID</param>
// /// <returns>无</returns>
// [HttpDelete]
// [Route("{id}")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Delete)]
// virtual public async Task DeleteAsync(Guid id)
// {
// var entity = await GetFromCacheAsync(id);
// await Cache.DeleteAsync<CentralizedControl>(id.ToString());
// await _repository.DeleteAsync(id);
// }
// /// <summary>
// /// 按IDs删除实体列表
// /// </summary>
// /// <param name="ids">IDs</param>
// /// <returns>是否执行成功</returns>
// [HttpPost]
// [Route("delete")]
//[Authorize(SettleAccountPermissions.CentralizedControls.Delete)]
// virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
// {
// var _query = _repository.Where(p => ids.Contains(p.Id));
// int i = await _query.BatchDeleteAsync();
// if (i == 0)
// {
// return false;
// }
// return true;
// }
// [HttpPost]
// [Route("open")]
// [Authorize(SettleAccountPermissions.CentralizedControls.Create)]
// public async Task<bool> OpenVersion(List<Guid> ids)
// {
// foreach (var id in ids)
// {
// var _entity = await _repository.GetAsync(id);
// _entity.OpenVersion();
// }
// return true;
// }
// [HttpPost]
// [Route("close")]
// [Authorize(SettleAccountPermissions.CentralizedControls.Create)]
// /// <summary>
// /// 关闭版本
// /// </summary>
// /// <param name="ids">选择要关闭的ID</param>
// /// <returns></returns>
// public async Task<bool> ClosedVersion(List<Guid> ids)
// {
// foreach (var id in ids)
// {
// var _entity = await _repository.GetAsync(id);
// _entity.ClosedVersion();
// }
// return true;
// }
// [HttpPost]
// [Route("openlist")]
// /// <summary>
// /// 获得开放的版本列表
// /// </summary>
// /// <returns></returns>
// public async Task<List<CentralizedControlDto>> GetOpenVersionList()
// {
// var _list = await _repository.Where(p => p.State == 0).ToListAsync();
// var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(_list);
// return dtos;
// }
#endregion
} }

870
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Materials/MaterialAppService.cs

@ -1,25 +1,13 @@
using System; using Microsoft.AspNetCore.Authorization;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using EFCore.BulkExtensions;
using Magicodes.ExporterAndImporter.Core;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Distributed; using Microsoft.EntityFrameworkCore;
using Shouldly; using Shouldly;
using Volo.Abp; using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.Caching; using Volo.Abp.Caching;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Guids;
using Volo.Abp.ObjectMapping;
using Volo.Abp.Uow;
using Win.Abp.Snowflakes; using Win.Abp.Snowflakes;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Boms; using Win.Sfs.SettleAccount.Boms;
@ -31,41 +19,34 @@ using Win.Sfs.SettleAccount.Entities.Prices;
using Win.Sfs.SettleAccount.Entities.TaskJobs; using Win.Sfs.SettleAccount.Entities.TaskJobs;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.ExportReports; using Win.Sfs.SettleAccount.ExportReports;
using Win.Sfs.SettleAccount.MaterialRelationships; using Win.Sfs.SettleAccount.MaterialRelationships;
using Win.Sfs.Shared.CacheBase; using Win.Sfs.Shared.RepositoryBase;
using Win.Utils;
namespace Win.Sfs.SettleAccount.Entities.Materials namespace Win.Sfs.SettleAccount.Entities.Materials
{ {
/// <summary> /// <summary>
/// 物料主数据应用服务 /// 物料主数据
/// </summary> /// </summary>
[Authorize(SettleAccountPermissions.Materials.Default)] //[Authorize(SettleAccountPermissions.Materials.Default)]
//[AllowAnonymous] [AllowAnonymous]
[Route("api/settleaccount/Material")] [Route("api/settleaccount/Material")]
public class MaterialAppService : SettleAccountApplicationBase<Material>, IMaterialAppService public class MaterialAppService : SettleAccountApplicationBase<Material>
{ {
private readonly IExcelImportAppService _excelImportService; private readonly IExcelImportAppService _excelImportService;
private readonly ISettleAccountBranchEfCoreRepository<Material, Guid> _repository; private readonly INormalEfCoreRepository<Material, Guid> _repository;
private readonly ISettleAccountBranchEfCoreRepository<Bom, Guid> _bomRepository; private readonly ISettleAccountBranchEfCoreRepository<Bom, Guid> _bomRepository;
private readonly ISettleAccountBranchEfCoreRepository<BomVersion, Guid> _bomversionRepository; private readonly ISettleAccountBranchEfCoreRepository<BomVersion, Guid> _bomversionRepository;
private readonly ISettleAccountBranchEfCoreRepository<PriceList, Guid> _priceRepository; private readonly ISettleAccountBranchEfCoreRepository<PriceList, Guid> _priceRepository;
private readonly ISettleAccountBranchEfCoreRepository<PriceListVersion, Guid> _priceversionRepository; private readonly ISettleAccountBranchEfCoreRepository<PriceListVersion, Guid> _priceversionRepository;
private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository; private readonly ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> _mapRepository;
private readonly ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> _relationshipRepository; private readonly ISettleAccountBranchEfCoreRepository<MaterialRelationship, Guid> _relationshipRepository;
/// <summary> /// <summary>
/// 构建方法 /// 构建方法
/// </summary> /// </summary>
/// <param name="guidGenerator">构建UID</param>
/// <param name="objectMapper">自动map</param>
/// <param name="repository">仓储接口</param>
/// <param name="cache">缓存</param>
public MaterialAppService( public MaterialAppService(
INormalEfCoreRepository<Material, Guid> repository,
ISettleAccountBranchEfCoreRepository<Material, Guid> repository,
ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository, ISettleAccountBranchEfCoreRepository<ImportColumnMap, Guid> mapRepository,
ISettleAccountBranchEfCoreRepository<Bom, Guid> bomRepository, ISettleAccountBranchEfCoreRepository<Bom, Guid> bomRepository,
ISettleAccountBranchEfCoreRepository<BomVersion, Guid> bomversionRepository, ISettleAccountBranchEfCoreRepository<BomVersion, Guid> bomversionRepository,
@ -92,461 +73,512 @@ namespace Win.Sfs.SettleAccount.Entities.Materials
} }
#region 导入、导出
/// <summary> /// <summary>
/// 导入功能 /// 导
/// </summary> /// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
[HttpPost] [HttpPost]
[Route("ExcelImport-TH")] [Route("Export")]
[DisableRequestSizeLimit] //[Authorize(SettleAccountPermissions.Materials.Default)]
[Authorize(SettleAccountPermissions.Materials.Default)] public virtual async Task<string> ExportAsync(MaterialRequestDto input)
public async Task<string> MaterialUploadExcelImportMap([FromForm] IFormFileCollection files,string version)
{ {
string _fileName = string.Format("物料主数据_{0}.xlsx", DateTime.Now.ToString("yyyyMMdd"));
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue,
0, true);
var dtoDetails = ObjectMapper.Map<List<Material>, List<MaterialExportDto>>(entities);
//声明导出容器
ExportImporter _exportImporter = new ExportImporter(); ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExtendExcelImport<MaterialImportDtoTH>(files, _excelImportService);
await UpdateMaterial(result,version); var result = await _exportImporter.ExcelExporter(dtoDetails);
await UpdateBom(result,version);
await UpdatePrice(result,version);
return ApplicationConsts.SuccessStr; result.ShouldNotBeNull();
}
private async Task<List<ErrorExportDto>> UpdateBom(List<MaterialImportDtoTH> result,string version)
{
var _versionQuery = _bomversionRepository.Where(p => p.Version == version );
await _versionQuery.BatchDeleteAsync();
var _query = _bomRepository.Where(p => p.Version == version );
await _query.BatchDeleteAsync();
var entityList = new List<Bom>();
var _ls=result.Where(p=>!string.IsNullOrEmpty(p.ChildMaterialCode) && !string.IsNullOrEmpty(p.MaterialCode)).ToList();
foreach (var itm in _ls)
{
entityList.Add(new Bom(GuidGenerator.Create(),GuidGenerator.Create(),itm.MaterialCode,itm.MaterialDesc,itm.ChildMaterialCode,itm.ChildMaterialDesc,string.Empty,itm.Qty,0,itm.Qty,string.Empty,DateTime.Now,DateTime.Now,string.Empty,0,GuidGenerator.Create(),string.Empty));
}
var checkList = new List<ErrorExportDto>();
var _group = entityList.GroupBy(x => new { x.ParentItemCode, x.ChildItemCode, x.Version }).Select(p => new { Count = p.Count(), ParentItmeCode = p.Key.ParentItemCode, ChildItemCode = p.Key.ChildItemCode });
foreach (var itm in _group)
{
if (itm.Count > 1)
{
checkList.Add(new ErrorExportDto(version, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("不能导入父编码{0},子编码{1}有重复数据", itm.ParentItmeCode, itm.ChildItemCode), string.Empty));
}
}
var _id = GuidGenerator.Create();
var _bomList = new List<BomVersion>();
_bomList.Add(new BomVersion(_id, GuidGenerator.Create(), DateTime.Now.Year.ToString(),DateTime.Now.Month.ToString(), version, string.Empty, string.Empty));
foreach (var itm in entityList)
{
itm.SetValue(GuidGenerator.Create(), GuidGenerator.Create(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString(), version, _id, string.Empty);
}
await _bomRepository.GetDbContext().BulkInsertAsync<Bom>(entityList);
await _bomversionRepository.GetDbContext().BulkInsertAsync(_bomList);
return checkList;
//保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto
{
Name = _fileName,
Content = result
}
);
return _fileName;
} }
#endregion
private async Task<List<ErrorExportDto>> UpdatePrice(List<MaterialImportDtoTH> result,string version) #region CURD
/// <summary>
/// 获取列表
/// </summary>
[HttpPost]
[Route("list")]
//[Authorize(SettleAccountPermissions.Materials.Default)]
virtual public async Task<PagedResultDto<MaterialDto>> GetListAsync(MaterialRequestDto input)
{ {
var checkList = new List<ErrorExportDto>(); var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, input.MaxResultCount,
var _priceversion= _priceversionRepository.Where(p => p.Version == version); input.SkipCount, true);
await _priceversion.BatchDeleteAsync(); var totalCount = await _repository.GetCountByFilterAsync(input.Filters);
var _prices=_priceRepository.Where(p => p.Version == version); var dtos = ObjectMapper.Map<List<Material>, List<MaterialDto>>(entities);
await _prices.BatchDeleteAsync(); return new PagedResultDto<MaterialDto>(totalCount, dtos);
var _materialList = result.Where(p => !string.IsNullOrEmpty(p.MaterialCode)).Select(p => p.MaterialCode).Distinct().ToList();
_materialList.Remove("xxbmr016.p b+");
_materialList.Remove(null);
_materialList.Remove("END OF REPORT");
_materialList.Remove("Report Attributes (see Comment)");
_materialList.Remove("Report Criteria (see Comment)");
var _partList = result.Where(p => !string.IsNullOrEmpty(p.ChildMaterialCode)).Select(p => p.ChildMaterialCode).Distinct().ToList();
_partList.Remove(null);
List<PriceList> _priceList = new List<PriceList>();
List<PriceListVersion> _priceVersion = new List<PriceListVersion>();
foreach (var itm in _materialList)
{
var _first = result.FirstOrDefault(p => p.MaterialCode == itm);
if (_first != null)
{
var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.MaterialPrice, _first.MaterialCode, 0, GuidGenerator.Create(), version,string.Empty);
_priceList.Add(_price);
}
}
foreach (var itm in _partList)
{
var _first = result.FirstOrDefault(p => p.ChildMaterialCode == itm);
if (_first != null)
{
var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.ChildMaterialPrice, _first.ChildMaterialCode, 0, GuidGenerator.Create(), version,string.Empty);
_priceList.Add(_price);
}
}
var _versionList= new List<PriceListVersion>() { new PriceListVersion(GuidGenerator.Create(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString(), version) };
await _priceRepository.GetDbContext().BulkInsertAsync(_priceList);
await _priceversionRepository.GetDbContext().BulkInsertAsync(_versionList);
return checkList;
} }
#endregion
#region 原方法(废弃)
///// <summary>
///// 导入功能
///// </summary>
///// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
///// <returns></returns>
//[HttpPost]
//[Route("ExcelImport-TH")]
//[DisableRequestSizeLimit]
//[Authorize(SettleAccountPermissions.Materials.Default)]
//public async Task<string> MaterialUploadExcelImportMap([FromForm] IFormFileCollection files, string version)
//{
// ExportImporter _exportImporter = new ExportImporter();
// var result = await _exportImporter.ExtendExcelImport<MaterialImportDtoTH>(files, _excelImportService);
// await UpdateMaterial(result, version);
// await UpdateBom(result, version);
// await UpdatePrice(result, version);
private async Task<List<ErrorExportDto>> UpdateMaterial(List<MaterialImportDtoTH> result,string version) // return ApplicationConsts.SuccessStr;
{ //}
//private async Task<List<ErrorExportDto>> UpdateBom(List<MaterialImportDtoTH> result, string version)
//{
// var _versionQuery = _bomversionRepository.Where(p => p.Version == version);
// await _versionQuery.BatchDeleteAsync();
// var _query = _bomRepository.Where(p => p.Version == version);
// await _query.BatchDeleteAsync();
// var entityList = new List<Bom>();
// var _ls = result.Where(p => !string.IsNullOrEmpty(p.ChildMaterialCode) && !string.IsNullOrEmpty(p.MaterialCode)).ToList();
// foreach (var itm in _ls)
// {
// entityList.Add(new Bom(GuidGenerator.Create(), GuidGenerator.Create(), itm.MaterialCode, itm.MaterialDesc, itm.ChildMaterialCode, itm.ChildMaterialDesc, string.Empty, itm.Qty, 0, itm.Qty, string.Empty, DateTime.Now, DateTime.Now, string.Empty, 0, GuidGenerator.Create(), string.Empty));
// }
// var checkList = new List<ErrorExportDto>();
// var _group = entityList.GroupBy(x => new { x.ParentItemCode, x.ChildItemCode, x.Version }).Select(p => new { Count = p.Count(), ParentItmeCode = p.Key.ParentItemCode, ChildItemCode = p.Key.ChildItemCode });
// foreach (var itm in _group)
// {
// if (itm.Count > 1)
// {
// checkList.Add(new ErrorExportDto(version, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Format("不能导入父编码{0},子编码{1}有重复数据", itm.ParentItmeCode, itm.ChildItemCode), string.Empty));
// }
// }
// var _id = GuidGenerator.Create();
// var _bomList = new List<BomVersion>();
// _bomList.Add(new BomVersion(_id, GuidGenerator.Create(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString(), version, string.Empty, string.Empty));
// foreach (var itm in entityList)
// {
// itm.SetValue(GuidGenerator.Create(), GuidGenerator.Create(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString(), version, _id, string.Empty);
// }
// await _bomRepository.GetDbContext().BulkInsertAsync<Bom>(entityList);
// await _bomversionRepository.GetDbContext().BulkInsertAsync(_bomList);
// return checkList;
var _list = await _repository.GetAllAsync(GuidGenerator.Create()); //}
//var _relationshiplist = _relationshipRepository.GetAllAsync(GuidGenerator.Create());
List<ErrorExportDto> _errorList = new List<ErrorExportDto>();
List<Material> _insertls = new List<Material>();
var materialList = result.Where(p => !string.IsNullOrEmpty(p.MaterialCode)).Select(p => p.MaterialCode).Distinct().ToList();
materialList.Remove("xxbmr016.p b+");
materialList.Remove(null);
materialList.Remove("END OF REPORT");
materialList.Remove("Report Attributes (see Comment)");
materialList.Remove("Report Criteria (see Comment)");
//xxbmr016.p b+
foreach (var itm in materialList)
{
var _material = result.Where(p => p.MaterialCode == itm).FirstOrDefault();
if (_material != null)
{
var _m = new Material(GuidGenerator.Create(), GuidGenerator.Create(), string.Empty, _material.MaterialCode, _material.MaterialDesc, string.Empty, _material.EstimateType, string.Empty);
_insertls.Add(_m);
}
}
var _ls = from r1 in _insertls
join r2 in _list on r1.MaterialCode equals r2.MaterialCode
into temp
from t in temp.DefaultIfEmpty()
where t == null
select r1;
var _ls1 = from r1 in _insertls
join r2 in _list on r1.MaterialCode equals r2.MaterialCode
select r1;
var checkList = new List<ErrorExportDto>();
var check = _ls.Where(p => string.IsNullOrEmpty(p.EstimateType)).ToList();
if (_ls.Count() > 0)
{
await _repository.GetDbContext().BulkInsertAsync<Material>(_ls.ToList());
}
if (_ls1.Count() > 0)
{
await _repository.GetDbContext().BulkUpdateAsync(_ls1.ToList());
}
return _errorList;
}
//private async Task<List<ErrorExportDto>> UpdatePrice(List<MaterialImportDtoTH> result, string version)
//{
// var checkList = new List<ErrorExportDto>();
// var _priceversion = _priceversionRepository.Where(p => p.Version == version);
// await _priceversion.BatchDeleteAsync();
// var _prices = _priceRepository.Where(p => p.Version == version);
// await _prices.BatchDeleteAsync();
// var _materialList = result.Where(p => !string.IsNullOrEmpty(p.MaterialCode)).Select(p => p.MaterialCode).Distinct().ToList();
// _materialList.Remove("xxbmr016.p b+");
// _materialList.Remove(null);
// _materialList.Remove("END OF REPORT");
// _materialList.Remove("Report Attributes (see Comment)");
// _materialList.Remove("Report Criteria (see Comment)");
// var _partList = result.Where(p => !string.IsNullOrEmpty(p.ChildMaterialCode)).Select(p => p.ChildMaterialCode).Distinct().ToList();
// _partList.Remove(null);
// List<PriceList> _priceList = new List<PriceList>();
// List<PriceListVersion> _priceVersion = new List<PriceListVersion>();
// foreach (var itm in _materialList)
// {
// var _first = result.FirstOrDefault(p => p.MaterialCode == itm);
// if (_first != null)
// {
// var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.MaterialPrice, _first.MaterialCode, 0, GuidGenerator.Create(), version, string.Empty);
// _priceList.Add(_price);
// }
// }
// foreach (var itm in _partList)
// {
// var _first = result.FirstOrDefault(p => p.ChildMaterialCode == itm);
// if (_first != null)
// {
// var _price = new PriceList(GuidGenerator.Create(), DateTime.MinValue, DateTime.MaxValue, _first.ChildMaterialPrice, _first.ChildMaterialCode, 0, GuidGenerator.Create(), version, string.Empty);
// _priceList.Add(_price);
// }
// }
// var _versionList = new List<PriceListVersion>() { new PriceListVersion(GuidGenerator.Create(), DateTime.Now.Year.ToString(), DateTime.Now.Month.ToString(), version) };
// await _priceRepository.GetDbContext().BulkInsertAsync(_priceList);
// await _priceversionRepository.GetDbContext().BulkInsertAsync(_versionList);
// return checkList;
//}
//private async Task<List<ErrorExportDto>> UpdateMaterial(List<MaterialImportDtoTH> result, string version)
//{
// var _list = await _repository.GetAllAsync(GuidGenerator.Create());
// //var _relationshiplist = _relationshipRepository.GetAllAsync(GuidGenerator.Create());
// List<ErrorExportDto> _errorList = new List<ErrorExportDto>();
// List<Material> _insertls = new List<Material>();
// var materialList = result.Where(p => !string.IsNullOrEmpty(p.MaterialCode)).Select(p => p.MaterialCode).Distinct().ToList();
// materialList.Remove("xxbmr016.p b+");
// materialList.Remove(null);
// materialList.Remove("END OF REPORT");
// materialList.Remove("Report Attributes (see Comment)");
// materialList.Remove("Report Criteria (see Comment)");
// //xxbmr016.p b+
// foreach (var itm in materialList)
// {
// var _material = result.Where(p => p.MaterialCode == itm).FirstOrDefault();
// if (_material != null)
// {
// var _m = new Material(GuidGenerator.Create(), GuidGenerator.Create(), string.Empty, _material.MaterialCode, _material.MaterialDesc, string.Empty, _material.EstimateType, string.Empty);
// _insertls.Add(_m);
// }
// }
// var _ls = from r1 in _insertls
// join r2 in _list on r1.MaterialCode equals r2.MaterialCode
// into temp
// from t in temp.DefaultIfEmpty()
// where t == null
// select r1;
// var _ls1 = from r1 in _insertls
// join r2 in _list on r1.MaterialCode equals r2.MaterialCode
// select r1;
// var checkList = new List<ErrorExportDto>();
// var check = _ls.Where(p => string.IsNullOrEmpty(p.EstimateType)).ToList();
// if (_ls.Count() > 0)
// {
// await _repository.GetDbContext().BulkInsertAsync<Material>(_ls.ToList());
// }
// if (_ls1.Count() > 0)
// {
// await _repository.GetDbContext().BulkUpdateAsync(_ls1.ToList());
// }
// return _errorList;
//}
/// <summary>
/// 导入功能
/// </summary>
/// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
/// <returns></returns>
[HttpPost]
[Route("ExcelImport")]
[DisableRequestSizeLimit]
[Authorize(SettleAccountPermissions.Materials.Default)]
public async Task<string> MaterialUploadExcelImport([FromForm] IFormFileCollection files)
{
ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.UploadExcelImport<MaterialImportDto>(files, _excelImportService);
var _ls = ObjectMapper.Map<List<MaterialImportDto>, List<Material>>(result);
var checkList = new List<ErrorExportDto>();
foreach (var itm in _ls)
{
var _first = await _repository.FirstOrDefaultAsync(p => p.MaterialCode == itm.MaterialCode);
if (_first == null)
{
var entity = new Material(
GuidGenerator.Create(),
GuidGenerator.Create(),
itm.Factory,
itm.MaterialCode,
itm.MaterialDesc,
itm.Unit,
itm.EstimateType,
itm.EstimateTypeDesc
);
await _repository.InsertAsync(entity);
}
else
{
_first.Update(itm.MaterialDesc, itm.Unit, itm.EstimateType, itm.EstimateTypeDesc, itm.Factory
);
await _repository.UpdateAsync(_first);
}
var _f = await _relationshipRepository.FirstOrDefaultAsync(p => p.ErpMaterialCode == itm.MaterialCode);
if (_f != null)
{
_f.Update(itm.MaterialDesc, _f.MaterialProperty, _f.SettleMaterialCode, _f.ShipMaterailCode);
await _relationshipRepository.UpdateAsync(_f);
}
else
{
var _r = new MaterialRelationship(GuidGenerator.Create(), GuidGenerator.Create(), itm.MaterialCode, itm.MaterialDesc, string.Empty, string.Empty, string.Empty, itm.EstimateType);
await _relationshipRepository.InsertAsync(_r);
}
}
return ApplicationConsts.SuccessStr;
}
/// <summary>
/// 按ID获取唯一实体
/// </summary>
/// <remarks>
/// 返回实体全部属性
/// </remarks>
/// <param name="id">ID</param>
/// <returns>实体DTO</returns>
[HttpGet]
[Route("{id}")]
[Authorize(SettleAccountPermissions.Materials.Default)]
virtual public async Task<MaterialDto> GetAsync(Guid id)
{
var result = await GetFromCacheAsync(id); ///// <summary>
var dto = ObjectMapper.Map<Material, MaterialDto>(result); ///// 导入功能
return dto; ///// </summary>
} ///// <param name="files">上传的文件(前端已经限制只能上传一个附件)</param>
///// <returns></returns>
//[HttpPost]
//[Route("ExcelImport")]
//[DisableRequestSizeLimit]
//[Authorize(SettleAccountPermissions.Materials.Default)]
//public async Task<string> MaterialUploadExcelImport([FromForm] IFormFileCollection files)
//{
// ExportImporter _exportImporter = new ExportImporter();
// var result = await _exportImporter.UploadExcelImport<MaterialImportDto>(files, _excelImportService);
// var _ls = ObjectMapper.Map<List<MaterialImportDto>, List<Material>>(result);
// var checkList = new List<ErrorExportDto>();
// foreach (var itm in _ls)
// {
// var _first = await _repository.FirstOrDefaultAsync(p => p.MaterialCode == itm.MaterialCode);
// if (_first == null)
// {
// var entity = new Material(
// GuidGenerator.Create(),
// GuidGenerator.Create(),
// itm.Factory,
// itm.MaterialCode,
// itm.MaterialDesc,
// itm.Unit,
// itm.EstimateType,
// itm.EstimateTypeDesc
// );
// await _repository.InsertAsync(entity);
// }
// else
// {
// _first.Update(itm.MaterialDesc, itm.Unit, itm.EstimateType, itm.EstimateTypeDesc, itm.Factory
// );
// await _repository.UpdateAsync(_first);
// }
// var _f = await _relationshipRepository.FirstOrDefaultAsync(p => p.ErpMaterialCode == itm.MaterialCode);
// if (_f != null)
// {
// _f.Update(itm.MaterialDesc, _f.MaterialProperty, _f.SettleMaterialCode, _f.ShipMaterailCode);
// await _relationshipRepository.UpdateAsync(_f);
// }
// else
// {
// var _r = new MaterialRelationship(GuidGenerator.Create(), GuidGenerator.Create(), itm.MaterialCode, itm.MaterialDesc, string.Empty, string.Empty, string.Empty, itm.EstimateType);
// await _relationshipRepository.InsertAsync(_r);
// }
// }
// return ApplicationConsts.SuccessStr;
//}
private async Task<Material> GetFromCacheAsync(Guid id)
{
var result = await _repository.GetAsync(id);
return result; ///// <summary>
} ///// 按ID获取唯一实体
///// </summary>
///// <remarks>
///// 返回实体全部属性
///// </remarks>
///// <param name="id">ID</param>
///// <returns>实体DTO</returns>
//[HttpGet]
//[Route("{id}")]
//[Authorize(SettleAccountPermissions.Materials.Default)]
//virtual public async Task<MaterialDto> GetAsync(Guid id)
//{
private async Task<long> GetCountAsync(MaterialRequestDto input) // var result = await GetFromCacheAsync(id);
{ // var dto = ObjectMapper.Map<Material, MaterialDto>(result);
return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters); // return dto;
} //}
//private async Task<Material> GetFromCacheAsync(Guid id)
//{
// var result = await _repository.GetAsync(id);
// return result;
//}
///// <summary>
/// <summary> //private async Task<long> GetCountAsync(MaterialRequestDto input)
/// 根据筛选条件获取实体列表 //{
/// </summary> // return await _repository.GetCountByFilterAsync(input.BranchId, input.Filters);
/// <remarks> //}
/// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
/// </remarks>
/// <param name="input">请求条件</param>
/// <returns>实体DTO列表</returns>
[HttpPost]
[Route("list")]
[Authorize(SettleAccountPermissions.Materials.Default)]
virtual public async Task<PagedResultDto<MaterialDto>> GetListAsync(MaterialRequestDto 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<Material>, List<MaterialDto>>(entities);
return new PagedResultDto<MaterialDto>(totalCount, dtos);
}
/// <summary> /////// <summary>
/// 获取实体总数
/// </summary>
/// <returns>实体总数</returns>
[HttpGet]
[Route("count")]
[Authorize(SettleAccountPermissions.Materials.Default)]
virtual public async Task<long> GetTotalCountAsync(Guid branchId)
{
return await _repository.GetCountAsync(branchId);
}
/// <summary> ///// <summary>
/// 获取全部实体列表 ///// 根据筛选条件获取实体列表
/// </summary> ///// </summary>
/// <returns>实体DTO列表</returns> ///// <remarks>
[HttpGet] ///// 请求条件包括:筛选条件列表,排序条件,数据数量,页码
[Route("all")] ///// </remarks>
[Authorize(SettleAccountPermissions.Materials.Default)] ///// <param name="input">请求条件</param>
virtual public async Task<ListResultDto<MaterialDto>> GetAllAsync(Guid branchId) ///// <returns>实体DTO列表</returns>
{ //[HttpPost]
var entities = await _repository.GetAllAsync(branchId, true); //[Route("list")]
//[Authorize(SettleAccountPermissions.Materials.Default)]
//virtual public async Task<PagedResultDto<MaterialDto>> GetListAsync(MaterialRequestDto 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<Material>, List<MaterialDto>>(entities);
var dtos = ObjectMapper.Map<List<Material>, List<MaterialDto>>(entities); // return new PagedResultDto<MaterialDto>(totalCount, dtos);
//}
return new ListResultDto<MaterialDto>(dtos); ///// <summary>
} ///// 获取实体总数
///// </summary>
///// <returns>实体总数</returns>
//[HttpGet]
//[Route("count")]
//[Authorize(SettleAccountPermissions.Materials.Default)]
//virtual public async Task<long> GetTotalCountAsync(Guid branchId)
//{
// return await _repository.GetCountAsync(branchId);
//}
///// <summary>
///// 获取全部实体列表
///// </summary>
///// <returns>实体DTO列表</returns>
//[HttpGet]
//[Route("all")]
//[Authorize(SettleAccountPermissions.Materials.Default)]
//virtual public async Task<ListResultDto<MaterialDto>> GetAllAsync(Guid branchId)
//{
// var entities = await _repository.GetAllAsync(branchId, true);
// var dtos = ObjectMapper.Map<List<Material>, List<MaterialDto>>(entities);
/// <summary>
/// 批量导入实体列表
/// </summary>
/// <remarks>
/// 以ID为依据,数据库中找不到ID的实体会新增,已有ID的实体会修改
/// </remarks>
/// <param name="entities">实体列表</param>
/// <returns>是否导入成功</returns>
//[HttpPost]
//[Route("import")]
[Authorize(SettleAccountPermissions.Materials.Create)]
//virtual public async Task<bool> ImportAsync(List<MaterialCreateDto> dtos)
//{
// var entities =ObjectMapper.Map<List<MaterialCreateDto>, List<Material>>(dtos);
// var result = await _repository.ImportAsync(entities); // return new ListResultDto<MaterialDto>(dtos);
//}
// return result;
//}
/// <summary>
/// 新增实体
/// </summary>
/// <param name="input">新增实体DTO</param>
/// <returns>实体DTO</returns>
[HttpPost] ///// <summary>
[Route("")] ///// 批量导入实体列表
[Authorize(SettleAccountPermissions.Materials.Create)] ///// </summary>
virtual public async Task<MaterialDto> CreateAsync(MaterialCreateDto input) ///// <remarks>
{ ///// 以ID为依据,数据库中找不到ID的实体会新增,已有ID的实体会修改
///// </remarks>
///// <param name="entities">实体列表</param>
///// <returns>是否导入成功</returns>
////[HttpPost]
////[Route("import")]
//[Authorize(SettleAccountPermissions.Materials.Create)]
////virtual public async Task<bool> ImportAsync(List<MaterialCreateDto> dtos)
////{
//// var entities =ObjectMapper.Map<List<MaterialCreateDto>, List<Material>>(dtos);
//// var result = await _repository.ImportAsync(entities);
//// return result;
////}
try ///// <summary>
{ ///// 新增实体
if (_repository.Any(p => p.MaterialCode == input.MaterialCode)) ///// </summary>
{ ///// <param name="input">新增实体DTO</param>
throw new BusinessException("8989",string.Format("已存在编号{0}的物料数据",input.MaterialCode)); ///// <returns>实体DTO</returns>
}
var entity = new Material(
GuidGenerator.Create(),
input.BranchId,
input.Factory,
input.MaterialCode,
input.MaterialDesc,
input.Unit,
input.EstimateType,
input.EstimateTypeDesc
);
await _repository.InsertAsync(entity);
var dto = ObjectMapper.Map<Material, MaterialDto>(entity);
return dto;
}
catch
{
throw new BusinessException("", "数据项有重复,或其他问题请检查!");
}
return null;
} //[HttpPost]
//[Route("")]
//[Authorize(SettleAccountPermissions.Materials.Create)]
//virtual public async Task<MaterialDto> CreateAsync(MaterialCreateDto input)
//{
/// <summary> // try
/// 修改实体 // {
/// </summary> // if (_repository.Any(p => p.MaterialCode == input.MaterialCode))
/// <param name="id">ID</param> // {
/// <param name="input">修改实体DTO</param> // throw new BusinessException("8989", string.Format("已存在编号{0}的物料数据", input.MaterialCode));
/// <returns>实体DTO</returns> // }
[HttpPut] // var entity = new Material(
[Route("{id}")] // GuidGenerator.Create(),
[Authorize(SettleAccountPermissions.Materials.Update)] // input.BranchId,
virtual public async Task<MaterialDto> UpdateAsync(Guid id, MaterialUpdateDto input) // input.Factory,
{ // input.MaterialCode,
var entity = await _repository.GetAsync(id); // input.MaterialDesc,
// input.Unit,
// input.EstimateType,
// input.EstimateTypeDesc
// );
// await _repository.InsertAsync(entity);
// var dto = ObjectMapper.Map<Material, MaterialDto>(entity);
// return dto;
// }
// catch
// {
// throw new BusinessException("", "数据项有重复,或其他问题请检查!");
// }
// return null;
//}
///// <summary>
///// 修改实体
///// </summary>
///// <param name="id">ID</param>
///// <param name="input">修改实体DTO</param>
///// <returns>实体DTO</returns>
//[HttpPut]
//[Route("{id}")]
//[Authorize(SettleAccountPermissions.Materials.Update)]
//virtual public async Task<MaterialDto> UpdateAsync(Guid id, MaterialUpdateDto input)
//{
// var entity = await _repository.GetAsync(id);
await Cache.SetAsync(id.ToString(), entity, CacheStrategyConst.FIVE_MINUTES); // await Cache.SetAsync(id.ToString(), entity, CacheStrategyConst.FIVE_MINUTES);
var dto = ObjectMapper.Map<Material, MaterialDto>(entity); // var dto = ObjectMapper.Map<Material, MaterialDto>(entity);
return dto; // return dto;
} //}
/// <summary> ///// <summary>
/// 删除实体 ///// 删除实体
/// </summary> ///// </summary>
/// <param name="id">ID</param> ///// <param name="id">ID</param>
/// <returns>无</returns> ///// <returns>无</returns>
[HttpDelete] //[HttpDelete]
[Route("{id}")] //[Route("{id}")]
[Authorize(SettleAccountPermissions.Materials.Delete)] //[Authorize(SettleAccountPermissions.Materials.Delete)]
virtual public async Task DeleteAsync(Guid id) //virtual public async Task DeleteAsync(Guid id)
{ //{
var entity = await GetFromCacheAsync(id); // var entity = await GetFromCacheAsync(id);
await Cache.DeleteAsync<Material>(id.ToString()); // await Cache.DeleteAsync<Material>(id.ToString());
await _repository.DeleteAsync(id); // await _repository.DeleteAsync(id);
} //}
/// <summary> ///// <summary>
/// 按IDs删除实体列表 ///// 按IDs删除实体列表
/// </summary> ///// </summary>
/// <param name="ids">IDs</param> ///// <param name="ids">IDs</param>
/// <returns>是否执行成功</returns> ///// <returns>是否执行成功</returns>
[HttpPost] //[HttpPost]
[Route("delete")] //[Route("delete")]
[Authorize(SettleAccountPermissions.Materials.Delete)] //[Authorize(SettleAccountPermissions.Materials.Delete)]
virtual public async Task<bool> DeleteListAsync(List<Guid> ids) //virtual public async Task<bool> DeleteListAsync(List<Guid> ids)
{ //{
var _query = _repository.Where(p => ids.Contains(p.Id)); // var _query = _repository.Where(p => ids.Contains(p.Id));
int i = await _query.BatchDeleteAsync(); // int i = await _query.BatchDeleteAsync();
if (i == 0) // if (i == 0)
{ // {
return false; // return false;
} // }
return true; // return true;
} //}
[HttpPost] //[HttpPost]
[Route("Export")] //[Route("Export")]
[Authorize(SettleAccountPermissions.Materials.Default)] //[Authorize(SettleAccountPermissions.Materials.Default)]
virtual public async Task<string> ExportAsync(MaterialRequestDto input) //virtual public async Task<string> ExportAsync(MaterialRequestDto input)
{ //{
string _fileName = string.Format("物料主数据_{0}.xlsx", DateTime.Now.ToString("yyyyMMdd")); // string _fileName = string.Format("物料主数据_{0}.xlsx", DateTime.Now.ToString("yyyyMMdd"));
var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue, // var entities = await _repository.GetListByFilterAsync(input.BranchId, input.Filters, input.Sorting, int.MaxValue,
0, true); // 0, true);
var dtoDetails = ObjectMapper.Map<List<Material>, List<MaterialExportDto>>(entities); // var dtoDetails = ObjectMapper.Map<List<Material>, List<MaterialExportDto>>(entities);
//声明导出容器 // //声明导出容器
ExportImporter _exportImporter = new ExportImporter(); // ExportImporter _exportImporter = new ExportImporter();
var result = await _exportImporter.ExcelExporter(dtoDetails); // var result = await _exportImporter.ExcelExporter(dtoDetails);
result.ShouldNotBeNull(); // result.ShouldNotBeNull();
//保存导出文件到服务器存成二进制 // //保存导出文件到服务器存成二进制
await _excelImportService.SaveBlobAsync( // await _excelImportService.SaveBlobAsync(
new SaveExcelImportInputDto // new SaveExcelImportInputDto
{ // {
Name = _fileName, // Name = _fileName,
Content = result // Content = result
} // }
); // );
return _fileName; // return _fileName;
} //}
#endregion

13
code/src/Modules/SettleAccount/src/SettleAccount.Application/Entities/Prices/PriceListAppServiceBJ.cs

@ -1,24 +1,15 @@
using Magicodes.ExporterAndImporter.Core; using Microsoft.AspNetCore.Authorization;
using Magicodes.ExporterAndImporter.Csv;
using Magicodes.ExporterAndImporter.Excel;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Shouldly;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services;
using Win.Sfs.BaseData.ImportExcelCommon; using Win.Sfs.BaseData.ImportExcelCommon;
using Win.Sfs.SettleAccount.Bases; using Win.Sfs.SettleAccount.Bases;
using Win.Sfs.SettleAccount.Constant; using Win.Sfs.SettleAccount.Constant;
using Win.Sfs.SettleAccount.Entities.ImportMap; using Win.Sfs.SettleAccount.Entities.ImportMap;
using Win.Sfs.SettleAccount.ExcelImporter; using Win.Sfs.SettleAccount.ExcelImporter;
using Win.Sfs.SettleAccount.Repository;
using Win.Sfs.Shared.Filter;
using Win.Sfs.Shared.RepositoryBase; using Win.Sfs.Shared.RepositoryBase;
namespace Win.Sfs.SettleAccount.Entities.Prices namespace Win.Sfs.SettleAccount.Entities.Prices
@ -29,7 +20,7 @@ namespace Win.Sfs.SettleAccount.Entities.Prices
//[Authorize(SettleAccountPermissions.PriceLists.Default)] //[Authorize(SettleAccountPermissions.PriceLists.Default)]
[AllowAnonymous] [AllowAnonymous]
[Route("api/SettleAccount/PriceListBJ")] [Route("api/SettleAccount/PriceListBJ")]
public class PriceListAppServiceBJ : CurdBaseAppService<PriceListBJ, PriceListBJDto, PriceListBJRequestDto, PriceListBJ, PriceListBJExportDto, PriceListBJExportDto> public class PriceListAppServiceBJ : CurdBaseAppService<PriceListBJ, PriceListBJDto, PriceListBJRequestDto, PriceListBJ, PriceListBJImportDto, PriceListBJExportDto>
{ {
private readonly INormalEfCoreRepository<PriceListBJ, Guid> _repository; private readonly INormalEfCoreRepository<PriceListBJ, Guid> _repository;
private readonly PriceListManagerBJ _priceListManagerBJ; private readonly PriceListManagerBJ _priceListManagerBJ;

Loading…
Cancel
Save