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
e0d20c9d
Commit
e0d20c9d
authored
Jul 08, 2024
by
lilongyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、获取并网容量接口的片区数据获取改为从本地获取
2、获取片区指标完成情况接口的片区数据获取改为从本地获取,并与调用外部接口的数据对比汇总
parent
8a58c918
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
34 deletions
+83
-34
EnergyAccessController.java
...t/module/jxiop/biz/controller/EnergyAccessController.java
+1
-1
EnergyAccessService.java
...os/boot/module/jxiop/biz/service/EnergyAccessService.java
+1
-1
EnergyAccessServiceImpl.java
...odule/jxiop/biz/service/impl/EnergyAccessServiceImpl.java
+81
-32
No files found.
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/controller/EnergyAccessController.java
View file @
e0d20c9d
...
@@ -37,7 +37,7 @@ public class EnergyAccessController extends BaseController {
...
@@ -37,7 +37,7 @@ public class EnergyAccessController extends BaseController {
@RequestMapping
(
value
=
"/getQuotaCompleteInfo"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/getQuotaCompleteInfo"
,
method
=
RequestMethod
.
GET
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"获取片区指标完成情况"
,
notes
=
"获取片区指标完成情况"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"获取片区指标完成情况"
,
notes
=
"获取片区指标完成情况"
)
public
ResponseModel
<
Page
<
Map
<
String
,
Object
>>>
getQuotaCompleteInfo
(
String
current
,
String
pageSize
,
String
code
,
String
sourceStationId
,
String
tp
)
{
public
ResponseModel
<
Page
<
Map
<
String
,
Object
>>>
getQuotaCompleteInfo
(
String
current
,
String
pageSize
,
String
code
,
String
sourceStationId
,
String
tp
)
{
logger
.
info
(
"获取片区指标完成情况入参:current ={},pageSize ={},code = {},sourceStationId = {},tp = {}"
,
current
,
pageSize
,
code
,
sourceStationId
,
tp
);
logger
.
info
(
"获取片区指标完成情况入参:current ={},pageSize ={},code = {},sourceStationId = {},tp = {}"
,
current
,
pageSize
,
code
,
sourceStationId
,
tp
);
return
ResponseHelper
.
buildResponse
(
energyAccessServiceImpl
.
getQuotaCompleteInfo
(
current
,
pageSize
,
code
,
sourceStationId
,
tp
));
return
ResponseHelper
.
buildResponse
(
energyAccessServiceImpl
.
getQuotaCompleteInfo
(
current
,
pageSize
,
code
,
sourceStationId
,
tp
));
}
}
...
...
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/EnergyAccessService.java
View file @
e0d20c9d
...
@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...
@@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
java.util.Map
;
import
java.util.Map
;
public
interface
EnergyAccessService
{
public
interface
EnergyAccessService
{
Page
<
Map
<
String
,
Object
>>
getInstalledCapacity
(
String
current
,
String
pageSize
,
String
code
,
String
sourceStationId
,
String
tp
);
Page
<
Map
<
String
,
Object
>>
getInstalledCapacity
(
String
current
,
String
pageSize
,
String
code
,
String
sourceStationId
,
String
tp
)
throws
Exception
;
Page
<
Map
<
String
,
Object
>>
getQuotaCompleteInfo
(
String
current
,
String
pageSize
,
String
code
,
String
sourceStationId
,
String
tp
);
Page
<
Map
<
String
,
Object
>>
getQuotaCompleteInfo
(
String
current
,
String
pageSize
,
String
code
,
String
sourceStationId
,
String
tp
);
}
}
amos-boot-system-jxiop/amos-boot-module-jxiop-bigscreen-biz/src/main/java/com/yeejoin/amos/boot/module/jxiop/biz/service/impl/EnergyAccessServiceImpl.java
View file @
e0d20c9d
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jxiop
.
biz
.
service
.
impl
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.boot.module.jxiop.api.util.Constants
;
import
com.yeejoin.amos.boot.module.jxiop.api.util.Constants
;
import
com.yeejoin.amos.boot.module.jxiop.api.util.HttpRequestUtil
;
import
com.yeejoin.amos.boot.module.jxiop.api.util.HttpRequestUtil
;
import
com.yeejoin.amos.boot.module.jxiop.api.mapper.EnergyAccessMapper
;
import
com.yeejoin.amos.boot.module.jxiop.biz.service.EnergyAccessService
;
import
com.yeejoin.amos.boot.module.jxiop.biz.service.EnergyAccessService
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -15,9 +18,8 @@ import org.springframework.util.CollectionUtils;
...
@@ -15,9 +18,8 @@ import org.springframework.util.CollectionUtils;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.format.DateTimeFormatter
;
import
java.time.format.DateTimeFormatter
;
import
java.util.Arrays
;
import
java.util.*
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.Map
;
@Service
@Service
public
class
EnergyAccessServiceImpl
implements
EnergyAccessService
{
public
class
EnergyAccessServiceImpl
implements
EnergyAccessService
{
...
@@ -25,10 +27,23 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
...
@@ -25,10 +27,23 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
@Autowired
@Autowired
private
HttpRequestUtil
httpRequestUtil
;
private
HttpRequestUtil
httpRequestUtil
;
@Autowired
EnergyAccessMapper
energyAccessMapper
;
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EnergyAccessServiceImpl
.
class
);
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
EnergyAccessServiceImpl
.
class
);
@Override
@Override
public
Page
<
Map
<
String
,
Object
>>
getInstalledCapacity
(
String
current
,
String
pageSize
,
String
code
,
String
sourceStationId
,
String
tp
)
{
public
Page
<
Map
<
String
,
Object
>>
getInstalledCapacity
(
String
current
,
String
pageSize
,
String
code
,
String
sourceStationId
,
String
tp
)
{
if
(
StringUtils
.
isEmpty
(
tp
))
{
logger
.
error
(
"参数tp不能为空"
);
throw
new
RuntimeException
(
"参数tp不能为空"
);
}
List
<
Map
<
String
,
Object
>>
returnList
;
if
(
"1"
.
equals
(
tp
))
{
returnList
=
energyAccessMapper
.
getStationInfo
(
code
);
logger
.
info
(
"获取并网容量接口查询本地返回结果:{}"
,
returnList
.
toString
());
}
else
{
//改为部盾接口
//改为部盾接口
StringBuilder
requestUrl
=
new
StringBuilder
(
Constants
.
BASE_URL
).
append
(
"?"
).
append
(
Constants
.
get_station_actual_installed_capacity
);
StringBuilder
requestUrl
=
new
StringBuilder
(
Constants
.
BASE_URL
).
append
(
"?"
).
append
(
Constants
.
get_station_actual_installed_capacity
);
if
(
StringUtils
.
isNotEmpty
(
code
))
{
if
(
StringUtils
.
isNotEmpty
(
code
))
{
...
@@ -44,16 +59,21 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
...
@@ -44,16 +59,21 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
}
}
JSONObject
data
=
httpRequestUtil
.
getResPonse
(
requestUrl
.
toString
(),
Constants
.
REQUEST_GET
,
""
,
JSONObject
data
=
httpRequestUtil
.
getResPonse
(
requestUrl
.
toString
(),
Constants
.
REQUEST_GET
,
""
,
Constants
.
resovleRule_data
);
Constants
.
resovleRule_data
);
returnList
=
JSONArray
.
parseObject
(
data
.
getJSONArray
(
"data"
).
toJSONString
(),
new
TypeReference
<
List
<
Map
<
String
,
Object
>>>()
{});
List
returnList
=
data
.
getJSONArray
(
"data"
);
logger
.
info
(
"获取并网容量接口调用对端返回结果:{}"
,
returnList
.
toString
()
);
logger
.
info
(
"获取并网容量接口调用对端返回结果:{}"
,
returnList
.
toString
());
}
Page
<
Map
<
String
,
Object
>>
pageIPage
;
Page
<
Map
<
String
,
Object
>>
pageIPage
;
returnList
.
forEach
(
result
->
{
returnList
.
forEach
(
jsonObject
->
{
JSONObject
jsonObject
=
(
JSONObject
)
result
;
String
actualInstalledCapacity
;
String
actualInstalledCapacity
=
jsonObject
.
getString
(
"actual_installed_capacity"
);
if
(
"1"
.
equals
(
tp
))
{
actualInstalledCapacity
=
String
.
valueOf
(
jsonObject
.
get
(
"installed_capacity"
));
}
else
{
actualInstalledCapacity
=
String
.
valueOf
(
jsonObject
.
get
(
"actual_installed_capacity"
));
}
if
(
StringUtils
.
isNotEmpty
(
actualInstalledCapacity
))
{
if
(
StringUtils
.
isNotEmpty
(
actualInstalledCapacity
))
{
BigDecimal
bd
=
new
BigDecimal
(
actualInstalledCapacity
);
BigDecimal
bd
=
new
BigDecimal
(
actualInstalledCapacity
);
jsonObject
.
put
(
"actual_installed_capacity"
,
bd
.
setScale
(
4
,
BigDecimal
.
ROUND_HALF_UP
));
jsonObject
.
put
(
"actual_installed_capacity"
,
bd
.
setScale
(
4
,
BigDecimal
.
ROUND_HALF_UP
));
}
}
});
});
int
newCurrent
=
Integer
.
parseInt
(
current
);
int
newCurrent
=
Integer
.
parseInt
(
current
);
...
@@ -75,7 +95,7 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
...
@@ -75,7 +95,7 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
}
else
{
}
else
{
pageIPage
.
setRecords
(
returnList
.
subList
(((
newCurrent
-
1
)
*
newPageSize
),
returnList
.
size
()));
pageIPage
.
setRecords
(
returnList
.
subList
(((
newCurrent
-
1
)
*
newPageSize
),
returnList
.
size
()));
}
}
logger
.
info
(
"获取并网容量接口最终返回结果:{}"
,
pageIPage
.
getRecords
());
logger
.
info
(
"获取并网容量接口最终返回结果:{}"
,
pageIPage
.
getRecords
());
return
pageIPage
;
return
pageIPage
;
}
}
...
@@ -101,8 +121,38 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
...
@@ -101,8 +121,38 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
JSONObject
data
=
httpRequestUtil
.
getResPonse
(
requestUrl
.
toString
(),
Constants
.
REQUEST_GET
,
""
,
JSONObject
data
=
httpRequestUtil
.
getResPonse
(
requestUrl
.
toString
(),
Constants
.
REQUEST_GET
,
""
,
Constants
.
resovleRule_data
);
Constants
.
resovleRule_data
);
List
returnList
=
data
.
getJSONArray
(
"data"
);
List
<
Map
<
String
,
Object
>>
returnList
=
JSONArray
.
parseObject
(
data
.
getJSONArray
(
"data"
).
toJSONString
(),
new
TypeReference
<
List
<
Map
<
String
,
Object
>>>()
{});
logger
.
info
(
"获取片区指标完成情况调用对端返回结果:{}"
,
returnList
.
toString
());
logger
.
info
(
"获取片区指标完成情况调用对端返回结果:{}"
,
returnList
.
toString
());
List
<
Map
<
String
,
Object
>>
finalList
=
new
ArrayList
<>();
//tp=1,代表是根据片区查询,需要根据本地查询的结果数据取交集
if
(
"1"
.
equals
(
tp
))
{
List
<
Map
<
String
,
Object
>>
currentList
=
energyAccessMapper
.
getStationInfo
(
code
);
logger
.
info
(
"获取片区指标完成情况查询本地返回结果:{}"
,
currentList
.
toString
());
if
(!
CollectionUtils
.
isEmpty
(
currentList
)){
finalList
=
currentList
.
stream
().
map
(
e1
->
returnList
.
stream
()
.
filter
(
e2
->
e1
.
get
(
"station_name"
).
equals
(
e2
.
get
(
"station_name"
)))
.
findFirst
()
.
map
(
e2
->
{
e1
.
put
(
"name"
,
String
.
valueOf
(
e2
.
get
(
"station_name"
)));
e1
.
put
(
"quota"
,
String
.
valueOf
(
e2
.
get
(
"quota"
)));
e1
.
put
(
"generating_capacity"
,
e2
.
get
(
"generating_capacity"
));
e1
.
put
(
"rate"
,
String
.
valueOf
(
e2
.
get
(
"rate"
)));
return
e1
;
}).
orElseGet
(()
->
{
e1
.
put
(
"name"
,
e1
.
get
(
"station_name"
));
e1
.
put
(
"quota"
,
"0"
);
e1
.
put
(
"generating_capacity"
,
"0"
);
e1
.
put
(
"rate"
,
"0"
);
return
e1
;
})
).
collect
(
Collectors
.
toList
());
}
}
else
{
finalList
.
addAll
(
returnList
);
}
//rate的值去掉百分号,名称字段名统一用name代替
//rate的值去掉百分号,名称字段名统一用name代替
Page
<
Map
<
String
,
Object
>>
pageIPage
;
Page
<
Map
<
String
,
Object
>>
pageIPage
;
int
newCurrent
=
Integer
.
parseInt
(
current
);
int
newCurrent
=
Integer
.
parseInt
(
current
);
...
@@ -112,52 +162,51 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
...
@@ -112,52 +162,51 @@ public class EnergyAccessServiceImpl implements EnergyAccessService {
}
else
{
}
else
{
pageIPage
=
new
Page
<>(
newCurrent
,
newPageSize
);
pageIPage
=
new
Page
<>(
newCurrent
,
newPageSize
);
}
}
if
(
CollectionUtils
.
isEmpty
(
return
List
))
{
if
(
CollectionUtils
.
isEmpty
(
final
List
))
{
return
pageIPage
;
return
pageIPage
;
}
}
return
List
.
forEach
(
result
->
{
final
List
.
forEach
(
result
->
{
String
oldName
=
""
;
String
oldName
=
""
;
JSONObject
jsonObject
=
(
JSONObject
)
result
;
String
rate
=
String
.
valueOf
(
result
.
get
(
"rate"
));
String
rate
=
jsonObject
.
getString
(
"rate"
);
String
newRate
=
""
;
String
newRate
=
""
;
if
(
StringUtils
.
isNotEmpty
(
rate
))
{
if
(
StringUtils
.
isNotEmpty
(
rate
))
{
newRate
=
rate
.
replace
(
"%"
,
""
);
newRate
=
rate
.
replace
(
"%"
,
""
);
BigDecimal
bd
=
new
BigDecimal
(
newRate
);
BigDecimal
bd
=
new
BigDecimal
(
newRate
);
jsonObject
.
put
(
"rate"
,
bd
.
setScale
(
4
,
BigDecimal
.
ROUND_HALF_UP
));
result
.
put
(
"rate"
,
bd
.
setScale
(
4
,
BigDecimal
.
ROUND_HALF_UP
));
}
}
String
quota
=
jsonObject
.
getString
(
"quota"
);
String
quota
=
String
.
valueOf
(
result
.
get
(
"quota"
)
);
if
(
StringUtils
.
isNotEmpty
(
quota
))
{
if
(
StringUtils
.
isNotEmpty
(
quota
))
{
BigDecimal
bd
=
new
BigDecimal
(
quota
);
BigDecimal
bd
=
new
BigDecimal
(
quota
);
jsonObject
.
put
(
"quota"
,
bd
.
setScale
(
4
,
BigDecimal
.
ROUND_HALF_UP
));
result
.
put
(
"quota"
,
bd
.
setScale
(
4
,
BigDecimal
.
ROUND_HALF_UP
));
}
}
String
generatingCapacity
=
jsonObject
.
getString
(
"generating_capacity"
);
String
generatingCapacity
=
String
.
valueOf
(
result
.
get
(
"generating_capacity"
)
);
if
(
StringUtils
.
isNotEmpty
(
generatingCapacity
))
{
if
(
StringUtils
.
isNotEmpty
(
generatingCapacity
))
{
BigDecimal
bd
=
new
BigDecimal
(
generatingCapacity
);
BigDecimal
bd
=
new
BigDecimal
(
generatingCapacity
);
jsonObject
.
put
(
"generating_capacity"
,
bd
.
setScale
(
4
,
BigDecimal
.
ROUND_HALF_UP
));
result
.
put
(
"generating_capacity"
,
bd
.
setScale
(
4
,
BigDecimal
.
ROUND_HALF_UP
));
}
}
jsonObject
.
put
(
"seriesData"
,
StringUtils
.
isNotEmpty
(
newRate
)
?
Arrays
.
asList
(
new
BigDecimal
(
newRate
).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_UP
))
:
0
D
);
result
.
put
(
"seriesData"
,
StringUtils
.
isNotEmpty
(
newRate
)
?
Arrays
.
asList
(
new
BigDecimal
(
newRate
).
setScale
(
4
,
BigDecimal
.
ROUND_HALF_UP
))
:
0
D
);
jsonObjec
t
.
put
(
"axisData"
,
Arrays
.
asList
(
"RATE"
));
resul
t
.
put
(
"axisData"
,
Arrays
.
asList
(
"RATE"
));
if
(
"1"
.
equals
(
tp
))
{
if
(
"1"
.
equals
(
tp
))
{
oldName
=
jsonObject
.
getString
(
"station_name"
);
oldName
=
String
.
valueOf
(
result
.
get
(
"station_name"
)
);
jsonObjec
t
.
remove
(
"station_name"
);
resul
t
.
remove
(
"station_name"
);
}
else
{
}
else
{
oldName
=
jsonObject
.
getString
(
"area_name"
);
oldName
=
String
.
valueOf
(
result
.
get
(
"area_name"
)
);
jsonObjec
t
.
remove
(
"area_name"
);
resul
t
.
remove
(
"area_name"
);
}
}
jsonObjec
t
.
put
(
"name"
,
oldName
);
resul
t
.
put
(
"name"
,
oldName
);
});
});
pageIPage
.
setTotal
(
returnList
.
size
());
pageIPage
.
setTotal
(
returnList
.
size
());
int
endIndex
=
newCurrent
*
newPageSize
;
int
endIndex
=
newCurrent
*
newPageSize
;
if
(
returnList
.
size
()
>
endIndex
)
{
if
(
returnList
.
size
()
>
endIndex
)
{
pageIPage
.
setRecords
(
return
List
.
subList
(((
newCurrent
-
1
)
*
newPageSize
),
endIndex
));
pageIPage
.
setRecords
(
final
List
.
subList
(((
newCurrent
-
1
)
*
newPageSize
),
endIndex
));
}
else
{
}
else
{
pageIPage
.
setRecords
(
return
List
.
subList
(((
newCurrent
-
1
)
*
newPageSize
),
returnList
.
size
()));
pageIPage
.
setRecords
(
final
List
.
subList
(((
newCurrent
-
1
)
*
newPageSize
),
returnList
.
size
()));
}
}
logger
.
info
(
"获取片区指标完成情况最终返回结果:{}"
,
pageIPage
.
getRecords
());
logger
.
info
(
"获取片区指标完成情况最终返回结果:{}"
,
pageIPage
.
getRecords
());
return
pageIPage
;
return
pageIPage
;
}
}
}
}
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