update 修复sql查询过长,cpu占用过高问题
This commit is contained in:
@@ -78,11 +78,14 @@ public class RealPowerInsetTask {
|
|||||||
public List<ProductMachineDto> getRealPower(String coin){
|
public List<ProductMachineDto> getRealPower(String coin){
|
||||||
List<LeaseProductMachine> leaseProductMachines = leaseProductMachineMapper.selectList(new LambdaQueryWrapper<LeaseProductMachine>()
|
List<LeaseProductMachine> leaseProductMachines = leaseProductMachineMapper.selectList(new LambdaQueryWrapper<LeaseProductMachine>()
|
||||||
.eq(LeaseProductMachine::getDel, false));
|
.eq(LeaseProductMachine::getDel, false));
|
||||||
List<ProductMachineDto> recentlyFiveMinutesData = leaseProductMachineMapper.getRecentlyFiveMinutesData(leaseProductMachines, coin);
|
List<ProductMachineDto> recentlyFiveMinutesData = new ArrayList<>();
|
||||||
|
if(!leaseProductMachines.isEmpty()){
|
||||||
|
recentlyFiveMinutesData = leaseProductMachineMapper.getRecentlyFiveMinutesData(leaseProductMachines, coin);
|
||||||
for (ProductMachineDto recentlyFiveMinutesDatum : recentlyFiveMinutesData) {
|
for (ProductMachineDto recentlyFiveMinutesDatum : recentlyFiveMinutesData) {
|
||||||
recentlyFiveMinutesDatum.setComputingPower(recentlyFiveMinutesDatum.getComputingPower()
|
recentlyFiveMinutesDatum.setComputingPower(recentlyFiveMinutesDatum.getComputingPower()
|
||||||
.divide(BigDecimal.valueOf(24 * 60 * 60),2, RoundingMode.HALF_UP));
|
.divide(BigDecimal.valueOf(24 * 60 * 60),2, RoundingMode.HALF_UP));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return recentlyFiveMinutesData;
|
return recentlyFiveMinutesData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,9 +91,9 @@
|
|||||||
WHERE
|
WHERE
|
||||||
`date` >= DATE_SUB(now(), INTERVAL 1 DAY)
|
`date` >= DATE_SUB(now(), INTERVAL 1 DAY)
|
||||||
<if test="leaseProductMachines != null and leaseProductMachines.size() > 0">
|
<if test="leaseProductMachines != null and leaseProductMachines.size() > 0">
|
||||||
AND (
|
AND (`user`, miner) IN (
|
||||||
<foreach collection="leaseProductMachines" item="pair" separator="OR">
|
<foreach collection="leaseProductMachines" item="pair" separator=",">
|
||||||
(`user` = #{pair.user} AND miner = #{pair.miner})
|
(#{pair.user}, #{pair.miner})
|
||||||
</foreach>
|
</foreach>
|
||||||
)
|
)
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user