1、如果是山东的火点,2、同时开关已打开,那么就把火点转存到山东火点表,否则就直接存到火点表

This commit is contained in:
liuchengqian 2022-06-02 10:06:59 +08:00
parent 30327a25b1
commit c1d7e65756
4 changed files with 418 additions and 35 deletions

View File

@ -6,6 +6,7 @@ import com.xkrs.model.entity.SettingEntity;
import com.xkrs.model.qo.SettingQo;
import org.apache.http.util.TextUtils;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@ -40,9 +41,22 @@ public class SettingController {
settingDao.save(settingEntity);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
}
SettingEntity settingEntity = settingEntityList.get(0);
settingDao.updateSwitchStateById(settingEntity.getId(), settingQo.getSwitchState());
for (SettingEntity settingEntity : settingEntityList) {
settingDao.updateSwitchStateById(settingEntity.getId(), settingQo.getSwitchState());
}
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "修改成功", locale);
}
@GetMapping("/queryswitchstate")
public String querySwitchState() {
Locale locale = LocaleContextHolder.getLocale();
List<SettingEntity> settingEntityList = settingDao.findAll();
if (settingEntityList.isEmpty()) {
return outputEncapsulationObject(PromptMessageEnum.DATA_NONE, "暂时还没有状态信息", locale);
}
SettingEntity settingEntity = settingEntityList.get(0);
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, settingEntity.getSwitchState(), locale);
}
}

View File

@ -0,0 +1,19 @@
package com.xkrs.dao;
import com.xkrs.model.entity.ShanDongFirePointEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Component;
@Component
public interface ShanDongFirePointDao extends JpaRepository<ShanDongFirePointEntity, Long>, JpaSpecificationExecutor<ShanDongFirePointEntity> {
/**
* 根据火点编码查询火点信息
*
* @param fireCode
* @return
*/
ShanDongFirePointEntity findByFireCode(String fireCode);
}

View File

