瀏覽代碼

档案刷新sort

cr 1 周之前
父節點
當前提交
14c8aad260

+ 6 - 2
blade-service/blade-business/src/main/java/org/springblade/business/controller/ArchiveFileController.java

@@ -42,6 +42,7 @@ import org.springblade.manager.vo.ArchiveTreeVO2;
 import org.springblade.system.entity.Role;
 import org.springblade.system.feign.ISysClient;
 import org.springframework.beans.BeanUtils;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -532,8 +533,11 @@ public class ArchiveFileController extends BladeController {
     }
 
 
-    public R flushArchiveFileSort(Long projectId){
-        return R.status(archiveFileService.flushArchiveFileSort(projectId));
+    @Scheduled(cron = "0 04 10 * * ?")
+    @GetMapping("/flushArchiveFileSort")
+    public void flushArchiveFileSort(){
+        Long projectId=1935614356128206849L;
+        archiveFileService.flushArchiveFileSort(projectId);
     }
 
 

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/service/IArchiveFileService.java

@@ -80,5 +80,5 @@ public interface IArchiveFileService extends BaseService<ArchiveFile> {
 
     Integer selectMaxSortByContractId(Long contractId);
 
-    boolean flushArchiveFileSort(Long projectId);
+    void flushArchiveFileSort(Long projectId);
 }

+ 12 - 3
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/ArchiveFileServiceImpl.java

@@ -2,6 +2,7 @@ package org.springblade.business.service.impl;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -376,12 +377,13 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
     }
 
     @Override
-    public boolean flushArchiveFileSort(Long projectId) {
+    public void flushArchiveFileSort(Long projectId) {
         List<ArchiveFile>archileFileList=baseMapper.selectArchiveFileByProjectId(projectId);
         Map<String, List<ArchiveFile>> archiveMap = archileFileList.stream().collect(Collectors.groupingBy(ArchiveFile::getNodeId));
         List<Long> NodeIds = archileFileList.stream()
                 .map(ArchiveFile::getNodeId)
                 .map(Long::parseLong)
+                .distinct()
                 .collect(Collectors.toList());
         List<ArchiveTreeContract> sortIds = archiveTreeContractClient.getArchiveTreeContractListByListOrderByTreeSort(NodeIds);
         int sort=10100001;
@@ -398,7 +400,14 @@ public class ArchiveFileServiceImpl extends BaseServiceImpl<ArchiveFileMapper, A
                 }
             }
         }
-        this.updateBatchById(archileFileList);
-        return true;
+        int i=1;
+        for (ArchiveFile file : archileFileList) {
+            this.update(Wrappers.<ArchiveFile>lambdaUpdate()
+                    .set(ArchiveFile::getSort, file.getSort())
+                    .eq(ArchiveFile::getId, file.getId()));
+            System.out.println("归档文件排序进度:" + i + "/" + archileFileList.size());
+            i++;
+        }
+        System.out.println("归档文件排序成功");
     }
 }