caozixuan 4 年之前
父節點
當前提交
d2010f9948

+ 8 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/BasicCourseService.java

@@ -37,4 +37,12 @@ public interface BasicCourseService extends IService<BasicCourse> {
     List<CourseInfoDto> findByUserLoginNameAndRealName(String loginName, String realName);
 
     BasicCourse findByCourseCode(String courseCode);
+
+    /**
+     * 创建课程
+     * @param schoolId 学校id
+     * @param courseCode 课程编号
+     * @param courseName 课程名称
+     */
+    void createCourse(Long schoolId,String courseCode,String courseName);
 }

+ 17 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/service/impl/BasicCourseServiceImpl.java

@@ -81,4 +81,21 @@ public class BasicCourseServiceImpl extends ServiceImpl<BasicCourseMapper, Basic
     public BasicCourse findByCourseCode(String courseCode) {
         return this.getOne(new QueryWrapper<BasicCourse>().lambda().eq(BasicCourse::getCode,courseCode));
     }
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void createCourse(Long schoolId, String courseCode, String courseName) {
+        // 向'basic_course'表新增数据
+        List<BasicCourse> basicCourseList = this.list(new QueryWrapper<BasicCourse>().lambda()
+                .eq(BasicCourse::getSchoolId,schoolId).eq(BasicCourse::getCode,courseCode));
+        if (basicCourseList.size() > 0){
+            throw ExceptionResultEnum.ERROR.exception("已存在学校id为【" + schoolId + "】,课程编号为【" + courseCode + "】的课程");
+        }
+        BasicCourse basicCourse = new BasicCourse();
+        basicCourse.setId(SystemConstant.getDbUuid());
+        basicCourse.setCode(courseCode);
+        basicCourse.setName(courseName);
+        basicCourse.setSchoolId(schoolId);
+        this.save(basicCourse);
+    }
 }

+ 169 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/dto/excel/ExaminationDto.java

@@ -0,0 +1,169 @@
+package com.qmth.teachcloud.report.business.bean.dto.excel;
+
+import com.qmth.teachcloud.common.annotation.ExcelNote;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @Description: 考务数据导入模板
+ * @Author: CaoZixuan
+ * @Date: 2021-06-22
+ */
+public class ExaminationDto implements Serializable {
+    @ExcelNote(value = "课头号")
+    @NotNull
+    private String courseHeaderCode;
+
+    @ExcelNote(value = "课程号")
+    @NotNull
+    private String courseExaminationCode;
+
+    @ExcelNote(value = "课程名")
+    @NotNull
+    private String courseName;
+
+    @ExcelNote(value = "教师号")
+    @NotNull
+    private String teacherCode;
+
+    @ExcelNote(value = "教师")
+    @NotNull
+    private String teacherName;
+
+    @ExcelNote(value = "授课学院")
+    @NotNull
+    private String teachCollegeName;
+
+    @ExcelNote(value = "学分")
+    @NotNull
+    private String credit;
+
+    @ExcelNote(value = "学号")
+    @NotNull
+    private String studentCode;
+
+    @ExcelNote(value = "学生姓名")
+    @NotNull
+    private String studentName;
+
+    @ExcelNote(value = "学生学院")
+    @NotNull
+    private String inspectCollegeName;
+
+    @ExcelNote(value = "专业")
+    @NotNull
+    private String major;
+
+    @ExcelNote(value = "学习类型")
+    @NotNull
+    private String studyType;
+
+    @ExcelNote(value = "年级")
+    @NotNull
+    private String grade;
+
+    public String getCourseHeaderCode() {
+        return courseHeaderCode;
+    }
+
+    public void setCourseHeaderCode(String courseHeaderCode) {
+        this.courseHeaderCode = courseHeaderCode;
+    }
+
+    public String getCourseExaminationCode() {
+        return courseExaminationCode;
+    }
+
+    public void setCourseExaminationCode(String courseExaminationCode) {
+        this.courseExaminationCode = courseExaminationCode;
+    }
+
+    public String getCourseName() {
+        return courseName;
+    }
+
+    public void setCourseName(String courseName) {
+        this.courseName = courseName;
+    }
+
+    public String getTeacherCode() {
+        return teacherCode;
+    }
+
+    public void setTeacherCode(String teacherCode) {
+        this.teacherCode = teacherCode;
+    }
+
+    public String getTeacherName() {
+        return teacherName;
+    }
+
+    public void setTeacherName(String teacherName) {
+        this.teacherName = teacherName;
+    }
+
+    public String getTeachCollegeName() {
+        return teachCollegeName;
+    }
+
+    public void setTeachCollegeName(String teachCollegeName) {
+        this.teachCollegeName = teachCollegeName;
+    }
+
+    public String getCredit() {
+        return credit;
+    }
+
+    public void setCredit(String credit) {
+        this.credit = credit;
+    }
+
+    public String getStudentCode() {
+        return studentCode;
+    }
+
+    public void setStudentCode(String studentCode) {
+        this.studentCode = studentCode;
+    }
+
+    public String getStudentName() {
+        return studentName;
+    }
+
+    public void setStudentName(String studentName) {
+        this.studentName = studentName;
+    }
+
+    public String getInspectCollegeName() {
+        return inspectCollegeName;
+    }
+
+    public void setInspectCollegeName(String inspectCollegeName) {
+        this.inspectCollegeName = inspectCollegeName;
+    }
+
+    public String getMajor() {
+        return major;
+    }
+
+    public void setMajor(String major) {
+        this.major = major;
+    }
+
+    public String getStudyType() {
+        return studyType;
+    }
+
+    public void setStudyType(String studyType) {
+        this.studyType = studyType;
+    }
+
+    public String getGrade() {
+        return grade;
+    }
+
+    public void setGrade(String grade) {
+        this.grade = grade;
+    }
+}

