Merge remote-tracking branch 'origin/dev_2.0.0' into dev_2.0.0

dev_2.0.0
xueqingkun 2 years ago
commit 4320559301

@ -16,28 +16,34 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Slf4j @Slf4j
public class JwtInterceptor implements HandlerInterceptor { public class JwtInterceptor implements HandlerInterceptor {
private static final ConcurrentHashMap<Object, JWT> singleLoginTokenCacheMap = new ConcurrentHashMap<>();
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
//请求消息头获取用户ID //请求消息头获取用户ID
String token = request.getHeader("token"); String token = request.getHeader("token");
if (StrUtil.isBlank(token) ) { if (StrUtil.isBlank(token)) {
// 如果是swagger来的接口,说明这里是测试的,会伪造一个用户 // 如果是swagger来的接口,说明这里是测试的,会伪造一个用户
if (StrUtil.isNotBlank(request.getHeader("Knife4j-Gateway-Code"))){ if (StrUtil.isNotBlank(request.getHeader("Knife4j-Gateway-Code"))) {
token = devActiveUser(); cacheAuth(JWTUtil.parseToken(devActiveUser()));
}else { return true;
throw new BusinessException("当前用户未登录",HttpStatus.UNAUTHORIZED.value()); } else {
throw new BusinessException("当前用户未登录", HttpStatus.UNAUTHORIZED.value());
} }
} }
JWT jwt = JWTUtil.parseToken(token); JWT jwt = JWTUtil.parseToken(token);
// 校验token是否过期,如果过期了,需要提示过期重新登录 // 校验token是否过期,如果过期了,需要提示过期重新登录
checkTokenExpire(jwt); checkTokenExpire(jwt);
// 校验是否重复登录
checkSingleLogin(jwt);
cacheAuth(jwt); cacheAuth(jwt);
return true; return true;
} }
@ -56,7 +62,27 @@ public class JwtInterceptor implements HandlerInterceptor {
// 校验是否比当前时间大 // 校验是否比当前时间大
long currentTimeMillis = System.currentTimeMillis(); long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis > l) { if (currentTimeMillis > l) {
throw new BusinessException("用户登录已过期,请重新登录",HttpStatus.UNAUTHORIZED.value()); throw new BusinessException("用户登录已过期,请重新登录", HttpStatus.UNAUTHORIZED.value());
}
}
private void checkSingleLogin(JWT currentJwt) {
Object id = currentJwt.getPayload("id");
JWT singleLoginTokenCache = singleLoginTokenCacheMap.get(id);
// 然后将当前的expireTime和singleLoginTokenCache进行比较
Object expireTime = singleLoginTokenCache.getPayload("expireTime");
long singleLoginTokenCacheExpireTime = Long.parseLong(String.valueOf(expireTime));
Object currentJwtExpireTimeObject = currentJwt.getPayload("expireTime");
long currentJwtExpireTime = Long.parseLong(String.valueOf(currentJwtExpireTimeObject));
if (singleLoginTokenCacheExpireTime == currentJwtExpireTime) {
// 如果相等,说明这个token就是最新的,直接放行
return;
} else if (currentJwtExpireTime > singleLoginTokenCacheExpireTime) {
// 如果当前的超时时间要大于缓存的,说明重新登录了,这个时候要把最新的放到缓存中
singleLoginTokenCacheMap.put(id, currentJwt);
} else {
// 走到这里,说明singleLoginTokenCache是最新的,说明当前请求的token就过期了
throw new BusinessException("当前用户已在其他地方登录!");
} }
} }
@ -69,11 +95,11 @@ public class JwtInterceptor implements HandlerInterceptor {
} }
} }
private String devActiveUser(){ private String devActiveUser() {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("id","1"); map.put("id", "1");
map.put("account","test"); map.put("account", "test");
map.put("name","测试账户"); map.put("name", "测试账户");
return TokenUtil.creatToken(JSONUtil.toJsonStr(map)); return TokenUtil.creatToken(JSONUtil.toJsonStr(map));
} }

