Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gf_back
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tianchao
gf_back
Commits
05b7d202
Commit
05b7d202
authored
Sep 18, 2023
by
ZWT
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
45be9b6d
d48500b6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
C12-prediction/pps-core-prediction/src/main/java/pps/core/prediction/service/PlantPredictedPowerDataService.java
...re/prediction/service/PlantPredictedPowerDataService.java
+38
-0
No files found.
C12-prediction/pps-core-prediction/src/main/java/pps/core/prediction/service/PlantPredictedPowerDataService.java
View file @
05b7d202
...
...
@@ -14,6 +14,7 @@ import xstartup.base.util.XStringUtils;
import
xstartup.data.XListResult
;
import
xstartup.feature.api.annotation.XApiGet
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
java.util.List
;
...
...
@@ -68,4 +69,41 @@ public class PlantPredictedPowerDataService {
});
return
XListResult
.
success
(
outputs
);
}
@XApiGet
@XText
(
"根据电站预测30天的预测数据"
)
public
XListResult
<
GetPlantPredictedPowerDataOutput
>
getThirtyPlantPredictedPowerData
(
XContext
context
,
GetPlantPredictedPowerDataInput
input
){
//今年(7天总值)/去年(7天的总值) 同比值
PlantPredictedPowerDataMapper
mapper
=
context
.
getBean
(
PlantPredictedPowerDataMapper
.
class
);
Date
date
=
new
Date
();
QueryWrapper
<
PlantPredictedPowerDataEnt
>
queryWrapper
=
new
QueryWrapper
<>();
queryWrapper
.
select
(
" IFNULL(avg(power ) , 0 ) power"
);
queryWrapper
.
lambda
().
eq
(
PlantPredictedPowerDataEnt:
:
getPlantId
,
input
.
getPlantId
());
queryWrapper
.
lambda
().
ge
(
PlantPredictedPowerDataEnt:
:
getDataDate
,
date
);
queryWrapper
.
lambda
().
le
(
PlantPredictedPowerDataEnt:
:
getDataDate
,
XDateUtils
.
addDays
(
date
,
7
));
PlantPredictedPowerDataEnt
currentData
=
mapper
.
selectOne
(
queryWrapper
);
queryWrapper
.
clear
();
queryWrapper
.
select
(
" IFNULL(avg(power ) , 0 ) power"
);
queryWrapper
.
lambda
().
eq
(
PlantPredictedPowerDataEnt:
:
getPlantId
,
input
.
getPlantId
());
queryWrapper
.
lambda
().
ge
(
PlantPredictedPowerDataEnt:
:
getDataDate
,
XDateUtils
.
addDays
(
date
,
-
365
));
queryWrapper
.
lambda
().
le
(
PlantPredictedPowerDataEnt:
:
getDataDate
,
XDateUtils
.
addDays
(
date
,
-
358
));
PlantPredictedPowerDataEnt
lastData
=
mapper
.
selectOne
(
queryWrapper
);
BigDecimal
compare
=
new
BigDecimal
(
1
);
if
(
lastData
.
getPower
().
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
compare
=
currentData
.
getPower
().
divide
(
lastData
.
getPower
()
,
6
,
BigDecimal
.
ROUND_HALF_UP
);
queryWrapper
.
clear
();
queryWrapper
.
select
(
" data_date , power "
);
queryWrapper
.
lambda
().
eq
(
PlantPredictedPowerDataEnt:
:
getPlantId
,
input
.
getPlantId
());
queryWrapper
.
lambda
().
ge
(
PlantPredictedPowerDataEnt:
:
getDataDate
,
XDateUtils
.
addDays
(
date
,
-
365
));
queryWrapper
.
lambda
().
le
(
PlantPredictedPowerDataEnt:
:
getDataDate
,
XDateUtils
.
addDays
(
date
,
-
335
));
List
<
PlantPredictedPowerDataEnt
>
lastList
=
mapper
.
selectList
(
queryWrapper
);
//获取去年30天的数据,预测今年30天的数据
List
<
GetPlantPredictedPowerDataOutput
>
outputs
=
XCopyUtils
.
copyNewList
(
lastList
,
GetPlantPredictedPowerDataOutput
.
class
);
for
(
GetPlantPredictedPowerDataOutput
item
:
outputs
){
item
.
setPredictedPower
(
item
.
getPower
().
multiply
(
compare
));
item
.
setDataDate
(
XDateUtils
.
getString
(
XDateUtils
.
addDays
(
XDateUtils
.
parse
(
item
.
getDataDate
())
,
365
)));
}
return
XListResult
.
success
(
outputs
);
}
}
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