zouxuan 3 år sedan
förälder
incheckning
2fd2a2d8f9

+ 4 - 9
mec-biz/src/main/java/com/ym/mec/biz/service/ExportService.java

@@ -270,18 +270,13 @@ public interface ExportService {
     //保存下载记录
     ManagerDownload saveManagerDownload(ExportTypeEnum exportTypeEnum, Integer userId);
 
-    @Async
-    abstract void orderList(Map<String, Object> params, ManagerDownload managerDownload,List<String> headColumns) throws FileNotFoundException;
+    void orderList(Map<String, Object> params, ManagerDownload managerDownload,List<String> headColumns) throws FileNotFoundException;
 
+    void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload,List<String> headColumns) throws FileNotFoundException;
 
-    @Async
-    abstract void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload,List<String> headColumns) throws FileNotFoundException;
+    void superFindCourseSchedules(EndCourseScheduleQueryInfo queryInfo, ManagerDownload managerDownload) throws FileNotFoundException;
 
-    @Async
-    abstract void superFindCourseSchedules(EndCourseScheduleQueryInfo queryInfo, ManagerDownload managerDownload) throws FileNotFoundException;
-
-    @Async
-    abstract void studentVipPractice(String organId, ManagerDownload managerDownload, Integer tenantId,List<String> headColumns) throws FileNotFoundException;
+    void studentVipPractice(String organId, ManagerDownload managerDownload, Integer tenantId,List<String> headColumns) throws FileNotFoundException;
 
     void queryStudentCourseInfo(String organId, Integer tenantId, String vip, ManagerDownload managerDownload, List<String> headColumns,ExportEnum exportEnum) throws FileNotFoundException;
 }

+ 48 - 35
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -1391,11 +1391,14 @@ public class ExportServiceImpl implements ExportService {
         }
         queryInfo.setRoutingOrganId(null);
         ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.ROUTE_ORDER,sysUser.getId());
