Commit 1093b6b2 authored by caotao's avatar caotao

锦浪云-定数据采集10分钟更新一次

parent 6c07a322
......@@ -2,9 +2,6 @@ package com.yeejoin.amos.api.householdapi.face.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.druid.support.opds.udf.ExportSelectListColumns;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.api.householdapi.Utils.GolangRequestUtil;
import com.yeejoin.amos.api.householdapi.constant.GoLangConstant;
......@@ -25,12 +22,11 @@ import com.yeejoin.amos.api.householdapi.face.orm.mapper.hygf.JpStationMapper;
import com.yeejoin.amos.openapi.enums.PVProducerInfoEnum;
import fastjson.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import javax.lang.model.util.ElementScanner6;
import java.rmi.AlreadyBoundException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
......@@ -38,9 +34,10 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
@Async
@Service
public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionService {
private final String dataRequstScheduled = "0 0/10 * * * *";
@Autowired
private GolangRequestUtil golangRequestUtil;
@Autowired
......@@ -73,8 +70,8 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
private HYGFJPInverterElecHistoryMapper hygfjpInverterElecHistoryMapper;
@Scheduled(cron =dataRequstScheduled )
@Override
public void stationList() {
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("pageNo", 1);
......@@ -92,7 +89,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
golangStationMapper.insert(golangStationList);
}
}
@Scheduled(cron =dataRequstScheduled )
@Override
public void stationDetail() {
List<String> stationIds = golangStationMapper.getStationIds();
......@@ -163,7 +160,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
}
}
}
@Scheduled(cron =dataRequstScheduled )
@Override
public void collectorList() {
List<String> stationIds = golangStationMapper.getStationIds();
......@@ -191,7 +188,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
}
}
}
@Scheduled(cron =dataRequstScheduled )
@Override
public void collectorDetail() {
List<Long> collectorIds = golangCollectorListMapper.getCollectIds();
......@@ -258,7 +255,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
}
}
}
@Scheduled(cron =dataRequstScheduled )
@Override
public void inverterList() {
List<String> stationIds = golangStationMapper.getStationIds();
......@@ -286,7 +283,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
}
}
}
@Scheduled(cron =dataRequstScheduled )
@Override
public void inverterDetail() {
List<Long> inverterIds = golangInverterListMapper.getInverterIds();
......@@ -338,50 +335,50 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
} else {
jpInverterMapper.insert(jpInverter);
}
String jsonString =JSON.toJSONString(inverterDetailDto);
Map<String,Object> hanlderResult = JSON.parseObject(jsonString,Map.class);
String jsonString = JSON.toJSONString(inverterDetailDto);
Map<String, Object> hanlderResult = JSON.parseObject(jsonString, Map.class);
for (int k = 1; k < 4; k++) {
JpInverterElectricity jpInverterElectricity=jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>().
eq("sn_code",inverterDetailDto.getSn()).
eq("type","交流").
eq("name","AC"+k)
JpInverterElectricity jpInverterElectricity = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>().
eq("sn_code", inverterDetailDto.getSn()).
eq("type", "交流").
eq("name", "AC" + k)
);
if(ObjectUtils.isEmpty(jpInverterElectricity)){
jpInverterElectricity=new JpInverterElectricity();
if (ObjectUtils.isEmpty(jpInverterElectricity)) {
jpInverterElectricity = new JpInverterElectricity();
}
jpInverterElectricity.setInverterId(inverterDetailDto.getId());
jpInverterElectricity.setSnCode(inverterDetailDto.getSn());
jpInverterElectricity.setThirdCode(PVProducerInfoEnum.JLY.getCode());
jpInverterElectricity.setType("交流");
jpInverterElectricity.setName("AC"+k);
jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("uAc"+k).toString()));
jpInverterElectricity.setCurrent(Double.valueOf(hanlderResult.get("iAc"+k).toString()));
if(ObjectUtils.isEmpty(jpInverterElectricity.getSequenceNbr())){
jpInverterElectricity.setName("AC" + k);
jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("uAc" + k).toString()));
jpInverterElectricity.setCurrent(Double.valueOf(hanlderResult.get("iAc" + k).toString()));
if (ObjectUtils.isEmpty(jpInverterElectricity.getSequenceNbr())) {
jpInverterElectricityMapper.insert(jpInverterElectricity);
}else {
} else {
jpInverterElectricityMapper.updateById(jpInverterElectricity);
}
}
for (int k1 = 1; k1 < 33; k1++) {
JpInverterElectricity jpInverterElectricity=jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>().
eq("sn_code",inverterDetailDto.getSn()).
eq("type","直流").
eq("name","PV"+k1)
JpInverterElectricity jpInverterElectricity = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>().
eq("sn_code", inverterDetailDto.getSn()).
eq("type", "直流").
eq("name", "PV" + k1)
);
if(ObjectUtils.isEmpty(jpInverterElectricity)){
jpInverterElectricity=new JpInverterElectricity();
if (ObjectUtils.isEmpty(jpInverterElectricity)) {
jpInverterElectricity = new JpInverterElectricity();
}
jpInverterElectricity.setInverterId(inverterDetailDto.getId());
jpInverterElectricity.setSnCode(inverterDetailDto.getSn());
jpInverterElectricity.setThirdCode(PVProducerInfoEnum.JLY.getCode());
jpInverterElectricity.setType("直流");
jpInverterElectricity.setName("PV"+k1);
jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("uPv"+k1).toString()));
jpInverterElectricity.setCurrent(Double.valueOf(hanlderResult.get("iPv"+k1).toString()));
jpInverterElectricity.setPower(Double.valueOf(hanlderResult.get("pow"+k1).toString()));
if(ObjectUtils.isEmpty(jpInverterElectricity.getSequenceNbr())){
jpInverterElectricity.setName("PV" + k1);
jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("uPv" + k1).toString()));
jpInverterElectricity.setCurrent(Double.valueOf(hanlderResult.get("iPv" + k1).toString()));
jpInverterElectricity.setPower(Double.valueOf(hanlderResult.get("pow" + k1).toString()));
if (ObjectUtils.isEmpty(jpInverterElectricity.getSequenceNbr())) {
jpInverterElectricityMapper.insert(jpInverterElectricity);
}else {
} else {
jpInverterElectricityMapper.updateById(jpInverterElectricity);
}
}
......@@ -400,7 +397,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
hygfjpInverterElecHistoryMapper.insert(hygfjpInverterElecHistory);
// 逆变器历史
String today = DateUtil.today();
HYGFJPInverterHistory hygfjpInverterHistory = hygfjpInverterHistoryMapper.selectOne(new QueryWrapper<HYGFJPInverterHistory>().eq("sn_code", inverterDetailDto.getSn()).eq("date",today));
HYGFJPInverterHistory hygfjpInverterHistory = hygfjpInverterHistoryMapper.selectOne(new QueryWrapper<HYGFJPInverterHistory>().eq("sn_code", inverterDetailDto.getSn()).eq("date", today));
if (ObjectUtils.isEmpty(hygfjpInverterHistory)) {
hygfjpInverterHistory = new HYGFJPInverterHistory();
}
......@@ -421,7 +418,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
}
}
}
@Scheduled(cron =dataRequstScheduled )
@Override
public void inverAlramInfo() {
List<String> inverterIds = golangInverterListMapper.getInverterSns();
......@@ -435,7 +432,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
requestInfo.put("pageNo", 1);
requestInfo.put("pageSize", 100);
requestInfo.put("alarmDeviceSn", inverterIds.get(i));
requestInfo.put("alarmBeginTime",DateUtil.today());
requestInfo.put("alarmBeginTime", DateUtil.today());
requestInfo.put("alarmEndTime", DateUtil.today());
String requestParaminfo = JSON.toJSONString(requestInfo);
List<AlarmDto> result = golangRequestUtil.getResPonse(GoLangConstant.alarmListUrl,
......@@ -446,9 +443,10 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
);
for (int j = 0; j < result.size(); j++) {
AlarmDto alarmDto = result.get(j);
HYGFJPInverterWarn hygfjpInverterWarn=new HYGFJPInverterWarn();
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()));
......
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