xiaofei 2 жил өмнө
parent
commit
34e2ea4fd6

+ 7 - 0
src/main/java/com/qmth/eds/api/ExamAssignController.java

@@ -74,6 +74,13 @@ public class ExamAssignController {
         return ResultUtil.ok(examAssignService.calcData(data), "");
     }
 
+    @ApiOperation(value = "发布赋分成绩")
+    @PostMapping("/publish")
+    @ApiResponses({@ApiResponse(code = 200, message = "保存/更新成功", response = EditResult.class)})
+    public Result publish(Long id) {
+        return ResultUtil.ok(examAssignService.publish(id));
+    }
+
     @ApiOperation(value = "计算结果查询")
     @PostMapping("/result")
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = AssignResultPreviewResult.class)})

+ 8 - 4
src/main/java/com/qmth/eds/api/SysSettingController.java

@@ -12,10 +12,7 @@ import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiResponse;
 import io.swagger.annotations.ApiResponses;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.List;
@@ -49,4 +46,11 @@ public class SysSettingController {
         return ResultUtil.ok(sysSettingService.saveData(simpleObjectList));
     }
 
+    @ApiOperation(value = "刷新缓存")
+    @RequestMapping(value = "/flush_cache", method = RequestMethod.POST)
+    public Result flushCache(String type) {
+        sysSettingService.flushCache(type);
+        return ResultUtil.ok(true);
+    }
+
 }

+ 11 - 0
src/main/java/com/qmth/eds/common/entity/ExamAssign.java

