|
@ -4,10 +4,7 @@ package com.yihu.jw.care.service.device;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.yihu.jw.care.config.AqgConfig;
|
|
|
import com.yihu.jw.care.dao.device.BaseSleepPlanDao;
|
|
|
import com.yihu.jw.care.dao.device.DeviceDao;
|
|
|
import com.yihu.jw.care.dao.device.DeviceDetailDao;
|
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
|
import com.yihu.jw.care.dao.device.*;
|
|
|
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
|
|
|
import com.yihu.jw.care.service.contacts.ContactsService;
|
|
|
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
|
|
@ -18,10 +15,7 @@ import com.yihu.jw.care.util.MyJdbcTemplate;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.device.BaseSleepPlan;
|
|
|
import com.yihu.jw.entity.care.device.Device;
|
|
|
import com.yihu.jw.entity.care.device.DeviceDetail;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
|
import com.yihu.jw.entity.care.device.*;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.restmodel.ResponseContant;
|
|
|
import com.yihu.jw.util.common.GpsUtil;
|
|
@ -119,6 +113,9 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
|
private SecurityMonitoringOrderService securityMonitoringOrderService;
|
|
|
@Autowired
|
|
|
private CountDistance countDistance;
|
|
|
@Autowired
|
|
|
private PatientSafeAreaDao safeAreaDao;
|
|
|
|
|
|
@PostConstruct
|
|
|
public void init() {
|
|
|
relations.put(0, "其他");
|
|
@ -1005,7 +1002,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
|
day = DateUtil.getStringDateShort();
|
|
|
}
|
|
|
// 电子围栏
|
|
|
devInfoObj.put("safeAreaGz", securityMonitoringOrderService.getElectronicFence(deviceSn));
|
|
|
devInfoObj.put("safeAreaGz", securityMonitoringOrderService.getElectronicFence(device.getUser()));
|
|
|
// 行动轨迹
|
|
|
devInfoObj.put("actionTrack", securityMonitoringOrderService.getActionTrack(deviceSn,day));
|
|
|
//当前定位
|
|
@ -1032,7 +1029,11 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
|
devInfoObj.put("currentLon",lon); //当前定位
|
|
|
double dulat =Double.parseDouble(lat);
|
|
|
double dulon = Double.parseDouble(lon);
|
|
|
String safeArea = device.getSafeAreaGz();
|
|
|
List<PatientSafeAreaDO> safeAreaDOS = safeAreaDao.findByPatient(device.getUser());
|
|
|
String safeArea=null;
|
|
|
if (safeAreaDOS.size()>0){
|
|
|
safeArea = safeAreaDOS.get(0).getSafeAreaGz();
|
|
|
}
|
|
|
String[] safeAreas = safeArea.split(";");
|
|
|
com.alibaba.fastjson.JSONArray fenceLocation = new com.alibaba.fastjson.JSONArray();
|
|
|
for (String area:safeAreas){
|
|
@ -1351,54 +1352,89 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public com.alibaba.fastjson.JSONObject updateDeviceFenceArea(String deviceSn,Integer fenceNO,String enable,String name,String freq,
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String updateDeviceFenceArea(String patient,String deviceSn,Integer fenceNO,String enable,String name,String freq,
|
|
|
String time_begin,String time_end,String safe_area ,String clear) throws Exception{
|
|
|
List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
|
|
|
String url ="";
|
|
|
|
|
|
if ("16".equals(devices.get(0).getCategoryCode())) {
|
|
|
DevicePatientDevice patientDevice = devices.get(0);
|
|
|
if (StringUtils.isNotBlank(safe_area)){
|
|
|
patientDevice.setSafeAreaGz(safe_area);
|
|
|
patientDeviceDao.save(patientDevice);
|
|
|
com.alibaba.fastjson.JSONObject object = new com.alibaba.fastjson.JSONObject();
|
|
|
object.put("success",true);
|
|
|
return object;
|
|
|
if(StringUtils.isBlank(patient)){
|
|
|
List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
|
|
|
if (devices.size()>0){
|
|
|
DevicePatientDevice deviceTmp = devices.get(0);
|
|
|
if ("4".equals(deviceTmp.getCategoryCode())||"16".equals(deviceTmp.getCategoryCode())){
|
|
|
patient = deviceTmp.getUser();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if ("4".equals(devices.get(0).getCategoryCode())){//手表
|
|
|
Device device = deviceDao.findOne(devices.get(0).getDeviceId());
|
|
|
if (device!=null){
|
|
|
if ("X1".equals(device.getModel())){
|
|
|
url = MessageFormat.format(AqgConfig.X1fence_area, deviceSn,fenceNO);
|
|
|
}
|
|
|
List<DevicePatientDevice> devices = patientDeviceDao.findAllByUserAndCategoryCode(patient,"4");
|
|
|
PatientSafeAreaDO safeAreaDO = new PatientSafeAreaDO();
|
|
|
if (StringUtils.isNotBlank(patient)){
|
|
|
List<PatientSafeAreaDO> safeAreaDOS = safeAreaDao.findByPatient(patient);
|
|
|
// 1删除 空修改或删除
|
|
|
if (safeAreaDOS.size()>0){
|
|
|
safeAreaDO = safeAreaDOS.get(0);
|
|
|
}else {
|
|
|
safeAreaDO.setPatient(patient);
|
|
|
safeAreaDO.setCreateTime(new Date());
|
|
|
safeAreaDO.setUpdateTime(new Date());
|
|
|
safeAreaDO.setSuccessFlag(-1);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(clear)) {//删除
|
|
|
safeAreaDao.deleteByPatient(patient);
|
|
|
}
|
|
|
else{//新增或修改
|
|
|
safeAreaDO.setSafeAreaGz(safe_area);
|
|
|
safeAreaDO.setUpdateTime(new Date());
|
|
|
safeAreaDO.setSuccessFlag(-1);
|
|
|
}
|
|
|
}else {
|
|
|
url = MessageFormat.format(AqgConfig.S3fence_area, deviceSn,fenceNO);
|
|
|
}
|
|
|
MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
|
|
|
if(StringUtils.isBlank(clear)){
|
|
|
if (StringUtils.isNotBlank(safe_area)){
|
|
|
String[] position = safe_area.split(";");
|
|
|
safe_area = "";
|
|
|
for (String tmp:position){
|
|
|
String[] point = tmp.split(",");
|
|
|
safe_area+= gpsUtil.bd09_To_Gcj02_str(Double.parseDouble(point[1]),Double.parseDouble(point[0]))+";";
|
|
|
if (devices.size()>0){
|
|
|
DevicePatientDevice patientDevice = devices.get(0);
|
|
|
String deviceSnTmp = patientDevice.getDeviceSn();
|
|
|
String url ="";
|
|
|
if ("4".equals(devices.get(0).getCategoryCode())){//手表
|
|
|
Device device = deviceDao.findOne(devices.get(0).getDeviceId());
|
|
|
if (device!=null){
|
|
|
if ("X1".equals(device.getModel())){
|
|
|
url = MessageFormat.format(AqgConfig.X1fence_area, deviceSnTmp,fenceNO);
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
url = MessageFormat.format(AqgConfig.S3fence_area, deviceSnTmp,fenceNO);
|
|
|
}
|
|
|
MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
|
|
|
if(StringUtils.isBlank(clear)){
|
|
|
if (StringUtils.isNotBlank(safe_area)){
|
|
|
String[] position = safe_area.split(";");
|
|
|
safe_area = "";
|
|
|
for (String tmp:position){
|
|
|
String[] point = tmp.split(",");
|
|
|
safe_area+= gpsUtil.bd09_To_Gcj02_str(Double.parseDouble(point[1]),Double.parseDouble(point[0]))+";";
|
|
|
}
|
|
|
}
|
|
|
param.add("name", name);
|
|
|
param.add("freq", freq);
|
|
|
param.add("enable",enable);
|
|
|
param.add("time_begin", time_begin);
|
|
|
param.add("time_end", time_end);
|
|
|
param.add("safe_area", safe_area);
|
|
|
|
|
|
}else {
|
|
|
param.add("clear",clear);
|
|
|
}
|
|
|
HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.POST, getCookie());
|
|
|
com.alibaba.fastjson.JSONObject responseObj = response.getBody();
|
|
|
if (responseObj.getBoolean("success")){
|
|
|
safeAreaDO.setSuccessFlag(1);
|
|
|
}
|
|
|
else {
|
|
|
throw new Exception("安全区域设置失败!");
|
|
|
}
|
|
|
if (StringUtils.isBlank(clear)&&StringUtils.isNotBlank(patient)){
|
|
|
safeAreaDao.save(safeAreaDO);
|
|
|
}
|
|
|
param.add("name", name);
|
|
|
param.add("freq", freq);
|
|
|
param.add("enable",enable);
|
|
|
param.add("time_begin", time_begin);
|
|
|
param.add("time_end", time_end);
|
|
|
param.add("safe_area", safe_area);
|
|
|
|
|
|
}else {
|
|
|
param.add("clear",clear);
|
|
|
}
|
|
|
HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.POST, getCookie());
|
|
|
return response.getBody();
|
|
|
return "success";
|
|
|
}
|
|
|
|
|
|
/**
|