Bladeren bron

fix:bugfix

caozixuan 1 jaar geleden
bovenliggende
commit
9ea3882cb5

+ 15 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/BasicExamStudentDto.java

@@ -1,5 +1,6 @@
 package com.qmth.distributed.print.business.bean.dto;
 
+import com.qmth.boot.tools.excel.annotation.ExcelColumn;
 import com.qmth.teachcloud.common.annotation.ExcelNote;
 import com.qmth.teachcloud.common.annotation.ExcelProperty;
 import io.swagger.annotations.ApiModelProperty;
@@ -16,75 +17,89 @@ public class BasicExamStudentDto {
     @ApiModelProperty("课程名称")
     @ExcelProperty(name = "课程名称", width = 10, index = 1)
     @ExcelNote(value = "课程名称")
+    @ExcelColumn(name = "课程名称",index = 0,nullable = true)
     @NotNull
     private String courseName;
 
     @ApiModelProperty("课程代码")
     @ExcelProperty(name = "课程代码", width = 10, index = 2)
     @ExcelNote(value = "课程代码")
+    @ExcelColumn(name = "课程代码",index = 1,nullable = true)
     @NotNull
     private String courseCode;
 
     @ApiModelProperty("姓名")
     @ExcelProperty(name = "姓名", width = 10, index = 3)
     @ExcelNote(value = "姓名")
+    @ExcelColumn(name = "姓名",index = 2,nullable = true)
     @NotNull
     private String studentName;
 
     @ApiModelProperty("学号")
     @ExcelProperty(name = "学号", width = 10, index = 4)
     @ExcelNote(value = "学号")
+    @ExcelColumn(name = "学号",index = 3,nullable = true)
     @NotNull
     private String studentCode;
 
     @ApiModelProperty("学院")
     @ExcelProperty(name = "学院", width = 10, index = 5)
     @ExcelNote(value = "学院")
+    @ExcelColumn(name = "学院",index = 4)
     private String college;
 
     @ApiModelProperty("专业")
     @ExcelProperty(name = "专业", width = 10, index = 6)
     @ExcelNote(value = "专业")
+    @ExcelColumn(name = "专业",index = 5)
     private String major;
 
     @ApiModelProperty("教学班")
     @ExcelProperty(name = "教学班", width = 10, index = 7)
     @ExcelNote(value = "教学班")
+    @ExcelColumn(name = "教学班",index = 6,nullable = true)
     private String teachClazz;
 
     @ApiModelProperty("试卷编号")
     @ExcelProperty(name = "试卷编号", width = 10, index = 8)
     @ExcelNote(value = "试卷编号")
+    @ExcelColumn(name = "试卷编号",index = 7)
     private String paperNumber;
 
     @ApiModelProperty("任课老师")
     @ExcelProperty(name = "任课老师", width = 10, index = 9)
     @ExcelNote(value = "任课老师")
+    @ExcelColumn(name = "任课老师",index = 8)
     private String teacherName;
 
     @ApiModelProperty("任课老师工号")
     @ExcelProperty(name = "任课老师工号", width = 10, index = 10)
     @ExcelNote(value = "任课老师工号")
+    @ExcelColumn(name = "任课老师工号",index = 9)
     private String teacherCode;
 
     @ApiModelProperty("考试日期")
     @ExcelProperty(name = "考试日期", width = 10, index = 11)
     @ExcelNote(value = "考试日期")
+    @ExcelColumn(name = "考试日期",index = 10)
     private String examDate;
 
     @ApiModelProperty("考试时间")
     @ExcelProperty(name = "考试时间", width = 10, index = 12)
     @ExcelNote(value = "考试时间")
+    @ExcelColumn(name = "考试时间",index = 11)
     private String examTime;
 
     @ApiModelProperty("考点(校区)")
     @ExcelProperty(name = "考点(校区)", width = 10, index = 13)
     @ExcelNote(value = "考点(校区)")
+    @ExcelColumn(name = "考点(校区)",index = 12)
     private String examPlace;
 
     @ApiModelProperty("考场(考试教室)")
     @ExcelProperty(name = "考场(考试教室)", width = 10, index = 14)
     @ExcelNote(value = "考场(考试教室)")
+    @ExcelColumn(name = "考场(考试教室)",index = 13)
     private String examRoom;
 
     @ApiModelProperty("异常信息")

+ 4 - 30
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/CourseDimensionImportDto.java

@@ -12,42 +12,16 @@ import javax.validation.constraints.NotNull;
  */
 public class CourseDimensionImportDto {
 
-    @ApiModelProperty("课程代码")
-    @ExcelNote(value = "课程代码")
-    @NotNull
-    private String courseCode;
-
-    @ApiModelProperty("课程名称")
-    @ExcelNote(value = "课程名称")
-    @NotNull
-    private String courseName;
-
-    @ApiModelProperty("一级属性内容")
-    @ExcelNote(value = "一级属性内容")
+    @ApiModelProperty("一级知识点内容")
+    @ExcelNote(value = "一级知识点内容")
     @NotNull
     private String firstDimensionName;
 
-    @ApiModelProperty("二级属性内容")
-    @ExcelNote(value = "二级属性内容")
+    @ApiModelProperty("二级知识点内容")
+    @ExcelNote(value = "二级知识点内容")
     @NotNull
     private String secondDimensionName;
 
-    public String getCourseCode() {
-        return courseCode;
-    }
-
-    public void setCourseCode(String courseCode) {
-        this.courseCode = courseCode;
-    }
-
-    public String getCourseName() {
-        return courseName;
-    }
-
-    public void setCourseName(String courseName) {
-        this.courseName = courseName;
-    }
-
     public String getFirstDimensionName() {
         return firstDimensionName;
     }

+ 43 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/listener/ObjectCollector.java

@@ -0,0 +1,43 @@
+package com.qmth.distributed.print.business.listener;
+
+import com.alibaba.fastjson.JSON;
+import com.qmth.boot.tools.excel.listener.ObjectListener;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * @Description: 收集器
+ * @Author: CaoZixuan
+ * @Date: 2024-03-21
+ */
+public class ObjectCollector<E> implements ObjectListener<E> {
+
+    private final List<E> successList;
+
+    private final List<String> errorList;
+
+    public ObjectCollector() {
+        this.successList = new LinkedList<>();
+        this.errorList = new LinkedList<>();
+    }
+
+    @Override
+    public void output(E obj) {
+        successList.add(obj);
+    }
+
+    @Override
+    public void error(int rowIndex, Collection<String> collection) {
+        errorList.add(rowIndex + JSON.toJSONString(collection));
+    }
+
+    public List<E> getSuccessList() {
+        return successList;
+    }
+
+    public List<String> getErrorList() {
+        return errorList;
+    }
+}

+ 3 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicExamStudentService.java

@@ -6,6 +6,7 @@ import com.qmth.distributed.print.business.bean.params.BasicExamStudentParam;
 import com.qmth.distributed.print.business.bean.result.BasicExamStudentResult;
 import com.qmth.distributed.print.business.entity.BasicExamStudent;
 import com.qmth.teachcloud.common.entity.SysUser;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -105,4 +106,6 @@ public interface BasicExamStudentService extends IService<BasicExamStudent> {
      * @return 考生字典
      */
     BasicExamStudent editEntityHelp(BasicExamStudentParam basicExamStudentParam, SysUser requestUser);
+
+    void testImport(MultipartFile file) throws Exception;
 }

+ 15 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicExamStudentServiceImpl.java

@@ -1,14 +1,20 @@
 package com.qmth.distributed.print.business.service.impl;
 
+import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.boot.tools.excel.ExcelReader;
+import com.qmth.boot.tools.excel.enums.ExcelType;
+import com.qmth.boot.tools.excel.model.DataMap;
+import com.qmth.boot.tools.models.ByteArray;
 import com.qmth.distributed.print.business.bean.dto.BasicExamStudentDto;
 import com.qmth.distributed.print.business.bean.params.BasicExamStudentParam;
 import com.qmth.distributed.print.business.bean.result.BasicExamStudentResult;
 import com.qmth.distributed.print.business.entity.BasicExamStudent;
 import com.qmth.distributed.print.business.entity.BasicTeachClazz;
+import com.qmth.distributed.print.business.listener.ObjectCollector;
 import com.qmth.distributed.print.business.mapper.BasicExamStudentMapper;
 import com.qmth.distributed.print.business.service.BasicExamStudentService;
 import com.qmth.distributed.print.business.service.BasicTeachClazzService;
@@ -27,6 +33,7 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletResponse;
@@ -307,4 +314,12 @@ public class BasicExamStudentServiceImpl extends ServiceImpl<BasicExamStudentMap
 
         return basicExamStudent;
     }
+
+    @Override
+    public void testImport(MultipartFile file) throws Exception {
+        ExcelReader excelReader = ExcelReader.create(ExcelType.XLSX, file.getInputStream(), 1);
+        List<String[]> list = excelReader.getDataArrayList();
+
+        System.out.println(JSON.toJSONString(list));
+    }
 }

