Kaynağa Gözat

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

huangwenjie 7 yıl önce
ebeveyn
işleme
ab4fe2ed00
16 değiştirilmiş dosya ile 348 ekleme ve 53 silme
  1. 10 5
      common/common-entity/pom.xml
  2. 10 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientAimSports.java
  3. 6 0
      common/common-entity/src/main/java/com/yihu/wlyy/entity/security/Token.java
  4. 19 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/device/WlyyDeviceController.java
  5. 14 2
      patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/DmDeviceService.java
  6. 19 2
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/device_create_js.jsp
  7. 22 4
      patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/device_modify_js.jsp
  8. 25 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java
  9. 11 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java
  10. 13 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  11. 21 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/TokenService.java
  12. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/applets/AppletsService.java
  13. 124 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemDataRedis.java
  14. 33 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  15. 9 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java
  16. 10 2
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

+ 10 - 5
common/common-entity/pom.xml

@ -64,11 +64,16 @@
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
        </dependency>
 <!--       <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
            <version>1.3.5.RELEASE</version>
        </dependency>-->
        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
        </dependency>
        <!--       <dependency>
                   <groupId>org.springframework.boot</groupId>
                   <artifactId>spring-boot-starter-data-elasticsearch</artifactId>
                   <version>1.3.5.RELEASE</version>
               </dependency>-->
    </dependencies>
</project>

+ 10 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/patient/PatientAimSports.java

@ -20,6 +20,7 @@ public class PatientAimSports extends IdEntity {
    private Integer dailyStepCount;     //运动步数
    private String bmiMax;              //bmi标准上限
    private String bmiMin;              //bmi标准下线
    private String createDate;      //上传日期
    private Date createTime;       //创建时间
@ -84,4 +85,13 @@ public class PatientAimSports extends IdEntity {
        this.createTime = createTime;
    }
    @Basic
    @Column(name = "create_date")
    public String getCreateDate() {
        return createDate;
    }
    public void setCreateDate(String createDate) {
        this.createDate = createDate;
    }
}

+ 6 - 0
common/common-entity/src/main/java/com/yihu/wlyy/entity/security/Token.java

@ -2,6 +2,7 @@ package com.yihu.wlyy.entity.security;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.wlyy.entity.IdEntity;
import net.sf.json.JSONObject;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -78,4 +79,9 @@ public class Token extends IdEntity {
		this.del = del;
	}
	public String toJson(){
		JSONObject jsonObject = JSONObject.fromObject(this);
		return jsonObject.toString();
	}
}

+ 19 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/controller/manager/device/WlyyDeviceController.java

