Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
2fce7232
Commit
2fce7232
authored
Sep 11, 2023
by
caotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化调整户用光伏数据采集
parent
f937b12d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
40 deletions
+33
-40
GoLangHeaderUtils.java
...eejoin/amos/api/householdapi/Utils/GoLangHeaderUtils.java
+27
-35
HouseholdPvUtils.java
...yeejoin/amos/api/householdapi/Utils/HouseholdPvUtils.java
+6
-5
DockingData.java
...c/main/java/com/yeejoin/amos/dockingData/DockingData.java
+0
-0
No files found.
amos-boot-data/amos-boot-data-accessapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/GoLangHeaderUtils.java
View file @
2fce7232
package
com
.
yeejoin
.
amos
.
api
.
householdapi
.
Utils
;
import
com.yeejoin.amos.api.householdapi.face.model.HouseholdPvApiDto
;
import
com.yeejoin.amos.openapi.enums.PVProducerInfoEnum
;
import
org.apache.commons.codec.binary.Base64
;
import
javax.crypto.Mac
;
...
...
@@ -11,40 +13,6 @@ import java.text.SimpleDateFormat;
import
java.util.*
;
//锦浪云 header处理类
public
class
GoLangHeaderUtils
{
// public static void main(String[] args) {
// try {
// String key = "";
// String keySecret = "";
// Map<String,Object> map = new HashMap();
// map.put("pageNo",1);
// map.put("pageSize",10);
// String body = JSON.toJSONString(map);
// String ContentMd5 = getDigest(body);
// String Date = getGMTTime();
// String path = "/v1/api/userStationList";
// String param = "POST" + "\n" + ContentMd5 + "\n" + "application/json" + "\n" + Date + "\n" + path;
// String sign = HmacSHA1Encrypt(param, keySecret);
// String url = "url" + path ;
// OkHttpClient client = new OkHttpClient();
// MediaType xmlType = MediaType.parse("application/json;charset=UTF-8");
// okhttp3.RequestBody requestBody = okhttp3.RequestBody.create(xmlType,body);
// okhttp3.Request request = new okhttp3.Request.Builder()
// .url(url)
// .addHeader("Content-type", "application/json;charset=UTF-8")
// .addHeader("Authorization","API "+key+":"+sign)
// .addHeader("Content-MD5",ContentMd5)
// .addHeader("Date",Date)
// .post(requestBody)
// .build();
// Response response = client.newCall(request).execute();
// String string = response.body().string();
// System.out.println(string);
//
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
public
static
String
HmacSHA1Encrypt
(
String
encryptText
,
String
KeySecret
)
throws
Exception
{
byte
[]
data
=
KeySecret
.
getBytes
(
"UTF-8"
);
...
...
@@ -77,5 +45,29 @@ public class GoLangHeaderUtils {
}
return
result
;
}
/***
*
* @param params 参数字符窜
* @param householdPvApiDto apidto
* @param headMap header头
* @param orginalAuthorization 原始的orginalAuthorization
* @param appsecret appsecret
* @param cacheParams 缓存的参数值
* @desc 锦浪云请求参数及head头处理
*/
public
void
JLYHeaderMapHandler
(
String
params
,
HouseholdPvApiDto
householdPvApiDto
,
HashMap
<
String
,
String
>
headMap
,
String
orginalAuthorization
,
String
appsecret
,
String
cacheParams
)
{
if
(
PVProducerInfoEnum
.
JLY
.
getCode
().
equals
(
householdPvApiDto
.
getProducerId
()))
{
String
contentMD5
=
GoLangHeaderUtils
.
getDigest
(
params
);
headMap
.
put
(
"Date"
,
GoLangHeaderUtils
.
getGMTTime
());
String
param
=
"POST"
+
"\n"
+
contentMD5
+
"\n"
+
"application/json"
+
"\n"
+
headMap
.
get
(
"Date"
)
+
"\n"
+
householdPvApiDto
.
getApiUrl
();
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
);
}
}
}
amos-boot-data/amos-boot-data-accessapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/HouseholdPvUtils.java
View file @
2fce7232
...
...
@@ -19,6 +19,7 @@ import io.swagger.annotations.ApiModelProperty;
import
io.swagger.models.auth.In
;
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.*
;
...
...
@@ -54,7 +55,7 @@ public class HouseholdPvUtils {
String
body
=
JSON
.
toJSONString
(
map
);
String
response
=
HttpUtil
.
createPost
(
url
).
body
(
body
).
execute
().
body
();
JSONObject
jsonObject
=
JSON
.
parseObject
(
response
);
if
(
jsonObject
.
get
(
"data"
)
!=
null
)
{
if
(
!
ObjectUtils
.
isEmpty
(
jsonObject
.
get
(
"data"
))
)
{
JSONObject
jsonObject1
=
(
JSONObject
)
jsonObject
.
get
(
"data"
);
hashMaphead
.
put
(
"token"
,
(
String
)
jsonObject1
.
get
(
"token"
));
hashMap
.
put
(
"header"
,
hashMaphead
);
...
...
@@ -196,20 +197,20 @@ public class HouseholdPvUtils {
Map
<
String
,
Object
>
maps1
=
(
Map
<
String
,
Object
>)
o
;
Set
<
String
>
keys
=
maps1
.
keySet
();
keys
.
forEach
((
key
)
->
{
maps1
.
put
(
key
,
maps1
.
get
(
key
).
toString
());
maps1
.
put
(
key
,
ObjectUtils
.
isEmpty
(
maps1
.
get
(
key
))?
""
:
maps1
.
get
(
key
).
toString
());
});
if
(
cacheField
!=
null
)
{
if
(
!
ObjectUtils
.
isEmpty
(
"cacheField"
)
)
{
list
.
add
(
maps1
.
get
(
cacheField
));
}
Map
<
String
,
String
>
maps2
=
new
HashMap
<>();
maps2
.
put
(
"key"
,
UUID
.
randomUUID
().
toString
());
if
(
measurement
!=
null
)
{
if
(
!
ObjectUtils
.
isEmpty
(
measurement
)
)
{
influxDbConnection
.
insert
(
measurement
,
maps2
,
maps1
);
}
}
}
if
(
cacheField
!=
null
)
{
if
(
!
ObjectUtils
.
isEmpty
(
cacheField
)
)
{
saveList
=
Redis
.
getRedisTemplate
().
opsForList
().
range
(
apiID
,
0
,
-
1
);
if
(
saveList
.
size
()
==
0
)
{
Redis
.
getRedisTemplate
().
opsForList
().
leftPushAll
(
apiID
,
list
);
...
...
amos-boot-data/amos-boot-data-accessapi/src/main/java/com/yeejoin/amos/dockingData/DockingData.java
View file @
2fce7232
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment