提交 6ada2bc1 authored 作者: 杨凯's avatar 杨凯

feat:家庭医生初始化

上级 e63756a8
package com.ebaiyihui.family.doctor.common.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @ClassName: GoeasyPushMsgReqDTO
* @Author:yanliang
* @Date:2024/3/15 16:50
* @Description
*/
@Data
public class GoeasyPushMsgReqDTO {
@ApiModelProperty(value = "通知的主体内容")
private String body;
@ApiModelProperty(value = "业务编码")
private String busiCode;
@ApiModelProperty(value = "用户ID")
private String userId;
}
package com.ebaiyihui.family.doctor.server.common.constants;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @ClassName: ProjProperties
* @Author:yanliang
* @Date:2024/3/15 16:45
* @Description
*/
@Data
@Component
@ConfigurationProperties(prefix = "projprops")
public class ProjProperties {
private String userFindUserId;
private String userInfo;
private String baseAddress;
}
package com.ebaiyihui.family.doctor.server.common.constants;
/**
* @ClassName: UrlConstants
* @Author:yanliang
* @Date:2024/3/15 16:49
* @Description
*/
public class UrlConstants {
public static final String GO_EASY_PUSH = "/cloud/push/goeasy/pushgoeasyuserid";
}
package com.ebaiyihui.family.doctor.server.service;
/**
* @ClassName: GoEasyPushService
* @Author:yanliang
* @Date:2024/3/15 16:29
* @Description
*/
public interface GoEasyPushService {
void newOrderToReceive(String admId);
}
package com.ebaiyihui.family.doctor.server.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.doctoruser.api.pojo.vo.*;
import com.ebaiyihui.family.doctor.common.dto.GoeasyPushMsgReqDTO;
import com.ebaiyihui.family.doctor.server.common.constants.IMInformConstants;
import com.ebaiyihui.family.doctor.server.common.constants.ProjProperties;
import com.ebaiyihui.family.doctor.server.common.constants.UrlConstants;
import com.ebaiyihui.family.doctor.server.common.enums.StatusEnum;
import com.ebaiyihui.family.doctor.server.entity.PatientSignEntity;
import com.ebaiyihui.family.doctor.server.mapper.PatientSignMapper;
import com.ebaiyihui.family.doctor.server.service.GoEasyPushService;
import com.ebaiyihui.family.doctor.server.util.UserRestTemplateUtil;
import com.ebaiyihui.framework.utils.HttpKit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* @ClassName: GoEasyPushServiceImpl
* @Author:yanliang
* @Date:2024/3/15 16:30
* @Description
*/
@Service
@Slf4j
public class GoEasyPushServiceImpl implements GoEasyPushService {
@Autowired
private ProjProperties projProperties;
@Autowired
private PatientSignMapper patientSignMapper;
@Override
public void newOrderToReceive(String admId) {
log.info("医生web端推送开始:{}", admId);
QueryWrapper<PatientSignEntity> wrapper = new QueryWrapper<>();
PatientSignEntity patientSign = new PatientSignEntity();
patientSign.setAdmId(admId);
wrapper.setEntity(patientSign);
PatientSignEntity patientSignEntity = patientSignMapper.selectOne(wrapper);
//是否订单
boolean isOrder = Objects.equals(StatusEnum.IN_CONSULTATION.getValue(), patientSignEntity.getStatus());
if (isOrder) {
UserInfoByUserIdRespVO userInfoByUserIdRespVO = queryDocAccountInfo(String.valueOf(patientSignEntity.getDoctorId()));
String userId = userInfoByUserIdRespVO.getUserId();
Map<String, String> map = new HashMap<>();
map.put("id", patientSignEntity.getAdmId());
map.put("body", "您有一笔新的家庭医生订单待处理,请及时查看");
map.put("type", "jtys_new_order");
map.put("title", "家庭医生订单提醒");
map.put("subTitle", "家庭医生订单提醒");
map.put("pushCode", "1");
goEasyPush(userId, JSON.toJSONString(map), IMInformConstants.IM_SYSTEM_BUSINESS_CODE);
}
}
/**
* @param docId 医生ID
* @return 医生userId
*/
private UserInfoByUserIdRespVO queryDocAccountInfo(String docId) {
// 查询医生userId
FindUserIdListReq findUserIdListReq = new FindUserIdListReq();
FindUserIdReqVO findUserIdReqVO = new FindUserIdReqVO();
findUserIdReqVO.setReqId(docId);
findUserIdReqVO.setUserType((short) 1);
List<FindUserIdReqVO> findUserIdReqVOList = new ArrayList<>(1);
findUserIdReqVOList.add(findUserIdReqVO);
findUserIdListReq.setFindUserIdReqVOS(findUserIdReqVOList);
log.info("findUserIdListReq:{}", JSON.toJSONString(findUserIdListReq));
//查询医生userId
List<com.doctoruser.api.pojo.vo.FindUserIdRespVO> findUserIdRespVOS =
UserRestTemplateUtil.queryUserIdList(findUserIdListReq, projProperties.getUserFindUserId());
log.info("00001查询用户Id请求对象:{}", JSON.toJSONString(findUserIdRespVOS));
if (null == findUserIdRespVOS) {
return null;
}
FindUserIdRespVO findUserIdRespVO = findUserIdRespVOS.get(0);
log.info("000========:{}", JSON.toJSONString(findUserIdRespVO));
// 查询医生账号信息
GetUserInfoByUserIdReqVO getUserInfoByUserIdReqVO = new GetUserInfoByUserIdReqVO();
getUserInfoByUserIdReqVO.setUserId(findUserIdRespVO.getUserId());
log.info("0002获取用户基础资料请求对象入参:{}", JSON.toJSONString(getUserInfoByUserIdReqVO));
//获取用户基础资料
UserInfoByUserIdRespVO userInfo =
UserRestTemplateUtil.getUserInfo(getUserInfoByUserIdReqVO, projProperties.getUserInfo());
log.info("0002获取用户基础资料请求对象出参:{}", JSON.toJSONString(userInfo));
if (null != userInfo) {
return userInfo;
}
return null;
}
public void goEasyPush(String userId, String text, String busiCode) {
String url = projProperties.getBaseAddress() + UrlConstants.GO_EASY_PUSH;
try {
log.info("goeasy推送url----------->{}", url);
GoeasyPushMsgReqDTO vo = new GoeasyPushMsgReqDTO();
vo.setBusiCode(busiCode);
vo.setBody(text);
vo.setUserId(userId);
log.info("=======>goeasy推送参数----->{}", JSON.toJSONString(vo));
String httpResult = HttpKit.jsonPost(url, JSON.toJSONString(vo));
log.info("=======>goeasy推送返回结果----->{}", httpResult);
} catch (Exception e) {
log.info("=======>goeasy推送 - 获取异常", e);
}
}
}
......@@ -8,6 +8,7 @@ import com.doctoruser.api.pojo.base.vo.doctor.PersonnelInfo;
import com.ebaiyihui.family.doctor.common.dto.ImInfoDetailDocReqDTO;
import com.ebaiyihui.family.doctor.common.dto.ImInfoListDocReqDTO;
import com.ebaiyihui.family.doctor.common.vo.*;
import com.ebaiyihui.family.doctor.server.common.constants.IMInformConstants;
import com.ebaiyihui.family.doctor.server.common.constants.ImConstants;
import com.ebaiyihui.family.doctor.server.common.enums.StatusEnum;
import com.ebaiyihui.family.doctor.server.entity.PatientEntity;
......@@ -111,9 +112,9 @@ public class PatientSignServiceImpl implements PatientSignService {
log.info("获取IM登录信息:{}", imSysResult);
IMQueryMsgReqVO imQueryMsgReqVO = new IMQueryMsgReqVO();
imQueryMsgReqVO.setAppCode("EHOS_PATIENT");
imQueryMsgReqVO.setAppCode(IMInformConstants.PATIENT_APPLICATION_CODE);
imQueryMsgReqVO.setUserId(patientSignEntity.getPatientUserId());
imQueryMsgReqVO.setBusinessCode("zxzx");
imQueryMsgReqVO.setBusinessCode(IMInformConstants.IM_SYSTEM_BUSINESS_CODE);
imQueryMsgReqVO.setMsgType("1");
imQueryMsgReqVO.setPageSize(999);
imQueryMsgReqVO.setSortOrder("ASC");
......
package com.ebaiyihui.family.doctor.server.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.doctoruser.api.pojo.dto.UcConfigurationDTO;
import com.doctoruser.api.pojo.vo.*;
import com.doctoruser.api.pojo.vo.account.DoctorIdReqVO;
import com.doctoruser.api.pojo.vo.account.DoctorInfoRespVO;
import com.ebaiyihui.framework.response.BaseResponse;
import com.ebaiyihui.framework.utils.HttpKit;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.web.client.RestTemplate;
import java.util.List;
/**
* @ClassName: UserRestTemplateUtil
* @Author:yanliang
* @Date:2024/3/15 16:51
* @Description
*/
@Slf4j
public class UserRestTemplateUtil {
public static UserInfoByUserIdRespVO getUserInfo(GetUserInfoByUserIdReqVO getUserInfoByUserIdReqVO, String url) {
log.info("1用户调用" + JSON.toJSONString(getUserInfoByUserIdReqVO));
BaseResponse response = null;
try {
String result = HttpKit.jsonPost(url, JSON.toJSONString(getUserInfoByUserIdReqVO));
response = JSONObject.toJavaObject(JSONObject.parseObject(result), BaseResponse.class);
log.info("response:{}" + JSON.toJSONString(response));
} catch (Exception e) {
log.error("调用用户资料接口失败" + e.getMessage());
}
log.info("response :{}", JSON.toJSONString(response));
if ("-1".equals(response.getErrCode())) {
log.info("=================用户调用失败================");
return null;
}
UserInfoByUserIdRespVO userInfoByUserIdRespVO = JSONObject.parseObject(JSONObject.toJSONString(response.getData()), UserInfoByUserIdRespVO.class);
return userInfoByUserIdRespVO;
}
/**
* @param findUserIdListReq
*/
public static List<FindUserIdRespVO> queryUserIdList(FindUserIdListReq findUserIdListReq, String url) {
log.info("2用户调用" + JSON.toJSONString(findUserIdListReq));
BaseResponse response = null;
try {
String result = HttpKit.jsonPost(url, JSON.toJSONString(findUserIdListReq));
response = JSONObject.toJavaObject(JSONObject.parseObject(result), BaseResponse.class);
log.info("response:{}" + JSON.toJSONString(response));
} catch (Exception e) {
log.error("调用批量查询用户id接口失败" + e.getMessage());
}
log.info("response :{}", JSON.toJSONString(response));
if ("-1".equals(response.getErrCode())) {
log.info("=================用户调用失败================");
return null;
}
Object data = response.getData();
List<FindUserIdRespVO> userIdResplist =
JSONObject.parseObject(JSONObject.toJSONString(data), new TypeReference<List<FindUserIdRespVO>>() {
});
log.info("userIdResplist:{}" + userIdResplist.toString());
return userIdResplist;
}
/**
* @param doctorIdReqVO
*/
public static DoctorInfoRespVO queryDoctorByDoctorId(DoctorIdReqVO doctorIdReqVO, String url) {
log.info("3用户调用" + JSON.toJSONString(doctorIdReqVO));
HttpHeaders headers = new HttpHeaders();
//定义请求参数类型,这里用json所以是MediaType.APPLICATION_JSON
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<DoctorIdReqVO> request = new HttpEntity<>(doctorIdReqVO, headers);
RestTemplate restTemplate = new RestTemplate();
log.info("url :{}", JSON.toJSONString(url));
log.info("request :{}", JSON.toJSONString(request));
BaseResponse response = restTemplate.postForObject(url, request, BaseResponse.class);
log.info("response :{}", JSON.toJSONString(response));
if ("-1".equals(response.getErrCode())) {
log.info("=================用户调用失败================");
return null;
}
DoctorInfoRespVO doctorInfoResp =
JSONObject.parseObject(JSONObject.toJSONString(response.getData()), DoctorInfoRespVO.class);
return doctorInfoResp;
}
/**
* 获取 配置详情
*
* @param appCode
* @return
*/
public static String getConfigurationDetail(String appCode, String type, String url) {
UcConfigurationDTO ucConfigurationDTO = new UcConfigurationDTO();
ucConfigurationDTO.setType(type);
ucConfigurationDTO.setAppCode(appCode);
BaseResponse response = null;
try {
String result = HttpKit.jsonPost(url, JSON.toJSONString(ucConfigurationDTO));
response = JSONObject.toJavaObject(JSONObject.parseObject(result), BaseResponse.class);
} catch (Exception e) {
log.error("调用推送接口失败" + e.getMessage());
}
log.info("获取配置详情 返回:{}", JSON.toJSONString(response));
UcConfigurationVO ucConfigurationVO = JSONObject.parseObject(JSONObject.toJSONString(response.getData()), UcConfigurationVO.class);
log.info("获取配置详情看json解析: {}", JSON.toJSONString(ucConfigurationVO));
return ucConfigurationVO.getClientCode();
}
}
......@@ -64,3 +64,8 @@ swagger:
cloudDoctorUrl: https://testapi.chinachdu.com/cloud/doctorbasedata/
cloudDoctorUserUrl: https://testapi.chinachdu.com/cloud/doctoruser/
projprops:
userFindUserId: https://testapi.chinachdu.com/cloud/doctoruser/user/finduserid
userInfo: https://testapi.chinachdu.com/cloud/doctoruser/user/getuserinfoByUserId
baseAddress: https://testapi.chinachdu.com/
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论