浏览代码

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

# Conflicts:
#	common/common-request-mapping/src/main/java/com/yihu/jw/rm/patient/PatientRequestMapping.java
chenyongxing 6 年之前
父节点
当前提交
c55adb46e4
共有 21 个文件被更改,包括 512 次插入41 次删除
  1. 2 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientMedicareCardDao.java
  2. 13 0
      business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientMedicardCardService.java
  3. 12 0
      business/base-service/src/main/java/com/yihu/jw/wechat/dao/JsapiTicketDao.java
  4. 32 0
      business/base-service/src/main/java/com/yihu/jw/wechat/service/WxAccessTokenService.java
  5. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  6. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageDO.java
  7. 71 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/JsApiTicket.java
  8. 33 12
      common/common-entity/src/main/java/com/yihu/jw/entity/myFamily/PatientApplyLog.java
  9. 9 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/patient/PatientRequestMapping.java
  10. 9 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/patient/signPackage/ServicePackageVO.java
  11. 11 1
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/EnvelopRestEndpoint.java
  12. 38 1
      svr/svr-patient/sql/sql
  13. 3 1
      svr/svr-patient/src/main/java/com/yihu/jw/patient/dao/myFamily/PatientApplyLogDao.java
  14. 3 0
      svr/svr-patient/src/main/java/com/yihu/jw/patient/dao/myFamily/PatientFamilyMemberDao.java
  15. 20 2
      svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/myFamily/MyFamilyEndpoint.java
  16. 140 0
      svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/wechat/WechatEndPoint.java
  17. 95 18
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/MyFamilyService.java
  18. 4 0
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/PatientApplyLogService.java
  19. 5 3
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/PatientFamilyMemberService.java
  20. 1 1
      svr/svr-patient/src/main/java/com/yihu/jw/patient/service/service_package/PackageService.java
  21. 1 1
      svr/svr-patient/src/main/resources/bootstrap.yml

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientMedicareCardDao.java

@ -17,4 +17,6 @@ public interface BasePatientMedicareCardDao extends PagingAndSortingRepository<P
    @Query("select id from PatientMedicareCardDO where patientCode = ?1")
    Set<Object> findIdListByPatientCode(String patientCode);
    PatientMedicareCardDO findByCode(String code);
}

+ 13 - 0
business/base-service/src/main/java/com/yihu/jw/patient/service/BasePatientMedicardCardService.java

@ -56,4 +56,17 @@ public class BasePatientMedicardCardService extends BaseJpaService<PatientMedica
        return basePatientMedicareCardDao.findIdListByPatientCode(patientCode);
    }
    /**
     * 根据居民标识获取关联卡id列表
     * @param patientCode
     * @return
     */
    public PatientMedicareCardDO findByCode(String patientCode) throws Exception{
        PatientMedicareCardDO patientMedicareCard = basePatientMedicareCardDao.findByCode(patientCode);
        if(patientMedicareCard==null){
            throw new Exception("no PatientMedicareCard entity");
        }
        return patientMedicareCard;
    }
}

+ 12 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/dao/JsapiTicketDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.wechat.dao;
import com.yihu.jw.entity.base.wx.JsApiTicket;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface JsapiTicketDao extends PagingAndSortingRepository<JsApiTicket, Long> {
    @Query("select p from JsApiTicket p where p.acc_id = ?1 order by p.add_timestamp desc")
    Iterable<JsApiTicket> findJsapiTicket(String accId);
}

+ 32 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/service/WxAccessTokenService.java

