Browse Source

球机代码初步完成 等待雷达持续发送数据 进行测试

v1
GG 1 year ago
parent
commit
4202946054
  1. BIN
      military/military-base/military-base-api/military-system-cloud-api/target/military-system-cloud-api-2.4.5.jar
  2. BIN
      military/military-base/military-base-api/military-system-local-api/target/military-system-local-api-2.4.5.jar
  3. BIN
      military/military-base/military-base-core/target/military-base-core-2.4.5.jar
  4. 2
      military/military-base/military-base-tools/src/main/java/com/zgx/common/util/GEOUtils.java
  5. BIN
      military/military-base/military-base-tools/target/military-base-tools-2.4.5.jar
  6. 577
      military/military-module-system/src/main/java/com/zgx/MilitaryZMQApplication.java
  7. 2
      military/military-module-system/src/main/java/com/zgx/modules/military/entity/MsCameraSetting.java
  8. 3
      military/military-module-system/src/main/java/com/zgx/modules/military/service/IMsCameraSettingService.java
  9. 119
      military/military-module-system/src/main/java/com/zgx/modules/military/service/impl/MsCameraSettingServiceImpl.java
  10. 12
      military/military-module-system/src/main/java/com/zgx/modules/military/utils/hp/HPDataHandle.java
  11. 2
      military/military-module-system/src/main/java/com/zgx/modules/military/utils/hp/HPTcpKeepAlive.java
  12. 3
      military/military-module-system/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
  13. 1
      military/military-module-system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
  14. BIN
      military/military-module-system/target/military-module-system-2.4.5.jar
  15. BIN
      military/military-module-system/target/military-module-system-2.4.5.jar.original

BIN
military/military-base/military-base-api/military-system-cloud-api/target/military-system-cloud-api-2.4.5.jar

Binary file not shown.

BIN
military/military-base/military-base-api/military-system-local-api/target/military-system-local-api-2.4.5.jar

Binary file not shown.

BIN
military/military-base/military-base-core/target/military-base-core-2.4.5.jar

Binary file not shown.

2
military/military-base/military-base-tools/src/main/java/com/zgx/common/util/GEOUtils.java