+ 13 - 25
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/bean/result/CellResult.java

@@ -1,10 +1,8 @@
 package com.qmth.teachcloud.report.business.bean.result;
 
-import com.fasterxml.jackson.annotation.JsonInclude;
 import io.swagger.annotations.ApiModelProperty;
 
 import java.io.Serializable;
-import java.math.BigDecimal;
 
 /**
  * @Description: CellResult
@@ -24,14 +22,11 @@ public class CellResult implements Serializable {
     @ApiModelProperty(value = "分数")
     private String scope;
 
-    @ApiModelProperty(value = "学院平均分得分率")
-    private Double colAvgScoreRate;
-
     @ApiModelProperty(value = "学校平均分得分率")
     private Double schAvgScoreRate;
 
-    @ApiModelProperty(value = "教师平均分得分率")
-    private Double teaAvgScoreRate;
+    @ApiModelProperty(value = "我的(学院、教师)平均分得分率")
+    private Double myAvgScoreRate;
 
     @ApiModelProperty(value = "计数")
     private Integer count;
@@ -40,11 +35,12 @@ public class CellResult implements Serializable {
 
     }
 
-    public CellResult(String interpret, String scope, Double colAvgScoreRate, Double schAvgScoreRate, Integer count) {
+    public CellResult(String paperType, String interpret, String scope, Double schAvgScoreRate, Double myAvgScoreRate, Integer count) {
+        this.paperType = paperType;
         this.interpret = interpret;
         this.scope = scope;
-        this.colAvgScoreRate = colAvgScoreRate;
         this.schAvgScoreRate = schAvgScoreRate;
+        this.myAvgScoreRate = myAvgScoreRate;
         this.count = count;
     }
 
@@ -56,14 +52,6 @@ public class CellResult implements Serializable {
         this.paperType = paperType;
     }
 
-    public Double getTeaAvgScoreRate() {
-        return teaAvgScoreRate;
-    }
-
-    public void setTeaAvgScoreRate(Double teaAvgScoreRate) {
-        this.teaAvgScoreRate = teaAvgScoreRate;
-    }
-
     public String getInterpret() {
         return interpret;
     }
@@ -80,14 +68,6 @@ public class CellResult implements Serializable {
         this.scope = scope;
     }
 
-    public Double getColAvgScoreRate() {
-        return colAvgScoreRate;
-    }
-
-    public void setColAvgScoreRate(Double colAvgScoreRate) {
-        this.colAvgScoreRate = colAvgScoreRate;
-    }
-
     public Double getSchAvgScoreRate() {
         return schAvgScoreRate;
     }
@@ -96,6 +76,14 @@ public class CellResult implements Serializable {
         this.schAvgScoreRate = schAvgScoreRate;
     }
 
+    public Double getMyAvgScoreRate() {
+        return myAvgScoreRate;
+    }
+
+    public void setMyAvgScoreRate(Double myAvgScoreRate) {
+        this.myAvgScoreRate = myAvgScoreRate;
+    }
+
     public Integer getCount() {
         return count;
     }

+ 24 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/entity/TAExamCourse.java

@@ -197,6 +197,14 @@ public class TAExamCourse implements Serializable {
     @TableField(value = "coefficient")
     private BigDecimal coefficient;
 
+    @ApiModelProperty(value = "卷面总体通过人数")
+    @TableField(value = "paper_pass_count")
+    private int paperPassCount;
+
+    @ApiModelProperty(value = "卷面应届通过人数")
+    @TableField(value = "paper_current_pass_count")
+    private int paperCurrentPassCount;
+
     @ApiModelProperty(value = "不及格率")
     @TableField(exist = false)
     private String notPassRate;
@@ -656,4 +664,20 @@ public class TAExamCourse implements Serializable {
     public void setInspectCollegeNames(String inspectCollegeNames) {
         this.inspectCollegeNames = inspectCollegeNames;
     }
+
+    public int getPaperPassCount() {
+        return paperPassCount;
+    }
+
+    public void setPaperPassCount(int paperPassCount) {
+        this.paperPassCount = paperPassCount;
+    }
+
+    public int getPaperCurrentPassCount() {
+        return paperCurrentPassCount;
+    }
+
+    public void setPaperCurrentPassCount(int paperCurrentPassCount) {
+        this.paperCurrentPassCount = paperCurrentPassCount;
+    }
 }

+ 9 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/TBExamCourseService.java

@@ -46,4 +46,13 @@ public interface TBExamCourseService extends IService<TBExamCourse> {
      * @return
      */
     List<TBExamCourseResult> findCourseList(Long schoolId, Long examId);
