Explorar o código

机构导入,课程删除

caozixuan %!s(int64=2) %!d(string=hai) anos
pai
achega
b8c082be8e
Modificáronse 17 ficheiros con 229 adicións e 81 borrados
  1. 72 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncSysOrgImportService.java
  2. 9 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/TaskLogicService.java
  3. 35 0
      distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java
  4. 1 1
      distributed-print-business/src/main/resources/db/2、init-table-data.sql
  5. 10 17
      distributed-print/src/main/java/com/qmth/distributed/print/api/BasicCourseController.java
  6. 1 1
      distributed-print/src/main/java/com/qmth/distributed/print/api/SysController.java
  7. 32 7
      distributed-print/src/main/java/com/qmth/distributed/print/api/SysOrgController.java
  8. 27 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/excel/SysOrgImportDto.java
  9. 1 0
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/TaskTypeEnum.java
  10. 0 2
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/mapper/BasicCourseMapper.java
  11. 4 9
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/BasicCourseService.java
  12. 7 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/SysOrgService.java
  13. 24 37
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicCourseServiceImpl.java
  14. 4 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysOrgServiceImpl.java
  15. 1 1
      teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TeachcloudCommonServiceImpl.java
  16. 0 3
      teachcloud-common/src/main/resources/mapper/BasicCourseMapper.xml
  17. 1 1
      teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/SysOrgController.java

+ 72 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncSysOrgImportService.java

@@ -0,0 +1,72 @@
+package com.qmth.distributed.print.business.templete.execute;
+
+import cn.hutool.core.date.DateUtil;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.distributed.print.business.templete.importData.AsyncImportTaskTemplete;
+import com.qmth.distributed.print.business.templete.service.TaskLogicService;
+import com.qmth.teachcloud.common.contant.SpringContextHolder;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.entity.TBTask;
+import com.qmth.teachcloud.common.enums.TaskResultEnum;
+import com.qmth.teachcloud.common.enums.TaskStatusEnum;
+import com.qmth.teachcloud.common.service.TBTaskService;
+import com.qmth.teachcloud.common.util.Result;
+import com.qmth.teachcloud.common.util.ResultUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.StringJoiner;
+
+/**
+ * @Description: 系统机构批量导入
+ * @Author: CaoZixuan
+ * @Date: 2022-08-16
+ */
+@Service
+public class AsyncSysOrgImportService extends AsyncImportTaskTemplete {
+    private final static Logger log = LoggerFactory.getLogger(AsyncSysOrgImportService.class);
+
+    public static final String ORG_TITLE = "机构数据";
+
+
+    @Override
+    public Result importTask(Map<String, Object> map) throws IOException, Exception {
+        TBTask tbTask = (TBTask) map.get(SystemConstant.TASK);
+        InputStream inputStream = super.getUploadFileInputStream(tbTask);
+        map.put("inputStream", inputStream);
+
+        StringJoiner stringJoinerSummary = new StringJoiner("\n")
+                .add(MessageFormat.format("{0}{1}{2}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), BEGIN_TITLE, ORG_TITLE));
+        tbTask.setStatus(TaskStatusEnum.RUNNING);
+        TBTaskService tbTaskService = SpringContextHolder.getBean(TBTaskService.class);
+        tbTaskService.updateById(tbTask);
+
+        try {
+            TaskLogicService taskLogicService = SpringContextHolder.getBean(TaskLogicService.class);
+
+            // 执行导入基础用户数据
+            Map<String, Object> result = taskLogicService.executeImportSysOrgLogic(map);
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), FINISH_TITLE, Long.valueOf(String.valueOf(result.get("dataCount"))), FINISH_SIZE));
+            tbTask.setResult(TaskResultEnum.SUCCESS);
+        } catch (Exception e) {
+            log.error(SystemConstant.LOG_ERROR, e);
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
+            tbTask.setResult(TaskResultEnum.ERROR);
+            if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        } finally {//生成txt文件
+            tbTask.setSummary(stringJoinerSummary.toString());
+            super.createTxt(tbTask);
+        }
+        return ResultUtil.ok(map);
+    }
+}

