浏览代码

爱牵挂

yeshijie 4 年之前
父节点
当前提交
daa900f211

+ 4 - 1
common/common-entity/sql记录

@ -445,4 +445,7 @@ alter table base_doctor add doctor_level tinyint(4) DEFAULT NULL COMMENT '类型
-- 2021-04-29 wj
alter table base_patient ADD disease varchar(50) ;
alter table patient_medicare_card ADD medicare_number varchar(50) ;
alter table patient_medicare_card ADD medicare_number varchar(50) ;
-- 2021-05-07 ysj
alter table base_patient_family_member add is_contacts tinyint(1) DEFAULT NULL COMMENT '是否是一键联系人';

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientFamilyMemberDO.java

@ -17,6 +17,7 @@ public class BasePatientFamilyMemberDO extends UuidIdentityEntityWithOperator {
    private String familyMember;//家庭成员code',
    private Integer familyRelation;//家庭关系关系 1配偶 2父亲 3母亲 4公公 5婆婆 6岳父 7岳母 8子女',
    private Integer isAuthorize;//是否授权0:未授权,1:已授权,默认为1',
    private Integer isContacts;//是否是一键联系人 1是
    private Integer del;//删除标志(1正常,0删除)
    @Column(name = "patient")
@ -63,4 +64,13 @@ public class BasePatientFamilyMemberDO extends UuidIdentityEntityWithOperator {
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "is_contacts")
    public Integer getIsContacts() {
        return isContacts;
    }
    public void setIsContacts(Integer isContacts) {
        this.isContacts = isContacts;
    }
}

+ 8 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/family/PatientFamilyMemberDao.java

@ -50,4 +50,12 @@ public interface PatientFamilyMemberDao extends PagingAndSortingRepository<BaseP
    BasePatientFamilyMemberDO findByPatientAndFamilyMember(String patient,String member);
    List<BasePatientFamilyMemberDO> findByFamilyMemberAndIsAuthorize(String familyMember,Integer isAuthorize);
    @Modifying
    @Query("update BasePatientFamilyMemberDO m set m.isContacts = 0 where m.patient=?1 ")
    int updateContactsByPatient(String patient);
    @Modifying
    @Query("update BasePatientFamilyMemberDO m set m.isContacts = 1 where m.id=?1 ")
    int updateContactsById(String id);
}

+ 4 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java

@ -171,21 +171,21 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
    /**
     * 家庭成员查询
     * @param patient
     * @param isAgree (任意值已同意(只查询家人关系表),null不同意)
     * @param isContacts (1是一键联系人)
     * @return
     */
    @RequestMapping(value = "/members", method = RequestMethod.GET)
    @ApiOperation(value = "家庭成员查询")
    public ObjEnvelop getPatientFamilyMembers(@RequestParam(required = false) String patient,
                                              @RequestParam(required = false) String isContain,
                                              @RequestParam(required = false) Integer isAgree) {
                                              @RequestParam(required = false) Integer isContacts) {
        try {
            JSONObject data = new JSONObject();
            JSONArray result = new JSONArray();
            if (StringUtils.isNotEmpty(patient)) {
                result = familyMemberService.getPatientMembers(patient, "", isContain,isAgree);
                result = familyMemberService.getPatientMembers(patient, "", isContain,isContacts);
            } else  {
                result = familyMemberService.getPatientFamilyMembers(getUID(), "",null);
                result = familyMemberService.getPatientFamilyMembers(getUID(), "",isContacts);
            }
            data.put("normalmembers",result);//家人关系

+ 69 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientContactsEndpoint.java

@ -0,0 +1,69 @@
package com.yihu.jw.care.endpoint.patient;
import com.alibaba.fastjson.JSONArray;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/7
 * @Description:
 */
@RestController
@RequestMapping("patientContacts" )
@Api(tags = "居民-联系人", description = "居民-联系人")
public class PatientContactsEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ContactsService contactsService;
    /**
     * 联系人查询
     * @param patient
     * @param isContacts (1是一键联系人)
     * @return
     */
    @RequestMapping(value = "getPatientContacts", method = RequestMethod.GET)
    @ApiOperation(value = "联系人查询")
    public Envelop getPatientContacts(@RequestParam(required = true) String patient,
                                      @RequestParam(required = true) Integer isContacts) {
        try {
            JSONArray result = contactsService.getPatientContacts(patient,isContacts);
            return ObjEnvelop.getSuccess( "查询成功", result);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "查询失败");
        }
    }
    /**
     * 设置一键联系人
     * @param patient
     * @return
     */
    @RequestMapping(value = "setPatientContacts", method = RequestMethod.POST)
    @ApiOperation(value = "设置一键联系人")
    public Envelop setPatientContacts(@RequestParam(required = true) String patient,
                                      @RequestParam(required = true) String fid) {
        try {
            contactsService.setContacts(fid,patient);
            return ObjEnvelop.getSuccess("设置成功");
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("设置失败");
        }
    }
}

