chenweida 8 lat temu
rodzic
commit
029c92f62d

+ 53 - 53
patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java

@ -23,59 +23,59 @@ public class DoctorInterceptor extends BaseInterceptor {
	@Override
	public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
		boolean flag = true;
		try {
			response.setCharacterEncoding("UTF-8");
			JSONObject json = getAgent(request);
			if (json == null) {
				// 未登录
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				return false;
			}
			String tokenStr = json.has("token") ? json.getString("token") : "";
			String uid = json.has("uid") ? json.getString("uid") : "";
			String imei = json.has("imei") ? json.getString("imei") : "";
			if (StringUtils.isEmpty(tokenStr) || StringUtils.isEmpty(imei) || StringUtils.isEmpty(uid)) {
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				return false;
			}
			Token token = SystemData.doctorTokens.get(uid);
			if (token == null) {
				token = tokenDao.findByPatient(uid, 2);
				if (token != null) {
					// 加入缓存
					SystemData.doctorTokens.put(uid, token);
				}
			}
			if (token == null || token.getPlatform() != 2) {
				// 未登录
				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
				flag = false;
			} else {
				if (token.getTimeout().getTime() < new Date().getTime()) {
					// 登录超时
					response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes());
					flag = false;
				} else if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(uid, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
					// 别处登录
					response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes());
					flag = false;
				} else {
					// 一天只更新一次
					if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
						// 今天未更新,则更新缓存
						token.setCzrq(new Date());
						// 更新内存
						SystemData.doctorTokens.put(uid, token);
						// 更新数据库
						tokenDao.save(token);
					}
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
//		try {
//			response.setCharacterEncoding("UTF-8");
//			JSONObject json = getAgent(request);
//			if (json == null) {
//				// 未登录
//				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
//				return false;
//			}
//			String tokenStr = json.has("token") ? json.getString("token") : "";
//			String uid = json.has("uid") ? json.getString("uid") : "";
//			String imei = json.has("imei") ? json.getString("imei") : "";
//
//			if (StringUtils.isEmpty(tokenStr) || StringUtils.isEmpty(imei) || StringUtils.isEmpty(uid)) {
//				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
//				return false;
//			}
//
//			Token token = SystemData.doctorTokens.get(uid);
//			if (token == null) {
//				token = tokenDao.findByPatient(uid, 2);
//				if (token != null) {
//					// 加入缓存
//					SystemData.doctorTokens.put(uid, token);
//				}
//			}
//			if (token == null || token.getPlatform() != 2) {
//				// 未登录
//				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes());
//				flag = false;
//			} else {
//				if (token.getTimeout().getTime() < new Date().getTime()) {
//					// 登录超时
//					response.getOutputStream().write(error(SystemConf.LOGIN_TIMEOUT, "登录超时,请重新登录").getBytes());
//					flag = false;
//				} else if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(uid, token.getUser()) || !StringUtils.equals(imei, token.getImei())) {
//					// 别处登录
//					response.getOutputStream().write(error(SystemConf.LOGIN_OTHER, "帐号在别处登录,请重新登录").getBytes());
//					flag = false;
//				} else {
//					// 一天只更新一次
//					if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
//						// 今天未更新,则更新缓存
//						token.setCzrq(new Date());
//						// 更新内存
//						SystemData.doctorTokens.put(uid, token);
//						// 更新数据库
//						tokenDao.save(token);
//					}
//				}
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
		return flag;
	}

+ 3 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/doctor/SignPatientLabelDao.java

@ -54,4 +54,7 @@ public interface SignPatientLabelDao extends
    @Query("select a from SignPatientLabel a where a.status = 1 and a.labelName = ?1 and a.labelType = ?2 and a.teamCode = ?3")
    SignPatientLabel findByLabelNameAndLabelTypeAndTeamCode(String labelName,String labelType,Long teamCode);
    @Query("select a from SignPatientLabel a where a.status = ?2 and a.labelType = ?1 and (a.teamCode = ?3 or a.teamCode is null)")
    List<SignPatientLabel> findByLabelTypeAndStatusAndTeamCode(String labelType, int i, Long team);
}

+ 2 - 3
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/FamilyContractService.java

@ -1915,7 +1915,7 @@ public class FamilyContractService extends BaseService {
        datas = jdbcTemplate.queryForList(sql, labelType, doctorCode, teamCode);
        //根据类别查找标签
        List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatus(labelType, 1);
        List<SignPatientLabel> s =  labelDao.findByLabelTypeAndStatusAndTeamCode(labelType, 1,teamCode);
        if (s != null && s.size() > 0) {
            for (SignPatientLabel one : s) {
                returnMap.put(one.getLabelName(), new JSONArray());
@ -2188,7 +2188,6 @@ public class FamilyContractService extends BaseService {
    public JSONObject getPatientByLable(String doctorCode, String labelType, String level, Long team) throws Exception {
        JSONObject returnMap = new JSONObject();
        Doctor doctor = doctorDao.findByCode(doctorCode);
        //判断当前用户是健康管理师还是全科
        List<Map<String, Object>> datas = null;
        if (level.equals("3")) {
@ -2244,7 +2243,7 @@ public class FamilyContractService extends BaseService {
            throw new Exception("参数错误!");
        }
        //根据类别查找标签
        List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatus(labelType, 1);
        List<SignPatientLabel> s = labelDao.findByLabelTypeAndStatusAndTeamCode(labelType, 1,team);
        if (s != null && s.size() > 0) {
            for (SignPatientLabel one : s) {
                returnMap.put(one.getLabelName(), new JSONArray());