Commit 98722217 authored by caotao's avatar caotao

锦浪云-告警数据处理

parent 8d417b64
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName(value = "td_hygf_day_power" ,autoResultMap = true)
public class HYGFJPDayPower {
private Long createdTime;
private String tationId;
private String hour;
private String yearMonthDay;
private Double power;
}
......@@ -7,7 +7,7 @@ import java.io.Serializable;
import java.util.Date;
@Data
@TableName(value = "td_hygf_jp_invertor_elec_history" ,autoResultMap = true)
@TableName(value = "td_hygf_jp_station_power_history" ,autoResultMap = true)
public class HYGFJPStationPowerHistory implements Serializable {
private Long createdTime;
private Double power;
......
package com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.HYGFJPDayPower;
public interface HYGFJPDayPowerMapper extends BaseMapper<HYGFJPDayPower> {
}
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.api.householdapi.face.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.api.householdapi.Utils.GolangRequestUtil;
import com.yeejoin.amos.api.householdapi.constant.GoLangConstant;
......@@ -21,6 +22,7 @@ import com.yeejoin.amos.api.householdapi.face.service.GoLangDataAcquisitionServi
import com.yeejoin.amos.api.householdapi.face.orm.mapper.hygf.JpStationMapper;
import com.yeejoin.amos.openapi.enums.PVProducerInfoEnum;
import fastjson.JSON;
import org.bouncycastle.crypto.engines.AESLightEngine;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
......@@ -38,6 +40,7 @@ import java.util.concurrent.TimeUnit;
@Service
public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionService {
private final String dataRequstScheduled = "0 0/10 * * * *";
private final String stationPowerScheduled = "0 0 * * * *";
@Autowired
private GolangRequestUtil golangRequestUtil;
@Autowired
......@@ -68,9 +71,10 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
private HYGFJPInverterWarnMapper hygfjpInverterWarnMapper;
@Autowired
private HYGFJPInverterElecHistoryMapper hygfjpInverterElecHistoryMapper;
@Autowired
private HYGFJPDayPowerMapper hygfjpDayPowerMapper;
@Scheduled(cron =dataRequstScheduled )
@Scheduled(cron = dataRequstScheduled)
@Override
public void stationList() {
HashMap<String, Object> requestInfo = new HashMap<>();
......@@ -89,10 +93,13 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
golangStationMapper.insert(golangStationList);
}
}
@Scheduled(cron =dataRequstScheduled )
@Scheduled(cron = dataRequstScheduled)
@Override
public void stationDetail() {
List<String> stationIds = golangStationMapper.getStationIds();
String today = DateUtil.today();
String hour = new Date().getHours() + ":00";
for (int i = 0; i < stationIds.size(); i++) {
try {
TimeUnit.SECONDS.sleep(1);
......@@ -127,7 +134,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
jpStation.setLatitude(golangStationDetail.getLatitude());
jpStation.setUserName(golangStationDetail.getUsername());
jpStation.setUserPhone(String.valueOf(golangStationDetail.getUsermobile()));
jpStation.setStationContact(String.valueOf(golangStationDetail.getMobile()));
jpStation.setStationContact(StrUtil.nullToDefault(String.valueOf(golangStationDetail.getMobile()), ""));
jpStation.setModuleCount(Math.toIntExact(golangStationDetail.getModule()));
//并网类型
jpStation.setOnGridType(GoLangConstant.stationStaus.get(String.valueOf(golangStationDetail.getState())));
......@@ -149,18 +156,37 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
jpStationMapper.insert(jpStation);
}
HYGFJPStationPowerHistory hygfjpStationPowerHistory = new HYGFJPStationPowerHistory();
hygfjpStationPowerHistory = new HYGFJPStationPowerHistory();
hygfjpStationPowerHistory.setCreatedTime(System.currentTimeMillis());
hygfjpStationPowerHistory.setThirdStationId(jpStation.getThirdStationId());
hygfjpStationPowerHistory.setPower(jpStation.getRealTimePower());
hygfjpStationPowerHistory.setThirdCode(jpStation.getThirdCode());
hygfjpStationPowerHistory.setTime(System.currentTimeMillis());
golangStationDetailMapper.updateById(golangStationDetail);
hygfjpStationPowerHistoryMapper.insert(hygfjpStationPowerHistory);
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper.selectOne(new QueryWrapper<HYGFJPDayPower>().
eq("tation_id", String.valueOf(golangStationDetail.getId())).
eq("year_month_day", today).
eq("hour", hour)
);
if (ObjectUtils.isEmpty(hygfjpDayPower)) {
hygfjpDayPower = new HYGFJPDayPower();
}
hygfjpDayPower = new HYGFJPDayPower();
hygfjpDayPower.setTationId(String.valueOf(golangStationDetail.getId()));
hygfjpDayPower.setHour(hour);
hygfjpDayPower.setYearMonthDay(today);
hygfjpDayPower.setPower(golangStationDetail.getPower());
if (ObjectUtils.isEmpty(hygfjpDayPower.getCreatedTime())) {
hygfjpDayPower.setCreatedTime(System.currentTimeMillis());
hygfjpDayPowerMapper.insert(hygfjpDayPower);
} else {
hygfjpDayPowerMapper.insert(hygfjpDayPower);
}
}
}
}
@Scheduled(cron =dataRequstScheduled )
@Scheduled(cron = dataRequstScheduled)
@Override
public void collectorList() {
List<String> stationIds = golangStationMapper.getStationIds();
......@@ -188,7 +214,8 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
}
}
}
@Scheduled(cron =dataRequstScheduled )
@Scheduled(cron = dataRequstScheduled)
@Override
public void collectorDetail() {
List<Long> collectorIds = golangCollectorListMapper.getCollectIds();
......@@ -255,7 +282,8 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
}
}
}
@Scheduled(cron =dataRequstScheduled )
@Scheduled(cron = dataRequstScheduled)
@Override
public void inverterList() {
List<String> stationIds = golangStationMapper.getStationIds();
......@@ -283,7 +311,8 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
}
}
}
@Scheduled(cron =dataRequstScheduled )
@Scheduled(cron = dataRequstScheduled)
@Override
public void inverterDetail() {
List<Long> inverterIds = golangInverterListMapper.getInverterIds();
......@@ -418,7 +447,8 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
}
}
}
@Scheduled(cron =dataRequstScheduled )
@Scheduled(cron = dataRequstScheduled)
@Override
public void inverAlramInfo() {
List<String> inverterIds = golangInverterListMapper.getInverterSns();
......@@ -443,20 +473,33 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
);
for (int j = 0; j < result.size(); j++) {
AlarmDto alarmDto = result.get(j);
HYGFJPInverterWarn hygfjpInverterWarn = new HYGFJPInverterWarn();
hygfjpInverterWarn.setCreatedTime(System.currentTimeMillis());
hygfjpInverterWarn.setTime(System.currentTimeMillis());
hygfjpInverterWarn.setTimeLong(System.currentTimeMillis());
hygfjpInverterWarn.setSnCode(alarmDto.getAlarmDeviceSn());
hygfjpInverterWarn.setThirdCode(String.valueOf(alarmDto.getStationId()));
hygfjpInverterWarn.setLevel(GoLangConstant.alarmLevel.get(alarmDto.getAlarmLevel()));
hygfjpInverterWarn.setContent(alarmDto.getAlarmMsg());
hygfjpInverterWarn.setThirdCode(PVProducerInfoEnum.JLY.getCode());
hygfjpInverterWarn.setTreatment(alarmDto.getAdvice());
hygfjpInverterWarn.setStartTime(alarmDto.getAlarmBeginTime());
hygfjpInverterWarn.setRecoverTime(alarmDto.getAlarmEndTime());
hygfjpInverterWarn.setState(GoLangConstant.alarmstatus.get(alarmDto.getState()));
hygfjpInverterWarnMapper.insert(hygfjpInverterWarn);
if (!ObjectUtils.isEmpty(alarmDto.getAlarmDeviceSn())) {
HYGFJPInverterWarn hygfjpInverterWarn = hygfjpInverterWarnMapper.selectOne(new QueryWrapper<HYGFJPInverterWarn>()
.eq("sn_code", alarmDto.getAlarmDeviceSn())
.eq("start_time", alarmDto.getAlarmBeginTime())
.eq("third_station_id", String.valueOf(alarmDto.getStationId()))
);
if (ObjectUtils.isEmpty(hygfjpInverterWarn)) {
hygfjpInverterWarn = new HYGFJPInverterWarn();
}
hygfjpInverterWarn.setTime(System.currentTimeMillis());
hygfjpInverterWarn.setTimeLong(System.currentTimeMillis());
hygfjpInverterWarn.setSnCode(alarmDto.getAlarmDeviceSn());
hygfjpInverterWarn.setThirdStationId(String.valueOf(alarmDto.getStationId()));
hygfjpInverterWarn.setLevel(GoLangConstant.alarmLevel.get(alarmDto.getAlarmLevel()));
hygfjpInverterWarn.setContent(alarmDto.getAlarmMsg());
hygfjpInverterWarn.setThirdCode(PVProducerInfoEnum.JLY.getCode());
hygfjpInverterWarn.setTreatment(alarmDto.getAdvice());
hygfjpInverterWarn.setStartTime(alarmDto.getAlarmBeginTime());
hygfjpInverterWarn.setRecoverTime(alarmDto.getAlarmEndTime());
hygfjpInverterWarn.setState(GoLangConstant.alarmstatus.get(alarmDto.getState()));
if (ObjectUtils.isEmpty(hygfjpInverterWarn.getCreatedTime())) {
hygfjpInverterWarn.setCreatedTime(System.currentTimeMillis());
hygfjpInverterWarnMapper.insert(hygfjpInverterWarn);
} else {
hygfjpInverterWarnMapper.insert(hygfjpInverterWarn);
}
}
}
}
}
......
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