@ -0,0 +1,292 @@
package com.xkrs.model.entity;
import javax.persistence.*;
import java.io.Serializable;
/**
* @author XinYi Song
*/
@Entity
@Table(name = "fire_point_shandong")
public class ShanDongFirePointEntity implements Serializable {
/**
* 指定主键建立自增序列主键值取自序列
*/
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "fire_point_shandong_seq_gen")
@SequenceGenerator(name = "fire_point_shandong_seq_gen", sequenceName = "fire_point_shandong_id_seq", allocationSize = 1)
private Integer id;
/**
* 火点编码
*/
@Column(length = 32, unique = true, columnDefinition = "varchar(32)")
private String fireCode;
/**
* 经度
*/
private double longitude;
/**
* 纬度
*/
private double latitude;
/**
* 省市区的编码
*/
@Column(length = 32, columnDefinition = "varchar(32)")
private String countyCode;
/**
* 省市区的名称
*/
@Column(columnDefinition = "varchar(64)")
private String countyName;
/**
* 卫星监测的时间
*/
private String satelliteTime;
/**
* 卫星的类型
*/
@Column(columnDefinition = "varchar(64)")
private String satelliteType;
/**
* 植被类型
*/
@Column(columnDefinition = "varchar(64)")
private String landType;
/**
* 添加的时间
*/
private String addTime;
/**
* 置信度
*/
@Column(length = 32, columnDefinition = "varchar(32)")
private String confidence;
/**
* 详细地址
*/
private String firePointAddress;
/**
* 火点状态 0 发现 1预警 2核查 -1,3结案
*/
@Column(length = 32, columnDefinition = "varchar(32)")
private String fireType;
/**
* 当前火点的图片
*/
private String fireImage;
/**
* 卫星影像图片
*/
private String satelliteImage;
/**
* 火点前的图片
*/
private String beforeFireImage;
/**
* 火点后的图片
*/
private String afterFireImage;
/**
* 街道编码
*/
@Column(length = 65, columnDefinition = "varchar(65)")
private String streetCode;
@Column(length = 65, columnDefinition = "varchar(85)")
private String streetName;
/**
* 0未审核
* 1审核通过
* 2审核不通过
*/
@Column(length = 65, columnDefinition = "varchar(85)")
private String verifyState;
public ShanDongFirePointEntity() {
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getFireCode() {
return fireCode;
}
public void setFireCode(String fireCode) {
this.fireCode = fireCode;
}
public double getLongitude() {
return longitude;
}
public void setLongitude(double longitude) {
this.longitude = longitude;
}
public double getLatitude() {
return latitude;
}
public void setLatitude(double latitude) {
this.latitude = latitude;
}
public String getCountyCode() {
return countyCode;
}
public void setCountyCode(String countyCode) {
this.countyCode = countyCode;
}
public String getCountyName() {
return countyName;
}
public void setCountyName(String countyName) {
this.countyName = countyName;
}
public String getSatelliteTime() {
return satelliteTime;
}
public void setSatelliteTime(String satelliteTime) {
this.satelliteTime = satelliteTime;
}
public String getSatelliteType() {
return satelliteType;
}
public void setSatelliteType(String satelliteType) {
this.satelliteType = satelliteType;
}
public String getLandType() {
return landType;
}
public void setLandType(String landType) {
this.landType = landType;
}
public String getAddTime() {
return addTime;
}
public void setAddTime(String addTime) {
this.addTime = addTime;
}
public String getConfidence() {
return confidence;
}
public void setConfidence(String confidence) {
this.confidence = confidence;
}
public String getFirePointAddress() {
return firePointAddress;
}
public void setFirePointAddress(String firePointAddress) {
this.firePointAddress = firePointAddress;
}
public String getFireType() {
return fireType;
}
public void setFireType(String fireType) {
this.fireType = fireType;
}
public String getFireImage() {
return fireImage;
}
public void setFireImage(String fireImage) {
this.fireImage = fireImage;
}
public String getSatelliteImage() {
return satelliteImage;
}
public void setSatelliteImage(String satelliteImage) {
this.satelliteImage = satelliteImage;
}
public String getBeforeFireImage() {
return beforeFireImage;
}
public void setBeforeFireImage(String beforeFireImage) {
this.beforeFireImage = beforeFireImage;
}
public String getAfterFireImage() {
return afterFireImage;
}
public void setAfterFireImage(String afterFireImage) {
this.afterFireImage = afterFireImage;
}
public String getStreetCode() {
return streetCode;
}
public void setStreetCode(String streetCode) {
this.streetCode = streetCode;
}
public String getStreetName() {
return streetName;
}
public void setStreetName(String streetName) {
this.streetName = streetName;
}
public String getVerifyState() {
return verifyState;
}
public void setVerifyState(String verifyState) {
this.verifyState = verifyState;
}
@Override
public String toString() {
return "ShanDongFirePointEntity{" + "id=" + id + ", fireCode='" + fireCode + '\'' + ", longitude=" + longitude + ", latitude=" + latitude + ", countyCode='" + countyCode + '\'' + ", countyName='" + countyName + '\'' + ", satelliteTime='" + satelliteTime + '\'' + ", satelliteType='" + satelliteType + '\'' + ", landType='" + landType + '\'' + ", addTime='" + addTime + '\'' + ", confidence='" + confidence + '\'' + ", firePointAddress='" + firePointAddress + '\'' + ", fireType='" + fireType + '\'' + ", fireImage='" + fireImage + '\'' + ", satelliteImage='" + satelliteImage + '\'' + ", beforeFireImage='" + beforeFireImage + '\'' + ", afterFireImage='" + afterFireImage + '\'' + ", streetCode='" + streetCode + '\'' + ", streetName='" + streetName + '\'' + ", verifyState='" + verifyState + '\'' + '}';
}
}

View File