@ -11,7 +11,7 @@ public class TokenUtil {
public static String creatToken(String userInfo){ public static String creatToken(String userInfo){
final JWTSigner signer = JWTSignerUtil.hs256("123456".getBytes()); final JWTSigner signer = JWTSignerUtil.hs256("123456".getBytes());
JSONObject info = JSONUtil.parseObj(userInfo); JSONObject info = JSONUtil.parseObj(userInfo);
// 过期时间一天 // 过期时间一天,同时这个字段也作为单点登录使用
info.putOnce("expireTime",System.currentTimeMillis() + 1000 * 60 * 60 * 24); info.putOnce("expireTime",System.currentTimeMillis() + 1000 * 60 * 60 * 24);
return JWTUtil.createToken(info, signer); return JWTUtil.createToken(info, signer);
} }

@ -1,14 +1,13 @@
package com.supervision.manage.pojo.vo; package com.supervision.manage.pojo.vo;
import com.supervision.model.AskPatientAnswer; import com.supervision.vo.manage.DiseaseAncillaryResVo;
import com.supervision.model.MedicalRec; import com.supervision.vo.manage.DiseasePhysicalResVo;
import com.supervision.model.Patient; import com.supervision.vo.manage.TreatmentPlanResVo;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import java.util.List; import java.util.List;
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@ -17,12 +16,12 @@ import java.util.List;
public class MedicalRecInfoVO extends MedicalRecManageVO { public class MedicalRecInfoVO extends MedicalRecManageVO {
@ApiModelProperty("辅助检查") @ApiModelProperty("辅助检查")
private List<MedicalRecCheckResVO> ancillaryList; private List<DiseaseAncillaryResVo> ancillaryList;
@ApiModelProperty("体格检查") @ApiModelProperty("体格检查")
private List<MedicalRecCheckResVO> physicalList; private List<DiseasePhysicalResVo> physicalList;
@ApiModelProperty("处置计划列表") @ApiModelProperty("处置计划列表")
private List<MedicalRecTreatmentPlanResVO> treatmentPlanList; private List<TreatmentPlanResVo> treatmentPlanList;
} }

@ -10,6 +10,9 @@ import com.supervision.exception.BusinessException;
import com.supervision.manage.pojo.vo.MedicalRecInfoVO; import com.supervision.manage.pojo.vo.MedicalRecInfoVO;
import com.supervision.manage.pojo.vo.MedicalRecManageVO; import com.supervision.manage.pojo.vo.MedicalRecManageVO;
import com.supervision.manage.pojo.vo.MedicalRecQaVO; import com.supervision.manage.pojo.vo.MedicalRecQaVO;
import com.supervision.manage.service.DiseaseAncillaryManageService;
import com.supervision.manage.service.DiseasePhysicalManageService;
import com.supervision.manage.service.DiseaseTreatmentPlanManageService;
import com.supervision.model.*; import com.supervision.model.*;
import com.supervision.service.*; import com.supervision.service.*;
import com.supervision.vo.manage.MedicalRecPageResVO; import com.supervision.vo.manage.MedicalRecPageResVO;
@ -42,6 +45,12 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
private final DiseaseQuestionService diseaseQuestionService; private final DiseaseQuestionService diseaseQuestionService;
private final DiseaseAncillaryManageService diseaseAncillaryManageService;
private final DiseasePhysicalManageService diseasePhysicalManageService;
private final DiseaseTreatmentPlanManageService diseaseTreatmentPlanManageService;
public List<Disease> queryDiseaseListByKeyWord(String keyword) { public List<Disease> queryDiseaseListByKeyWord(String keyword) {
// 注意,这里不支持查询复杂疾病,如果需要支持复杂疾病,这里需要单独进行改造 // 注意,这里不支持查询复杂疾病,如果需要支持复杂疾病,这里需要单独进行改造
return diseaseService.lambdaQuery().eq(Disease::getDiseaseType, 0).like(Disease::getDiseaseName, keyword).list(); return diseaseService.lambdaQuery().eq(Disease::getDiseaseType, 0).like(Disease::getDiseaseName, keyword).list();
@ -86,7 +95,7 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
public List<MedicalRecQaVO> queryQuestionListByCreat(String diseaseId) { public List<MedicalRecQaVO> queryQuestionListByCreat(String diseaseId) {
// 去vp_disease_question获取 // 去vp_disease_question获取
List<DiseaseQuestion> list = diseaseQuestionService.lambdaQuery().eq(DiseaseQuestion::getDiseaseId, diseaseId).list(); List<DiseaseQuestion> list = diseaseQuestionService.lambdaQuery().eq(DiseaseQuestion::getDiseaseId, diseaseId).list();
if (CollUtil.isEmpty(list)){ if (CollUtil.isEmpty(list)) {
return new ArrayList<>(); return new ArrayList<>();
} }
// 获取问题 // 获取问题
@ -162,11 +171,11 @@ public class MedicalRecManageServiceImpl implements MedicalRecManageService {
// 病人基本信息 // 病人基本信息
medicalRecInfoVO.setPatient(patientService.getById(medicalRec.getPatientId())); medicalRecInfoVO.setPatient(patientService.getById(medicalRec.getPatientId()));
// 辅助检查 // 辅助检查
// medicalRecInfoVO.setAncillaryList(); medicalRecInfoVO.setAncillaryList(diseaseAncillaryManageService.queryListByDiseaseId(medicalRec.getDiseaseId()));
// 体格检查 // 体格检查
// medicalRecInfoVO.setPhysicalList(); medicalRecInfoVO.setPhysicalList(diseasePhysicalManageService.queryListByDiseaseId(medicalRec.getDiseaseId()));
// 处置计划 // 处置计划
// medicalRecInfoVO.setTreatmentPlanList(); medicalRecInfoVO.setTreatmentPlanList(diseaseTreatmentPlanManageService.queryListByDiseaseId(medicalRec.getDiseaseId()));
// 问答策略 // 问答策略
medicalRecInfoVO.setQaList(queryMedicalRecQaInfo(id)); medicalRecInfoVO.setQaList(queryMedicalRecQaInfo(id));
return medicalRecInfoVO; return medicalRecInfoVO;

@ -14,6 +14,10 @@ public class MedicalRecPageResVO {
private Integer age; private Integer age;
private String gender; private String gender;
private LocalDateTime time; private LocalDateTime time;
/**
* ->
*/
private String diagnosisPrimaryStr;
} }

@ -36,14 +36,15 @@
select select
t1.id as medicalId, t1.id as medicalId,
t2.id as patientId, t2.id as patientId,
t3.disease_name as diagnosisPrimaryStr,
t1.no as no, t1.no as no,
t2.name as name, t2.name as name,
t2.age as age, t2.age as age,
t2.gender as gender, t2.gender as gender,
if(t1.update_time is null, t1.create_time, t1.update_time) as time if(t1.update_time is null, t1.create_time, t1.update_time) as time
from vp_medical_rec t1 from vp_medical_rec t1
left join vp_patient t2 left join vp_patient t2 on t1.patient_id = t2.id
on t1.patient_id = t2.id left join vp_disease t3 on t1.disease_id = t3.id
<where> <where>
<if test="selfDescKeyword != null and selfDescKeyword != ''"> <if test="selfDescKeyword != null and selfDescKeyword != ''">
AND t1.patient_self_desc like concat("%",#{selfDescKeyword}, "%") AND t1.patient_self_desc like concat("%",#{selfDescKeyword}, "%")

Loading…
Cancel
Save