Просмотр исходного кода

Merge branch 'dev' of http://192.168.1.220:10080/jiwei/wlyy2.0 into dev

yeshijie 6 лет назад
Родитель
Сommit
46f501cb13
23 измененных файлов с 497 добавлено и 191 удалено
  1. 2 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/sms/SmsDO.java
  2. 22 1
      common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationOperateRecordsDO.java
  3. 3 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java
  4. 3 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/sms/SmsVO.java
  5. 20 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/specialist/PatientSignInfoVO.java
  6. 10 0
      server/svr-authentication/src/main/java/com/yihu/AuthServer.java
  7. 42 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/model/Captcha.java
  8. 2 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/model/Oauth2Envelop.java
  9. 31 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/model/PublicKey.java
  10. 19 5
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/core/redis/WlyyRedisVerifyCodeService.java
  11. 27 38
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java
  12. 158 107
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  13. 5 8
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyTokenEndpoint.java
  14. 41 16
      svr/svr-base/src/main/java/com/yihu/jw/base/activemq/ConsumerRunner.java
  15. 1 1
      svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActiveRecordService.java
  16. 6 0
      svr/svr-wlyy-specialist/pom.xml
  17. 17 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationManageController.java
  18. 27 3
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationPlanController.java
  19. 1 1
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationDetailDao.java
  20. 4 0
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationOperateRecordsDao.java
  21. 23 5
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java
  22. 24 4
      svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java
  23. 9 0
      svr/svr-wlyy-specialist/src/main/resources/application.yml

+ 2 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/sms/SmsDO.java

@ -1,5 +1,6 @@
package com.yihu.jw.entity.base.sms;
package com.yihu.jw.entity.base.sms;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.*;
import javax.persistence.*;
@ -85,6 +86,7 @@ public class SmsDO extends UuidIdentityEntity {
	}
	}
	@Column(name = "deadline", nullable = false)
	@Column(name = "deadline", nullable = false)
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	public Date getDeadline() {
	public Date getDeadline() {
		return deadline;
		return deadline;
	}
	}

+ 22 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/specialist/rehabilitation/RehabilitationOperateRecordsDO.java

@ -20,11 +20,13 @@ public class RehabilitationOperateRecordsDO extends UuidIdentityEntityWithOperat
    private String patientName;//居民名称
    private String patientName;//居民名称
    private String doctorCode;//执行医生code
    private String doctorCode;//执行医生code
    private String doctorName;//执行医生名称
    private String doctorName;//执行医生名称
    private Integer relationRecordType;//关联记录类型(1、随访记录,2、健康指导,3、健康教育)
    private Integer relationRecordType;//关联记录类型(1、随访记录,2、健康指导,3、健康教育,4、服务码)
    private String relationRecordCode;//关联记录code
    private String relationRecordCode;//关联记录code
    private String relationRecordImg;//相关记录图片地址,json格式
    private Date reserveTime;//服务预定完成时间
    private Date reserveTime;//服务预定完成时间
    private Date completeTime;//服务完成时间
    private Date completeTime;//服务完成时间
    private Integer status;//是否确认完成(0、未确认,1、已确认)
    private Integer status;//是否确认完成(0、未确认,1、已确认)
    private String node;//服务完成笔记
    @Column(name = "saas_id")
    @Column(name = "saas_id")
    public String getSaasId() {
    public String getSaasId() {
@ -80,6 +82,15 @@ public class RehabilitationOperateRecordsDO extends UuidIdentityEntityWithOperat
        this.doctorName = doctorName;
        this.doctorName = doctorName;
    }
    }
    @Column(name = "node")
    public String getNode() {
        return node;
    }
    public void setNode(String node) {
        this.node = node;
    }
    @Column(name = "relation_record_type")
    @Column(name = "relation_record_type")
    public Integer getRelationRecordType() {
    public Integer getRelationRecordType() {
        return relationRecordType;
        return relationRecordType;
@ -98,6 +109,15 @@ public class RehabilitationOperateRecordsDO extends UuidIdentityEntityWithOperat
        this.relationRecordCode = relationRecordCode;
        this.relationRecordCode = relationRecordCode;
    }
    }
    @Column(name = "relation_record_img")
    public String getRelationRecordImg() {
        return relationRecordImg;
    }
    public void setRelationRecordImg(String relationRecordImg) {
        this.relationRecordImg = relationRecordImg;
    }
    @Column(name = "reserve_time")
    @Column(name = "reserve_time")
    public Date getReserveTime() {
    public Date getReserveTime() {
        return reserveTime;
        return reserveTime;
@ -124,4 +144,5 @@ public class RehabilitationOperateRecordsDO extends UuidIdentityEntityWithOperat
    public void setStatus(Integer status) {
    public void setStatus(Integer status) {
        this.status = status;
        this.status = status;
    }
    }
}
}

+ 3 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/specialist/SpecialistMapping.java

