|
|
@ -1,11 +1,11 @@ |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Shouldly; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using EFCore.BulkExtensions; |
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
using Shouldly; |
|
|
|
using Volo.Abp; |
|
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
using Volo.Abp.Caching; |
|
|
@ -15,424 +15,419 @@ using Win.Sfs.SettleAccount.CommonManagers; |
|
|
|
using Win.Sfs.SettleAccount.ExcelImporter; |
|
|
|
using Win.Sfs.Shared.RepositoryBase; |
|
|
|
|
|
|
|
namespace Win.Sfs.SettleAccount.Entities.Controls |
|
|
|
namespace Win.Sfs.SettleAccount.Entities.Controls; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 期间设置
|
|
|
|
/// </summary>
|
|
|
|
[AllowAnonymous] |
|
|
|
[Route("api/settleaccount/[controller]/[action]")]
|
|
|
|
public class CentralizedControlAppService : SettleAccountApplicationBase<CentralizedControl> |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// 期间设置
|
|
|
|
/// 期间设置仓储
|
|
|
|
/// </summary>
|
|
|
|
private readonly INormalEfCoreRepository<CentralizedControl, Guid> _repository; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 构造
|
|
|
|
/// </summary>
|
|
|
|
[AllowAnonymous] |
|
|
|
[Route("api/settleaccount/[controller]/[action]")]
|
|
|
|
public class CentralizedControlAppService : SettleAccountApplicationBase<CentralizedControl> |
|
|
|
public CentralizedControlAppService( |
|
|
|
INormalEfCoreRepository<CentralizedControl, Guid> repository, |
|
|
|
IDistributedCache<CentralizedControl> cache, |
|
|
|
IExcelImportAppService excelImportService, |
|
|
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
|
|
|
ICommonManager commonManager |
|
|
|
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// 期间设置仓储
|
|
|
|
/// </summary>
|
|
|
|
private readonly INormalEfCoreRepository<CentralizedControl, Guid> _repository; |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 构造
|
|
|
|
/// </summary>
|
|
|
|
public CentralizedControlAppService( |
|
|
|
INormalEfCoreRepository<CentralizedControl, Guid> repository, |
|
|
|
IDistributedCache<CentralizedControl> cache, |
|
|
|
IExcelImportAppService excelImportService, |
|
|
|
ISnowflakeIdGenerator snowflakeIdGenerator, |
|
|
|
ICommonManager commonManager |
|
|
|
) : base(cache, excelImportService, snowflakeIdGenerator, commonManager) |
|
|
|
{ |
|
|
|
_repository = repository; |
|
|
|
} |
|
|
|
_repository = repository; |
|
|
|
} |
|
|
|
|
|
|
|
#region 导出
|
|
|
|
/// <summary>
|
|
|
|
/// 导出
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<string> ExportAsync(CentralizedControlRequestDto input) |
|
|
|
{ |
|
|
|
string fileName = $"期间设置_{Guid.NewGuid()}.xlsx"; |
|
|
|
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); |
|
|
|
var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlExportDto>>(entities); |
|
|
|
#region 导出
|
|
|
|
/// <summary>
|
|
|
|
/// 导出
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<string> ExportAsync(CentralizedControlRequestDto input) |
|
|
|
{ |
|
|
|
string fileName = $"期间设置_{Guid.NewGuid()}.xlsx"; |
|
|
|
var entities = await _repository.GetListByFilterAsync(input.Filters, input.Sorting, int.MaxValue, 0, true); |
|
|
|
var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlExportDto>>(entities); |
|
|
|
|
|
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
|
var result = await _exportImporter.ExcelExporter(dtos); |
|
|
|
result.ShouldNotBeNull(); |
|
|
|
ExportImporter _exportImporter = new ExportImporter(); |
|
|
|
var result = await _exportImporter.ExcelExporter(dtos); |
|
|
|
result.ShouldNotBeNull(); |
|
|
|
|
|
|
|
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }); |
|
|
|
return fileName; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region CURD
|
|
|
|
/// <summary>
|
|
|
|
/// 获取全部
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<ListResultDto<CentralizedControlDto>> GetAllAsync() |
|
|
|
{ |
|
|
|
var entities = await _repository.GetAllAsync(true); |
|
|
|
var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(entities); |
|
|
|
return new ListResultDto<CentralizedControlDto>(dtos); |
|
|
|
} |
|
|
|
await _excelImportService.SaveBlobAsync(new SaveExcelImportInputDto { Name = fileName, Content = result }); |
|
|
|
return fileName; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<PagedResultDto<CentralizedControlDto>> GetListAsync(CentralizedControlRequestDto 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<CentralizedControl>, List<CentralizedControlDto>>(entities); |
|
|
|
return new PagedResultDto<CentralizedControlDto>(totalCount, dtos); |
|
|
|
} |
|
|
|
#region CURD
|
|
|
|
/// <summary>
|
|
|
|
/// 获取全部
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<ListResultDto<CentralizedControlDto>> GetAllAsync() |
|
|
|
{ |
|
|
|
var entities = await _repository.GetAllAsync(true); |
|
|
|
var dtos = ObjectMapper.Map<List<CentralizedControl>, List<CentralizedControlDto>>(entities); |
|
|
|
return new ListResultDto<CentralizedControlDto>(dtos); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<PagedResultDto<CentralizedControlDto>> GetListAsync(CentralizedControlRequestDto 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<CentralizedControl>, List<CentralizedControlDto>>(entities); |
|
|
|
return new PagedResultDto<CentralizedControlDto>(totalCount, dtos); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 添加
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<CentralizedControlDto> CreateAsync(CentralizedControlCreateDto input) |
|
|
|
{ |
|
|
|
var _first = _repository.Where(p => p.Version == input.Version).FirstOrDefault(); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 添加
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<CentralizedControlDto> CreateAsync(CentralizedControlCreateDto input) |
|
|
|
if (_first != null) |
|
|
|
{ |
|
|
|
var _first = _repository.Where(p => p.Version == input.Version).FirstOrDefault(); |
|
|
|
throw new BusinessException("001", "已经存在该期间,不能重复添加!"); |
|
|
|
} |
|
|
|
|
|
|
|
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 |
|
|
|
); |
|
|
|
|
|
|
|
var entity = new CentralizedControl( |
|
|
|
GuidGenerator.Create(), |
|
|
|
input.BranchId, |
|
|
|
input.Year, |
|
|
|
input.Period, |
|
|
|
input.Year + input.Period, |
|
|
|
input.State |
|
|
|
); |
|
|
|
await _repository.InsertAsync(entity); |
|
|
|
|
|
|
|
await _repository.InsertAsync(entity); |
|
|
|
var dto = ObjectMapper.Map<CentralizedControl, CentralizedControlDto>(entity); |
|
|
|
return dto; |
|
|
|
|
|
|
|
var dto = ObjectMapper.Map<CentralizedControl, CentralizedControlDto>(entity); |
|
|
|
return dto; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 删除实体
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">ID</param>
|
|
|
|
/// <returns>无</returns>
|
|
|
|
[HttpDelete] |
|
|
|
public async Task DeleteAsync(Guid id) |
|
|
|
{ |
|
|
|
var entity = await _repository.GetAsync(id); |
|
|
|
await _repository.DeleteAsync(id); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 删除实体
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="id">ID</param>
|
|
|
|
/// <returns>无</returns>
|
|
|
|
[HttpDelete] |
|
|
|
public async Task DeleteAsync(Guid id) |
|
|
|
{ |
|
|
|
var entity = await _repository.GetAsync(id); |
|
|
|
await _repository.DeleteAsync(id); |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 按IDs删除实体列表
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<bool> DeleteListAsync(List<Guid> ids) |
|
|
|
{ |
|
|
|
var _query = _repository.Where(p => ids.Contains(p.Id)); |
|
|
|
int i = await _query.BatchDeleteAsync(); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 按IDs删除实体列表
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<bool> DeleteListAsync(List<Guid> ids) |
|
|
|
{ |
|
|
|
var _query = _repository.Where(p => ids.Contains(p.Id)); |
|
|
|
int i = await _query.BatchDeleteAsync(); |
|
|
|
return i == 0; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
return i == 0; |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 开启、关闭
|
|
|
|
/// <summary>
|
|
|
|
/// 开启版本
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<bool> OpenVersion(List<Guid> ids) |
|
|
|
#region 开启、关闭
|
|
|
|
/// <summary>
|
|
|
|
/// 开启版本
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<bool> OpenVersion(List<Guid> ids) |
|
|
|
{ |
|
|
|
var entitys = await _repository.GetListAsync(p => ids.Contains(p.Id)); |
|
|
|
foreach (var entity in entitys) |
|
|
|
{ |
|
|
|
var entitys = await _repository.GetListAsync(p => ids.Contains(p.Id)); |
|
|
|
foreach (var entity in entitys) |
|
|
|
{ |
|
|
|
entity.OpenVersion(); |
|
|
|
} |
|
|
|
return true; |
|
|
|
entity.OpenVersion(); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 关闭版本
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<bool> ClosedVersion(List<Guid> ids) |
|
|
|
/// <summary>
|
|
|
|
/// 关闭版本
|
|
|
|
/// </summary>
|
|
|
|
[HttpPost] |
|
|
|
public async Task<bool> ClosedVersion(List<Guid> ids) |
|
|
|
{ |
|
|
|
var entitys = await _repository.GetListAsync(p => ids.Contains(p.Id)); |
|
|
|
foreach (var entity in entitys) |
|
|
|
{ |
|
|
|
var entitys = await _repository.GetListAsync(p => ids.Contains(p.Id)); |
|
|
|
foreach (var entity in entitys) |
|
|
|
{ |
|
|
|
entity.ClosedVersion(); |
|
|
|
} |
|
|
|
return true; |
|
|
|
entity.ClosedVersion(); |
|
|
|
} |
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 原方法(废弃)
|
|
|
|
// /// <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]
|
|
|
|
// [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
|
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 原方法(废弃)
|
|
|
|
// /// <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]
|
|
|
|
// [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
|
|
|
|
|
|
|
|
} |
|
|
|