Browse Source

feat(all): 修改报表异步任务异常问题

master
zhaoqiaobo 9 months ago
parent
commit
600d2f8062
  1. 4
      blade-service/logpm-report/src/main/java/com/logpm/report/service/IAsyncService.java
  2. 3
      blade-service/logpm-report/src/main/java/com/logpm/report/service/ReportDeliverService.java
  3. 17
      blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/AsyncServiceImpl.java
  4. 12
      blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportDataServiceImpl.java
  5. 6
      blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportDeliverServiceImpl.java

4
blade-service/logpm-report/src/main/java/com/logpm/report/service/IAsyncService.java

@ -1,6 +1,7 @@
package com.logpm.report.service; package com.logpm.report.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.logpm.report.dto.DeliveryTrainLoadedScanDTO;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -13,4 +14,7 @@ public interface IAsyncService {
void initExportData(ExportReader service, Wrapper query, Long pageSize, Long count, int finalNum, Map<Integer, List<Object>> pageMap, int finalI, CountDownLatch countDownLatch); void initExportData(ExportReader service, Wrapper query, Long pageSize, Long count, int finalNum, Map<Integer, List<Object>> pageMap, int finalI, CountDownLatch countDownLatch);
List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnInvnByIds(List<Long> idBatch);
List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnByIds(List<Long> idBatch);
} }

3
blade-service/logpm-report/src/main/java/com/logpm/report/service/ReportDeliverService.java

@ -3,6 +3,7 @@ package com.logpm.report.service;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.logpm.report.dto.DeliveryTrainLoadedScanDTO;
import com.logpm.report.query.DevilerDetailsQuery; import com.logpm.report.query.DevilerDetailsQuery;
import com.logpm.report.query.ReportCustomerQuery; import com.logpm.report.query.ReportCustomerQuery;
import com.logpm.report.query.ReportDevilerQuery; import com.logpm.report.query.ReportDevilerQuery;
@ -93,4 +94,6 @@ public interface ReportDeliverService {
void exportStockOrder(HttpServletResponse response, StockOrderVO vo, StockOrderQuery query); void exportStockOrder(HttpServletResponse response, StockOrderVO vo, StockOrderQuery query);
List<T> getDeliveryTrainPageReader(Page page, Wrapper query); List<T> getDeliveryTrainPageReader(Page page, Wrapper query);
List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnInvnByIds(List<Long> idBatch);
} }

17
blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/AsyncServiceImpl.java

@ -4,11 +4,14 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.logpm.report.dto.DeliveryTrainLoadedScanDTO;
import com.logpm.report.mapper.ReportDeliverMapeer;
import com.logpm.report.service.ExportReader; import com.logpm.report.service.ExportReader;
import com.logpm.report.service.IAsyncService; import com.logpm.report.service.IAsyncService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
import org.springblade.common.annotations.LogpmAsync; import org.springblade.common.annotations.LogpmAsync;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -24,6 +27,8 @@ public class AsyncServiceImpl implements IAsyncService {
@Resource @Resource
private Executor asyncExecutor; private Executor asyncExecutor;
@Autowired
private ReportDeliverMapeer reportDeliverMapeer;
@Override @Override
public CompletableFuture<List> getListCompletableFuture(ExportReader service, Wrapper query, Long pageSize, Long count, int finalNum, Map<Integer, List<Object>> pageMap, int finalI) { public CompletableFuture<List> getListCompletableFuture(ExportReader service, Wrapper query, Long pageSize, Long count, int finalNum, Map<Integer, List<Object>> pageMap, int finalI) {
@ -79,4 +84,16 @@ public class AsyncServiceImpl implements IAsyncService {
// 当前线程执行完成 // 当前线程执行完成
countDownLatch.countDown(); countDownLatch.countDown();
} }
@Override
@LogpmAsync("asyncExecutor")
public List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnInvnByIds(List<Long> idBatch) {
return reportDeliverMapeer.getDeliveryTrainLoadSacnInvnByIds(idBatch);
}
@Override
@LogpmAsync("asyncExecutor")
public List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnByIds(List<Long> idBatch) {
return reportDeliverMapeer.getDeliveryTrainLoadSacnByIds(idBatch);
}
} }

12
blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportDataServiceImpl.java

