修改申请
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.ruoyi.common.enums;
|
||||
|
||||
/**
|
||||
* @author wangqiong
|
||||
* @description 修改案件的提交状态
|
||||
* @date 2023-11-17 14:05
|
||||
*/
|
||||
public enum UpdateSubmitStatus
|
||||
{
|
||||
UNCOMMITTED(0, "未提交"),
|
||||
COMMITTED(1, "已提交"),
|
||||
AGREE(2, "同意已修改的案件"),
|
||||
REFUSE(3, "拒绝已修改的案件"),
|
||||
REVOKE(4, "撤销"),
|
||||
AGREE_REVOKE(5, "同意撤销修改"),
|
||||
REFUSE_REVOKE(6, "拒绝撤销修改"),
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
private final String text;
|
||||
|
||||
UpdateSubmitStatus(Integer code, String text)
|
||||
{
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ruoyi.common.enums;
|
||||
|
||||
/**
|
||||
* @author wangqiong
|
||||
* @description 是否枚举
|
||||
* @date 2023-11-17 14:05
|
||||
*/
|
||||
public enum YesOrNoEnum
|
||||
{
|
||||
NO(0, "否"),
|
||||
YES(1, "是"),
|
||||
|
||||
;
|
||||
|
||||
private final Integer code;
|
||||
private final String text;
|
||||
|
||||
YesOrNoEnum(Integer code, String text)
|
||||
{
|
||||
this.code = code;
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public Integer getCode()
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return text;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package com.ruoyi.common.utils.thread;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* @description 线程池工具类
|
||||
* @Author wangqiong
|
||||
* @Date 2023/11/7 15:41
|
||||
* @Version V1.0
|
||||
**/
|
||||
@Slf4j
|
||||
public class ThreadPoolUtil {
|
||||
/** cpu核心数 */
|
||||
private static int corePoolSize = (Runtime.getRuntime().availableProcessors());
|
||||
/**创建固定大小线程池*/
|
||||
private static ExecutorService executors = new ThreadPoolExecutor(
|
||||
corePoolSize,
|
||||
corePoolSize,
|
||||
0L,
|
||||
TimeUnit.MILLISECONDS,
|
||||
new LinkedBlockingQueue<>());
|
||||
|
||||
/**
|
||||
* 异步任务
|
||||
* @param task
|
||||
*/
|
||||
public static void execute(Runnable task){
|
||||
executors.execute(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* 可获取返回结果的任务且可设置超时时间
|
||||
* @param task
|
||||
* @param timeout
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> T execute(Callable<T> task, long timeout){
|
||||
Future<T> future = executors.submit(task);
|
||||
T result = null;
|
||||
try {
|
||||
result = future.get(timeout, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
future.cancel(true);
|
||||
log.error("ThreadPoolUtil.InterruptedException. e:{}", e);
|
||||
} catch (ExecutionException e) {
|
||||
future.cancel(true);
|
||||
log.error("ThreadPoolUtil.ExecutionException. e:{}", e);
|
||||
} catch (TimeoutException e) {
|
||||
future.cancel(true);
|
||||
log.error("ThreadPoolUtil.TimeoutException. e:{}", e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 可获取返回结果的任务
|
||||
* @param task
|
||||
* @return
|
||||
*/
|
||||
public static <T> Future<T> submit(Callable<T> task){
|
||||
return executors.submit(task);
|
||||
}
|
||||
|
||||
/**
|
||||
* 可获取返回结果的任务
|
||||
* @param tasks
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> submit(Callable<T>... tasks){
|
||||
List<Future<T>> list=new ArrayList<>();
|
||||
List<T> resultList=new ArrayList<>();
|
||||
if(tasks==null||tasks.length==0){
|
||||
return resultList;
|
||||
}
|
||||
for(Callable<T> task:tasks){
|
||||
list.add(executors.submit(task));
|
||||
}
|
||||
for(Future<T> future:list){
|
||||
try {
|
||||
resultList.add(future.get());
|
||||
} catch (InterruptedException e) {
|
||||
future.cancel(true);
|
||||
log.error("ThreadPoolUtil.InterruptedException. e:{}", e);
|
||||
} catch (ExecutionException e) {
|
||||
future.cancel(true);
|
||||
log.error("ThreadPoolUtil.ExecutionException. e:{}", e);
|
||||
}
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行完所有返回
|
||||
* @param tasks
|
||||
*/
|
||||
public static void submit(Runnable ...tasks){
|
||||
if(tasks==null||tasks.length==0){
|
||||
return;
|
||||
}
|
||||
List<CompletableFuture> futureList=new ArrayList<>();
|
||||
for (Runnable task : tasks) {
|
||||
futureList.add(CompletableFuture.runAsync(task,executors));
|
||||
}
|
||||
CompletableFuture.allOf(futureList.toArray(new CompletableFuture[futureList.size()])).join();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user