+ 109 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java

@ -0,0 +1,109 @@
package com.yihu.jw.care.service.contacts;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.family.PatientFamilyMemberDao;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/7
 * @Description:
 */
@Service
public class ContactsService {
    @Autowired
    private PatientFamilyMemberDao memberDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private PatientFamilyMemberService patientFamilyMemberService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 获取居民的联系人
     * @param patient 居民
     * @return
     */
    public JSONArray getPatientContacts(String patient, Integer isContacts) {
        JSONArray resultArray = new JSONArray();
        String sql = "select *,t1.id fid " +
                " from " +
                "    base_patient_family_member t1, " +
                "    base_patient t2 " +
                " where " +
                "    t2.id in (select family_member from base_patient_family_member where patient = ? ) " +
                "    and t1.patient = ? " +
                "    and t1.family_member = t2.id ";
        if(isContacts == 1){
            sql += " and t1.is_contacts = "+ isContacts;
        }
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient, patient});
        if (result != null && result.size() > 0) {
            for (Map<String, Object> map : result) {
                JSONObject obj = new JSONObject();
                obj.put("id", map.get("id"));
                obj.put("fid", map.get("fid"));
                obj.put("name", map.get("name"));
                obj.put("isContacts", map.get("is_contacts"));
                obj.put("sex", map.get("sex"));
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                obj.put("familyRelation", map.get("family_relation"));
                obj.put("familyRelationName", PatientFamilyMemberService.relations.get(map.get("family_relation")));
                resultArray.add(obj);
            }
        }
        return resultArray;
    }
    @Transactional(rollbackFor = Exception.class)
    public void setContacts(String fid,String patient){
        BasePatientFamilyMemberDO familyMemberDO = memberDao.findOne(fid);
        BasePatientDO patientDO = basePatientDao.findById(patient);
        //设置爱牵挂智能设备sos号码
        try {
            List<DevicePatientDevice> patientDeviceList = patientDeviceDao.findByPatient(patient);
            for(DevicePatientDevice patientDevice : patientDeviceList){
                if("4".equals(patientDevice.getCategoryCode())||"7".equals(patientDevice.getCategoryCode())){
                    patientDeviceService.updAqgDeviceSosInfo(patientDevice.getDeviceSn(),"1",
                            PatientFamilyMemberService.relations.get(familyMemberDO.getFamilyRelation()),patientDO.getMobile(),"1",null);
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        memberDao.updateContactsByPatient(patient);
        familyMemberDO.setIsContacts(1);
        memberDao.save(familyMemberDO);
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -713,7 +713,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    若该设备以前已设置亲情号码2,则以前设置的亲情号码2也会被清空]
    |
     */
    public com.alibaba.fastjson.JSONObject updAqgDeviceSosInfo(String deviceSn,String seqid,String name,String num,String dial_flag,String clear) throws Exception{
    public com.alibaba.fastjson.JSONObject updAqgDeviceSosInfo(String deviceSn,String seqid,String name,String num,String dial_flag,String clear){
        String url = MessageFormat.format(AqgConfig.sos_numbers, deviceSn,seqid);
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        if(StringUtils.isBlank(clear)){

+ 8 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java

@ -18,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -29,7 +28,7 @@ import java.util.regex.Pattern;
@Service
public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamilyMemberDO, PatientFamilyMemberDao> {
    Map<Integer, String> relations = new HashMap<>();
    public static Map<Integer, String> relations = new HashMap<>();
    @Autowired
    private PatientFamilyMemberDao memberDao;
    @Autowired
@ -40,8 +39,8 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @PostConstruct
    public void init() {
    static {
        relations.put(0, "其他");
        relations.put(1, "父亲");
        relations.put(2, "母亲");
@ -356,7 +355,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
     * @param patient 居民
     * @return
     */
    public JSONArray getPatientFamilyMembers(String patient, String doctorCode, Integer isAgree) {
    public JSONArray getPatientFamilyMembers(String patient, String doctorCode, Integer isContacts) {
        JSONArray resultArray = new JSONArray();
        String sql = "select * " +
                " from " +
@ -366,7 +365,9 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                "    t2.id in (select family_member from base_patient_family_member where patient = ? ) " +
                "    and t1.patient = ? " +
                "    and t1.family_member = t2.id ";
        if(isContacts != null){
            sql += " and t1.is_contacts = "+ isContacts;
        }
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient, patient});
        if (result != null && result.size() > 0) {
@ -384,6 +385,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                obj.put("id", map.get("id"));
                obj.put("name", map.get("name"));
                obj.put("isContacts", map.get("is_contacts"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", isAuthorize);//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));