Commit f84ef9ab authored by chenzhao's avatar chenzhao

Merge branch 'developer' of http://39.98.45.134:8090/moa/amos-boot-biz into developer

parents 4b32b581 860a7d9e
package com.yeejoin.amos.api.householdapi.Utils;
import org.apache.commons.codec.binary.Base64;
import org.springframework.stereotype.Component;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
@Component
/**
* Created by jhb on 2022-08-03 14:16
*/
public class AESUtils {
public static final String DEFAULT_SECRET_KEY = "kstar_ase_keysfo";
/**
* 加密
* @param sSrc 需要加密的字符串
* @param sKey 此处使用AES-128-ECB加密模式,key需要为16位。
* @return
* @throws Exception
*/
public static String Encrypt(String sSrc, String sKey) throws Exception {
// 判断Key是否为16位
if (sKey.length() != 16) {
System.out.print("Key长度不是16位");
return null;
}
byte[] raw = sKey.getBytes("utf-8");
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");//"算法/模式/补码方式"
cipher.init(Cipher.ENCRYPT_MODE, skeySpec);
byte[] encrypted = cipher.doFinal(sSrc.getBytes("utf-8"));
return new Base64().encodeToString(encrypted);//此处使用BASE64做转码功能,同时能起到2次加密的作用。
}
/**
* 解密
* @param sSrc 需要解密的字符串
* @param sKey 此处使用AES-128-ECB加密模式,key需要为16位。
* @return
* @throws Exception
*/
public static String Decrypt(String sSrc, String sKey) throws Exception {
try {
// 判断Key是否正确
if (sKey == null) {
System.out.print("Key为空null");
return null;
}
// 判断Key是否为16位
if (sKey.length() != 16) {
System.out.print("Key长度不是16位");
return null;
}
byte[] raw = sKey.getBytes("utf-8");
SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES");
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, skeySpec);
byte[] encrypted1 = new Base64().decode(sSrc);//先用base64解密
try {
byte[] original = cipher.doFinal(encrypted1);
String originalString = new String(original,"utf-8");
return originalString;
} catch (Exception e) {
System.out.println(e.toString());
return null;
}
} catch (Exception ex) {
System.out.println(ex.toString());
return null;
}
}
public static void main(String[] args) throws Exception {
/*
* 此处使用AES-128-ECB加密模式,key需要为16位。
*/
String cKey = "kstar_ase_keysfo";
// 需要加密的字串
String cSrc = "sygn2022";
System.out.println(cSrc);
// 加密
String enString = AESUtils.Encrypt(cSrc, cKey);
System.out.println("加密后的字串是:" + enString);
// 解密
String DeString = AESUtils.Decrypt(enString, cKey);
System.out.println("解密后的字串是:" + DeString);
}
}
......@@ -5,13 +5,8 @@ import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.api.householdapi.constant.GoLangConstant;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.GolangStationList;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine.GolangStationMapper;
import com.yeejoin.amos.api.householdapi.face.service.impl.HouseholdPvProducerInfoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.cache.Redis;
import java.util.*;
......@@ -19,11 +14,6 @@ import java.util.*;
public class GolangRequestUtil {
@Autowired
private HouseholdPvProducerInfoServiceImpl householdPvProducerInfoServiceImpl;
@Autowired
private GolangStationMapper golangStationMapper;
/**
* @return HashMap<String, Object> 发送请求前的准备 准备header信息
......
package com.yeejoin.amos.api.householdapi.Utils;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.api.householdapi.constant.GoLangConstant;
import com.yeejoin.amos.api.householdapi.face.orm.mapper.tdengine.GolangStationMapper;
import com.yeejoin.amos.api.householdapi.face.service.impl.HouseholdPvProducerInfoServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Component
public class GoodWeRequestUtil {
@Autowired
private HouseholdPvProducerInfoServiceImpl householdPvProducerInfoServiceImpl;
@Autowired
private GolangStationMapper golangStationMapper;
/**
* @return HashMap<String, Object> 发送请求前的准备 准备header信息
* @deprecated 根据厂商编码获取厂商的hearer
*/
public HashMap<String, Object> getHeaderOfGolang() {
HashMap<String, Object> hashMap = new HashMap<>();
HashMap<String, String> hashMaphead = new HashMap<>();
String url = GoLangConstant.baseurl + GoLangConstant.tokenurl;
hashMap.put("apiurl", GoLangConstant.baseurl);
hashMaphead.put("Content-type", "application/json;charset=UTF-8");
hashMaphead.put("Authorization", "API " + GoLangConstant.prodcerappid);
hashMaphead.put("Content-MD5", null);
hashMaphead.put("Date", GoLangHeaderUtils.getGMTTime());
hashMap.put("header", hashMaphead);
hashMap.put("appsecret", GoLangConstant.prodcerappsecret);
return hashMap;
}
/**
* @param apiurl 请求url
* @param requestMethod 请求方式
* @param requestParmInfo 请求参数mapper
* @param ResultResolveRule 请求的解析
* @param tClass 需要转换成的bean
* @param <T> 泛型数据
* @return List<T> list<Result>
* @desc 根据请求参数发送http请求并且对于返回的数据进行处理
*/
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 {
HashMap<String, Object> producerInfo = getHeaderOfGolang();
String baseurl = (String) producerInfo.get("apiurl");
HashMap<String, String> headMap = (HashMap<String, String>) producerInfo.get("header");
String orginalAuthorization = headMap.get("Authorization") + ":";
String url = baseurl + apiurl;
String appsecret = (String) producerInfo.get("appsecret");
JLYHeaderMapHandler(params, headMap, orginalAuthorization, appsecret, apiurl);
respone = sendRequest(requestMethod, url, requestParmInfo, headMap);
jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone);
if (!ObjectUtils.isEmpty(jsonArray)) {
result = JSONArray.parseArray(jsonArray.toJSONString(), tClass);
}
} catch (Exception exception) {
return result;
}
return result;
}
/**
* @param resultResovle 请求返回的解析规则 来源与数据库
* @param response 请求返回的字符串
* @return 解析后的数据
* @desc 根据解析规则解析请求返回数据
*/
public JSONArray handlerResponseByResultResolverule(String resultResovle, String response) {
JSONObject jsonObject = JSONObject.parseObject(response);
JSONArray jsonArray = new JSONArray();
if (ObjectUtil.isNotEmpty(resultResovle)) {
String[] rules = resultResovle.split(",");
if (rules.length > 0) {
for (int i = 0; i < rules.length; i++) {
try {
jsonObject = (JSONObject) jsonObject.get(rules[i]);
if (jsonObject == null) {
jsonArray = (JSONArray) jsonObject.get(rules[i]);
}
} catch (Exception exception) {
jsonArray = (JSONArray) jsonObject.get(rules[i]);
}
}
}
if (jsonArray.size() == 0) {
jsonArray.add(jsonObject);
}
}
return jsonArray;
}
public String sendRequest(String requestMethod, String url, String params, HashMap<String, String> headMap) {
String respone = "";
if (requestMethod.equals("POST")) {
respone = HttpUtil.createPost(url).headerMap(headMap, false).
body(params).execute().body();
}
if (requestMethod.equals("GET")) {
respone = HttpUtil.createGet(url).headerMap(headMap, true).
body(params).execute().body();
}
return respone;
}
/***
*
* @param params 参数字符窜
* @param headMap header头
* @param orginalAuthorization 原始的orginalAuthorization
* @param appsecret appsecret
* @desc 锦浪云请求参数及head头处理
*/
public void JLYHeaderMapHandler(String params, HashMap<String, String> headMap, String orginalAuthorization, String appsecret, String apiurl) {
String contentMD5 = GoLangHeaderUtils.getDigest(params);
headMap.put("Date", GoLangHeaderUtils.getGMTTime());
String param = "POST" + "\n" + contentMD5 + "\n" + "application/json" + "\n" + headMap.get("Date") + "\n" + apiurl;
String sign = "";
try {
sign = GoLangHeaderUtils.HmacSHA1Encrypt(param, appsecret);
} catch (Exception e) {
throw new RuntimeException(e);
}
headMap.put("Content-MD5", contentMD5);
headMap.put("Authorization", orginalAuthorization + sign);
}
/**
* @param pageSizeResovle
* @param response
* @return
* @desc 根据分页规则 获取分页数
*/
public Integer getPagesize(String pageSizeResovle, String response) {
Integer pageSize = 0;
String[] rules = pageSizeResovle.split(",");
JSONObject jsonObject = JSONObject.parseObject(response);
if (rules.length > 0) {
for (int i = 0; i < rules.length - 1; i++) {
jsonObject = (JSONObject) jsonObject.get(rules[i]);
}
}
pageSize = (Integer) jsonObject.get(rules[rules.length - 1]);
return pageSize;
}
}
package com.yeejoin.amos.api.householdapi.Utils;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.api.householdapi.constant.GoLangConstant;
import com.yeejoin.amos.api.householdapi.constant.KSolarConstant;
import org.bouncycastle.jcajce.provider.symmetric.AES;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
@Component
public class KSolarRequestUtil {
@Autowired
private AESUtils aesUtils;
/**
* @return HashMap<String, Object> 发送请求前的准备 准备header信息
* @deprecated 根据厂商编码获取厂商的hearer
*/
public HashMap<String, Object> getHeader() {
HashMap<String, Object> hashMap = new HashMap<>();
HashMap<String, Object> requsetParams = new HashMap<>();
HashMap<String, String> hashMaphead = new HashMap<>();
requsetParams.put("username", KSolarConstant.account);
try {
requsetParams.put("password", AESUtils.Encrypt(KSolarConstant.password, AESUtils.DEFAULT_SECRET_KEY));
} catch (Exception e) {
throw new RuntimeException(e);
}
String url = KSolarConstant.baseurl + KSolarConstant.tokenUrl;
hashMaphead.put("Authorization", "Basic " + Base64.getUrlEncoder().encodeToString((KSolarConstant.authUsername + ":" + KSolarConstant.authPassword).getBytes(StandardCharsets.UTF_8)));
String ResPonse = HttpUtil.createPost(url).headerMap(hashMaphead, false).body(JSONObject.toJSONString(requsetParams)).execute().body();
return hashMap;
}
/**
* @param apiurl 请求url
* @param requestMethod 请求方式
* @param requestParmInfo 请求参数mapper
* @param ResultResolveRule 请求的解析
* @param tClass 需要转换成的bean
* @param <T> 泛型数据
* @return List<T> list<Result>
* @desc 根据请求参数发送http请求并且对于返回的数据进行处理
*/
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 {
HashMap<String, Object> producerInfo = getHeader();
String baseurl = (String) producerInfo.get("apiurl");
HashMap<String, String> headMap = (HashMap<String, String>) producerInfo.get("header");
String orginalAuthorization = headMap.get("Authorization") + ":";
String url = baseurl + apiurl;
String appsecret = (String) producerInfo.get("appsecret");
JLYHeaderMapHandler(params, headMap, orginalAuthorization, appsecret, apiurl);
respone = sendRequest(requestMethod, url, requestParmInfo, headMap);
jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone);
if (!ObjectUtils.isEmpty(jsonArray)) {
result = JSONArray.parseArray(jsonArray.toJSONString(), tClass);
}
} catch (Exception exception) {
return result;
}
return result;
}
/**
* @param resultResovle 请求返回的解析规则 来源与数据库
* @param response 请求返回的字符串
* @return 解析后的数据
* @desc 根据解析规则解析请求返回数据
*/
public JSONArray handlerResponseByResultResolverule(String resultResovle, String response) {
JSONObject jsonObject = JSONObject.parseObject(response);
JSONArray jsonArray = new JSONArray();
if (ObjectUtil.isNotEmpty(resultResovle)) {
String[] rules = resultResovle.split(",");
if (rules.length > 0) {
for (int i = 0; i < rules.length; i++) {
try {
jsonObject = (JSONObject) jsonObject.get(rules[i]);
if (jsonObject == null) {
jsonArray = (JSONArray) jsonObject.get(rules[i]);
}
} catch (Exception exception) {
jsonArray = (JSONArray) jsonObject.get(rules[i]);
}
}
}
if (jsonArray.size() == 0) {
jsonArray.add(jsonObject);
}
}
return jsonArray;
}
public String sendRequest(String requestMethod, String url, String params, HashMap<String, String> headMap) {
String respone = "";
if (requestMethod.equals("POST")) {
respone = HttpUtil.createPost(url).headerMap(headMap, false).
body(params).execute().body();
}
if (requestMethod.equals("GET")) {
respone = HttpUtil.createGet(url).headerMap(headMap, true).
body(params).execute().body();
}
return respone;
}
/***
*
* @param params 参数字符窜
* @param headMap header头
* @param orginalAuthorization 原始的orginalAuthorization
* @param appsecret appsecret
* @desc 锦浪云请求参数及head头处理
*/
public void JLYHeaderMapHandler(String params, HashMap<String, String> headMap, String orginalAuthorization, String appsecret, String apiurl) {
String contentMD5 = GoLangHeaderUtils.getDigest(params);
headMap.put("Date", GoLangHeaderUtils.getGMTTime());
String param = "POST" + "\n" + contentMD5 + "\n" + "application/json" + "\n" + headMap.get("Date") + "\n" + apiurl;
String sign = "";
try {
sign = GoLangHeaderUtils.HmacSHA1Encrypt(param, appsecret);
} catch (Exception e) {
throw new RuntimeException(e);
}
headMap.put("Content-MD5", contentMD5);
headMap.put("Authorization", orginalAuthorization + sign);
}
/**
* @param pageSizeResovle
* @param response
* @return
* @desc 根据分页规则 获取分页数
*/
public Integer getPagesize(String pageSizeResovle, String response) {
Integer pageSize = 0;
String[] rules = pageSizeResovle.split(",");
JSONObject jsonObject = JSONObject.parseObject(response);
if (rules.length > 0) {
for (int i = 0; i < rules.length - 1; i++) {
jsonObject = (JSONObject) jsonObject.get(rules[i]);
}
}
pageSize = (Integer) jsonObject.get(rules[rules.length - 1]);
return pageSize;
}
}
package com.yeejoin.amos.api.householdapi.Utils;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.api.householdapi.constant.GoLangConstant;
import org.springframework.stereotype.Component;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Component
public class SofarRequestUtil {
/**
* @return HashMap<String, Object> 发送请求前的准备 准备header信息
* @deprecated 根据厂商编码获取厂商的hearer
*/
public HashMap<String, Object> getHeaderOfGolang() {
HashMap<String, Object> hashMap = new HashMap<>();
HashMap<String, String> hashMaphead = new HashMap<>();
String url = GoLangConstant.baseurl + GoLangConstant.tokenurl;
hashMap.put("apiurl", GoLangConstant.baseurl);
hashMaphead.put("Content-type", "application/json;charset=UTF-8");
hashMaphead.put("Authorization", "API " + GoLangConstant.prodcerappid);
hashMaphead.put("Content-MD5", null);
hashMaphead.put("Date", GoLangHeaderUtils.getGMTTime());
hashMap.put("header", hashMaphead);
hashMap.put("appsecret", GoLangConstant.prodcerappsecret);
return hashMap;
}
/**
* @param apiurl 请求url
* @param requestMethod 请求方式
* @param requestParmInfo 请求参数mapper
* @param ResultResolveRule 请求的解析
* @param tClass 需要转换成的bean
* @param <T> 泛型数据
* @return List<T> list<Result>
* @desc 根据请求参数发送http请求并且对于返回的数据进行处理
*/
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 {
HashMap<String, Object> producerInfo = getHeaderOfGolang();
String baseurl = (String) producerInfo.get("apiurl");
HashMap<String, String> headMap = (HashMap<String, String>) producerInfo.get("header");
String orginalAuthorization = headMap.get("Authorization") + ":";
String url = baseurl + apiurl;
String appsecret = (String) producerInfo.get("appsecret");
JLYHeaderMapHandler(params, headMap, orginalAuthorization, appsecret, apiurl);
respone = sendRequest(requestMethod, url, requestParmInfo, headMap);
jsonArray = handlerResponseByResultResolverule(ResultResolveRule, respone);
if (!ObjectUtils.isEmpty(jsonArray)) {
result = JSONArray.parseArray(jsonArray.toJSONString(), tClass);
}
} catch (Exception exception) {
return result;
}
return result;
}
/**
* @param resultResovle 请求返回的解析规则 来源与数据库
* @param response 请求返回的字符串
* @return 解析后的数据
* @desc 根据解析规则解析请求返回数据
*/
public JSONArray handlerResponseByResultResolverule(String resultResovle, String response) {
JSONObject jsonObject = JSONObject.parseObject(response);
JSONArray jsonArray = new JSONArray();
if (ObjectUtil.isNotEmpty(resultResovle)) {
String[] rules = resultResovle.split(",");
if (rules.length > 0) {
for (int i = 0; i < rules.length; i++) {
try {
jsonObject = (JSONObject) jsonObject.get(rules[i]);
if (jsonObject == null) {
jsonArray = (JSONArray) jsonObject.get(rules[i]);
}
} catch (Exception exception) {
jsonArray = (JSONArray) jsonObject.get(rules[i]);
}
}
}
if (jsonArray.size() == 0) {
jsonArray.add(jsonObject);
}
}
return jsonArray;
}
public String sendRequest(String requestMethod, String url, String params, HashMap<String, String> headMap) {
String respone = "";
if (requestMethod.equals("POST")) {
respone = HttpUtil.createPost(url).headerMap(headMap, false).
body(params).execute().body();
}
if (requestMethod.equals("GET")) {
respone = HttpUtil.createGet(url).headerMap(headMap, true).
body(params).execute().body();
}
return respone;
}
/***
*
* @param params 参数字符窜
* @param headMap header头
* @param orginalAuthorization 原始的orginalAuthorization
* @param appsecret appsecret
* @desc 锦浪云请求参数及head头处理
*/
public void JLYHeaderMapHandler(String params, HashMap<String, String> headMap, String orginalAuthorization, String appsecret, String apiurl) {
String contentMD5 = GoLangHeaderUtils.getDigest(params);
headMap.put("Date", GoLangHeaderUtils.getGMTTime());
String param = "POST" + "\n" + contentMD5 + "\n" + "application/json" + "\n" + headMap.get("Date") + "\n" + apiurl;
String sign = "";
try {
sign = GoLangHeaderUtils.HmacSHA1Encrypt(param, appsecret);
} catch (Exception e) {
throw new RuntimeException(e);
}
headMap.put("Content-MD5", contentMD5);
headMap.put("Authorization", orginalAuthorization + sign);
}
/**
* @param pageSizeResovle
* @param response
* @return
* @desc 根据分页规则 获取分页数
*/
public Integer getPagesize(String pageSizeResovle, String response) {
Integer pageSize = 0;
String[] rules = pageSizeResovle.split(",");
JSONObject jsonObject = JSONObject.parseObject(response);
if (rules.length > 0) {
for (int i = 0; i < rules.length - 1; i++) {
jsonObject = (JSONObject) jsonObject.get(rules[i]);
}
}
pageSize = (Integer) jsonObject.get(rules[rules.length - 1]);
return pageSize;
}
}
......@@ -5,6 +5,9 @@ import org.apache.xmlbeans.impl.xb.xsdschema.Public;
import java.time.format.DateTimeFormatter;
import java.util.HashMap;
/**
* 锦浪云常量
*/
public class GoLangConstant {
public static final HashMap<String, String> stationStaus = new HashMap<String, String>() {
{
......
package com.yeejoin.amos.api.householdapi.constant;
/**
* 固德威常量
*/
public class GoodWeConstant {
}
package com.yeejoin.amos.api.householdapi.constant;
public class KSolarConstant {
public static String baseurl ="http://111.230.136.62:8092";
public static String account ="三一硅能";
public static String password ="sygn2022";
public static String tokenUrl ="/authentication/form";
public static String authUsername ="kstar";
public static String authPassword ="kstarSecret";
}
package com.yeejoin.amos.api.householdapi.constant;
/**
* 首航常量
*/
public class SoFarConstant {
}
package com.yeejoin.amos.api.householdapi.controller;
import com.yeejoin.amos.api.householdapi.Utils.GolangRequestUtil;
import com.yeejoin.amos.api.householdapi.Utils.HouseholdPvUtils;
import com.yeejoin.amos.api.householdapi.constant.GoLangConstant;
import com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.GolangStationList;
import com.yeejoin.amos.api.householdapi.Utils.KSolarRequestUtil;
import com.yeejoin.amos.api.householdapi.face.service.GoLangDataAcquisitionService;
import fastjson.JSON;
import io.swagger.annotations.Api;
......@@ -33,6 +31,8 @@ public class HouseholdTestController {
private HouseholdPvUtils householdPvUtils;
@Autowired
private GoLangDataAcquisitionService goLangDataAcquisitionService;
@Autowired
private KSolarRequestUtil kSolarRequestUtil;
/**
......@@ -46,6 +46,7 @@ public class HouseholdTestController {
public String save(Long seq) throws IOException {
return householdPvUtils.gerResponseByAPiID(seq);
}
/**
* 新增户用光伏-厂商API haders
*
......@@ -56,11 +57,66 @@ public class HouseholdTestController {
@ApiOperation(httpMethod = "POST", value = "锦浪云", notes = "锦浪云")
public void golangnew() throws IOException {
// goLangDataAcquisitionService.stationList();
goLangDataAcquisitionService.stationDetail();
// goLangDataAcquisitionService.stationDetail();
// goLangDataAcquisitionService.collectorList();
//// goLangDataAcquisitionService.inverterList();
goLangDataAcquisitionService.collectorDetail();
goLangDataAcquisitionService.inverterDetail();
// goLangDataAcquisitionService.inverAlramInfo();
}
/**
* 新增户用光伏-厂商API haders
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/sofarnew")
@ApiOperation(httpMethod = "POST", value = "首航", notes = "首航")
public void sofarnew() throws IOException {
// goLangDataAcquisitionService.stationList();
// goLangDataAcquisitionService.stationDetail();
// goLangDataAcquisitionService.collectorList();
//// goLangDataAcquisitionService.inverterList();
// goLangDataAcquisitionService.collectorDetail();
// goLangDataAcquisitionService.inverterDetail();
// goLangDataAcquisitionService.inverAlramInfo();
}
/**
* 新增户用光伏-厂商API haders
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/goodWenew")
@ApiOperation(httpMethod = "POST", value = "固德威", notes = "固德威")
public void goodWenew() throws IOException {
// goLangDataAcquisitionService.stationList();
// goLangDataAcquisitionService.stationDetail();
// goLangDataAcquisitionService.collectorList();
//// goLangDataAcquisitionService.inverterList();
// goLangDataAcquisitionService.collectorDetail();
// goLangDataAcquisitionService.inverterDetail();
// goLangDataAcquisitionService.inverAlramInfo();
}
/**
* 新增户用光伏-厂商API haders
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@PostMapping(value = "/ksolarnew")
@ApiOperation(httpMethod = "POST", value = "科士达", notes = "科士达")
public void ksolarnew() throws IOException {
// goLangDataAcquisitionService.stationList();
// goLangDataAcquisitionService.stationDetail();
// goLangDataAcquisitionService.collectorList();
//// goLangDataAcquisitionService.inverterList();
// goLangDataAcquisitionService.collectorDetail();
// goLangDataAcquisitionService.inverterDetail();
// goLangDataAcquisitionService.inverAlramInfo();
kSolarRequestUtil.getHeader();
}
}
......@@ -13,6 +13,7 @@ public class CollectorDetailDto {
private String stationId;
private String rssiLevel;
private String model;
private String name;
private String addr;
private String stationName;
}
......@@ -126,5 +126,9 @@ public class JpCollector implements Serializable {
*/
@TableField("addr")
private String addr;
/**
* 场站地址
*/
@TableField("name")
private String name;
}
package com.yeejoin.amos.api.householdapi.face.service;
public interface GoodWeDataAcquisitionService {
/**
* @descrption 场站列表数据入库
*/
void stationList();
/**
* @descrption 场站详情数据入库
*/
void stationDetail();
/**
* @descrption 采集器列表数据入库
*/
void collectorList();
/**
* @descrption 采集器详情数据入库
*/
void collectorDetail();
/**
* @descrption 逆变器列表数据入库
*/
void inverterList();
/**
* @descrption 逆变器详情数据入库
*/
void inverterDetail();
/**
* @descrption 采集器告警列表数据入库
*/
void inverAlramInfo();
}
package com.yeejoin.amos.api.householdapi.face.service;
public interface SofarDataAcquisitionService {
/**
* @descrption 场站列表数据入库
*/
void stationList();
/**
* @descrption 场站详情数据入库
*/
void stationDetail();
/**
* @descrption 采集器列表数据入库
*/
void collectorList();
/**
* @descrption 采集器详情数据入库
*/
void collectorDetail();
/**
* @descrption 逆变器列表数据入库
*/
void inverterList();
/**
* @descrption 逆变器详情数据入库
*/
void inverterDetail();
/**
* @descrption 采集器告警列表数据入库
*/
void inverAlramInfo();
}
......@@ -2,9 +2,7 @@ package com.yeejoin.amos.api.householdapi.face.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.core.JsonParser;
import com.yeejoin.amos.api.householdapi.Utils.GolangRequestUtil;
import com.yeejoin.amos.api.householdapi.constant.GoLangConstant;
import com.yeejoin.amos.api.householdapi.face.dto.AlarmDto;
......@@ -39,7 +37,7 @@ import java.util.concurrent.TimeUnit;
@Service
public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionService {
//定时任务执行频率 当前为10分钟一次
private final String dataRequstScheduled = "0 0/10 * * * *";
private final String dataRequstScheduled = "0 0/60 * * * *";
//锦浪云请求工具封装
@Autowired
......@@ -151,11 +149,11 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
jpStation.setStationContact(String.valueOf(golangStationDetail.getMobile()).toLowerCase().replace("null", ""));
jpStation.setModuleCount(ObjectUtils.isEmpty(Math.toIntExact(golangStationDetail.getModule()))?0:Math.toIntExact(golangStationDetail.getModule()));
//并网类型
jpStation.setOnGridType(GoLangConstant.stationStaus.get(String.valueOf(golangStationDetail.getState())));
jpStation.setState(GoLangConstant.stationStaus.get(String.valueOf(golangStationDetail.getState())));
jpStation.setThirdStationId(String.valueOf(golangStationDetail.getId()));
jpStation.setThirdCode(PVProducerInfoEnum.JLY.getCode());
jpStation.setRealTimePower(golangStationDetail.getPower());
jpStation.setState(GoLangConstant.intoNetWorkStatus.get(String.valueOf(golangStationDetail.getStationtypenew())));
jpStation.setOnGridType(GoLangConstant.intoNetWorkStatus.get(String.valueOf(golangStationDetail.getStationtypenew())));
jpStation.setDayGenerate(golangStationDetail.getDayenergy());
jpStation.setMonthGenerate(golangStationDetail.getMonthenergy() * GoLangConstant.mwhTokwh);
jpStation.setYearGenerate(golangStationDetail.getYearenergy() * GoLangConstant.mwhTokwh);
......@@ -285,8 +283,10 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
jpCollector.setThirdCode(PVProducerInfoEnum.JLY.getCode());
//第三方厂商标识
jpCollector.setState(GoLangConstant.stationStaus.get(collectorDetailDto.getState()));
jpCollector.setStationName(collectorDetailDto.getStationName());
jpCollector.setAddr(collectorDetailDto.getAddr());
jpCollector.setName(collectorDetailDto.getName());
if (ObjectUtils.isEmpty(jpCollector.getSequenceNbr())) {
jpCollectorMapper.insert(jpCollector);
} else {
......@@ -401,6 +401,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
jpInverterElectricity.setInverterId(inverterDetailDto.getId());
jpInverterElectricity.setSnCode(inverterDetailDto.getSn());
jpInverterElectricity.setThirdCode(PVProducerInfoEnum.JLY.getCode());
jpInverterElectricity.setThirdStationId(String.valueOf(inverterDetailDto.getStationId()));
jpInverterElectricity.setType("交流");
jpInverterElectricity.setName("AC" + k);
jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("uAc" + k).toString()));
......@@ -423,6 +424,7 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
jpInverterElectricity.setInverterId(inverterDetailDto.getId());
jpInverterElectricity.setSnCode(inverterDetailDto.getSn());
jpInverterElectricity.setThirdCode(PVProducerInfoEnum.JLY.getCode());
jpInverterElectricity.setThirdStationId(String.valueOf(inverterDetailDto.getStationId()));
jpInverterElectricity.setType("直流");
jpInverterElectricity.setName("PV" + k1);
jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("uPv" + k1).toString()));
......
......@@ -6,7 +6,9 @@ public enum PVProducerInfoEnum {
GDW("固德威","GDW"),
SH("首航","SH"),
JLY("锦浪云","JLY");
JLY("锦浪云","JLY"),
KSOLAR("科士达","KSD"),
HUAWEI("华为","HW");
private String name;
......
......@@ -158,7 +158,7 @@ public class JpStationController extends BaseController {
collector.put("zx",0);
collector.put("bj",0);
collector.put("lx",0);
if(list!=null&&list.isEmpty()){
if(list!=null&&!list.isEmpty()){
for (Map<String, Object> map : list) {
if("在线".equals(map.get("state").toString())){
collector.put("zx",Integer.valueOf(map.get("num").toString()));
......
......@@ -205,9 +205,9 @@ public class TdHygfJpInverterWarnController extends BaseController {
if(datalist!=null&&!datalist.isEmpty()){
for (Map<String, Object> map : datalist) {
if("未处理".equals(map.get("state").toString())){
collector.put("wcl",map.get("num"));
collector.put("wcl",Integer.valueOf(map.get("num").toString()));
}else if("已处理".equals(map.get("state").toString())||"已恢复".equals(map.get("state").toString())){
collector.put("ycl",map.get("num"));
collector.put("ycl",Integer.valueOf(map.get("num").toString()));
}
}
}
......
......@@ -8,6 +8,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.MonthPowerServiceImpl;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.TdHygfJpCollectorHistoryServiceImpl;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.TdHygfJpInvertorElecHistoryServiceImpl;
import org.springframework.stereotype.Component;
/**
* @description:
......@@ -15,6 +16,7 @@ import com.yeejoin.amos.boot.module.hygf.biz.service.impl.TdHygfJpInvertorElecHi
* @createDate: 2023/9/21
*/
@EnableScheduling
@Component
public class WindSpeedScheduled {
@Autowired
......
......@@ -128,7 +128,13 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
int month = aCalendar.get(Calendar.MONTH) + 1;//月份
int day = aCalendar.getActualMaximum(Calendar.DATE);
for (int i = 1; i <= day; i++) {
String aDate = month+"-"+i;
String aDate =null;
if(i<10){
aDate = date+"-0"+i;
}else{
aDate = date+"-"+i;
}
listx.add(aDate);
listy.add(0);
}
......@@ -145,7 +151,13 @@ public class JpStationServiceImpl extends BaseService<JpStationDto,JpStation,JpS
List<Object> listx =new ArrayList<>();
List<Object> listy =new ArrayList<>();
for (int i = 1; i <= 12; i++) {
String aDate = date+"-"+i;
String aDate =null;
if(i<10){
aDate = date+"-0"+i;
}else{
aDate = date+"-"+i;
}
listx.add(aDate);
listy.add(0);
}
......
......@@ -8,7 +8,7 @@
FROM
(
SELECT
IFNULL( AVG( HEALTH_INDEX ), 0 ) AS avgHealthIndex
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex
FROM
idx_biz_fan_health_index
<where>ANALYSIS_TYPE = '按天'
......@@ -27,7 +27,7 @@
UNION ALL
(
SELECT
IFNULL( AVG( HEALTH_INDEX ), 0 ) AS avgHealthIndex
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex
FROM
idx_biz_pv_health_index
<where>
......@@ -49,7 +49,7 @@
<select id="getHealthListInfo" resultType="java.util.Map">
SELECT
IFNULL( AVG( HEALTH_INDEX ), 0 ) AS avgHealthIndex,
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex,
a.date
FROM
(
......@@ -123,7 +123,7 @@
FROM
(
SELECT
IFNULL( AVG( HEALTH_INDEX ), 0 ) AS avgHealthIndex,
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex,
ARAE
FROM
idx_biz_fan_health_index
......@@ -135,7 +135,7 @@
ARAE UNION ALL
(
SELECT
IFNULL( AVG( HEALTH_INDEX ), 0 ) AS avgHealthIndex,
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex,
ARAE
FROM
idx_biz_pv_health_index
......@@ -180,7 +180,7 @@
FROM
(
SELECT
IFNULL( AVG( HEALTH_INDEX ), 0 ) AS avgHealthIndex,
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex,
STATION
FROM
idx_biz_fan_health_index
......@@ -197,7 +197,7 @@
STATION UNION ALL
(
SELECT
IFNULL( AVG( HEALTH_INDEX ), 0 ) AS avgHealthIndex,
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex,
STATION
FROM
idx_biz_pv_health_index
......@@ -307,7 +307,7 @@
<select id="getSubSystemInfo" resultType="java.util.Map">
SELECT
IFNULL( HEALTH_INDEX, 0 ) AS healthIndex,
IFNULL( HEALTH_INDEX, 100 ) AS healthIndex,
SUB_SYSTEM AS subSystem
FROM
idx_biz_fan_health_index
......@@ -317,7 +317,7 @@
AND ANALYSIS_TYPE = '按天'
AND DATE_FORMAT( REC_DATE, "%Y-%m-%d" ) = CURRENT_DATE
<if test="equipmentName != null and equipmentName != ''">
AND EQUIPMENT_NAME = #{equipmentName}
AND EQUIPMENT_NAME like concat( '%', #{equipmentName} '风机系统')
</if>
<if test="gatewayId != null and gatewayId != ''">
AND GATEWAY_ID = #{gatewayId}
......@@ -346,7 +346,7 @@
<select id="getFanHealthInfoList" resultType="java.util.Map">
SELECT
IFNULL( AVG( HEALTH_INDEX ), 0 ) AS avgHealthIndex,
IFNULL( AVG( HEALTH_INDEX ), 100 ) AS avgHealthIndex,
EQUIPMENT_NAME as equipmentName
FROM
idx_biz_fan_health_index
......@@ -371,7 +371,7 @@
idx_biz_fan_point_process_variable_classification
<where>
<if test="equipmentName != null and equipmentName != ''">
AND EQUIPMENT_NAME = #{equipmentName}
AND EQUIPMENT_NAME like concat( '%', #{equipmentName} '风机系统')
</if>
<if test="gatewayId != null and gatewayId != ''">
AND GATEWAY_ID = #{gatewayId}
......@@ -401,7 +401,7 @@
<select id="getHealthInfoBySubSystem" resultType="java.util.Map">
SELECT
IFNULL( avg( HEALTH_INDEX ), 0 ) AS healthIndex,
IFNULL( avg( HEALTH_INDEX ), 100 ) AS healthIndex,
POINT_NAME AS pointName
FROM
idx_biz_fan_health_index
......@@ -547,7 +547,8 @@
<select id="getPvPointNameListBySumSystem" resultType="java.util.Map">
SELECT
POINT_NAME as pointName
POINT_NAME as pointName,
INDEX_ADDRESS as indexAddress
FROM
idx_biz_pv_point_process_variable_classification
<where>
......
......@@ -257,8 +257,14 @@ public class HouseholdPvController extends BaseController {
row.createCell(4).setCellValue(ObjectUtils.isEmpty(item.getPhone()) ? "" : item.getPhone());
row.createCell(5).setCellValue(ObjectUtils.isEmpty(item.getInstallAddress()) ? "" : item.getInstallAddress());
// 安装总功率
if (!ObjectUtils.isEmpty(item)&& !ObjectUtils.isEmpty(item.getActualCapacity()) && !ObjectUtils.isEmpty(item.getInstallCount())) {
long multiplyExact = Math.multiplyExact(Long.parseLong(item.getActualCapacity()), Long.parseLong(item.getInstallCount()));
//updateTime: 2023年9月22日 14点26分
//desc:客户提出导出时该值由原来的 预计功率*安装数量 修改为 组件单片功率 * 安装数量
//changer: 曹涛
// if (!ObjectUtils.isEmpty(item)&& !ObjectUtils.isEmpty(item.getActualCapacity()) && !ObjectUtils.isEmpty(item.getInstallCount())) {
// long multiplyExact = Math.multiplyExact(Long.parseLong(item.getActualCapacity()), Long.parseLong(item.getInstallCount()));
// row.createCell(6).setCellValue(String.valueOf(multiplyExact));
if (!ObjectUtils.isEmpty(item)&& !ObjectUtils.isEmpty(item.getMonolithicPower()) && !ObjectUtils.isEmpty(item.getInstallCount())) {
long multiplyExact = Math.multiplyExact(Long.parseLong(item.getMonolithicPower()), Long.parseLong(item.getInstallCount()));
row.createCell(6).setCellValue(String.valueOf(multiplyExact));
} else {
row.createCell(6).setCellValue(0);
......
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