修改火点入库接口

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

@ -7,7 +7,7 @@ import java.io.Serializable;
* @author XinYi Song * @author XinYi Song
*/ */
@Entity @Entity
@Table(name="fire_point") @Table(name = "fire_point")
public class FirePointEntity implements Serializable { public class FirePointEntity implements Serializable {
/** /**
@ -15,13 +15,13 @@ public class FirePointEntity implements Serializable {
*/ */
@Id @Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_point_seq_gen") @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_point_seq_gen")
@SequenceGenerator(name = "fire_point_seq_gen", sequenceName = "fire_point_id_seq",allocationSize = 1) @SequenceGenerator(name = "fire_point_seq_gen", sequenceName = "fire_point_id_seq", allocationSize = 1)
private Integer id; private Integer id;
/** /**
* 火点编码 * 火点编码
*/ */
@Column( length = 32,unique = true,columnDefinition = "varchar(32)") @Column(length = 32, unique = true, columnDefinition = "varchar(32)")
private String fireCode; private String fireCode;
/** /**
@ -43,7 +43,7 @@ public class FirePointEntity implements Serializable {
/** /**
* 省市区的名称 * 省市区的名称
*/ */
@Column( columnDefinition = "varchar(64)") @Column(columnDefinition = "varchar(64)")
private String countyName; private String countyName;
/** /**
@ -54,13 +54,13 @@ public class FirePointEntity implements Serializable {
/** /**
* 卫星的类型 * 卫星的类型
*/ */
@Column( columnDefinition = "varchar(64)") @Column(columnDefinition = "varchar(64)")
private String satelliteType; private String satelliteType;
/** /**
* 植被类型 * 植被类型
*/ */
@Column( columnDefinition = "varchar(64)") @Column(columnDefinition = "varchar(64)")
private String landType; private String landType;
/** /**
@ -105,31 +105,15 @@ public class FirePointEntity implements Serializable {
*/ */
private String afterFireImage; private String afterFireImage;
/**
* 街道编码
*/
@Column(length = 65, columnDefinition = "varchar(65)")
private String streetCode;
public FirePointEntity() { 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() { public Integer getId() {
return id; return id;
} }
@ -266,6 +250,14 @@ public class FirePointEntity implements Serializable {
this.afterFireImage = afterFireImage; this.afterFireImage = afterFireImage;
} }
public String getStreetCode() {
return streetCode;
}
public void setStreetCode(String streetCode) {
this.streetCode = streetCode;
}
@Override @Override
public String toString() { public String toString() {
return "FirePointEntity{" + return "FirePointEntity{" +
@ -286,6 +278,7 @@ public class FirePointEntity implements Serializable {
", satelliteImage='" + satelliteImage + '\'' + ", satelliteImage='" + satelliteImage + '\'' +
", beforeFireImage='" + beforeFireImage + '\'' + ", beforeFireImage='" + beforeFireImage + '\'' +
", afterFireImage='" + afterFireImage + '\'' + ", afterFireImage='" + afterFireImage + '\'' +
", streetCode='" + streetCode + '\'' +
'}'; '}';
} }
} }

View File

@ -48,9 +48,8 @@ public class GaoDeIgGeocodeVo {
public void setRegeocodes(List<Regeocode> regeocodes) { public void setRegeocodes(List<Regeocode> regeocodes) {
this.regeocodes = regeocodes; this.regeocodes = regeocodes;
} }
}
class Regeocode { public static class Regeocode {
private String formatted_address; private String formatted_address;
private List<AddressComponent> addressComponent; private List<AddressComponent> addressComponent;
private List<Poi> pois; private List<Poi> pois;
@ -109,9 +108,9 @@ class Regeocode {
public void setAois(List<Aoi> aois) { public void setAois(List<Aoi> aois) {
this.aois = aois; this.aois = aois;
} }
} }
class AddressComponent { public static class AddressComponent {
private String country; private String country;
private String province; private String province;
private String city; private String city;
@ -232,9 +231,9 @@ class AddressComponent {
public void setBusinessAreas(List<BusinessArea> businessAreas) { public void setBusinessAreas(List<BusinessArea> businessAreas) {
this.businessAreas = businessAreas; this.businessAreas = businessAreas;
} }
} }
class Neighborhood { public static class Neighborhood {
private String name; private String name;
private String type; private String type;
@ -256,9 +255,9 @@ class Neighborhood {
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
} }
class Building { public static class Building {
private String name; private String name;
private String type; private String type;
@ -280,9 +279,9 @@ class Building {
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
} }
class StreetNumber { public static class StreetNumber {
private String street; private String street;
private String number; private String number;
private String location; private String location;
@ -331,9 +330,9 @@ class StreetNumber {
public void setDistance(String distance) { public void setDistance(String distance) {
this.distance = distance; this.distance = distance;
} }
} }
class BusinessArea { public static class BusinessArea {
private String businessArea; private String businessArea;
private String location; private String location;
private String name; private String name;
@ -373,9 +372,9 @@ class BusinessArea {
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
} }
class Road { public static class Road {
private String id; private String id;
private String name; private String name;
private String distance; private String distance;
@ -424,9 +423,9 @@ class Road {
public void setLocation(String location) { public void setLocation(String location) {
this.location = location; this.location = location;
} }
} }
class Roadinter { public static class Roadinter {
private String distance; private String distance;
private String direction; private String direction;
private String location; private String location;
@ -493,9 +492,9 @@ class Roadinter {
public void setSecond_name(String second_name) { public void setSecond_name(String second_name) {
this.second_name = second_name; this.second_name = second_name;
} }
} }
class Poi { public static class Poi {
private String id; private String id;
private String name; private String name;
private String type; private String type;
@ -580,9 +579,9 @@ class Poi {
public void setBusinessarea(String businessarea) { public void setBusinessarea(String businessarea) {
this.businessarea = businessarea; this.businessarea = businessarea;
} }
} }
class Aoi { public static class Aoi {
private String id; private String id;
private String name; private String name;
private String adcode; private String adcode;
@ -640,4 +639,7 @@ class Aoi {
public void setDistance(String distance) { public void setDistance(String distance) {
this.distance = distance; this.distance = distance;
} }
}
} }

View File

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

View File

@ -7,6 +7,7 @@ import com.xkrs.model.entity.*;
import com.xkrs.model.qo.FirePointQo; import com.xkrs.model.qo.FirePointQo;
import com.xkrs.model.vo.AppPhotoVo; import com.xkrs.model.vo.AppPhotoVo;
import com.xkrs.model.vo.AppTaskBodyVo; import com.xkrs.model.vo.AppTaskBodyVo;
import com.xkrs.model.vo.GaoDeIgGeocodeVo;
import com.xkrs.service.FirePointService; import com.xkrs.service.FirePointService;
import com.xkrs.utils.*; import com.xkrs.utils.*;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -105,6 +106,12 @@ public class FirePointServiceImpl implements FirePointService {
firePointEntity.setFireType("0"); firePointEntity.setFireType("0");
firePointEntity.setFireImage(firePointQo.getFireImage()); firePointEntity.setFireImage(firePointQo.getFireImage());
firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage()); firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage());
try {
bindStreetCode(firePointEntity);
} catch (Exception e) {
e.printStackTrace();
System.out.println("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
}
log.info("-------发现新火点"); log.info("-------发现新火点");
/*log.info("---------------开始进行实时通讯,将检测到的火点传给前端"); /*log.info("---------------开始进行实时通讯,将检测到的火点传给前端");
Map map = new HashMap(3); 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; package com.xkrs.utils;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.xkrs.common.encapsulation.PromptMessageEnum;
import com.xkrs.controller.GaodeApiController;
import com.xkrs.model.vo.GaoDeIgGeocodeVo; import com.xkrs.model.vo.GaoDeIgGeocodeVo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List; 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_KEY;
import static com.xkrs.utils.CommonConstant.INVERSEGEOGRAPHY_URL; import static com.xkrs.utils.CommonConstant.INVERSEGEOGRAPHY_URL;
import static com.xkrs.utils.HttpClientUtils.sendHttpsGet; import static com.xkrs.utils.HttpClientUtils.sendHttpsGet;
@ -27,18 +23,19 @@ public class GaoDeApiUtil {
/** /**
* 逆地理编码 * 逆地理编码
*
* @param location 示例["116,23", "117,24"] * @param location 示例["116,23", "117,24"]
* @return * @return
*/ */
public GaoDeIgGeocodeVo geocode(List<String> location) { public static GaoDeIgGeocodeVo geocode(List<String> location) {
if (location.size() == 0) { if (location.size() == 0) {
return new GaoDeIgGeocodeVo(){{ return new GaoDeIgGeocodeVo() {{
setInfo("参数为空"); setInfo("参数为空");
setInfocode("-1");}}; setInfocode("-1");
}};
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String var : for (String var : location) {
location) {
sb.append(var).append("|"); sb.append(var).append("|");
} }
String url = INVERSEGEOGRAPHY_URL + "?key=" + INVERSEGEOGRAPHY_KEY + "&radius=1000&extensions=all&batch=true&roadlevel=0&location="; String url = INVERSEGEOGRAPHY_URL + "?key=" + INVERSEGEOGRAPHY_KEY + "&radius=1000&extensions=all&batch=true&roadlevel=0&location=";
@ -49,7 +46,7 @@ public class GaoDeApiUtil {
} catch (Exception e) { } catch (Exception e) {
log.error("获取高德天气失败, {}", e.getMessage()); log.error("获取高德天气失败, {}", e.getMessage());
} }
return new GaoDeIgGeocodeVo(){{ return new GaoDeIgGeocodeVo() {{
setInfo("获取高德天气失败"); setInfo("获取高德天气失败");
setInfocode("-1"); setInfocode("-1");
}}; }};