@ -6,11 +6,14 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.logpm.report.dto.DeliveryTrainLoadedScanDTO; import com.logpm.report.dto.DeliveryTrainLoadedScanDTO;
import com.logpm.report.mapper.ReportDeliverMapeer; import com.logpm.report.mapper.ReportDeliverMapeer;
import com.logpm.report.service.IAsyncService;
import com.logpm.report.service.ReportDataService; import com.logpm.report.service.ReportDataService;
import com.logpm.report.vo.ReportDevilerVO; import com.logpm.report.vo.ReportDevilerVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
@ -18,6 +21,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -30,6 +34,10 @@ import java.util.stream.Collectors;
public class ReportDataServiceImpl implements ReportDataService { public class ReportDataServiceImpl implements ReportDataService {
private final ReportDeliverMapeer reportDeliverMapeer; private final ReportDeliverMapeer reportDeliverMapeer;
private final IAsyncService asyncService;
@Autowired
private Executor asyncExecutor;
@Override @Override
public List<ReportDevilerVO> getReportDevilerVOList(IPage<ReportDevilerVO> page, Wrapper queryWrapper) { public List<ReportDevilerVO> getReportDevilerVOList(IPage<ReportDevilerVO> page, Wrapper queryWrapper) {
@ -62,7 +70,7 @@ public class ReportDataServiceImpl implements ReportDataService {
private @NotNull CompletableFuture<List<DeliveryTrainLoadedScanDTO>> getTrainLoadedScanInvnFuture(List<Long> idBatch, List<ReportDevilerVO> deliveryTrainPage) { private @NotNull CompletableFuture<List<DeliveryTrainLoadedScanDTO>> getTrainLoadedScanInvnFuture(List<Long> idBatch, List<ReportDevilerVO> deliveryTrainPage) {
CompletableFuture<List<DeliveryTrainLoadedScanDTO>> future = CompletableFuture.supplyAsync(() -> CompletableFuture<List<DeliveryTrainLoadedScanDTO>> future = CompletableFuture.supplyAsync(() ->
reportDeliverMapeer.getDeliveryTrainLoadSacnInvnByIds(idBatch)); asyncService.getDeliveryTrainLoadSacnInvnByIds(idBatch), (ThreadPoolTaskExecutor) asyncExecutor);
future.thenAccept(list -> { future.thenAccept(list -> {
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
// list 封装为map deliveryId为key // list 封装为map deliveryId为key
@ -86,7 +94,7 @@ public class ReportDataServiceImpl implements ReportDataService {
private @NotNull CompletableFuture<List<DeliveryTrainLoadedScanDTO>> getTrainLoadedScanFuture(List<Long> idBatch, List<ReportDevilerVO> deliveryTrainPage) { private @NotNull CompletableFuture<List<DeliveryTrainLoadedScanDTO>> getTrainLoadedScanFuture(List<Long> idBatch, List<ReportDevilerVO> deliveryTrainPage) {
CompletableFuture<List<DeliveryTrainLoadedScanDTO>> future = CompletableFuture.supplyAsync(() -> CompletableFuture<List<DeliveryTrainLoadedScanDTO>> future = CompletableFuture.supplyAsync(() ->
reportDeliverMapeer.getDeliveryTrainLoadSacnByIds(idBatch)); asyncService.getDeliveryTrainLoadSacnByIds(idBatch), (ThreadPoolTaskExecutor) asyncExecutor);
future.thenAccept(list -> { future.thenAccept(list -> {
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
// list 封装为map deliveryId为key // list 封装为map deliveryId为key

6
blade-service/logpm-report/src/main/java/com/logpm/report/service/impl/ReportDeliverServiceImpl.java

@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.logpm.basicdata.feign.IBasicdataWarehouseClient; import com.logpm.basicdata.feign.IBasicdataWarehouseClient;
import com.logpm.report.dto.DeliveryTrainLoadedScanDTO;
import com.logpm.report.mapper.ReportDeliverMapeer; import com.logpm.report.mapper.ReportDeliverMapeer;
import com.logpm.report.query.DevilerDetailsQuery; import com.logpm.report.query.DevilerDetailsQuery;
import com.logpm.report.query.ReportCustomerQuery; import com.logpm.report.query.ReportCustomerQuery;
@ -262,4 +263,9 @@ public class ReportDeliverServiceImpl implements ReportDeliverService {
return reportDataService.getReportDevilerVOList(page, query); return reportDataService.getReportDevilerVOList(page, query);
} }
@Override
public List<DeliveryTrainLoadedScanDTO> getDeliveryTrainLoadSacnInvnByIds(List<Long> idBatch) {
return reportDeliverMapeer.getDeliveryTrainLoadSacnInvnByIds(idBatch);
}
} }

Loading…
Cancel
Save