优化火点入库

This commit is contained in:
liuchengqian 2022-08-23 11:06:30 +08:00
parent ddac4c7b22
commit d2ba8cc959
3 changed files with 34 additions and 41 deletions

View File

@ -87,11 +87,11 @@ public class FirePointController {
*/
@PostMapping("/insertFirePoint")
public String insertFirePoint(@RequestBody FirePointQo firePointQo) {
FirePointEntity firePointEntity = firePointService.insertFirePoint(firePointQo);
if (firePointEntity == null) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加数据失败", locale);
} else {
boolean success = firePointService.insertFirePoint(firePointQo);
if (success) {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
} else {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加失败", locale);
}
}
@ -103,11 +103,11 @@ public class FirePointController {
*/
@PostMapping("/insertfirepointchanneltwo")
public String insertFirePointChannelTwo(@RequestBody FirePointQo firePointQo) {
ShanDongFirePointEntity firePointEntity = firePointService.insertFirePointChannelTwo(firePointQo);
if (firePointEntity == null) {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加数据失败", locale);
} else {
boolean success = firePointService.insertFirePointChannelTwo(firePointQo);
if (success) {
return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "添加成功", locale);
} else {
return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL, "添加失败", locale);
}
}

View File

@ -22,7 +22,7 @@ public interface FirePointService {
* @param firePointQo
* @return
*/
FirePointEntity insertFirePoint(FirePointQo firePointQo);
boolean insertFirePoint(FirePointQo firePointQo);
/**
* 添加火点信息
@ -30,7 +30,7 @@ public interface FirePointService {
* @param firePointQo
* @return
*/
ShanDongFirePointEntity insertFirePointChannelTwo(FirePointQo firePointQo);
boolean insertFirePointChannelTwo(FirePointQo firePointQo);
/**
* 查询今天的火点信息

View File

@ -95,21 +95,17 @@ public class FirePointServiceImpl implements FirePointService {
/**
* 添加火点信息
*
* @param firePointQo
* @return
*/
@CacheEvict(value = "FirePointServiceCache", allEntries = true)
@Override
public FirePointEntity insertFirePoint(FirePointQo firePointQo) {
if (firePointQo.getLandtype().equals("水体")) {
return null;
public boolean insertFirePoint(FirePointQo firePointQo) {
if ("水体".equals(firePointQo.getLandtype())) {
return false;
}
if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())) {
return null;
if ("Himawari 8".equals(firePointQo.getSatelliteType())) {
if ("N".equals(firePointQo.getConfidence()) || "L".equals(firePointQo.getConfidence())) {
return false;
}
if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())) {
return null;
}
FirePointEntity firePointEntity = new FirePointEntity();
firePointEntity.setFireCode(firePointQo.getFireCode());
@ -133,33 +129,30 @@ public class FirePointServiceImpl implements FirePointService {
System.out.println("添加火点信息 逆地理编码请求街道编号失败:" + e.getMessage());
}
if (firePointEntity.getCountyCode().startsWith("37")) {
return null;
return false;
}
FirePointEntity existFireCode = firePointDao.findByFireCode(firePointEntity.getFireCode());
if (existFireCode != null) {
return null;
return false;
}
log.info("-------发现新火点");
return firePointDao.save(firePointEntity);
firePointDao.save(firePointEntity);
return true;
}
/**
* 添加火点信息
*
* @param firePointQo
* @return
*/
@CacheEvict(value = "FirePointServiceCache", allEntries = true)
@Override
public ShanDongFirePointEntity insertFirePointChannelTwo(FirePointQo firePointQo) {
if (firePointQo.getLandtype().equals("水体")) {
return null;
public boolean insertFirePointChannelTwo(FirePointQo firePointQo) {
if ("水体".equals(firePointQo.getLandtype())) {
return false;
}
if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "L".equals(firePointQo.getConfidence())) {
return null;
if ("Himawari 8".equals(firePointQo.getSatelliteType())) {
if ("N".equals(firePointQo.getConfidence()) || "L".equals(firePointQo.getConfidence())) {
return false;
}
if ("Himawari 8".equals(firePointQo.getSatelliteType()) && "N".equals(firePointQo.getConfidence())) {
return null;
}
ShanDongFirePointEntity shanDongFirePoint = new ShanDongFirePointEntity();
shanDongFirePoint.setFireCode(firePointQo.getFireCode());
@ -188,7 +181,7 @@ public class FirePointServiceImpl implements FirePointService {
//如果开关已打开就只将未审核的火点添加到山东临时表
if (shanDongFirePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) {
//山东临时表已经有编号相同的火点存在返回添加失败
return null;
return false;
}
log.info("-------发现新山东火点");
ShanDongFirePointEntity savedShanDongFirePoint = shanDongFirePointDao.save(shanDongFirePoint);
@ -198,16 +191,16 @@ public class FirePointServiceImpl implements FirePointService {
} catch (Exception e) {
e.printStackTrace();
}
return savedShanDongFirePoint;
return true;
} else {
//如果开关已关闭就将火点添加到山东临时表同时自动审核通过添加到全国火点表
if (shanDongFirePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) {
//山东临时表已经有编号相同的火点存在返回添加失败
return null;
return false;
}
if (firePointDao.findByFireCode(shanDongFirePoint.getFireCode()) != null) {
//全国火点表已经有编号相同的火点存在返回添加失败
return null;
return false;
}
log.info("-------发现新火点");
shanDongFirePoint.setVerifyState("1");
@ -218,10 +211,10 @@ public class FirePointServiceImpl implements FirePointService {
firePointDao.save(firePoint);
//发送消息通知
sendBroadcast(firePoint);
return savedShanDongFirePoint;
return true;
}
}
return null;
return false;
}
/**