工单优化
This commit is contained in:
parent
98791b9d6c
commit
7fc738861f
@ -27,12 +27,11 @@ import com.zhgd.xmgl.modules.quality.service.IQualityRegionService;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
|
||||
import com.zhgd.xmgl.util.EntityUtils;
|
||||
import com.zhgd.xmgl.util.MapBuilder;
|
||||
import com.zhgd.xmgl.util.PageUtil;
|
||||
import com.zhgd.xmgl.util.RefUtil;
|
||||
import com.zhgd.xmgl.util.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -86,6 +85,9 @@ public class WorkTicketServiceImpl extends ServiceImpl<WorkTicketMapper, WorkTic
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IWorkTicketOrderService workTicketOrderService;
|
||||
@Autowired
|
||||
@Qualifier("doubleCarbonExecutor")
|
||||
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||
|
||||
@Override
|
||||
public IPage<WorkTicketVo> queryPageList(HashMap<String, Object> param) {
|
||||
@ -254,14 +256,6 @@ public class WorkTicketServiceImpl extends ServiceImpl<WorkTicketMapper, WorkTic
|
||||
workTicketHistoryService.completeEndTimeByTicketId(ticketId);
|
||||
}
|
||||
if (workTicketService.enableBindCamera(ticket.getProjectSn())) {
|
||||
PoliceCameraManufacturer manufacturer = policeCameraManufacturerFactory.getPoliceCameraManufacturer(ticket.getProjectSn());
|
||||
if (manufacturer != null) {
|
||||
if (workTicketDto.getOperateStatus() == 1 || workTicketDto.getOperateStatus() == 3) {
|
||||
manufacturer.beginWork(ticket, his.getId() + "", his.getNo());
|
||||
} else if (workTicketDto.getOperateStatus() == 2 || workTicketDto.getOperateStatus() == 4) {
|
||||
manufacturer.endWork(ticket, his.getId() + "");
|
||||
}
|
||||
}
|
||||
if (workTicketDto.getOperateStatus() == 1 || workTicketDto.getOperateStatus() == 3) {
|
||||
for (PoliceCameraItem item : ticket.getItemList()) {
|
||||
WorkTicketOrder order = new WorkTicketOrder();
|
||||
@ -284,6 +278,17 @@ public class WorkTicketServiceImpl extends ServiceImpl<WorkTicketMapper, WorkTic
|
||||
.eq(WorkTicketOrder::getHistoryId, his.getId())
|
||||
);
|
||||
}
|
||||
WorkTicketHistory finalHis = his;
|
||||
AsyncTaskUtil.runAsync(() -> {
|
||||
PoliceCameraManufacturer manufacturer = policeCameraManufacturerFactory.getPoliceCameraManufacturer(ticket.getProjectSn());
|
||||
if (manufacturer != null) {
|
||||
if (workTicketDto.getOperateStatus() == 1 || workTicketDto.getOperateStatus() == 3) {
|
||||
manufacturer.beginWork(ticket, finalHis.getId() + "", finalHis.getNo());
|
||||
} else if (workTicketDto.getOperateStatus() == 2 || workTicketDto.getOperateStatus() == 4) {
|
||||
manufacturer.endWork(ticket, finalHis.getId() + "");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
38
src/main/java/com/zhgd/xmgl/util/AsyncTaskUtil.java
Normal file
38
src/main/java/com/zhgd/xmgl/util/AsyncTaskUtil.java
Normal file
@ -0,0 +1,38 @@
|
||||
package com.zhgd.xmgl.util;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@Component
|
||||
public class AsyncTaskUtil {
|
||||
|
||||
private static ThreadPoolTaskExecutor doubleCarbonExecutor;
|
||||
|
||||
/**
|
||||
* 执行异步任务
|
||||
*/
|
||||
public static CompletableFuture<Void> runAsync(Runnable task) {
|
||||
return CompletableFuture.runAsync(task, doubleCarbonExecutor);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行异步任务并支持异常处理
|
||||
*/
|
||||
public static CompletableFuture<Void> runAsync(Runnable task, Consumer<Throwable> exceptionHandler) {
|
||||
return CompletableFuture.runAsync(task, doubleCarbonExecutor)
|
||||
.exceptionally(throwable -> {
|
||||
exceptionHandler.accept(throwable);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
@Autowired
|
||||
public void setDoubleCarbonExecutor(@Qualifier("doubleCarbonExecutor") ThreadPoolTaskExecutor executor) {
|
||||
AsyncTaskUtil.doubleCarbonExecutor = executor;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user