Quellcode durchsuchen

设备详情数据加时间,监护数据加类型

xiaoyunquan vor 2 Jahren
Ursprung
Commit
6975ee7098

+ 16 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -1562,4 +1562,20 @@ public class DateUtil {
        return timeAgoStr;
    }
    /**
     * 获取指定时间的前后若干时间戳
     * list[0]前
     * list[1]后
     * @return
     */
    public static List<String> getTimeByBeforeAndAfterTime(String time,long l){
        List<String> list = new ArrayList<>();
        Date date = DateUtil.strToDate(time);
        Date beforeTime = new Date(date.getTime()-l);
        Date afterTime = new Date(date.getTime()+l);
        list.add(DateUtil.dateToStrLong(beforeTime));
        list.add(DateUtil.dateToStrLong(afterTime));
        return list;
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorDeviceController.java

@ -308,7 +308,7 @@ public class DoctorDeviceController extends BaseController {
			if(permissionService.noPermission(1,param)){
				return PageEnvelop.getSuccess("该操作没有权限");
			}
			return deviceManageService.getPatientMonitorData(patient,startTime,endTime,page,size);
			return deviceManageService.getPatientMonitorData(patient,startTime,endTime,page,size,null);
		} catch (Exception e) {
			e.printStackTrace();
			return PageEnvelop.getError("系统繁忙");

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

@ -518,7 +518,7 @@ public class PatientDeviceController extends BaseController {
			if(permissionService.noPermission(1,param)){
				return PageEnvelop.getSuccess("该操作没有权限");
			}
            return deviceManageService.getPatientMonitorData(patient,startTime,endTime,page,size);
            return deviceManageService.getPatientMonitorData(patient,startTime,endTime,page,size,null);
        } catch (Exception e) {
            e.printStackTrace();
            return PageEnvelop.getError("系统繁忙");

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/admin/AdminListInfoController.java

@ -52,7 +52,7 @@ public class AdminListInfoController extends EnvelopRestEndpoint {
                return ObjEnvelop.getError("该操作没有权限");
            }
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getPatientDeviceInfoWithDetail(patient,null));
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getPatientDeviceInfoWithDetail(patient,null,null));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }

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

