Browse Source

预警追踪

wsl 2 years ago
parent
commit
d03f4b970f

+ 0 - 13
common/common-entity/src/main/java/com/yihu/jw/entity/base/dict/BaseYujingDict.java

@ -42,11 +42,6 @@ public class BaseYujingDict extends IdEntity {
     */
    private Integer del;
    /**
     * 归属社区code
     */
    private String hospital;
    /**
     * create_time
     */
@ -103,14 +98,6 @@ public class BaseYujingDict extends IdEntity {
        this.del = del;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    @Column(name = "create_time")

+ 12 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java

@ -181,6 +181,18 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getPatientDeviceNameList")
    @ApiOperation("获取老人设备 下拉列表")
    public ListEnvelop getPatientDeviceNameList(@ApiParam(name = "patient", value = "居民id", required = true)
                                                @RequestParam(value = "patient", required = true) String patient) {
        try {
            return ListEnvelop.getSuccess("查询成功",patientInfoPlatFormService.patientDeviceNameList(patient));
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "getEmeAndOlderServiceInfo")
    @ApiOperation("大屏获取老人紧急预警、助老服务情况")
    public ObjEnvelop getEmeAndOlderServiceInfo(@ApiParam(name="patient",value = "居民id",required = true)

+ 154 - 18
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java

@ -733,6 +733,115 @@ public class PatientInfoPlatFormService {
            Map<String,Object> detailInfo =  getDeviceIndexAndOrder(category_code,deviceSN,patient,warnTime);
            tmp.put("detailInfo",detailInfo);
        }
        Map<String,Object> resultMap =  deviceIndexInfo(list);
        list.add(resultMap);
        return list;
    }
    private Map<String, Object> deviceIndexInfo(List<Map<String,Object>> list){
        Map<String, Object> resultMap = new HashMap<>();
        Integer deviceStatus = 0;
        Integer oldIndex = 0;
        List<Map<String, Object>> deviceOnLineList = new ArrayList<>();
        List<Map<String, Object>> oldCheckInfoList = new ArrayList<>();
        Map<String,Object> oldCheckInfoMap = new HashMap<>();
        for (Map<String, Object> map : list) {
            Map<String, Object> deviceOnLineMap = new HashMap<>();
            Integer categoryCode = Integer.parseInt(map.get("category_code").toString());
            String device_name = map.get("device_name").toString();
            Map<String,Object> detailInfo = (Map) map.get("detailInfo");
            String online = detailInfo.get("contact_status").toString().equals("1")?"在线":"离线";
            switch (categoryCode) {
                case 4:
                    deviceOnLineMap.put("deviceName",device_name);
                    if (detailInfo.get("wear_flagName").toString().equals("未佩戴"))deviceStatus +=1;
                    deviceOnLineMap.put("deviceStatus",detailInfo.get("wear_flagName").toString());
                    //Map heartRate = detailInfo.get("heartRate").equals("暂无数据?")?(Map) detailInfo.get("heartRate"):new HashMap<>();
                   Map<String,Object> heartRate = !detailInfo.get("heartRate").equals("暂无数据?")?(Map) detailInfo.get("heartRate"): (Map)new HashMap(){{put("value1_status","暂无数据?");}};
                    Map location = detailInfo.get("location")!=null?(Map) detailInfo.get("location"):new HashMap<>();
                    Map steps = (Map) detailInfo.get("steps");
                    if (!heartRate.get("value1_status").equals("正常")) oldIndex+=1;
                    oldCheckInfoMap.put("heartStatus",heartRate.get("value1_status"));
                    oldCheckInfoMap.put("leaveHome",detailInfo.get("homeRange"));
                    oldCheckInfoMap.put("address",location.get("address"));
                    oldCheckInfoMap.put("stepsStatus",detailInfo.get("steps_status"));
                    oldCheckInfoMap.put("steps",steps.get("steps"));
                    break;
                case 12:
                    deviceOnLineMap.put("deviceName",device_name);
                    deviceOnLineMap.put("deviceStatus",online);
                    if (online.equals("离线")) deviceStatus+=1;
                    //deviceOnLineMap.put("deviceStatus",detailInfo.get("warnStatus").toString().equals("true")?"正常":"异常");
                    break;
                case 13:
                    if (online.equals("离线")) deviceStatus+=1;
                    deviceOnLineMap.put("deviceName",device_name);
                    deviceOnLineMap.put("deviceStatus",online);
                    if (!detailInfo.get("breath_status").equals("正常"))oldIndex+=1;
                    oldCheckInfoMap.put("breathStatus",detailInfo.get("breath_status"));
                    oldCheckInfoMap.put("bedStatus",detailInfo.get("bedStatus"));
                    break;
                case 14:
                    deviceOnLineMap.put("deviceName",device_name);
                    deviceOnLineMap.put("deviceStatus",online);
                    if (!detailInfo.get("warnStatus").equals("异常"))oldIndex+=1;
                    oldCheckInfoMap.put("qgValueStatus",detailInfo.get("warnStatus"));
                    oldCheckInfoMap.put("qgValue",detailInfo.get("value"));
                    if (online.equals("离线")) deviceStatus+=1;
                    break;
                case 15:
                    deviceOnLineMap.put("deviceName",device_name);
                    deviceOnLineMap.put("deviceStatus",online);
                    if (online.equals("离线")) deviceStatus+=1;
                    if (!detailInfo.get("value1_Status").equals("异常"))oldIndex+=1;
                    oldCheckInfoMap.put("ygValueStatus",detailInfo.get("value1_Status"));
                    oldCheckInfoMap.put("ygValue",detailInfo.get("value"));
                    if (!detailInfo.get("temperature_status").equals("异常"))oldIndex+=1;
                    oldCheckInfoMap.put("temperatureStatus",detailInfo.get("temperature_status"));
                    oldCheckInfoMap.put("temperatureValue",detailInfo.get("temperature_value"));
                    break;
            }
            if (!deviceOnLineMap.isEmpty())deviceOnLineList.add(deviceOnLineMap);
        }
        oldCheckInfoList.add(oldCheckInfoMap);
        String dictSql = "SELECT * from base_yujing_dict where del =1";
        List<BaseYujingDict> dictList = jdbcTemplate.query(dictSql, new BeanPropertyRowMapper<>(BaseYujingDict.class));
        if (deviceStatus>0&&oldIndex>0){
            resultMap.put("synthesisProposal",dict(dictList,"device_index4"));
        }else if (deviceStatus>0&&oldIndex==0){
            resultMap.put("synthesisProposal",dict(dictList,"device_index3"));
        }else if (deviceStatus==0&&oldIndex>0){
            resultMap.put("synthesisProposal",dict(dictList,"device_index2"));
        }else if (deviceStatus==0&&oldIndex==0){
            resultMap.put("synthesisProposal",dict(dictList,"device_index1"));
        }
        resultMap.put("deviceRunInfo",deviceOnLineList);
        resultMap.put("oldCheck",oldCheckInfoList);
        return resultMap;
    }
    public List<Map<String, Object>> patientDeviceNameList(String patient){
        String sql = "SELECT dd.category_code,dd.model,pd.device_name,dd.device_type AS deviceType  FROM dm_device dd " +
                " INNER JOIN wlyy_patient_device pd ON dd.category_code = pd.category_code INNER JOIN wlyy_devices wd ON dd.model = wd.device_model " +
                " AND pd.device_sn = wd.device_code  WHERE 1 = 1 AND pd.del = 0 AND pd.`user` = '"+patient+"' " +
                " GROUP BY dd.category_code ORDER BY dd.device_type DESC,pd.czrq ASC";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
@ -848,6 +957,8 @@ public class PatientInfoPlatFormService {
                    //在线状态实时获取
                    if (!response.getBoolean("online")) {//设备在线状态
                        detailInfo.put("contact_status",0);
                        //离线时间
                        detailInfo.put("offlineDate",DateUtil.getHours(new Date(),response.getJSONObject("lastlogin_at").getDate("$date")));
                    } else {
                        detailInfo.put("contact_status",1);
                    }
@ -859,12 +970,35 @@ public class PatientInfoPlatFormService {
                //手表步数数据
                sql = "select *,CAST(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') as char) create_time " +
                        " from base_patient_step where 1=1  and device_sn='"+deviceSn+"' ";
                pageSql =bl?" and create_time >= '"+beforeTime+"' and create_time <= '"+afterTime+"' order by create_time desc limit 1 ": " order by create_time desc limit 1 ";
                pageSql =bl?" and create_time >= '"+beforeTime+"' and create_time <= '"+afterTime+"' order by create_time desc limit 2 ": " order by create_time desc limit 2 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0) {
                    detailInfo.put("steps",sqlResult.get(0));
                    if (bl&&sqlResult.size()>=2) {
                        Integer steps1 = Integer.parseInt(sqlResult.get(0).get("steps").toString());
                        Integer steps2 = Integer.parseInt(sqlResult.get(1).get("steps").toString());
                        if (steps1>steps2) {
                            dictCode = "yd2";
                        }else{
                            dictCode = "yd3";
                        }
                        detailInfo.put("steps_status",zwsj);
                    }else if (!bl&&sqlResult.size()>=2){
                        Integer steps1 = Integer.parseInt(sqlResult.get(0).get("steps").toString());
                        Integer steps2 = Integer.parseInt(sqlResult.get(1).get("steps").toString());
                        if (steps1>steps2) {
                            dictCode = "yd2";
                        }else{
                            dictCode = "yd1";
                        }
                    }else {
                        dictCode = "ty3";
                    }
                    detailInfo.put("steps_status",dict(dictList,dictCode));
                }else {
                    detailInfo.put("steps","无步数数据");
                    detailInfo.put("steps",0);
                    detailInfo.put("steps_status",zwsj);
                }
                //手表心率数据
                sql = " select *,CAST(DATE_FORMAT(record_date,'%Y-%m-%d %H:%i:%S') as char) record_date,  " +
@ -877,7 +1011,7 @@ public class PatientInfoPlatFormService {
                    Integer xl = Integer.parseInt(sqlResult.get(0).get("value1").toString());
                    if (xl>=50&&xl<=100) {
                        dictCode= "xl1";
                        dictCode= "zc1";
                    }else if (xl<50){
                        dictCode="xl2";
                    }else if (xl>100){
@ -915,7 +1049,9 @@ public class PatientInfoPlatFormService {
                            }else {
                                detailInfo.put("isAtHome",dict(dictList,"ty4"));
                            }
                            detailInfo.put("homeRange",homeDistance * 1000);
                        }else {
                            detailInfo.put("homeRange",zwsj);
                            detailInfo.put("isAtHome",zwsj);
                        }
                        detailInfo.put("location", tmp);
@ -1014,7 +1150,7 @@ public class PatientInfoPlatFormService {
                                detailInfo.put("contact_status",1);
                            }
                            if (response.getBooleanValue("onbed")) {//当前在床状态
                                detailInfo.put("bedStatus", 1);
                                detailInfo.put("bedStatus", dict(dictList,"yachuang1"));
                                Integer heartRate = response.getInteger("heartrate");
                                Integer breath = response.getInteger("breathrate");
                                dictCode = "";
@ -1023,22 +1159,22 @@ public class PatientInfoPlatFormService {
                                } else if (heartRate < 50) {
                                    dictCode = "xl2";
                                } else if (heartRate >= 50 && heartRate <= 100) {
                                    dictCode = "xl1";
                                    dictCode = "zc1";
                                }
                                detailInfo.put("heartRate", heartRate);
                                detailInfo.put("breath", breath);
                                detailInfo.put("heartRate_status",dict(dictList,dictCode));
                                if (breath > 100) {
                                    dictCode = "xl3";
                                } else if (breath < 50) {
                                    dictCode = "xl2";
                                } else if (breath >= 50 && breath <= 100) {
                                    dictCode = "xl1";
                                if (breath > 20) {
                                    dictCode = "hx1";
                                } else if (breath < 10) {
                                    dictCode = "hx2";
                                } else if (breath >= 10 && breath <= 20) {
                                    dictCode = "zc1";
                                }
                                detailInfo.put("breath_status",dict(dictList,dictCode));
                            } else {
                                detailInfo.put("bedStatus", 0);
                                detailInfo.put("bedStatus", dict(dictList,"yachuang2"));
                                detailInfo.put("heartRate", zwsj);
                                detailInfo.put("breath", zwsj);
                            }
@ -1053,10 +1189,10 @@ public class PatientInfoPlatFormService {
                pageSql =bl?" and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' ORDER BY create_time desc   limit 1 ": " ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
                    detailInfo.put("warnStatus",dict(dictList,"yc1"));
                    detailInfo.put("orderInfo",sqlResult.get(0));
                }else {
                    detailInfo.put("warnStatus",false);
                    detailInfo.put("warnStatus",dict(dictList,"zc1"));
                }
                //获取最新一次燃气浓度
                if(bl){
@ -1080,10 +1216,10 @@ public class PatientInfoPlatFormService {
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    //烟雾浓度
                    detailInfo.put("value1_Status",dict(dictList,"yg1"));
                    detailInfo.put("value1_Status",dict(dictList,"yc1"));
                    detailInfo.put("orderInfo",sqlResult.get(0));
                }else {
                    detailInfo.put("value1_Status",dict(dictList,"yg2"));
                    detailInfo.put("value1_Status",dict(dictList,"zc1"));
                }
                //获取最新一次烟雾浓度
                if(bl){
@ -1108,9 +1244,9 @@ public class PatientInfoPlatFormService {
                dictCode ="";
                if (sqlResult.size()>0){
                    if (Integer.parseInt(sqlResult.get(0).get("temperature_value").toString())<50) {
                        dictCode = "yg4";
                        dictCode = "zc1";
                    }else {
                        dictCode = "yg3";
                        dictCode = "yc1";
                    }
                    detailInfo.putAll(sqlResult.get(0));
                    detailInfo.put("temperature_status",dict(dictList,dictCode));