浏览代码

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

LiTaohong 6 年之前
父节点
当前提交
b3b699c186
共有 17 个文件被更改,包括 541 次插入242 次删除
  1. 51 0
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatService.java
  2. 14 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java
  3. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageDO.java
  4. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageSignRecordDO.java
  5. 1 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/patient/PatientRequestMapping.java
  6. 16 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/org/BaseOrgVO.java
  7. 209 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/patient/signPackage/ServicePackageRecordVO.java
  8. 9 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/patient/signPackage/ServicePackageVO.java
  9. 3 6
      server/svr-authentication/src/main/resources/application.yml
  10. 1 1
      server/svr-authentication/src/main/resources/bootstrap.yml
  11. 15 37
      svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/personal_info/PatientEndpoint.java
  12. 14 0
      svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/servicepackage/PackageServiceEndpoint.java
  13. 19 1
      svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/wechat/WechatEndPoint.java
  14. 33 6
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/personal_Info/PatientService.java
  15. 131 4
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/servicepackage/PackageService.java
  16. 0 182
      svr/svr-patient/src/main/java/com/yihu/jw/patient/util/RSAService.java
  17. 7 4
      svr/svr-patient/src/main/resources/application.yml

+ 51 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/service/WechatService.java

@ -0,0 +1,51 @@
package com.yihu.jw.wechat.service;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.dao.WechatDao;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class WechatService {
    @Autowired
    private WechatDao wechatDao;
    /**
     * 通过code获取判断openid
     *
     * @param code
     * @return
     */
    public String getOpenidByCode(String code,String appId,String appSecret) {
        try {
            String token_url = "https://api.weixin.qq.com/sns/oauth2/access_token";
            String params = "appid=" + appId + "&secret=" +appSecret+ "&code=" + code + "&grant_type=authorization_code";
            String result = HttpUtil.sendGet(token_url, params);
            System.out.println("getOpenidByCode:"+result);
            JSONObject json = new JSONObject(result);
            if (json.has("openid")) {
                return json.get("openid").toString();
            } else {
                return null;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     * 通过code获取判断openid
     *
     * @param code
     * @return
     */
    public String getOpenidByCode(String code,String wxId) {
        //通过wxId获取appId和appSecret
        WxWechatDO wxWechatDO = wechatDao.findById(wxId);
        return getOpenidByCode(code,wxWechatDO.getAppId(),wxWechatDO.getAppSecret());
    }
}

+ 14 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java

@ -145,6 +145,13 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
	 */
	 */
	private String del;
	private String del;
    /**
     * 11一级甲等 12一级乙等 13一级丙等
     * 21二级甲等 22二级乙等 23二级丙等
     * 31三级特等 32三级甲等 33三级乙等 34三级丙级
     */
    private Integer level;
    public BaseOrgDO() {
    public BaseOrgDO() {
    }
    }
@ -360,6 +367,12 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
        this.del = del;
        this.del = del;
    }
    }
    @Column(name = "level")
    public Integer getLevel() {
        return level;
    }
    public void setLevel(Integer level) {
        this.level = level;
    }
}
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageDO.java

@ -92,6 +92,7 @@ public class ServicePackageDO extends UuidIdentityEntity implements Serializable
    private String introduce;//服务介绍
    private String introduce;//服务介绍
    private String endIntroduce;//过期时间说明
    private String endIntroduce;//过期时间说明
    private String status;//审核状态(预留字段0待审核,1审核通过,2审核不通过)
    private String status;//审核状态(预留字段0待审核,1审核通过,2审核不通过)
    private Date endTime;//结束时间
    private Integer del;//是否有效(1有效,0失效)
    private Integer del;//是否有效(1有效,0失效)
    private Integer sort;//排序
    private Integer sort;//排序
@ -240,4 +241,12 @@ public class ServicePackageDO extends UuidIdentityEntity implements Serializable
    public void setOrganizationName(String organizationName) {
    public void setOrganizationName(String organizationName) {
        this.organizationName = organizationName;
        this.organizationName = organizationName;
    }
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
}
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageSignRecordDO.java

