| 
					
				 | 
			
			
				@ -25,65 +25,65 @@ public class PatientInterceptor extends BaseInterceptor { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
					public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						boolean flag = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			if(request.getRequestURI().contains("/patient/hosptail/getHositalByTownCode")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			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 user = json.has("uid") ? json.getString("uid") : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			String imei = json.has("imei") ? json.getString("imei") : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			String openid = json.has("openid") ? json.getString("openid") : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			int platform = json.has("platform") ? json.getInt("platform") : 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			if (StringUtils.isEmpty(imei)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				imei = openid; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				// 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			Token token = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			if (platform == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				token = SystemData.patientTokens.get(user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			} else if (platform == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				token = SystemData.wxPatientTokens.get(user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			if (token == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				token = tokenDao.findByPatient(user, platform); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 加入缓存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				if (platform == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					SystemData.patientTokens.put(user, token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				} else if (platform == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					SystemData.wxPatientTokens.put(user, token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			if (token == null || StringUtils.isEmpty(tokenStr) || (token.getPlatform() != 1 && token.getPlatform() != 3)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				// 未登录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				flag = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(user, 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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						// 更新内存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						if (platform == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							SystemData.patientTokens.put(user, token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						} else if (platform == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//							SystemData.wxPatientTokens.put(user, token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						// 更新数据库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//						tokenDao.save(token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				//			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if(request.getRequestURI().contains("/patient/hosptail/getHositalByTownCode")){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								return true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							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 user = json.has("uid") ? json.getString("uid") : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							String imei = json.has("imei") ? json.getString("imei") : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							String openid = json.has("openid") ? json.getString("openid") : ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							int platform = json.has("platform") ? json.getInt("platform") : 1; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (StringUtils.isEmpty(imei)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								imei = openid; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							Token token = null; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (platform == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								token = SystemData.patientTokens.get(user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} else if (platform == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								token = SystemData.wxPatientTokens.get(user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (token == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								token = tokenDao.findByPatient(user, platform); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 加入缓存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (platform == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									SystemData.patientTokens.put(user, token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} else if (platform == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									SystemData.wxPatientTokens.put(user, token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							if (token == null || StringUtils.isEmpty(tokenStr) || (token.getPlatform() != 1 && token.getPlatform() != 3)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								// 未登录 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								response.getOutputStream().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!").getBytes()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								flag = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								if (!StringUtils.equals(tokenStr, token.getToken()) || !StringUtils.equals(user, 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()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										// 更新内存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										if (platform == 1) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
											SystemData.patientTokens.put(user, token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										} else if (platform == 3) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
											SystemData.wxPatientTokens.put(user, token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										// 更新数据库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
										tokenDao.save(token); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
									} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
								} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} catch (Exception e) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
							e.printStackTrace(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
						} 
			 |