Browse Source

修改人员信息

master
DESKTOP-G961P6V\Zhh 2 years ago
parent
commit
ad669e43da
  1. 36
      src/Shentun.WebPeis.Application.Contracts/Persons/PersonDto.cs
  2. 4
      src/Shentun.WebPeis.Application.Contracts/Persons/SmsVerifyCodeInputDto.cs
  3. 111
      src/Shentun.WebPeis.Application.Contracts/Persons/UpdatePersonDto.cs
  4. 96
      src/Shentun.WebPeis.Application/Persons/PersonAppService.cs
  5. 2
      src/Shentun.WebPeis.Application/WebPeisApplicationAutoMapperProfile.cs
  6. 8
      src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs
  7. 35
      src/Shentun.WebPeis.Domain/Persons/PersonManager.cs
  8. 14
      test/Shentun.WebPeis.Application.Tests/PersonAppServiceTest.cs

36
src/Shentun.WebPeis.Application.Contracts/Persons/PersonDto.cs

@ -29,12 +29,18 @@ namespace Shentun.WebPeis.Persons
/// 性别
/// </summary>
public char SexId { get; set; }
/// <summary>
/// 性别名称
/// </summary>
public string SexName { get; set; }
/// <summary>
/// 婚姻状况
/// </summary>
public char MaritalStatusId { get; set; }
/// <summary>
/// 婚姻状况名
/// </summary>
public string MaritalStatusName { get; set; }
@ -47,6 +53,9 @@ namespace Shentun.WebPeis.Persons
/// 民族编号
/// </summary>
public string? NationId { get; set; }
/// <summary>
/// 民族名称
/// </summary>
public string? NationName { get; set; }
@ -84,20 +93,45 @@ namespace Shentun.WebPeis.Persons
/// 简码
/// </summary>
public string SimpleCode { get; set; } = null!;
/// <summary>
/// 身份证件类别ID
/// </summary>
public string? IdTypeId { get; set; }
public string? CountryCode { get; set; }
/// <summary>
/// 允许绑定
/// </summary>
public char? IsAllowBind { get; set; }
/// <summary>
/// 启用
/// </summary>
public char? IsActive { get; set; }
/// <summary>
/// 显示顺序
/// </summary>
public int DisplayOrder { get; set; }
/// <summary>
/// 有问卷
/// </summary>
public char IsHaveQuestionRegister { get; set; }
/// <summary>
/// 身高
/// </summary>
public decimal? Height { get; set; }
/// <summary>
/// 体重
/// </summary>
public decimal? Weight { get; set; }
}

4
src/Shentun.WebPeis.Application.Contracts/Persons/SmsVerifyCodeInputDto.cs

