Bläddra i källkod

项目拐点坐标 风机更新 条件判断

hxf 2 år sedan
förälder
incheckning
02d7bc0b97

+ 20 - 8
neim-biz/src/main/java/com/jiayue/biz/service/impl/FengJiInfoServiceImpl.java

@@ -100,11 +100,20 @@ public class FengJiInfoServiceImpl extends ServiceImpl<WindTowerDataParentTableM
     //项目风机更新
     public void updateFanTowerForProjectInfo(FanTowerDto fanTowerDto) {
         ProjectInfo projectInfoById = projectInfoService.getOneProjectInfoById(fanTowerDto.getId());
-        List<FanTower> fanTowerList = projectInfoById.getFanTowerList().stream().peek(s -> {
-            if (s.getId().equals(fanTowerDto.getFanId())) {
-                this.getFanTower(fanTowerDto, s);
-            }
-        }).collect(Collectors.toList());
+        List<FanTower> fanTowerList;
+        if (projectInfoById.getFanTowerList() != null) {
+            fanTowerList = projectInfoById.getFanTowerList().stream().peek(s -> {
+                if (s.getId().equals(fanTowerDto.getFanId())) {
+                    this.getFanTower(fanTowerDto, s);
+                }
+            }).collect(Collectors.toList());
+        }else{
+            FanTower fanTower = new FanTower();
+            this.getFanTower(fanTowerDto, fanTower);
+            fanTowerList = new ArrayList<>();
+            fanTowerList.add(fanTower);
+        }
+
         projectInfoById.setFanTowerList(fanTowerList);
         projectInfoService.saveProjectInfo(projectInfoById);
     }
@@ -154,9 +163,12 @@ public class FengJiInfoServiceImpl extends ServiceImpl<WindTowerDataParentTableM
     //项目删除风机信息
     public void deleteFanTowerForProjectInfo(FanTowerDto fanTowerDto) {
         ProjectInfo projectInfoById = projectInfoService.getOneProjectInfoById(fanTowerDto.getId());
-        List<FanTower> fanTowerList = projectInfoById.getFanTowerList().stream().filter(s -> !s.getId().equals(fanTowerDto.getFanId())).collect(Collectors.toList());
-        projectInfoById.setFanTowerList(fanTowerList);
-        projectInfoService.saveProjectInfo(projectInfoById);
+        if (projectInfoById.getFanTowerList() != null) {
+            List<FanTower> fanTowerList = projectInfoById.getFanTowerList().stream().filter(s -> !s.getId().equals(fanTowerDto.getFanId())).collect(Collectors.toList());
+            projectInfoById.setFanTowerList(fanTowerList);
+            projectInfoService.saveProjectInfo(projectInfoById);
+        }
+
     }
 
 

+ 17 - 7
neim-biz/src/main/java/com/jiayue/biz/service/impl/ProjectServiceImpl.java

@@ -159,7 +159,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
     //修改
     public void updateProject(ProjectDto projectDto) {
         List<WindTowerInfo> windTowerInfoList = windTowerInfoService.list();
-
+        List<List<Coordinates>> cooList;
         ProjectInfo projectInfo = projectInfoService.getOneProjectInfoById(projectDto.getId());
 
         ProjectBasicInfo projectBasicInfo = projectInfo.getProjectBasicInfo();
@@ -170,7 +170,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             List<Equipment> equipment = CalculationUtil.getEquipment(windTowerInfoList, projectDto.getEquipment());
             projectInfo.setEquipment(equipment);
         }
-        ArrayList<List<Coordinates>> cooList = new ArrayList<>();
+        if (projectInfo.getCoordinates() == null) {
+            cooList = new ArrayList<>();
+        } else {
+            cooList = projectInfo.getCoordinates();
+        }
+
         if (projectDto.getCoordinates().contains("。")) {
             String[] split = projectDto.getCoordinates().split("。");
             for (String s : split) {
@@ -181,18 +186,23 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
             List<Coordinates> coordinatesList1 = this.getCoordinates(projectDto.getCoordinates());
             cooList.add(coordinatesList1);
         }
+        projectInfo.setCoordinates(cooList);
         mongoTemplate.save(projectInfo);
     }
 
 
     public List<Coordinates> getCoordinates(String coordinates) {
         ArrayList<Coordinates> coordinatesList = new ArrayList<>();
-        Coordinates coordinates1 = new Coordinates();
         if (coordinates.length() > 0) {
-            String[] split = coordinates.split(";");
-            coordinates1.setLongitude(split[0]);
-            coordinates1.setLatitude(split[1]);
-            coordinatesList.add(coordinates1);
+            String[] splits = coordinates.split(";");
+            for (String s : splits) {
+                String[] split = s.split(",");
+                Coordinates coordinates1 = new Coordinates();
+                coordinates1.setLongitude(split[0]);
+                coordinates1.setLatitude(split[1]);
+                coordinatesList.add(coordinates1);
+            }
+
         }
         return coordinatesList;
     }