|
@@ -1,12 +1,10 @@
|
|
|
package com.jiayue.biz.service.impl;
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import com.jiayue.biz.domain.Equipment;
|
|
|
-import com.jiayue.biz.domain.StationBasicInfo;
|
|
|
-import com.jiayue.biz.domain.StationInfo;
|
|
|
-import com.jiayue.biz.domain.WindTowerInfo;
|
|
|
+import com.jiayue.biz.domain.*;
|
|
|
import com.jiayue.biz.dto.StationInfoDto;
|
|
|
import com.jiayue.biz.service.StationInfoService;
|
|
|
+import com.jiayue.biz.service.WeatherStationInfoService;
|
|
|
import com.jiayue.biz.service.WindTowerInfoService;
|
|
|
import com.jiayue.biz.util.CalculationUtil;
|
|
|
import com.jiayue.common.utils.DateUtil;
|
|
@@ -28,6 +26,9 @@ public class StationInfoServiceImpl implements StationInfoService {
|
|
|
|
|
|
private final WindTowerInfoService windTowerInfoService;
|
|
|
|
|
|
+ //环境监测仪
|
|
|
+ private final WeatherStationInfoService weatherStationInfoService;
|
|
|
+
|
|
|
//新增场站信息
|
|
|
public void saveStation(StationInfo stationInfo) {
|
|
|
mongoTemplate.save(stationInfo);
|
|
@@ -44,9 +45,10 @@ public class StationInfoServiceImpl implements StationInfoService {
|
|
|
return mongoTemplate.find(query, StationInfo.class);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
//删除
|
|
|
- public void del(String id){
|
|
|
- mongoTemplate.remove(new Query(Criteria.where("_id").is(id)),StationInfo.class);
|
|
|
+ public void del(String id) {
|
|
|
+ mongoTemplate.remove(new Query(Criteria.where("_id").is(id)), StationInfo.class);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -83,25 +85,35 @@ public class StationInfoServiceImpl implements StationInfoService {
|
|
|
return list;
|
|
|
|
|
|
}
|
|
|
+
|
|
|
//删除
|
|
|
- public void delStationInfo(StationInfoDto stationInfoDto){
|
|
|
+ public void delStationInfo(StationInfoDto stationInfoDto) {
|
|
|
this.del(stationInfoDto.getId());
|
|
|
}
|
|
|
|
|
|
|
|
|
//保存
|
|
|
- public void saveStationInfo(StationInfoDto stationInfoDto){
|
|
|
+ public void saveStationInfo(StationInfoDto stationInfoDto) {
|
|
|
List<WindTowerInfo> list = windTowerInfoService.list();
|
|
|
+ List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoService.list();
|
|
|
stationInfoDto.setId(UUID.randomUUID().toString());
|
|
|
StationInfo stationInfo = new StationInfo();
|
|
|
StationBasicInfo stationBasicInfo = this.getStationBasicInfo(stationInfoDto);
|
|
|
stationInfo.setStationBasicInfo(stationBasicInfo);
|
|
|
- if (stationInfoDto.getEquipment() != null && !stationInfoDto.getEquipment().equals("")) {
|
|
|
- List<Equipment> equipment = CalculationUtil.getEquipment(list, stationInfoDto.getEquipment());
|
|
|
- stationInfo.setEquipment(equipment);
|
|
|
+ if (stationInfo.getStationBasicInfo().getStationType().contains("风")) {
|
|
|
+ if (stationInfoDto.getEquipment() != null && !stationInfoDto.getEquipment().equals("")) {
|
|
|
+ List<Equipment> equipment = CalculationUtil.getEquipment(list, stationInfoDto.getEquipment());
|
|
|
+ stationInfo.setEquipment(equipment);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (stationInfo.getStationBasicInfo().getStationType().contains("光")){
|
|
|
+ if (stationInfoDto.getEquipment() != null && !stationInfoDto.getEquipment().equals("")) {
|
|
|
+ List<WeatherStationInfo> weatherStationInfo = this.getWeatherStationInfo(weatherStationInfoList, stationInfoDto.getEquipment());
|
|
|
+ stationInfo.setWeatherStationInfos(weatherStationInfo);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- this.saveStation(stationInfo);
|
|
|
+ this.saveStation(stationInfo);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -109,18 +121,40 @@ public class StationInfoServiceImpl implements StationInfoService {
|
|
|
//更新
|
|
|
public void updateStationInfo(StationInfoDto stationInfoDto) {
|
|
|
List<WindTowerInfo> list = windTowerInfoService.list();
|
|
|
+
|
|
|
+ List<WeatherStationInfo> weatherStationInfoList = weatherStationInfoService.list();
|
|
|
StationInfo stationInfo = getOneStationInfo(stationInfoDto.getId());
|
|
|
StationBasicInfo stationBasicInfo = this.getStationBasicInfo(stationInfoDto);
|
|
|
stationInfo.setStationBasicInfo(stationBasicInfo);
|
|
|
- if (stationInfoDto.getEquipment() != null && !stationInfoDto.getEquipment().equals("")) {
|
|
|
- List<Equipment> equipment = CalculationUtil.getEquipment(list, stationInfoDto.getEquipment());
|
|
|
- stationInfo.setEquipment(equipment);
|
|
|
+ if (stationInfo.getStationBasicInfo().getStationType().equals("风")) {
|
|
|
+ if (stationInfoDto.getEquipment() != null && !stationInfoDto.getEquipment().equals("")) {
|
|
|
+ List<Equipment> equipment = CalculationUtil.getEquipment(list, stationInfoDto.getEquipment());
|
|
|
+ stationInfo.setEquipment(equipment);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else if (stationInfo.getStationBasicInfo().getStationType().equals("光")) {
|
|
|
+ if (stationInfoDto.getEquipment() != null && !stationInfoDto.getEquipment().equals("")) {
|
|
|
+ List<WeatherStationInfo> weatherStationInfo = this.getWeatherStationInfo(weatherStationInfoList, stationInfoDto.getEquipment());
|
|
|
+ stationInfo.setWeatherStationInfos(weatherStationInfo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
+
|
|
|
this.saveStation(stationInfo);
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ public List<WeatherStationInfo> getWeatherStationInfo(List<WeatherStationInfo> weatherStationInfoList, String equipmentStr) {
|
|
|
+ ArrayList<WeatherStationInfo> list = new ArrayList<>();
|
|
|
+ String[] split = equipmentStr.split(",");
|
|
|
+ for (String s : split) {
|
|
|
+ List<WeatherStationInfo> collect = weatherStationInfoList.stream().filter(w -> w.getId().equals(s)).collect(Collectors.toList());
|
|
|
+ list.add(collect.get(0));
|
|
|
+ }
|
|
|
+ return list;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -138,5 +172,4 @@ public class StationInfoServiceImpl implements StationInfoService {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
}
|