Browse Source

代码修改

liubing 3 years ago
parent
commit
6346b69185

+ 3 - 3
common/common-entity/sql记录

@ -1368,12 +1368,12 @@ CREATE TABLE `base_sleep_plan_detail` (
  `siesta_time_end` timestamp NULL DEFAULT NULL COMMENT '午睡结束时间',
  `siesta_long` varchar(10) DEFAULT NULL COMMENT '午睡时长 单位秒',
  `in_status` varchar(10) DEFAULT NULL COMMENT '睡觉状态 0未入床 1已入床',
  `in_time_begin` varchar(10) DEFAULT NULL COMMENT '夜眠开始时间',
  `in_time_end` varchar(10) DEFAULT NULL COMMENT '夜眠结束时间 ',
  `in_time_begin` timestamp null DEFAULT NULL COMMENT '夜眠开始时间',
  `in_time_end` timestamp null DEFAULT NULL COMMENT '夜眠结束时间 ',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建日期',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新日期',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='睡眠带监测计划详情';
-- 20210824
alter table base_security_monitoring_order add COLUMN warn_info varchar(255) DEFAULT NULL COMMENT '触发工单时信息如 烟雾心率等';
alter table base_security_monitoring_order add COLUMN warn_info varchar(3000) DEFAULT NULL COMMENT '触发工单时信息如 烟雾心率等';

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

@ -350,19 +350,31 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        }
        if (5==orderDO.getOrderSource()){//睡眠带工单
            try {
                JSONObject monitorInfo = patientSignTopicInfo(null,orderDO.getPatient(),"preventOutOfBed");
                Map<String,Object> tmp = JSONObject.parseObject(objectMapper.writeValueAsString(monitorInfo));
                if ("true".equals( tmp.get("sleepStatus").toString())){
                    Map<String,Object> sleepInfo = (Map<String, Object>) tmp.get("sleepInfo");
                    sleepInfo.put("outBedTime","30分钟");
                }
                emergencyOrderVO.setInformation(tmp);
                JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall");
                emergencyOrderVO.setInformation(monitorInfo);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        if (6==orderDO.getOrderSource()){//气感工单
            try {
                JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall");
                emergencyOrderVO.setInformation(monitorInfo);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        if (7==orderDO.getOrderSource()){//烟感工单
            try {
                JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall");
                emergencyOrderVO.setInformation(monitorInfo);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        //TODO 火灾、燃气、离床专题返回值
        // http://192.168.1.103:85/%E5%8C%BB%E5%85%BB%E7%BB%93%E5%90%88/V0.7.0/#g=1&p=%E6%96%B0%E5%AE%89%E9%98%B2%E5%8C%85
        //通知对象
        List<Map<String,Object>> noticePersons = new ArrayList<>();

+ 34 - 34
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

@ -571,13 +571,10 @@ public class DeviceService {
                    }
                    if (null!=sleepPlan){
                        Date timeDate = DateUtil.strToDate(time_begin);//当前时间
                        //12点以后
                        Calendar today = Calendar.getInstance();
                        today.set(Calendar.HOUR_OF_DAY, 4);
                        today.set(Calendar.MINUTE, 59);
                        today.set(Calendar.SECOND, 59);
                        today.set(Calendar.MILLISECOND, 999);
                        Date bedUp = DateUtil.strToDate(DateUtil.getStringDateShort()+" "+sleepPlan.getGetUpTime());// 起床时间 起床前一小时内算为起床
                        Date bedUp = DateUtil.strToDate(DateUtil.getStringDateShort()+" "+sleepPlan.getGetUpTime()+":00");// 起床时间 起床前一小时内算为起床
                        if (timeDate.before(bedUp)){
                            bedUp = DateUtil.getNextDay1(bedUp,-1);
                        }
                        Date bedUpBegin = DateUtil.getNextMin(bedUp,-60);//起床时间 起床前一小时内算为起床
                        Date bedUpEnd = DateUtil.getNextMin(bedUp,60*3);//起床时间 起床后一小时内算为起床
                        boolean needSiesta=false;// 是否有午睡习惯
@ -585,18 +582,18 @@ public class DeviceService {
                        Date SiestaBegin = null;// 午睡开始时间
                        if (StringUtils.isNotBlank(sleepPlan.getNapTime())){
                            needSiesta=true;
                            SiestaTime = DateUtil.strToDate(DateUtil.getStringDateShort()+" "+sleepPlan.getNapTime());
                            SiestaTime = DateUtil.strToDate(DateUtil.getStringDateShort()+" "+sleepPlan.getNapTime()+":00");
                            SiestaBegin = DateUtil.getNextMin(SiestaTime,-60);// 午睡开始时间
                        }
                        String dayTime = DateUtil.dateToStr(bedUp,DateUtil.YYYY_MM_DD);//监测日期
                        String inTime = sleepPlan.getNightRestTime();
                        Date bedIn = null;// 入睡时间
                        Date bedBegin = null;// 入睡开始时间
                        String dayTime = DateUtil.dateToStr(bedUp,DateUtil.YYYY_MM_DD);//监测日期
                        if (inTime.charAt(0)=='0') {
                            bedIn = DateUtil.strToDate(dayTime+" "+sleepPlan.getNightRestTime());
                            bedIn = DateUtil.strToDate(dayTime+" "+sleepPlan.getNightRestTime()+":00");
                            bedIn = DateUtil.getNextDay1(bedIn,1);
                        }else {
                            bedIn = DateUtil.strToDate(dayTime+" "+sleepPlan.getNightRestTime());
                            bedIn = DateUtil.strToDate(dayTime+" "+sleepPlan.getNightRestTime()+":00");
                        }
                        bedBegin = DateUtil.getNextMin(bedIn,-60*2);
                        List<BaseSleepPlanDetail> planDetails = sleepPlanDetailDao.findByDay(dayTime);
@ -625,7 +622,7 @@ public class DeviceService {
                                        planDetail.setBedStatus(0);
                                        planDetail.setBreath(breath);
                                        planDetail.setHeartRate(heartrate);
                                        outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"超时未起床",JSON.toJSONString(planDetail,SerializerFeature.WriteMapNullValue));
                                        outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"超时未起床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                        orderCreate=true;
                                    }
                                }
@ -634,20 +631,21 @@ public class DeviceService {
                        /***午睡***/
                        if(needSiesta&&DateUtil.isInArea(timeDate,SiestaBegin,bedIn)){//午睡时段
                            if ("0".equals(bed_status)){
                                if(1==planDetail.getSiestaStatus()&&null==planDetail.getSiestaTimeEnd()){//午睡起床
                                    planDetail.setSiestaTimeEnd(timeDate);
                                    timeDiffer = (planDetail.getSiestaTimeEnd().getTime()-planDetail.getSiestaTimeBegin().getTime())/1000;
                                    planDetail.setSiestaLong(timeDiffer+"");
                                }
                                else if (null==planDetail.getSiestaStatus()){//超时未午睡午睡
                                if (null==planDetail.getSiestaStatus()){//超时未午睡午睡
                                    timeDiffer = timeDate.getTime() - SiestaTime.getTime();
                                    if (0<timeDiffer&&timeDiffer<3600*siestaLongWarn*1000){
                                    if (timeDiffer>3600*siestaLongWarn*1000){
                                        planDetail.setSiestaStatus(0);
                                        planDetail.setBedStatus(0);
                                        outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"超时未午睡",JSON.toJSONString(planDetail,SerializerFeature.WriteMapNullValue));
                                        outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"超时未午睡",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                        orderCreate=true;
                                    }
                                }
                                else if(1 == planDetail.getSiestaStatus()&&null==planDetail.getSiestaTimeEnd()){//午睡起床
                                    planDetail.setSiestaTimeEnd(timeDate);
                                    timeDiffer = (planDetail.getSiestaTimeEnd().getTime()-planDetail.getSiestaTimeBegin().getTime())/1000;
                                    planDetail.setSiestaLong(timeDiffer+"");
                                }
                            }
                            if ("1".equals(bed_status)){
                                if (null==planDetail.getSiestaStatus()){
@ -660,7 +658,7 @@ public class DeviceService {
                                        planDetail.setBedStatus(0);
                                        planDetail.setBreath(breath);
                                        planDetail.setHeartRate(heartrate);
                                        outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"午睡超时未起床",JSON.toJSONString(planDetail,SerializerFeature.WriteMapNullValue));
                                        outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"午睡超时未起床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                        orderCreate=true;
                                    }
                                }
@ -668,7 +666,7 @@ public class DeviceService {
                        }
                        /**晚休***/
                        timeDiffer = timeDate.getTime() - bedBegin.getTime();
                        if (timeDiffer>0&&timeDate.before(bedUp)){ //起夜记录
                        if (timeDiffer>0&&timeDate.after(bedBegin)){ //起夜记录
                            BaseSleepNightRecord record = new BaseSleepNightRecord();
                            if ("1".equals(bed_status)){
                                if (null==planDetail.getInStatus()){
@ -690,7 +688,17 @@ public class DeviceService {
                            }
                            if ("0".equals(bed_status)){//离床
                                List<BaseSleepNightRecord> records = nightRecord.findBySnStaPaTime(device,patient,0,bedIn);
                                if (1==planDetail.getInStatus()){
                                if(null==planDetail.getInStatus()){
                                    timeDiffer = timeDate.getTime() - bedIn.getTime();
                                    if (timeDiffer>3600*nightLongWarn*1000){
                                        planDetail.setInStatus(0);
                                        planDetail.setBedStatus(1);
                                        planDetail.setSleepNightRecordList(records);
                                        outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"超时未上床晚休",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                        orderCreate=true;
                                    }
                                }
                                else if (1==planDetail.getInStatus()){
                                    if (records.size()==0){
                                        record.setPatient(devicePatientDeviceDos.get(0).getUser());
                                        record.setDeviceSn(device);
@ -704,18 +712,10 @@ public class DeviceService {
                                        if (timeDiffer>3600*nightLongWarn*1000){//超过2未回床小时 触发工单
                                            planDetail.setSleepNightRecordList(records);
                                            planDetail.setBedStatus(0);
                                            outBedOrder(records.get(0),devicePatientDeviceDos.get(0),patient,device,"起夜超时未回床",JSON.toJSONString(planDetail,SerializerFeature.WriteMapNullValue));
                                            outBedOrder(records.get(0),devicePatientDeviceDos.get(0),patient,device,"起夜超时未回床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                            orderCreate=true;
                                        }
                                    }
                                }else if(null==planDetail.getInStatus()){
                                    timeDiffer = timeDate.getTime() - bedIn.getTime();
                                    if (0<timeDiffer&&timeDiffer<3600*nightLongWarn*1000){
                                        planDetail.setSiestaStatus(0);
                                        planDetail.setBedStatus(1);
                                        outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"超时未上床晚休",JSON.toJSONString(planDetail,SerializerFeature.WriteMapNullValue));
                                        orderCreate=true;
                                    }
                                }
                            }
                        }
@ -735,7 +735,7 @@ public class DeviceService {
                                    planDetail.setBreath(breath);
                                    planDetail.setHeartRate(heartrate);
                                    planDetail.setBedStatus(1);
                                    outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"心率和呼吸频率异常",JSON.toJSONString(planDetail,SerializerFeature.WriteMapNullValue));
                                    outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"心率和呼吸频率异常",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                    return null;
                                }
                            }
@ -745,7 +745,7 @@ public class DeviceService {
                                    planDetail.setBreath(breath);
                                    planDetail.setHeartRate(heartrate);
                                    planDetail.setBedStatus(1);
                                    outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"心率和呼吸频率异常",JSON.toJSONString(planDetail,SerializerFeature.WriteMapNullValue));
                                    outBedOrder(null,devicePatientDeviceDos.get(0),patient,device,"心率和呼吸频率异常",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                    return null;
                                }
                            }

+ 7 - 2
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/HvDeviceService.java

@ -3,6 +3,7 @@ package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.dao.device.DeviceHealthIndexDao;
import com.yihu.jw.care.dao.device.HvDeviceRecordDao;
import com.yihu.jw.care.dao.device.HvDeviceSosLogDao;
@ -96,12 +97,16 @@ public class HvDeviceService {
            }
            if("600006".equals(deviceType)){
                //独立式可燃气体探测器(NB)
                ysDeviceService.createOrder(resourceSerial,null,new JSONObject(),6,"11","preventGasLeakage");
                JSONObject tmp = new JSONObject();
                tmp.put("gas",monitorValue);
                ysDeviceService.createOrder(resourceSerial,null,new JSONObject(),6,"11","preventGasLeakage",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
            }
            if("600002".equals(deviceType)){
                //独立式光电感烟探测器(NB)
                ysDeviceService.createOrder(resourceSerial,null,new JSONObject(),7,"10","preventFire");
                JSONObject tmp = new JSONObject();
                tmp.put("smoke",monitorValue);
                ysDeviceService.createOrder(resourceSerial,null,new JSONObject(),7,"10","preventFire",JSON.toJSONString(tmp, SerializerFeature.WriteMapNullValue));
            }
        }

+ 3 - 2
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java

@ -137,7 +137,7 @@ public class YsDeviceService {
                }
            }
            if (fallFlag){//发起安防工单
                result = createOrder(deviceSN,sceneUrl,result,4,"2","preventFall");
                result = createOrder(deviceSN,sceneUrl,result,4,"2","preventFall",null);
            }
        }catch (Exception e){
            e.printStackTrace();
@ -148,7 +148,7 @@ public class YsDeviceService {
    }
    public JSONObject createOrder(String deviceSN,String sceneUrl,JSONObject result,Integer orderSource,String dictCode,String topicItem){
    public JSONObject createOrder(String deviceSN,String sceneUrl,JSONObject result,Integer orderSource,String dictCode,String topicItem,String warnInfo){
        try {
            String lat = "";
            String lon = "";
@ -192,6 +192,7 @@ public class YsDeviceService {
                jsonObject.put("serveLon",lon);
                jsonObject.put("topicItem",topicItem);
                jsonObject.put("deviceSn",deviceSN);
                jsonObject.put("warnInfo",warnInfo);
                if (StringUtils.isNotBlank(sceneUrl)){
                    jsonObject.put("sceneImg",sceneUrl);
                }