Browse Source

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

chenyongxing 6 years ago
parent
commit
a14ef0be80

+ 2 - 5
business/base-service/src/main/java/com/yihu/jw/message/service/MessageService.java

@ -2,7 +2,6 @@ package com.yihu.jw.message.service;
import com.yihu.jw.entity.base.message.BaseMessageDO;
import com.yihu.jw.message.dao.MessageDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
@ -10,7 +9,6 @@ import org.springframework.data.domain.Sort;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
@ -104,9 +102,8 @@ public class MessageService extends BaseJpaService<BaseMessageDO, MessageDao> {
    }
    public List<Map<String, Object>> applyMessageList(String patient, Date failureTime, String msgTypeCode){
        String failureTimeStr = DateUtil.dateToStr(failureTime,"yyyy-MM-dd HH:mm:ss");
        String sql = "select m.* from base_message m join patient_apply_for_log l on m.relation_data=l.id where m.failure_Time>='"+failureTimeStr+"' and m.msgTypeCode='"+msgTypeCode+"'";
    public List<Map<String, Object>> applyMessageList(String patient, String msgTypeCode){
        String sql = "select m.* from base_message m join patient_apply_for_log l on m.relation_data=l.id where  m.msg_type_code='"+msgTypeCode+"' and m.receiver='"+patient+"'";
        return jdbcTemplate.queryForList(sql);
//        return messageDao.applyMessageList(patient,failureTime,msgTypeCode);
    }

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

@ -19,4 +19,6 @@ public interface BasePatientMedicareCardDao extends PagingAndSortingRepository<P
    Set<Object> findIdListByPatientCode(String patientCode);
    PatientMedicareCardDO findByCode(String code);
    PatientMedicareCardDO findByTypeAndPatientCodeAndDel(String Type,String patientCode,String del);
}

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

@ -70,4 +70,12 @@ public class BasePatientMedicardCardService<T, R extends CrudRepository> extends
        return patientMedicareCard;
    }
    public PatientMedicareCardDO findByTypeAndPatientCodeAndDel(String Type,String patientCode,String del)throws Exception{
        PatientMedicareCardDO patientMedicareCardDO = basePatientMedicareCardDao.findByTypeAndPatientCodeAndDel(Type,patientCode,del);
        if(patientMedicareCardDO==null){
            throw new Exception("no PatientMedicareCard entity");
        }
        return patientMedicareCardDO;
    }
}

+ 22 - 0
business/base-service/src/main/java/com/yihu/jw/wechat/service/WeChatQrcodeService.java

@ -95,6 +95,28 @@ public class WeChatQrcodeService {
        return "";
    }
    public String getQrcode( String wechatId, String scene) throws Exception{
        String token_url = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" + wxAccessTokenService.getWxAccessTokenById(wechatId).getAccessToken();
        String params = "{\"action_name\": \"QR_LIMIT_STR_SCENE\", \"action_info\": {\"scene\": {\"scene_str\": \"" + scene + "\"}}}";
        //服务号必须是通过腾讯认证,每年是300元,如果没有认证而导致的错误提示,那就去认证
        //微信登录提示48001,{"errcode":48001,"errmsg":"api unauthorized, hints: [ req_id: 1QoCla0699ns81 ]"}
        String result = HttpUtil.sendPost(token_url, params);
        if (!StringUtils.isEmpty(result)) {
            JSONObject json = new JSONObject(result);
            if (json.has("ticket")) {
                // 请求输入流
                InputStream inputStream = null;
                // 下载二维码图片
                String  urlGet = "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket="
                        + URLEncoder.encode(json.get("ticket").toString(), "UTF-8");
                return urlGet;
            }
        }
        return "";
    }
//    public void write(InputStream inputStream)throws Exception{
//        String file = "D:\\workspace\\file\\test.png";
//        // 保存文件

+ 0 - 27
common/common-entity/src/main/java/com/yihu/jw/entity/base/message/BaseMessageDO.java

@ -113,16 +113,6 @@ public class BaseMessageDO extends IntegerIdentityEntity {
     */
    private String relationData;
    /**
     * 消息存续类型(1、时效性,2、非时效性)
     */
    private Integer type;
    /**
     * 消息失效时间
     */
    private Date failureTime;
    @Column(name = "receiver")
    public String getReceiver() {
        return receiver;
@ -294,21 +284,4 @@ public class BaseMessageDO extends IntegerIdentityEntity {
        this.relationData = relationData;
    }
    @Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "failure_time")
    public Date getFailureTime() {
        return failureTime;
    }
    public void setFailureTime(Date failureTime) {
        this.failureTime = failureTime;
    }
}

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

