Browse Source

导图、删图增加判断

bjmzak
wxd 2 years ago
parent
commit
b404e035fe
  1. 11
      src/Shentun.Peis.Application.Contracts/MyUser/OrganizationUnitIdIuputDto.cs
  2. 36
      src/Shentun.Peis.Application/MyUser/MyUserAppService.cs
  3. 51
      src/Shentun.Peis.Application/RegisterCheckPictures/RegisterCheckPictureAppService.cs

11
src/Shentun.Peis.Application.Contracts/MyUser/OrganizationUnitIdIuputDto.cs

@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.Peis.MyUser
{
public class OrganizationUnitIdIuputDto
{
public Guid? OrganizationUnitId { get; set; }
}
}

36
src/Shentun.Peis.Application/MyUser/MyUserAppService.cs

@ -59,7 +59,7 @@ namespace Shentun.Peis.MyUser
private readonly IHttpClientFactory _httpClientFactory; private readonly IHttpClientFactory _httpClientFactory;
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly IRepository<OrganizationUnit, Guid> _organizationUnitRepository; private readonly IRepository<OrganizationUnit, Guid> _organizationUnitRepository;
//private readonly IRepository<IdentityUserOrganizationUnit> _identityUserOrganizationUnitRepository;
private readonly IRepository<IdentityUserOrganizationUnit> _identityUserOrganizationUnitRepository;
private readonly CurrentUser _currentUser; private readonly CurrentUser _currentUser;
private readonly IDistributedCache<IdentityUser, Guid> _userCache; private readonly IDistributedCache<IdentityUser, Guid> _userCache;
@ -75,7 +75,7 @@ namespace Shentun.Peis.MyUser
PeisOrganizationUnitManager peisOrganizationUnitManager, PeisOrganizationUnitManager peisOrganizationUnitManager,
IHttpClientFactory httpClientFactory, IHttpClientFactory httpClientFactory,
IConfiguration configuration, IConfiguration configuration,
//IRepository<IdentityUserOrganizationUnit> identityUserOrganizationUnitRepository,
IRepository<IdentityUserOrganizationUnit> identityUserOrganizationUnitRepository,
CurrentUser currentUser, CurrentUser currentUser,
IDistributedCache<IdentityUser, Guid> userCache) : IDistributedCache<IdentityUser, Guid> userCache) :
base(userManager, base(userManager,
@ -93,7 +93,7 @@ namespace Shentun.Peis.MyUser
this._httpClientFactory = httpClientFactory; this._httpClientFactory = httpClientFactory;
this._configuration = configuration; this._configuration = configuration;
this._organizationUnitRepository = organizationUnitRepository; this._organizationUnitRepository = organizationUnitRepository;
// this._identityUserOrganizationUnitRepository = identityUserOrganizationUnitRepository;
this._identityUserOrganizationUnitRepository = identityUserOrganizationUnitRepository;
this._currentUser = currentUser; this._currentUser = currentUser;
_userCache = userCache; _userCache = userCache;
} }
@ -261,21 +261,29 @@ namespace Shentun.Peis.MyUser
return base.GetListAsync(input); return base.GetListAsync(input);
} }
/// <summary> /// <summary>
/// 获取列表 根据科室查询
/// </summary>
/// <param name="OrganizationUnitId">科室ID</param>
/// 获取列表 根据科室查询 不传科室查所有
/// </summary>
/// <param name="input"></param>
/// <returns></returns> /// <returns></returns>
[Authorize(PeisPermissions.Users.Default)] [Authorize(PeisPermissions.Users.Default)]
[HttpGet("api/identity/users/getlistinorganizationunit")]
public async Task<List<IdentityUserWithExtensionDto>> GetListInOrganizationUnitAsync(Guid OrganizationUnitId)
[HttpPost("api/identity/users/getlistinorganizationunit")]
public async Task<List<IdentityUserWithExtensionDto>> GetListInOrganizationUnitAsync(OrganizationUnitIdIuputDto input)
{ {
if (OrganizationUnitId == Guid.Empty)
List<IdentityUser> userList = new List<IdentityUser>();
var identityUserOrganizationUnitList = await _identityUserOrganizationUnitRepository.GetListAsync();
if (input.OrganizationUnitId != null && input.OrganizationUnitId != Guid.Empty)
{
List<Guid> organizationUnitIds = await _peisOrganizationUnitManager.GetOrganizationUnitChildIds(input.OrganizationUnitId.Value);
userList = await _userRepository.GetUsersInOrganizationsListAsync(organizationUnitIds);
}
else
{ {
throw new UserFriendlyException("参数有误");
userList = await _identityUserRepository.GetListAsync(m => m.IsDeleted == false);
} }
List<Guid> organizationUnitIds = await _peisOrganizationUnitManager.GetOrganizationUnitChildIds(OrganizationUnitId);
var entlist = await _userRepository.GetUsersInOrganizationsListAsync(organizationUnitIds);
var entlistdto = entlist.Select(s => new IdentityUserWithExtensionDto
var entlistdto = userList.Select(s => new IdentityUserWithExtensionDto
{ {
UserSign = s.GetProperty<string>("user_sign"), UserSign = s.GetProperty<string>("user_sign"),
UserPhoto = s.GetProperty<string>("user_photo"), UserPhoto = s.GetProperty<string>("user_photo"),
@ -300,7 +308,7 @@ namespace Shentun.Peis.MyUser
Surname = s.Surname, Surname = s.Surname,
TenantId = s.TenantId, TenantId = s.TenantId,
UserName = s.UserName, UserName = s.UserName,
OrganizationUnitId = OrganizationUnitId,
OrganizationUnitId = identityUserOrganizationUnitList.FirstOrDefault(m => m.UserId == s.Id).OrganizationUnitId,
SimpleCode = LanguageConverter.GetPYSimpleCode(s.Surname) SimpleCode = LanguageConverter.GetPYSimpleCode(s.Surname)
}).ToList(); }).ToList();

51
src/Shentun.Peis.Application/RegisterCheckPictures/RegisterCheckPictureAppService.cs

@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Shentun.Peis.Enums;
using Shentun.Peis.GuideTypes; using Shentun.Peis.GuideTypes;
using Shentun.Peis.Models; using Shentun.Peis.Models;
using System; using System;
@ -26,6 +27,8 @@ namespace Shentun.Peis.RegisterCheckPictures
private readonly IRepository<IdentityUser, Guid> _userRepository; private readonly IRepository<IdentityUser, Guid> _userRepository;
private readonly IRepository<RegisterCheckPicture, Guid> _registerCheckPictureRepository; private readonly IRepository<RegisterCheckPicture, Guid> _registerCheckPictureRepository;
private readonly IRepository<RegisterCheckAsbitem, Guid> _registerAsbitemRepository; private readonly IRepository<RegisterCheckAsbitem, Guid> _registerAsbitemRepository;
private readonly IRepository<RegisterCheck, Guid> _registerCheckRepository;
private readonly IRepository<PatientRegister, Guid> _patientRegisterRepository;
private readonly RegisterCheckPictureManager _registerCheckPictureManager; private readonly RegisterCheckPictureManager _registerCheckPictureManager;
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
@ -34,13 +37,17 @@ namespace Shentun.Peis.RegisterCheckPictures
RegisterCheckPictureManager registerCheckPictureManager, RegisterCheckPictureManager registerCheckPictureManager,
IRepository<IdentityUser, Guid> userRepository, IRepository<IdentityUser, Guid> userRepository,
IRepository<RegisterCheckAsbitem, Guid> registerAsbitemRepository, IRepository<RegisterCheckAsbitem, Guid> registerAsbitemRepository,
IConfiguration configuration)
IConfiguration configuration,
IRepository<RegisterCheck, Guid> registerCheckRepository,
IRepository<PatientRegister, Guid> patientRegisterRepository)
{ {
_registerCheckPictureRepository = registerCheckPictureRepository; _registerCheckPictureRepository = registerCheckPictureRepository;
_registerCheckPictureManager = registerCheckPictureManager; _registerCheckPictureManager = registerCheckPictureManager;
_userRepository = userRepository; _userRepository = userRepository;
_registerAsbitemRepository = registerAsbitemRepository; _registerAsbitemRepository = registerAsbitemRepository;
_configuration = configuration; _configuration = configuration;
_registerCheckRepository = registerCheckRepository;
_patientRegisterRepository = patientRegisterRepository;
} }
/// <summary> /// <summary>
@ -148,15 +155,21 @@ namespace Shentun.Peis.RegisterCheckPictures
string PatientRegisterId = ""; string PatientRegisterId = "";
var registerAsbitemEntity = await _registerAsbitemRepository.FirstOrDefaultAsync(m => m.RegisterCheckId == input.RegisterCheckId);
if (registerAsbitemEntity != null)
{
PatientRegisterId = registerAsbitemEntity.PatientRegisterId.ToString();
}
else
{
var patientRegisterCompleteFlag = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync()
join registerCheck in await _registerCheckRepository.GetQueryableAsync() on patientRegister.Id equals registerCheck.PatientRegisterId
where registerCheck.Id == input.RegisterCheckId
select new
{
CompleteFlag = patientRegister.CompleteFlag
}).ToList();
if (patientRegisterCompleteFlag.Count == 0)
throw new UserFriendlyException("体检人员不存在"); throw new UserFriendlyException("体检人员不存在");
}
if (patientRegisterCompleteFlag.FirstOrDefault().CompleteFlag == PatientRegisterCompleteFlag.PreRegistration)
throw new UserFriendlyException("预登记人员不能导入图片");
if (patientRegisterCompleteFlag.FirstOrDefault().CompleteFlag == PatientRegisterCompleteFlag.SumCheck)
throw new UserFriendlyException("已总检人员不能导入图片");
List<RegisterCheckPicture> entlist_insert = new List<RegisterCheckPicture>(); List<RegisterCheckPicture> entlist_insert = new List<RegisterCheckPicture>();
@ -297,6 +310,26 @@ namespace Shentun.Peis.RegisterCheckPictures
{ {
if (ids.Any()) if (ids.Any())
{ {
var patientRegisterCompleteFlag = (from patientRegister in await _patientRegisterRepository.GetQueryableAsync()
join registerCheck in await _registerCheckRepository.GetQueryableAsync()
on patientRegister.Id equals registerCheck.PatientRegisterId
join registerCheckPicture in await _registerCheckPictureRepository.GetQueryableAsync()
on registerCheck.Id equals registerCheckPicture.RegisterCheckId
where ids.Contains(registerCheckPicture.Id)
select new
{
CompleteFlag = patientRegister.CompleteFlag
}).ToList();
if (patientRegisterCompleteFlag.Count == 0)
throw new UserFriendlyException("Id不存在");
if (patientRegisterCompleteFlag.FirstOrDefault().CompleteFlag == PatientRegisterCompleteFlag.SumCheck)
{
throw new UserFriendlyException("已总检人员不能删除图片");
}
await _registerCheckPictureRepository.DeleteAsync(m => ids.Contains(m.Id)); await _registerCheckPictureRepository.DeleteAsync(m => ids.Contains(m.Id));
} }
else else

Loading…
Cancel
Save