Commit 83241be3 authored by caotao's avatar caotao

固德威场站数据入库到mysql、tdengine

parent c8cfba5f
package com.yeejoin.amos.api.householdapi.face.dto;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;
@Data
public class GoodWeStationMonitorDto {
private String powerstation_id;
private String stationname;
private String first_letter;
private String adcode;
private String location;
private Integer status;
private Double pac;
private Double capacity;
private Double eday;
private Double emonth;
private Double eday_income;
private Double etotal;
private Double etotal_income;
private String powerstation_type;
private String pre_org_id;
private String org_id;
private String longitude;
private String latitude;
private Double pac_kw;
private Double to_hour;
private String currency;
private Double yield_rate;
}
......@@ -35,7 +35,15 @@ public class GoodWeStationDetail {
private Double pac;
@TableField("eday")
private Double eday;
@TableField(exist = false)
private Double emonth;
@TableField(exist = false)
private Double eday_income;
@TableField("etotal")
private Double etotal;
@TableField(exist = false)
private Double etotal_income;
@TableField(exist = false)
private Double yield_rate;
}
......@@ -25,8 +25,14 @@ public class GoodWeStationMonitorList {
private Double capacity;
@TableField("eday")
private Double eday;
@TableField(exist = false)
private Double eday_income;
@TableField("etotal")
private Double etotal;
@TableField(exist = false)
private Double emonth;
@TableField(exist = false)
private Double etotal_income;
@TableField("powerstation_type")
private String powerstation_type;
@TableField("longitude")
......@@ -37,4 +43,17 @@ public class GoodWeStationMonitorList {
private Double pac_kw;
@TableField("to_hour")
private Double to_hour;
@TableField(exist = false)
private Double currency;
@TableField(exist = false)
private Double yield_rate;
@TableField("address")
private String address;
@TableField("owner_name")
private String owner_name;
@TableField("owner_phone")
private String owner_phone;
@TableField("turnon_time")
private String turnon_time;
}
package com.yeejoin.amos.api.householdapi.face.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.yeejoin.amos.api.householdapi.Utils.GoodWeRequestUtil;
import com.yeejoin.amos.api.householdapi.constant.GoodWeConstant;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.GoodWeStationDetail;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.GoodWeStationMonitorList;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine.GoodWeStationDetailMapper;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine.GoodWeStationMonitorListMapper;
import com.yeejoin.amos.api.householdapi.face.dto.GoodWeStationMonitorDto;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpStation;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.*;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.hygf.JpStationMapper;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine.*;
import com.yeejoin.amos.api.householdapi.face.service.GoodWeDataAcquisitionService;
import com.yeejoin.amos.openapi.enums.PVProducerInfoEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.servlet.server.Jsp;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Service
......@@ -21,18 +29,176 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
GoodWeStationMonitorListMapper goodWeStationMonitorListMapper;
@Autowired
GoodWeStationDetailMapper goodWeStationDetailMapper;
@Autowired
JpStationMapper jpStationMapper;
@Autowired
private HYGFJPStationPowerHistoryMapper hygfjpStationPowerHistoryMapper;
//户用光伏逆变器历史mapper
@Autowired
private HYGFJPInverterHistoryMapper hygfjpInverterHistoryMapper;
//户用光伏采集器历史mapper
@Autowired
private HYGFJPCollectorHistoryMapper hygfjpCollectorHistoryMapper;
//户用光伏逆变器告警
@Autowired
private HYGFJPInverterWarnMapper hygfjpInverterWarnMapper;
//户用光伏逆变器历史mapper
@Autowired
private HYGFJPInverterElecHistoryMapper hygfjpInverterElecHistoryMapper;
//户用光伏日发电量
@Autowired
private HYGFJPDayPowerMapper hygfjpDayPowerMapper;
@Autowired
private TdHYGFStationDayGenerateMapper tdHYGFStationDayGenerateMapper;
@Autowired
private TdHYGFStationMonthGenerateMapper tdHYGFStationMonthGenerateMapper;
@Autowired
private TdHYGFStationYearGenerateMapper tdHYGFStationYearGenerateMapper;
@Autowired
private TdHYGFInverterTotalGenerateMapper tdHYGFInverterTotalGenerateMapper;
@Override
public void stationList() {
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("page_index", 1);
requestInfo.put("page_size", 200);
String requstParam = JSON.toJSONString(requestInfo);
List<GoodWeStationMonitorList> goodWeStationLists =goodWeRequestUtil.getResPonse(GoodWeConstant.stationListStatusUrl, GoodWeConstant.requestPost, requstParam, GoodWeConstant.resovleRule_data_list, GoodWeStationMonitorList.class);
String today = DateUtil.today();
String hour = new Date().getHours() + ":00";
List<GoodWeStationMonitorDto> goodWeStationLists =goodWeRequestUtil.getResPonse(GoodWeConstant.stationListStatusUrl, GoodWeConstant.requestPost, requstParam, GoodWeConstant.resovleRule_data_list, GoodWeStationMonitorDto.class);
if(goodWeStationLists.size()>0){
goodWeStationLists.forEach(goodWeStationList -> {
goodWeStationLists.forEach(goodWeStationMonitorDto -> {
GoodWeStationMonitorList goodWeStationList = new GoodWeStationMonitorList();
BeanUtil.copyProperties(goodWeStationMonitorDto, goodWeStationList);
goodWeStationList.setCreatedTime(System.currentTimeMillis());
goodWeStationMonitorListMapper.insert(goodWeStationList);
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.GDW.getCode()).eq("third_station_id",goodWeStationList.getPowerstation_id()));
if(ObjectUtils.isEmpty(jpStation)){
jpStation = new JpStation();
}
jpStation.setThirdCode(PVProducerInfoEnum.GDW.getCode());
jpStation.setSnCode(goodWeStationList.getPowerstation_id());
jpStation.setCapacity(goodWeStationList.getCapacity());
jpStation.setName(goodWeStationList.getStationname());
jpStation.setPrice(0.42);
jpStation.setAddress(goodWeStationList.getAddress());
jpStation.setLatitude(goodWeStationList.getLatitude());
jpStation.setLongitude(goodWeStationList.getLongitude());
jpStation.setUserName(goodWeStationList.getOwner_name());
jpStation.setUserPhone(goodWeStationList.getOwner_phone());
jpStation.setStationContact(goodWeStationList.getOwner_name());
jpStation.setModuleCount(0);
jpStation.setRealTimePower(goodWeStationList.getYield_rate());
jpStation.setState(GoodWeConstant.stationStaus.get(goodWeStationList.getStatus()));
jpStation.setDayGenerate(goodWeStationList.getEday());
jpStation.setDayIncome(goodWeStationList.getEday_income());
jpStation.setMonthGenerate(goodWeStationList.getEmonth());
if(ObjectUtils.isNotEmpty(goodWeStationList.getEmonth())){
jpStation.setMonthIncome(goodWeStationList.getEmonth()*jpStation.getPrice());
}
jpStation.setYearGenerate(0.0);
jpStation.setYearIncome(0.0);
jpStation.setAccumulatedPower(goodWeStationList.getEtotal());
jpStation.setCumulativeIncome(goodWeStationList.getEtotal_income());
if(ObjectUtils.isEmpty(jpStation.getSequenceNbr())){
jpStation.setCreateTime(new Date(goodWeStationList.getCreatedTime()));
if(ObjectUtils.isNotEmpty(goodWeStationList.getTurnon_time())){
jpStation.setAccessTime(new Date(goodWeStationList.getTurnon_time()));
}
jpStationMapper.insert(jpStation);
}else {
jpStationMapper.updateById(jpStation);
}
HYGFJPStationPowerHistory hygfjpStationPowerHistory = new HYGFJPStationPowerHistory();
hygfjpStationPowerHistory.setCreatedTime(System.currentTimeMillis());
hygfjpStationPowerHistory.setThirdStationId(jpStation.getThirdStationId());
hygfjpStationPowerHistory.setPower(jpStation.getRealTimePower());
hygfjpStationPowerHistory.setThirdCode(jpStation.getThirdCode());
hygfjpStationPowerHistory.setTime(System.currentTimeMillis());
hygfjpStationPowerHistoryMapper.insert(hygfjpStationPowerHistory);
HYGFJPDayPower hygfjpDayPower = hygfjpDayPowerMapper.selectOne(
new QueryWrapper<HYGFJPDayPower>().
eq("tation_id", jpStation.getThirdStationId()).
eq("year_month_day", today).
eq("hour", hour)
);
if (org.springframework.util.ObjectUtils.isEmpty(hygfjpDayPower)) {
hygfjpDayPower = new HYGFJPDayPower();
}
hygfjpDayPower.setTationId(goodWeStationList.getPowerstation_id());
hygfjpDayPower.setHour(hour);
hygfjpDayPower.setYearMonthDay(today);
hygfjpDayPower.setPower(jpStation.getRealTimePower());
if (org.springframework.util.ObjectUtils.isEmpty(hygfjpDayPower.getCreatedTime())) {
hygfjpDayPower.setCreatedTime(System.currentTimeMillis());
hygfjpDayPowerMapper.insert(hygfjpDayPower);
} else {
hygfjpDayPowerMapper.insert(hygfjpDayPower);
}
Date today1 = new Date();
//户用场站日发电量
TdHYGFStationDayGenerate tdHYGFStationDayGenerate = tdHYGFStationDayGenerateMapper.selectOne(new QueryWrapper<TdHYGFStationDayGenerate>()
.eq("third_station_id", jpStation.getThirdStationId())
.eq("day_time", DateUtil.format(today1, "yyyy-MM-dd"))
.eq("year_month", DateUtil.format(today1, "yyyy-MM")));
if (org.springframework.util.ObjectUtils.isEmpty(tdHYGFStationDayGenerate)) {
tdHYGFStationDayGenerate = new TdHYGFStationDayGenerate();
}
tdHYGFStationDayGenerate.setThirdStationId(jpStation.getThirdStationId());
tdHYGFStationDayGenerate.setDayTime(DateUtil.format(today1, "yyyy-MM-dd"));
tdHYGFStationDayGenerate.setYearMonth(DateUtil.format(today1, "yyyy-MM"));
tdHYGFStationDayGenerate.setGenerate(jpStation.getDayGenerate());
tdHYGFStationDayGenerate.setFullhour(goodWeStationList.getTo_hour());
tdHYGFStationDayGenerate.setIncome(jpStation.getDayIncome());
if (org.springframework.util.ObjectUtils.isEmpty(tdHYGFStationDayGenerate.getCreatedTime())) {
tdHYGFStationDayGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFStationDayGenerateMapper.insert(tdHYGFStationDayGenerate);
} else {
tdHYGFStationDayGenerateMapper.insert(tdHYGFStationDayGenerate);
}
//户用场站月发电量
TdHYGFStationMonthGenerate tdHYGFStationMonthGenerate = tdHYGFStationMonthGenerateMapper.selectOne(new QueryWrapper<TdHYGFStationMonthGenerate>()
.eq("third_station_id", jpStation.getThirdStationId())
.eq("month_time", DateUtil.format(today1, "yyyy-MM"))
.eq("year", DateUtil.format(today1, "yyyy")));
if (org.springframework.util.ObjectUtils.isEmpty(tdHYGFStationMonthGenerate)) {
tdHYGFStationMonthGenerate = new TdHYGFStationMonthGenerate();
}
tdHYGFStationMonthGenerate.setThirdStationId(jpStation.getThirdStationId());
tdHYGFStationMonthGenerate.setMonthTime(DateUtil.format(today1, "yyyy-MM"));
tdHYGFStationMonthGenerate.setYear(DateUtil.format(today1, "yyyy"));
tdHYGFStationMonthGenerate.setGenerate(jpStation.getMonthGenerate());
if(ObjectUtils.isNotEmpty(jpStation.getMonthGenerate())){
tdHYGFStationMonthGenerate.setFullhour(jpStation.getMonthGenerate() / jpStation.getCapacity());
}
tdHYGFStationMonthGenerate.setIncome(jpStation.getMonthIncome());
if (org.springframework.util.ObjectUtils.isEmpty(tdHYGFStationMonthGenerate.getCreatedTime())) {
tdHYGFStationMonthGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFStationMonthGenerateMapper.insert(tdHYGFStationMonthGenerate);
} else {
tdHYGFStationMonthGenerateMapper.insert(tdHYGFStationMonthGenerate);
}
//户用场站年发电量
TdHYGFStationYearGenerate tdHYGFStationYearGenerate = tdHYGFStationYearGenerateMapper.selectOne(new QueryWrapper<TdHYGFStationYearGenerate>()
.eq("third_station_id", jpStation.getThirdStationId())
.eq("year_time", DateUtil.format(today1, "yyyy"))
.eq("year", DateUtil.format(today1, "yyyy")));
if (org.springframework.util.ObjectUtils.isEmpty(tdHYGFStationYearGenerate)) {
tdHYGFStationYearGenerate = new TdHYGFStationYearGenerate();
}
tdHYGFStationYearGenerate.setThirdStationId(jpStation.getThirdStationId());
tdHYGFStationYearGenerate.setYearTime(DateUtil.format(today1, "yyyy"));
tdHYGFStationYearGenerate.setYear(DateUtil.format(today1, "yyyy"));
tdHYGFStationYearGenerate.setGenerate(jpStation.getYearGenerate());
tdHYGFStationYearGenerate.setFullhour(jpStation.getYearGenerate() / jpStation.getCapacity());
tdHYGFStationYearGenerate.setIncome(jpStation.getYearIncome());
if (org.springframework.util.ObjectUtils.isEmpty(tdHYGFStationYearGenerate.getCreatedTime())) {
tdHYGFStationYearGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFStationYearGenerateMapper.insert(tdHYGFStationYearGenerate);
} else {
tdHYGFStationYearGenerateMapper.insert(tdHYGFStationYearGenerate);
}
});
}
}
......@@ -41,7 +207,6 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
public void stationDetail() {
List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
stationIds.forEach(stationId ->{
HashMap<String, Object> requestInfo = new HashMap<>();
String requstParam = JSON.toJSONString(requestInfo);
String apiurl = GoodWeConstant.stationDetailUrl+"?id="+stationId;
......@@ -50,6 +215,16 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
goodWeStationDetails.forEach(goodWeStationDetail -> {
goodWeStationDetail.setCreatedTime(System.currentTimeMillis());
goodWeStationDetailMapper.insert(goodWeStationDetail);
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.GDW.getCode()).eq("third_station_id",goodWeStationDetail.getPowerstation_id()));
if(ObjectUtils.isEmpty(jpStation)){
jpStation = new JpStation();
}
jpStation.setUserName(goodWeStationDetail.getOwner_name());
jpStation.setUserPhone(goodWeStationDetail.getOwner_phone());
jpStation.setStationContact(goodWeStationDetail.getOwner_name());
if(!ObjectUtils.isEmpty(jpStation.getSequenceNbr())){
jpStationMapper.updateById(jpStation);
}
});
}
});
......
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