+
+    /**
+     * 创建课程
+     * @param schoolId 学校id
+     * @param examId 考试id
+     * @param courseCode 课程编号
+     * @param courseName 课程名称
+     */
+    void createCourse(Long schoolId,Long examId,String courseCode,String courseName);
 }

+ 2 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/AnalyzeForReportServiceImpl.java

@@ -308,8 +308,10 @@ public class AnalyzeForReportServiceImpl implements AnalyzeForReportService {
             taExamCourse.setDifficulty(difficulty);
             taExamCourse.setPaperAvgScore(BigDecimal.valueOf(paperAvgScore));
             taExamCourse.setPaperPassRate(paperPassRate);
+            taExamCourse.setPaperPassCount((int) paperPassCount);
             taExamCourse.setPaperCurrentAvgScore(BigDecimal.valueOf(paperCurrentAvgScore));
             taExamCourse.setPaperCurrentPassRate(paperCurrentPassRate);
+            taExamCourse.setPaperCurrentPassCount((int) paperCurrentPassCount);
             taExamCourse.setCoefficient(coefficient);
             taExamCourseList.add(taExamCourse);
         }

+ 25 - 0
teachcloud-report-business/src/main/java/com/qmth/teachcloud/report/business/service/impl/TBExamCourseServiceImpl.java

@@ -2,6 +2,7 @@ package com.qmth.teachcloud.report.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicCourse;
 import com.qmth.teachcloud.common.entity.SysOrg;
 import com.qmth.teachcloud.common.entity.SysUser;