@ -57,7 +57,7 @@ public class GEOUtils {
public static double position(double lon1, double lat1, double lon2, double lat2) {
double longitude1 = lon1;
double longitude2 = lon2;
double latitude1 = Math.toRadians(lat1);//将度数转为y值
double latitude1 = Math.toRadians(lat1);
double latitude2 = Math.toRadians(lat2);
double longDiff = Math.toRadians(longitude2 - longitude1);
double y = Math.sin(longDiff) * Math.cos(latitude2);

BIN
military/military-base/military-base-tools/target/military-base-tools-2.4.5.jar

Binary file not shown.

577
military/military-module-system/src/main/java/com/zgx/MilitaryZMQApplication.java

@ -128,7 +128,7 @@ public class MilitaryZMQApplication implements ApplicationRunner {
zmqApplication.msAreaPointService = this.msAreaPointService;
zmqApplication.msPreWarnService = this.msPreWarnService;
zmqApplication.msAlarmSettingsService = this.msAlarmSettingsService;
zmqApplication.msCameraSettingService=this.msCameraSettingService;
zmqApplication.msCameraSettingService = this.msCameraSettingService;
}
@Override
@ -683,6 +683,7 @@ public class MilitaryZMQApplication implements ApplicationRunner {
//todo 新增代码 目标位置信息
/**
* case4 : 点击的目标数据 (只有点击雷达图上的目标时才发送)
* address : 172.20.0.77 (ZMQ发布地址)
* port : 5151
* topic : NyGuideCamPos
@ -809,69 +810,44 @@ public class MilitaryZMQApplication implements ApplicationRunner {
//todo : 联动控制球机
log.info("联动控制球机:");
List<MsCameraSetting> cameraSettings=null;//todo : 查询所有的球机 暂时查询本项目数据库 实际可能查询别的项目数据库
List<MsCameraSetting> cameraSettings = null;//todo : 查询所有的球机 暂时查询本项目数据库 实际可能查询别的项目数据库
LambdaQueryWrapper<MsCameraSetting> cameraSettingLambdaQueryWrapper = new LambdaQueryWrapper<>();
cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,2);//只查询球机的信息 type:2 球机 type:1 枪击 type:10 故障
//todo : 用于调整球机初始角
//cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,5);//只查询球机的信息
cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType, 2);//只查询球机的信息 type:2 球机 type:1 枪击 type:10 故障
//cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,5);//只查询球机的信息 用于调整球机初始角
cameraSettings = msCameraSettingService.list(cameraSettingLambdaQueryWrapper);
if (cameraSettings==null|| cameraSettings.isEmpty()){
if (cameraSettings == null || cameraSettings.isEmpty()) {
return;
}
log.info("case4 : 遍历相机列表 寻找最近的点的球机去跟踪");
log.info("case4 : "+JSON.toJSONString(cameraSettings));
//todo : 未优化算法(减少相机数量)
/* double minDis=GEOUtils.GetDistance(cameraSettings.get(0).getLongitude().doubleValue(),cameraSettings.get(0).getLatitude().doubleValue(), targetLonLat.getLon(), targetLonLat.getLat());
int index=0;
for (int i = 1; i < cameraSettings.size(); i++) {
MsCameraSetting cameraSetting = cameraSettings.get(i);
//todo : 1.计算距离 选最近球机 进行跟踪
BigDecimal cameraHeight = cameraSetting.getHeight();
BigDecimal labelHeight = new BigDecimal(h);
double heightDiff = cameraHeight.subtract(labelHeight).doubleValue();
if (heightDiff < 0) {
log.info("IP:"+cameraSetting.getIp()+"与目标的高度差:"+heightDiff+"小于0");
} else{
BigDecimal longitude = cameraSetting.getLongitude();//经度
BigDecimal latitude = cameraSetting.getLatitude();//纬度
double zDis = GEOUtils.GetDistance(longitude.doubleValue(), latitude.doubleValue(), targetLonLat.getLon(), targetLonLat.getLat());
log.info("下标i:"+i+ " 相机IP:"+ cameraSetting.getIp() +" 距离当前相机:"+zDis);
//todo : 更新距离最小的数据 如果数据是按顺序的 可以判断当数据比前一个数据变大的时候就终止 取前一个数据
if (zDis<minDis){
minDis=zDis;
index=i;
}
}
}*/
log.info("case4 : " + JSON.toJSONString(cameraSettings));
// todo : 优化1.0
// 计算距离最近的球机
MsCameraSetting msCameraSetting=null;//最近球机信息
double nearestDistance=0;//最近距离
double heightDiff=0;//最近球机的高度差
MsCameraSetting msCameraSetting = null;//最近球机信息
double nearestDistance = 0;//最近距离
double heightDiff = 0;//最近球机的高度差
//Map cameraList=new HashMap();//保存距离目标球机的顺序
for (MsCameraSetting cameraSetting : cameraSettings) {
// todo : 判断该球机是否满足照射范围 不满足的话还可以找第二近的球机 如果放到后面才判断高度差 就无法找第二近的去跟踪了
BigDecimal cameraHeight = cameraSetting.getHeight();//球机高度
BigDecimal labelHeight = new BigDecimal(h);//目标高度
double tempHeightDiff = cameraHeight.subtract(labelHeight).doubleValue();//球机与目标高度差
if (tempHeightDiff<0){
log.info("case4 :"+"ip="+cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围");
}else {
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(),cameraSetting.getLatitude().doubleValue(),targetLonLat.getLon(),targetLonLat.getLat());
if (tempHeightDiff < 0) {
log.info("case4 :" + "ip=" + cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围");
} else {
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(), cameraSetting.getLatitude().doubleValue(), targetLonLat.getLon(), targetLonLat.getLat());
// 第一次 先将第一个球机的距离作为最近距离 和 最近球机信息
if (msCameraSetting==null){
msCameraSetting=cameraSetting;
nearestDistance=temp;
if (msCameraSetting == null) {
msCameraSetting = cameraSetting;
nearestDistance = temp;
continue;
}
// 第二次以后 如果距离更近则更新最近距离 以及 最近球机信息
if (nearestDistance>temp){
msCameraSetting=cameraSetting;
nearestDistance=temp;
heightDiff=tempHeightDiff;
if (nearestDistance > temp) {
msCameraSetting = cameraSetting;
nearestDistance = temp;
heightDiff = tempHeightDiff;
}
}
}
@ -881,30 +857,17 @@ public class MilitaryZMQApplication implements ApplicationRunner {
double heightDiff= msCameraSetting.getHeight().subtract(BigDecimal.valueOf(h)).doubleValue();
*/ //判断两点的距离是否超过有效距离,超过则丢掉
if (nearestDistance > Integer.parseInt(redisUtil.hget("alarm_settings", "inOutEffectDistance").toString())) {
log.info("case4 :"+"超过跟踪的最大距离"+redisUtil.hget("alarm_settings", "inOutEffectDistance").toString());
log.info("case4 :" + "超过跟踪的最大距离" + redisUtil.hget("alarm_settings", "inOutEffectDistance").toString());
return;
}
//MsCameraSetting msCameraSetting = cameraSettings.get(index);
log.info("case4 :"+" 相机IP:"+ msCameraSetting.getIp() +" 最短距离nearestDistance:"+nearestDistance);
log.info("case4 :"+"距离最近的相机:"+JSON.toJSONString(msCameraSetting));
/* //todo : 计算PTZ
//球机高度
BigDecimal cameraHeight = msCameraSetting.getHeight();
//目标高度
BigDecimal labelHeight = new BigDecimal(h);
//球机与目标的高度差
double heightDiff = cameraHeight.subtract(labelHeight).doubleValue();
//高度差小于0 则说明目标在球机上方 超过球机照射范围
if (heightDiff < 0) {
log.info("heightDiff < 0 超过球机照射范围");
return;
}*/
log.info("case4 :" + " 相机IP:" + msCameraSetting.getIp() + " 最短距离nearestDistance:" + nearestDistance);
log.info("case4 :" + "距离最近的相机:" + JSON.toJSONString(msCameraSetting));
//todo : 球机也跟踪光电过去(此处可保留 也可删除 因为轨迹数据也会让球机过去)
//1.先控制球机照射目标
log.info("【尝试使用ptzControllerByLatLonAndDistance】");
log.info("case4【尝试使用ptzControllerByLatLonAndDistance】将球机转到目标位置");
msCameraSettingService.ptzControllerByLatLon(msCameraSetting.getIp(),
msCameraSetting.getUser(),
msCameraSetting.getPassword(),
@ -917,64 +880,42 @@ public class MilitaryZMQApplication implements ApplicationRunner {
targetLonLat.getLon(),
targetLonLat.getLat(),
msCameraSetting.getStyle());//style用于区分品牌类型 1:海康 2:宇视
log.info("case4 :"+"【参数信息】");
log.info("cameraSetting.getUser():"+msCameraSetting.getUser());
log.info("cameraSetting.getPassword():"+msCameraSetting.getPassword());
log.info("cameraSetting.getMaxElevation():"+msCameraSetting.getMaxElevation());
log.info("cameraSetting.getZeroAzimuth():"+msCameraSetting.getZeroAzimuth());
log.info("heightDiff:"+heightDiff);
log.info("cameraSetting.getZoomFactor():"+msCameraSetting.getZoomFactor());
log.info("cameraSetting.getLongitude():"+msCameraSetting.getLongitude().doubleValue());
log.info("cameraSetting.getLatitude():"+msCameraSetting.getLatitude().doubleValue());
log.info("targetLonLat.getLon()"+targetLonLat.getLon());
log.info("targetLonLat.getLat()"+targetLonLat.getLat());
log.info("case4 :" + "【参数信息】");
log.info("cameraSetting.getUser():" + msCameraSetting.getUser());
log.info("cameraSetting.getPassword():" + msCameraSetting.getPassword());
log.info("cameraSetting.getMaxElevation():" + msCameraSetting.getMaxElevation());
log.info("cameraSetting.getZeroAzimuth():" + msCameraSetting.getZeroAzimuth());
log.info("heightDiff:" + heightDiff);
log.info("cameraSetting.getZoomFactor():" + msCameraSetting.getZoomFactor());
log.info("cameraSetting.getLongitude():" + msCameraSetting.getLongitude().doubleValue());
log.info("cameraSetting.getLatitude():" + msCameraSetting.getLatitude().doubleValue());
log.info("targetLonLat.getLon()" + targetLonLat.getLon());
log.info("targetLonLat.getLat()" + targetLonLat.getLat());
//todo : 2.水平跟踪目标 目标详细信息再redis中 当雷达开启目标跟踪后 将发case3数据 订阅case3数据后 将目标详细数据缓存到redis中
log.info("------case4将球机转到目标位置-------");
//由于只能接收到方位角和距离 并且轨迹不断更新 所以只能将方位角和距离进行
//由于经纬度不断变化 暂时不使用经纬度进行定位
DecimalFormat decimalFormat = new DecimalFormat("#.00");//保留两位小数
String longitude = decimalFormat.format(targetLonLat.getLon());
String latitude = decimalFormat.format(targetLonLat.getLat());
//获取轨迹信息
//String redisKey = "tracks"+"_"+longitude+"_"+latitude;
int redisAzimuth=(int)azimuth;
String redisKey = "tracks:"+redisAzimuth;
log.info("case4 :"+"longitude:"+longitude+" "+"latitude"+latitude+"azimuth"+redisAzimuth);
// todo : 1.通过船速和航向控制球机转动(不采用)
/* float targetSpeed = Float.parseFloat(redisUtil.hget(redisKey, "targetSpeed").toString());//航速
float targetCourse =Float.parseFloat(redisUtil.hget(redisKey, "targetCourse").toString());//航向
int redisAzimuth = (int) azimuth;
int redisDis = (((int) distance + 999) / 1000) * 1000;
String redisKey = "tracks:" + redisAzimuth + "_" + redisDis;
log.info("case4 :" + "longitude:" + longitude + " " + "latitude" + latitude + "azimuth" + redisAzimuth + redisDis);
log.info("case4 :" + "redisKey = " + redisKey);
log.info("targetCourse 航向:"+String.valueOf(targetSpeed));
log.info("targetSpeed 航速:"+String.valueOf(targetCourse));
double ySpend = Math.cos(Math.toRadians(targetCourse))*targetSpeed; //正数 上 负数 下
log.info("ySpend 方向:"+String.valueOf(ySpend));
String instruct="stop";
//todo : 待优化
if (ySpend>=0){ //160 下 330 上
instruct="right";//(-1, 0, 0)
}else {
instruct="left";//(1, 0, 0)
}
//todo : 速度的计算 根据航速和航向
float speed= (float) (targetSpeed * msCameraSetting.getLeftAngle());
log.info("相机水平转动速度:"+String.valueOf(speed)+"方向:"+instruct);
msCameraSettingService.ptzControl(msCameraSetting.getIp(), msCameraSetting.getUser(), msCameraSetting.getPassword(),instruct,speed);
*/
//todo : 2.通过不断更新的船经纬度信息控制球机转动
/* redisUtil.hget(redisKey,"targetLon");
redisUtil.hget(redisKey,"targetLat");*/
int trackId = (int) redisUtil.hget(redisKey, "trackId");//根据方位角 找到 轨迹Id
redisUtil.hset("trackingTargetId", String.valueOf(trackId),msCameraSetting.getIp());//将该轨迹 和 定位该轨迹的球机 保存到跟踪队列中
log.info("正在跟踪的trackId:"+trackId);
int trackId = Integer.valueOf(redisUtil.hget(redisKey, "trackId").toString());//根据方位角 找到 轨迹Id
redisUtil.hset("trackingTargetId", String.valueOf(trackId), msCameraSetting.getIp());//将该轨迹 和 定位该轨迹的球机 保存到跟踪队列中
log.info("正在跟踪的trackId:" + trackId);
//todo : 根据trackId更新的数据转动球机
//todo : case4 当前轨迹数据是正在跟踪点时 调动球机跟踪
} catch (UnsupportedEncodingException e) {
@ -986,8 +927,10 @@ public class MilitaryZMQApplication implements ApplicationRunner {
};
new Thread(nyGuideCamPosThread).start();
//todo : 新增代码 球机联动
/**
* case3 : 船轨迹数据 (开启目标跟踪使能后 持续发送)
* address : 172.20.0.77 (ZMQ发布地址)
* port : 5151
* topic : RadarTrack(todo : 暂时写死 后续通过配置文件配置)
@ -997,13 +940,13 @@ public class MilitaryZMQApplication implements ApplicationRunner {
public void dealWithData(byte[] data) throws ParseException {
log.info(Thread.currentThread().getName() + "接收到数据:" + new String(data));
JSONObject jsonObject = JSON.parseObject(new String(data));
log.info("case3 :"+"1.RadarTrack数据:" + jsonObject.toString());
log.info("case3 :" + "1.RadarTrack数据:" + jsonObject.toString());
String radarTarcksJsonString = (String) jsonObject.get("radarTracks");
List<RadarTrackModel> radarTrackModels = JSONObject.parseArray(radarTarcksJsonString, RadarTrackModel.class);
log.info(JSON.toJSONString(radarTrackModels));
RadarTrackModel radarTrackModel = radarTrackModels.get(0);
log.info("case3 :"+JSON.toJSONString(radarTrackModel));
log.info("case3 :" + JSON.toJSONString(radarTrackModel));
//将经纬度作为key去定位
DecimalFormat decimalFormat = new DecimalFormat("#.00");
@ -1011,107 +954,105 @@ public class MilitaryZMQApplication implements ApplicationRunner {
String latitude = decimalFormat.format(radarTrackModel.getLatitude());
String azimuth = decimalFormat.format(radarTrackModel.getAzimuth());
log.info("longitude:"+longitude+"latitude:"+latitude+"azimuth:"+azimuth);
log.info("longitude:" + longitude + "latitude:" + latitude + "azimuth:" + azimuth);
//将每个目标轨迹信息进行缓存
//String redisKey = "tracks"+"_"+longitude+"_"+latitude;//经纬度来进行缓存
float redisAzimuth=Float.parseFloat(azimuth);
float redisAzimuth = Float.parseFloat(azimuth);
int redisDis = ((radarTrackModel.getDis() + 999) / 1000) * 1000;
String redisKey = "tracks:"+(int)redisAzimuth;//方位角进行缓存
String redisKey = "tracks:" + (int) redisAzimuth + "_" + redisDis;//方位角进行缓存
//String redisKey = "tracks";//方位角进行缓存
//todo : 将雷达轨迹数据持续进行缓存 后续根据当用户点击雷达图的目标时 持续跟踪最新的该目标信息(存在的问题 : 雷达数据不更新)
log.info("redisKey:"+redisKey);
log.info("redisKey:" + redisKey);
//缓存 Azimuth =》 船信息
redisUtil.hset(redisKey,"targetLon",radarTrackModel.getLongitude());
redisUtil.hset(redisKey,"targetLat",radarTrackModel.getLatitude());
redisUtil.hset(redisKey,"targetDis",radarTrackModel.getDis());
redisUtil.hset(redisKey,"targetAzimuth",radarTrackModel.getAzimuth());
redisUtil.hset(redisKey,"targetCourse",radarTrackModel.getCourse());
redisUtil.hset(redisKey,"targetSpeed",radarTrackModel.getSpeed());
redisUtil.hset(redisKey,"trackId",radarTrackModel.getTrackId());
redisUtil.hset(redisKey, "targetLon", radarTrackModel.getLongitude());
redisUtil.hset(redisKey, "targetLat", radarTrackModel.getLatitude());
redisUtil.hset(redisKey, "targetDis", radarTrackModel.getDis());
redisUtil.hset(redisKey, "targetAzimuth", radarTrackModel.getAzimuth());
redisUtil.hset(redisKey, "targetCourse", radarTrackModel.getCourse());
redisUtil.hset(redisKey, "targetSpeed", radarTrackModel.getSpeed());
redisUtil.hset(redisKey, "trackId", radarTrackModel.getTrackId());
//缓存 TrackId =》 船信息 (todo:如果雷达case 4数据可以多发一个trackId 就无需多缓存azimuth)
String trackIdKey = "trackIds:"+radarTrackModel.getTrackId();
redisUtil.hset(trackIdKey,"targetLon",radarTrackModel.getLongitude());
redisUtil.hset(trackIdKey,"targetLat",radarTrackModel.getLatitude());
redisUtil.hset(trackIdKey,"targetDis",radarTrackModel.getDis());
redisUtil.hset(trackIdKey,"targetAzimuth",radarTrackModel.getAzimuth());
redisUtil.hset(trackIdKey,"targetCourse",radarTrackModel.getCourse());
redisUtil.hset(trackIdKey,"targetSpeed",radarTrackModel.getSpeed());
redisUtil.hset(trackIdKey,"trackId",radarTrackModel.getTrackId());
String trackIdKey = "trackIds:" + radarTrackModel.getTrackId();
redisUtil.hset(trackIdKey, "targetLon", radarTrackModel.getLongitude());
redisUtil.hset(trackIdKey, "targetLat", radarTrackModel.getLatitude());
redisUtil.hset(trackIdKey, "targetDis", radarTrackModel.getDis());
redisUtil.hset(trackIdKey, "targetAzimuth", radarTrackModel.getAzimuth());
redisUtil.hset(trackIdKey, "targetCourse", radarTrackModel.getCourse());
redisUtil.hset(trackIdKey, "targetSpeed", radarTrackModel.getSpeed());
redisUtil.hset(trackIdKey, "trackId", radarTrackModel.getTrackId());
//redis中存在正在跟踪的轨迹目标信息
String ip = (String) redisUtil.hget("trackingTargetId", String.valueOf(radarTrackModel.getTrackId()));//获取并判断雷达传过来的轨迹数据 看是否该轨迹在跟踪目标队列中
log.info("查询当前轨迹是否处于跟踪状态"+ip);
if (ip!=null){// 该轨迹处于跟踪状态
log.info("查询当前轨迹是否处于跟踪状态" + ip);
if (ip != null) {// 该轨迹处于跟踪状态
// todo : 2.0
//计算最近球机
List<MsCameraSetting> cameraSettings=null;//todo : 查询所有的球机 暂时查询本项目数据库 实际可能查询别的项目数据库
List<MsCameraSetting> cameraSettings = null;//todo : 查询所有的球机 暂时查询本项目数据库 实际可能查询别的项目数据库
LambdaQueryWrapper<MsCameraSetting> cameraSettingLambdaQueryWrapper = new LambdaQueryWrapper<>();
cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,2);//只查询球机的信息 type:2 球机 type:1 枪击 type:10 故障
//todo : 用于调整球机初始角
//cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,5);//只查询球机的信息
cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType, 2);//只查询球机的信息 type:2 球机 type:1 枪击 type:10 故障
//cameraSettingLambdaQueryWrapper.eq(MsCameraSetting::getType,5);//只查询球机的信息 用于调整球机初始角
cameraSettings = msCameraSettingService.list(cameraSettingLambdaQueryWrapper);
if (cameraSettings==null|| cameraSettings.isEmpty()){
if (cameraSettings == null || cameraSettings.isEmpty()) {
return;
}
log.info("遍历相机列表 寻找最近的点的球机去跟踪");
log.info(JSON.toJSONString(cameraSettings));
MsCameraSetting msCameraSetting=null;//最近球机信息
double nearestDistance=0;//最近距离
double heightDiff=0;//最近球机的高度差
MsCameraSetting msCameraSetting = null;//最近球机信息
double nearestDistance = 0;//最近距离
double heightDiff = 0;//最近球机的高度差
double targetHeight = Double.parseDouble(redisUtil.hget("alarm_settings", "targetHeight").toString());
//Map cameraList=new HashMap();//保存距离目标球机的顺序
for (MsCameraSetting cameraSetting : cameraSettings) {
// todo : 判断该球机是否满足照射范围 不满足的话还可以找第二近的球机 如果放到后面才判断高度差 就无法找第二近的去跟踪了
BigDecimal cameraHeight = cameraSetting.getHeight();//球机高度
BigDecimal labelHeight = new BigDecimal(targetHeight);//目标高度
double tempHeightDiff = cameraHeight.subtract(labelHeight).doubleValue();//球机与目标高度差
if (tempHeightDiff<0){
log.info("case3 :"+"ip="+cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围");
}else {
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(),cameraSetting.getLatitude().doubleValue(),(double) redisUtil.hget("trackIds:"+radarTrackModel.getTrackId(), "targetLon"),(double) redisUtil.hget("trackIds:"+radarTrackModel.getTrackId(), "targetLat"));
if (tempHeightDiff < 0) {
log.info("case3 :" + "ip=" + cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围");
} else {
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(), cameraSetting.getLatitude().doubleValue(), (double) redisUtil.hget("trackIds:" + radarTrackModel.getTrackId(), "targetLon"), (double) redisUtil.hget("trackIds:" + radarTrackModel.getTrackId(), "targetLat"));
// 第一次 先将第一个球机的距离作为最近距离 和 最近球机信息
if (msCameraSetting==null){
msCameraSetting=cameraSetting;
nearestDistance=temp;
if (msCameraSetting == null) {
msCameraSetting = cameraSetting;
nearestDistance = temp;
continue;
}
// 第二次以后 如果距离更近则更新最近距离 以及 最近球机信息
if (nearestDistance>temp){
msCameraSetting=cameraSetting;
nearestDistance=temp;
heightDiff=tempHeightDiff;
if (nearestDistance > temp) {
msCameraSetting = cameraSetting;
nearestDistance = temp;
heightDiff = tempHeightDiff;
}
}
}
//判断两点的距离是否超过有效距离,超过则丢掉
if (nearestDistance > Integer.parseInt(redisUtil.hget("alarm_settings", "inOutEffectDistance").toString())) {
log.info("case3 :"+"超过跟踪的最大距离"+redisUtil.hget("alarm_settings", "inOutEffectDistance").toString());
log.info("case3 :" + "超过跟踪的最大距离" + redisUtil.hget("alarm_settings", "inOutEffectDistance").toString());
return;
}
//MsCameraSetting msCameraSetting = cameraSettings.get(index);
log.info("case3 :"+" 相机IP:"+ msCameraSetting.getIp() +" 最短距离nearestDistance:"+nearestDistance);
log.info("case3 :"+"距离最近的相机:"+JSON.toJSONString(msCameraSetting));
log.info("case3 :" + " 相机IP:" + msCameraSetting.getIp() + " 最短距离nearestDistance:" + nearestDistance);
log.info("case3 :" + "距离最近的相机:" + JSON.toJSONString(msCameraSetting));
//todo : 1.0
String trackIdKey2 = "trackIds:"+radarTrackModel.getTrackId();//获取该轨迹对应的最新数据
String trackIdKey2 = "trackIds:" + radarTrackModel.getTrackId();//获取该轨迹对应的最新数据
double targetLon = (double) redisUtil.hget(trackIdKey2, "targetLon");
double targetLat = (double) redisUtil.hget(trackIdKey2, "targetLat");
//LambdaQueryWrapper<MsCameraSetting> lambdaQueryWrapper = new LambdaQueryWrapper<MsCameraSetting>().eq(MsCameraSetting::getIp, ip);
//MsCameraSetting msCameraSetting = msCameraSettingService.getOne(lambdaQueryWrapper);
//控制球机照射目标
log.info("case3 :"+"【尝试使用ptzControllerByLatLonAndDistance】");
log.info("case3 :" + "【尝试使用ptzControllerByLatLonAndDistance】");
msCameraSettingService.ptzControllerByLatLon(msCameraSetting.getIp(),
msCameraSetting.getUser(),
msCameraSetting.getPassword(),
@ -1125,18 +1066,17 @@ public class MilitaryZMQApplication implements ApplicationRunner {
targetLat,
msCameraSetting.getStyle());//style用于区分品牌类型 1:海康 2:宇视
log.info("【参数信息】");
log.info("cameraSetting.getUser():"+msCameraSetting.getUser());
log.info("cameraSetting.getPassword():"+msCameraSetting.getPassword());
log.info("cameraSetting.getMaxElevation():"+msCameraSetting.getMaxElevation());
log.info("cameraSetting.getZeroAzimuth():"+msCameraSetting.getZeroAzimuth());
log.info("heightDiff:"+heightDiff);
log.info("cameraSetting.getZoomFactor():"+msCameraSetting.getZoomFactor());
log.info("cameraSetting.getLongitude():"+msCameraSetting.getLongitude().doubleValue());
log.info("cameraSetting.getLatitude():"+msCameraSetting.getLatitude().doubleValue());
log.info("targetLonLat.getLon()"+targetLon);
log.info("targetLonLat.getLat()"+targetLat);
log.info("case3 :"+"已控制球机照过去 等待下一次轨迹信息 在进行下次定位");
log.info("cameraSetting.getUser():" + msCameraSetting.getUser());
log.info("cameraSetting.getPassword():" + msCameraSetting.getPassword());
log.info("cameraSetting.getMaxElevation():" + msCameraSetting.getMaxElevation());
log.info("cameraSetting.getZeroAzimuth():" + msCameraSetting.getZeroAzimuth());
log.info("heightDiff:" + heightDiff);
log.info("cameraSetting.getZoomFactor():" + msCameraSetting.getZoomFactor());
log.info("cameraSetting.getLongitude():" + msCameraSetting.getLongitude().doubleValue());
log.info("cameraSetting.getLatitude():" + msCameraSetting.getLatitude().doubleValue());
log.info("targetLonLat.getLon()" + targetLon);
log.info("targetLonLat.getLat()" + targetLat);
log.info("case3 :" + "已控制球机照过去 等待下一次更新的轨迹信息 在进行下次定位");
}
}
@ -1146,133 +1086,6 @@ public class MilitaryZMQApplication implements ApplicationRunner {
public static void main(String[] args) throws SOAPException, ConnectException {
float speed=10.45f;
System.out.println(speed*1000L);
long result= (long) (speed*1000L);
System.out.println(result);
RadarTrackModel radarTrackModel =new RadarTrackModel();
radarTrackModel.setDis(1);
log.info(JSON.toJSONString(radarTrackModel));
String a="314.8044";
float b= Float.parseFloat(a);
System.out.println(b);
float azimuth=314.80445f;
int redisAzimuth=(int)azimuth;
System.out.println(redisAzimuth);
double targetSpeed=1.0831853;
double targetCourse=330;
double degree=Math.toRadians(targetCourse);
double cos=Math.cos(degree);
double ySpend = Math.cos(targetCourse)*targetSpeed;
System.out.println(degree);
System.out.println(cos);
System.out.println(ySpend);
System.out.println("--------------------");
/* System.out.println(System.getProperty("user.dir") + "\\lib\\hk\\win64\\HCNetSDK.dll");
de.onvif.soap.OnvifDevice onvifDevice = new OnvifDevice("192.168.1.71","admin","hk123456");
PtzDevices ptzDevices = onvifDevice.getPtz();
String token = onvifDevice.getDevices().getProfiles().get(0).getToken();*/
// boolean absoluteMoveSupported = ptzDevices.isAbsoluteMoveSupported(token);
/* System.out.println(absoluteMoveSupported);
ptzDevices.absoluteMove(token,0.5f,0.5f,0.5f);
ptzDevices.relativeMove(token,0,0,0.5f);*/
/* ptzDevices.absoluteMove(token,0.5f,0f,0f);
ptzDevices.relativeMove(token,0,0,0.5f);
ptzDevices.continuousMove(token,0.5f , 0f, 0f);
//ptzDevices.stopMove(token);
PTZStatus status = ptzDevices.getStatus(token);*/
JSONObject jsonObject = new JSONObject();
jsonObject.put("flag",1);
jsonObject.put("sourceId","AgilTrack_cat010bsz");
jsonObject.put("utc",System.currentTimeMillis());
List<RadarTrackModel> radarTracks=new ArrayList<>();
RadarTrackModel radarTrack = new RadarTrackModel();
radarTrack.setDis(100);
radarTrack.setAzimuth(315);
radarTrack.setRadarId(10);
radarTrack.setSpeed(10);
radarTrack.setLatitude(22.180616f);
radarTrack.setLongitude(113.40126f);
radarTracks.add(radarTrack);
jsonObject.put("radarTracks",JSON.toJSONString(radarTracks));
String jsonString = JSON.toJSONString(jsonObject);
byte[] data=jsonString.getBytes();
JSONObject jsonObject2 = JSON.parseObject(new String(data));
log.info("1.RadarTrack数据:" + jsonObject2.toString());
String radarTarcksJsonString = (String) jsonObject2.get("radarTracks");
List<RadarTrackModel> radarTrackModels = JSONObject.parseArray(radarTarcksJsonString, RadarTrackModel.class);
float latitude = radarTrackModels.get(0).getLatitude();
float longitude = radarTrackModels.get(0).getLongitude();
DecimalFormat decimalFormat = new DecimalFormat("#.00");
String l = decimalFormat.format(latitude);
String r = decimalFormat.format(longitude);
System.out.println(latitude);
System.out.println(longitude);
System.out.println(l);
System.out.println(r);
System.out.println(radarTrackModels);
float ab=1.0831853f;
log.info(String.valueOf(ab));
}
/**
* 获取最近球机
* @param cameraSettings 所有球机
* @param targetHeight 目标高度
* @param targetLon 目标经度
* @param targetLat 目标纬度
* @return
*/
public MsCameraSetting getNearestDistanceCamera(List<MsCameraSetting> cameraSettings,double targetHeight,double targetLon,double targetLat){
// todo : 优化1.0
// 计算距离最近的球机
MsCameraSetting msCameraSetting=null;//最近球机信息
double nearestDistance=0;//最近距离
double heightDiff=0;//最近球机的高度差
//Map cameraList=new HashMap();//保存距离目标球机的顺序
for (MsCameraSetting cameraSetting : cameraSettings) {
// todo : 判断该球机是否满足照射范围 不满足的话还可以找第二近的球机 如果放到后面才判断高度差 就无法找第二近的去跟踪了
BigDecimal cameraHeight = cameraSetting.getHeight();//球机高度
BigDecimal labelHeight = new BigDecimal(targetHeight);//目标高度
double tempHeightDiff = cameraHeight.subtract(labelHeight).doubleValue();//球机与目标高度差
if (tempHeightDiff<0){
log.info("ip="+cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围");
}else {
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(),cameraSetting.getLatitude().doubleValue(),targetLon,targetLat);
// 第一次 先将第一个球机的距离作为最近距离 和 最近球机信息
if (msCameraSetting==null){
msCameraSetting=cameraSetting;
nearestDistance=temp;
continue;
}
// 第二次以后 如果距离更近则更新最近距离 以及 最近球机信息
if (nearestDistance>temp){
msCameraSetting=cameraSetting;
nearestDistance=temp;
heightDiff=tempHeightDiff;
}
}
}
//判断两点的距离是否超过有效距离,超过则丢掉
if (nearestDistance > Integer.parseInt(redisUtil.hget("alarm_settings", "inOutEffectDistance").toString())) {
log.info("超过跟踪的最大距离"+redisUtil.hget("alarm_settings", "inOutEffectDistance").toString());
}
return msCameraSetting;
}
/**
* 计算围网报警有效区域围网外5米 + 雷达测角误差±1°造成的距离偏差
@ -1346,7 +1159,7 @@ public class MilitaryZMQApplication implements ApplicationRunner {
msPreWarn.setKind(WarnType.WARN.getValue());
boolean result = msPreWarnService.save(msPreWarn);
if (result) {
// 当新增报警信息时,websocket通知前端刷新数据
//当新增报警信息时,websocket通知前端刷新数据
JSONObject obj = new JSONObject();
obj.put("cmd", "new_warn_info");//业务类型
obj.put("serialNum", msPreWarn.getEventSerialNum());//时间编号
@ -1416,4 +1229,176 @@ public class MilitaryZMQApplication implements ApplicationRunner {
return new MsAreaPoint[]{pointMap.get(min1), pointMap.get(min2)};
}
//测试数据
public static void main(String[] args) throws SOAPException, ConnectException {
float d = 3142f;
int redisDis = (((int) d + 999) / 1000) * 1000;
System.out.println(redisDis);
int dis = 845;
int count = (int) Math.log10(dis) + 1;
System.out.println();//判断一个数是几位数
int num = 5000;
System.out.println(((num + 999) / 1000) * 1000);
float speed = 10.45f;
System.out.println(speed * 1000L);
long result = (long) (speed * 1000L);
System.out.println(result);
RadarTrackModel radarTrackModel = new RadarTrackModel();
radarTrackModel.setDis(1);
log.info(JSON.toJSONString(radarTrackModel));
String a = "314.8044";
float b = Float.parseFloat(a);
System.out.println(b);
float azimuth = 314.80445f;
int redisAzimuth = (int) azimuth;
System.out.println(redisAzimuth);
double targetSpeed = 1.0831853;
double targetCourse = 330;
double degree = Math.toRadians(targetCourse);
double cos = Math.cos(degree);
double ySpend = Math.cos(targetCourse) * targetSpeed;
System.out.println(degree);
System.out.println(cos);
System.out.println(ySpend);
System.out.println("--------------------");
/* System.out.println(System.getProperty("user.dir") + "\\lib\\hk\\win64\\HCNetSDK.dll");
de.onvif.soap.OnvifDevice onvifDevice = new OnvifDevice("192.168.1.71","admin","hk123456");
PtzDevices ptzDevices = onvifDevice.getPtz();
String token = onvifDevice.getDevices().getProfiles().get(0).getToken();*/
// boolean absoluteMoveSupported = ptzDevices.isAbsoluteMoveSupported(token);
/* System.out.println(absoluteMoveSupported);
ptzDevices.absoluteMove(token,0.5f,0.5f,0.5f);
ptzDevices.relativeMove(token,0,0,0.5f);*/
/* ptzDevices.absoluteMove(token,0.5f,0f,0f);
ptzDevices.relativeMove(token,0,0,0.5f);
ptzDevices.continuousMove(token,0.5f , 0f, 0f);
//ptzDevices.stopMove(token);
PTZStatus status = ptzDevices.getStatus(token);*/
JSONObject jsonObject = new JSONObject();
jsonObject.put("flag", 1);
jsonObject.put("sourceId", "AgilTrack_cat010bsz");
jsonObject.put("utc", System.currentTimeMillis());
List<RadarTrackModel> radarTracks = new ArrayList<>();
RadarTrackModel radarTrack = new RadarTrackModel();
radarTrack.setDis(100);
radarTrack.setAzimuth(315);
radarTrack.setRadarId(10);
radarTrack.setSpeed(10);
radarTrack.setLatitude(22.180616f);
radarTrack.setLongitude(113.40126f);
radarTracks.add(radarTrack);
jsonObject.put("radarTracks", JSON.toJSONString(radarTracks));
String jsonString = JSON.toJSONString(jsonObject);
byte[] data = jsonString.getBytes();
JSONObject jsonObject2 = JSON.parseObject(new String(data));
log.info("1.RadarTrack数据:" + jsonObject2.toString());
String radarTarcksJsonString = (String) jsonObject2.get("radarTracks");
List<RadarTrackModel> radarTrackModels = JSONObject.parseArray(radarTarcksJsonString, RadarTrackModel.class);
float latitude = radarTrackModels.get(0).getLatitude();
float longitude = radarTrackModels.get(0).getLongitude();
DecimalFormat decimalFormat = new DecimalFormat("#.00");
String l = decimalFormat.format(latitude);
String r = decimalFormat.format(longitude);
System.out.println(latitude);
System.out.println(longitude);
System.out.println(l);
System.out.println(r);
System.out.println(radarTrackModels);
float ab = 1.0831853f;
log.info(String.valueOf(ab));
}
//根据船速和航向进行跟踪
private void trackingTarget() {
// todo : 通过船速和航向控制球机转动(不采用)
MsCameraSetting msCameraSetting=null;
String redisKey = "";//根据雷达图上目标的距离和方位角找到轨迹数据中对应的目标ID
float targetSpeed = Float.parseFloat(redisUtil.hget(redisKey, "targetSpeed").toString());//获取跟踪目标的航速
float targetCourse = Float.parseFloat(redisUtil.hget(redisKey, "targetCourse").toString());//获取跟踪目标的航向
log.info("targetCourse 航向:" + String.valueOf(targetSpeed));
log.info("targetSpeed 航速:" + String.valueOf(targetCourse));
//计算水平运动速度
double ySpend = Math.cos(Math.toRadians(targetCourse)) * targetSpeed; //正数 上 负数 下
log.info("ySpend 方向:" + String.valueOf(ySpend));
String instruct = "stop";
//todo : 待优化
if (ySpend >= 0) { //160 下 330 上
instruct = "right";//(-1, 0, 0)
} else {
instruct = "left";//(1, 0, 0)
}
//todo : 速度的计算 根据航速和航向
float speed = (float) (targetSpeed * msCameraSetting.getLeftAngle());
log.info("相机水平转动速度:" + String.valueOf(speed) + "方向:" + instruct);
msCameraSettingService.ptzControl(msCameraSetting.getIp(), msCameraSetting.getUser(), msCameraSetting.getPassword(), instruct, speed);
}
/**
* 获取最近球机
*
* @param cameraSettings 所有球机
* @param targetHeight 目标高度
* @param targetLon 目标经度
* @param targetLat 目标纬度
* @return
*/
public MsCameraSetting getNearestDistanceCamera(List<MsCameraSetting> cameraSettings, double targetHeight, double targetLon, double targetLat) {
// 计算距离最近的球机
MsCameraSetting msCameraSetting = null;//最近球机信息
double nearestDistance = 0;//最近距离
double heightDiff = 0;//最近球机的高度差
//Map cameraList=new HashMap();//保存距离目标球机的顺序
for (MsCameraSetting cameraSetting : cameraSettings) {
// todo : 判断该球机是否满足照射范围 不满足的话还可以找第二近的球机 如果放到后面才判断高度差 就无法找第二近的去跟踪了
BigDecimal cameraHeight = cameraSetting.getHeight();//球机高度
BigDecimal labelHeight = new BigDecimal(targetHeight);//目标高度
double tempHeightDiff = cameraHeight.subtract(labelHeight).doubleValue();//球机与目标高度差
if (tempHeightDiff < 0) {
log.info("ip=" + cameraSetting.getIp() + " tempHeightDiff < 0 超过球机照射范围");
} else {
double temp = GEOUtils.GetDistance(cameraSetting.getLongitude().doubleValue(), cameraSetting.getLatitude().doubleValue(), targetLon, targetLat);
// 第一次 先将第一个球机的距离作为最近距离 和 最近球机信息
if (msCameraSetting == null) {
msCameraSetting = cameraSetting;
nearestDistance = temp;
continue;
}
// 第二次以后 如果距离更近则更新最近距离 以及 最近球机信息
if (nearestDistance > temp) {
msCameraSetting = cameraSetting;
nearestDistance = temp;
heightDiff = tempHeightDiff;
}
}
}
//判断两点的距离是否超过有效距离,超过则丢掉
if (nearestDistance > Integer.parseInt(redisUtil.hget("alarm_settings", "inOutEffectDistance").toString())) {
log.info("超过跟踪的最大距离" + redisUtil.hget("alarm_settings", "inOutEffectDistance").toString());
}
return msCameraSetting;
}
}

2
military/military-module-system/src/main/java/com/zgx/modules/military/entity/MsCameraSetting.java

@ -23,6 +23,8 @@ import lombok.experimental.Accessors;
* @Date: 2021-07-01
* @Version: V1.0
*/
//todo : 少了字段 1.厂家
@Data
@TableName("ms_camera_setting")
@Accessors(chain = true)

3
military/military-module-system/src/main/java/com/zgx/modules/military/service/IMsCameraSettingService.java

@ -142,5 +142,6 @@ public interface IMsCameraSettingService extends IService<MsCameraSetting> {
double lon1,
double lat1,
double lon2,
double lat2);
double lat2,
int style);
}

119
military/military-module-system/src/main/java/com/zgx/modules/military/service/impl/MsCameraSettingServiceImpl.java

@ -173,9 +173,11 @@ public class MsCameraSettingServiceImpl extends ServiceImpl<MsCameraSettingMappe
//计算PTZ值(根据数据库设置的初始值进行进一步计算) -1<P<1 -1<T<1 0<Z<1
PTZVo ptzVo = new PTZVo();
if (style==1){
ptzVo = ptzCal1(yOffsetAngle, zOffsetAngle, focusDis, yAngle, zAngle, factor);//todo : 海康计算方法
//ptzVo = ptzCal1(yOffsetAngle, zOffsetAngle, focusDis, yAngle, zAngle, factor);//todo : 海康计算方法
ptzVo = HKPTZCal(yOffsetAngle, zOffsetAngle, focusDis, yAngle, zAngle, factor);//todo : 海康计算方法
}else if(style==2){
ptzVo = ptzCal2(yOffsetAngle, zOffsetAngle, focusDis, yAngle, zAngle, factor);//todo : 宇视计算方法
//ptzVo = ptzCal2(yOffsetAngle, zOffsetAngle, focusDis, yAngle, zAngle, factor);//todo : 宇视计算方法
ptzVo = YSPTZCal(yOffsetAngle, zOffsetAngle, focusDis, yAngle, zAngle, factor);//todo : 宇视计算方法
}
log.info("【计算后的ptzVo】"+ptzVo.toString());
@ -604,6 +606,8 @@ public class MsCameraSettingServiceImpl extends ServiceImpl<MsCameraSettingMappe
}
// todo : 计算海康PTZ值
/**
* 计算ptz2的值
@ -702,4 +706,115 @@ public class MsCameraSettingServiceImpl extends ServiceImpl<MsCameraSettingMappe
}
/**
* 计算宇视ptz的值
* @param yOffsetAngle 最大仰角
* @param zOffsetAngle 水平初始角
* @param distance 相机与目标距离
* @param yAngle 相机与视野垂直夹角垂直移动角度
* @param zAngle 相机与视野水平夹角水平移动角度
* @param factor 变倍因子
* @return
*/
public PTZVo YSPTZCal(double yOffsetAngle,//最大仰角
double zOffsetAngle,//水平初始角
double distance,
double yAngle,//球机需要转动的垂直角度
double zAngle,
double factor) {
PTZVo ptzVo = new PTZVo();
double zReal = (zAngle + 360 - zOffsetAngle) % 360;
double panValue = 0f;
double tiltValue = 0f;
double commonAngle = 180.00f;
double commonAngle1 = (yOffsetAngle + 90.00f) / 2.00f;
if (zReal < 180) {
if (zReal <= 0) {
panValue = 0f;
} else {
panValue = zReal / commonAngle;
}
} else {
panValue = (zReal - commonAngle) / commonAngle - 1;
}
if (yAngle > commonAngle1) {
if (yAngle > commonAngle1 * 2) { // yAngle < 90 yOffsetAngle <
tiltValue = 1;
} else {
tiltValue = ((yAngle - commonAngle1) / commonAngle1) * (-1);
}
} else {
tiltValue = (yAngle - commonAngle1) / commonAngle1;
}
ptzVo.setPanValue(panValue);
ptzVo.setTileValue(tiltValue);
double zoomValue = factor * distance * 0.01;
if (zoomValue > 1) {
zoomValue = 1;
}
if (zoomValue < factor) {
zoomValue = factor;
}
ptzVo.setZoomValue(zoomValue);
return ptzVo;
}
/**
* 计算海康球机的ptz的值
* @param yOffsetAngle 最大仰角
* @param zOffsetAngle 水平初始角
* @param distance 相机与目标距离
* @param yAngle 相机与视野垂直夹角垂直移动角度
* @param zAngle 相机与视野水平夹角水平移动角度
* @param factor 变倍因子
* @return
*/
public PTZVo HKPTZCal(double yOffsetAngle,//最大仰角
double zOffsetAngle,//水平初始角
double distance,
double yAngle,//球机需要转动的垂直角度
double zAngle,//根据球机经纬度和目标经纬度计算得出水平角
double factor) {
PTZVo ptzVo = new PTZVo();
double zReal = (zAngle + 360 - zOffsetAngle) % 360;
double panValue = 0f;
double tiltValue= 0f;
double commonAngle = 180.00f;
double commonAngle1 = 45.00f;
//P算法
if (zReal < 180) {
if (zReal <= 0) {
panValue = 0f;
} else {
panValue = zReal / commonAngle;//p的取值范围在0-1之间
}
} else {
panValue = (zReal - commonAngle) / commonAngle - 1;
}
//T算法 (yAngle-45)/45 * (-1)
tiltValue=(-1)*(yAngle-commonAngle1)/commonAngle1; //yAngle的取值范围是0-90 一般是 86~89度左右
ptzVo.setPanValue(panValue);
ptzVo.setTileValue(tiltValue);//T值范围修正
// Z算法
double zoomValue = factor * distance * 0.01; //可以通过数据库factor去控制聚焦
if (zoomValue > 1) {
zoomValue = 1;
}
if (zoomValue < factor) {
zoomValue = factor;
}
ptzVo.setZoomValue(zoomValue);
return ptzVo;
}
}

12
military/military-module-system/src/main/java/com/zgx/modules/military/utils/hp/HPDataHandle.java

@ -98,7 +98,7 @@ public class HPDataHandle {
redisUtil.hset("PTZStatus", "ptRunState", param.getIntValue("ptRunState"));
break;
case "ivpReport": //todo : 智能分析上报消息
log.info(tcpClient.getIp() + "======" + new String(data, "UTF-8"));
//log.info(tcpClient.getIp() + "======" + new String(data, "UTF-8"));//todo : 先不打印
JSONArray targets = param.getJSONArray("targets");
for (int i = 0; i < targets.size(); i++) {
//检测到目标为人
@ -137,12 +137,12 @@ public class HPDataHandle {
break;
case "ivpTrackingStatusGet": //todo : 获取目标跟踪状态
//判断当前光电是否正在跟踪,否的话判断是否存在目标ID,有的话让其跟踪
log.info("3.ivpTrackingStatusGet:ackvalue="+param.getInteger("ackvalue").toString());
//log.info("3.ivpTrackingStatusGet:ackvalue="+param.getInteger("ackvalue").toString());
if (param.getInteger("ackvalue") == 100) {
boolean bTracking = param.getBooleanValue("bTracking");
if (bTracking) {
System.out.println("【正在跟踪...】");
log.info("正在跟踪...");
//log.info("正在跟踪...");
//如果正在跟踪,判断当前是否已经丢失了目标
tcpClient.send(
HPDataParser.send(
@ -152,9 +152,9 @@ public class HPDataHandle {
);
} else {
System.out.println("【当前不在跟踪状态】");
log.info("当前不在跟踪状态...");
//log.info("当前不在跟踪状态...");
if (redisUtil.get(tcpClient.getIp() + "_trackTarget") != null) {
System.out.println("跟踪目标ID" + Integer.parseInt(String.valueOf(redisUtil.get(tcpClient.getIp() + "_trackTarget"))));
//System.out.println("跟踪目标ID" + Integer.parseInt(String.valueOf(redisUtil.get(tcpClient.getIp() + "_trackTarget"))));
//跟踪目标
tcpClient.send(
HPDataParser.send(
@ -169,7 +169,7 @@ public class HPDataHandle {
case "ivpGetResult": //todo : 获取智能分析结果
if (param.getInteger("ackvalue") == 100) {
//若目标丢失了,则停止跟踪
System.out.println("【智能分析結果-】" + param.getJSONArray("targets"));
//System.out.println("【智能分析結果-】" + param.getJSONArray("targets"));
if (param.getJSONArray("targets").size() == 0) {
System.out.println("目标已经丢失,停止跟踪");
tcpClient.send(

2
military/military-module-system/src/main/java/com/zgx/modules/military/utils/hp/HPTcpKeepAlive.java

@ -33,7 +33,7 @@ public class HPTcpKeepAlive extends Thread {
try {
for (Map.Entry<String, TcpClient> entity : ThreadManager.getTcpClientMap().entrySet()) {
if (entity.getValue().isConnected()) {
log.info(entity.getKey() + "===发送心跳");
//log.info(entity.getKey() + "===发送心跳");
if (entity.getKey().equals(String.valueOf(redisUtil.hget("dataRecordServer", "ip")))) {
data = AlarmInfoConvert.getStateInformationData(
Integer.valueOf(redisUtil.hget("dataRecordServer", "deviceNum").toString()),

3
military/military-module-system/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst

@ -262,7 +262,6 @@ com\zgx\modules\system\service\ISysDepartRolePermissionService.class
com\zgx\modules\military\controller\MsAisInfoController.class
com\zgx\modules\system\service\ISysCheckRuleService.class
com\zgx\modules\system\service\ISysDictItemService.class
com\zgx\MilitaryZMQApplication$3.class
com\zgx\modules\system\util\SecurityUtil.class
com\zgx\modules\system\model\DepartIdModel.class
com\zgx\modules\quartz\service\IQuartzJobService.class
@ -340,6 +339,7 @@ com\zgx\modules\system\service\impl\SysDataSourceServiceImpl.class
com\zgx\modules\system\service\impl\SysPermissionServiceImpl.class
com\zgx\modules\military\controller\MsDeviceInfoController$1.class
com\zgx\modules\military\controller\MsFencesInfoController.class
com\zgx\modules\military\entity\RadarTrackModel.class
com\zgx\modules\system\service\ISysUserAgentService.class
com\zgx\modules\military\mapper\MsModelPositionMapper.class
com\zgx\modules\system\util\PermissionDataUtil.class
@ -364,7 +364,6 @@ com\zgx\modules\military\constant\enums\AlarmType2.class
com\zgx\modules\api\controller\SystemAPIController.class
com\zgx\modules\message\entity\SysMessage.class
com\zgx\modules\system\service\ISysUserService.class
com\zgx\MilitaryZMQApplication$4.class
com\zgx\modules\military\service\impl\MsDeviceInfoVOServiceImpl.class
com\zgx\modules\military\mapper\MsDutyUserMapper.class
com\zgx\modules\military\entity\MsDutyUserBak.class

1
military/military-module-system/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

@ -107,6 +107,7 @@ C:\Users\15819\Desktop\military\military\military-module-system\src\main\java\co
C:\Users\15819\Desktop\military\military\military-module-system\src\main\java\com\zgx\modules\military\service\IMsCameraSiteService.java
C:\Users\15819\Desktop\military\military\military-module-system\src\main\java\com\zgx\modules\system\mapper\SysDepartRoleMapper.java
C:\Users\15819\Desktop\military\military\military-module-system\src\main\java\com\zgx\modules\system\vo\thirdapp\SyncInfoVo.java
C:\Users\15819\Desktop\military\military\military-module-system\src\main\java\com\zgx\modules\military\entity\RadarTrackModel.java
C:\Users\15819\Desktop\military\military\military-module-system\src\main\java\com\zgx\modules\system\util\TenantContext.java
C:\Users\15819\Desktop\military\military\military-module-system\src\main\java\com\zgx\modules\military\utils\hp\HPReqParamEnc.java
C:\Users\15819\Desktop\military\military\military-module-system\src\main\java\com\zgx\modules\monitor\controller\ActuatorRedisController.java

BIN
military/military-module-system/target/military-module-system-2.4.5.jar

Binary file not shown.

BIN
military/military-module-system/target/military-module-system-2.4.5.jar.original

Binary file not shown.
Loading…
Cancel
Save