@ -73,6 +73,9 @@ public class SpecialistMapping {
        public static final String updateStatusRehabilitationOperate = "/updateStatusRehabilitationOperate";
        public static final String updateStatusRehabilitationOperate = "/updateStatusRehabilitationOperate";
        public static final String patientRehabilitationDetail = "/patientRehabilitationDetail";
        public static final String patientRehabilitationDetail = "/patientRehabilitationDetail";
        public static final String recentPlanDetailRecord = "/recentPlanDetailRecord";
        public static final String recentPlanDetailRecord = "/recentPlanDetailRecord";
        public static final String saveRehabilitationOperateRecodr="/saveRehabilitationOperateRecodr";
        public static final String updateNoteAndImageRehabilitationOperate = "/updateNoteAndImageRehabilitationOperate";
        public static final String findServiceItemsByHospital = "/findServiceItemsByHospital";
        public static final String findServiceItemsByHospital = "/findServiceItemsByHospital";
        public static final String serviceDoctorList = "/serviceDoctorList";
        public static final String serviceDoctorList = "/serviceDoctorList";
        public static final String dailyJob = "/dailyJob";
        public static final String dailyJob = "/dailyJob";

+ 3 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/sms/SmsVO.java

@ -1,5 +1,6 @@
package com.yihu.jw.restmodel.base.sms;
package com.yihu.jw.restmodel.base.sms;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
import com.yihu.jw.restmodel.UuidIdentityVO;
import com.yihu.jw.restmodel.UuidIdentityVO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModel;
@ -31,7 +32,7 @@ public class SmsVO extends UuidIdentityVO {
    @ApiModelProperty(value = "短信内容", example = "【i健康综合管理平台】您使用的是i健康综合管理平台短信模板,您的验证码是826612,请于10分钟内正确输入!")
    @ApiModelProperty(value = "短信内容", example = "【i健康综合管理平台】您使用的是i健康综合管理平台短信模板,您的验证码是826612,请于10分钟内正确输入!")
    private String content;
    private String content;
    //过期时间
    //过期时间
    @ApiModelProperty(value = "应用ID", example = "EwC0iRSrcS")
    @ApiModelProperty(value = "过期时间", example = "2018-09-03 15:34:34")
    private Date deadline;
    private Date deadline;
    //验证码
    //验证码
    private String captcha;
    private String captcha;
@ -78,6 +79,7 @@ public class SmsVO extends UuidIdentityVO {
        this.content = content;
        this.content = content;
    }
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getDeadline() {
    public Date getDeadline() {
        return deadline;
        return deadline;
    }
    }

+ 20 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/specialist/PatientSignInfoVO.java

@ -20,6 +20,10 @@ public class PatientSignInfoVO {
    private String patient;
    private String patient;
    @ApiModelProperty("居民")
    @ApiModelProperty("居民")
    private String patientName;
    private String patientName;
    @ApiModelProperty("居民身份证")
    private String idcard;
    @ApiModelProperty("居民社保卡号")
    private String ssc;
    @ApiModelProperty("医生code")
    @ApiModelProperty("医生code")
    private String doctor;
    private String doctor;
    @ApiModelProperty("医生")
    @ApiModelProperty("医生")
@ -195,4 +199,20 @@ public class PatientSignInfoVO {
    public void setHealthAssistantName(String healthAssistantName) {
    public void setHealthAssistantName(String healthAssistantName) {
        this.healthAssistantName = healthAssistantName;
        this.healthAssistantName = healthAssistantName;
    }
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getSsc() {
        return ssc;
    }
    public void setSsc(String ssc) {
        this.ssc = ssc;
    }
}
}

+ 10 - 0
server/svr-authentication/src/main/java/com/yihu/AuthServer.java

@ -4,6 +4,9 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
/**
/**
 * Created by progr1mmer on 2018/8/29.
 * Created by progr1mmer on 2018/8/29.
@ -19,4 +22,11 @@ public class AuthServer extends SpringBootServletInitializer {
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(AuthServer.class);
        return application.sources(AuthServer.class);
    }
    }
    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }
}
}

+ 42 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/model/Captcha.java

@ -0,0 +1,42 @@
package com.yihu.jw.security.model;
import java.io.Serializable;
import java.util.Date;
/**
 * Model - 验证码
 * Created by progr1mmer on 2018/9/3.
 */
public class Captcha implements Serializable {
    //验证码
    private String code;
    //过期时间(秒)
    private int expiresIn;
    //请求间隔(秒)
    private int interval;
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public int getExpiresIn() {
        return expiresIn;
    }
    public void setExpiresIn(int expiresIn) {
        this.expiresIn = expiresIn;
    }
    public int getInterval() {
        return interval;
    }
    public void setInterval(int interval) {
        this.interval = interval;
    }
}

+ 2 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/model/Oauth2Envelop.java

@ -2,13 +2,14 @@ package com.yihu.jw.security.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashMap;
/**
/**
 * Model - 认证失败信息
 * Model - 认证失败信息
 * Created by progr1mmer on 2018/8/29.
 * Created by progr1mmer on 2018/8/29.
 */
 */
public class Oauth2Envelop<T> {
public class Oauth2Envelop<T> implements Serializable {
    protected String message;
    protected String message;
    protected Integer status;
    protected Integer status;

+ 31 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/model/PublicKey.java

@ -0,0 +1,31 @@
package com.yihu.jw.security.model;
import java.io.Serializable;
/**
 * Model 公钥
 * Created by progr1mmer on 2018/9/3.
 */
public class PublicKey implements Serializable {
    //模
    private String modulus;
    //指数
    private String exponent;
    public String getModulus() {
        return modulus;
    }
    public void setModulus(String modulus) {
        this.modulus = modulus;
    }
    public String getExponent() {
        return exponent;
    }
    public void setExponent(String exponent) {
        this.exponent = exponent;
    }
}

+ 19 - 5
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/core/redis/WlyyRedisVerifyCodeService.java

@ -6,6 +6,7 @@ import org.springframework.util.StringUtils;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeUnit;
/**
/**
 * Service - 验证码缓存
 * Created by progr1mmer on 2018/4/18.
 * Created by progr1mmer on 2018/4/18.
 */
 */
public class WlyyRedisVerifyCodeService {
public class WlyyRedisVerifyCodeService {
@ -17,21 +18,34 @@ public class WlyyRedisVerifyCodeService {
        this.redisTemplate = redisTemplate;
        this.redisTemplate = redisTemplate;
    }
    }
    public void store (String client_id, String username, String code, long expire) {
    public void store (String client_id, String username, String code, int expire) {
        String key = client_id + ":" + username + KEY_SUFFIX;
        String key = client_id + ":" + username + KEY_SUFFIX;
        redisTemplate.opsForValue().set(key, code);
        redisTemplate.opsForValue().set(key, code);
        redisTemplate.expire(key, expire, TimeUnit.MILLISECONDS);
        redisTemplate.expire(key, expire, TimeUnit.SECONDS);
        String intervalKey = key + ":" + code + "_interval";
        redisTemplate.opsForValue().set(intervalKey, 60);
        redisTemplate.expire(intervalKey, 60, TimeUnit.SECONDS);
    }
    }
    public Integer getExpireTime (String client_id, String username) {
        return new Long(redisTemplate.getExpire(client_id + ":" + username + KEY_SUFFIX)).intValue();
    public boolean isIntervalTimeout(String client_id, String username) {
        String key = client_id + ":" + username + KEY_SUFFIX;
        String code = (String) redisTemplate.opsForValue().get(key);
        if (null == code) {
            return true;
        }
        String intervalKey = key + ":" + code + "_interval";
        if (redisTemplate.opsForValue().get(intervalKey) != null) {
            return false;
        }
        return true;
    }
    }
    public boolean verification (String client_id, String username, String code) {
    public boolean verification (String client_id, String username, String code) {
        if (StringUtils.isEmpty(code)) {
        if (StringUtils.isEmpty(code)) {
            return false;
            return false;
        }
        }
        String _code = (String) redisTemplate.opsForValue().get(client_id + ":" + username + KEY_SUFFIX);
        String key = client_id + ":" + username + KEY_SUFFIX;
        String _code = (String) redisTemplate.opsForValue().get(key);
        if (null == _code) {
        if (null == _code) {
            return false;
            return false;
        }
        }

+ 27 - 38
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/WlyyTokenGranter.java

@ -37,38 +37,38 @@ public class WlyyTokenGranter implements TokenGranter {
                            OAuth2RequestFactory requestFactory,
                            OAuth2RequestFactory requestFactory,
                            WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService) {
                            WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService) {
        tokenGranters.put(EhrAuthorizationCodeGranter.GRANT_TYPE,
                new EhrAuthorizationCodeGranter(
        tokenGranters.put(WlyyAuthorizationCodeGranter.GRANT_TYPE,
                new WlyyAuthorizationCodeGranter(
                        tokenServices,
                        tokenServices,
                        authorizationCodeServices,
                        authorizationCodeServices,
                        clientDetailsService,
                        clientDetailsService,
                        requestFactory
                        requestFactory
                ));
                ));
        tokenGranters.put(EhrResourceOwnerPasswordTokenGranter.GRANT_TYPE,
                new EhrResourceOwnerPasswordTokenGranter(
        tokenGranters.put(WlyyResourceOwnerPasswordTokenGranter.GRANT_TYPE,
                new WlyyResourceOwnerPasswordTokenGranter(
                        authenticationManager,
                        authenticationManager,
                        tokenServices,
                        tokenServices,
                        clientDetailsService,
                        clientDetailsService,
                        requestFactory
                        requestFactory
                ));
                ));
        tokenGranters.put(EhrRefreshTokenGranter.GRANT_TYPE,
                new EhrRefreshTokenGranter(
        tokenGranters.put(WlyyRefreshTokenGranter.GRANT_TYPE,
                new WlyyRefreshTokenGranter(
                        tokenServices,
                        tokenServices,
                        clientDetailsService,
                        clientDetailsService,
                        requestFactory
                        requestFactory
                ));
                ));
        tokenGranters.put(EhrImplicitTokenGranter.GRANT_TYPE,
                new EhrImplicitTokenGranter(
        tokenGranters.put(WlyyImplicitTokenGranter.GRANT_TYPE,
                new WlyyImplicitTokenGranter(
                        tokenServices,
                        tokenServices,
                        clientDetailsService,
                        clientDetailsService,
                        requestFactory
                        requestFactory
                ));
                ));
        tokenGranters.put(EhrVerifyCodeTokenGranter.GRANT_TYPE,
                new EhrVerifyCodeTokenGranter(
        tokenGranters.put(WlyyCaptchaTokenGranter.GRANT_TYPE,
                new WlyyCaptchaTokenGranter(
                        authenticationManager,
                        authenticationManager,
                        tokenServices,
                        tokenServices,
                        clientDetailsService,
                        clientDetailsService,
@ -88,19 +88,19 @@ public class WlyyTokenGranter implements TokenGranter {
    /**
    /**
     * authorization_code模式Token授权器。
     * authorization_code模式Token授权器。
     */
     */
    public static class EhrAuthorizationCodeGranter extends AbstractTokenGranter {
    public static class WlyyAuthorizationCodeGranter extends AbstractTokenGranter {
        public static final String GRANT_TYPE = "authorization_code";
        public static final String GRANT_TYPE = "authorization_code";
        private final AuthorizationCodeServices authorizationCodeServices;
        private final AuthorizationCodeServices authorizationCodeServices;
        public EhrAuthorizationCodeGranter(AuthorizationServerTokenServices tokenServices,
        public WlyyAuthorizationCodeGranter(AuthorizationServerTokenServices tokenServices,
                                           AuthorizationCodeServices authorizationCodeServices,
                                           AuthorizationCodeServices authorizationCodeServices,
                                           ClientDetailsService clientDetailsService,
                                           ClientDetailsService clientDetailsService,
                                           OAuth2RequestFactory requestFactory) {
                                           OAuth2RequestFactory requestFactory) {
            this(tokenServices, authorizationCodeServices, clientDetailsService, requestFactory, GRANT_TYPE);
            this(tokenServices, authorizationCodeServices, clientDetailsService, requestFactory, GRANT_TYPE);
        }
        }
        protected EhrAuthorizationCodeGranter(AuthorizationServerTokenServices tokenServices,
        protected WlyyAuthorizationCodeGranter(AuthorizationServerTokenServices tokenServices,
                                              AuthorizationCodeServices authorizationCodeServices,
                                              AuthorizationCodeServices authorizationCodeServices,
                                              ClientDetailsService clientDetailsService,
                                              ClientDetailsService clientDetailsService,
                                              OAuth2RequestFactory requestFactory,
                                              OAuth2RequestFactory requestFactory,
@ -162,17 +162,6 @@ public class WlyyTokenGranter implements TokenGranter {
            Authentication userAuth = storedAuth.getUserAuthentication();
            Authentication userAuth = storedAuth.getUserAuthentication();
            //再次通过pk获取当前请求的用户信息
            /*String pk = combinedParameters.get("pk");
            String keyId = ehrJDBCUserSecurityService.getDefaultKeyIdSelectStatement(pk);
            String userId = ehrJDBCUserSecurityService.getDefaultUserIdByKeyIdSelectStatement(keyId);
            String userName = ehrJDBCUserSecurityService.getDefaultUserNameByUserId(userId);
            UserDetails userDetails = ehrUserDetailsService.loadUserByUsername(userName);
            if (StringUtils.isEmpty(keyId) || StringUtils.isEmpty(userId) || StringUtils.isEmpty(userName)) {
                throw new InsufficientAuthenticationException("Illegal pk");
            }
            UsernamePasswordAuthenticationToken userToken = new UsernamePasswordAuthenticationToken(userDetails.getUsername(), userDetails.getPassword(), userDetails.getAuthorities());*/
            return new OAuth2Authentication(finalStoredOAuth2Request, userAuth);
            return new OAuth2Authentication(finalStoredOAuth2Request, userAuth);
        }
        }
    }
    }
@ -180,17 +169,17 @@ public class WlyyTokenGranter implements TokenGranter {
    /**
    /**
     * password模式Token授权器。
     * password模式Token授权器。
     */
     */
    public static class EhrResourceOwnerPasswordTokenGranter extends AbstractTokenGranter {
    public static class WlyyResourceOwnerPasswordTokenGranter extends AbstractTokenGranter {
        private static final String GRANT_TYPE = "password";
        private static final String GRANT_TYPE = "password";
        private final AuthenticationManager authenticationManager;
        private final AuthenticationManager authenticationManager;
        public EhrResourceOwnerPasswordTokenGranter(AuthenticationManager authenticationManager,
        public WlyyResourceOwnerPasswordTokenGranter(AuthenticationManager authenticationManager,
                                                 AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
                                                 AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
        }
        }
        protected EhrResourceOwnerPasswordTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices,
        protected WlyyResourceOwnerPasswordTokenGranter(AuthenticationManager authenticationManager, AuthorizationServerTokenServices tokenServices,
                                                    ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, String grantType) {
                                                    ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory, String grantType) {
            super(tokenServices, clientDetailsService, requestFactory, grantType);
            super(tokenServices, clientDetailsService, requestFactory, grantType);
            this.authenticationManager = authenticationManager;
            this.authenticationManager = authenticationManager;
@ -230,10 +219,10 @@ public class WlyyTokenGranter implements TokenGranter {
    /**
    /**
     * refresh模式Token授权器。
     * refresh模式Token授权器。
     */
     */
    public static class EhrRefreshTokenGranter extends AbstractTokenGranter {
    public static class WlyyRefreshTokenGranter extends AbstractTokenGranter {
        static final String GRANT_TYPE = "refresh_token";
        static final String GRANT_TYPE = "refresh_token";
        public EhrRefreshTokenGranter(AuthorizationServerTokenServices tokenServices,
        public WlyyRefreshTokenGranter(AuthorizationServerTokenServices tokenServices,
                                      ClientDetailsService clientDetailsService,
                                      ClientDetailsService clientDetailsService,
                                      OAuth2RequestFactory requestFactory) {
                                      OAuth2RequestFactory requestFactory) {
            super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
            super(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
@ -250,14 +239,14 @@ public class WlyyTokenGranter implements TokenGranter {
    /**
    /**
     * Implicit模式Token授权器。
     * Implicit模式Token授权器。
     */
     */
    public static class EhrImplicitTokenGranter extends AbstractTokenGranter {
    public static class WlyyImplicitTokenGranter extends AbstractTokenGranter {
        private static final String GRANT_TYPE = "implicit";
        private static final String GRANT_TYPE = "implicit";
        public EhrImplicitTokenGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
        public WlyyImplicitTokenGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService, OAuth2RequestFactory requestFactory) {
            this(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
            this(tokenServices, clientDetailsService, requestFactory, GRANT_TYPE);
        }
        }
        protected EhrImplicitTokenGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService,
        protected WlyyImplicitTokenGranter(AuthorizationServerTokenServices tokenServices, ClientDetailsService clientDetailsService,
                                       OAuth2RequestFactory requestFactory, String grantType) {
                                       OAuth2RequestFactory requestFactory, String grantType) {
            super(tokenServices, clientDetailsService, requestFactory, grantType);
            super(tokenServices, clientDetailsService, requestFactory, grantType);
        }
        }
@ -285,14 +274,14 @@ public class WlyyTokenGranter implements TokenGranter {
    /**
    /**
     * verify_code模式Token授权器。
     * verify_code模式Token授权器。
     */
     */
    public static class EhrVerifyCodeTokenGranter extends AbstractTokenGranter {
        private static final String GRANT_TYPE = "verify_code";
    public static class WlyyCaptchaTokenGranter extends AbstractTokenGranter {
        private static final String GRANT_TYPE = "captcha";
        private final AuthenticationManager authenticationManager;
        private final AuthenticationManager authenticationManager;
        // Ehr Properties
        // Ehr Properties
        private final WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
        private final WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
        public EhrVerifyCodeTokenGranter(AuthenticationManager authenticationManager,
        public WlyyCaptchaTokenGranter(AuthenticationManager authenticationManager,
                                         AuthorizationServerTokenServices tokenServices,
                                         AuthorizationServerTokenServices tokenServices,
                                         ClientDetailsService clientDetailsService,
                                         ClientDetailsService clientDetailsService,
                                         OAuth2RequestFactory requestFactory,
                                         OAuth2RequestFactory requestFactory,
@ -300,7 +289,7 @@ public class WlyyTokenGranter implements TokenGranter {
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE, wlyyRedisVerifyCodeService);
            this(authenticationManager, tokenServices, clientDetailsService, requestFactory, GRANT_TYPE, wlyyRedisVerifyCodeService);
        }
        }
        protected EhrVerifyCodeTokenGranter(AuthenticationManager authenticationManager,
        protected WlyyCaptchaTokenGranter(AuthenticationManager authenticationManager,
                                            AuthorizationServerTokenServices tokenServices,
                                            AuthorizationServerTokenServices tokenServices,
                                            ClientDetailsService clientDetailsService,
                                            ClientDetailsService clientDetailsService,
                                            OAuth2RequestFactory requestFactory,
                                            OAuth2RequestFactory requestFactory,
@ -317,10 +306,10 @@ public class WlyyTokenGranter implements TokenGranter {
            Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters());
            Map<String, String> parameters = new LinkedHashMap<String, String>(tokenRequest.getRequestParameters());
            String client_id = parameters.get("client_id");
            String client_id = parameters.get("client_id");
            String username = parameters.get("username");
            String username = parameters.get("username");
            String verify_code = parameters.get("verify_code");
            String verify_code = parameters.get("captcha");
            if (!wlyyRedisVerifyCodeService.verification(client_id, username, verify_code)){
            if (!wlyyRedisVerifyCodeService.verification(client_id, username, verify_code)){
                throw new InvalidGrantException("Invalid verify_code");
                throw new InvalidGrantException("Invalid captcha");
            }
            }
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username, verify_code, getGrantedAuthorities(username));
            Authentication userAuth = new UsernamePasswordAuthenticationToken(username, verify_code, getGrantedAuthorities(username));
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);
            ((AbstractAuthenticationToken) userAuth).setDetails(parameters);

+ 158 - 107
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -1,18 +1,19 @@
package com.yihu.jw.security.oauth2.provider.endpoint;
package com.yihu.jw.security.oauth2.provider.endpoint;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.security.model.Captcha;
import com.yihu.jw.security.model.PublicKey;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.oauth2.core.redis.WlyyRedisVerifyCodeService;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.core.userdetails.jdbc.WlyyUserDetailsService;
import com.yihu.jw.security.model.Oauth2Envelop;
import com.yihu.jw.security.model.Oauth2Envelop;
import com.yihu.jw.security.model.WlyyUserSimple;
import com.yihu.jw.security.model.WlyyUserSimple;
import com.yihu.utils.security.RSAUtils;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.*;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
@ -24,15 +25,27 @@ import org.springframework.security.oauth2.provider.request.DefaultOAuth2Request
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestValidator;
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestValidator;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
import org.springframework.util.Assert;
import org.springframework.util.Assert;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.annotation.PostConstruct;
import javax.annotation.PostConstruct;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.IOException;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Map;
import java.util.UUID;
/**
/**
 * <p>
 * <p>
@ -64,26 +77,36 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    @Autowired
    @Autowired
    private WlyyUserDetailsService userDetailsService;
    private WlyyUserDetailsService userDetailsService;
    @Autowired
    @Autowired
    private WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
    private RestTemplate restTemplate;
    @Autowired
    @Autowired
    private ObjectMapper objectMapper;
    private WlyyRedisVerifyCodeService wlyyRedisVerifyCodeService;
    @PostConstruct
    @PostConstruct
    private void init() {
    private void init() {
        super.setTokenGranter(tokenGranter);
        super.setTokenGranter(tokenGranter);
    }
    }
    /**
     * 登陆
     * @param parameters
     * @param httpSession
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/login", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/login", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> login(@RequestParam Map<String, String> parameters) {
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> login(@RequestParam Map<String, String> parameters, HttpSession httpSession) throws Exception {
        String client_id = parameters.get("client_id");
        String client_id = parameters.get("client_id");
        if (StringUtils.isEmpty(client_id)) {
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
            throw new InvalidRequestException("client_id");
        }
        }
        if (StringUtils.isEmpty(parameters.get("verify_code"))) {
        if (StringUtils.isEmpty(parameters.get("captcha"))) {
            parameters.put("grant_type", "password");
            parameters.put("grant_type", "password");
            if (parameters.get("password") != null) {
                RSAPrivateKey rsaPrivateKey = (RSAPrivateKey)httpSession.getAttribute("privateKey");
                parameters.put("password", RSAUtils.decryptByPrivateKey(new String(Base64.decodeBase64(parameters.get("password"))), rsaPrivateKey));
            }
        } else {
        } else {
            parameters.put("grant_type", "verify_code");
            parameters.put("grant_type", "captcha");
        }
        }
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
        ClientDetails authenticatedClient = clientDetailsService.loadClientByClientId(client_id);
@ -118,6 +141,11 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        return getResponse(wlyyUserSimple);
        return getResponse(wlyyUserSimple);
    }
    }
    /**
     * 单点登陆第二步 - token验证
     * @param parameters
     * @return
     */
    @RequestMapping(value = "/oauth/sso", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/sso", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> sso(@RequestParam Map<String, String> parameters) {
    public ResponseEntity<Oauth2Envelop<WlyyUserSimple>> sso(@RequestParam Map<String, String> parameters) {
        String clientId = parameters.get("client_id");
        String clientId = parameters.get("client_id");
@ -154,6 +182,12 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        return getResponse(wlyyUserSimple);
        return getResponse(wlyyUserSimple);
    }
    }
    /**
     * 登出
     * @param parameters
     * @param request
     * @return
     */
    @RequestMapping(value = "/oauth/logout", method = RequestMethod.POST)
    @RequestMapping(value = "/oauth/logout", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop> logout(@RequestParam Map<String, String> parameters, HttpServletRequest request) {
    public ResponseEntity<Oauth2Envelop> logout(@RequestParam Map<String, String> parameters, HttpServletRequest request) {
        String token = request.getHeader("token");
        String token = request.getHeader("token");
@ -172,112 +206,125 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
    }
    }
    /*@RequestMapping(value = ServiceApi.Authentication.VerifyCode, method = RequestMethod.POST)
    public ResponseEntity<Envelop> verifyCode(@RequestParam Map<String, String> parameters) throws  Exception{
        Envelop envelop = new Envelop();
    /**
     * 获取公钥
     * @param httpSession
     * @param httpServletResponse
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/public_key", method = RequestMethod.GET)
    public ResponseEntity<Oauth2Envelop<PublicKey>> publicKey (
            HttpSession httpSession,
            HttpServletResponse httpServletResponse) throws Exception {
        //生成公钥和私钥
        HashMap<String, Object> map = RSAUtils.generateKeys();
        RSAPublicKey rsaPublicKey = (RSAPublicKey) map.get("public");
        RSAPrivateKey rsaPrivateKey = (RSAPrivateKey) map.get("private");
        PublicKey publicKey = new PublicKey();
        publicKey.setModulus(Base64.encodeBase64String(rsaPublicKey.getModulus().toByteArray()));
        publicKey.setExponent(Base64.encodeBase64String(rsaPublicKey.getPublicExponent().toByteArray()));
        httpSession.setAttribute("privateKey", rsaPrivateKey);
        //生成Cookie
        Cookie cookie = new Cookie("oauth2", UUID.randomUUID().toString());
        cookie.setMaxAge(60);
        cookie.setPath("/oauth");
        httpServletResponse.addCookie(cookie);
        HttpHeaders headers = new HttpHeaders();
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        headers.set("Pragma", "no-cache");
        Oauth2Envelop<PublicKey> oauth2Envelop = new Oauth2Envelop<>("public_key", 200, publicKey);
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
    }
    /**
     * 获取验证码
     * @param parameters
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/captcha", method = RequestMethod.GET)
    public ResponseEntity<Oauth2Envelop<Captcha>> captcha(@RequestParam Map<String, String> parameters) throws  Exception{
        String client_id = parameters.get("client_id");
        String client_id = parameters.get("client_id");
        String username = parameters.get("username");
        String username = parameters.get("username");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if (StringUtils.isEmpty(username)){
        if (StringUtils.isEmpty(username)){
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("手机号码【"+username+"】不能为空!");
            return new ResponseEntity<>(envelop, headers, HttpStatus.OK);
            throw new InvalidRequestException("username");
        }
        }
        VerifyCode verifyCode = new VerifyCode();
        //手机短信验证码
        RandomUtil randomUtil = new RandomUtil();
        String random = randomUtil.getRandomString(6);
        //发送短信
        String api = "MsgGW.Sms.send";
        String content = "尊敬的用户:欢迎使用健康上饶,您的验证码为:【" + random + "】,有效期10分钟,请尽快完成注册。若非本人操作,请忽略。";
        Map<String, String> apiParamMap = new HashMap<>();
        //手机号码
        apiParamMap.put("mobile", username);
        //业务标签
        apiParamMap.put("handlerId", fzHandlerId);
        //短信内容
        apiParamMap.put("content", content);
        //渠道号
        apiParamMap.put("clientId", fzClientId);
        String result = null;
        Envelop resultEnvelop = fzApiClient.fzInnerApi(api, objectMapper.writeValueAsString(apiParamMap), 1);
        if (resultEnvelop.isSuccessFlg()) {
            result = resultEnvelop.getObj().toString();
        //验证请求间隔超时,防止频繁获取验证码
        if (!wlyyRedisVerifyCodeService.isIntervalTimeout(client_id, username)) {
            throw new IllegalAccessException("SMS request frequency is too fast");
        }
        }
        if (!StringUtils.isEmpty(result)) {
            Map<String, Object> resultMap = objectMapper.readValue(result, Map.class);
            Integer resultCode = 0;
            if (null != resultMap.get("Code") && !"".equals(resultMap.get("Code"))) {
                resultCode = Integer.valueOf(resultMap.get("Code").toString());
            }
            if (resultCode == 10000) {
                verifyCode.setExpiresIn(600);
                verifyCode.setNextRequestTime(60);
                //验证码有效期
                ehrRedisVerifyCodeService.store(client_id, username, random, 600000);
                envelop.setSuccessFlg(true);
                envelop.setObj(verifyCode);
            } else if(resultCode == -201){
                envelop.setSuccessFlg(false);
                envelop.setErrorCode(resultCode);
                envelop.setErrorMsg("短信已达每天限制的次数(10次)!");
            } else if(resultCode == -200){
                envelop.setSuccessFlg(false);
                envelop.setErrorCode(resultCode);
                envelop.setErrorMsg("短信发送频率太快(不能低于60s)!");
            } else {
                envelop.setSuccessFlg(false);
                envelop.setErrorCode(resultCode);
                envelop.setErrorMsg("短信验证码发送失败!");
            }
        } else {
            envelop.setSuccessFlg(false);
            envelop.setErrorCode(ErrorCode.REQUEST_NOT_COMPLETED.value());
            envelop.setErrorMsg("短信验证码发送失败!");
        //发送短信获取验证码
        HttpHeaders reqHeaders = new HttpHeaders();
        reqHeaders.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
        params.add("clientId", client_id);
        params.add("type", "login");
        params.add("to", username);
        HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(params, reqHeaders);
        HashMap<String, Object> result = restTemplate.postForObject("http://svr-base:10020/sms_gateway/send", httpEntity, HashMap.class);
        if (200 == (Integer) result.get("status")){
            Map<String, Object> sms =  (Map)result.get("obj");
            String captcha = (String) sms.get("captcha");
            Date deadline = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse((String) sms.get("deadline"));
            Long expire = (deadline.getTime() - new Date().getTime()) / 1000;
            Captcha _captcha = new Captcha();
            _captcha.setCode(captcha);
            _captcha.setExpiresIn(expire.intValue());
            wlyyRedisVerifyCodeService.store(client_id, username, captcha, expire.intValue());
            Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop<>("captcha", 200, _captcha);
            HttpHeaders headers = new HttpHeaders();
            headers.set("Cache-Control", "no-store");
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }
        }
        return new ResponseEntity<>(envelop, headers, HttpStatus.OK);
    }
    @RequestMapping(value = ServiceApi.Authentication.VerifyCodeExpire, method = RequestMethod.POST)
    public ResponseEntity<VerifyCode> verifyCodeExpire(@RequestParam Map<String, String> parameters) {
        String client_id = parameters.get("client_id");
        String username = parameters.get("username");
        VerifyCode verifyCode = new VerifyCode();
        int expiresIn = ehrRedisVerifyCodeService.getExpireTime(client_id, username);
        int nextRequestTime = 60 + (expiresIn - 600 ) > 0 ? 60 + (expiresIn - 600 ) : 0;
        verifyCode.setNextRequestTime(nextRequestTime);
        verifyCode.setExpiresIn(expiresIn);
        throw new IllegalStateException((String) result.get("message"));
        /*Captcha _captcha = new Captcha();
        _captcha.setCode("12345");
        _captcha.setExpiresIn(10000);
        _captcha.setInterval(60);
        wlyyRedisVerifyCodeService.store(client_id, username, "12345", 100);
        Oauth2Envelop<Captcha> oauth2Envelop = new Oauth2Envelop("captcha", 200, _captcha);
        HttpHeaders headers = new HttpHeaders();
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        headers.set("Pragma", "no-cache");
        return new ResponseEntity<>(verifyCode, headers, HttpStatus.OK);
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);*/
    }
    }
    @RequestMapping(value = ServiceApi.Authentication.VerifyCodeValidate, method = RequestMethod.POST)
    public ResponseEntity<Envelop> verifyCodeValidate(@RequestParam Map<String, String> parameters) throws  Exception{
        Envelop envelop = new Envelop();
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
    /**
     * 验证验证码
     * @param parameters
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/oauth/captcha", method = RequestMethod.POST)
    public ResponseEntity<Oauth2Envelop> captchaCheck  (@RequestParam Map<String, String> parameters) throws  Exception{
        String client_id = parameters.get("client_id");
        String client_id = parameters.get("client_id");
        String username = parameters.get("username");
        String username = parameters.get("username");
        String verifyCode = parameters.get("verify_code");
        if (StringUtils.isEmpty(verifyCode)){
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("验证码不能为空!");
            return new ResponseEntity<>(envelop, headers, HttpStatus.OK);
        String captcha = parameters.get("captcha");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        }
        boolean _verify = ehrRedisVerifyCodeService.verification(client_id, username, verifyCode);
        if (_verify){
            envelop.setSuccessFlg(true);
        if (StringUtils.isEmpty(username)){
            throw new InvalidRequestException("username");
        }
        if (StringUtils.isEmpty(captcha)){
            throw new InvalidRequestException("captcha");
        }
        Oauth2Envelop<Boolean> oauth2Envelop;
        if (wlyyRedisVerifyCodeService.verification(client_id, username, captcha)) {
            oauth2Envelop = new Oauth2Envelop<>("验证码正确", 200, true);
        } else {
        } else {
            envelop.setSuccessFlg(false);
            envelop.setErrorMsg("请输入正确的验证码!");
            oauth2Envelop = new Oauth2Envelop<>("验证码错误", 200, false);
        }
        }
        return new ResponseEntity<>(envelop, headers, HttpStatus.OK);
    }*/
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
    }
    @Override
    @Override
    protected TokenGranter getTokenGranter() {
    protected TokenGranter getTokenGranter() {
@ -308,27 +355,31 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    public ResponseEntity<Oauth2Envelop> handleException(Exception e) throws Exception {
    public ResponseEntity<Oauth2Envelop> handleException(Exception e) throws Exception {
        LOG.info(e.getMessage(), e);
        LOG.info(e.getMessage(), e);
        if (e instanceof UsernameNotFoundException) {
        if (e instanceof UsernameNotFoundException) {
            return handleOAuth2Exception(new Oauth2Envelop("用户未注册!", HttpStatus.UNAUTHORIZED.value()));
            return handleOAuth2Exception(new Oauth2Envelop("用户未注册!", HttpStatus.UNAUTHORIZED.value()), e);
        } else if (e instanceof NoSuchClientException) {
        } else if (e instanceof NoSuchClientException) {
            return handleOAuth2Exception(new Oauth2Envelop("应用未注册!", HttpStatus.UNAUTHORIZED.value()));
            return handleOAuth2Exception(new Oauth2Envelop("应用未注册!", HttpStatus.UNAUTHORIZED.value()), e);
        } else if (e instanceof InvalidGrantException) {
        } else if (e instanceof InvalidGrantException) {
            if (e.getMessage().equals("verify_code")) {
                return handleOAuth2Exception(new Oauth2Envelop("验证码有误!", HttpStatus.UNAUTHORIZED.value()));
            if (e.getMessage().contains("captcha")) {
                return handleOAuth2Exception(new Oauth2Envelop("验证码有误!", HttpStatus.UNAUTHORIZED.value()), e);
            }
            }
            return handleOAuth2Exception(new Oauth2Envelop("密码有误!", HttpStatus.UNAUTHORIZED.value()));
            return handleOAuth2Exception(new Oauth2Envelop("密码有误!", HttpStatus.UNAUTHORIZED.value()), e);
        } else if (e instanceof InvalidTokenException) {
        } else if (e instanceof InvalidTokenException) {
            return handleOAuth2Exception(new Oauth2Envelop("Token有误!", HttpStatus.UNAUTHORIZED.value()));
            return handleOAuth2Exception(new Oauth2Envelop("Token有误!", HttpStatus.UNAUTHORIZED.value()), e);
        } else if (e instanceof InvalidRequestException) {
        } else if (e instanceof InvalidRequestException) {
            return handleOAuth2Exception(new Oauth2Envelop("参数" + e.getMessage() + "缺失!", HttpStatus.UNAUTHORIZED.value()));
            return handleOAuth2Exception(new Oauth2Envelop("参数" + e.getMessage() + "缺失!", HttpStatus.UNAUTHORIZED.value()), e);
        } else if (e instanceof IllegalAccessException) {
            return handleOAuth2Exception(new Oauth2Envelop("短信请求频率过快,请稍后再试!", -1), e);
        } else if (e instanceof IllegalStateException) {
            return handleOAuth2Exception(new Oauth2Envelop("短信网关请求失败!", -1), e);
        }
        }
        return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1));
        return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1), e);
    }
    }
    private ResponseEntity<Oauth2Envelop> handleOAuth2Exception(Oauth2Envelop authenticationFailed) throws IOException {
    private ResponseEntity<Oauth2Envelop> handleOAuth2Exception(Oauth2Envelop authenticationFailed, Exception e) throws IOException {
        HttpHeaders headers = new HttpHeaders();
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        headers.set("Pragma", "no-cache");
        headers.set("WWW-Authenticate", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, authenticationFailed.getMessage()));
        headers.set("WWW-Authenticate", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, e.getMessage()));
        ResponseEntity<Oauth2Envelop> response = new ResponseEntity<>(authenticationFailed, headers, HttpStatus.OK);
        ResponseEntity<Oauth2Envelop> response = new ResponseEntity<>(authenticationFailed, headers, HttpStatus.OK);
        return response;
        return response;
    }
    }

+ 5 - 8
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyTokenEndpoint.java

@ -97,7 +97,6 @@ public class WlyyTokenEndpoint extends AbstractEndpoint {
        TokenRequest tokenRequest = getOAuth2RequestFactory().createTokenRequest(parameters, authenticatedClient);
        TokenRequest tokenRequest = getOAuth2RequestFactory().createTokenRequest(parameters, authenticatedClient);
        /*
        /*
         * customize
         * skip this step
         * skip this step
         */
         */
        /*if (clientId != null && !clientId.equals("")) {
        /*if (clientId != null && !clientId.equals("")) {
@ -136,7 +135,7 @@ public class WlyyTokenEndpoint extends AbstractEndpoint {
        if (token == null) {
        if (token == null) {
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
            throw new UnsupportedGrantTypeException("Unsupported grant type: " + tokenRequest.getGrantType());
        }
        }
        // customize ---------------------------------
        // ----------------- Simple Result ----------------
        WlyyOAuth2AccessToken wlyyOAuth2AccessToken = new WlyyOAuth2AccessToken();
        WlyyOAuth2AccessToken wlyyOAuth2AccessToken = new WlyyOAuth2AccessToken();
        wlyyOAuth2AccessToken.setAccessToken(token.getValue());
        wlyyOAuth2AccessToken.setAccessToken(token.getValue());
        wlyyOAuth2AccessToken.setTokenType(token.getTokenType());
        wlyyOAuth2AccessToken.setTokenType(token.getTokenType());
@ -144,7 +143,7 @@ public class WlyyTokenEndpoint extends AbstractEndpoint {
        wlyyOAuth2AccessToken.setRefreshToken(token.getRefreshToken().getValue());
        wlyyOAuth2AccessToken.setRefreshToken(token.getRefreshToken().getValue());
        wlyyOAuth2AccessToken.setScope(org.apache.commons.lang.StringUtils.join(token.getScope(), " "));
        wlyyOAuth2AccessToken.setScope(org.apache.commons.lang.StringUtils.join(token.getScope(), " "));
        wlyyOAuth2AccessToken.setState(parameters.get("state"));
        wlyyOAuth2AccessToken.setState(parameters.get("state"));
        // customize ---------------------------------
        // ----------------- Simple Result ----------------
        return getResponse(wlyyOAuth2AccessToken);
        return getResponse(wlyyOAuth2AccessToken);
@ -201,7 +200,6 @@ public class WlyyTokenEndpoint extends AbstractEndpoint {
    }*/
    }*/
    /**
    /**
     * (customize)
     * @param e
     * @param e
     * @return
     * @return
     * @throws Exception
     * @throws Exception
@ -209,7 +207,7 @@ public class WlyyTokenEndpoint extends AbstractEndpoint {
    @ExceptionHandler(Exception.class)
    @ExceptionHandler(Exception.class)
    public ResponseEntity<Oauth2Envelop> handleException(Exception e) throws Exception {
    public ResponseEntity<Oauth2Envelop> handleException(Exception e) throws Exception {
        LOG.info(e.getMessage(), e);
        LOG.info(e.getMessage(), e);
        return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1));
        return handleOAuth2Exception(new Oauth2Envelop(e.getMessage(), -1), e);
    }
    }
    private ResponseEntity<WlyyOAuth2AccessToken> getResponse(WlyyOAuth2AccessToken accessToken) {
    private ResponseEntity<WlyyOAuth2AccessToken> getResponse(WlyyOAuth2AccessToken accessToken) {
@ -220,17 +218,16 @@ public class WlyyTokenEndpoint extends AbstractEndpoint {
    }
    }
    /**
    /**
     * customize
     * return results directly
     * return results directly
     * @param authenticationFailed
     * @param authenticationFailed
     * @return
     * @return
     * @throws IOException
     * @throws IOException
     */
     */
    private ResponseEntity<Oauth2Envelop> handleOAuth2Exception(Oauth2Envelop authenticationFailed) throws IOException {
    private ResponseEntity<Oauth2Envelop> handleOAuth2Exception(Oauth2Envelop authenticationFailed, Exception e) throws IOException {
        HttpHeaders headers = new HttpHeaders();
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        headers.set("Pragma", "no-cache");
        headers.set("WWW-Authenticate", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, authenticationFailed.getMessage()));
        headers.set("WWW-Authenticate", String.format("%s %s", OAuth2AccessToken.BEARER_TYPE, e.getMessage()));
        ResponseEntity<Oauth2Envelop> response = new ResponseEntity<>(authenticationFailed, headers, HttpStatus.OK);
        ResponseEntity<Oauth2Envelop> response = new ResponseEntity<>(authenticationFailed, headers, HttpStatus.OK);
        return response;
        return response;
    }
    }

+ 41 - 16
svr/svr-base/src/main/java/com/yihu/jw/base/activemq/ConsumerRunner.java

@ -9,6 +9,7 @@ import org.springframework.util.Assert;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.RestTemplate;
import javax.jms.*;
import javax.jms.*;
import javax.jms.IllegalStateException;
import java.util.Set;
import java.util.Set;
/**
/**
@ -21,36 +22,59 @@ public class ConsumerRunner implements Runnable, ExceptionListener {
    private final String topic;
    private final String topic;
    private Set<String> pushUrl;
    private Set<String> pushUrl;
    private TopicConnection topicConnection;
    private QueueConnection connection;
    private Session session;
    private MessageConsumer consumer;
    private MessageConsumer consumer;
    private RestTemplate restTemplate;
    private RestTemplate restTemplate;
    public ConsumerRunner(String topic, Set<String> pushUrl) throws Exception {
    public ConsumerRunner(String topic, Set<String> pushUrl) {
        Assert.notNull(topic, "Topic cannot be null");
        Assert.notNull(topic, "Topic cannot be null");
        this.topic = topic;
        this.topic = topic;
        this.pushUrl = pushUrl;
        this.pushUrl = pushUrl;
        init();
        init();
    }
    }
    private void init() throws Exception {
    private void init() {
        try {
            ActiveMQConnectionFactory connectionFactory = SpringContext.getService(ActiveMQConnectionFactory.class);
            // Create a Connection
            connection = connectionFactory.createQueueConnection();
            connection.start();
            connection.setExceptionListener(this);
            // Create a Session
            session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
            // Create the destination (Topic or Queue)
            Destination destination = session.createQueue(topic);
            // Create a MessageConsumer from the Session to the Topic or Queue
            consumer = session.createConsumer(destination);
            restTemplate = new RestTemplate();
        } catch (JMSException e) {
            LOGGER.error("Failed to init ConsumerRunner", e);
        }
    }
    private void recover() throws JMSException {
        ActiveMQConnectionFactory connectionFactory = SpringContext.getService(ActiveMQConnectionFactory.class);
        ActiveMQConnectionFactory connectionFactory = SpringContext.getService(ActiveMQConnectionFactory.class);
        // Create a Connection
        // Create a Connection
        topicConnection = connectionFactory.createTopicConnection();
        topicConnection.start();
        topicConnection.setExceptionListener(this);
        connection = connectionFactory.createQueueConnection();
        connection.start();
        connection.setExceptionListener(this);
        // Create a Session
        // Create a Session
        Session session = topicConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
        // Create the destination (Topic or Queue)
        // Create the destination (Topic or Queue)
        Destination destination = session.createTopic(topic);
        Destination destination = session.createQueue(topic);
        // Create a MessageConsumer from the Session to the Topic or Queue
        // Create a MessageConsumer from the Session to the Topic or Queue
        consumer = session.createConsumer(destination);
        consumer = session.createConsumer(destination);
        restTemplate = new RestTemplate();
        if (null == restTemplate) {
            restTemplate = new RestTemplate();
        }
    }
    }
    @Override
    @Override
    public void run() {
    public void run() {
        while (true) {
        while (true) {
            try {
            try {
                Thread.sleep(1000);
                // Wait for a message
                // Wait for a message
                Message message = consumer.receive(1000);
                Message message = consumer.receive(1000);
                if (message != null) {
                if (message != null) {
@ -70,18 +94,19 @@ public class ConsumerRunner implements Runnable, ExceptionListener {
                }
                }
            } catch (Exception e) {
            } catch (Exception e) {
                LOGGER.error(e.getMessage(), e);
                LOGGER.error(e.getMessage(), e);
                if (e instanceof IllegalStateException) {
                    try {
                        recover();
                    } catch (JMSException jme) {
                        LOGGER.error("Failed to recover ConsumerRunner", jme);
                    }
                }
            }
            }
        }
        }
    }
    }
    @Override
    @Override
    public void onException(JMSException e) {
    public void onException(JMSException e) {
        LOGGER.error("Trying to recover from JMS Connection exception", e);
        try {
            topicConnection.close();
            topicConnection.start();
        } catch (Exception ex) {
            LOGGER.error("Failed to recover JMS Connection", ex);
        }
        LOGGER.error("ConsumerRunner onException", e);
    }
    }
}
}

+ 1 - 1
svr/svr-wlyy-health-bank/src/main/java/com/yihu/jw/service/ActiveRecordService.java

@ -26,7 +26,7 @@ import java.util.Map;
 **/
 **/
@Service
@Service
@Transactional
@Transactional
public class ActiveRecordService extends BaseJpaService<ActiveRecordDO,ActiveRecordDO> {
public class ActiveRecordService extends BaseJpaService<ActiveRecordDO, ActiveRecordDao> {
    @Autowired
    @Autowired
    private TaskDao taskDao;
    private TaskDao taskDao;

+ 6 - 0
svr/svr-wlyy-specialist/pom.xml

@ -121,6 +121,12 @@
            <artifactId>jxl</artifactId>
            <artifactId>jxl</artifactId>
            <version>2.6</version>
            <version>2.6</version>
        </dependency>
        </dependency>
        <!--<dependency>
            <groupId>com.yihu.ehr</groupId>
            <artifactId>commons-util</artifactId>
            <version>1.1.0</version>
            <scope>compile</scope>
        </dependency>-->
    </dependencies>
    </dependencies>
    <build>
    <build>

+ 17 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationManageController.java

@ -279,4 +279,21 @@ public class RehabilitationManageController {
            return ObjEnvelop.getError(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
        }
        }
    }
    }
    @PostMapping(value = SpecialistMapping.rehabilitation.updateNoteAndImageRehabilitationOperate)
    @ApiOperation(value = "康复计划完成时更新服务完成笔记和图片接口.")
    public Envelop updateNoteAndImageRehabilitationOperate(@ApiParam(name = "planDetailId", value = "服务项目id", required = true)@RequestParam(value = "planDetailId", required = true)String planDetailId,
                                                           @ApiParam(name = "node", value = "服务完成笔记", required = true)@RequestParam(value = "node", required = true)String node,
                                                           @ApiParam(name = "image", value = "相关记录图片,json格式", required = true)@RequestParam(value = "image", required = true)String image){
        try {
            if(rehabilitationManageService.updateNodeAndRelationRecordImg(node,image,planDetailId)>0){
                return Envelop.getSuccess(SpecialistMapping.api_success);
            }
            return Envelop.getError("update error!");
        }catch (Exception e){
            e.printStackTrace();
            tracer.getCurrentSpan().logEvent(e.getMessage());
            return ObjEnvelop.getError(e.getMessage());
        }
    }
}
}

Разница между файлами не показана из-за своего большого размера
+ 27 - 3
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/controller/rehabilitation/RehabilitationPlanController.java


+ 1 - 1
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationDetailDao.java

@ -55,6 +55,6 @@ public interface RehabilitationDetailDao extends PagingAndSortingRepository<Reha
    RehabilitationDetailDO findById(String planDetailId);
    RehabilitationDetailDO findById(String planDetailId);
    @Query(value ="select d.doctor,p.patient,count(1) from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.status!=1 and d.execute_time>=?1 and d.execute_time<=?2 GROUP BY d.doctor,p.patient",nativeQuery = true)
    @Query(value ="select d.doctor,p.patient,count(1) as num from wlyy_rehabilitation_plan_detail d left join wlyy_patient_rehabilitation_plan p on d.plan_id=p.id where d.status!=1 and d.execute_time>=?1 and d.execute_time<=?2 GROUP BY d.doctor,p.patient",nativeQuery = true)
    List<Map<String,Object>> dailyJob(String startTime,String endTime);
    List<Map<String,Object>> dailyJob(String startTime,String endTime);
}
}

+ 4 - 0
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/dao/rehabilitation/RehabilitationOperateRecordsDao.java

@ -18,4 +18,8 @@ public interface RehabilitationOperateRecordsDao extends PagingAndSortingReposit
    @Modifying
    @Modifying
    @Query("update RehabilitationOperateRecordsDO a set a.status=?1 where a.rehabilitationDetailId =?2 ")
    @Query("update RehabilitationOperateRecordsDO a set a.status=?1 where a.rehabilitationDetailId =?2 ")
    int updateStatus(Integer status,String rehabilitationDetailId);
    int updateStatus(Integer status,String rehabilitationDetailId);
    @Modifying
    @Query("update RehabilitationOperateRecordsDO a set a.node=?1,a.relationRecordImg=?2 where a.rehabilitationDetailId =?3 ")
    int updateNodeAndRelationRecordImg(String node,String rehabilitationRecordImg,String rehabilitataioDetailId);
}
}

+ 23 - 5
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

@ -18,6 +18,8 @@ import com.yihu.jw.rm.specialist.SpecialistMapping;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.PageRequest;
@ -105,7 +107,7 @@ public class RehabilitationManageService {
//        }
//        }
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(finalSql);
        List<Map<String,Object>> rstotal = jdbcTemplate.queryForList(finalSql);
        int count = 0;
        int count = 0;
        if(rstotal!=null&&rstotal.size()>0){
        if(rstotal!=null&&rstotal.size()>0&&rstotal.get(0).get("id")!=null){
            count = rstotal.size();
            count = rstotal.size();
        }
        }
        finalSql += " ORDER BY b.create_time DESC LIMIT "+(page-1)*pageSize+","+pageSize;
        finalSql += " ORDER BY b.create_time DESC LIMIT "+(page-1)*pageSize+","+pageSize;
@ -445,7 +447,11 @@ public class RehabilitationManageService {
                    }
                    }
                }
                }
            }else{
            }else{
                m.put("myTaskFlag",0);
                if(doctorCode.equals(one.get("doctor").toString())){
                    m.put("myTaskFlag",1);
                }else{
                    m.put("myTaskFlag",0);
                }
            }
            }
            if(m.containsKey("planDetailIds")){
            if(m.containsKey("planDetailIds")){
                m.put("planDetailIds",m.get("planDetailIds")+","+one.get("id"));
                m.put("planDetailIds",m.get("planDetailIds")+","+one.get("id"));
@ -497,7 +503,7 @@ public class RehabilitationManageService {
            planDetailList +=",'"+one+"'";
            planDetailList +=",'"+one+"'";
        }
        }
        String planDetailResult = StringUtils.isNotEmpty(planDetailList)?planDetailList.substring(1):"";
        String planDetailResult = StringUtils.isNotEmpty(planDetailList)?planDetailList.substring(1):"";
        String sql = "select i.title,i.content,i.type,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as specialistDoctor," +
        String sql = "select i.title,i.content,i.type,i.reserve,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as specialistDoctor," +
                " d.doctor_name as specialistDoctorName,p.patient ,p.create_user ,p.create_user_name " +
                " d.doctor_name as specialistDoctorName,p.patient ,p.create_user ,p.create_user_name " +
                " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
                " LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
@ -517,11 +523,13 @@ public class RehabilitationManageService {
            executeDoctorList.add(one.get("specialistDoctorName")+"");
            executeDoctorList.add(one.get("specialistDoctorName")+"");
            resultMap.put("executeDoctorList",executeDoctorList);
            resultMap.put("executeDoctorList",executeDoctorList);
            resultMap.put("title",one.get("title"));//项目标题
            resultMap.put("title",one.get("title"));//项目标题
            resultMap.put("planDetaiId",one.get("id"));//计划服务项目id
            resultMap.put("shortExecuteTime",DateUtil.dateToStr((Date) one.get("execute_time"),DateUtil.HH_MM));//项目标题
            resultMap.put("shortExecuteTime",DateUtil.dateToStr((Date) one.get("execute_time"),DateUtil.HH_MM));//项目标题
            resultMap.put("content",one.get("content"));//项目内容
            resultMap.put("content",one.get("content"));//项目内容
            resultMap.put("hospitalName",one.get("hospital_name"));//地点
            resultMap.put("hospitalName",one.get("hospital_name"));//地点
            resultMap.put("executeTime",one.get("execute_time"));//执行时间
            resultMap.put("executeTime",one.get("execute_time"));//执行时间
            resultMap.put("expense",one.get("expense"));//收费
            resultMap.put("expense",one.get("expense"));//收费
            resultMap.put("reserve",one.get("reserve"));//是否需要预约(1预约、0不预约)
            Integer status = Integer.valueOf(one.get("status").toString());//状态(0未完成,1已完成,2已预约)
            Integer status = Integer.valueOf(one.get("status").toString());//状态(0未完成,1已完成,2已预约)
            String statusName = "";
            String statusName = "";
            switch (status){
            switch (status){
@ -544,7 +552,7 @@ public class RehabilitationManageService {
            resultMap.put("messageList",messageMapList);//指导与汇报记录
            resultMap.put("messageList",messageMapList);//指导与汇报记录
            resultMap.put("patient",one.get("patient"));
            resultMap.put("patient",one.get("patient"));
            resultMap.put("type",one.get("type"));
            resultMap.put("type",one.get("type"));
            resultMap.put("status",status);//状态
            //是否完成任务
            //是否完成任务
            List<RehabilitationOperateRecordsDO> operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString());
            List<RehabilitationOperateRecordsDO> operateList = rehabilitationOperateRecordsDao.findByRehabilitationDetailId(one.get("id").toString());
            Integer operate = 0;
            Integer operate = 0;
@ -566,7 +574,7 @@ public class RehabilitationManageService {
     * @throws Exception
     * @throws Exception
     */
     */
    public ObjEnvelop serviceItem(String planDetailId) throws Exception{
    public ObjEnvelop serviceItem(String planDetailId) throws Exception{
        String sql = "select i.title,i.content,i.type as itemType,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as specialistDoctor, " +
        String sql = "select i.title,i.content,i.type as itemType,i.reserve,d.id,d.execute_time,d.hospital_name,d.status,d.type,d.expense,d.doctor as specialistDoctor, " +
                " d.doctor_name as specialistDoctorName,p.patient ,p.create_user ,p.create_user_name " +
                " d.doctor_name as specialistDoctorName,p.patient ,p.create_user ,p.create_user_name " +
                " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " from wlyy_specialist.wlyy_rehabilitation_plan_detail d " +
                " LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
                " LEFT JOIN wlyy_specialist.wlyy_hospital_service_item h on d.hospital_service_item_id = h.id "+
@ -588,6 +596,7 @@ public class RehabilitationManageService {
        resultMap.put("hospitalName",one.get("hospital_name"));//地点
        resultMap.put("hospitalName",one.get("hospital_name"));//地点
        resultMap.put("executeTime",one.get("execute_time"));//执行时间
        resultMap.put("executeTime",one.get("execute_time"));//执行时间
        resultMap.put("expense",one.get("expense"));//收费
        resultMap.put("expense",one.get("expense"));//收费
        resultMap.put("reserve",one.get("reserve"));//是否需要预约(1预约、0不预约)
        Integer status = Integer.valueOf(one.get("status").toString());//状态(0未完成,1已完成,2已预约)
        Integer status = Integer.valueOf(one.get("status").toString());//状态(0未完成,1已完成,2已预约)
        String statusName = "";
        String statusName = "";
        switch (status){
        switch (status){
@ -622,6 +631,8 @@ public class RehabilitationManageService {
            String completeTimeStr = DateUtil.dateToStr(completeTime,DateUtil.YYYY_MM_DD_HH_MM);
            String completeTimeStr = DateUtil.dateToStr(completeTime,DateUtil.YYYY_MM_DD_HH_MM);
            resultMap.put("completeTime",completeTimeStr);//完成时间
            resultMap.put("completeTime",completeTimeStr);//完成时间
            resultMap.put("operatorDoctorName",temp.getDoctorName());//执行医生名称
            resultMap.put("operatorDoctorName",temp.getDoctorName());//执行医生名称
            resultMap.put("node",temp.getNode());
            resultMap.put("relationRecordImg",temp.getRelationRecordImg()!=null?(new JSONArray(temp.getRelationRecordImg())):null);
            if(itemType!=1&&itemType!=0){
            if(itemType!=1&&itemType!=0){
                resultMap.put("relationRecordCode",temp.getRelationRecordCode());
                resultMap.put("relationRecordCode",temp.getRelationRecordCode());
                resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,"yyyy/MM/dd"));
                resultMap.put("completeTimeShort",DateUtil.dateToStr(completeTime,"yyyy/MM/dd"));
@ -943,6 +954,7 @@ public class RehabilitationManageService {
        Map<String,Object> generalDoctorMap =  new HashMap<>();
        Map<String,Object> generalDoctorMap =  new HashMap<>();
        generalDoctorMap.put("type","全科医生");
        generalDoctorMap.put("type","全科医生");
        generalDoctorMap.put("doctorName",generalDoctorName);
        generalDoctorMap.put("doctorName",generalDoctorName);
        generalDoctorMap.put("doctorCode",generalDoctor);
        Integer generalUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(generalDoctor,patientCode,1);
        Integer generalUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(generalDoctor,patientCode,1);
        Integer generalFinishCount = rehabilitationDetailDao.findItemByDoctor(generalDoctor,patientCode);
        Integer generalFinishCount = rehabilitationDetailDao.findItemByDoctor(generalDoctor,patientCode);
        Integer generalServiceCount = rehabilitationDetailDao.completeServiceByDoctor(generalDoctor,patientCode,1);
        Integer generalServiceCount = rehabilitationDetailDao.completeServiceByDoctor(generalDoctor,patientCode,1);
@ -953,6 +965,7 @@ public class RehabilitationManageService {
        Map<String,Object> healthDoctorMap =  new HashMap<>();
        Map<String,Object> healthDoctorMap =  new HashMap<>();
        healthDoctorMap.put("type","健管师");
        healthDoctorMap.put("type","健管师");
        healthDoctorMap.put("doctorName",healthDoctorName);
        healthDoctorMap.put("doctorName",healthDoctorName);
        healthDoctorMap.put("doctorCode",healthDoctor);
        Integer healthUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(healthDoctor,patientCode,1);
        Integer healthUnfinishCount = rehabilitationDetailDao.unfinishItemByDoctor(healthDoctor,patientCode,1);
        Integer healthFinishCount = rehabilitationDetailDao.findItemByDoctor(healthDoctor,patientCode);
        Integer healthFinishCount = rehabilitationDetailDao.findItemByDoctor(healthDoctor,patientCode);
        Integer healthServiceCount = rehabilitationDetailDao.completeServiceByDoctor(healthDoctor,patientCode,1);
        Integer healthServiceCount = rehabilitationDetailDao.completeServiceByDoctor(healthDoctor,patientCode,1);
@ -972,6 +985,7 @@ public class RehabilitationManageService {
            map.put("finishedItem",finishCount-unfinishCount);
            map.put("finishedItem",finishCount-unfinishCount);
            map.put("serviceCount",serviceCount);
            map.put("serviceCount",serviceCount);
            map.put("doctorName",doctorName);
            map.put("doctorName",doctorName);
            map.put("doctorCode",doctor);
            map.put("type","专科医生");
            map.put("type","专科医生");
            serviceDoctorList.add(map);
            serviceDoctorList.add(map);
        }
        }
@ -1010,4 +1024,8 @@ public class RehabilitationManageService {
        List<Map<String,Object>> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
        List<Map<String,Object>> list = rehabilitationDetailDao.dailyJob(startTime,endTime);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
        return ObjEnvelop.getSuccess(SpecialistMapping.api_success,list);
    }
    }
    public int updateNodeAndRelationRecordImg(String node,String image,String planDeatilId){
        return rehabilitationOperateRecordsDao.updateNodeAndRelationRecordImg(node,image,planDeatilId);
    }
}
}

+ 24 - 4
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationPlanService.java

@ -1,13 +1,19 @@
package com.yihu.jw.service.rehabilitation;
package com.yihu.jw.service.rehabilitation;
import com.yihu.jw.dao.rehabilitation.*;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.dao.rehabilitation.PatientRehabilitationPlanDao;
import com.yihu.jw.dao.rehabilitation.PatientRehabilitationPlanDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationDetailDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationDetailDao;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.yihu.jw.dao.rehabilitation.PatientRehabilitationPlanDao;
import com.yihu.jw.entity.rehabilitation.RehabilitationPlanningDO;
import com.yihu.jw.dao.rehabilitation.RehabilitationPlanTemplateDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationPlanTemplateDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationTemplateDetailDao;
import com.yihu.jw.dao.rehabilitation.RehabilitationTemplateDetailDao;
import com.yihu.jw.entity.specialist.HospitalServiceItemDO;
import com.yihu.jw.entity.specialist.HospitalServiceItemDO;
import com.yihu.jw.entity.specialist.rehabilitation.*;
import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO;
import com.yihu.jw.entity.specialist.rehabilitation.PatientRehabilitationPlanDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationDetailDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationDetailDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationPlanTemplateDO;
import com.yihu.jw.entity.specialist.rehabilitation.RehabilitationPlanTemplateDO;
@ -21,6 +27,8 @@ import com.yihu.jw.service.SpecialistHospitalServiceItemService;
import com.yihu.jw.service.SpecialistService;
import com.yihu.jw.service.SpecialistService;
import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.jw.util.common.QrcodeUtil;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.fastdfs.FastDFSUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.annotation.Value;
@ -35,13 +43,15 @@ import java.util.Date;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
import java.util.*;
import java.util.*;
import java.util.*;
import java.util.*;
/**
/**
 * Created by humingfen on 2018/8/17.
 * Created by humingfen on 2018/8/17.
 */
 */
@Service
@Service
@Transactional
@Transactional
public class RehabilitationPlanService {
public class RehabilitationPlanService extends BaseJpaService<RehabilitationPlanningDO, RehabilitationPlanningDO> {
    @Value("${neiwang.enable}")
    @Value("${neiwang.enable}")
    private Boolean isneiwang;  //如果不是内网项目要转到到内网wlyy在上传
    private Boolean isneiwang;  //如果不是内网项目要转到到内网wlyy在上传
@ -64,6 +74,8 @@ public class RehabilitationPlanService {
    @Autowired
    @Autowired
    protected HttpServletRequest request;
    protected HttpServletRequest request;
    @Autowired
    @Autowired
    private RehabilitationOperateRecordsDao rehabilitationOperateRecordsDao;
    @Autowired
    private SpecialistHospitalServiceItemService hospitalServiceItemService;
    private SpecialistHospitalServiceItemService hospitalServiceItemService;
    @Autowired
    @Autowired
    private SpecialistService specialistService;
    private SpecialistService specialistService;
@ -202,14 +214,14 @@ public class RehabilitationPlanService {
        return MixEnvelop.getSuccess(SpecialistMapping.api_success, jsonArray);
        return MixEnvelop.getSuccess(SpecialistMapping.api_success, jsonArray);
    }
    }
    public MixEnvelop<String,String> createServiceQrCode(String planDetailId){
    public MixEnvelop<String,String> createServiceQrCode(String planDetailId,String sessionId){
        RehabilitationDetailDO rehabilitationDetailDO = rehabilitationDetailDao.findById(planDetailId);
        RehabilitationDetailDO rehabilitationDetailDO = rehabilitationDetailDao.findById(planDetailId);
        String fileUrl = "";
        String fileUrl = "";
        if (rehabilitationDetailDO!=null) {
        if (rehabilitationDetailDO!=null) {
            if (org.apache.commons.lang3.StringUtils.isNotBlank(rehabilitationDetailDO.getServiceQrCode())) {
            if (org.apache.commons.lang3.StringUtils.isNotBlank(rehabilitationDetailDO.getServiceQrCode())) {
                fileUrl = rehabilitationDetailDO.getServiceQrCode();
                fileUrl = rehabilitationDetailDO.getServiceQrCode();
            } else {
            } else {
                String contentJsonStr="{\"planDetailId\":\""+planDetailId+"\"}";
                String contentJsonStr="{\"planDetailId\":\""+planDetailId+"\",\"sessionId\":\""+sessionId+"\"}";
                InputStream ipt = QrcodeUtil.createQrcode(contentJsonStr, 300, "png");
                InputStream ipt = QrcodeUtil.createQrcode(contentJsonStr, 300, "png");
                isneiwang = false;
                isneiwang = false;
                if (isneiwang) {
                if (isneiwang) {
@ -249,7 +261,7 @@ public class RehabilitationPlanService {
        return MixEnvelop.getSuccess("获取二维码成功!",fileUrl);
        return MixEnvelop.getSuccess("获取二维码成功!",fileUrl);
    }
    }
    public Integer checkAfterQrCode(String planDetailId,String patietCode){
    public Integer checkAfterQrCode(String planDetailId,String patietCode)throws Exception{
        int result = 0;
        int result = 0;
        String sql ="SELECT rp.patient FROM `wlyy_rehabilitation_plan_detail` pd LEFT JOIN wlyy_patient_rehabilitation_plan rp ON pd.plan_id = rp.id WHERE pd.id='"+planDetailId+"'";
        String sql ="SELECT rp.patient FROM `wlyy_rehabilitation_plan_detail` pd LEFT JOIN wlyy_patient_rehabilitation_plan rp ON pd.plan_id = rp.id WHERE pd.id='"+planDetailId+"'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
@ -264,4 +276,12 @@ public class RehabilitationPlanService {
        }
        }
        return result;
        return result;
    }
    }
    public RehabilitationOperateRecordsDO saveRehabilitationRecord(RehabilitationOperateRecordsDO rehabilitationOperateRecordsDO){
        RehabilitationDetailDO rehabilitationDetailDO = rehabilitationDetailDao.findById(rehabilitationOperateRecordsDO.getRehabilitationDetailId());
        rehabilitationOperateRecordsDO.setId(getCode());
        rehabilitationOperateRecordsDO.setReserveTime(rehabilitationDetailDO.getExecuteTime());
        rehabilitationOperateRecordsDO.setCompleteTime(new Date());
        return rehabilitationOperateRecordsDao.save(rehabilitationOperateRecordsDO);
    }
}
}

+ 9 - 0
svr/svr-wlyy-specialist/src/main/resources/application.yml

@ -86,6 +86,9 @@ neiwang:
  enable: true
  enable: true
  wlyy: http://localhost:10051/
  wlyy: http://localhost:10051/
base:
  url: http://172.17.110.212:10020/
---
---
spring:
spring:
  profiles: jwtest
  profiles: jwtest
@ -104,6 +107,9 @@ fast-dfs:
neiwang:
neiwang:
  enable: false
  enable: false
  wlyy: http://59.61.92.90:10051/
  wlyy: http://59.61.92.90:10051/
base:
  url: http://172.17.110.212:10020/
---
---
spring:
spring:
  profiles: jwdevtest
  profiles: jwdevtest
@ -122,6 +128,9 @@ fast-dfs:
neiwang:
neiwang:
  enable: true
  enable: true
  wlyy: http://172.19.103.88:10051/svr-slyy-specialist/
  wlyy: http://172.19.103.88:10051/svr-slyy-specialist/
base:
  url: http://172.17.110.212:10020/
---
---
spring:
spring:
  profiles: prod
  profiles: prod