@ -1,10 +1,12 @@
package com.yihu.jw.wechat.service;
import com.yihu.jw.entity.base.wx.JsApiTicket;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.exception.ApiException;
import com.yihu.jw.exception.code.ExceptionCode;
import com.yihu.jw.rm.base.WechatRequestMapping;
import com.yihu.jw.wechat.dao.JsapiTicketDao;
import com.yihu.jw.wechat.dao.WechatDao;
import com.yihu.jw.wechat.dao.WxAccessTokenDao;
import com.yihu.mysql.query.BaseJpaService;
@ -33,6 +35,13 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessTokenDO, WxAcce
    @Autowired
    private WechatDao wechatDao;
    @Autowired
    private JsapiTicketDao jsapiTicketDao;
    public WxWechatDO getWxInfo(String wxId){
        return wechatDao.findOne(wxId);
    }
    /**
     * 根据原始id查找
     * @param appOriginId
@ -154,4 +163,27 @@ public class WxAccessTokenService extends BaseJpaService<WxAccessTokenDO, WxAcce
            return null;
        }
    }
    /**
     * 获取凭证
     * @param accId 微信原始id
     * @return
     */
    public Iterable<JsApiTicket> findJsapiTicket(String accId) {
        return jsapiTicketDao.findJsapiTicket(accId);
    }
    public void delJsapiTicket(JsApiTicket jsApiTicket) {
        jsapiTicketDao.delete(jsApiTicket);
    }
    /**
     * 添加JsapiTicket
     */
    public void addJsapiTicket(JsApiTicket jsApiTicket) {
        jsApiTicket.setAdd_timestamp(System.currentTimeMillis());
        jsApiTicket.setCzrq(new Date());
        jsapiTicketDao.save(jsApiTicket);
    }
}

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -192,7 +192,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
	private Date openidTime;
    /**
	 * 绑定电子社保卡主体(共济为操作人code)
	 * 绑定电子社保卡主体(共济为操作人code,医社保关联patient_medicare_card)
	 */
	private String principalCode;

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