@@ -15,7 +16,9 @@ import com.qmth.teachcloud.report.business.enums.PublishStatusEnum;
 import com.qmth.teachcloud.report.business.enums.TestStatusEnum;
 import com.qmth.teachcloud.report.business.mapper.TBExamCourseMapper;
 import com.qmth.teachcloud.report.business.service.TBExamCourseService;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.*;
@@ -128,4 +131,26 @@ public class TBExamCourseServiceImpl extends ServiceImpl<TBExamCourseMapper, TBE
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
         return tbExamCourseMapper.findCourseListByTeacherId(schoolId, examId, sysUser.getId());
     }
+
+    @Transactional
+    @Override
+    public void createCourse(Long schoolId, Long examId, String courseCode, String courseName) {
+        List<TBExamCourse> tbExamCourseList = this.list(new QueryWrapper<TBExamCourse>().lambda()
+                .eq(TBExamCourse::getExamId,examId)
+                .eq(TBExamCourse::getSchoolId,schoolId)
+                .eq(TBExamCourse::getCourseCode,courseCode)
+                .eq(TBExamCourse::getCourseName,courseName));
+        if (tbExamCourseList.size() > 0){
+            throw ExceptionResultEnum.ERROR.exception("考试课程已存在");
+        }
+        TBExamCourse tbExamCourse = new TBExamCourse();
+        tbExamCourse.setId(SystemConstant.getDbUuid());
+        tbExamCourse.setSchoolId(schoolId);
+        tbExamCourse.setExamId(examId);
+        tbExamCourse.setCourseCode(courseCode);
+        tbExamCourse.setCourseName(courseName);
+        tbExamCourse.setTestStatus(TestStatusEnum.UN_TEST);
+        tbExamCourse.setPublishStatus(PublishStatusEnum.UN_COMPUTE);
+        this.save(tbExamCourse);
+    }
 }

+ 1 - 1
teachcloud-report-business/src/main/resources/mapper/TAExamCourseDifficultMapper.xml

@@ -9,7 +9,7 @@
             tik.count,
             tik.interpret,
             round(tik.sch_avg_score_rate * 100,2) as schAvgScoreRate,
-            round(tik.col_avg_score_rate * 100,2) as colAvgScoreRate
+            round(tik.col_avg_score_rate * 100,2) as myAvgScoreRate
         from t_a_exam_course_difficult tik
        <where>
            <if test="collegeId != null and collegeId != ''">

+ 1 - 1
teachcloud-report-business/src/main/resources/mapper/TAExamCourseTeacherDifficultMapper.xml

@@ -9,7 +9,7 @@
             tik.count,
             tik.interpret,
             round(tik.sch_avg_score_rate * 100,2) as schAvgScoreRate,
-            round(tik.tea_avg_score_rate * 100,2) as teaAvgScoreRate
+            round(tik.tea_avg_score_rate * 100,2) as myAvgScoreRate
         from t_a_exam_course_teacher_difficult tik
         <where>
             <if test="teacherId != null and teacherId != ''">

+ 85 - 0
teachcloud-report/src/main/java/com/qmth/teachcloud/report/api/BasicDatasourceController.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.google.common.collect.Lists;
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.distributed.print.business.bean.dto.ExaminationImportDto;
 import com.qmth.teachcloud.common.bean.params.UserSaveParams;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.BasicCourse;
@@ -41,6 +42,7 @@ import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.util.WebUtils;
 
 import javax.annotation.Resource;
