Browse Source

超限预警BUG修复,使用long获取卡口配置超限值时发生精度丢失

sbj 3 days ago
parent
commit
1e26db7d54

+ 14 - 0
general-controller-service/src/main/java/com/shanghaichengdi/generalcontrollerservice/controller/DataController.java

@@ -411,4 +411,18 @@ public class DataController {
 
     return dateTime.isAfter(morning6am) && dateTime.isBefore(evening6pm);
   }
+
+
+  @PostMapping(value = "/generateCxWarning")
+  public void generateCxWarning(@RequestBody String boatName){
+    try {
+      DataReq data = new DataReq();
+      data.setCrosssectionId("14");
+      dataFaced.generateCxWarning(data, WarningType.CX, "振兴机60009");
+    }catch (Exception e) {
+      log.info("生成CX预警异常{}",e.getMessage());
+      PrintLogUtils.printErrorLogInfo(e,"生成CX预警异常");
+    }
+
+  }
 }

+ 4 - 2
general-controller-service/src/main/java/com/shanghaichengdi/generalcontrollerservice/domain/BoatWarningCxDict.java

@@ -3,6 +3,8 @@ package com.shanghaichengdi.generalcontrollerservice.domain;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
+import java.math.BigDecimal;
+
 import lombok.Data;
 
 /**
@@ -28,13 +30,13 @@ public class BoatWarningCxDict implements Serializable {
      * 限制船长(m)
      */
     @TableField(value = "CC_LIMIT")
-    private Long ccLimit;
+    private BigDecimal ccLimit;
 
     /**
      * 限制船宽(m)
      */
     @TableField(value = "CK_LIMIT")
-    private Long ckLimit;
+    private BigDecimal ckLimit;
 
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;

+ 3 - 20
general-controller-service/src/main/java/com/shanghaichengdi/generalcontrollerservice/faced/DataFaced.java

@@ -1686,7 +1686,7 @@ public class DataFaced {
         boatWarningService.saveBatch(boatWarningList);
         }
 
-  private void generateCxWarning(DataReq data, WarningType warningType, String name)
+  public void generateCxWarning(DataReq data, WarningType warningType, String name)
       throws ParseException {
     List<BoatWarningCxDict> cxDictList = boatWarningCxDictService.list();
     log.warn("超限列表为:"+cxDictList);
@@ -1702,8 +1702,8 @@ public class DataFaced {
                   && !Objects.isNull(boatInfo.getLength())
                   && !Objects.isNull(boatInfo.getWidth())
                   && !Objects.isNull(bayonetName)) {
-            if (boatInfo.getLength().compareTo(new BigDecimal(cxDict.getCcLimit())) > 0
-                    || boatInfo.getWidth().compareTo(new BigDecimal(cxDict.getCkLimit())) > 0) {
+            if (boatInfo.getLength().compareTo(cxDict.getCcLimit()) > 0
+                    || boatInfo.getWidth().compareTo(cxDict.getCkLimit()) > 0) {
               generateBoatWarning(warningType, data, "超限。");
             }
           }
@@ -1715,23 +1715,6 @@ public class DataFaced {
     }
   }
 
-  private void generateCzWarning(DataReq data, WarningType warningType, String name)
-          throws ParseException {
-    List<BoatWarningCxDict> cxDictList = boatWarningCxDictService.list();
-    if (org.springframework.util.StringUtils.hasLength(name)) {
-      ShipIdentificationVo vo = boatWarningCxDictService.selectPageDataByName(name).get(0);
-      for (BoatWarningCxDict cxDict : cxDictList) {
-        if (!Objects.isNull(vo) && cxDict.getName().equals(vo.getBayonetName()) && !Objects.isNull(
-                vo.getLength())
-                && !Objects.isNull(vo.getWidth())) {
-          if (vo.getLength() > cxDict.getCcLimit() || vo.getWidth() > cxDict.getCkLimit()) {
-            generateBoatWarning(warningType, data, "超限。");
-          }
-        }
-      }
-    }
-  }
-
   private void generateKeyTrackWarning(DataReq data, WarningType warningType, String name)
       throws ParseException {
     List<KeyTrackShipRealtime> keyTrackShipRealtimeList = keyTrackShipRealtimeService.list(