瀏覽代碼

Merge branch 'dev' of xiaoyunquan/wlyy2.0 into dev

chinawu123 2 年之前
父節點
當前提交
de3dd3213a

+ 10 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/emergency/EmergencyOrderVO.java

@ -59,6 +59,16 @@ public class EmergencyOrderVO {
    private Integer OrderType;//20紧急 22安防
    private Integer know;//知悉 1已知悉 0未知悉
    private String serveDesc;//服务描述
    public String getServeDesc() {
        return serveDesc;
    }
    public void setServeDesc(String serveDesc) {
        this.serveDesc = serveDesc;
    }
    public String getId() {
        return id;
    }

+ 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);
        }

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -591,7 +591,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        emergencyOrderVO.setOtherDoctorDistance(otherDoctorDistance.toJSONString());
        emergencyOrderVO.setNoticePersons(noticePersons);
        JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONStringWithDateFormat(emergencyOrderVO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
        jsonObject.put("serveDesc","紧急呼叫");
        //获取咨询
        ConsultDo consult = consultDao.queryByRelationCode(orderID);
        if (null != consult) {

+ 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);

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

@ -380,6 +380,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                break;
        }
        emergencyOrderVO.setStatusName(statusName);
        emergencyOrderVO.setServeDesc(orderDO.getServeDesc());
        emergencyOrderVO.setOrderId(orderID);
        emergencyOrderVO.setStatus(orderDO.getStatus());
        emergencyOrderVO.setCreateTime(orderDO.getCreateTime());

+ 152 - 46
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);
@ -749,16 +760,14 @@ public class PatientInfoPlatFormService {
        if (contact_status.size()>0){
            detailInfo.put("contact_status",contact_status.get(0));
        }
        BasePatientDO patientDO = patientDao.findById(patient);
        switch (category_code){
            case "1"://血糖 最近一次血糖、在线状态
                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 limit 1 ": " 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));
                }else {
@ -769,8 +778,9 @@ 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 limit 1 ": " ORDER BY sort_date DESC LIMIT 1  ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("healthIndex",sqlResult.get(0));
                }else {
@ -786,6 +796,18 @@ 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 limit 1 ";
                }
                sqlResult = jdbcTemplate.queryForList(sql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
@ -815,19 +837,23 @@ 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 limit 1 ": " order by create_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0) {
                    detailInfo.put("steps",sqlResult.get(0));
                }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 limit 1 ": " ORDER BY sort_date DESC LIMIT 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("heartRate",sqlResult.get(0));
                }else {
@ -846,6 +872,23 @@ public class PatientInfoPlatFormService {
                        tmp.put("city", dw.getString("last_city"));
                        tmp.put("province", dw.getString("last_province"));
                        tmp.put("address", dw.getString("last_address"));
                        Long aLong = dw.getJSONObject("created_at").getLong("$date");
                        tmp.put("createTime",aLong==null?"":DateUtil.dateToStrLong(new Date(aLong)));
                        //获取居民家庭定位
                        BasePatientDO p = patientDao.findById(patient);
                        if(p != null && StringUtils.isNotBlank(p.getHomeLatLon())){
                            String homeLatLon = p.getHomeLatLon();
                            double homeLat = Double.parseDouble(homeLatLon.split(",")[0]);
                            double homeLon = Double.parseDouble(homeLatLon.split(",")[1]);
                            double homeDistance = countDistance.getDistance(homeLat,homeLon,lat,lon);
                            if (homeDistance * 1000 > 50) {
                                detailInfo.put("isAtHome","离家");
                            }else {
                                detailInfo.put("isAtHome","居家");
                            }
                        }else {
                            detailInfo.put("isAtHome","");
                        }
                        detailInfo.put("location", tmp);
                    }
                }
