|
@ -1458,10 +1458,81 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
*老人家属首页实时监护信息
|
|
|
* 居家状态取手表 无手表缺省
|
|
|
* 监控
|
|
|
*/
|
|
|
public JSONObject patientMonitoringInfo2(String patient){
|
|
|
JSONObject result = new JSONObject();
|
|
|
result.put("atHome",null);// 居家状态
|
|
|
result.put("location",null);
|
|
|
result.put("fences",null);
|
|
|
result.put("gasLeakage",null);
|
|
|
result.put("fire",null);
|
|
|
result.put("fall",null);
|
|
|
result.put("sleep",null);
|
|
|
result.put("deviceSn",null);
|
|
|
result.put("emeAssistance",false);
|
|
|
result.put("monitorInfo",null);
|
|
|
String sql = " select dict.code,count(ord.id) total from base_system_dict_entry dict LEFT JOIN base_security_monitoring_order ord " +
|
|
|
" on dict.code = ord.topic_item COLLATE utf8_unicode_ci and ord.status="+SecurityMonitoringOrderDO.Status.apply.getType()+" where dict.dict_code='service_item' " +
|
|
|
"and dict.remark='security' and ord.patient='"+patient+"' GROUP BY dict.code ";
|
|
|
List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
|
|
|
for (Map<String,Object>tmp:sqlResult){
|
|
|
switch (tmp.get("code").toString()){
|
|
|
case "preventGasLeakage":
|
|
|
Integer count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("gasLeakage",true);
|
|
|
}else {
|
|
|
result.put("gasLeakage",false);
|
|
|
}
|
|
|
break;
|
|
|
case "preventFire":
|
|
|
count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("fire",true);
|
|
|
}else {
|
|
|
result.put("fire",false);
|
|
|
}
|
|
|
break;
|
|
|
case "preventFall":
|
|
|
count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("fall",true);
|
|
|
}else {
|
|
|
result.put("fall",false);
|
|
|
}
|
|
|
break;
|
|
|
case "preventOutOfBed":
|
|
|
count = Integer.parseInt(tmp.get("total").toString());
|
|
|
if (count>0){
|
|
|
result.put("sleep",true);
|
|
|
}else {
|
|
|
result.put("sleep",false);
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
sql = " select count(id) from base_emergency_assistance_order where patient='"+patient+"' and status="+ EmergencyAssistanceDO.Status.apply.getType();
|
|
|
Integer counnt = jdbcTemplate.queryForObject(sql,Integer.class);
|
|
|
if (counnt>0){
|
|
|
result.put("emeAssistance",true);
|
|
|
}
|
|
|
List<DevicePatientDevice> devices4 = patientDeviceDao.findByUserAndCategoryCode(patient,"4");//手表
|
|
|
if (devices4.size()>0){
|
|
|
result = patientSignTopicInfo(result,patient,"preventLost",devices4.get(0).getDeviceSn());
|
|
|
}
|
|
|
patientSignTopicInfo(result,patient,"preventFall",null);
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
public void preventLost(JSONObject result,String patient,String deviceSn){
|
|
|
//手表与拐杖同时绑定时优先手表,围栏状态其中一个超出围栏即为超出围栏
|
|
|
try {
|
|
|
Integer categoryCode=0;
|
|
|
Integer categoryCode=0;//未指定设备
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos = new ArrayList<>();
|
|
|
List<DevicePatientDevice> devicePatientDeviceDos2 = new ArrayList<>();
|
|
|
if (StringUtils.isNotBlank(deviceSn)){//查看指定设备详情
|
|
@ -1476,11 +1547,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
devicePatientDeviceDos2 = devices;
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
|
|
|
devicePatientDeviceDos2 = patientDeviceDao.findByUserAndCategoryCode(patient,"16");
|
|
|
}else {//未指定设备
|
|
|
devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");//手表
|
|
|
devicePatientDeviceDos2 = patientDeviceDao.findByUserAndCategoryCode(patient,"16");//拐杖
|
|
|
}
|
|
|
if (devicePatientDeviceDos.size()>0&&(4==categoryCode||0==categoryCode)){
|
|
|
if (devicePatientDeviceDos.size()>0&&(4==categoryCode||0==categoryCode)){//手表
|
|
|
DevicePatientDevice device = devicePatientDeviceDos.get(0);
|
|
|
result.put("deviceSn",device.getDeviceSn());
|
|
|
JSONObject response= patientDeviceService.getAqgDeviceInfo2(device.getDeviceSn());
|
|
@ -1495,6 +1566,22 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
tmp.put("province",response.getString("last_province"));
|
|
|
tmp.put("address",response.getString("last_address"));
|
|
|
result.put("location",tmp);
|
|
|
BasePatientDO patientDO = basePatientDao.findById(patient);
|
|
|
if (null != patientDO){
|
|
|
if (StringUtils.isNotBlank(patientDO.getHomeLatLon())){
|
|
|
String homeLatLon = patientDO.getHomeLatLon();
|
|
|
double homeLat = Double.parseDouble( homeLatLon.split(",")[0]);
|
|
|
double homeLon = Double.parseDouble( homeLatLon.split(",")[1]);
|
|
|
double homeDistance = countDistance.getDistance(result.getJSONObject("location").getDouble("lat"),result.getJSONObject("location").getDouble("lon"),
|
|
|
homeLat,homeLon);
|
|
|
if (homeDistance>50*1000){
|
|
|
result.put("atHome",false);
|
|
|
}else {
|
|
|
result.put("atHome",true);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//围栏信息
|
|
|
if (response.containsKey("fences")&&response.get("fences")!=null){
|
|
@ -1525,7 +1612,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (devicePatientDeviceDos2.size()>0&&(16==categoryCode||0==categoryCode)) {
|
|
|
if (devicePatientDeviceDos2.size()>0&&(16==categoryCode||0==categoryCode)) {//拐杖
|
|
|
DevicePatientDevice deviceDO = devicePatientDeviceDos2.get(0);
|
|
|
double dulat = 0l;
|
|
|
double dulon = 0l;
|
|
@ -1571,11 +1658,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
positionTmp.put("lon", areaLon);
|
|
|
fenceLocation.add(positionTmp);
|
|
|
}
|
|
|
if (devicePatientDeviceDos2.size() > 0 && 0 == categoryCode) {
|
|
|
if (devicePatientDeviceDos2.size() > 0 && 0 == categoryCode && devicePatientDeviceDos2.size()>0) {
|
|
|
JSONObject obj = result.getJSONArray("fences").getJSONObject(0);
|
|
|
if (!obj.getBooleanValue("inFenceStatus")) {
|
|
|
if (obj.getBooleanValue("inFenceStatus")) {
|
|
|
if (!countDistance.isInPolygon(dulon, dulat, fenceLocation)) {
|
|
|
obj.put("inFenceStatus", false);
|
|
|
obj.put("inFenceStatus", false);//超出围栏
|
|
|
obj = result.getJSONObject("location");
|
|
|
obj.put("address", address);
|
|
|
obj.put("lon", dulon);
|
|
@ -1583,7 +1670,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (devicePatientDeviceDos2.size() > 0 && 16 == categoryCode) {
|
|
|
else if(devicePatientDeviceDos2.size() > 0) {//指定拐杖设备
|
|
|
if (StringUtils.isNotBlank(safeArea)) {
|
|
|
result.put("deviceSn", deviceDO.getDeviceSn());
|
|
|
JSONObject location = new JSONObject();
|