Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
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
quanku
qk_backend
Commits
d26b049b
Commit
d26b049b
authored
Sep 14, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
平均价格
parent
1c326896
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
ch-core/src/main/java/com/wwdz/ch/core/entity/Chart.java
ch-core/src/main/java/com/wwdz/ch/core/entity/Chart.java
+1
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/QueryPriceServiceImpl.java
.../main/java/com/wwdz/ch/wx/impl/QueryPriceServiceImpl.java
+13
-4
No files found.
ch-core/src/main/java/com/wwdz/ch/core/entity/Chart.java
View file @
d26b049b
...
@@ -9,5 +9,5 @@ public class Chart implements Entity {
...
@@ -9,5 +9,5 @@ public class Chart implements Entity {
private
List
<
String
>
xData
;
private
List
<
String
>
xData
;
private
List
<
Object
>
values
;
private
List
<
Double
>
values
;
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/QueryPriceServiceImpl.java
View file @
d26b049b
...
@@ -69,7 +69,7 @@ public class QueryPriceServiceImpl implements QueryPriceService {
...
@@ -69,7 +69,7 @@ public class QueryPriceServiceImpl implements QueryPriceService {
dto
.
setEndBidTime
(
nowMills
);
dto
.
setEndBidTime
(
nowMills
);
List
<
BidRecord
>
bidRecordList
=
bidRecordDao
.
queryByCid
(
dto
);
List
<
BidRecord
>
bidRecordList
=
bidRecordDao
.
queryByCid
(
dto
);
List
<
String
>
xData
=
new
ArrayList
<>();
List
<
String
>
xData
=
new
ArrayList
<>();
List
<
Object
>
valueList
=
new
ArrayList
<>();
List
<
Double
>
valueList
=
new
ArrayList
<>();
double
totalPrice
=
0
;
double
totalPrice
=
0
;
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"details"
,
CategoryVo
.
of
(
category
));
map
.
put
(
"details"
,
CategoryVo
.
of
(
category
));
...
@@ -81,12 +81,21 @@ public class QueryPriceServiceImpl implements QueryPriceService {
...
@@ -81,12 +81,21 @@ public class QueryPriceServiceImpl implements QueryPriceService {
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd"
);
String
time
=
date
.
format
(
formatter
);
String
time
=
date
.
format
(
formatter
);
xData
.
add
(
time
);
xData
.
add
(
time
);
totalPrice
+=
(
bidRecord
.
getPrice
()
/
(
double
)
100
);
//
totalPrice += (bidRecord.getPrice() / (double)100);
valueList
.
add
(
bidRecord
.
getPrice
()
/
(
double
)
100
/
(
double
)
10000
);
valueList
.
add
(
bidRecord
.
getPrice
()
/
(
double
)
100
/
(
double
)
10000
);
}
}
double
averagePrice
=
0
;
double
averagePrice
=
0
;
int
maxTimeNum
=
0
;
if
(!
CollectionUtils
.
isEmpty
(
bidRecordList
))
{
if
(!
CollectionUtils
.
isEmpty
(
bidRecordList
))
{
averagePrice
=
totalPrice
/
bidRecordList
.
size
();
String
maxTime
=
xData
.
get
(
xData
.
size
()
-
1
);
for
(
int
i
=
0
;
i
<
xData
.
size
();
i
++)
{
if
(
xData
.
get
(
i
).
equals
(
maxTime
))
{
maxTimeNum
=
maxTimeNum
+
1
;
totalPrice
+=
valueList
.
get
(
i
);
}
}
averagePrice
=
totalPrice
/
maxTimeNum
;
map
.
put
(
"averagePrice"
,
StringUtil
.
formatAmount
(
String
.
valueOf
(
Math
.
round
(
averagePrice
*
10000
))));
Instant
instant
=
Instant
.
ofEpochSecond
(
bidRecordList
.
get
(
bidRecordList
.
size
()
-
1
).
getBidTime
());
Instant
instant
=
Instant
.
ofEpochSecond
(
bidRecordList
.
get
(
bidRecordList
.
size
()
-
1
).
getBidTime
());
LocalDateTime
date
=
LocalDateTime
.
ofInstant
(
instant
,
ZoneId
.
systemDefault
());
LocalDateTime
date
=
LocalDateTime
.
ofInstant
(
instant
,
ZoneId
.
systemDefault
());
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy年MM月dd日"
);
DateTimeFormatter
formatter
=
DateTimeFormatter
.
ofPattern
(
"yyyy年MM月dd日"
);
...
@@ -96,7 +105,7 @@ public class QueryPriceServiceImpl implements QueryPriceService {
...
@@ -96,7 +105,7 @@ public class QueryPriceServiceImpl implements QueryPriceService {
chart
.
setXData
(
xData
);
chart
.
setXData
(
xData
);
chart
.
setValues
(
valueList
);
chart
.
setValues
(
valueList
);
map
.
put
(
"chart"
,
chart
);
map
.
put
(
"chart"
,
chart
);
map
.
put
(
"averagePrice"
,
StringUtil
.
formatAmount
(
String
.
valueOf
(
Math
.
round
(
averagePrice
))));
return
Result
.
success
(
map
);
return
Result
.
success
(
map
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"查询类目价格详情失败:{}"
,
e
);
logger
.
error
(
"查询类目价格详情失败:{}"
,
e
);
...
...
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