Commit 462e1115 authored by wujiang's avatar wujiang

Merge branch 'developer' of http://36.40.66.175:5000/moa/amos-boot-biz into developer

parents 64b87016 a27d92f2
......@@ -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 请求返回的字符串
......
package com.yeejoin.amos.api.householdapi.Utils;
import cn.hutool.core.text.UnicodeUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.google.gson.Gson;
import com.yeejoin.amos.api.householdapi.face.dto.SunlightDto;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.houseapi.HousepvapiRecordsMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.naming.Name;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
/**
* @description:
* @author阳光电站采集
* @createDate: 2024/2/29
*/
@Component
@Slf4j
public class SunlightUtil {
public static String dfurl="https://gateway.isolarcloud.com";
public static String appkey="D9A9B8A58FD193EEEFEE0C6BD4664626";
public static String access_key="vz47buat1ibrkf66jfiksmvm7att6sk4";
public static String name="jxiop_jdxny";
public static String pasword="tA9WAgmG4z:48gp";
//场站接口
public static String getPowerStationList= "/openapi/getPowerStationList";
//电站详情
public static String getPowerStationDetail="/openapi/getPowerStationDetail";
//电站设备
public static String getDeviceList="/openapi/getDeviceList";
//月,年
public static String getDevicePointsDayMonthYearDataList="/openapi/getDevicePointsDayMonthYearDataList";
//逆变器参数
public static String getPVInverterRealTimeData="/openapi/getPVInverterRealTimeData";
//告警
public static String getFaultAlarmInfo= "/openapi/getFaultAlarmInfo";
public static final HashMap<String, String> intoNetWorkStatus = new HashMap<String, String>() {
{
put("1", "全额上网");
put("2", ":自发自用,余电上网");
put("3", "自发自用,无馈网");
put("4", "离网");
}
};
// public static final HashMap<String, Double> co = new HashMap<String, Double>() {
// {
// put("克",0.001 );
// put("千克", );
// put("吨", );
// put("千吨", );
// }
// };
public static final HashMap<String, Double> zj = new HashMap<String, Double>() {
{
put("Wp", 0.001);
put("kWp", 1.0);
put("MWp",1000.0 );
put("GWp", 1000000.0);
}
};
public static final HashMap<String, Double> fd = new HashMap<String, Double>() {
{
put("度", 1.0);
put("千度", 1000.0);
put("万度", 10000.0);
put("亿度", 100000000.0);
}
};
public static final HashMap<String, Double> sy = new HashMap<String, Double>() {
{
put("元", 1.0);
put("万元", 10000.0);
put("亿元", 100000000.0);
}
};
public static final HashMap<String, Double> GL = new HashMap<String, Double>() {
{
put("W", 0.001);
put("kW", 1.0);
put("MW", 1000.0);
put("GW", 1000000.0);
}
};
public static final HashMap<String, String> zt= new HashMap<String, String>() {
{
put("1", "在线");
put("0", "离线");
put("2","报警" );
}
};
public static final HashMap<String, String> alarmLevel = new HashMap<String, String>() {
{
put("1", "重要");
put("2", "次要");
put("3", "一般");
put("3", "轻微");
}
};
public static final HashMap<String, String> alarmstatus = new HashMap<String, String>() {
{
put("1", "未确认");
put("2", "待处理");
put("3", "处理中");
put("4", "已解决");
put("5", "已关闭");
}
};
private static final String redisKey = "YG-TOKEN";
@Autowired
RedisUtils redisUtils;
/*
*
* 登录获取token
* */
public String getSunlightToken(){
String token=null;
try {
Object o = redisUtils.get(redisKey);
if(o != null) {
return o.toString();
}
//请求头
HttpRequest request = HttpUtil.createPost(dfurl+"/openapi/login");
request.header("Content-Type", "application/json;charset=UTF-8");
request.header("sys_code", "901");
request.header("x-access-key", access_key);
//请求body
Map<String, String> param = new HashMap();
param.put("appkey", appkey);
param.put("user_account", name);
param.put("user_password", pasword);
Gson gson = new Gson();
String body = gson.toJson(param);
request.body(body);
HttpResponse execute = request.execute();
if (!execute.isOk()) {
log.error("请求token失败,body={},execute={}", execute.body(), execute);
throw new RuntimeException(execute.body());
}
String res = UnicodeUtil.toString(execute.body());
JSONObject jsonObject = JSONUtil.parseObj(res, true);
if (!jsonObject.get("result_msg").toString().equals("success")){
log.error("请求失败,code={},result={}", jsonObject.get("result_msg"), jsonObject);
throw new RuntimeException("请求失败!");
}
JSONObject resultData = JSONUtil.parseObj(jsonObject.get("result_data"), true);
if (!resultData.get("login_state").toString().equals("1")) {
log.error("获取token失败,code={},msg={},result={}", resultData.get("login_state"), resultData.get("msg"), resultData);
throw new RuntimeException("获取token失败,code=" + resultData.get("login_state") + ",msg=" + resultData.get("msg"));
}
redisUtils.set(redisKey,resultData.get("token").toString(),14400 );
return resultData.get("token").toString();
} catch (Exception e) {
log.error("requestToken失败,msg={}", e.getMessage());
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}
//获取接口数据
public JSONObject getdata(String url,Map<String, Object> bodyparam ){
String data=null;
try {
//请求头
HttpRequest request = HttpUtil.createPost(dfurl+url);
request.header("Content-Type", "application/json;charset=UTF-8");
request.header("sys_code", "901");
request.header("x-access-key", access_key);
//请求body
bodyparam.put("appkey", appkey);
bodyparam.put("token", this.getSunlightToken());
Gson gson = new Gson();
String body = gson.toJson(bodyparam);
request.body(body);
HttpResponse execute = request.execute();
if (!execute.isOk()) {
throw new RuntimeException(execute.body());
}
String res = UnicodeUtil.toString(execute.body());
JSONObject jsonObject = JSONUtil.parseObj(res, true);
JSONObject resultData = JSONUtil.parseObj(jsonObject.get("result_data"), true);
return resultData;
} catch (Exception e) {
log.error("失败,msg={}", e.getMessage());
e.printStackTrace();
throw new RuntimeException(e.getMessage());
}
}
}
package com.yeejoin.amos.api.householdapi.constant;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
/**
* 固德威常量
......@@ -16,6 +18,151 @@ public class GoodWeConstant {
put("2", "停机");
}
};
public static final HashMap<String, String> warningStaus = new HashMap<String, String>() {
{
put("0", "未处理");
put("1", "已处理");
}
};
public static final HashMap<String, String> taskStaus = new HashMap<String, String>() {
{
put("1", "已派送");
put("2", "未派送");
}
};
public static final HashMap<String, List<String>> errorCodeMap = new HashMap<String, List<String>>() {
{
put("E0", Arrays.asList("漏电流自检异常",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.机器内部元器件出现故障",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E1", Arrays.asList("交流电流自检异常",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.机器内部元器件出现故障",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E2", Arrays.asList("采样基准电压异常",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.控制板有问题",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E3", Arrays.asList("直流分量校验异常",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.控制板有问题",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E4", Arrays.asList("漏电流校验异常",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.机器内部元器件出现故障",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E5", Arrays.asList("未知类型",
"1.请联系售后",
"1.请联系售后"));
put("E6", Arrays.asList("漏电流传感器故障",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.控制板有问题",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E7", Arrays.asList("继电器故障",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.控制板有问题",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E8", Arrays.asList("交流传感器故障",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.控制板有问题",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E9", Arrays.asList("电网丢失故障",
"1.电网停电 |2.机器 AC 端接线异常|3.AC 开关连接异常或开关损坏|4.AC 端未连接",
"1.确定电网是否停电|2.利用万用表测量机器AC 端是否有电压|3.检查 AC 开关是否损坏|4.确认AC 端接线是否有误 (零火线是否接反)|5.确认电网连接正常,确保 AC 开关闭合|6.尝试g关闭机器DC/AC 端,5 分钟之后重新连接 DC/AC 端"));
put("E10", Arrays.asList("漏电流高故障",
"1.交流测零地线接 线有误|2.报错发生在早晚或阴雨天气,空气湿度相对较高,也有可能引起报错",
"用万用变测量机器外壳对地是否有电压,若有电压说明 AC 端地线接线有问题"));
put("E11", Arrays.asList("直流母线过高故障",
"1.光伏组串电压超过机器最大直流输入电压|2.机器控制板有问题",
"1.用万用表测量DC 端实际电压,看是否超过机器正常电压范围|2.如果 DC 电压超高,建议减少每个组串组件的数量,确保组串电压在机器最大直流输入电压范围内"));
put("E12", Arrays.asList("内部风扇故障",
"1.外部风扇设备被异物阻塞|2.风扇内部接线有异常",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E13", Arrays.asList("机器温度过高故障",
"1.机器长时间在高温环境下运行|2.机器安装环境不利于机器散热(如比较封闭的环境等)",
"1. 设法降低机器周围的温度|2.检查机器安装是否满足产品用户手册要求|3. 尝试关闭机器,15 分钟后再重新打开"));
put("E14", Arrays.asList("漏电流自检超时",
"机器自检时GFCI 值偏高导致",
"1.尝试重新启动机器,查看是否正常|2.可能需要升级机器软件版本解决问题"));
put("E15", Arrays.asList("面板电压过高故障",
"PV 组串电压(开路电压)超出逆变器最大直流输入电压",
"1.用万用表测量DC 端实际电压,看是否超过机器正常电压范围|2.如果 DC 电压超高,建议减少每个组串组件的数量,确保组串电压在机器最大直流输入电压范围内"));
put("E16", Arrays.asList("外部风扇故障",
"1.外部风扇设备被异物阻塞|2.风扇内部接线有异常",
"请检查风扇内部是否有异物阻塞"));
put("E17", Arrays.asList("电网电压异常",
"1.安规设置错误|2.市电电压不稳定|3.交流线线径小,或者交流线较长导致交流线阻值较高,压降较高|4.交流线接线有误,导致交流端电压异常",
"1.检查机器安规设置是否正确,如不正确,请关闭交流电,更改安规后再连接交流电|2. 如果安规设置正确,请用万用表测量交流测每项火线对零线的电压值是否超出正常范围|3.确认机器安装地区市电电压是否有不稳定情况"));
put("E18", Arrays.asList("面板绝缘阻抗低故障",
"1. 光伏面板接地线未连接或连接有误|2.直流线破损|3.交流端零、地线接线有误|4.报错发生在早晚或阴雨天气,空气湿度相对较高,易引发ISO 报错",
"1.依次插拔每串组件,确定引发报错的组串|2.检查直流线是否有破|3. 利用万用表测量AC 端零地线之间的电压是否过高(一般不超过 10V), 如超过 10V, 则说明零地线接线异常|4.检查组件接地线是否有异常,确保每串组件接地线能够接触到大地"));
put("E19", Arrays.asList("输出直流分量过高",
"机器检测到内部直流输入分量超出正常范围",
"请联系售后服务"));
put("E20", Arrays.asList("LCD 通讯故障",
"1.内部LCD 数据线松动.",
"请联系售后服务"));
put("E21", Arrays.asList("组串过流",
"某一组串电流过大",
"请检查组串连接情况"));
put("E22", Arrays.asList("主从频率校验异常",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.控制板有问题",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E23", Arrays.asList("主从电压校验异常",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.控制板有问题",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E24", Arrays.asList("未知类型",
"请联系售后",
"请联系售后服务"));
put("E25", Arrays.asList("继电器自检异常",
"1.三相机控制板和功率版之间的排线松动|2.交流端零、地线接线有误|3.机器控制板问题",
"1.利用万用表测量AC 端零地线之间的电压是否过高(一般不超过10V),如超过 10V, 则说明零地线接线异常|2. 尝试重启机器,看是否机器可回复正常工作"));
put("E26", Arrays.asList("电池授权错误",
"连接该逆变器的电池功能未激活",
"请先购买电池激活码并在 PV Master 中激活电池功能,然后连接电池使用该功能"));
put("E27", Arrays.asList("未知类型",
"1.请联系售后",
"1.请联系售后服务"));
put("E28", Arrays.asList("未知类型",
"1.请联系售后",
"1.请联系售后服务"));
put("E29", Arrays.asList("电网频率异常",
"1.安规设置错误|2.电网频率不稳定",
"1.检查机器安规设置是否正确,如不正确,请关闭交流电,更改安规后再连接交流电 |2.如果机器安规设置正确,请在机器页面查看是否电网频率(Fac)超出正常范围|3.如果“电网频率限”报错只是偶尔出现,并很快恢复正常,则说明报错是因为电网频率偶尔的不稳定造成的, 对系统正常运行不会影响"));
put("E30", Arrays.asList("内部存储故障",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.机器内部元器件损",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
put("E31", Arrays.asList("内部通讯故障",
"1.受外部因素(如受 磁场影响等)引起的暂时性现象|2.控制板有问题",
"1.尝试重启机器,看机器是否仍然报错, 如果机器恢复正常,说明该报错只是偶然性事件,不会影响系统正常运行|2. 如果重启机器无法恢复正常,请联系售后服务"));
}
};
public static String baseurl = "http://openapi.sems.com.cn";
public static String account = "18679135705";
......@@ -25,11 +172,14 @@ public class GoodWeConstant {
public static String stationListUrl = "/api/OpenApi/GetUserPowerStation";
public static String stationListStatusUrl = "/api/OpenApi/QueryPowerStationMonitor";
public static String stationDetailUrl = "/api/OpenApi/GetPowerStationMonitorDetail";
public static String stationGenUrl = "/api/OpenApi/GetPowerStationPower";
public static String collectorListUrl = "/v1/api/collectorList";
public static String collectorDetailUrl = "/v1/api/collectorDetail";
public static String inverterListUrl = "/v1/api/inverterList";
public static String queryInventerUrl = "/api/OpenApi/QueryInventers";
public static String getInventersDatas = "/api/OpenApi/GetInventersDatas";
public static String getinverterGenURl = "/api/OpenApi/GetInverterPower";
public static String inverterDetailUrl = "/v1/api/inverterDetail";
public static String alarmListUrl = "/v1/api/alarmList";
public static String alarmListUrl = "/api/OpenApi/GetPowerStationWariningInfoByMultiCondition";
public static String stationDayGenUrl ="/v1/api/stationDayEnergyList";
public static String stationMonthEnergyList ="/v1/api/stationDayEnergyList";
public static String stationYearEnergyList ="/v1/api/stationDayEnergyList";
......@@ -46,4 +196,5 @@ public class GoodWeConstant {
public static DateTimeFormatter formatter = DateTimeFormatter.ofPattern(datePattern);
public static Double kwhToMwh = 0.0001;
public static Double mwhTokwh = 1000.0;
public static Double wToKw = 0.001;
}
......@@ -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";
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.api.householdapi.controller;
import com.yeejoin.amos.api.householdapi.Utils.GoodWeRequestUtil;
import com.yeejoin.amos.api.householdapi.Utils.HouseholdPvUtils;
import com.yeejoin.amos.api.householdapi.face.dto.GoodWEGenStation;
import com.yeejoin.amos.api.householdapi.face.service.*;
import com.yeejoin.amos.api.householdapi.face.service.impl.ImasterDataServiceImpl;
import com.yeejoin.amos.api.householdapi.face.service.impl.SofarDataAcquisitionServiceImpl;
......@@ -52,7 +53,15 @@ public class HouseholdTestController {
@ApiOperation(httpMethod = "POST", value = "固德威示例", notes = "固德威示例")
public void goodweDemo() throws IOException {
// goodWeDataAcquisitionService.stationList();
goodWeDataAcquisitionService.stationDetail();
// goodWeDataAcquisitionService.stationDetail();
// goodWeDataAcquisitionService.inverAlramInfo();
// goodWeDataAcquisitionService.inverterList();
// goodWeDataAcquisitionService.inverterDetail();
// goodWeDataAcquisitionService.stationMonthGen();
// goodWeDataAcquisitionService.stationYearGen();
// goodWeDataAcquisitionService.inverterDetail();
goodWeDataAcquisitionService.inverterMonthGen();
goodWeDataAcquisitionService.inverterYearGen();
}
/**
......
package com.yeejoin.amos.api.householdapi.face.dto;
import lombok.Data;
// 固德威实时数据
@Data
public class D {
public double vpv3;
public double vpv2;
public double vpv1;
public double fac3;
public double fac2;
public double fac1;
public double vpv4;
public double ipv2;
public double pac;
public double ipv1;
public double ipv4;
public double ipv3;
public double eDay;
public double vac3;
public String creationDate;
public double istr9;
public double vac2;
public double istr8;
public double vac1;
public double istr5;
public double istr10;
public double istr4;
public double eTotal;
public double istr7;
public double istr6;
public double istr1;
public double iac2;
public double istr3;
public double iac1;
public double hTotal;
public double istr2;
public double iac3;
public double istr16;
public double istr15;
public double istr14;
public double istr13;
public double istr12;
public double istr11;
}
package com.yeejoin.amos.api.householdapi.face.dto;
import lombok.Data;
/**
* @description:
* @author: tw
* @createDate: 2024/3/4
*/
@Data
public class Device {
private Integer chnnl_id;//设备通道 ID
private String type_name;//设备类型名称
private String ps_key;//设备的 ps_key,查询设备数据需要用到
private String device_sn;//设备的 SN
private String dev_status;//设备当前在线离线状态
private String dev_fault_status;//设备当前故障状态设备故障状态:
private Integer device_type;//设备类型编码
private String factory_name;//生产厂家名
private Integer uuid;//设备 uuid
private String grid_connection_date;//电网连接日期
private String device_name;//设备名称
private Integer rel_state;//设备认领状态:
private Integer device_code;//设备地址编码
private Integer ps_id;//电站id
private Integer device_model_id;//设备型号 ID
private String communication_dev_sn;//设备对应的通信设备的 SN
private String device_model_code;//设备型号名称
}
package com.yeejoin.amos.api.householdapi.face.dto;
import lombok.Data;
@Data
public class GoodWEGenStation {
private String date;
private String power;
private String income;
}
package com.yeejoin.amos.api.householdapi.face.dto;
import lombok.Data;
import org.joda.time.DateTime;
@Data
public class GoodWeAlarmDto {
// stationId string 电站 ID
// adcode string 区域编码
// stationname string 电站名称
// devicesn string 设备 SN
// warningid string 告警 id
// warningname string 告警名称
// status int 状态 1:已处理 0:未处理
// happentime Datetime? 发生时间
// recoverytime Datetime? 恢复时间
// is_add_task Int 是否派送 1:已派送 2:未派送
// error_code string 错误编码-详细参考 3.3 告警错误
private String stationId;
private String adcode;
private String stationname;
private String devicesn;
private String warningid;
private String warningname;
private Integer status;
private DateTime happentime;
private DateTime recoverytime;
private Integer is_add_task;
private String error_code;
}
package com.yeejoin.amos.api.householdapi.face.dto;
import lombok.Data;
@Data
public class GoodWeINverterDetailDto {
private String id;
private String pw_id;
private String it_name;
private String it_sn;
private String it_type;
private Double it_capacity;
private Double it_checkcode;
private String conn_date;
private Boolean it_change_flag;
}
package com.yeejoin.amos.api.householdapi.face.dto;
import lombok.Data;
@Data
public class GoodWeInverterCurrentDataDto {
public int error_original;
public D d;
public double out_pac;
public String type;
public double etotal;
public double capacity;
public double tempperature;
public String turnon_time;
public String check_code;
public String name;
public double eday;
public boolean it_change_flag;
public String sn;
public double in_pac;
public int status;
}
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;
}
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.dto;
import lombok.Data;
import java.util.Map;
/**
* @description:
* @author: tw
* @createDate: 2024/3/4
*/
@Data
public class SunlightDto {
private Integer ps_id ;// 11 电站 ID
private String ps_name ;// 电站名称
private String share_type; // 1 电站的分享类型 1:分享类型(浏览权限)2:分享类型(管理权限)0:非分享电站(本人电站)
// 1:地面电站
//3:分布式光伏
//4:户用光伏
//5:户用储能
//6;村级电站
//7:分布式储能
//8:扶贫电站
//9:风能电站
private Integer ps_type ;
private Integer valid_flag ; //电站状态1:正常,2:停用, 3:接入中
private String install_date;// 建站时间
private String ps_current_time_zone;// 电站当前时区
private String ps_location ; //电站位置
private String description ;//电站简介
private Double longitude; // 32 经度
private Double latitude;// Double 32 纬度
private Integer fault_count; //故障数量
private Integer alarm_count;// 告警数量
private Integer ps_status ;// 电站状态
private Integer ps_fault_status;// 电站故障状态
private Integer build_status ;// 电站建设状态
private Integer connect_type;// 并网类型:
private String total_energy_update_time;//电站累计发电量最后更新时间格式:yyyy-MM-dd'T'HH:mm:ssXXX
private String today_energy_update_time; //今日发电量最后更新时间格式:yyyy-MM-dd'T'HH:mm:ssXXX
private String cur_power_update_time;//当前功率最后更新时间
private String today_income_update_time;//今日收益最后更新时间
private String total_income_update_time;//累计收益最后更新时间
private String co2_reduce_update_time;//减排最后更新时间格式:yyyy-MM-dd'T'HH:mm:ssXXX
private String co2_reduce_total_update_time;//co2 减排最后更新时间格式:yyyy-MM-dd'T'HH:mm:ssXXX
private String total_capcity_update_time;//总装机量最后更新时间
private String equivalent_hour_update_time;//今日等效小时最后更新时间格式:yyyy-MM-dd'T'HH:mm:ssXXX
private Map<String,String> total_energy ;// 电站累计发电<value,unit>
private Map<String,String> today_energy ;// 电站今日发电<value,unit>
private Map<String,String> curr_power ;// 当前功率<value,unit>
private Map<String,String> today_income ;// 今日收益<value,unit>
private Map<String,String> total_income ;// 累计收益<value,unit>
private Map<String,String> co2_reduce ;// 今日 CO2 减排<value,unit>
private Map<String,String> co2_reduce_total ;// 累计 CO2 减排<value,unit>
private Map<String,String> total_capcity ;// 总装机量<value,unit>
private Map<String,String> equivalent_hour ;// 今日等效小时<value,unit>
}
package com.yeejoin.amos.api.householdapi.face.dto;
import lombok.Data;
/**
* @description:
* @author: tw
* @createDate: 2024/3/4
*/
@Data
public class SunlightMap {
private String unit ;// 数值单位
private String value ;//数值
}
package com.yeejoin.amos.api.householdapi.face.dto;
import lombok.Data;
/**
* @description:
* @author: tw
* @createDate: 2024/3/6
*/
@Data
public class SunlightWarm {
private Integer ps_id;//电站 id
private String ps_key ;// 设备 ps_key
private String fault_code ;// 故障唯一 id
private Integer fault_type_code ;// 故障类型编码
private Integer fault_type ;// 故障类型:
private Integer fault_level ;// 故障级别:
private Integer process_status ;// 故障处理状态:
private String fault_name ;// 故障名称
private String fault_desc ;// 故障描述
private String type_name ;// 设备类型名称
private String ps_name ;// 电站名称
private String device_name ;// 设备名称
private String device_model_code ;// 设备型号
private Integer uuid ;// 设备的 uuid
private String create_time ;// 故障发生时间
private String over_time ;// 故障的恢复时间
}
......@@ -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;
}
......@@ -21,4 +21,5 @@ public class HYGFJPInverterWarn implements Serializable {
private String thirdStationId;
private String thirdCode;
private String state;
private String warnId;
}
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.orm.houseapi.entity.tdeingine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
/**
* @description:
* @author: tw
* @createDate: 2024/3/7
*/
//电站
@Data
@TableName(value = "sofar_station_list" ,autoResultMap = true)
public class SofarStationList {
private Long createdTime;
private Integer batterySoc;//电池容量
private Long createDate ;//创建时间
private Integer generationPower ;// 发电功率
private String gridInterconnectionType ;// 并网类型,如:DISTRIBUTED_FULLY
private Long id ;//电站id
private Integer installedCapacity ;// 装机容量
private Long lastUpdateTime ;//电站的最后一条数据更新时间
private String locationAddress ;// 详细地址
private Integer locationLat ;// 纬度
private Integer locationLng ;// 经度
private String name ;// 电站名称
private String networkStatus ;// 通信状态
private Integer regionLevel1 ;// 行政区1
private Integer regionLevel2 ;// 行政区2
private Integer regionLevel3 ;// 行政区3
private Integer regionLevel4 ;// 行政区4
private Integer regionLevel5 ;// 行政区5
private String stationImage ;// 电站封面
private Long startOperatingTime ;//开始运行时间
private String type ;// 电站类型,如:HOUSE_ROOF
}
package com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.io.Serializable;
/**
* @description:
* @author: tw
* @createDate: 2024/3/4
*/
@Data
@TableName(value = "sunlight_station_list" ,autoResultMap = true)
public class Sunlight implements Serializable {
private Long createdTime;
private Integer psId ; //id
private String psName ; //电站名称
private Integer validFlag ;// 电站状态
private String psLocation; //电站位置
private String description; //电站简介
private Double longitude; //经度
private Double latitude; //纬度
private Integer psStatus; //电站状态
private Integer psFaultStatus; //电站故障状态
}
......@@ -4,7 +4,12 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpInverter;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface JpInverterMapper extends BaseMapper<JpInverter> {
@Select("SELECT sum(current_power) FROM hygf_jp_inverter WHERE third_code='HW'")
Double getHuaWeiStationCurrentPower();
@Select("select sn_code from hygf_jp_inverter where third_code='GOODWE'")
List<String> getGoodWeSnCodes();
}
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.SofarStationList;
/**
* @description:
* @author: tw
* @createDate: 2024/3/7
*/
public interface SofarStationListMapper extends BaseMapper<SofarStationList> {
}
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.Sunlight;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* @description:
* @author: tw
* @createDate: 2024/3/4
*/
public interface SunlightMapper extends BaseMapper<Sunlight> {
@Select("select psId from sunlight_station_list group by psId")
List<String> getStationIds();
}
......@@ -9,6 +9,9 @@ public interface GoodWeDataAcquisitionService {
* @descrption 场站详情数据入库
*/
void stationDetail();
void stationMonthGen();
void stationYearGen();
/**
* @descrption 采集器列表数据入库
*/
......@@ -25,6 +28,10 @@ public interface GoodWeDataAcquisitionService {
* @descrption 逆变器详情数据入库
*/
void inverterDetail();
void inverterMonthGen();
void inverterYearGen();
/**
* @descrption 采集器告警列表数据入库
*/
......
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 逆变器详情数据入库
*/
......
package com.yeejoin.amos.api.householdapi.face.service;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine.KsolarStationMapper;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine.SunlightMapper;
import org.springframework.beans.factory.annotation.Autowired;
/**
* @description:
* @author: tw
* @createDate: 2024/3/4
*/
public interface SunlightService {
/**
* @descrption 场站列表数据入td库
*/
void stationList();
/**
* 告警信息
* */
void inverAlramInfo();
}
package com.yeejoin.amos.api.householdapi.face.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.google.common.collect.Lists;
import com.qiniu.util.Json;
import com.yeejoin.amos.api.householdapi.Utils.GoodWeRequestUtil;
import com.yeejoin.amos.api.householdapi.constant.GoLangConstant;
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.*;
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.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.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;
import java.util.Map;
import java.util.stream.Collectors;
@Service
public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionService {
@Autowired
......@@ -21,6 +41,45 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
GoodWeStationMonitorListMapper goodWeStationMonitorListMapper;
@Autowired
GoodWeStationDetailMapper goodWeStationDetailMapper;
@Autowired
JpStationMapper jpStationMapper;
@Autowired
private JpInverterMapper jpInverterMapper;
@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 JpInverterElectricityMapper jpInverterElectricityMapper;
@Autowired
private TdHYGFInverterDayGenerateMapper tdHYGFInverterDayGenerateMapper;
@Autowired
private TdHYGFInverterMonthGenerateMapper tdHYGFInverterMonthGenerateMapper;
@Autowired
private TdHYGFInverterYearGenerateMapper tdHYGFInverterYearGenerateMapper;
@Autowired
private HYGFJPDayPowerMapper hygfjpDayPowerMapper;
@Autowired
private TdHYGFStationDayGenerateMapper tdHYGFStationDayGenerateMapper;
@Autowired
private TdHYGFStationMonthGenerateMapper tdHYGFStationMonthGenerateMapper;
@Autowired
private TdHYGFStationYearGenerateMapper tdHYGFStationYearGenerateMapper;
@Autowired
private TdHYGFInverterTotalGenerateMapper tdHYGFInverterTotalGenerateMapper;
@Override
public void stationList() {
......@@ -28,11 +87,137 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
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);
if(goodWeStationLists.size()>0){
goodWeStationLists.forEach(goodWeStationList -> {
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(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.setThirdStationId(goodWeStationList.getPowerstation_id());
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.getPac() * GoodWeConstant.wToKw);
jpStation.setState(GoodWeConstant.stationStaus.get(goodWeStationList.getStatus()));
jpStation.setDayGenerate(goodWeStationList.getEday());
jpStation.setDayIncome(goodWeStationList.getEday_income());
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);
}
});
}
}
......@@ -40,23 +225,81 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
@Override
public void stationDetail() {
List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
stationIds.forEach(stationId ->{
stationIds.forEach(stationId -> {
HashMap<String, Object> requestInfo = new HashMap<>();
String requstParam = JSON.toJSONString(requestInfo);
String apiurl = GoodWeConstant.stationDetailUrl+"?id="+stationId;
List<GoodWeStationDetail> goodWeStationDetails =goodWeRequestUtil.getResPonse(apiurl, GoodWeConstant.requestGet, requstParam, GoodWeConstant.resovleRule_data, GoodWeStationDetail.class);
if(goodWeStationDetails.size()>0){
String apiurl = GoodWeConstant.stationDetailUrl + "?id=" + stationId;
List<GoodWeStationDetail> goodWeStationDetails = goodWeRequestUtil.getResPonse(apiurl, GoodWeConstant.requestGet, requstParam, GoodWeConstant.resovleRule_data, GoodWeStationDetail.class);
if (goodWeStationDetails.size() > 0) {
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());
jpStation.setAccessTime(DateUtil.parse(goodWeStationDetail.getTurnon_time(), DatePattern.NORM_DATETIME_PATTERN));
if (!ObjectUtils.isEmpty(jpStation.getSequenceNbr())) {
jpStationMapper.updateById(jpStation);
}
});
}
});
}
@Override
public void stationMonthGen() {
List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
stationIds.forEach(stationId -> {
String currentMonth = DateUtil.format(new Date(), "yyyyMM");
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("id", stationId);
requestInfo.put("date", DateUtil.today());
requestInfo.put("count", 0);
requestInfo.put("type", 1);
String requstParam = JSON.toJSONString(requestInfo);
List<GoodWEGenStation> goodWEGenStations = goodWeRequestUtil.getResPonse(GoodWeConstant.stationGenUrl, GoodWeConstant.requestPost, requstParam, GoodWeConstant.resovleRule_data, GoodWEGenStation.class);
List<GoodWEGenStation> currentMonthGenStations = goodWEGenStations.stream().filter(goodWEGenStation -> goodWEGenStation.getDate().equals(currentMonth)).collect(Collectors.toList());
currentMonthGenStations.forEach(goodWEGenStation -> {
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.GDW.getCode()).eq("third_station_id", stationId));
if (ObjectUtils.isNotEmpty(jpStation)) {
jpStation.setMonthGenerate(Double.parseDouble(goodWEGenStation.getPower()));
jpStation.setMonthIncome(jpStation.getMonthGenerate() * 0.42);
jpStationMapper.updateById(jpStation);
}
});
});
}
@Override
public void stationYearGen() {
List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
stationIds.forEach(stationId -> {
String currentYear = DateUtil.format(new Date(), "yyyy");
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("id", stationId);
requestInfo.put("date", DateUtil.today());
requestInfo.put("count", 0);
requestInfo.put("type", 2);
String requstParam = JSON.toJSONString(requestInfo);
List<GoodWEGenStation> goodWEGenStations = goodWeRequestUtil.getResPonse(GoodWeConstant.stationGenUrl, GoodWeConstant.requestPost, requstParam, GoodWeConstant.resovleRule_data, GoodWEGenStation.class);
List<GoodWEGenStation> currentMonthGenStations = goodWEGenStations.stream().filter(goodWEGenStation -> goodWEGenStation.getDate().equals(currentYear)).collect(Collectors.toList());
currentMonthGenStations.forEach(goodWEGenStation -> {
JpStation jpStation = jpStationMapper.selectOne(new QueryWrapper<JpStation>().eq("third_code", PVProducerInfoEnum.GDW.getCode()).eq("third_station_id", stationId));
if (ObjectUtils.isNotEmpty(jpStation)) {
jpStation.setYearGenerate(Double.parseDouble(goodWEGenStation.getPower()));
jpStation.setYearIncome(jpStation.getYearGenerate() * 0.42);
jpStationMapper.updateById(jpStation);
}
});
});
}
@Override
public void collectorList() {
......@@ -69,16 +312,364 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
@Override
public void inverterList() {
List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
stationIds.stream().forEach(stationId -> {
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("page_index", 1);
requestInfo.put("page_size", 100);
requestInfo.put("pw_id", stationId);
String requstParam = JSON.toJSONString(requestInfo);
List<GoodWeINverterDetailDto> inverterDetailDtoList = goodWeRequestUtil.getResPonse(GoodWeConstant.queryInventerUrl
, GoodWeConstant.requestPost, requstParam, GoodWeConstant.resovleRule_data_list, GoodWeINverterDetailDto.class);
inverterDetailDtoList.forEach(goodWeINverterDetailDto -> {
// System.out.println(goodWeINverterDetailDto.getIt_sn());
JpInverter jpInverter = jpInverterMapper.selectOne(new QueryWrapper<JpInverter>().
eq("third_station_id", goodWeINverterDetailDto.getPw_id()).
eq("third_code", PVProducerInfoEnum.GDW.getCode()).
eq("sn_code", goodWeINverterDetailDto.getIt_sn()));
if (org.springframework.util.ObjectUtils.isEmpty(jpInverter)) {
jpInverter = new JpInverter();
}
jpInverter.setName(goodWeINverterDetailDto.getIt_name());
jpInverter.setSnCode(goodWeINverterDetailDto.getIt_sn());
jpInverter.setUpdateTime(new Date());
jpInverter.setId(String.valueOf(goodWeINverterDetailDto.getId()));
jpInverter.setCapacity(goodWeINverterDetailDto.getIt_capacity());
jpInverter.setThirdStationId(goodWeINverterDetailDto.getPw_id());
jpInverter.setThirdCode(PVProducerInfoEnum.GDW.getCode());
jpInverter.setStationName(goodWeINverterDetailDto.getIt_name());
jpInverter.setRecDate(new Date());
if (!org.springframework.util.ObjectUtils.isEmpty(jpInverter.getSequenceNbr())) {
jpInverterMapper.updateById(jpInverter);
} else {
jpInverterMapper.insert(jpInverter);
}
});
});
}
@Override
public void inverterDetail() {
List<String> goodweSnList = jpInverterMapper.getGoodWeSnCodes();
List<List<String>> splitList = Lists.partition(goodweSnList, 50);
HashMap<String, Object> requestInfo = new HashMap<>();
String requstParam = JSON.toJSONString(requestInfo);
for (int i = 0; i < splitList.size(); i++) {
String requestSns = splitList.get(i).stream().map(s -> "sns=" + s).collect(Collectors.joining("&"));
String apiUrl = GoodWeConstant.getInventersDatas + "?" + requestSns;
List<GoodWeInverterCurrentDataDto> list = goodWeRequestUtil.getResPonse(apiUrl, GoodWeConstant.requestGet, requstParam, GoodWeConstant.resovleRule_data_list, GoodWeInverterCurrentDataDto.class);
list.forEach(goodWeInverterCurrentDataDto -> {
JpInverter jpInverter = jpInverterMapper.selectOne(new QueryWrapper<JpInverter>().
eq("third_code", PVProducerInfoEnum.GDW.getCode()).
eq("sn_code", goodWeInverterCurrentDataDto.getSn()));
jpInverter.setIgbtTemperature(String.valueOf(goodWeInverterCurrentDataDto.getTempperature()));
jpInverter.setDayPowerGeneration(goodWeInverterCurrentDataDto.getEday());
jpInverter.setCapacity(goodWeInverterCurrentDataDto.getCapacity());
jpInverterMapper.updateById(jpInverter);
JSONObject hanlderResult = JSONObject.parseObject(JSON.toJSONString(goodWeInverterCurrentDataDto.getD()));
for (int k = 1; k < 3; k++) {
JpInverterElectricity jpInverterElectricity = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>().
eq("sn_code", goodWeInverterCurrentDataDto.getSn()).
eq("type", "交流").
eq("name", "AC" + k)
);
if (org.springframework.util.ObjectUtils.isEmpty(jpInverterElectricity)) {
jpInverterElectricity = new JpInverterElectricity();
}
jpInverterElectricity.setInverterId(jpInverter.getId());
jpInverterElectricity.setSnCode(goodWeInverterCurrentDataDto.getSn());
jpInverterElectricity.setThirdCode(PVProducerInfoEnum.GDW.getCode());
jpInverterElectricity.setThirdStationId(jpInverter.getThirdStationId());
jpInverterElectricity.setType("交流");
jpInverterElectricity.setName("AC" + k);
jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("vac" + k).toString()));
jpInverterElectricity.setCurrent(Double.valueOf(hanlderResult.get("iac" + k).toString()));
if (org.springframework.util.ObjectUtils.isEmpty(jpInverterElectricity.getSequenceNbr())) {
jpInverterElectricityMapper.insert(jpInverterElectricity);
} else {
jpInverterElectricityMapper.updateById(jpInverterElectricity);
}
}
for (int k1 = 1; k1 < 4; k1++) {
JpInverterElectricity jpInverterElectricity = jpInverterElectricityMapper.selectOne(new QueryWrapper<JpInverterElectricity>().
eq("sn_code", goodWeInverterCurrentDataDto.getSn()).
eq("type", "直流").
eq("name", "PV" + k1)
);
if (org.springframework.util.ObjectUtils.isEmpty(jpInverterElectricity)) {
jpInverterElectricity = new JpInverterElectricity();
}
jpInverterElectricity.setInverterId(jpInverter.getId());
jpInverterElectricity.setSnCode(goodWeInverterCurrentDataDto.getSn());
jpInverterElectricity.setThirdCode(PVProducerInfoEnum.GDW.getCode());
jpInverterElectricity.setThirdStationId(jpInverter.getThirdStationId());
jpInverterElectricity.setType("直流");
jpInverterElectricity.setName("PV" + k1);
jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("vpv" + k1).toString()));
jpInverterElectricity.setCurrent(Double.valueOf(hanlderResult.get("ipv" + k1).toString()));
// jpInverterElectricity.setPower(Double.valueOf(hanlderResult.get("pow" + k1).toString()));
if (org.springframework.util.ObjectUtils.isEmpty(jpInverterElectricity.getSequenceNbr())) {
jpInverterElectricityMapper.insert(jpInverterElectricity);
} else {
jpInverterElectricityMapper.updateById(jpInverterElectricity);
}
}
HYGFJPInverterElecHistory hygfjpInverterElecHistory = new HYGFJPInverterElecHistory();
hygfjpInverterElecHistory.setThirdStationId(jpInverter.getThirdStationId());
hygfjpInverterElecHistory.setCreatedTime(System.currentTimeMillis());
hygfjpInverterElecHistory.setSnCode(goodWeInverterCurrentDataDto.getSn());
hygfjpInverterElecHistory.setUAcCurrent(goodWeInverterCurrentDataDto.getD().getIac1());
hygfjpInverterElecHistory.setVAcCurrent(goodWeInverterCurrentDataDto.getD().getIac2());
hygfjpInverterElecHistory.setWAcCurrent(goodWeInverterCurrentDataDto.getD().getIac3());
hygfjpInverterElecHistory.setUAcVoltage(goodWeInverterCurrentDataDto.getD().getVac1());
hygfjpInverterElecHistory.setVAcVoltage(goodWeInverterCurrentDataDto.getD().getVac2());
hygfjpInverterElecHistory.setWAcVoltage(goodWeInverterCurrentDataDto.getD().getVac3());
hygfjpInverterElecHistory.setThirdCode(PVProducerInfoEnum.GDW.getCode());
hygfjpInverterElecHistory.setTime(System.currentTimeMillis());
hygfjpInverterElecHistoryMapper.insert(hygfjpInverterElecHistory);
// 逆变器历史
String today = DateUtil.today();
HYGFJPInverterHistory hygfjpInverterHistory = hygfjpInverterHistoryMapper.selectOne(new QueryWrapper<HYGFJPInverterHistory>()
.eq("sn_code", goodWeInverterCurrentDataDto.getSn())
.eq("date", today));
if (org.springframework.util.ObjectUtils.isEmpty(hygfjpInverterHistory)) {
hygfjpInverterHistory = new HYGFJPInverterHistory();
}
hygfjpInverterHistory.setDate(today);
hygfjpInverterHistory.setThirdStationId(jpInverter.getThirdStationId());
hygfjpInverterHistory.setInverterId(jpInverter.getId());
hygfjpInverterHistory.setSnCode(goodWeInverterCurrentDataDto.getSn());
hygfjpInverterHistory.setThirdCode(PVProducerInfoEnum.GDW.getCode());
if(ObjectUtils.isNotEmpty(jpInverter.getCapacity())&&ObjectUtils.isNotEmpty(jpInverter.getDayPowerGeneration())){
hygfjpInverterHistory.setGenerationHours(jpInverter.getDayPowerGeneration()/jpInverter.getCapacity());
}
hygfjpInverterHistory.setPowerGeneration(goodWeInverterCurrentDataDto.getEday());
if (org.springframework.util.ObjectUtils.isEmpty(hygfjpInverterHistory.getCreatedTime())) {
hygfjpInverterHistory.setCreatedTime(System.currentTimeMillis());
hygfjpInverterHistoryMapper.insert(hygfjpInverterHistory);
} else {
hygfjpInverterHistoryMapper.insert(hygfjpInverterHistory);
}
//-----------------------户用光伏日报表----------------------
TdHYGFInverterDayGenerate tdHYGFInverterDayGenerate = new TdHYGFInverterDayGenerate();
tdHYGFInverterDayGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFInverterDayGenerate.setName(jpInverter.getName());
tdHYGFInverterDayGenerate.setThirdStationId(String.valueOf(jpInverter.getThirdStationId()));
tdHYGFInverterDayGenerate.setSnCode(jpInverter.getSnCode().trim());
tdHYGFInverterDayGenerate.setWorkStatus(jpInverter.getState());
D d = goodWeInverterCurrentDataDto.getD();
//交流电压
tdHYGFInverterDayGenerate.setDcv1(d.getVac1());
tdHYGFInverterDayGenerate.setDcv2(d.getVac2());
tdHYGFInverterDayGenerate.setDcv3(d.getVac3());
//交流电流
// tdHYGFInverterDayGenerate.setDcv4(inverterDetailDto.getUAc4());
tdHYGFInverterDayGenerate.setDcc1(d.getIac1());
tdHYGFInverterDayGenerate.setDcc2(d.getIac2());
tdHYGFInverterDayGenerate.setDcc3(d.getIac3());
// tdHYGFInverterDayGenerate.setDcc4(inverterDetailDto.getIAc4());
//直流电压
tdHYGFInverterDayGenerate.setAcv1(d.getVpv1());
tdHYGFInverterDayGenerate.setAcv2(d.getVpv2());
tdHYGFInverterDayGenerate.setAcv3(d.getVpv3());
tdHYGFInverterDayGenerate.setAcv4(d.getVpv4());
//直流电流
tdHYGFInverterDayGenerate.setAcc1(d.getIpv1());
tdHYGFInverterDayGenerate.setAcc2(d.getIpv2());
tdHYGFInverterDayGenerate.setAcc3(d.getIpv3());
tdHYGFInverterDayGenerate.setAcc4(d.getIpv4());
//功率
// tdHYGFInverterDayGenerate.setPv1(inverterDetailDto.getPow1());
// tdHYGFInverterDayGenerate.setPv2(inverterDetailDto.getPow2());
// tdHYGFInverterDayGenerate.setPv3(inverterDetailDto.getPow3());
// tdHYGFInverterDayGenerate.setPv4(inverterDetailDto.getPow4());
// tdHYGFInverterDayGenerate.setTotalPower(inverterDetailDto.getPac());
// tdHYGFInverterDayGenerate.setFrequency(String.valueOf(inverterDetailDto.getFac()));
// tdHYGFInverterDayGenerate.setPowerFactor(inverterDetailDto.getPowerFactor());
tdHYGFInverterDayGenerate.setDayGen(jpInverter.getDayPowerGeneration());
tdHYGFInverterDayGenerate.setMonthGen(jpInverter.getMonthPowerGeneration());
tdHYGFInverterDayGenerate.setYearGen(jpInverter.getYearPowerGeneration());
tdHYGFInverterDayGenerate.setTotalGen(jpInverter.getTotalPowerGeneration());
tdHYGFInverterDayGenerate.setIgbtTemp(goodWeInverterCurrentDataDto.getTempperature());
tdHYGFInverterDayGenerate.setIncome(null);
if(ObjectUtils.isNotEmpty(jpInverter.getCapacity())&&ObjectUtils.isNotEmpty(jpInverter.getDayPowerGeneration())){
tdHYGFInverterDayGenerate.setFullhour(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 (org.springframework.util.ObjectUtils.isEmpty(tdHYGFInverterMonthGenerate)) {
tdHYGFInverterMonthGenerate = new TdHYGFInverterMonthGenerate();
}
tdHYGFInverterMonthGenerate.setThirdStationId(jpInverter.getThirdStationId());
tdHYGFInverterMonthGenerate.setSnCode(jpInverter.getSnCode().trim());
tdHYGFInverterMonthGenerate.setName(jpInverter.getName());
tdHYGFInverterMonthGenerate.setDayTime(DateUtil.format(today1, "yyyy-MM-dd"));
tdHYGFInverterMonthGenerate.setYearMonth(DateUtil.format(today1, "yyyy-MM"));
tdHYGFInverterMonthGenerate.setGenerate(jpInverter.getDayPowerGeneration());
if(ObjectUtils.isNotEmpty(jpInverter.getCapacity())&&ObjectUtils.isNotEmpty(jpInverter.getDayPowerGeneration())){
tdHYGFInverterMonthGenerate.setFullhour(jpInverter.getDayPowerGeneration() / jpInverter.getCapacity());}
if (org.springframework.util.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 (org.springframework.util.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());
if(ObjectUtils.isNotEmpty(jpInverter.getCapacity())&&ObjectUtils.isNotEmpty(jpInverter.getMonthPowerGeneration())){
tdHYGFInverterYearGenerate.setFullhour(jpInverter.getMonthPowerGeneration() / jpInverter.getCapacity());
}
tdHYGFInverterYearGenerate.setName(jpInverter.getName());
if (org.springframework.util.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 (org.springframework.util.ObjectUtils.isEmpty(tdHYGFInverterTotalGenerate)) {
tdHYGFInverterTotalGenerate = new TdHYGFInverterTotalGenerate();
}
tdHYGFInverterTotalGenerate.setThirdStationId(jpInverter.getThirdStationId());
tdHYGFInverterTotalGenerate.setName(null == jpInverter.getName() ? null : jpInverter.getName());
tdHYGFInverterTotalGenerate.setSnCode(jpInverter.getSnCode().trim());
tdHYGFInverterTotalGenerate.setYearTime(DateUtil.format(today1, "yyyy"));
tdHYGFInverterTotalGenerate.setYear(DateUtil.format(today1, "yyyy"));
tdHYGFInverterTotalGenerate.setGenerate(jpInverter.getYearPowerGeneration());
if(ObjectUtils.isNotEmpty(jpInverter.getCapacity())&&ObjectUtils.isNotEmpty(jpInverter.getYearPowerGeneration())) {
tdHYGFInverterTotalGenerate.setFullhour(jpInverter.getYearPowerGeneration() / jpInverter.getCapacity());
}
if (org.springframework.util.ObjectUtils.isEmpty(tdHYGFInverterTotalGenerate.getCreatedTime())) {
tdHYGFInverterTotalGenerate.setCreatedTime(System.currentTimeMillis());
tdHYGFInverterTotalGenerateMapper.insert(tdHYGFInverterTotalGenerate);
} else {
tdHYGFInverterTotalGenerateMapper.insert(tdHYGFInverterTotalGenerate);
}
});
}
}
@Override
public void inverAlramInfo() {
public void inverterMonthGen() {
List<String> sns =jpInverterMapper.getGoodWeSnCodes() ;
String currentMonth = DateUtil.format(new Date(), "yyyyMM");
sns.forEach(sn -> {
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("sn", sn);
requestInfo.put("date", DateUtil.today());
requestInfo.put("count", 0);
requestInfo.put("type", 1);
String requstParam = JSON.toJSONString(requestInfo);
String apiUrl = GoodWeConstant.getinverterGenURl+"?sn="+sn+"&date="+DateUtil.today()+"&count=0&type=1";
List<GoodWEGenStation> goodWEGenStations = goodWeRequestUtil.getResPonse(apiUrl, GoodWeConstant.requestGet, requstParam, GoodWeConstant.resovleRule_data, GoodWEGenStation.class);
List<GoodWEGenStation> currentMonthGenStations = goodWEGenStations.stream().filter(goodWEGenStation -> goodWEGenStation.getDate().equals(currentMonth)).collect(Collectors.toList());
currentMonthGenStations.forEach(goodWEGenStation -> {
JpInverter jpInverter = jpInverterMapper.selectOne(new QueryWrapper<JpInverter>().eq("third_code", PVProducerInfoEnum.GDW.getCode()).eq("sn_code", sn));
if (ObjectUtils.isNotEmpty(jpInverter)) {
jpInverter.setMonthPowerGeneration(Double.parseDouble(goodWEGenStation.getPower()));
jpInverterMapper.updateById(jpInverter);
}
});
});
}
@Override
public void inverterYearGen() {
String currentYear = DateUtil.format(new Date(), "yyyy");
List<String> sns =jpInverterMapper.getGoodWeSnCodes() ;
sns.forEach(sn -> {
HashMap<String, Object> requestInfo = new HashMap<>();
requestInfo.put("sn", sn);
requestInfo.put("date", DateUtil.today());
requestInfo.put("count", 0);
requestInfo.put("type", 2);
String requstParam = JSON.toJSONString(requestInfo);
String apiUrl = GoodWeConstant.getinverterGenURl+"?sn="+sn+"&date="+DateUtil.today()+"&count=0&type=2";
List<GoodWEGenStation> goodWEGenStations = goodWeRequestUtil.getResPonse(apiUrl, GoodWeConstant.requestGet, requstParam, GoodWeConstant.resovleRule_data, GoodWEGenStation.class);
List<GoodWEGenStation> currentMonthGenStations = goodWEGenStations.stream().filter(goodWEGenStation -> goodWEGenStation.getDate().equals(currentYear)).collect(Collectors.toList());
currentMonthGenStations.forEach(goodWEGenStation -> {
JpInverter jpInverter = jpInverterMapper.selectOne(new QueryWrapper<JpInverter>().eq("third_code", PVProducerInfoEnum.GDW.getCode()).eq("sn_code", sn));
if (ObjectUtils.isNotEmpty(jpInverter)) {
jpInverter.setYearPowerGeneration(Double.parseDouble(goodWEGenStation.getPower()));
jpInverterMapper.updateById(jpInverter);
}
});
});
}
@Override
public void inverAlramInfo() {
HashMap<String, Object> requestInfo = new HashMap<>();
String today = DateUtil.today();
requestInfo.put("page_index", 1);
requestInfo.put("page_size", 1000);
requestInfo.put("starttime", today + " 00:00:00");
requestInfo.put("endtime", today + " 23:59:59");
requestInfo.put("status", 2);
String requstParam = JSON.toJSONString(requestInfo);
List<GoodWeAlarmDto> alarmList = goodWeRequestUtil.getResPonse(GoodWeConstant.alarmListUrl, GoodWeConstant.requestPost, requstParam, GoodWeConstant.resovleRule_data_list, GoodWeAlarmDto.class);
alarmList.forEach(goodWeAlarmDto -> {
if (!ObjectUtils.isEmpty(goodWeAlarmDto.getDevicesn())) {
HYGFJPInverterWarn hygfjpInverterWarn = hygfjpInverterWarnMapper.selectOne(new QueryWrapper<HYGFJPInverterWarn>()
.eq("sn_code", goodWeAlarmDto.getDevicesn())
.eq("start_time", goodWeAlarmDto.getHappentime().getMillis())
.eq("third_station_id", String.valueOf(goodWeAlarmDto.getStationId()))
);
if (ObjectUtils.isEmpty(hygfjpInverterWarn)) {
hygfjpInverterWarn = new HYGFJPInverterWarn();
}
hygfjpInverterWarn.setTime(System.currentTimeMillis());
hygfjpInverterWarn.setSnCode(goodWeAlarmDto.getDevicesn());
hygfjpInverterWarn.setThirdStationId(goodWeAlarmDto.getStationId());
// hygfjpInverterWarn.setLevel(GoLangConstant.alarmLevel.get(alarmDto.getAlarmLevel()));
hygfjpInverterWarn.setContent(goodWeAlarmDto.getWarningname());
hygfjpInverterWarn.setThirdCode(PVProducerInfoEnum.GDW.getCode());
hygfjpInverterWarn.setTreatment(GoodWeConstant.errorCodeMap.get(goodWeAlarmDto.getError_code()).get(2));
hygfjpInverterWarn.setStartTime(goodWeAlarmDto.getHappentime().getMillis());
hygfjpInverterWarn.setRecoverTime(null);
if (!ObjectUtils.isEmpty(goodWeAlarmDto.getRecoverytime())) {
hygfjpInverterWarn.setRecoverTime(goodWeAlarmDto.getRecoverytime().getMillis());
}
hygfjpInverterWarn.setTimeLong(null);
if ((!ObjectUtils.isEmpty(goodWeAlarmDto.getHappentime())) && (!ObjectUtils.isEmpty(goodWeAlarmDto.getRecoverytime()))) {
hygfjpInverterWarn.setTimeLong(goodWeAlarmDto.getRecoverytime().getMillis() - goodWeAlarmDto.getHappentime().getMillis());
}
hygfjpInverterWarn.setState(GoodWeConstant.warningStaus.get(goodWeAlarmDto.getStatus().toString()));
if (org.springframework.util.ObjectUtils.isEmpty(hygfjpInverterWarn.getCreatedTime())) {
hygfjpInverterWarn.setCreatedTime(System.currentTimeMillis());
hygfjpInverterWarnMapper.insert(hygfjpInverterWarn);
} else {
hygfjpInverterWarnMapper.insert(hygfjpInverterWarn);
}
}
});
}
}
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.SunlightUtil;
import com.yeejoin.amos.api.householdapi.constant.KSolarConstant;
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.openapi.enums.PVProducerInfoEnum;
import fastjson.JSON;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
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
public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionService {
@Autowired
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
@Scheduled(cron = "${dataRequstScheduled.Sofar}")
public void stationList() {
Map<String, Object> requestInfo = new HashMap<>();
requestInfo.put("page", 1);
requestInfo.put("size", 1000);
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
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
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
}
@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();
}
......
package com.yeejoin.amos.api.householdapi.face.service.impl;
import cn.hutool.core.date.DatePattern;
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.QueryWrapper;
import com.yeejoin.amos.api.householdapi.Utils.SunlightUtil;
import com.yeejoin.amos.api.householdapi.constant.KSolarConstant;
import com.yeejoin.amos.api.householdapi.face.dto.Device;
import com.yeejoin.amos.api.householdapi.face.dto.KsolarAlarmDto;
import com.yeejoin.amos.api.householdapi.face.dto.SunlightDto;
import com.yeejoin.amos.api.householdapi.face.dto.SunlightWarm;
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.SunlightService;
import com.yeejoin.amos.openapi.enums.PVProducerInfoEnum;
import fastjson.JSON;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* @description:
* @author: tw
* @createDate: 2024/3/4
*/
@Service
public class SunlightServiceImpl implements SunlightService {
@Autowired
SunlightMapper sunlightMapper;
@Autowired
private JpStationMapper jpStationMapper;
@Autowired
private JpCollectorMapper jpCollectorMapper;
@Autowired
private JpInverterMapper jpInverterMapper;
//监盘逆变器电量mapper
@Autowired
private JpInverterElectricityMapper jpInverterElectricityMapper;
@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
ApplicationContext applicationContext;
//户用光伏逆变器告警
@Autowired
private HYGFJPInverterWarnMapper hygfjpInverterWarnMapper;
@Autowired
SunlightUtil SunlightUtil;
//td电站信息存储
@Override
@Scheduled(cron = "${dataRequstScheduled.Sunlight}")
public void stationList() {
Map<String, Object> bodyparam=new HashMap<>();
bodyparam.put("ps_type", "1,3,4,5,6,7,8");
bodyparam.put("size", 3000);
bodyparam.put("curPage", 1);
JSONObject data = SunlightUtil.getdata(
SunlightUtil.getPowerStationList,
bodyparam
);
List<Sunlight> list = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), Sunlight.class);
this.stationDetail(data);
for (Sunlight sunlight : list) {
sunlight.setCreatedTime(System.currentTimeMillis());
sunlightMapper.insert(sunlight);
}
}
//电站数据如库,电站统计数据入库
public void stationDetail(JSONObject data){
//所有场站信息
List<SunlightDto> list = JSONArray.parseArray(JSON.toJSONString(data.get("pageList")), SunlightDto.class);
//业务表场站
List<JpStation> jpStations = jpStationMapper.selectList(new QueryWrapper<JpStation>().
eq("third_code", PVProducerInfoEnum.YG.getCode()));
Map<String, JpStation> bodyparam=new HashMap<>();
if(jpStations!=null&&jpStations.size()>0){
bodyparam = jpStations.stream().collect(Collectors.toMap(JpStation::getThirdStationId,Function.identity()));
}
//封装电站数据
// for (SunlightDto sunlightDto : list) {
for (int i = 0; i < list.size(); i++) {
SunlightDto sunlightDto=list.get(i);
if(i==160){
System.out.println("22222");
}
System.out.println(i+"====================================================");
JpStation jpStation=null;
if(bodyparam.containsKey(sunlightDto.getPs_id().toString())){
jpStation=bodyparam.get(sunlightDto.getPs_id().toString());
}else{
jpStation=new JpStation();
}
jpStation.setThirdStationId(sunlightDto.getPs_id().toString());
jpStation.setName(sunlightDto.getPs_name());
jpStation.setAddress(sunlightDto.getPs_location());
jpStation.setLongitude(("null".equals(sunlightDto.getLongitude())||(sunlightDto.getLongitude()==null)||"0.0".equals(sunlightDto.getLongitude()))?null:sunlightDto.getLongitude().toString());
jpStation.setLatitude(("null".equals(sunlightDto.getLatitude())||(sunlightDto.getLatitude()==null)||"0.0".equals(sunlightDto.getLatitude()))?null:sunlightDto.getLatitude().toString());
jpStation.setThirdCode(PVProducerInfoEnum.YG.getCode());
// 并网类型
jpStation.setOnGridType(SunlightUtil.intoNetWorkStatus.get(String.valueOf(sunlightDto.getConnect_type())));
//第三方厂商标识
jpStation.setThirdCode(PVProducerInfoEnum.YG.getCode());
jpStation.setRecDate(new Date());
//获取单个电站详情
Map<String, Object> bodyparamf=new HashMap<>();
bodyparamf.put("ps_id", sunlightDto.getPs_id().toString());
JSONObject jsonObject = SunlightUtil.getdata(
SunlightUtil.getPowerStationDetail,
bodyparamf
);
jpStation.setRatedPower(jsonObject.get("design_capacity")!=null?Double.valueOf(jsonObject.get("design_capacity").toString())/1000:null);//额定功率
jpStation.setUserName(jsonObject.get("ps_name")!=null?jsonObject.get("ps_name").toString():null);// 业主姓名
jpStation.setEmail(jsonObject.get("email")!=null?jsonObject.get("email").toString():null);// 邮箱
jpStation.setUserPhone(jsonObject.get("user_moble_tel")!=null?jsonObject.get("user_moble_tel").toString():null);//业主电话
jpStation.setCreateTime(jsonObject.get("install_date")!=null?
DateUtil.parse(jsonObject.get("install_date")+"", "yyyy-MM-dd HH:mm:ss") :null); // 创建时间
jpStation.setType("家庭户用");//电站类型
// jpStation.setArea();//地区
jpStation.setPrice(1.0);//上网电价
// jpStation.setOnGridTime(); // 并网时间
// jpStation.setAccessTime();// 接入平台时间
// jpStation.setStationContact();// 电站联系人
// jpStation.setModuleCount(); // 组件数量
jpStation.setSnCode(sunlightDto.getPs_id().toString());//sncode
Map<String,String> map= sunlightDto.getTotal_capcity();
jpStation.setCapacity( map!=null&&map.get("unit")!=null?
SunlightUtil.zj.get(String.valueOf(map.get("unit")))*Double.valueOf(String.valueOf(map.get("value"))):null);//装机容量
Map<String,String> map1= sunlightDto.getCurr_power();
jpStation.setRealTimePower( map1!=null&&map1.get("unit")!=null?
SunlightUtil.GL.get(String.valueOf(map1.get("unit")))*Double.valueOf(String.valueOf(map1.get("value"))):null);//实时功率
Map<String,String> map2= sunlightDto.getToday_energy();
jpStation.setDayGenerate( map2!=null&&map2.get("unit")!=null?
SunlightUtil.fd.get(String.valueOf(map2.get("unit")))*Double.valueOf(String.valueOf(map2.get("value"))):null);//日发电量
Map<String,String> map3= sunlightDto.getTotal_energy();
jpStation.setAccumulatedPower(map3!=null&&map3.get("unit")!=null?
SunlightUtil.fd.get(String.valueOf(map3.get("unit")))*Double.valueOf(String.valueOf(map3.get("value"))):null);//累计发电量
Map<String,String> map4= sunlightDto.getToday_income();
jpStation.setDayIncome(map4!=null&&map4.get("unit")!=null?
SunlightUtil.sy.get(String.valueOf(map4.get("unit")))*Double.valueOf(String.valueOf(map4.get("value"))):null);// 日收益
Map<String,String> map5= sunlightDto.getTotal_income();
jpStation.setCumulativeIncome(map5!=null&&map5.get("unit")!=null?
SunlightUtil.sy.get(String.valueOf(map5.get("unit")))*Double.valueOf(String.valueOf(map5.get("value"))):null);// 累计收益
if(sunlightDto.getPs_fault_status()>2) {
jpStation.setState(SunlightUtil.zt.get(sunlightDto.getPs_status()+""));//电站状态
}else{
jpStation.setState("报警");//电站状态
}
//获取电站下逆变器
Map<String, Object> bodyparamjp=new HashMap<>();
List<String> lif=new ArrayList<>();
lif.add("1");
bodyparamjp.put("ps_id", sunlightDto.getPs_id().toString());
bodyparamjp.put("size", 3000);
bodyparamjp.put("curPage", 1);
bodyparamjp.put("device_type_list",lif);
JSONObject jsonObject1data = SunlightUtil.getdata(
SunlightUtil.getDeviceList,
bodyparamjp
);
List<Device> listd = JSONArray.parseArray(JSON.toJSONString(jsonObject1data.get("pageList")), Device.class );
//获取电站,月发电量
if(listd!=null&&listd.size()>0){
Map<String, Object> bodyparamnb=new HashMap<>();
List<String> li=new ArrayList<>();
li.add(listd.get(0).getPs_key());
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
bodyparamnb.put("ps_key_list", li);
bodyparamnb.put("start_time",year + "" + ( month<10 ? "0" + month : month) );
bodyparamnb.put("end_time", year + "" + ( month<10 ? "0" + month : month));
bodyparamnb.put("data_type", "4");
bodyparamnb.put("order", "0");
bodyparamnb.put("query_type", "2");
bodyparamnb.put("data_point", "p1");
JSONObject jsonObject1nb = SunlightUtil.getdata(
SunlightUtil.getDevicePointsDayMonthYearDataList,
bodyparamnb
);
JSONObject jsonObject22 = JSONUtil.parseObj(jsonObject1nb.get(listd.get(0).getPs_key()), true);
List<Map> js= JSONArray.parseArray(JSON.toJSONString(jsonObject22.get("p1")),Map.class);
// 月发电量
jpStation.setMonthGenerate(js.get(0).get("4")!=null?Double.valueOf(js.get(0).get("4")+"")/1000:null);
// 月收益
jpStation.setMonthIncome(js.get(0).get("4")!=null?Double.valueOf(js.get(0).get("4")+"")/1000:null);
}
//获取电站,年发电量
if(listd!=null&&listd.size()>0){
Map<String, Object> bodyparamnb=new HashMap<>();
List<String> li=new ArrayList<>();
li.add(listd.get(0).getPs_key());
Calendar calendar = Calendar.getInstance();
int year = calendar.get(Calendar.YEAR);
int month = calendar.get(Calendar.MONTH) + 1;
bodyparamnb.put("ps_key_list", li);
bodyparamnb.put("start_time",year + "" );
bodyparamnb.put("end_time", year + "");
bodyparamnb.put("data_type", "4");
bodyparamnb.put("order", "0");
bodyparamnb.put("query_type", "3");
bodyparamnb.put("data_point", "p1");
JSONObject jsonObject1nb = SunlightUtil.getdata(
SunlightUtil.getDevicePointsDayMonthYearDataList,
bodyparamnb
);
JSONObject jsonObject23 = JSONUtil.parseObj(jsonObject1nb.get(listd.get(0).getPs_key()), true);
List<Map> js= JSONArray.parseArray(JSON.toJSONString(jsonObject23.get("p1")),Map.class);
// 年发电量
jpStation.setYearGenerate(Double.valueOf(js.get(0).get("4")+"")/1000);
// 年收益
jpStation.setYearIncome(Double.valueOf(js.get(0).get("4")+"")/1000);
if (!ObjectUtils.isEmpty(jpStation.getSequenceNbr())) {
jpStationMapper.updateById(jpStation);
} else {
jpStationMapper.insert(jpStation);
}
this.setJpInverte(listd.get(0),jpStation);
}
//电站报表
//户用场站日发电量
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);
}
}
}
//逆变器数据入库,逆变器参数入库
public void setJpInverte(Device device,JpStation jpStation){
new Thread(new Runnable(){
@Override
public void run(){
try{
if(device!=null){
//获取逆变器信息存库
JpInverter jpInverter = jpInverterMapper.selectOne(new QueryWrapper<JpInverter>().
eq("third_station_id", device.getPs_id().toString()).
eq("third_code", PVProducerInfoEnum.YG.getCode()).
eq("ID", device.getUuid().toString()));
if (ObjectUtils.isEmpty(jpInverter)) {
jpInverter = new JpInverter();
}
// 品牌
jpInverter.setBrand(device.getFactory_name());
jpInverter.setSnCode(device.getDevice_sn());
jpInverter.setId(device.getUuid().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(device.getDevice_name());
jpInverter.setStationName(jpStation.getName());
jpInverter.setAddr(jpStation.getAddress());
jpInverter.setModel(device.getDevice_model_code());
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);
}
}
//逆变器指标信息
Map<String, Object> bodyparamnb=new HashMap<>();
List<String> li=new ArrayList<>();
li.add(device.getPs_key());
bodyparamnb.put("ps_key_list", li);
JSONObject jsonObject1nb = SunlightUtil.getdata(
SunlightUtil.getPVInverterRealTimeData,
bodyparamnb
);
List<Map> js= JSONArray.parseArray(JSON.toJSONString(jsonObject1nb.get("device_point_list")),Map.class);
if(js!=null&&js.size()>0){
Map jsd= JSONUtil.parseObj(js.get(0).get("device_point"));
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.YG.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;
switch (liname.get(i)) {
case "AC1":
voltage=jsd.get("p18")!=null?jsd.get("p18").toString():null;
current=jsd.get("p21")!=null?jsd.get("p21").toString():null;
break;
case "AC2":
voltage=jsd.get("p19")!=null?jsd.get("p19").toString():null;
current=jsd.get("p22")!=null?jsd.get("p22").toString():null;
break;
case "AC3":
voltage=jsd.get("p20")!=null?jsd.get("p20").toString():null;
current=jsd.get("p23")!=null?jsd.get("p23").toString():null;
break;
case "PV1":
voltage=jsd.get("p5")!=null?jsd.get("p5").toString():null;
current=jsd.get("p6")!=null?jsd.get("p6").toString():null;
break;
case "PV2":
voltage=jsd.get("p7")!=null?jsd.get("p7").toString():null;
current=jsd.get("p8")!=null?jsd.get("p8").toString():null;
break;
case "PV3":
voltage=jsd.get("p9")!=null?jsd.get("p9").toString():null;
current=jsd.get("p10")!=null?jsd.get("p10").toString():null;
break;
case "PV4":
voltage=jsd.get("p45")!=null?jsd.get("p45").toString():null;
current=jsd.get("")!=null?jsd.get("").toString():null;
break;
case "PV5":
voltage=jsd.get("p47")!=null?jsd.get("p47").toString():null;
current=jsd.get("p46")!=null?jsd.get("p46").toString():null;
break;
case "PV6":
voltage=jsd.get("p49")!=null?jsd.get("p49").toString():null;
current=jsd.get("p48")!=null?jsd.get("p48").toString():null;
break;
case "PV7":
voltage=jsd.get("p51")!=null?jsd.get("p51").toString():null;
current=jsd.get("p50")!=null?jsd.get("p50").toString():null;
break;
case "PV8":
voltage=jsd.get("p53")!=null?jsd.get("p53").toString():null;
current=jsd.get("p52")!=null?jsd.get("p52").toString():null;
break;
case "PV9":
voltage=jsd.get("p55")!=null?jsd.get("p55").toString():null;
current=jsd.get("p54")!=null?jsd.get("p54").toString():null;
break;
case "PV10":
voltage=jsd.get("p57")!=null?jsd.get("p57").toString():null;
current=jsd.get("p58")!=null?jsd.get("p58").toString():null;
break;
default:
}
jpInverterElectricity.setVoltage(voltage!=null?Double.valueOf(voltage):null);
jpInverterElectricity.setCurrent(current!=null?Double.valueOf(current):null);
jpInverterElectricity.setPower(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(jsd.get("p18")!=null?Double.valueOf(jsd.get("p18").toString()):null);
tdHYGFInverterDayGenerate.setDcv2(jsd.get("p19")!=null?Double.valueOf(jsd.get("p19").toString()):null);
tdHYGFInverterDayGenerate.setDcv3(jsd.get("p20")!=null?Double.valueOf(jsd.get("p20").toString()):null);
//交流电流
tdHYGFInverterDayGenerate.setDcc1(jsd.get("p21")!=null?Double.valueOf(jsd.get("p21").toString()):null);
tdHYGFInverterDayGenerate.setDcc2(jsd.get("p22")!=null?Double.valueOf(jsd.get("p22").toString()):null);
tdHYGFInverterDayGenerate.setDcc3(jsd.get("p23")!=null?Double.valueOf(jsd.get("p23").toString()):null);
//直流电压
tdHYGFInverterDayGenerate.setAcv1(jsd.get("p5")!=null?Double.valueOf(jsd.get("p5").toString()):null);
tdHYGFInverterDayGenerate.setAcv2(jsd.get("p7")!=null?Double.valueOf(jsd.get("p7").toString()):null);
tdHYGFInverterDayGenerate.setAcv3(jsd.get("p9")!=null?Double.valueOf(jsd.get("p9").toString()):null);
tdHYGFInverterDayGenerate.setAcv4(jsd.get("p45")!=null?Double.valueOf(jsd.get("p45").toString()):null);
//直流电流
tdHYGFInverterDayGenerate.setAcc1(jsd.get("p6")!=null?Double.valueOf(jsd.get("p6").toString()):null);
tdHYGFInverterDayGenerate.setAcc2(jsd.get("p8")!=null?Double.valueOf(jsd.get("p8").toString()):null);
tdHYGFInverterDayGenerate.setAcc3(jsd.get("p10")!=null?Double.valueOf(jsd.get("p10").toString()):null);
tdHYGFInverterDayGenerate.setAcc4(jsd.get("p46")!=null?Double.valueOf(jsd.get("p46").toString()):null);
tdHYGFInverterDayGenerate.setPv1(null);
tdHYGFInverterDayGenerate.setPv2(null);
tdHYGFInverterDayGenerate.setPv3(null);
tdHYGFInverterDayGenerate.setPv4(null);
//功率
tdHYGFInverterDayGenerate.setTotalPower(jpInverter.getCurrentPower());
// //频率
tdHYGFInverterDayGenerate.setFrequency(String.valueOf(jsd.get("p27")));
// //功率因数
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();
}
@Scheduled(cron = "${dataRequstScheduled.Sunlight}")
@Override
public void inverAlramInfo() {
//获取所有未处理告警
Map<String, Object> bodyparamf=new HashMap<>();
bodyparamf.put("size", 1000);
bodyparamf.put("curPage",1);
JSONObject jsonObject = SunlightUtil.getdata(
SunlightUtil.getFaultAlarmInfo,
bodyparamf
);
List<SunlightWarm> listd = jsonObject.get("pageList")!=null?JSONArray.parseArray(JSON.toJSONString(jsonObject.get("pageList")), SunlightWarm.class ):null;
//获取系统未处理的告警
List<String> li=new ArrayList<>();
li.add(SunlightUtil.alarmstatus.get("4"));
li.add(SunlightUtil.alarmstatus.get("5"));
List<HYGFJPInverterWarn> hygfjpInverterWarnlist = hygfjpInverterWarnMapper.selectList(new QueryWrapper<HYGFJPInverterWarn>()
.notIn("`state`", li)
.eq("third_code", PVProducerInfoEnum.YG.getCode())
);
Map<String, HYGFJPInverterWarn> bodyparam=new HashMap<>();
if(hygfjpInverterWarnlist!=null&&hygfjpInverterWarnlist.size()>0){
bodyparam = hygfjpInverterWarnlist.stream().collect(Collectors.toMap(HYGFJPInverterWarn::getWarnId,Function.identity()));
}
//获取所有逆变器
List<JpInverter> jpInverter = jpInverterMapper.selectList(new QueryWrapper<JpInverter>().
eq("third_code", PVProducerInfoEnum.YG.getCode()));
Map<String, String> jpInverterbodyparam=new HashMap<>();
if(jpInverter!=null&&jpInverter.size()>0){
jpInverterbodyparam = jpInverter.stream().collect(Collectors.toMap(JpInverter::getId,JpInverter::getSnCode));
}
if(listd!=null&&!listd.isEmpty()){
for (SunlightWarm sunlightWarm : listd) {
//告警已存在
if(!bodyparam.isEmpty()&&bodyparam.containsKey(sunlightWarm.getFault_code())) {
bodyparam.remove(sunlightWarm.getFault_code());
}else{
//告警不存在,新增
HYGFJPInverterWarn hygfjpInverterWarn = new HYGFJPInverterWarn();
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().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().toString()));
hygfjpInverterWarn.setTimeLong(null);
hygfjpInverterWarn.setRecoverTime(null);
hygfjpInverterWarn.setTimeLong(null);
hygfjpInverterWarn.setWarnId(sunlightWarm.getFault_code());
try {
TimeUnit.MINUTES.sleep(1);
hygfjpInverterWarn.setCreatedTime(System.currentTimeMillis());
}catch (Exception e){
e.printStackTrace();
}
hygfjpInverterWarnMapper.insert(hygfjpInverterWarn);
}
}
}
//更新td已消除告警,由于第三方获取会出现请求次数超限,状态只能手动修改,没有消除时间,
if(!bodyparam.isEmpty()){
Object[] ids= bodyparam.keySet().toArray();
for (Object id : ids) {
// Map<String, Object> bodyparamfx=new HashMap<>();
// bodyparamfx.put("size", 1000);
// bodyparamfx.put("curPage",1);
// bodyparamfx.put("process_status",9);
// bodyparamfx.put("fault_code",id);
// JSONObject jsonObjectx = SunlightUtil.getdata(
// SunlightUtil.getFaultAlarmInfo,
// bodyparamfx
// );
// List<SunlightWarm> listx = JSONArray.parseArray(JSON.toJSONString(jsonObjectx.get("pageList")), SunlightWarm.class );
// if(listx!=null&&!listx.isEmpty()){
// SunlightWarm sunlightWarm=listx.get(0);
HYGFJPInverterWarn hygfjpInverterWarn= bodyparam.get(id);
//
// if (StringUtils.isNotBlank(sunlightWarm.getOver_time())) {
// hygfjpInverterWarn.setRecoverTime(DateUtil.parse(sunlightWarm.getOver_time(), DatePattern.NORM_DATETIME_PATTERN).getTime());
// }
// if (!ObjectUtils.isEmpty(hygfjpInverterWarn.getStartTime()) && !ObjectUtils.isEmpty(hygfjpInverterWarn.getRecoverTime())) {
// hygfjpInverterWarn.setTimeLong(hygfjpInverterWarn.getRecoverTime() - hygfjpInverterWarn.getStartTime());
// }
//hygfjpInverterWarn.setState(SunlightUtil.alarmstatus.get(sunlightWarm.getProcess_status()));
hygfjpInverterWarn.setState(SunlightUtil.alarmstatus.get("5"));
hygfjpInverterWarnMapper.insert(hygfjpInverterWarn);
// }
}
}
}
}
......@@ -4,10 +4,11 @@ package com.yeejoin.amos.openapi.enums;
public enum PVProducerInfoEnum {
GDW("固德威","GDW"),
GDW("固德威","GOODWE"),
SH("首航","SH"),
JLY("锦浪云","JLY"),
KSOLAR("科士达","KSD"),
YG("阳光","YG"),
HUAWEI("华为","HW");
private String name;
......
......@@ -5,19 +5,19 @@ server.port=11006
## DB properties hygf
## db1-production database
spring.db1.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db1.datasource.url=jdbc:mysql://172.16.10.220:3306/amos_openapi?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db1.datasource.url=jdbc:mysql://47.92.234.253:3306/amos_openapi?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db1.datasource.username=root
spring.db1.datasource.password=Yeejoin@2020
spring.db1.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
## db2-sync_data
spring.db2.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db2.datasource.url=jdbc:mysql://47.92.234.253:3306/amos_project_2023?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db2.datasource.url=jdbc:mysql://47.92.234.253:3306/amos_project?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8
spring.db2.datasource.username=root
spring.db2.datasource.password=Yeejoin@2020
spring.db2.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
## db3-taosiData
spring.db3.datasource.type: com.alibaba.druid.pool.DruidDataSource
spring.db3.datasource.url=jdbc:TAOS-RS://139.9.170.47:6041/house_pv_data?user=root&password=taosdata&characterEncoding=utf8
spring.db3.datasource.url=jdbc:TAOS-RS://47.92.234.253:6041/house_pv_data?user=root&password=taosdata&characterEncoding=utf8
spring.db3.datasource.username=root
spring.db3.datasource.password=taosdata
spring.db3.datasource.driver-class-name=com.taosdata.jdbc.rs.RestfulDriver
......@@ -25,7 +25,7 @@ spring.db3.datasource.driver-class-name=com.taosdata.jdbc.rs.RestfulDriver
# REDIS (RedisProperties)
spring.redis.database=1
spring.redis.host=172.16.10.220
spring.redis.host=47.92.234.253
spring.redis.port=6379
spring.redis.password=yeejoin@2020
spring.redis.lettuce.pool.max-active=200
......@@ -35,7 +35,7 @@ spring.redis.lettuce.pool.min-idle=0
spring.redis.expire.time=300
#注册中心地址
eureka.client.service-url.defaultZone =http://172.16.10.220:10001/eureka/
eureka.client.service-url.defaultZone =http://admin:a1234560@47.92.234.253:10001/eureka/
eureka.instance.prefer-ip-address=true
management.endpoint.health.show-details=always
management.endpoints.web.exposure.include=*
......@@ -49,7 +49,7 @@ eureka.instance.instance-id=${eureka.instance.ip-address}:${server.port}
##emqx
emqx.clean-session=true
emqx.client-id=${spring.application.name}-${random.int[1024,65536]}
emqx.broker=tcp://172.16.10.220:1883
emqx.broker=tcp://47.92.234.253:1883
emqx.client-user-name=admin
emqx.client-password=public
......@@ -69,6 +69,11 @@ biz.lxyd.lift.url=http://39.106.181.149:8088/elevatorapi
# ??????????
dataRequstScheduled.jinlangyun=0 0/10 * * * *
dataRequstScheduled.huawei=0 0/10 * * * *
dataRequstScheduled.keshida=0 0/10 * * * *
\ No newline at end of file
dataRequstScheduled.jinlangyun=0 0/50 * * * *
dataRequstScheduled.huawei=0 0/50 * * * *
dataRequstScheduled.keshida=0 0/50 * * * *
dataRequstScheduled.Sunlight=0 0/50 * * * *
dataRequstScheduled.Sofar=0 0/3 * * * *
\ No newline at end of file
......@@ -391,6 +391,9 @@ public class IdxBizFanHealthIndexController extends BaseController {
startTimeTop = formatter.format(startDate);
}
List<String> gatewayIds = this.getGatewayIds();
if(this.getGatewayIds().size()==0){
gatewayIds= Arrays.asList("qweqweqweqweqweqwe");
}
List<FanHealthIndexDay> fanHealthIndexDays = fanHealthIndexDayMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop,(current-1)*size,size, gatewayIds);
fanHealthIndexDays.forEach(item -> {
......@@ -568,8 +571,10 @@ public class IdxBizFanHealthIndexController extends BaseController {
@RequestParam(value = "subSystem",required = false) String subSystem,
@RequestParam(value = "current",required = false) Integer current,
@RequestParam(value = "size",required = false) Integer size){
List<String> gatewayIds = this.getGatewayIds();
if(this.getGatewayIds().size()==0){
gatewayIds= Arrays.asList("qweqweqweqweqweqwe");
}
if (requiredType.equals("按天")){
// if (null != type && type.equals("0")){
Date startDayTime = DateUtils.getCurrentDayStartTime(new Date());
......@@ -583,7 +588,7 @@ public class IdxBizFanHealthIndexController extends BaseController {
// Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTimeTop), -8);
// startTimeTop = formatter.format(startDate);
// }
List<FanHealthIndexDay> fanHealthIndexDays = fanHealthIndexDayMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop,(current-1)*size,size, null);
List<FanHealthIndexDay> fanHealthIndexDays = fanHealthIndexDayMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop,(current-1)*size,size, gatewayIds);
fanHealthIndexDays.forEach(item -> {
item.setHealthIndex(Double.parseDouble(df.format(item.getHealthIndex())));
});
......@@ -608,7 +613,7 @@ public class IdxBizFanHealthIndexController extends BaseController {
// Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTimeTop), -8);
// startTimeTop = formatter.format(startDate);
// }
List<FanHealthIndexHour> fanHealthIndexHours = fanHealthIndexHourMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop,(current-1)*size,size, null);
List<FanHealthIndexHour> fanHealthIndexHours = fanHealthIndexHourMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop,(current-1)*size,size, gatewayIds);
fanHealthIndexHours.forEach(item -> {
item.setHealthIndex(Double.parseDouble(df.format(item.getHealthIndex())));
});
......@@ -632,7 +637,7 @@ public class IdxBizFanHealthIndexController extends BaseController {
// Date startDate = DateUtils.dateAddHours(DateUtils.longStr2Date(startTimeTop), -8);
// startTimeTop = formatter.format(startDate);
// }
List<FanHealthIndexMoment> fanHealthIndexMoments = fanHealthIndexMomentMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop,(current-1)*size,size, null);
List<FanHealthIndexMoment> fanHealthIndexMoments = fanHealthIndexMomentMapper.selectData(healthLevel, area, equipmentName, subSystem, analysisType, analysisObjType, station, pointName, indexAddress, startTimeTop, endTimeTop,(current-1)*size,size, gatewayIds);
fanHealthIndexMoments.forEach(item -> {
item.setHealthIndex(Double.parseDouble(df.format(item.getHealthIndex())));
});
......
......@@ -265,6 +265,9 @@ public class IdxBizPvHealthIndexController extends BaseController {
List<String> gatewayIds = this.getGatewayIds();
if(gatewayIds.size()==0){
gatewayIds = Arrays.asList("qweqweqweqeqwqweqw");
}
if (requiredType.equals("按天")){
Date startDayTime = DateUtils.getCurrentDayStartTime(new Date());
Date date = DateUtils.dateAddHours(startDayTime, -9);
......
......@@ -380,13 +380,14 @@ public class KafkaAnalyseController {
if (rootNodeName.equals("all")) {
return fullViewRecallInfoDTOS;
} else {
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS1 = fullViewRecallInfoDTOS.get(0).getChildren().stream().filter(item -> item.getName().equals(rootNodeName)).collect(Collectors.toList());
List<String> stringList = Arrays.asList(rootNodeName,rootNodeName.replace("片区","区域"),rootNodeName.replace("区域","片区"),rootNodeName.replace("电站","电场"),rootNodeName.replace("电场","电站"));
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS1 = fullViewRecallInfoDTOS.get(0).getChildren().stream().filter(item -> stringList.contains(item.getName())).collect(Collectors.toList());
if (fullViewRecallInfoDTOS1.size() > 0) {
return fullViewRecallInfoDTOS1;
} else {
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS2 = fullViewRecallInfoDTOS.get(0).getChildren();
for (FullViewRecallInfoDTO fullViewRecallInfoDTO : fullViewRecallInfoDTOS2) {
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS3=fullViewRecallInfoDTO.getChildren().stream().filter(item -> item.getName().equals(rootNodeName)).collect(Collectors.toList());
List<FullViewRecallInfoDTO> fullViewRecallInfoDTOS3=fullViewRecallInfoDTO.getChildren().stream().filter(item -> stringList.contains(item.getName())).collect(Collectors.toList());
if (fullViewRecallInfoDTOS3.size()>0){
return fullViewRecallInfoDTOS3;
}
......
......@@ -4,6 +4,7 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.FanWarningRecordServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.HealthStatusIndicatorServiceImpl;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.PvWarningRecordServiceImpl;
......@@ -28,25 +29,20 @@ import java.util.stream.Collectors;
@Slf4j
public class WarningRecordStatusMessage extends EmqxListener {
@Autowired
protected EmqKeeper emqKeeper;
/**
* 预警状态修改消息 - 标准化
*/
public static final String WARNING_CHANGE_MESSAGE = "+/warning/change";
@Autowired
private FanWaringRecordMapper fanWaringRecordMapper;
@Autowired
private PvWaringRecordMapper pvWaringRecordMapper;
protected EmqKeeper emqKeeper;
@Autowired
FanWarningRecordServiceImpl fanWarningRecordService;
@Autowired
PvWarningRecordServiceImpl pvWarningRecordService;
@Autowired
private FanWaringRecordMapper fanWaringRecordMapper;
@Autowired
private PvWaringRecordMapper pvWaringRecordMapper;
@PostConstruct
void init() throws Exception {
......@@ -71,8 +67,29 @@ public class WarningRecordStatusMessage extends EmqxListener {
public void jxIopUpdateFan(JSONArray analysisResult) {
log.info("修改预警状态信息:{}", analysisResult);
List<JSONObject> taskList = JSONObject.parseArray(analysisResult.toJSONString(), JSONObject.class);
taskList = taskList.stream().filter(t-> "2".equals(t.getString("processingStatus"))).collect(Collectors.toList());
List<String> traceIds = taskList.stream().map(t -> t.get("extAttr1").toString()).collect(Collectors.toList());
taskList = taskList.stream().filter(t -> "2".equals(t.getString("processingStatus"))).collect(Collectors.toList());
taskList.stream().forEach(jsonObject -> {
String[] params = jsonObject.getString("extAttr1").split("@");
QueryWrapper<FanWarningRecord> queryWrapper =new QueryWrapper<>();
queryWrapper.eq("station",jsonObject.getString("sourceAttributionDesc"));
queryWrapper.eq("equipment_name",jsonObject.getString("objectName"));
queryWrapper.eq("point_name",jsonObject.getString("objectIndexValue"));
queryWrapper.eq("kks",jsonObject.getString("objectId"));
if(params.length==3){
queryWrapper.eq("sub_system",params[0]);
queryWrapper.eq("health_level",params[1]);
queryWrapper.eq("warning_period",params[2]);
}
List<FanWarningRecord> fanWarningRecords = fanWaringRecordMapper.selectList(queryWrapper);
fanWarningRecords.stream().forEach(fanWarningRecord -> {
fanWarningRecord.setDisposotionDate(DateUtil.now());
fanWarningRecord.setStatus("1");
fanWarningRecord.setDisposotionState("已确认");
fanWaringRecordMapper.insert(fanWarningRecord);
});
});
// List<String> traceIds = taskList.stream().map(t -> t.get("extAttr1").toString()).collect(Collectors.toList());
// LambdaUpdateWrapper<IdxBizFanWarningRecord> lambda = new LambdaUpdateWrapper<>();
// lambda.set(IdxBizFanWarningRecord::getDisposotionState, "已确认");
// lambda.set(IdxBizFanWarningRecord::getStatus, "1");
......@@ -80,19 +97,19 @@ public class WarningRecordStatusMessage extends EmqxListener {
// lambda.in(IdxBizFanWarningRecord::getSequenceNbr, traceIds);
// idxBizFanWarningRecordService.update(lambda);
List<FanWarningRecord> list = new ArrayList<>();
for (String traceId : traceIds) {
FanWarningRecord fanWarningRecord = new FanWarningRecord();
fanWarningRecord.setTs(Long.valueOf(traceId));
fanWarningRecord.setDisposotionDate(DateUtil.now());
fanWarningRecord.setStatus("1");
fanWarningRecord.setDisposotionState("已确认");
list.add(fanWarningRecord);
}
if(list.size()>0){
log.info("XXXXXXXXXXXX风电修改预警状态XXXXXXXXXXXXXXXXXX",JSON.toJSONString(list));
fanWaringRecordMapper.updateStatusByTs(list);
}
// List<FanWarningRecord> list = new ArrayList<>();
// for (String traceId : traceIds) {
// FanWarningRecord fanWarningRecord = new FanWarningRecord();
// fanWarningRecord.setTs(Long.valueOf(traceId));
// fanWarningRecord.setDisposotionDate(DateUtil.now());
// fanWarningRecord.setStatus("1");
// fanWarningRecord.setDisposotionState("已确认");
// list.add(fanWarningRecord);
// }
// if(list.size()>0){
// log.info("XXXXXXXXXXXX风电修改预警状态XXXXXXXXXXXXXXXXXX",JSON.toJSONString(list));
// fanWaringRecordMapper.updateStatusByTs(list);
// }
}
......@@ -100,27 +117,48 @@ public class WarningRecordStatusMessage extends EmqxListener {
public void jxIopUpdatePv(JSONArray analysisResult) {
log.info("修改预警状态信息:{}", analysisResult);
List<JSONObject> taskList = JSONObject.parseArray(analysisResult.toJSONString(), JSONObject.class);
taskList = taskList.stream().filter(t-> "2".equals(t.getString("processingStatus"))).collect(Collectors.toList());
List<String> traceIds = taskList.stream().map(t -> t.get("extAttr1").toString()).collect(Collectors.toList());
// LambdaUpdateWrapper<IdxBizPvWarningRecord> lambda = new LambdaUpdateWrapper<>();
// lambda.set(IdxBizPvWarningRecord::getDisposotionState, "已处置");
// lambda.set(IdxBizPvWarningRecord::getStatus, "1");
// lambda.set(IdxBizPvWarningRecord::getDisposotionDate, new Date());
// lambda.in(IdxBizPvWarningRecord::getSequenceNbr, traceIds);
// idxBizPvWarningRecordService.update(lambda);
// td
List<PvWarningRecord> list = new ArrayList<>();
for (String traceId : traceIds) {
PvWarningRecord pvWarningRecord = new PvWarningRecord();
pvWarningRecord.setTs(Long.valueOf(traceId));
pvWarningRecord.setDisposotionDate(DateUtil.now());
pvWarningRecord.setStatus("1");
pvWarningRecord.setDisposotionState("已确认");
list.add(pvWarningRecord);
}
if(list.size()>0){
log.info("XXXXXXXXXXXX光伏修改预警状态XXXXXXXXXXXXXXXXXX",JSON.toJSONString(list));
pvWaringRecordMapper.updateStatusByTs(list);
}
taskList = taskList.stream().filter(t -> "2".equals(t.getString("processingStatus"))).collect(Collectors.toList());
taskList.stream().forEach(jsonObject -> {
String[] params = jsonObject.getString("extAttr1").split("@");
QueryWrapper<PvWarningRecord> queryWrapper =new QueryWrapper<>();
queryWrapper.eq("station",jsonObject.getString("sourceAttributionDesc"));
queryWrapper.eq("equipment_name",jsonObject.getString("objectName"));
queryWrapper.eq("point_name",jsonObject.getString("objectIndexValue"));
queryWrapper.eq("kks",jsonObject.getString("objectId"));
if(params.length==3){
queryWrapper.eq("subarray",params[0]);
queryWrapper.eq("health_level",params[1]);
queryWrapper.eq("warning_period",params[2]);
}
List<PvWarningRecord> pvWarningRecords = pvWaringRecordMapper.selectList(queryWrapper);
pvWarningRecords.stream().forEach(pvWarningRecord -> {
pvWarningRecord.setDisposotionDate(DateUtil.now());
pvWarningRecord.setStatus("1");
pvWarningRecord.setDisposotionState("已确认");
pvWaringRecordMapper.insert(pvWarningRecord);
});
});
// List<String> traceIds = taskList.stream().map(t -> t.get("extAttr1").toString()).collect(Collectors.toList());
//// LambdaUpdateWrapper<IdxBizPvWarningRecord> lambda = new LambdaUpdateWrapper<>();
//// lambda.set(IdxBizPvWarningRecord::getDisposotionState, "已处置");
//// lambda.set(IdxBizPvWarningRecord::getStatus, "1");
//// lambda.set(IdxBizPvWarningRecord::getDisposotionDate, new Date());
//// lambda.in(IdxBizPvWarningRecord::getSequenceNbr, traceIds);
//// idxBizPvWarningRecordService.update(lambda);
// // td
// List<PvWarningRecord> list = new ArrayList<>();
// for (String traceId : traceIds) {
// PvWarningRecord pvWarningRecord = new PvWarningRecord();
// pvWarningRecord.setTs(Long.valueOf(traceId));
// pvWarningRecord.setDisposotionDate(DateUtil.now());
// pvWarningRecord.setStatus("1");
// pvWarningRecord.setDisposotionState("已确认");
// list.add(pvWarningRecord);
// }
// if (list.size() > 0) {
// log.info("XXXXXXXXXXXX光伏修改预警状态XXXXXXXXXXXXXXXXXX", JSON.toJSONString(list));
// pvWaringRecordMapper.updateStatusByTs(list);
// }
}
}
......@@ -1548,14 +1548,12 @@ public class HealthStatusIndicatorServiceImpl {
tabContent.add(tableContentVo10);
tabContent.add(tableContentVo11);
dynamicDetailsVo.setTabContent(tabContent);
detailsVos.add(dynamicDetailsVo);
riskBizInfoVo.setDynamicDetails(detailsVos);
bizMessage.setBizInfo(riskBizInfoVo);
bizMessage.setTraceId2(idxBizPvWarningRecord.getTs().toString());
// 子系统@健康指数@预警周期
String traceId2 = idxBizPvWarningRecord.getSubarray()+"@"+idxBizPvWarningRecord.getHealthLevel()+"@"+idxBizPvWarningRecord.getWarningPeriod();
bizMessage.setTraceId2(traceId2);
try {
emqKeeper.getMqttClient().publish(SMART_ANALYSE_PV + "/data/analysis", JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
......@@ -1615,7 +1613,9 @@ public class HealthStatusIndicatorServiceImpl {
detailsVos.add(dynamicDetailsVo);
riskBizInfoVo.setDynamicDetails(detailsVos);
bizMessage.setBizInfo(riskBizInfoVo);
bizMessage.setTraceId2(idxBizFanWarningRecord.getTs().toString());
// 子系统@健康指数@预警周期
String traceId2 = idxBizFanWarningRecord.getSubSystem()+"@"+idxBizFanWarningRecord.getHealthLevel()+"@"+idxBizFanWarningRecord.getWarningPeriod();
bizMessage.setTraceId2(traceId2);
try {
emqKeeper.getMqttClient().publish(SMART_ANALYSE_FAN + "/data/analysis", JSON.toJSONString(bizMessage).getBytes(StandardCharsets.UTF_8), 2, false);
} catch (MqttException e) {
......
......@@ -101,18 +101,18 @@ public class IPermissionServiceImpl implements IPermissionService {
@Override
public String getCurrentUserPersmissions() {
String rootNodeName = "all";
String rootNodeName = "";
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
String userId = reginParams.getUserModel().getUserId();
StdUserEmpower stdUserEmpower = userEmpowerMapper.selectOne(new QueryWrapper<StdUserEmpower>().eq("amos_user_id", userId).eq("permission_type", "YTH"));
if (ObjectUtils.isEmpty(stdUserEmpower)) {
return rootNodeName;
return rootNodeName+"_111";
} else {
String permissionOrgCode = stdUserEmpower.getAmosOrgCode().get(0);
Map<String, String> companyInfo = userEmpowerMapper.getCompanyInfoByOrgCode(permissionOrgCode);
String companyLevel = companyInfo.get("level").toString();
if (companyLevel.equals("categroy_leve2")) {
return rootNodeName;
return "all";
}
if (companyLevel.equals("area")) {
List<StationBasic> stationBasics = stationBasicMapper.selectList(new QueryWrapper<StationBasic>().like("project_org_code", permissionOrgCode));
......
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