浏览代码

课表导出bug

zouxuan 3 年之前
父节点
当前提交
17167ac895

+ 12 - 0
mec-biz/src/main/java/com/ym/mec/biz/service/impl/ExportServiceImpl.java

@@ -169,6 +169,8 @@ public class ExportServiceImpl implements ExportService {
     private MusicGroupService musicGroupService;
     @Autowired
     private SysUserCashAccountLogService sysUserCashAccountLogService;
+    @Autowired
+    private SysTenantConfigService sysTenantConfigService;
 
     @Value("${spring.profiles.active:dev}")
     private String profiles;
@@ -1540,6 +1542,16 @@ public class ExportServiceImpl implements ExportService {
         queryInfo.setOrganIdList(organizationService.getEmployeeOrgan(sysUser.getId(),queryInfo.getOrganIdList(),sysUser.getIsSuperAdmin()));
         Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
+        Integer tenantId = TenantContextHolder.getTenantId();
+        if(Objects.equals("COURSE_TIME_ERROR",queryInfo.getSearchType())){
+            String courseStartTimeError = sysTenantConfigService.getTenantConfigValue(SysConfigService.COURSE_START_TIME_ERROR, tenantId);
+            String courseEndTimeError = sysTenantConfigService.getTenantConfigValue(SysConfigService.COURSE_END_TIME_ERROR, tenantId);
+            if(StringUtils.isEmpty(courseStartTimeError) || StringUtils.isEmpty(courseEndTimeError)){
+                return BaseController.failed("没有可导出的数据");
+            }
+            params.put("courseStartTimeError",courseStartTimeError);
+            params.put("courseEndTimeError",courseEndTimeError);
+        }
         int count = scheduleService.endCountCourseSchedules(params);
         if (count <= 0) {
             return BaseController.failed("没有可导出的数据");

+ 23 - 1
mec-web/src/main/java/com/ym/mec/web/controller/ExportController.java

@@ -33,6 +33,9 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import java.util.stream.Collectors;
 
 @RequestMapping
@@ -132,6 +135,8 @@ public class ExportController extends BaseController {
     private MusicEnlightenmentQuestionnaireService musicEnlightenmentQuestionnaireService;
     @Autowired
     private MusicGroupService musicGroupService;
+    @Autowired
+    private SysTenantConfigService sysTenantConfigService;
 
     @ApiOperation(value = "获取可导出字段")
     @RequestMapping("export/getFields")
@@ -1961,6 +1966,16 @@ public class ExportController extends BaseController {
         queryInfo.setOrganIdList(organizationService.getEmployeeOrgan(sysUser.getId(),queryInfo.getOrganIdList(),sysUser.getIsSuperAdmin()));
         Map<String, Object> params = new HashMap<>();
         MapUtil.populateMap(params, queryInfo);
+        Integer tenantId = TenantContextHolder.getTenantId();
+        if(Objects.equals("COURSE_TIME_ERROR",queryInfo.getSearchType())){
+            String courseStartTimeError = sysTenantConfigService.getTenantConfigValue(SysConfigService.COURSE_START_TIME_ERROR, tenantId);
+            String courseEndTimeError = sysTenantConfigService.getTenantConfigValue(SysConfigService.COURSE_END_TIME_ERROR, tenantId);
+            if(StringUtils.isEmpty(courseStartTimeError) || StringUtils.isEmpty(courseEndTimeError)){
+                return failed("没有可导出的数据");
+            }
+            params.put("courseStartTimeError",courseStartTimeError);
+            params.put("courseEndTimeError",courseEndTimeError);
+        }
         int count = scheduleService.endCountCourseSchedules(params);
         if (count <= 0) {
             return failed("没有可导出的数据");
@@ -1969,7 +1984,14 @@ public class ExportController extends BaseController {
             return failed("数据集太大,不能导出.最大数据集不能超过50000");
         }
         ManagerDownload managerDownload = exportService.saveManagerDownload(ExportTypeEnum.COURSE_SCHEDULE,sysUser.getId());
-        exportService.superFindCourseSchedules(queryInfo, managerDownload);
+        ExecutorService executor = Executors.newCachedThreadPool();
+        CompletableFuture.runAsync(()->{
+            try {
+                exportService.superFindCourseSchedules(queryInfo, managerDownload);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        },executor);
         HttpResponseResult<Object> succeed = succeed();
         succeed.setMsg(managerDownload.getName() + "导出申请已提交,请到【报表中心-下载列表查看】");
         return succeed;