@ -6,6 +6,10 @@ namespace Shentun.WebPeis.Persons
{
public class SmsVerifyCodeInputDto
{
/// <summary>
/// 人员ID
/// </summary>
public Guid? PersonId { get; set; }
/// <summary>
/// 微信OpenId
/// </summary>

111
src/Shentun.WebPeis.Application.Contracts/Persons/UpdatePersonDto.cs

@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace Shentun.WebPeis.Persons
{
public class UpdatePersonDto
{
/// <summary>
/// 人员ID
/// </summary>
public Guid PersonId { get; set; }
/// <summary>
/// 姓名
/// </summary>
public string PersonName { get; set; } = null!;
/// <summary>
/// 性别
/// </summary>
public char SexId { get; set; }
/// <summary>
/// 婚姻状况
/// </summary>
public char MaritalStatusId { get; set; }
/// <summary>
/// 出生日期
/// </summary>
public DateTime? BirthDate { get; set; }
/// <summary>
/// 民族编号
/// </summary>
public string? NationId { get; set; }
/// <summary>
/// 出生地
/// </summary>
public Guid? BirthPlaceId { get; set; }
/// <summary>
/// 身份证号
/// </summary>
public string? IdNo { get; set; }
/// <summary>
/// 邮政编码
/// </summary>
public string? PostalCode { get; set; }
/// <summary>
/// email
/// </summary>
public string? Email { get; set; }
/// <summary>
/// 手机号
/// </summary>
public string? MobileTelephone { get; set; }
/// <summary>
/// 地址
/// </summary>
public string? Address { get; set; }
/// <summary>
/// 身份证件类别
/// </summary>
public string? IdTypeId { get; set; }
/// <summary>
/// 国家码
/// </summary>
public string? CountryCode { get; set; }
/// <summary>
/// 允许绑定
/// </summary>
public char? IsAllowBind { get; set; }
/// <summary>
/// 身高
/// </summary>
public decimal? Height { get; set; }
/// <summary>
/// 体重
/// </summary>
public decimal? Weight { get; set; }
/// <summary>
/// 短信校验码
/// </summary>
public string SmsVerifyCode { get; set; }
/// <summary>
/// 短信校验码键
/// </summary>
public string SmsVerifyCodeKey { get; set; }
/// <summary>
/// 会话键
/// </summary>
public string SessionKey { get; set; }
/// <summary>
/// 会话键值
/// </summary>
public string SessionKeyValue { get; set; }
}
}

96
src/Shentun.WebPeis.Application/Persons/PersonAppService.cs

@ -243,7 +243,48 @@ namespace Shentun.WebPeis.Persons
}
/// <summary>
/// 更新
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
/// <exception cref="UserFriendlyException"></exception>
[HttpPost("api/app/Person/Update")]
public async Task<PersonDto> UpdateAsync(UpdatePersonDto input)
{
var entity = ObjectMapper.Map<UpdatePersonDto, Person>(input);
if (string.IsNullOrWhiteSpace(input.MobileTelephone))
{
throw new UserFriendlyException("手机号码不能为空");
}
if (input.MobileTelephone.Length != 11)
{
throw new UserFriendlyException("手机号码必须为11位");
}
if (string.IsNullOrWhiteSpace(input.SmsVerifyCodeKey))
{
throw new UserFriendlyException("短信校验码键不能为空");
}
if (_cache.Get(input.SmsVerifyCodeKey) != input.SmsVerifyCode)
{
throw new UserFriendlyException("无效的短信校验码或已过期");
}
//更新人员信息
var person = await _repository.GetAsync(o =>o.PersonId == input.PersonId);
await _personManager.UpdateAsync(entity, person);
await _repository.UpdateAsync(person);
//更新用户信息
var user = await _identityUserRepository.GetAsync(person.PersonId);
user.Name = input.PersonName;
user.SetPhoneNumber(input.MobileTelephone,false);
await _identityUserRepository.UpdateAsync(user);
return ObjectMapper.Map<Person, PersonDto>(person);
}
/// <summary>
/// 创建亲属
/// </summary>
@ -313,6 +354,18 @@ namespace Shentun.WebPeis.Persons
}
/// <summary>
/// 取消人员绑定
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
[HttpPost("api/app/Person/CancelPersonKinship")]
public async Task CancelPersonKinshipAsync(PersonIdInputDto input)
{
var personKinship = await _personKinshipRepository.GetAsync(o => o.ParentPersonId == (Guid)CurrentUser.Id && o.PersonId == input.PersonId);
await _personKinshipRepository.DeleteAsync(personKinship);
}
/// <summary>
/// 获取体检次数列表
/// </summary>
@ -364,14 +417,28 @@ namespace Shentun.WebPeis.Persons
select new PersonDto
{
PersonId = user.Id,
PersonNo = person.PersonNo,
MedicalCenterId = person.MedicalCenterId,
PersonName = user.Name,
SexId = person.SexId,
SexName = _cacheService.GetSexNameAsync(person.SexId).Result,
MaritalStatusId = person.MaritalStatusId,
MaritalStatusName = _cacheService.GetMaritalStatusNameAsync(person.MaritalStatusId).Result,
BirthDate = person.BirthDate,
NationId = person.NationId,
NationName = _cacheService.GetNationNameAsync(person.NationId).Result,
BirthPlaceId = person.BirthPlaceId,
IdNo = person.IdNo,
PostalCode = person.PostalCode,
Email = user.Email,
MobileTelephone = user.PhoneNumber,
IsHaveQuestionRegister = haveQuestionRegister == null ? 'N' : 'Y'
Address = person.Address,
IdTypeId = person.IdTypeId,
CountryCode = person.CountryCode,
IsAllowBind = person.IsAllowBind,
IsHaveQuestionRegister = haveQuestionRegister == null ? 'N' : 'Y',
Height = person.Height,
Weight = person.Weight
}).Distinct().ToList();
@ -527,23 +594,26 @@ namespace Shentun.WebPeis.Persons
throw new UserFriendlyException("身份证长度必须为18位");
}
//var sexByIdNo = ConvertExtr.ToSexByIdNo(idNo).ToCharArray();
var person = await _repository.FindAsync(o => o.IdNo == input.IdNo);
if (person != null)
if (input.PersonId == null || input.PersonId == default(Guid))
{
var user = (await _identityUserRepository.GetQueryableAsync()).Where(o => o.Id == person.PersonId &&
o.PhoneNumber == input.MobileTelephone).FirstOrDefault();
if (user == null)
var person = await _repository.FindAsync(o => o.IdNo == input.IdNo);
if (person != null)
{
throw new UserFriendlyException("该身份证号已注册,但手机号码不一致");
var user = (await _identityUserRepository.GetQueryableAsync()).Where(o => o.Id == person.PersonId &&
o.PhoneNumber == input.MobileTelephone).FirstOrDefault();
if (user == null)
{
throw new UserFriendlyException("该身份证号已注册,但手机号码不一致");
}
//if (!string.IsNullOrWhiteSpace(person.WechatOpenId))
//{
// throw new UserFriendlyException("该微信号已注册");
//}
}
//if (!string.IsNullOrWhiteSpace(person.WechatOpenId))
//{
// throw new UserFriendlyException("该微信号已注册");
//}
}
var createSmsTaskDto = new CreateSmsTaskDto()
{
PersonId = "0001",

2
src/Shentun.WebPeis.Application/WebPeisApplicationAutoMapperProfile.cs

@ -50,6 +50,8 @@ public class WebPeisApplicationAutoMapperProfile : Profile
CreateMap<CreatePersonDto, Person>();
CreateMap<CreatePersonKinshipDto, Person>();
CreateMap<UpdatePersonDto, Person>();
CreateMap<CreateNationDto, Nation>();
CreateMap<UpdateNationDto, Nation>();

8
src/Shentun.WebPeis.Domain/AppointPatientRegisters/AppointPatientRegisterManager.cs

@ -212,10 +212,11 @@ namespace Shentun.WebPeis.AppointPatientRegisters
throw new UserFriendlyException("单位分组项目不能取消");
}
});
foreach(var asbitem in entity.AppointRegisterAsbitems)
decimal addMoney = 0;
var customerOrgGroup = await _customerOrgGroupRepository.GetAsync(o => o.CustomerOrgGroupId == entity.CustomerOrgGroupId);
foreach (var asbitem in entity.AppointRegisterAsbitems)
{
decimal addMoney = 0;
var customerOrgGroupDetail = customerOrgGroupDetails.Where(o => o.AsbitemId == asbitem.AsbitemId).FirstOrDefault();
if(customerOrgGroupDetail == null)
{
@ -224,7 +225,6 @@ namespace Shentun.WebPeis.AppointPatientRegisters
if(addMoney > 0)
{
var customerOrgGroup = await _customerOrgGroupRepository.GetAsync(o => o.CustomerOrgGroupId == entity.CustomerOrgGroupId);
if(addMoney > customerOrgGroup.CanAddMoney)
{
throw new UserFriendlyException($"自选的单位支付金额不能超过{customerOrgGroup.CanAddMoney}元");

35
src/Shentun.WebPeis.Domain/Persons/PersonManager.cs

@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration.UserSecrets;
using NPOI.POIFS.FileSystem;
using Shentun.Utilities;
using Shentun.Utilities.Enums;
using Shentun.WebPeis.Models;
@ -73,26 +74,26 @@ namespace Shentun.WebPeis.Persons
{
throw new UserFriendlyException("该手机号已经在人员信息中注册");
}
var wechatPerson = await _repository.FindAsync(o => o.WechatOpenId == entity.WechatOpenId
var wechatPerson = await _repository.FindAsync(o => o.WechatOpenId == entity.WechatOpenId
&& !string.IsNullOrWhiteSpace(entity.WechatOpenId));
if (wechatPerson != null)
{
throw new UserFriendlyException("该微信号已经注册");
}
entity.PersonNo = await CreatePersonNoAsync(entity.MedicalCenterId);
if(string.IsNullOrWhiteSpace(email))
if (string.IsNullOrWhiteSpace(email))
{
email = entity.PersonNo + "@qq.com";
}
var user = new IdentityUser(GuidGenerator.Create(), entity.PersonNo, email)
{
Name = name,
};
user.SetPhoneNumber(phone, false);
// await _identityUserManager.CreateAsync(user);
// await _identityUserManager.CreateAsync(user);
if (!string.IsNullOrWhiteSpace(entity.IdNo))
@ -119,7 +120,27 @@ namespace Shentun.WebPeis.Persons
}
public async Task UpdateAsync(Person sourceEntity,
Person targetEntity
)
{
sourceEntity.MedicalCenterId = targetEntity.MedicalCenterId;
await Verify(sourceEntity);
targetEntity.SexId = sourceEntity.SexId;
targetEntity.MaritalStatusId = sourceEntity.MaritalStatusId;
targetEntity.BirthDate = sourceEntity.BirthDate;
targetEntity.NationId = sourceEntity.NationId;
targetEntity.BirthPlaceId = sourceEntity.BirthPlaceId;
targetEntity.IdNo = sourceEntity.IdNo;
targetEntity.PostalCode = sourceEntity.PostalCode;
targetEntity.Address = sourceEntity.Address;
targetEntity.IdTypeId = sourceEntity.IdTypeId;
targetEntity.IsAllowBind = sourceEntity.IsAllowBind;
targetEntity.Height = sourceEntity.Height;
targetEntity.Weight = sourceEntity.Weight;
}
private async Task Verify(Person entity)
{
Check.NotNull(entity, "entity");
@ -127,7 +148,7 @@ namespace Shentun.WebPeis.Persons
Check.NotNullOrWhiteSpace(entity.NationId, "民族");
CheckExter.CheckSex(entity.SexId);
CheckExter.CheckMaritalStatus(entity.MaritalStatusId);
if(string.IsNullOrWhiteSpace(entity.IdTypeId))
if (string.IsNullOrWhiteSpace(entity.IdTypeId))
{
entity.IdTypeId = "01";
}
@ -143,7 +164,7 @@ namespace Shentun.WebPeis.Persons
{
throw new UserFriendlyException("体检中心不能为空");
}
if (!string.IsNullOrEmpty(entity.IdNo))
{

14
test/Shentun.WebPeis.Application.Tests/PersonAppServiceTest.cs

@ -83,6 +83,20 @@ namespace Shentun.WebPeis
}
}
[Fact]
public async Task UpdateAsync()
{
using (var unitOfWork = _unitOfWorkManager.Begin(isTransactional: true))
{
var entity = await _repository.GetAsync(o => o.PersonId == new Guid("3a12d72c-19d9-e8b2-71f6-cf283103e191"));
//var newEntity = await _appService.UpdateAsync(entity);
await unitOfWork.CompleteAsync();
}
}
[Fact]
public async Task GetPersonKinshipList()
{

Loading…
Cancel
Save