@ -853,8 +896,9 @@ 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  limit 1 ": " 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));
@ -878,9 +922,9 @@ 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  limit 1 ": " 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));
@ -900,9 +944,9 @@ 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  limit 1 ": " 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));
@ -936,9 +980,9 @@ 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   limit 1 ": " 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));
@ -958,9 +1002,9 @@ 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  limit 1  ": " 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));
@ -997,6 +1041,18 @@ 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  limit 1  ";
                }
                sqlResult = jdbcTemplate.queryForList(sql);
                if (sqlResult.size()>0){
                    detailInfo.put("warnStatus",true);
@ -1004,24 +1060,43 @@ public class PatientInfoPlatFormService {
                }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  limit 1 ": " ORDER BY create_time DESC limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if (sqlResult.size()>0){
                    detailInfo.put("newlonlat",sqlResult.get(0));
                    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);
                    //判断是否居家
                    BasePatientDO p = patientDao.findById(patient);
                    if(p != null && StringUtils.isNotBlank(p.getHomeLatLon())){
                        String homeLatLon = p.getHomeLatLon();
                        double homeLat = Double.parseDouble(homeLatLon.split(",")[0]);
                        double homeLon = Double.parseDouble(homeLatLon.split(",")[1]);
                        double homeDistance = countDistance.getDistance(homeLat,homeLon,Double.parseDouble(sqlResult.get(0).get("lat").toString()),(Double.parseDouble(sqlResult.get(0).get("lon").toString())));
                        if (homeDistance * 1000 > 50) {
                            detailInfo.put("isAtHome","离家");
                        }else {
                            detailInfo.put("isAtHome","居家");
                        }
                    }else {
                        detailInfo.put("isAtHome","");
                    }
                }else {
                    detailInfo.put("newlonlat",null);
                    detailInfo.put("location", null);
                    detailInfo.put("isAtHome","");
                }
                break;
            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  limit 1 " : " 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));
@ -1032,22 +1107,36 @@ public class PatientInfoPlatFormService {
            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));
                }else {
                    detailInfo.put("warnStatus",false);
                }
                //门禁数据
                sql = " SELECT f.img,CAST(DATE_FORMAT(f.pass_time,'%Y-%m-%d %H:%i:%S') as char) passTime,p.name,f.patient from base_device_face_record f " +
                        " inner join base_patient p on f.patient = p.id " +
                        " where f.patient = '"+patient+"' ";
                pageSql = bl?" and f.pass_time >= '"+beforeTime+"' and f.pass_time <= '"+afterTime+"' ORDER BY f.pass_time desc  limit 1 ":" ORDER BY f.pass_time desc limit 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if(sqlResult.size()>0){
                    detailInfo.putAll(sqlResult.get(0));
                }else {
                    detailInfo.put("img","");
                    detailInfo.put("passTime","");
                    detailInfo.put("name","");
                    detailInfo.put("patient","");
                }
                break;
            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  limit 1 ":" 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));
@ -1055,12 +1144,29 @@ public class PatientInfoPlatFormService {
                    detailInfo.put("warnStatus",false);
                }
                break;
            case "21"://电表监测
                if(patientDO!=null){
                    String idcard = patientDO.getIdcard();
                    sql = "SELECT syndyqzl,syndfy,lszyql from hz.gsq_hzrqjmyhglxtrqgrxx WHERE yhsfzh =? ORDER BY tongid desc LIMIT 1 " ;
                    sqlResult = jdbcTemplate.queryForList(sql,new Object[]{idcard});
                    detailInfo.put("naturalGasRecord",sqlResult);
            case "21"://todo 天然气
                /*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  ";
                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("orderInfo",sqlResult.get(0));
                }else {
                    detailInfo.put("warnStatus",false);
                }*/
                sql = " SELECT g.syndyqzl,g.syndfy,g.lszyql,CAST(DATE_FORMAT(g.tong_time,'%Y-%m-%d %H:%i:%S') as char) as createTime from hz.gsq_hzrqjmyhglxtrqgrxx g " +
                        " inner join base.base_patient p on g.yhsfzh = p.idcard " +
                        " where p.id = '"+patient+"' ";
                pageSql = bl?" and g.tong_time >= '"+beforeTime+"' and g.tong_time <= '"+afterTime+"' ORDER BY g.tongid desc LIMIT 1 ":" ORDER BY g.tongid desc LIMIT 1 ";
                sqlResult = jdbcTemplate.queryForList(sql+pageSql);
                if(sqlResult.size() >0 ){
                    detailInfo.putAll(sqlResult.get(0));
                }else {
                    detailInfo.put("syndyqzl","");
                    detailInfo.put("syndfy","");
                    detailInfo.put("lszyql","");
                }
        }
        return detailInfo;

+ 1 - 1
svr/svr-wlyy-specialist/src/main/java/com/yihu/jw/service/rehabilitation/RehabilitationManageService.java

@ -504,7 +504,7 @@ public class RehabilitationManageService {
        sql = TransforSqlUtl.wlyy_rehabilitation_plan_detailAll2(sql);
        List<Map<String,Object>> rehabilitationDetailList = jdbcTemplate.queryForList(sql);
        String planPatientSql = " SELECT patient FROM wlyy_specialist.wlyy_rehabilitation_plan_detail WHERE id in ("+planCondition+" )";
        String planPatientSql = " SELECT patient FROM wlyy_specialist.wlyy_patient_rehabilitation_plan WHERE id in ("+planCondition+" )";
        List<Map<String, Object>> patientCodeList = jdbcTemplate.queryForList(planPatientSql);
        List<Map<String, Object>> list = null;