Browse Source

我的家人模块代码提交

liuwenbin 6 years ago
parent
commit
2be0e23ac3

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

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

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

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

@ -38,6 +38,7 @@ public class PatientRequestMapping {
    public static class MyFamily extends Basic {
        public static final String PREFIX  = "/myFamily";
        public static final String getMyFamilyBindingRole  = "/getMyFamilyBindingRole";
        public static final String getBindingList  = "/getBindingList";
    }

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

+ 77 - 7
svr/svr-patient/src/main/java/com/yihu/jw/patient/service/myFamily/MyFamilyService.java

@ -4,8 +4,10 @@ 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.BasePatientMedicardCardService;
import com.yihu.jw.patient.service.personal_Info.PatientService;
import com.yihu.jw.wechat.service.WeChatQrcodeService;
import org.apache.commons.collections.map.HashedMap;
@ -36,6 +38,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{
@ -97,7 +101,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 +110,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 +145,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 +163,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 +182,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,7 +204,65 @@ 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());//身份证
        PatientMedicareCardDO patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode());
        map.put("principalNum",patientMedicareCard.getMedicareNumber());//社保卡号
        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());//身份证
            patientMedicareCard = patientMedicareCardService.findByCode(basePatientDO.getPrincipalCode());
            map2.put("principalNum",patientMedicareCard.getMedicareNumber());//社保卡号
            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);
    }
}