|
@ -6,12 +6,16 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.yihu.jw.care.dao.device.*;
|
|
|
import com.yihu.jw.care.endpoint.Result;
|
|
|
import com.yihu.jw.care.util.CountDistance;
|
|
|
import com.yihu.jw.care.util.SecurityOrderUtil;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.care.device.*;
|
|
|
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
|
|
|
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.util.common.GpsUtil;
|
|
|
import com.yihu.jw.util.common.LatitudeUtils;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
|
|
|
import com.yihu.jw.utils.StringUtil;
|
|
@ -56,7 +60,13 @@ public class DeviceUploadService {
|
|
|
@Autowired
|
|
|
private HvDeviceService hvDeviceService;
|
|
|
@Autowired
|
|
|
private CountDistance countDistance;
|
|
|
@Autowired
|
|
|
private YsDeviceService ysDeviceService;
|
|
|
@Autowired
|
|
|
private SecurityOrderUtil orderUtil;
|
|
|
@Autowired
|
|
|
private GpsUtil gpsUtil;
|
|
|
|
|
|
public Result uploadDevicesData(String dataJson)throws Exception {
|
|
|
try {
|
|
@ -435,59 +445,135 @@ public class DeviceUploadService {
|
|
|
* @return
|
|
|
*/
|
|
|
public void parsingInstruction(String instructions){
|
|
|
if(StringUtils.isBlank(instructions)){
|
|
|
return;
|
|
|
}
|
|
|
String res = "";
|
|
|
//位置[434036bb95761faaf8771d10029ae8eaIC*860314001160427*0113*UD,210826,093829,V,0.000000,N,0.000000,E,0.00,0.0,100.0,0,62,31,0,0,00000000,1,1,460,0,22831,259001902,62,6,wifi0,20:6b:e7:67:bf:1f,-63,wifi1,d4:9e:05:a7:60:a6,-65,wifi2,e0:d4:62:2d:67:9c,-71,wifi3,54:75:95:b9:4f:8e,-73,wifi4,e4:72:e2:aa:73:0c,-73,wifi5,e0:d4:62:2d:67:a1,-73]
|
|
|
//报警[XT*334588000000156*00CD*AL,180916,064153,A,22.570512,N,113.8623267,E,0.00,154.8,0.0,11,10 0,100,0,0,00100018,7,0,460,1,9529,21809,155,9529,21242,132,9529,21405,131,9529,63554,131,9 529,63555,130,9529,63556,118,9529,21869,116,0,12.4]
|
|
|
String instruct[] = instructions.split("]");
|
|
|
for (int i=0;i<instruct.length;i++){
|
|
|
String inst = instruct[i];
|
|
|
String tmp[] = inst.split("\\*");
|
|
|
String sn = tmp[1];
|
|
|
String order = tmp[3];
|
|
|
if(order.contains(",")){
|
|
|
String tmp1[] = order.split(",");
|
|
|
if("UD".equals(tmp1[0])||"CRUD".equals(tmp1[0])||"AL".equals(tmp1[0])){
|
|
|
//处理位置信息
|
|
|
String lat,lon;
|
|
|
if("A".equals(tmp1[4])){
|
|
|
lat = tmp1[5];
|
|
|
lon = tmp1[7];
|
|
|
}else{
|
|
|
lat = tmp1[4];
|
|
|
lon = tmp1[6];
|
|
|
try {
|
|
|
if(StringUtils.isBlank(instructions)){
|
|
|
return;
|
|
|
}
|
|
|
String res = "";
|
|
|
//位置[434036bb95761faaf8771d10029ae8eaIC*860314001160427*0113*UD,210826,093829,V,0.000000,N,0.000000,E,0.00,0.0,100.0,0,62,31,0,0,00000000,1,1,460,0,22831,259001902,62,6,wifi0,20:6b:e7:67:bf:1f,-63,wifi1,d4:9e:05:a7:60:a6,-65,wifi2,e0:d4:62:2d:67:9c,-71,wifi3,54:75:95:b9:4f:8e,-73,wifi4,e4:72:e2:aa:73:0c,-73,wifi5,e0:d4:62:2d:67:a1,-73]
|
|
|
//报警[XT*334588000000156*00CD*AL,180916,064153,A,22.570512,N,113.8623267,E,0.00,154.8,0.0,11,10 0,100,0,0,00100018,7,0,460,1,9529,21809,155,9529,21242,132,9529,21405,131,9529,63554,131,9 529,63555,130,9529,63556,118,9529,21869,116,0,12.4]
|
|
|
String instruct[] = instructions.split("]");
|
|
|
for (int i=0;i<instruct.length;i++){
|
|
|
String inst = instruct[i];
|
|
|
String tmp[] = inst.split("\\*");
|
|
|
String sn = tmp[1];
|
|
|
String order = tmp[3];
|
|
|
if(order.contains(",")){
|
|
|
String tmp1[] = order.split(",");
|
|
|
if("UD".equals(tmp1[0])||"CRUD".equals(tmp1[0])){
|
|
|
//处理位置信息
|
|
|
String lat,lon;
|
|
|
if("A".equals(tmp1[4])){
|
|
|
lat = tmp1[5];
|
|
|
lon = tmp1[7];
|
|
|
//判断是否超出围栏,
|
|
|
}else{
|
|
|
lat = tmp1[4];
|
|
|
lon = tmp1[6];
|
|
|
}
|
|
|
double dulat =Double.parseDouble(lat);
|
|
|
double dulon = Double.parseDouble(lon);
|
|
|
if (!(dulat==0.0&&dulon==0.0)){//判断是否触发工单
|
|
|
List<DevicePatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(sn);
|
|
|
DevicePatientDevice patientDevice = null;
|
|
|
if (patientDeviceList.size()>0){
|
|
|
for (DevicePatientDevice pd2:patientDeviceList){
|
|
|
if (StringUtils.isNotBlank(pd2.getSafeAreaGz())){
|
|
|
patientDevice = pd2;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
if (null!=patientDevice){//存在围栏地址
|
|
|
String safeArea = patientDevice.getSafeAreaGz();
|
|
|
String[] safeAreas = safeArea.split(";");
|
|
|
JSONArray fenceLocation = new JSONArray();
|
|
|
for (String area:safeAreas){
|
|
|
String[] areaPoint = area.split(",");
|
|
|
JSONObject positionTmp = new JSONObject();
|
|
|
Double areaLon = Double.parseDouble( areaPoint[0]);
|
|
|
Double areaLat = Double.parseDouble( areaPoint[1]);
|
|
|
// com.alibaba.fastjson.JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
|
|
|
positionTmp.put("lat",areaLat);
|
|
|
positionTmp.put("lon",areaLon);
|
|
|
fenceLocation.add(positionTmp);
|
|
|
}
|
|
|
if (!countDistance.isInPolygon(dulon,dulat,fenceLocation)){
|
|
|
orderUtil.createSecurityOrder(sn,null,null,8,"1","yslkaqqy",null);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
BaseYxDeviceIndex deviceIndex = new BaseYxDeviceIndex();
|
|
|
deviceIndex.setSn(sn);
|
|
|
deviceIndex.setLat(lat);
|
|
|
deviceIndex.setLon(lon);
|
|
|
yxDeviceIndexDao.save(deviceIndex);
|
|
|
hvDeviceService.updContactStatus(sn,1);
|
|
|
}
|
|
|
if ("AL".equals(equals(tmp1[0]))){//触发报警
|
|
|
String lat,lon;
|
|
|
if("A".equals(tmp1[4])){
|
|
|
lat = tmp1[5];
|
|
|
lon = tmp1[7];
|
|
|
//判断是否超出围栏,
|
|
|
}else{
|
|
|
lat = tmp1[4];
|
|
|
lon = tmp1[6];
|
|
|
}
|
|
|
double dulat =Double.parseDouble(lat);
|
|
|
double dulon = Double.parseDouble(lon);
|
|
|
|
|
|
List<DevicePatientDevice> patientDeviceList = patientDeviceDao.findByDeviceSn(sn);
|
|
|
if (patientDeviceList.size()>0){
|
|
|
DevicePatientDevice deviceDO = patientDeviceList.get(0);
|
|
|
BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
|
|
|
//发起救助工单
|
|
|
//获取居民坐标
|
|
|
//如果没获取取居民坐标
|
|
|
if ((dulat==0.0&&dulon==0.0)){
|
|
|
String points = patientDO.getLatLon();
|
|
|
if (StringUtils.isNotBlank(points)){
|
|
|
String[] pointss = points.split(",");
|
|
|
if (2==pointss.length){
|
|
|
if (StringUtils.isNotBlank(pointss[0])){
|
|
|
dulat = Double.parseDouble(pointss[0]);
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(pointss[1])){
|
|
|
dulat = Double.parseDouble(pointss[1]);
|
|
|
}
|
|
|
}
|
|
|
}else {
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
if ((dulat==0.0&&dulon==0.0)){
|
|
|
return;
|
|
|
}
|
|
|
DeviceSosLogDO logDO = new DeviceSosLogDO();
|
|
|
logDO.setPatient(patientDO.getId());
|
|
|
logDO.setPatientName(patientDO.getName());
|
|
|
logDO.setIdcard(patientDO.getIdcard());
|
|
|
logDO.setCategoryCode(deviceDO.getCategoryCode());
|
|
|
logDO.setDeviceSn(deviceDO.getDeviceSn());
|
|
|
logDO.setCreateTime(new Date());
|
|
|
|
|
|
com.alibaba.fastjson.JSONObject position = gpsUtil.Gps84_To_bd09(dulat,dulon);
|
|
|
//坐标
|
|
|
logDO.setSosLat(position.getDouble("lat")+"");
|
|
|
logDO.setSosLon(position.getDouble("lon")+"");
|
|
|
logDO.setSosAddress(LatitudeUtils.getLocationAddress(position.getDouble("lat")+"",position.getDouble("lon")+""));
|
|
|
orderUtil.createEmeOrder(logDO,"4");
|
|
|
}
|
|
|
}
|
|
|
//判断是否触发防走失工单
|
|
|
|
|
|
BaseYxDeviceIndex deviceIndex = new BaseYxDeviceIndex();
|
|
|
deviceIndex.setSn(sn);
|
|
|
deviceIndex.setLat(lat);
|
|
|
deviceIndex.setLon(lon);
|
|
|
yxDeviceIndexDao.save(deviceIndex);
|
|
|
hvDeviceService.updContactStatus(sn,1);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 判断是否触发防走失工单
|
|
|
*/
|
|
|
public void yxLossPrevention(String sn,String lat,String lon){
|
|
|
if("0.000000".equals(lat)&&"0.000000".equals(lon)){
|
|
|
return;
|
|
|
}
|
|
|
List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSnAndCategoryCode(sn,"16");
|
|
|
String safeAreaGz = null;
|
|
|
if (devices.size()>0){
|
|
|
safeAreaGz = devices.get(0).getSafeAreaGz();
|
|
|
}
|
|
|
if(StringUtil.isBlank(safeAreaGz)){
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|