|
@ -5,10 +5,12 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.yihu.jw.care.config.AqgConfig;
|
|
|
import com.yihu.jw.care.dao.device.BaseSleepDeviceReportDao;
|
|
|
import com.yihu.jw.care.dao.device.DevicePatientHealthIndexDao;
|
|
|
import com.yihu.jw.care.dao.device.DeviceSosLogDao;
|
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.device.BaseSleepDeviceReport;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
|
import com.yihu.jw.entity.care.device.DeviceSosLogDO;
|
|
@ -76,6 +78,8 @@ public class DeviceService {
|
|
|
private HealthIndexUtil healthIndexUtil;
|
|
|
@Autowired
|
|
|
private ImUtil imUtil;
|
|
|
@Autowired
|
|
|
private BaseSleepDeviceReportDao sleepDeviceReportDao;
|
|
|
|
|
|
/**
|
|
|
* 获取爱牵挂管理员cookie
|
|
@ -158,10 +162,10 @@ public class DeviceService {
|
|
|
}
|
|
|
}
|
|
|
//发送紧急救助
|
|
|
String sql =" select Distinct item.org_code,item.org_name\n" +
|
|
|
String sql =" select Distinct pack.org_code,pack.org_name\n" +
|
|
|
"from base_service_package_sign_record sr INNER JOIN base_service_package_record pr\n" +
|
|
|
"on sr.id = pr.sign_id and sr.status=1 INNER JOIN base_service_package_item item on pr.service_package_id = item.service_package_id and item.del=1 \n" +
|
|
|
"where item.code='emergencyAssistance' and sr.patient='"+patientDO.getId()+"'";
|
|
|
"INNER JOIN base_service_package pack pack on pr.service_package_id = pack.id where item.code='emergencyAssistance' and sr.patient='"+patientDO.getId()+"'";
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
if (sqlResult.size()>0){
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
@ -264,7 +268,7 @@ public class DeviceService {
|
|
|
Double lon = jsonObjectData.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getJSONObject("point").getDouble("lon");
|
|
|
String address = jsonObjectData.getJSONObject("data").getJSONObject("obj").getJSONObject("locationdata").getString("address");
|
|
|
|
|
|
String sql ="select DISTINCT item.org_code,item.org_name\n" +
|
|
|
String sql ="select DISTINCT pack.org_code,pack.org_name\n" +
|
|
|
" from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack\n" +
|
|
|
"where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id \tand item.`code`='preventLost' and item.service_package_id = pack.id \n" +
|
|
|
" and pack.del=1";
|
|
@ -551,7 +555,55 @@ public class DeviceService {
|
|
|
public void bySleep(String device,String time_begin,String heartrate,String breath,String turn_over,String is_warn) {
|
|
|
try {
|
|
|
if(StringUtils.isNotBlank(device)){
|
|
|
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
|
|
|
if (devicePatientDeviceDos.size()>0){
|
|
|
if ("1".equals(is_warn)){//触发安防工单
|
|
|
BasePatientDO patientDO = patientDao.findById(devicePatientDeviceDos.get(0).getUser());
|
|
|
if(null==patientDO){
|
|
|
String sql ="select DISTINCT pack.org_code,pack.org_name\n" +
|
|
|
" from base_service_package_sign_record sr,base_service_package_record pr,base_service_package_item item ,base_service_package pack\n" +
|
|
|
"where pr.patient = '"+patientDO.getId()+"' and sr.id = pr.sign_id and pr.service_package_id = item.service_package_id \tand item.`code`='preventOutOfBed' and item.service_package_id = pack.id \n" +
|
|
|
" and pack.del=1";
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
Map<String, String> json = null;
|
|
|
String address= devicePatientDeviceDos.get(0).getSosAddress();
|
|
|
if (StringUtils.isNotBlank(devicePatientDeviceDos.get(0).getSosAddress())) {
|
|
|
json = LatitudeUtils.getGeocoderLatitude(address.replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
|
|
|
}
|
|
|
String lat=null;
|
|
|
String lng=null;
|
|
|
if (json != null) {
|
|
|
lat= json.get("lat".toString());
|
|
|
lng = json.get("lng".toString());
|
|
|
}
|
|
|
Map<String,Object> map = new HashMap();
|
|
|
String url = cloudCareUrl+"/cloudCare/noLogin/security/createOrder";
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("patient",patientDO.getId());
|
|
|
jsonObject.put("patientName",patientDO.getName());
|
|
|
jsonObject.put("patientPhone",patientDO.getMobile());
|
|
|
jsonObject.put("serveDesc","疑似发生意外");
|
|
|
jsonObject.put("hospital",sqlResult.get(0).get("org_code"));
|
|
|
jsonObject.put("serveAddress",address.replace(" ",""));
|
|
|
jsonObject.put("serveLat",lat);
|
|
|
jsonObject.put("serveLon",lng);
|
|
|
jsonObject.put("topicItem","preventOutOfBed");
|
|
|
jsonObject.put("deviceSn",device);
|
|
|
JSONObject jsonObjectParam = new JSONObject();
|
|
|
jsonObjectParam.put("order", jsonObject);
|
|
|
map.put("jsonData", jsonObjectParam.toJSONString());
|
|
|
map.put("orderSource", 5);
|
|
|
map.put("warnStr", "疑似发生意外");
|
|
|
|
|
|
String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
|
|
|
String postParams = AesEncryptUtils.agEncrypt(content);
|
|
|
String response = httpClientUtil.postBodyRawForm(url,postParams);
|
|
|
JSONObject result = com.alibaba.fastjson.JSONObject.parseObject(response);
|
|
|
JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
|
|
|
System.out.println(jsonObjectData.toJSONString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
@ -561,12 +613,52 @@ public class DeviceService {
|
|
|
|
|
|
|
|
|
@Async
|
|
|
public void bySleepReport(String device,String date,String fallasleep,String sleepTime,String restTime,String awakeTime,String lightTime,
|
|
|
public void bySleepReport(String device,String dateStr,String fallasleep,String sleepTime,String restTime,String awakeTime,String lightTime,
|
|
|
String remTime,String deepTime,String[] bucket,String avghr,String avgbr,String awakePer,String remPer,String lightPer,
|
|
|
String efficiency,String score) {
|
|
|
try {
|
|
|
if(StringUtils.isNotBlank(device)){
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
|
|
|
if (devicePatientDeviceDos.size()>0){
|
|
|
String patient = devicePatientDeviceDos.get(0).getUser();
|
|
|
BaseSleepDeviceReport report = new BaseSleepDeviceReport();
|
|
|
report.setPatient(patient);
|
|
|
Date date = DateUtil.strToDate(dateStr,DateUtil.YYYYMMDD);
|
|
|
report.setCreateTime(date);
|
|
|
report.setFallaSleep(fallasleep);
|
|
|
report.setSleepTime(sleepTime);
|
|
|
report.setRestTime(restTime);
|
|
|
report.setAwakeTime(awakeTime);
|
|
|
report.setLightTime(lightTime);
|
|
|
report.setRemTime(remTime);
|
|
|
report.setDeepTime(deepTime);
|
|
|
String buckets =JSON.toJSONString(bucket);
|
|
|
report.setBucket(buckets);
|
|
|
report.setAvghr(avghr);
|
|
|
report.setAvgbr(avgbr);
|
|
|
report.setAwakePer(awakePer);
|
|
|
report.setRemPer(remPer);
|
|
|
report.setLightPer(lightPer);
|
|
|
report.setEfficiency(efficiency);
|
|
|
report.setScore(score);
|
|
|
sleepDeviceReportDao.save(report);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Async
|
|
|
public void byOnlineStatus(String device,String onlinestatu,String time_begin){
|
|
|
try {
|
|
|
if(StringUtils.isNotBlank(device)){
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
|
|
|
if (devicePatientDeviceDos.size()>0){
|
|
|
DevicePatientDevice tmp = devicePatientDeviceDos.get(0);
|
|
|
tmp.setOnlineStatus(Integer.parseInt(onlinestatu));
|
|
|
patientDeviceDao.save(tmp);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
@ -574,4 +666,9 @@ public class DeviceService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
String ss="123123,2323";
|
|
|
System.out.println(String.join(",",ss));
|
|
|
}
|
|
|
}
|