|
@ -4,8 +4,11 @@ package com.yihu.jw.care.service.device;
|
|
|
import com.yihu.jw.care.config.AqgConfig;
|
|
|
import com.yihu.jw.care.dao.device.DeviceDao;
|
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
|
import com.yihu.jw.care.dao.device.WlyyDeviceDao;
|
|
|
import com.yihu.jw.entity.care.device.Device;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
|
import com.yihu.jw.restmodel.iot.device.WlyyDeviceVO;
|
|
|
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
|
|
|
import com.yihu.jw.util.common.GpsUtil;
|
|
|
import com.yihu.jw.util.http.HttpClientUtil;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@ -16,12 +19,14 @@ 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.stereotype.Component;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.text.MessageFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
@ -41,6 +46,10 @@ public class PatientDeviceService {
|
|
|
private GpsUtil gpsUtil;
|
|
|
@Autowired
|
|
|
private DeviceDao deviceDao;
|
|
|
@Autowired
|
|
|
private WlyyDeviceDao wlyyDeviceDao;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
Map<Integer, String> relations = new HashMap<>();
|
|
|
|
|
@ -218,4 +227,59 @@ public class PatientDeviceService {
|
|
|
|
|
|
/******************************************* 爱牵挂设备end *****************************************************/
|
|
|
|
|
|
|
|
|
/**************************************物联网检测大屏失联率start************************************************/
|
|
|
public void selectAndUpdate(){
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String endTime = sdf.format(new Date());
|
|
|
Calendar device1 = Calendar.getInstance();
|
|
|
device1.setTime(new Date());
|
|
|
device1.add(device1.DATE, -30);
|
|
|
Date nowDate = device1.getTime();
|
|
|
String startTimeDevice1 = sdf.format(nowDate);
|
|
|
|
|
|
Calendar device2 = Calendar.getInstance();
|
|
|
device2.setTime(new Date());
|
|
|
device2.add(device2.DATE, -2);
|
|
|
Date nowDate2 = device2.getTime();
|
|
|
String startTimeDevice2 = sdf.format(nowDate2);
|
|
|
try {
|
|
|
/**血糖仪**/
|
|
|
String sql1 = "SELECT pd.device_sn FROM base.wlyy_patient_device pd WHERE (SELECT COUNT(1) FROM base.wlyy_patient_health_index WHERE \n" +
|
|
|
"record_date BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"' ) = 0 AND del = 0 AND category_code = 1";
|
|
|
List<Map<String , Object>> list1 = jdbcTemplate.queryForList(sql1);
|
|
|
if (list1.size() > 0) {
|
|
|
for (int i=0;i<list1.size();i++) {
|
|
|
wlyyDeviceDao.updateContactStatus(new Date(), (String) list1.get(i).get("device_sn"));
|
|
|
}
|
|
|
}
|
|
|
/**血压计**/
|
|
|
String sql2 = "SELECT pd.device_sn FROM base.wlyy_patient_device pd WHERE (SELECT COUNT(1) FROM base.wlyy_patient_health_index WHERE \n" +
|
|
|
"record_date BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"' ) = 0 AND del = 0 AND category_code = 2";
|
|
|
List<Map<String , Object>> list2 = jdbcTemplate.queryForList(sql2);
|
|
|
if (list2.size() > 0) {
|
|
|
for (int i=0;i<list2.size();i++) {
|
|
|
wlyyDeviceDao.updateContactStatus(new Date(), (String) list2.get(i).get("device_sn"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**智能手表**/
|
|
|
//startTimeDevice2 2天
|
|
|
|
|
|
/**智能拐杖**/
|
|
|
String sql3 = "SELECT pd.device_sn FROM base.wlyy_patient_device pd WHERE (SELECT COUNT(1) FROM base.base_yxdevice_index WHERE \n" +
|
|
|
"create_time BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"' ) = 0 AND del = 0 AND category_code = 16";
|
|
|
List<Map<String , Object>> list3 = jdbcTemplate.queryForList(sql3);
|
|
|
if (list3.size() > 0) {
|
|
|
for (int i=0;i<list3.size();i++) {
|
|
|
wlyyDeviceDao.updateContactStatus(new Date(), (String) list3.get(i).get("device_sn"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
logger.info(e.getMessage());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|