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.
156 lines
5.7 KiB
156 lines
5.7 KiB
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Shentun.Peis.AsbitemDetails;
|
|
using Shentun.Peis.Asbitems;
|
|
using Shentun.Peis.DeviceTypes;
|
|
using Shentun.Peis.HelperDto;
|
|
using Shentun.Peis.Models;
|
|
using Shentun.Peis.SampleGroupDetails;
|
|
using Shentun.Peis.SampleGroups;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Volo.Abp;
|
|
using Volo.Abp.Application.Dtos;
|
|
using Volo.Abp.Application.Services;
|
|
using Volo.Abp.Domain.Repositories;
|
|
using Volo.Abp.Identity;
|
|
using Volo.Abp.Users;
|
|
|
|
namespace Shentun.Peis.SampleGroupDetails
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
/// 标本分组包含组合项目
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "Work")]
|
|
[Authorize]
|
|
public class SampleGroupDetailAppService : ApplicationService
|
|
{
|
|
private readonly IRepository<SampleGroupDetail> _repository;
|
|
private readonly IRepository<IdentityUser, Guid> _userRepository;
|
|
private readonly SampleGroupDetailManager _manager;
|
|
|
|
public SampleGroupDetailAppService(
|
|
IRepository<SampleGroupDetail> repository,
|
|
IRepository<IdentityUser, Guid> userRepository,
|
|
SampleGroupDetailManager manager)
|
|
{
|
|
this._repository = repository;
|
|
this._userRepository = userRepository;
|
|
this._manager = manager;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task<SampleGroupDetailDto> CreateAsync(CreateSampleGroupDetailDto input)
|
|
{
|
|
var createEntity = ObjectMapper.Map<CreateSampleGroupDetailDto, SampleGroupDetail>(input);
|
|
var entity = await _repository.InsertAsync(createEntity);
|
|
var dto = ObjectMapper.Map<SampleGroupDetail, SampleGroupDetailDto>(entity);
|
|
return dto;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 批量创建 先删除
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/samplegroupdetail/createsamplegroupdetail")]
|
|
public async Task CreateSampleGroupDetailAsync(CreateSampleGroupDetailDto input)
|
|
{
|
|
await _manager.CheckAndDeleteAsync(input.SampleGroupId);
|
|
if (input.Details.Any())
|
|
{
|
|
List<SampleGroupDetail> sampleGroupDetails = new List<SampleGroupDetail>();
|
|
foreach (var details in input.Details)
|
|
{
|
|
var entity = new SampleGroupDetail
|
|
{
|
|
SampleGroupId = input.SampleGroupId,
|
|
AsbitemId = details.AsbitemId
|
|
};
|
|
sampleGroupDetails.Add(_manager.CreateAsync(entity));
|
|
}
|
|
|
|
if (sampleGroupDetails.Count > 0)
|
|
{
|
|
await _repository.InsertManyAsync(sampleGroupDetails);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 删除
|
|
/// </summary>
|
|
/// <param name="SampleGroupId"></param>
|
|
/// <param name="AsbitemId"></param>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task DeleteAsync(Guid SampleGroupId, Guid AsbitemId)
|
|
{
|
|
// await _repository.DeleteAsync(d => d.AsbitemId == AsbitemId && d.SampleGroupId == SampleGroupId);
|
|
await _manager.CheckAndDeleteInSampleGroupIdAndAsbitemIdAsync(SampleGroupId, AsbitemId);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取列表 标本分组包含的组合项目
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
public async Task<List<AsbitemDto>> GetSampleGroupInAsbitemAsync(SampleGroupInAsbitemDto input)
|
|
{
|
|
|
|
var entlist = (await _repository.GetDbSetAsync()).Include(c => c.Asbitem)
|
|
.Where(m => m.SampleGroupId == input.SampleGroupId).ToList();
|
|
var userList = await _userRepository.GetListAsync();
|
|
var entdto = entlist.Select(s => new AsbitemDto
|
|
{
|
|
ClinicalMeaning = s.Asbitem.ClinicalMeaning,
|
|
CreationTime = s.Asbitem.CreationTime,
|
|
CreatorId = s.Asbitem.CreatorId,
|
|
DefaultResult = s.Asbitem.DefaultResult,
|
|
DeviceTypeId = s.Asbitem.DeviceTypeId,
|
|
DiagnosisFunction = s.Asbitem.DiagnosisFunction,
|
|
DisplayName = s.Asbitem.DisplayName,
|
|
DisplayOrder = s.Asbitem.DisplayOrder,
|
|
ForSexId = s.Asbitem.ForSexId,
|
|
Id = s.Asbitem.Id,
|
|
//InvoiceItemTypeId = s.Asbitem.InvoiceItemTypeId,
|
|
IsActive = s.Asbitem.IsActive,
|
|
IsBeforeEat = s.Asbitem.IsBeforeEat,
|
|
IsCheck = s.Asbitem.IsCheck,
|
|
IsContinueProcess = s.Asbitem.IsContinueProcess,
|
|
IsDiagnosisFunction = s.Asbitem.IsDiagnosisFunction,
|
|
IsItemResultMerger = s.Asbitem.IsItemResultMerger,
|
|
IsPictureRotate = s.Asbitem.IsPictureRotate,
|
|
ItemTypeId = s.Asbitem.ItemTypeId,
|
|
LastModificationTime = s.Asbitem.LastModificationTime,
|
|
LastModifierId = s.Asbitem.LastModifierId,
|
|
Price = s.Asbitem.Price,
|
|
QueueTime = s.Asbitem.QueueTime,
|
|
ShortName = s.Asbitem.ShortName,
|
|
SimpleCode = s.Asbitem.SimpleCode,
|
|
CreatorName = EntityHelper.GetSurnameNoSql(userList, s.Asbitem.CreatorId),
|
|
LastModifierName = EntityHelper.GetSurnameNoSql(userList, s.Asbitem.LastModifierId)
|
|
}).ToList();
|
|
|
|
return entdto;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|