Kaynağa Gözat

fix lnglat [][]

459242451@qq.com 3 yıl önce
ebeveyn
işleme
b4a9bec546

+ 14 - 1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/gas/GasCommonController.java

@@ -48,6 +48,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.Date;
@@ -289,6 +290,7 @@ public class GasCommonController {
         List<AisShip> aisShipAddressList = aisShipService.queryShipAddressList(1);
         // 组装一段时间内的经纬度数据
         Map<String, List<String>> collect = aisShipAddressList.stream().collect(Collectors.groupingBy(AisShip::getMmsi, Collectors.mapping(a -> a.getLng() + "," + a.getLat(), Collectors.toList())));
+        Map<String, List<BigDecimal>> headCollect = aisShipAddressList.stream().collect(Collectors.groupingBy(AisShip::getMmsi, Collectors.mapping(AisShip::getHead, Collectors.toList())));
         for (IllegalInfo illegalInfo : pageList) {
             if (StrUtil.isNotBlank(illegalInfo.getMmsi())) {
                 AisShip aisShip = aisShipMap.get(illegalInfo.getMmsi());
@@ -300,7 +302,18 @@ public class GasCommonController {
                     illegalInfo.setSpeed(ObjectUtil.isEmpty(aisShip.getSpeed()) ? "-" : aisShip.getSpeed() + "节");
                     illegalInfo.setCourse(ObjectUtil.isEmpty(aisShip.getCourse()) ? "-" : aisShip.getCourse() + "");
                 }
-                illegalInfo.setLnglat(collect.get(illegalInfo.getMmsi()));
+                // 数组转二维数组
+                List<String> lnglat = collect.get(illegalInfo.getMmsi());
+                Double[][] covert = new Double[lnglat.size()][];
+                for (int i = 0; i < lnglat.size(); i++) {
+                    String[] second = lnglat.get(i).split(",");
+                    covert[i] = new Double[second.length];
+                    for (int j = 0; j < second.length; j++) {
+                        covert[i][j] = Double.parseDouble(second[j]);
+                    }
+                }
+                illegalInfo.setLnglat(covert);
+                illegalInfo.setHeads(headCollect.get(illegalInfo.getMmsi()));
             }
         }
         pageList =

+ 3 - 1
ruoyi-system/src/main/java/com/ruoyi/system/domain/IllegalInfo.java

@@ -41,7 +41,9 @@ public class IllegalInfo {
     // 船舶实时经纬度
     private BigDecimal lat;
 
-    private List<String> lnglat;
+    private Double[][] lnglat;
+
+    private List<BigDecimal> heads;
 
     // 船舶实时经纬度上传时间
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")

+ 2 - 1
ruoyi-system/src/main/resources/mapper/system/AisShipMapper.xml

@@ -35,7 +35,8 @@
     <select id="queryShipAddressList" resultType="com.ruoyi.system.domain.AisShip">
         SELECT mmsi,
                lng,
-               lat
+               lat,
+               head
         FROM ais_ship
         WHERE DATE_SUB(CURDATE(), INTERVAL #{day} DAY) &lt;= date (receive)
         order BY receive