Browse Source

大屏部分

liubing 3 năm trước cách đây
mục cha
commit
b79418da82

+ 1 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BaseSleepDeviceReportDao.java

@ -8,5 +8,4 @@ import org.springframework.data.repository.PagingAndSortingRepository;
 * Created by Bing on 2021/8/12.
 * Created by Bing on 2021/8/12.
 */
 */
public interface BaseSleepDeviceReportDao extends PagingAndSortingRepository<BaseSleepDeviceReport,Long> ,
public interface BaseSleepDeviceReportDao extends PagingAndSortingRepository<BaseSleepDeviceReport,Long> ,
        JpaSpecificationExecutor<BaseSleepDeviceReport> {
}
        JpaSpecificationExecutor<BaseSleepDeviceReport> {}

+ 22 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java

@ -13,6 +13,7 @@ import com.yihu.jw.entity.care.device.BaseSleepPlan;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
@ -435,6 +436,27 @@ public class PatientDeviceController extends BaseController {
        }
        }
    }
    }
    @ApiOperation("获取睡眠带睡眠报告")
    @RequestMapping(value ="getSleepReport",method = RequestMethod.GET)
    public String getSleepReport(@ApiParam(name="patient")@RequestParam(value = "patient",required = false)String patient,
                                     @ApiParam(name="deviceSn")@RequestParam(value = "deviceSn",required = false)String deviceSn,
                                     @ApiParam(name="day")@RequestParam(value = "day",required = false)String day){
        try {
            if (StringUtils.isBlank(patient)&&StringUtils.isBlank(deviceSn)){
                return error(-1,"请求参数");
            }
            JSONObject result = patientDeviceService.getSleepReport(patient,deviceSn,day);
            if (ResponseContant.success==result.getInt(ResponseContant.resultFlag)){
                return write(200,"获取成功","data",result.getJSONObject(ResponseContant.resultMsg));
            }else {
                return error(-1,result.getString(ResponseContant.resultMsg));
            }
        }catch (Exception e){
            return errorResult(e);
        }
    }
    @ApiOperation("获取设备详情数据 --设备可多人绑定查询数据时与patient无关")
    @ApiOperation("获取设备详情数据 --设备可多人绑定查询数据时与patient无关")
    @RequestMapping(value = "getPatientDeviceData",method = RequestMethod.GET)
    @RequestMapping(value = "getPatientDeviceData",method = RequestMethod.GET)
    public String getPatientDeviceData(@ApiParam(name="patient")
    public String getPatientDeviceData(@ApiParam(name="patient")

+ 32 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java

@ -15,6 +15,7 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.*;
@ -174,6 +175,37 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
        }
        }
    }
    }
    @ApiOperation("获取睡眠带睡眠报告")
    @RequestMapping(value ="getSleepReport",method = RequestMethod.GET)
    public ObjEnvelop getSleepReport(@ApiParam(name="patient")@RequestParam(value = "patient",required = false)String patient,
                                     @ApiParam(name="deviceSn")@RequestParam(value = "deviceSn",required = false)String deviceSn,
                                     @ApiParam(name="day")@RequestParam(value = "day",required = false)String day){
        try {
            if (StringUtils.isBlank(patient)&&StringUtils.isBlank(deviceSn)){
                return ObjEnvelop.getError("请求参数");
            }
            org.json.JSONObject result = patientDeviceService.getSleepReport(patient,deviceSn,day);
            if (ResponseContant.success==result.getInt(ResponseContant.resultFlag)){
                return ObjEnvelop.getSuccess("获取成功",result.get(ResponseContant.resultMsg));
            }else {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @ApiOperation("获取烟雾/燃气浓度列表")
    @RequestMapping(value ="getSmokeOrGasList",method = RequestMethod.GET)
    public ListEnvelop getSmokeOrGasList(@ApiParam(name="deviceSn")@RequestParam(value = "deviceSn",required = true)String deviceSn,
                                         @ApiParam(name="day",value = "yyyy-MM-dd")@RequestParam(value = "day",required = false)String day){
        try {
            return ListEnvelop.getSuccess("获取成功",patientDeviceService.getSmokeOrGasList(deviceSn,day));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    /********************v1.1.0**************************/
    /********************v1.1.0**************************/
    @GetMapping(value = "getGiveEarlyWarning")
    @GetMapping(value = "getGiveEarlyWarning")

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

@ -44,6 +44,7 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Transactional;
@ -949,11 +950,52 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            devInfo.put("patient", patient);
            devInfo.put("patient", patient);
            devInfo.put("sosContactsDOS", new ArrayList<>());
            devInfo.put("sosContactsDOS", new ArrayList<>());
            //v1.4获取设备在线状态、数据采集量、异常指标量、 、
            //v1.4获取其绑定设备的居民列表 //todo 各平台全部对接后外层无用字段删除(患者相关,如patientName,orgCode等)
            //v1.4获取设备在线状态、数据采集量、异常指标量、
            sql =" select contact_status  from wlyy_devices where device_code='"+deviceSn+"' ";
            List<String> onLineStatus = jdbcTemplate.queryForList(sql,String.class);
            if (onLineStatus.size()>0){
                devInfo.put("contactStatus",onLineStatus.get(0));
            }else {
                devInfo.put("contactStatus",0);//在线状态
            }
            //数据采集量
            if(1==device.getDeviceType()){//安防设备
                sql = " select count(id) from device_data_push_log where device_sn='"+deviceSn+"' ";
                Long dataCount = jdbcTemplate.queryForObject(sql,Long.class);
                devInfo.put("dataCount",dataCount);//
                sql = " select sum(total) from (\n" +
                        "select count(id) total from base_emergency_assistance_order where device_sn='"+deviceSn+"'\n" +
                        "UNION ALL\n" +
                        "select count(id) total from base_security_monitoring_order where device_sn='"+deviceSn+"'" +
                        ")A ";
                Long orderCount = jdbcTemplate.queryForObject(sql,Long.class);
                devInfo.put("errorCount",orderCount);//         //异常量
            }else if (2==device.getDeviceType()){//健康设备
                sql = " select count(id) from wlyy_patient_health_index where device_sn ='"+deviceSn+"' ";
                Long dataCount = jdbcTemplate.queryForObject(sql,Long.class);
                devInfo.put("dataCount",dataCount);//异常量
                sql += " and status =1 ";
                dataCount = jdbcTemplate.queryForObject(sql,Long.class);
                devInfo.put("errorCount",dataCount);//异常量
            }
            //v1.4获取其绑定设备的居民列表 //todo 各平台全部对接后外层无用字段删除(患者相关,如patientName,orgCode等)
            sql =" select  p.id patient,p.photo,p.name,case p.sex when 1 then '男' when 2 then '女' else sex end as sex,TIMESTAMPDIFF(year,p.birthday,now()) as age, \n" +
                    "p.residential_area residentialArea,p.mobile,p.idcard,p.address from base_patient p INNER JOIN wlyy_patient_device pd on p.id = pd.user and pd.del=0  " +
                    "where 1=1 and pd.device_sn='"+deviceSn+"' ";
            List<Map<String,Object>> patientList = jdbcTemplate.queryForList(sql);
            for (Map<String,Object>map :patientList){
                String patientStr = map.get("patient").toString();
                sql ="SELECT GROUP_CONCAT(Distinct sp.org_name) orgName FROM base_service_package_record spr INNER JOIN base_service_package sp on " +
                        " spr.service_package_id = sp.id AND spr.patient = '"+patientStr+"' where sp.org_code " +
                        " IS NOT NULL GROUP BY spr.patient ";
                List<String> orgs = jdbcTemplate.queryForList(sql,String.class);
                if (orgs.size()>0){
                    map.put("orgName", orgs.get(0));
                }
            }
            devInfo.put("patientList",patientList);
            String dataSql = "";
            String dataSql = "";
            String recordSql = "";
            String recordSql = "";
@ -1098,6 +1140,93 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return result;
        return result;
    }
    }
    /**
     * 获取睡眠带 睡眠报告
     * @param patient
     * @param deviceSn
     * @param day
     * @return
     */
    public JSONObject getSleepReport(String patient,String deviceSn,String day){
        JSONObject result = new JSONObject();
        String sql = " select * from base_sleep_device where 1=1 ";
        if (StringUtils.isNotBlank(patient)){
            sql +=" and patient='"+patient+"'";
        }
        if (StringUtils.isNotBlank(deviceSn)){
            sql += " and device_sn='"+deviceSn+"' ";
        }
        if (StringUtils.isNotBlank(day)){
            sql +=" and create_time>="+day+" 00:00:00 and create_time<'"+day+"' 23:59:59 ";
        }else   {
            sql +=" order by create_time desc ";
        }
        sql +=" limit 1 ";
        List<BaseSleepDeviceReport> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper<>(BaseSleepDeviceReport.class));
        if (list.size()>0){
            result.put(ResponseContant.resultFlag,ResponseContant.success);
            result.put(ResponseContant.resultMsg,list.get(0));
        }else {
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"无睡眠记录");
        }
        return result;
    }
    public List<Map<String,Object>> getSmokeOrGasList(String deviceSn,String day){
        List<Map<String,Object>> result = new ArrayList<>();
        Date now = new Date();
        String nowDay =  DateUtil.getStringDateShort();
        if (StringUtils.isBlank(day)){
            day = nowDay;
        }
        String timeBeginStr = day+" 00:00:00";
        String timeEndStr = "";
        if (nowDay.equals(day)){//同一天
            timeEndStr = DateUtil.dateToStr(now,DateUtil.yyyy_MM_dd_HH_mm_ss);
        }else {
            timeEndStr = day+ " 23:59:59";
        }
        Date timeBegin = DateUtil.strToDate(timeBeginStr,DateUtil.yyyy_MM_dd_HH_mm_ss);
        Date timeEnd = DateUtil.strToDate(timeEndStr,DateUtil.yyyy_MM_dd_HH_mm_ss);
        String sql = " SELECT r.value,CAST(DATE_FORMAT(r.create_time,'%Y-%m-%d %H:%i:%S') as char) create_time " +
                " from wlyy_patient_device pd,base_device_health_index r WHERE pd.device_sn = r.device_sn " +
                " and r.device_sn='"+deviceSn+"' order by r.create_time asc";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        //遍历时间区间,无数据时间点产生数据
        int i=0; //list遍历索引
        int length = list.size();
        Date prTimeBegin = timeBegin;
        Date listIndexTime = null;
        if (length>0){
            listIndexTime = DateUtil.strToDate(list.get(0).get("create_time").toString(),DateUtil.yyyy_MM_dd_HH_mm_ss);
        }
        for (;timeEnd.after(timeBegin);){
            timeBegin =  DateUtil.getNextMin(timeBegin,15);
            Map<String,Object> map = new HashMap<>();
            if (length>0&&i<length){
                if ((prTimeBegin.before(listIndexTime)||prTimeBegin.equals(listIndexTime))&&(timeBegin.after(listIndexTime)||timeBegin.equals(listIndexTime))){
                    map.put("value",Double.parseDouble( list.get(i).get("value").toString()));
                    map.put("createTime",list.get(i).get("create_time").toString());
                    i++;
                    if (i<length){
                        listIndexTime = DateUtil.strToDate(list.get(i).get("create_time").toString(),DateUtil.yyyy_MM_dd_HH_mm_ss);
                    }
                }else {
                    map.put("value",0.00);
                    map.put("createTime",DateUtil.dateToStr(timeBegin,DateUtil.yyyy_MM_dd_HH_mm_ss));
                }
            }else {
                map.put("value",0.00);
                map.put("createTime",DateUtil.dateToStr(timeBegin,DateUtil.yyyy_MM_dd_HH_mm_ss));
            }
            result.add(map);
        }
        return result;
    }
    /**
    /**
     * 根据设备sn及居民code获取居民有效的设备绑定数据
     * 根据设备sn及居民code获取居民有效的设备绑定数据
     * @param deviceSn 设备sn码
     * @param deviceSn 设备sn码
@ -1260,6 +1389,10 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            long count = jdbcTemplate.queryForObject(sqlCount,long.class);
            long count = jdbcTemplate.queryForObject(sqlCount,long.class);
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            for (Map<String,Object> map:list){
            }
            String str = JSON.toJSONString(list,SerializerFeature.WriteMapNullValue);
            String str = JSON.toJSONString(list,SerializerFeature.WriteMapNullValue);
            com.alibaba.fastjson.JSONArray arr = com.alibaba.fastjson.JSONArray.parseArray(str);
            com.alibaba.fastjson.JSONArray arr = com.alibaba.fastjson.JSONArray.parseArray(str);
@ -1316,7 +1449,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            Date dateNow = new Date();
            Date dateNow = new Date();
            Date dateNow1 = DateUtil.strToDate(DateUtil.getStringDateShort()+" 08:00:00");
            Date dateNow1 = DateUtil.strToDate(DateUtil.getStringDateShort()+" 08:00:00");
            Date dateNow2 = DateUtil.strToDate(DateUtil.getStringDateShort()+" 20:00:00");
            Date dateNow2 = DateUtil.strToDate(DateUtil.getStringDateShort()+" 20:00:00");
            List<String> noWarnDays = new ArrayList<>();
            List<String> noWarnDays = new ArrayList<>();//无预警记录
            String dateTmp = "";
            String dateTmp = "";
            if (dateNow.after(dateNow1)){
            if (dateNow.after(dateNow1)){
                dateTmp = DateUtil.dateToStr(dateNow1,DateUtil.yyyy_MM_dd_HH_mm_ss);
                dateTmp = DateUtil.dateToStr(dateNow1,DateUtil.yyyy_MM_dd_HH_mm_ss);

+ 1 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/prescription/BaseCarePrescriptionService.java

@ -55,6 +55,7 @@ public class BaseCarePrescriptionService {
                "     case p.sex " +
                "     case p.sex " +
                "     when 1 then '男'  " +
                "     when 1 then '男'  " +
                "     when 2 then '女' " +
                "     when 2 then '女' " +
                "     else sex "+
                "     end AS sex," +
                "     end AS sex," +
                "     'prescription' as type, " +
                "     'prescription' as type, " +
                "     TIMESTAMPDIFF(year,p.birthday,NOW()) AS age  ";
                "     TIMESTAMPDIFF(year,p.birthday,NOW()) AS age  ";

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

@ -936,6 +936,10 @@ public class DeviceService {
    public void sleepHealthIndex(String device,String heartrate,String breath,String time_begin) {
    public void sleepHealthIndex(String device,String heartrate,String breath,String time_begin) {
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
        if (devicePatientDeviceDos.size() > 0) {
        if (devicePatientDeviceDos.size() > 0) {
            Integer theshold_breath_h = 25;
            Integer theshold_breath_l = 8;
            Integer theshold_heartrate_h = 100;
            Integer theshold_heartrate_l = 50;
            if (StringUtils.isNotBlank(heartrate)) {
            if (StringUtils.isNotBlank(heartrate)) {
                if (!"0".equals(heartrate)) {
                if (!"0".equals(heartrate)) {
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
@ -952,6 +956,13 @@ public class DeviceService {
                    patientHealthIndex.setSortDate(recordDate);
                    patientHealthIndex.setSortDate(recordDate);
                    patientHealthIndex.setCzrq(new Date());
                    patientHealthIndex.setCzrq(new Date());
                    patientHealthIndex.setStatus(0);
                    patientHealthIndex.setStatus(0);
                    Integer heartrate1 = Integer.parseInt(heartrate);
                    if (heartrate1>theshold_heartrate_h||theshold_heartrate_h<theshold_heartrate_l){
                        patientHealthIndex.setStatus(1);
                    }
                    else {
                        patientHealthIndex.setStatus(0);
                    }
                    patientHealthIndex.setDel("1");
                    patientHealthIndex.setDel("1");
                    healthIndexDao.save(patientHealthIndex);
                    healthIndexDao.save(patientHealthIndex);
                }
                }
@ -971,6 +982,12 @@ public class DeviceService {
                    patientHealthIndex.setRecordDate(recordDate);
                    patientHealthIndex.setRecordDate(recordDate);
                    patientHealthIndex.setSortDate(recordDate);
                    patientHealthIndex.setSortDate(recordDate);
                    patientHealthIndex.setCzrq(new Date());
                    patientHealthIndex.setCzrq(new Date());
                    Integer breath1 = Integer.parseInt(breath);
                    if (breath1>theshold_breath_h||breath1<theshold_breath_l){
                        patientHealthIndex.setStatus(1);
                    }else {
                        patientHealthIndex.setStatus(0);
                    }
                    patientHealthIndex.setStatus(0);
                    patientHealthIndex.setStatus(0);
                    patientHealthIndex.setDel("1");
                    patientHealthIndex.setDel("1");
                    healthIndexDao.save(patientHealthIndex);
                    healthIndexDao.save(patientHealthIndex);

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

@ -214,7 +214,6 @@ public class YsDeviceService {
                                if ("tumble_detection".equals(alarmType)){//tumble_detection跌倒类型    //有人出现SmartHumanDet
                                if ("tumble_detection".equals(alarmType)){//tumble_detection跌倒类型    //有人出现SmartHumanDet
                                    fallFlag = true;
                                    fallFlag = true;
                                    deviceSN = bodyJsonObj2.getString("devSerial");//设备SN
                                    deviceSN = bodyJsonObj2.getString("devSerial");//设备SN
                                    dataPushLogUtil.savePushLog(deviceSN,bodyJsonObj.toJSONString(bodyJsonObj,SerializerFeature.WriteMapNullValue),"萤石监控跌倒数据接收");
                                    if (bodyJsonObj2.containsKey("pictureList")&&bodyJsonObj2.getJSONArray("pictureList")!=null){
                                    if (bodyJsonObj2.containsKey("pictureList")&&bodyJsonObj2.getJSONArray("pictureList")!=null){
                                        JSONArray pictureList = bodyJsonObj2.getJSONArray("pictureList");
                                        JSONArray pictureList = bodyJsonObj2.getJSONArray("pictureList");
                                        if (pictureList.size()>0){
                                        if (pictureList.size()>0){
@ -260,6 +259,7 @@ public class YsDeviceService {
                String deviceSN = bodyJsonObj2.getString("devSerial");//设备SN
                String deviceSN = bodyJsonObj2.getString("devSerial");//设备SN
                DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviceSN);
                DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviceSN);
                dataPushLogUtil.savePushLog(deviceSN,bodyJsonObj.toJSONString(bodyJsonObj,SerializerFeature.WriteMapNullValue),"跌倒监护摄像头数据接收");
                if (deviceDetail!=null){
                if (deviceDetail!=null){
                    deviceDetail.setContactStatus(1);
                    deviceDetail.setContactStatus(1);
                    deviceDetailDao.save(deviceDetail);
                    deviceDetailDao.save(deviceDetail);