@ -90,6 +90,7 @@ public class ServicePackageDO extends UuidIdentityEntity implements Serializable
    private String introduce;//服务介绍
    private String status;//审核状态(预留字段0待审核,1审核通过,2审核不通过)
    private Integer del;//是否有效(1有效,0失效)
    private Integer sort;//排序
    public String getProvinceCode() {
        return provinceCode;
@ -204,4 +205,12 @@ public class ServicePackageDO extends UuidIdentityEntity implements Serializable
    public void setDel(Integer del) {
        this.del = del;
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
}

+ 71 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/wx/JsApiTicket.java

@ -0,0 +1,71 @@
package com.yihu.jw.entity.base.wx;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IntegerIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * JavaScript API访问所需要的凭据
 */
@Entity
@Table(name = "wx_jsapi_ticket")
public class JsApiTicket extends IntegerIdentityEntity {
    private static final long serialVersionUID = -3297644428262254694L;
    private String jsapi_ticket;
    private String acc_id;;
    private Long add_timestamp;
    private Long expires_in;
    private Date czrq;
    public String getAcc_id() {
        return acc_id;
    }
    public void setAcc_id(String acc_id) {
        this.acc_id = acc_id;
    }
    public String getJsapi_ticket() {
        return jsapi_ticket;
    }
    public void setJsapi_ticket(String jsapi_ticket) {
        this.jsapi_ticket = jsapi_ticket;
    }
    public Long getAdd_timestamp() {
        return add_timestamp;
    }
    public void setAdd_timestamp(Long add_timestamp) {
        this.add_timestamp = add_timestamp;
    }
    public Long getExpires_in() {
        return expires_in;
    }
    public void setExpires_in(Long expires_in) {
        this.expires_in = expires_in;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCzrq() {
        return czrq;
    }
    public void setCzrq(Date czrq) {
        this.czrq = czrq;
    }
}

+ 33 - 12
common/common-entity/src/main/java/com/yihu/jw/entity/myFamily/PatientApplyLog.java

@ -15,8 +15,8 @@ import java.util.Date;
@Table(name = "patient_apply_for_log")
public class PatientApplyLog extends IntegerIdentityEntity {
    private String patientFamilyMemberName;//家庭成员名称
    private String patienyFamilyMemberCode;//家庭成员code
    private String familyMemberName;//家庭成员名称
    private String familyMemberCode;//家庭成员code
    private String qrCode;//二维码地址
    private Date failureTime;//失效时间
    private Integer status;//1、添加家人(默认),2、邀请登录,3、通过,4、拒绝
@ -25,23 +25,26 @@ public class PatientApplyLog extends IntegerIdentityEntity {
    private String createUser;//申请人
    private String createUserName;//申请人姓名
    private Integer remindType;//提醒方式(1、打电话,2、发短信,3、微信)
    private Date confirmTime;//确认时间
    private Integer familyBindRole;//1配偶,2父亲,3母亲,4公公,5婆婆,6岳父,7岳母,8女婿,9儿媳,10子女
    @Column(name = "patient_family_member_name")
    public String getPatientFamilyMemberName() {
        return patientFamilyMemberName;
    @Column(name = "family_member_name")
    public String getFamilyMemberName() {
        return familyMemberName;
    }
    public void setPatientFamilyMemberName(String patientFamilyMemberName) {
        this.patientFamilyMemberName = patientFamilyMemberName;
    public void setFamilyMemberName(String familyMemberName) {
        this.familyMemberName = familyMemberName;
    }
    @Column(name = "patient_family_member_code")
    public String getPatienyFamilyMemberCode() {
        return patienyFamilyMemberCode;
    @Column(name = "family_member_code")
    public String getFamilyMemberCode() {
        return familyMemberCode;
    }
    public void setPatienyFamilyMemberCode(String patienyFamilyMemberCode) {
        this.patienyFamilyMemberCode = patienyFamilyMemberCode;
    public void setFamilyMemberCode(String familyMemberCode) {
        this.familyMemberCode = familyMemberCode;
    }
    @Column(name = "qr_code")
@ -117,4 +120,22 @@ public class PatientApplyLog extends IntegerIdentityEntity {
    public void setRemindType(Integer remindType) {
        this.remindType = remindType;
    }
    @Column(name = "confirm_time")
    public Date getConfirmTime() {
        return confirmTime;
    }
    public void setConfirmTime(Date confirmTime) {
        this.confirmTime = confirmTime;
    }
    @Column(name = "family_bind_role")
    public Integer getFamilyBindRole() {
        return familyBindRole;
    }
    public void setFamilyBindRole(Integer familyBindRole) {
        this.familyBindRole = familyBindRole;
    }
}

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

@ -17,6 +17,15 @@ public class PatientRequestMapping {
        public static final String LIST = "/list";
    }
    public abstract static class Wechat extends Basic{
        public static final String wxBase =  "/wxBase";
        public static final String api_success ="success";
        public static final String api_error ="error";
        public static final String getSign ="/getSign";
    }
    /**
     * signPackage
     */

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

@ -10,6 +10,7 @@ import java.util.List;
 */
public class ServicePackageVO {
    private String id;
    private String provinceCode;
    private String provinceName;
    private String cityCode;
@ -27,6 +28,14 @@ public class ServicePackageVO {
    private List<SerivePackageItemVO> items;//服务项描述
    public String getId() {
        return id;
    }
    public void setId(String id) {
        this.id = id;
    }
    public String getProvinceCode() {
        return provinceCode;
    }

+ 11 - 1
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/web/endpoint/EnvelopRestEndpoint.java

@ -4,7 +4,6 @@ package com.yihu.jw.restmodel.web.endpoint;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.restmodel.web.*;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -353,6 +352,17 @@ public abstract class EnvelopRestEndpoint {
            return null;
        }
    }
    public String getUID(String patient) {
        try {
            if(StringUtils.isEmpty(patient)){
                patient=this.getUID();
            }
            return patient;
        } catch (Exception e) {
            return null;
        }
    }
    public String getUNAME(){
        try {

+ 38 - 1
svr/svr-patient/sql/sql

@ -61,4 +61,41 @@ create table `account_appeal`
  `img` varchar(1000) not null COMMENT '身份证正反面照片,存地址,逗号分割',
  primary key (id)
)
  ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='账号申诉';
  ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='账号申诉';
-- 我的家人
DROP TABLE IF EXISTS `patient_apply_for_log`;
CREATE TABLE `patient_apply_for_log` (
  `id` int(11) NOT NULL,
  `family_member_name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '家庭成员',
  `family_member_code` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '家庭成员code',
  `qr_code` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
  `failure_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '失效时间',
  `status` int(2) DEFAULT '1' COMMENT '1、添加家人(默认),2、邀请登录,3、通过,4、拒绝',
  `create_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '申请时间',
  `create_user` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '申请人',
  `create_user_name` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '申请人姓名',
  `del` int(2) DEFAULT NULL COMMENT '删除标志(1正常,0删除)申请人主动终止申请',
  `remind_type` int(1) DEFAULT NULL COMMENT '提醒方式(1、打电话,2、发短信,3、微信)',
  `confirm_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '绑定确认时间',
  `family_bind_role` int(2) DEFAULT NULL COMMENT '1配偶,2父亲,3母亲,4公公,5婆婆,6岳父,7岳母,8女婿,9儿媳,10子女',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='绑定家人申请表';
DROP TABLE IF EXISTS `base_patient_family_member`;
CREATE TABLE `base_patient_family_member` (
  `id` varchar(50) NOT NULL COMMENT '主键',
  `patient` varchar(50) DEFAULT NULL COMMENT '居民code',
  `family_member` varchar(50) DEFAULT NULL COMMENT '家庭成员code',
  `family_relation` int(2) DEFAULT NULL COMMENT '1"配偶",2"父亲",3"母亲",4"公公",5"婆婆",6"岳父",7"岳母",8"女婿",9"儿媳",10"子女"',
  `is_authorize` int(1) DEFAULT NULL COMMENT '是否授权0:未授权,1:已授权,默认为1',
  `del` int(1) DEFAULT NULL COMMENT '删除标志(1正常,0删除)',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '操作日期',
  `update_user` varchar(50) DEFAULT NULL,
  `update_user_name` varchar(50) DEFAULT NULL,
  `create_time` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
  `create_user` varchar(50) DEFAULT NULL,
  `create_user_name` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `fmaily_member_patient` (`patient`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='居民家庭成员表';

+ 3 - 1
svr/svr-patient/src/main/java/com/yihu/jw/patient/dao/myFamily/PatientApplyLogDao.java

@ -13,6 +13,8 @@ public interface PatientApplyLogDao extends PagingAndSortingRepository<PatientAp
    @Modifying
    @Query("update PatientApplyLog t set t.remindType = ?1 where t.id=?2 ")
    int updateRemindTypeById(Integer remindType, Integer patientApplyLogId);
    int updateRemindTypeById(Integer remindType, Integer id);
    PatientApplyLog findById(Integer id);
}

+ 3 - 0
svr/svr-patient/src/main/java/com/yihu/jw/patient/dao/myFamily/PatientFamilyMemberDao.java

@ -26,4 +26,7 @@ public interface PatientFamilyMemberDao extends PagingAndSortingRepository<BaseP
    @Query("select m from BasePatientFamilyMemberDO m where m.del=1 and m.familyMember=?1 and m.familyRelation in (?2,?3)")
    List<BasePatientFamilyMemberDO> getByFamilyMemberAndFamilyRelation(String familyMember,Integer familyRelation1,Integer familyRelation2);
    @Query("select m from BasePatientFamilyMemberDO m where m.del=1 and (m.familyMember=?1 or m.patient=?1)")
    List<BasePatientFamilyMemberDO> getByPatientAndFamilyMember(String patient);
}

+ 20 - 2
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/myFamily/MyFamilyEndpoint.java

@ -6,9 +6,11 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.patient.PatientRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@ -27,9 +29,25 @@ public class MyFamilyEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = PatientRequestMapping.MyFamily.getMyFamilyBindingRole)
    @ApiOperation(value = "获取我的家人")
    public Envelop getMyFamilyBindingRole() throws Exception {
    public Envelop getMyFamilyBindingRole(
            @ApiParam(name = "patient", value = "居民code", required = false)
            @RequestParam(value = "patient",required = false) String patient) throws Exception {
        try{
            List<Map<String,Object>> basePatients = myFamilyService.getMyFamilyBindingRole(getUID());
            List<Map<String,Object>> basePatients = myFamilyService.getMyFamilyBindingRole(getUID(patient));
            return success(basePatients);
        }catch (Exception e){
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
    @GetMapping(value = PatientRequestMapping.MyFamily.getBindingList)
    @ApiOperation(value = "签约界面已绑定家人信息")
    public Envelop getBindingList(
            @ApiParam(name = "patient", value = "居民code", required = false)
            @RequestParam(value = "patient",required = false) String patient) throws Exception {
        try{
            List<Map<String,Object>> basePatients = myFamilyService.getBindingList(getUID(patient));
            return success(basePatients);
        }catch (Exception e){
            e.printStackTrace();

+ 140 - 0
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/wechat/WechatEndPoint.java

@ -0,0 +1,140 @@
package com.yihu.jw.patient.endpoint.wechat;
import com.yihu.jw.entity.base.wx.JsApiTicket;
import com.yihu.jw.entity.base.wx.WxWechatDO;
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.rm.patient.PatientRequestMapping;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import io.swagger.annotations.Api;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.security.MessageDigest;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
 * Created by Trick on 2018/12/3.
 */
@Controller
@RequestMapping(value = PatientRequestMapping.Wechat.wxBase)
@Api(value = "微信相关操作", description = "微信相关操作", tags = {"居民端 - 微信相关操作"})
public class WechatEndPoint extends EnvelopRestEndpoint {
    private static Logger logger = LoggerFactory.getLogger(WechatEndPoint.class);
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    /**
     * 获取签名signature
     *
     * @param pageUrl 需要签名的页面全地址(?后的也需要除了#后的不需要)
     * @return
     */
    @RequestMapping(value = "getSign", method = RequestMethod.POST)
    @ResponseBody
    public Envelop getSign(String pageUrl,String wxId) {
        String ticket = getJsapi_ticketByToken(wxId);
            Map<Object, Object> map = new HashMap<Object, Object>();
            if (ticket != null) {
                String noncestr = UUID.randomUUID().toString();
                long timestamp = System.currentTimeMillis() / 1000;
                String url = pageUrl;
                String str = "jsapi_ticket=" + ticket + "&noncestr=" + noncestr + "&timestamp=" + timestamp + "&url=" + url;
                // sha1加密
                String signature = SHA1(str);
                map.put("noncestr", noncestr);
                map.put("timestamp", timestamp);
                map.put("signature", signature);
                return success(PatientRequestMapping.Wechat.api_success,map);
            }
        return failed(PatientRequestMapping.Wechat.api_error);
    }
    /**
     * 获取微信的jsapi_ticket
     *
     * @return
     */
    public String getJsapi_ticketByToken(String wxId) {
        try {
            WxWechatDO wxWechat = wxAccessTokenService.getWxInfo(wxId);
            Iterable<JsApiTicket> jsapiTickets = wxAccessTokenService.findJsapiTicket(wxWechat.getAppOriginId());
            if (jsapiTickets != null) {
                for (JsApiTicket jsApiTicket : jsapiTickets) {
                    if ((System.currentTimeMillis() - jsApiTicket.getAdd_timestamp()) < (jsApiTicket.getExpires_in() * 1000)) {
                        return jsApiTicket.getJsapi_ticket();
                    } else {
                        wxAccessTokenService.delJsapiTicket(jsApiTicket);
                        break;
                    }
                }
            }
            String token = wxAccessTokenService.getWxAccessTokenById(wxId).getAccessToken();
            if (token != null) {
                String token_url = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
                String params = "access_token=" + token + "&type=jsapi";
                String result = HttpUtil.sendGet(token_url, params);
                JSONObject json = new JSONObject(result);
                if (json.has("ticket")) {
                    String ticket = json.get("ticket").toString();
                    String expires_in = json.get("expires_in").toString();
                    JsApiTicket newJsApiTicket = new JsApiTicket();
                    newJsApiTicket.setJsapi_ticket(ticket);
                    newJsApiTicket.setExpires_in(Long.parseLong(expires_in));
                    newJsApiTicket.setAcc_id(wxWechat.getAppOriginId());
                    newJsApiTicket.setAcc_id(wxWechat.getAppOriginId());
                    wxAccessTokenService.addJsapiTicket(newJsApiTicket);
                    return ticket;
                } else {
                    return null;
                }
            } else {
                return null;
            }
        } catch (Exception e) {
            logger.error(e.getMessage());
            return null;
        }
    }
    /**
     * @description: SHA、SHA1加密 @parameter: str:待加密字符串 @return: 加密串
     **/
    public String SHA1(String str) {
        try {
            MessageDigest digest = java.security.MessageDigest.getInstance("SHA-1"); // 如果是SHA加密只需要将"SHA-1"改成"SHA"即可
            digest.update(str.getBytes());
            byte messageDigest[] = digest.digest();
            // Create Hex String
            StringBuffer hexStr = new StringBuffer();
            // 字节数组转换为 十六进制 数
            for (int i = 0; i < messageDigest.length; i++) {
                String shaHex = Integer.toHexString(messageDigest[i] & 0xFF);
                if (shaHex.length() < 2) {
                    hexStr.append(0);
                }
                hexStr.append(shaHex);
            }
            return hexStr.toString();
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return null;
    }
}

+ 95 - 18
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/MyFamilyService.java

@ -4,11 +4,14 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.message.BaseMessageDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.myFamily.PatientApplyLog;
import com.yihu.jw.message.service.MessageService;
import com.yihu.jw.patient.service.BasePatientService;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
import com.yihu.jw.patient.service.personal_Info.PatientService;
import com.yihu.jw.wechat.service.WeChatQrcodeService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.LinkedMap;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -27,7 +30,7 @@ public class MyFamilyService {
    @Autowired
    private PatientFamilyMemberService patientFamilyMemberService;
    @Autowired
    private BasePatientService patientService;
    private PatientService patientService;
    @Autowired
    private MessageService messageService;
    @Value("${myFamily.qrCodeFailurTime}")
@ -36,6 +39,8 @@ public class MyFamilyService {
    private WeChatQrcodeService weChatQrcodeService;
    @Autowired
    private PatientApplyLogService patientApplyLogService;
    @Autowired
    private BasePatientMedicardCardService  patientMedicareCardService;
    public List<Map<String,Object>> getMyFamilyBindingRole(String patient) throws Exception{
@ -44,9 +49,9 @@ public class MyFamilyService {
        BasePatientDO patientDO = patientService.findByIdAndDel(patient);
        Integer sex = patientDO.getSex();
        LinkedList<String> role = new LinkedList<>(Arrays.asList("配偶","父亲","母亲","公公","婆婆","岳父","岳母","女婿","儿媳","子女"));
        Map<String,Map<String,Object>> map = new HashedMap();
        Map<String,Map<String,Object>> map = new LinkedMap();
        for(int i =0;i<role.size();i++){
            Map<String,Object> m = new HashedMap();
            Map<String,Object> m = new LinkedMap();
            m.put("name",role.get(i));
            m.put("isBinding",0);
            m.put("key",(i+1));
@ -77,13 +82,9 @@ public class MyFamilyService {
        if(childrenList.size()==2){
            map.get("10").put("isBinding",1);
        }
        List<Map<String,Object>> resultList = new ArrayList();
        Iterator iter = map.entrySet().iterator(); // 获得map的Iterator
        while (iter.hasNext()) {
            String key = iter.next().toString();
            resultList.add(map.get(key));
        }
        return resultList;
        Collection<Map<String,Object>> valueCollection = map.values();
        List<Map<String,Object>> valueList = new LinkedList<>(valueCollection);
        return valueList;
    }
    /**
@ -97,7 +98,7 @@ public class MyFamilyService {
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public PatientApplyLog bindingMyFamily(HttpServletRequest request,String wechatId, String saasId, String patient, String familyMobile, Integer platform) throws Exception{
    public PatientApplyLog bindingMyFamily(HttpServletRequest request,String wechatId, String saasId, String patient, String familyMobile, Integer platform,Integer familyBindRole) throws Exception{
        BasePatientDO patientDO = patientService.findByIdAndDel(patient);
        //1、检验手机号码是否有存在账号,
@ -106,8 +107,8 @@ public class MyFamilyService {
        BasePatientDO familyPatient = null;
        //3、生成申请绑定的记录,二维码
        PatientApplyLog patientApplyLog = createFamilyQrCode(request,familyPatient,wechatId,patient);
        //3、生成申请绑定的记录,申请绑定二维码
        PatientApplyLog patientApplyLog = createFamilyQrCode(request,familyPatient,wechatId,patient,familyBindRole);
        //4、发送绑定家人的系统消息
        BaseMessageDO messageDO = new BaseMessageDO();
        messageDO.setSaasId(saasId);
@ -141,11 +142,11 @@ public class MyFamilyService {
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public PatientApplyLog createFamilyQrCode(HttpServletRequest request,BasePatientDO familyPatient,String wechatId, String patient) throws Exception{
    public PatientApplyLog createFamilyQrCode(HttpServletRequest request,BasePatientDO familyPatient,String wechatId, String patient,Integer familyBindRole) throws Exception{
        BasePatientDO patientDO = patientService.findByIdAndDel(patient);
        PatientApplyLog patientApplyLog = new PatientApplyLog();
        patientApplyLog.setPatientFamilyMemberName(familyPatient.getName());
        patientApplyLog.setPatienyFamilyMemberCode(familyPatient.getId());
        patientApplyLog.setFamilyMemberName(familyPatient.getName());
        patientApplyLog.setFamilyMemberCode(familyPatient.getId());
        String scene ="family_"+familyPatient.getId()+"_"+familyPatient.getId();
        String qrCode = weChatQrcodeService.getQrcode(request,wechatId, scene);
        if(StringUtils.isEmpty(qrCode)){
@ -159,6 +160,7 @@ public class MyFamilyService {
        patientApplyLog.setCreateTime(new Date());
        patientApplyLog.setCreateUser(familyPatient.getId());
        patientApplyLog.setCreateUserName(patientDO.getName());
        patientApplyLog.setFamilyBindRole(familyBindRole);
        patientApplyLogService.save(patientApplyLog);
        return patientApplyLog;
    }
@ -177,7 +179,14 @@ public class MyFamilyService {
        }
    }
    public void confirmApply(Integer messageId,Integer patientApplyLogId){
    /**
     * 家人确认绑定
     * @param messageId
     * @param patientApplyLogId
     * @param status 1、添加家人(默认),2、邀请登录,3、通过,4、拒绝
     */
    @Transactional(rollbackFor = Exception.class)
    public void confirmApply(Integer messageId,Integer patientApplyLogId,Integer status,Integer isAuthorize){
        BaseMessageDO messageDO = null;
        if(messageId!=null){
@ -192,9 +201,77 @@ public class MyFamilyService {
            messageService.save(messageDO);
        }
        PatientApplyLog patientApplyLog = patientApplyLogService.findById(patientApplyLogId);
        patientApplyLog.setStatus(status);
        patientApplyLog.setConfirmTime(new Date());
        patientApplyLogService.save(patientApplyLog);
        if(status==3){
            BasePatientFamilyMemberDO patientFamilyMember = new BasePatientFamilyMemberDO();
            patientFamilyMember.setPatient(patientApplyLog.getCreateUser());
            patientFamilyMember.setFamilyMember(patientApplyLog.getFamilyMemberCode());
            patientFamilyMember.setFamilyRelation(patientApplyLog.getFamilyBindRole());
            patientFamilyMember.setIsAuthorize(isAuthorize);
            patientFamilyMember.setDel(1);
            patientFamilyMemberService.save(patientFamilyMember);
        }
    }
    /**
     * 签约界面已绑定家人列表
     * @param patient
     * @return
     * @throws Exception
     */
    public List<Map<String,Object>> getBindingList(String patient) throws Exception{
        List<Map<String,Object>> resultList = new LinkedList<>();
        List<BasePatientFamilyMemberDO> list = patientFamilyMemberService.getByPatientAndFamilyMember(patient);
        String patientTemp = null;
        //自己
        BasePatientDO basePatientDO = patientService.findByIdAndDel(patient);
        Map<String,Object> map = new HashedMap();
        map.put("appellation","自己");//别称
        map.put("patientCode",patient);//居民code
        map.put("name",basePatientDO.getName());//姓名
        map.put("cardTypeName","身份证");
        map.put("idcard",basePatientDO.getIdcard());//身份证
        if(!StringUtils.isEmpty(basePatientDO.getPrincipalCode())){
            PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode());
            map.put("principalNum",patientMedicareCard.getMedicareNumber());//社保卡号
        }else{
            map.put("principalNum","");//社保卡号
        }
        map.put("mobile",basePatientDO.getMobile());//手机号码
        resultList.add(map);
        //家人
        for(BasePatientFamilyMemberDO one:list){
            Map<String,Object> map2 = new HashedMap();
            if(patient.equals(one.getPatient())){
                patientTemp = one.getPatient();
            }else{
                patientTemp = one.getFamilyMember();
            }
            basePatientDO = patientService.findByIdAndDel(patientTemp);
            map2.put("appellation",basePatientDO.getName());//别称
            map2.put("patientCode",patientTemp);//居民code
            map2.put("name",basePatientDO.getName());//姓名
            map2.put("cardTypeName","身份证");
            map2.put("idcard",basePatientDO.getIdcard());//身份证
            if(!StringUtils.isEmpty(basePatientDO.getPrincipalCode())){
                PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode());
                map2.put("principalNum",patientMedicareCard.getMedicareNumber());//社保卡号
            }else{
                map2.put("principalNum","");//社保卡号
            }
            map2.put("mobile",basePatientDO.getMobile());//手机号码
            resultList.add(map2);
        }
        return resultList;
    }
    /**
     * 家庭关系转换

+ 4 - 0
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/PatientApplyLogService.java

@ -24,4 +24,8 @@ public class PatientApplyLogService extends BaseJpaService<PatientApplyLog, Pati
    public int updateRemindTypeById(Integer remindType, Integer patientApplyLogId){
        return  patientApplyLogDao.updateRemindTypeById(remindType,patientApplyLogId);
    }
    public PatientApplyLog findById(Integer id){
        return  patientApplyLogDao.findById(id);
    }
}

+ 5 - 3
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/PatientFamilyMemberService.java

@ -1,8 +1,6 @@
package com.yihu.jw.patient.service.myFamily;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.myFamily.PatientFamilyMemberDao;
import com.yihu.mysql.query.BaseJpaService;
import org.springframework.beans.factory.annotation.Autowired;
@ -14,7 +12,7 @@ import java.util.List;
 * @author liuwenbin on 2018/11/27.
 */
@Service
public class PatientFamilyMemberService extends BaseJpaService<BasePatientDO, BasePatientDao> {
public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamilyMemberDO, PatientFamilyMemberDao> {
    @Autowired
    private PatientFamilyMemberDao patientFamilyMemberDao;
@ -50,4 +48,8 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientDO, Ba
        return list;
    }
    public List<BasePatientFamilyMemberDO> getByPatientAndFamilyMember(String patient){
        return patientFamilyMemberDao.getByPatientAndFamilyMember(patient);
    }
}

+ 1 - 1
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/service_package/PackageService.java

@ -100,7 +100,7 @@ public class PackageService {
            sql +=  " ADN l.label_code='"+labelCode+"'" +
                    " AND l.label_type='"+labelType+"' ";
        }
        sql +=  " LIMIT " + (page - 1) * size + "," + size + "";
        sql +=  "ORDER BY p.sort ASC LIMIT " + (page - 1) * size + "," + size + "";
        List<ServicePackageVO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(ServicePackageVO.class));
        return MixEnvelop.getSuccessListWithPage(PatientRequestMapping.SignPackage.api_success, list, page, size, count);

+ 1 - 1
svr/svr-patient/src/main/resources/bootstrap.yml

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