Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-zx-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
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
Jobs
Commits
Open sidebar
项目统一框架
一体化_户用光伏项目代码
amos-boot-zx-biz
Commits
c6da4be4
Commit
c6da4be4
authored
Dec 18, 2024
by
hezhuozhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加日志
parent
1c31154b
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
214 additions
and
39 deletions
+214
-39
GolangRequestUtil.java
...eejoin/amos/api/householdapi/Utils/GolangRequestUtil.java
+29
-6
GoodWeRequestUtil.java
...eejoin/amos/api/householdapi/Utils/GoodWeRequestUtil.java
+29
-6
ImasterUtils.java
...com/yeejoin/amos/api/householdapi/Utils/ImasterUtils.java
+24
-4
KsolarRequestUtil.java
...eejoin/amos/api/householdapi/Utils/KsolarRequestUtil.java
+13
-2
SofarRequestUtil.java
...yeejoin/amos/api/householdapi/Utils/SofarRequestUtil.java
+27
-6
SunlightUtil.java
...com/yeejoin/amos/api/householdapi/Utils/SunlightUtil.java
+36
-8
TanYinApiUtils.java
...m/yeejoin/amos/api/householdapi/Utils/TanYinApiUtils.java
+34
-1
ImasterDataServiceImpl.java
...ouseholdapi/face/service/impl/ImasterDataServiceImpl.java
+22
-6
No files found.
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/GolangRequestUtil.java
View file @
c6da4be4
...
...
@@ -64,15 +64,18 @@ public class GolangRequestUtil {
JSONArray
jsonArray
=
null
;
List
<
T
>
result
=
new
ArrayList
<>();
Integer
pageNo
=
1
;
String
url
=
""
;
HashMap
<
String
,
String
>
headMap
=
new
HashMap
<>();
String
requestParmInfo
=
""
;
try
{
do
{
requestInfo
.
put
(
"pageNo"
,
pageNo
);
String
requestParmInfo
=
JSON
.
toJSONString
(
requestInfo
);
requestParmInfo
=
JSON
.
toJSONString
(
requestInfo
);
HashMap
<
String
,
Object
>
producerInfo
=
getHeaderOfGolang
();
String
baseurl
=
(
String
)
producerInfo
.
get
(
"apiurl"
);
HashMap
<
String
,
String
>
headMap
=
(
HashMap
<
String
,
String
>)
producerInfo
.
get
(
"header"
);
headMap
=
(
HashMap
<
String
,
String
>)
producerInfo
.
get
(
"header"
);
String
orginalAuthorization
=
headMap
.
get
(
"Authorization"
)
+
":"
;
String
url
=
baseurl
+
apiurl
;
url
=
baseurl
+
apiurl
;
String
appsecret
=
(
String
)
producerInfo
.
get
(
"appsecret"
);
JLYHeaderMapHandler
(
params
,
headMap
,
orginalAuthorization
,
appsecret
,
apiurl
);
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
...
...
@@ -99,7 +102,7 @@ public class GolangRequestUtil {
JSONObject
page
=
data
.
getJSONObject
(
"page"
);
responePages
=
page
.
getInteger
(
"pages"
);
}
if
(
responePages
=
=
pageNo
){
if
(
responePages
<
=
pageNo
){
break
;
}
else
{
pageNo
++;
...
...
@@ -107,6 +110,15 @@ public class GolangRequestUtil {
}
while
(
true
);
}
catch
(
Exception
exception
)
{
log
.
error
(
exception
.
getMessage
(),
exception
);
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
JLY
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
requestMethod
);
hygfThirdStationLog
.
setReqHeaders
(
headMap
.
toString
());
hygfThirdStationLog
.
setReqPath
(
url
);
hygfThirdStationLog
.
setReqBody
(
requestParmInfo
);
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
return
result
;
}
return
result
;
...
...
@@ -127,12 +139,14 @@ public class GolangRequestUtil {
String
params
=
""
;
JSONArray
jsonArray
=
null
;
List
<
T
>
result
=
new
ArrayList
<>();
String
url
=
""
;
HashMap
<
String
,
String
>
headMap
=
new
HashMap
<>();
try
{
HashMap
<
String
,
Object
>
producerInfo
=
getHeaderOfGolang
();
String
baseurl
=
(
String
)
producerInfo
.
get
(
"apiurl"
);
HashMap
<
String
,
String
>
headMap
=
(
HashMap
<
String
,
String
>)
producerInfo
.
get
(
"header"
);
headMap
=
(
HashMap
<
String
,
String
>)
producerInfo
.
get
(
"header"
);
String
orginalAuthorization
=
headMap
.
get
(
"Authorization"
)
+
":"
;
String
url
=
baseurl
+
apiurl
;
url
=
baseurl
+
apiurl
;
String
appsecret
=
(
String
)
producerInfo
.
get
(
"appsecret"
);
JLYHeaderMapHandler
(
params
,
headMap
,
orginalAuthorization
,
appsecret
,
apiurl
);
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
...
...
@@ -150,6 +164,15 @@ public class GolangRequestUtil {
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
}
catch
(
Exception
exception
)
{
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
JLY
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
requestMethod
);
hygfThirdStationLog
.
setReqHeaders
(
headMap
.
toString
());
hygfThirdStationLog
.
setReqPath
(
url
);
hygfThirdStationLog
.
setReqBody
(
requestParmInfo
);
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
return
result
;
}
return
result
;
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/GoodWeRequestUtil.java
View file @
c6da4be4
...
...
@@ -65,12 +65,15 @@ public class GoodWeRequestUtil {
JSONArray
jsonArray
=
null
;
List
<
T
>
result
=
new
ArrayList
<>();
Integer
pageNo
=
1
;
String
url
=
""
;
HashMap
<
String
,
String
>
headMap
=
new
HashMap
<>();
String
requestParmInfo
=
""
;
try
{
do
{
requestInfo
.
put
(
"page_index"
,
pageNo
);
String
requestParmInfo
=
fastjson
.
JSON
.
toJSONString
(
requestInfo
);
HashMap
<
String
,
String
>
headMap
=
getHeaderOfGoodWE
();
String
url
=
GoodWeConstant
.
baseurl
+
apiurl
;
requestParmInfo
=
fastjson
.
JSON
.
toJSONString
(
requestInfo
);
headMap
=
getHeaderOfGoodWE
();
url
=
GoodWeConstant
.
baseurl
+
apiurl
;
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
//token如果失效重新获取{"code":100002,"msg":"授权已失效,请重新登录","data":null}
if
(
JSONObject
.
parseObject
(
respone
).
getInteger
(
"code"
)
==
100002
){
...
...
@@ -96,7 +99,7 @@ public class GoodWeRequestUtil {
Integer
record
=
data
.
getInteger
(
"record"
);
Integer
pageSize
=
requestInfo
.
get
(
"page_size"
)==
null
||
(
Integer
)
requestInfo
.
get
(
"page_size"
)==
0
?
1
:(
Integer
)
requestInfo
.
get
(
"page_size"
);
Integer
responePages
=(
record
/
pageSize
)+
1
;
if
(
responePages
=
=
pageNo
){
if
(
responePages
<
=
pageNo
){
break
;
}
else
{
pageNo
++;
...
...
@@ -104,6 +107,15 @@ public class GoodWeRequestUtil {
}
while
(
true
);
}
catch
(
Exception
exception
)
{
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
GDW
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
requestMethod
);
hygfThirdStationLog
.
setReqHeaders
(
headMap
.
toString
());
hygfThirdStationLog
.
setReqPath
(
url
);
hygfThirdStationLog
.
setReqBody
(
requestParmInfo
);
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
return
result
;
}
return
result
;
...
...
@@ -124,9 +136,11 @@ public class GoodWeRequestUtil {
String
params
=
""
;
JSONArray
jsonArray
=
null
;
List
<
T
>
result
=
new
ArrayList
<>();
String
url
=
""
;
HashMap
<
String
,
String
>
headMap
=
new
HashMap
<>();
try
{
HashMap
<
String
,
String
>
headMap
=
getHeaderOfGoodWE
();
String
url
=
GoodWeConstant
.
baseurl
+
apiurl
;
headMap
=
getHeaderOfGoodWE
();
url
=
GoodWeConstant
.
baseurl
+
apiurl
;
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
//token如果失效重新获取{"code":100002,"msg":"授权已失效,请重新登录","data":null}
if
(
JSONObject
.
parseObject
(
respone
).
getInteger
(
"code"
)
==
100002
){
...
...
@@ -147,6 +161,15 @@ public class GoodWeRequestUtil {
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
}
catch
(
Exception
exception
)
{
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
GDW
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
requestMethod
);
hygfThirdStationLog
.
setReqHeaders
(
headMap
.
toString
());
hygfThirdStationLog
.
setReqPath
(
url
);
hygfThirdStationLog
.
setReqBody
(
requestParmInfo
);
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
return
result
;
}
return
result
;
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/ImasterUtils.java
View file @
c6da4be4
...
...
@@ -77,10 +77,11 @@ public class ImasterUtils {
String
params
=
""
;
JSONArray
jsonArray
=
null
;
List
<
T
>
result
=
new
ArrayList
<>();
HashMap
<
String
,
String
>
headMap
=
new
HashMap
<>();
try
{
Object
o
=
redisUtils
.
get
(
redisKey
);
if
(
o
!=
null
)
{
HashMap
<
String
,
String
>
headMap
=
new
HashMap
<>();
headMap
=
new
HashMap
<>();
headMap
.
put
(
"XSRF-TOKEN"
,
o
.
toString
());
String
url
=
ImasterConstant
.
baseurl
+
apiurl
;
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
...
...
@@ -109,7 +110,7 @@ public class ImasterUtils {
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
}
else
{
HashMap
<
String
,
String
>
headMap
=
getHeader
();
headMap
=
getHeader
();
String
url
=
ImasterConstant
.
baseurl
+
apiurl
;
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
jsonArray
=
handlerResponseByResultResolverule
(
ResultResolveRule
,
respone
);
...
...
@@ -128,6 +129,15 @@ public class ImasterUtils {
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
}
}
catch
(
Exception
exception
)
{
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
HUAWEI
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
requestMethod
);
hygfThirdStationLog
.
setReqHeaders
(
headMap
.
toString
());
hygfThirdStationLog
.
setReqPath
(
ImasterConstant
.
baseurl
+
apiurl
);
hygfThirdStationLog
.
setReqBody
(
requestParmInfo
);
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
return
result
;
}
return
result
;
...
...
@@ -149,10 +159,11 @@ public class ImasterUtils {
String
params
=
""
;
JSONArray
jsonArray
=
null
;
List
<
T
>
result
=
new
ArrayList
<>();
HashMap
<
String
,
String
>
headMap
=
new
HashMap
<>();
try
{
Object
o
=
redisUtils
.
get
(
redisKey
);
if
(
o
!=
null
)
{
HashMap
<
String
,
String
>
headMap
=
new
HashMap
<>();
headMap
=
new
HashMap
<>();
headMap
.
put
(
"XSRF-TOKEN"
,
o
.
toString
());
String
url
=
ImasterConstant
.
baseurl
+
apiurl
;
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
...
...
@@ -186,7 +197,7 @@ public class ImasterUtils {
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
}
else
{
HashMap
<
String
,
String
>
headMap
=
getHeader
();
headMap
=
getHeader
();
String
url
=
ImasterConstant
.
baseurl
+
apiurl
;
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
jsonArray
=
handlerResponseByResultResolveruleOther
(
ResultResolveRule
,
respone
);
...
...
@@ -206,6 +217,15 @@ public class ImasterUtils {
}
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
HUAWEI
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
requestMethod
);
hygfThirdStationLog
.
setReqHeaders
(
headMap
.
toString
());
hygfThirdStationLog
.
setReqPath
(
ImasterConstant
.
baseurl
+
apiurl
);
hygfThirdStationLog
.
setReqBody
(
requestParmInfo
);
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
return
result
;
}
return
result
;
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/KsolarRequestUtil.java
View file @
c6da4be4
...
...
@@ -65,9 +65,11 @@ public class KsolarRequestUtil {
String
params
=
""
;
JSONArray
jsonArray
=
null
;
List
<
T
>
result
=
new
ArrayList
<>();
String
url
=
""
;
HashMap
<
String
,
String
>
headMap
=
new
HashMap
<>();
try
{
HashMap
<
String
,
String
>
headMap
=
getHeader
();
String
url
=
KSolarConstant
.
baseurl
+
apiurl
;
headMap
=
getHeader
();
url
=
KSolarConstant
.
baseurl
+
apiurl
;
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
jsonArray
=
handlerResponseByResultResolverule
(
ResultResolveRule
,
respone
);
//log.info("原始数据:{}", jsonArray);
...
...
@@ -84,6 +86,15 @@ public class KsolarRequestUtil {
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
}
catch
(
Exception
exception
)
{
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
KSOLAR
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
requestMethod
);
hygfThirdStationLog
.
setReqHeaders
(
headMap
.
toString
());
hygfThirdStationLog
.
setReqPath
(
url
);
hygfThirdStationLog
.
setReqBody
(
requestParmInfo
);
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
return
result
;
}
return
result
;
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/SofarRequestUtil.java
View file @
c6da4be4
...
...
@@ -134,7 +134,7 @@ public class SofarRequestUtil {
Integer
total
=
responeJSON
.
getInteger
(
"total"
);
Integer
pageSize
=
requestInfo
.
get
(
"size"
)==
null
||
(
Integer
)
requestInfo
.
get
(
"size"
)==
0
?
1
:(
Integer
)
requestInfo
.
get
(
"size"
);
Integer
responePages
=(
total
/
pageSize
)+
1
;
if
(
responePages
=
=
pageNo
){
if
(
responePages
<
=
pageNo
){
break
;
}
else
{
pageNo
++;
...
...
@@ -160,10 +160,11 @@ public class SofarRequestUtil {
public
<
T
>
List
<
T
>
getResPonse
(
String
apiurl
,
String
requestMethod
,
String
requestParmInfo
,
String
ResultResolveRule
,
Class
<
T
>
tClass
)
{
String
respone
=
""
;
List
<
T
>
result
=
new
ArrayList
<>();
String
url
=
""
;
HashMap
<
String
,
String
>
headMap
=
new
HashMap
<>();
try
{
HashMap
<
String
,
String
>
headMap
=
getHeaderOfSofar
();
String
url
=
SoFarConstant
.
baseurl
+
apiurl
;
headMap
=
getHeaderOfSofar
();
url
=
SoFarConstant
.
baseurl
+
apiurl
;
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
respone
);
if
(
jsonObject
!=
null
&&
jsonObject
.
get
(
ResultResolveRule
)!=
null
){
...
...
@@ -181,6 +182,15 @@ public class SofarRequestUtil {
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
SH
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
requestMethod
);
hygfThirdStationLog
.
setReqHeaders
(
headMap
.
toString
());
hygfThirdStationLog
.
setReqPath
(
url
);
hygfThirdStationLog
.
setReqBody
(
requestParmInfo
);
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
return
result
;
}
return
result
;
...
...
@@ -190,9 +200,11 @@ public class SofarRequestUtil {
public
JSONObject
getResPonseobj
(
String
apiurl
,
String
requestMethod
,
String
requestParmInfo
,
String
ResultResolveRule
)
{
String
respone
=
""
;
JSONObject
jsonObject
=
null
;
String
url
=
""
;
HashMap
<
String
,
String
>
headMap
=
new
HashMap
<>();
try
{
HashMap
<
String
,
String
>
headMap
=
getHeaderOfSofar
();
String
url
=
SoFarConstant
.
baseurl
+
apiurl
;
headMap
=
getHeaderOfSofar
();
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
());
...
...
@@ -209,6 +221,15 @@ public class SofarRequestUtil {
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
}
catch
(
Exception
exception
)
{
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
SH
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
requestMethod
);
hygfThirdStationLog
.
setReqHeaders
(
headMap
.
toString
());
hygfThirdStationLog
.
setReqPath
(
url
);
hygfThirdStationLog
.
setReqBody
(
requestParmInfo
);
hygfThirdStationLog
.
setResBody
(
respone
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
exception
.
printStackTrace
();
}
return
jsonObject
;
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/SunlightUtil.java
View file @
c6da4be4
...
...
@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Objects
;
/**
* @description:
...
...
@@ -212,11 +213,14 @@ public class SunlightUtil {
JSONObject
resultData
=
new
JSONObject
();
JSONArray
pageList
=
new
JSONArray
();
Integer
pageNo
=
1
;
HttpRequest
request
=
null
;
String
body
=
""
;
String
res
=
""
;
try
{
do
{
bodyparam
.
put
(
"curPage"
,
pageNo
);
//请求头
HttpRequest
request
=
HttpUtil
.
createPost
(
dfurl
+
url
);
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
);
...
...
@@ -225,13 +229,13 @@ public class SunlightUtil {
bodyparam
.
put
(
"token"
,
this
.
getSunlightToken
());
Gson
gson
=
new
Gson
();
String
body
=
gson
.
toJson
(
bodyparam
);
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
());
res
=
UnicodeUtil
.
toString
(
execute
.
body
());
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
res
,
true
);
resultData
=
JSONUtil
.
parseObj
(
jsonObject
.
get
(
"result_data"
),
true
);
...
...
@@ -252,7 +256,7 @@ public class SunlightUtil {
Integer
rowCount
=
resultData
.
getInt
(
"rowCount"
);
Integer
pageSize
=
bodyparam
.
get
(
"size"
)==
null
||
(
Integer
)
bodyparam
.
get
(
"size"
)==
0
?
1
:(
Integer
)
bodyparam
.
get
(
"size"
);
Integer
responePages
=(
rowCount
/
pageSize
)+
1
;
if
(
responePages
=
=
pageNo
){
if
(
responePages
<
=
pageNo
){
break
;
}
else
{
pageNo
++;
...
...
@@ -260,6 +264,17 @@ public class SunlightUtil {
}
while
(
true
);
}
catch
(
Exception
e
)
{
log
.
error
(
"失败,msg["
+
e
.
getMessage
()+
"]"
,
e
);
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
YG
.
getCode
());
if
(
Objects
.
nonNull
(
request
)){
hygfThirdStationLog
.
setReqMethod
(
request
.
getMethod
().
toString
());
hygfThirdStationLog
.
setReqHeaders
(
request
.
headers
().
toString
());
}
hygfThirdStationLog
.
setReqPath
(
dfurl
+
url
);
hygfThirdStationLog
.
setReqBody
(
body
);
hygfThirdStationLog
.
setResBody
(
res
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
return
resultData
;
}
return
resultData
;
...
...
@@ -271,10 +286,12 @@ public class SunlightUtil {
public
JSONObject
getdata
(
String
url
,
Map
<
String
,
Object
>
bodyparam
){
String
data
=
null
;
HttpRequest
request
=
null
;
String
body
=
""
;
String
res
=
""
;
try
{
//请求头
HttpRequest
request
=
HttpUtil
.
createPost
(
dfurl
+
url
);
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
);
...
...
@@ -283,13 +300,13 @@ public class SunlightUtil {
bodyparam
.
put
(
"token"
,
this
.
getSunlightToken
());
Gson
gson
=
new
Gson
();
String
body
=
gson
.
toJson
(
bodyparam
);
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
());
res
=
UnicodeUtil
.
toString
(
execute
.
body
());
JSONObject
jsonObject
=
JSONUtil
.
parseObj
(
res
,
true
);
JSONObject
resultData
=
JSONUtil
.
parseObj
(
jsonObject
.
get
(
"result_data"
),
true
);
...
...
@@ -306,6 +323,17 @@ public class SunlightUtil {
return
resultData
;
}
catch
(
Exception
e
)
{
log
.
error
(
"失败,msg["
+
e
.
getMessage
()+
"]"
,
e
);
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
YG
.
getCode
());
if
(
Objects
.
nonNull
(
request
)){
hygfThirdStationLog
.
setReqMethod
(
request
.
getMethod
().
toString
());
hygfThirdStationLog
.
setReqHeaders
(
request
.
headers
().
toString
());
}
hygfThirdStationLog
.
setReqPath
(
dfurl
+
url
);
hygfThirdStationLog
.
setReqBody
(
body
);
hygfThirdStationLog
.
setResBody
(
res
);
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
return
new
JSONObject
();
}
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/TanYinApiUtils.java
View file @
c6da4be4
...
...
@@ -120,7 +120,7 @@ public class TanYinApiUtils {
// 记录请求开始的日志信息。
log
.
debug
(
"请求 => 碳银{}接口,url:{}"
,
desc
,
url
);
Map
<
String
,
String
>
headers
=
new
HashMap
<>();
HttpResponse
response
;
HttpResponse
response
=
null
;
try
{
// 添加Authorization头,使用Bearer令牌模式。
headers
.
put
(
"Authorization"
,
"Bearer "
+
getAccessToken
(
clientKey
,
clientSecret
));
...
...
@@ -144,6 +144,17 @@ public class TanYinApiUtils {
response
=
HttpUtil
.
createGet
(
url
).
execute
();
return
parseResponse
(
desc
,
response
,
resultClass
);
}
catch
(
Exception
e
)
{
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
TANYIN
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
HttpMethod
.
GET
.
name
());
hygfThirdStationLog
.
setReqHeaders
(
headers
.
toString
());
hygfThirdStationLog
.
setReqPath
(
url
);
hygfThirdStationLog
.
setReqBody
(
null
);
if
(
Objects
.
nonNull
(
response
)){
hygfThirdStationLog
.
setResBody
(
response
.
toString
());
}
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
// 记录未预期异常的日志信息。
log
.
warn
(
String
.
format
(
"异常 => 碳银%s接口"
,
desc
),
e
);
return
null
;
...
...
@@ -206,6 +217,17 @@ public class TanYinApiUtils {
log
.
warn
(
String
.
format
(
"异常 => 碳银%s接口,参数: %s,响应: %s"
,
desc
,
paramsJsonStr
,
response
!=
null
?
response
.
body
()
:
businessException
.
getMessage
()));
return
null
;
}
catch
(
Exception
e
)
{
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
TANYIN
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
HttpMethod
.
GET
.
name
());
hygfThirdStationLog
.
setReqHeaders
(
headers
.
toString
());
hygfThirdStationLog
.
setReqPath
(
url
);
hygfThirdStationLog
.
setReqBody
(
null
);
if
(
Objects
.
nonNull
(
response
)){
hygfThirdStationLog
.
setResBody
(
response
.
toString
());
}
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
// 记录未预期的异常日志。
log
.
warn
(
String
.
format
(
"异常 => 碳银%s接口,参数: %s"
,
desc
,
paramsJsonStr
),
e
);
return
null
;
...
...
@@ -267,6 +289,17 @@ public class TanYinApiUtils {
log
.
warn
(
String
.
format
(
"异常 => 碳银%s接口,参数: %s,响应: %s"
,
desc
,
paramsJsonStr
,
response
!=
null
?
response
.
body
()
:
businessException
.
getMessage
()));
return
null
;
}
catch
(
Exception
e
)
{
//存储日志
HYGFThirdStationLog
hygfThirdStationLog
=
new
HYGFThirdStationLog
();
hygfThirdStationLog
.
setThirdCode
(
PVProducerInfoEnum
.
TANYIN
.
getCode
());
hygfThirdStationLog
.
setReqMethod
(
HttpMethod
.
GET
.
name
());
hygfThirdStationLog
.
setReqHeaders
(
headers
.
toString
());
hygfThirdStationLog
.
setReqPath
(
url
);
hygfThirdStationLog
.
setReqBody
(
null
);
if
(
Objects
.
nonNull
(
response
)){
hygfThirdStationLog
.
setResBody
(
response
.
toString
());
}
thirdStationLogService
.
saveLog
(
hygfThirdStationLog
);
// 记录异常日志
log
.
warn
(
String
.
format
(
"异常 => 碳银%s接口,参数: %s"
,
desc
,
paramsJsonStr
),
e
);
return
null
;
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/face/service/impl/ImasterDataServiceImpl.java
View file @
c6da4be4
package
com
.
yeejoin
.
amos
.
api
.
householdapi
.
face
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.yeejoin.amos.api.householdapi.Utils.CalendarAdjust
;
...
...
@@ -33,6 +35,9 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.ObjectUtils
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -1035,7 +1040,6 @@ public class ImasterDataServiceImpl implements ImasterDataService {
// jpStationMapper.updateById(jpStation1);
}
@Scheduled
(
cron
=
"${dataRequstScheduled.huawei}"
)
@Override
@Async
...
...
@@ -1043,6 +1047,10 @@ public class ImasterDataServiceImpl implements ImasterDataService {
long
ts
=
System
.
currentTimeMillis
();
logger
.
info
(
"-------华为同步告警开始"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
List
<
String
>
inverterSns
=
imasterInverterListMapper
.
getCollectIds
();
if
(
CollectionUtil
.
isEmpty
(
inverterSns
)){
logger
.
warn
(
"-------没有逆变器,跳过告警-------"
);
return
;
}
// for (int i = 0; i < inverterSns.size(); i++) {
// try {
// TimeUnit.MINUTES.sleep(3);
...
...
@@ -1050,12 +1058,20 @@ public class ImasterDataServiceImpl implements ImasterDataService {
// throw new RuntimeException(e);
// }
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
// 获取今天的日期
LocalDate
today
=
LocalDate
.
now
();
// 将 LocalDate 转换为 LocalDateTime,设置时间为零点
LocalDateTime
midnight
=
today
.
atStartOfDay
();
// 将 LocalDateTime 转换为 Date
Date
date
=
Date
.
from
(
midnight
.
atZone
(
ZoneId
.
systemDefault
()).
toInstant
());
// 获取今天零点的时间戳(毫秒)
long
todayTimestamp
=
date
.
getTime
();
requestInfo
.
put
(
"sns"
,
inverterSns
.
stream
().
collect
(
Collectors
.
joining
(
","
)));
requestInfo
.
put
(
"language"
,
"zh_CN
"
);
requestInfo
.
put
(
"devTypes"
,
1
);
requestInfo
.
put
(
"beginTime"
,
DateUtil
.
today
()
);
requestInfo
.
put
(
"endTime"
,
DateUtil
.
today
());
requestInfo
.
put
(
"language"
,
"zh_CN"
);
requestInfo
.
put
(
"devTypes"
,
"1"
);
requestInfo
.
put
(
"beginTime"
,
todayTimestamp
);
requestInfo
.
put
(
"endTime"
,
System
.
currentTimeMillis
());
String
requestParaminfo
=
JSON
.
toJSONString
(
requestInfo
);
List
<
ImasterAlarmDto
>
result
=
imasterUtils
.
getResPonse
(
ImasterConstant
.
alarmListUrl
,
GoLangConstant
.
requestPost
,
...
...
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