Commit 691e403e authored by hezhuozhi's avatar hezhuozhi

修改电站监控数据不一致问题

parent d7721b58
...@@ -12,10 +12,7 @@ import java.util.Map; ...@@ -12,10 +12,7 @@ import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.yeejoin.amos.api.householdapi.face.dto.GoodWeStationMonitorDto;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -127,8 +124,8 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ ...@@ -127,8 +124,8 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ
sunlight.setCreatedTime(System.currentTimeMillis()); sunlight.setCreatedTime(System.currentTimeMillis());
sofarStationListMapper.insert(sunlight); sofarStationListMapper.insert(sunlight);
} }
//删除多余的电站 //删除多余的信息
deleteSHStation(jsonObject); deleteSHMessage(jsonObject);
// mysql电站信息 // mysql电站信息
this.stationDetail(jsonObject); this.stationDetail(jsonObject);
} }
...@@ -137,12 +134,13 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ ...@@ -137,12 +134,13 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ
* 删除多余的首航场站 * 删除多余的首航场站
* @param sofarStationLists * @param sofarStationLists
*/ */
private void deleteSHStation(List<SofarStationList> sofarStationLists) { private void deleteSHMessage(List<SofarStationList> sofarStationLists) {
if(CollectionUtil.isNotEmpty(sofarStationLists)){ if(CollectionUtil.isNotEmpty(sofarStationLists)){
List<String> stationIds = new ArrayList<>(); List<String> stationIds = new ArrayList<>();
for (SofarStationList sofarStationList : sofarStationLists) { for (SofarStationList sofarStationList : sofarStationLists) {
stationIds.add(sofarStationList.getId().toString()); stationIds.add(sofarStationList.getId().toString());
} }
//场站
QueryWrapper<JpStation> wrapper = new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.SH.getCode()); QueryWrapper<JpStation> wrapper = new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.SH.getCode());
List<JpStation> jpStations = jpStationMapper.selectList(wrapper); List<JpStation> jpStations = jpStationMapper.selectList(wrapper);
if(CollectionUtil.isNotEmpty(jpStations)){ if(CollectionUtil.isNotEmpty(jpStations)){
...@@ -153,6 +151,28 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ ...@@ -153,6 +151,28 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ
} }
} }
} }
//采集器
QueryWrapper<JpCollector> wrapper1 = new QueryWrapper<JpCollector>().eq("third_code", PVProducerInfoEnum.SH.getCode());
List<JpCollector> jpCollectors = jpCollectorMapper.selectList(wrapper1);
if(CollectionUtil.isNotEmpty(jpCollectors)){
for (JpCollector jpCollector : jpCollectors) {
if(!stationIds.contains(jpCollector.getThirdStationId())){
//删除多余数据
jpCollectorMapper.deleteById(jpCollector.getSequenceNbr());
}
}
}
//逆变器
QueryWrapper<JpInverter> wrapper2 = new QueryWrapper<JpInverter>().eq("third_code", PVProducerInfoEnum.SH.getCode());
List<JpInverter> jpInverters = jpInverterMapper.selectList(wrapper2);
if(CollectionUtil.isNotEmpty(jpInverters)){
for (JpInverter jpInverter : jpInverters) {
if(!stationIds.contains(jpInverter.getThirdStationId())){
//删除多余数据
jpInverterMapper.deleteById(jpInverter.getSequenceNbr());
}
}
}
} }
} }
......
...@@ -8,13 +8,8 @@ import cn.hutool.json.JSONUtil; ...@@ -8,13 +8,8 @@ import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.google.gson.JsonObject;
import com.qiniu.util.Json;
import com.yeejoin.amos.api.householdapi.Utils.SunlightUtil; import com.yeejoin.amos.api.householdapi.Utils.SunlightUtil;
import com.yeejoin.amos.api.householdapi.constant.ImasterConstant;
import com.yeejoin.amos.api.householdapi.constant.KSolarConstant;
import com.yeejoin.amos.api.householdapi.face.dto.Device; import com.yeejoin.amos.api.householdapi.face.dto.Device;
import com.yeejoin.amos.api.householdapi.face.dto.KsolarAlarmDto;
import com.yeejoin.amos.api.householdapi.face.dto.SunlightDto; import com.yeejoin.amos.api.householdapi.face.dto.SunlightDto;
import com.yeejoin.amos.api.householdapi.face.dto.SunlightWarm; import com.yeejoin.amos.api.householdapi.face.dto.SunlightWarm;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpCollector; import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpCollector;
...@@ -38,7 +33,6 @@ import org.springframework.context.ApplicationContext; ...@@ -38,7 +33,6 @@ import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -47,8 +41,6 @@ import java.util.concurrent.TimeUnit; ...@@ -47,8 +41,6 @@ import java.util.concurrent.TimeUnit;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
/** /**
* @description: * @description:
* @author: tw * @author: tw
...@@ -117,7 +109,7 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -117,7 +109,7 @@ public class SunlightServiceImpl implements SunlightService {
JSONObject data = SunlightUtil.getDataList(SunlightUtil.getPowerStationList, bodyparam); JSONObject data = SunlightUtil.getDataList(SunlightUtil.getPowerStationList, bodyparam);
List<Sunlight> list = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), Sunlight.class); List<Sunlight> list = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), Sunlight.class);
//删除多余的场站 //删除多余的场站
deleteYGStation(data); deleteYGMessage(data);
this.stationDetail(data); this.stationDetail(data);
for (Sunlight sunlight : list) { for (Sunlight sunlight : list) {
...@@ -131,7 +123,7 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -131,7 +123,7 @@ public class SunlightServiceImpl implements SunlightService {
* 删除多余的阳光场站 * 删除多余的阳光场站
* @param data * @param data
*/ */
private void deleteYGStation(JSONObject data) { private void deleteYGMessage(JSONObject data) {
// 所有场站信息 // 所有场站信息
List<SunlightDto> sunlightDtos = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), SunlightDto.class); List<SunlightDto> sunlightDtos = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), SunlightDto.class);
if(CollectionUtil.isNotEmpty(sunlightDtos)){ if(CollectionUtil.isNotEmpty(sunlightDtos)){
...@@ -139,6 +131,7 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -139,6 +131,7 @@ public class SunlightServiceImpl implements SunlightService {
for (SunlightDto sunlightDto : sunlightDtos) { for (SunlightDto sunlightDto : sunlightDtos) {
stationIds.add(sunlightDto.getPs_id().toString()); stationIds.add(sunlightDto.getPs_id().toString());
} }
//场站
QueryWrapper<JpStation> wrapper = new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.YG.getCode()); QueryWrapper<JpStation> wrapper = new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.YG.getCode());
List<JpStation> jpStations = jpStationMapper.selectList(wrapper); List<JpStation> jpStations = jpStationMapper.selectList(wrapper);
if(CollectionUtil.isNotEmpty(jpStations)){ if(CollectionUtil.isNotEmpty(jpStations)){
...@@ -149,6 +142,28 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -149,6 +142,28 @@ public class SunlightServiceImpl implements SunlightService {
} }
} }
} }
//采集器
QueryWrapper<JpCollector> wrapper1 = new QueryWrapper<JpCollector>().eq("third_code", PVProducerInfoEnum.YG.getCode());
List<JpCollector> jpCollectors = jpCollectorMapper.selectList(wrapper1);
if(CollectionUtil.isNotEmpty(jpCollectors)){
for (JpCollector jpCollector : jpCollectors) {
if(!stationIds.contains(jpCollector.getThirdStationId())){
//删除多余数据
jpCollectorMapper.deleteById(jpCollector.getSequenceNbr());
}
}
}
//逆变器
QueryWrapper<JpInverter> wrapper2 = new QueryWrapper<JpInverter>().eq("third_code", PVProducerInfoEnum.YG.getCode());
List<JpInverter> jpInverters = jpInverterMapper.selectList(wrapper2);
if(CollectionUtil.isNotEmpty(jpInverters)){
for (JpInverter jpInverter : jpInverters) {
if(!stationIds.contains(jpInverter.getThirdStationId())){
//删除多余数据
jpInverterMapper.deleteById(jpInverter.getSequenceNbr());
}
}
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment