|
@@ -27,6 +27,7 @@ import com.gz.service.statistics.SelectStatisticsService;
|
|
|
import com.gz.service.system.ArchivesTreeService;
|
|
import com.gz.service.system.ArchivesTreeService;
|
|
|
import com.gz.service.system.impl.AuthServiceImpl;
|
|
import com.gz.service.system.impl.AuthServiceImpl;
|
|
|
import com.gz.utils.JwtUtils;
|
|
import com.gz.utils.JwtUtils;
|
|
|
|
|
+import com.gz.utils.UnitUtils;
|
|
|
import com.gz.vo.statistics.StatisticsVO;
|
|
import com.gz.vo.statistics.StatisticsVO;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
@@ -95,7 +96,7 @@ public class SelectStatisticsServiceImpl implements SelectStatisticsService {
|
|
|
archivesTreeDTOS.forEach(dto -> {
|
|
archivesTreeDTOS.forEach(dto -> {
|
|
|
if (dto.getParentId() != -1) {
|
|
if (dto.getParentId() != -1) {
|
|
|
for (ArchivesTreeDTO dt : archivesTreeDTOS) {
|
|
for (ArchivesTreeDTO dt : archivesTreeDTOS) {
|
|
|
- if (dto.getParentId() == dt.getId()) {
|
|
|
|
|
|
|
+ if (dto.getParentId().equals(dt.getId())) {
|
|
|
list.add(dt.getTitle());
|
|
list.add(dt.getTitle());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -119,12 +120,12 @@ public class SelectStatisticsServiceImpl implements SelectStatisticsService {
|
|
|
//二级分类
|
|
//二级分类
|
|
|
for (File category2 : category.listFiles()) {
|
|
for (File category2 : category.listFiles()) {
|
|
|
if (ObjectUtil.isNotEmpty(category2)) {
|
|
if (ObjectUtil.isNotEmpty(category2)) {
|
|
|
- String s1 = this.getLinuxDirectorySize(category);
|
|
|
|
|
|
|
+ String s1 = UnitUtils.storageUnitConvertStr(this.getLinuxDirectorySize(category));
|
|
|
map.put(category.getName(), s1);
|
|
map.put(category.getName(), s1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- String s2 = this.getLinuxDirectorySize(category);
|
|
|
|
|
|
|
+ String s2 = UnitUtils.storageUnitConvertStr(this.getLinuxDirectorySize(category));
|
|
|
map.put(category.getName(), s2);
|
|
map.put(category.getName(), s2);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -185,7 +186,7 @@ public class SelectStatisticsServiceImpl implements SelectStatisticsService {
|
|
|
// 年份
|
|
// 年份
|
|
|
for (File year : qzh.listFiles()) {
|
|
for (File year : qzh.listFiles()) {
|
|
|
if (ObjectUtil.isNotEmpty(year)) {
|
|
if (ObjectUtil.isNotEmpty(year)) {
|
|
|
- String linuxDirectorySize = this.getLinuxDirectorySize(year);
|
|
|
|
|
|
|
+ String linuxDirectorySize = UnitUtils.storageUnitConvertStr(this.getLinuxDirectorySize(year));
|
|
|
archiveYearStatisticsRVOS.forEach(statisticsRVO -> {
|
|
archiveYearStatisticsRVOS.forEach(statisticsRVO -> {
|
|
|
if (statisticsRVO.getGdnd().equals(year.getName())) {
|
|
if (statisticsRVO.getGdnd().equals(year.getName())) {
|
|
|
statisticsRVO.setSpace(linuxDirectorySize);
|
|
statisticsRVO.setSpace(linuxDirectorySize);
|
|
@@ -202,11 +203,12 @@ public class SelectStatisticsServiceImpl implements SelectStatisticsService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * @return 文件夹占用空间大小 单位:字节(K) 1GB = 1024MB = 1024 * 1024 KB = 1024 * 1024 * 1024 B
|
|
|
* @description 获取Linux文件夹大小
|
|
* @description 获取Linux文件夹大小
|
|
|
* @author ZhangHai
|
|
* @author ZhangHai
|
|
|
* @since 2021/9/15 11:33
|
|
* @since 2021/9/15 11:33
|
|
|
*/
|
|
*/
|
|
|
- private String getLinuxDirectorySize(File file) {
|
|
|
|
|
|
|
+ private Long getLinuxDirectorySize(File file) {
|
|
|
if (!file.exists()) {
|
|
if (!file.exists()) {
|
|
|
throw new BusinessException(500, "文件见不存在");
|
|
throw new BusinessException(500, "文件见不存在");
|
|
|
}
|
|
}
|
|
@@ -214,13 +216,19 @@ public class SelectStatisticsServiceImpl implements SelectStatisticsService {
|
|
|
throw new BusinessException(500, "参数非文件见");
|
|
throw new BusinessException(500, "参数非文件见");
|
|
|
}
|
|
}
|
|
|
// 执行命令Format
|
|
// 执行命令Format
|
|
|
- final String commandFomat = "du -sh {}";
|
|
|
|
|
|
|
+ final String commandFomat = "du -s {}";
|
|
|
// 需要执行的命令
|
|
// 需要执行的命令
|
|
|
final String command = StrUtil.format(commandFomat, file.getAbsoluteFile());
|
|
final String command = StrUtil.format(commandFomat, file.getAbsoluteFile());
|
|
|
log.info("文件夹大小扫描命令执行:{}", command);
|
|
log.info("文件夹大小扫描命令执行:{}", command);
|
|
|
// 执行命令的结果
|
|
// 执行命令的结果
|
|
|
String commandResult = RuntimeUtil.execForStr(command);
|
|
String commandResult = RuntimeUtil.execForStr(command);
|
|
|
- return commandResult.substring(0, commandResult.indexOf(" "));
|
|
|
|
|
|
|
+ // 占用空间大小 String类型
|
|
|
|
|
+ String sizeStr = commandResult.substring(0, commandResult.indexOf("\t"));
|
|
|
|
|
+ Long size = 0L;
|
|
|
|
|
+ if (StrUtil.isNotEmpty(sizeStr)) {
|
|
|
|
|
+ size = Long.parseLong(sizeStr);
|
|
|
|
|
+ }
|
|
|
|
|
+ return size;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|