@ -35,6 +35,7 @@ public class ServicePackageSignRecordDO extends UuidIdentityEntity implements Se
    private String doctorTeamCode;//医生服务团队code
    private String doctorTeamCode;//医生服务团队code
    private String operator;//签约申请人处理人
    private String operator;//签约申请人处理人
    private Date createTime;//创建时间
    private Date createTime;//创建时间
    private Integer sort;//排序:0 待支付,1未通过,2未通过,3待审核,4.生效
    @Column(name = "saas_id")
    @Column(name = "saas_id")
    public String getSaasId() {
    public String getSaasId() {
@ -198,4 +199,12 @@ public class ServicePackageSignRecordDO extends UuidIdentityEntity implements Se
    public void setOperator(String operator) {
    public void setOperator(String operator) {
        this.operator = operator;
        this.operator = operator;
    }
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
}
}

+ 1 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/patient/PatientRequestMapping.java

@ -41,6 +41,7 @@ public class PatientRequestMapping {
        public static final String findDoctorById  = "/findDoctorById";
        public static final String findDoctorById  = "/findDoctorById";
        public static final String findOrgByCode  = "/findOrgByCode";
        public static final String findOrgByCode  = "/findOrgByCode";
        public static final String findPatientSignExist  = "/findPatientSignExist";
        public static final String findPatientSignExist  = "/findPatientSignExist";
        public static final String findPatientSignPackage  = "/findPatientSignPackage";
    }
    }
    /**
    /**
     * myFamily
     * myFamily

+ 16 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/base/org/BaseOrgVO.java

@ -144,6 +144,14 @@ public class BaseOrgVO extends UuidIdentityVOWithOperator {
	@ApiModelProperty(value = "作废标识,1正常,0作废", example = "1")
	@ApiModelProperty(value = "作废标识,1正常,0作废", example = "1")
    private String del;
    private String del;
    /**
     * 11一级甲等 12一级乙等 13一级丙等
     * 21二级甲等 22二级乙等 23二级丙等
     * 31三级特等 32三级甲等 33三级乙等 34三级丙级
     */
    @ApiModelProperty(value = "11一级甲等 12一级乙等 13一级丙等二级甲等 22二级乙等 23二级丙等31三级特等 32三级甲等 33三级乙等 34三级丙级", example = "1")
    private Integer level;
    private List<DictHospitalDeptVO> depts;
    private List<DictHospitalDeptVO> depts;
    public String getCode() {
    public String getCode() {
@ -291,6 +299,14 @@ public class BaseOrgVO extends UuidIdentityVOWithOperator {
        return depts;
        return depts;
    }
    }
    public Integer getLevel() {
        return level;
    }
    public void setLevel(Integer level) {
        this.level = level;
    }
    public void setDepts(List<DictHospitalDeptVO> depts) {
    public void setDepts(List<DictHospitalDeptVO> depts) {
        this.depts = depts;
        this.depts = depts;
    }
    }

+ 209 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/patient/signPackage/ServicePackageRecordVO.java

@ -0,0 +1,209 @@
package com.yihu.jw.restmodel.patient.signPackage;
import java.util.Date;
/**
 * Created by Trick on 2018/12/6.
 */
public class ServicePackageRecordVO {
    private String saasId;
    private String servicePackageId;//服务包id
    private String servicePackageName;//服务包名称
    private String patient;//居民code
    private String name;//居民姓名
    private String idcard;//居民身份证
    private String ssc;//社保卡号
    private String signDoctor;//签约医生code
    private String signDoctorName;//签约医生名称
    private String hospital;//医院code
    private String hospitalName;//医院名称
    private Long adminTeamCode;//行政团队id
    private Long price;//服务总价
    private Date startTime;//服务开始时间
    private Date endTime;//服务结束时间
    private Integer status;//状态(0待审核,1已同意,待支付,2.支付成功,已生效,-1未通过,-2已取消,-3已过期)
    private String doctorTeamCode;//医生服务团队code
    private String operator;//签约申请人处理人
    private Date createTime;//创建时间
    private Integer sort;//排序:0 待支付,1未通过,2未通过,3待审核,4.生效
    private String introduce;//服务介绍
    private String endIntroduce;//过期时间说明
    public String getSaasId() {
        return saasId;
    }
    public void setSaasId(String saasId) {
        this.saasId = saasId;
    }
    public String getServicePackageId() {
        return servicePackageId;
    }
    public void setServicePackageId(String servicePackageId) {
        this.servicePackageId = servicePackageId;
    }
    public String getServicePackageName() {
        return servicePackageName;
    }
    public void setServicePackageName(String servicePackageName) {
        this.servicePackageName = servicePackageName;
    }
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    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;
    }
    public String getSignDoctor() {
        return signDoctor;
    }
    public void setSignDoctor(String signDoctor) {
        this.signDoctor = signDoctor;
    }
    public String getSignDoctorName() {
        return signDoctorName;
    }
    public void setSignDoctorName(String signDoctorName) {
        this.signDoctorName = signDoctorName;
    }
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    public String getHospitalName() {
        return hospitalName;
    }
    public void setHospitalName(String hospitalName) {
        this.hospitalName = hospitalName;
    }
    public Long getAdminTeamCode() {
        return adminTeamCode;
    }
    public void setAdminTeamCode(Long adminTeamCode) {
        this.adminTeamCode = adminTeamCode;
    }
    public Long getPrice() {
        return price;
    }
    public void setPrice(Long price) {
        this.price = price;
    }
    public Date getStartTime() {
        return startTime;
    }
    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getDoctorTeamCode() {
        return doctorTeamCode;
    }
    public void setDoctorTeamCode(String doctorTeamCode) {
        this.doctorTeamCode = doctorTeamCode;
    }
    public String getOperator() {
        return operator;
    }
    public void setOperator(String operator) {
        this.operator = operator;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    public String getIntroduce() {
        return introduce;
    }
    public void setIntroduce(String introduce) {
        this.introduce = introduce;
    }
    public String getEndIntroduce() {
        return endIntroduce;
    }
    public void setEndIntroduce(String endIntroduce) {
        this.endIntroduce = endIntroduce;
    }
}

+ 9 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/patient/signPackage/ServicePackageVO.java

@ -28,6 +28,7 @@ public class ServicePackageVO {
    private String endIntroduce;//过期描述
    private String endIntroduce;//过期描述
    private String status;//审核状态(预留字段0待审核,1审核通过,2审核不通过)
    private String status;//审核状态(预留字段0待审核,1审核通过,2审核不通过)
    private Integer del;//是否有效(1有效,0失效)
    private Integer del;//是否有效(1有效,0失效)
    private Date endTime;
    private List<SerivePackageItemVO> items;//服务项描述
    private List<SerivePackageItemVO> items;//服务项描述
@ -182,4 +183,12 @@ public class ServicePackageVO {
    public void setOrganizationName(String organizationName) {
    public void setOrganizationName(String organizationName) {
        this.organizationName = organizationName;
        this.organizationName = organizationName;
    }
    }
    public Date getEndTime() {
        return endTime;
    }
    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }
}
}

