优化排序和查询速度
This commit is contained in:
+4
-1
@@ -41,7 +41,10 @@ public class RmResourceRegistrationController extends BaseController
|
||||
public TableDataInfo list(@RequestBody RmResourceRegistration rmResourceRegistration)
|
||||
{
|
||||
Map<String, Object> resultMap = rmResourceRegistrationService.getRegistrationTableInfoList(rmResourceRegistration);
|
||||
if(rmResourceRegistration.getQueryParam() != null && rmResourceRegistration.getQueryParam() != ""){
|
||||
if((rmResourceRegistration.getQueryParam() != null &&
|
||||
rmResourceRegistration.getQueryParam() != "") ||
|
||||
(rmResourceRegistration.getBandwidthResultSort() != null &&
|
||||
rmResourceRegistration.getBandwidthResultSort() != 3)){
|
||||
return getDataTable((List<RmResourceRegistration>) resultMap.get("list"), (int) resultMap.get("total"));
|
||||
}
|
||||
return getDataTable((List<RmResourceRegistration>) resultMap.get("list"));
|
||||
|
||||
+10
-26
@@ -24,8 +24,6 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -132,11 +130,8 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
|
||||
// 3. 内存分页
|
||||
int total = filteredList.size();
|
||||
int fromIndex = Math.min((pageNum - 1) * pageSize, total);
|
||||
int toIndex = Math.min(fromIndex + pageSize, total);
|
||||
|
||||
// 注意:这里要用copy,因为后续要修改数据
|
||||
List<RmResourceRegistration> pageList = applyPagination(filteredList, rmResourceRegistration.getPageNum(), rmResourceRegistration.getPageSize());
|
||||
List<RmResourceRegistration> pageList = applyPagination(filteredList, pageNum, pageSize);
|
||||
List<RmResourceRegistration> currentPageData = new ArrayList<>(pageList);
|
||||
|
||||
// 4. 只处理当前页数据
|
||||
@@ -557,26 +552,15 @@ public class RmResourceRegistrationServiceImpl implements IRmResourceRegistratio
|
||||
|
||||
public void setBandwidthYestoday(RmResourceRegistration registration){
|
||||
// 查询昨日95值
|
||||
String yesterday = LocalDate.now().minusDays(1).format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));;
|
||||
Date yesterdayDate = DateUtils.parseDate(yesterday);
|
||||
EpsNodeBandwidth epsNodeBandwidth = new EpsNodeBandwidth();
|
||||
epsNodeBandwidth.setClientId(registration.getClientId());
|
||||
epsNodeBandwidth.setBandwidthType("1");
|
||||
epsNodeBandwidth.setCreateTime(yesterdayDate);
|
||||
List<EpsNodeBandwidth> nodeBandwidthList = epsNodeBandwidthMapper.selectEpsNodeBandwidthList(epsNodeBandwidth);
|
||||
if(nodeBandwidthList != null && !nodeBandwidthList.isEmpty()){
|
||||
EpsNodeBandwidth nodeBandwidth = nodeBandwidthList.get(0);
|
||||
BigDecimal bandwidthResult = nodeBandwidth.getBandwidthResult();
|
||||
registration.setBandwidthResult(bandwidthResult);
|
||||
BigDecimal reportedBandwidth = registration.getReportedBandwidth();
|
||||
if(reportedBandwidth != null){
|
||||
if(reportedBandwidth.compareTo(BigDecimal.ZERO) == 0){
|
||||
registration.setBandwidthRate("0%");
|
||||
}else{
|
||||
// 计算日95带宽值利用率
|
||||
BigDecimal bandwidthRate = bandwidthResult.multiply(new BigDecimal(100)).divide(reportedBandwidth, 1, RoundingMode.HALF_UP);
|
||||
registration.setBandwidthRate(bandwidthRate + "%");
|
||||
}
|
||||
BigDecimal bandwidthResult = registration.getBandwidthResult();
|
||||
BigDecimal reportedBandwidth = registration.getReportedBandwidth();
|
||||
if(reportedBandwidth != null && bandwidthResult != null){
|
||||
if(reportedBandwidth.compareTo(BigDecimal.ZERO) == 0){
|
||||
registration.setBandwidthRate(null);
|
||||
}else{
|
||||
// 计算日95带宽值利用率
|
||||
BigDecimal bandwidthRate = bandwidthResult.multiply(new BigDecimal(100)).divide(reportedBandwidth, 1, RoundingMode.HALF_UP);
|
||||
registration.setBandwidthRate(bandwidthRate + "%");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -210,7 +210,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
a.onboard_time as onboardTime,
|
||||
a.remark as remark,
|
||||
a.reported_bandwidth as reportedBandwidth,
|
||||
b.machine_code as machineCode
|
||||
b.machine_code as machineCode,
|
||||
(select bandwidth_result from eps_node_bandwidth
|
||||
where client_id=a.client_id and calculation_mode='1000' and bandwidth_type=1
|
||||
AND create_time = DATE(DATE_SUB(NOW(), INTERVAL 1 DAY)) limit 1) as bandwidthResult
|
||||
from rm_resource_registration a
|
||||
left join rm_registration_machine b on a.client_id = b.client_id
|
||||
<where>
|
||||
|
||||
Reference in New Issue
Block a user