You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
264 lines
14 KiB
264 lines
14 KiB
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Shentun.Peis.BigtextResultTemplates;
|
|
using Shentun.Peis.CommonTables;
|
|
using Shentun.Peis.HelperDto;
|
|
using Shentun.Peis.Items;
|
|
using Shentun.Peis.Models;
|
|
using SqlSugar;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
|
|
namespace Shentun.Peis.BigtextResultTemplates
|
|
{
|
|
/// <summary>
|
|
/// 大文本结果模板
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "Work")]
|
|
[Authorize]
|
|
public class BigtextResultTemplateAppService : ApplicationService
|
|
{
|
|
private readonly IRepository<BigtextResultTemplate, Guid> _bigtextResultTemplateRepository;
|
|
private readonly CacheService _cacheService;
|
|
private readonly BigtextResultTemplateManager _bigtextResultTemplateManager;
|
|
private readonly IRepository<BigtextResultConclusion, Guid> _bigtextResultConclusionRepository;
|
|
private readonly IRepository<BigtextResultDescription, Guid> _bigtextResultDescriptionRepository;
|
|
private readonly IRepository<ItemBigtextResultType> _itemBigtextResultTypeRepository;
|
|
private readonly IRepository<BigtextResultType, Guid> _bigtextResultTypeRepository;
|
|
|
|
public BigtextResultTemplateAppService(
|
|
IRepository<BigtextResultTemplate, Guid> bigtextResultTemplateRepository,
|
|
CacheService cacheService,
|
|
BigtextResultTemplateManager bigtextResultTemplateManager,
|
|
IRepository<BigtextResultConclusion, Guid> bigtextResultConclusionRepository,
|
|
IRepository<BigtextResultDescription, Guid> bigtextResultDescriptionRepository,
|
|
IRepository<ItemBigtextResultType> itemBigtextResultTypeRepository,
|
|
IRepository<BigtextResultType, Guid> bigtextResultTypeRepository)
|
|
{
|
|
_bigtextResultTemplateRepository = bigtextResultTemplateRepository;
|
|
_cacheService = cacheService;
|
|
_bigtextResultTemplateManager = bigtextResultTemplateManager;
|
|
_bigtextResultConclusionRepository = bigtextResultConclusionRepository;
|
|
_bigtextResultDescriptionRepository = bigtextResultDescriptionRepository;
|
|
_itemBigtextResultTypeRepository = itemBigtextResultTypeRepository;
|
|
_bigtextResultTypeRepository = bigtextResultTypeRepository;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取通过主键
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/BigtextResultTemplate/Get")]
|
|
public async Task<BigtextResultTemplateDto> GetAsync(BigtextResultTemplateIdInputDto input)
|
|
{
|
|
var bigtextResultTemplateEnt = await _bigtextResultTemplateRepository.GetAsync(input.BigtextResultTemplateId);
|
|
var entityDto = ObjectMapper.Map<BigtextResultTemplate, BigtextResultTemplateDto>(bigtextResultTemplateEnt);
|
|
entityDto.CreatorName = await _cacheService.GetSurnameAsync(entityDto.CreatorId);
|
|
entityDto.LastModifierName = await _cacheService.GetSurnameAsync(entityDto.LastModifierId);
|
|
return entityDto;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取列表 可根据条件检索
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/BigtextResultTemplate/GetList")]
|
|
public async Task<List<BigtextResultTemplateDto>> GetListAsync(BigtextResultTemplateListInputDto input)
|
|
{
|
|
|
|
var query = await _bigtextResultTemplateRepository.GetQueryableAsync();
|
|
|
|
if (input.BigtextResultTypeId != null)
|
|
query = query.Where(m => m.BigtextResultTypeId == input.BigtextResultTypeId);
|
|
|
|
if (!string.IsNullOrWhiteSpace(input.KeyWord))
|
|
query = query.Where(m => m.DisplayName.Contains(input.KeyWord) || m.SimpleCode.Contains(input.KeyWord));
|
|
|
|
|
|
var entdto = query.Select(s => new BigtextResultTemplateDto
|
|
{
|
|
CreationTime = s.CreationTime,
|
|
CreatorId = s.CreatorId,
|
|
DisplayName = s.DisplayName,
|
|
DisplayOrder = s.DisplayOrder,
|
|
Id = s.Id,
|
|
BigtextResultTypeId = s.BigtextResultTypeId,
|
|
LastModificationTime = s.LastModificationTime,
|
|
LastModifierId = s.LastModifierId,
|
|
SimpleCode = s.SimpleCode,
|
|
CreatorName = _cacheService.GetSurnameAsync(s.CreatorId).Result,
|
|
LastModifierName = _cacheService.GetSurnameAsync(s.LastModifierId).Result
|
|
}).OrderBy(o => o.DisplayOrder).ToList();
|
|
|
|
return entdto;
|
|
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/BigtextResultTemplate/Create")]
|
|
public async Task<BigtextResultTemplateDto> CreateAsync(CreateBigtextResultTemplateDto input)
|
|
{
|
|
var createEntity = ObjectMapper.Map<CreateBigtextResultTemplateDto, BigtextResultTemplate>(input);
|
|
var entity = await _bigtextResultTemplateManager.CreateAsync(createEntity);
|
|
entity = await _bigtextResultTemplateRepository.InsertAsync(entity);
|
|
var dto = ObjectMapper.Map<BigtextResultTemplate, BigtextResultTemplateDto>(entity);
|
|
dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId);
|
|
dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId);
|
|
return dto;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/BigtextResultTemplate/Update")]
|
|
public async Task<BigtextResultTemplateDto> UpdateAsync(UpdateBigtextResultTemplateDto input)
|
|
{
|
|
var entity = await _bigtextResultTemplateRepository.GetAsync(input.BigtextResultTemplateId);
|
|
var sourceEntity = ObjectMapper.Map<UpdateBigtextResultTemplateDto, BigtextResultTemplate>(input);
|
|
await _bigtextResultTemplateManager.UpdateAsync(sourceEntity, entity);
|
|
entity = await _bigtextResultTemplateRepository.UpdateAsync(entity);
|
|
var dto = ObjectMapper.Map<BigtextResultTemplate, BigtextResultTemplateDto>(entity);
|
|
dto.CreatorName = await _cacheService.GetSurnameAsync(dto.CreatorId);
|
|
dto.LastModifierName = await _cacheService.GetSurnameAsync(dto.LastModifierId);
|
|
return dto;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/BigtextResultTemplate/Delete")]
|
|
public async Task DeleteAsync(BigtextResultTemplateIdInputDto input)
|
|
{
|
|
await _bigtextResultTemplateManager.CheckAndDeleteAsync(input.BigtextResultTemplateId);
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 修改排序 置顶,置底
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/BigtextResultTemplate/UpdateManySort")]
|
|
public async Task UpdateManySortAsync(UpdateManySortBigtextResultTemplateInputDto input)
|
|
{
|
|
await _bigtextResultTemplateManager.UpdateManySortAsync(input.BigtextResultTemplateId, input.SortType);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改排序 拖拽
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/BigtextResultTemplate/UpdateSortMany")]
|
|
public async Task UpdateSortManyAsync(UpdateSortManyCommonDto input)
|
|
{
|
|
await _bigtextResultTemplateManager.UpdateSortManyAsync(input);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取模板下的描述跟结论
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/BigtextResultTemplate/GetBigtextResultTemplateDetail")]
|
|
public async Task<GetBigtextResultTemplateDetailDto> GetBigtextResultTemplateDetailAsync(GetBigtextResultTemplateDetailInputDto input)
|
|
{
|
|
var entDto = new GetBigtextResultTemplateDetailDto();
|
|
|
|
var descriptionDetail = (from bigtextResultTemplate in await _bigtextResultTemplateRepository.GetQueryableAsync()
|
|
join bigtextResultDescription in await _bigtextResultDescriptionRepository.GetQueryableAsync()
|
|
on bigtextResultTemplate.Id equals bigtextResultDescription.BigtextResultTemplateId
|
|
orderby bigtextResultTemplate.DisplayOrder, bigtextResultDescription.DisplayOrder ascending
|
|
select new GetBigtextResultTemplateDetailDescription
|
|
{
|
|
BigtextResultTemplateId = bigtextResultTemplate.Id,
|
|
BigtextResultTemplateName = bigtextResultTemplate.DisplayName,
|
|
Description = bigtextResultDescription.Description
|
|
});
|
|
|
|
|
|
|
|
var conclusionDetail = (from bigtextResultTemplate in await _bigtextResultTemplateRepository.GetQueryableAsync()
|
|
join bigtextResultConclusion in await _bigtextResultConclusionRepository.GetQueryableAsync()
|
|
on bigtextResultTemplate.Id equals bigtextResultConclusion.BigtextResultTemplateId
|
|
orderby bigtextResultTemplate.DisplayOrder, bigtextResultConclusion.DisplayOrder ascending
|
|
select new GetBigtextResultTemplateDetailConclusion
|
|
{
|
|
BigtextResultTemplateId = bigtextResultTemplate.Id,
|
|
BigtextResultTemplateName = bigtextResultTemplate.DisplayName,
|
|
Conclusion = bigtextResultConclusion.Conclusion,
|
|
IsAbnormal = bigtextResultConclusion.IsAbnormal
|
|
});
|
|
|
|
if (input.BigtextResultTemplateIds.Any())
|
|
{
|
|
descriptionDetail = descriptionDetail.Where(m => input.BigtextResultTemplateIds.Contains(m.BigtextResultTemplateId));
|
|
conclusionDetail = conclusionDetail.Where(m => input.BigtextResultTemplateIds.Contains(m.BigtextResultTemplateId));
|
|
}
|
|
|
|
entDto.ConclusionDetail = conclusionDetail.ToList();
|
|
entDto.DescriptionDetail = descriptionDetail.ToList();
|
|
|
|
return entDto;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据项目获取对应的词条模板、描述跟建议(多条换行合并)
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/BigtextResultTemplate/GetBigtextResultTemplateWithDetail")]
|
|
public async Task<List<GetBigtextResultTemplateWithDetailDto>> GetBigtextResultTemplateWithDetailAsync(ItemIdInputDto input)
|
|
{
|
|
var query = (from itemBigtextResultType in await _itemBigtextResultTypeRepository.GetQueryableAsync()
|
|
join bigtextResultType in await _bigtextResultTypeRepository.GetQueryableAsync() on itemBigtextResultType.BigtextResultTypeId equals bigtextResultType.Id
|
|
join bigtextResultTemplate in await _bigtextResultTemplateRepository.GetQueryableAsync() on bigtextResultType.Id equals bigtextResultTemplate.BigtextResultTypeId
|
|
join bigtextResultConclusion in await _bigtextResultConclusionRepository.GetQueryableAsync() on bigtextResultTemplate.Id equals bigtextResultConclusion.BigtextResultTemplateId into bigtextResultConclusionTemp
|
|
from bigtextResultConclusionHaveEmpty in bigtextResultConclusionTemp.DefaultIfEmpty()
|
|
join bigtextResultDescription in await _bigtextResultDescriptionRepository.GetQueryableAsync() on bigtextResultTemplate.Id equals bigtextResultDescription.BigtextResultTemplateId into bigtextResultDescriptionTemp
|
|
from bigtextResultDescriptionHaveEmpty in bigtextResultDescriptionTemp.DefaultIfEmpty()
|
|
where itemBigtextResultType.ItemId == input.ItemId
|
|
orderby bigtextResultTemplate.DisplayOrder ascending
|
|
select new
|
|
{
|
|
bigtextResultTypeName = bigtextResultType.DisplayName,
|
|
bigtextResultTemplateName = bigtextResultTemplate.DisplayName,
|
|
bigtextResultTemplateId = bigtextResultTemplate.Id,
|
|
bigtextResultConclusionHaveEmpty,
|
|
bigtextResultDescriptionHaveEmpty
|
|
}).ToList();
|
|
|
|
var bigtextResultTemplateGroup = query.GroupBy(g => g.bigtextResultTemplateId);
|
|
|
|
var entListDto = bigtextResultTemplateGroup.Select(s => new GetBigtextResultTemplateWithDetailDto
|
|
{
|
|
BigtextResultTypeName = s.FirstOrDefault().bigtextResultTypeName,
|
|
BigtextResultTemplateName = s.FirstOrDefault().bigtextResultTemplateName,
|
|
bigtextResultDescription = string.Join(";", s.Where(m => m.bigtextResultDescriptionHaveEmpty != null).Select(ss => ss.bigtextResultDescriptionHaveEmpty.Description).Distinct()),
|
|
bigtextResultConclusion = string.Join(";", s.Where(m => m.bigtextResultConclusionHaveEmpty != null).Select(ss => ss.bigtextResultConclusionHaveEmpty.Conclusion).Distinct())
|
|
}).ToList();
|
|
|
|
return entListDto;
|
|
}
|
|
|
|
|
|
}
|
|
}
|