优化火点入库-去除重复数据
This commit is contained in:
parent
d2ba8cc959
commit
aed56cd96d
@ -22,6 +22,9 @@ public interface FirePointDao extends JpaRepository<FirePointEntity, Long>, JpaS
|
|||||||
*/
|
*/
|
||||||
FirePointEntity findByFireCode(String fireCode);
|
FirePointEntity findByFireCode(String fireCode);
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM fire_point WHERE longitude = ?1 AND latitude = ?2 AND street_code = ?3 AND satellite_time = ?4 AND satellite_type = ?5 AND land_type = ?6", nativeQuery = true)
|
||||||
|
List<FirePointEntity> findDuplicatedData(double longitude, double latitude, String streetCode, String satelliteTime, String satelliteType, String landType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据火点编码修改火点状态
|
* 根据火点编码修改火点状态
|
||||||
*/
|
*/
|
||||||
|
@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Modifying;
|
|||||||
import org.springframework.data.jpa.repository.Query;
|
import org.springframework.data.jpa.repository.Query;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public interface ShanDongFirePointDao extends JpaRepository<ShanDongFirePointEntity, Long>, JpaSpecificationExecutor<ShanDongFirePointEntity> {
|
public interface ShanDongFirePointDao extends JpaRepository<ShanDongFirePointEntity, Long>, JpaSpecificationExecutor<ShanDongFirePointEntity> {
|
||||||
|
|
||||||
@ -18,6 +20,9 @@ public interface ShanDongFirePointDao extends JpaRepository<ShanDongFirePointEnt
|
|||||||
*/
|
*/
|
||||||
ShanDongFirePointEntity findByFireCode(String fireCode);
|
ShanDongFirePointEntity findByFireCode(String fireCode);
|
||||||
|
|
||||||
|
@Query(value = "SELECT * FROM fire_point_shandong WHERE longitude = ?1 AND latitude = ?2 AND street_code = ?3 AND satellite_time = ?4 AND satellite_type = ?5 AND land_type = ?6", nativeQuery = true)
|
||||||
|
List<ShanDongFirePointEntity> findDuplicatedData(double longitude, double latitude, String streetCode, String satelliteTime, String satelliteType, String landType);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 在山东临时火点表中根据火点编码修改审核状态
|
* 在山东临时火点表中根据火点编码修改审核状态
|
||||||
*/
|
*/
|
||||||
|
@ -126,13 +126,13 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
bindAddress(firePointEntity);
|
bindAddress(firePointEntity);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
|
log.info("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (firePointEntity.getCountyCode().startsWith("37")) {
|
if (firePointEntity.getCountyCode().startsWith("37")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FirePointEntity existFireCode = firePointDao.findByFireCode(firePointEntity.getFireCode());
|
if (checkDuplicatedData(firePointEntity)) {
|
||||||
if (existFireCode != null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
log.info("-------发现新火点");
|
log.info("-------发现新火点");
|
||||||
@ -140,6 +140,39 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查重复数据
|
||||||
|
*
|
||||||
|
* @param firePointEntity 待入库实体类
|
||||||
|
* @return true-是重复数据,拒绝入库;false-不是重复数据,可以入库
|
||||||
|
*/
|
||||||
|
private boolean checkDuplicatedData(FirePointEntity firePointEntity) {
|
||||||
|
List<FirePointEntity> duplicatedDataList = firePointDao.findDuplicatedData(firePointEntity.getLongitude(), firePointEntity.getLatitude(), firePointEntity.getStreetCode(), firePointEntity.getSatelliteTime(), firePointEntity.getSatelliteType(), firePointEntity.getLandType());
|
||||||
|
return duplicatedDataList != null && duplicatedDataList.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查重复数据
|
||||||
|
*
|
||||||
|
* @param shanDongFirePoint 待入库实体类
|
||||||
|
* @return true-是重复数据,拒绝入库;false-不是重复数据,可以入库
|
||||||
|
*/
|
||||||
|
private boolean checkDuplicatedDataX(ShanDongFirePointEntity shanDongFirePoint) {
|
||||||
|
List<FirePointEntity> duplicatedDataList = firePointDao.findDuplicatedData(shanDongFirePoint.getLongitude(), shanDongFirePoint.getLatitude(), shanDongFirePoint.getStreetCode(), shanDongFirePoint.getSatelliteTime(), shanDongFirePoint.getSatelliteType(), shanDongFirePoint.getLandType());
|
||||||
|
return duplicatedDataList != null && duplicatedDataList.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查重复数据
|
||||||
|
*
|
||||||
|
* @param shanDongFirePoint 待入库实体类
|
||||||
|
* @return true-是重复数据,拒绝入库;false-不是重复数据,可以入库
|
||||||
|
*/
|
||||||
|
private boolean checkDuplicatedData(ShanDongFirePointEntity shanDongFirePoint) {
|
||||||
|
List<ShanDongFirePointEntity> duplicatedDataList = shanDongFirePointDao.findDuplicatedData(shanDongFirePoint.getLongitude(), shanDongFirePoint.getLatitude(), shanDongFirePoint.getStreetCode(), shanDongFirePoint.getSatelliteTime(), shanDongFirePoint.getSatelliteType(), shanDongFirePoint.getLandType());
|
||||||
|
return duplicatedDataList != null && duplicatedDataList.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加火点信息
|
* 添加火点信息
|
||||||
*/
|
*/
|
||||||
@ -175,17 +208,17 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("添加山东火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
|
System.out.println("添加山东火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
|
||||||
}
|
}
|
||||||
|
if (checkDuplicatedDataX(shanDongFirePoint) || checkDuplicatedData(shanDongFirePoint)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
//如果是山东的点,就入库
|
//如果是山东的点,就入库
|
||||||
if (shanDongFirePoint.getCountyCode().startsWith("37")) {
|
if (shanDongFirePoint.getCountyCode().startsWith("37")) {
|
||||||
if (isSwitchStateOpen()) {
|
if (isSwitchStateOpen()) {
|
||||||
//如果开关已打开,就只将未审核的火点添加到山东临时表
|
//如果开关已打开,就只将未审核的火点添加到山东临时表
|
||||||
if (shanDongFirePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) {
|
|
||||||
//山东临时表已经有编号相同的火点存在,返回添加失败
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
log.info("-------发现新山东火点");
|
log.info("-------发现新山东火点");
|
||||||
ShanDongFirePointEntity savedShanDongFirePoint = shanDongFirePointDao.save(shanDongFirePoint);
|
ShanDongFirePointEntity savedShanDongFirePoint = shanDongFirePointDao.save(shanDongFirePoint);
|
||||||
try {//微信消息通知火点审核工作组
|
//微信消息通知火点审核工作组
|
||||||
|
try {
|
||||||
String messageContent = getMessageContent(savedShanDongFirePoint);
|
String messageContent = getMessageContent(savedShanDongFirePoint);
|
||||||
WDWxSendMsgUtil.sendMsg("18447024917@chatroom", messageContent, 0);
|
WDWxSendMsgUtil.sendMsg("18447024917@chatroom", messageContent, 0);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -194,18 +227,9 @@ public class FirePointServiceImpl implements FirePointService {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
//如果开关已关闭,就将火点添加到山东临时表,同时自动审核通过添加到全国火点表
|
//如果开关已关闭,就将火点添加到山东临时表,同时自动审核通过添加到全国火点表
|
||||||
if (shanDongFirePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) {
|
|
||||||
//山东临时表已经有编号相同的火点存在,返回添加失败
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (firePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) {
|
|
||||||
//全国火点表已经有编号相同的火点存在,返回添加失败
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
log.info("-------发现新火点");
|
log.info("-------发现新火点");
|
||||||
shanDongFirePoint.setVerifyState("1");
|
shanDongFirePoint.setVerifyState("1");
|
||||||
ShanDongFirePointEntity savedShanDongFirePoint = shanDongFirePointDao.save(shanDongFirePoint);
|
shanDongFirePointDao.save(shanDongFirePoint);
|
||||||
|
|
||||||
FirePointEntity firePoint = getFirePointByShanDongFirePoint(shanDongFirePoint);
|
FirePointEntity firePoint = getFirePointByShanDongFirePoint(shanDongFirePoint);
|
||||||
log.info("-------转存新火点");
|
log.info("-------转存新火点");
|
||||||
firePointDao.save(firePoint);
|
firePointDao.save(firePoint);
|
||||||
|
Loading…
Reference in New Issue
Block a user