Browse Source

相机导入修改和筛选

gao.qiang 2 months ago
parent
commit
49d5b455b2

+ 15 - 1
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraManagementController.java

@@ -52,6 +52,7 @@ import javax.servlet.http.HttpServletResponse;
 import javax.validation.constraints.NotNull;
 import java.io.InputStream;
 import java.math.BigDecimal;
+import java.text.DecimalFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -147,6 +148,14 @@ public class BaseCameraManagementController extends BaseController {
                     baseCameraManagement.setHeartTime(list.get(0).getCreateTime());
                 }
             }
+            // 将字符串转换为浮点数
+            double installLatitude = Double.parseDouble(baseCameraManagement.getInstallLatitude());
+            double installLongitude = Double.parseDouble(baseCameraManagement.getInstallLongitude());
+            // 创建 DecimalFormat 对象,指定格式
+            DecimalFormat decimalFormat = new DecimalFormat("#.00");
+            // 格式化数字
+            baseCameraManagement.setInstallLatitude(decimalFormat.format(installLatitude));
+            baseCameraManagement.setInstallLongitude(decimalFormat.format(installLongitude));
             return AjaxResult.success(baseCameraManagement);
         } else if (!StringUtils.isEmpty(isLock) && isLock == 2 && !StringUtils.isEmpty(cameraCode)) {
             MsgAlarm msgAlarm = msgAlarmService.selectByCameraCode(cameraCode);
@@ -172,7 +181,12 @@ public class BaseCameraManagementController extends BaseController {
             }
             String mile = AppendUtils.stringAppend(baseCameraManagement.getInstallMile());
             msgAlarmResp.setAlarmMile(mile);
-            msgAlarmResp.setInstallLongitude(baseCameraManagement.getInstallLongitude() + "," + baseCameraManagement.getInstallLatitude());
+            double installLatitude = Double.parseDouble(baseCameraManagement.getInstallLatitude());
+            double installLongitude = Double.parseDouble(baseCameraManagement.getInstallLongitude());
+            // 创建 DecimalFormat 对象,指定格式
+            DecimalFormat decimalFormat = new DecimalFormat("#.00");
+            // 格式化数字
+            msgAlarmResp.setInstallLongitude(decimalFormat.format(installLongitude) + "," + decimalFormat.format(installLatitude));
             String[] split = msgAlarm.getImageUrl().split(";");
             ArrayList<String> objects = new ArrayList<>(Arrays.asList(split));
             msgAlarmResp.setImageUrls(objects);