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
d7721b58
Commit
d7721b58
authored
Sep 18, 2024
by
hezhuozhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改电站监控数据不一致问题
parent
ca0b7ae1
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
527 additions
and
50 deletions
+527
-50
GolangRequestUtil.java
...eejoin/amos/api/householdapi/Utils/GolangRequestUtil.java
+59
-0
GoodWeRequestUtil.java
...eejoin/amos/api/householdapi/Utils/GoodWeRequestUtil.java
+54
-0
SofarRequestUtil.java
...yeejoin/amos/api/householdapi/Utils/SofarRequestUtil.java
+48
-3
SunlightUtil.java
...com/yeejoin/amos/api/householdapi/Utils/SunlightUtil.java
+60
-0
GoLangDataAcquisitionServiceImpl.java
...i/face/service/impl/GoLangDataAcquisitionServiceImpl.java
+135
-16
GoodWeDataAcquisitionServiceImpl.java
...i/face/service/impl/GoodWeDataAcquisitionServiceImpl.java
+83
-18
SofarDataAcquisitionServiceImpl.java
...pi/face/service/impl/SofarDataAcquisitionServiceImpl.java
+30
-5
SunlightServiceImpl.java
...i/householdapi/face/service/impl/SunlightServiceImpl.java
+32
-4
TanYinDataAcquisitionServiceImpl.java
...i/face/service/impl/TanYinDataAcquisitionServiceImpl.java
+5
-4
SchedulerConfig.java
...rc/main/java/com/yeejoin/amos/config/SchedulerConfig.java
+21
-0
No files found.
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/GolangRequestUtil.java
View file @
d7721b58
...
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.api.householdapi.Utils;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.log.Log
;
import
com.alibaba.fastjson.JSONArray
;
...
...
@@ -11,6 +12,7 @@ import com.yeejoin.amos.api.householdapi.constant.GoLangConstant;
import
com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.houseapi.HousepvapiRecords
;
import
com.yeejoin.amos.api.householdapi.face.orm.mapper.houseapi.HousepvapiRecordsMapper
;
import
com.yeejoin.amos.openapi.enums.PVProducerInfoEnum
;
import
fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -43,6 +45,63 @@ public class GolangRequestUtil {
return
hashMap
;
}
/**
* 这个方法是为了查出全部的数据
* @param apiurl 请求url
* @param requestMethod 请求方式
* @param requestInfo 请求信息
* @param ResultResolveRule 请求的解析
* @param tClass 需要转换成的bean
* @param <T> 泛型数据
* @return List<T> list<Result>
* @desc 根据请求参数发送http请求并且对于返回的数据进行处理
*/
public
<
T
>
List
<
T
>
getResPonseList
(
String
apiurl
,
String
requestMethod
,
HashMap
<
String
,
Object
>
requestInfo
,
String
ResultResolveRule
,
Class
<
T
>
tClass
)
{
String
respone
=
""
;
String
params
=
""
;
JSONArray
jsonArray
=
null
;
List
<
T
>
result
=
new
ArrayList
<>();
Integer
pageNo
=
1
;
try
{
do
{
requestInfo
.
put
(
"pageNo"
,
pageNo
);
String
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"
);
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
.
addAll
(
JSONArray
.
parseArray
(
jsonArray
.
toJSONString
(),
tClass
));
}
//处理其他页数的数据
JSONObject
responeJSON
=
JSONObject
.
parseObject
(
respone
);
JSONObject
data
=
responeJSON
.
getJSONObject
(
"data"
);
Integer
responePages
=
0
;
if
(
data
.
containsKey
(
"pages"
)){
responePages
=
data
.
getInteger
(
"pages"
);
}
else
{
JSONObject
page
=
data
.
getJSONObject
(
"page"
);
responePages
=
page
.
getInteger
(
"pages"
);
}
if
(
responePages
==
pageNo
){
break
;
}
else
{
pageNo
++;
}
}
while
(
true
);
}
catch
(
Exception
exception
)
{
log
.
error
(
exception
.
getMessage
(),
exception
);
return
result
;
}
return
result
;
}
/**
* @param apiurl 请求url
* @param requestMethod 请求方式
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/GoodWeRequestUtil.java
View file @
d7721b58
...
...
@@ -46,6 +46,55 @@ public class GoodWeRequestUtil {
}
return
hashMap
;
}
/**
* @param apiurl 请求url
* @param requestMethod 请求方式
* @param requestInfo 请求参数mapper
* @param ResultResolveRule 请求的解析
* @param tClass 需要转换成的bean
* @param <T> 泛型数据
* @return List<T> list<Result>
* @desc 根据请求参数发送http请求并且对于返回的数据进行处理
*/
public
<
T
>
List
<
T
>
getResPonseList
(
String
apiurl
,
String
requestMethod
,
HashMap
<
String
,
Object
>
requestInfo
,
String
ResultResolveRule
,
Class
<
T
>
tClass
)
{
String
respone
=
""
;
JSONArray
jsonArray
=
null
;
List
<
T
>
result
=
new
ArrayList
<>();
Integer
pageNo
=
1
;
try
{
do
{
requestInfo
.
put
(
"page_index"
,
pageNo
);
String
requestParmInfo
=
fastjson
.
JSON
.
toJSONString
(
requestInfo
);
HashMap
<
String
,
String
>
headMap
=
getHeaderOfGoodWE
();
String
url
=
GoodWeConstant
.
baseurl
+
apiurl
;
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
//token如果失效重新获取{"code":100002,"msg":"授权已失效,请重新登录","data":null}
if
(
JSONObject
.
parseObject
(
respone
).
getInteger
(
"code"
)
==
100002
){
redisUtils
.
del
(
redisKey
);
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
getHeaderOfGoodWE
());
}
jsonArray
=
handlerResponseByResultResolverule
(
ResultResolveRule
,
respone
);
if
(!
ObjectUtils
.
isEmpty
(
jsonArray
))
{
result
.
addAll
(
JSONArray
.
parseArray
(
jsonArray
.
toJSONString
(),
tClass
));
}
//处理其他页数的数据
JSONObject
responeJSON
=
JSONObject
.
parseObject
(
respone
);
JSONObject
data
=
responeJSON
.
getJSONObject
(
"data"
);
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
){
break
;
}
else
{
pageNo
++;
}
}
while
(
true
);
}
catch
(
Exception
exception
)
{
return
result
;
}
return
result
;
}
/**
* @param apiurl 请求url
...
...
@@ -66,6 +115,11 @@ public class GoodWeRequestUtil {
HashMap
<
String
,
String
>
headMap
=
getHeaderOfGoodWE
();
String
url
=
GoodWeConstant
.
baseurl
+
apiurl
;
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
//token如果失效重新获取{"code":100002,"msg":"授权已失效,请重新登录","data":null}
if
(
JSONObject
.
parseObject
(
respone
).
getInteger
(
"code"
)
==
100002
){
redisUtils
.
del
(
redisKey
);
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
getHeaderOfGoodWE
());
}
jsonArray
=
handlerResponseByResultResolverule
(
ResultResolveRule
,
respone
);
if
(!
ObjectUtils
.
isEmpty
(
jsonArray
))
{
result
=
JSONArray
.
parseArray
(
jsonArray
.
toJSONString
(),
tClass
);
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/SofarRequestUtil.java
View file @
d7721b58
...
...
@@ -5,16 +5,14 @@ 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.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
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Component
...
...
@@ -86,6 +84,53 @@ public class SofarRequestUtil {
return
requestHeader
;
}
/**
* @param apiurl 请求url
* @param requestMethod 请求方式
* @param requestInfo 请求参数mapper
* @param ResultResolveRule 请求的解析
* @param tClass 需要转换成的bean
* @param <T> 泛型数据
* @return List<T> list<Result>
* @desc 根据请求参数发送http请求并且对于返回的数据进行处理
*/
public
<
T
>
List
<
T
>
getResPonseList
(
String
apiurl
,
String
requestMethod
,
Map
<
String
,
Object
>
requestInfo
,
String
ResultResolveRule
,
Class
<
T
>
tClass
)
{
String
respone
=
""
;
List
<
T
>
result
=
new
ArrayList
<>();
Integer
pageNo
=
1
;
try
{
do
{
requestInfo
.
put
(
"page"
,
pageNo
);
String
requestParmInfo
=
JSON
.
toJSONString
(
requestInfo
);
HashMap
<
String
,
String
>
headMap
=
getHeaderOfSofar
();
String
url
=
SoFarConstant
.
baseurl
+
apiurl
;
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
//token如果失效重新获取{"code": 500,"msg": "Login status has expired","success": false}
if
(
JSONObject
.
parseObject
(
respone
).
getInteger
(
"code"
)
==
500
){
redisUtils
.
del
(
redisKey
);
respone
=
sendRequest
(
requestMethod
,
url
,
requestParmInfo
,
headMap
);
}
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
respone
);
if
(
jsonObject
!=
null
&&
jsonObject
.
get
(
ResultResolveRule
)!=
null
){
result
.
addAll
(
JSONArray
.
parseArray
(
fastjson
.
JSON
.
toJSONString
(
jsonObject
.
get
(
ResultResolveRule
)),
tClass
));
}
//处理其他页数的数据
JSONObject
responeJSON
=
JSONObject
.
parseObject
(
respone
);
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
){
break
;
}
else
{
pageNo
++;
}
}
while
(
true
);
}
catch
(
Exception
exception
)
{
exception
.
printStackTrace
();
}
return
result
;
}
/**
* @param apiurl 请求url
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/SunlightUtil.java
View file @
d7721b58
...
...
@@ -6,9 +6,12 @@ import cn.hutool.http.HttpResponse;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSONArray
;
import
com.google.gson.Gson
;
import
com.yeejoin.amos.api.householdapi.face.dto.SunlightDto
;
import
com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.tdeingine.Sunlight
;
import
com.yeejoin.amos.api.householdapi.face.orm.mapper.houseapi.HousepvapiRecordsMapper
;
import
fastjson.JSON
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.client.methods.CloseableHttpResponse
;
...
...
@@ -23,7 +26,9 @@ import javax.naming.Name;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -207,6 +212,61 @@ public class SunlightUtil {
}
}
/**
* 获取全部的数据
* @param url
* @param bodyparam
* @return
*/
public
JSONObject
getDataList
(
String
url
,
Map
<
String
,
Object
>
bodyparam
){
JSONObject
resultData
=
new
JSONObject
();
JSONArray
pageList
=
new
JSONArray
();
Integer
pageNo
=
1
;
try
{
do
{
bodyparam
.
put
(
"curPage"
,
pageNo
);
//请求头
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
);
resultData
=
JSONUtil
.
parseObj
(
jsonObject
.
get
(
"result_data"
),
true
);
if
(
resultData
!=
null
&&
resultData
.
get
(
"pageList"
)!=
null
){
pageList
.
addAll
(
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
resultData
.
get
(
"pageList"
))));
resultData
.
putOpt
(
"pageList"
,
pageList
);
}
//处理其他页数的数据
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
){
break
;
}
else
{
pageNo
++;
}
}
while
(
true
);
}
catch
(
Exception
e
)
{
log
.
error
(
"失败,msg={}"
,
e
.
getMessage
());
e
.
printStackTrace
();
throw
new
RuntimeException
(
e
.
getMessage
());
}
return
resultData
;
}
//获取接口数据
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/face/service/impl/GoLangDataAcquisitionServiceImpl.java
View file @
d7721b58
package
com
.
yeejoin
.
amos
.
api
.
householdapi
.
face
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DateTime
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.log.Log
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.yeejoin.amos.api.householdapi.Utils.GolangRequestUtil
;
...
...
@@ -121,9 +123,8 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
requestInfo
.
put
(
"pageNo"
,
1
);
requestInfo
.
put
(
"pageSize"
,
100
);
String
requestParaminfo
=
JSON
.
toJSONString
(
requestInfo
);
List
<
GolangStationList
>
result
=
golangRequestUtil
.
getResPonse
(
GoLangConstant
.
stationListUrl
,
GoLangConstant
.
requestPost
,
requestParaminfo
,
GoLangConstant
.
resovleRule_data_page_records
,
List
<
GolangStationList
>
result
=
golangRequestUtil
.
getResPonseList
(
GoLangConstant
.
stationListUrl
,
GoLangConstant
.
requestPost
,
requestInfo
,
GoLangConstant
.
resovleRule_data_page_records
,
GolangStationList
.
class
);
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++)
{
GolangStationList
golangStationList
=
result
.
get
(
i
);
...
...
@@ -139,7 +140,9 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
public
void
stationDetail
()
{
long
ts
=
System
.
currentTimeMillis
();
logger
.
info
(
"-------锦浪同步电站详情开始+"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
List
<
String
>
stationIds
=
golangStationMapper
.
getStationIds
();
// List<String> stationIds = golangStationMapper.getStationIds();
//此处改成实时去查询电站数并且和mysql存储进行对比,不符合的直接删除
List
<
String
>
stationIds
=
getStationIds
();
String
today
=
DateUtil
.
today
();
String
hour
=
new
Date
().
getHours
()
+
":00"
;
for
(
int
i
=
0
;
i
<
stationIds
.
size
();
i
++)
{
...
...
@@ -367,6 +370,36 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
logger
.
info
(
"-------锦浪同步电站详情结束+"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
}
/**
* 获取场站id
* @return
*/
private
List
<
String
>
getStationIds
()
{
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
requestInfo
.
put
(
"pageNo"
,
1
);
requestInfo
.
put
(
"pageSize"
,
100
);
List
<
String
>
stationIds
=
new
ArrayList
<>();
List
<
GolangStationList
>
golangStationLists
=
golangRequestUtil
.
getResPonseList
(
GoLangConstant
.
stationListUrl
,
GoLangConstant
.
requestPost
,
requestInfo
,
GoLangConstant
.
resovleRule_data_page_records
,
GolangStationList
.
class
);
if
(
CollectionUtil
.
isNotEmpty
(
golangStationLists
)){
for
(
GolangStationList
golangStationList
:
golangStationLists
)
{
stationIds
.
add
(
golangStationList
.
getId
());
}
QueryWrapper
<
JpStation
>
wrapper
=
new
QueryWrapper
<
JpStation
>().
eq
(
"third_code"
,
PVProducerInfoEnum
.
JLY
.
getCode
());
List
<
JpStation
>
jpStations
=
jpStationMapper
.
selectList
(
wrapper
);
if
(
CollectionUtil
.
isNotEmpty
(
jpStations
)){
for
(
JpStation
jpStation
:
jpStations
)
{
if
(!
stationIds
.
contains
(
jpStation
.
getThirdStationId
())){
//删除多余数据
jpStationMapper
.
deleteById
(
jpStation
.
getSequenceNbr
());
}
}
}
}
return
stationIds
;
}
@Scheduled
(
cron
=
"${dataRequstScheduled.jinlangyun}"
)
@Async
@Override
...
...
@@ -384,9 +417,8 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
// requestInfo.put("stationId", Long.valueOf(stationIds.get(i)));
requestInfo
.
put
(
"pageNo"
,
1
);
requestInfo
.
put
(
"pageSize"
,
100
);
String
requestParaminfo
=
JSON
.
toJSONString
(
requestInfo
);
List
<
GolangCollectorList
>
result
=
golangRequestUtil
.
getResPonse
(
GoLangConstant
.
collectorListUrl
,
GoLangConstant
.
requestPost
,
requestParaminfo
,
GoLangConstant
.
resovleRule_data_page_records
,
List
<
GolangCollectorList
>
result
=
golangRequestUtil
.
getResPonseList
(
GoLangConstant
.
collectorListUrl
,
GoLangConstant
.
requestPost
,
requestInfo
,
GoLangConstant
.
resovleRule_data_page_records
,
GolangCollectorList
.
class
);
for
(
int
j
=
0
;
j
<
result
.
size
();
j
++)
{
GolangCollectorList
golangCollectorList
=
result
.
get
(
j
);
...
...
@@ -403,7 +435,9 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
public
void
collectorDetail
()
{
long
ts
=
System
.
currentTimeMillis
();
logger
.
info
(
"-------锦浪同步采集器详情开始+"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
List
<
Long
>
collectorIds
=
golangCollectorListMapper
.
getCollectIds
();
// List<Long> collectorIds = golangCollectorListMapper.getCollectIds();
//此处改成实时去查询并且和mysql存储进行对比,不符合的直接删除
List
<
Long
>
collectorIds
=
getCollectIds
();
for
(
int
i
=
0
;
i
<
collectorIds
.
size
();
i
++)
{
try
{
TimeUnit
.
SECONDS
.
sleep
(
1
);
...
...
@@ -472,6 +506,38 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
logger
.
info
(
"-------锦浪同步采集器详情结束+"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
}
/**
* 获取监盘采集器数据
* @return
*/
private
List
<
Long
>
getCollectIds
()
{
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
requestInfo
.
put
(
"pageNo"
,
1
);
requestInfo
.
put
(
"pageSize"
,
100
);
List
<
Long
>
collectIds
=
new
ArrayList
<>();
List
<
String
>
stationIds
=
new
ArrayList
<>();
List
<
GolangCollectorList
>
golangCollectorLists
=
golangRequestUtil
.
getResPonseList
(
GoLangConstant
.
collectorListUrl
,
GoLangConstant
.
requestPost
,
requestInfo
,
GoLangConstant
.
resovleRule_data_page_records
,
GolangCollectorList
.
class
);
if
(
CollectionUtil
.
isNotEmpty
(
golangCollectorLists
)){
for
(
GolangCollectorList
golangCollectorList
:
golangCollectorLists
)
{
collectIds
.
add
(
golangCollectorList
.
getId
());
stationIds
.
add
(
String
.
valueOf
(
golangCollectorList
.
getStationid
()));
}
QueryWrapper
<
JpCollector
>
wrapper
=
new
QueryWrapper
<
JpCollector
>().
eq
(
"third_code"
,
PVProducerInfoEnum
.
JLY
.
getCode
());
List
<
JpCollector
>
jpCollectors
=
jpCollectorMapper
.
selectList
(
wrapper
);
if
(
CollectionUtil
.
isNotEmpty
(
jpCollectors
)){
for
(
JpCollector
jpCollector
:
jpCollectors
)
{
if
(!
stationIds
.
contains
(
jpCollector
.
getThirdStationId
())){
//删除多余数据
jpCollectorMapper
.
deleteById
(
jpCollector
.
getSequenceNbr
());
}
}
}
}
return
collectIds
;
}
@Scheduled
(
cron
=
"${dataRequstScheduled.jinlangyun}"
)
@Async
@Override
...
...
@@ -489,9 +555,8 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
// requestInfo.put("stationId", Long.valueOf(stationIds.get(i)));
requestInfo
.
put
(
"pageNo"
,
1
);
requestInfo
.
put
(
"pageSize"
,
100
);
String
requestParaminfo
=
JSON
.
toJSONString
(
requestInfo
);
List
<
GolangInverterList
>
result
=
golangRequestUtil
.
getResPonse
(
GoLangConstant
.
inverterListUrl
,
GoLangConstant
.
requestPost
,
requestParaminfo
,
GoLangConstant
.
resovleRule_data_page_records
,
List
<
GolangInverterList
>
result
=
golangRequestUtil
.
getResPonseList
(
GoLangConstant
.
inverterListUrl
,
GoLangConstant
.
requestPost
,
requestInfo
,
GoLangConstant
.
resovleRule_data_page_records
,
GolangInverterList
.
class
);
for
(
int
j
=
0
;
j
<
result
.
size
();
j
++)
{
GolangInverterList
golangInverterList
=
result
.
get
(
j
);
...
...
@@ -502,13 +567,15 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
logger
.
info
(
"-------锦浪同步逆变器结束+"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
}
@Scheduled
(
cron
=
"${dataRequstScheduled.jinlangyun}"
)
@Async
@Override
public
void
inverterDetail
()
{
long
ts
=
System
.
currentTimeMillis
();
logger
.
info
(
"-------锦浪同步逆变器详情开始+"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
List
<
String
>
inverterSns
=
golangInverterListMapper
.
getInverterSns
();
// List<String> inverterSns = golangInverterListMapper.getInverterSns();
List
<
String
>
inverterSns
=
getInverterSns
();
for
(
int
i
=
0
;
i
<
inverterSns
.
size
();
i
++)
{
try
{
TimeUnit
.
SECONDS
.
sleep
(
1
);
...
...
@@ -812,13 +879,46 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
logger
.
info
(
"-------锦浪同步逆变器详情结束+"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
}
/**
* 获取逆变器数据
* @return
*/
private
List
<
String
>
getInverterSns
()
{
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
requestInfo
.
put
(
"pageNo"
,
1
);
requestInfo
.
put
(
"pageSize"
,
100
);
List
<
String
>
inverterSns
=
new
ArrayList
<>();
List
<
String
>
stationIds
=
new
ArrayList
<>();
List
<
GolangInverterList
>
golangInverterLists
=
golangRequestUtil
.
getResPonseList
(
GoLangConstant
.
inverterListUrl
,
GoLangConstant
.
requestPost
,
requestInfo
,
GoLangConstant
.
resovleRule_data_page_records
,
GolangInverterList
.
class
);
if
(
CollectionUtil
.
isNotEmpty
(
golangInverterLists
)){
for
(
GolangInverterList
golangInverterList
:
golangInverterLists
)
{
inverterSns
.
add
(
golangInverterList
.
getSn
());
stationIds
.
add
(
String
.
valueOf
(
golangInverterList
.
getStationid
()));
}
QueryWrapper
<
JpInverter
>
wrapper
=
new
QueryWrapper
<
JpInverter
>().
eq
(
"third_code"
,
PVProducerInfoEnum
.
JLY
.
getCode
());
List
<
JpInverter
>
jpInverters
=
jpInverterMapper
.
selectList
(
wrapper
);
if
(
CollectionUtil
.
isNotEmpty
(
jpInverters
)){
for
(
JpInverter
jpInverter
:
jpInverters
)
{
if
(!
stationIds
.
contains
(
jpInverter
.
getThirdStationId
())){
//删除多余数据
jpInverterMapper
.
deleteById
(
jpInverter
.
getSequenceNbr
());
}
}
}
}
return
inverterSns
;
}
@Scheduled
(
cron
=
"${dataRequstScheduled.jinlangyun}"
)
@Async
@Override
public
void
inverAlramInfo
()
{
long
ts
=
System
.
currentTimeMillis
();
logger
.
info
(
"-------锦浪同步告警开始+"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
List
<
String
>
inverterIds
=
golangInverterListMapper
.
getInverterSns
();
// List<String> inverterIds = golangInverterListMapper.getInverterSns();
//实时获取数据
List
<
String
>
inverterIds
=
getInverterSnsToAlramInfo
();
for
(
int
i
=
0
;
i
<
inverterIds
.
size
();
i
++)
{
try
{
TimeUnit
.
SECONDS
.
sleep
(
1
);
...
...
@@ -831,9 +931,8 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
requestInfo
.
put
(
"alarmDeviceSn"
,
inverterIds
.
get
(
i
));
requestInfo
.
put
(
"alarmBeginTime"
,
DateUtil
.
today
());
requestInfo
.
put
(
"alarmEndTime"
,
DateUtil
.
today
());
String
requestParaminfo
=
JSON
.
toJSONString
(
requestInfo
);
List
<
AlarmDto
>
result
=
golangRequestUtil
.
getResPonse
(
GoLangConstant
.
alarmListUrl
,
GoLangConstant
.
requestPost
,
requestParaminfo
,
GoLangConstant
.
resovleRule_data_records
,
List
<
AlarmDto
>
result
=
golangRequestUtil
.
getResPonseList
(
GoLangConstant
.
alarmListUrl
,
GoLangConstant
.
requestPost
,
requestInfo
,
GoLangConstant
.
resovleRule_data_records
,
AlarmDto
.
class
);
for
(
int
j
=
0
;
j
<
result
.
size
();
j
++)
{
AlarmDto
alarmDto
=
result
.
get
(
j
);
...
...
@@ -888,4 +987,24 @@ public class GoLangDataAcquisitionServiceImpl implements GoLangDataAcquisitionSe
}
logger
.
info
(
"-------锦浪同步告警结束+"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
}
/**
* 获取逆变器数据
* @return
*/
private
List
<
String
>
getInverterSnsToAlramInfo
()
{
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
requestInfo
.
put
(
"pageNo"
,
1
);
requestInfo
.
put
(
"pageSize"
,
100
);
List
<
String
>
inverterSns
=
new
ArrayList
<>();
List
<
GolangInverterList
>
golangInverterLists
=
golangRequestUtil
.
getResPonseList
(
GoLangConstant
.
inverterListUrl
,
GoLangConstant
.
requestPost
,
requestInfo
,
GoLangConstant
.
resovleRule_data_page_records
,
GolangInverterList
.
class
);
if
(
CollectionUtil
.
isNotEmpty
(
golangInverterLists
)){
for
(
GolangInverterList
golangInverterList
:
golangInverterLists
)
{
inverterSns
.
add
(
golangInverterList
.
getSn
());
}
}
return
inverterSns
;
}
}
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/face/service/impl/GoodWeDataAcquisitionServiceImpl.java
View file @
d7721b58
package
com
.
yeejoin
.
amos
.
api
.
householdapi
.
face
.
service
.
impl
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
...
...
@@ -35,10 +36,7 @@ import org.springframework.scheduling.annotation.Scheduled;
import
org.springframework.stereotype.Service
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
javax.annotation.PostConstruct
;
...
...
@@ -109,12 +107,13 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
requestInfo
.
put
(
"page_index"
,
1
);
requestInfo
.
put
(
"page_size"
,
200
);
// requestInfo.put("key", "龙虎山北区");
String
requstParam
=
JSON
.
toJSONString
(
requestInfo
);
String
today
=
DateUtil
.
today
();
String
hour
=
new
Date
().
getHours
()
+
":00"
;
List
<
GoodWeStationMonitorDto
>
goodWeStationLists
=
goodWeRequestUtil
.
getResPonse
(
GoodWeConstant
.
stationListStatusUrl
,
GoodWeConstant
.
requestPost
,
requ
stParam
,
List
<
GoodWeStationMonitorDto
>
goodWeStationLists
=
goodWeRequestUtil
.
getResPonse
List
(
GoodWeConstant
.
stationListStatusUrl
,
GoodWeConstant
.
requestPost
,
requ
estInfo
,
GoodWeConstant
.
resovleRule_data_list
,
GoodWeStationMonitorDto
.
class
);
//删除多余的场站
deleteBDWStation
(
goodWeStationLists
);
if
(
goodWeStationLists
.
size
()
>
0
)
{
goodWeStationLists
.
forEach
(
goodWeStationMonitorDto
->
{
GoodWeStationMonitorList
goodWeStationList
=
new
GoodWeStationMonitorList
();
...
...
@@ -296,7 +295,9 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
TdHYGFStationAllGenerate
.
setYearTime
(
DateUtil
.
format
(
today1
,
"yyyy"
));
TdHYGFStationAllGenerate
.
setYear
(
DateUtil
.
format
(
today1
,
"yyyy"
));
TdHYGFStationAllGenerate
.
setGenerate
(
jpStation
.
getYearGenerate
());
TdHYGFStationAllGenerate
.
setFullhour
(
jpStation
.
getYearGenerate
()
/
jpStation
.
getCapacity
());
if
(
ObjectUtils
.
isNotEmpty
(
jpStation
.
getYearGenerate
()))
{
TdHYGFStationAllGenerate
.
setFullhour
(
jpStation
.
getYearGenerate
()
/
jpStation
.
getCapacity
());
}
TdHYGFStationAllGenerate
.
setIncome
(
jpStation
.
getYearIncome
());
// 新加
TdHYGFStationAllGenerate
.
setAmosCompanyCode
(
jpStation
.
getAmosCompanyCode
());
...
...
@@ -315,13 +316,37 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
logger
.
info
(
"-------固德威同步场站和告警结束"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
}
/**
* 删除多余的场站
* @param goodWeStationLists
*/
private
void
deleteBDWStation
(
List
<
GoodWeStationMonitorDto
>
goodWeStationLists
)
{
if
(
CollectionUtil
.
isNotEmpty
(
goodWeStationLists
)){
List
<
String
>
stationIds
=
new
ArrayList
<>();
for
(
GoodWeStationMonitorDto
goodWeStationMonitorDto
:
goodWeStationLists
)
{
stationIds
.
add
(
goodWeStationMonitorDto
.
getPowerstation_id
());
}
QueryWrapper
<
JpStation
>
wrapper
=
new
QueryWrapper
<
JpStation
>().
eq
(
"third_code"
,
PVProducerInfoEnum
.
GDW
.
getCode
());
List
<
JpStation
>
jpStations
=
jpStationMapper
.
selectList
(
wrapper
);
if
(
CollectionUtil
.
isNotEmpty
(
jpStations
)){
for
(
JpStation
jpStation
:
jpStations
)
{
if
(!
stationIds
.
contains
(
jpStation
.
getThirdStationId
())){
//删除多余数据
jpStationMapper
.
deleteById
(
jpStation
.
getSequenceNbr
());
}
}
}
}
}
@Override
@Scheduled
(
cron
=
"${dataRequstScheduled.GoodWe}"
)
@Async
public
void
stationDetail
()
{
long
ts
=
System
.
currentTimeMillis
();
logger
.
info
(
"-------固德威同步场站详情开始"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
List
<
String
>
stationIds
=
goodWeStationMonitorListMapper
.
getStationIds
();
// List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
List
<
String
>
stationIds
=
getStationIds
();
stationIds
.
forEach
(
stationId
->
{
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
String
requstParam
=
JSON
.
toJSONString
(
requestInfo
);
...
...
@@ -352,13 +377,34 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
logger
.
info
(
"-------固德威同步场站详情结束"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
}
/**
* 获取场站id
* @return
*/
private
List
<
String
>
getStationIds
()
{
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
requestInfo
.
put
(
"page_index"
,
1
);
requestInfo
.
put
(
"page_size"
,
200
);
List
<
GoodWeStationMonitorDto
>
goodWeStationLists
=
goodWeRequestUtil
.
getResPonseList
(
GoodWeConstant
.
stationListStatusUrl
,
GoodWeConstant
.
requestPost
,
requestInfo
,
GoodWeConstant
.
resovleRule_data_list
,
GoodWeStationMonitorDto
.
class
);
List
<
String
>
stationIds
=
new
ArrayList
<>();
if
(
CollectionUtil
.
isNotEmpty
(
goodWeStationLists
)){
for
(
GoodWeStationMonitorDto
goodWeStationMonitorDto
:
goodWeStationLists
)
{
stationIds
.
add
(
goodWeStationMonitorDto
.
getPowerstation_id
());
}
}
return
stationIds
;
}
@Override
@Scheduled
(
cron
=
"${dataRequstScheduled.GoodWe}"
)
@Async
public
void
stationMonthGen
()
{
long
ts
=
System
.
currentTimeMillis
();
logger
.
info
(
"-------固德威同步场站月发电量开始"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
List
<
String
>
stationIds
=
goodWeStationMonitorListMapper
.
getStationIds
();
// List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
List
<
String
>
stationIds
=
getStationIds
();
stationIds
.
forEach
(
stationId
->
{
String
currentMonth
=
DateUtil
.
format
(
new
Date
(),
"yyyyMM"
);
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
...
...
@@ -395,7 +441,8 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
public
void
stationYearGen
()
{
long
ts
=
System
.
currentTimeMillis
();
logger
.
info
(
"-------固德威同步场站年发电量开始"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
List
<
String
>
stationIds
=
goodWeStationMonitorListMapper
.
getStationIds
();
// List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
List
<
String
>
stationIds
=
getStationIds
();
stationIds
.
forEach
(
stationId
->
{
String
currentYear
=
DateUtil
.
format
(
new
Date
(),
"yyyy"
);
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
...
...
@@ -438,7 +485,10 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
public
void
inverterList
()
{
long
ts
=
System
.
currentTimeMillis
();
logger
.
info
(
"-------固德威同步逆变器开始"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
List
<
String
>
stationIds
=
goodWeStationMonitorListMapper
.
getStationIds
();
// List<String> stationIds = goodWeStationMonitorListMapper.getStationIds();
List
<
String
>
stationIds
=
getStationIds
();
//删除多余的逆变器
deleteGDWInverter
(
stationIds
);
stationIds
.
stream
().
forEach
(
stationId
->
{
HashMap
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
requestInfo
.
put
(
"page_index"
,
1
);
...
...
@@ -446,9 +496,8 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
requestInfo
.
put
(
"pw_id"
,
stationId
);
JpStation
jpStation
=
jpStationMapper
.
selectOne
(
new
QueryWrapper
<
JpStation
>().
eq
(
"third_station_id"
,
stationId
).
orderByDesc
(
"create_time"
));
String
requstParam
=
JSON
.
toJSONString
(
requestInfo
);
List
<
GoodWeINverterDetailDto
>
inverterDetailDtoList
=
goodWeRequestUtil
.
getResPonse
(
GoodWeConstant
.
queryInventerUrl
,
GoodWeConstant
.
requestPost
,
requstParam
,
List
<
GoodWeINverterDetailDto
>
inverterDetailDtoList
=
goodWeRequestUtil
.
getResPonseList
(
GoodWeConstant
.
queryInventerUrl
,
GoodWeConstant
.
requestPost
,
requestInfo
,
GoodWeConstant
.
resovleRule_data_list
,
GoodWeINverterDetailDto
.
class
);
inverterDetailDtoList
.
forEach
(
goodWeINverterDetailDto
->
{
// System.out.println(goodWeINverterDetailDto.getIt_sn());
...
...
@@ -480,6 +529,23 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
logger
.
info
(
"-------固德威同步逆变器结束"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
}
/**
* 删除多余的逆变器
* @param stationIds
*/
private
void
deleteGDWInverter
(
List
<
String
>
stationIds
)
{
QueryWrapper
<
JpInverter
>
wrapper
=
new
QueryWrapper
<
JpInverter
>().
eq
(
"third_code"
,
PVProducerInfoEnum
.
GDW
.
getCode
());
List
<
JpInverter
>
jpInverters
=
jpInverterMapper
.
selectList
(
wrapper
);
if
(
CollectionUtil
.
isNotEmpty
(
jpInverters
)){
for
(
JpInverter
jpInverter
:
jpInverters
)
{
if
(!
stationIds
.
contains
(
jpInverter
.
getThirdStationId
())){
//删除多余数据
jpInverterMapper
.
deleteById
(
jpInverter
.
getSequenceNbr
());
}
}
}
}
@Override
@Scheduled
(
cron
=
"${dataRequstScheduled.GoodWe}"
)
@Async
...
...
@@ -847,9 +913,8 @@ public class GoodWeDataAcquisitionServiceImpl implements GoodWeDataAcquisitionSe
requestInfo
.
put
(
"endtime"
,
today
+
" 23:59:59"
);
requestInfo
.
put
(
"stationid"
,
stationid
);
// 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
);
List
<
GoodWeAlarmDto
>
alarmList
=
goodWeRequestUtil
.
getResPonseList
(
GoodWeConstant
.
alarmListUrl
,
GoodWeConstant
.
requestPost
,
requestInfo
,
GoodWeConstant
.
resovleRule_data_list
,
GoodWeAlarmDto
.
class
);
alarmList
.
forEach
(
goodWeAlarmDto
->
{
if
(!
ObjectUtils
.
isEmpty
(
goodWeAlarmDto
.
getDevicesn
()))
{
HYGFJPInverterWarn
hygfjpInverterWarn
=
hygfjpInverterWarnMapper
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/face/service/impl/SofarDataAcquisitionServiceImpl.java
View file @
d7721b58
...
...
@@ -14,6 +14,8 @@ import java.util.stream.Stream;
import
javax.annotation.PostConstruct
;
import
cn.hutool.core.collection.CollectionUtil
;
import
com.yeejoin.amos.api.householdapi.face.dto.GoodWeStationMonitorDto
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -118,18 +120,42 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ
Map
<
String
,
Object
>
requestInfo
=
new
HashMap
<>();
requestInfo
.
put
(
"page"
,
1
);
requestInfo
.
put
(
"size"
,
1000
);
String
param
=
JSON
.
toJSONString
(
requestInfo
);
List
<
SofarStationList
>
jsonObject
=
requestUtil
.
getResPonse
(
SoFarConstant
.
stationListUrl
,
SoFarConstant
.
requestPost
,
param
,
SoFarConstant
.
resovleRule_data
,
SofarStationList
.
class
);
List
<
SofarStationList
>
jsonObject
=
requestUtil
.
getResPonseList
(
SoFarConstant
.
stationListUrl
,
SoFarConstant
.
requestPost
,
requestInfo
,
SoFarConstant
.
resovleRule_data
,
SofarStationList
.
class
);
// 新增td电站
for
(
SofarStationList
sunlight
:
jsonObject
)
{
sunlight
.
setCreatedTime
(
System
.
currentTimeMillis
());
sofarStationListMapper
.
insert
(
sunlight
);
}
//删除多余的电站
deleteSHStation
(
jsonObject
);
// mysql电站信息
this
.
stationDetail
(
jsonObject
);
}
/**
* 删除多余的首航场站
* @param sofarStationLists
*/
private
void
deleteSHStation
(
List
<
SofarStationList
>
sofarStationLists
)
{
if
(
CollectionUtil
.
isNotEmpty
(
sofarStationLists
)){
List
<
String
>
stationIds
=
new
ArrayList
<>();
for
(
SofarStationList
sofarStationList
:
sofarStationLists
)
{
stationIds
.
add
(
sofarStationList
.
getId
().
toString
());
}
QueryWrapper
<
JpStation
>
wrapper
=
new
QueryWrapper
<
JpStation
>().
eq
(
"third_code"
,
PVProducerInfoEnum
.
SH
.
getCode
());
List
<
JpStation
>
jpStations
=
jpStationMapper
.
selectList
(
wrapper
);
if
(
CollectionUtil
.
isNotEmpty
(
jpStations
)){
for
(
JpStation
jpStation
:
jpStations
)
{
if
(!
stationIds
.
contains
(
jpStation
.
getThirdStationId
())){
//删除多余数据
jpStationMapper
.
deleteById
(
jpStation
.
getSequenceNbr
());
}
}
}
}
}
@Override
public
void
stationDetail
(
List
<
SofarStationList
>
list
)
{
...
...
@@ -1212,8 +1238,7 @@ public class SofarDataAcquisitionServiceImpl implements SofarDataAcquisitionServ
// if (jpStation.getThirdStationId().equals("517021808701218816")){
// System.out.println("6666666666666666666666666");
// }
String
param
=
JSON
.
toJSONString
(
requestInfo
);
List
<
SofarWarm
>
jsonObject2
=
requestUtil
.
getResPonse
(
SoFarConstant
.
alert
,
SoFarConstant
.
requestPost
,
param
,
List
<
SofarWarm
>
jsonObject2
=
requestUtil
.
getResPonseList
(
SoFarConstant
.
alert
,
SoFarConstant
.
requestPost
,
requestInfo
,
SoFarConstant
.
stationAlertItems
,
SofarWarm
.
class
);
// if (jsonObject2 != null && jsonObject2.size() > 0) {
// System.out.println("88888888888888888888888");
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/face/service/impl/SunlightServiceImpl.java
View file @
d7721b58
package
com
.
yeejoin
.
amos
.
api
.
householdapi
.
face
.
service
.
impl
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.json.JSONObject
;
...
...
@@ -113,8 +114,10 @@ public class SunlightServiceImpl implements SunlightService {
bodyparam
.
put
(
"ps_type"
,
"1,3,4,5,6,7,8"
);
bodyparam
.
put
(
"size"
,
3000
);
bodyparam
.
put
(
"curPage"
,
1
);
JSONObject
data
=
SunlightUtil
.
get
data
(
SunlightUtil
.
getPowerStationList
,
bodyparam
);
JSONObject
data
=
SunlightUtil
.
get
DataList
(
SunlightUtil
.
getPowerStationList
,
bodyparam
);
List
<
Sunlight
>
list
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
data
.
get
(
"pageList"
)),
Sunlight
.
class
);
//删除多余的场站
deleteYGStation
(
data
);
this
.
stationDetail
(
data
);
for
(
Sunlight
sunlight
:
list
)
{
...
...
@@ -124,6 +127,31 @@ public class SunlightServiceImpl implements SunlightService {
logger
.
info
(
"-------阳光同步电站/逆变器/采集器结束"
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
}
/**
* 删除多余的阳光场站
* @param data
*/
private
void
deleteYGStation
(
JSONObject
data
)
{
// 所有场站信息
List
<
SunlightDto
>
sunlightDtos
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
data
.
get
(
"pageList"
)),
SunlightDto
.
class
);
if
(
CollectionUtil
.
isNotEmpty
(
sunlightDtos
)){
List
<
String
>
stationIds
=
new
ArrayList
<>();
for
(
SunlightDto
sunlightDto
:
sunlightDtos
)
{
stationIds
.
add
(
sunlightDto
.
getPs_id
().
toString
());
}
QueryWrapper
<
JpStation
>
wrapper
=
new
QueryWrapper
<
JpStation
>().
eq
(
"third_code"
,
PVProducerInfoEnum
.
YG
.
getCode
());
List
<
JpStation
>
jpStations
=
jpStationMapper
.
selectList
(
wrapper
);
if
(
CollectionUtil
.
isNotEmpty
(
jpStations
)){
for
(
JpStation
jpStation
:
jpStations
)
{
if
(!
stationIds
.
contains
(
jpStation
.
getThirdStationId
())){
//删除多余数据
jpStationMapper
.
deleteById
(
jpStation
.
getSequenceNbr
());
}
}
}
}
}
// 电站数据如库,电站统计数据入库
public
void
stationDetail
(
JSONObject
data
)
{
// 所有场站信息
...
...
@@ -271,7 +299,7 @@ public class SunlightServiceImpl implements SunlightService {
bodyparamjp11
.
put
(
"size"
,
3000
);
bodyparamjp11
.
put
(
"curPage"
,
1
);
bodyparamjp11
.
put
(
"device_type_list"
,
lif11
);
JSONObject
jsonObject1data11
=
SunlightUtil
.
get
data
(
SunlightUtil
.
getDeviceList
,
bodyparamjp11
);
JSONObject
jsonObject1data11
=
SunlightUtil
.
get
DataList
(
SunlightUtil
.
getDeviceList
,
bodyparamjp11
);
List
<
Device
>
listdtx
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
jsonObject1data11
.
get
(
"pageList"
)),
Device
.
class
);
// 获取电站下逆变器
...
...
@@ -282,7 +310,7 @@ public class SunlightServiceImpl implements SunlightService {
bodyparamjp
.
put
(
"size"
,
3000
);
bodyparamjp
.
put
(
"curPage"
,
1
);
bodyparamjp
.
put
(
"device_type_list"
,
lif
);
JSONObject
jsonObject1data
=
SunlightUtil
.
get
data
(
SunlightUtil
.
getDeviceList
,
bodyparamjp
);
JSONObject
jsonObject1data
=
SunlightUtil
.
get
DataList
(
SunlightUtil
.
getDeviceList
,
bodyparamjp
);
List
<
Device
>
listd
=
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
jsonObject1data
.
get
(
"pageList"
)),
Device
.
class
);
// 获取电站,月发电量
...
...
@@ -1000,7 +1028,7 @@ public class SunlightServiceImpl implements SunlightService {
Map
<
String
,
Object
>
bodyparamf
=
new
HashMap
<>();
bodyparamf
.
put
(
"size"
,
1000
);
bodyparamf
.
put
(
"curPage"
,
1
);
JSONObject
jsonObject
=
SunlightUtil
.
get
data
(
SunlightUtil
.
getFaultAlarmInfo
,
bodyparamf
);
JSONObject
jsonObject
=
SunlightUtil
.
get
DataList
(
SunlightUtil
.
getFaultAlarmInfo
,
bodyparamf
);
List
<
SunlightWarm
>
listd
=
jsonObject
.
get
(
"pageList"
)
!=
null
?
JSONArray
.
parseArray
(
JSON
.
toJSONString
(
jsonObject
.
get
(
"pageList"
)),
SunlightWarm
.
class
)
:
null
;
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/face/service/impl/TanYinDataAcquisitionServiceImpl.java
View file @
d7721b58
...
...
@@ -67,10 +67,7 @@ import java.text.SimpleDateFormat;
import
java.time.LocalDate
;
import
java.time.ZoneId
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -566,6 +563,10 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
for
(
TanYinInveterInfo
tanYinInveterInfo
:
tanYinInveterInfos
)
{
// region 逆变器信息
JSONObject
tanYinInveterInfoResultJson
=
tanYinInveterInfoResultMap
.
getJSONObject
(
tanYinInveterInfo
.
getSn
());
//处理空指针问题
if
(
Objects
.
isNull
(
tanYinInveterInfoResultJson
)){
continue
;
}
TanYinInveterInfo
tanYinInveterInfoDTO
=
tanYinInveterInfoResultJson
.
toJavaObject
(
TanYinInveterInfo
.
class
);
tanYinInveterInfoDTO
.
setProjectNo
(
tanYinInveterInfo
.
getProjectNo
());
tanYinInveterInfoDTO
.
setDeviceName
(
tanYinInveterInfo
.
getDeviceName
());
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/config/SchedulerConfig.java
0 → 100644
View file @
d7721b58
package
com
.
yeejoin
.
amos
.
config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler
;
@Configuration
@EnableScheduling
public
class
SchedulerConfig
{
@Bean
public
ThreadPoolTaskScheduler
taskScheduler
()
{
ThreadPoolTaskScheduler
scheduler
=
new
ThreadPoolTaskScheduler
();
scheduler
.
setPoolSize
(
10
);
// 设置线程池大小为10
scheduler
.
setThreadNamePrefix
(
"my-scheduled-task-"
);
// 设置线程名称前缀
scheduler
.
initialize
();
// 初始化线程池
return
scheduler
;
}
}
\ No newline at end of file
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