|
@ -1,6 +1,5 @@
|
|
|
package com.yihu.jw.patient.service.myFamily;
|
|
|
|
|
|
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;
|
|
@ -41,14 +40,14 @@ public class MyFamilyService {
|
|
|
private PatientApplyLogService patientApplyLogService;
|
|
|
@Autowired
|
|
|
private BasePatientMedicardCardService patientMedicareCardService;
|
|
|
|
|
|
LinkedList<String> role = new LinkedList<>(Arrays.asList("配偶","父亲","母亲","公公","婆婆","岳父","岳母","女婿","儿媳","子女"));
|
|
|
|
|
|
public List<Map<String,Object>> getMyFamilyBindingRole(String patient) throws Exception{
|
|
|
|
|
|
//获取用户的信息,根据完善信息获取男女
|
|
|
BasePatientDO patientDO = patientService.findByIdAndDel(patient);
|
|
|
Integer sex = patientDO.getSex();
|
|
|
LinkedList<String> role = new LinkedList<>(Arrays.asList("配偶","父亲","母亲","公公","婆婆","岳父","岳母","女婿","儿媳","子女"));
|
|
|
|
|
|
Map<String,Map<String,Object>> map = new LinkedMap();
|
|
|
for(int i =0;i<role.size();i++){
|
|
|
Map<String,Object> m = new LinkedMap();
|
|
@ -115,7 +114,8 @@ public class MyFamilyService {
|
|
|
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("家人绑定");
|
|
@ -132,6 +132,36 @@ public class MyFamilyService {
|
|
|
return patientApplyLog;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 签约绑定家人
|
|
|
* @param request
|
|
|
* @param wechatId
|
|
|
* @param saasId
|
|
|
* @param patient
|
|
|
* @param familyMobile
|
|
|
* @param platform
|
|
|
* @param familyBindRole 1"配偶",2"父亲",3"母亲",4"公公",5"婆婆",6"岳父",7"岳母",8"女婿",9"儿媳",10"子女"
|
|
|
* @param isAdult 0未成年人 1成年人
|
|
|
*/
|
|
|
public PatientApplyLog signBindFamily(HttpServletRequest request,String wechatId, String saasId, String patient, String familyMobile, Integer platform,Integer familyBindRole,Integer isAdult) throws Exception{
|
|
|
if(isAdult==1){
|
|
|
PatientApplyLog p = bindingMyFamily(request,wechatId, saasId,patient, familyMobile, platform,familyBindRole);
|
|
|
return p;
|
|
|
}else if(isAdult==0){
|
|
|
//注册一个没有手机号码的用户信息
|
|
|
BasePatientDO familyPatient = null;
|
|
|
//生成绑定信息
|
|
|
BasePatientFamilyMemberDO patientFamilyMember = new BasePatientFamilyMemberDO();
|
|
|
patientFamilyMember.setPatient(patient);
|
|
|
patientFamilyMember.setFamilyMember(familyPatient.getId());
|
|
|
patientFamilyMember.setFamilyRelation(familyBindRole);
|
|
|
patientFamilyMember.setIsAuthorize(1);//0:未授权,1:已授权
|
|
|
patientFamilyMember.setDel(1);
|
|
|
patientFamilyMemberService.save(patientFamilyMember);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成绑定家人的二维码
|
|
|
* @param request
|
|
@ -172,6 +202,7 @@ public class MyFamilyService {
|
|
|
* @param remindType
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void remindMyFamily(Integer patientApplyLogId,Integer remindType) throws Exception{
|
|
|
int i = patientApplyLogService.updateRemindTypeById(remindType,patientApplyLogId);
|
|
|
if(i<0){
|
|
@ -181,25 +212,12 @@ public class MyFamilyService {
|
|
|
|
|
|
/**
|
|
|
* 家人确认绑定
|
|
|
* @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){
|
|
|
public void confirmApply(Integer patientApplyLogId,Integer status,Integer isAuthorize){
|
|
|
|
|
|
BaseMessageDO messageDO = null;
|
|
|
if(messageId!=null){
|
|
|
messageDO = messageService.findById(messageId);
|
|
|
}
|
|
|
if(messageDO!=null&&patientApplyLogId==null){
|
|
|
String json = messageDO.getRelationData();
|
|
|
JSONObject jsonObject = JSONObject.parseObject(json);
|
|
|
patientApplyLogId = (Integer)jsonObject.get("patientApplyLogId");
|
|
|
messageDO.setReadState(1);
|
|
|
messageDO.setReadTime(new Date());
|
|
|
messageService.save(messageDO);
|
|
|
}
|
|
|
|
|
|
PatientApplyLog patientApplyLog = patientApplyLogService.findById(patientApplyLogId);
|
|
|
patientApplyLog.setStatus(status);
|
|
@ -272,6 +290,87 @@ public class MyFamilyService {
|
|
|
return resultList;
|
|
|
}
|
|
|
|
|
|
public void myFamilyBindList(String patient) throws Exception{
|
|
|
//已绑定的
|
|
|
List<BasePatientFamilyMemberDO> bindList = patientFamilyMemberService.getByPatientAndFamilyMember(patient);
|
|
|
BasePatientDO patientDO = patientService.findByIdAndDel(patient);//绑定人
|
|
|
List<Map<String,Object>> resultList = new ArrayList<>();
|
|
|
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);
|
|
|
}
|
|
|
resultList.add(map);
|
|
|
}
|
|
|
//已邀请的
|
|
|
// patientApplyLogService.
|
|
|
//已取消的
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 有效的申请绑定消息
|
|
|
* @param patient
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public List<Map<String,Object>> applyMessageList(String patient) throws Exception{
|
|
|
List<BaseMessageDO> msgList = messageService.applyMessageList(patient, new Date(), "010801");
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
PatientApplyLog patientApplyLog = null;
|
|
|
for(BaseMessageDO one:msgList){
|
|
|
Map<String,Object> map = new HashedMap();
|
|
|
String o = one.getRelationData();
|
|
|
patientApplyLog = patientApplyLogService.findById(Integer.valueOf(o));
|
|
|
Integer bindRole = patientApplyLog.getFamilyBindRole();
|
|
|
String createUser = patientApplyLog.getCreateUser();//申请人code
|
|
|
|
|
|
BasePatientDO patientDO = patientService.findByIdAndDel(patient);//被绑定人
|
|
|
BasePatientDO createPatient = patientService.findByIdAndDel(createUser);//绑定人
|
|
|
Integer converRole = familyRelationTrans(bindRole,createPatient.getSex());//转换后的角色
|
|
|
|
|
|
map.put("patientApplyLogId",one.getId());
|
|
|
map.put("patientPhoto",patientDO.getPhoto());
|
|
|
map.put("applyPatientPhoto",createPatient.getPhoto());
|
|
|
map.put("explain","您的"+role.get(converRole-1)+createPatient.getName()+"邀请您绑定家人账号");
|
|
|
result.add(map);
|
|
|
one.setReadonly(1);
|
|
|
one.setReadTime(new Date());
|
|
|
messageService.save(one);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 取消申请绑定家人
|
|
|
* @param patientApplyLogId
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void cancelApply(Integer patientApplyLogId) throws Exception{
|
|
|
int i= patientApplyLogService.updateStatusById(5, patientApplyLogId);
|
|
|
if(i<0){
|
|
|
throw new Exception("update data failur !");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 家庭关系转换
|