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
1dff0a2b
Commit
1dff0a2b
authored
Jul 17, 2024
by
yangyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接 碳银电站接口
parent
c671dc3b
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
264 additions
and
173 deletions
+264
-173
TanYinApiUtils.java
...m/yeejoin/amos/api/householdapi/Utils/TanYinApiUtils.java
+23
-22
TanYinConstant.java
...eejoin/amos/api/householdapi/constant/TanYinConstant.java
+16
-0
BusinessException.java
...in/amos/api/householdapi/exception/BusinessException.java
+10
-1
TanYinInveterInfo.java
...face/orm/houseapi/entity/tdeingine/TanYinInveterInfo.java
+78
-18
TanYinDataAcquisitionServiceImpl.java
...i/face/service/impl/TanYinDataAcquisitionServiceImpl.java
+129
-130
application-dev.properties
...-housepvapi/src/main/resources/application-dev.properties
+8
-2
No files found.
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/Utils/TanYinApiUtils.java
View file @
1dff0a2b
...
...
@@ -162,19 +162,23 @@ public class TanYinApiUtils {
// 记录请求日志。
log
.
debug
(
"请求 => 碳银{}接口,url:{},参数:{},headers:{}"
,
desc
,
url
,
paramsJsonStr
,
JSON
.
toJSONString
(
headers
));
HttpResponse
response
;
HttpResponse
response
=
null
;
try
{
// 发送POST请求,带上参数和headers,并执行。
response
=
HttpUtil
.
createPost
(
url
).
body
(
paramsJsonStr
,
MediaType
.
APPLICATION_JSON_UTF8_VALUE
).
headerMap
(
headers
,
true
).
execute
();
// 解析响应并返回。
return
parseResponse
(
desc
,
response
,
resultClass
);
}
catch
(
BusinessException
businessException
)
{
// 在业务异常情况下,尝试刷新令牌并重试请求。
// 刷新 Access_token
headers
.
put
(
"Authorization"
,
"Bearer "
+
refreshAccessToken
(
clientKey
,
clientSecret
));
response
=
HttpUtil
.
createPost
(
url
).
body
(
paramsJsonStr
,
MediaType
.
APPLICATION_JSON_UTF8_VALUE
).
headerMap
(
headers
,
true
).
execute
();
// 解析刷新令牌后的响应并返回。
return
parseResponse
(
desc
,
response
,
resultClass
);
if
(
businessException
.
isTokenError
())
{
// 在业务异常情况下,尝试刷新令牌并重试请求。
// 刷新 Access_token
headers
.
put
(
"Authorization"
,
"Bearer "
+
refreshAccessToken
(
clientKey
,
clientSecret
));
response
=
HttpUtil
.
createPost
(
url
).
body
(
paramsJsonStr
,
MediaType
.
APPLICATION_JSON_UTF8_VALUE
).
headerMap
(
headers
,
true
).
execute
();
// 解析刷新令牌后的响应并返回。
return
parseResponse
(
desc
,
response
,
resultClass
);
}
log
.
warn
(
String
.
format
(
"异常 => 碳银%s接口,参数: %s,响应: %s"
,
desc
,
paramsJsonStr
,
response
!=
null
?
response
.
body
()
:
businessException
.
getMessage
()));
return
null
;
}
catch
(
Exception
e
)
{
// 记录未预期的异常日志。
log
.
warn
(
String
.
format
(
"异常 => 碳银%s接口,参数: %s"
,
desc
,
paramsJsonStr
),
e
);
...
...
@@ -208,24 +212,25 @@ public class TanYinApiUtils {
// 记录请求日志
log
.
info
(
"请求 => 碳银{}接口,url:{},参数:{},headers:{}"
,
desc
,
url
,
paramsJsonStr
,
JSON
.
toJSONString
(
headers
));
HttpResponse
response
;
HttpResponse
response
=
null
;
try
{
// 发送POST请求,设置请求体和请求头
response
=
HttpUtil
.
createPost
(
url
).
body
(
paramsJsonStr
,
MediaType
.
APPLICATION_JSON_UTF8_VALUE
).
headerMap
(
headers
,
true
).
execute
();
// 记录响应日志
log
.
info
(
"响应 => 碳银{}接口,参数:{},httpCode:{}, response:{}"
,
desc
,
paramsJsonStr
,
response
.
getStatus
(),
response
.
body
());
// 解析响应,返回分页信息和请求结果
return
parsePageResponse
(
desc
,
response
,
resultClass
);
}
catch
(
BusinessException
businessException
)
{
// 在业务异常情况下,尝试刷新令牌并重试请求。
// 刷新 Access_token
headers
.
put
(
"Authorization"
,
"Bearer "
+
refreshAccessToken
(
clientKey
,
clientSecret
));
// 重新发送请求并解析响应
response
=
HttpUtil
.
createPost
(
url
).
body
(
paramsJsonStr
,
MediaType
.
APPLICATION_JSON_UTF8_VALUE
).
headerMap
(
headers
,
true
).
execute
();
return
parsePageResponse
(
desc
,
response
,
resultClass
);
if
(
businessException
.
isTokenError
())
{
// 在业务异常情况下,尝试刷新令牌并重试请求。
// 刷新 Access_token
headers
.
put
(
"Authorization"
,
"Bearer "
+
refreshAccessToken
(
clientKey
,
clientSecret
));
// 重新发送请求并解析响应
response
=
HttpUtil
.
createPost
(
url
).
body
(
paramsJsonStr
,
MediaType
.
APPLICATION_JSON_UTF8_VALUE
).
headerMap
(
headers
,
true
).
execute
();
return
parsePageResponse
(
desc
,
response
,
resultClass
);
}
log
.
warn
(
String
.
format
(
"异常 => 碳银%s接口,参数: %s,响应: %s"
,
desc
,
paramsJsonStr
,
response
!=
null
?
response
.
body
()
:
businessException
.
getMessage
()));
return
null
;
}
catch
(
Exception
e
)
{
// 记录异常日志
log
.
warn
(
String
.
format
(
"异常 => 碳银%s接口,参数: %s"
,
desc
,
paramsJsonStr
),
e
);
...
...
@@ -261,11 +266,7 @@ public class TanYinApiUtils {
// 检查响应是否成功并存在有效数据,如果不成功且错误码为401,则抛出业务异常;其他情况返回null。
if
(!
baseResult
.
getSuccess
()
||
Objects
.
isNull
(
baseResult
.
getData
()))
{
if
(
"401"
.
equals
(
baseResult
.
getCode
()))
{
// Token 过期
throw
new
BusinessException
(
baseResult
.
getCode
().
toString
(),
baseResult
.
getMsg
());
}
return
null
;
throw
new
BusinessException
(
baseResult
.
getCode
().
toString
(),
baseResult
.
getMsg
());
}
// 解析响应数据部分,根据其类型进行相应的处理和转换。
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/constant/TanYinConstant.java
View file @
1dff0a2b
package
com
.
yeejoin
.
amos
.
api
.
householdapi
.
constant
;
import
java.util.HashMap
;
/**
* 碳银常量类
* <p>
...
...
@@ -35,4 +37,18 @@ public class TanYinConstant {
*/
public
static
String
refreshAccessTokenUrl
=
"/v1/auth/refreshAccessToken"
;
public
static
final
HashMap
<
String
,
String
>
stationStatus
=
new
HashMap
<
String
,
String
>()
{
{
put
(
"0"
,
"在线"
);
put
(
"1"
,
"离线"
);
put
(
"2"
,
"异常"
);
}
};
public
static
final
HashMap
<
String
,
String
>
intoNetWorkStatus
=
new
HashMap
<
String
,
String
>()
{
{
put
(
"0"
,
"普通并网"
);
}
};
}
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/exception/BusinessException.java
View file @
1dff0a2b
...
...
@@ -12,18 +12,27 @@ import org.typroject.tyboot.core.foundation.exception.BaseException;
*/
public
class
BusinessException
extends
BaseException
{
private
String
code
=
""
;
public
BusinessException
(
String
message
)
{
super
(
message
,
BusinessException
.
class
.
getSimpleName
(),
"错误的请求."
);
this
.
code
=
"-1"
;
this
.
httpStatus
=
500
;
}
public
BusinessException
(
String
message
,
String
errorCod
e
)
{
public
BusinessException
(
String
errorCode
,
String
messag
e
)
{
super
(
message
,
BusinessException
.
class
.
getSimpleName
(),
message
);
if
(
StringUtils
.
isBlank
(
errorCode
))
{
this
.
httpStatus
=
500
;
this
.
code
=
errorCode
;
}
else
{
this
.
httpStatus
=
Integer
.
parseInt
(
errorCode
);
this
.
code
=
errorCode
;
}
}
public
boolean
isTokenError
()
{
return
"401"
.
equals
(
this
.
code
);
}
}
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/face/orm/houseapi/entity/tdeingine/TanYinInveterInfo.java
View file @
1dff0a2b
...
...
@@ -37,6 +37,10 @@ public class TanYinInveterInfo {
@TableField
(
"gmt_create"
)
private
String
gmtCreate
;
@ApiModelProperty
(
"ID"
)
@TableField
(
"idString"
)
private
String
idString
;
@ApiModelProperty
(
"功率"
)
@TableField
(
"watt"
)
private
String
watt
;
...
...
@@ -81,10 +85,50 @@ public class TanYinInveterInfo {
@TableField
(
"vol4"
)
private
String
vol4
;
@ApiModelProperty
(
"输出电压 1"
)
@TableField
(
"vol5"
)
private
String
vol5
;
@ApiModelProperty
(
"输出电压 2"
)
@TableField
(
"vol6"
)
private
String
vol6
;
@ApiModelProperty
(
"输出电压 3"
)
@TableField
(
"vol7"
)
private
String
vol7
;
@ApiModelProperty
(
"输出电压 3"
)
@TableField
(
"vol8"
)
private
String
vol8
;
@ApiModelProperty
(
"输出电压 3"
)
@TableField
(
"vol9"
)
private
String
vol9
;
@ApiModelProperty
(
"输入电压 6"
)
@TableField
(
"vol10"
)
private
String
vol10
;
@ApiModelProperty
(
"输出电压 3"
)
@TableField
(
"vol11"
)
private
String
vol11
;
@ApiModelProperty
(
"输出电压 3"
)
@TableField
(
"vol12"
)
private
String
vol12
;
@ApiModelProperty
(
"输出电压 3"
)
@TableField
(
"vol13"
)
private
String
vol13
;
@ApiModelProperty
(
"输出电压 3"
)
@TableField
(
"vol14"
)
private
String
vol14
;
@ApiModelProperty
(
"输出电压 3"
)
@TableField
(
"vol15"
)
private
String
vol15
;
@ApiModelProperty
(
"输入电流 1"
)
@TableField
(
"amp0"
)
private
String
amp0
;
...
...
@@ -106,33 +150,49 @@ public class TanYinInveterInfo {
private
String
amp4
;
@ApiModelProperty
(
"输入电流 6"
)
@TableField
(
"amp10"
)
private
String
amp10
;
@ApiModelProperty
(
"输出电压 1"
)
@TableField
(
"vol5"
)
private
String
vol5
;
@ApiModelProperty
(
"输出电压 2"
)
@TableField
(
"vol6"
)
private
String
vol6
;
@ApiModelProperty
(
"输出电压 3"
)
@TableField
(
"vol7"
)
private
String
vol7
;
@ApiModelProperty
(
"输出电流 1"
)
@TableField
(
"amp5"
)
private
String
amp5
;
@ApiModelProperty
(
"输
出电流 2
"
)
@ApiModelProperty
(
"输
入电流 7
"
)
@TableField
(
"amp6"
)
private
String
amp6
;
@ApiModelProperty
(
"输
出电流 3
"
)
@ApiModelProperty
(
"输
入电流 8
"
)
@TableField
(
"amp7"
)
private
String
amp7
;
@ApiModelProperty
(
"输入电流 9"
)
@TableField
(
"amp8"
)
private
String
amp8
;
@ApiModelProperty
(
"输入电流 10"
)
@TableField
(
"amp9"
)
private
String
amp9
;
@ApiModelProperty
(
"输入电流 11"
)
@TableField
(
"amp10"
)
private
String
amp10
;
@ApiModelProperty
(
"输入电流 12"
)
@TableField
(
"amp11"
)
private
String
amp11
;
@ApiModelProperty
(
"输入电流 13"
)
@TableField
(
"amp12"
)
private
String
amp12
;
@ApiModelProperty
(
"输入电流 14"
)
@TableField
(
"amp13"
)
private
String
amp13
;
@ApiModelProperty
(
"输入电流 15"
)
@TableField
(
"amp14"
)
private
String
amp14
;
@ApiModelProperty
(
"输入电流 16"
)
@TableField
(
"amp15"
)
private
String
amp15
;
@ApiModelProperty
(
"温度(单位:摄氏度)"
)
@TableField
(
"temperature"
)
private
String
temperature
;
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/java/com/yeejoin/amos/api/householdapi/face/service/impl/TanYinDataAcquisitionServiceImpl.java
View file @
1dff0a2b
package
com
.
yeejoin
.
amos
.
api
.
householdapi
.
face
.
service
.
impl
;
import
cn.hutool.core.collection.ListUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.map.MapBuilder
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.Wrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.toolkit.StringUtils
;
import
com.github.pagehelper.PageInfo
;
import
com.yeejoin.amos.api.householdapi.Utils.RedisUtils
;
import
com.yeejoin.amos.api.householdapi.Utils.TanYinApiUtils
;
import
com.yeejoin.amos.api.householdapi.constant.GoLangConstant
;
import
com.yeejoin.amos.api.householdapi.constant.TanYinConstant
;
import
com.yeejoin.amos.api.householdapi.face.dto.D
;
import
com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpInverter
;
import
com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpInverterElectricity
;
import
com.yeejoin.amos.api.householdapi.face.orm.houseapi.entity.hygf.JpStation
;
...
...
@@ -168,16 +164,28 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
private
final
static
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
private
final
static
String
pageNo
=
"1"
;
private
final
static
String
pageSize
=
"100"
;
/**
* 每隔 10分钟通过并网时间段同步碳银对应范围内的项目信息
*
* @param
* @return {@link }
* @throws
* @author yangyang
* @date 2024/7/17 13:56
*/
@Scheduled
(
cron
=
"${dataRequestScheduled.tanYin}"
)
@Override
public
void
customerInfoList
()
{
long
ts
=
System
.
currentTimeMillis
();
log
.
info
(
"-------碳银同步项目信息开始: {} ------- "
,
ts
);
Map
<
String
,
Object
>
params
=
MapBuilder
.<
String
,
Object
>
create
()
.
put
(
"pageNo"
,
"1"
)
.
put
(
"pageSize"
,
"100"
)
// 每页行数
.
put
(
"startDate"
,
LocalDate
.
now
().
minus
Days
(
360
).
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)))
// 开始时间 YYYY-MM-dd
.
put
(
"pageNo"
,
pageNo
)
.
put
(
"pageSize"
,
pageSize
)
// 每页行数
.
put
(
"startDate"
,
LocalDate
.
now
().
minus
Years
(
1
).
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)))
// 开始时间 YYYY-MM-dd
.
put
(
"endDate"
,
LocalDate
.
now
().
plusDays
(
1
).
format
(
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
)))
// 结束时间 YYYY-MM-dd
.
build
();
PageInfo
<
TanYinCustomerInfo
>
tanYinCustomerInfos
=
tanYinApiUtils
.
postPage
(
"客户信息"
,
apiUrl
+
TanYinConstant
.
customerInfoUrl
,
JSON
.
toJSONString
(
params
),
null
,
TanYinCustomerInfo
.
class
);
...
...
@@ -192,6 +200,15 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
log
.
info
(
"-------碳银同步项目信息结束: {} ------- "
,
ts
,
sdf
.
format
(
new
Date
()));
}
/**
* 每隔 10分钟通过项目编号同步碳银对应电站信息
*
* @param
* @return {@link }
* @throws
* @author yangyang
* @date 2024/7/17 13:57
*/
@Scheduled
(
cron
=
"${dataRequestScheduled.tanYin}"
)
@Async
@Override
...
...
@@ -200,15 +217,23 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
log
.
info
(
"-------碳银同步电站开始: {} ------- "
,
ts
);
List
<
String
>
projectNos
=
tanYinCustomerInfoMapper
.
listProjectNo
();
projectNos
.
add
(
"TF2024060312382700202"
);
String
powerDate
=
"2024-07-17"
;
if
(
CollectionUtils
.
isEmpty
(
projectNos
))
{
return
;
}
Map
<
String
,
Object
>
params
=
MapBuilder
.<
String
,
Object
>
create
().
put
(
"projectNoList"
,
projectNos
).
put
(
"powerDate"
,
"2024-07-16"
).
build
();
List
<
TanYinStationInfo
>
tanYinStationInfos
=
tanYinApiUtils
.
post
(
"电站基本信息"
,
apiUrl
+
TanYinConstant
.
stationListUrl
,
params
,
null
,
TanYinStationInfo
.
class
);
List
<
List
<
String
>>
projectNoLists
=
ListUtil
.
partition
(
projectNos
,
200
);
// 每次最多 200个
List
<
TanYinStationInfo
>
tanYinStationInfos
=
new
ArrayList
<>();
for
(
List
<
String
>
projectNoList
:
projectNoLists
)
{
Map
<
String
,
Object
>
params
=
MapBuilder
.<
String
,
Object
>
create
().
put
(
"projectNoList"
,
projectNoList
).
put
(
"powerDate"
,
powerDate
).
build
();
List
<
TanYinStationInfo
>
tanYinStationInfoList
=
tanYinApiUtils
.
post
(
"电站基本信息"
,
apiUrl
+
TanYinConstant
.
stationListUrl
,
params
,
null
,
TanYinStationInfo
.
class
);
if
(
CollectionUtils
.
isEmpty
(
tanYinStationInfoList
))
{
return
;
}
tanYinStationInfos
.
addAll
(
tanYinStationInfoList
);
}
if
(
CollectionUtils
.
isEmpty
(
tanYinStationInfos
))
{
return
;
}
List
<
String
>
stationIds
=
tanYinStationInfos
.
stream
().
map
(
TanYinStationInfo:
:
getProjectNo
).
collect
(
Collectors
.
toList
());
List
<
JpStation
>
jpStations
=
jpStationMapper
.
selectList
(
new
QueryWrapper
<
JpStation
>().
eq
(
"third_code"
,
PVProducerInfoEnum
.
TANYIN
.
getCode
()).
in
(
"third_station_id"
,
stationIds
));
Map
<
String
,
JpStation
>
jpStationMap
=
jpStations
.
stream
().
collect
(
Collectors
.
toMap
(
JpStation:
:
getThirdStationId
,
Function
.
identity
()));
...
...
@@ -251,20 +276,15 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
// 并网类型
// jpStation.setSnCode(golangStationDetail.getNmicode());
// jpStation.setPrice();
// if (!ObjectUtils.isEmpty(golangStationDetail.getModule())) {
// jpStation.setModuleCount(ObjectUtils.isEmpty(Math.toIntExact(golangStationDetail.getModule())) ? 0 : Math.toIntExact(golangStationDetail.getModule()));
// }
// jpStation.setState(GoLangConstant.stationStaus.get(String.valueOf(golangStationDetail.getState())));
// jpStation.setThirdStationId(String.valueOf(golangStationDetail.getId()));
// jpStation.setRealTimePower();
// jpStation.setOnGridType();
// jpStation.setDayIncome();
// jpStation.setMonthIncome();
// jpStation.setYearIncome();
// jpStation.setCumulativeIncome();
// jpStation.setArea();
// jpStation.setEmail();
// jpStation.setModuleCount(ObjectUtils.isEmpty(Math.toIntExact(golangStationDetail.getModule())) ? 0 : Math.toIntExact(golangStationDetail.getModule()));
jpStation
.
setOnGridType
(
TanYinConstant
.
intoNetWorkStatus
.
get
(
"0"
));
// 没有该字段默认写死
// jpStation.setOnGridTime();
jpStation
.
setDayIncome
(
tanYinStationInfo
.
getDayPower
()
!=
null
?
Double
.
parseDouble
(
tanYinStationInfo
.
getDayPower
())
*
0.45
:
0.0
);
jpStation
.
setMonthIncome
(
tanYinStationInfo
.
getMonthPower
()
!=
null
?
Double
.
parseDouble
(
tanYinStationInfo
.
getMonthPower
())
*
0.45
:
0.0
);
jpStation
.
setYearIncome
(
tanYinStationInfo
.
getYearPower
()
!=
null
?
Double
.
parseDouble
(
tanYinStationInfo
.
getYearPower
())
*
0.45
:
0.0
);
jpStation
.
setCumulativeIncome
(
tanYinStationInfo
.
getTotalPower
()
!=
null
?
Double
.
parseDouble
(
tanYinStationInfo
.
getTotalPower
())
*
0.45
:
0.0
);
jpStation
.
setArea
(
tanYinStationInfo
.
getArea
());
// jpStation.setEmail();
// jpStation.setAccessTime();
// jpStation.setCreateTime();
// jpStation.setRatedPower();
...
...
@@ -394,32 +414,44 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
log
.
info
(
"-------碳银同步电站结束: {} ------- "
+
ts
+
"------- "
+
sdf
.
format
(
new
Date
()));
}
/**
* 每隔 10分钟同步碳银电站逆变器信息
*
* @param
* @return {@link }
* @throws
* @author yangyang
* @date 2024/7/17 13:58
*/
@Scheduled
(
cron
=
"${dataRequestScheduled.tanYin}"
)
@Override
public
void
inverterList
()
{
long
ts
=
System
.
currentTimeMillis
();
log
.
info
(
"-------碳银同步逆变器开始: {} ------- "
,
ts
);
Wrapper
<
TanYinInveterInfo
>
queryWrapper
=
new
QueryWrapper
<>();
List
<
TanYinInveterInfo
>
tanYinInveterInfos
=
tanYinInveterInfoMapper
.
selectList
(
queryWrapper
);
List
<
TanYinInveterInfo
>
tanYinInveterInfos
=
tanYinInveterInfoMapper
.
selectList
(
new
QueryWrapper
<>());
if
(
CollectionUtils
.
isEmpty
(
tanYinInveterInfos
))
{
return
;
}
List
<
String
>
snList
=
tanYinInveterInfos
.
stream
().
map
(
TanYinInveterInfo:
:
getSn
).
distinct
().
collect
(
Collectors
.
toList
());
Map
<
String
,
TanYinInveterInfo
>
tanYinInveterInfoMap
=
tanYinInveterInfos
.
stream
().
collect
(
Collectors
.
toMap
(
TanYinInveterInfo:
:
getSn
,
v
->
v
,
(
k1
,
k2
)
->
k1
));
Map
<
String
,
TanYinInveterInfo
>
tanYinInveterInfoMap
=
tanYinInveterInfos
.
stream
().
collect
(
Collectors
.
toMap
(
TanYinInveterInfo:
:
getSn
,
v
->
v
,
(
k1
,
k2
)
->
k1
));
List
<
String
>
stationIds
=
tanYinInveterInfos
.
stream
().
map
(
TanYinInveterInfo:
:
getProjectNo
).
collect
(
Collectors
.
toList
());
List
<
JpStation
>
jpStations
=
jpStationMapper
.
selectList
(
new
QueryWrapper
<
JpStation
>().
eq
(
"third_code"
,
PVProducerInfoEnum
.
TANYIN
.
getCode
()).
in
(
"third_station_id"
,
stationIds
));
Map
<
String
,
JpStation
>
jpStationMap
=
jpStations
.
stream
().
collect
(
Collectors
.
toMap
(
JpStation:
:
getThirdStationId
,
Function
.
identity
()));
Map
<
String
,
Object
>
params
=
MapBuilder
.<
String
,
Object
>
create
().
put
(
"snList"
,
snList
).
build
();
JSONObject
tanYinInveterInfoResultMap
=
tanYinApiUtils
.
post
(
"电站逆变器信息"
,
apiUrl
+
TanYinConstant
.
inverterListUrl
,
params
,
null
,
JSONObject
.
class
);
if
(
CollectionUtils
.
isEmpty
(
tanYinInveterInfoMap
))
{
return
;
List
<
String
>
sns
=
tanYinInveterInfos
.
stream
().
map
(
TanYinInveterInfo:
:
getSn
).
distinct
().
collect
(
Collectors
.
toList
());
List
<
List
<
String
>>
snLists
=
ListUtil
.
partition
(
sns
,
200
);
// 最多 200 个
JSONObject
tanYinInveterInfoResultMap
=
new
JSONObject
();
for
(
List
<
String
>
snList
:
snLists
)
{
Map
<
String
,
Object
>
params
=
MapBuilder
.<
String
,
Object
>
create
().
put
(
"snList"
,
snList
).
build
();
JSONObject
tanYinInveterInfoResult
=
tanYinApiUtils
.
post
(
"电站逆变器信息"
,
apiUrl
+
TanYinConstant
.
inverterListUrl
,
params
,
null
,
JSONObject
.
class
);
if
(
CollectionUtils
.
isEmpty
(
tanYinInveterInfoResult
))
{
continue
;
}
tanYinInveterInfoResultMap
.
putAll
(
tanYinInveterInfoResult
);
}
for
(
TanYinInveterInfo
tanYinInveterInfo
:
tanYinInveterInfos
)
{
TanYinInveterInfo
tanYinInveterInfoDTO
=
tanYinInveterInfoResultMap
.
getJSONObject
(
tanYinInveterInfo
.
getSn
()).
toJavaObject
(
TanYinInveterInfo
.
class
);
JSONObject
tanYinInveterInfoResultJson
=
tanYinInveterInfoResultMap
.
getJSONObject
(
tanYinInveterInfo
.
getSn
());
TanYinInveterInfo
tanYinInveterInfoDTO
=
tanYinInveterInfoResultJson
.
toJavaObject
(
TanYinInveterInfo
.
class
);
JpInverter
jpInverter
=
jpInverterMapper
.
selectOne
(
new
QueryWrapper
<
JpInverter
>().
eq
(
"third_station_id"
,
tanYinInveterInfo
.
getProjectNo
())
...
...
@@ -430,29 +462,20 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
}
jpInverter
.
setBrand
(
tanYinInveterInfoDTO
.
getSupplier
().
toString
());
jpInverter
.
setSnCode
(
tanYinInveterInfo
.
getSn
());
// jpInverter.setId(String.valueOf(goodWeINverterDetailDto.getId()
));
jpInverter
.
setId
(
tanYinInveterInfo
.
getIdString
(
));
jpInverter
.
setThirdStationId
(
tanYinInveterInfo
.
getProjectNo
());
jpInverter
.
setThirdCode
(
PVProducerInfoEnum
.
TANYIN
.
getCode
());
// 0、离线 1、在线 2、异常
if
(
"1"
.
equals
(
tanYinInveterInfoDTO
.
getStatus
()))
{
jpInverter
.
setState
(
"离线"
);
}
else
if
(
"2"
.
equals
(
tanYinInveterInfoDTO
.
getStatus
()))
{
jpInverter
.
setState
(
"异常"
);
}
else
{
jpInverter
.
setState
(
"在线"
);
}
jpInverter
.
setState
(
TanYinConstant
.
stationStatus
.
get
(
tanYinInveterInfoDTO
.
getStatus
()));
jpInverter
.
setRecDate
(
new
Date
());
if
(
tanYinInveterInfoDTO
.
getGmtCreate
()
!=
null
)
{
jpInverter
.
setUpdateTime
(
new
Date
(
Long
.
parseLong
(
tanYinInveterInfoDTO
.
getGmtCreate
())));
}
else
{
jpInverter
.
setUpdateTime
(
new
Date
());
}
jpInverter
.
setUpdateTime
(
tanYinInveterInfoDTO
.
getGmtCreate
()
!=
null
?
new
Date
(
Long
.
parseLong
(
tanYinInveterInfoDTO
.
getGmtCreate
()))
:
new
Date
());
JpStation
jpStation
=
jpStationMap
.
get
(
tanYinInveterInfo
.
getProjectNo
());
if
(
jpStation
!=
null
)
{
jpInverter
.
setDayPowerGeneration
(
jpStation
.
getDayGenerate
());
jpInverter
.
setMonthPowerGeneration
(
jpStation
.
getMonthGenerate
());
jpInverter
.
setYearPowerGeneration
(
jpStation
.
getYearGenerate
());
jpInverter
.
setTotalPowerGeneration
(
jpStation
.
getAccumulatedPower
());
// 逆变器没有就空着
// jpInverter.setDayPowerGeneration(jpStation.getDayGenerate());
// jpInverter.setMonthPowerGeneration(jpStation.getMonthGenerate());
// jpInverter.setYearPowerGeneration(jpStation.getYearGenerate());
// jpInverter.setTotalPowerGeneration(jpStation.getAccumulatedPower());
jpInverter
.
setStationName
(
jpStation
.
getName
());
jpInverter
.
setAddr
(
jpStation
.
getAddress
());
jpInverter
.
setCapacity
(
jpStation
.
getCapacity
());
...
...
@@ -467,53 +490,60 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
}
else
{
jpInverterMapper
.
insert
(
jpInverter
);
}
// for (int k = 1; k < 3; k++) {
// JpInverterElectricity jpInverterElectricity = jpInverterElectricityMapper
// .selectOne(new QueryWrapper<JpInverterElectricity>()
// .eq("sn_code", goodWeInverterCurrentDataDto.getSn()).eq("type", "交流")
// .eq("name", "AC" + k));
// if (org.springframework.util.ObjectUtils.isEmpty(jpInverterElectricity)) {
// jpInverterElectricity = new JpInverterElectricity();
// }
// jpInverterElectricity.setInverterId(jpInverter.getId());
// jpInverterElectricity.setSnCode(goodWeInverterCurrentDataDto.getSn());
// jpInverterElectricity.setThirdCode(PVProducerInfoEnum.TANYIN.getCode());
// jpInverterElectricity.setThirdStationId(jpInverter.getThirdStationId());
// jpInverterElectricity.setType("交流");
// jpInverterElectricity.setName("AC" + k);
// jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("vac" + k).toString()));
// jpInverterElectricity.setCurrent(Double.valueOf(hanlderResult.get("iac" + k).toString()));
// if (org.springframework.util.ObjectUtils.isEmpty(jpInverterElectricity.getSequenceNbr())) {
// jpInverterElectricityMapper.insert(jpInverterElectricity);
// } else {
// jpInverterElectricityMapper.updateById(jpInverterElectricity);
// }
// }
//
// for (int k1 = 1; k1 < 4; k1++) {
// JpInverterElectricity jpInverterElectricity = jpInverterElectricityMapper
// .selectOne(new QueryWrapper<JpInverterElectricity>()
// .eq("sn_code", goodWeInverterCurrentDataDto.getSn()).eq("type", "直流")
// .eq("name", "PV" + k1));
// if (org.springframework.util.ObjectUtils.isEmpty(jpInverterElectricity)) {
// jpInverterElectricity = new JpInverterElectricity();
// }
// jpInverterElectricity.setInverterId(jpInverter.getId());
// jpInverterElectricity.setSnCode(goodWeInverterCurrentDataDto.getSn());
// jpInverterElectricity.setThirdCode(PVProducerInfoEnum.TANYIN.getCode());
// jpInverterElectricity.setThirdStationId(jpInverter.getThirdStationId());
// jpInverterElectricity.setType("直流");
// jpInverterElectricity.setName("PV" + k1);
// jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("vpv" + k1).toString()));
// jpInverterElectricity.setCurrent(Double.valueOf(hanlderResult.get("ipv" + k1).toString()));
// // jpInverterElectricity.setPower(Double.valueOf(hanlderResult.get("pow" + k1).toString()));
// if (org.springframework.util.ObjectUtils.isEmpty(jpInverterElectricity.getSequenceNbr())) {
// jpInverterElectricityMapper.insert(jpInverterElectricity);
// } else {
// jpInverterElectricityMapper.updateById(jpInverterElectricity);
// }
// }
// 解析电站逆变器信息
// 确认先按照 vol1, amp1 这样入库
for
(
int
k
=
0
;
k
<=
15
;
k
++)
{
String
name
=
"vol"
+
k
;
JpInverterElectricity
jpInverterElectricity
=
jpInverterElectricityMapper
.
selectOne
(
new
QueryWrapper
<
JpInverterElectricity
>()
.
eq
(
"sn_code"
,
tanYinInveterInfoDTO
.
getSn
())
.
eq
(
"name"
,
name
));
if
(
org
.
springframework
.
util
.
ObjectUtils
.
isEmpty
(
jpInverterElectricity
))
{
jpInverterElectricity
=
new
JpInverterElectricity
();
}
jpInverterElectricity
.
setInverterId
(
jpInverter
.
getId
());
jpInverterElectricity
.
setSnCode
(
tanYinInveterInfoDTO
.
getSn
());
jpInverterElectricity
.
setThirdCode
(
PVProducerInfoEnum
.
TANYIN
.
getCode
());
jpInverterElectricity
.
setThirdStationId
(
jpInverter
.
getThirdStationId
());
// jpInverterElectricity.setType("交流");
jpInverterElectricity
.
setName
(
name
);
if
(
tanYinInveterInfoResultJson
.
get
(
name
)
!=
null
&&
!
""
.
equals
(
tanYinInveterInfoResultJson
.
get
(
name
)))
{
jpInverterElectricity
.
setVoltage
(
Double
.
valueOf
(
tanYinInveterInfoResultJson
.
get
(
name
).
toString
()));
// 电压
}
// jpInverterElectricity.setCurrent(Double.valueOf(hanlderResult.get("amp" + k).toString()));// 电流
if
(
org
.
springframework
.
util
.
ObjectUtils
.
isEmpty
(
jpInverterElectricity
.
getSequenceNbr
()))
{
jpInverterElectricityMapper
.
insert
(
jpInverterElectricity
);
}
else
{
jpInverterElectricityMapper
.
updateById
(
jpInverterElectricity
);
}
}
for
(
int
n
=
0
;
n
<
15
;
n
++)
{
String
name
=
"amp"
+
n
;
JpInverterElectricity
jpInverterElectricity
=
jpInverterElectricityMapper
.
selectOne
(
new
QueryWrapper
<
JpInverterElectricity
>()
.
eq
(
"sn_code"
,
tanYinInveterInfoDTO
.
getSn
())
.
eq
(
"name"
,
name
));
if
(
org
.
springframework
.
util
.
ObjectUtils
.
isEmpty
(
jpInverterElectricity
))
{
jpInverterElectricity
=
new
JpInverterElectricity
();
}
jpInverterElectricity
.
setInverterId
(
jpInverter
.
getId
());
jpInverterElectricity
.
setSnCode
(
tanYinInveterInfoDTO
.
getSn
());
jpInverterElectricity
.
setThirdCode
(
PVProducerInfoEnum
.
TANYIN
.
getCode
());
jpInverterElectricity
.
setThirdStationId
(
jpInverter
.
getThirdStationId
());
// jpInverterElectricity.setType("直流");
jpInverterElectricity
.
setName
(
name
);
// jpInverterElectricity.setVoltage(Double.valueOf(hanlderResult.get("vpv" + k1).toString()));
if
(
tanYinInveterInfoResultJson
.
get
(
name
)
!=
null
&&
!
""
.
equals
(
tanYinInveterInfoResultJson
.
get
(
name
)))
{
jpInverterElectricity
.
setCurrent
(
Double
.
valueOf
(
tanYinInveterInfoResultJson
.
get
(
name
).
toString
()));
}
// jpInverterElectricity.setPower(Double.valueOf(hanlderResult.get("pow" + k1).toString()));
if
(
org
.
springframework
.
util
.
ObjectUtils
.
isEmpty
(
jpInverterElectricity
.
getSequenceNbr
()))
{
jpInverterElectricityMapper
.
insert
(
jpInverterElectricity
);
}
else
{
jpInverterElectricityMapper
.
updateById
(
jpInverterElectricity
);
}
}
HYGFJPInverterElecHistory
hygfjpInverterElecHistory
=
new
HYGFJPInverterElecHistory
();
hygfjpInverterElecHistory
.
setThirdStationId
(
jpInverter
.
getThirdStationId
());
...
...
@@ -562,37 +592,6 @@ public class TanYinDataAcquisitionServiceImpl implements TanYinDataAcquisitionSe
tdHYGFInverterDayGenerate
.
setThirdStationId
(
String
.
valueOf
(
jpInverter
.
getThirdStationId
()));
tdHYGFInverterDayGenerate
.
setSnCode
(
jpInverter
.
getSnCode
().
trim
());
tdHYGFInverterDayGenerate
.
setWorkStatus
(
jpInverter
.
getState
());
// D d = goodWeInverterCurrentDataDto.getD();
// // 交流电压
// tdHYGFInverterDayGenerate.setDcv1(d.getVac1());
// tdHYGFInverterDayGenerate.setDcv2(d.getVac2());
// tdHYGFInverterDayGenerate.setDcv3(d.getVac3());
// // 交流电流
// // tdHYGFInverterDayGenerate.setDcv4(inverterDetailDto.getUAc4());
// tdHYGFInverterDayGenerate.setDcc1(d.getIac1());
// tdHYGFInverterDayGenerate.setDcc2(d.getIac2());
// tdHYGFInverterDayGenerate.setDcc3(d.getIac3());
// // tdHYGFInverterDayGenerate.setDcc4(inverterDetailDto.getIAc4());
// // 直流电压
// tdHYGFInverterDayGenerate.setAcv1(d.getVpv1());
// tdHYGFInverterDayGenerate.setAcv2(d.getVpv2());
// tdHYGFInverterDayGenerate.setAcv3(d.getVpv3());
// tdHYGFInverterDayGenerate.setAcv4(d.getVpv4());
// // 直流电流
// tdHYGFInverterDayGenerate.setAcc1(d.getIpv1());
// tdHYGFInverterDayGenerate.setAcc2(d.getIpv2());
// tdHYGFInverterDayGenerate.setAcc3(d.getIpv3());
// tdHYGFInverterDayGenerate.setAcc4(d.getIpv4());
// 功率
// tdHYGFInverterDayGenerate.setPv1(inverterDetailDto.getPow1());
// tdHYGFInverterDayGenerate.setPv2(inverterDetailDto.getPow2());
// tdHYGFInverterDayGenerate.setPv3(inverterDetailDto.getPow3());
// tdHYGFInverterDayGenerate.setPv4(inverterDetailDto.getPow4());
// tdHYGFInverterDayGenerate.setTotalPower(inverterDetailDto.getPac());
// tdHYGFInverterDayGenerate.setFrequency(String.valueOf(inverterDetailDto.getFac()));
// tdHYGFInverterDayGenerate.setPowerFactor(inverterDetailDto.getPowerFactor());
tdHYGFInverterDayGenerate
.
setDayGen
(
jpInverter
.
getDayPowerGeneration
());
tdHYGFInverterDayGenerate
.
setMonthGen
(
jpInverter
.
getMonthPowerGeneration
());
...
...
amos-boot-data/amos-boot-data-housepvapi/src/main/resources/application-dev.properties
View file @
1dff0a2b
...
...
@@ -72,4 +72,10 @@ dataRequstScheduled.keshida=0 0/50 * * * *
dataRequstScheduled.Sunlight
=
0 0/50 * * * *
dataRequstScheduled.GoodWe
=
0 0/3 * * * *
dataRequstScheduled.Sofar
=
0 0/50 * * * *
\ No newline at end of file
dataRequstScheduled.Sofar
=
0 0/50 * * * *
# 碳银
tanYin.api.apiUrl
=
https://userauth.tanwin.cn
tanYin.api.clientSecret
=
rKrWVa2sXsSZeNAOW43v
tanYin.api.clientKey
=
yx10001
dataRequestScheduled.tanYin
=
0 0/10 * * * *
\ 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