public IActionResult GetAskedDoctorClassicQa([FromBody] GetAskedDoctorClassicQaRequestDto requestDto) { QaBiz qaBiz = new QaBiz(); var qaModels = qaBiz.GetQaModels(requestDto.PageIndex, requestDto.PageSize, "where enable=true", "last_updated_date desc"); if (qaModels == null) { return(Failed(ErrorCode.Empty)); } DoctorBiz doctorBiz = new DoctorBiz(); UserBiz userBiz = new UserBiz(); AccessoryBiz accessoryBiz = new AccessoryBiz(); LikeBiz likeBiz = new LikeBiz(); List <GetAskedDoctorClassicQaResponseDto> dtos = new List <GetAskedDoctorClassicQaResponseDto>(); foreach (var model in qaModels) { var dto = model.ToDto <GetAskedDoctorClassicQaResponseDto>(); dto.DoctorName = userBiz.GetUser(model.AuthorGuid)?.UserName; dto.LikeNumber = likeBiz.GetLikeNumByTargetGuid(model.QaGuid); var doctorModel = doctorBiz.GetDoctor(model.AuthorGuid); if (doctorModel != null) { var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(doctorModel.PortraitGuid); dto.DoctorPortrait = accessoryModel?.BasePath + accessoryModel?.RelativePath; } dtos.Add(dto); } return(Success(dtos)); }
public IActionResult GetDoctorDetails(string doctorGuid) { var doctorBiz = new DoctorBiz(); var model = doctorBiz.GetDoctor(doctorGuid); if (model == null) { return(Failed(ErrorCode.Empty)); } var userBiz = new UserBiz(); var dictionaryBiz = new DictionaryBiz(); var accessoryBiz = new AccessoryBiz(); var topicBiz = new TopicBiz(); var dto = model.ToDto <GetDoctorDetailsResponseDto>(); var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(model.PortraitGuid); dto.DoctorName = userBiz.GetUser(doctorGuid)?.UserName; dto.Title = dictionaryBiz.GetModelById(model.TitleGuid)?.ConfigName; dto.Portrait = $"{accessoryModel?.BasePath}{accessoryModel?.RelativePath}"; var signature = accessoryBiz.GetAccessoryModelByGuid(model.SignatureGuid); dto.SignatureUrl = $"{signature?.BasePath}{signature?.RelativePath}"; dto.CommentScore = new CommentBiz().GetTargetAvgScoreAsync(model.DoctorGuid).Result; dto.FansVolume = new CollectionBiz().GetListCountByTarget(model.DoctorGuid); dto.ConsultationVolume = doctorBiz.GetDocotrConsultationVolumeAsync(model.DoctorGuid).Result; return(Success(dto)); }
public IActionResult GetDoctorArticleDetails(string articleGuid) { ArticleBiz articleBiz = new ArticleBiz(); var model = articleBiz.GetModel(articleGuid); if (model == null) { return(Failed(ErrorCode.Empty)); } var doctorBiz = new DoctorBiz(); var accessoryBiz = new AccessoryBiz(); var userBiz = new UserBiz(); var likeBiz = new LikeBiz(); var richtextBiz = new RichtextBiz(); var dto = model.ToDto <GetDoctorArticleDetailsResponseDto>(); dto.Content = richtextBiz.GetModel(model.ContentGuid)?.Content; dto.DoctorName = userBiz.GetUser(model.AuthorGuid)?.UserName; var doctorModel = doctorBiz.GetDoctor(model.AuthorGuid); if (doctorModel != null) { var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(doctorModel.PortraitGuid); dto.DoctorPortrait = accessoryModel?.BasePath + accessoryModel?.RelativePath; dto.HospitalGuid = doctorModel.HospitalGuid; dto.HospitalName = doctorModel.HospitalName; dto.OfficeGuid = doctorModel.OfficeGuid; dto.OfficeName = doctorModel.OfficeName; } dto.LikeNumber = likeBiz.GetLikeNumByTargetGuid(articleGuid); dto.Liked = likeBiz.GetLikeState(UserID, articleGuid); return(Success(dto)); }
public async Task <IActionResult> GetDoctorIntegralPageAsync([FromBody] GetDoctorIntegralPageRequestDto request) { DoctorBiz doctorBiz = new DoctorBiz(); ScoreBiz scoreBiz = new ScoreBiz(); var response = await doctorBiz.GetDoctorIntegralAsync(request); if (!response.CurrentPage.Any()) { return(Success(response)); } var users = response.CurrentPage.Select(a => a.DoctorGuid).ToArray(); var totalPoints = await scoreBiz.GetUserPointsAsync(users); var earnPoints = await scoreBiz.GetUserEarnPointsAsync(users); var usePoints = await scoreBiz.GetUserUsePointsAsync(users); foreach (var item in response.CurrentPage) { item.TotalPoints = totalPoints.FirstOrDefault(a => a.UserGuid == item.DoctorGuid)?.Variation ?? 0; item.EarnPoints = earnPoints.FirstOrDefault(a => a.UserGuid == item.DoctorGuid)?.Variation ?? 0; item.UsePoints = usePoints.FirstOrDefault(a => a.UserGuid == item.DoctorGuid)?.Variation ?? 0; } return(Success(response)); }
public IActionResult GetAskedDoctorClassicQaDetails(string qaGuid) { var qaBiz = new QaBiz(); var doctorBiz = new DoctorBiz(); var accessoryBiz = new AccessoryBiz(); var userBiz = new UserBiz(); var likeBiz = new LikeBiz(); var dictionaryBiz = new DictionaryBiz(); var model = qaBiz.GetModel(qaGuid); if (model == null) { return(Failed(ErrorCode.Empty)); } var dto = model.ToDto <GetAskedDoctorClassicQaDetailsResponseDto>(); dto.DoctorName = userBiz.GetUser(model.AuthorGuid)?.UserName; var doctorModel = doctorBiz.GetDoctor(model.AuthorGuid); if (doctorModel != null) { var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(doctorModel.PortraitGuid); dto.DoctorPortrait = $"{accessoryModel?.BasePath}{accessoryModel?.RelativePath}"; dto.HospitalGuid = doctorModel.HospitalGuid; dto.HospitalName = doctorModel.HospitalName; dto.JobTitle = dictionaryBiz.GetModelById(doctorModel.TitleGuid)?.ConfigName; } dto.LikeNumber = likeBiz.GetLikeNumByTargetGuid(qaGuid); dto.Liked = likeBiz.GetLikeState(UserID, qaGuid); return(Success(dto)); }
public async Task <IActionResult> TopicMessageAsync([FromBody] TopicMessageRequestDto request) { var doctorBiz = new DoctorBiz(); var response = await doctorBiz.TopicMessageAsync(request); return(Success(response)); }
/// <summary> /// 自动的执行任务 /// </summary> /// <remarks> /// Interval 单位为毫秒 /// Begin 从 2019-1-1 0:0:0 开始计时执行 /// </remarks> public override void Run() { if (!CheckOperationOnline()) { Logger.Error($"运营IM账号登录失败,本轮医生出席定时任务取消执行 at {nameof(DoctorPresent)}.Run"); return; } Thread.Sleep(10000); var list = client.GetRosterAsync().Result.Select(a => a.Key); var doctorGuids = new DoctorBiz().GetAllDoctorIdsAsync().Result; RedisHelper.Set("CloudDoctor:DoctorList", JsonConvert.SerializeObject(doctorGuids));//缓存医生Id集合数据 var expiredIds = list.Except(doctorGuids); foreach (var item in expiredIds) { var task = client.DeleteRosterAsync(item);//删除失效的医生账号关联 task.Wait(); if (!task.Result) { // 删除失败 } new UserPresenceBiz().DeletePresenceStatus(item); } if (expiredIds.Count() > 0) { Logger.Debug($"删除redis中无效用户的出席状态key:{JsonConvert.SerializeObject(expiredIds)}"); } var exceptIds = doctorGuids.Except(list); var tmpExceptIds = new List <string>(); foreach (var item in exceptIds) { var status = Client.QueryStatusAsync(item).Result; // 如果不存在,则无需创建关系 if (status == IMStatus.NotExist) { continue; } tmpExceptIds.Add(item); var task = client.AddRosterAsync(item); // 需要添加的好友账号和昵称 task.Wait(); if (!task.Result) { // 添加失败 } } if (tmpExceptIds.Count() > 0) { Logger.Debug($"需要添加用户好友关系的数据:{JsonConvert.SerializeObject(tmpExceptIds)}"); } }
public async Task <IActionResult> ExportDoctorIntegralAsync([FromBody] ExportDoctorIntegralRequestDto request) { DoctorBiz doctorBiz = new DoctorBiz(); var response = await doctorBiz.ExportDoctorIntegralAsync(request); return(Success(new ExportDoctorIntegralResponseDto { Items = response })); }
public async Task <IActionResult> GetDoctorRegisterState() { var doctorBiz = new DoctorBiz(); var model = doctorBiz.GetDoctor(UserID); var result = await new ReviewRecordBiz().GetLatestReviewRecordByTargetGuidAsync(UserID, ReviewRecordModel.TypeEnum.Doctors.ToString()); return(Success(new GetDoctorRegisterStateResponseDto { WhetherRegister = model != null, RegisterState = model?.Status, ApprovalMessage = result?.RejectReason })); }
public async Task <IActionResult> GetClientArticleDetailAsync(string articleGuid, ArticleModel.ArticleSourceTypeEnum articleSource = ArticleModel.ArticleSourceTypeEnum.Doctor) { if (string.IsNullOrWhiteSpace(articleGuid)) { return(Failed(ErrorCode.UserData, "文章Id articleGuid 不可为空")); } var response = new GetClientArticleDetailResponseDto(); ArticleBiz articleBiz = new ArticleBiz(); var model = articleBiz.GetModel(articleGuid); if (model == null) { return(Failed(ErrorCode.Empty)); } var doctorBiz = new DoctorBiz(); var accessoryBiz = new AccessoryBiz(); var userBiz = new UserBiz(); var likeBiz = new LikeBiz(); var richtextBiz = new RichtextBiz(); response.ArticleGuid = model.ArticleGuid; response.Title = model.Title; response.AuthorGuid = model.AuthorGuid; response.LastUpdatedDate = model.LastUpdatedDate; response.Content = richtextBiz.GetModel(model.ContentGuid)?.Content; response.LikeNumber = likeBiz.GetLikeNumByTargetGuid(articleGuid); response.Liked = likeBiz.GetLikeState(UserID, articleGuid); if (articleSource == ArticleModel.ArticleSourceTypeEnum.Doctor) { response.AuthorName = userBiz.GetUser(model.AuthorGuid)?.UserName; var doctorModel = doctorBiz.GetDoctor(model.AuthorGuid); if (doctorModel != null) { var accessoryModel = accessoryBiz.GetAccessoryModelByGuid(doctorModel.PortraitGuid); response.AuthorPortrait = accessoryModel?.BasePath + accessoryModel?.RelativePath; response.HospitalName = doctorModel.HospitalName; response.OfficeName = doctorModel.OfficeName; } } else if (articleSource == ArticleModel.ArticleSourceTypeEnum.Manager) { response.AuthorName = (await new ManagerAccountBiz().GetAsync(model.AuthorGuid))?.UserName; } else { return(Failed(ErrorCode.UserData, $"文章来源 articleSource:{articleSource.ToString()} 数据值非法")); } return(Success(response)); }
public IActionResult AuditDoctorRegisterInfo([FromBody] AuditDoctorRegisterInfoRequestDto requestDto) { DoctorBiz doctorBiz = new DoctorBiz(); var model = doctorBiz.GetDoctor(requestDto.DoctorGuid); if (model == null) { return(Failed(ErrorCode.Empty, "未查到该医生数据")); } model.Status = requestDto.Status.ToString(); model.LastUpdatedBy = UserID; model.LastUpdatedDate = DateTime.Now; return(doctorBiz.UpdateModel(model) ? Success() : Failed(ErrorCode.DataBaseError, "审核医生数据出现错误")); }
public async Task <IActionResult> GetDoctorRecommendAsync(string doctorGuid) { if (string.IsNullOrWhiteSpace(doctorGuid)) { return(Failed(ErrorCode.UserData, "医生Id不能为空")); } var doctorBiz = new DoctorBiz(); var model = doctorBiz.GetDoctor(doctorGuid); if (model == null) { return(Failed(ErrorCode.UserData, "医生不存在")); } DoctorAppointmentBiz doctorAppointmentBiz = new DoctorAppointmentBiz(); var response = await doctorAppointmentBiz.GetDoctorRecommendAsync(UserID, model.OfficeGuid, model.HospitalGuid); return(Success(response)); }
public async Task <IActionResult> GetDoctorInfoAsync([FromBody] GetDoctorInfoRequestDto request) { var doctorBiz = new DoctorBiz(); var doctorModel = await doctorBiz.GetAsync(request.DoctorGuid); var userModel = await new UserBiz().GetAsync(request.DoctorGuid); var accModel = await new AccessoryBiz().GetAsync(doctorModel.PortraitGuid); var WorkCitys = doctorModel.WorkCity == "未知" || string.IsNullOrWhiteSpace(doctorModel.WorkCity) ? new string[] { } : doctorModel.WorkCity.Split('-'); string[] adeptTags = null; try { adeptTags = Newtonsoft.Json.JsonConvert.DeserializeObject <string[]>(string.IsNullOrWhiteSpace(doctorModel.AdeptTags) ? "[]" : doctorModel.AdeptTags); } catch (Exception) { }; var response = new GetDoctorInfoResponseDto { WorkCity = WorkCitys, DoctorGuid = doctorModel.DoctorGuid, AdeptTags = adeptTags, Background = doctorModel.Background, Birthday = userModel?.Birthday ?? DateTime.Now, OfficeGuid = doctorModel.OfficeGuid, TitleGuid = doctorModel.TitleGuid, Gender = userModel?.Gender, Honor = doctorModel.Honor, HospitalGuid = doctorModel.HospitalGuid, IdentityNumber = userModel?.IdentityNumber, PortraitGuid = doctorModel.PortraitGuid, PractisingHospital = doctorModel.PractisingHospital, SignatureGuid = doctorModel.SignatureGuid, UserName = userModel?.UserName, PortraitUrl = $"{accModel?.BasePath}{accModel?.RelativePath}", Phone = userModel?.Phone, Enable = doctorModel.Enable, IsRecommend = doctorModel.IsRecommend, WorkAge = doctorModel.WorkAge, JobNumber = doctorModel.JobNumber }; return(Success(response)); }
public async Task <IActionResult> GetDoctorTopicAsync([FromBody] GetDoctorTopicRequestDto request) { var doctorBiz = new DoctorBiz(); var response = await doctorBiz.GetDoctorTopicAsync(request); foreach (var item in response.CurrentPage) { if (item.SponsorGuid != request.DoctorGuid) { item.Consultants = item.SponsorName; } else if (item.ReceiverGuid != request.DoctorGuid) { item.Consultants = item.ReceiverName; } item.LastMessage = (await doctorBiz.GetTopicLastMessageAsync(item.TopicGuid)); } return(Success(response)); }
public async Task <IActionResult> RecommendDoctorAsync([FromBody] RecommendDoctorRequestDto request) { var doctorBiz = new DoctorBiz(); var entity = await doctorBiz.GetAsync(request.Guid); if (entity == null) { return(Failed(ErrorCode.UserData, "找不到数据")); } entity.LastUpdatedBy = UserID; entity.LastUpdatedDate = DateTime.Now; entity.IsRecommend = request.IsRecommend; var result = await doctorBiz.UpdateAsync(entity); if (!result) { return(Failed(ErrorCode.UserData, "修改失败")); } return(Success()); }
public async Task <IActionResult> ReviewApprovedDoctorAsync([FromBody] ReviewApprovedDoctorRequestDto request) { DoctorBiz doctorBiz = new DoctorBiz(); var entity = await doctorBiz.GetAsync(request.OwnerGuid); if (entity == null) { return(Failed(ErrorCode.DataBaseError)); } if (entity.Status.ToLower() == DoctorModel.StatusEnum.Approved.ToString().ToLower()) { return(Failed(ErrorCode.DataBaseError, "请不要重复审核")); } entity.Status = DoctorModel.StatusEnum.Approved.ToString(); entity.LastUpdatedBy = UserID; entity.LastUpdatedDate = DateTime.Now; var response = await doctorBiz.ReviewDoctorAsync(entity, "审核通过"); if (!response) { return(Failed(ErrorCode.DataBaseError, "审核失败")); } return(Success()); }
public async Task <IActionResult> ModifyDoctorInfoAsync([FromBody] ModifyDoctorInfoRequestDto doctorDto) { var doctorModelGuid = UserID; var doctorBiz = new DoctorBiz(); var checkDoctor = await doctorBiz.GetAsync(doctorModelGuid); if (checkDoctor == null) { return(Failed(ErrorCode.DataBaseError, "该用户未注册医生!")); } var userModel = await new UserBiz().GetModelAsync(UserID); userModel.UserName = doctorDto.UserName; userModel.IdentityNumber = doctorDto.IdentityNumber; userModel.Birthday = doctorDto.Birthday; userModel.Gender = doctorDto.Gender; var hospitalBiz = new HospitalBiz(); var officeBiz = new OfficeBiz(); var accessoryBiz = new AccessoryBiz(); var doctorModel = new DoctorModel(); doctorModel = checkDoctor; //医生数据 doctorModel.HospitalGuid = doctorDto.HospitalGuid; doctorModel.OfficeGuid = doctorDto.DocOffice; doctorModel.WorkCity = doctorDto.City; doctorModel.PractisingHospital = doctorDto.PractisingHospital; doctorModel.Honor = doctorDto.Honor; doctorModel.Background = doctorDto.Background; doctorModel.TitleGuid = doctorDto.DocTitle; doctorModel.AdeptTags = doctorDto.Adepts; doctorModel.Status = StatusEnum.Submit.ToString(); //doctorModel.SignatureGuid = doctorDto.SignatureGuid; doctorModel.CreatedBy = UserID; doctorModel.OrgGuid = ""; doctorModel.LastUpdatedBy = UserID; doctorModel.PortraitGuid = doctorDto.PortraitGuid; doctorModel.LastUpdatedDate = DateTime.Now; //医院名称 var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid); if (hospitalModel == null) { return(Failed(ErrorCode.Empty, "未查到医院数据")); } doctorModel.HospitalName = hospitalModel?.HosName; //科室名称 var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid); if (officeModel == null) { return(Failed(ErrorCode.Empty, "未查到科室数据")); } doctorModel.OfficeName = officeModel?.OfficeName; //医生证书配置项 & 附件 var lstCertificate = new List <CertificateModel>(); var lstAccessory = new List <AccessoryModel>(); if (doctorDto.Certificates.Any()) { foreach (var certificate in doctorDto.Certificates) { var certificateModel = new CertificateModel { CertificateGuid = Guid.NewGuid().ToString("N"), PictureGuid = certificate.AccessoryGuid, OwnerGuid = doctorModel.DoctorGuid, DicGuid = certificate.DicGuid, CreatedBy = UserID, OrgGuid = "", LastUpdatedBy = UserID }; lstCertificate.Add(certificateModel); var accModel = await accessoryBiz.GetAsync(certificate.AccessoryGuid); if (accModel != null) { accModel.OwnerGuid = certificateModel.CertificateGuid; accModel.LastUpdatedDate = DateTime.Now; lstAccessory.Add(accModel); } } } var doctorCompositeBiz = new DoctorCompositeBiz(); var result = await doctorCompositeBiz.RegisterDoctor(doctorModel, lstCertificate, lstAccessory, userModel, false); return(result ? Success() : Failed(ErrorCode.DataBaseError, "医生数据修改失败!")); }
public async Task <IActionResult> RegisterDoctor([FromBody] RegisterDoctorRequestDto doctorDto) { var doctorModelGuid = UserID; var doctorBiz = new DoctorBiz(); var checkModel = await doctorBiz.GetAsync(doctorModelGuid, true, true); bool isAdd = checkModel == null;;//当前为更新操作还是新增操作 var statusCheck = string.Equals(checkModel?.Status, StatusEnum.Submit.ToString(), StringComparison.OrdinalIgnoreCase) || string.Equals(checkModel?.Status, StatusEnum.Approved.ToString(), StringComparison.OrdinalIgnoreCase); if (checkModel != null && statusCheck && checkModel.Enable) { return(Failed(ErrorCode.DataBaseError, "该用户已注册过医生!")); } var doctorCertificates = await new DictionaryBiz().GetListByParentGuidAsync(DictionaryType.DoctorDicConfig); foreach (var item in doctorCertificates) { if (doctorDto.Certificates.FirstOrDefault(a => a.DicGuid == item.DicGuid) == null) { var eMsg = $"[{item.ConfigName}]没有上传"; return(Failed(ErrorCode.UserData, $"上传的医生证书项和系统配置的项不符,请核对,详情:{eMsg}")); } } var userModel = await new UserBiz().GetModelAsync(UserID); userModel.UserName = doctorDto.UserName; userModel.IdentityNumber = doctorDto.IdentityNumber; userModel.Birthday = doctorDto.Birthday; userModel.Gender = doctorDto.Gender; var hospitalBiz = new HospitalBiz(); var officeBiz = new OfficeBiz(); var accessoryBiz = new AccessoryBiz(); var doctorModel = new DoctorModel(); if (!isAdd) { doctorModel = checkModel; } //医生数据 doctorModel.DoctorGuid = doctorModelGuid; doctorModel.HospitalGuid = doctorDto.HospitalGuid; doctorModel.OfficeGuid = doctorDto.DocOffice; doctorModel.WorkCity = doctorDto.City; doctorModel.PractisingHospital = doctorDto.PractisingHospital; doctorModel.Honor = doctorDto.Honor; doctorModel.Background = doctorDto.Background; doctorModel.TitleGuid = doctorDto.DocTitle; doctorModel.AdeptTags = Newtonsoft.Json.JsonConvert.SerializeObject(doctorDto.Adepts); doctorModel.Status = StatusEnum.Submit.ToString(); doctorModel.SignatureGuid = doctorDto.SignatureGuid; doctorModel.CreatedBy = UserID; doctorModel.OrgGuid = ""; doctorModel.LastUpdatedBy = UserID; doctorModel.PortraitGuid = doctorDto.PortraitGuid; doctorModel.LastUpdatedDate = DateTime.Now; doctorModel.Enable = true; //医院名称 var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid); if (hospitalModel == null) { return(Failed(ErrorCode.Empty, "未查到医院数据")); } doctorModel.HospitalName = hospitalModel?.HosName; //科室名称 var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid); if (officeModel == null) { return(Failed(ErrorCode.Empty, "未查到科室数据")); } doctorModel.OfficeName = officeModel?.OfficeName; //医生证书配置项 & 附件 var lstCertificate = new List <CertificateModel>(); var lstAccessory = new List <AccessoryModel>(); if (doctorDto.Certificates.Any()) { foreach (var certificate in doctorDto.Certificates) { var certificateModel = new CertificateModel { CertificateGuid = Guid.NewGuid().ToString("N"), PictureGuid = certificate.AccessoryGuid, OwnerGuid = doctorModel.DoctorGuid, DicGuid = certificate.DicGuid, CreatedBy = UserID, OrgGuid = "", LastUpdatedBy = UserID }; lstCertificate.Add(certificateModel); var accModel = await accessoryBiz.GetAsync(certificate.AccessoryGuid); if (accModel != null) { accModel.OwnerGuid = certificateModel.CertificateGuid; accModel.LastUpdatedDate = DateTime.Now; lstAccessory.Add(accModel); } } } var doctorCompositeBiz = new DoctorCompositeBiz(); var result = await doctorCompositeBiz.RegisterDoctor(doctorModel, lstCertificate, lstAccessory, userModel, isAdd); if (result) { new DoctorActionBiz().RegisterDoctor(this.UserID); } return(result ? Success() : Failed(ErrorCode.DataBaseError, "医生注册数据插入不成功!")); }
public async Task <IActionResult> UpdateDoctorInfoAsync([FromBody] UpdateDoctorInfoRequestDto request) { var doctorBiz = new DoctorBiz(); var doctorModel = await doctorBiz.GetAsync(request.DoctorGuid); if (doctorModel == null) { return(Failed(ErrorCode.DataBaseError, "该用户未注册医生!")); } var userModel = await new UserBiz().GetAsync(request.DoctorGuid); if (userModel.Phone != request.Phone) { UserModel userPhoneModel = await new UserBiz().GetByPnoneAsync(request.Phone); if (userPhoneModel != null) { return(Failed(ErrorCode.UserData, "用户手机已注册!")); } } var existNumber = await doctorBiz.ExistJobNumber(request.JobNumber, doctorModel.DoctorGuid); if (existNumber) { return(Failed(ErrorCode.DataBaseError, $"工号【{request.JobNumber}】已存在")); } userModel.UserName = request.UserName; userModel.IdentityNumber = request.IdentityNumber; userModel.Birthday = request.Birthday; userModel.Gender = request.Gender; userModel.Phone = request.Phone; userModel.LastUpdatedBy = UserID; userModel.LastUpdatedDate = DateTime.Now; //医生数据 doctorModel.HospitalGuid = request.HospitalGuid; doctorModel.OfficeGuid = request.OfficeGuid; doctorModel.WorkCity = string.Join('-', request.WorkCity); doctorModel.JobNumber = request.JobNumber; doctorModel.PractisingHospital = request.PractisingHospital; doctorModel.Honor = request.Honor; doctorModel.Background = request.Background; doctorModel.TitleGuid = request.TitleGuid; doctorModel.AdeptTags = Newtonsoft.Json.JsonConvert.SerializeObject(request.AdeptTags); doctorModel.IsRecommend = request.IsRecommend; doctorModel.RecommendSort = request.RecommendSort; doctorModel.LastUpdatedBy = UserID; doctorModel.LastUpdatedDate = DateTime.Now; doctorModel.PortraitGuid = request.PortraitGuid; //医院名称 var hospitalBiz = new HospitalBiz(); var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid); if (hospitalModel == null) { return(Failed(ErrorCode.Empty, "未查到医院数据")); } doctorModel.HospitalName = hospitalModel?.HosName; //科室名称 var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid); if (officeModel == null) { return(Failed(ErrorCode.Empty, "未查到科室数据")); } doctorModel.OfficeName = officeModel?.OfficeName; //商户配置项证书信息 & 配置项证书附件信息 var clientDicGuids = request.Certificates.Select(b => b.DicGuid); CertificateBiz certificateBiz = new CertificateBiz(); var dbCertificate = await certificateBiz.GetListAsync(doctorModel.DoctorGuid); var dbDicGuids = dbCertificate.Select(b => b.DicGuid); var updateCertificate = dbCertificate.Where(a => clientDicGuids.Contains(a.DicGuid)).Select(a => { var cc = request.Certificates.FirstOrDefault(c => c.DicGuid == a.DicGuid); a.PictureGuid = cc.AccessoryGuid; a.LastUpdatedBy = UserID; a.LastUpdatedDate = DateTime.Now; return(a); }); var addCertificate = request.Certificates.Where(a => !dbDicGuids.Contains(a.DicGuid)).Select(item => new CertificateModel { CertificateGuid = Guid.NewGuid().ToString("N"), PictureGuid = item.AccessoryGuid, OwnerGuid = doctorModel.DoctorGuid, DicGuid = item.DicGuid, CreatedBy = UserID, OrgGuid = string.Empty, LastUpdatedBy = UserID }); var delCertificate = dbCertificate.Where(a => !clientDicGuids.Contains(a.DicGuid)); var result = await doctorBiz.UpdateDoctorAsync(doctorModel, userModel, addCertificate, delCertificate, updateCertificate); if (!result) { return(Failed(ErrorCode.DataBaseError, "医生数据修改失败!")); } return(Success()); }
public async Task <IActionResult> AddDoctorInfoAsync([FromBody] AddDoctorInfoRequestDto request) { var doctorBiz = new DoctorBiz(); var userIsInsert = false; var userModel = await new UserBiz().GetByPnoneAsync(request.Phone); if (userModel != null) { var doctor = await doctorBiz.GetAsync(userModel.UserGuid); if (doctor != null) { return(Failed(ErrorCode.DataBaseError, "该用户已注册医生!")); } userModel.UserName = request.UserName; userModel.IdentityNumber = request.IdentityNumber; userModel.Birthday = request.Birthday; userModel.Gender = request.Gender; userModel.Phone = request.Phone; } else { //var password = request.Phone.Substring(request.Phone.Length - 6); var password = "******";//默认密码 var userid = Guid.NewGuid().ToString("N"); userModel = new UserModel { Birthday = request.Birthday, CreatedBy = userid, Enable = true, Gender = request.Gender, LastUpdatedBy = userid, NickName = request.UserName, OrgGuid = string.Empty, Password = Common.Helper.CryptoHelper.AddSalt(userid, GD.Common.Helper.CryptoHelper.Md5(password)), Phone = request.Phone, UserGuid = userid, UserName = request.UserName, IdentityNumber = request.IdentityNumber }; userIsInsert = true; } var existNumber = await doctorBiz.ExistJobNumber(request.JobNumber); if (existNumber) { return(Failed(ErrorCode.DataBaseError, $"工号【{request.JobNumber}】已存在")); } //医生数据 var doctorModel = new DoctorModel { DoctorGuid = userModel.UserGuid, HospitalGuid = request.HospitalGuid, OfficeGuid = request.OfficeGuid, WorkCity = string.Join('-', request.WorkCity), PractisingHospital = request.PractisingHospital, Honor = request.Honor, Background = request.Background, TitleGuid = request.TitleGuid, AdeptTags = Newtonsoft.Json.JsonConvert.SerializeObject(request.AdeptTags), Status = DoctorModel.StatusEnum.Approved.ToString(), SignatureGuid = string.Empty, CreatedBy = userModel.UserGuid, OrgGuid = string.Empty, LastUpdatedBy = userModel.UserGuid, PortraitGuid = request.PortraitGuid, //HospitalName = string.Empty, //OfficeName = string.Empty, CreationDate = DateTime.Now, IsRecommend = request.IsRecommend, RecommendSort = request.RecommendSort, Enable = request.Enable, WorkAge = request.WorkAge, JobNumber = request.JobNumber }; //医院名称 var hospitalBiz = new HospitalBiz(); var hospitalModel = await hospitalBiz.GetAsync(doctorModel.HospitalGuid); if (hospitalModel == null) { return(Failed(ErrorCode.Empty, "未查到医院数据")); } doctorModel.HospitalName = hospitalModel?.HosName; //科室名称 var officeModel = await new OfficeBiz().GetAsync(doctorModel.OfficeGuid); if (officeModel == null) { return(Failed(ErrorCode.Empty, "未查到科室数据")); } doctorModel.OfficeName = officeModel?.OfficeName; //商户配置项证书信息 & 配置项证书附件信息 var lstCertificate = request.Certificates.Select(item => new CertificateModel { CertificateGuid = Guid.NewGuid().ToString("N"), PictureGuid = item.AccessoryGuid, OwnerGuid = doctorModel.DoctorGuid, DicGuid = item.DicGuid, CreatedBy = UserID, OrgGuid = string.Empty, LastUpdatedBy = UserID }); var result = await doctorBiz.AddDoctorAsync(doctorModel, userModel, userIsInsert, lstCertificate); if (!result) { return(Failed(ErrorCode.DataBaseError, "医生数据修改失败!")); } return(Success()); }
/// <summary> /// 医生离线消息通知 /// </summary> /// <param name="messageModel"></param> /// <returns></returns> private void DoctorOfflineMessageNotification(MessageModel messageModel) { #region 通知医生离线消息 if (string.IsNullOrWhiteSpace(PlatformSettings.DoctorOfflineMsgTemplate)) { return; } Task.Run(() => { string controllerName = nameof(MessageController); string actionName = nameof(DoctorOfflineMessageNotification); try { var topiclModel = new TopicBiz().GetModelById(messageModel.TopicGuid); Logger.Debug($"{actionName}-请求参数-{JsonConvert.SerializeObject(messageModel)}{Environment.NewLine}MessageToGuid({messageModel.ToGuid})-TopicReceiverGuid({topiclModel.ReceiverGuid})"); if (messageModel.ToGuid == topiclModel.ReceiverGuid) { var doctorStatus = new UserPresenceBiz().GetPresenceStatus(messageModel.ToGuid); Logger.Debug($"{actionName}-当前医生({messageModel.ToGuid})在线状态-{JsonConvert.SerializeObject(doctorStatus)}"); //医生为在线状态,不通知 if (doctorStatus.IsOnline) { return; } var doctorModel = new DoctorBiz().GetDoctor(messageModel.ToGuid); if (doctorModel == null) { Logger.Debug($"{actionName}-当前接收者不是医生({messageModel.ToGuid})"); return; } #region 离线消息十分钟发一次逻辑去掉,改为,离线消息,全部发送给医生 //var timeStep = 10;//每十分钟通知一次医生 //var msgNotificationKey = $"CloudDoctor:MsgNotificationKey:{messageModel.ToGuid}"; //DateTime? latestNotificationTime = null; //if (RedisHelper.Exist(msgNotificationKey)) //{ // DateTime.TryParse(RedisHelper.Get<string>(msgNotificationKey), out DateTime result); // latestNotificationTime = result; //} //else //{ // latestNotificationTime = DateTime.Now.AddHours(-1); //} //Logger.Debug($"{actionName}-当前医生离线消息Redis记录时间({msgNotificationKey}-{latestNotificationTime.Value.ToString("yyyy-MM-dd HH:mm:ss")})"); ////通知间隔不足10分钟 //if ((DateTime.Now - latestNotificationTime.Value).TotalMinutes < timeStep) //{ // return; //} //RedisHelper.Set(msgNotificationKey, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); #endregion //var tokenRes = WeChartApi.GetAccessToken(PlatformSettings.DoctorClientAppId, PlatformSettings.DoctorClientAppSecret).Result; //用户无openId,不通知 if (string.IsNullOrWhiteSpace(doctorModel.WechatOpenid)) { Logger.Debug($"{actionName}-当前医生无企业微信userid数据-{JsonConvert.SerializeObject(doctorModel)}"); return; } //if (string.IsNullOrWhiteSpace(tokenRes.AccessToken)) //{ // Logger.Error($"GD.API.Controllers.Utility.{controllerName}.{actionName} 获取token失败 appId:[{PlatformSettings.DoctorClientAppId}] {Environment.NewLine} error:{tokenRes?.Errmsg}"); // return; //} var userModel = new UserBiz().GetModelAsync(messageModel.FromGuid).Result; var content = messageModel.Context.Substring(0, messageModel.Context.Length > 25 ? 25 : messageModel.Context.Length); //var tmplateMsg = new WeChatTemplateMsg //{ // Touser = doctorModel.WechatOpenid, // Template_Id = PlatformSettings.DoctorOfflineMsgTemplate, // Data = new // { // First = new { Value = "【待处理提醒】" }, // //用户昵称 // Keyword1 = new { Value = userModel?.NickName }, // //时间 // Keyword2 = new { Value = messageModel.CreationDate.ToString("MM月dd日 HH:mm") }, // //咨询内容 // Keyword3 = new { Value = $"{content}..." }, // Remark = new { Value = "您有待办信息,请尽快处理" }, // } //}; //var response = WeChartApi.SendTemplateMsg(tmplateMsg, tokenRes.AccessToken); //Logger.Debug($"{actionName}-发送模板消息结果-{JsonConvert.SerializeObject(response)}{Environment.NewLine}消息内容-{JsonConvert.SerializeObject(tmplateMsg)}"); var qyMsg = new QyTextCardMessageRequest { ToUser = doctorModel.WechatOpenid, AgentId = PlatformSettings.EnterpriseWeChatMobileAgentid, TextCard = new QyTextCardMessageRequest.Content { Title = "问医离线消息通知", Description = $"<div class=\"normal\">用户昵称:{userModel?.NickName}</div>" + $"<div class=\"normal\">咨询时间:{messageModel.CreationDate.ToString("MM月dd日 HH:mm")}</div>" + $"<div class=\"normal\">咨询内容:{content}...</div>" + $"<div class=\"blue\">您有待办信息,请尽快处理</div>" } }; var token = EnterpriseWeChatApi.GetEnterpriseAccessToken(PlatformSettings.EnterpriseWeChatAppid, PlatformSettings.EnterpriseWeChatMobileSecret).Result; if (token.Errcode != 0) { Logger.Error($"发送问医离线消息通知获取企业微信token失败:{token.Errmsg}"); return; } var sendResult = EnterpriseWeChatApi.SendQyMessageAsync(qyMsg, token.AccessToken).Result; Logger.Debug($"{actionName}-发送问医离线消息通知结果-{JsonConvert.SerializeObject(sendResult)}{Environment.NewLine}消息内容-{JsonConvert.SerializeObject(qyMsg)}"); } } catch (Exception ex) { Logger.Error($"GD.API.Controllers.Utility.{controllerName}.{actionName}-传入参数:({JsonConvert.SerializeObject(messageModel)}) {Environment.NewLine} error:{ex.Message}"); } }); #endregion }