@@ -54,6 +54,9 @@ public class ExamAssign extends BaseEntity implements Serializable {
     @TableField(value = "error_msg", updateStrategy = FieldStrategy.IGNORED)
     private String errorMsg;
 
+    @ApiModelProperty(value = "是否发布")
+    private Boolean publish;
+
     public Long getSchoolId() {
         return schoolId;
     }
@@ -133,4 +136,12 @@ public class ExamAssign extends BaseEntity implements Serializable {
     public void setErrorMsg(String errorMsg) {
         this.errorMsg = errorMsg;
     }
+
+    public Boolean getPublish() {
+        return publish;
+    }
+
+    public void setPublish(Boolean publish) {
+        this.publish = publish;
+    }
 }

+ 2 - 0
src/main/java/com/qmth/eds/service/ExamAssignService.java

@@ -43,4 +43,6 @@ public interface ExamAssignService extends IService<ExamAssign> {
     Map contrast(Long semesterId, Long examTypeId, String courseCode);
 
     ExamAssignDto toCalc(Long semesterId, Long examTypeId, String courseCode, String courseName, String openCollege);
+
+    boolean publish(Long id);
 }

+ 1 - 0
src/main/java/com/qmth/eds/service/SysSettingService.java

@@ -20,4 +20,5 @@ public interface SysSettingService extends IService<SysSetting> {
 
     SysSetting getBySchoolId(Long schoolId);
 
+    void flushCache(String type);
 }

+ 87 - 8
src/main/java/com/qmth/eds/service/impl/ExamAssignServiceImpl.java

@@ -2,32 +2,31 @@ package com.qmth.eds.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 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.eds.bean.dto.ExamAssignDto;
 import com.qmth.eds.bean.result.AssignResultPreviewResult;
 import com.qmth.eds.common.contant.SystemConstant;
-import com.qmth.eds.common.entity.ExamAssign;
-import com.qmth.eds.common.entity.ExamSyncStudent;
-import com.qmth.eds.common.entity.ExamSyncTotal;
-import com.qmth.eds.common.entity.SysUser;
+import com.qmth.eds.common.entity.*;
 import com.qmth.eds.common.enums.ExamAssignStatusEnum;
 import com.qmth.eds.common.enums.ExceptionResultEnum;
 import com.qmth.eds.common.util.ServletUtil;
 import com.qmth.eds.mapper.ExamAssignMapper;
-import com.qmth.eds.service.AsyncTaskService;
-import com.qmth.eds.service.ExamAssignService;
-import com.qmth.eds.service.ExamSyncStudentService;
-import com.qmth.eds.service.ExamSyncTotalService;
+import com.qmth.eds.service.*;
+import org.apache.commons.lang3.StringUtils;
+import org.checkerframework.checker.units.qual.C;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 import java.util.stream.Collectors;
 
 /**
@@ -47,6 +46,12 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
     @Resource
     AsyncTaskService asyncTaskService;
 
+    @Resource
+    CloudMarkingScoreService cloudMarkingScoreService;
+
+    @Resource
+    CloudMarkingScoreForeignService cloudMarkingScoreForeignService;
+
     @Resource
     ExamAssignMapper examAssignMapper;
 
@@ -173,4 +178,78 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
         examAssignDto.setInspectCollege(kcxyList);
         return examAssignDto;
     }
+
+    @Transactional
+    @Override
+    public boolean publish(Long id) {
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        ExamAssign examAssign = this.getById(id);
+        Long semesterId = examAssign.getSemesterId();
+        Long examTypeId = examAssign.getExamTypeId();
+        Long collegeId = examAssign.getSchoolId();
+        String courseCode = examAssign.getCourseCode();
+
+        // 查询对外数据
+        ExamSyncTotal examSyncTotal = examSyncTotalService.getBySemesterIdAndExamTypeIdAndUseFile(schoolId, semesterId, examTypeId, true);
+        if (examSyncTotal == null) {
+            throw ExceptionResultEnum.ERROR.exception("未设置使用数据文件,请联系管理员处理");
+        }
+
+        QueryWrapper<CloudMarkingScore> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(CloudMarkingScore::getSchoolId, collegeId)
+                .eq(CloudMarkingScore::getSemesterId, semesterId)
+                .eq(CloudMarkingScore::getExamTypeId, examTypeId)
+                .eq(CloudMarkingScore::getSubjectCode, courseCode);
+        List<CloudMarkingScore> cloudMarkingScoreList = cloudMarkingScoreService.list(queryWrapper);
+
+        List<CloudMarkingScoreForeign> cloudMarkingScoreForeigns = new ArrayList<>();
+        List<ExamSyncStudent> examSyncStudents = examSyncStudentService.listByExamSyncTotalId(examSyncTotal);
+        for (CloudMarkingScore cloudMarkingScore : cloudMarkingScoreList) {
+            if (cloudMarkingScore.getExamSyncStudentId() != null) {
+                ExamSyncStudent examSyncStudent = examSyncStudents.stream().filter(m -> cloudMarkingScore.getExamSyncStudentId().equals(m.getId())).findFirst().get();
+                cloudMarkingScoreForeigns.add(new CloudMarkingScoreForeign(collegeId, semesterId, examTypeId, cloudMarkingScore.getExamId(), examSyncStudent.getXnm(), examSyncStudent.getXqm(), examSyncStudent.getJxbId(), examSyncStudent.getKch(), examSyncStudent.getKcmc(), examSyncStudent.getXh(), cloudMarkingScore.getAssignScore()));
+            } else {
+                Optional<ExamSyncStudent> optional = examSyncStudents.stream()
+                        .filter(s -> s.getJxbmc().equals(cloudMarkingScore.getClassName())
+                                && ((StringUtils.isBlank(s.getCloudMarkingCourseCode()) && s.getKch().equals(cloudMarkingScore.getSubjectCode())) || (StringUtils.isNotBlank(s.getCloudMarkingCourseCode()) && s.getCloudMarkingCourseCode().equals(cloudMarkingScore.getSubjectCode())))
+                                && s.getXh().equals(cloudMarkingScore.getStudentCode())).findFirst();
+                if (!optional.isPresent()) {
+                    cloudMarkingScoreForeigns.add(new CloudMarkingScoreForeign(collegeId, semesterId, examTypeId, cloudMarkingScore.getExamId(), null, null, null, cloudMarkingScore.getSubjectCode(), cloudMarkingScore.getSubjectName(), cloudMarkingScore.getStudentCode(), cloudMarkingScore.getAssignScore()));
+                } else {
+                    ExamSyncStudent examSyncStudent = optional.get();
+                    // 匹配上,保存考务数据表ID
+                    cloudMarkingScoreForeigns.add(new CloudMarkingScoreForeign(collegeId, semesterId, examTypeId, cloudMarkingScore.getExamId(), examSyncStudent.getXnm(), examSyncStudent.getXqm(), examSyncStudent.getJxbId(), examSyncStudent.getKch(), examSyncStudent.getKcmc(), examSyncStudent.getXh(), cloudMarkingScore.getAssignScore()));
+                }
+            }
+        }
+
+        List<Integer> examIds = cloudMarkingScoreList.stream().map(CloudMarkingScore::getExamId).distinct().collect(Collectors.toList());
+        // 删除全量数据
+        UpdateWrapper<CloudMarkingScoreForeign> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().eq(CloudMarkingScoreForeign::getSchoolId, collegeId)
+                .eq(CloudMarkingScoreForeign::getSemesterId, semesterId)
+                .eq(CloudMarkingScoreForeign::getExamTypeId, examTypeId)
+                .in(CloudMarkingScoreForeign::getExamId, examIds);
+        cloudMarkingScoreForeignService.remove(updateWrapper);
+
+        List<CloudMarkingScoreForeign> foreignData = new ArrayList<>();
+        //1000条提交一次
+        for (CloudMarkingScoreForeign scoreForeign : cloudMarkingScoreForeigns) {
+            if (foreignData.size() == 1000) {
+                cloudMarkingScoreForeignService.saveBatch(foreignData);
+                foreignData.clear();
+            }
+            foreignData.add(scoreForeign);
+        }
+        //将剩下的数据也导入
+        if (!foreignData.isEmpty()) {
+            cloudMarkingScoreForeignService.saveBatch(foreignData);
+        }
+
+        // 更新发布状态为已发布
+        UpdateWrapper<ExamAssign> examAssignUpdateWrapper = new UpdateWrapper<>();
+        examAssignUpdateWrapper.lambda().set(ExamAssign::getPublish, true)
+                .eq(ExamAssign::getId, id);
+        return this.update(examAssignUpdateWrapper);
+    }
 }

+ 7 - 1
src/main/java/com/qmth/eds/service/impl/SysCollegeServiceImpl.java

@@ -9,6 +9,7 @@ import com.qmth.eds.service.SysCollegeService;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -24,6 +25,11 @@ public class SysCollegeServiceImpl extends ServiceImpl<SysCollegeMapper, SysColl
         QueryWrapper<SysCollege> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(SysCollege::getSchoolId, schoolId)
                 .orderByAsc(SysCollege::getCode);
-        return this.list(queryWrapper);
+        List<SysCollege> colleges = this.list(queryWrapper);
+        return colleges.stream().map(m -> {
+            m.setAccessKey(null);
+            m.setAccessSecret(null);
+            return m;
+        }).collect(Collectors.toList());
     }
 }

+ 10 - 0
src/main/java/com/qmth/eds/service/impl/SysSettingServiceImpl.java

@@ -8,6 +8,7 @@ import com.qmth.eds.common.contant.SystemConstant;
 import com.qmth.eds.common.entity.BasicSchool;
 import com.qmth.eds.common.entity.SysSetting;
 import com.qmth.eds.common.enums.ExceptionResultEnum;
+import com.qmth.eds.common.enums.PrivilegePropertyEnum;
 import com.qmth.eds.common.util.ServletUtil;
 import com.qmth.eds.mapper.SysSettingMapper;
 import com.qmth.eds.service.CommonCacheService;
@@ -85,4 +86,13 @@ public class SysSettingServiceImpl extends ServiceImpl<SysSettingMapper, SysSett
         queryWrapper.lambda().eq(SysSetting::getSchoolId, schoolId);
         return this.getOne(queryWrapper);
     }
+
+    @Override
+    public void flushCache(String type) {
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        commonCacheService.removeSysSetting(schoolId);
+        commonCacheService.getSysSetting(schoolId);
+        commonCacheService.removePrivilegeUrlCache(PrivilegePropertyEnum.AUTH);
+        commonCacheService.removePrivilegeUrlCache(PrivilegePropertyEnum.SYS);
+    }
 }

+ 25 - 18
src/main/java/com/qmth/eds/service/impl/WhuDataSyncServiceImpl.java

@@ -323,6 +323,8 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
         } finally {
             examAssign.setStatus(ExamAssignStatusEnum.FINISH);
             examAssign.setErrorMsg(errorMsg);
+            // 重新计算后,发布状态改为未发布
+            examAssign.setPublish(false);
             examAssignService.updateById(examAssign);
         }
     }
@@ -386,29 +388,18 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
         }
     }
 
+    /**
+     * 处理计算出来的赋分值
+     *
+     * @param value
+     * @return
+     */
     private String stripTrailingZeros(String value) {
-        return new BigDecimal(value).stripTrailingZeros().toPlainString();
+        return new BigDecimal(value).setScale(0, RoundingMode.HALF_UP).stripTrailingZeros().toPlainString();
     }
 
     @Transactional
     public void saveScoreData(Long schoolId, Long collegeId, Long semesterId, Long examTypeId, Integer examId, List<CloudMarkingScore> cloudMarkingScoreList) {
-        // 删除旧数据
-        cloudMarkingScoreService.deleteByKeys(collegeId, semesterId, examTypeId, examId);
-
-        List<CloudMarkingScore> data = new ArrayList<>();
-        //1000条提交一次
-        for (CloudMarkingScore markingScore : cloudMarkingScoreList) {
-            if (data.size() == 1000) {
-                cloudMarkingScoreService.saveBatch(data);
-                data.clear();
-            }
-            data.add(markingScore);
-        }
-        //将剩下的数据也导入
-        if (!data.isEmpty()) {
-            cloudMarkingScoreService.saveBatch(data);
-        }
-
         // 查询对外数据
         ExamSyncTotal examSyncTotal = examSyncTotalService.getBySemesterIdAndExamTypeIdAndUseFile(schoolId, semesterId, examTypeId, true);
         if (examSyncTotal == null) {
@@ -431,6 +422,22 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
             }
         }
 
+        // 删除旧数据
+        cloudMarkingScoreService.deleteByKeys(collegeId, semesterId, examTypeId, examId);
+        List<CloudMarkingScore> data = new ArrayList<>();
+        //1000条提交一次
+        for (CloudMarkingScore markingScore : cloudMarkingScoreList) {
+            if (data.size() == 1000) {
+                cloudMarkingScoreService.saveBatch(data);
+                data.clear();
+            }
+            data.add(markingScore);
+        }
+        //将剩下的数据也导入
+        if (!data.isEmpty()) {
+            cloudMarkingScoreService.saveBatch(data);
+        }
+
         // 删除全量数据
         UpdateWrapper<CloudMarkingScoreForeign> updateWrapper = new UpdateWrapper<>();
         updateWrapper.lambda().eq(CloudMarkingScoreForeign::getSchoolId, collegeId)

+ 9 - 0
src/main/resources/db/log/log-1.0.4.sql

@@ -25,6 +25,11 @@ INSERT INTO `sys_privilege` VALUES (55, '查询班级列表', '/api/common/clazz
 INSERT INTO `sys_privilege` VALUES (56, '查询任课老师列表', '/api/common/teacher/list', 'URL', 45, 9, 'SYS', NULL, 1, 1, 1);
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('57', '考务数据列表-设置使用当前数据文件', '/api/exam_sync_total/used', 'URL', '9', '4', 'AUTH', '1', '1', '1');
 INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('58', '查询课程列表', '/api/common/course/list', 'URL', '45', '10', 'SYS', '1', '1', '1');
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `sequence`, `enable`, `default_auth`, `front_display`) VALUES ('59', '系统参数设置', 'SysSetting', 'MENU', '6', '1', '1', '1');
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('60', '参数查询', '/api/sys_setting/get', 'URL', '58', '1', 'AUTH', '1', '1', '1');
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('61', '参数保存', '/api/sys_setting/save', 'URL', '58', '2', 'AUTH', '1', '1', '1');
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('62', '刷新参数缓存', '/api/sys_setting/flush_cache', 'URL', '58', '3', 'AUTH', '1', '1', '1');
+INSERT INTO `sys_privilege` (`id`, `name`, `url`, `type`, `parent_id`, `sequence`, `property`, `enable`, `default_auth`, `front_display`) VALUES ('63', '发布赋分数据', '/api/assign/publish', 'URL', '45', '7', 'AUTH', '1', '1', '1');
 
 
 
@@ -37,6 +42,7 @@ INSERT INTO `sys_role_privilege` (`id`, `role_id`, `privilege_id`, `enable`) VAL
 INSERT INTO `sys_role_privilege` (`id`, `role_id`, `privilege_id`, `enable`) VALUES ('51', '3', '51', '1');
 INSERT INTO `sys_role_privilege` (`id`, `role_id`, `privilege_id`, `enable`) VALUES ('52', '3', '53', '1');
 INSERT INTO `sys_role_privilege` (`id`, `role_id`, `privilege_id`, `enable`) VALUES ('53', '2', '57', '1');
+INSERT INTO `sys_role_privilege` (`id`, `role_id`, `privilege_id`, `enable`) VALUES ('54', '3', '63', '1');
 
 
 CREATE TABLE `exam_assign` (
@@ -51,6 +57,7 @@ CREATE TABLE `exam_assign` (
      `coefficient` MEDIUMTEXT NULL COMMENT '系统对象(json格式)',
      `status` VARCHAR(45) NULL COMMENT '状态(INIT-未计算,RUNNING-计算中,FINISH-计算完成)',
      `error_msg` MEDIUMTEXT NULL COMMENT '错误原因(成功时为null,失败时为失败原因)',
+     `publish` TINYINT(1) NULL DEFAULT 0 COMMENT '是否发布',
      `create_id` BIGINT(20) NULL,
      `create_time` BIGINT(20) NULL,
      `update_id` BIGINT(20) NULL,
@@ -65,3 +72,5 @@ ALTER TABLE `cloud_marking_score`
 
 ALTER TABLE `exam_sync_total`
     ADD COLUMN `use_file` TINYINT(1) NULL DEFAULT 0 COMMENT '是否使用当前数据文件' AFTER `download_status`;
+
+DELETE FROM `sys_role` WHERE (`id` = '1');