Commit b20197e3 authored by tangwei's avatar tangwei

首航采集

parent c8cfba5f
...@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONArray; ...@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.api.householdapi.constant.GoodWeConstant; import com.yeejoin.amos.api.householdapi.constant.GoodWeConstant;
import com.yeejoin.amos.api.householdapi.constant.SoFarConstant; import com.yeejoin.amos.api.householdapi.constant.SoFarConstant;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.Sunlight;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -21,6 +22,32 @@ public class SofarRequestUtil { ...@@ -21,6 +22,32 @@ public class SofarRequestUtil {
private final String redisKey = "SOFAR_REQUEST_TOKEN"; private final String redisKey = "SOFAR_REQUEST_TOKEN";
public static final HashMap<String, String> intoNetWorkStatus = new HashMap<String, String>() {
{
put("DISTRIBUTED_FULLY", "分布式全额上网");
put("EXCESS", "分布式自发自用余电上网");
put("OFF_GRID", "离网");
put("BATTERY_BACKUP", "储能系统");
put("GROUND_FULLY", "地面全额上网");
}
};
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
...@@ -65,8 +92,6 @@ public class SofarRequestUtil { ...@@ -65,8 +92,6 @@ public class SofarRequestUtil {
*/ */
public <T> List<T> getResPonse(String apiurl, String requestMethod, String requestParmInfo, String ResultResolveRule, Class<T> tClass) { public <T> List<T> getResPonse(String apiurl, String requestMethod, String requestParmInfo, String ResultResolveRule, Class<T> tClass) {
String respone = ""; String respone = "";
String params = "";
JSONArray jsonArray = null;
List<T> result = new ArrayList<>(); List<T> result = new ArrayList<>();
try { try {
...@@ -74,16 +99,36 @@ public class SofarRequestUtil { ...@@ -74,16 +99,36 @@ public class SofarRequestUtil {
String url = SoFarConstant.baseurl + apiurl; String url = SoFarConstant.baseurl + apiurl;
respone = sendRequest(requestMethod, url, requestParmInfo, headMap); respone = sendRequest(requestMethod, url, requestParmInfo, headMap);
JSONObject jsonObject = JSONObject.parseObject(respone); JSONObject jsonObject = JSONObject.parseObject(respone);
// jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone); if(jsonObject!=null&&jsonObject.get(ResultResolveRule)!=null){
// if (!ObjectUtils.isEmpty(jsonArray)) { result = JSONArray.parseArray(fastjson.JSON.toJSONString(jsonObject.get(ResultResolveRule)), tClass);
// result = JSONArray.parseArray(jsonArray.toJSONString(), tClass);
// } }
} catch (Exception exception) { } catch (Exception exception) {
return result; exception.printStackTrace();
} }
return result; return result;
} }
public JSONObject getResPonseobj(String apiurl, String requestMethod, String requestParmInfo, String ResultResolveRule) {
String respone = "";
JSONObject jsonObject = null;
try {
HashMap<String, String> headMap = getHeaderOfSofar();
String url = SoFarConstant.baseurl + apiurl;
respone = sendRequest(requestMethod, url, requestParmInfo, headMap);
if(respone!=null&&JSONObject.parseObject(respone).get(ResultResolveRule)!=null&&ResultResolveRule!=null){
jsonObject = JSONObject.parseObject(JSONObject.parseObject(respone).get(ResultResolveRule).toString());
}else{
jsonObject = JSONObject.parseObject(respone);
}
} catch (Exception exception) {
exception.printStackTrace();
}
return jsonObject;
}
/** /**
* @param resultResovle 请求返回的解析规则 来源与数据库 * @param resultResovle 请求返回的解析规则 来源与数据库
* @param response 请求返回的字符串 * @param response 请求返回的字符串
......
...@@ -9,13 +9,16 @@ import java.util.HashMap; ...@@ -9,13 +9,16 @@ import java.util.HashMap;
public class SoFarConstant { public class SoFarConstant {
public static final HashMap<String, String> stationStaus = new HashMap<String, String>() { public static final HashMap<String, String> stationStaus = new HashMap<String, String>() {
{ {
put("-1", "离线"); put("1", "在线");
put("0", "待机"); put("0", "离线");
put("1", "正常"); put("2","报警" );
put("2", "停机");
} }
}; };
public static String baseurl = "https://openapi.sofarsolarmonitor.com"; public static String baseurl = "https://openapi.sofarsolarmonitor.com";
public static String appId = "447430219192733696"; public static String appId = "447430219192733696";
public static String appSecret = "5881ee8c062817016a2b34425c45937d"; public static String appSecret = "5881ee8c062817016a2b34425c45937d";
...@@ -26,6 +29,12 @@ public class SoFarConstant { ...@@ -26,6 +29,12 @@ public class SoFarConstant {
public static String tokenurl = "/account/auth/createToken"; public static String tokenurl = "/account/auth/createToken";
public static String stationListUrl = "/station/v1.0/list"; public static String stationListUrl = "/station/v1.0/list";
public static String stationUrl = "/station/v1.0/base";
public static String currentData = "/device/v1.0/currentData";
public static String nbqlist = "/station/v1.0/device?language=zh";
public static String historical = "/device/v1.0/historical";
public static String stationListStatusUrl = "/api/OpenApi/QueryPowerStationMonitor"; public static String stationListStatusUrl = "/api/OpenApi/QueryPowerStationMonitor";
public static String stationDetailUrl = "/api/OpenApi/GetPowerStationMonitorDetail"; public static String stationDetailUrl = "/api/OpenApi/GetPowerStationMonitorDetail";
public static String collectorListUrl = "/v1/api/collectorList"; public static String collectorListUrl = "/v1/api/collectorList";
...@@ -42,7 +51,11 @@ public class SoFarConstant { ...@@ -42,7 +51,11 @@ public class SoFarConstant {
public static String resovleRule_data_page_records = "data,page,records"; public static String resovleRule_data_page_records = "data,page,records";
public static String resovleRule_data_list = "data,list"; public static String resovleRule_data_list = "data,list";
public static String resovleRule_data_records = "data,records"; public static String resovleRule_data_records = "data,records";
public static String resovleRule_data = "data"; public static String resovleRule_data = "stationList";
public static String deviceListItems = "deviceListItems";
public static String dataList = "dataList";
public static String paramDataList = "paramDataList";
public static String requestPost = "POST"; public static String requestPost = "POST";
public static String requestGet = "GET"; public static String requestGet = "GET";
public static String datePattern = "yyyy-MM-dd HH:mm:ss.SSS"; public static String datePattern = "yyyy-MM-dd HH:mm:ss.SSS";
......
package com.yeejoin.amos.api.householdapi.face.dto;
import lombok.Data;
/**
* @description:
* @author: tw
* @createDate: 2024/3/8
*/
@Data
public class SofarInverterDto {
private String key;
private String value;
private String name;
private String unit;
}
package com.yeejoin.amos.api.householdapi.face.dto;
import lombok.Data;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2024/3/8
*/
@Data
public class Sofarhistorical {
private String collectTime;
private List<SofarInverterDto> dataList;
}
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
* @description:
* @author: tw
* @createDate: 2024/3/7
*/
@Data
@TableName(value = "sofar_inverter_list" ,autoResultMap = true)
public class SofarInverter {
private Long deviceId;// 设备ID
private String deviceSn;// 设备SN
private Integer connectStatus;// 设备当前状态(1在线;2报警;3离线)
private String deviceType;// 设备类型(1逆变器;2采集器;3电表;4电池;5汇流箱;)
private Long collectionTime;// 设备更新时间
}
package com.yeejoin.amos.api.householdapi.face.service; package com.yeejoin.amos.api.householdapi.face.service;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpStation;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.SofarInverter;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.SofarStationList;
import java.util.List;
import java.util.Map;
public interface SofarDataAcquisitionService { public interface SofarDataAcquisitionService {
/** /**
* @descrption 场站列表数据入库 * @descrption 场站列表数据入库
...@@ -8,11 +15,11 @@ public interface SofarDataAcquisitionService { ...@@ -8,11 +15,11 @@ public interface SofarDataAcquisitionService {
/** /**
* @descrption 场站详情数据入库 * @descrption 场站详情数据入库
*/ */
void stationDetail(); void stationDetail(List<SofarStationList> jsonObject);
/** /**
* @descrption 采集器列表数据入库 * @descrption 采集器列表数据入库
*/ */
void collectorList(); void collectorList( List<SofarStationList> jsonObject);
/** /**
* @descrption 采集器详情数据入库 * @descrption 采集器详情数据入库
*/ */
...@@ -20,7 +27,7 @@ public interface SofarDataAcquisitionService { ...@@ -20,7 +27,7 @@ public interface SofarDataAcquisitionService {
/** /**
* @descrption 逆变器列表数据入库 * @descrption 逆变器列表数据入库
*/ */
void inverterList(); void inverterList(SofarInverter sofarInverter, JpStation jpStation, Map<String, String> maps);
/** /**
* @descrption 逆变器详情数据入库 * @descrption 逆变器详情数据入库
*/ */
......
package com.yeejoin.amos.api.householdapi.face.service.impl; package com.yeejoin.amos.api.householdapi.face.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.api.householdapi.Utils.SofarRequestUtil; import com.yeejoin.amos.api.householdapi.Utils.SofarRequestUtil;
import com.yeejoin.amos.api.householdapi.Utils.SunlightUtil;
import com.yeejoin.amos.api.householdapi.constant.KSolarConstant;
import com.yeejoin.amos.api.householdapi.constant.SoFarConstant; import com.yeejoin.amos.api.householdapi.constant.SoFarConstant;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.GolangStationList; import com.yeejoin.amos.api.householdapi.face.dto.Device;
import com.yeejoin.amos.api.householdapi.face.dto.SofarInverterDto;
import com.yeejoin.amos.api.householdapi.face.dto.Sofarhistorical;
import com.yeejoin.amos.api.householdapi.face.dto.SunlightDto;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpCollector;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpInverter;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpInverterElectricity;
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.JpCollectorMapper;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.hygf.JpInverterElectricityMapper;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.hygf.JpInverterMapper;
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.SofarDataAcquisitionService; import com.yeejoin.amos.api.householdapi.face.service.SofarDataAcquisitionService;
import com.yeejoin.amos.openapi.enums.PVProducerInfoEnum;
import fastjson.JSON; import fastjson.JSON;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.HashMap;
import java.util.Map;
@Service @Service
public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionService { public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionService {
@Autowired @Autowired
private SofarRequestUtil requestUtil; private SofarRequestUtil requestUtil;
@Autowired
private JpInverterMapper jpInverterMapper;
@Autowired
SofarStationListMapper sofarStationListMapper;
@Autowired
private TdHYGFInverterDayGenerateMapper tdHYGFInverterDayGenerateMapper;
@Autowired
private TdHYGFInverterMonthGenerateMapper tdHYGFInverterMonthGenerateMapper;
@Autowired
private TdHYGFInverterYearGenerateMapper tdHYGFInverterYearGenerateMapper;
@Autowired
private TdHYGFStationDayGenerateMapper tdHYGFStationDayGenerateMapper;
@Autowired
private TdHYGFStationMonthGenerateMapper tdHYGFStationMonthGenerateMapper;
@Autowired
private TdHYGFStationYearGenerateMapper tdHYGFStationYearGenerateMapper;
@Autowired
private TdHYGFInverterTotalGenerateMapper tdHYGFInverterTotalGenerateMapper;
@Autowired
private JpInverterElectricityMapper jpInverterElectricityMapper;
//户用光伏逆变器告警
@Autowired
private HYGFJPInverterWarnMapper hygfjpInverterWarnMapper;
@Autowired
private JpStationMapper jpStationMapper;
@Autowired
private HYGFJPCollectorHistoryMapper hygfjpCollectorHistoryMapper;
@Autowired
private JpCollectorMapper jpCollectorMapper;
@Override @Override
@Scheduled(cron = "${dataRequstScheduled.Sofar}")
public void stationList() { public void stationList() {
Map<String, Object> requestInfo = new HashMap<>(); Map<String, Object> requestInfo = new HashMap<>();
requestInfo.put("page", 1); requestInfo.put("page", 1);
requestInfo.put("size", 1000); requestInfo.put("size", 1000);
String param = JSON.toJSONString(requestInfo); String param = JSON.toJSONString(requestInfo);
requestUtil.getResPonse(SoFarConstant.stationListUrl,SoFarConstant.requestPost, param, SoFarConstant.resovleRule_data, GolangStationList.class); List<SofarStationList> jsonObject= requestUtil.getResPonse(
SoFarConstant.stationListUrl,
SoFarConstant.requestPost,
param,
SoFarConstant.resovleRule_data,
SofarStationList.class);
//新增td电站
for (SofarStationList sunlight : jsonObject) {
sunlight.setCreatedTime(System.currentTimeMillis());
sofarStationListMapper.insert(sunlight);
}
//mysql电站信息
this.stationDetail(jsonObject);
} }
@Override @Override
public void stationDetail() { public void stationDetail(List<SofarStationList> list) {
//业务表场站
List<JpStation> jpStations = jpStationMapper.selectList(new QueryWrapper<JpStation>().
eq("third_code", PVProducerInfoEnum.SH.getCode()));
Map<String, JpStation> bodyparam=new HashMap<>();
if(jpStations!=null&&jpStations.size()>0){
bodyparam = jpStations.stream().collect(Collectors.toMap(JpStation::getThirdStationId, Function.identity()));
}
//封装电站数据
for (int i = 0; i < list.size(); i++) {
SofarStationList sunlightDto=list.get(i);
System.out.println(i+"====================================================");
JpStation jpStation=null;
if(bodyparam.containsKey(sunlightDto.getId().toString())){
jpStation=bodyparam.get(sunlightDto.getId().toString());
}else{
jpStation=new JpStation();
}
jpStation.setThirdStationId(sunlightDto.getId().toString());
jpStation.setName(sunlightDto.getName());
jpStation.setAddress(sunlightDto.getLocationAddress());
jpStation.setLongitude(sunlightDto.getLocationLng()==null?null:sunlightDto.getLocationLng().toString());
jpStation.setLatitude(sunlightDto.getLocationLat()==null?null:sunlightDto.getLocationLat().toString());
jpStation.setThirdCode(PVProducerInfoEnum.SH.getCode());
// 并网类型
jpStation.setOnGridType(SofarRequestUtil.intoNetWorkStatus.get(sunlightDto.getGridInterconnectionType()));
//第三方厂商标识
jpStation.setThirdCode(PVProducerInfoEnum.YG.getCode());
jpStation.setRecDate(new Date());
//获取单个电站详情
Map<String, Object> requestInfo = new HashMap<>();
requestInfo.put("stationId", sunlightDto.getId());
String param = JSON.toJSONString(requestInfo);
com.alibaba.fastjson.JSONObject jsonObject= requestUtil.getResPonseobj(
SoFarConstant.stationUrl,
SoFarConstant.requestPost,
param,
null
);
jpStation.setType("家庭户用");//电站类型
jpStation.setPrice(jsonObject.get("mergeElectricPrice")!=null?Double.valueOf(jsonObject.get("mergeElectricPrice").toString()):null);//上网电价
jpStation.setUserName(jsonObject.get("ownerName")!=null?jsonObject.get("ownerName").toString():null);// 业主姓名
// jpStation.setEmail(null);// 邮箱
// jpStation.setArea();//地区
// jpStation.setOnGridTime(); // 并网时间
// jpStation.setAccessTime();// 接入平台时间
// jpStation.setStationContact();// 电站联系人
// jpStation.setModuleCount(); // 组件数量
jpStation.setUserPhone(jsonObject.get("contactPhone")!=null?jsonObject.get("contactPhone").toString():null);//业主电话
jpStation.setCreateTime(sunlightDto.getCreateDate()!=null?
new Date(sunlightDto.getCreateDate()) :null); // 创建时间
jpStation.setSnCode(sunlightDto.getId().toString());//sncode
jpStation.setCapacity( jsonObject.get("installedCapacity")!=null? Double.valueOf(jsonObject.get("installedCapacity").toString())/100:null);//装机容量
jpStation.setRatedPower(sunlightDto.getGenerationPower()!=null?Double.valueOf(sunlightDto.getGenerationPower())/1000:null);//额定功率
//获取所电站下逆变器
Map<String, Object> requestInfo2 = new HashMap<>();
requestInfo2.put("stationId", sunlightDto.getId());
requestInfo2.put("deviceType", "INVERTER");
String param2 = JSON.toJSONString(requestInfo2);
List<SofarInverter> jsonObject2= requestUtil.getResPonse(
SoFarConstant.nbqlist,
SoFarConstant.requestPost,
param2,
SoFarConstant.deviceListItems,
SofarInverter.class);
if(jsonObject2!=null&&jsonObject2.size()>0){
//获取设备实时数据
Map<String, Object> requestInfo1 = new HashMap<>();
requestInfo1.put("deviceSn", jsonObject2.get(0).getDeviceSn());
String param1 = JSON.toJSONString(requestInfo1);
List<SofarInverterDto> jsonObject1= requestUtil.getResPonse(
SoFarConstant.currentData,
SoFarConstant.requestPost,
param1,
SoFarConstant.dataList,
SofarInverterDto.class
);
//状态
if( jsonObject2.get(0).getConnectStatus()!=null) {
jpStation.setState(SoFarConstant.stationStaus.get(jsonObject2.get(0).getConnectStatus()+""));//电站状态
}
if(jsonObject1!=null&&!jsonObject1.isEmpty()){
Map<String, String> maps = jsonObject1.stream().collect(Collectors.toMap(SofarInverterDto::getKey,SofarInverterDto::getValue));
//功率
jpStation.setRealTimePower( maps!=null&&maps.containsKey("TPG")?
(String.valueOf(maps.get("TPG"))!=null?Double.valueOf(maps.get("TPG").toString())/1000:null):null);//实时功率
//日发电量
jpStation.setDayGenerate( maps!=null&&maps.containsKey("Etdy_ge1")?
(String.valueOf(maps.get("Etdy_ge1"))!=null?Double.valueOf(maps.get("Etdy_ge1").toString()):null):null);//日发电量
//累计发电量
jpStation.setAccumulatedPower(maps!=null&&maps.containsKey("Et_ge0")?
(String.valueOf(maps.get("Et_ge0"))!=null?Double.valueOf(maps.get("Et_ge0").toString()):null):null);//累计发电量
//累计发电量
jpStation.setAccumulatedPower(jpStation.getDayGenerate()!=null?
Double.valueOf(jpStation.getDayGenerate().toString())*0.45:null);//日收益
//累计发电量
jpStation.setCumulativeIncome(jpStation.getAccumulatedPower()!=null?
Double.valueOf(jpStation.getAccumulatedPower().toString())*0.45:null);//累计收益
//获取月发电量
Map<String, Object> requestInfoy = new HashMap<>();
requestInfoy.put("deviceSn", jsonObject2.get(0).getDeviceSn());
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
requestInfoy.put("startTime",year+"" );
requestInfoy.put("endTime", year+"");
requestInfoy.put("timeType", 4);
String paramy = JSON.toJSONString(requestInfoy);
List<Sofarhistorical> jsonObjecty= requestUtil.getResPonse(
SoFarConstant.currentData,
SoFarConstant.requestPost,
paramy,
SoFarConstant.paramDataList,
Sofarhistorical.class
);
if(jsonObjecty!=null&&jsonObjecty.size()>0){
List<Sofarhistorical> jsonObjectyf=jsonObjecty.stream()
.filter(da -> Objects.nonNull(da))
.filter(da -> da.getCollectTime().equals(month+""))
.collect(Collectors.toList());
if(!jsonObjectyf.isEmpty()){
for (Sofarhistorical sofarhistorical : jsonObjectyf) {
if(sofarhistorical.getDataList().get(0).getKey().equals("generation")){
// 月发电量
jpStation.setMonthGenerate(sofarhistorical.getDataList().get(0).getValue()!=null?Double.valueOf(sofarhistorical.getDataList().get(0).getValue()):null);
// 月收益
jpStation.setMonthIncome(jpStation.getMonthGenerate()!=null?jpStation.getMonthGenerate()*0.45:null);
}
}
}
}
//获取月发电量
Map<String, Object> requestInfoyn = new HashMap<>();
requestInfoyn.put("deviceSn", jsonObject2.get(0).getDeviceSn());
requestInfoyn.put("startTime",year+"" );
requestInfoyn.put("endTime", year+"");
requestInfoyn.put("timeType", 5);
String paramyn = JSON.toJSONString(requestInfoyn);
List<Sofarhistorical> jsonObjectyn= requestUtil.getResPonse(
SoFarConstant.currentData,
SoFarConstant.requestPost,
paramyn,
SoFarConstant.paramDataList,
Sofarhistorical.class
);
if(jsonObjectyn!=null&&jsonObjectyn.size()>0){
List<Sofarhistorical> jsonObjectyfn=jsonObjectyn.stream()
.filter(da -> Objects.nonNull(da))
.filter(da -> da.getCollectTime().equals(year+""))
.collect(Collectors.toList());
if(!jsonObjectyfn.isEmpty()){
for (Sofarhistorical sofarhistorical : jsonObjectyfn) {
if(sofarhistorical.getDataList().get(0).getKey().equals("generation")){
// 月发电量
jpStation.setYearGenerate(sofarhistorical.getDataList().get(0).getValue()!=null?Double.valueOf(sofarhistorical.getDataList().get(0).getValue()):null);
// 月收益
jpStation.setYearIncome(jpStation.getYearGenerate()!=null?jpStation.getYearGenerate()*0.45:null);
}
}
}
}
if (!ObjectUtils.isEmpty(jpStation.getSequenceNbr())) {
jpStationMapper.updateById(jpStation);
} else {
jpStationMapper.insert(jpStation);
}
//逆变器信信息
this.inverterList( jsonObject2.get(0), jpStation, maps);
}
}
//电站报表
//户用场站日发电量
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 (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(
(jpStation.getDayGenerate()==null || jpStation.getCapacity()==null)?null:
(jpStation.getCapacity()<=0.0?null:jpStation.getDayGenerate()/jpStation.getCapacity())
);
tdHYGFStationDayGenerate.setIncome(jpStation.getDayIncome());
if (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 (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());
tdHYGFStationMonthGenerate.setFullhour(
// jpStation.getMonthGenerate() / jpStation.getCapacity()
(jpStation.getMonthGenerate()==null || jpStation.getCapacity()==null)?null:
(jpStation.getCapacity()<=0.0?null:jpStation.getMonthGenerate()/jpStation.getCapacity())
);
tdHYGFStationMonthGenerate.setIncome(jpStation.getMonthIncome());
if (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 (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()
(jpStation.getYearGenerate()==null || jpStation.getCapacity()==null)?null:
(jpStation.getCapacity()<=0.0?null:jpStation.getYearGenerate()/jpStation.getCapacity())
);
tdHYGFStationYearGenerate.setIncome(jpStation.getYearIncome());
if (ObjectUtils.isEmpty(tdHYGFStationYearGenerate.getCreatedTime())) {
tdHYGFStationYearGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFStationYearGenerateMapper.insert(tdHYGFStationYearGenerate);
} else {
tdHYGFStationYearGenerateMapper.insert(tdHYGFStationYearGenerate);
}
}
} }
@Override @Override
public void collectorList() { public void collectorList( List<SofarStationList> jsonObject) {
for (SofarStationList sunlightDto : jsonObject) {
//获取所电站下采集器
Map<String, Object> requestInfo2 = new HashMap<>();
requestInfo2.put("stationId", sunlightDto.getId());
requestInfo2.put("deviceType", "COLLECTOR");
String param2 = JSON.toJSONString(requestInfo2);
List<SofarInverter> jsonObject2= requestUtil.getResPonse(
SoFarConstant.nbqlist,
SoFarConstant.requestPost,
param2,
SoFarConstant.deviceListItems,
SofarInverter.class);
if(jsonObject2!=null&&jsonObject2.size()>0) {
//获取采集器实时数据
Map<String, Object> requestInfo1 = new HashMap<>();
requestInfo1.put("deviceSn", jsonObject2.get(0).getDeviceSn());
String param1 = JSON.toJSONString(requestInfo1);
List<SofarInverterDto> jsonObject1 = requestUtil.getResPonse(
SoFarConstant.currentData,
SoFarConstant.requestPost,
param1,
SoFarConstant.dataList,
SofarInverterDto.class
);
}
// for (KsolarStationCollectList ksolarStationCollectList : result) {
//
//
// JpCollector jpCollector = jpCollectorMapper.selectOne(new QueryWrapper<JpCollector>().
// eq("third_station_id", ksolarStationCollectList.getThirdStationId()).
// eq("sn_code", ksolarStationCollectList.getCollectId().trim()).
// eq("third_code", PVProducerInfoEnum.KSOLAR.getCode()));
// if (ObjectUtils.isEmpty(jpCollector)) {
// jpCollector = new JpCollector();
// }
//// //出场日期
//// jpCollector.setDischargeDate(new Date(collectorDetailDto.getFactoryTime()));
//// //生产日期
//// jpCollector.setProductDate(new Date(collectorDetailDto.getFactoryTime()));
//// //数据上传间隔
//// jpCollector.setDataPeriod(collectorDetailDto.getDataUploadCycle());
//// //本次上电时间
//// jpCollector.setThisWorkTime(new DateTime(collectorDetailDto.getCurrentWorkingTime()));
//// //累计工作时间
//// jpCollector.setTotalWorkTime(new DateTime(collectorDetailDto.getTotalWorkingTime()));
//
// // sn编码
// jpCollector.setSnCode(ksolarStationCollectList.getCollectId().trim());
// // 更新时间
// jpCollector.setUpdateTime(new Date());
// // 第三方电站id
// jpCollector.setThirdStationId(ksolarStationCollectList.getThirdStationId());
// // 第三方厂商标识
// jpCollector.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode());
// //第三方厂商标识
// jpCollector.setState(KSolarConstant.collectStaus.get(ksolarStationCollectList.getStatus()));
// jpCollector.setStationName(ksolarStationCollectList.getStationName());
// jpCollector.setAddr(ksolarStationCollectList.getAddress());
// jpCollector.setName(ksolarStationCollectList.getCollectName());
// jpCollector.setVersion(ksolarStationCollectList.getCollectVersion());
// jpCollector.setType(ksolarStationCollectList.getDeviceModel());
// //信号强度
// jpCollector.setSignalStrength(String.valueOf(ksolarStationCollectList.getSignal()));
// jpCollector.setRecDate(new Date());
// if (ObjectUtils.isEmpty(jpCollector.getSequenceNbr())) {
// jpCollectorMapper.insert(jpCollector);
// } else {
// jpCollectorMapper.updateById(jpCollector);
// }
// HYGFJPCollectorHistory hygfjpCollectorHistory = new HYGFJPCollectorHistory();
// hygfjpCollectorHistory.setTime(System.currentTimeMillis());
// hygfjpCollectorHistory.setCreatedTime(System.currentTimeMillis());
// hygfjpCollectorHistory.setSnCode(ksolarStationCollectList.getCollectId().trim());
// hygfjpCollectorHistory.setSignalStrength(ksolarStationCollectList.getSignal());
// hygfjpCollectorHistory.setThirdStationId(ksolarStationCollectList.getThirdStationId());
// hygfjpCollectorHistory.setThirdCode(PVProducerInfoEnum.KSOLAR.getCode());
// hygfjpCollectorHistoryMapper.insert(hygfjpCollectorHistory);
// }
}
} }
...@@ -40,7 +513,325 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ ...@@ -40,7 +513,325 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ
} }
@Override @Override
public void inverterList() { public void inverterList(SofarInverter device, JpStation jpStation,Map<String, String> maps) {
//存储逆变器
new Thread(new Runnable(){
@Override
public void run(){
try{
if(device!=null){
//获取逆变器信息存库
JpInverter jpInverter = jpInverterMapper.selectOne(new QueryWrapper<JpInverter>().
eq("third_station_id", jpStation.getThirdStationId()).
eq("third_code", PVProducerInfoEnum.SH.getCode()).
eq("ID", device.getDeviceId().toString()));
if (ObjectUtils.isEmpty(jpInverter)) {
jpInverter = new JpInverter();
}
// 品牌
jpInverter.setBrand(null);
jpInverter.setSnCode(device.getDeviceSn());
jpInverter.setId(device.getDeviceId().toString());
jpInverter.setState(jpStation.getState());
jpInverter.setUpdateTime(new Date());
jpInverter.setDayPowerGeneration(jpStation.getDayGenerate());
jpInverter.setMonthPowerGeneration(jpStation.getMonthGenerate());
jpInverter.setYearPowerGeneration(jpStation.getYearGenerate());
jpInverter.setTotalPowerGeneration(jpStation.getAccumulatedPower());
jpInverter.setThirdStationId(jpStation.getThirdStationId());
jpInverter.setThirdCode(PVProducerInfoEnum.YG.getCode());
jpInverter.setName(jpStation.getName());
jpInverter.setStationName(jpStation.getName());
jpInverter.setAddr(jpStation.getAddress());
jpInverter.setModel(null);
jpInverter.setCapacity(jpStation.getCapacity());
jpInverter.setCurrentPower(jpStation.getRealTimePower());
// // 国标
// jpInverter.setNationalStandard(inverterDetailDto.getNationalStandards());
// // 满发小时数
// jpInverter.setGenerationHours(String.valueOf(inverterDetailDto.getFullHour()));
// //版本
// jpInverter.setVersion(device.getDevice_model_code());
// //采集器id
// jpInverter.setCollectorId(ksolarStationCollectList.getCollectId().trim());
// //采集器sn编码
// jpInverter.setCollectorSnCode(ksolarStationCollectList.getCollectId().trim());
if (!ObjectUtils.isEmpty(jpInverter.getSequenceNbr())) {
jpInverterMapper.updateById(jpInverter);
} else {
if(StringUtils.isNotEmpty(jpInverter.getSnCode())){
jpInverterMapper.insert(jpInverter);
}
}
//逆变器指标信息
if(maps!=null&&!maps.isEmpty()){
List<String> liname=new ArrayList<>();
liname.add("AC1");//A 相电压
liname.add("AC2");//B 相电压
liname.add("AC3");//C 相电压
liname.add("PV1");//直流电压 1
liname.add("PV2");//直流电压 2
liname.add("PV3");//直流电压 3
liname.add("PV4");//直流电压 4
liname.add("PV5");//直流电压 5
liname.add("PV6");//直流电压 6
liname.add("PV7");//直流电压 7
liname.add("PV8");//直流电压 8
liname.add("PV9");//直流电压 9
liname.add("PV10");//直流电压 10
for (int i = 0; i < liname.size(); i++) {
JpInverterElectricity jpInverterElectricity = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>().
eq("sn_code",jpInverter.getSnCode()).
eq("third_code", PVProducerInfoEnum.SH.getCode()).
eq("name", liname.get(i))
);
if (ObjectUtils.isEmpty(jpInverterElectricity)) {
jpInverterElectricity = new JpInverterElectricity();
}
jpInverterElectricity.setInverterId(jpInverter.getId());
jpInverterElectricity.setSnCode(jpInverter.getSnCode());
jpInverterElectricity.setThirdCode(PVProducerInfoEnum.YG.getCode());
jpInverterElectricity.setThirdStationId(jpInverter.getThirdStationId());
if(i>2){
jpInverterElectricity.setType("直流");
}else{
jpInverterElectricity.setType("交流");
}
jpInverterElectricity.setName(liname.get(i));
String voltage=null;
String current=null;
String power=null;
switch (liname.get(i)) {
case "AC1":
voltage=maps.containsKey("AV1")&&maps.get("AV1")!=null?maps.get("AV1").toString():null;
current=maps.containsKey("AC1")&&maps.get("AC1")!=null?maps.get("AC1").toString():null;
break;
case "AC2":
voltage=maps.containsKey("AV2")&&maps.get("AV2")!=null?maps.get("AV2").toString():null;
current=maps.containsKey("AC2")&&maps.get("AC2")!=null?maps.get("AC2").toString():null;
break;
case "AC3":
voltage=maps.containsKey("AV3")&&maps.get("AV3")!=null?maps.get("AV3").toString():null;
current=maps.containsKey("AC3")&&maps.get("AC3")!=null?maps.get("AC3").toString():null;
break;
case "PV1":
voltage=maps.containsKey("DV1")&&maps.get("DV1")!=null?maps.get("DV1").toString():null;
current=maps.containsKey("DC1")&&maps.get("DC1")!=null?maps.get("DC1").toString():null;
power=maps.containsKey("DP1")&&maps.get("DP1")!=null?maps.get("DP1").toString():null;
break;
case "PV2":
voltage=maps.containsKey("DV2")&&maps.get("DV2")!=null?maps.get("DV2").toString():null;
current=maps.containsKey("DC2")&&maps.get("DC2")!=null?maps.get("DC2").toString():null;
power=maps.containsKey("DP2")&&maps.get("DP2")!=null?maps.get("DP2").toString():null;
break;
case "PV3":
voltage=maps.containsKey("DV3")&&maps.get("DV3")!=null?maps.get("DV3").toString():null;
current=maps.containsKey("DC3")&&maps.get("DC3")!=null?maps.get("DC3").toString():null;
power=maps.containsKey("DP3")&&maps.get("DP3")!=null?maps.get("DP3").toString():null;
break;
case "PV4":
voltage=maps.containsKey("DV4")&&maps.get("DV4")!=null?maps.get("DV4").toString():null;
current=maps.containsKey("DC4")&&maps.get("DC4")!=null?maps.get("DC4").toString():null;
power=maps.containsKey("DP4")&&maps.get("DP4")!=null?maps.get("DP4").toString():null;
break;
case "PV5":
voltage=maps.containsKey("DV5")&&maps.get("DV5")!=null?maps.get("DV5").toString():null;
current=maps.containsKey("DC5")&&maps.get("DC5")!=null?maps.get("DC5").toString():null;
power=maps.containsKey("DP5")&&maps.get("DP5")!=null?maps.get("DP5").toString():null;
break;
case "PV6":
voltage=maps.containsKey("DV6")&&maps.get("DV6")!=null?maps.get("DV6").toString():null;
current=maps.containsKey("DC6")&&maps.get("DC6")!=null?maps.get("DC6").toString():null;
power=maps.containsKey("DP6")&&maps.get("DP6")!=null?maps.get("DP6").toString():null;
break;
case "PV7":
voltage=maps.containsKey("DV7")&&maps.get("DV7")!=null?maps.get("DV7").toString():null;
current=maps.containsKey("DC7")&&maps.get("DC7")!=null?maps.get("DC7").toString():null;
power=maps.containsKey("DP7")&&maps.get("DP7")!=null?maps.get("DP7").toString():null;
break;
case "PV8":
voltage=maps.containsKey("DV8")&&maps.get("DV8")!=null?maps.get("DV8").toString():null;
current=maps.containsKey("DC8")&&maps.get("DC8")!=null?maps.get("DC8").toString():null;
power=maps.containsKey("DP8")&&maps.get("DP8")!=null?maps.get("DP8").toString():null;
break;
case "PV9":
voltage=maps.containsKey("DV9")&&maps.get("DV9")!=null?maps.get("DV9").toString():null;
current=maps.containsKey("DC9")&&maps.get("DC9")!=null?maps.get("DC9").toString():null;
power=maps.containsKey("DP9")&&maps.get("DP9")!=null?maps.get("DP9").toString():null;
break;
case "PV10":
voltage=maps.containsKey("DV10")&&maps.get("DV10")!=null?maps.get("DV10").toString():null;
current=maps.containsKey("DC10")&&maps.get("DC10")!=null?maps.get("DC10").toString():null;
power=maps.containsKey("DP10")&&maps.get("DP10")!=null?maps.get("DP10").toString():null;
break;
default:
}
jpInverterElectricity.setVoltage(voltage!=null?Double.valueOf(voltage):null);
jpInverterElectricity.setCurrent(current!=null?Double.valueOf(current):null);
jpInverterElectricity.setPower(power!=null?Double.valueOf(power):null);
if (ObjectUtils.isEmpty(jpInverterElectricity.getSequenceNbr())) {
jpInverterElectricityMapper.insert(jpInverterElectricity);
} else {
jpInverterElectricityMapper.updateById(jpInverterElectricity);
}
}
//逆变器报表
//-----------------------户用光伏日报表----------------------
TdHYGFInverterDayGenerate tdHYGFInverterDayGenerate = new TdHYGFInverterDayGenerate();
tdHYGFInverterDayGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFInverterDayGenerate.setThirdStationId(jpInverter.getThirdStationId());
tdHYGFInverterDayGenerate.setSnCode(jpInverter.getSnCode());
tdHYGFInverterDayGenerate.setName(jpInverter.getName());
tdHYGFInverterDayGenerate.setWorkStatus(jpInverter.getState());
//交流电压
tdHYGFInverterDayGenerate.setDcv1(maps.containsKey("AV1")&&maps.get("AV1")!=null?Double.valueOf(maps.get("AV1").toString()):null);
tdHYGFInverterDayGenerate.setDcv2(maps.containsKey("AV2")&&maps.get("AV2")!=null?Double.valueOf(maps.get("AV2").toString()):null);
tdHYGFInverterDayGenerate.setDcv3(maps.containsKey("AV3")&&maps.get("AV3")!=null?Double.valueOf(maps.get("AV3").toString()):null);
//交流电流
tdHYGFInverterDayGenerate.setDcc1(maps.containsKey("AC1")&&maps.get("AC1")!=null?Double.valueOf(maps.get("AC1").toString()):null);
tdHYGFInverterDayGenerate.setDcc2(maps.containsKey("AC2")&&maps.get("AC2")!=null?Double.valueOf(maps.get("AC2").toString()):null);
tdHYGFInverterDayGenerate.setDcc3(maps.containsKey("AC3")&&maps.get("AC3")!=null?Double.valueOf(maps.get("AC3").toString()):null);
//直流电压
tdHYGFInverterDayGenerate.setAcv1(maps.containsKey("DV1")&&maps.get("DV1")!=null?Double.valueOf(maps.get("DV1").toString()):null);
tdHYGFInverterDayGenerate.setAcv2(maps.containsKey("DV2")&&maps.get("DV2")!=null?Double.valueOf(maps.get("DV2").toString()):null);
tdHYGFInverterDayGenerate.setAcv3(maps.containsKey("DV3")&&maps.get("DV3")!=null?Double.valueOf(maps.get("DV3").toString()):null);
tdHYGFInverterDayGenerate.setAcv4(maps.containsKey("DV4")&&maps.get("DV4")!=null?Double.valueOf(maps.get("DV4").toString()):null);
//直流电流
tdHYGFInverterDayGenerate.setAcc1(maps.containsKey("DC1")&&maps.get("DC1")!=null?Double.valueOf(maps.get("DC1").toString()):null);
tdHYGFInverterDayGenerate.setAcc2(maps.containsKey("DC2")&&maps.get("DC2")!=null?Double.valueOf(maps.get("DC2").toString()):null);
tdHYGFInverterDayGenerate.setAcc3(maps.containsKey("DC3")&&maps.get("DC3")!=null?Double.valueOf(maps.get("DC3").toString()):null);
tdHYGFInverterDayGenerate.setAcc4(maps.containsKey("DC4")&&maps.get("DC4")!=null?Double.valueOf(maps.get("DC4").toString()):null);
tdHYGFInverterDayGenerate.setPv1(maps.containsKey("DP1")&&maps.get("DP1")!=null?Double.valueOf(maps.get("DP1").toString()):null);
tdHYGFInverterDayGenerate.setPv2(maps.containsKey("DP2")&&maps.get("DP2")!=null?Double.valueOf(maps.get("DP2").toString()):null);
tdHYGFInverterDayGenerate.setPv3(maps.containsKey("DP3")&&maps.get("DP3")!=null?Double.valueOf(maps.get("DP3").toString()):null);
tdHYGFInverterDayGenerate.setPv4(maps.containsKey("DP4")&&maps.get("DP4")!=null?Double.valueOf(maps.get("DP4").toString()):null);
//功率
tdHYGFInverterDayGenerate.setTotalPower(jpInverter.getCurrentPower());
// //频率
tdHYGFInverterDayGenerate.setFrequency(maps.containsKey("A_Fo1")&&maps.get("A_Fo1")!=null?String.valueOf(maps.get("A_Fo1")):null);
// //功率因数
tdHYGFInverterDayGenerate.setPowerFactor(1.0);
tdHYGFInverterDayGenerate.setDayGen(jpInverter.getDayPowerGeneration());
tdHYGFInverterDayGenerate.setMonthGen(jpInverter.getMonthPowerGeneration());
tdHYGFInverterDayGenerate.setYearGen(jpInverter.getYearPowerGeneration());
tdHYGFInverterDayGenerate.setTotalGen(jpInverter.getTotalPowerGeneration());
tdHYGFInverterDayGenerate.setIgbtTemp(ObjectUtils.isEmpty(jpInverter.getIgbtTemperature()) ? null : Double.valueOf(jpInverter.getIgbtTemperature()));
tdHYGFInverterDayGenerate.setIncome(null);
tdHYGFInverterDayGenerate.setFullhour(
(jpInverter.getDayPowerGeneration()==null || jpInverter.getCapacity()==null)?null:
(jpInverter.getCapacity()<=0.0?null:jpInverter.getDayPowerGeneration()/jpInverter.getCapacity())
);
tdHYGFInverterDayGenerateMapper.insert(tdHYGFInverterDayGenerate);
//户用场站月发电量
Date today1 = new Date();
TdHYGFInverterMonthGenerate tdHYGFInverterMonthGenerate = tdHYGFInverterMonthGenerateMapper.selectOne(new QueryWrapper<TdHYGFInverterMonthGenerate>()
.eq("third_station_id", jpInverter.getThirdStationId())
.eq("sn_code", jpInverter.getSnCode())
.eq("day_time", DateUtil.format(today1, "yyyy-MM-dd"))
.eq("year_month", DateUtil.format(today1, "yyyy-MM")));
if (ObjectUtils.isEmpty(tdHYGFInverterMonthGenerate)) {
tdHYGFInverterMonthGenerate = new TdHYGFInverterMonthGenerate();
}
tdHYGFInverterMonthGenerate.setThirdStationId(jpInverter.getThirdStationId());
tdHYGFInverterMonthGenerate.setSnCode(jpInverter.getSnCode().trim());
tdHYGFInverterMonthGenerate.setDayTime(DateUtil.format(today1, "yyyy-MM-dd"));
tdHYGFInverterMonthGenerate.setYearMonth(DateUtil.format(today1, "yyyy-MM"));
tdHYGFInverterMonthGenerate.setGenerate(jpInverter.getDayPowerGeneration());
tdHYGFInverterMonthGenerate.setName(jpInverter.getName());
tdHYGFInverterMonthGenerate.setFullhour(
(jpInverter.getDayPowerGeneration()==null || jpInverter.getCapacity()==null)?null:
(jpInverter.getCapacity()<=0.0?null:jpInverter.getDayPowerGeneration()/jpInverter.getCapacity())
);
if (ObjectUtils.isEmpty(tdHYGFInverterMonthGenerate.getCreatedTime())) {
tdHYGFInverterMonthGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFInverterMonthGenerateMapper.insert(tdHYGFInverterMonthGenerate);
} else {
tdHYGFInverterMonthGenerateMapper.insert(tdHYGFInverterMonthGenerate);
}
//户用场站年发电量
TdHYGFInverterYearGenerate tdHYGFInverterYearGenerate = tdHYGFInverterYearGenerateMapper.selectOne(new QueryWrapper<TdHYGFInverterYearGenerate>()
.eq("third_station_id", jpInverter.getThirdStationId())
.eq("sn_code", jpInverter.getSnCode())
.eq("month_time", DateUtil.format(today1, "yyyy-MM"))
.eq("year", DateUtil.format(today1, "yyyy")));
if (ObjectUtils.isEmpty(tdHYGFInverterYearGenerate)) {
tdHYGFInverterYearGenerate = new TdHYGFInverterYearGenerate();
}
tdHYGFInverterYearGenerate.setThirdStationId(jpInverter.getThirdStationId());
tdHYGFInverterYearGenerate.setSnCode(jpInverter.getSnCode().trim());
tdHYGFInverterYearGenerate.setMonthTime(DateUtil.format(today1, "yyyy-MM"));
tdHYGFInverterYearGenerate.setYear(DateUtil.format(today1, "yyyy"));
tdHYGFInverterYearGenerate.setGenerate(jpInverter.getMonthPowerGeneration());
tdHYGFInverterYearGenerate.setName(jpInverter.getName());
tdHYGFInverterYearGenerate.setFullhour(
(jpInverter.getMonthPowerGeneration()==null || jpInverter.getCapacity()==null)?null:
(jpInverter.getCapacity()<=0.0?null:jpInverter.getMonthPowerGeneration()/jpInverter.getCapacity())
);
if (ObjectUtils.isEmpty(tdHYGFInverterYearGenerate.getCreatedTime())) {
tdHYGFInverterYearGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFInverterYearGenerateMapper.insert(tdHYGFInverterYearGenerate);
} else {
tdHYGFInverterYearGenerateMapper.insert(tdHYGFInverterYearGenerate);
}
//户用场站年发电量
TdHYGFInverterTotalGenerate tdHYGFInverterTotalGenerate = tdHYGFInverterTotalGenerateMapper.selectOne(new QueryWrapper<TdHYGFInverterTotalGenerate>()
.eq("third_station_id", jpInverter.getThirdStationId())
.eq("sn_code", jpInverter.getSnCode())
.eq("year_time", DateUtil.format(today1, "yyyy"))
.eq("year", DateUtil.format(today1, "yyyy")));
if (ObjectUtils.isEmpty(tdHYGFInverterTotalGenerate)) {
tdHYGFInverterTotalGenerate = new TdHYGFInverterTotalGenerate();
}
tdHYGFInverterTotalGenerate.setThirdStationId(jpInverter.getThirdStationId());
tdHYGFInverterTotalGenerate.setSnCode(jpInverter.getSnCode().trim());
tdHYGFInverterTotalGenerate.setYearTime(DateUtil.format(today1, "yyyy"));
tdHYGFInverterTotalGenerate.setYear(DateUtil.format(today1, "yyyy"));
tdHYGFInverterTotalGenerate.setGenerate(jpInverter.getYearPowerGeneration());
tdHYGFInverterTotalGenerate.setFullhour(0.0d);
tdHYGFInverterTotalGenerate.setName(jpInverter.getName());
tdHYGFInverterTotalGenerate.setFullhour(
(jpInverter.getYearPowerGeneration()==null || jpInverter.getCapacity()==null)?null:
(jpInverter.getCapacity()<=0.0?null:jpInverter.getYearPowerGeneration()/jpInverter.getCapacity())
);
if (ObjectUtils.isEmpty(tdHYGFInverterTotalGenerate.getCreatedTime())) {
tdHYGFInverterTotalGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFInverterTotalGenerateMapper.insert(tdHYGFInverterTotalGenerate);
} else {
tdHYGFInverterTotalGenerateMapper.insert(tdHYGFInverterTotalGenerate);
}
}
}
}catch(Exception e){
e.printStackTrace();
}
}
}).start();
} }
......
...@@ -99,7 +99,6 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -99,7 +99,6 @@ public class SunlightServiceImpl implements SunlightService {
List<Sunlight> list = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), Sunlight.class); List<Sunlight> list = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), Sunlight.class);
this.stationDetail(data); this.stationDetail(data);
sunlightMapper.delete(null);
for (Sunlight sunlight : list) { for (Sunlight sunlight : list) {
sunlight.setCreatedTime(System.currentTimeMillis()); sunlight.setCreatedTime(System.currentTimeMillis());
...@@ -115,7 +114,7 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -115,7 +114,7 @@ public class SunlightServiceImpl implements SunlightService {
//电站数据如库,电站统计数据入库
public void stationDetail(JSONObject data){ public void stationDetail(JSONObject data){
//所有场站信息 //所有场站信息
List<SunlightDto> list = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), SunlightDto.class); List<SunlightDto> list = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), SunlightDto.class);
...@@ -390,7 +389,7 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -390,7 +389,7 @@ public class SunlightServiceImpl implements SunlightService {
} }
//逆变器 //逆变器数据入库,逆变器参数入库
public void setJpInverte(Device device,JpStation jpStation){ public void setJpInverte(Device device,JpStation jpStation){
new Thread(new Runnable(){ new Thread(new Runnable(){
...@@ -726,7 +725,7 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -726,7 +725,7 @@ public class SunlightServiceImpl implements SunlightService {
li.add(SunlightUtil.alarmstatus.get("4")); li.add(SunlightUtil.alarmstatus.get("4"));
li.add(SunlightUtil.alarmstatus.get("5")); li.add(SunlightUtil.alarmstatus.get("5"));
List<HYGFJPInverterWarn> hygfjpInverterWarnlist = hygfjpInverterWarnMapper.selectList(new QueryWrapper<HYGFJPInverterWarn>() List<HYGFJPInverterWarn> hygfjpInverterWarnlist = hygfjpInverterWarnMapper.selectList(new QueryWrapper<HYGFJPInverterWarn>()
.in("`state`", li) .notIn("`state`", li)
.eq("third_code", PVProducerInfoEnum.YG.getCode()) .eq("third_code", PVProducerInfoEnum.YG.getCode())
); );
...@@ -755,12 +754,12 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -755,12 +754,12 @@ public class SunlightServiceImpl implements SunlightService {
hygfjpInverterWarn.setTime(System.currentTimeMillis()); hygfjpInverterWarn.setTime(System.currentTimeMillis());
hygfjpInverterWarn.setSnCode(!jpInverterbodyparam.isEmpty()&&jpInverterbodyparam.containsKey(sunlightWarm.getUuid().toString())?jpInverterbodyparam.get(sunlightWarm.getUuid().toString()):null); hygfjpInverterWarn.setSnCode(!jpInverterbodyparam.isEmpty()&&jpInverterbodyparam.containsKey(sunlightWarm.getUuid().toString())?jpInverterbodyparam.get(sunlightWarm.getUuid().toString()):null);
hygfjpInverterWarn.setThirdStationId(sunlightWarm.getPs_id().toString()); hygfjpInverterWarn.setThirdStationId(sunlightWarm.getPs_id().toString());
hygfjpInverterWarn.setLevel(SunlightUtil.alarmLevel.get(sunlightWarm.getFault_level())); hygfjpInverterWarn.setLevel(SunlightUtil.alarmLevel.get(sunlightWarm.getFault_level().toString()));
hygfjpInverterWarn.setContent(sunlightWarm.getFault_name()); hygfjpInverterWarn.setContent(sunlightWarm.getFault_name());
hygfjpInverterWarn.setThirdCode(PVProducerInfoEnum.YG.getCode()); hygfjpInverterWarn.setThirdCode(PVProducerInfoEnum.YG.getCode());
hygfjpInverterWarn.setTreatment(sunlightWarm.getFault_desc()); hygfjpInverterWarn.setTreatment(sunlightWarm.getFault_desc());
hygfjpInverterWarn.setStartTime(DateUtil.parse(sunlightWarm.getCreate_time(), DatePattern.NORM_DATETIME_PATTERN).getTime()); hygfjpInverterWarn.setStartTime(DateUtil.parse(sunlightWarm.getCreate_time(), DatePattern.NORM_DATETIME_PATTERN).getTime());
hygfjpInverterWarn.setState(SunlightUtil.alarmstatus.get(sunlightWarm.getProcess_status())); hygfjpInverterWarn.setState(SunlightUtil.alarmstatus.get(sunlightWarm.getProcess_status().toString()));
hygfjpInverterWarn.setTimeLong(null); hygfjpInverterWarn.setTimeLong(null);
hygfjpInverterWarn.setRecoverTime(null); hygfjpInverterWarn.setRecoverTime(null);
hygfjpInverterWarn.setTimeLong(null); hygfjpInverterWarn.setTimeLong(null);
...@@ -777,7 +776,7 @@ public class SunlightServiceImpl implements SunlightService { ...@@ -777,7 +776,7 @@ public class SunlightServiceImpl implements SunlightService {
} }
//更新td已消除告警 //更新td已消除告警,由于第三方获取会出现请求次数超限,状态只能手动修改,没有消除时间,
if(!bodyparam.isEmpty()){ if(!bodyparam.isEmpty()){
Object[] ids= bodyparam.keySet().toArray(); Object[] ids= bodyparam.keySet().toArray();
......
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