tevin 2 months ago
parent
commit
0cf52f607d

+ 0 - 1
src/main/java/com/shanghaichengdi/schedule/PollutionWarningSchedule.java

@@ -20,7 +20,6 @@ public class PollutionWarningSchedule {
 
     @Scheduled(fixedRate = 10 * 60 * 1000)
     public void ShortBarge() {
-        System.out.println(System.currentTimeMillis());
         boatPollutionWarningService.handleShortBarge();
     }
 

+ 37 - 17
src/main/java/com/shanghaichengdi/service/impl/BoatPollutionWarningServiceImpl.java

@@ -118,23 +118,6 @@ public class BoatPollutionWarningServiceImpl extends ServiceImpl<BoatPollutionWa
             List<CCbShipEepReportRec> ccbShipEepReportRecList = ccbShipEepReportRecService.list(cCbShipEepReportRecLambdaQueryWrapper);
             if (!bpsList.isEmpty()) {
                 BoatPollutionSupervision bps = bpsList.get(0);
-                //查询排放物
-                LambdaQueryWrapper<BoatWaterPollutantAcceptF> boatWaterPollutantAcceptFLambdaQueryWrapper = new LambdaQueryWrapper<>();
-                if (v.get(0).getShipName() != null) {
-                    boatWaterPollutantAcceptFLambdaQueryWrapper.eq(BoatWaterPollutantAcceptF::getMmsi, v.get(0).getDeviceId())
-                            .eq(BoatWaterPollutantAcceptF::getShipName, v.get(0).getShipName())
-                            .eq(BoatWaterPollutantAcceptF::getSewageType, SewageTypeEnum.SEWAGE.getType())
-                            .ge(BoatWaterPollutantAcceptF::getFirstDtm, bps.getStartTime())
-                            .le(BoatWaterPollutantAcceptF::getFirstDtm, bps.getPredictwarnSwTime().isAfter(gpsTime) ? gpsTime : bps.getPredictwarnSwTime())
-                            .orderByDesc(BoatWaterPollutantAcceptF::getFirstDtm);
-                } else {
-                    boatWaterPollutantAcceptFLambdaQueryWrapper.eq(BoatWaterPollutantAcceptF::getMmsi, v.get(0).getDeviceId())
-                            .eq(BoatWaterPollutantAcceptF::getSewageType, SewageTypeEnum.SEWAGE.getType())
-                            .ge(BoatWaterPollutantAcceptF::getFirstDtm, bps.getStartTime())
-                            .le(BoatWaterPollutantAcceptF::getFirstDtm, bps.getPredictwarnSwTime().isAfter(gpsTime) ? gpsTime : bps.getPredictwarnSwTime())
-                            .orderByDesc(BoatWaterPollutantAcceptF::getFirstDtm);
-                }
-                List<BoatWaterPollutantAcceptF> boatWaterPollutantAcceptFList = boatWaterPollutantAcceptFService.list(boatWaterPollutantAcceptFLambdaQueryWrapper);
                 if (bps.getHasWarning().equals(HasWarningEnum.HAS.getStatusCode())) {
                     //有预警
                     log.info("==========BoatPollutionWarningServiceImpl.handleShortBarge.Warning.start==========");
@@ -149,6 +132,23 @@ public class BoatPollutionWarningServiceImpl extends ServiceImpl<BoatPollutionWa
                             this.remove(new QueryWrapper<BoatPollutionWarning>().lambda().eq(BoatPollutionWarning::getCode, boatPollutionWarning.getCode()));
                         }
                     } else if (boatPollutionWarning.getFilterState().equals(FilterStateEnum.CONFIRM.getStatusCode())) {
+                        //查询排放物
+                        LambdaQueryWrapper<BoatWaterPollutantAcceptF> boatWaterPollutantAcceptFLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                        if (v.get(0).getShipName() != null) {
+                            boatWaterPollutantAcceptFLambdaQueryWrapper.eq(BoatWaterPollutantAcceptF::getMmsi, v.get(0).getDeviceId())
+                                    .eq(BoatWaterPollutantAcceptF::getShipName, v.get(0).getShipName())
+                                    .eq(BoatWaterPollutantAcceptF::getSewageType, SewageTypeEnum.SEWAGE.getType())
+                                    .ge(BoatWaterPollutantAcceptF::getFirstDtm, bps.getStartTime())
+                                    .le(BoatWaterPollutantAcceptF::getFirstDtm, boatPollutionWarning.getWarningTime().plusDays(5).isAfter(gpsTime) ? gpsTime : boatPollutionWarning.getWarningTime().plusDays(5))
+                                    .orderByDesc(BoatWaterPollutantAcceptF::getFirstDtm);
+                        } else {
+                            boatWaterPollutantAcceptFLambdaQueryWrapper.eq(BoatWaterPollutantAcceptF::getMmsi, v.get(0).getDeviceId())
+                                    .eq(BoatWaterPollutantAcceptF::getSewageType, SewageTypeEnum.SEWAGE.getType())
+                                    .ge(BoatWaterPollutantAcceptF::getFirstDtm, bps.getStartTime())
+                                    .le(BoatWaterPollutantAcceptF::getFirstDtm, boatPollutionWarning.getWarningTime().plusDays(5).isAfter(gpsTime) ? gpsTime : boatPollutionWarning.getWarningTime().plusDays(5))
+                                    .orderByDesc(BoatWaterPollutantAcceptF::getFirstDtm);
+                        }
+                        List<BoatWaterPollutantAcceptF> boatWaterPollutantAcceptFList = boatWaterPollutantAcceptFService.list(boatWaterPollutantAcceptFLambdaQueryWrapper);
                         if (gpsTime.isAfter(boatPollutionWarning.getWarningTime().plusDays(5))) {
                             if (!boatWaterPollutantAcceptFList.isEmpty()) {
                                 log.info("==========BoatPollutionWarningServiceImpl.handleShortBarge.Warning.overBoatPollutionWarning.releive.Y5.pollutant_release==========");
@@ -209,6 +209,23 @@ public class BoatPollutionWarningServiceImpl extends ServiceImpl<BoatPollutionWa
                 } else {
                     //无预警
                     log.info("==========BoatPollutionWarningServiceImpl.handleShortBarge.noneWarning.start==========");
+                    //查询排放物
+                    LambdaQueryWrapper<BoatWaterPollutantAcceptF> boatWaterPollutantAcceptFLambdaQueryWrapper = new LambdaQueryWrapper<>();
+                    if (v.get(0).getShipName() != null) {
+                        boatWaterPollutantAcceptFLambdaQueryWrapper.eq(BoatWaterPollutantAcceptF::getMmsi, v.get(0).getDeviceId())
+                                .eq(BoatWaterPollutantAcceptF::getShipName, v.get(0).getShipName())
+                                .eq(BoatWaterPollutantAcceptF::getSewageType, SewageTypeEnum.SEWAGE.getType())
+                                .ge(BoatWaterPollutantAcceptF::getFirstDtm, bps.getStartTime())
+                                .le(BoatWaterPollutantAcceptF::getFirstDtm, bps.getPredictwarnSwTime().isAfter(gpsTime) ? gpsTime : bps.getPredictwarnSwTime())
+                                .orderByDesc(BoatWaterPollutantAcceptF::getFirstDtm);
+                    } else {
+                        boatWaterPollutantAcceptFLambdaQueryWrapper.eq(BoatWaterPollutantAcceptF::getMmsi, v.get(0).getDeviceId())
+                                .eq(BoatWaterPollutantAcceptF::getSewageType, SewageTypeEnum.SEWAGE.getType())
+                                .ge(BoatWaterPollutantAcceptF::getFirstDtm, bps.getStartTime())
+                                .le(BoatWaterPollutantAcceptF::getFirstDtm, bps.getPredictwarnSwTime().isAfter(gpsTime) ? gpsTime : bps.getPredictwarnSwTime())
+                                .orderByDesc(BoatWaterPollutantAcceptF::getFirstDtm);
+                    }
+                    List<BoatWaterPollutantAcceptF> boatWaterPollutantAcceptFList = boatWaterPollutantAcceptFService.list(boatWaterPollutantAcceptFLambdaQueryWrapper);
                     //查询是否到监控周期内的第五天
                     if (gpsTime.isAfter(bps.getStartTime().plusDays(5))) {
                         //是否有排放记录
@@ -475,6 +492,7 @@ public class BoatPollutionWarningServiceImpl extends ServiceImpl<BoatPollutionWa
                     }
                 }
             } else {
+                //无预警
                 //查询近三次AIS中是否有一个点在围栏内
                 boolean isIn = false;
                 LocalDateTime inTime = null;
@@ -498,11 +516,13 @@ public class BoatPollutionWarningServiceImpl extends ServiceImpl<BoatPollutionWa
                         cCbShipEepReportRecLambdaQueryWrapper.eq(CCbShipEepReportRec::getMmsi, v.get(0).getDeviceId())
                                 .between(CCbShipEepReportRec::getReportTime, inTime.minusDays(1), inTime)
                                 .eq(CCbShipEepReportRec::getArrivalOrLeave, ArrivalOrLeaveEnum.ARRIVAL.getStatusCode())
+                                .likeRight(CCbShipEepReportRec::getOrgCode, "29")
                                 .orderByDesc(CCbShipEepReportRec::getReportTime);
                     } else if (v.get(0).getShipName() != null) {
                         cCbShipEepReportRecLambdaQueryWrapper.eq(CCbShipEepReportRec::getShipNameCn, v.get(0).getShipName())
                                 .between(CCbShipEepReportRec::getReportTime, inTime.minusDays(1), inTime)
                                 .eq(CCbShipEepReportRec::getArrivalOrLeave, ArrivalOrLeaveEnum.ARRIVAL.getStatusCode())
+                                .likeRight(CCbShipEepReportRec::getOrgCode, "29")
                                 .orderByDesc(CCbShipEepReportRec::getReportTime);
                     }
                     List<CCbShipEepReportRec> ccbShipEepReportRecList = ccbShipEepReportRecService.list(cCbShipEepReportRecLambdaQueryWrapper);