@ -3,6 +3,8 @@ package com.yihu.wlyy.controller.manager.device;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.controller.BaseController;
import com.yihu.wlyy.device.entity.WlyyDevice;
import com.yihu.wlyy.entity.DmDevice;
import com.yihu.wlyy.service.manager.device.DmDeviceService;
import com.yihu.wlyy.service.manager.device.WlyyDeviceService;
import jxl.Workbook;
import jxl.read.biff.BiffException;
@ -29,9 +31,11 @@ import java.util.List;
@Controller
@RequestMapping("admin/device")
public class WlyyDeviceController extends BaseController {
    @Autowired
    private WlyyDeviceService deviceService;
    @Autowired
    private DmDeviceService dmDeviceService;
    @Autowired
    private ObjectMapper objectMapper;
@ -72,6 +76,20 @@ public class WlyyDeviceController extends BaseController {
        }
    }
    //设备型号列表
    @RequestMapping(value = "modelList",method = RequestMethod.POST)
    @ResponseBody
    public String findAll(){
        try{
            List<DmDevice> list = dmDeviceService.findAll();
            return  write(200,"操作成功","data",list);
        }catch (Exception ex){
            error(ex);
            return error(-1, "操作失败!");
        }
    }
    @RequestMapping(value = "device")
    @ResponseBody
    public String getDevice(@RequestParam(value = "id") Long id){
@ -142,7 +160,6 @@ public class WlyyDeviceController extends BaseController {
        return deviceService.existDeviceCode(deviceCode);
    }
    
    
    //导出设备报表
    @RequestMapping(value="toExcel",method = RequestMethod.POST,produces = "application/json;charset=UTF-8" )
    public void exportList(

+ 14 - 2
patient-co-manage/wlyy-manage/src/main/java/com/yihu/wlyy/service/manager/device/DmDeviceService.java

@ -1,9 +1,21 @@
package com.yihu.wlyy.service.manager.device;
import com.yihu.wlyy.entity.DmDevice;
import com.yihu.wlyy.repository.DmDeviceDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by Administrator on 2017/1/18.
 * Created by humingfen on 2018/8/17.
 */
@Service
public class DmDeviceService {
    @Autowired
    private DmDeviceDao dmDeviceDao;
    public List<DmDevice> findAll() {
        return (List<DmDevice>)dmDeviceDao.findAll();
    }
}

+ 19 - 2
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/device_create_js.jsp

@ -19,7 +19,8 @@
				    /*
				     *设备厂商列表
				     */
				    manufacturerList: '/admin/manufacturer/findAll'
				    manufacturerList: '/admin/manufacturer/findAll',
                    deviceModelList: '/admin/device/modelList'
                },
				init: function () {
                    this.initComboBox();
@ -31,7 +32,7 @@
					$("#inp_tel").ligerTextBox({width: 240})//联系电话
					$("#inp_serverIp").ligerTextBox({width: 240})//服务IP地址
					$("#inp_deviceName").ligerTextBox({width: 240})//设备名称
					$("#inp_deviceModel").ligerTextBox({width: 240})//设备型号
					// $("#inp_deviceModel").ligerTextBox({width: 240})//设备型号
					$("#inp_deviceCode").ligerTextBox({width: 240})//设备唯一标识
					$("#inp_sim").ligerTextBox({width: 240})//设备sim码
					//$("#inp_manufacturer").ligerTextBox({width: 240})//厂家名称
@ -56,6 +57,16 @@
                            });
                        }
                        that.initInpCat( d, that);
                    });
                    this.rAjax( this.url.deviceModelList,{} ,function (data) {
                        var d = [];
                        for (var i = 0; i < data.data.length; i++) {
                            d.push({
                                text: data.data[i].name,
                                id: data.data[i].model
                            });
                        }
                        that.initModel( d, that);
                    })
                },
                //设备厂商下拉框
@ -64,6 +75,12 @@
                        data: d,
                    });
                },
                //设备型号下拉框
                initModel: function(d, me) {
				    $("#inp_deviceModel").ligerComboBox({
                        data: d
                    })
                },
				//绑定事件
				bindEvents: function () {

+ 22 - 4
patient-co-manage/wlyy-manage/src/main/webapp/WEB-INF/views/device/device_modify_js.jsp

@ -19,6 +19,7 @@
				//变量
				$form: $("#div_patient_info_form"),
                $manufacturer: $("#sel_manufacturer"),
                $deviceModel: $("#inp_deviceModel"),
				init: function () {
                    _this = this;
                    this.$form.attrScan();
@ -29,7 +30,7 @@
					$("#inp_tel").ligerTextBox({width: 240})//联系电话
					$("#inp_serverIp").ligerTextBox({width: 240})//服务IP地址
					$("#inp_deviceName").ligerTextBox({width: 240})//设备名称
					$("#inp_deviceModel").ligerTextBox({width: 240})//设备型号
					// $("#inp_deviceModel").ligerTextBox({width: 240})//设备型号
					$("#inp_deviceCode").ligerTextBox({width: 240})//设备唯一标识
					$("#inp_sim").ligerTextBox({width: 240})//设备sim
					// $("#inp_manufacturer").ligerTextBox({width: 240})//厂家名称
@ -52,11 +53,27 @@
                            if (ajaxHeaderName) {
                                xhr.setRequestHeader(ajaxHeaderName, ajaxHeaderValue);
                            }
                        },
                        }
                    });
                    //厂商下拉框刷新
                    //设备型号下拉框
                    _this.deviceModelBox = _this.$deviceModel.ligerComboBox({
                        url: ctx + "/admin/device/modelList",
                        parms: {},
                        dataParmName: "data",
                        textField: "name",
                        valueField: "model",
                        isMultiSelect: false,
                        ajaxBeforeSend: function (xhr) {
                            if (ajaxHeaderName) {
                                xhr.setRequestHeader(ajaxHeaderName, ajaxHeaderValue);
                            }
                        }
                    });
                    //下拉框刷新
                    _this.reloadManufacturerBox = function () {
                        deviceInfo.manufacturerBox.reload();
                        deviceInfo.deviceModelBox.reload();
                    };
                },