+ 3 - 6
server/svr-authentication/src/main/resources/application.yml

@ -39,12 +39,9 @@ spring:
spring:
spring:
  profiles: jwtest
  profiles: jwtest
  datasource:
  datasource:
#    url: jdbc:mysql://172.17.110.160/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
#    username: ssgg
#    password: ssgg
    url: jdbc:mysql://172.19.103.77/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: root
    password: 123456
    url: jdbc:mysql://172.17.110.160/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true
    username: ssgg
    password: ssgg
  redis:
  redis:
    host: 172.19.103.88 # Redis server host.
    host: 172.19.103.88 # Redis server host.
    port: 6379 # Redis server port.
    port: 6379 # Redis server port.

+ 1 - 1
server/svr-authentication/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
spring:
  application:
  application:
    name: svr-authentication
    name: svr-authentication-lyx
  cloud:
  cloud:
    config:
    config:
      failFast: true
      failFast: true

+ 15 - 37
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/personal_info/PatientEndpoint.java

@ -1,14 +1,10 @@
package com.yihu.jw.patient.endpoint.personal_info;
package com.yihu.jw.patient.endpoint.personal_info;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.security.Token;
import com.yihu.jw.entity.base.sms.SmsDO;
import com.yihu.jw.entity.base.sms.SmsDO;
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
import com.yihu.jw.entity.base.sms.SmsTemplateDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.personal_Info.PatientService;
import com.yihu.jw.patient.service.personal_Info.PatientService;
import com.yihu.jw.patient.util.CommonUtils;
import com.yihu.jw.patient.util.ConstantUtils;
import com.yihu.jw.patient.util.ConstantUtils;
import com.yihu.jw.patient.util.RSAService;
import com.yihu.jw.restmodel.base.patient.BasePatientVO;
import com.yihu.jw.restmodel.base.patient.BasePatientVO;
import com.yihu.jw.restmodel.base.sms.SmsVO;
import com.yihu.jw.restmodel.base.sms.SmsVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
@ -17,17 +13,13 @@ import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.security.service.TokenService;
import com.yihu.jw.sms.service.BaseSmsGatewayService;
import com.yihu.jw.sms.service.BaseSmsGatewayService;
import com.yihu.jw.sms.service.BaseSmsService;
import com.yihu.jw.util.security.MD5;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
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;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartFile;
@ -57,35 +49,6 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    private BaseSmsGatewayService baseSmsGatewayService;
    private BaseSmsGatewayService baseSmsGatewayService;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private RSAService rsaService;
    @Autowired
    private TokenService tokenService;
    @Autowired
    private BaseSmsService baseSmsService;
    /**
     * 公钥生成并返回接口
     *
     * @return
     */
    @RequestMapping(value = BaseRequestMapping.BasePatient.GetKey, method = RequestMethod.GET)
    @ApiOperation("获取公钥")
    public Envelop publicKey() {
        String modulus = rsaService.getModulus();
        String exponent = rsaService.getExponent();
        Map<String, String> map = new HashMap<>();
        map.put("modulus", modulus); //加密指数
        map.put("exponent", exponent);//加密系数
        return success(map);
    }
    @ApiOperation("居民注册接口")
    @ApiOperation("居民注册接口")
    @RequestMapping(value = BaseRequestMapping.BasePatient.Regist, method = RequestMethod.POST)
    @RequestMapping(value = BaseRequestMapping.BasePatient.Regist, method = RequestMethod.POST)