+ 9 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/TaskLogicService.java

@@ -81,6 +81,15 @@ public interface TaskLogicService {
      */
     Map<String, Object> executeImportBasicCourseLogic(Map<String, Object> map) throws Exception;
 
+    /**
+     * 处理导入机构数据
+     *
+     * @param map 数据源
+     * @return 结果
+     * @throws Exception 异常
+     */
+    Map<String, Object> executeImportSysOrgLogic(Map<String, Object> map) throws Exception;
+
     /**
      * 处理导入用户数据
      *

+ 35 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/TaskLogicServiceImpl.java

@@ -44,6 +44,7 @@ import org.apache.poi.ss.usermodel.Workbook;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -57,6 +58,7 @@ import org.springframework.util.LinkedMultiValueMap;
 import javax.annotation.Resource;
 import java.io.*;
 import java.lang.reflect.Field;
+import java.security.NoSuchAlgorithmException;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -1353,6 +1355,39 @@ public class TaskLogicServiceImpl implements TaskLogicService {
         return basicCourseService.executeBasicCourseImportLogic(finalList, map);
     }
 
+    @Transactional
+    @Override
+    public Map<String, Object> executeImportSysOrgLogic(Map<String, Object> map) throws IOException, NoSuchFieldException, NoSuchAlgorithmException {
+        InputStream inputStream = (InputStream) map.get("inputStream");
+        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(inputStream, Lists.newArrayList(SysOrgImportDto.class, DescribeImportDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> finalExcelList);
+        List<String> orgInfoList = new ArrayList<>();
+        for (int i = 0; i < finalList.size(); i++) {
+            LinkedMultiValueMap<Integer, Object> excelMap = finalList.get(i);
+            List<Object> sysOrgImportDtoList = excelMap.get(i);
+            assert sysOrgImportDtoList != null;
+            if (sysOrgImportDtoList.get(0) instanceof DescribeImportDto) {
+                continue;
+            }
+            map.put("dataCount", sysOrgImportDtoList.size());
+            //  处理机构
+            if (sysOrgImportDtoList.get(0) instanceof SysOrgImportDto) {
+                List<SysOrgImportDto> datasource = sysOrgImportDtoList.stream().map(e -> {
+                    SysOrgImportDto sysOrgImportDto = new SysOrgImportDto();
+                    BeanUtils.copyProperties(e, sysOrgImportDto);
+                    return sysOrgImportDto;
+                }).collect(Collectors.toList());
+                if (datasource.size() > 0) {
+                    datasource.forEach(e -> orgInfoList.add(e.getName()));
+                }
+            }
+        }
+        if (orgInfoList.size() > 0){
+            SysUser requestUser = (SysUser) map.get(SystemConstant.SYS_USER);
+            sysOrgService.createOrGetOrgByOrgInfo(orgInfoList,requestUser);
+        }
+        return map;
+    }
+
     @Transactional
     @Override
     public Map<String, Object> executeImportSysUserLogic(Map<String, Object> map) throws Exception {

+ 1 - 1
distributed-print-business/src/main/resources/db/2、init-table-data.sql

@@ -703,7 +703,7 @@ INSERT INTO `sys_config` VALUES (5, NULL, NULL, 'sys.message.resendCount', '失
 INSERT INTO `sys_config` VALUES (6, NULL, NULL, 'sys.sync.enable', '是否开启数据同步云阅卷', 'true', 'true-启用,false-禁用', 1, NULL, NULL, NULL);
 INSERT INTO `sys_config` VALUES (7, NULL, NULL, 'sys.txt.charset', 'txt文件编码', 'gbk', NULL, 1, NULL, NULL, NULL);
 
-INSERT INTO `sys_role` VALUES (1, NULL, NULL, '系统管理员', 1, 'ADMIN', NULL, NULL, NULL, NULL, 1, NULL);
+INSERT INTO `sys_role` VALUES (1, NULL, NULL, '系统管理员', 1, 'ADMIN', NULL, NULL, NULL, NULL, 1, NULL, '系统内置');
 INSERT INTO `sys_role` VALUES (2, NULL, NULL, '教务处老师', 1, 'OFFICE_TEACHER', NULL, NULL, NULL, NULL, 1, 'ANALYSIS', '系统内置');
 INSERT INTO `sys_role` VALUES (3, NULL, NULL, '学院院长', 1, 'PRESIDENT', NULL, NULL, NULL, NULL, 1, 'ANALYSIS', '系统内置');
 INSERT INTO `sys_role` VALUES (4, NULL, NULL, '任课老师', 1, 'TEACHER', NULL, NULL, NULL, NULL, 1, 'ANALYSIS', '系统内置');

+ 10 - 17
distributed-print/src/main/java/com/qmth/distributed/print/api/BasicCourseController.java

@@ -85,10 +85,9 @@ public class BasicCourseController {
                                       @ApiParam(value = "课程名称(模糊查询)") @RequestParam(required = false) String courseName,
                                       @ApiParam(value = "创建时间(起始位置)") @RequestParam(required = false) String startCreateTime,
                                       @ApiParam(value = "创建时间(终止位置)") @RequestParam(required = false) String endCreateTime,
-                                      @ApiParam(value = "状态") @RequestParam(required = false) Boolean enable,
                                       @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
                                       @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
-        return ResultUtil.ok(basicCourseService.basicCoursePage(SystemConstant.convertIdToLong(belongOrgId), courseName, SystemConstant.convertIdToLong(startCreateTime), SystemConstant.convertIdToLong(endCreateTime), enable, pageNumber, pageSize));
+        return ResultUtil.ok(basicCourseService.basicCoursePage(SystemConstant.convertIdToLong(belongOrgId), courseName, SystemConstant.convertIdToLong(startCreateTime), SystemConstant.convertIdToLong(endCreateTime), pageNumber, pageSize));
     }
 
     @ApiOperation(value = "课程管理-新增/编辑")
@@ -102,33 +101,27 @@ public class BasicCourseController {
         return ResultUtil.ok(basicCourseService.saveBasicCourse(basicCourseParams, sysUser));
     }
 
-    @ApiOperation(value = "课程管理-批量启用/禁用")
-    @RequestMapping(value = "/enable", method = RequestMethod.POST)
+    @ApiOperation(value = "课程管理-批量删除")
+    @RequestMapping(value = "/delete_batch", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "删除成功", response = EditResult.class)})
-    public Result enableBasicCourse(@ApiParam(value = "选择的要删除的课程id集合", required = true) @RequestParam List<Long> idList,
-                                    @ApiParam(value = "启用/禁用(默认禁用)") @RequestParam(required = false) Boolean enable) {
-        if (Objects.isNull(enable)) {
-            enable = false;
-        }
-        return ResultUtil.ok(basicCourseService.removeBasicCourseBatch(idList, enable));
+    public Result enableBasicCourse(@ApiParam(value = "选择的要删除的课程id集合", required = true) @RequestParam List<Long> idList) {
+        return ResultUtil.ok(basicCourseService.removeBasicCourseBatch(idList));
     }
 
-    @ApiOperation(value = "课程管理-根据查询条件批量启用/禁用")
-    @RequestMapping(value = "/enable_by_query", method = RequestMethod.POST)
+    @ApiOperation(value = "课程管理-根据查询条件批量删除")
+    @RequestMapping(value = "/delete_by_query", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "删除成功", response = EditResult.class)})
     @OperationLogDetail(detail = "根据查询条件【所属机构id[{{belongOrgId}}],课程名称(模糊查询)[{{courseName}}],创建时间(起始位置)[{{startCreateTime}}]," +
             "创建时间(终止位置)[{{endCreateTime}}],状态[{{enable}}],启用&禁用操作[{{enableOperate}}]】批量启用/禁用课程",level = LevelEnum.TERTIARY,operationType = OperationTypeEnum.EDIT)
     public Result enableBasicCourseByQuery(@ApiParam(value = "所属机构id") @RequestParam(required = false) String belongOrgId,
                                            @ApiParam(value = "课程名称(模糊查询)") @RequestParam(required = false) String courseName,
                                            @ApiParam(value = "创建时间(起始位置)") @RequestParam(required = false) String startCreateTime,
-                                           @ApiParam(value = "创建时间(终止位置)") @RequestParam(required = false) String endCreateTime,
-                                           @ApiParam(value = "状态") @RequestParam(required = false) Boolean enable,
-                                           @ApiParam(value = "启用&禁用操作",required = true) @RequestParam Boolean enableOperate) {
+                                           @ApiParam(value = "创建时间(终止位置)") @RequestParam(required = false) String endCreateTime) {
         // 禁用条件
-        if (!SystemConstant.strNotNull(belongOrgId) && !SystemConstant.strNotNull(courseName) && !SystemConstant.strNotNull(startCreateTime) && !SystemConstant.strNotNull(endCreateTime) && Objects.isNull(enable)){
+        if (!SystemConstant.strNotNull(belongOrgId) && !SystemConstant.strNotNull(courseName) && !SystemConstant.strNotNull(startCreateTime) && !SystemConstant.strNotNull(endCreateTime)){
             throw ExceptionResultEnum.ERROR.exception("请选择要禁用的条件");
         }
-        return ResultUtil.ok(basicCourseService.removeBasicCourseBatchByQuery(SystemConstant.convertIdToLong(belongOrgId), courseName, SystemConstant.convertIdToLong(startCreateTime), SystemConstant.convertIdToLong(endCreateTime), enable,enableOperate));
+        return ResultUtil.ok(basicCourseService.removeBasicCourseBatchByQuery(SystemConstant.convertIdToLong(belongOrgId), courseName, SystemConstant.convertIdToLong(startCreateTime), SystemConstant.convertIdToLong(endCreateTime)));
     }
 
     @ApiOperation(value = "课程基本信息管理-批量导入(异步)")

+ 1 - 1
distributed-print/src/main/java/com/qmth/distributed/print/api/SysController.java

@@ -491,7 +491,7 @@ public class SysController {
             if (Objects.nonNull(localTempFile) && Objects.nonNull(dictionaryConfig.sysDomain()) && dictionaryConfig.sysDomain().isOss()) {
                 FileUtil.deleteFile(localTempFile);
             }
-            if (Objects.nonNull(pdfOriginalFile) && Objects.nonNull(dictionaryConfig.sysDomain()) && dictionaryConfig.sysDomain().isOss()) {
+            if (Objects.nonNull(pdfOriginalFile) && Objects.nonNull(dictionaryConfig.sysDomain())) {
                 FileUtil.deleteFile(pdfOriginalFile);
             }
         }

+ 32 - 7
distributed-print/src/main/java/com/qmth/distributed/print/api/SysOrgController.java

@@ -1,21 +1,29 @@
 package com.qmth.distributed.print.api;
 
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.distributed.print.business.bean.result.EditResult;
 import com.qmth.distributed.print.business.service.PrintCommonService;
+import com.qmth.distributed.print.business.templete.execute.AsyncSysOrgImportService;
+import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.SysOrg;
+import com.qmth.teachcloud.common.entity.SysUser;
+import com.qmth.teachcloud.common.entity.TBTask;
+import com.qmth.teachcloud.common.enums.TaskTypeEnum;
 import com.qmth.teachcloud.common.enums.userPush.SpecialPrivilegeEnum;
 import com.qmth.teachcloud.common.service.SysOrgService;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
+import com.qmth.teachcloud.common.util.ServletUtil;
+import io.swagger.annotations.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.BindingResult;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
+import java.util.Map;
+import java.util.Objects;
 
 /**
  * <p>
@@ -30,11 +38,14 @@ import javax.validation.Valid;
 @RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + "/${prefix.url.sys}/org")
 public class SysOrgController {
 
-    @Autowired
+    @Resource
     private SysOrgService sysOrgService;
 
     @Resource
-    PrintCommonService printCommonService;
+    private PrintCommonService printCommonService;
+
+    @Resource
+    private AsyncSysOrgImportService asyncSysOrgImportService;
 
     /**
      * 查询机构树
@@ -43,8 +54,9 @@ public class SysOrgController {
      */
     @ApiOperation(value = "查询")
     @RequestMapping(value = "/list", method = RequestMethod.POST)
-    public Result list(@RequestParam(value = "specialPrivilege", required = false) SpecialPrivilegeEnum specialPrivilege) {
-        return ResultUtil.ok(sysOrgService.listOrgTree(specialPrivilege));
+    public Result list(@RequestParam(value = "specialPrivilege", required = false) SpecialPrivilegeEnum specialPrivilege,
+                       @RequestParam(value = "withoutPrintingRoom", required = false) boolean withoutPrintingRoom) {
+        return ResultUtil.ok(sysOrgService.listOrgTree(specialPrivilege,withoutPrintingRoom));
     }
 
     /**
@@ -96,5 +108,18 @@ public class SysOrgController {
     public Result findByType(@ApiParam(value = "机构类型") @RequestParam(required = false) String orgType) {
         return ResultUtil.ok(sysOrgService.findDeepByOrgIdAndType(orgType));
     }
+
+    @ApiOperation(value = "机构管理-批量导入(异步)")
+    @RequestMapping(value = "/import", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = EditResult.class)})
+    public Result sysOrgImportAsync(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file) throws Exception {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        Map<String, Object> map = printCommonService.saveTask(file, TaskTypeEnum.ORG_IMPORT);
+        map.put(SystemConstant.SYS_USER, sysUser);
+
+        asyncSysOrgImportService.importTask(map);
+        TBTask tbTask = Objects.nonNull(map.get(SystemConstant.TASK)) ? (TBTask) map.get(SystemConstant.TASK) : null;
+        return Objects.nonNull(tbTask) ? ResultUtil.ok(tbTask.getId()) : ResultUtil.error("创建任务失败");
+    }
 }
 

+ 27 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/bean/dto/excel/SysOrgImportDto.java

@@ -0,0 +1,27 @@
+package com.qmth.teachcloud.common.bean.dto.excel;
+
+import com.qmth.teachcloud.common.annotation.ExcelImportTempleteVaild;
+import com.qmth.teachcloud.common.annotation.ExcelNote;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @Description: 系统机构导入Dto
+ * @Author: CaoZixuan
+ * @Date: 2022-08-16
+ */
+@ExcelImportTempleteVaild(value = true)
+public class SysOrgImportDto implements Serializable {
+    @ExcelNote(value = "组织架构")
+    @NotNull
+    private String name;
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+}

+ 1 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/enums/TaskTypeEnum.java

@@ -10,6 +10,7 @@ import java.util.Objects;
  * @Date: 2021/3/29
  */
 public enum TaskTypeEnum {
+    ORG_IMPORT("机构导入"),
 
     USER_IMPORT("用户导入"),
 

+ 0 - 2
teachcloud-common/src/main/java/com/qmth/teachcloud/common/mapper/BasicCourseMapper.java

@@ -36,7 +36,6 @@ public interface BasicCourseMapper extends BaseMapper<BasicCourse> {
      * @param courseName      课程名称(模糊查询)
      * @param startCreateTime 课程创建时间(起始值)
      * @param endCreateTime   课程创建时间(终止值)
-     * @param enable          状态
      * @param schoolId        学校id
      * @param orgIds          权限机构组
      * @return 结果
@@ -46,7 +45,6 @@ public interface BasicCourseMapper extends BaseMapper<BasicCourse> {
                                                  @Param("courseName") String courseName,
                                                  @Param("startCreateTime") Long startCreateTime,
                                                  @Param("endCreateTime") Long endCreateTime,
-                                                 @Param("enable") Boolean enable,
                                                  @Param("schoolId") Long schoolId,
                                                  @Param("orgIds") Set<Long> orgIds);
 

+ 4 - 9
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/BasicCourseService.java

@@ -2,7 +2,6 @@ package com.qmth.teachcloud.common.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.teachcloud.common.bean.dto.CourseInfoDto;
 import com.qmth.teachcloud.common.bean.params.BasicCourseParams;
 import com.qmth.teachcloud.common.bean.result.BasicCourseResult;
 import com.qmth.teachcloud.common.entity.BasicCourse;
@@ -56,12 +55,11 @@ public interface BasicCourseService extends IService<BasicCourse> {
      * @param courseName      课程名称(模糊查询)
      * @param startCreateTime 课程创建时间(起始)
      * @param endCreateTime   课程创建时间(终止)
-     * @param enable          状态
      * @param pageNumber      分页页码
      * @param pageSize        分页容量
      * @return 查询结果
      */
-    IPage<BasicCourseResult> basicCoursePage(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime, Boolean enable, int pageNumber, int pageSize);
+    IPage<BasicCourseResult> basicCoursePage(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime, int pageNumber, int pageSize);
 
     /**
      * 新增/编辑 课程基础信息
@@ -75,22 +73,19 @@ public interface BasicCourseService extends IService<BasicCourse> {
      * 批量删除课程基本信息(逻辑)
      *
      * @param idList 要删除的课程主键集合
-     * @param enable 启用/禁用标志
      * @return 是否删除成功
      */
-    Boolean removeBasicCourseBatch(List<Long> idList, Boolean enable);
+    Boolean removeBasicCourseBatch(List<Long> idList);
 
     /**
-     * 根据查询条件批量禁用基础课程
+     * 根据查询条件批量删除基础课程
      *
      * @param belongOrgId     所属机构id
      * @param courseName      课程名称(模糊查询)
      * @param startCreateTime 课程创建时间(起始)
      * @param endCreateTime   课程创建时间(终止)
-     * @param enable          启用&禁用 状态
-     * @param enableOperate   操作 启用&禁用 状态
      */
-    Boolean removeBasicCourseBatchByQuery(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime, Boolean enable, Boolean enableOperate);
+    Boolean removeBasicCourseBatchByQuery(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime);
 
     /**
      * 执行批量导入课程逻辑

+ 7 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/SysOrgService.java

@@ -20,7 +20,13 @@ import java.util.Set;
  */
 public interface SysOrgService extends IService<SysOrg> {
 
-    List<OrgDto> listOrgTree(SpecialPrivilegeEnum specialPrivilegeEnum);
+    /**
+     * 机构树
+     * @param specialPrivilegeEnum 特殊权限
+     * @param withoutPrintingRoom 是否去除印刷室机构
+     * @return 查询到的机构
+     */
+    List<OrgDto> listOrgTree(SpecialPrivilegeEnum specialPrivilegeEnum,boolean withoutPrintingRoom);
 
     /**
      * 获取所有机构

+ 24 - 37
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicCourseServiceImpl.java

@@ -108,11 +108,11 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
     }
 
     @Override
-    public IPage<BasicCourseResult> basicCoursePage(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime, Boolean enable, int pageNumber, int pageSize) {
+    public IPage<BasicCourseResult> basicCoursePage(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime, int pageNumber, int pageSize) {
         Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
         Set<Long> orgIds = teachcloudCommonService.listSubOrgIds(null);
         courseName = SystemConstant.translateSpecificSign(courseName);
-        IPage<BasicCourseResult> iPage = basicCourseMapper.findBasicCoursePage(new Page<>(pageNumber, pageSize), belongOrgId, courseName, startCreateTime, endCreateTime, enable, schoolId, orgIds);
+        IPage<BasicCourseResult> iPage = basicCourseMapper.findBasicCoursePage(new Page<>(pageNumber, pageSize), belongOrgId, courseName, startCreateTime, endCreateTime, schoolId, orgIds);
         List<BasicCourseResult> list = iPage.getRecords();
         for (BasicCourseResult basicCourseResult : list) {
             Long courseId = basicCourseResult.getId();
@@ -148,50 +148,40 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public Boolean removeBasicCourseBatch(List<Long> idList, Boolean enable) {
+    public Boolean removeBasicCourseBatch(List<Long> idList) {
         Long schoolId = SystemConstant.convertIdToLong(ServletUtil.getRequestHeaderSchoolId().toString());
         if (idList.size() == 0) {
             throw ExceptionResultEnum.ERROR.exception("请选择要目标");
         }
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        if (!enable) {
-            // 批量禁用判断
-            // 业务判断
-            Set<String> courseCodeSet = idList.stream().map(e -> {
-                BasicCourse basicCourse = this.getById(e);
-                if (Objects.isNull(basicCourse)) {
-                    throw ExceptionResultEnum.ERROR.exception("未找到课程");
-                }
-                return basicCourse.getCode();
-            }).collect(Collectors.toSet());
-            Set<Map<String, Object>> mapList = basicCourseMapper.findExamTaskByCourseCode(schoolId, courseCodeSet);
-            if (mapList.size() > 0) {
-                StringBuilder courseNames = new StringBuilder();
-                for (Map<String, Object> map : mapList) {
-                    courseNames.append(map.get("courseName")).append(",");
-                }
-                throw ExceptionResultEnum.ERROR.exception("课程 : 【" + courseNames.substring(0, courseNames.length() - 1) + "】 已经生成了命题任务,不允许禁用");
+        // 批量禁用判断
+        // 业务判断
+        Set<String> courseCodeSet = idList.stream().map(e -> {
+            BasicCourse basicCourse = this.getById(e);
+            if (Objects.isNull(basicCourse)) {
+                throw ExceptionResultEnum.ERROR.exception("未找到课程");
+            }
+            return basicCourse.getCode();
+        }).collect(Collectors.toSet());
+        Set<Map<String, Object>> mapList = basicCourseMapper.findExamTaskByCourseCode(schoolId, courseCodeSet);
+        if (mapList.size() > 0) {
+            StringBuilder courseNames = new StringBuilder();
+            for (Map<String, Object> map : mapList) {
+                courseNames.append(map.get("courseName")).append(",");
             }
+            throw ExceptionResultEnum.ERROR.exception("课程 : 【" + courseNames.substring(0, courseNames.length() - 1) + "】 已经生成了命题任务,不允许删除");
         }
-        // 课程批量启用禁用
-        basicUserCourseService.update(new UpdateWrapper<BasicUserCourse>().lambda()
+        // 课程批量删除
+        basicUserCourseService.remove(new QueryWrapper<BasicUserCourse>().lambda()
                 .in(BasicUserCourse::getCourseId, idList)
-                .eq(BasicUserCourse::getSchoolId, sysUser.getSchoolId())
-                .set(BasicUserCourse::getEnable, enable)
-                .set(BasicUserCourse::getUpdateId, sysUser.getId()));
+                .eq(BasicUserCourse::getSchoolId, sysUser.getSchoolId()));
 
-        UpdateWrapper<BasicCourse> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.lambda()
-                .set(BasicCourse::getEnable, enable)
-                .in(BasicCourse::getId, idList)
-                .set(BasicCourse::getUpdateId, sysUser.getId());
-
-        return this.update(updateWrapper);
+        return this.removeByIds(idList);
     }
 
     @Transactional(rollbackFor = Exception.class)
     @Override
-    public Boolean removeBasicCourseBatchByQuery(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime, Boolean enable, Boolean enableOperate) {
+    public Boolean removeBasicCourseBatchByQuery(Long belongOrgId, String courseName, Long startCreateTime, Long endCreateTime) {
         QueryWrapper<BasicCourse> basicCourseQueryWrapper = new QueryWrapper<>();
         if (SystemConstant.longNotNull(belongOrgId)) {
             basicCourseQueryWrapper.lambda().eq(BasicCourse::getTeachingRoomId, belongOrgId);
@@ -205,13 +195,10 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
         if (SystemConstant.longNotNull(endCreateTime)) {
             basicCourseQueryWrapper.lambda().le(BasicCourse::getCreateTime, endCreateTime);
         }
-        if (Objects.nonNull(enable)) {
-            basicCourseQueryWrapper.lambda().eq(BasicCourse::getEnable, enable);
-        }
         List<BasicCourse> basicCourseList = this.list(basicCourseQueryWrapper);
         List<Long> idList = basicCourseList.stream().map(BaseEntity::getId).distinct().collect(Collectors.toList());
 
-        return idList.size() > 0 ? this.removeBasicCourseBatch(idList, enableOperate) : true;
+        return idList.size() > 0 ? this.removeBasicCourseBatch(idList) : true;
     }
 
     @Transactional(rollbackFor = Exception.class)

+ 4 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/SysOrgServiceImpl.java

@@ -52,7 +52,7 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
     SysOrgMapper sysOrgMapper;
 
     @Override
-    public List<OrgDto> listOrgTree(SpecialPrivilegeEnum specialPrivilegeEnum) {
+    public List<OrgDto> listOrgTree(SpecialPrivilegeEnum specialPrivilegeEnum,boolean withoutPrintingRoom) {
         Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
         List<SysUserResult> sysUserResultList = sysUserService.findSysUserResultList();
         List<SysUserResult> finalSysUserResultList = sysUserResultList.stream()
@@ -73,6 +73,9 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
                 }).collect(Collectors.toList());
 
         List<OrgDto> orgList = this.listOrgAll(schoolId);
+        if (withoutPrintingRoom){
+            orgList = orgList.stream().filter(e -> !OrgTypeEnum.PRINTING_HOUSE.name().equals(e.getType())).collect(Collectors.toList());
+        }
         Map<Long, OrgDto> map = orgList.stream()
                 .peek(e -> {
                     // 加入机构下所有人员查询

+ 1 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/TeachcloudCommonServiceImpl.java

@@ -689,7 +689,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
         if (orgId == null) {
             return null;
         }
-        List<OrgDto> orgDtos = sysOrgService.listOrgTree(null);
+        List<OrgDto> orgDtos = sysOrgService.listOrgTree(null,false);
         Set<Long> stringSet = new HashSet<>();
         stringSet.add(orgId);
         stringSet = getOrgIds(stringSet, orgDtos, orgId);

+ 0 - 3
teachcloud-common/src/main/resources/mapper/BasicCourseMapper.xml

@@ -94,9 +94,6 @@
             <if test="endCreateTime != null and endCreateTime != ''">
                 AND #{endCreateTime} >= bc.create_time
             </if>
-            <if test="enable != null">
-                AND bc.enable = #{enable}
-            </if>
             <if test="schoolId != null and schoolId != ''">
                 and bc.school_id = #{schoolId}
             </if>

+ 1 - 1
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/SysOrgController.java

@@ -41,7 +41,7 @@ public class SysOrgController {
     @ApiOperation(value = "查询")
     @RequestMapping(value = "/list", method = RequestMethod.POST)
     public Result list() {
-        List<OrgDto> orgDtoList = sysOrgService.listOrgTree(null);
+        List<OrgDto> orgDtoList = sysOrgService.listOrgTree(null,false);
         return ResultUtil.ok(orgDtoList);
     }