Browse Source

提交修改

zk 3 days ago
parent
commit
fe24bd4761

+ 4 - 4
src/main/java/com/shcd/boat/entity/AISInChannel.java

@@ -6,9 +6,9 @@ import lombok.Data;
 public class AISInChannel {
 
     //赵家沟
-    private  String  zhaojiagou;
+    private  Boolean  zhaojiagou;
     //浦东运河(赵家沟-川杨河)
-    private  String  pudongyunhe;
-    private  String  zhaojiagoudong;
-    private  String  chuangyanghe;
+    private  Boolean  pudongyunhe;
+    private  Boolean  zhaojiagoudong;
+    private  Boolean  chuangyanghe;
 }

+ 2 - 1
src/main/java/com/shcd/boat/entity/BoatInfoEntity.java

@@ -32,13 +32,14 @@ public class BoatInfoEntity {
     private int pointWarningNum;
 
     //是否已生成预警
-    private boolean isWarning ;
+    private Boolean isWarning ;
 
     //首次进入时间
     @JSONField(format = "yyyy-MM-dd HH:mm:ss")
     private Date beginTime ;
 
     private String lastAisTime ;
+
     //初始进入航道 或所属航道
     private String inChannel;
 

+ 37 - 36
src/main/java/com/shcd/boat/service/impl/ShipSealOffServiceImpl.java

@@ -192,18 +192,18 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
         AISInChannel aisInChannel= shipSealOffSpaceMapper.getInChannel(thisAisPoint);
         if(aisInChannel!=null)
         {
-             if (!StringUtils.isEmpty(aisInChannel.getChuangyanghe()))
+             if (aisInChannel.getChuangyanghe())
              {
                  return "川杨河";
-             }else if (!StringUtils.isEmpty(aisInChannel.getPudongyunhe()))
+             }else if (aisInChannel.getPudongyunhe())
              {
                  return "浦东运河(赵家沟-川杨河)";
              }
-             else if (!StringUtils.isEmpty(aisInChannel.getZhaojiagoudong()))
+             else if (aisInChannel.getZhaojiagoudong())
              {
                  return "赵家沟东段";
              }
-             else if (!StringUtils.isEmpty(aisInChannel.getZhaojiagou()))
+             else if (aisInChannel.getZhaojiagou())
              {
                  return "赵家沟";
              }
@@ -234,7 +234,7 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
                 if (redisData.getLastAisTime().hashCode() != thisGpsTime.hashCode())  //只处理时间不同的
                 {
                     //没产生过预警,且已经有一个船速大于1的点位  需要产生预警
-                      if (!redisData.isWarning() && redisData.getPointNum() > 1 && thisAisPoint.getVelocity().compareTo(new BigDecimal("1")) > 0) {
+                      if (!redisData.getIsWarning() && redisData.getPointWarningNum() > 2 && thisAisPoint.getVelocity().compareTo(new BigDecimal("1")) > 0) {
                                     ShipSealOffInfo info = new ShipSealOffInfo();
                                     info.setSealId(redisData.getId());
                                     info.setMmsi(i);
@@ -277,34 +277,35 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
                                       sealOffPoints1.setPointJson(JSON.toJSONString(thisAisPoint));
                                       sealOffPoints1.setPointGeom(thisAisPoint.getMapx().toString() + " " + thisAisPoint.getMapy().toString());
                                       sealOffPoints.add(sealOffPoints1);
+
                                 }
                       else {  //全部记录定位 并更新状态
-                                            if (redisData.isWarning()) {
-                                                ShipSealOffInfo info = new ShipSealOffInfo();
-                                                info.setSealId(redisData.getId());
-                                                info.setMmsi(i);
-                                                info.setWarningVerifyStatus("待核实");
-                                                if (thisAisPoint.getVelocity().compareTo(new BigDecimal("1")) > 0) {
-                                                    info.setWarningStatus("航行中");
-                                                    redisData.setCunState("航行中");
-                                                } else {
-                                                    info.setWarningStatus("已停舶");
-                                                    redisData.setCunState("已停舶");
-                                                }
-                                                info.getWarningStatus();
-                                                updateNeedList.add(info);
-                                                //需增加本次的点位
-                                                ShipSealOffPoints sealOffPoints1 = new ShipSealOffPoints();
-                                                sealOffPoints1.setId(snowflakeConfig.snowflakeStringId());
-                                                sealOffPoints1.setMmsi(i);
-                                                sealOffPoints1.setShipName(thisAisPoint.getBoatName());
-                                                sealOffPoints1.setSourceType("市港航AIS");
-                                                sealOffPoints1.setSealId(redisData.getId());
-                                                sealOffPoints1.setAisTime(thisAisPoint.getGpsTime());
-                                                sealOffPoints1.setPointJson(JSON.toJSONString(thisAisPoint));
-                                                sealOffPoints1.setPointGeom(thisAisPoint.getMapx().toString() + " " + thisAisPoint.getMapy().toString());
-                                                sealOffPoints.add(sealOffPoints1);
-                                            }
+                            if (redisData.getIsWarning()) {
+                                ShipSealOffInfo info = new ShipSealOffInfo();
+                                info.setSealId(redisData.getId());
+                                info.setMmsi(i);
+                                info.setWarningVerifyStatus("待核实");
+                                if (thisAisPoint.getVelocity().compareTo(new BigDecimal("1")) > 0) {
+                                    info.setWarningStatus("航行中");
+                                    redisData.setCunState("航行中");
+                                } else {
+                                    info.setWarningStatus("已停舶");
+                                    redisData.setCunState("已停舶");
+                                }
+                                info.getWarningStatus();
+                                updateNeedList.add(info);
+                                //需增加本次的点位
+                                ShipSealOffPoints sealOffPoints1 = new ShipSealOffPoints();
+                                sealOffPoints1.setId(snowflakeConfig.snowflakeStringId());
+                                sealOffPoints1.setMmsi(i);
+                                sealOffPoints1.setShipName(thisAisPoint.getBoatName());
+                                sealOffPoints1.setSourceType("市港航AIS");
+                                sealOffPoints1.setSealId(redisData.getId());
+                                sealOffPoints1.setAisTime(thisAisPoint.getGpsTime());
+                                sealOffPoints1.setPointJson(JSON.toJSONString(thisAisPoint));
+                                sealOffPoints1.setPointGeom(thisAisPoint.getMapx().toString() + " " + thisAisPoint.getMapy().toString());
+                                sealOffPoints.add(sealOffPoints1);
+                            }
                       }
                       if (thisAisPoint.getVelocity().compareTo(new BigDecimal("1")) > 0) {
                            int currNum= redisData.getPointWarningNum();
@@ -328,9 +329,7 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
                         thisAis.setId(id);
                         thisAis.setPointNum(1);
                         thisAis.setBeginTime(thisAisPoint.getGpsTime());
-                        if (thisAisPoint.getVelocity().compareTo(new BigDecimal("1")) > 0) {
-                            thisAis.setPointWarningNum(1);
-                        }
+                        thisAis.setPointWarningNum(1);
                         //设置初始航道
                         thisAis.setInChannel(getInChannelForThisAIS(thisAisPoint));
                         List<GHAisInfo> aisInfos = new ArrayList<>();
@@ -387,15 +386,17 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
 
             }
         }
+
         if (insertNeedList!=null && insertNeedList.size()>0) {
             log.info("==  3.2 其中船速大于1连续两个点需要预警的有:"+insertNeedList.size()+"个:"+insertNeedList.toString());
             shipSealOffInfoService.saveBatch(insertNeedList);
           List<String> strings=  insertNeedList.stream().map(ShipSealOffInfo::getMmsi).collect(Collectors.toList());
+            log.info("==  3.2.1  调整缓存点为已预警:"+strings.toString());
             strings.stream().forEach(i->{
                 Object result = redisUtilTemplate.get(i);
                 if (!ObjectUtils.isEmpty(result)) {
                     BoatInfoEntity redisData = JSON.parseObject((String) result, BoatInfoEntity.class);
-                    redisData.setWarning(true);
+                    redisData.setIsWarning(true);
                     String dtoJSON = JSON.toJSONString(redisData);
                     // 将JSON字符串存入Redis
                     redisUtilTemplate.set(i, dtoJSON);
@@ -404,7 +405,7 @@ public class ShipSealOffServiceImpl implements ShipSealOffService {
         }
         if (updateNeedList!=null && updateNeedList.size()>0) {
             log.info("==  3.3 其中需要更新船舶:"+updateNeedList.size()+"个:"+updateNeedList.toString());
-            shipSealOffInfoService.saveOrUpdateBatch(updateNeedList);
+            shipSealOffInfoService.updateBatchById(updateNeedList);
         }
         if (sealOffPoints!=null && sealOffPoints.size()>0) {
             log.info("==  3.4 本次新增点位:"+sealOffPoints.size()+"个:"+sealOffPoints.toString());

+ 195 - 0
src/main/resources/logback.xml

@@ -0,0 +1,195 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
+<!-- scan:当此属性设置为true时,配置文档如果发生改变,将会被重新加载,默认值为true -->
+<!-- scanPeriod:设置监测配置文档是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。
+                 当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
+<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
+<configuration  scan="true" scanPeriod="10 seconds">
+    <contextName>logback</contextName>
+
+    <!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义后,可以使“${}”来使用变量。 -->
+    <property name="log.path" value="./logFiles" />
+
+    <!--0. 日志格式和颜色渲染 -->
+    <!-- 彩色日志依赖的渲染类 -->
+    <conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
+    <conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
+    <conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
+    <!-- 彩色日志格式 -->
+    <property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
+
+    <!--1. 输出到控制台-->
+    <appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
+        <!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
+        <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
+            <level>debug</level>
+        </filter>
+        <encoder>
+            <Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
+            <!-- 设置字符集 -->
+            <charset>UTF-8</charset>
+        </encoder>
+    </appender>
+
+    <!--2. 输出到文档-->
+    <!-- 2.1 level为 DEBUG 日志,时间滚动输出  -->
+    <appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 正在记录的日志文档的路径及文档名 -->
+        <file>${log.path}/web_debug.log</file>
+        <!--日志文档输出格式-->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+            <charset>UTF-8</charset> <!-- 设置字符集 -->
+        </encoder>
+        <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 日志归档 -->
+            <fileNamePattern>${log.path}/web-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>100MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+            <!--日志文档保留天数-->
+            <maxHistory>5</maxHistory>
+        </rollingPolicy>
+        <!-- 此日志文档只记录debug级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>debug</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 2.2 level为 INFO 日志,时间滚动输出  -->
+    <appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 正在记录的日志文档的路径及文档名 -->
+        <file>${log.path}/web_info.log</file>
+        <!--日志文档输出格式-->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+            <charset>UTF-8</charset>
+        </encoder>
+        <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!-- 每天日志归档路径以及格式 -->
+            <fileNamePattern>${log.path}/web-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>100MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+            <!--日志文档保留天数-->
+            <maxHistory>10</maxHistory>
+        </rollingPolicy>
+        <!-- 此日志文档只记录info级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>info</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 2.3 level为 WARN 日志,时间滚动输出  -->
+    <appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 正在记录的日志文档的路径及文档名 -->
+        <file>${log.path}/web_warn.log</file>
+        <!--日志文档输出格式-->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+            <charset>UTF-8</charset> <!-- 此处设置字符集 -->
+        </encoder>
+        <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${log.path}/web-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>100MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+            <!--日志文档保留天数-->
+            <maxHistory>5</maxHistory>
+        </rollingPolicy>
+        <!-- 此日志文档只记录warn级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>warn</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <!-- 2.4 level为 ERROR 日志,时间滚动输出  -->
+    <appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!-- 正在记录的日志文档的路径及文档名 -->
+        <file>${log.path}/web_error.log</file>
+        <!--日志文档输出格式-->
+        <encoder>
+            <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
+            <charset>UTF-8</charset> <!-- 此处设置字符集 -->
+        </encoder>
+        <!-- 日志记录器的滚动策略,按日期,按大小记录 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <fileNamePattern>${log.path}/web-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
+            <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
+                <maxFileSize>100MB</maxFileSize>
+            </timeBasedFileNamingAndTriggeringPolicy>
+            <!--日志文档保留天数-->
+            <maxHistory>5</maxHistory>
+        </rollingPolicy>
+        <!-- 此日志文档只记录ERROR级别的 -->
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>ERROR</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>DENY</onMismatch>
+        </filter>
+    </appender>
+
+    <logger name="com.InterfaceServices.mapper" level="DEBUG" />
+
+    <!--
+        <logger>用来设置某一个包或者具体的某一个类的日志打印级别、
+        以及指定<appender>。<logger>仅有一个name属性,
+        一个可选的level和一个可选的addtivity属性。
+        name:用来指定受此logger约束的某一个包或者具体的某一个类。
+        level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
+              还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。
+              如果未设置此属性,那么当前logger将会继承上级的级别。
+        addtivity:是否向上级logger传递打印信息。默认是true。
+        <logger name="org.springframework.web" level="info"/>
+        <logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>
+    -->
+
+    <!--
+        使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作:
+        第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息
+        第二种就是单独给dao下目录配置debug模式,代码如下,这样配置sql语句会打印,其他还是正常info级别:
+        【logging.level.org.mybatis=debug logging.level.dao=debug】
+     -->
+
+    <!--
+        root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性
+        level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
+        不能设置为INHERITED或者同义词NULL。默认是DEBUG
+        可以包含零个或多个元素,标识这个appender将会添加到这个logger。
+    -->
+
+    <!-- 4. 最终的策略 -->
+    <!-- 4.1 开发环境:打印控制台-->
+    <!-- <springProfile name="dev">
+        <logger name="com.sdcm.pmp" level="debug"/>
+    </springProfile> -->
+
+    <root level="info">
+        <appender-ref ref="CONSOLE" />
+        <appender-ref ref="DEBUG_FILE" />
+        <appender-ref ref="INFO_FILE" />
+        <appender-ref ref="WARN_FILE" />
+        <appender-ref ref="ERROR_FILE" />
+    </root>
+
+    <!-- 4.2 生产环境:输出到文档
+    <springProfile name="pro">
+        <root level="info">
+            <appender-ref ref="CONSOLE" />
+            <appender-ref ref="DEBUG_FILE" />
+            <appender-ref ref="INFO_FILE" />
+            <appender-ref ref="ERROR_FILE" />
+            <appender-ref ref="WARN_FILE" />
+        </root>
+    </springProfile> -->
+
+</configuration>