|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package com.ssf.mysqloracletest.task;
|
|
|
|
|
|
|
|
|
|
import com.ssf.mysqloracletest.domain.DevopsDeviceInfo;
|
|
|
|
|
import com.ssf.mysqloracletest.domain.DevopsVideoInfo0;
|
|
|
|
|
import com.ssf.mysqloracletest.service.DevopsDeviceInfoService;
|
|
|
|
|
import com.ssf.mysqloracletest.service.DevopsVideoInfoService0;
|
|
|
|
|
import com.ssf.mysqloracletest.utils.ConfigParam;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
@ -9,6 +11,7 @@ import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
@Component
|
|
|
|
@ -17,12 +20,13 @@ public class DevopsVideoInfoTask {
|
|
|
|
|
|
|
|
|
|
private static final Logger logger = LoggerFactory.getLogger(DevopsVideoInfoTask.class);
|
|
|
|
|
private final DevopsVideoInfoService0 videoInfoService0;
|
|
|
|
|
private final DevopsDeviceInfoService devopsDeviceInfoService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//偏移量
|
|
|
|
|
Double offset = 0.0001;
|
|
|
|
|
//查找用偏移量
|
|
|
|
|
Double offset1 = 0.00005;
|
|
|
|
|
Double offset1 = 0.00002;
|
|
|
|
|
|
|
|
|
|
//视频设备经纬度偏移
|
|
|
|
|
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
|
|
|
@ -66,4 +70,61 @@ public class DevopsVideoInfoTask {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Scheduled(initialDelay = 100, fixedDelay = 3000)
|
|
|
|
|
public void devicePosition(){
|
|
|
|
|
|
|
|
|
|
if (!"true".equals(ConfigParam.devicePositionSwitch)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//找出经纬度正常的设备
|
|
|
|
|
List<DevopsDeviceInfo> list = devopsDeviceInfoService.lambdaQuery()
|
|
|
|
|
.ne(DevopsDeviceInfo::getLongitude,0.000000)
|
|
|
|
|
.ne(DevopsDeviceInfo::getLatitude,0.000000)
|
|
|
|
|
.list();
|
|
|
|
|
for (DevopsDeviceInfo devopsDeviceInfo : list){
|
|
|
|
|
Double latitude = devopsDeviceInfo.getLatitude().doubleValue();
|
|
|
|
|
Double longitude = devopsDeviceInfo.getLongitude().doubleValue();
|
|
|
|
|
//根据一个设备的经纬度,找出该设备偏移范围内的所有设备
|
|
|
|
|
List<DevopsDeviceInfo> devopsDeviceInfos = devopsDeviceInfoService.lambdaQuery()
|
|
|
|
|
.ne(DevopsDeviceInfo::getGbsChannelNo,devopsDeviceInfo.getGbsChannelNo())
|
|
|
|
|
.between(DevopsDeviceInfo::getLatitude, latitude - offset1, latitude + offset1)
|
|
|
|
|
.between(DevopsDeviceInfo::getLongitude, longitude - offset1, longitude + offset1)
|
|
|
|
|
.list();
|
|
|
|
|
if (!devopsDeviceInfos.isEmpty()) {
|
|
|
|
|
double angleOffset = 360.0 / devopsDeviceInfos.size();
|
|
|
|
|
if (devopsDeviceInfos.size() == 1){
|
|
|
|
|
for (DevopsDeviceInfo deviceInfo:devopsDeviceInfos){
|
|
|
|
|
double newLatitude = deviceInfo.getLatitude().doubleValue() + offset;
|
|
|
|
|
double newLongitude = deviceInfo.getLongitude().doubleValue() + offset;
|
|
|
|
|
deviceInfo.setLatitude(BigDecimal.valueOf(newLatitude));
|
|
|
|
|
deviceInfo.setLongitude(BigDecimal.valueOf(newLongitude));
|
|
|
|
|
boolean update = devopsDeviceInfoService.lambdaUpdate()
|
|
|
|
|
.eq(DevopsDeviceInfo::getGbsChannelNo, deviceInfo.getGbsChannelNo())
|
|
|
|
|
.update(deviceInfo);
|
|
|
|
|
if (update){
|
|
|
|
|
logger.info("修改成功");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < devopsDeviceInfos.size(); i++) {
|
|
|
|
|
double angle = i * angleOffset;
|
|
|
|
|
DevopsDeviceInfo deviceInfo = devopsDeviceInfos.get(i);
|
|
|
|
|
// 将极坐标转换为直角坐标
|
|
|
|
|
double newLatitude = deviceInfo.getLatitude().doubleValue() + (offset * Math.cos(Math.toRadians(angle)));
|
|
|
|
|
double newLongitude = deviceInfo.getLongitude().doubleValue() + (offset * Math.sin(Math.toRadians(angle)));
|
|
|
|
|
deviceInfo.setLatitude(BigDecimal.valueOf(newLatitude));
|
|
|
|
|
deviceInfo.setLongitude(BigDecimal.valueOf(newLongitude));
|
|
|
|
|
boolean update = devopsDeviceInfoService.lambdaUpdate()
|
|
|
|
|
.eq(DevopsDeviceInfo::getGbsChannelNo, deviceInfo.getGbsChannelNo())
|
|
|
|
|
.update(deviceInfo);
|
|
|
|
|
if (update){
|
|
|
|
|
logger.info("修改成功");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|