@ -234,4 +197,19 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
        return success(smsDO, SmsVO.class);
        return success(smsDO, SmsVO.class);
    }
    }
    @GetMapping(value = "bespeakRegist")
    @ApiOperation(value = "发送验证码")
    public Envelop bespeakRegist(
            @ApiParam(name = "mobile", value = "手机号")
            @RequestParam(value = "mobile", required = true) String mobile) throws Exception {
        Map<String, Object> map = patientService.bespeakRegist(mobile, 2L);
        Envelop envelop = new Envelop();
        String code = map.get("code").toString();
        String message = map.get("message").toString();
        System.out.println("code====>>"+code);
        System.out.println("message====>>"+message);
        return envelop;
    }
}
}

+ 14 - 0
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/servicepackage/PackageServiceEndpoint.java

@ -132,5 +132,19 @@ public class PackageServiceEndpoint extends EnvelopRestEndpoint {
        return success(PatientRequestMapping.SignPackage.api_success,packageService.findPatientSignExist(patient,packageId));
        return success(PatientRequestMapping.SignPackage.api_success,packageService.findPatientSignExist(patient,packageId));
    }
    }
    @GetMapping(value = PatientRequestMapping.SignPackage.findPatientSignPackage)
    @ApiOperation(value = "签约记录", notes = "签约记录")
    public MixEnvelop findPatientSignPackage(@ApiParam(name = "label", value = "标签code") @RequestParam(value = "label", required = false)String label,
                                             @ApiParam(name = "labelType", value = "标签类型") @RequestParam(value = "labelType", required = false)String labelType,
                                             @ApiParam(name = "patient", value = "签约人") @RequestParam(value = "patient", required = false)String patient,
                                             @ApiParam(name = "operator", value = "创建人") @RequestParam(value = "operator", required = false)String operator,
                                             @ApiParam(name = "familyModel", value = "关系模式,1:查询自己;2:查询家人(未经授权);3:查询家人且授权") @RequestParam(value = "familyModel", required = true)String familyModel,
                                             @ApiParam(name = "status", value = "状态:0待审核,1已同意,待支付,2.支付成功,已生效,-1未通过,-2已取消,-3已过期") @RequestParam(value = "status", required = false)Integer status,
                                             @ApiParam(name = "isHos", value = "是否查询历史记录,1为查询历史,不传为当前记录") @RequestParam(value = "isHos", required = false)String isHos,
                                             @ApiParam(name = "page", value = "第几页") @RequestParam(value = "page", required = true)Integer page,
                                             @ApiParam(name = "size", value = "每页大小") @RequestParam(value = "size", required = true)Integer size) {
        return packageService.findPatientSignPackage( label, labelType, patient, operator, familyModel, status, isHos,  page, size);
    }
//=================================
//=================================
}
}

+ 19 - 1
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/wechat/WechatEndPoint.java