@ -400,15 +400,17 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    public PageEnvelop getPatientMonitorData(@ApiParam(name = "patient", value = "patient")
                                             @RequestParam(value = "patient") String patient,
                                             @ApiParam(name = "startTime", value = "开始时间")
                                             @RequestParam(value = "startTime") String startTime,
                                             @RequestParam(value = "startTime",required = false) String startTime,
                                             @ApiParam(name = "endTime", value = "endTime")
                                             @RequestParam(value = "endTime") String endTime,
                                             @RequestParam(value = "endTime",required = false) String endTime,
                                             @ApiParam(name = "page", value = "page")
                                             @RequestParam(value = "page") Integer page,
                                             @ApiParam(name = "size", value = "size")
                                             @RequestParam(value = "size") Integer size) {
                                             @RequestParam(value = "size") Integer size,
                                             @ApiParam(name = "categoryCode",value = "设备类型")
                                             @RequestParam(value = "categoryCode",required = false)Integer categoryCode) {
        try {
            return deviceManageService.getPatientMonitorData(patient, startTime, endTime, page, size);
            return deviceManageService.getPatientMonitorData(patient, startTime, endTime, page, size,categoryCode);
        } catch (Exception e) {
            e.printStackTrace();
            return PageEnvelop.getError("系统繁忙");

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

@ -171,9 +171,11 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop getPatientDeviceInfoWithDetail(@ApiParam(name="patient",value = "居民id",required = false)
                                                     @RequestParam(value = "patient",required = false)String patient,
                                                     @ApiParam(name="deviceSn",value = "设备SN",required = false)
                                                     @RequestParam(value = "deviceSn",required = false)String deviceSn){
                                                     @RequestParam(value = "deviceSn",required = false)String deviceSn,
                                                     @ApiParam(name = "warnTime",value = "预警时间")
                                                     @RequestParam(value = "warnTime",required = false)String warnTime){
        try {
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getPatientDeviceInfoWithDetail(patient,deviceSn));
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getPatientDeviceInfoWithDetail(patient,deviceSn,warnTime));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }

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

@ -243,13 +243,22 @@ public class DeviceManageService extends BaseJpaService<BaseDeviceRepairEntity,B
     * @param size
     * @return
     */
    public PageEnvelop<List<Map<String,Object>>> getPatientMonitorData(String patient,String startTime,String endTime,Integer page,Integer size){
    public PageEnvelop<List<Map<String,Object>>> getPatientMonitorData(String patient,String startTime,String endTime,Integer page,Integer size,Integer categoryCode){
        page = page>0?page-1:0;
        String sql = " select dm.name,dm.photo,dm.category_code,modata.patient,modata.patient_name,modata.device_info,modata.relation_code, " +
                "modata.type,DATE_FORMAT(modata.create_time,'%Y-%m-%d %H:%i:%S') create_time  " ;
        String sqlFilter =  " from base_patient_monitor_data modata INNER JOIN wlyy_patient_device pd on modata.device_sn = pd.device_sn and pd.del=0 " +
                "INNER JOIN dm_device dm on pd.device_id = dm.id " +
                "where patient='"+patient+"' and create_time>='"+startTime+"' and create_time<='"+endTime+"' ";
                "where patient='"+patient+"' ";
        if(StringUtils.isNotBlank(startTime) ){
            sqlFilter += " and create_time>='"+startTime+"' ";
        }
        if(StringUtils.isNotBlank(endTime)){
            sqlFilter += " and create_time<='"+endTime+"' ";
        }
        if(categoryCode != null){
            sqlFilter += " and modata.category_code = "+categoryCode+" ";
        }
        String sqlCount = " select count(modata.id) ";
        sql = sql+sqlFilter +" ORDER BY modata.id desc limit "+page*size+","+size;
        Long total = jdbcTemplate.queryForObject(sqlCount+sqlFilter,Long.class);

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

@ -706,7 +706,7 @@ public class PatientInfoPlatFormService {
    /**
     *获取设备详情
     */
    public List<Map<String,Object>> getPatientDeviceInfoWithDetail(String patient,String deviceSn){
    public List<Map<String,Object>> getPatientDeviceInfoWithDetail(String patient,String deviceSn,String warnTime){
        List<Map<String,Object>>  list = new ArrayList<>();
        String sql = "select dd.photo,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime,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 \n" +
@ -723,7 +723,7 @@ public class PatientInfoPlatFormService {
        for (Map<String,Object> tmp :list){
            String category_code = tmp.get("category_code").toString();
            String deviceSN = tmp.get("device_sn").toString();
            Map<String,Object> detailInfo =  getDeviceIndexAndOrder(category_code,deviceSN,patient);
            Map<String,Object> detailInfo =  getDeviceIndexAndOrder(category_code,deviceSN,patient,warnTime);
            tmp.put("detailInfo",detailInfo);
        }
        return list;
@ -741,7 +741,18 @@ public class PatientInfoPlatFormService {
     * 血压2:最近一次收缩压,舒张压、在线状态
     * 血糖1:最近一次血糖、在线状态
     */
    public Map<String,Object> getDeviceIndexAndOrder(String category_code,String deviceSn,String patient){
    public Map<String,Object> getDeviceIndexAndOrder(String category_code,String deviceSn,String patient,String filterTime){
        String beforeTime = "";
        String afterTime = "";
        boolean bl = false;//是否进行时间范围查询
        String pageSql = "";
        if(StringUtils.isNotBlank(filterTime)){
            //获取前后三十分钟的时间
            List<String> timeList = DateUtil.getTimeByBeforeAndAfterTime(filterTime, 30 * 60 * 1000);
            beforeTime = timeList.get(0);
            afterTime = timeList.get(1);
            bl = true;
        }
        Map<String,Object> detailInfo = new HashMap<>();
        String sql = " select IFNULL(contact_status,0) contact_status from wlyy_devices where device_code='"+deviceSn+"' ";
        List<String> contact_status = jdbcTemplate.queryForList(sql,String.class);
@ -754,10 +765,15 @@ public class PatientInfoPlatFormService {
                sql = " select *,CAST(DATE_FORMAT(record_date,'%Y-%m-%d %H:%i:%S') as char) record_date,  " +
                        " CAST(DATE_FORMAT(sort_date,'%Y-%m-%d %H:%i:%S') as char) sort_date,  " +
                        " CAST(DATE_FORMAT(czrq,'%Y-%m-%d %H:%i:%S') as char) czrq from wlyy_patient_health_index " +
                        " where device_sn='"+deviceSn+"' and del=1 ORDER BY sort_date DESC LIMIT 1  ";
                List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
                        " where device_sn='"+deviceSn+"' and del=1  ";
                pageSql =bl?" and record_date >= '"+beforeTime+"' and record_date <= '"+afterTime+"' ORDER BY sort_date DESC ": " ORDER BY sort_date DESC LIMIT 1  ";
                List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("healthIndex",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("healthIndex",sqlResult.get(0));
                    }else {
                        detailInfo.put("healthIndexList",sqlResult);
                    }
                }else {
                    detailInfo.put("healthIndex",null);
                }
@ -766,10 +782,15 @@ public class PatientInfoPlatFormService {
                sql = " select *,CAST(DATE_FORMAT(record_date,'%Y-%m-%d %H:%i:%S') as char) record_date,  " +
                        " CAST(DATE_FORMAT(sort_date,'%Y-%m-%d %H:%i:%S') as char) sort_date,  " +
                        " CAST(DATE_FORMAT(czrq,'%Y-%m-%d %H:%i:%S') as char) czrq from wlyy_patient_health_index " +
                        " where device_sn='"+deviceSn+"' and del=1 ORDER BY sort_date DESC LIMIT 1  ";
                sqlResult = jdbcTemplate.queryForList(sql);
                        " where device_sn='"+deviceSn+"' and del=1  ";
                pageSql =bl?" and record_date >= '"+beforeTime+"' and record_date <= '"+afterTime+"' ORDER BY sort_date DESC ": " ORDER BY sort_date DESC LIMIT 1  ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("healthIndex",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("healthIndex",sqlResult.get(0));
                    }else {
                        detailInfo.put("healthIndexList",sqlResult);
                    }
                }else {
                    detailInfo.put("healthIndex",null);
                }
@ -783,10 +804,26 @@ public class PatientInfoPlatFormService {
                        " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order o " +
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 " +
                        "ORDER BY create_time desc limit 1 ";
                if(bl){
                    sql = "  select o.id,p.id patient,p.name,p.idcard,p.residential_area,'20' OrderType,'1' type,o.serve_address,'紧急呼叫' serve_desc,  " +
                            " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_emergency_assistance_order o " +
                            " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 " +
                            " and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' " +
                            " UNION " +
                            " select o.id,p.id patient,p.name,p.idcard,p.residential_area,'22' OrderType,'1' type,o.serve_address,o.serve_desc,  " +
                            " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order o " +
                            " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 " +
                            " and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' " +
                            " ORDER BY create_time desc ";
                }
                sqlResult = jdbcTemplate.queryForList(sql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
                    detailInfo.put("orderInfo",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("orderInfo",sqlResult.get(0));
                    }else {
                        detailInfo.put("orderInfo",sqlResult);
                    }
                }else {
                    detailInfo.put("warnStatus",false);
                }
@ -812,19 +849,27 @@ public class PatientInfoPlatFormService {
                    detailInfo.put("wear_flagName", null);
                    detailInfo.put("remaining_power",null);
                }
                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+"' order by create_time desc limit 1";
                sqlResult = jdbcTemplate.queryForList(sql);
                //手表步数数据
                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 ": " order by create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0) {
                    detailInfo.put("steps",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("steps",sqlResult.get(0));
                    }else {
                        detailInfo.put("stepsList",sqlResult);
                    }
                }else {
                    detailInfo.put("steps","无步数数据");
                }
                //手表心率数据
                sql = " select *,CAST(DATE_FORMAT(record_date,'%Y-%m-%d %H:%i:%S') as char) record_date,  " +
                        " CAST(DATE_FORMAT(sort_date,'%Y-%m-%d %H:%i:%S') as char) sort_date,  " +
                        " CAST(DATE_FORMAT(czrq,'%Y-%m-%d %H:%i:%S') as char) czrq from wlyy_patient_health_index " +
                        " where type=5 and device_sn='"+deviceSn+"' and del=1 ORDER BY sort_date DESC LIMIT 1  ";
                sqlResult = jdbcTemplate.queryForList(sql);
                        " where type=5 and device_sn='"+deviceSn+"' and del=1   ";
                pageSql =bl?" and record_date >= '"+beforeTime+"' and record_date <= '"+afterTime+"'  ORDER BY sort_date DESC ": " ORDER BY sort_date DESC LIMIT 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("heartRate",sqlResult.get(0));
                }else {
@ -850,11 +895,16 @@ public class PatientInfoPlatFormService {
            case "7"://报警器 电量  是否报警、在线状态
                sql = "  select o.id,p.id patient,p.name,p.idcard,p.residential_area,'20' OrderType,'1' type,o.serve_address,'紧急呼叫' serve_desc,  " +
                        " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_emergency_assistance_order o " +
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql);
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1  ";
                pageSql =bl?" and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"'  ORDER BY create_time desc ": " ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
                    detailInfo.put("orderInfo",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("orderInfo",sqlResult.get(0));
                    }else {
                        detailInfo.put("orderInfoList",sqlResult);
                    }
                }else {
                    detailInfo.put("warnStatus",false);
                }
@ -875,12 +925,16 @@ public class PatientInfoPlatFormService {
            case "12"://监控
                sql = " select o.id,p.id patient,p.name,p.idcard,p.residential_area,'22' OrderType,'1' type,o.serve_address,o.serve_desc,  " +
                     " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order o " +
                     " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 " +
                     "ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql);
                     " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 ";
                pageSql =bl?" and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' ORDER BY create_time desc ": " ORDER BY create_time desc limit 1  ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
                    detailInfo.put("orderInfo",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("orderInfo",sqlResult.get(0));
                    }else {
                        detailInfo.put("orderInfoList",sqlResult);
                    }
                }else {
                    detailInfo.put("warnStatus",false);
                }
@ -897,12 +951,16 @@ public class PatientInfoPlatFormService {
            case "13"://床带 是否压床、 心率和呼吸频率、在线状态
                sql = " select o.id,p.id patient,p.name,p.idcard,p.residential_area,'22' OrderType,'1' type,o.serve_address,o.serve_desc,  " +
                        " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order o " +
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 " +
                        "ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql);
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 ";
                pageSql =bl?" and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' ORDER BY create_time desc ": " ORDER BY create_time desc limit 1  ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
                    detailInfo.put("orderInfo",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("orderInfo",sqlResult.get(0));
                    }else{
                        detailInfo.put("orderInfoList",sqlResult);
                    }
                }else {
                    detailInfo.put("warnStatus",false);
                }
@ -933,12 +991,16 @@ public class PatientInfoPlatFormService {
            case "14"://燃气
                sql = " select o.id,p.id patient,p.name,p.idcard,p.residential_area,'22' OrderType,'1' type,o.serve_address,o.serve_desc,  " +
                        " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order o " +
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 " +
                        "ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql);
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 ";
                pageSql =bl?" and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' ORDER BY create_time desc  ": " ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
                    detailInfo.put("orderInfo",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("orderInfo",sqlResult.get(0));
                    }else {
                        detailInfo.put("orderInfoList",sqlResult);
                    }
                }else {
                    detailInfo.put("warnStatus",false);
                }
@ -955,12 +1017,16 @@ public class PatientInfoPlatFormService {
            case "15"://烟感
                sql = " select o.id,p.id patient,p.name,p.idcard,p.residential_area,'22' OrderType,'1' type,o.serve_address,o.serve_desc,  " +
                        " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order o " +
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 " +
                        "ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql);
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 ";
                pageSql =bl?" and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' ORDER BY create_time desc  ": " ORDER BY create_time desc limit 1  ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
                    detailInfo.put("orderInfo",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("orderInfo",sqlResult.get(0));
                    }else {
                        detailInfo.put("orderInfoList",sqlResult);
                    }
                }else {
                    detailInfo.put("warnStatus",false);
                }
@ -994,17 +1060,39 @@ public class PatientInfoPlatFormService {
                        " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order o " +
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1  " +
                        "ORDER BY create_time desc limit 1 ";
                if(bl){
                    sql = "  select o.id,p.id patient,p.name,p.idcard,p.residential_area,'20' OrderType,'1' type,o.serve_address,'紧急呼叫' serve_desc,  " +
                            " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_emergency_assistance_order o " +
                            " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1 " +
                            " and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' " +
                            " UNION " +
                            " select o.id,p.id patient,p.name,p.idcard,p.residential_area,'22' OrderType,'1' type,o.serve_address,o.serve_desc,  " +
                            " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order o " +
                            " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1  " +
                            " and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' " +
                            "ORDER BY create_time desc  ";
                }
                sqlResult = jdbcTemplate.queryForList(sql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
                    detailInfo.put("orderInfo",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("orderInfo",sqlResult.get(0));
                    }else {
                        detailInfo.put("orderInfoList",sqlResult);
                    }
                }else {
                    detailInfo.put("warnStatus",false);
                }
                sql = "SELECT *,CAST(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') as char) create_time FROM base_yxdevice_index  WHERE sn = '" + deviceSn + "' AND lon != 0 AND lat != 0 ORDER BY create_time DESC limit 1";
                sqlResult = jdbcTemplate.queryForList(sql);
                sql = "SELECT *,CAST(DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') as char) create_time FROM base_yxdevice_index  " +
                        " WHERE sn = '" + deviceSn + "' AND lon != 0 AND lat != 0 ";
                pageSql =bl?" and create_time >= '"+beforeTime+"' and create_time <= '"+afterTime+"'  ORDER BY create_time ": " ORDER BY create_time DESC limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("newlonlat",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("newlonlat",sqlResult.get(0));
                    }else {
                        detailInfo.put("newlonlatList",sqlResult);
                    }
                    String address = LatitudeUtils.getLocationAddress(sqlResult.get(0).get("lat").toString(), sqlResult.get(0).get("lon").toString());
//                    JSONObject dz =  gpsUtil.gcj02_To_Bd09(Double.parseDouble(sqlResult.get(0).get("lat").toString()),Double.parseDouble(sqlResult.get(0).get("lon").toString()));
                    detailInfo.put("location", address);
@ -1016,36 +1104,49 @@ public class PatientInfoPlatFormService {
            case "18"://日常用水监测
                sql = " select o.id,p.id patient,p.name,p.idcard,p.residential_area,'22' OrderType,'1' type,o.serve_address,o.serve_desc,  " +
                      " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order o " +
                      " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1  " +
                      "ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql);
                      " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1  ";
                pageSql =bl?" and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' ORDER BY create_time desc " : " ORDER BY create_time desc limit 1  ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
                    detailInfo.put("orderInfo",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("orderInfo",sqlResult.get(0));
                    }else {
                        detailInfo.put("orderInfoList",sqlResult);
                    }
                }else {
                    detailInfo.put("warnStatus",false);
                }
            case "19"://门禁监测
                sql = " select o.id,p.id patient,p.name,p.idcard,p.residential_area,'22' OrderType,'1' type,o.serve_address,o.serve_desc,  " +
                        " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order o " +
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1  " +
                        "ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql);
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1  ";
                pageSql = bl?" and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' ORDER BY create_time desc  ":" ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
                    detailInfo.put("orderInfo",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("orderInfo",sqlResult.get(0));
                    }else {
                        detailInfo.put("orderInfoList",sqlResult);
                    }
                }else {
                    detailInfo.put("warnStatus",false);
                }
            case "20"://电表监测
                sql = " select o.id,p.id patient,p.name,p.idcard,p.residential_area,'22' OrderType,'1' type,o.serve_address,o.serve_desc,  " +
                        " o.status,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') create_time from base_security_monitoring_order o " +
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1  " +
                        "ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql);
                        " INNER JOIN base_patient p on p.id = o.patient where device_sn='"+deviceSn+"' and o.status=1  ";
                pageSql = bl?" and o.create_time >= '"+beforeTime+"' and o.create_time <= '"+afterTime+"' ORDER BY create_time desc ":" ORDER BY create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
                    detailInfo.put("orderInfo",sqlResult.get(0));
                    if(!bl){
                        detailInfo.put("orderInfo",sqlResult.get(0));
                    }else {
                        detailInfo.put("orderInfoList",sqlResult);
                    }
                }else {
                    detailInfo.put("warnStatus",false);
                }