|
|
|
@ -8,6 +8,7 @@ import com.ruoyi.business.domain.*;
|
|
|
|
|
import com.ruoyi.business.domain.VO.*;
|
|
|
|
|
import com.ruoyi.business.mapper.*;
|
|
|
|
|
import com.ruoyi.business.service.IHwDeviceService;
|
|
|
|
|
import com.ruoyi.business.utils.GpsCoordinateUtils;
|
|
|
|
|
import com.ruoyi.common.core.constant.Constants;
|
|
|
|
|
import com.ruoyi.common.core.constant.HwDictConstants;
|
|
|
|
|
import com.ruoyi.common.core.constant.SecurityConstants;
|
|
|
|
@ -76,6 +77,8 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
|
private RedisService redisService;
|
|
|
|
|
@Autowired
|
|
|
|
|
private HwFenceAreaMapper hwFenceAreaMapper;
|
|
|
|
|
public static final String SEPARATOR_UNDERLINE = "_";
|
|
|
|
|
public static final String SEPARATOR_COMMA = ",";
|
|
|
|
|
/**
|
|
|
|
|
* 查询设备信息
|
|
|
|
|
*
|
|
|
|
@ -360,7 +363,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
|
@Override
|
|
|
|
|
public int changeDeviceStatus(HwDevice hwDevice) {
|
|
|
|
|
HwDevice dbDevice = hwDeviceMapper.selectHwDeviceByDeviceId(hwDevice.getDeviceId());
|
|
|
|
|
if (dbDevice.getDeviceStatus().equals(HwDictConstants.DEVICE_STATUS_PUBLISH)) {
|
|
|
|
|
if (dbDevice.getDeviceStatus().equals(HwDictConstants.DEVICE_STATUS_PUBLISH) && !hwDevice.getDeviceStatus().equals("0")) {
|
|
|
|
|
throw new ServiceException("已发布状态不能修改");
|
|
|
|
|
}
|
|
|
|
|
hwDevice.setUpdateBy(SecurityUtils.getUsername());
|
|
|
|
@ -1264,10 +1267,17 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
|
String tableName = tdSelectDto.getTableName();
|
|
|
|
|
int underscoreIndex = tableName.lastIndexOf('_');
|
|
|
|
|
int deviceId = Integer.parseInt(tableName.substring(underscoreIndex + 1));
|
|
|
|
|
HwDevice hwDevice = hwDevices.stream().filter(x -> x.getDeviceId() == deviceId).findFirst().get();
|
|
|
|
|
if(hwDevice == null){
|
|
|
|
|
Optional<HwDevice> first = hwDevices.stream().filter(x -> x.getDeviceId() == deviceId).findFirst();
|
|
|
|
|
HwDevice hwDevice = new HwDevice();
|
|
|
|
|
if (first.isPresent()){
|
|
|
|
|
hwDevice = first.get();
|
|
|
|
|
}else {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
// HwDevice hwDevice = hwDevices.stream().filter(x -> x.getDeviceId() == deviceId).findFirst().get();
|
|
|
|
|
// if(hwDevice == null){
|
|
|
|
|
// continue;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
BeaconDevice beaconDevice = new BeaconDevice();
|
|
|
|
|
beaconDevice.setDeviceId(hwDevice.getDeviceId());
|
|
|
|
@ -1554,6 +1564,30 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
|
HwFenceArea hwFenceArea = new HwFenceArea();
|
|
|
|
|
hwFenceArea.setElectronicFenceId(hwElectronicFences.get(i).getElectronicFenceId());
|
|
|
|
|
List<HwFenceArea> hwFenceAreaList = hwFenceAreaMapper.selectHwFenceAreaList(hwFenceArea);
|
|
|
|
|
// for (HwFenceArea fenceArea : hwFenceAreaList) {
|
|
|
|
|
// if (fenceArea.getAreaShapeFlag().equals("1")){
|
|
|
|
|
// String[] points = fenceArea.getAreaRange().split("_");
|
|
|
|
|
// StringBuilder areaRange = new StringBuilder();
|
|
|
|
|
// for (String point : points) {
|
|
|
|
|
// areaRange.append(SEPARATOR_UNDERLINE);
|
|
|
|
|
// String[] location = point.split(",");
|
|
|
|
|
// double longitude = Double.parseDouble(location[0]);
|
|
|
|
|
// double latitude = Double.parseDouble(location[1]);
|
|
|
|
|
// double[] doubles = GpsCoordinateUtils.calWGS84toGCJ02(latitude, longitude);
|
|
|
|
|
// areaRange.append(doubles[1]).append(SEPARATOR_COMMA)
|
|
|
|
|
// .append(doubles[0]);
|
|
|
|
|
// }
|
|
|
|
|
// fenceArea.setAreaRange(areaRange.toString().replaceFirst(SEPARATOR_UNDERLINE, ""));
|
|
|
|
|
// }
|
|
|
|
|
// if (fenceArea.getAreaShapeFlag().equals("2")){
|
|
|
|
|
// String areaRange = fenceArea.getAreaRange();
|
|
|
|
|
// String[] points = areaRange.split(",");
|
|
|
|
|
// double longitude = Double.parseDouble(points[0]);
|
|
|
|
|
// double latitude = Double.parseDouble(points[1]);
|
|
|
|
|
// double[] doubles = GpsCoordinateUtils.calWGS84toGCJ02(latitude, longitude);
|
|
|
|
|
// fenceArea.setAreaRange(longitude+","+latitude+","+points[2]);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
hwElectronicFences.get(i).setHwFenceAreaList(hwFenceAreaList);
|
|
|
|
|
}
|
|
|
|
|
return hwElectronicFences;
|
|
|
|
@ -1575,7 +1609,7 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
|
Long integer = hwDeviceMapper.selectDeviceIfAlarm(Long.valueOf(map.get("deviceId")));
|
|
|
|
|
String ifAlarm = new String();
|
|
|
|
|
if (integer>0){
|
|
|
|
|
//正常
|
|
|
|
|
//有未处理报警
|
|
|
|
|
ifAlarm="1";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -1643,6 +1677,16 @@ public class HwDeviceServiceImpl implements IHwDeviceService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map getDeviceLocation(Long deviceId) {
|
|
|
|
|
TdSelectDto tdSelectDto = new TdSelectDto();
|
|
|
|
|
tdSelectDto.setDatabaseName("db_hwsaas");
|
|
|
|
|
tdSelectDto.setTableName("t_device_"+deviceId);
|
|
|
|
|
R<Map<String, Object>> deviceLocation = remoteTdEngineService.getDeviceLocation(tdSelectDto, SecurityConstants.INNER);
|
|
|
|
|
Map<String, Object> data = deviceLocation.getData();
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据名字搜索信标设备
|
|
|
|
|
* */
|
|
|
|
|