瀏覽代碼

里程位置字段类型修改

gao.qiang 1 年之前
父節點
當前提交
3e595611ab

+ 7 - 6
business-service/src/main/java/com/ozs/service/service/impl/BaseCameraManagementServiceImpl.java

@@ -27,6 +27,7 @@ import org.springframework.util.ObjectUtils;
 
 import javax.annotation.Resource;
 import javax.validation.Validator;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -106,14 +107,14 @@ public class BaseCameraManagementServiceImpl extends ServiceImpl<BaseCameraManag
                                 failureNum++;
                                 failureMsg.append(failureNum + "、相机编码为: " + accountManagement.getCameraCode() + "的数据,安装里程位置填写格式不正确,请填写数字");
                             } else {
-                                Double install = Double.valueOf(accountManagement.getInstallMiles());
+                                BigDecimal install = new BigDecimal(accountManagement.getInstallMiles());
                                 accountManagement.setRailwayCode(baseRailwayManagement.getRailwayCode());
-                                accountManagement.setInstallMile((int) (install * 1000));
+                                accountManagement.setInstallMile( install.multiply(BigDecimal.valueOf(1000)).intValue());
                                 if (!ObjectUtils.isEmpty(accountManagement.getBeginMiles()) && !ObjectUtils.isEmpty(accountManagement.getEndMiles())) {
-                                    Double end = Double.valueOf(accountManagement.getEndMiles());
-                                    Double begin = Double.valueOf(accountManagement.getBeginMiles());
-                                    accountManagement.setEndMile((int) (end * 1000));
-                                    accountManagement.setBeginMile((int) (begin * 1000));
+                                    BigDecimal end = new BigDecimal(accountManagement.getEndMiles());
+                                    BigDecimal begin =new BigDecimal(accountManagement.getBeginMiles());
+                                    accountManagement.setEndMile(end.multiply(BigDecimal.valueOf(1000)).intValue());
+                                    accountManagement.setBeginMile(begin.multiply(BigDecimal.valueOf(1000)).intValue());
                                     if (!accountManagement.getBeginMiles().matches(PATTERN) || !accountManagement.getEndMiles().matches(PATTERN)) {
                                         failureNum++;
                                         failureMsg.append(failureNum + "、相机编码为: " + accountManagement.getCameraCode() + "的数据,监控范围里程位置填写格式不正确,请填写数字");

+ 13 - 12
hazard-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraManagementController.java

@@ -61,6 +61,7 @@ import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.constraints.NotNull;
 import java.io.InputStream;
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -303,22 +304,22 @@ public class BaseCameraManagementController extends BaseController {
                 if (!baseCameraManagement.getBeginMiles().matches(PATTERN)) {
                     return error("监控范围开始里程位置填写格式不正确");
                 } else {
-                    double begin = Double.parseDouble(baseCameraManagement.getBeginMiles());
-                    baseCameraManagement.setBeginMile((int) (begin * 1000));
+                    BigDecimal begin = new BigDecimal(baseCameraManagement.getBeginMiles());
+                    baseCameraManagement.setBeginMile(begin.multiply(BigDecimal.valueOf(1000)).intValue());
                 }
             }
             if (!baseCameraManagement.getInstallMiles().matches(PATTERN)) {
                 return error("监控相机安装里程位置填写格式不正确");
             } else {
-                double install = Double.parseDouble(baseCameraManagement.getInstallMiles());
-                baseCameraManagement.setInstallMile((int) (install * 1000));
+                BigDecimal install = new BigDecimal(baseCameraManagement.getInstallMiles());
+                baseCameraManagement.setInstallMile(install.multiply(BigDecimal.valueOf(1000)).intValue());
             }
             if (!ObjectUtils.isEmpty(baseCameraManagement.getEndMiles())) {
                 if (!baseCameraManagement.getEndMiles().matches(PATTERN)) {
                     return error("监控范围结束里程位置填写格式不正确");
                 } else {
-                    double end = Double.parseDouble(baseCameraManagement.getEndMiles());
-                    baseCameraManagement.setEndMile((int) (end * 1000));
+                    BigDecimal end = new BigDecimal(baseCameraManagement.getEndMiles());
+                    baseCameraManagement.setEndMile(end.multiply(BigDecimal.valueOf(1000)).intValue());
                 }
             }
             if (!ObjectUtils.isEmpty(baseCameraManagement.getEndMiles()) && !ObjectUtils.isEmpty(baseCameraManagement.getBeginMiles())) {
@@ -377,8 +378,8 @@ public class BaseCameraManagementController extends BaseController {
             if (!baseCameraManagement.getBeginMiles().matches(PATTERN)) {
                 return error("监控范围开始里程位置填写格式不正确");
             } else {
-                double begin = Double.parseDouble(baseCameraManagement.getBeginMiles());
-                baseCameraManagement.setBeginMile((int) (begin * 1000));
+                BigDecimal begin = new BigDecimal(baseCameraManagement.getBeginMiles());
+                baseCameraManagement.setBeginMile(begin.multiply(BigDecimal.valueOf(1000)).intValue());
             }
         }else {
             baseCameraManagement.setBeginMile(null);
@@ -386,15 +387,15 @@ public class BaseCameraManagementController extends BaseController {
         if (!baseCameraManagement.getInstallMiles().matches(PATTERN)) {
             return error("监控相机安装里程位置填写格式不正确");
         } else {
-            double install = Double.parseDouble(baseCameraManagement.getInstallMiles());
-            baseCameraManagement.setInstallMile((int) (install * 1000));
+            BigDecimal install = new BigDecimal(baseCameraManagement.getInstallMiles());
+            baseCameraManagement.setInstallMile(install.multiply(BigDecimal.valueOf(1000)).intValue());
         }
         if (!ObjectUtils.isEmpty(baseCameraManagement.getEndMiles())) {
             if (!baseCameraManagement.getEndMiles().matches(PATTERN)) {
                 return error("监控范围结束里程位置填写格式不正确");
             } else {
-                double end = Double.parseDouble(baseCameraManagement.getEndMiles());
-                baseCameraManagement.setEndMile((int) (end * 1000));
+                BigDecimal end = new BigDecimal(baseCameraManagement.getEndMiles());
+                baseCameraManagement.setEndMile(end.multiply(BigDecimal.valueOf(1000)).intValue());
             }
         }else {
             baseCameraManagement.setEndMile(null);