liubing 3 gadi atpakaļ
vecāks
revīzija
1bfbe9462b

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientHealthIndex.java

@ -35,8 +35,8 @@ public class DevicePatientHealthIndex extends IdEntity {
	private String value6;
	// 睡前
	private String value7;
	// 健康指标类型(1血糖,2血压,3体重/身高/BMI,4腰围,5心率,6体温)
	// 健康指标类型(1血糖,2血压,3体重/身高/BMI,4腰围,5心率,6体温,7呼吸)
	private Integer type;
	// 记录时间
	private Date recordDate;

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

@ -948,6 +948,13 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            Map<String, Object> devInfo = jdbcTemplate.queryForMap(sql);
            devInfo.put("patient", patient);
            devInfo.put("sosContactsDOS", new ArrayList<>());
            //v1.4获取设备在线状态、数据采集量、异常指标量、 、
            //v1.4获取其绑定设备的居民列表 //todo 各平台全部对接后外层无用字段删除(患者相关,如patientName,orgCode等)
            String dataSql = "";
            String recordSql = "";
            List<Map<String, Object>> dataList = new ArrayList<>();

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

@ -296,6 +296,7 @@ public class DeviceController {
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带接收,请求参数:"+paraString+"\n"+(endTime-startTime)+"ms");
            dataPushLogUtil.savePushLog(device,paraString,"睡眠带数据接收");
            deviceService.sleepHealthIndex(device,heartrate,breath,time_begin);
            return success();
        } catch (Exception e) {
            e.printStackTrace();

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

@ -30,6 +30,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
@ -37,6 +38,7 @@ import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import javax.servlet.http.HttpServletRequest;
import java.text.MessageFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -144,8 +146,14 @@ public class DeviceService {
    public void aqgsos(String imei,String label_mac,String time_begin, HttpServletRequest request) {
        try {
            String address= request.getParameter("address");
            Double lat= Double.parseDouble(request.getParameter("lat"));
            Double lon= Double.parseDouble(request.getParameter("lon"));
            Double lat= null;
            Double lon= null;
            if (null==request.getParameter("lat")||null==request.getParameter("lon")){//呼叫时可能无该参数
            }else {
                lat= Double.parseDouble(request.getParameter("lat"));
                lon= Double.parseDouble(request.getParameter("lon"));
            }
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
            if (devicePatientDeviceDos.size()>0){
                DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
@ -158,10 +166,27 @@ public class DeviceService {
                logDO.setDeviceSn(deviceDO.getDeviceSn());
                logDO.setCreateTime(new Date());
                if (deviceDO.getCategoryCode().equals("4")) {
                    JSONObject position = gpsUtil.gcj02_To_Bd09(lat,lon);
                    logDO.setSosAddress(address);
                    logDO.setSosLat(position.getDouble("lat")+"");
                    logDO.setSosLon(position.getDouble("lon")+"");
                    if (null==lat||null==lon){//获取最新定位
                        String url = cloudCareUrl+"cloudCare/noLogin/device/getDeviceLastLocation";
                        List<NameValuePair> params = new ArrayList<>();
                        params.add(new BasicNameValuePair("deviceSn", imei));
                        String response = httpClientUtil.get(url, params,"UTF-8");
                        JSONObject resObj = JSONObject.parseObject(response);
                        if (resObj.getInteger("status")==200){
                            lat = resObj.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getJSONObject("point").getDouble("lat");
                            lon = resObj.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getJSONObject("point").getDouble("lon");
                            address = resObj.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getString("address").replace(" ","");
                            logDO.setSosAddress(address);
                            logDO.setSosLat(lat+"");
                            logDO.setSosLon(lon+"");
                        }
                    }
                    else {
                        JSONObject position = gpsUtil.gcj02_To_Bd09(lat,lon);
                        logDO.setSosAddress(address);
                        logDO.setSosLat(position.getDouble("lat")+"");
                        logDO.setSosLon(position.getDouble("lon")+"");
                    }
                }
                if (deviceDO.getCategoryCode().equals("7")) {
                    logDO.setSosAddress(deviceDO.getSosAddress());
@ -620,6 +645,7 @@ public class DeviceService {
                                        planDetail.setBedStatus(1);
                                        planDetail.setBreath(breath);
                                        planDetail.setHeartRate(heartrate);
                                        sleepPlanDetailDao.save(planDetail);
                                        outBedOrder(null, timeDate,devicePatientDeviceDos.get(0), patient, device, "超时未起床", JSON.toJSONStringWithDateFormat(planDetail, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
                                        orderCreate = true;
                                    }
@ -634,6 +660,7 @@ public class DeviceService {
                                    if (timeDiffer>3600*siestaLongWarn*1000){
                                        planDetail.setSiestaStatus(0);
                                        planDetail.setBedStatus(0);
                                        sleepPlanDetailDao.save(planDetail);
                                        outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"超时未午睡",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                        orderCreate=true;
                                    }
@ -658,6 +685,7 @@ public class DeviceService {
                                            planDetail.setSiestaTimeEnd(timeDate);//设置临时结束时间但不计算时长 避免重复发起工单
                                            planDetail.setBreath(breath);
                                            planDetail.setHeartRate(heartrate);
                                            sleepPlanDetailDao.save(planDetail);
                                            outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"午睡超时未起床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                            orderCreate=true;
                                        }
@ -698,6 +726,7 @@ public class DeviceService {
                                        planDetail.setInStatus(0);
                                        planDetail.setBedStatus(1);
                                        planDetail.setSleepNightRecordList(nightRecord.findBySnPaTime(device,patient,dayTime));
                                        sleepPlanDetailDao.save(planDetail);
                                        outBedOrder(null,timeDate,devicePatientDeviceDos.get(0),patient,device,"超时未上床晚休",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                        orderCreate=true;
                                    }
@ -716,6 +745,7 @@ public class DeviceService {
                                        if (timeDiffer>3600*nightLongWarn*1000&&0==records.get(0).getStatus()){//超过2未回床小时 触发工单
                                            planDetail.setSleepNightRecordList(nightRecord.findBySnPaTime(device,patient,dayTime));
                                            planDetail.setBedStatus(0);
                                            sleepPlanDetailDao.save(planDetail);
                                            outBedOrder(records.get(0),timeDate,devicePatientDeviceDos.get(0),patient,device,"起夜超时未回床",JSON.toJSONStringWithDateFormat(planDetail,"yyyy-MM-dd HH:mm:ss",SerializerFeature.WriteMapNullValue));
                                            orderCreate=true;
                                        }
@ -901,9 +931,52 @@ public class DeviceService {
        }
    }
    public static void main(String[] args) {
        String ss="123123,2323";
        System.out.println(String.join(",",ss));
    //睡眠带心率呼吸数据
    @Async
    public void sleepHealthIndex(String device,String heartrate,String breath,String time_begin) {
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
        if (devicePatientDeviceDos.size() > 0) {
            if (StringUtils.isNotBlank(heartrate)) {
                if (!"0".equals(heartrate)) {
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(devicePatientDevice.getUser());
                    DevicePatientHealthIndex patientHealthIndex = new DevicePatientHealthIndex();
                    patientHealthIndex.setName(patientDO.getName());
                    patientHealthIndex.setDeviceSn(device);
                    patientHealthIndex.setUser(devicePatientDevice.getUser());
                    patientHealthIndex.setIdcard(devicePatientDevice.getUserIdcard());
                    patientHealthIndex.setValue1(heartrate + "");
                    patientHealthIndex.setType(5);
                    Date recordDate = DateUtil.strToDate(time_begin);
                    patientHealthIndex.setRecordDate(recordDate);
                    patientHealthIndex.setSortDate(recordDate);
                    patientHealthIndex.setCzrq(new Date());
                    patientHealthIndex.setStatus(0);
                    patientHealthIndex.setDel("1");
                    healthIndexDao.save(patientHealthIndex);
                }
            }
            if (StringUtils.isNotBlank(breath)){
                if (!"0".equals(breath)){
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(devicePatientDevice.getUser());
                    DevicePatientHealthIndex patientHealthIndex = new DevicePatientHealthIndex();
                    patientHealthIndex.setName(patientDO.getName());
                    patientHealthIndex.setDeviceSn(device);
                    patientHealthIndex.setUser(devicePatientDevice.getUser());
                    patientHealthIndex.setIdcard(devicePatientDevice.getUserIdcard());
                    patientHealthIndex.setValue1(heartrate + "");
                    patientHealthIndex.setType(7);
                    Date recordDate = DateUtil.strToDate(time_begin);
                    patientHealthIndex.setRecordDate(recordDate);
                    patientHealthIndex.setSortDate(recordDate);
                    patientHealthIndex.setCzrq(new Date());
                    patientHealthIndex.setStatus(0);
                    patientHealthIndex.setDel("1");
                    healthIndexDao.save(patientHealthIndex);
                }
            }
        }
    }
}