Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        public IActionResult AddMessageTopicList([FromBody] List <AddMessageInfoListRequestDto> topicDtoList)
        {
            if (topicDtoList == null || topicDtoList.Count < 1)
            {
                return(Failed(ErrorCode.Empty, "传入数据为空!"));
            }
            var modelList = new List <TopicModel>();

            foreach (var dto in topicDtoList)
            {
                var model = new TopicModel
                {
                    TopicGuid     = Guid.NewGuid().ToString("N"),
                    SponsorGuid   = dto.SponsorGuid,
                    ReceiverGuid  = dto.ReceiverGuid,
                    AboutGuid     = dto.AboutGuid,
                    AboutType     = dto.EnumTb,
                    BeginDate     = TimeZoneInfo.ConvertTime(dto.BeginDate, TimeZoneInfo.Local),
                    EndDate       = TimeZoneInfo.ConvertTime(dto.EndDate, TimeZoneInfo.Local),
                    Enable        = true,
                    CreatedBy     = UserID,
                    CreationDate  = DateTime.Now,
                    OrgGuid       = "OrgGuid",
                    LastUpdatedBy = UserID
                };
                modelList.Add(model);
            }
            var topicBiz     = new TopicBiz();
            var isAddSuccess = topicBiz.AddModelList(modelList);

            return(isAddSuccess ? Success("数据新增成功!") : Failed(ErrorCode.Empty, "数据新增失败!"));
        }
Ejemplo n.º 3
0
        public IActionResult GetMyTopicList([FromBody] PageRequestDto pageRequest)
        {
            var topicBiz  = new TopicBiz();
            var topisList = topicBiz.GetListByUserId(UserID, pageRequest);

            if (topisList.Count < 1)
            {
                return(Failed(ErrorCode.Empty, "暂无数据!"));
            }
            var response = topisList.Select(a => a.ToDto <GetMyTopicListItemDto>()).ToList();

            return(Success(response));
        }
Ejemplo n.º 4
0
        public IActionResult AddMessageTopic([FromBody] AddMessageInfoListRequestDto topicDto)
        {
            var model = new TopicModel
            {
                TopicGuid     = Guid.NewGuid().ToString("N"),
                SponsorGuid   = topicDto.SponsorGuid,
                ReceiverGuid  = topicDto.ReceiverGuid,
                AboutGuid     = topicDto.AboutGuid,
                AboutType     = topicDto.EnumTb,
                BeginDate     = TimeZoneInfo.ConvertTime(topicDto.BeginDate, TimeZoneInfo.Local),
                EndDate       = TimeZoneInfo.ConvertTime(topicDto.EndDate, TimeZoneInfo.Local),
                Enable        = true,
                CreatedBy     = UserID,
                CreationDate  = DateTime.Now,
                OrgGuid       = "OrgGuid",
                LastUpdatedBy = UserID
            };
            var topicBiz  = new TopicBiz();
            var isAddGuid = topicBiz.Add(model);

            return(string.IsNullOrWhiteSpace(isAddGuid) ? Failed(ErrorCode.Empty, "数据新增失败!") : Success(isAddGuid));
        }
Ejemplo n.º 5
0
        /// <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
        }