@ -53,10 +53,13 @@ public class PatientRequestMapping {
        public static final String bindingMyFamily  = "/bindingMyFamily";
        public static final String createFamilyQrCode  = "/createFamilyQrCode";
        public static final String remindMyFamily  = "/remindMyFamily";
        public static final String scanQRcodeConfirmApply  = "/scanQRcodeConfirmApply";
        public static final String confirmApply  = "/confirmApply";
        public static final String applyMessageList  = "/applyMessageList";
        public static final String cancelApply  = "/cancelApply";
        public static final String myFamilyBindList  = "/myFamilyBindList";
        public static final String scanQRcode  = "/scanQRcode";
        public static final String messageToBinding  = "/messageToBinding";
    }

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

@ -1,12 +1,13 @@
package com.yihu.jw.patient.dao.myFamily;
import com.sun.tools.javac.util.List;
import com.yihu.jw.entity.myFamily.PatientApplyLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
/**
 * @author liuwenbin on 2018/11/30.
 */
@ -22,4 +23,6 @@ public interface PatientApplyLogDao extends PagingAndSortingRepository<PatientAp
    @Query("update PatientApplyLog t set t.status = ?1 where t.id=?2 ")
    int updateStatusById(Integer status,Integer id);
    @Query("select l from PatientApplyLog l where l.createUser=?1 and l.familyMemberCode=?2 and l.del=1 and l.status in(1,2) and l.failureTime<?3 and l.familyBindRole=?4")
    PatientApplyLog findValidOne(String createUser,String familyMemberCode,Date failureTime,Integer familyBindRole);
}

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

@ -27,6 +27,6 @@ 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)")
    @Query("select m from BasePatientFamilyMemberDO m where m.del=1 and m.patient=?1")
    List<BasePatientFamilyMemberDO> getByPatientAndFamilyMember(String patient);
}

+ 60 - 15
svr/svr-patient/src/main/java/com/yihu/jw/patient/endpoint/myFamily/MyFamilyEndpoint.java

