فهرست منبع

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

humingfen 7 سال پیش
والد
کامیت
c728812708
20فایلهای تغییر یافته به همراه348 افزوده شده و 95 حذف شده
  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. 1 1
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/LoadNewSignThread.java
  5. 8 8
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/LoadThread.java
  6. 3 0
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/SignFamilyRenewLogDao.java
  7. 45 38
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/ChargeZYService.java
  8. 1 0
      patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/SignRenewZYService.java
  9. 25 6
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/DoctorInterceptor.java
  10. 11 4
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/interceptors/PatientInterceptor.java
  11. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  12. 13 7
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/PatientService.java
  13. 21 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/account/TokenService.java
  14. 9 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java
  15. 2 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/applets/AppletsService.java
  16. 5 5
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java
  17. 124 0
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/util/SystemDataRedis.java
  18. 33 8
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/account/LoginController.java
  19. 9 3
      patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/util/ManagerUtilController.java
  20. 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();
	}
}

+ 1 - 1
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/LoadNewSignThread.java

@ -13,7 +13,7 @@ import java.util.Date;
 * */
public class LoadNewSignThread implements Runnable {
    int retryTime =  30000;
    int retryTime =  10000;
    //空闲时间
    Integer nightHours = 23;

+ 8 - 8
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/common/thread/LoadThread.java

@ -13,11 +13,11 @@ import java.util.Date;
 */
public class LoadThread implements Runnable {
    int retryTime =  30000;
    int retryTime =  10000;
    //空闲时间
    Integer nightHours = 22;
    Integer morningHours = 6;
    Integer nightHours = 23;
    Integer morningHours = 5;
    //默认线程间隔
    Integer sleepTime = 60;
@ -29,8 +29,8 @@ public class LoadThread implements Runnable {
                Date now = new Date();
                //判断非空闲时候
//                if(now.getHours()>=morningHours &&  now.getHours() < nightHours)
//                {
                if(now.getHours()>=morningHours &&  now.getHours() < nightHours)
                {
                    //签约更新
                    SignZYService signZYService = (SignZYService) SpringContextHolder.getSpringBean("SignZYService");
                    SystemDictService systemDictService = (SystemDictService) SpringContextHolder.getSpringBean("SystemDictService");
@ -58,9 +58,9 @@ public class LoadThread implements Runnable {
                        Thread.sleep(retryTime);
                        continue;
                    }
//                }
//
//                Thread.sleep(sleepTime*1000);
                }
                Thread.sleep(sleepTime*1000);
            } catch (Exception ex) {
                ex.printStackTrace();
                try {

+ 3 - 0
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/dao/SignFamilyRenewLogDao.java

@ -45,4 +45,7 @@ public interface SignFamilyRenewLogDao extends PagingAndSortingRepository<SignFa
    @Query("select a.proId from SignFamilyRenewLog a where a.signCode=?1")
    String getProId(String signCode);
    
    @Query("select a.renewProId from SignFamilyRenewLog a where a.signCode=?1")
    String getreProId(String signCode);
}

+ 45 - 38
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/ChargeZYService.java

@ -146,47 +146,54 @@ public class ChargeZYService {
    
                jsonObject.put("INSUR_PRO_ID",charge.getMiRegisterNo());//医保签约号
//                params.put("INSUR_PRO_ID", charge.getMiRegisterNo());  //医保签约号
                if("1".equals(sign.getRenewFlag())||"2".equals(sign.getRenewFlag())){
                    proId = signFamilyRenewLogDao.getProId(signCode);
                    if(StringUtils.isBlank(proId) || "0".equals(proId)){
                        
                        if("1".equals(sign.getSignSource())){
                            //如果是在基卫签约则需要更新同步
                            SignFamilyMapping signFamilyMapping = signFamilyMappingDao.findByCode(signCode);
                            signFamilyMapping.setNeedUpdate("1");
                            signFamilyMappingDao.save(signFamilyMapping);
                        }else{
                            //如果是网络签约则需要上传同步
                            SignFamilyRenewLog signFamilyRenewLog = signFamilyRenewLogDao.findBySignCode(signCode);
                            signFamilyRenewLog.setNeedUpload("1");
                            signFamilyRenewLogDao.save(signFamilyRenewLog);
                        }
    
                        //暂停30秒
                        Thread.sleep(30000);
                        return true;
                    }
                }else {
                    proId = signFamilyMappingDao.getProId(signCode);
                    if(StringUtils.isBlank(proId) || "0".equals(proId)){
    
                        SignFamilyMapping signFamilyMapping = signFamilyMappingDao.findByCode(signCode);
                        if("1".equals(sign.getSignSource())){
                            //如果是在基卫签约则需要更新同步
                            signFamilyMapping.setNeedUpdate("1");
                        }else{
                            //如果是网络签约则需要上传同步
                            signFamilyMapping.setNeedUpload("1");
                        }
                        signFamilyMappingDao.save(signFamilyMapping);
    
                        //暂停30秒
                        Thread.sleep(30000);
                        return true;
                proId = signFamilyMappingDao.getProId(signCode);
                if(StringUtils.isBlank(proId)){
                    proId = signFamilyRenewLogDao.getProId(signCode);
                    if(StringUtils.isBlank(proId)){
                        proId = signFamilyRenewLogDao.getreProId(signCode);
                    }
                }
//                if("1".equals(sign.getRenewFlag())||"2".equals(sign.getRenewFlag())){
//                    proId = signFamilyRenewLogDao.getProId(signCode);
//                    if(StringUtils.isBlank(proId) || "0".equals(proId)){
//
//                        if("1".equals(sign.getSignSource())){
//                            //如果是在基卫签约则需要更新同步
//                            SignFamilyMapping signFamilyMapping = signFamilyMappingDao.findByCode(signCode);
//                            signFamilyMapping.setNeedUpdate("1");
//                            signFamilyMappingDao.save(signFamilyMapping);
//                        }else{
//                            //如果是网络签约则需要上传同步
//                            SignFamilyRenewLog signFamilyRenewLog = signFamilyRenewLogDao.findBySignCode(signCode);
//                            signFamilyRenewLog.setNeedUpload("1");
//                            signFamilyRenewLogDao.save(signFamilyRenewLog);
//                        }
//
//                        //暂停30秒
//                        Thread.sleep(30000);
//                        return true;
//                    }
//                }else {
//                    proId = signFamilyMappingDao.getProId(signCode);
//                    if(StringUtils.isBlank(proId) || "0".equals(proId)){
//
//                        SignFamilyMapping signFamilyMapping = signFamilyMappingDao.findByCode(signCode);
//                        if("1".equals(sign.getSignSource())){
//                            //如果是在基卫签约则需要更新同步
//                            signFamilyMapping.setNeedUpdate("1");
//                        }else{
//                            //如果是网络签约则需要上传同步
//                            signFamilyMapping.setNeedUpload("1");
//                        }
//                        signFamilyMappingDao.save(signFamilyMapping);
//
//                        //暂停30秒
//                        Thread.sleep(30000);
//                        return true;
//                    }
//                }
    
                jsonObject.put("PRO_ID",proId);////标志(智业签约主键)
//                params.put("PRO_ID", proId);  //标志(智业签约主键)

+ 1 - 0
patient-co-service/wlyy_sign/src/main/java/com/yihu/wlyy/sign/service/SignRenewZYService.java

@ -1793,6 +1793,7 @@ public class SignRenewZYService {
                }
                mapping.setRenewUploadTime(new Date());
                mapping.setRenewProId(proId);
                mapping.setProId(proId);
                signFamilyMappingDao.save(mapping);
            }

+ 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);

+ 2 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -649,6 +649,8 @@ public class AdminTeamService extends BaseService {
            JSONObject doctorInfo = new JSONObject();
            doctorInfo.put("name",d.getName());
            doctorInfo.put("code",d.getCode());
            doctorInfo.put("dept_name",d.getDeptName());
            doctorInfo.put("job_name",d.getJobName());
            doctors.add(doctorInfo);
        }
        result.put("members",doctors);

+ 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);
		}
	}

+ 9 - 0
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/specialist/SpecialistService.java

@ -23,6 +23,7 @@ import com.yihu.wlyy.repository.specialist.SpecialDiseaseDao;
import com.yihu.wlyy.repository.specialist.TeamDiseaseRelationDao;
import com.yihu.wlyy.repository.wechat.WechatTemplateConfigDao;
import com.yihu.wlyy.service.BaseService;
import com.yihu.wlyy.service.app.team.AdminTeamService;
import com.yihu.wlyy.task.PushMsgTask;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.http.HttpResponse;
@ -81,6 +82,8 @@ public class SpecialistService extends BaseService {
    private PushMsgTask pushMsgTask;
    @Autowired
    private WechatTemplateConfigDao templateConfigDao;
    @Autowired
    private AdminTeamService memberService;
    public String setPatientLabelInfo(List<SignPatientLabelInfo> list) {
        if (list != null && list.size() > 0) {
@ -621,6 +624,12 @@ public class SpecialistService extends BaseService {
            JSONObject json = rs.getJSONObject("obj");
            List<PatientDiseaseServer> patientDiseaseServers =  patientDiseaseServerDao.findBySpecialistRelationCodeAndDel(code,"1");
            json.put("diseaseServer",patientDiseaseServers);
            
            //根据团队ID获取医生列表
            Long teamCode = json.getLong("teamCode");
            List<Doctor> members = memberService.getMembers(teamCode);
            json.put("doctors",members);
            
            return json;
        }
        return null;

+ 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);
        }

+ 5 - 5
patient-co/patient-co-wlyy/src/main/java/com/yihu/wlyy/service/weixin/wxpay/service/OnePayService.java

@ -328,10 +328,10 @@ public class OnePayService {
            if (signFamily != null) {
//                //签约人Code
                String signDoctorCode = signFamily.getSignDoctorCode();
                String doctorCode = signFamily.getDoctor();
                String people = signFamily.getPatient();
                Doctor doctor = doctorDao.findByCode(signDoctorCode);
                Doctor doctor = doctorDao.findByCode(doctorCode);
                Patient user = patientDao.findByCode(people);
    
                JSONObject familyContent =  new JSONObject();
@ -342,17 +342,17 @@ public class OnePayService {
                familyContent.put("moRegTelephone", user.getMobile());//签约人联系电话
                familyContent.put("moRegOrgNo", sbCode); //签约机构 限长4
                familyContent.put("moRegDocNo", doctor.getIdcard());//签约医生编号 限长18 身份证号
                familyContent.put("moRegDocName", signFamily.getSignDoctorName()); //签约医生姓名
                familyContent.put("moRegDocName", signFamily.getDoctorName()); //签约医生姓名
//                familyContent.put("moRegTime", format.format(signFamily.getBegin())); //签约时间
                familyContent.put("moRegTime", format.format(new Date())); //签约时间 v1.4.0更改
                familyContent.put("moRegEndTime", format.format(signFamily.getEnd())); //签约截止时间
                familyContent.put("moRegTear", signFamily.getSignYear());//签约年度
                familyContent.put("moRegSource", signFamily.getSignSource()); //签约来源
                familyContent.put("moCollectOrgNo", sbCode); //扣费机构 签约机构
                familyContent.put("moCollectorNo", signFamily.getSignDoctorName());//扣费人 签约医生姓名
                familyContent.put("moCollectorNo", signFamily.getDoctorName());//扣费人 签约医生姓名
                familyContent.put("benefitType", signFamily.getExpensesType()); //补贴类型
                familyContent.put("moBookOrgNo", sbCode);//登记机构 签约机构
                familyContent.put("moBookerNo", signFamily.getSignDoctorName()); //登记人 签约医生姓名
                familyContent.put("moBookerNo", signFamily.getDoctorName()); //登记人 签约医生姓名
                familyContent.put("moBookTime", format.format(signFamily.getBegin())); //登记时间 签约时间
    
                JSONObject moServiceType = new JSONObject();//服务类型

+ 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());