@ -42,6 +42,12 @@ public class FirePointServiceImpl implements FirePointService {
@Resource
private FirePointDao firePointDao;
@Resource
private SettingDao settingDao;
@Resource
private ShanDongFirePointDao shanDongFirePointDao;
@Resource
private Query query;
@ -87,43 +93,96 @@ public class FirePointServiceImpl implements FirePointService {
@CacheEvict(value = "FirePointServiceCache", allEntries = true)
@Override
public FirePointEntity insertFirePoint(FirePointQo firePointQo) {
FirePointEntity firePointEntity = new FirePointEntity();
if (firePointQo.getLandtype().equals("水体")) {
return null;
} else if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())) {
return null;
} else if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())) {
return null;
} else {
FirePointEntity existFireCode = firePointDao.findByFireCode(firePointQo.getFireCode());
if (existFireCode != null) {
return null;
}
firePointEntity.setFireCode(firePointQo.getFireCode());
firePointEntity.setCountyCode(firePointQo.getCountyCode().toString());
firePointEntity.setCountyName(firePointQo.getCountyName());
firePointEntity.setSatelliteTime(DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue()));
firePointEntity.setLongitude(firePointQo.getLongitude());
firePointEntity.setLatitude(firePointQo.getLatitude());
firePointEntity.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(), firePointQo.getLongitude().toString()));
firePointEntity.setSatelliteType(firePointQo.getSatelliteType());
firePointEntity.setLandType(firePointQo.getLandtype());
firePointEntity.setConfidence(firePointQo.getConfidence());
firePointEntity.setAddTime(DateTimeUtil.dateTimeToString(LocalDateTime.now()));
firePointEntity.setFireType("0");
firePointEntity.setFireImage(firePointQo.getFireImage());
firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage());
try {
bindStreetCodeName(firePointEntity);
} catch (Exception e) {
e.printStackTrace();
System.out.println("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
}
log.info("-------发现新火点");
return firePointDao.save(firePointEntity);
}
if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())) {
return null;
}
if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())) {
return null;
}
FirePointEntity firePointEntity = new FirePointEntity();
firePointEntity.setFireCode(firePointQo.getFireCode());
firePointEntity.setCountyCode(firePointQo.getCountyCode().toString());
firePointEntity.setCountyName(firePointQo.getCountyName());
firePointEntity.setSatelliteTime(DateTimeUtil.timeMillisToString(firePointQo.getSatelliteTimeTs().longValue()));
firePointEntity.setLongitude(firePointQo.getLongitude());
firePointEntity.setLatitude(firePointQo.getLatitude());
firePointEntity.setFirePointAddress(AddressUtils.getLocal(firePointQo.getLatitude().toString(), firePointQo.getLongitude().toString()));
firePointEntity.setSatelliteType(firePointQo.getSatelliteType());
firePointEntity.setLandType(firePointQo.getLandtype());
firePointEntity.setConfidence(firePointQo.getConfidence());
firePointEntity.setAddTime(DateTimeUtil.dateTimeToString(LocalDateTime.now()));
firePointEntity.setFireType("0");
firePointEntity.setFireImage(firePointQo.getFireImage());
firePointEntity.setSatelliteImage(firePointQo.getSatelliteImage());
try {
bindStreetCodeName(firePointEntity);
} catch (Exception e) {
e.printStackTrace();
System.out.println("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
}
//1如果是山东的火点2同时开关已打开那么就把火点转存到山东火点表否则就直接存到火点表
if (firePointEntity.getCountyCode().startsWith("37") && isSwitchStateOpen()) {
return saveToShanDongFirePoint(firePointEntity);
}
FirePointEntity existFireCode = firePointDao.findByFireCode(firePointEntity.getFireCode());
if (existFireCode != null) {
return null;
}
log.info("-------发现新火点");
return firePointDao.save(firePointEntity);
}
/**
* 返回开关是否为打开状态
*
* @return true已打开false已关闭
*/
private boolean isSwitchStateOpen() {
List<SettingEntity> settingEntityList = settingDao.findAll();
if (settingEntityList.isEmpty()) {
return false;
}
SettingEntity settingEntity = settingEntityList.get(0);
return "1".equals(settingEntity.getSwitchState());
}
/**
* 保存到山东火点表
*/
private FirePointEntity saveToShanDongFirePoint(FirePointEntity firePointEntity) {
ShanDongFirePointEntity existFireCode = shanDongFirePointDao.findByFireCode(firePointEntity.getFireCode());
if (existFireCode != null) {
return null;
}
ShanDongFirePointEntity shanDongFirePointEntity = new ShanDongFirePointEntity();
shanDongFirePointEntity.setFireCode(firePointEntity.getFireCode());
shanDongFirePointEntity.setCountyCode(firePointEntity.getCountyCode());
shanDongFirePointEntity.setCountyName(firePointEntity.getCountyName());
shanDongFirePointEntity.setSatelliteTime(firePointEntity.getSatelliteTime());
shanDongFirePointEntity.setLongitude(firePointEntity.getLongitude());
shanDongFirePointEntity.setLatitude(firePointEntity.getLatitude());
shanDongFirePointEntity.setFirePointAddress(firePointEntity.getFirePointAddress());
shanDongFirePointEntity.setSatelliteType(firePointEntity.getSatelliteType());
shanDongFirePointEntity.setLandType(firePointEntity.getLandType());
shanDongFirePointEntity.setConfidence(firePointEntity.getConfidence());
shanDongFirePointEntity.setAddTime(firePointEntity.getAddTime());
shanDongFirePointEntity.setFireType(firePointEntity.getFireType());
shanDongFirePointEntity.setFireImage(firePointEntity.getFireImage());
shanDongFirePointEntity.setSatelliteImage(firePointEntity.getSatelliteImage());
shanDongFirePointEntity.setStreetCode(firePointEntity.getStreetCode());
shanDongFirePointEntity.setStreetName(firePointEntity.getStreetName());
shanDongFirePointEntity.setVerifyState("0");
log.info("-------发现山东新火点");
shanDongFirePointDao.save(shanDongFirePointEntity);
return new FirePointEntity();
}
/**
* 为实体类设置街道编号和街道名称
*/
private void bindStreetCodeName(FirePointEntity firePointEntity) throws Exception {
List<String> locationList = new ArrayList<>();
locationList.add(firePointEntity.getLongitude() + "," + firePointEntity.getLatitude());
@ -139,7 +198,6 @@ public class FirePointServiceImpl implements FirePointService {
}
}
/**
* 查询今天的火点信息
*/