文档生成添加 11.23

master
zhc077 11 hours ago
parent 2250cb1137
commit ee3036e477
  1. 1
      jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/controller/ProjectController.java
  2. 14
      jeecg-boot/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/project/service/impl/Project4WordServiceImpl.java
  3. 54
      jeecg-boot/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/config/AsyncExecutor.java

@ -610,6 +610,7 @@ public class ProjectController extends JeecgController<Project, IProjectService>
log.setOperationMark("申请人提交项目书,申请人提交预算书");
//提交项目时,生成项目书pdf文件
// System.out.println("提交项目-the thread exec end:" + Thread.currentThread().getName());
iProject4WordService.createXiangMuShu4Word(project);
}
//申请单位审核通过,并向上级提交->科技主管部门待提交(区/县管理员)

@ -35,6 +35,7 @@ import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@ -257,7 +258,16 @@ public class Project4WordServiceImpl extends ServiceImpl<ProjectMapper, Project>
private String uploadPath;*/
@Override
@Async("getAsyncExecutorMethod")
public Object createXiangMuShu4Word(Project obj) {
log.info("---------createXiangMuShu4Word start,the thread name: {}", Thread.currentThread().getName());
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
long startTime = System.currentTimeMillis();
ProjectDto dto = getData4Xiangmushu(obj);
if (ObjectUtil.isEmpty(dto)) {
return null;
@ -326,6 +336,9 @@ public class Project4WordServiceImpl extends ServiceImpl<ProjectMapper, Project>
} catch (Exception e2) {
e2.printStackTrace();
}
long s = (System.currentTimeMillis() - startTime) / 1000;
log.info("---------createXiangMuShu4Word,the thread name:{},生成pdf文件用时: {}", Thread.currentThread().getName(), s + "秒");
return dto;
}
@ -333,6 +346,7 @@ public class Project4WordServiceImpl extends ServiceImpl<ProjectMapper, Project>
public Object createPdf(String wordPath, File file, String padFileName) {
if (wordPath.equals("")) {
log.error("---------------word文件路径不能为空!");
return null;
} else {
try {
// FileUtils.convertDocxToPdf(wordPath, file + File.separator + padFileName);

@ -0,0 +1,54 @@
package org.jeecg.modules.system.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
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 java.util.concurrent.ThreadPoolExecutor;
/**
* @Description: TODO
* @Author: Z.H.C
* @CreateTime: 2024-11-23 16:52
* @Version: 1.0
*/
@Configuration
@EnableAsync
public class AsyncExecutor {
private static final Logger logger = LoggerFactory.getLogger(AsyncExecutor.class);
//核心线程数
private static final int CORE_POOL_SIZE = 5;
//最大线程数
private static final int MAX_POOL_SIZE = 5;
//队列大小
private static final int QUEUE_CAPACITY = 30;
//线程池中的线程的名称前缀
private static final String THREAD_NAME = "MyExecutor-";
@Bean
public ThreadPoolTaskExecutor getAsyncExecutorMethod() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//配置核心线程数
executor.setCorePoolSize(CORE_POOL_SIZE);
//配置最大线程数
executor.setMaxPoolSize(MAX_POOL_SIZE);
//配置队列大小
executor.setQueueCapacity(QUEUE_CAPACITY);
//配置线程池中的线程的名称前缀
executor.setThreadNamePrefix(THREAD_NAME);
//配置线程池拒绝策略,我设置为CallerRunsPolicy,当线程和队列都满了,由发起线程的主线程自己执行
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.initialize();
return executor;
}
}
Loading…
Cancel
Save