@ -83,7 +100,6 @@
									serverIp: data.serverIp,
									deviceName: data.deviceName,
									sim: data.sim,
									deviceModel: data.deviceModel,
									deviceCode: data.deviceCode,
									address: data.address,
									representative: data.representative,
@ -94,6 +110,7 @@
								});
								//填值
								_this.manufacturerBox.selectValue(data.manufacturerId);
								_this.deviceModelBox.selectValue(data.deviceModel)
							} else {
								$.Notice.error(result.msg);
							}
@ -160,6 +177,7 @@
						//厂家名称
						values.manufacturerId = self.manufacturerBox.getValue();
                        values.manufacturer = self.manufacturerBox.getText();
                        values.deviceModel = self.deviceModelBox.getValue();
						if (!validator.validate()) {
							return;
						}

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

@ -6,10 +6,12 @@ import com.yihu.wlyy.logs.InterfaceCallLogs;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.util.SystemDataRedis;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
@ -34,6 +36,9 @@ public class DoctorInterceptor extends BaseInterceptor {
    public static String status = "1";
    @Autowired
    public SystemDataRedis systemDataRedis;
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        boolean flag = true;
@ -121,14 +126,19 @@ public class DoctorInterceptor extends BaseInterceptor {
            Token token = null;
            Map<String, Token> tempMap = null;
            //1.50 登录缓存存储为redis
            if (platform == 2) {
                tempMap = SystemData.doctorTokens;
                //tempMap = SystemData.doctorTokens;
                token = systemDataRedis.getDoctorToken(uid);
            } else if (platform == 4) {
                tempMap = SystemData.doctorPCTokens;
                //tempMap = SystemData.doctorPCTokens;
                token = systemDataRedis.getDoctorPCToken(uid);
            }else if(platform ==5){
                tempMap = SystemData.doctorWXTokens;
                //tempMap = SystemData.doctorWXTokens;
                token = systemDataRedis.getDoctorWXToken(uid);
            }
            token = tempMap.get(uid);
            //token = tempMap.get(uid);
            if (token == null) {
                token = tokenDao.findByPatient(uid, platform);
                if (token != null) {
@ -155,8 +165,17 @@ public class DoctorInterceptor extends BaseInterceptor {
                    if (DateUtil.getDays(token.getCzrq(), DateUtil.getNowDateShort()) != 0) {
                        // 今天未更新,则更新缓存
                        token.setCzrq(new Date());
                        // 更新内存
                        tempMap.put(uid, token);
                        //1.5.0更新redis缓存
                        if (platform == 2) {
                            systemDataRedis.setDoctorToken(token);
                        } else if (platform == 4) {
                            systemDataRedis.setDoctorPCToken(token);
                        }else if(platform ==5){
                            systemDataRedis.setDoctorWXToken(token);
                        }
//                        // 更新内存
//                        tempMap.put(uid, token);
                        // 更新数据库
                        tokenDao.save(token);
                    }

+ 11 - 4
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java

@ -5,10 +5,12 @@ import com.yihu.wlyy.logs.InterfaceCallLogs;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.util.SystemDataRedis;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
@ -29,6 +31,8 @@ import java.util.Date;
public class PatientInterceptor extends BaseInterceptor {
    private Logger logger = LoggerFactory.getLogger(PatientInterceptor.class);
    @Autowired
    private SystemDataRedis systemDataRedis;
    public static String status = "1";
@ -67,16 +71,18 @@ public class PatientInterceptor extends BaseInterceptor {
            if (StringUtils.isEmpty(imei)) {
                imei = openid;
            }
            //1.5.0 获取token redis
            Token token = null;
            if (platform == 3) {
                token = SystemData.patientTokens.get(user);
                token = systemDataRedis.getPatientToken(user);
//                token = SystemData.patientTokens.get(user);
            }
            if (token == null) {
                token = tokenDao.findByPatient(user, platform);
                // 加入缓存
                if (platform == 3) {
                    SystemData.patientTokens.put(user, token);
                    systemDataRedis.setPatientToken(token);
                    //SystemData.patientTokens.put(user, token);
                }
            }
            if (token == null || StringUtils.isEmpty(tokenStr) || (token.getPlatform() != 1 && token.getPlatform() != 3)) {
@ -95,7 +101,8 @@ public class PatientInterceptor extends BaseInterceptor {
                        token.setCzrq(new Date());
                        // 更新内存
                        if (platform == 3) {
                            SystemData.patientTokens.put(user, token);
                            systemDataRedis.setPatientToken(token);
                            //SystemData.patientTokens.put(user, token);
                        }
                        // 更新数据库
                        tokenDao.save(token);

+ 13 - 7
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java

@ -17,10 +17,7 @@ import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.repository.patient.PatientRecordLogDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.repository.security.TokenDao;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.EncodesUtil;
import com.yihu.wlyy.util.IdcardInfoExtractor;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.util.*;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
@ -60,6 +57,8 @@ public class PatientService extends TokenService {
    TokenDao tokenDao;
    @Autowired
    JdbcTemplate jdbcTemplate;
    @Autowired
    private SystemDataRedis systemDataRedis;
    private Clock clock = Clock.DEFAULT;
    //可续签月份
@ -122,9 +121,11 @@ public class PatientService extends TokenService {
            for (Token token : tokens) {
                i++;
                Patient p = patientDao.findByCode(token.getUser());
                //1.5.0 redis token
                if (p == null || i <= last) {
                    tokenDao.delete(token);
                    SystemData.patientTokens.remove(token.getUser());
                    systemDataRedis.delToken(SystemDataRedis.patientTokens,token.getUser());
                    //SystemData.patientTokens.remove(token.getUser());
                    continue;
                }
//                p.setOpenid("");
@ -132,7 +133,9 @@ public class PatientService extends TokenService {
                signFamilyDao.updateOpenidByPatient("", p.getCode());
                patientDao.save(p);
                tokenDao.delete(token);
                SystemData.patientTokens.remove(p.getCode());
                systemDataRedis.delToken(SystemDataRedis.patientTokens,token.getUser());
//                SystemData.patientTokens.remove(p.getCode());
                break;
            }
        }
@ -1145,7 +1148,10 @@ public class PatientService extends TokenService {
            patientRecordLogDao.save(patientRecordLog);
            //清登录缓存
            SystemData.patientTokens.remove(patient.getCode());
            //SystemData.patientTokens.remove(patient.getCode());
            //1.5.0清楚redis缓存
            systemDataRedis.delToken(SystemDataRedis.patientTokens,patient.getCode());
        }
        patientDao.clearOpenidByOpenid(openid);
        return "";

+ 21 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/TokenService.java

@ -7,6 +7,7 @@ import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.util.SystemDataRedis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -21,6 +22,8 @@ public class TokenService extends BaseService {
	public TokenDao tokenDao;
	@Autowired
	private PatientDao patientDao;
	@Autowired
	private SystemDataRedis systemDataRedis;
	/**
	 * 生成token
@ -56,14 +59,19 @@ public class TokenService extends BaseService {
			throw new Exception("Token生成失败");
		}
		// 更新token缓存
		//1.5.0 更新redis token缓存
		if (platform == 3) {
			SystemData.patientTokens.put(user, token);
			systemDataRedis.setPatientToken(token);
			//SystemData.patientTokens.put(user, token);
		} else if (platform == 2) {
			SystemData.doctorTokens.put(user, token);
			systemDataRedis.setDoctorToken(token);
			//SystemData.doctorTokens.put(user, token);
		}else if(platform == 4){
			SystemData.doctorPCTokens.put(user,token);
			systemDataRedis.setDoctorPCToken(token);
			//SystemData.doctorPCTokens.put(user,token);
		}else if(platform == 5){
			SystemData.doctorWXTokens.put(user,token);
			systemDataRedis.setDoctorWXToken(token);
			//SystemData.doctorWXTokens.put(user,token);
		}
		return token;
	}
@ -89,8 +97,10 @@ public class TokenService extends BaseService {
		if (token == null) {
			throw new Exception("Token生成失败");
		}
		//1.5.0 redis token
		// 更新token缓存
		SystemData.patientTokens.put(user, token);
		//SystemData.patientTokens.put(user, token);
		systemDataRedis.setPatientToken(token);
		return token;
	}
@ -103,11 +113,14 @@ public class TokenService extends BaseService {
	public void delToken(int platform, String uid) throws Exception {
		// 删除老的token
		tokenDao.deleteByUser(uid);
		// 更新token缓存
		// 1.5.0 更新token缓存 redis
		if (platform == 3) {
			SystemData.patientTokens.remove(uid);
			//1.5.0 删除居民Token
			systemDataRedis.delToken(SystemDataRedis.patientTokens,uid);
			//SystemData.patientTokens.remove(uid);
		} else if (platform == 2) {
			SystemData.doctorTokens.remove(uid);
			systemDataRedis.delToken(SystemDataRedis.doctorTokens,uid);
			//SystemData.doctorTokens.remove(uid);
		}
	}

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/applets/AppletsService.java

@ -6,6 +6,7 @@ import com.yihu.wlyy.repository.patient.PatientAimSportsDao;
import com.yihu.wlyy.repository.patient.PatientDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.health.bank.TaskService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.SecretUtils;
import com.yihu.wlyy.util.http.HttpResponse;
import com.yihu.wlyy.util.http.HttpUtils;
@ -138,6 +139,7 @@ public class AppletsService extends BaseService {
            patientAimSports.setDailyStepCount(step);
            patientAimSports.setCreateTime(new Date());
            patientAimSports.setPatientcode(patient);
            patientAimSports.setCreateDate(DateUtil.getStringDateShort());
            patientAimSportsDao.save(patientAimSports);
        }

+ 124 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemDataRedis.java

@ -0,0 +1,124 @@
package com.yihu.wlyy.util;
import com.yihu.wlyy.entity.security.Token;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.Set;
/**
 * Created by Trick on 2018/8/20.
 * 1.5.0 版本 将token 存储在redis
 */
@Component
public class SystemDataRedis {
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * tokenTypeName
     */
    public final static String doctorTokens = "doctorTokens";//医生缓存
    public final static String doctorPCTokens = "doctorPCTokens";//pc端缓存
    public final static String patientTokens = "patientTokens";//居民缓存
    public final static String doctorWXTokens = "doctorWXTokens";//医生微信缓存
//====设置token========
    /**
     * 设置医生缓存
     * @param token
     */
    public String setDoctorToken(Token token){
        return setToken(doctorTokens,token);
    }
    /**
     * 设置pc端缓存
     * @param token
     */
    public String setDoctorPCToken(Token token){
       return setToken(doctorPCTokens,token);
    }
    /**
     * 设置居民缓存
     * @param token
     */
    public String setPatientToken(Token token){
        return setToken(patientTokens,token);
    }
    /**
     *  设置医生微信缓存
     * @param token
     */
    public String setDoctorWXToken(Token token){
        return setToken(doctorWXTokens,token);
    }
//====设置token==end===
//====获取token========
    public Token getDoctorToken(String uid){
        return getToken(doctorTokens,uid);
    }
    public Token getDoctorPCToken(String uid){
        return getToken(doctorPCTokens,uid);
    }
    public Token getPatientToken(String uid){
        return getToken(patientTokens,uid);
    }
    public Token getDoctorWXToken(String uid){
        return getToken(doctorWXTokens,uid);
    }
//=====获取token===end===
    /**
     * 设置token
     * @param tokenTypeName
     * @param token
     */
    public String setToken(String tokenTypeName,Token token){
        JSONObject json = JSONObject.fromObject(token);
        String key = "token:"+tokenTypeName+":"+token.getUser();
        redisTemplate.opsForValue().set(key,json.toString());
        return json.toString();
    }
    /**
     * 获取token
     * @param tokenTypeName
     * @param uid
     * @return
     */
    public Token getToken(String tokenTypeName,String uid) {
        String tokenJosn = redisTemplate.opsForValue().get("token:" + tokenTypeName + ":" + uid);
        Token token = (Token)JSONObject.toBean(JSONObject.fromObject(tokenJosn),Token.class);
        return token;
    }
    /**
     * 删除token
     * @param tokenTypeName
     * @param uid
     * @return
     */
    public void delToken(String tokenTypeName,String uid){
        String key = "token:"+tokenTypeName+":"+uid;
        redisTemplate.delete(key);
    }
    public int getTokenMember(String tokenTypeName){
        Set set =  redisTemplate.keys("token:" + tokenTypeName);
        if(set!=null&&set.size()>0){
            return set.size();
        }
        return 0;
    }
}

+ 33 - 8
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java

@ -12,10 +12,7 @@ import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.service.common.account.RoleService;
import com.yihu.wlyy.service.common.account.TokenService;
import com.yihu.wlyy.service.common.login.LoginLogService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.MD5;
import com.yihu.wlyy.util.RSAUtils;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.util.*;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
@ -75,6 +72,9 @@ public class LoginController extends BaseController {
    @Autowired
    private DoctorInfoService doctorInfoService;
    @Autowired
    private SystemDataRedis systemDataRedis;
    /**
     * 公钥生成并返回接口
@ -438,13 +438,15 @@ public class LoginController extends BaseController {
                // response.getWriter().write(error(SystemConf.NOT_LOGIN, "请登录后再操作!"));
                return error(-1, "系统异常,操作失败");
            }
            Token token = SystemData.doctorTokens.get(uid);
            //1.5.0 存储redis缓存
            Token token = systemDataRedis.getDoctorToken(uid);
            //Token token = SystemData.doctorTokens.get(uid);
            if (token == null) {
                token = tokenDao.findByToken(tokenStr);
                if (token != null) {
                    // 加入缓存
                    SystemData.doctorTokens.put(uid, token);
                    systemDataRedis.setDoctorToken(token);
                    //SystemData.doctorTokens.put(uid, token);
                }
            }
            if (token == null || token.getPlatform() != 2) {
@ -466,7 +468,8 @@ public class LoginController extends BaseController {
                        // 今天未更新,则更新缓存
                        token.setCzrq(new Date());
                        // 更新内存
                        SystemData.doctorTokens.put(uid, token);
                        systemDataRedis.setDoctorToken(token);
                        //SystemData.doctorTokens.put(uid, token);
                        // 更新数据库
                        tokenDao.save(token);
                    }
@ -560,5 +563,27 @@ public class LoginController extends BaseController {
        }
    }
    @RequestMapping(value = "setTokenTest", method = RequestMethod.POST)
    @ResponseBody
    public String setToken(String uid){
        Token token = new Token();
        token.setToken("123456");
        token.setDel("1");
        token.setCzrq(new Date());
        token.setUser(uid);
        return write(200,systemDataRedis.setDoctorPCToken(token));
    }
    @RequestMapping(value = "getTokenTest", method = RequestMethod.POST)
    @ResponseBody
    public String getToken(String uid){
        return write(200,systemDataRedis.getDoctorPCToken(uid).toJson());
    }
    @RequestMapping(value = "getTokenNumberTest", method = RequestMethod.POST)
    @ResponseBody
    public String getTokenNumber(){
        return write(200,systemDataRedis.getTokenMember(SystemDataRedis.doctorTokens)+"");
    }
}

+ 9 - 3
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java

@ -12,6 +12,7 @@ import com.yihu.wlyy.service.common.util.ManageUtilService;
import com.yihu.wlyy.service.common.util.SignTeamAndGroupRunnable;
import com.yihu.wlyy.util.SpringUtil;
import com.yihu.wlyy.util.SystemData;
import com.yihu.wlyy.util.SystemDataRedis;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -50,6 +51,8 @@ public class ManagerUtilController extends BaseController {
    JdbcTemplate jdbcTemplate;
    @Autowired
    ConsultTeamDoctorDao consultTeamDoctorDao;
    @Autowired
    SystemDataRedis systemDataRedis;
    /*********************************************患者疾病相关******************************************/
    /**
@ -268,9 +271,12 @@ public class ManagerUtilController extends BaseController {
    public String online_num() {
        try {
            JSONObject jo = new JSONObject();
            jo.put("doctor_online", SystemData.doctorTokens.size());
            jo.put("pc_online", SystemData.doctorPCTokens.size());
            jo.put("patient_online", SystemData.patientTokens.size());
//            jo.put("doctor_online", SystemData.doctorTokens.size());
//            jo.put("pc_online", SystemData.doctorPCTokens.size());
//            jo.put("patient_online", SystemData.patientTokens.size());
            jo.put("doctor_online", systemDataRedis.getTokenMember(SystemDataRedis.doctorTokens));
            jo.put("pc_online", systemDataRedis.getTokenMember(SystemDataRedis.doctorPCTokens));
            jo.put("patient_online", systemDataRedis.getTokenMember(SystemDataRedis.patientTokens));
            return write(200, "启动成功","data",jo);
        } catch (Exception e) {
            error(e);

+ 10 - 2
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -76,6 +76,8 @@ public class PatientController extends WeixinBaseController {
    private WeiXinTagUtil weiXinTagUtil;
    @Autowired
    private RSAUtils rsaUtils;
    @Autowired
    private SystemDataRedis systemDataRedis;
    /**
     * 患者基本信息查询接口
@ -393,7 +395,10 @@ public class PatientController extends WeixinBaseController {
            } else {
                //patient.setOpenid("");
                //patientInfoService.updateUser(patient);
                Token token = SystemData.patientTokens.get(getUID());
                //1.5.0 token存储redis
                //Token token = SystemData.patientTokens.get(getUID());
                Token token = systemDataRedis.getPatientToken(getUID());
                if (token == null) {
                    token = tokenDao.findByPatient(getUID(), 3);
                }
@ -404,7 +409,10 @@ public class PatientController extends WeixinBaseController {
                token.setDel("0");
                tokenDao.save(token);
                SystemData.patientTokens.remove(getUID());
                systemDataRedis.delToken(SystemDataRedis.patientTokens,getUID());
//                SystemData.patientTokens.remove(getUID());
                //清空患者的微信标签
                weiXinTagUtil.deleteTagWithOpenid(patient.getOpenid(),patient.getWxtagid());
                patient.setIsWxtag(Patient.isWchatTage.no.getValue());