Commit 3b3b19e1 authored by chenzhao's avatar chenzhao

车辆坐标反馈需求

parent 44484a21
package com.yeejoin.amos.boot.module.command.api.entity;
public class Gps {
private double wgLat; // 纬度
private double wgLon; // 经度
public Gps(){
}
public Gps(double wgLat, double wgLon) {
setWgLat(wgLat);
setWgLon(wgLon);
}
public double getWgLat() {
return wgLat;
}
public void setWgLat(double wgLat) {
this.wgLat = wgLat;
}
public double getWgLon() {
return wgLon;
}
public void setWgLon(double wgLon) {
this.wgLon = wgLon;
}
@Override
public String toString() {
return wgLat + "," + wgLon;
}
}
\ No newline at end of file
...@@ -30,4 +30,7 @@ public class ESCar { ...@@ -30,4 +30,7 @@ public class ESCar {
@Field(type = FieldType.Long) @Field(type = FieldType.Long)
private Long Time; private Long Time;
@Field(type = FieldType.Text)
private String carNum;
} }
...@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.jcs.api.service; ...@@ -2,6 +2,8 @@ package com.yeejoin.amos.boot.module.jcs.api.service;
import com.yeejoin.amos.boot.module.jcs.api.entity.ESCar; import com.yeejoin.amos.boot.module.jcs.api.entity.ESCar;
import java.util.List;
/** /**
* @description: * @description:
* @author: tw * @author: tw
...@@ -10,4 +12,5 @@ import com.yeejoin.amos.boot.module.jcs.api.entity.ESCar; ...@@ -10,4 +12,5 @@ import com.yeejoin.amos.boot.module.jcs.api.entity.ESCar;
public interface IESCarService { public interface IESCarService {
public ESCar saveESCar(ESCar Car) throws Exception; public ESCar saveESCar(ESCar Car) throws Exception;
public Iterable<ESCar> findAllById(List<Long> ids) throws Exception;
} }
...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -9,6 +9,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.sun.xml.bind.v2.TODO;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.biz.common.dto.PermissionModelDto; import com.yeejoin.amos.boot.biz.common.dto.PermissionModelDto;
...@@ -18,7 +19,9 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils; ...@@ -18,7 +19,9 @@ import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.WordConverterUtils; import com.yeejoin.amos.boot.biz.common.utils.WordConverterUtils;
import com.yeejoin.amos.boot.module.command.api.dto.CarTaskDto; import com.yeejoin.amos.boot.module.command.api.dto.CarTaskDto;
import com.yeejoin.amos.boot.module.command.api.dto.SeismometeorologyDto; import com.yeejoin.amos.boot.module.command.api.dto.SeismometeorologyDto;
import com.yeejoin.amos.boot.module.command.api.entity.Gps;
import com.yeejoin.amos.boot.module.command.biz.service.impl.RemoteSecurityService; import com.yeejoin.amos.boot.module.command.biz.service.impl.RemoteSecurityService;
import com.yeejoin.amos.boot.module.command.biz.utils.PositionUtil;
import com.yeejoin.amos.boot.module.common.api.dto.*; import com.yeejoin.amos.boot.module.common.api.dto.*;
import com.yeejoin.amos.boot.module.common.api.entity.FireTeam; import com.yeejoin.amos.boot.module.common.api.entity.FireTeam;
import com.yeejoin.amos.boot.module.common.api.entity.Firefighters; import com.yeejoin.amos.boot.module.common.api.entity.Firefighters;
...@@ -36,11 +39,13 @@ import com.yeejoin.amos.boot.module.jcs.api.mapper.AirportStandMapper; ...@@ -36,11 +39,13 @@ import com.yeejoin.amos.boot.module.jcs.api.mapper.AirportStandMapper;
import com.yeejoin.amos.boot.module.jcs.api.mapper.PowerTransferCompanyResourcesMapper; import com.yeejoin.amos.boot.module.jcs.api.mapper.PowerTransferCompanyResourcesMapper;
import com.yeejoin.amos.boot.module.jcs.api.mapper.PowerTransferMapper; import com.yeejoin.amos.boot.module.jcs.api.mapper.PowerTransferMapper;
import com.yeejoin.amos.boot.module.jcs.api.service.*; import com.yeejoin.amos.boot.module.jcs.api.service.*;
import com.yeejoin.amos.component.rule.config.RuleConfig;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.systemctl.Systemctl; import com.yeejoin.amos.feign.systemctl.Systemctl;
import com.yeejoin.amos.feign.systemctl.model.MessageModel; import com.yeejoin.amos.feign.systemctl.model.MessageModel;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
...@@ -48,6 +53,7 @@ import org.springframework.util.ObjectUtils; ...@@ -48,6 +53,7 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.exception.BaseException; import org.typroject.tyboot.core.foundation.exception.BaseException;
...@@ -64,6 +70,7 @@ import java.io.File; ...@@ -64,6 +70,7 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
* *指挥资源Api * *指挥资源Api
...@@ -162,12 +169,17 @@ public class CommandController extends BaseController { ...@@ -162,12 +169,17 @@ public class CommandController extends BaseController {
IESCarService esCarService; IESCarService esCarService;
@Autowired @Autowired
private EmqKeeper emqKeeper;
@Autowired
AirportStandMapper airportStandMapper; AirportStandMapper airportStandMapper;
private static final String JW = "mechinePosition"; private static final String JW = "mechinePosition";
private static final String KEYSITE = "keySiteExcle"; private static final String KEYSITE = "keySiteExcle";
private OrgUsrMapper orgUsrMapper; private OrgUsrMapper orgUsrMapper;
@Value("${mqtt.topic.command.car.jw}")
private String topic;
/** /**
* 警情列表 * 警情列表
...@@ -1193,10 +1205,6 @@ public class CommandController extends BaseController { ...@@ -1193,10 +1205,6 @@ public class CommandController extends BaseController {
queryWrapper.eq("status", FireCarStatusEnum.执行中.getCode()); queryWrapper.eq("status", FireCarStatusEnum.执行中.getCode());
List<PowerTransferCompanyResources> alertFormValue = powerTransferCompanyResourcesMapper.selectList(queryWrapper); List<PowerTransferCompanyResources> alertFormValue = powerTransferCompanyResourcesMapper.selectList(queryWrapper);
result.stream().forEach(e -> { result.stream().forEach(e -> {
e.put("latitude", 34.43760404432992);
e.put("longitude", 108.7585304877751);
if (e.get("carState").equals("在位")) { if (e.get("carState").equals("在位")) {
e.put("carState", FireCarStatusEnum.执勤.getName()); e.put("carState", FireCarStatusEnum.执勤.getName());
} }
...@@ -1732,15 +1740,38 @@ public class CommandController extends BaseController { ...@@ -1732,15 +1740,38 @@ public class CommandController extends BaseController {
Date date= new Date(); Date date= new Date();
esCar.setTime(date.getTime()); esCar.setTime(date.getTime());
esCarService.saveESCar(esCar); esCarService.saveESCar(esCar);
//给App端发送
// TODO
//给WEB端发送 前端传递的为高德经纬度 需转换为WGS84
Gps gps = PositionUtil.gcj02_To_Gps84(Double.valueOf(esCar.getLatitude()), Double.valueOf(esCar.getLongitude()));
esCar.setLatitude(String.valueOf(gps.getWgLat()));
esCar.setLongitude(String.valueOf(gps.getWgLon()));
emqKeeper.getMqttClient().publish(topic, esCar.toString().getBytes(), RuleConfig.DEFAULT_QOS, false);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return ResponseHelper.buildResponse(true); return ResponseHelper.buildResponse(true);
} }
@TycloudOperation(needAuth = true, ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/getEsCar", produces = "application/json;charset=UTF-8", method = RequestMethod.GET
)
@ApiOperation(httpMethod = "get", value = "手机上报", notes = "手机上报")
public ResponseModel<Object> getEsCar(Long sequenceNbr) throws Exception {
Iterable<ESCar> allById = esCarService.findAllById(Arrays.asList(sequenceNbr));
List<ESCar> esCars = new ArrayList<>();
allById.forEach(e -> {
ESCar esCar = new ESCar();
BeanUtils.copyProperties(e,esCar);
esCars.add(esCar);
});
ESCar esCar = esCars.stream().sorted(Comparator.comparing(ESCar::getTime).reversed()).collect(Collectors.toList()).get(0);
return ResponseHelper.buildResponse(esCar);
}
} }
\ No newline at end of file
package com.yeejoin.amos.boot.module.command.biz.utils;
import com.yeejoin.amos.boot.module.command.api.entity.Gps;
public class PositionUtil {
private static double pi = 3.1415926535897932384626;
private static double a = 6378245.0;
private static double ee = 0.00669342162296594323;
/**
* 84 to 火星坐标系 (GCJ-02)
*
* World Geodetic System ==> Mars Geodetic System
*
* @param lat
* @param lon
* @return
*/
public static Gps gps84_To_Gcj02(double lat, double lon) {
if (outOfChina(lat, lon)) {
return null;
}
double dLat = transformLat(lon - 105.0, lat - 35.0);
double dLon = transformLon(lon - 105.0, lat - 35.0);
double radLat = lat / 180.0 * pi;
double magic = Math.sin(radLat);
magic = 1 - ee * magic * magic;
double sqrtMagic = Math.sqrt(magic);
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
double mgLat = lat + dLat;
double mgLon = lon + dLon;
return new Gps(mgLat, mgLon);
}
/**
* 火星坐标系 (GCJ-02) to 84
*
* @param lon
* @param lat
* @return
*/
public static Gps gcj02_To_Gps84(double lat, double lon) {
Gps gps = transform(lat, lon);
double lontitude = lon * 2 - gps.getWgLon();
double latitude = lat * 2 - gps.getWgLat();
return new Gps(latitude, lontitude);
}
/**
* 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法
*
* 将 GCJ-02 坐标转换成 BD-09 坐标
*
* @param gg_lat
* @param gg_lon
*/
public static Gps gcj02_To_Bd09(double gg_lat, double gg_lon) {
double x = gg_lon, y = gg_lat;
double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);
double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);
double bd_lon = z * Math.cos(theta) + 0.0065;
double bd_lat = z * Math.sin(theta) + 0.006;
return new Gps(bd_lat, bd_lon);
}
/**
* 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法
*
* 将 BD-09 坐标转换成GCJ-02 坐标
*
* @param bd_lat
* @param bd_lon
* @return
*/
public static Gps bd09_To_Gcj02(double bd_lat, double bd_lon) {
double x = bd_lon - 0.0065, y = bd_lat - 0.006;
double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi);
double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi);
double gg_lon = z * Math.cos(theta);
double gg_lat = z * Math.sin(theta);
return new Gps(gg_lat, gg_lon);
}
private static boolean outOfChina(double lat, double lon) {
if (lon < 72.004 || lon > 137.8347)
return true;
if (lat < 0.8293 || lat > 55.8271)
return true;
return false;
}
private static Gps transform(double lat, double lon) {
if (outOfChina(lat, lon)) {
return new Gps(lat, lon);
}
double dLat = transformLat(lon - 105.0, lat - 35.0);
double dLon = transformLon(lon - 105.0, lat - 35.0);
double radLat = lat / 180.0 * pi;
double magic = Math.sin(radLat);
magic = 1 - ee * magic * magic;
double sqrtMagic = Math.sqrt(magic);
dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
double mgLat = lat + dLat;
double mgLon = lon + dLon;
return new Gps(mgLat, mgLon);
}
private static double transformLat(double x, double y) {
double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y
+ 0.2 * Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
return ret;
}
private static double transformLon(double x, double y) {
double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1
* Math.sqrt(Math.abs(x));
ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0
* pi)) * 2.0 / 3.0;
return ret;
}
}
\ No newline at end of file
...@@ -957,7 +957,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i ...@@ -957,7 +957,7 @@ public class BuildingServiceImpl extends ServiceImpl<BuildingMapper, Building> i
} }
} }
x.setVedioFormat(vedioFormat); x.setVedioFormat(vedioFormat);
// x.setUrl(videoService.getVideoUrl(x.getName(), x.getPresetPosition(), x.getUrl(), x.getCode())); x.setUrl(videoService.getVideoUrl(x.getName(), x.getPresetPosition(), x.getUrl(), x.getCode()));
}); });
return pages; return pages;
} }
......
...@@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate; import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* @description: * @description:
* @author: tw * @author: tw
...@@ -29,4 +31,11 @@ public class ESCarService implements IESCarService { ...@@ -29,4 +31,11 @@ public class ESCarService implements IESCarService {
esCarRepository.save(Car); esCarRepository.save(Car);
return Car; return Car;
} }
@Override
public Iterable<ESCar> findAllById(List<Long> ids) throws Exception {
return esCarRepository.findAllById(ids);
}
} }
...@@ -347,6 +347,7 @@ ...@@ -347,6 +347,7 @@
wl_equipment_specific_alarm_log wlesal wl_equipment_specific_alarm_log wlesal
LEFT JOIN wl_equipment we ON wlesal.equipment_code = we.code LEFT JOIN wl_equipment we ON wlesal.equipment_code = we.code
LEFT JOIN wl_equipment_specific_alarm wlesa ON wlesa.id = wlesal.equipment_specific_alarm_id LEFT JOIN wl_equipment_specific_alarm wlesa ON wlesa.id = wlesal.equipment_specific_alarm_id
LEFT JOIN wl_equipment_specific wls ON wls.id = wlesal.equipment_specific_id
<where> <where>
<if test="param.bizOrgCode != null and param.bizOrgCode != ''">AND <if test="param.bizOrgCode != null and param.bizOrgCode != ''">AND
wls.biz_org_code like concat (#{param.bizOrgCode},'%') wls.biz_org_code like concat (#{param.bizOrgCode},'%')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment