liubing %!s(int64=3) %!d(string=hai) anos
pai
achega
360a64ce7b

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

@ -1584,4 +1584,8 @@ CREATE TABLE `dm_ys_config` (
  `iot_access_token_key` varchar(25) DEFAULT NULL COMMENT 'iot token Key',
  `secret_key` varchar(25) DEFAULT NULL COMMENT '设备的解密秘钥 key',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8mb4;
-- 2021-11-11
alter table base_patient  add column `home_lat_lon` varchar(100) DEFAULT NULL COMMENT '居民家庭经纬度';
ALTER table wlyy_patient_safe_area add column manage_status TINYINT(2) default '0' COMMENT '电子围栏确认情况 0待确认 1已确认';

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

@ -292,6 +292,8 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String medicalState;//医保授权状态
    private String homeLatLon;//家庭经纬度
    @Column(name = "medical_state")
    public String getMedicalState() {
@ -906,4 +908,13 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public void setDeviceFlag(Integer deviceFlag) {
        this.deviceFlag = deviceFlag;
    }
    @Column(name="home_lat_lon")
    public String getHomeLatLon() {
        return homeLatLon;
    }
    public void setHomeLatLon(String homeLatLon) {
        this.homeLatLon = homeLatLon;
    }
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/PatientSafeAreaDO.java

@ -21,6 +21,8 @@ public class PatientSafeAreaDO extends IdEntity {
    private Date createTime;
    private Date updateTime;
    private Integer manageStatus;//电子围栏确认情况 0待确认 1已确认
    public String getPatient() {
        return patient;
    }
@ -63,4 +65,12 @@ public class PatientSafeAreaDO extends IdEntity {
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getManageStatus() {
        return manageStatus;
    }
    public void setManageStatus(Integer manageStatus) {
        this.manageStatus = manageStatus;
    }
}

+ 3 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/label/PatientLabelEndpoint.java

@ -49,12 +49,14 @@ public class PatientLabelEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "labelCode",required = true) String labelCode,
            @ApiParam(name = "name", value = "姓名或身份证", required = false)
            @RequestParam(value = "name",required = false) String name,
            @ApiParam(name = "topicItem", value = "专题code,关联security_topic_dict字典", required = false)//有绑定相关专题设备
            @RequestParam(value = "topicItem",required = false) String topicItem,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
            @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        try{
            return patientLableService.findSignPatientLabelListByTeamCode(teamCode, labelCode, name, page, size);
            return patientLableService.findSignPatientLabelListByTeamCode(teamCode, labelCode, name,topicItem, page, size);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java

@ -333,6 +333,18 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("老人家属首页实时监护信息")
    @RequestMapping(value = "patientMonitoringInfo2", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public ObjEnvelop patientMonitoringInfo2(@ApiParam(name = "patient", value = "patient")
                                            @RequestParam(value = "patient") String patient) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", securityMonitoringOrderService.patientMonitoringInfo2(patient));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @ApiOperation("获取居民签约专题信息")
    @RequestMapping(value = "patientSignTopicInfo", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody

+ 15 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java

@ -3,6 +3,7 @@ package com.yihu.jw.care.service.label;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.restmodel.web.PageEnvelop;
@ -27,6 +28,8 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
    private DictService dictService;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private ServicePackageService servicePackageService;
    /**
     * 按团队查找签约居民的标签统计
@ -59,9 +62,9 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
     * @param teamCode
     * @return
     */
    public PageEnvelop<List<Map<String,Object>>> findSignPatientLabelListByTeamCode(String teamCode, String labelCode, String name, int page, int size){
    public PageEnvelop<List<Map<String,Object>>> findSignPatientLabelListByTeamCode(String teamCode, String labelCode, String name,String topicItem, int page, int size){
        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.idcard,p.mobile,p.openid,p.sex,p.pad_imei padImei " ;
        sql +=",(select COUNT(*) from wlyy_patient_device a where a.`user` = p.id) deviceFlag ";
        sql +=",(select COUNT(*) from wlyy_patient_device a where a.`user` = p.id and a.del=0) deviceFlag ";
        String countSql = "SELECT count(DISTINCT p.id) ";
        String filters = "from base_service_package_sign_record sr,base_service_package_record r,  " +
                "                base_patient p,wlyy_patient_label l " +
@ -71,6 +74,11 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
        if(StringUtils.isNotBlank(name)){
            filters += " and (p.name like '%"+name+"%' or p.idcard like '%"+name+"%') ";
        }
        if (StringUtils.isNotBlank(topicItem)){
            filters += " and EXISTS (select 1 from wlyy_patient_device pd INNER JOIN dm_device dd on pd.device_id = dd.id " +
                    "where  pd.user = sr.patient and  FIND_IN_SET(dd.service_topic,'"+topicItem+"')) ";
        }
        String orderBy = " ORDER BY sr.create_time DESC " +
                "LIMIT "+ (page - 1) * size + "," + size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filters+orderBy);
@ -78,6 +86,11 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
            String idcard = map.get("idcard").toString();
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            map.put("deviceType",deviceService.getPatientDeviceCategoryCode(map.get("id").toString()));
            //签约医生标识
            List<Map<String,Object>> doctorList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","1");
            List<Map<String,Object>> helperList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","2");
            map.put("helper", helperList.size()>0?1:0);
            map.put("doctor", doctorList.size()>0?1:0);
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);

+ 97 - 10
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java

@ -1458,10 +1458,81 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return result;
    }
    /**
     *老人家属首页实时监护信息
     * 居家状态取手表 无手表缺省
     * 监控
     */
    public JSONObject patientMonitoringInfo2(String patient){
        JSONObject result = new JSONObject();
        result.put("atHome",null);// 居家状态
        result.put("location",null);
        result.put("fences",null);
        result.put("gasLeakage",null);
        result.put("fire",null);
        result.put("fall",null);
        result.put("sleep",null);
        result.put("deviceSn",null);
        result.put("emeAssistance",false);
        result.put("monitorInfo",null);
        String sql = " select dict.code,count(ord.id) total from base_system_dict_entry dict LEFT JOIN base_security_monitoring_order ord " +
                " on dict.code = ord.topic_item COLLATE utf8_unicode_ci and ord.status="+SecurityMonitoringOrderDO.Status.apply.getType()+" where dict.dict_code='service_item' " +
                "and dict.remark='security' and ord.patient='"+patient+"' GROUP BY dict.code ";
        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
        for (Map<String,Object>tmp:sqlResult){
            switch (tmp.get("code").toString()){
                case "preventGasLeakage":
                    Integer count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("gasLeakage",true);
                    }else {
                        result.put("gasLeakage",false);
                    }
                    break;
                case "preventFire":
                    count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("fire",true);
                    }else {
                        result.put("fire",false);
                    }
                    break;
                case "preventFall":
                    count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("fall",true);
                    }else {
                        result.put("fall",false);
                    }
                    break;
                case "preventOutOfBed":
                    count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("sleep",true);
                    }else {
                        result.put("sleep",false);
                    }
                    break;
            }
        }
        sql = " select count(id) from base_emergency_assistance_order  where patient='"+patient+"' and status="+ EmergencyAssistanceDO.Status.apply.getType();
        Integer counnt = jdbcTemplate.queryForObject(sql,Integer.class);
        if (counnt>0){
            result.put("emeAssistance",true);
        }
        List<DevicePatientDevice> devices4 = patientDeviceDao.findByUserAndCategoryCode(patient,"4");//手表
        if (devices4.size()>0){
            result =  patientSignTopicInfo(result,patient,"preventLost",devices4.get(0).getDeviceSn());
        }
        patientSignTopicInfo(result,patient,"preventFall",null);
        return result;
    }
    public void preventLost(JSONObject result,String patient,String deviceSn){
        //手表与拐杖同时绑定时优先手表,围栏状态其中一个超出围栏即为超出围栏
        try {
            Integer categoryCode=0;
            Integer categoryCode=0;//未指定设备
            List<DevicePatientDevice> devicePatientDeviceDos = new ArrayList<>();
            List<DevicePatientDevice> devicePatientDeviceDos2 = new ArrayList<>();
            if (StringUtils.isNotBlank(deviceSn)){//查看指定设备详情
@ -1476,11 +1547,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                        devicePatientDeviceDos2 = devices;
                    }
                }
            }else {
                devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
                devicePatientDeviceDos2 = patientDeviceDao.findByUserAndCategoryCode(patient,"16");
            }else {//未指定设备
                devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");//手表
                devicePatientDeviceDos2 = patientDeviceDao.findByUserAndCategoryCode(patient,"16");//拐杖
            }
            if (devicePatientDeviceDos.size()>0&&(4==categoryCode||0==categoryCode)){
            if (devicePatientDeviceDos.size()>0&&(4==categoryCode||0==categoryCode)){//手表
                DevicePatientDevice device = devicePatientDeviceDos.get(0);
                result.put("deviceSn",device.getDeviceSn());
                JSONObject response= patientDeviceService.getAqgDeviceInfo2(device.getDeviceSn());
@ -1495,6 +1566,22 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                        tmp.put("province",response.getString("last_province"));
                        tmp.put("address",response.getString("last_address"));
                        result.put("location",tmp);
                        BasePatientDO patientDO = basePatientDao.findById(patient);
                        if (null != patientDO){
                            if (StringUtils.isNotBlank(patientDO.getHomeLatLon())){
                                String homeLatLon = patientDO.getHomeLatLon();
                                double homeLat = Double.parseDouble( homeLatLon.split(",")[0]);
                                double homeLon = Double.parseDouble( homeLatLon.split(",")[1]);
                                double homeDistance =  countDistance.getDistance(result.getJSONObject("location").getDouble("lat"),result.getJSONObject("location").getDouble("lon"),
                                       homeLat,homeLon);
                                if (homeDistance>50*1000){
                                    result.put("atHome",false);
                                }else {
                                    result.put("atHome",true);
                                }
                            }
                        }
                    }
                    //围栏信息
                    if (response.containsKey("fences")&&response.get("fences")!=null){
@ -1525,7 +1612,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                    }
                }
            }
            if (devicePatientDeviceDos2.size()>0&&(16==categoryCode||0==categoryCode)) {
            if (devicePatientDeviceDos2.size()>0&&(16==categoryCode||0==categoryCode)) {//拐杖
                DevicePatientDevice deviceDO = devicePatientDeviceDos2.get(0);
                double dulat = 0l;
                double dulon = 0l;
@ -1571,11 +1658,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                            positionTmp.put("lon", areaLon);
                            fenceLocation.add(positionTmp);
                        }
                        if (devicePatientDeviceDos2.size() > 0 && 0 == categoryCode) {
                        if (devicePatientDeviceDos2.size() > 0 && 0 == categoryCode && devicePatientDeviceDos2.size()>0) {
                            JSONObject obj = result.getJSONArray("fences").getJSONObject(0);
                            if (!obj.getBooleanValue("inFenceStatus")) {
                            if (obj.getBooleanValue("inFenceStatus")) {
                                if (!countDistance.isInPolygon(dulon, dulat, fenceLocation)) {
                                    obj.put("inFenceStatus", false);
                                    obj.put("inFenceStatus", false);//超出围栏
                                    obj = result.getJSONObject("location");
                                    obj.put("address", address);
                                    obj.put("lon", dulon);
@ -1583,7 +1670,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                                }
                            }
                        }
                        if (devicePatientDeviceDos2.size() > 0 && 16 == categoryCode) {
                        else if(devicePatientDeviceDos2.size() > 0) {//指定拐杖设备
                            if (StringUtils.isNotBlank(safeArea)) {
                                result.put("deviceSn", deviceDO.getDeviceSn());
                                JSONObject location = new JSONObject();