Преглед изворни кода

把线程池相关代码删除

wuweihao пре 4 година
родитељ
комит
2b13e0d815

+ 1 - 5
720yun_fd_manage/gis_application/src/main/resources/application.properties

@@ -25,11 +25,7 @@ pagehelper.reasonable=false
 pagehelper.support-methods-arguments=true
 
 
-# \u7EBF\u7A0B\u6C60\u914D\u7F6E
-spring.task.pool.corePoolSize=10
-spring.task.pool.maxPoolSize=100
-spring.task.pool.keepAliveSeconds=100
-spring.task.pool.queueCapacity=100
+
 
 
 

+ 0 - 29
720yun_fd_manage/gis_common/src/main/java/com/gis/common/task/AsyncTask.java

@@ -1,29 +0,0 @@
-package com.gis.common.task;
-
-import cn.hutool.core.io.FileUtil;
-import com.gis.common.util.AliyunOssUtil;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Async;
-import org.springframework.stereotype.Component;
-
-
-/**
- * Created by owen on 2021/1/20 0020 20:38
- */
-@Slf4j
-@Component
-public class AsyncTask {
-
-    @Autowired
-    AliyunOssUtil aliyunOssUtil;
-
-    @Async("taskExecutor")
-    public void uploadOss(String savePath, String ossPath) {
-        log.info("run task uploadOss");
-        aliyunOssUtil.upload(savePath, ossPath);
-        // 删除服务器临时文件
-        FileUtil.del(savePath);
-        log.info("end task uploadOss");
-    }
-}

+ 0 - 44
720yun_fd_manage/gis_common/src/main/java/com/gis/common/task/TaskExecutePool.java

@@ -1,44 +0,0 @@
-package com.gis.common.task;
-
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.scheduling.annotation.EnableAsync;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import org.springframework.stereotype.Component;
-
-import java.util.concurrent.Executor;
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * Created by owen on 2017/8/29.
- */
-//@Configuration
-@Component
-@EnableAsync
-public class TaskExecutePool {
-
-    @Value("${spring.task.pool.corePoolSize}")
-    private int corePoolSize;
-    @Value("${spring.task.pool.corePoolSize}")
-    private int maxPoolSize;
-    @Value("${spring.task.pool.keepAliveSeconds}")
-    private int keepAliveSeconds;
-    @Value("${spring.task.pool.queueCapacity}")
-    private int queueCapacity;
-
-    @Bean
-    public Executor taskExecutor() {
-        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
-        executor.setCorePoolSize(corePoolSize);
-        executor.setMaxPoolSize(maxPoolSize);
-        executor.setQueueCapacity(queueCapacity);
-        executor.setKeepAliveSeconds(keepAliveSeconds);
-        executor.setThreadNamePrefix("MyExecutor-");
-        // rejection-policy:当pool已经达到max size的时候,如何处理新任务
-        // CALLER_RUNS:不在新线程中执行任务,而是由调用者所在的线程来执行
-        executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
-        executor.initialize();
-        return executor;
-    }
-}

+ 0 - 107
720yun_fd_manage/gis_common/src/main/java/com/gis/common/util/FileUtils.java

@@ -4,7 +4,6 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.img.Img;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.URLUtil;
-import com.gis.common.task.AsyncTask;
 import lombok.extern.log4j.Log4j2;
 import org.apache.commons.lang3.StringUtils;
 import org.junit.Test;
