Commit b20197e3 authored by tangwei's avatar tangwei

首航采集

parent c8cfba5f
......@@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.api.householdapi.constant.GoodWeConstant;
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.stereotype.Component;
import org.springframework.util.ObjectUtils;
......@@ -21,6 +22,32 @@ public class SofarRequestUtil {
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
private RedisUtils redisUtils;
......@@ -65,8 +92,6 @@ public class SofarRequestUtil {
*/
public <T> List<T> getResPonse(String apiurl, String requestMethod, String requestParmInfo, String ResultResolveRule, Class<T> tClass) {
String respone = "";
String params = "";
JSONArray jsonArray = null;
List<T> result = new ArrayList<>();
try {
......@@ -74,16 +99,36 @@ public class SofarRequestUtil {
String url = SoFarConstant.baseurl + apiurl;
respone = sendRequest(requestMethod, url, requestParmInfo, headMap);
JSONObject jsonObject = JSONObject.parseObject(respone);
// jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone);
// if (!ObjectUtils.isEmpty(jsonArray)) {
// result = JSONArray.parseArray(jsonArray.toJSONString(), tClass);
// }
if(jsonObject!=null&&jsonObject.get(ResultResolveRule)!=null){
result = JSONArray.parseArray(fastjson.JSON.toJSONString(jsonObject.get(ResultResolveRule)), tClass);
}
} catch (Exception exception) {
return result;
exception.printStackTrace();
}
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 response 请求返回的字符串
......
......@@ -9,13 +9,16 @@ import java.util.HashMap;
public class SoFarConstant {
public static final HashMap<String, String> stationStaus = new HashMap<String, String>() {
{
put("-1", "离线");
put("0", "待机");
put("1", "正常");
put("2", "停机");
put("1", "在线");
put("0", "离线");
put("2","报警" );
}
};
public static String baseurl = "https://openapi.sofarsolarmonitor.com";
public static String appId = "447430219192733696";
public static String appSecret = "5881ee8c062817016a2b34425c45937d";
......@@ -26,6 +29,12 @@ public class SoFarConstant {
public static String tokenurl = "/account/auth/createToken";
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 stationDetailUrl = "/api/OpenApi/GetPowerStationMonitorDetail";
public static String collectorListUrl = "/v1/api/collectorList";
......@@ -42,7 +51,11 @@ public class SoFarConstant {
public static String resovleRule_data_page_records = "data,page,records";
public static String resovleRule_data_list = "data,list";
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 requestGet = "GET";
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;
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 {
/**
* @descrption 场站列表数据入库
......@@ -8,11 +15,11 @@ public interface SofarDataAcquisitionService {
/**
* @descrption 场站详情数据入库
*/
void stationDetail();
void stationDetail(List<SofarStationList> jsonObject);
/**
* @descrption 采集器列表数据入库
*/
void collectorList();
void collectorList( List<SofarStationList> jsonObject);
/**
* @descrption 采集器详情数据入库
*/
......@@ -20,7 +27,7 @@ public interface SofarDataAcquisitionService {
/**
* @descrption 逆变器列表数据入库
*/
void inverterList();
void inverterList(SofarInverter sofarInverter, JpStation jpStation, Map<String, String> maps);
/**
* @descrption 逆变器详情数据入库
*/
......
......@@ -99,7 +99,6 @@ public class SunlightServiceImpl implements SunlightService {
List<Sunlight> list = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), Sunlight.class);
this.stationDetail(data);
sunlightMapper.delete(null);
for (Sunlight sunlight : list) {
sunlight.setCreatedTime(System.currentTimeMillis());
......@@ -115,7 +114,7 @@ public class SunlightServiceImpl implements SunlightService {
//电站数据如库,电站统计数据入库
public void stationDetail(JSONObject data){
//所有场站信息
List<SunlightDto> list = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), SunlightDto.class);
......@@ -390,7 +389,7 @@ public class SunlightServiceImpl implements SunlightService {
}
//逆变器
//逆变器数据入库,逆变器参数入库
public void setJpInverte(Device device,JpStation jpStation){
new Thread(new Runnable(){
......@@ -726,7 +725,7 @@ public class SunlightServiceImpl implements SunlightService {
li.add(SunlightUtil.alarmstatus.get("4"));
li.add(SunlightUtil.alarmstatus.get("5"));
List<HYGFJPInverterWarn> hygfjpInverterWarnlist = hygfjpInverterWarnMapper.selectList(new QueryWrapper<HYGFJPInverterWarn>()
.in("`state`", li)
.notIn("`state`", li)
.eq("third_code", PVProducerInfoEnum.YG.getCode())
);
......@@ -755,12 +754,12 @@ public class SunlightServiceImpl implements SunlightService {
hygfjpInverterWarn.setTime(System.currentTimeMillis());
hygfjpInverterWarn.setSnCode(!jpInverterbodyparam.isEmpty()&&jpInverterbodyparam.containsKey(sunlightWarm.getUuid().toString())?jpInverterbodyparam.get(sunlightWarm.getUuid().toString()):null);
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.setThirdCode(PVProducerInfoEnum.YG.getCode());
hygfjpInverterWarn.setTreatment(sunlightWarm.getFault_desc());
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.setRecoverTime(null);
hygfjpInverterWarn.setTimeLong(null);
......@@ -777,7 +776,7 @@ public class SunlightServiceImpl implements SunlightService {
}
//更新td已消除告警
//更新td已消除告警,由于第三方获取会出现请求次数超限,状态只能手动修改,没有消除时间,
if(!bodyparam.isEmpty()){
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