Commit 3306d465 authored by wujiang's avatar wujiang

增加固德威逆变器状态

parent 85a121f7
......@@ -208,6 +208,7 @@ public class GoodWeConstant {
public static String inverterDayURL ="/v1/api/inverterDay";
public static String inverterMonthURL ="/v1/api/inverterMonth";
public static String inverterYearURL ="/v1/api/inverterYear";
public static String snStatusURL ="/api/OpenApi/GetPowerStationMonitorDetailBySn";
public static String resovleRule_data_page_records = "data,page,records";
public static String resovleRule_data_list = "data,list";
public static String resovleRule_data_records = "data,records";
......
......@@ -112,7 +112,7 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
List<GoodWeStationMonitorDto> goodWeStationLists = goodWeRequestUtil.getResPonseList(
GoodWeConstant.stationListStatusUrl, GoodWeConstant.requestPost, requestInfo,
GoodWeConstant.resovleRule_data_list, GoodWeStationMonitorDto.class);
//删除多余的场站
// 删除多余的场站
deleteBDWStation(goodWeStationLists);
if (goodWeStationLists.size() > 0) {
goodWeStationLists.forEach(goodWeStationMonitorDto -> {
......@@ -203,8 +203,9 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
hygfjpStationPowerHistory.setStationState(jpStation.getState());
hygfjpStationPowerHistoryMapper.insert(hygfjpStationPowerHistory);
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper.selectOne(new QueryWrapper<HYGFJPDayPower>()
.eq("third_station_id", jpStation.getThirdStationId()).eq("year_month_day", today).eq("hour", hour));
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper.selectOne(
new QueryWrapper<HYGFJPDayPower>().eq("third_station_id", jpStation.getThirdStationId())
.eq("year_month_day", today).eq("hour", hour));
if (org.springframework.util.ObjectUtils.isEmpty(hygfjpDayPower)) {
hygfjpDayPower = new HYGFJPDayPower();
}
......@@ -318,20 +319,22 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
/**
* 删除多余的场站
*
* @param goodWeStationLists
*/
private void deleteBDWStation(List<GoodWeStationMonitorDto> goodWeStationLists) {
if(CollectionUtil.isNotEmpty(goodWeStationLists)){
if (CollectionUtil.isNotEmpty(goodWeStationLists)) {
List<String> stationIds = new ArrayList<>();
for (GoodWeStationMonitorDto goodWeStationMonitorDto : goodWeStationLists) {
stationIds.add(goodWeStationMonitorDto.getPowerstation_id());
}
QueryWrapper<JpStation> wrapper = new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.GDW.getCode());
QueryWrapper<JpStation> wrapper = new QueryWrapper<JpStation>().eq("third_code",
PVProducerInfoEnum.GDW.getCode());
List<JpStation> jpStations = jpStationMapper.selectList(wrapper);
if(CollectionUtil.isNotEmpty(jpStations)){
if (CollectionUtil.isNotEmpty(jpStations)) {
for (JpStation jpStation : jpStations) {
if(!stationIds.contains(jpStation.getThirdStationId())){
//删除多余数据
if (!stationIds.contains(jpStation.getThirdStationId())) {
// 删除多余数据
jpStationMapper.deleteById(jpStation.getSequenceNbr());
}
}
......@@ -379,6 +382,7 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
/**
* 获取场站id
*
* @return
*/
private List<String> getStationIds() {
......@@ -389,7 +393,7 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
GoodWeConstant.stationListStatusUrl, GoodWeConstant.requestPost, requestInfo,
GoodWeConstant.resovleRule_data_list, GoodWeStationMonitorDto.class);
List<String> stationIds = new ArrayList<>();
if(CollectionUtil.isNotEmpty(goodWeStationLists)){
if (CollectionUtil.isNotEmpty(goodWeStationLists)) {
for (GoodWeStationMonitorDto goodWeStationMonitorDto : goodWeStationLists) {
stationIds.add(goodWeStationMonitorDto.getPowerstation_id());
}
......@@ -404,7 +408,7 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
long ts = System.currentTimeMillis();
logger.info("-------固德威同步场站月发电量开始" + ts + "------- " + sdf.format(new Date()));
// List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
List<String> stationIds = getStationIds();
List<String> stationIds = getStationIds();
stationIds.forEach(stationId -> {
String currentMonth = DateUtil.format(new Date(), "yyyyMM");
HashMap<String, Object> requestInfo = new HashMap<>();
......@@ -442,7 +446,7 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
long ts = System.currentTimeMillis();
logger.info("-------固德威同步场站年发电量开始" + ts + "------- " + sdf.format(new Date()));
// List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
List<String> stationIds = getStationIds();
List<String> stationIds = getStationIds();
stationIds.forEach(stationId -> {
String currentYear = DateUtil.format(new Date(), "yyyy");
HashMap<String, Object> requestInfo = new HashMap<>();
......@@ -482,12 +486,13 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
@Override
@Scheduled(cron = "${dataRequstScheduled.GoodWe}")
@Async
@PostConstruct
public void inverterList() {
long ts = System.currentTimeMillis();
logger.info("-------固德威同步逆变器开始" + ts + "------- " + sdf.format(new Date()));
// List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
List<String> stationIds = getStationIds();
//删除多余的逆变器
// 删除多余的逆变器
deleteGDWInverter(stationIds);
stationIds.stream().forEach(stationId -> {
HashMap<String, Object> requestInfo = new HashMap<>();
......@@ -519,6 +524,26 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
jpInverter.setStationName(jpStation.getName());
}
jpInverter.setRecDate(new Date());
HashMap<String, Object> requestInfo2 = new HashMap<>();
requestInfo2.put("page_index", 1);
requestInfo2.put("page_size", 1);
requestInfo2.put("sn", jpInverter.getSnCode());
String requstParam2 = JSON.toJSONString(requestInfo2);
List<GoodWeStationDetail> goodWeStationDetails = goodWeRequestUtil.getResPonse(GoodWeConstant.snStatusURL,
GoodWeConstant.requestPost, requstParam2, GoodWeConstant.resovleRule_data_list,
GoodWeStationDetail.class);
if (goodWeStationDetails != null&&!goodWeStationDetails.isEmpty()) {
Integer s = goodWeStationDetails.get(0).getStatus();
//(“” or null:全部,-1:离线 0:待机 1:发电中 2:停机 -2:无设备)
if (s == 0 || s == 1) {
jpInverter.setState("在线");
} else if (s == null || s == -1 || s == 2 | s == -2) {
jpInverter.setState("离线");
}
}
if (!org.springframework.util.ObjectUtils.isEmpty(jpInverter.getSequenceNbr())) {
jpInverterMapper.updateById(jpInverter);
} else {
......@@ -531,15 +556,17 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
/**
* 删除多余的逆变器
*
* @param stationIds
*/
private void deleteGDWInverter(List<String> stationIds) {
QueryWrapper<JpInverter> wrapper = new QueryWrapper<JpInverter>().eq("third_code", PVProducerInfoEnum.GDW.getCode());
QueryWrapper<JpInverter> wrapper = new QueryWrapper<JpInverter>().eq("third_code",
PVProducerInfoEnum.GDW.getCode());
List<JpInverter> jpInverters = jpInverterMapper.selectList(wrapper);
if(CollectionUtil.isNotEmpty(jpInverters)){
if (CollectionUtil.isNotEmpty(jpInverters)) {
for (JpInverter jpInverter : jpInverters) {
if(!stationIds.contains(jpInverter.getThirdStationId())){
//删除多余数据
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