修改火点入库接口

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 + '\'' +
'}'; '}';
} }
} }

File diff suppressed because it is too large Load Diff

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,43 +42,47 @@ 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 cityCode 县编码 * @param cityCodeOne 市编码
* @param cityCode 县编码
* @param satelliteType * @param satelliteType
* @param landType * @param landType
* @param startTime * @param startTime
* @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
* @param startTime * @param startTime
* @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");
}}; }};