|
@@ -4,12 +4,17 @@ import cn.kdan.compdf.config.RedisConstantServer;
|
|
|
import cn.kdan.compdf.entity.BackgroundConvertData;
|
|
|
import cn.kdan.compdf.entity.dto.AnalysisDataDTO;
|
|
|
import cn.kdan.compdf.entity.dto.DashboardDetailedDataDTO;
|
|
|
+import cn.kdan.compdf.entity.dto.DashboardExportObject;
|
|
|
import cn.kdan.compdf.entity.dto.DashboardQueryDTO;
|
|
|
import cn.kdan.compdf.enums.BackgroundErrorEnum;
|
|
|
import cn.kdan.compdf.enums.ResponseEnum;
|
|
|
import cn.kdan.compdf.exception.CommonException;
|
|
|
import cn.kdan.compdf.mapper.BackgroundConvertDataMapper;
|
|
|
import cn.kdan.compdf.service.BackgroundConvertDataService;
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
+import com.alibaba.excel.util.MapUtils;
|
|
|
+import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
@@ -22,12 +27,20 @@ import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.cache.annotation.CacheRemove;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.time.Duration;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
+import java.time.chrono.ChronoLocalDateTime;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* @author comPDF-Kit WPH 2022-10-09
|
|
@@ -42,7 +55,7 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Cacheable(value = RedisConstantServer.DASHBOARD_ANALYSIS_DATA,cacheManager = "oneDayCacheManager", key = "T(String).valueOf(#queryDTO.toString())", unless = "#result == null")
|
|
|
+ @Cacheable(value = RedisConstantServer.DASHBOARD_ANALYSIS_DATA, cacheManager = "oneDayCacheManager", key = "T(String).valueOf(#queryDTO.toString())", unless = "#result == null")
|
|
|
public AnalysisDataDTO getAnalysisData(DashboardQueryDTO queryDTO) {
|
|
|
// 获取一个查询query
|
|
|
LambdaQueryWrapper<BackgroundConvertData> queryWrapper = getDashboardQueryWrapper(queryDTO);
|
|
@@ -73,21 +86,20 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Cacheable(value = RedisConstantServer.DASHBOARD_SUCCESS_DATA,cacheManager = "oneDayCacheManager", key = "T(String).valueOf(#queryDTO.toString())", unless = "#result == null")
|
|
|
+ @Cacheable(value = RedisConstantServer.DASHBOARD_SUCCESS_DATA, cacheManager = "oneDayCacheManager", key = "T(String).valueOf(#queryDTO.toString())", unless = "#result == null")
|
|
|
public List<DashboardDetailedDataDTO> getSuccessfulRequestDetailedData(DashboardQueryDTO queryDTO) {
|
|
|
LambdaQueryWrapper<BackgroundConvertData> queryWrapper = getDashboardQueryWrapper(queryDTO);
|
|
|
// 添加select 查询参数
|
|
|
- queryWrapper.select(BackgroundConvertData::getFileSuccessTotal,BackgroundConvertData::getSyncTime);
|
|
|
+ queryWrapper.select(BackgroundConvertData::getFileSuccessTotal, BackgroundConvertData::getSyncTime);
|
|
|
// 查询数据
|
|
|
List<BackgroundConvertData> backgroundConvertData = this.baseMapper.selectList(queryWrapper);
|
|
|
- // 判断查询类型
|
|
|
- LocalDateTime nowTime = LocalDateTime.now();
|
|
|
- // 减去分钟数
|
|
|
- nowTime = nowTime.minus(nowTime.getMinute(), ChronoUnit.MINUTES);
|
|
|
+
|
|
|
+ LocalDateTime nowTime = getLocalDataTime();
|
|
|
// 返回数据集合
|
|
|
List<DashboardDetailedDataDTO> dataDTOS = new ArrayList<>();
|
|
|
|
|
|
int successTotal = 0;
|
|
|
+ // 判断查询类型
|
|
|
switch (queryDTO.getQueryType()) {
|
|
|
case 0:
|
|
|
if (queryDTO.getDays() == 1) {
|
|
@@ -96,7 +108,8 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
LocalDateTime minus = nowTime.minus(i, ChronoUnit.HOURS);
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1小时
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusHours(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus)
|
|
|
+ && !localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plusHours(1))) {
|
|
|
successTotal += backgroundConvertDatum.getFileSuccessTotal();
|
|
|
}
|
|
|
}
|
|
@@ -108,10 +121,11 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
} else {
|
|
|
for (int i = 0; i < queryDTO.getDays(); i++) {
|
|
|
// 减去 i 天时间
|
|
|
- LocalDateTime minus = nowTime.minus(i, ChronoUnit.DAYS);
|
|
|
+ LocalDate minus = nowTime.minus(i, ChronoUnit.DAYS).toLocalDate();
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1天
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusDays(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.atStartOfDay())
|
|
|
+ && !localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plusDays(1).atStartOfDay())) {
|
|
|
successTotal += backgroundConvertDatum.getFileSuccessTotal();
|
|
|
}
|
|
|
}
|
|
@@ -123,17 +137,18 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
}
|
|
|
break;
|
|
|
case 1:
|
|
|
- LocalDateTime startDateTime = queryDTO.getStartDateTime();
|
|
|
- LocalDateTime endDateTime = queryDTO.getEndDateTime();
|
|
|
+ LocalDate startDateTime = queryDTO.getStartDateTime();
|
|
|
+ LocalDate endDateTime = queryDTO.getEndDateTime();
|
|
|
Duration duration = Duration.between(startDateTime, endDateTime);
|
|
|
long days = duration.toDays(); //相差的天数
|
|
|
- if (days == 0L) {
|
|
|
- for (int i = 0; i < nowTime.getHour(); i++) {
|
|
|
+ if (days == 1L) {
|
|
|
+ for (int i = 0; i < 24; i++) {
|
|
|
// 减去 i 小时时间
|
|
|
- LocalDateTime minus = nowTime.minus(i, ChronoUnit.HOURS);
|
|
|
+ LocalDate minus = endDateTime.minus(i, ChronoUnit.HOURS);
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1小时
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusHours(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.atStartOfDay())
|
|
|
+ && !localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plus(1L, ChronoUnit.HOURS).atStartOfDay())) {
|
|
|
successTotal += backgroundConvertDatum.getFileSuccessTotal();
|
|
|
}
|
|
|
}
|
|
@@ -145,10 +160,11 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
} else {
|
|
|
for (int i = 0; i < days; i++) {
|
|
|
// 减去 i 天时间
|
|
|
- LocalDateTime minus = endDateTime.minus(i, ChronoUnit.DAYS);
|
|
|
+ LocalDate minus = endDateTime.minus(i, ChronoUnit.DAYS);
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1天
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusDays(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.atStartOfDay())
|
|
|
+ && localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plusDays(1).atStartOfDay())) {
|
|
|
successTotal += backgroundConvertDatum.getFileSuccessTotal();
|
|
|
}
|
|
|
}
|
|
@@ -166,11 +182,11 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Cacheable(value = RedisConstantServer.DASHBOARD_FAIL_DATA,cacheManager = "oneDayCacheManager", key = "T(String).valueOf(#queryDTO.toString())", unless = "#result == null")
|
|
|
+ @Cacheable(value = RedisConstantServer.DASHBOARD_FAIL_DATA, cacheManager = "oneDayCacheManager", key = "T(String).valueOf(#queryDTO.toString())", unless = "#result == null")
|
|
|
public List<DashboardDetailedDataDTO> getErrorRequestDetailedData(DashboardQueryDTO queryDTO) {
|
|
|
LambdaQueryWrapper<BackgroundConvertData> queryWrapper = getDashboardQueryWrapper(queryDTO);
|
|
|
// 添加select 查询参数
|
|
|
- queryWrapper.select(BackgroundConvertData::getFileFailedTotal,BackgroundConvertData::getSyncTime);
|
|
|
+ queryWrapper.select(BackgroundConvertData::getFileFailedTotal, BackgroundConvertData::getSyncTime);
|
|
|
// 查询数据
|
|
|
List<BackgroundConvertData> backgroundConvertData = this.baseMapper.selectList(queryWrapper);
|
|
|
// 判断查询类型
|
|
@@ -189,7 +205,8 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
LocalDateTime minus = nowTime.minus(i, ChronoUnit.HOURS);
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1小时
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusHours(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus)
|
|
|
+ && !localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plusHours(1))) {
|
|
|
fileFailedTotal += backgroundConvertDatum.getFileFailedTotal();
|
|
|
}
|
|
|
}
|
|
@@ -201,10 +218,11 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
} else {
|
|
|
for (int i = 0; i < queryDTO.getDays(); i++) {
|
|
|
// 减去 i 天时间
|
|
|
- LocalDateTime minus = nowTime.minus(i, ChronoUnit.DAYS);
|
|
|
+ LocalDate minus = nowTime.minus(i, ChronoUnit.DAYS).toLocalDate();
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1天
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusDays(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.atStartOfDay())
|
|
|
+ && !localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plusDays(1).atStartOfDay())) {
|
|
|
fileFailedTotal += backgroundConvertDatum.getFileFailedTotal();
|
|
|
}
|
|
|
}
|
|
@@ -216,17 +234,18 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
}
|
|
|
break;
|
|
|
case 1:
|
|
|
- LocalDateTime startDateTime = queryDTO.getStartDateTime();
|
|
|
- LocalDateTime endDateTime = queryDTO.getEndDateTime();
|
|
|
+ LocalDate startDateTime = queryDTO.getStartDateTime();
|
|
|
+ LocalDate endDateTime = queryDTO.getEndDateTime();
|
|
|
Duration duration = Duration.between(startDateTime, endDateTime);
|
|
|
long days = duration.toDays(); //相差的天数
|
|
|
- if (days == 0L) {
|
|
|
- for (int i = 0; i < nowTime.getHour(); i++) {
|
|
|
+ if (days == 1L) {
|
|
|
+ for (int i = 0; i < 24; i++) {
|
|
|
// 减去 i 小时时间
|
|
|
- LocalDateTime minus = nowTime.minus(i, ChronoUnit.HOURS);
|
|
|
+ LocalDate minus = endDateTime.minus(i, ChronoUnit.HOURS);
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1小时
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusHours(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.atStartOfDay())
|
|
|
+ && !localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plus(1L, ChronoUnit.HOURS).atStartOfDay())) {
|
|
|
fileFailedTotal += backgroundConvertDatum.getFileFailedTotal();
|
|
|
}
|
|
|
}
|
|
@@ -238,10 +257,11 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
} else {
|
|
|
for (int i = 0; i < days; i++) {
|
|
|
// 减去 i 天时间
|
|
|
- LocalDateTime minus = endDateTime.minus(i, ChronoUnit.DAYS);
|
|
|
+ LocalDate minus = endDateTime.minus(i, ChronoUnit.DAYS);
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1天
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusDays(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.atStartOfDay())
|
|
|
+ && localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plusDays(1).atStartOfDay())) {
|
|
|
fileFailedTotal += backgroundConvertDatum.getFileFailedTotal();
|
|
|
}
|
|
|
}
|
|
@@ -259,7 +279,7 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Cacheable(value = RedisConstantServer.DASHBOARD_ERROR_RATIO_DATA,cacheManager = "oneDayCacheManager", key = "T(String).valueOf(#queryDTO.toString())", unless = "#result == null")
|
|
|
+ @Cacheable(value = RedisConstantServer.DASHBOARD_ERROR_RATIO_DATA, cacheManager = "oneDayCacheManager", key = "T(String).valueOf(#queryDTO.toString())", unless = "#result == null")
|
|
|
public List<DashboardDetailedDataDTO> getErrorRatioDetailedData(DashboardQueryDTO queryDTO) {
|
|
|
List<DashboardDetailedDataDTO> successfulRequestDetailedData = this.getSuccessfulRequestDetailedData(queryDTO);
|
|
|
List<DashboardDetailedDataDTO> errorRequestDetailedData = this.getErrorRequestDetailedData(queryDTO);
|
|
@@ -270,7 +290,7 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
|
|
|
dataDTOS.add(DashboardDetailedDataDTO.builder()
|
|
|
.xData(successfulRequestDetailedData.get(i).getXData())
|
|
|
- .yData(fileTotal == 0 ? "0.00" : new BigDecimal(String.format("%.2f",Integer.parseInt(errorRequestDetailedData.get(i).getYData()) * 100.00
|
|
|
+ .yData(fileTotal == 0 ? "0.00" : new BigDecimal(String.format("%.2f", Integer.parseInt(errorRequestDetailedData.get(i).getYData()) * 100.00
|
|
|
/ fileTotal)).toString())
|
|
|
.build());
|
|
|
}
|
|
@@ -278,11 +298,11 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Cacheable(value = RedisConstantServer.DASHBOARD_AVERAGE_PROCESS_DATA,cacheManager = "oneDayCacheManager", key = "T(String).valueOf(#queryDTO.toString())", unless = "#result == null")
|
|
|
+ @Cacheable(value = RedisConstantServer.DASHBOARD_AVERAGE_PROCESS_DATA, cacheManager = "oneDayCacheManager", key = "T(String).valueOf(#queryDTO.toString())", unless = "#result == null")
|
|
|
public List<DashboardDetailedDataDTO> getAverageProcessTimeDetailedData(DashboardQueryDTO queryDTO) {
|
|
|
LambdaQueryWrapper<BackgroundConvertData> queryWrapper = getDashboardQueryWrapper(queryDTO);
|
|
|
// 添加select 查询参数
|
|
|
- queryWrapper.select(BackgroundConvertData::getFileConvertTime,BackgroundConvertData::getSyncTime);
|
|
|
+ queryWrapper.select(BackgroundConvertData::getFileConvertTime, BackgroundConvertData::getSyncTime);
|
|
|
// 查询数据
|
|
|
List<BackgroundConvertData> backgroundConvertData = this.baseMapper.selectList(queryWrapper);
|
|
|
// 判断查询类型
|
|
@@ -301,7 +321,8 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
LocalDateTime minus = nowTime.minus(i, ChronoUnit.HOURS);
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1小时
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusHours(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus)
|
|
|
+ && !localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plusHours(1))){
|
|
|
convertTime = convertTime.add(backgroundConvertDatum.getFileConvertTime());
|
|
|
}
|
|
|
}
|
|
@@ -313,10 +334,11 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
} else {
|
|
|
for (int i = 0; i < queryDTO.getDays(); i++) {
|
|
|
// 减去 i 天时间
|
|
|
- LocalDateTime minus = nowTime.minus(i, ChronoUnit.DAYS);
|
|
|
+ LocalDate minus = nowTime.minus(i, ChronoUnit.DAYS).toLocalDate();
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1天
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusDays(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.atStartOfDay())
|
|
|
+ && !localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plusDays(1).atStartOfDay())) {
|
|
|
convertTime = convertTime.add(backgroundConvertDatum.getFileConvertTime());
|
|
|
}
|
|
|
}
|
|
@@ -328,17 +350,18 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
}
|
|
|
break;
|
|
|
case 1:
|
|
|
- LocalDateTime startDateTime = queryDTO.getStartDateTime();
|
|
|
- LocalDateTime endDateTime = queryDTO.getEndDateTime();
|
|
|
+ LocalDate startDateTime = queryDTO.getStartDateTime();
|
|
|
+ LocalDate endDateTime = queryDTO.getEndDateTime();
|
|
|
Duration duration = Duration.between(startDateTime, endDateTime);
|
|
|
long days = duration.toDays(); //相差的天数
|
|
|
- if (days == 0L) {
|
|
|
- for (int i = 0; i < nowTime.getHour(); i++) {
|
|
|
+ if (days == 1L) {
|
|
|
+ for (int i = 0; i < 24; i++) {
|
|
|
// 减去 i 小时时间
|
|
|
- LocalDateTime minus = nowTime.minus(i, ChronoUnit.HOURS);
|
|
|
+ LocalDate minus = endDateTime.minus(i, ChronoUnit.HOURS);
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1小时
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusHours(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.atStartOfDay())
|
|
|
+ && !localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plus(1L, ChronoUnit.HOURS).atStartOfDay())) {
|
|
|
convertTime = convertTime.add(backgroundConvertDatum.getFileConvertTime());
|
|
|
}
|
|
|
}
|
|
@@ -350,10 +373,11 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
} else {
|
|
|
for (int i = 0; i < days; i++) {
|
|
|
// 减去 i 天时间
|
|
|
- LocalDateTime minus = endDateTime.minus(i, ChronoUnit.DAYS);
|
|
|
+ LocalDate minus = endDateTime.minus(i, ChronoUnit.DAYS);
|
|
|
for (BackgroundConvertData backgroundConvertDatum : backgroundConvertData) {
|
|
|
// 如果同步时间大于当前 minus 并且小于 minus+1天
|
|
|
- if (backgroundConvertDatum.getSyncTime().isAfter(minus) && backgroundConvertDatum.getSyncTime().isBefore(minus.plusDays(1))) {
|
|
|
+ if (localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.atStartOfDay())
|
|
|
+ && localDataCompareTo(backgroundConvertDatum.getSyncTime(),minus.plusDays(1).atStartOfDay())) {
|
|
|
convertTime = convertTime.add(backgroundConvertDatum.getFileConvertTime());
|
|
|
}
|
|
|
}
|
|
@@ -371,7 +395,71 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @CacheEvict(cacheNames = RedisConstantServer.DASHBOARD+"*" ,allEntries = true)
|
|
|
+ public void dashboardExport(DashboardQueryDTO queryDTO, HttpServletResponse response) {
|
|
|
+ List<DashboardDetailedDataDTO> successfulRequestDetailedData = this.getSuccessfulRequestDetailedData(queryDTO);
|
|
|
+ List<DashboardDetailedDataDTO> errorRequestDetailedData = this.getErrorRequestDetailedData(queryDTO);
|
|
|
+ List<DashboardDetailedDataDTO> errorRatioDetailedData = this.getErrorRatioDetailedData(queryDTO);
|
|
|
+ List<DashboardDetailedDataDTO> averageProcessTimeDetailedData = this.getAverageProcessTimeDetailedData(queryDTO);
|
|
|
+ List<DashboardExportObject> dashboardExportObjects = new ArrayList<>();
|
|
|
+ for (int i = 0; i < successfulRequestDetailedData.size(); i++) {
|
|
|
+ dashboardExportObjects.add(DashboardExportObject.builder()
|
|
|
+ .time(successfulRequestDetailedData.get(i).getXData())
|
|
|
+ .successfulRequests(successfulRequestDetailedData.get(i).getYData())
|
|
|
+ .errorRequests(errorRequestDetailedData.get(i).getYData())
|
|
|
+ .errorRatio(errorRatioDetailedData.get(i).getYData())
|
|
|
+ .averageProcessTime(averageProcessTimeDetailedData.get(i).getYData())
|
|
|
+ .build());
|
|
|
+ }
|
|
|
+
|
|
|
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ List<List<String>> listHand = new ArrayList<>();
|
|
|
+ List<String> head0 = new ArrayList<>();
|
|
|
+ // 判断是Hour还是Date
|
|
|
+ head0.add((queryDTO.getQueryType() == 0 && queryDTO.getDays() == 1) || (queryDTO.getQueryType() == 1 && queryDTO.getStartDateTime().equals(queryDTO.getEndDateTime())) ? "Hour" : "Date");
|
|
|
+ List<String> head1 = new ArrayList<>();
|
|
|
+ head1.add("Succesful Requests");
|
|
|
+ List<String> head2 = new ArrayList<>();
|
|
|
+ head2.add("Error Requests");
|
|
|
+ List<String> head3 = new ArrayList<>();
|
|
|
+ head3.add("Error Ratio");
|
|
|
+ List<String> head4 = new ArrayList<>();
|
|
|
+ head4.add("Average Process Time");
|
|
|
+ listHand.add(head0);
|
|
|
+ listHand.add(head1);
|
|
|
+ listHand.add(head2);
|
|
|
+ listHand.add(head3);
|
|
|
+ listHand.add(head4);
|
|
|
+ try {
|
|
|
+ // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
|
|
+ String fileName = URLEncoder.encode("Dashboard表单", "UTF-8").replaceAll("\\+", "%20");
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
|
|
|
+ EasyExcel.write(response.getOutputStream())
|
|
|
+ .head(listHand)
|
|
|
+ .autoCloseStream(Boolean.FALSE)
|
|
|
+ .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy())
|
|
|
+ .sheet("Dashboard")
|
|
|
+ .doWrite(dashboardExportObjects);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // 重置response
|
|
|
+ response.reset();
|
|
|
+ response.setContentType("application/json");
|
|
|
+ response.setCharacterEncoding("utf-8");
|
|
|
+ Map<String, String> map = MapUtils.newHashMap();
|
|
|
+ map.put("status", "failure");
|
|
|
+ map.put("message", "下载文件失败" + e.getMessage());
|
|
|
+ try {
|
|
|
+ response.getWriter().println(JSON.toJSONString(map));
|
|
|
+ } catch (IOException ioException) {
|
|
|
+ ioException.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @CacheEvict(cacheNames = RedisConstantServer.DASHBOARD + "*", allEntries = true)
|
|
|
public void test() {
|
|
|
System.out.println("删除");
|
|
|
}
|
|
@@ -399,8 +487,8 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
LocalDateTime minus = nowDateTime.minus(days, ChronoUnit.DAYS);
|
|
|
queryWrapper.ge(BackgroundConvertData::getSyncTime, minus);
|
|
|
} else if (queryType == 1) {
|
|
|
- LocalDateTime startDateTime = queryDTO.getStartDateTime();
|
|
|
- LocalDateTime endDateTime = queryDTO.getEndDateTime();
|
|
|
+ LocalDate startDateTime = queryDTO.getStartDateTime();
|
|
|
+ LocalDate endDateTime = queryDTO.getEndDateTime();
|
|
|
|
|
|
if (startDateTime.isAfter(endDateTime)) {
|
|
|
// 查询参数异常 开始时间大于结束时间
|
|
@@ -409,7 +497,7 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
// 开始时间等于结束时间
|
|
|
endDateTime = endDateTime.plusDays(1);
|
|
|
queryDTO.setEndDateTime(endDateTime.plusDays(1));
|
|
|
- } else if (Duration.between(startDateTime, endDateTime).toDays() > 30) {
|
|
|
+ } else if (ChronoUnit.DAYS.between(startDateTime, endDateTime) > 30) {
|
|
|
// 开始时间和结束时间大于30天
|
|
|
startDateTime = endDateTime.minus(30, ChronoUnit.DAYS);
|
|
|
queryDTO.setStartDateTime(endDateTime.minus(30, ChronoUnit.DAYS));
|
|
@@ -431,12 +519,31 @@ public class BackgroundConvertDataServiceImpl extends ServiceImpl<BackgroundConv
|
|
|
return queryWrapper;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取整数小时时间
|
|
|
+ */
|
|
|
+ private static LocalDateTime getLocalDataTime() {
|
|
|
+ LocalDateTime nowTime = LocalDateTime.now();
|
|
|
+ LocalDate nowData = LocalDate.now();
|
|
|
+ return LocalDateTime.of(nowData, LocalTime.of(nowTime.getHour(), 0));
|
|
|
+ }
|
|
|
+
|
|
|
+ private static boolean localDataCompareTo(LocalDateTime dateTime1,LocalDateTime dateTime2){
|
|
|
+ return dateTime1.compareTo(dateTime2) >= 0;
|
|
|
+ }
|
|
|
+
|
|
|
public static void main(String[] args) {
|
|
|
// String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH"));
|
|
|
// LocalDateTime minus = DateUtil.toLocalDateTime(format, "yyyy-MM-dd HH");
|
|
|
// LocalDateTime minus = nowDateTime.minus(20, ChronoUnit.DAYS);
|
|
|
- LocalDateTime minus = LocalDateTime.now();
|
|
|
- LocalDateTime minus1 = minus.minus(minus.getMinute(), ChronoUnit.MINUTES);
|
|
|
- System.out.println(minus1.toString());
|
|
|
+ LocalDateTime nowTime = LocalDateTime.now();
|
|
|
+
|
|
|
+ System.out.println(localDataCompareTo(nowTime, nowTime));
|
|
|
+
|
|
|
+// LocalDate nowData = LocalDate.now();
|
|
|
+// nowTime = LocalDateTime.of(nowData, LocalTime.of(nowTime.getHour(), 0));
|
|
|
+// System.out.println(nowTime);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|