|
@ -5,10 +5,13 @@ import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
import com.yihu.jw.care.dao.security.*;
|
|
import com.yihu.jw.care.dao.security.*;
|
|
import com.yihu.jw.care.service.device.PatientDeviceService;
|
|
import com.yihu.jw.care.service.device.PatientDeviceService;
|
|
import com.yihu.jw.care.service.sign.ServicePackageService;
|
|
import com.yihu.jw.care.service.sign.ServicePackageService;
|
|
|
|
import com.yihu.jw.care.util.CountDistance;
|
|
|
|
import com.yihu.jw.care.util.GpsUtil;
|
|
import com.yihu.jw.care.util.MessageUtil;
|
|
import com.yihu.jw.care.util.MessageUtil;
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
|
|
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
|
|
@ -68,6 +71,10 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
private BaseDoctorHospitalDao baseDoctorHospitalDao;
|
|
private BaseDoctorHospitalDao baseDoctorHospitalDao;
|
|
@Autowired
|
|
@Autowired
|
|
private PatientDeviceService patientDeviceService;
|
|
private PatientDeviceService patientDeviceService;
|
|
|
|
@Autowired
|
|
|
|
private GpsUtil gpsUtil;
|
|
|
|
@Autowired
|
|
|
|
private CountDistance countDistance;
|
|
|
|
|
|
private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
|
|
private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
|
|
|
|
|
|
@ -912,8 +919,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
public JSONObject patientMonitoringInfo(String patient){
|
|
public JSONObject patientMonitoringInfo(String patient){
|
|
JSONObject result = new JSONObject();
|
|
JSONObject result = new JSONObject();
|
|
result.put("location",null);
|
|
result.put("location",null);
|
|
result.put("enclosureStatus",null);
|
|
|
|
result.put("enclosurePosition",null);
|
|
|
|
|
|
result.put("fences",null);
|
|
result.put("smoke",null);
|
|
result.put("smoke",null);
|
|
result.put("fire",null);
|
|
result.put("fire",null);
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
|
|
List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
|
|
@ -923,28 +929,51 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
|
|
else {
|
|
else {
|
|
DevicePatientDevice device = devicePatientDeviceDos.get(0);
|
|
DevicePatientDevice device = devicePatientDeviceDos.get(0);
|
|
try {
|
|
try {
|
|
JSONObject response= patientDeviceService.getDeviceLastLocation(device.getDeviceSn(),null);
|
|
|
|
if (response.getBooleanValue("success")){
|
|
|
|
JSONObject tmp = response.getJSONObject("obj");
|
|
|
|
if (tmp.containsKey("locationdata")&&tmp.get("locationdata")!=null){
|
|
|
|
JSONObject locationTmp = tmp.getJSONObject("locationdata");
|
|
|
|
Double lon = locationTmp.getJSONObject("point").getJSONArray("coordinates").getDouble(0);
|
|
|
|
Double lat = locationTmp.getJSONObject("point").getJSONArray("coordinates").getDouble(1);
|
|
|
|
tmp = new JSONObject();
|
|
|
|
|
|
JSONObject response= patientDeviceService.getAqgDeviceInfo(device.getDeviceSn());
|
|
|
|
if (response!=null){
|
|
|
|
//定位信息
|
|
|
|
if (response.containsKey("last_location")&&response.get("last_location")!=null){
|
|
|
|
JSONObject locationTmp = response.getJSONObject("last_location");
|
|
|
|
Double lon = locationTmp.getJSONArray("coordinates").getDouble(0);
|
|
|
|
Double lat = locationTmp.getJSONArray("coordinates").getDouble(1);
|
|
|
|
JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat,lon);
|
|
tmp.put("city",locationTmp.getString("city"));
|
|
tmp.put("city",locationTmp.getString("city"));
|
|
tmp.put("address",locationTmp.getString("address"));
|
|
tmp.put("address",locationTmp.getString("address"));
|
|
result.put("location",tmp);
|
|
result.put("location",tmp);
|
|
}
|
|
}
|
|
|
|
//围栏信息
|
|
|
|
if (response.containsKey("fences")&&response.get("fences")!=null){
|
|
|
|
JSONArray fencesArr = response.getJSONArray("fences");
|
|
|
|
JSONArray fencesEnables = new JSONArray();
|
|
|
|
for (int i=0;i<fencesArr.size();i++){
|
|
|
|
JSONObject tmp = fencesArr.getJSONObject(i);
|
|
|
|
if (tmp.getBooleanValue("enable")){//围栏生效
|
|
|
|
JSONObject fenceTmp = new JSONObject();
|
|
|
|
fenceTmp.put("fenceNO",tmp.getInteger("seqid").toString());
|
|
|
|
fenceTmp.put("name",tmp.getString("name"));
|
|
|
|
JSONArray fenceLocationTmp = tmp.getJSONObject("safe_area").getJSONArray("coordinates").getJSONArray(0);
|
|
|
|
JSONArray fenceLocation = new JSONArray();
|
|
|
|
for (int j=0;j<fenceLocationTmp.size();j++){
|
|
|
|
Double lon = fenceLocationTmp.getJSONArray(j).getDouble(0);
|
|
|
|
Double lat = fenceLocationTmp.getJSONArray(j).getDouble(1);
|
|
|
|
JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
|
|
|
|
fenceLocation.add(positionTmp);
|
|
|
|
}
|
|
|
|
fenceTmp.put("location",fenceLocation);
|
|
|
|
fenceTmp.put("inFenceStatus",countDistance.isInPolygon(result.getJSONObject("location").getDouble("lon"),result.getJSONObject("location").getDouble("lat"),fenceLocation));
|
|
|
|
fencesEnables.add(fenceTmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fencesEnables.size()>0){
|
|
|
|
result.put("fences",fencesEnables);
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
result.put("location",null);
|
|
result.put("location",null);
|
|
}
|
|
}
|
|
result.put("enclosureStatus",null);
|
|
|
|
result.put("enclosurePosition",null);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|