|
|
|
@ -71,7 +71,7 @@ namespace Shentun.WebPeis.Persons |
|
|
|
IRepository<PatientRegister> patientRegisterRepository, |
|
|
|
IRepository<Patient> patientRepository, |
|
|
|
CacheService cacheService, |
|
|
|
//IHttpContextAccessor httpContextAccessor,
|
|
|
|
IHttpContextAccessor httpContextAccessor, |
|
|
|
IRepository<CustomerOrg> customerOrgRepository) |
|
|
|
{ |
|
|
|
_repository = repository; |
|
|
|
@ -85,7 +85,7 @@ namespace Shentun.WebPeis.Persons |
|
|
|
_patientRegisterRepository = patientRegisterRepository; |
|
|
|
_patientRepository = patientRepository; |
|
|
|
_cacheService = cacheService; |
|
|
|
//_httpContextAccessor = httpContextAccessor;
|
|
|
|
_httpContextAccessor = httpContextAccessor; |
|
|
|
_customerOrgRepository = customerOrgRepository; |
|
|
|
} |
|
|
|
|
|
|
|
@ -130,11 +130,14 @@ namespace Shentun.WebPeis.Persons |
|
|
|
|
|
|
|
var dicStr = dic.Select(m => m.Key + "=" + m.Value).DefaultIfEmpty().Aggregate((m, n) => m + "&" + n); |
|
|
|
var token = await GetTokenAsync(dicStr); |
|
|
|
var options = new DistributedCacheEntryOptions() |
|
|
|
.SetAbsoluteExpiration(TimeSpan.FromDays(3)); |
|
|
|
var sessionKey = CacheKeys.SessionKey + Guid.NewGuid().ToString(); |
|
|
|
var sessionKeyValue = Guid.NewGuid().ToString(); |
|
|
|
_cache.Set(sessionKey, sessionKeyValue); |
|
|
|
_cache.Set(sessionKey, sessionKeyValue, options); |
|
|
|
token.SessionKey = sessionKey; |
|
|
|
token.SessionKeyValue = sessionKeyValue; |
|
|
|
|
|
|
|
return token; |
|
|
|
|
|
|
|
} |
|
|
|
@ -187,7 +190,7 @@ namespace Shentun.WebPeis.Persons |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("该身份证号已注册,但手机号码不一致"); |
|
|
|
} |
|
|
|
if(!string.IsNullOrWhiteSpace(person.WechatOpenId)) |
|
|
|
if (!string.IsNullOrWhiteSpace(person.WechatOpenId)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("该微信号已注册"); |
|
|
|
} |
|
|
|
@ -240,7 +243,7 @@ namespace Shentun.WebPeis.Persons |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建亲属
|
|
|
|
/// </summary>
|
|
|
|
@ -267,12 +270,12 @@ namespace Shentun.WebPeis.Persons |
|
|
|
throw new UserFriendlyException("无效的短信校验码或已过期"); |
|
|
|
} |
|
|
|
|
|
|
|
var person = await _repository.FindAsync(o=>o.IdNo == input.IdNo); |
|
|
|
var person = await _repository.FindAsync(o => o.IdNo == input.IdNo); |
|
|
|
if (person != null) |
|
|
|
{ |
|
|
|
var user = (await _identityUserRepository.GetQueryableAsync()).Where(o =>o.Id == person.PersonId && |
|
|
|
o.PhoneNumber == input.MobileTelephone).FirstOrDefault(); |
|
|
|
if(user == null) |
|
|
|
var user = (await _identityUserRepository.GetQueryableAsync()).Where(o => o.Id == person.PersonId && |
|
|
|
o.PhoneNumber == input.MobileTelephone).FirstOrDefault(); |
|
|
|
if (user == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("该身份证号已注册,但手机号码不一致"); |
|
|
|
} |
|
|
|
@ -285,9 +288,9 @@ namespace Shentun.WebPeis.Persons |
|
|
|
await _personKinshipRepository.InsertAsync(personKinshipExist); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var userWithPerson = await _personManager.CreateAsync(entity, input.PersonName, |
|
|
|
input.Email, input.MobileTelephone); |
|
|
|
|
|
|
|
@ -306,15 +309,15 @@ namespace Shentun.WebPeis.Persons |
|
|
|
(await _userManager.RemovePasswordAsync(userWithPerson.User)).CheckErrors(); |
|
|
|
(await _userManager.AddPasswordAsync(userWithPerson.User, Shentun.Utilities. |
|
|
|
Encrypt.RandomHelper.CreateRandom(Utilities.Enums.RandomType.NumAndChar, 10) + "0Cz*")).CheckErrors(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取体检次数列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <summary>
|
|
|
|
/// 获取体检次数列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="input"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpPost("api/app/Person/GetMedicalTimesListByPersonId")] |
|
|
|
public async Task<List<PersonMedicalTimesDto>> GetMedicalTimesListByPersonIdAsync(PersonIdInputDto input) |
|
|
|
{ |
|
|
|
@ -323,11 +326,11 @@ namespace Shentun.WebPeis.Persons |
|
|
|
join person in await _repository.GetQueryableAsync() |
|
|
|
on user.Id equals person.PersonId |
|
|
|
join patient in await _patientRepository.GetQueryableAsync() |
|
|
|
on new { idNo = person.IdNo ,phone = user.PhoneNumber} equals new { idNo = patient.IdNo, phone = patient.MobileTelephone } |
|
|
|
on new { idNo = person.IdNo, phone = user.PhoneNumber } equals new { idNo = patient.IdNo, phone = patient.MobileTelephone } |
|
|
|
join patientRegister in await _patientRegisterRepository.GetQueryableAsync() |
|
|
|
on patient.PatientId equals patientRegister.PatientId |
|
|
|
where user.Id == input.PersonId && |
|
|
|
( patientRegister.CompleteFlag == PatientRegisterCompleteFlag.Audit) |
|
|
|
where user.Id == input.PersonId && |
|
|
|
(patientRegister.CompleteFlag == PatientRegisterCompleteFlag.Audit) |
|
|
|
orderby patientRegister.MedicalStartDate |
|
|
|
select new PersonMedicalTimesDto() |
|
|
|
{ |
|
|
|
@ -365,10 +368,10 @@ namespace Shentun.WebPeis.Persons |
|
|
|
MaritalStatusName = _cacheService.GetMaritalStatusNameAsync(person.MaritalStatusId).Result, |
|
|
|
IdNo = person.IdNo, |
|
|
|
MobileTelephone = user.PhoneNumber |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}).ToList(); |
|
|
|
for(var i = 0; i<personList.Count;i++) |
|
|
|
for (var i = 0; i < personList.Count; i++) |
|
|
|
{ |
|
|
|
personList[i].DisplayOrder = i + 1; |
|
|
|
if (personList[i].PersonId == CurrentUser.Id) |
|
|
|
@ -376,7 +379,7 @@ namespace Shentun.WebPeis.Persons |
|
|
|
personList[i].DisplayOrder = 0; //本人强行排第一个
|
|
|
|
} |
|
|
|
} |
|
|
|
personList = personList.OrderBy(o=>o.DisplayOrder).ToList(); |
|
|
|
personList = personList.OrderBy(o => o.DisplayOrder).ToList(); |
|
|
|
return personList; |
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
@ -388,19 +391,19 @@ namespace Shentun.WebPeis.Persons |
|
|
|
[HttpPost("api/app/Person/GetMedicalReportByPatientRegisterId")] |
|
|
|
public async Task<MedicalReportDto> GetMedicalReportByPatientRegisterIdAsync(PatientRegisterIdInputDto input) |
|
|
|
{ |
|
|
|
var entity = await _patientRegisterRepository.GetAsync(o=>o.PatientRegisterId == input.PatientRegisterId); |
|
|
|
if(string.IsNullOrWhiteSpace(entity.ReportFile)) |
|
|
|
var entity = await _patientRegisterRepository.GetAsync(o => o.PatientRegisterId == input.PatientRegisterId); |
|
|
|
if (string.IsNullOrWhiteSpace(entity.ReportFile)) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("没有报告单"); |
|
|
|
} |
|
|
|
var Host = $"{_httpContextAccessor.HttpContext.Request.Scheme}://{_httpContextAccessor.HttpContext.Request.Host.Host}:{ _httpContextAccessor.HttpContext.Request.Host.Port}"; |
|
|
|
var Host = $"{_httpContextAccessor.HttpContext.Request.Scheme}://{_httpContextAccessor.HttpContext.Request.Host.Host}:{_httpContextAccessor.HttpContext.Request.Host.Port}"; |
|
|
|
var returnValue = new MedicalReportDto() |
|
|
|
{ |
|
|
|
FilePath = entity.ReportFile, |
|
|
|
FileBase64 = Shentun.Utilities.FileHelper.ToBase64(Host + entity.ReportFile) |
|
|
|
}; |
|
|
|
}; |
|
|
|
return returnValue; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
/// <summary>
|
|
|
|
/// 获取校验码
|
|
|
|
@ -412,7 +415,7 @@ namespace Shentun.WebPeis.Persons |
|
|
|
[HttpPost("api/app/Person/GetSmsVerifyCode")] |
|
|
|
public async Task<SmsVerifyCodeDto> GetSmsVerifyCodeAsync(SmsVerifyCodeInputDto input) |
|
|
|
{ |
|
|
|
if(input == null) |
|
|
|
if (input == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("input不能为空"); |
|
|
|
} |
|
|
|
@ -463,7 +466,7 @@ namespace Shentun.WebPeis.Persons |
|
|
|
if (person != null) |
|
|
|
{ |
|
|
|
var user = (await _identityUserRepository.GetQueryableAsync()).Where(o => o.Id == person.PersonId && |
|
|
|
o.PhoneNumber == input.MobileTelephone).FirstOrDefault(); |
|
|
|
o.PhoneNumber == input.MobileTelephone).FirstOrDefault(); |
|
|
|
if (user == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("该身份证号已注册,但手机号码不一致"); |
|
|
|
@ -517,7 +520,7 @@ namespace Shentun.WebPeis.Persons |
|
|
|
OpenId = wechatUserDto.OpenId |
|
|
|
}; |
|
|
|
var options = new DistributedCacheEntryOptions() |
|
|
|
.SetAbsoluteExpiration(TimeSpan.FromMinutes(720)); |
|
|
|
.SetAbsoluteExpiration(TimeSpan.FromDays(3)); |
|
|
|
_cache.Set(CacheKeys.OpenIdKey + wechatUserDto.OpenId, |
|
|
|
wechatUserDto.OpenId, options); |
|
|
|
|
|
|
|
@ -557,7 +560,7 @@ namespace Shentun.WebPeis.Persons |
|
|
|
|
|
|
|
public async Task<string> SendVerifySms(CreateSmsTaskDto createSmsTaskDto) |
|
|
|
{ |
|
|
|
if(createSmsTaskDto == null) |
|
|
|
if (createSmsTaskDto == null) |
|
|
|
{ |
|
|
|
throw new UserFriendlyException("createSmsTaskDto参数不能为空"); |
|
|
|
} |
|
|
|
@ -571,20 +574,20 @@ namespace Shentun.WebPeis.Persons |
|
|
|
throw new Exception("解析校验短信有效时间错误"); |
|
|
|
} |
|
|
|
|
|
|
|
createSmsTaskDto.Content = message+"|" + verifySmsValidTime.ToString(); |
|
|
|
createSmsTaskDto.Content = message + "|" + verifySmsValidTime.ToString(); |
|
|
|
//发送短信
|
|
|
|
createSmsTaskDto.TaskCycleType = '0'; |
|
|
|
await SmsClientHelper.CreateVerifySmsTask(createSmsTaskDto); |
|
|
|
//存储短信校验码
|
|
|
|
var options = new DistributedCacheEntryOptions() |
|
|
|
.SetAbsoluteExpiration(TimeSpan.FromMinutes(verifySmsValidTime)); |
|
|
|
var smsVerifyCodeKey = CacheKeys.SmsKey + createSmsTaskDto.MobileTelephone + Guid.NewGuid().ToString(); |
|
|
|
var smsVerifyCodeKey = CacheKeys.SmsKey + createSmsTaskDto.MobileTelephone + Guid.NewGuid().ToString(); |
|
|
|
_cache.Set(smsVerifyCodeKey, message, options); |
|
|
|
return smsVerifyCodeKey; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |