优化双火点渠道入库逻辑
This commit is contained in:
parent
e45fb56358
commit
8b69e5a874
@ -35,6 +35,7 @@ class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
.antMatchers(HttpMethod.OPTIONS).permitAll()
|
.antMatchers(HttpMethod.OPTIONS).permitAll()
|
||||||
.antMatchers("/global/configuration/**").permitAll()
|
.antMatchers("/global/configuration/**").permitAll()
|
||||||
.antMatchers("/push/**").permitAll()
|
.antMatchers("/push/**").permitAll()
|
||||||
|
.antMatchers("/dispatch/**").permitAll()
|
||||||
.antMatchers("/queryFirePoint").permitAll()
|
.antMatchers("/queryFirePoint").permitAll()
|
||||||
.antMatchers(HttpMethod.POST, "/api/user/updateSysUser").permitAll()
|
.antMatchers(HttpMethod.POST, "/api/user/updateSysUser").permitAll()
|
||||||
.antMatchers(HttpMethod.GET, "/selectGlobalConfigDict").permitAll()
|
.antMatchers(HttpMethod.GET, "/selectGlobalConfigDict").permitAll()
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package com.xkrs.sms;
|
package com.xkrs.sms;
|
||||||
|
|
||||||
import com.xkrs.dao.GlobalConfigurationDao;
|
import com.xkrs.dao.GlobalConfigurationDao;
|
||||||
import com.xkrs.model.bean.KeyValueBean;
|
|
||||||
import com.xkrs.model.entity.FirePointEntity;
|
import com.xkrs.model.entity.FirePointEntity;
|
||||||
import com.xkrs.model.entity.GlobalConfigurationEntity;
|
import com.xkrs.model.entity.GlobalConfigurationEntity;
|
||||||
import com.xkrs.model.entity.SysUserEntity;
|
import com.xkrs.model.entity.SysUserEntity;
|
||||||
import com.xkrs.service.GlobalConfigurationService;
|
import com.xkrs.service.GlobalConfigurationService;
|
||||||
|
import com.xkrs.straw.model.bean.KeyValueBean;
|
||||||
import com.xkrs.utils.HttpClientUtils;
|
import com.xkrs.utils.HttpClientUtils;
|
||||||
import org.springframework.data.domain.Sort;
|
import org.springframework.data.domain.Sort;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
@ -6,14 +6,13 @@ import com.xkrs.straw.service.DispatchFirePointService;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.context.i18n.LocaleContextHolder;
|
import org.springframework.context.i18n.LocaleContextHolder;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@RequestMapping(value = "/dispatch")
|
||||||
public class DispatchFirePointController {
|
public class DispatchFirePointController {
|
||||||
|
|
||||||
public static Logger log = LoggerFactory.getLogger(FirePointServiceImpl.class);
|
public static Logger log = LoggerFactory.getLogger(FirePointServiceImpl.class);
|
||||||
@ -23,6 +22,11 @@ public class DispatchFirePointController {
|
|||||||
@Resource
|
@Resource
|
||||||
private DispatchFirePointService firePointService;
|
private DispatchFirePointService firePointService;
|
||||||
|
|
||||||
|
@GetMapping("/debug")
|
||||||
|
public String debug() {
|
||||||
|
return firePointService.debug();
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/insertFirePointChannelOrdinary")
|
@PostMapping("/insertFirePointChannelOrdinary")
|
||||||
public String insertFirePointChannelOrdinary(@RequestBody AllFirePointQo firePointQo) {
|
public String insertFirePointChannelOrdinary(@RequestBody AllFirePointQo firePointQo) {
|
||||||
return firePointService.insertFirePointChannelOrdinary(firePointQo);
|
return firePointService.insertFirePointChannelOrdinary(firePointQo);
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package com.xkrs.straw.dao;
|
||||||
|
|
||||||
|
import com.xkrs.straw.model.entity.FirePointChannelConfigEntity;
|
||||||
|
import org.springframework.data.jpa.repository.JpaRepository;
|
||||||
|
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public interface FirePointChannelConfigDao extends JpaRepository<FirePointChannelConfigEntity, Long>, JpaSpecificationExecutor<FirePointChannelConfigEntity> {
|
||||||
|
}
|
101
src/main/java/com/xkrs/straw/helper/GeoCodeHelper.java
Normal file
101
src/main/java/com/xkrs/straw/helper/GeoCodeHelper.java
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
package com.xkrs.straw.helper;
|
||||||
|
|
||||||
|
import com.xkrs.model.vo.GaoDeIgGeocodeVo;
|
||||||
|
import com.xkrs.straw.service.impl.DispatchFirePointServiceImpl;
|
||||||
|
import com.xkrs.utils.GaoDeApiUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GeoCodeHelper {
|
||||||
|
|
||||||
|
public static Logger log = LoggerFactory.getLogger(DispatchFirePointServiceImpl.class);
|
||||||
|
private GaoDeIgGeocodeVo geocode;
|
||||||
|
|
||||||
|
public void doGeoCode(Double longitude, Double latitude) {
|
||||||
|
try {
|
||||||
|
List<String> locationList = new ArrayList<>();
|
||||||
|
locationList.add(longitude + "," + latitude);
|
||||||
|
this.geocode = GaoDeApiUtil.geocode(locationList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
this.geocode = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCalCountyCode() {
|
||||||
|
try {
|
||||||
|
GaoDeIgGeocodeVo.Regeocode reGeoCode = geocode.getRegeocodes().get(0);
|
||||||
|
GaoDeIgGeocodeVo.AddressComponent addressComponent = reGeoCode.getAddressComponent().get(0);
|
||||||
|
return addressComponent.getAdcode();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCalCountyName() {
|
||||||
|
try {
|
||||||
|
GaoDeIgGeocodeVo.Regeocode reGeoCode = geocode.getRegeocodes().get(0);
|
||||||
|
GaoDeIgGeocodeVo.AddressComponent addressComponent = reGeoCode.getAddressComponent().get(0);
|
||||||
|
return addressComponent.getDistrict();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCalTownCode() {
|
||||||
|
try {
|
||||||
|
GaoDeIgGeocodeVo.Regeocode reGeoCode = geocode.getRegeocodes().get(0);
|
||||||
|
GaoDeIgGeocodeVo.AddressComponent addressComponent = reGeoCode.getAddressComponent().get(0);
|
||||||
|
String townCode = addressComponent.getTowncode();
|
||||||
|
return townCode.length() > 9 ? townCode.substring(0, 9) : townCode;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCalTownName() {
|
||||||
|
try {
|
||||||
|
GaoDeIgGeocodeVo.Regeocode reGeoCode = geocode.getRegeocodes().get(0);
|
||||||
|
GaoDeIgGeocodeVo.AddressComponent addressComponent = reGeoCode.getAddressComponent().get(0);
|
||||||
|
return addressComponent.getTownship();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCalFirePointAddress() {
|
||||||
|
try {
|
||||||
|
GaoDeIgGeocodeVo.Regeocode reGeoCode = geocode.getRegeocodes().get(0);
|
||||||
|
return reGeoCode.getFormatted_address();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean checkGeoCodeResult(String receivedCountyCode, String receivedCountyName, String receivedTownCode) {
|
||||||
|
String calCountyCode = getCalCountyCode();
|
||||||
|
String calCountyName = getCalCountyName();
|
||||||
|
String calTownCode = getCalTownCode();
|
||||||
|
if (!calCountyCode.equals(receivedCountyCode)) {
|
||||||
|
log.info("-------逆地理编码校验失败:接收到的countyCode=" + receivedCountyCode + ",计算得到的countyCode=" + calCountyCode);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!calCountyName.equals(receivedCountyName)) {
|
||||||
|
log.info("-------逆地理编码校验失败:接收到的countyName=" + receivedCountyName + ",计算得到的countyName=" + calCountyName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!calTownCode.equals(receivedTownCode)) {
|
||||||
|
log.info("-------逆地理编码校验失败:接收到的townCode=" + receivedTownCode + ",计算得到的townCode=" + calTownCode);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
package com.xkrs.straw.model.bean;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FirePointChannelConfigBean {
|
||||||
|
|
||||||
|
public static final String Ordinary = "Ordinary";
|
||||||
|
public static final String Precise = "Precise";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道名称
|
||||||
|
*/
|
||||||
|
private String channelName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道配置列表
|
||||||
|
*/
|
||||||
|
private List<ChannelConfig> configList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道配置
|
||||||
|
*/
|
||||||
|
public static class ChannelConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始时间
|
||||||
|
*/
|
||||||
|
private String startTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束时间
|
||||||
|
*/
|
||||||
|
private String endTime;
|
||||||
|
|
||||||
|
public String getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(String startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(String endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChannelName() {
|
||||||
|
return channelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChannelName(String channelName) {
|
||||||
|
this.channelName = channelName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ChannelConfig> getConfigList() {
|
||||||
|
return configList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigList(List<ChannelConfig> configList) {
|
||||||
|
this.configList = configList;
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.xkrs.model.bean;
|
package com.xkrs.straw.model.bean;
|
||||||
|
|
||||||
public class KeyValueBean {
|
public class KeyValueBean {
|
||||||
|
|
@ -0,0 +1,50 @@
|
|||||||
|
package com.xkrs.straw.model.entity;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "fire_point_channel_config")
|
||||||
|
public class FirePointChannelConfigEntity implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 指定主键,建立自增序列,主键值取自序列
|
||||||
|
*/
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_point_ordinary_seq_gen")
|
||||||
|
@SequenceGenerator(name = "fire_point_ordinary_seq_gen", sequenceName = "fire_point_ordinary_id_seq", allocationSize = 1)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Json配置内容
|
||||||
|
*/
|
||||||
|
@Column(length = 1024, columnDefinition = "varchar(1024)")
|
||||||
|
private String jsonContent;
|
||||||
|
|
||||||
|
public FirePointChannelConfigEntity() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Long id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJsonContent() {
|
||||||
|
return jsonContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJsonContent(String jsonContent) {
|
||||||
|
this.jsonContent = jsonContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "FirePointChannelConfigEntity{" +
|
||||||
|
"id=" + id +
|
||||||
|
", jsonContent='" + jsonContent + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -16,90 +16,110 @@ public class FirePointOrdinaryEntity implements Serializable {
|
|||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_point_ordinary_seq_gen")
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_point_ordinary_seq_gen")
|
||||||
@SequenceGenerator(name = "fire_point_ordinary_seq_gen", sequenceName = "fire_point_ordinary_id_seq", allocationSize = 1)
|
@SequenceGenerator(name = "fire_point_ordinary_seq_gen", sequenceName = "fire_point_ordinary_id_seq", allocationSize = 1)
|
||||||
private Integer id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 火点编码
|
* 火点编码
|
||||||
*/
|
*/
|
||||||
@Column(length = 32, unique = true, columnDefinition = "varchar(32)")
|
@Column(length = 32, unique = true, columnDefinition = "varchar(32)")
|
||||||
private String fireCode;
|
private String fireCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 省市区的编码
|
* 省市区的编码
|
||||||
*/
|
*/
|
||||||
@Column(length = 32, columnDefinition = "varchar(32)")
|
@Column(length = 32, columnDefinition = "varchar(32)")
|
||||||
private Long countyCode;
|
private String countyCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 省市区的名称
|
* 省市区的名称
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String countyName;
|
private String countyName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卫星监测的时间
|
* 卫星监测的时间
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String satelliteTime;
|
private String satelliteTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 经度
|
* 经度
|
||||||
*/
|
*/
|
||||||
private Double longitude;
|
private Double longitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 纬度
|
* 纬度
|
||||||
*/
|
*/
|
||||||
private Double latitude;
|
private Double latitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卫星类型
|
* 卫星类型
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String satelliteType;
|
private String satelliteType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 植被类型
|
* 植被类型
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String landType;
|
private String landType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 置信度
|
* 置信度
|
||||||
*/
|
*/
|
||||||
@Column(length = 32, columnDefinition = "varchar(32)")
|
@Column(length = 32, columnDefinition = "varchar(32)")
|
||||||
private String confidence;
|
private String confidence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前火点的图片
|
* 当前火点的图片
|
||||||
*/
|
*/
|
||||||
@Column(length = 512, columnDefinition = "varchar(512)")
|
@Column(length = 512, columnDefinition = "varchar(512)")
|
||||||
private String fireImage;
|
private String fireImage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卫星影像图片
|
* 卫星影像图片
|
||||||
*/
|
*/
|
||||||
@Column(length = 512, columnDefinition = "varchar(512)")
|
@Column(length = 512, columnDefinition = "varchar(512)")
|
||||||
private String satelliteImage;
|
private String satelliteImage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 乡镇街道的编码
|
* 乡镇街道的编码
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String townCode;
|
private String townCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 乡镇街道的名字
|
* 乡镇街道的名字
|
||||||
*/
|
*/
|
||||||
@Column(length = 85, columnDefinition = "varchar(85)")
|
@Column(length = 85, columnDefinition = "varchar(85)")
|
||||||
private String townName;
|
private String townName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加的时间
|
* 添加的时间
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String addTime;
|
private String addTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 详细地址
|
* 详细地址
|
||||||
*/
|
*/
|
||||||
@Column(length = 255, columnDefinition = "varchar(255)")
|
@Column(length = 255, columnDefinition = "varchar(255)")
|
||||||
private String firePointAddress;
|
private String firePointAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@Column(length = 1024, columnDefinition = "varchar(1024)")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
public FirePointOrdinaryEntity() {
|
public FirePointOrdinaryEntity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Integer id) {
|
public void setId(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,11 +131,11 @@ public class FirePointOrdinaryEntity implements Serializable {
|
|||||||
this.fireCode = fireCode;
|
this.fireCode = fireCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getCountyCode() {
|
public String getCountyCode() {
|
||||||
return countyCode;
|
return countyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCountyCode(Long countyCode) {
|
public void setCountyCode(String countyCode) {
|
||||||
this.countyCode = countyCode;
|
this.countyCode = countyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,8 +243,34 @@ public class FirePointOrdinaryEntity implements Serializable {
|
|||||||
this.firePointAddress = firePointAddress;
|
this.firePointAddress = firePointAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FirePointOrdinaryEntity{" + "id=" + id + ", fireCode='" + fireCode + '\'' + ", countyCode=" + countyCode + ", countyName='" + countyName + '\'' + ", satelliteTime='" + satelliteTime + '\'' + ", longitude=" + longitude + ", latitude=" + latitude + ", satelliteType='" + satelliteType + '\'' + ", landType='" + landType + '\'' + ", confidence='" + confidence + '\'' + ", fireImage='" + fireImage + '\'' + ", satelliteImage='" + satelliteImage + '\'' + ", townCode='" + townCode + '\'' + ", townName='" + townName + '\'' + ", addTime='" + addTime + '\'' + ", firePointAddress='" + firePointAddress + '\'' + '}';
|
return "FirePointOrdinaryEntity{" +
|
||||||
|
"id=" + id +
|
||||||
|
", fireCode='" + fireCode + '\'' +
|
||||||
|
", countyCode='" + countyCode + '\'' +
|
||||||
|
", countyName='" + countyName + '\'' +
|
||||||
|
", satelliteTime='" + satelliteTime + '\'' +
|
||||||
|
", longitude=" + longitude +
|
||||||
|
", latitude=" + latitude +
|
||||||
|
", satelliteType='" + satelliteType + '\'' +
|
||||||
|
", landType='" + landType + '\'' +
|
||||||
|
", confidence='" + confidence + '\'' +
|
||||||
|
", fireImage='" + fireImage + '\'' +
|
||||||
|
", satelliteImage='" + satelliteImage + '\'' +
|
||||||
|
", townCode='" + townCode + '\'' +
|
||||||
|
", townName='" + townName + '\'' +
|
||||||
|
", addTime='" + addTime + '\'' +
|
||||||
|
", firePointAddress='" + firePointAddress + '\'' +
|
||||||
|
", remark='" + remark + '\'' +
|
||||||
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,90 +16,110 @@ public class FirePointPreciseEntity implements Serializable {
|
|||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_point_precise_seq_gen")
|
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_point_precise_seq_gen")
|
||||||
@SequenceGenerator(name = "fire_point_precise_seq_gen", sequenceName = "fire_point_precise_id_seq", allocationSize = 1)
|
@SequenceGenerator(name = "fire_point_precise_seq_gen", sequenceName = "fire_point_precise_id_seq", allocationSize = 1)
|
||||||
private Integer id;
|
private Long id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 火点编码
|
* 火点编码
|
||||||
*/
|
*/
|
||||||
@Column(length = 32, unique = true, columnDefinition = "varchar(32)")
|
@Column(length = 32, unique = true, columnDefinition = "varchar(32)")
|
||||||
private String fireCode;
|
private String fireCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 省市区的编码
|
* 省市区的编码
|
||||||
*/
|
*/
|
||||||
@Column(length = 32, columnDefinition = "varchar(32)")
|
@Column(length = 32, columnDefinition = "varchar(32)")
|
||||||
private Long countyCode;
|
private String countyCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 省市区的名称
|
* 省市区的名称
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String countyName;
|
private String countyName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卫星监测的时间
|
* 卫星监测的时间
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String satelliteTime;
|
private String satelliteTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 经度
|
* 经度
|
||||||
*/
|
*/
|
||||||
private Double longitude;
|
private Double longitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 纬度
|
* 纬度
|
||||||
*/
|
*/
|
||||||
private Double latitude;
|
private Double latitude;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卫星类型
|
* 卫星类型
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String satelliteType;
|
private String satelliteType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 植被类型
|
* 植被类型
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String landType;
|
private String landType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 置信度
|
* 置信度
|
||||||
*/
|
*/
|
||||||
@Column(length = 32, columnDefinition = "varchar(32)")
|
@Column(length = 32, columnDefinition = "varchar(32)")
|
||||||
private String confidence;
|
private String confidence;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前火点的图片
|
* 当前火点的图片
|
||||||
*/
|
*/
|
||||||
@Column(length = 512, columnDefinition = "varchar(512)")
|
@Column(length = 512, columnDefinition = "varchar(512)")
|
||||||
private String fireImage;
|
private String fireImage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卫星影像图片
|
* 卫星影像图片
|
||||||
*/
|
*/
|
||||||
@Column(length = 512, columnDefinition = "varchar(512)")
|
@Column(length = 512, columnDefinition = "varchar(512)")
|
||||||
private String satelliteImage;
|
private String satelliteImage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 乡镇街道的编码
|
* 乡镇街道的编码
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String townCode;
|
private String townCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 乡镇街道的名字
|
* 乡镇街道的名字
|
||||||
*/
|
*/
|
||||||
@Column(length = 85, columnDefinition = "varchar(85)")
|
@Column(length = 85, columnDefinition = "varchar(85)")
|
||||||
private String townName;
|
private String townName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加的时间
|
* 添加的时间
|
||||||
*/
|
*/
|
||||||
@Column(length = 64, columnDefinition = "varchar(64)")
|
@Column(length = 64, columnDefinition = "varchar(64)")
|
||||||
private String addTime;
|
private String addTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 详细地址
|
* 详细地址
|
||||||
*/
|
*/
|
||||||
@Column(length = 255, columnDefinition = "varchar(255)")
|
@Column(length = 255, columnDefinition = "varchar(255)")
|
||||||
private String firePointAddress;
|
private String firePointAddress;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备注
|
||||||
|
*/
|
||||||
|
@Column(length = 1024, columnDefinition = "varchar(1024)")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
public FirePointPreciseEntity() {
|
public FirePointPreciseEntity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getId() {
|
public Long getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(Integer id) {
|
public void setId(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,11 +131,11 @@ public class FirePointPreciseEntity implements Serializable {
|
|||||||
this.fireCode = fireCode;
|
this.fireCode = fireCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getCountyCode() {
|
public String getCountyCode() {
|
||||||
return countyCode;
|
return countyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCountyCode(Long countyCode) {
|
public void setCountyCode(String countyCode) {
|
||||||
this.countyCode = countyCode;
|
this.countyCode = countyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,8 +243,34 @@ public class FirePointPreciseEntity implements Serializable {
|
|||||||
this.firePointAddress = firePointAddress;
|
this.firePointAddress = firePointAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "FirePointPreciseEntity{" + "id=" + id + ", fireCode='" + fireCode + '\'' + ", countyCode=" + countyCode + ", countyName='" + countyName + '\'' + ", satelliteTime='" + satelliteTime + '\'' + ", longitude=" + longitude + ", latitude=" + latitude + ", satelliteType='" + satelliteType + '\'' + ", landType='" + landType + '\'' + ", confidence='" + confidence + '\'' + ", fireImage='" + fireImage + '\'' + ", satelliteImage='" + satelliteImage + '\'' + ", townCode='" + townCode + '\'' + ", townName='" + townName + '\'' + ", addTime='" + addTime + '\'' + ", firePointAddress='" + firePointAddress + '\'' + '}';
|
return "FirePointPreciseEntity{" +
|
||||||
|
"id=" + id +
|
||||||
|
", fireCode='" + fireCode + '\'' +
|
||||||
|
", countyCode='" + countyCode + '\'' +
|
||||||
|
", countyName='" + countyName + '\'' +
|
||||||
|
", satelliteTime='" + satelliteTime + '\'' +
|
||||||
|
", longitude=" + longitude +
|
||||||
|
", latitude=" + latitude +
|
||||||
|
", satelliteType='" + satelliteType + '\'' +
|
||||||
|
", landType='" + landType + '\'' +
|
||||||
|
", confidence='" + confidence + '\'' +
|
||||||
|
", fireImage='" + fireImage + '\'' +
|
||||||
|
", satelliteImage='" + satelliteImage + '\'' +
|
||||||
|
", townCode='" + townCode + '\'' +
|
||||||
|
", townName='" + townName + '\'' +
|
||||||
|
", addTime='" + addTime + '\'' +
|
||||||
|
", firePointAddress='" + firePointAddress + '\'' +
|
||||||
|
", remark='" + remark + '\'' +
|
||||||
|
'}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import com.xkrs.straw.model.qo.AllFirePointQo;
|
|||||||
|
|
||||||
public interface DispatchFirePointService {
|
public interface DispatchFirePointService {
|
||||||
|
|
||||||
|
String debug();
|
||||||
|
|
||||||
String insertFirePointChannelOrdinary(AllFirePointQo firePointQo);
|
String insertFirePointChannelOrdinary(AllFirePointQo firePointQo);
|
||||||
|
|
||||||
String insertFirePointChannelPrecise(AllFirePointQo firePointQo);
|
String insertFirePointChannelPrecise(AllFirePointQo firePointQo);
|
||||||
|
@ -1,56 +1,119 @@
|
|||||||
package com.xkrs.straw.service.impl;
|
package com.xkrs.straw.service.impl;
|
||||||
|
|
||||||
|
import com.xkrs.straw.dao.FirePointChannelConfigDao;
|
||||||
import com.xkrs.straw.dao.FirePointOrdinaryDao;
|
import com.xkrs.straw.dao.FirePointOrdinaryDao;
|
||||||
import com.xkrs.straw.dao.FirePointPreciseDao;
|
import com.xkrs.straw.dao.FirePointPreciseDao;
|
||||||
|
import com.xkrs.straw.helper.GeoCodeHelper;
|
||||||
|
import com.xkrs.straw.model.entity.FirePointChannelConfigEntity;
|
||||||
|
import com.xkrs.straw.model.entity.FirePointOrdinaryEntity;
|
||||||
|
import com.xkrs.straw.model.entity.FirePointPreciseEntity;
|
||||||
import com.xkrs.straw.model.qo.AllFirePointQo;
|
import com.xkrs.straw.model.qo.AllFirePointQo;
|
||||||
import com.xkrs.straw.service.DispatchFirePointService;
|
import com.xkrs.straw.service.DispatchFirePointService;
|
||||||
|
import com.xkrs.straw.utils.DispatchFirePointUtils;
|
||||||
|
import com.xkrs.utils.DateTimeUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneOffset;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
||||||
|
|
||||||
|
public static Logger log = LoggerFactory.getLogger(DispatchFirePointServiceImpl.class);
|
||||||
|
@Resource
|
||||||
|
private FirePointChannelConfigDao channelConfigDao;
|
||||||
@Resource
|
@Resource
|
||||||
private FirePointOrdinaryDao firePointOrdinaryDao;
|
private FirePointOrdinaryDao firePointOrdinaryDao;
|
||||||
private FirePointPreciseDao firePointPreciseDao;
|
private FirePointPreciseDao firePointPreciseDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String debug() {
|
||||||
|
|
||||||
|
// FirePointChannelConfigBean firePointChannelConfigBean = new FirePointChannelConfigBean();
|
||||||
|
// firePointChannelConfigBean.setChannelName(FirePointChannelConfigBean.Precise);
|
||||||
|
// List<FirePointChannelConfigBean.ChannelConfig> configList = new ArrayList<>();
|
||||||
|
//
|
||||||
|
// FirePointChannelConfigBean.ChannelConfig channelConfig1 = new FirePointChannelConfigBean.ChannelConfig();
|
||||||
|
// channelConfig1.setStartTime("2022-01-01 00:00:00");
|
||||||
|
// channelConfig1.setEndTime("2022-09-01 00:00:00");
|
||||||
|
// configList.add(channelConfig1);
|
||||||
|
//
|
||||||
|
// FirePointChannelConfigBean.ChannelConfig channelConfig2 = new FirePointChannelConfigBean.ChannelConfig();
|
||||||
|
// channelConfig2.setStartTime("2022-10-01 00:00:00");
|
||||||
|
// channelConfig2.setEndTime("2022-11-01 00:00:00");
|
||||||
|
// configList.add(channelConfig2);
|
||||||
|
//
|
||||||
|
// firePointChannelConfigBean.setConfigList(configList);
|
||||||
|
// String serialize = JsonUtils.<FirePointChannelConfigBean>serialize(firePointChannelConfigBean);
|
||||||
|
// FirePointChannelConfigEntity firePointChannelConfigEntity = new FirePointChannelConfigEntity();
|
||||||
|
// firePointChannelConfigEntity.setJsonContent(serialize);
|
||||||
|
// channelConfigDao.save(firePointChannelConfigEntity);
|
||||||
|
return "null";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String insertFirePointChannelOrdinary(AllFirePointQo firePointQo) {
|
public String insertFirePointChannelOrdinary(AllFirePointQo firePointQo) {
|
||||||
|
|
||||||
|
String fireCode = firePointQo.getFireCode();
|
||||||
|
Long countyCode = firePointQo.getCountyCode();
|
||||||
|
String countyName = firePointQo.getCountyName();
|
||||||
|
Long satelliteTimeTs = firePointQo.getSatelliteTimeTs();
|
||||||
|
Double longitude = firePointQo.getLongitude();
|
||||||
|
Double latitude = firePointQo.getLatitude();
|
||||||
|
String satelliteType = firePointQo.getSatelliteType();
|
||||||
|
String landType = firePointQo.getLandType();
|
||||||
|
String confidence = firePointQo.getConfidence();
|
||||||
|
String fireImage = firePointQo.getFireImage();
|
||||||
|
String satelliteImage = firePointQo.getSatelliteImage();
|
||||||
|
String townCode = firePointQo.getTownCode();
|
||||||
|
|
||||||
firePointQo.getFireCode();
|
LocalDateTime satelliteLocalDateTime = LocalDateTime.ofEpochSecond(satelliteTimeTs, 0, ZoneOffset.ofHours(8));
|
||||||
firePointQo.getCountyCode();
|
String satelliteTime = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime);//卫星时间
|
||||||
firePointQo.getCountyName();
|
String addTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());//添加时间
|
||||||
firePointQo.getSatelliteTimeTs();
|
|
||||||
firePointQo.getLongitude();
|
|
||||||
firePointQo.getLatitude();
|
|
||||||
firePointQo.getSatelliteType();
|
|
||||||
firePointQo.getLandType();
|
|
||||||
firePointQo.getConfidence();
|
|
||||||
firePointQo.getFireImage();
|
|
||||||
firePointQo.getSatelliteImage();
|
|
||||||
firePointQo.getTownCode();
|
|
||||||
|
|
||||||
|
//普通渠道来的火点直接入库普通火点库
|
||||||
|
FirePointOrdinaryEntity firePointOrdinaryEntity = new FirePointOrdinaryEntity();
|
||||||
|
firePointOrdinaryEntity.setFireCode(fireCode);
|
||||||
|
firePointOrdinaryEntity.setCountyCode(String.valueOf(countyCode));
|
||||||
|
firePointOrdinaryEntity.setCountyName(countyName);
|
||||||
|
firePointOrdinaryEntity.setSatelliteTime(satelliteTime);
|
||||||
|
firePointOrdinaryEntity.setLongitude(longitude);
|
||||||
|
firePointOrdinaryEntity.setLatitude(latitude);
|
||||||
|
firePointOrdinaryEntity.setSatelliteType(satelliteType);
|
||||||
|
firePointOrdinaryEntity.setLandType(landType);
|
||||||
|
firePointOrdinaryEntity.setConfidence(confidence);
|
||||||
|
firePointOrdinaryEntity.setFireImage(fireImage);
|
||||||
|
firePointOrdinaryEntity.setSatelliteImage(satelliteImage);
|
||||||
|
firePointOrdinaryEntity.setTownCode(townCode);
|
||||||
|
firePointOrdinaryEntity.setAddTime(addTime);
|
||||||
|
bindFirePointAddress(firePointOrdinaryEntity);
|
||||||
|
firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
||||||
|
|
||||||
// FirePointOrdinaryEntity firePointOrdinaryEntity = new FirePointOrdinaryEntity();
|
List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll();
|
||||||
// firePointOrdinaryEntity.setFireCode();
|
boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(satelliteLocalDateTime, firePointChannelConfigEntityList);
|
||||||
// firePointOrdinaryEntity.setCountyCode();
|
//如果现在不属于精准渠道的时间范围,那么普通渠道来的火点就入库精准火点库
|
||||||
// firePointOrdinaryEntity.setCountyName();
|
if (!inPreciseTimeRange) {
|
||||||
// firePointOrdinaryEntity.setSatelliteTime();
|
FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity();
|
||||||
// firePointOrdinaryEntity.setLongitude();
|
firePointPreciseEntity.setFireCode(fireCode);
|
||||||
// firePointOrdinaryEntity.setLatitude();
|
firePointPreciseEntity.setCountyCode(String.valueOf(countyCode));
|
||||||
// firePointOrdinaryEntity.setSatelliteType();
|
firePointPreciseEntity.setCountyName(countyName);
|
||||||
// firePointOrdinaryEntity.setLandType();
|
firePointPreciseEntity.setSatelliteTime(satelliteTime);
|
||||||
// firePointOrdinaryEntity.setConfidence();
|
firePointPreciseEntity.setLongitude(longitude);
|
||||||
// firePointOrdinaryEntity.setFireImage();
|
firePointPreciseEntity.setLatitude(latitude);
|
||||||
// firePointOrdinaryEntity.setSatelliteImage();
|
firePointPreciseEntity.setSatelliteType(satelliteType);
|
||||||
// firePointOrdinaryEntity.setTownCode();
|
firePointPreciseEntity.setLandType(landType);
|
||||||
// firePointOrdinaryEntity.setTownName();
|
firePointPreciseEntity.setConfidence(confidence);
|
||||||
// firePointOrdinaryEntity.setAddTime();
|
firePointPreciseEntity.setFireImage(fireImage);
|
||||||
// firePointOrdinaryEntity.setFirePointAddress();
|
firePointPreciseEntity.setSatelliteImage(satelliteImage);
|
||||||
// firePointOrdinaryDao.save(firePointOrdinaryEntity);
|
firePointPreciseEntity.setTownCode(townCode);
|
||||||
|
firePointPreciseEntity.setAddTime(addTime);
|
||||||
|
bindFirePointAddress(firePointPreciseEntity);
|
||||||
|
firePointPreciseDao.save(firePointPreciseEntity);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -58,40 +121,82 @@ public class DispatchFirePointServiceImpl implements DispatchFirePointService {
|
|||||||
@Override
|
@Override
|
||||||
public String insertFirePointChannelPrecise(AllFirePointQo firePointQo) {
|
public String insertFirePointChannelPrecise(AllFirePointQo firePointQo) {
|
||||||
|
|
||||||
firePointQo.getFireCode();
|
String fireCode = firePointQo.getFireCode();
|
||||||
firePointQo.getCountyCode();
|
Long countyCode = firePointQo.getCountyCode();
|
||||||
firePointQo.getCountyName();
|
String countyName = firePointQo.getCountyName();
|
||||||
firePointQo.getSatelliteTimeTs();
|
Long satelliteTimeTs = firePointQo.getSatelliteTimeTs();
|
||||||
firePointQo.getLongitude();
|
Double longitude = firePointQo.getLongitude();
|
||||||
firePointQo.getLatitude();
|
Double latitude = firePointQo.getLatitude();
|
||||||
firePointQo.getSatelliteType();
|
String satelliteType = firePointQo.getSatelliteType();
|
||||||
firePointQo.getLandType();
|
String landType = firePointQo.getLandType();
|
||||||
firePointQo.getConfidence();
|
String confidence = firePointQo.getConfidence();
|
||||||
firePointQo.getFireImage();
|
String fireImage = firePointQo.getFireImage();
|
||||||
firePointQo.getSatelliteImage();
|
String satelliteImage = firePointQo.getSatelliteImage();
|
||||||
firePointQo.getTownCode();
|
String townCode = firePointQo.getTownCode();
|
||||||
|
|
||||||
|
LocalDateTime satelliteLocalDateTime = LocalDateTime.ofEpochSecond(satelliteTimeTs, 0, ZoneOffset.ofHours(8));
|
||||||
|
String satelliteTime = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime);//卫星时间
|
||||||
|
String addTime = DateTimeUtils.localDateTimeToString(LocalDateTime.now());//添加时间
|
||||||
|
|
||||||
// FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity();
|
List<FirePointChannelConfigEntity> firePointChannelConfigEntityList = channelConfigDao.findAll();
|
||||||
// firePointPreciseEntity.setFireCode();
|
boolean inPreciseTimeRange = DispatchFirePointUtils.checkIfInPreciseTimeRange(satelliteLocalDateTime, firePointChannelConfigEntityList);
|
||||||
// firePointPreciseEntity.setCountyCode();
|
//如果现在属于精准渠道的时间范围,那么精准渠道来的火点就入库精准火点库
|
||||||
// firePointPreciseEntity.setCountyName();
|
if (inPreciseTimeRange) {
|
||||||
// firePointPreciseEntity.setSatelliteTime();
|
FirePointPreciseEntity firePointPreciseEntity = new FirePointPreciseEntity();
|
||||||
// firePointPreciseEntity.setLongitude();
|
firePointPreciseEntity.setFireCode(fireCode);
|
||||||
// firePointPreciseEntity.setLatitude();
|
firePointPreciseEntity.setCountyCode(String.valueOf(countyCode));
|
||||||
// firePointPreciseEntity.setSatelliteType();
|
firePointPreciseEntity.setCountyName(countyName);
|
||||||
// firePointPreciseEntity.setLandType();
|
firePointPreciseEntity.setSatelliteTime(satelliteTime);
|
||||||
// firePointPreciseEntity.setConfidence();
|
firePointPreciseEntity.setLongitude(longitude);
|
||||||
// firePointPreciseEntity.setFireImage();
|
firePointPreciseEntity.setLatitude(latitude);
|
||||||
// firePointPreciseEntity.setSatelliteImage();
|
firePointPreciseEntity.setSatelliteType(satelliteType);
|
||||||
// firePointPreciseEntity.setTownCode();
|
firePointPreciseEntity.setLandType(landType);
|
||||||
// firePointPreciseEntity.setTownName();
|
firePointPreciseEntity.setConfidence(confidence);
|
||||||
// firePointPreciseEntity.setAddTime();
|
firePointPreciseEntity.setFireImage(fireImage);
|
||||||
// firePointPreciseEntity.setFirePointAddress();
|
firePointPreciseEntity.setSatelliteImage(satelliteImage);
|
||||||
// firePointPreciseDao.save(firePointPreciseEntity);
|
firePointPreciseEntity.setTownCode(townCode);
|
||||||
|
firePointPreciseEntity.setAddTime(addTime);
|
||||||
|
bindFirePointAddress(firePointPreciseEntity);
|
||||||
|
firePointPreciseDao.save(firePointPreciseEntity);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void bindFirePointAddress(FirePointPreciseEntity firePointPreciseEntity) {
|
||||||
|
String countyCode = firePointPreciseEntity.getCountyCode();
|
||||||
|
String countyName = firePointPreciseEntity.getCountyName();
|
||||||
|
String townCode = firePointPreciseEntity.getTownCode();
|
||||||
|
GeoCodeHelper geoCodeHelper = new GeoCodeHelper();
|
||||||
|
geoCodeHelper.doGeoCode(firePointPreciseEntity.getLongitude(), firePointPreciseEntity.getLatitude());
|
||||||
|
boolean geoCodeResult = geoCodeHelper.checkGeoCodeResult(countyCode, countyName, townCode);
|
||||||
|
if (geoCodeResult) {
|
||||||
|
firePointPreciseEntity.setTownCode(geoCodeHelper.getCalTownCode());
|
||||||
|
firePointPreciseEntity.setTownName(geoCodeHelper.getCalTownName());
|
||||||
|
firePointPreciseEntity.setFirePointAddress(geoCodeHelper.getCalFirePointAddress());
|
||||||
|
firePointPreciseEntity.setRemark("");
|
||||||
|
} else {
|
||||||
|
String remark = "接收到的countyCode=" + countyCode + ",计算得到的countyCode=" + geoCodeHelper.getCalCountyCode() + "。接收到的countyName=" + countyName + ",计算得到的countyName=" + geoCodeHelper.getCalCountyName() + "。接收到的townCode=" + townCode + ",计算得到的townCode=" + geoCodeHelper.getCalTownCode() + "。";
|
||||||
|
firePointPreciseEntity.setRemark(remark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bindFirePointAddress(FirePointOrdinaryEntity firePointOrdinaryEntity) {
|
||||||
|
String countyCode = firePointOrdinaryEntity.getCountyCode();
|
||||||
|
String countyName = firePointOrdinaryEntity.getCountyName();
|
||||||
|
String townCode = firePointOrdinaryEntity.getTownCode();
|
||||||
|
GeoCodeHelper geoCodeHelper = new GeoCodeHelper();
|
||||||
|
geoCodeHelper.doGeoCode(firePointOrdinaryEntity.getLongitude(), firePointOrdinaryEntity.getLatitude());
|
||||||
|
boolean geoCodeResult = geoCodeHelper.checkGeoCodeResult(countyCode, countyName, townCode);
|
||||||
|
if (geoCodeResult) {
|
||||||
|
firePointOrdinaryEntity.setTownCode(geoCodeHelper.getCalTownCode());
|
||||||
|
firePointOrdinaryEntity.setTownName(geoCodeHelper.getCalTownName());
|
||||||
|
firePointOrdinaryEntity.setFirePointAddress(geoCodeHelper.getCalFirePointAddress());
|
||||||
|
firePointOrdinaryEntity.setRemark("");
|
||||||
|
} else {
|
||||||
|
String remark = "接收到的countyCode=" + countyCode + ",计算得到的countyCode=" + geoCodeHelper.getCalCountyCode() + "。接收到的countyName=" + countyName + ",计算得到的countyName=" + geoCodeHelper.getCalCountyName() + "。接收到的townCode=" + townCode + ",计算得到的townCode=" + geoCodeHelper.getCalTownCode() + "。";
|
||||||
|
firePointOrdinaryEntity.setRemark(remark);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
110
src/main/java/com/xkrs/straw/utils/DispatchFirePointUtils.java
Normal file
110
src/main/java/com/xkrs/straw/utils/DispatchFirePointUtils.java
Normal file
@ -0,0 +1,110 @@
|
|||||||
|
package com.xkrs.straw.utils;
|
||||||
|
|
||||||
|
import com.xkrs.straw.model.bean.FirePointChannelConfigBean;
|
||||||
|
import com.xkrs.straw.model.entity.FirePointChannelConfigEntity;
|
||||||
|
import com.xkrs.straw.service.impl.DispatchFirePointServiceImpl;
|
||||||
|
import com.xkrs.utils.DateTimeUtils;
|
||||||
|
import org.apache.hc.core5.util.TextUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DispatchFirePointUtils {
|
||||||
|
|
||||||
|
public static Logger log = LoggerFactory.getLogger(DispatchFirePointServiceImpl.class);
|
||||||
|
|
||||||
|
private DispatchFirePointUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean checkIfInPreciseTimeRange(LocalDateTime satelliteLocalDateTime, List<FirePointChannelConfigEntity> firePointChannelConfigEntityList) {
|
||||||
|
if (firePointChannelConfigEntityList == null || firePointChannelConfigEntityList.size() == 0) {
|
||||||
|
//TODO 报错,发短信通知我
|
||||||
|
log.info("系统报错:checkIfInPreciseTimeRange firePointChannelConfigEntityList == null || firePointChannelConfigEntityList.size() == 0");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (FirePointChannelConfigEntity firePointChannelConfigEntity : firePointChannelConfigEntityList) {
|
||||||
|
String jsonContent = firePointChannelConfigEntity.getJsonContent();
|
||||||
|
FirePointChannelConfigBean firePointChannelConfigBean = JsonUtils.deserialize(jsonContent, FirePointChannelConfigBean.class);
|
||||||
|
if (FirePointChannelConfigBean.Precise.equals(firePointChannelConfigBean.getChannelName())) {
|
||||||
|
List<FirePointChannelConfigBean.ChannelConfig> channelConfigList = firePointChannelConfigBean.getConfigList();
|
||||||
|
if (channelConfigList == null || channelConfigList.size() == 0) {
|
||||||
|
//TODO 报错,发短信通知我
|
||||||
|
log.info("系统报错:checkIfInPreciseTimeRange channelConfigList == null || channelConfigList.size() == 0");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (FirePointChannelConfigBean.ChannelConfig channelConfig : channelConfigList) {
|
||||||
|
//预处理开始时间
|
||||||
|
String startTime = channelConfig.getStartTime();//获取精准火点渠道的开始时间
|
||||||
|
boolean needCheckStartTime = !TextUtils.isEmpty(startTime);
|
||||||
|
LocalDateTime thisYearStartTime = null;
|
||||||
|
if (needCheckStartTime) {
|
||||||
|
thisYearStartTime = obtainLocalDateTimeThisYear(startTime);
|
||||||
|
needCheckStartTime = thisYearStartTime != null;
|
||||||
|
}
|
||||||
|
//预处理结束时间
|
||||||
|
String endTime = channelConfig.getEndTime();//获取精准火点渠道的结束时间
|
||||||
|
boolean needCheckEndTime = !TextUtils.isEmpty(endTime);
|
||||||
|
LocalDateTime thisYearEndTime = null;
|
||||||
|
if (needCheckEndTime) {
|
||||||
|
thisYearEndTime = obtainLocalDateTimeThisYear(endTime);
|
||||||
|
needCheckEndTime = thisYearEndTime != null;
|
||||||
|
}
|
||||||
|
//排列组合4种情况
|
||||||
|
if (needCheckStartTime) {
|
||||||
|
if (needCheckEndTime) {
|
||||||
|
//开始时间、结束时间都需要比较
|
||||||
|
if (satelliteLocalDateTime.isBefore(thisYearStartTime) || thisYearEndTime.isBefore(satelliteLocalDateTime)) {
|
||||||
|
String time0 = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime);
|
||||||
|
String time1 = DateTimeUtils.localDateTimeToString(thisYearStartTime);
|
||||||
|
String time2 = DateTimeUtils.localDateTimeToString(thisYearEndTime);
|
||||||
|
log.info("开始时间、结束时间都需要比较,比较结果:不属于精准时间范围内,详情:火点时间=" + time0 + ",开始时间=" + time1 + ",结束时间=" + time2);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//开始时间需要比较,结束时间不需要比较
|
||||||
|
if (satelliteLocalDateTime.isBefore(thisYearStartTime)) {
|
||||||
|
String time0 = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime);
|
||||||
|
String time1 = DateTimeUtils.localDateTimeToString(thisYearStartTime);
|
||||||
|
log.info("开始时间需要比较,结束时间不需要比较,比较结果:不属于精准时间范围内,详情:火点时间=" + time0 + ",开始时间=" + time1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (needCheckEndTime) {
|
||||||
|
//开始时间不需要比较,结束时间需要比较
|
||||||
|
if (thisYearEndTime.isBefore(satelliteLocalDateTime)) {
|
||||||
|
String time0 = DateTimeUtils.localDateTimeToString(satelliteLocalDateTime);
|
||||||
|
String time2 = DateTimeUtils.localDateTimeToString(thisYearEndTime);
|
||||||
|
log.info("开始时间不需要比较,结束时间需要比较,比较结果:不属于精准时间范围内,详情:火点时间=" + time0 + ",结束时间=" + time2);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//开始时间、结束时间都不需要比较
|
||||||
|
log.info("开始时间、结束时间都不需要比较,比较结果:属于精准时间范围内");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//没有因为遇到不符合条件的情况提前退出,就认为在精准渠道配置的时间范围之内
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param formattedTime 2022-01-01 00:00:00
|
||||||
|
*/
|
||||||
|
private static LocalDateTime obtainLocalDateTimeThisYear(String formattedTime) {
|
||||||
|
try {
|
||||||
|
LocalDateTime localDateTime = LocalDateTime.parse(formattedTime, DateTimeUtils.DATE_TIME_FORMATTER_1);
|
||||||
|
int dYear = LocalDateTime.now().getYear() - localDateTime.getYear();
|
||||||
|
return localDateTime.plusYears(dYear);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
39
src/main/java/com/xkrs/straw/utils/JsonUtils.java
Normal file
39
src/main/java/com/xkrs/straw/utils/JsonUtils.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package com.xkrs.straw.utils;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
public class JsonUtils {
|
||||||
|
|
||||||
|
private static ObjectMapper MAPPER = new ObjectMapper();
|
||||||
|
|
||||||
|
static {
|
||||||
|
// 通过spi注册支持的modules(对象映射器),如JavaTimeModule等
|
||||||
|
MAPPER.findAndRegisterModules();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> String serialize(T data) {
|
||||||
|
try {
|
||||||
|
return MAPPER.writeValueAsString(data);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T deserialize(String json, Class<T> clazz) {
|
||||||
|
try {
|
||||||
|
return MAPPER.readValue(json, clazz);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T deserialize(String json, TypeReference<T> clazz) {
|
||||||
|
try {
|
||||||
|
return MAPPER.readValue(json, clazz);
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user