@ -3,16 +3,17 @@ package com.yihu.jw.patient.endpoint.wechat;
import com.yihu.jw.entity.base.wx.JsApiTicket;
import com.yihu.jw.entity.base.wx.JsApiTicket;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.service.WechatService;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import org.json.JSONObject;
import org.json.JSONObject;
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.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestMethod;
@ -35,6 +36,10 @@ public class WechatEndPoint extends EnvelopRestEndpoint {
    @Autowired
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    private WxAccessTokenService wxAccessTokenService;
    @Autowired
    private WechatService wechatService;
    @Value("${wechat.id}")
    private String wxId;
    /**
    /**
     * 获取签名signature
     * 获取签名signature
     *
     *
@ -64,6 +69,19 @@ public class WechatEndPoint extends EnvelopRestEndpoint {
        return failed(PatientRequestMapping.Wechat.api_error);
        return failed(PatientRequestMapping.Wechat.api_error);
    }
    }
    /**
     * 获取微信openid
     *
     * @param code
     * @return
     */
    @RequestMapping(value = "getOpenidByCode", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public String getOpenidByCode(String code) {
        return wechatService.getOpenidByCode(code,wxId);
    }
    /**
    /**
     * 获取微信的jsapi_ticket
     * 获取微信的jsapi_ticket
     *
     *

+ 33 - 6
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/personal_Info/PatientService.java

@ -7,18 +7,17 @@ import com.yihu.jw.exception.business.patient.CapthcaInvalidException;
import com.yihu.jw.exception.business.patient.PatientNotFoundException;
import com.yihu.jw.exception.business.patient.PatientNotFoundException;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.file_upload.FileUploadService;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.personal_info.PatientDao;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.patient.util.CommonUtils;
import com.yihu.jw.patient.util.CommonUtils;
import com.yihu.jw.patient.util.ConstantUtils;
import com.yihu.jw.patient.util.ConstantUtils;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.restmodel.iot.common.UploadVO;
import com.yihu.jw.patient.util.RSAService;
import com.yihu.jw.sms.service.BaseSmsService;
import com.yihu.jw.sms.service.BaseSmsService;
import com.yihu.utils.security.MD5;
import com.yihu.utils.security.MD5;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.csource.common.MyException;
import org.csource.common.MyException;
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.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.util.Assert;
@ -28,6 +27,7 @@ import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
/**
 * 居民信息服务
 * 居民信息服务
@ -46,6 +46,11 @@ public class PatientService extends BasePatientService<BasePatientDO, BasePatien
    @Autowired
    @Autowired
    private FileUploadService fileUploadService;
    private FileUploadService fileUploadService;
    @Autowired
    private StringRedisTemplate redisTemplate;
    private static String BespeakRegist = "bespeakRegist:";
    @Value("${fastDFS.fastdfs_file_url}")
    @Value("${fastDFS.fastdfs_file_url}")
    private String fastdfsUrl;
    private String fastdfsUrl;
@ -109,12 +114,34 @@ public class PatientService extends BasePatientService<BasePatientDO, BasePatien
    /**
    /**
     * 预注册功能接口
     * 预注册功能接口
     * @param phone
     * @param mobile
     * @param time 预注册过期时间 例如: 2 , 则2分钟过期
     * @return
     * @return
     */
     */
//    public Map<String,Object> bespeakRegist(String phone){
//
//    }
    public Map<String,Object> bespeakRegist(String mobile,long time){
        Map<String, Object> map = new HashMap<>();
        boolean b = CommonUtils.isMobile(mobile);
        if(!b){
            map.put("code",-1);
            map.put("message","手机号码格式不正确");
            return map;
        }
        //验证手机是否被注册
        List<BasePatientDO> list = basePatientDao.findByMobileAndDel(mobile,"1");
        if(list!=null && list.size()> 0){
            map.put("code",-1);
            map.put("message","该手机号已经注册!");
            return map;
        }
        //将预注册信息存到redis中
        redisTemplate.opsForValue().set(BespeakRegist+mobile , mobile, time, TimeUnit.MINUTES);
        map.put("code",1);
        map.put("message","预注册成功");
        return map;
    }
    /**
    /**
     * 设置登录密码/修改密码
     * 设置登录密码/修改密码

+ 131 - 4
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/servicepackage/PackageService.java

@ -12,9 +12,11 @@ import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.servicepackage.ServicePackageDao;
import com.yihu.jw.patient.dao.servicepackage.ServicePackageDao;
import com.yihu.jw.patient.dao.servicepackage.ServicePackageItemDao;
import com.yihu.jw.patient.dao.servicepackage.ServicePackageItemDao;
import com.yihu.jw.patient.dao.servicepackage.ServicePackageSignRecordDao;
import com.yihu.jw.patient.dao.servicepackage.ServicePackageSignRecordDao;
import com.yihu.jw.patient.service.myFamily.MyFamilyService;
import com.yihu.jw.patient.useragent.UserAgent;
import com.yihu.jw.patient.useragent.UserAgent;
import com.yihu.jw.restmodel.base.doctor.BaseDoctorOrgVO;
import com.yihu.jw.restmodel.base.doctor.BaseDoctorOrgVO;
import com.yihu.jw.restmodel.base.org.OrgDistanceVO;
import com.yihu.jw.restmodel.base.org.OrgDistanceVO;
import com.yihu.jw.restmodel.patient.signPackage.ServicePackageRecordVO;
import com.yihu.jw.restmodel.patient.signPackage.ServicePackageVO;
import com.yihu.jw.restmodel.patient.signPackage.ServicePackageVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -25,6 +27,7 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.List;
import java.util.Map;
import java.util.Map;
@ -58,6 +61,9 @@ public class PackageService {
    @Autowired
    @Autowired
    private DictHospitalDeptDao dictHospitalDeptDao;
    private DictHospitalDeptDao dictHospitalDeptDao;
    @Autowired
    private MyFamilyService myFamilyService;
    public MixEnvelop findPackageService(String city,String labelCode,String labelType,Integer page,Integer size){
    public MixEnvelop findPackageService(String city,String labelCode,String labelType,Integer page,Integer size){
        String totalSql ="SELECT " +
        String totalSql ="SELECT " +
@ -218,8 +224,10 @@ public class PackageService {
        return MixEnvelop.getSuccessListWithPage(PatientRequestMapping.SignPackage.api_success, list, page, size, count);
        return MixEnvelop.getSuccessListWithPage(PatientRequestMapping.SignPackage.api_success, list, page, size, count);
    }
    }
    public Envelop signPackage(ServicePackageSignRecordDO recordDO){
    public Envelop signPackage(ServicePackageSignRecordDO recordDO) throws Exception{
        servicePackageSignRecordDao.save(recordDO);
        servicePackageSignRecordDao.save(recordDO);
        return Envelop.getSuccess(PatientRequestMapping.SignPackage.api_success);
        return Envelop.getSuccess(PatientRequestMapping.SignPackage.api_success);
    }
    }
@ -244,7 +252,126 @@ public class PackageService {
        }
        }
    }
    }
//    public MixEnvelop findSignPackage(){
//
//    }
    public MixEnvelop findPatientSignPackage(String label,String labelType,String patient,String operator,String familyModel,Integer status,String isHos, Integer page,Integer size){
        String totalSql="SELECT DISTINCT " +
                " r.id " +
                " FROM " +
                " base_service_package_sign_record r  " +
                " JOIN base_service_package p ON r.service_package_id = p.id ";
        if(StringUtils.isNotBlank(label)&&StringUtils.isNotBlank(labelType)){
            totalSql += " JOIN base_package_label_info l ON r.service_package_id = l.service_package_id ";
        }
        totalSql +=" WHERE 1=1 ";
        if("1".equals(familyModel)){
            //自己
            if(StringUtils.isNotBlank(patient)){
                totalSql +=" AND r.patient = '"+patient+"'";
            }
        }else if("2".equals(familyModel)){
            //未经授权查询家人,只查自己创建的
            if(StringUtils.isNotBlank(patient)&&StringUtils.isNotBlank(operator)){
                totalSql +=" AND r.operator = '"+operator+"' " +
                        " AND r.patient = '"+patient+"' ";
            }
        }else if("3".equals(familyModel)){
            //查询已经授权,自己创建和家人相关记录
            if(StringUtils.isNotBlank(patient)&&StringUtils.isNotBlank(operator)){
                totalSql +=" AND (r.operator = '"+operator+"' " +
                        " OR r.patient = '"+patient+"' )";
            }
        }
        if(status != null){
            totalSql +=" AND r.`status` ="+status;
        }
        if(StringUtils.isNotBlank(isHos)){
            totalSql +=" AND r.`status` < 0 ";
        }else{
            totalSql +=" AND r.`status` >= 0 ";
        }
        if(StringUtils.isNotBlank(label)&&StringUtils.isNotBlank(labelType)){
            totalSql +=" AND l.label ='"+label+"'" +
                    " AND l.label_type ='"+labelType+"'";
        }
        List<Map<String, Object>> rstotal = jdbcTemplate.queryForList(totalSql);
        Long count = 0L;
        if (rstotal != null && rstotal.size() > 0) {
            count =(long)rstotal.size();
        }
        String sql="SELECT DISTINCT " +
                " r.id, " +
                " r.saas_id AS saasId," +
                " p.id AS servicePackageId, " +
                " p.name AS servicePackageName, " +
                " r.patient," +
                " r.name," +
                " r.idcard," +
                " r.sign_doctor AS signDoctor, " +
                " r.sign_doctor_name AS signDoctorName, " +
                " r.ssc," +
                " r.hospital," +
                " r.hospital_name AS hospitalName," +
                " r.admin_team_code AS adminTeamCode," +
                " r.price," +
                " r.start_time AS startTime," +
                " r.end_time AS endTime," +
                " r.status," +
                " r.doctor_team_code AS doctorTeamCode," +
                " r.operator," +
                " r.create_time AS createTime," +
                " r.sort," +
                " p.introduce, " +
                " p.end_introduce AS endIntroduce " +
                " FROM " +
                " base_service_package_sign_record r  " +
                " JOIN base_service_package p ON r.service_package_id = p.id ";
                if(StringUtils.isNotBlank(label)&&StringUtils.isNotBlank(labelType)){
                    sql += " JOIN base_package_label_info l ON r.service_package_id = l.service_package_id ";
                }
                sql +=" WHERE 1=1 ";
                if("1".equals(familyModel)){
                    //自己
                    if(StringUtils.isNotBlank(patient)){
                        sql +=" AND r.patient = '"+patient+"'";
                    }
                }else if("2".equals(familyModel)){
                    //未经授权查询家人,只查自己创建的
                    if(StringUtils.isNotBlank(patient)&&StringUtils.isNotBlank(operator)){
                        sql +=" AND r.operator = '"+operator+"' " +
                              " AND r.patient = '"+patient+"' ";
                    }
                }else if("3".equals(familyModel)){
                    //查询已经授权,自己创建和家人相关记录
                    if(StringUtils.isNotBlank(patient)&&StringUtils.isNotBlank(operator)){
                        sql +=" AND (r.operator = '"+operator+"' " +
                                " OR r.patient = '"+patient+"' )";
                    }
                }
                if(status != null){
                    sql +=" AND r.`status` ="+status;
                }
                if(StringUtils.isNotBlank(isHos)){
                    sql +=" AND r.`status` < 0 ";
                }else{
                    sql +=" AND r.`status` >= 0 ";
                }
                if(StringUtils.isNotBlank(label)&&StringUtils.isNotBlank(labelType)){
                    sql +=" AND l.label ='"+label+"'" +
                          " AND l.label_type ='"+labelType+"'";
                }
                sql +=" ORDER BY r.sort ASC  "+
                      " LIMIT " + (page - 1) * size + "," + size + "";
        List<ServicePackageRecordVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ServicePackageRecordVO.class));
        return MixEnvelop.getSuccessListWithPage(PatientRequestMapping.SignPackage.api_success, list, page, size, count);
    }
}
}

+ 0 - 182
svr/svr-patient/src/main/java/com/yihu/jw/patient/util/RSAService.java

@ -1,182 +0,0 @@
package com.yihu.jw.patient.util;
import java.io.*;
import java.security.*;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.util.Iterator;
import com.yihu.jw.entity.base.security.RSA;
import com.yihu.jw.patient.dao.security.RSADao;
import com.yihu.jw.util.common.RSAUtils;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class RSAService {
    @Autowired
    private RSADao rsaDao;
    /**
     * 缓存的密钥对。
     */
    private KeyPair oneKeyPair = null;
    /**
     * 读取RSA加密信息
     * @return
     */
    public RSA loadRSA() {
        Iterable<RSA> iterable = rsaDao.findAll();
        if (iterable != null) {
            Iterator<RSA> it = iterable.iterator();
            if (it != null && it.hasNext()) {
                return it.next();
            }
        }
        return null;
    }
    public KeyPair getKeyPair() {
        if (oneKeyPair == null) {
            // 从数据库加载
            RSA rsa = loadRSA();
            if (rsa == null) {
                // 生成密钥
                generateKeyPair();
            } else {
                // 由数据库取出来
                Object obj = toObject(rsa.getData());
                oneKeyPair = (KeyPair) obj;
            }
        }
        return oneKeyPair;
    }
    /**
     * 生成并返回RSA密钥对。
     */
    private synchronized KeyPair generateKeyPair() {
        try {
            oneKeyPair = RSAUtils.initKey();
            // 保存到数据库
            saveRSA(oneKeyPair);
            return oneKeyPair;
        } catch (InvalidParameterException ex) {
            ex.printStackTrace();
        } catch (NullPointerException ex) {
            ex.printStackTrace();
        }
        return null;
    }
    /**
     * 保存RSA加密信息
     * @return
     */
    public RSA saveRSA(KeyPair keyPair) {
        RSA rsa = new RSA();
        rsa.setData(toByteArray(keyPair));
        // 先清空
        rsaDao.deleteAll();
        // 再添加
        return rsaDao.save(rsa);
    }
    /**
     * 返回已初始化的默认的公钥。
     */
    public RSAPublicKey getDefaultPublicKey() {
        KeyPair keyPair = getKeyPair();
        if (keyPair != null) {
            return (RSAPublicKey) keyPair.getPublic();
        }
        return null;
    }
    public String getModulus() {
        return new String(Hex.encodeHex(getDefaultPublicKey().getModulus().toByteArray()));
    }
    public String getExponent() {
        return new String(Hex.encodeHex(getDefaultPublicKey().getPublicExponent().toByteArray()));
    }
    /**
     * 对象转数组
     *
     * @param obj
     * @return
     */
    public byte[] toByteArray(Object obj) {
        byte[] bytes = null;
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        try {
            ObjectOutputStream oos = new ObjectOutputStream(bos);
            oos.writeObject(obj);
            oos.flush();
            bytes = bos.toByteArray();
            oos.close();
            bos.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        return bytes;
    }
    /**
     * 数组转对象
     *
     * @param bytes
     * @return
     */
    public Object toObject(byte[] bytes) {
        Object obj = null;
        try {
            ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
            ObjectInputStream ois = new ObjectInputStream(bis);
            obj = ois.readObject();
            ois.close();
            bis.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (ClassNotFoundException ex) {
            ex.printStackTrace();
        }
        return obj;
    }
    /**
     * 使用默认的私钥解密给定的字符串。
     * <p>
     * 若{@code encrypttext} 为 {@code null}或空字符串则返回 {@code null}。
     * 私钥不匹配时,返回 {@code null}。
     *
     * @param encrypttext 密文。
     * @return 原文字符串。
     */
    public String decryptString(String encrypttext) {
        if (StringUtils.isBlank(encrypttext)) {
            return null;
        }
        try {
            byte[] en_data = Hex.decodeHex(encrypttext.toCharArray());
            byte[] data =   RSAUtils.decrypt((RSAPrivateKey) getKeyPair().getPrivate(), en_data);
            return new String(data);
        } catch (NullPointerException ex) {
            ex.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return null;
    }
}

+ 7 - 4
svr/svr-patient/src/main/resources/application.yml

@ -108,7 +108,8 @@ jw:
  smsUrl: http://svr-base:10020/sms_gateway/send
  smsUrl: http://svr-base:10020/sms_gateway/send
myFamily:
myFamily:
  qrCodeFailurTime: 2
  qrCodeFailurTime: 2
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
# 短信验证码发送的客户端标识,居民端
# 短信验证码发送的客户端标识,居民端
sms:
sms:
  clientId: EwC0iRSrcP
  clientId: EwC0iRSrcP
@ -139,7 +140,8 @@ spring:
    port: 6379 # Redis server port.
    port: 6379 # Redis server port.
fastDFS:
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
  fastdfs_file_url: http://172.19.103.54:80/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
# 短信验证码发送的客户端标识,居民端
# 短信验证码发送的客户端标识,居民端
sms:
sms:
  clientId: EwC0iRSrcP
  clientId: EwC0iRSrcP
@ -169,9 +171,10 @@ spring:
    port: 6379 # Redis server port.
    port: 6379 # Redis server port.
fastDFS:
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
  fastdfs_file_url: http://172.19.103.54:80/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段  # todo 待配置
# 短信验证码发送的客户端标识,居民端
# 短信验证码发送的客户端标识,居民端
sms:
sms:
  clientId: EwC0iRSrcP
  clientId: EwC0iRSrcP #todo 待配置
myFamily:
myFamily:
  qrCodeFailurTime: 2
  qrCodeFailurTime: 2