Commit ff5b30f8 authored by caotao's avatar caotao

户用光伏数据采集-同步更新mysql数据

parent 05ed8c82
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 户用光伏监盘采集器表
*
* @author system_generator
* @date 2023-09-19
*/
@Data
@Accessors(chain = true)
@TableName("hygf_jp_collector")
public class JpCollector implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 是否删除
*/
@TableField(value = "is_delete")
public Boolean isDelete = false;
@TableId(value = "sequence_nbr", type = IdType.ID_WORKER)
protected Long sequenceNbr;
@TableField(value = "rec_date", fill = FieldFill.INSERT_UPDATE)
protected Date recDate;
@TableField(value = "rec_user_id", fill = FieldFill.INSERT_UPDATE)
protected String recUserId;
@TableField(value = "rec_user_name", fill = FieldFill.INSERT_UPDATE)
protected String recUserName;
/**
* sn编码
*/
@TableField("sn_code")
private String snCode;
/**
* 状态
*/
@TableField("state")
private String state;
/**
* 类型
*/
@TableField("type")
private String type;
/**
* sim卡号
*/
@TableField("sim_code")
private String simCode;
/**
* 数据来源
*/
@TableField("data_source")
private String dataSource;
/**
* 更新时间
*/
@TableField("update_time")
private Date updateTime;
/**
* 采集器版本
*/
@TableField("version")
private String version;
/**
* 出场日期
*/
@TableField("discharge_date")
private Date dischargeDate;
/**
* 生产日期
*/
@TableField("product_date")
private Date productDate;
/**
* 数据上传间隔
*/
@TableField("data_period")
private Double dataPeriod;
/**
* 本次上电工作时间
*/
@TableField("this_work_time")
private Date thisWorkTime;
/**
* 累计工作时间
*/
@TableField("total_work_time")
private Date totalWorkTime;
/**
* 第三方电站id
*/
@TableField("third_station_id")
private String thirdStationId;
/**
* 第三方厂商标识
*/
@TableField("third_code")
private String thirdCode;
}
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 户用光伏监盘逆变器表
*
* @author system_generator
* @date 2023-09-19
*/
@Data
@Accessors(chain = true)
@TableName("hygf_jp_inverter")
public class JpInverter implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "sequence_nbr", type = IdType.ID_WORKER)
protected Long sequenceNbr;
@TableField(value = "rec_date", fill = FieldFill.INSERT_UPDATE)
protected Date recDate;
@TableField(value = "rec_user_id", fill = FieldFill.INSERT_UPDATE)
protected String recUserId;
@TableField(value = "rec_user_name", fill = FieldFill.INSERT_UPDATE)
protected String recUserName;
/**
* 是否删除
*/
@TableField(value = "is_delete")
public Boolean isDelete=false;
/**
* sn编码
*/
@TableField("sn_code")
private String snCode;
/**
* 状态
*/
@TableField("state")
private String state;
/**
* 额定功率
*/
@TableField("rated_power")
private Double ratedPower;
/**
* 采集器id
*/
@TableField("collector_id")
private Long collectorId;
/**
* 采集器sn编码
*/
@TableField("collector_sn_code")
private String collectorSnCode;
/**
* 更新时间
*/
@TableField("update_time")
private Date updateTime;
/**
* 实时功率
*/
@TableField("current_power")
private Double currentPower;
/**
* 日发电量
*/
@TableField("day_power_generation")
private Double dayPowerGeneration;
/**
* 月发电量
*/
@TableField("month_power_generation")
private Double monthPowerGeneration;
/**
* 年发电量
*/
@TableField("year_power_generation")
private Double yearPowerGeneration;
/**
* 品牌
*/
@TableField("brand")
private String brand;
/**
* 型号
*/
@TableField("model")
private String model;
/**
* 国标
*/
@TableField("national_standard")
private String nationalStandard;
/**
* 版本号
*/
@TableField("version")
private String version;
/**
* 满发小时数
*/
@TableField("generation_hours")
private String generationHours;
/**
* 质保期
*/
@TableField("warranty_period")
private String warrantyPeriod;
/**
* IGBT温度
*/
@TableField("IGBT_temperature")
private String igbtTemperature;
/**
* AFCI方案
*/
@TableField("AFCI_programme")
private String afciProgramme;
/**
* AFCI版本
*/
@TableField("AFCI_version")
private String afciVersion;
/**
* ID
*/
@TableField("ID")
private Long id;
/**
* 第三方电站id
*/
@TableField("third_station_id")
private String thirdStationId;
/**
* 装机容量
*/
@TableField("capacity")
private Integer capacity;
/**
* 累计发电量
*/
@TableField("total_power_generation")
private Double totalPowerGeneration;
/**
* 日用电量
*/
@TableField("day_power_use")
private Double dayPowerUse;
/**
* 月用电量
*/
@TableField("month_power_use")
private Double monthPowerUse;
/**
* 年用电量
*/
@TableField("year_power_use")
private Double yearPowerUse;
}
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 户用光伏监盘逆变器电能表
*
* @author system_generator
* @date 2023-09-19
*/
@Data
@Accessors(chain = true)
@TableName("hygf_jp_inverter_electricity")
public class JpInverterElectricity implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "sequence_nbr", type = IdType.ID_WORKER)
protected Long sequenceNbr;
@TableField(value = "rec_date", fill = FieldFill.INSERT_UPDATE)
protected Date recDate;
@TableField(value = "rec_user_id", fill = FieldFill.INSERT_UPDATE)
protected String recUserId;
@TableField(value = "rec_user_name", fill = FieldFill.INSERT_UPDATE)
protected String recUserName;
/**
* 是否删除
*/
@TableField(value = "is_delete")
public Boolean isDelete=false;
/**
* 逆变器id
*/
@TableField("inverter_id")
private Long inverterId;
/**
* sn编码
*/
@TableField("sn_code")
private String snCode;
/**
* 电能名称
*/
@TableField("name")
private String name;
/**
* 电能类型(直流/交流)
*/
@TableField("type")
private String type;
/**
* 电压
*/
@TableField("voltage")
private Double voltage;
/**
* 电流
*/
@TableField("current")
private Double current;
/**
* 功率
*/
@TableField("power")
private Double power;
/**
* 频率
*/
@TableField("frequency")
private Double frequency;
/**
* 第三方电站id
*/
@TableField("third_station_id")
private String thirdStationId;
/**
* 第三方厂商标识
*/
@TableField("third_code")
private String thirdCode;
}
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 户用光伏监盘人员场站关系表
*
* @author system_generator
* @date 2023-09-19
*/
@Data
@Accessors(chain = true)
@TableName("hygf_jp_person_station")
public class JpPersonStation implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "sequence_nbr", type = IdType.ID_WORKER)
protected Long sequenceNbr;
@TableField(value = "rec_date", fill = FieldFill.INSERT_UPDATE)
protected Date recDate;
@TableField(value = "rec_user_id", fill = FieldFill.INSERT_UPDATE)
protected String recUserId;
@TableField(value = "rec_user_name", fill = FieldFill.INSERT_UPDATE)
protected String recUserName;
/**
* 是否删除
*/
@TableField(value = "is_delete")
public Boolean isDelete=false;
/**
* 人员id
*/
@TableField("person_id")
private String personId;
/**
* 场站id
*/
@TableField("station_id")
private Long stationId;
/**
* 场站名称
*/
@TableField("station_name")
private String stationName;
/**
* 业主名称
*/
@TableField("owner")
private String owner;
}
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* 第三方场站
*
* @author system_generator
* @date 2023-09-19
*/
@Data
@Accessors(chain = true)
@TableName("hygf_jp_station")
public class JpStation implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(value = "sequence_nbr", type = IdType.ID_WORKER)
protected Long sequenceNbr;
@TableField(value = "rec_date", fill = FieldFill.INSERT_UPDATE)
protected Date recDate;
@TableField(value = "rec_user_id", fill = FieldFill.INSERT_UPDATE)
protected String recUserId;
@TableField(value = "rec_user_name", fill = FieldFill.INSERT_UPDATE)
protected String recUserName;
/**
* 是否删除
*/
@TableField(value = "is_delete")
public Boolean isDelete=false;
/**
* sn编码
*/
@TableField("sn_code")
private String snCode;
/**
* 装机容量
*/
@TableField("capacity")
private Double capacity;
/**
* 电站名称
*/
@TableField("name")
private String name;
/**
* 电站编码
*/
@TableField("code")
private String code;
/**
* 组织编码
*/
@TableField("system_code")
private String systemCode;
/**
* 接入平台时间
*/
@TableField("access_time")
private Date accessTime;
/**
* 创建时间
*/
@TableField("create_time")
private Date createTime;
/**
* 地址
*/
@TableField("address")
private String address;
/**
* 经度
*/
@TableField("longitude")
private String longitude;
/**
* 维度
*/
@TableField("latitude")
private String latitude;
/**
* 上网电价
*/
@TableField("price")
private Double price;
/**
* 业主姓名
*/
@TableField("user_name")
private String userName;
/**
* 业主电话
*/
@TableField("user_phone")
private String userPhone;
/**
* 电站联系人
*/
@TableField("station_contact")
private String stationContact;
/**
* 组件数量
*/
@TableField("module_count")
private Integer moduleCount;
/**
* 并网类型
*/
@TableField("on_grid_type")
private String onGridType;
/**
* 并网时间
*/
@TableField("on_grid_time")
private Date onGridTime;
/**
* 第三方电站id
*/
@TableField("third_station_id")
private String thirdStationId;
/**
* 电站id
*/
@TableField("station_id")
private Long stationId;
/**
* 第三方厂商标识
*/
@TableField("third_code")
private String thirdCode;
/**
* 实时功率
*/
@TableField("real_time_power")
private Double realTimePower;
/**
* 累计发电量
*/
@TableField("accumulated_power")
private Double accumulatedPower;
/**
* 状态
*/
@TableField("state")
private String state;
/**
* 电站类型
*/
@TableField("type")
private String type ;
/**
* 组织编码
*/
@TableField("organizational_code")
private String organizationalCode;
//日发电量
@TableField("day_generate")
private Double dayGenerate;
//月发电量
@TableField("month_generate")
private Double monthGenerate;
//年发电量
@TableField("year_generate")
private Double yearGenerate;
//日收益
@TableField("day_income")
private Double dayIncome;
//月收益
@TableField("month_income")
private Double monthIncome;
// 年收益
@TableField("year_income")
private Double yearIncome;
//地区
@TableField("area")
private String area;
//累计收益
@TableField("cumulative_income")
private Double cumulativeIncome;
@TableField("day_power_use")
private Double dayPowerUse; // 日用电量
@TableField("month_power_use")
private Double monthPowerPse; // 月用电量
@TableField("year_power_use")
private Double yearPowerUse; // 年用电量
}
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.models.auth.In;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
@TableName(value = "golang_station_detail", autoResultMap = true)
public class GolangStationDetail implements Serializable {
private Date createdTime;
private Long id;
private String stationname;
private String addr;
private Long userid;
private String username;
private Long usermobile;
private String useremail;
private String capacity;
private String capacitystr;
private Double dayenergy;
private String dayenergystr;
private Double batterytotaldischargeenergy;
private Double batterytotalchargeenergy;
private Double gridpurchasedtotalenergy;
private Double gridselltotalenergy;
private Double homeloadtotalenergy;
private Double oneself;
private Double batterytodaydischargeenergy;
private Double batterytodaychargeenergy;
private Double gridpurchasedtodayenergy;
private Double gridselltodayenergy;
private Double homeloadtodayenergy;
private String money;
private Long fispowertime;
private Long fisgeneratetime;
private String remark1;
private String remark2;
private String remark3;
private Integer state;
private Long datatimestamp;
private String inverterpower;
private String nmicode;
private Double monthenergy;
private String monthenergystr;
private Double yearenergy;
private String yearenergystr;
private Double allenergy;
private String allenergystr;
private Double dayincome;
private String dayincomeunit;
private Double monthincome;
private String monthincomeunit;
private Double yearincome;
private String yearincomeunit;
private Double allincome;
private String allincomeunit;
private Double fullhour;
private String picname;
private Double power;
private String powerstr;
private String latitude;
private String longitude;
private Double dip;
private Double azimuth;
private String price;
private String brand;
private String condtxtn;
private String condtxtd;
private String tmpmax;
private String tmpmin;
private String tmpunit;
private String sr;
private String ss;
private String windspd;
private String winddir;
private String powerstationnumtree;
private String powerstationnumtreeunit;
private String powerstationavoidedco2;
private String powerstationavoidedco2unit;
private Long module;
private Long mobile;
private String installeremail;
private Long installermobile;
private Double batterypower;
private String batterypowerstr;
private Double batterypowerpec;
private Double batterydischargeenergy;
private String batterydischargeenergystr;
private Double batterychargeenergy;
private String batterychargeenergystr;
private Double batterypercent;
private Double batterydischargemonthenergy;
private String batterydischargemonthenergystr;
private Double batterydischargeyearenergy;
private String batterydischargeyearenergystr;
private Double batterydischargetotalenergy;
private String batterydischargetotalenergystr;
private Double batterychargemonthenergy;
private String batterychargemonthenergystr;
private Double batterychargeyearenergy;
private String batterychargeyearenergystr;
private Double batterychargetotalenergy;
private String batterychargetotalenergystr;
private Double psum;
private String psumstr;
private Double psumpec;
private Double gridpurchaseddayenergy;
private String gridpurchaseddayenergystr;
private Double gridpurchasedmonthenergy;
private String gridpurchasedmonthenergystr;
private Double gridpurchasedyearenergy;
private String gridpurchasedyearenergystr;
private String gridpurchasedtotalenergystr;
private Double gridselldayenergy;
private String gridselldayenergystr;
private Double gridsellmonthenergy;
private String gridsellmonthenergystr;
private Double gridsellyearenergy;
private String gridsellyearenergystr;
private String gridselltotalenergystr;
private Double familyloadpower;
private String familyloadpowerstr;
private Double familyloadpowerpec;
private Double homeloadenergy;
private String homeloadenergystr;
private Double homeloadmonthenergy;
private String homeloadmonthenergystr;
private Double homeloadyearenergy;
private String homeloadyearenergystr;
private String homeloadtotalenergystr;
private Integer country;
private String countrystr;
private Integer region;
private String regionstr;
private Integer city;
private String citystr;
private Integer county;
private String countystr;
private Double timezone;
private String timezonename;
private String timezonestr;
private Long timezoneid;
private Double daylight;
private Long createdate;
private Integer stationtypenew;
}
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.GolangStationDetail;
public interface GolangStationDetailMapper extends BaseMapper<GolangStationDetail> {
}
package com.yeejoin.amos.api.householdapi.face.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.api.householdapi.Utils.GolangRequestUtil;
import com.yeejoin.amos.api.householdapi.constant.GoLangConstant;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpStation;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.GolangStationDetail;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.GolangStationList;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine.GolangStationDetailMapper;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine.GolangStationMapper;
import com.yeejoin.amos.api.householdapi.face.service.GoLangDataAcquisitionService;
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.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Service
public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionService {
@Autowired
private GolangRequestUtil golangRequestUtil;
@Autowired
private GolangStationMapper golangStationMapper;
@Autowired
private JpStationMapper jpStationMapper;
@Autowired
private GolangStationDetailMapper golangStationDetailMapper;
public void stationList() {
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("pageNo", 1);
requestInfo.put("pageSize", 100);
String requestParaminfo = JSON.toJSONString(requestInfo);
List<GolangStationList> result = golangRequestUtil.getResPonse(GoLangConstant.stationListUrl,
GoLangConstant.requestPost,
requestParaminfo,
GoLangConstant.resovleRule_data_page_records,
GolangStationList.class
);
for (int i = 0; i < result.size(); i++) {
GolangStationList golangStationList = result.get(i);
golangStationList.setCreatedTime(new Date());
golangStationMapper.insert(golangStationList);
}
}
@Override
public void stationDetail() {
List<String> stationIds = golangStationMapper.getStationIds();
for (int i = 0; i < stationIds.size(); i++) {
try {
TimeUnit.SECONDS.sleep(1);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("id", Long.valueOf(stationIds.get(i)));
String requestParaminfo = JSON.toJSONString(requestInfo);
List<GolangStationDetail> result = golangRequestUtil.getResPonse(GoLangConstant.stationDetailUrl,
GoLangConstant.requestPost,
requestParaminfo,
GoLangConstant.resovleRule_data,
GolangStationDetail.class
);
for (int j = 0; j < result.size(); j++) {
GolangStationDetail golangStationDetail = result.get(j);
golangStationDetail.setCreatedTime(new Date());
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.JLY.getCode()).eq("third_station_id", stationIds.get(i)));
//给户用光伏存储的数据赋值
if (ObjectUtils.isEmpty(jpStation)) {
jpStation = new JpStation();
}
jpStation.setSnCode(golangStationDetail.getNmicode());
jpStation.setCapacity(Double.valueOf(golangStationDetail.getCapacity()));
jpStation.setName(golangStationDetail.getStationname());
jpStation.setPrice(Double.valueOf(golangStationDetail.getPrice()));
jpStation.setAddress(golangStationDetail.getAddr());
jpStation.setLongitude(golangStationDetail.getLongitude());
jpStation.setLatitude(golangStationDetail.getLatitude());
jpStation.setUserName(golangStationDetail.getUsername());
jpStation.setUserPhone(String.valueOf(golangStationDetail.getUsermobile()));
jpStation.setStationContact(String.valueOf(golangStationDetail.getMobile()));
jpStation.setModuleCount(Math.toIntExact(golangStationDetail.getModule()));
//并网类型
jpStation.setOnGridType(GoLangConstant.stationStaus.get(String.valueOf(golangStationDetail.getState())));
jpStation.setThirdStationId(String.valueOf(golangStationDetail.getId()));
jpStation.setThirdCode(PVProducerInfoEnum.JLY.getCode());
jpStation.setRealTimePower(golangStationDetail.getPower());
jpStation.setState(GoLangConstant.intoNetWorkStatus.get(String.valueOf(golangStationDetail.getStationtypenew())));
jpStation.setDayGenerate(golangStationDetail.getDayenergy());
jpStation.setMonthGenerate(golangStationDetail.getMonthenergy());
jpStation.setYearGenerate(golangStationDetail.getYearenergy());
jpStation.setDayIncome(golangStationDetail.getDayincome());
jpStation.setMonthIncome(golangStationDetail.getMonthincome());
jpStation.setYearIncome(golangStationDetail.getYearincome());
jpStation.setCumulativeIncome(golangStationDetail.getAllincome());
jpStation.setArea(golangStationDetail.getRegionstr());
if (!ObjectUtils.isEmpty(jpStation.getSequenceNbr())) {
jpStationMapper.updateById(jpStation);
} else {
jpStationMapper.insert(jpStation);
}
golangStationDetailMapper.insert(golangStationDetail);
}
}
}
}
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