优化火点入库

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

View File

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