@ -1,7 +1,5 @@
package com.yihu.jw.patient.endpoint.myFamily;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.myFamily.PatientApplyLog;
import com.yihu.jw.patient.service.myFamily.MyFamilyService;
import com.yihu.jw.patient.service.personal_Info.PatientService;
import com.yihu.jw.restmodel.web.Envelop;
@ -13,7 +11,6 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
@ -65,14 +62,12 @@ public class MyFamilyEndpoint extends EnvelopRestEndpoint {
    public Envelop bindingMyFamily(
            @ApiParam(name = "patient", value = "居民code", required = false)
            @RequestParam(value = "patient",required = false) String patient,
            @ApiParam(name = "wechatId", value = "wechatId", required = true)
            @RequestParam(value = "wechatId",required = true) String wechatId,
            @ApiParam(name = "familyMobile", value = "家人的手机号码", required = true)
            @RequestParam(value = "familyMobile",required = true) String familyMobile,
            @ApiParam(name = "familyBindRole", value = "家庭关系关系 1配偶 2父亲 3母亲 4公公 5婆婆 6岳父 7岳母 8子女", required = true)
            @RequestParam(value = "familyBindRole",required = true) Integer familyBindRole,HttpServletRequest request) throws Exception {
            @RequestParam(value = "familyBindRole",required = true) Integer familyBindRole) throws Exception {
        try{
            PatientApplyLog patientApplyLog = myFamilyService.bindingMyFamily(request,wechatId, getUID(patient), familyMobile, 1,familyBindRole);
            Map<String,Object> patientApplyLog = myFamilyService.bindingMyFamily( getUID(patient), familyMobile, 1,familyBindRole);
            return success(patientApplyLog);
        }catch (Exception e){
            e.printStackTrace();
@ -85,16 +80,13 @@ public class MyFamilyEndpoint extends EnvelopRestEndpoint {
    public Envelop createFamilyQrCode(
            @ApiParam(name = "patient", value = "居民code", required = false)
            @RequestParam(value = "patient",required = false) String patient,
            @ApiParam(name = "familyMobile", value = "家人的手机号码", required = true)
            @RequestParam(value = "familyMobile",required = true) String familyMobile,
            @ApiParam(name = "wechatId", value = "wechatId", required = true)
            @RequestParam(value = "wechatId",required = true) String wechatId,
            @ApiParam(name = "familyBindRole", value = "家庭关系关系 1配偶 2父亲 3母亲 4公公 5婆婆 6岳父 7岳母 8子女", required = true)
            @RequestParam(value = "familyBindRole",required = true) Integer familyBindRole,HttpServletRequest request) throws Exception {
            @RequestParam(value = "familyBindRole",required = true) Integer familyBindRole) throws Exception {
        try{
            BasePatientDO familyPatient = patientService.findByMobileAndDel(familyMobile);
            PatientApplyLog patientApplyLog = myFamilyService.createFamilyQrCode(request,familyPatient,wechatId, getUID(patient),familyBindRole);
            return success(patientApplyLog.getQrCode());
            Map<String,Object> resultMap = myFamilyService.createFamilyQrCode(wechatId, getUID(patient),familyBindRole);
            return success(resultMap);
        }catch (Exception e){
            e.printStackTrace();
            return failed(e.getMessage());
@ -118,7 +110,7 @@ public class MyFamilyEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = PatientRequestMapping.MyFamily.applyMessageList)
    @ApiOperation(value = "有效的申请绑定消息")
    @ApiOperation(value = "家人登录后,弹出绑定邀请窗口")
    public Envelop applyMessageList(
            @ApiParam(name = "patient", value = "居民code", required = false)
            @RequestParam(value = "patient",required = false) String patient) throws Exception {
@ -141,7 +133,28 @@ public class MyFamilyEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "isAuthorize", value = "0:未授权,1:已授权", required = true)
            @RequestParam(value = "isAuthorize",required = true) Integer isAuthorize) throws Exception {
        try{
            myFamilyService.confirmApply(patientApplyLogId,status,isAuthorize);
            return success(myFamilyService.confirmApply(patientApplyLogId,status,isAuthorize));
        }catch (Exception e){
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
    @PostMapping(value = PatientRequestMapping.MyFamily.scanQRcodeConfirmApply)
    @ApiOperation(value = "扫码绑定确认")
    public Envelop scanQRcodeConfirmApply(
            @ApiParam(name = "applyPatient", value = "申请人code", required = true)
            @RequestParam(value = "applyPatient",required = true) String applyPatient,
            @ApiParam(name = "applyPatient", value = "家人code", required = false)
            @RequestParam(value = "familyPatient",required = false) String familyPatient,
            @ApiParam(name = "familyBindRole", value = "家庭关系关系 1配偶 2父亲 3母亲 4公公 5婆婆 6岳父 7岳母 8子女", required = true)
            @RequestParam(value = "familyBindRole",required = true) Integer familyBindRole,
            @ApiParam(name = "isAuthorize", value = "0:未授权,1:已授权", required = true)
            @RequestParam(value = "isAuthorize",required = true) Integer isAuthorize,
            @ApiParam(name = "status", value = "3、通过,4、拒绝", required = true)
            @RequestParam(value = "status",required = true) Integer status) throws Exception {
        try{
            myFamilyService.scanQRcodeConfirmApply(status,applyPatient,getUID(familyPatient),familyBindRole,isAuthorize);
            return success();
        }catch (Exception e){
            e.printStackTrace();
@ -176,4 +189,36 @@ public class MyFamilyEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = PatientRequestMapping.MyFamily.scanQRcode)
    @ApiOperation(value = "扫码到确认绑定页面")
    public Envelop scanQRcode(
            @ApiParam(name = "applyPatient", value = "申请人code", required = true)
            @RequestParam(value = "applyPatient",required = true) String applyPatient,
            @ApiParam(name = "familyPatient", value = "家人code", required = false)
            @RequestParam(value = "familyPatient",required = false) String familyPatient,
            @ApiParam(name = "familyBindRole", value = "家庭关系关系 1配偶 2父亲 3母亲 4公公 5婆婆 6岳父 7岳母 8子女", required = true)
            @RequestParam(value = "familyBindRole",required = true) Integer familyBindRole) throws Exception {
        try{
            Map<String,Object> resultMap = myFamilyService.scanQRcode(applyPatient,getUID(familyPatient),familyBindRole);
            return success(resultMap);
        }catch (Exception e){
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
    @GetMapping(value = PatientRequestMapping.MyFamily.messageToBinding)
    @ApiOperation(value = "消息到确认绑定页面")
    public Envelop messageToBinding(
            @ApiParam(name = "messageId", value = "消息的id", required = true)
            @RequestParam(value = "messageId",required = true) Integer messageId) throws Exception {
        try{
            Map<String,Object> resultMap = myFamilyService.messageToBinding(messageId);
            return success(resultMap);
        }catch (Exception e){
            e.printStackTrace();
            return failed(e.getMessage());
        }
    }
}

+ 182 - 100
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/MyFamilyService.java

@ -9,6 +9,7 @@ import com.yihu.jw.message.service.MessageService;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
import com.yihu.jw.patient.service.personal_Info.PatientService;
import com.yihu.jw.patient.service.servicepackage.PackageService;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.wechat.service.WeChatQrcodeService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections.map.LinkedMap;
@ -18,7 +19,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
@ -34,7 +34,7 @@ public class MyFamilyService {
    @Autowired
    private MessageService messageService;
    @Value("${myFamily.qrCodeFailurTime}")
    private String qrCodeFailurTime;
    private String qrCodeFailurTime;//单位天
    @Autowired
    private WeChatQrcodeService weChatQrcodeService;
    @Autowired
@ -91,61 +91,85 @@ public class MyFamilyService {
    /**
     * 一键绑定
     * @param request
     * @param wechatId
     * @param patient
     * @param familyMobile
     * @param platform
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    public PatientApplyLog bindingMyFamily(HttpServletRequest request,String wechatId, String patient, String familyMobile, Integer platform,Integer familyBindRole) throws Exception{
    public Map<String,Object> bindingMyFamily( String patient, String familyMobile, Integer platform,Integer familyBindRole) throws Exception{
        BasePatientDO patientDO = patientService.findByIdAndDel(patient);
        //1、检验手机号码是否有存在账号,
        BasePatientDO familyPatient = patientService.findByMobileAndDel(familyMobile);
        if(familyPatient==null){
            //2、没有存在账号的,预注册一个账号,调用预注册接口
        }
        //3、生成申请绑定的记录
        PatientApplyLog patientApplyLog = patientApplyLogService.findValidOne(patient,familyPatient.getId(),new Date(),familyBindRole);
        if(patientApplyLog==null){
            patientApplyLog = new PatientApplyLog();
            patientApplyLog.setFamilyMemberName(familyPatient.getName());
            patientApplyLog.setFamilyMemberCode(familyPatient.getId());
            patientApplyLog.setDel(1);
            patientApplyLog.setCreateTime(new Date());
            patientApplyLog.setCreateUser(familyPatient.getId());
            patientApplyLog.setCreateUserName(patientDO.getName());
            patientApplyLog.setFamilyBindRole(familyBindRole);
            //4、发送绑定家人的系统消息
            BaseMessageDO messageDO = new BaseMessageDO();
            messageDO.setReceiver(familyPatient.getId());
            messageDO.setReceiverName(familyPatient.getName());
            messageDO.setSender(patient);
            messageDO.setSenderName(patientDO.getName());
            messageDO.setSenderPhoto(patientDO.getPhoto());
            messageDO.setTitle("家人绑定");
            messageDO.setMsgDigest("");
            messageDO.setMsgContent("");
            messageDO.setMsgTypeCode("010801");
            messageDO.setMsgTypeName("");
            messageDO.setPlatform(platform);
            messageDO.setReadState(0);
            messageDO.setReadonly(0);
            messageDO.setDel("1");
            messageDO.setCreateTime(new Date());
            messageService.save(messageDO);
        }
        Long time = 1000*60*60*Long.valueOf(qrCodeFailurTime);
        Long failurTime = System.currentTimeMillis()+time;
        patientApplyLog.setFailureTime(new Date(failurTime));
        patientApplyLog = patientApplyLogService.save(patientApplyLog);
//        PatientApplyLog patientApplyLog = createFamilyQrCode(request,familyPatient,wechatId,patient,familyBindRole);
        //2、没有存在账号的,预注册一个账号,调用预注册接口
        BasePatientDO familyPatient = null;
        //3、生成申请绑定的记录,申请绑定二维码
        PatientApplyLog patientApplyLog = createFamilyQrCode(request,familyPatient,wechatId,patient,familyBindRole);
        //4、发送绑定家人的系统消息
        BaseMessageDO messageDO = new BaseMessageDO();
        messageDO.setReceiver(familyPatient.getId());
        messageDO.setReceiverName(familyPatient.getName());
        messageDO.setSender(patient);
        messageDO.setType(1);
        messageDO.setFailureTime(patientApplyLog.getFailureTime());
        messageDO.setSenderName(patientDO.getName());
        messageDO.setSenderPhoto(patientDO.getPhoto());
        messageDO.setTitle("家人绑定");
        messageDO.setMsgDigest("");
        messageDO.setMsgContent("");
        messageDO.setMsgTypeCode("010801");
        messageDO.setMsgTypeName("");
        messageDO.setPlatform(platform);
        messageDO.setReadState(0);
        messageDO.setReadonly(0);
        messageDO.setDel("1");
        messageDO.setCreateTime(new Date());
        messageService.save(messageDO);
        return patientApplyLog;
        Map<String,Object> map = new HashedMap();
        map.put("patientApplyLogId",patientApplyLog.getId());//
        map.put("familyMemberName",patientApplyLog.getFamilyMemberName());//家人的名称
        map.put("familyMemberCode",patientApplyLog.getFamilyMemberCode());//家人的code
        map.put("familyMemberPhoto",familyPatient.getPhoto());//家人的头像
        map.put("failureTime", DateUtil.dateToStr(patientApplyLog.getFailureTime(),"yyyy-MM-dd HH:mm:ss"));//失效时间
        map.put("status",patientApplyLog.getStatus());//状态
        map.put("createTime",DateUtil.dateToStr(patientApplyLog.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));//创建时间
        map.put("createUser",patientApplyLog.getCreateUser());//申请人
        map.put("createUserName",patientApplyLog.getCreateUserName());//申请人姓名
        map.put("createUserPhoto",patientDO.getPhoto());//申请人头像
        map.put("familyBindRole",patientApplyLog.getFamilyBindRole());//角色 1"配偶",2"父亲",3"母亲",4"公公",5"婆婆",6"岳父",7"岳母",8"女婿",9"儿媳",10"子女"
        map.put("familyMobile",familyMobile);//家人手机号码
        return map;
    }
    /**
     * 签约绑定家人
     * @param request
     * @param wechatId
     * @param patient
     * @param familyMobile
     * @param platform
     * @param patient 申请绑定的居民code
     * @param familyMobile 家人的手机号码
     * @param platform  消息平台,1微信端/患者端,2医生APP端
     * @param familyBindRole 1"配偶",2"父亲",3"母亲",4"公公",5"婆婆",6"岳父",7"岳母",8"女婿",9"儿媳",10"子女"
     * @param isAdult 0未成年人 1成年人
     */
    public PatientApplyLog signBindFamily(HttpServletRequest request,String wechatId, String patient, String familyMobile, Integer platform,Integer familyBindRole,Integer isAdult) throws Exception{
    public Map<String,Object> signBindFamily( String patient, String familyMobile, Integer platform,Integer familyBindRole,Integer isAdult) throws Exception{
        if(isAdult==1){
            PatientApplyLog p = bindingMyFamily(request,wechatId,patient, familyMobile, platform,familyBindRole);
            Map<String,Object> p = bindingMyFamily(patient, familyMobile, platform,familyBindRole);
            return p;
        }else if(isAdult==0){
            //注册一个没有手机号码的用户信息
@ -164,35 +188,24 @@ public class MyFamilyService {
    /**
     * 生成绑定家人的二维码
     * @param request
     * @param familyPatient
     * @param wechatId
     * @param patient
     * @return
     * @throws Exception
     */
    @Transactional(rollbackFor = Exception.class)
    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.setFamilyMemberName(familyPatient.getName());
        patientApplyLog.setFamilyMemberCode(familyPatient.getId());
        String scene ="family_"+familyPatient.getId()+"_"+familyPatient.getId();
        String qrCode = weChatQrcodeService.getQrcode(request,wechatId, scene);
    public Map<String,Object> createFamilyQrCode(String wechatId, String patient,Integer familyBindRole) throws Exception{
        Map<String,Object> map = new HashedMap();
        String scene ="family_"+patient+"_"+familyBindRole;
        String qrCode = weChatQrcodeService.getQrcode(wechatId, scene);
        if(StringUtils.isEmpty(qrCode)){
            throw new Exception("qrCode is null");
        }
        patientApplyLog.setQrCode(qrCode);
        Long time = 1000*60*60*Long.valueOf(qrCodeFailurTime);
        Long failurTime = (new Date()).getTime()+time;
        patientApplyLog.setFailureTime(new Date(failurTime));
        patientApplyLog.setDel(1);
        patientApplyLog.setCreateTime(new Date());
        patientApplyLog.setCreateUser(familyPatient.getId());
        patientApplyLog.setCreateUserName(patientDO.getName());
        patientApplyLog.setFamilyBindRole(familyBindRole);
        patientApplyLogService.save(patientApplyLog);
        return patientApplyLog;
        map.put("qrCode",qrCode);
        map.put("familyBindRole",familyBindRole);
        map.put("myFamilyBindingRole",getMyFamilyBindingRole(patient));
        return map;
    }
@ -216,10 +229,20 @@ public class MyFamilyService {
     * @param status 1、添加家人(默认),2、邀请登录,3、通过,4、拒绝
     */
    @Transactional(rollbackFor = Exception.class)
    public void confirmApply(Integer patientApplyLogId,Integer status,Integer isAuthorize){
    public Map<String,Object> confirmApply(Integer patientApplyLogId,Integer status,Integer isAuthorize)throws Exception{
        Map<String,Object> map = new HashedMap();
        PatientApplyLog patientApplyLog = patientApplyLogService.findById(patientApplyLogId);
        BasePatientDO apply = patientService.findByIdAndDel(patientApplyLog.getCreateUser());
        BasePatientDO family = patientService.findByIdAndDel(patientApplyLog.getFamilyMemberCode());
        Integer converRole = familyRelationTrans(patientApplyLog.getFamilyBindRole(),apply.getSex());
        if(patientApplyLog.getFailureTime().getTime()<System.currentTimeMillis()){
            map.put("key","0");
            map.put("keyName","绑定过期");
            map.put("applyPhoto",apply.getPhoto());
            map.put("familyPhoto",family.getPhoto());
            map.put("explain","您的"+role.get(converRole-1)+apply.getName()+"向您发起的绑定邀请已过期,您可以点下下方邀请绑定按钮,重新邀请绑定家人。");
            return map;
        }
        patientApplyLog.setStatus(status);
        patientApplyLog.setConfirmTime(new Date());
        patientApplyLogService.save(patientApplyLog);
@ -229,11 +252,82 @@ public class MyFamilyService {
            patientFamilyMember.setPatient(patientApplyLog.getCreateUser());
            patientFamilyMember.setFamilyMember(patientApplyLog.getFamilyMemberCode());
            patientFamilyMember.setFamilyRelation(patientApplyLog.getFamilyBindRole());
            patientFamilyMember.setIsAuthorize(isAuthorize);
            patientFamilyMember.setIsAuthorize(0);
            patientFamilyMember.setDel(1);
            patientFamilyMemberService.save(patientFamilyMember);
            BasePatientFamilyMemberDO patientFamilyMember2 = new BasePatientFamilyMemberDO();
            patientFamilyMember2.setPatient(patientApplyLog.getFamilyMemberCode());
            patientFamilyMember2.setFamilyMember(patientApplyLog.getCreateUser());
            BasePatientDO createUser = patientService.findByIdAndDel(patientApplyLog.getCreateUser());
            patientFamilyMember2.setFamilyRelation(familyRelationTrans(patientApplyLog.getFamilyBindRole(),createUser.getSex()));
            patientFamilyMember2.setIsAuthorize(isAuthorize);
            patientFamilyMember2.setDel(1);
            patientFamilyMemberService.save(patientFamilyMember2);
        }
        map.put("key","1");
        map.put("keyName","绑定成功");
        return map;
    }
    /**
     * 扫码绑定确认
     * @param status
     * @param applyPatient
     * @param familyPatient
     * @param familyBindRole
     * @param isAuthorize
     * @throws Exception
     */
    public void scanQRcodeConfirmApply(Integer status,String applyPatient,String familyPatient,Integer familyBindRole,Integer isAuthorize)throws Exception{
        if(status==3){
            BasePatientFamilyMemberDO patientFamilyMember = new BasePatientFamilyMemberDO();
            patientFamilyMember.setPatient(applyPatient);
            patientFamilyMember.setFamilyMember(familyPatient);
            patientFamilyMember.setFamilyRelation(familyBindRole);
            patientFamilyMember.setIsAuthorize(0);
            patientFamilyMember.setDel(1);
            patientFamilyMemberService.save(patientFamilyMember);
            BasePatientFamilyMemberDO patientFamilyMember2 = new BasePatientFamilyMemberDO();
            patientFamilyMember2.setPatient(familyPatient);
            patientFamilyMember2.setFamilyMember(applyPatient);
            BasePatientDO createUser = patientService.findByIdAndDel(applyPatient);
            patientFamilyMember2.setFamilyRelation(familyRelationTrans(familyBindRole,createUser.getSex()));
            patientFamilyMember2.setIsAuthorize(isAuthorize);
            patientFamilyMember2.setDel(1);
            patientFamilyMemberService.save(patientFamilyMember2);
        }
    }
    /**
     * 扫码到确认绑定页面
     * @param applyPatient
     * @param familyPatient
     * @param familyBindRole
     * @throws Exception
     */
    public Map<String,Object> scanQRcode(String applyPatient,String familyPatient,Integer familyBindRole) throws Exception{
        Map<String,Object> map = new HashedMap();
        BasePatientDO apply = patientService.findByIdAndDel(applyPatient);
        BasePatientDO family = patientService.findByIdAndDel(familyPatient);
        Integer converRole = familyRelationTrans(familyBindRole,apply.getSex());
        map.put("applyPhoto",apply.getPhoto());
        map.put("familyPhoto",family.getPhoto());
        map.put("explain","您的"+role.get(converRole-1)+apply.getName()+"邀请您绑定家人账号");
        return map;
    }
    /**
     * 消息到确认绑定页面
     * @param messageId
     * @return
     * @throws Exception
     */
    public Map<String,Object> messageToBinding(Integer messageId)throws Exception{
        BaseMessageDO messageDO = messageService.findById(messageId);
        PatientApplyLog patientApplyLog = patientApplyLogService.findById(Integer.valueOf(messageDO.getRelationData()+""));
        Map<String,Object> map = scanQRcode(patientApplyLog.getCreateUser(),patientApplyLog.getFamilyMemberCode(),patientApplyLog.getFamilyBindRole());
        map.put("patientApplyLogId",patientApplyLog.getId());
        return map;
    }
    /**
@ -245,7 +339,6 @@ public class MyFamilyService {
    public List<Map<String,Object>> getBindingList(String patient,String packageId) 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();
@ -254,10 +347,10 @@ public class MyFamilyService {
        map.put("name",basePatientDO.getName());//姓名
        map.put("cardTypeName","身份证");
        map.put("idcard",basePatientDO.getIdcard());//身份证
        if(!StringUtils.isEmpty(basePatientDO.getPrincipalCode())){
        PatientMedicareCardDO patientMedicareCardDO = patientMedicareCardService.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.SocialSecurityCard.getType(),patient,"1");
        if(patientMedicareCardDO!=null){
            PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode());
            map.put("principalNum",patientMedicareCard.getCode());//社保卡号
            map.put("principalNum",patientMedicareCardDO.getCode());//社保卡号
        }else{
            map.put("principalNum","");//社保卡号
        }
@ -274,20 +367,15 @@ public class MyFamilyService {
        //家人
        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);
            basePatientDO = patientService.findByIdAndDel(one.getPatient());
            map2.put("appellation",basePatientDO.getName());//别称
            map2.put("patientCode",patientTemp);//居民code
            map2.put("patientCode",basePatientDO.getId());//居民code
            map2.put("name",basePatientDO.getName());//姓名
            map2.put("cardTypeName","身份证");
            map2.put("idcard",basePatientDO.getIdcard());//身份证
            if(!StringUtils.isEmpty(basePatientDO.getPrincipalCode())){
            PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByTypeAndPatientCodeAndDel(PatientMedicareCardDO.Type.SocialSecurityCard.getType(),patient,"1");
            if(patientMedicareCardDO!=null){
                PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode());
                map2.put("principalNum",patientMedicareCard.getCode());//社保卡号
            }else{
                map2.put("principalNum","");//社保卡号
@ -313,28 +401,15 @@ public class MyFamilyService {
        BasePatientDO patientDO = patientService.findByIdAndDel(patient);//绑定人
        for(BasePatientFamilyMemberDO one:bindList){
            Map<String,Object> map = new HashedMap();
            if(patient.equals(one.getPatient())){
                BasePatientDO familyMember = patientService.findByIdAndDel(one.getFamilyMember());
                map.put("photo",familyMember.getPhoto());//头像
                map.put("name",familyMember.getName());//姓名
                map.put("roleName",role.get(one.getFamilyRelation()+1));//角色名称
                map.put("mobile",familyMember.getMobile());//手机号码
                map.put("isAuthorize",one.getIsAuthorize());//0:未授权,1:已授权
                map.put("familyMemberId",one.getId());
                map.put("patientId",familyMember.getId());
                map.put("type",1);
            }else{
                Integer familyRelation = familyRelationTrans(one.getFamilyRelation(),patientDO.getSex());
                BasePatientDO familyMember = patientService.findByIdAndDel(one.getPatient());
                map.put("photo",familyMember.getPhoto());//头像
                map.put("name",familyMember.getName());//姓名
                map.put("roleName",role.get(familyRelation+1));//角色名称
                map.put("mobile",familyMember.getMobile());//手机号码
                map.put("isAuthorize",one.getIsAuthorize());//0:未授权,1:已授权
                map.put("familyMemberId",one.getId());
                map.put("patientId",familyMember.getId());
                map.put("type",1);
            }
            BasePatientDO familyMember = patientService.findByIdAndDel(one.getFamilyMember());
            map.put("photo",familyMember.getPhoto());//头像
            map.put("name",familyMember.getName());//姓名
            map.put("roleName",role.get(one.getFamilyRelation()+1));//角色名称
            map.put("mobile",familyMember.getMobile());//手机号码
            map.put("isAuthorize",one.getIsAuthorize());//0:未授权,1:已授权
            map.put("familyMemberId",one.getId());
            map.put("patientId",familyMember.getId());
            map.put("type",1);
            resultList.add(map);
        }
        //已邀请的
@ -385,13 +460,20 @@ public class MyFamilyService {
     */
    @Transactional(rollbackFor = Exception.class)
    public List<Map<String,Object>> applyMessageList(String patient) throws Exception{
        List<Map<String, Object>> msgList = messageService.applyMessageList(patient, new Date(), "010801");
        List<Map<String, Object>> msgList = messageService.applyMessageList(patient, "010801");
        List<Map<String,Object>> result = new ArrayList<>();
        PatientApplyLog patientApplyLog = null;
        for(Map<String, Object> one:msgList){
            Map<String,Object> map = new HashedMap();
            String relationData = one.get("relation_data")+"";
            patientApplyLog = patientApplyLogService.findById(Integer.valueOf(relationData));
            if(patientApplyLog.getFailureTime().getTime()<System.currentTimeMillis()){
                BaseMessageDO msg = messageService.findById(Integer.valueOf(one.get("id")+""));
                msg.setReadonly(1);
                msg.setReadTime(new Date());
                messageService.save(msg);
               continue;
            }
            Integer bindRole = patientApplyLog.getFamilyBindRole();
            String createUser = patientApplyLog.getCreateUser();//申请人code
@ -429,7 +511,7 @@ public class MyFamilyService {
    /**
     * 家庭关系转换
     * @param familyRelation
     * @param sex 1男,2女
     * @param sex 申请人的性别 1男,2女
     */
    public Integer familyRelationTrans(Integer familyRelation,Integer sex){
        //1"配偶",2"父亲",3"母亲",4"公公",5"婆婆",6"岳父",7"岳母",8"女婿",9"儿媳",10"子女"

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

@ -57,4 +57,8 @@ public class PatientApplyLogService extends BaseJpaService<PatientApplyLog, Pati
        String sql = "select l.* from patient_apply_for_log l where l.create_user='"+patient+"' and l.del=1 and (l.status in (4,5) or (l.failure_time>='"+ DateUtil.dateToStr(new Date(),"yyyy-MM-dd HH:mm:ss")+"' and l.status in (1,2))) limit0,10";
        return jdbcTemplate.queryForList(sql);
    }
    public PatientApplyLog findValidOne(String createUser,String familyMemberCode,Date failureTime,Integer familyBindRole){
        return  patientApplyLogDao.findValidOne(createUser,familyMemberCode,failureTime,familyBindRole);
    }
}

+ 3 - 3
svr/svr-patient/src/main/resources/application.yml

@ -107,7 +107,7 @@ fastDFS:
jw:
  smsUrl: http://svr-base:10020/sms_gateway/send
myFamily:
  qrCodeFailurTime: 2
  qrCodeFailurTime: 7
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040  # base库中,wx_wechat 的id字段
# 短信验证码发送的客户端标识,居民端
@ -146,7 +146,7 @@ wechat:
sms:
  clientId: EwC0iRSrcP
myFamily:
  qrCodeFailurTime: 2
  qrCodeFailurTime: 7
---
spring:
  profiles: prod
@ -177,4 +177,4 @@ wechat:
sms:
  clientId: EwC0iRSrcP #todo 待配置
myFamily:
  qrCodeFailurTime: 2
  qrCodeFailurTime: 7