+ 15 - 10
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/CourseDimensionServiceImpl.java

@@ -95,17 +95,15 @@ public class CourseDimensionServiceImpl extends ServiceImpl<CourseDimensionMappe
                     Integer rowIndex = y + 1;
                     CourseDimensionImportDto courseDimensionImportDto = (CourseDimensionImportDto) courseDimensionDtoList.get(
                             y);
-                    String excelCourseCode = StringUtils.trimToNull(courseDimensionImportDto.getCourseCode());
-                    String excelCourseName = StringUtils.trimToNull(courseDimensionImportDto.getCourseName());
                     String firstDimensionName = StringUtils.trimToNull(courseDimensionImportDto.getFirstDimensionName());
                     String secondDimensionName = StringUtils.trimToNull(courseDimensionImportDto.getSecondDimensionName());
 
                     // 本行全部列为空,跳过
-                    if (StringUtils.isAllBlank(excelCourseCode, excelCourseName, firstDimensionName, secondDimensionName)) {
+                    if (StringUtils.isAllBlank(firstDimensionName, secondDimensionName)) {
                         continue;
                     }
-                    if (!courseCode.equals(excelCourseCode)) {
-                        errorMsgList.add(String.format("第[%s]行,课程代码异常", rowIndex));
+                    if (!SystemConstant.strNotNull(firstDimensionName)){
+                        errorMsgList.add(String.format("第[%s]行缺少一级知识点内容",rowIndex));
                     }
                     list.add(courseDimensionImportDto);
                 }
@@ -121,17 +119,24 @@ public class CourseDimensionServiceImpl extends ServiceImpl<CourseDimensionMappe
         Map<String, List<String>> dimensionMap = new HashMap<>();
         for (CourseDimensionImportDto courseDimensionImportDto : list) {
             String firstDimensionName = courseDimensionImportDto.getFirstDimensionName();
+            if (!SystemConstant.strNotNull(firstDimensionName)) {
+                throw ExceptionResultEnum.ERROR.exception("excel中存在没有填写的一级知识点");
+            }
             String secondDimensionName = courseDimensionImportDto.getSecondDimensionName();
 
             if (dimensionMap.containsKey(firstDimensionName)) {
-                List<String> sl = dimensionMap.get(firstDimensionName);
-                if (!sl.contains(secondDimensionName)) {
-                    sl.add(secondDimensionName);
-                    dimensionMap.put(firstDimensionName, sl);
+                if (SystemConstant.strNotNull(secondDimensionName)) {
+                    List<String> sl = dimensionMap.get(firstDimensionName);
+                    if (!sl.contains(secondDimensionName)) {
+                        sl.add(secondDimensionName);
+                        dimensionMap.put(firstDimensionName, sl);
+                    }
                 }
             } else {
                 List<String> sl = new ArrayList<>();
-                sl.add(secondDimensionName);
+                if (SystemConstant.strNotNull(secondDimensionName)) {
+                    sl.add(secondDimensionName);
+                }
                 dimensionMap.put(firstDimensionName, sl);
             }
         }

+ 9 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/TeachCourseServiceImpl.java

@@ -569,6 +569,10 @@ public class TeachCourseServiceImpl extends ServiceImpl<TeachCourseMapper, Teach
             throw ExceptionResultEnum.ERROR.exception("非课程创建人没有分配班级的权限");
         }
         Long leaderTeachCourseId = teachCourse.getId();
+        if (!teachCourse.getUserId().equals(teachCourse.getCreateId())){
+            // 管理员权限的科组长进入旗下教师团队的教学课程进行分配了 - 特殊处理
+            leaderTeachCourseId = this.findByExamIdCourseCodeAndUserId(teachCourse.getExamId(),teachCourse.getCourseCode(),teachCourse.getCreateId()).getId();
+        }
 
         // 所有教学班
         QueryWrapper<TeachClazz> queryWrapper = new QueryWrapper<>();
@@ -623,6 +627,11 @@ public class TeachCourseServiceImpl extends ServiceImpl<TeachCourseMapper, Teach
         if (!teachCourse.getCreateId().equals(requestUserId)) {
             throw ExceptionResultEnum.ERROR.exception("该用户没有分配教师班级的权限");
         }
+        if (!teachCourse.getUserId().equals(teachCourse.getCreateId())) {
+            // 管理员权限的科组长进入旗下教师团队的教学课程进行分配了 - 特殊处理
+            teachCourse = this.findByExamIdCourseCodeAndUserId(examId, courseCode, teachCourse.getCreateId());
+            teachCourseId = teachCourse.getId();
+        }
 
         if (teacherId.equals(requestUserId)) {
             // 课程负责人分配自己的班级

+ 6 - 3
distributed-print/src/main/java/com/qmth/distributed/print/api/BasicExamStudentController.java

@@ -87,9 +87,12 @@ public class BasicExamStudentController {
     @OperationLogDetail(customizedOperationType = CustomizedOperationTypeEnum.IMPORT)
     public Result basicExamStudentImportSync(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
             @ApiParam(value = "考试id", required = true) @RequestParam String examId) throws Exception {
-        Map<String, Object> map = printCommonService.saveTask(file,SystemConstant.convertIdToLong(examId), TaskTypeEnum.BASIC_EXAM_STUDENT_IMPORT);
-        map.put("examId", SystemConstant.convertIdToLong(examId));
-        return syncBasicExamStudentImportService.importTask(map);
+//        Map<String, Object> map = printCommonService.saveTask(file,SystemConstant.convertIdToLong(examId), TaskTypeEnum.BASIC_EXAM_STUDENT_IMPORT);
+//        map.put("examId", SystemConstant.convertIdToLong(examId));
+//        return syncBasicExamStudentImportService.importTask(map);
+
+        basicExamStudentService.testImport(file);
+        return ResultUtil.ok();
     }
 
     @ApiOperation(value = "考生字典管理-导出")

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

@@ -92,7 +92,6 @@ public class CourseTargetController {
     @ApiOperation(value = "课程目标管理-课程知识点树查询")
     @RequestMapping(value = "/dimension_tree", method = RequestMethod.POST)
     @ApiResponses({ @ApiResponse(code = 200, message = "查询成功", response = CourseDimensionTree.class) })
-    @Transactional
     public Result findDimensionTree(@ApiParam(value = "教学课程id") @RequestParam(required = false) String teachCourseId) {
         try {
             courseDimensionService.syncTikuCourseProperties(SystemConstant.convertIdToLong(teachCourseId));

BIN
distributed-print/src/main/resources/temps/courseDimension.xlsx