Browse Source

update:“优化日志下载,能够下载最新日志”

soobin 1 year ago
parent
commit
0ac379bb34
1 changed files with 11 additions and 5 deletions
  1. 11 5
      src/main/java/com/szwl/controller/TEquipmentController.java

+ 11 - 5
src/main/java/com/szwl/controller/TEquipmentController.java

@@ -47,8 +47,7 @@ import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
-import static com.szwl.constant.ResponseCodesEnum.A0001;
-import static com.szwl.constant.ResponseCodesEnum.P0002;
+import static com.szwl.constant.ResponseCodesEnum.*;
 
 /**
  * <p>
@@ -1063,7 +1062,7 @@ public class TEquipmentController {
         LambdaQueryWrapper<TEquipment> query = Wrappers.lambdaQuery();
         query.eq(TEquipment::getAdminId, Long.valueOf(adminId));
         List<TEquipment> equipmentList = tEquipmentService.list(query);
-        long nowTime = new Date().getTime();
+        long nowTime = System.currentTimeMillis();
         if (equipmentList.size() > 0) {
             for (TEquipment equipment : equipmentList) {
                 long modifyTime = equipment.getModifyDate().getTime();
@@ -1520,8 +1519,15 @@ public class TEquipmentController {
         String filepath = "/home/hboxs/log/"+kind+".txt";
         // 1.1 如果文件已存在,直接下载
         if(Files.exists(Paths.get(filepath))) {
-            DownloadUtils.downloadFile(filepath, response);
-            return R.ok();
+//            DownloadUtils.downloadFile(filepath, response);
+//            return R.ok();
+            try {
+                Files.delete(Paths.get(filepath));
+                return R.ok();
+            } catch (IOException e) {
+                e.printStackTrace();
+                return R.fail(B0004,"请重试");
+            }
         }
         String channel = tEquipment.getChannel();
         String equimentType = tEquipment.getEquimentType();