修改火点入库接口

This commit is contained in:
liuchengqian 2022-05-07 15:20:28 +08:00
parent 2aa8b7ca4c
commit e357bc9b2e
5 changed files with 639 additions and 612 deletions

View File

@ -105,31 +105,15 @@ public class FirePointEntity implements Serializable {
*/
private String afterFireImage;
/**
* 街道编码
*/
@Column(length = 65, columnDefinition = "varchar(65)")
private String streetCode;
public FirePointEntity() {
}
public FirePointEntity(Integer id, String fireCode, double longitude, double latitude, String countyCode, String countyName, String satelliteTime, String satelliteType, String landType, String addTime, String confidence, String firePointAddress, String fireType, String fireImage, String satelliteImage, String beforeFireImage, String afterFireImage) {
this.id = id;
this.fireCode = fireCode;
this.longitude = longitude;
this.latitude = latitude;
this.countyCode = countyCode;
this.countyName = countyName;
this.satelliteTime = satelliteTime;
this.satelliteType = satelliteType;
this.landType = landType;
this.addTime = addTime;
this.confidence = confidence;
this.firePointAddress = firePointAddress;
this.fireType = fireType;
this.fireImage = fireImage;
this.satelliteImage = satelliteImage;
this.beforeFireImage = beforeFireImage;
this.afterFireImage = afterFireImage;
}
public Integer getId() {
return id;
}
@ -266,6 +250,14 @@ public class FirePointEntity implements Serializable {
this.afterFireImage = afterFireImage;
}
public String getStreetCode() {
return streetCode;
}
public void setStreetCode(String streetCode) {
this.streetCode = streetCode;
}
@Override
public String toString() {
return "FirePointEntity{" +
@ -286,6 +278,7 @@ public class FirePointEntity implements Serializable {
", satelliteImage='" + satelliteImage + '\'' +
", beforeFireImage='" + beforeFireImage + '\'' +
", afterFireImage='" + afterFireImage + '\'' +
", streetCode='" + streetCode + '\'' +
'}';
}
}

View File

@ -48,9 +48,8 @@ public class GaoDeIgGeocodeVo {
public void setRegeocodes(List<Regeocode> regeocodes) {
this.regeocodes = regeocodes;
}
}
class Regeocode {
public static class Regeocode {
private String formatted_address;
private List<AddressComponent> addressComponent;
private List<Poi> pois;
@ -111,7 +110,7 @@ class Regeocode {
}
}
class AddressComponent {
public static class AddressComponent {
private String country;
private String province;
private String city;
@ -234,7 +233,7 @@ class AddressComponent {
}
}
class Neighborhood {
public static class Neighborhood {
private String name;
private String type;
@ -258,7 +257,7 @@ class Neighborhood {
}
}
class Building {
public static class Building {
private String name;
private String type;
@ -282,7 +281,7 @@ class Building {
}
}
class StreetNumber {
public static class StreetNumber {
private String street;
private String number;
private String location;
@ -333,7 +332,7 @@ class StreetNumber {
}
}
class BusinessArea {
public static class BusinessArea {
private String businessArea;
private String location;
private String name;
@ -375,7 +374,7 @@ class BusinessArea {
}
}
class Road {
public static class Road {
private String id;
private String name;
private String distance;
@ -426,7 +425,7 @@ class Road {
}
}
class Roadinter {
public static class Roadinter {
private String distance;
private String direction;
private String location;
@ -495,7 +494,7 @@ class Roadinter {
}
}
class Poi {
public static class Poi {
private String id;
private String name;
private String type;
@ -582,7 +581,7 @@ class Poi {
}
}
class Aoi {
public static class Aoi {
private String id;
private String name;
private String adcode;
@ -641,3 +640,6 @@ class Aoi {
this.distance = distance;
}
}
}

View File

@ -1,6 +1,5 @@
package com.xkrs.service;
import com.xkrs.dao.FirePointDao;
import com.xkrs.model.entity.FirePoint;
import com.xkrs.model.entity.FirePointEntity;
import com.xkrs.model.qo.FirePointQo;
@ -18,6 +17,7 @@ public interface FirePointService {
/**
* 添加火点信息
*
* @param firePointQo
* @return
*/
@ -25,6 +25,7 @@ public interface FirePointService {
/**
* 查询今天的火点信息
*
* @param
* @return
*/
@ -32,6 +33,7 @@ public interface FirePointService {
/**
* 动态多条件查询火点信息()
*
* @param proCode
* @param cityCode
* @param satelliteType
@ -45,6 +47,7 @@ public interface FirePointService {
/**
* 动态多条件查询火点信息()
*
* @param cityCodeOne 市编码
* @param cityCode 县编码
* @param satelliteType
@ -57,6 +60,7 @@ public interface FirePointService {
/**
* 动态多条件查询火点信息()
*
* @param cityCode 县编码
* @param satelliteType
* @param landType
@ -68,6 +72,7 @@ public interface FirePointService {
/**
* 根据火点编码修改火点的状态预警
*
* @param fireCode
* @param fireType
* @param token
@ -77,6 +82,7 @@ public interface FirePointService {
/**
* 提交核查任务信息
*
* @param files
* @param appTaskBodyVo
* @return
@ -86,6 +92,7 @@ public interface FirePointService {
/**
* 根据火点编码查询任务信息
*
* @param fireCode
* @param
* @return
@ -95,36 +102,42 @@ public interface FirePointService {
/**
* 查询近一周天的火点信息
*
* @return
*/
List<FirePointEntity> selectFirePointBetweenSeven();
/**
* 查询近一个月的火点信息
*
* @return
*/
List<FirePointEntity> selectFirePointByMonth(String countyCode);
/**
* 查询近一个月的火点数量
*
* @return
*/
String selectFirePointNumMonth();
/**
* 查询近一天的火点数量
*
* @return
*/
String selectFirePointNumDay();
/**
* 查询
*
* @return
*/
String selectFirePointNumWeek();
/**
* 查询该省所有的市
*
* @param code
* @return
*/
@ -132,6 +145,7 @@ public interface FirePointService {
/**
* 查询市包含的区县和编码
*
* @param code
* @return
*/
@ -139,6 +153,7 @@ public interface FirePointService {
/**
* 测试插入火点信息
*
* @param firePointQo
* @return
*/
@ -146,6 +161,7 @@ public interface FirePointService {
/**
* 导入全国省市区
*
* @param file
* @throws Exception
*/
@ -153,6 +169,7 @@ public interface FirePointService {
/**
* 查询今日火点信息测试
*
* @param countyCode
* @return
*/

View File

@ -7,6 +7,7 @@ import com.xkrs.model.entity.*;
import com.xkrs.model.qo.FirePointQo;
import com.xkrs.model.vo.AppPhotoVo;
import com.xkrs.model.vo.AppTaskBodyVo;
import com.xkrs.model.vo.GaoDeIgGeocodeVo;
import com.xkrs.service.FirePointService;
import com.xkrs.utils.*;
import org.slf4j.Logger;
@ -105,6 +106,12 @@ public class FirePointServiceImpl implements FirePointService {
firePointEntity.setFireType("0");
firePointEntity.setFireImage(firePointQo.getFireImage());
firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage());
try {
bindStreetCode(firePointEntity);
} catch (Exception e) {
e.printStackTrace();
System.out.println("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
}
log.info("-------发现新火点");
/*log.info("---------------开始进行实时通讯,将检测到的火点传给前端");
Map map = new HashMap(3);
@ -126,6 +133,17 @@ public class FirePointServiceImpl implements FirePointService {
}
}
private void bindStreetCode(FirePointEntity firePointEntity) throws Exception {
List<String> locationList = new ArrayList<>();
locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude());
GaoDeIgGeocodeVo geocode = GaoDeApiUtil.geocode(locationList);
String townCode = geocode.getRegeocodes().get(0).getAddressComponent().get(0).getTowncode();
if (townCode.length() > 9) {
townCode = townCode.substring(0, 9);
}
firePointEntity.setStreetCode(townCode);
}
/**
* 查询今天的火点信息
*

View File

@ -1,18 +1,14 @@
package com.xkrs.utils;
import com.alibaba.fastjson.JSON;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.controller.GaodeApiController;
import com.xkrs.model.vo.GaoDeIgGeocodeVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.List;
import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject;
import static com.xkrs.utils.CommonConstant.INVERSEGEOGRAPHY_KEY;
import static com.xkrs.utils.CommonConstant.INVERSEGEOGRAPHY_URL;
import static com.xkrs.utils.HttpClientUtils.sendHttpsGet;
@ -27,18 +23,19 @@ public class GaoDeApiUtil {
/**
* 逆地理编码
*
* @param location 示例["116,23", "117,24"]
* @return
*/
public GaoDeIgGeocodeVo geocode(List<String> location) {
public static GaoDeIgGeocodeVo geocode(List<String> location) {
if (location.size() == 0) {
return new GaoDeIgGeocodeVo() {{
setInfo("参数为空");
setInfocode("-1");}};
setInfocode("-1");
}};
}
StringBuilder sb = new StringBuilder();
for (String var :
location) {
for (String var : location) {
sb.append(var).append("|");
}
String url = INVERSEGEOGRAPHY_URL + "?key=" + INVERSEGEOGRAPHY_KEY + "&radius=1000&extensions=all&batch=true&roadlevel=0&location=";