+import javax.crypto.ExemptionMechanism;
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.math.BigDecimal;
@@ -100,6 +102,8 @@ public class BasicDatasourceController {
     private SysRoleService sysRoleService;
     @Resource
     private AnalyzeForReportService analyzeForReportService;
+    @Resource
+    private TBExaminationService tbExaminationService;
 
     @ApiOperation(value = "试卷数据导入")
     @RequestMapping(value = "/paper/import", method = RequestMethod.POST)
@@ -834,6 +838,87 @@ public class BasicDatasourceController {
         return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
     }
 
+    @ApiOperation(value = "创建课程")
+    @RequestMapping(value = "/course/create", method = RequestMethod.POST)
+    @Transactional(rollbackFor = Exception.class)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    public Result courseCreate(@RequestParam Long schoolId, @RequestParam String examId, @RequestParam String courseCode,@RequestParam String courseName) {
+        basicCourseService.createCourse(schoolId,courseCode,courseName);
+        tbExamCourseService.createCourse(schoolId,SystemConstant.convertIdToLong(examId),courseCode,courseName);
+
+        return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
+    }
+
+    @ApiOperation(value = "考务数据同步")
+    @RequestMapping(value = "/examination/sync", method = RequestMethod.POST)
+    @Transactional(rollbackFor = Exception.class)
+    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    public Result examinationSync(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,@RequestParam Long schoolId, @RequestParam String examId) throws IOException, NoSuchFieldException {
+        if (Objects.isNull(file)) {
+            throw ExceptionResultEnum.ERROR.exception("附件不存在");
+        }
+        if (Objects.isNull(schoolId) || schoolId == 0) {
+            throw ExceptionResultEnum.ERROR.exception("参数缺失");
+        }
+        List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(ExaminationDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
+            if (finalExcelErrorList.size() > 0) {
+                throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
+            }
+            return finalExcelList;
+        });
+
+        List<TBExamination> tbExaminationList = new ArrayList<>();
+        if (Objects.nonNull(finalList) && finalList.size() > 0) {
+            for (int i = 0; i < finalList.size(); i++) {
+                LinkedMultiValueMap<Integer, Object> map = finalList.get(i);
+                List<Object> examinationList = map.get(i);
+                for (int y = 0; y < Objects.requireNonNull(examinationList).size(); y++) {
+                    if (examinationList.get(y) instanceof ExaminationDto) {
+                        // excel 数据解析
+                        ExaminationDto examinationDto = (ExaminationDto) examinationList.get(y);
+                        String courseHeaderCode = examinationDto.getCourseHeaderCode();
+                        String courseExaminationCode = examinationDto.getCourseExaminationCode();
+                        String courseName = examinationDto.getCourseName();
+                        String teacherCode = examinationDto.getTeacherCode();
+                        String teacherName = examinationDto.getTeacherName();
+                        String teachCollegeName = examinationDto.getTeachCollegeName();
+                        String credit = examinationDto.getCredit();
+                        String studentCode = examinationDto.getStudentCode();
+                        String studentName = examinationDto.getStudentName();
+                        String inspectCollegeName = examinationDto.getInspectCollegeName();
+                        String major = examinationDto.getMajor();
+                        String studyType = examinationDto.getStudyType();
+                        String grade = examinationDto.getGrade();
+                        // 数据组装
+                        TBExamination tbExamination = new TBExamination();
+                        tbExamination.setId(SystemConstant.getDbUuid());
+                        tbExamination.setSchoolId(schoolId);
+                        tbExamination.setExamId(SystemConstant.convertIdToLong(examId));
+                        tbExamination.setCourseHeaderCode(courseHeaderCode);
+                        tbExamination.setExaminationCourseCode(courseExaminationCode);
+                        tbExamination.setCourseName(courseName);
+                        tbExamination.setTeacherCode(teacherCode);
+                        tbExamination.setTeacherName(teacherName);
+                        tbExamination.setTeachCollegeName(teachCollegeName);
+                        tbExamination.setCredit(credit);
+                        tbExamination.setStudentCode(studentCode);
+                        tbExamination.setStudentName(studentName);
+                        tbExamination.setInspectCollegeName(inspectCollegeName);
+                        tbExamination.setMajor(major);
+                        tbExamination.setStudyType(studyType);
+                        tbExamination.setGrade(grade);
+                        tbExaminationList.add(tbExamination);
+                    }
+                }
+            }
+        }
+        tbExaminationService.remove(new QueryWrapper<TBExamination>().lambda().eq(TBExamination::getExamId,examId));
+        tbExaminationService.saveBatch(tbExaminationList);
+        return ResultUtil.ok(Collections.singletonMap(SystemConstant.SUCCESS, true));
+    }
+
+
+
     /**
      * 更新或新增专业信息
      *