-        try {
-            this.routeOrderList(params, managerDownload, headColumns);
-        } catch (FileNotFoundException e) {
-            return BaseController.failed(e.getMessage());
-        }
+        ExecutorService executor = Executors.newCachedThreadPool();
+        CompletableFuture.runAsync(()->{
+            try {
+                this.routeOrderList(params, managerDownload, headColumns);
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+        },executor);
         HttpResponseResult<Object> succeed = BaseController.succeed();
         succeed.setMsg(managerDownload.getName() + "导出申请已提交,请到【报表中心-下载列表查看】");
         return succeed;
@@ -1412,11 +1415,14 @@ public class ExportServiceImpl implements ExportService {
         Integer tenantId = TenantContextHolder.getTenantId();
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.STUDENT_VIP_PRACTICE,sysUser.getId());
-        try {
-            this.studentVipPractice(organId, managerDownload, tenantId,headColumns);
-        } catch (FileNotFoundException e) {
-            return BaseController.failed(e.getMessage());
-        }
+        ExecutorService executor = Executors.newCachedThreadPool();
+        CompletableFuture.runAsync(()->{
+            try {
+                this.studentVipPractice(organId, managerDownload, tenantId,headColumns);
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+        },executor);
         HttpResponseResult<Object> succeed = BaseController.succeed();
         succeed.setMsg(managerDownload.getName() + "导出申请已提交,请到【报表中心-下载列表查看】");
         return succeed;
@@ -1433,11 +1439,14 @@ public class ExportServiceImpl implements ExportService {
         }
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.STUDENT_VIP_COURSE_INFO,sysUser.getId());
-        try {
-            this.queryStudentCourseInfo(organId, tenantId,"VIP", managerDownload,headColumns,ExportEnum.STUDENT_VIP_COURSE_INFO);
-        } catch (FileNotFoundException e) {
-            return BaseController.failed(e.getMessage());
-        }
+        ExecutorService executor = Executors.newCachedThreadPool();
+        CompletableFuture.runAsync(()->{
+            try {
+                this.queryStudentCourseInfo(organId, tenantId,"VIP", managerDownload,headColumns,ExportEnum.STUDENT_VIP_COURSE_INFO);
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+        },executor);
         HttpResponseResult<Object> succeed = BaseController.succeed();
         succeed.setMsg(managerDownload.getName() + "导出申请已提交,请到【报表中心-下载列表查看】");
         return succeed;
@@ -1454,11 +1463,14 @@ public class ExportServiceImpl implements ExportService {
         }
         SysUser sysUser = sysUserFeignService.queryUserInfo();
         ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.STUDENT_MUSIC_THEORY_COURSE_INFO,sysUser.getId());
-        try {
-            this.queryStudentCourseInfo(organId, tenantId,"THEORY", managerDownload,headColumns,ExportEnum.STUDENT_MUSIC_THEORY_COURSE_INFO);
-        } catch (FileNotFoundException e) {
-            return BaseController.failed(e.getMessage());
-        }
+        ExecutorService executor = Executors.newCachedThreadPool();
+        CompletableFuture.runAsync(()->{
+            try {
+                this.queryStudentCourseInfo(organId, tenantId,"THEORY", managerDownload,headColumns,ExportEnum.STUDENT_MUSIC_THEORY_COURSE_INFO);
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+        },executor);
         HttpResponseResult<Object> succeed = BaseController.succeed();
         succeed.setMsg(managerDownload.getName() + "导出申请已提交,请到【报表中心-下载列表查看】");
         return succeed;
@@ -1491,11 +1503,14 @@ public class ExportServiceImpl implements ExportService {
             return BaseController.failed("数据集太大,不能导出.最大数据集不能超过50000");
         }
         ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.ORDER,sysUser.getId());
-        try {
-            this.orderList(params, managerDownload, headColumns);
-        } catch (FileNotFoundException e) {
-            return BaseController.failed(e.getMessage());
-        }
+        ExecutorService executor = Executors.newCachedThreadPool();
+        CompletableFuture.runAsync(()->{
+            try {
+                this.orderList(params, managerDownload, headColumns);
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+        },executor);
         HttpResponseResult<Object> succeed = BaseController.succeed();
         succeed.setMsg(managerDownload.getName() + "导出申请已提交,请到【报表中心-下载列表查看】");
         return succeed;
@@ -1520,11 +1535,14 @@ public class ExportServiceImpl implements ExportService {
             return BaseController.failed("数据集太大,不能导出.最大数据集不能超过50000");
         }
         ManagerDownload managerDownload = saveManagerDownload(ExportTypeEnum.COURSE_SCHEDULE,sysUser.getId());
-        try {
-            this.superFindCourseSchedules(queryInfo, managerDownload);
-        } catch (FileNotFoundException e) {
-            return BaseController.failed(e.getMessage());
-        }
+        ExecutorService executor = Executors.newCachedThreadPool();
+        CompletableFuture.runAsync(()->{
+            try {
+                this.superFindCourseSchedules(queryInfo, managerDownload);
+            } catch (FileNotFoundException e) {
+                e.printStackTrace();
+            }
+        },executor);
         HttpResponseResult<Object> succeed = BaseController.succeed();
         succeed.setMsg(managerDownload.getName() + "导出申请已提交,请到【报表中心-下载列表查看】");
         return succeed;
@@ -1553,7 +1571,6 @@ public class ExportServiceImpl implements ExportService {
 
 
     @Override
-    @Async
     public void orderList(Map<String, Object> params, ManagerDownload managerDownload,List<String> headColumns) throws FileNotFoundException {
         List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentOrderService.ExportQueryPage(params);
         long i = 1;
@@ -1870,7 +1887,6 @@ public class ExportServiceImpl implements ExportService {
     }
 
     @Override
-    @Async
     public void routeOrderList(Map<String, Object> params, ManagerDownload managerDownload,List<String> headColumns) throws FileNotFoundException {
         List<StudentPaymentOrderExportDto> studentPaymentOrderExportDtos = studentPaymentRouteOrderDao.ExportQueryPage(params);
 
@@ -2383,7 +2399,6 @@ public class ExportServiceImpl implements ExportService {
     }
 
     @Override
-    @Async
     public void superFindCourseSchedules(EndCourseScheduleQueryInfo queryInfo, ManagerDownload managerDownload) throws FileNotFoundException {
         List<CourseScheduleEndDto> rows = courseScheduleService.endFindCourseSchedules(queryInfo).getRows();
         for (CourseScheduleEndDto row : rows) {
@@ -2424,7 +2439,6 @@ public class ExportServiceImpl implements ExportService {
     }
 
     @Override
-    @Async
     public void studentVipPractice(String organId, ManagerDownload managerDownload, Integer tenantId,List<String> headColumns) throws FileNotFoundException {
         List<StudentVipPracticeExportDto> studentVipPracticeExportDtos = courseScheduleStudentPaymentDao.exportStudentVipPractice(organId, tenantId);
         if(studentVipPracticeExportDtos != null && studentVipPracticeExportDtos.size() > 0){
@@ -2490,7 +2504,6 @@ public class ExportServiceImpl implements ExportService {
     }
 
     @Override
-    @Async
     public void queryStudentCourseInfo(String organId, Integer tenantId, String groupType, ManagerDownload managerDownload, List<String> headColumns,ExportEnum exportEnum) throws FileNotFoundException {
         List<ExportStudentCourseInfoDto> studentCourseInfoDtos = courseScheduleStudentPaymentDao.queryStudentCourseInfo(organId,tenantId,groupType);
         String basePath = new ApplicationHome(this.getClass()).getSource().getParentFile().getPath();