@@ -29,15 +28,10 @@ import java.util.*;
 @Component
 public class FileUtils {
 
-    /** 临时文件存放目录*/
-    private final static String PROJECT_NAME = "cms_pano_fcb_dev_data/";
 
     @Autowired
     AliyunOssUtil aliyunOssUtil;
 
-    @Autowired
-    AsyncTask asyncTask;
-
 
     /**
      * 多文件上传
@@ -165,41 +159,6 @@ public class FileUtils {
     }
 
 
-    /**
-     * 重命名文件上传
-     * @param file
-     * @param savePath
-     * @return
-     * @throws IOException
-     */
-    public static String renameUpload(MultipartFile file, String savePath, String baseUrl)  {
-        if (file == null) {
-            log.error("文件不能为空");
-            return null;
-        }
-
-        String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS");
-
-        String fileName = file.getOriginalFilename();
-
-
-
-        String suffix = StringUtils.substringAfterLast(fileName, ".");
-        String newName = time  + "."  +suffix;
-        savePath = savePath  + newName;
-
-        try {
-            FileUtil.writeFromStream(file.getInputStream(), savePath);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-
-        String path = StringUtils.substringAfterLast(savePath, PROJECT_NAME);
-
-        return baseUrl+ PROJECT_NAME +path;
-
-    }
-
     /***
      * 文件上传oss
      * @param file
@@ -424,72 +383,6 @@ public class FileUtils {
 
 
     /**
-     * 使用opencv 生成缩略图
-     * 压缩图片
-     * 需要图片比例是2:1,否则图片压出来会变形
-     */
-    public  String compressImgAndUploadOss(String inputFilePath, String ossBasePath, String ossDomain) throws IOException, InterruptedException {
-        String serverBasePath = StringUtils.substringBeforeLast(inputFilePath, "/");
-
-        String time = DateUtil.format(new Date(), "yyyyMMdd_HHmmssSSS");
-        String suffix = StringUtils.substringAfterLast(inputFilePath, ".");
-        String fileName ="/thumb_"+ time  + "."  +suffix;
-
-        // 保存图片位置
-        String saveCompressImgPath = serverBasePath + fileName;
-
-//        Img.from(new File(inputFilePath)).scale(300, 150).write(new File(saveCompressImgPath));
-        // ./DAGE_Downsample 100m.jpg out.jpg 300 150
-        String cmd = "/home/720yun/100m/DAGE_Downsample " + inputFilePath + " " +  saveCompressImgPath + " 300 150";
-        log.info("cmd: " + cmd);
-        long start = System.currentTimeMillis();
-        CmdUtils.cmdThumb(cmd);
-        long end = System.currentTimeMillis();
-        log.info("openCV耗时: " + (end-start)/1000 + " s");
-        log.info("图片压缩成功: " + saveCompressImgPath);
-
-        // 上传oss
-        String ossPath = ossBasePath + "image/" + fileName;
-        log.info("ossPath: " + ossPath);
-        asyncTask.uploadOss(saveCompressImgPath, ossPath);
-        String ossUrl = ossDomain + ossPath;
-        log.info("图片上传成功: " + ossUrl);
-        return ossUrl;
-    }
-
-
-    /**
-     * 使用java 生成缩略图
-     * @param ossBasePath
-     * @param ossDomain
-     * @return
-     */
-//    public  String compressImgAndUploadOss2(MultipartFile file, String ossBasePath, String ossDomain, Integer width, Integer height, String imgName) throws Exception {
-//        // 保存图片位置
-//        String saveCompressImgPath = ossBasePath + imgName;
-//        String ossUrl = null;
-//
-////            Img.from(new File(file.getInputStream())).scale(width, height).write(new File(saveCompressImgPath));
-//            Img.from(new File("")).scale(width, height).write(new File(saveCompressImgPath));
-//            log.info("图片压缩成功: " + saveCompressImgPath);
-//
-//            if (FileUtil.isFile(saveCompressImgPath)) {
-//                // 上传oss
-//                String ossPath = ossBasePath + imgName;
-//                log.info("ossPath: " + ossPath);
-//                aliyunOssUtil.upload(saveCompressImgPath, ossPath);
-//                ossUrl = ossDomain + ossPath;
-//                log.info("图片上传成功: " + ossUrl);
-//            } else {
-//                log.error("缩略图不存在: " + saveCompressImgPath);
-//            }
-//
-//
-//        return ossUrl;
-//    }
-
-
-    /**
      * 压缩图片
      * 固定名称: 名称固定是xxx.jpg
      * @param inputFilePath

+ 0 - 4
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -7,7 +7,6 @@ import com.gis.common.config.RabbitConfig;
 import com.gis.common.constant.ConfigConstant;
 import com.gis.common.constant.MsgCode;
 import com.gis.common.exception.BaseRuntimeException;
-import com.gis.common.task.AsyncTask;
 import com.gis.common.util.*;
 import com.gis.domain.dto.*;
 import com.gis.domain.entity.FodderEntity;
@@ -26,7 +25,6 @@ import org.springframework.web.multipart.MultipartFile;
 
 import javax.transaction.Transactional;
 import java.awt.image.BufferedImage;
-import java.io.*;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -61,8 +59,6 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
     @Autowired
     AliyunOssUtil aliyunOssUtil;
 
-    @Autowired
-    AsyncTask asyncTask;
 
     @Override
     public IBaseMapper<FodderEntity, Long> getBaseMapper() {