Commit 1093b6b2 authored by caotao's avatar caotao

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

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