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.
142 lines
5.0 KiB
142 lines
5.0 KiB
using AutoMapper.Internal.Mappers;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Shentun.Peis.Diagnosises;
|
|
using Shentun.Peis.AsbitemDetails;
|
|
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;
|
|
using Volo.Abp.Identity;
|
|
using TencentCloud.Ame.V20190916.Models;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Shentun.Peis.Items;
|
|
using Volo.Abp;
|
|
using Shentun.Peis.Models;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
namespace Shentun.Peis.AsbitemDetails
|
|
{
|
|
|
|
/// <summary>
|
|
/// 组合项目包含的小项目
|
|
/// </summary>
|
|
[ApiExplorerSettings(GroupName = "Work")]
|
|
[Authorize]
|
|
public class AsbitemDetailAppService : ApplicationService
|
|
{
|
|
private readonly IRepository<AsbitemDetail> _repository;
|
|
private readonly IRepository<IdentityUser, Guid> _userRepository;
|
|
private readonly AsbitemDetailManager _manager;
|
|
|
|
public AsbitemDetailAppService(IRepository<AsbitemDetail> repository, IRepository<IdentityUser, Guid> userRepository, AsbitemDetailManager manager)
|
|
{
|
|
this._repository = repository;
|
|
this._userRepository = userRepository;
|
|
this._manager = manager;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[RemoteService(false)]
|
|
public async Task<AsbitemDetailDto> CreateAsync(CreateAsbitemDetailDto input)
|
|
{
|
|
var createEntity = ObjectMapper.Map<CreateAsbitemDetailDto, AsbitemDetail>(input);
|
|
var entity = await _repository.InsertAsync(createEntity);
|
|
var dto = ObjectMapper.Map<AsbitemDetail, AsbitemDetailDto>(entity);
|
|
return dto;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 批量创建 先删除
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("api/app/asbitemdetail/createasbitemdetailmany")]
|
|
public async Task CreateAsbitemDetailManyAsync(CreateAsbitemDetailDto input)
|
|
{
|
|
await _manager.CheckAndDeleteAsync(input.AsbitemId);
|
|
|
|
if (input.Details.Any())
|
|
{
|
|
List<AsbitemDetail> asbitemDetails = new List<AsbitemDetail>();
|
|
foreach (var details in input.Details)
|
|
{
|
|
var entity = new AsbitemDetail
|
|
{
|
|
AsbitemId = input.AsbitemId,
|
|
ItemId = details.ItemId
|
|
};
|
|
asbitemDetails.Add(_manager.CreateAsbitemAsync(entity));
|
|
}
|
|
|
|
if (asbitemDetails.Count > 0)
|
|
{
|
|
await _repository.InsertManyAsync(asbitemDetails);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 获取列表 组合项目包含的小项目
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
public async Task<List<ItemDto>> GetAsbitemDetailInItemAsync(AsbitemDetailInItemDto input)
|
|
{
|
|
|
|
var entlist = _repository.GetDbSetAsync().Result.Include(c => c.Item)
|
|
.Where(m => m.AsbitemId == input.AsbitemId).ToList();
|
|
|
|
|
|
var userList = await _userRepository.GetListAsync();
|
|
|
|
var entdto = entlist.Select(s => new ItemDto
|
|
{
|
|
CreationTime = s.Item.CreationTime,
|
|
CreatorId = s.Item.CreatorId,
|
|
DisplayName = s.Item.DisplayName,
|
|
DisplayOrder = s.Item.DisplayOrder,
|
|
Id = s.Item.Id,
|
|
ItemTypeId = s.Item.ItemTypeId,
|
|
LastModificationTime = s.Item.LastModificationTime,
|
|
LastModifierId = s.Item.LastModifierId,
|
|
SimpleCode = s.Item.SimpleCode,
|
|
CalculationFunction = s.Item.CalculationFunction,
|
|
DefaultResult = s.Item.DefaultResult,
|
|
DiagnosisFunction = s.Item.DiagnosisFunction,
|
|
EnglishShortName = s.Item.EnglishShortName,
|
|
InputCheck = s.Item.InputCheck,
|
|
IsActive = s.Item.IsActive,
|
|
IsCalculationItem = s.Item.IsCalculationItem,
|
|
IsContinueProcess = s.Item.IsContinueProcess,
|
|
IsDiagnosisFunction = s.Item.IsDiagnosisFunction,
|
|
IsNameIntoSummary = s.Item.IsNameIntoSummary,
|
|
IsProduceSummary = s.Item.IsProduceSummary,
|
|
Price = s.Item.Price,
|
|
PriceItemId = s.Item.PriceItemId,
|
|
ReferenceRangeTypeFlag = s.Item.ReferenceRangeTypeFlag,
|
|
ResultTemplateTypeFlag = s.Item.ResultTemplateTypeFlag,
|
|
UnitId = s.Item.UnitId,
|
|
CreatorName = EntityHelper.GetUserNameNoSql(userList, s.Item.CreatorId),
|
|
LastModifierName = EntityHelper.GetUserNameNoSql(userList, s.Item.LastModifierId)
|
|
}).ToList();
|
|
|
|
return entdto;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|