Browse Source

Merge remote-tracking branch 'origin/dev_v1.0.4' into dev_v1.0.4

# Conflicts:
#	src/main/java/com/qmth/eds/service/CommonService.java
#	src/main/java/com/qmth/eds/service/impl/CommonServiceImpl.java
wangliang 2 years ago
parent
commit
212e4c2b59

+ 3 - 6
src/main/java/com/qmth/eds/api/ExamAssignController.java

@@ -16,10 +16,7 @@ import com.qmth.eds.service.ExamAssignService;
 import io.swagger.annotations.*;
 import org.springframework.util.CollectionUtils;
 import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.constraints.Max;
@@ -72,8 +69,8 @@ public class ExamAssignController {
     @ApiOperation(value = "计算")
     @PostMapping("/calc")
     @ApiResponses({@ApiResponse(code = 200, message = "保存/更新成功", response = EditResult.class)})
-    public Result save(@RequestParam(value = "examAssign", required = false) ExamAssign examAssign) {
-        return ResultUtil.ok(examAssignService.calcData(examAssign));
+    public Result save(@RequestBody String data) {
+        return ResultUtil.ok(examAssignService.calcData(data),"");
     }
 
     @ApiOperation(value = "计算结果查询")

+ 21 - 0
src/main/java/com/qmth/eds/api/SysController.java

@@ -102,6 +102,27 @@ public class SysController {
         return ResultUtil.ok();
     }
 
+    @ApiOperation(value = "查询科目列表")
+    @PostMapping("/course/list")
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = ExamineCollegeResult.class)})
+    public Result examineCollegeList(@ApiParam(value = "学期id") @RequestParam(required = false) Long semesterId,
+                                     @ApiParam(value = "考试类型id") @RequestParam(required = false) Long examTypeId) {
+        List<ExamSyncStudent> examSyncStudentList = commonService.conditionCourseQuery(semesterId, examTypeId);
+        Set<CourseResult> courseResultList = null;
+        if (!CollectionUtils.isEmpty(examSyncStudentList)) {
+            courseResultList = new HashSet<>();
+            Map<String, String> map = new HashMap<>();
+            for (ExamSyncStudent e : examSyncStudentList) {
+                if (map.containsKey(e.getKch())) {
+                    continue;
+                }
+                map.put(e.getKch(), e.getKcmc());
+                courseResultList.add(new CourseResult(e.getKch(), e.getKcmc()));
+            }
+        }
+        return ResultUtil.ok(!CollectionUtils.isEmpty(courseResultList) ? courseResultList : Collections.emptyList());
+    }
+
     @ApiOperation(value = "查询考查学院列表")
     @PostMapping("/examine/college/list")
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = ExamineCollegeResult.class)})

+ 42 - 0
src/main/java/com/qmth/eds/bean/result/CourseResult.java

@@ -0,0 +1,42 @@
+package com.qmth.eds.bean.result;
+
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 科目result
+ */
+public class CourseResult implements Serializable {
+
+    @ApiModelProperty(value = "编码")
+    String courseCode;
+
+    @ApiModelProperty(value = "名称")
+    String courseName;
+
+    public CourseResult() {
+
+    }
+
+    public CourseResult(String courseCode, String courseName) {
+        this.courseCode = courseCode;
+        this.courseName = courseName;
+    }
+
+    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;
+    }
+}

+ 1 - 0
src/main/java/com/qmth/eds/common/contant/SysSettingConstant.java

@@ -26,6 +26,7 @@ public class SysSettingConstant {
     public static final String CLOUD_MARKING_ACCESS_KEY = "cloudMarkingAccessKey";
     public static final String CLOUD_MARKING_ACCESS_SECRET = "cloudMarkingAccessSecret";
     public static final String CLOUD_MARKING_ROOT_URL = "cloudMarkingRootUrl";
+    public static final String FILE_HOST_URL = "fileHostUrl";
 
     // 云阅卷考试查询api
     public static final String CLOUD_MARKING_EXAM_URL = "/api/exams";

+ 2 - 2
src/main/java/com/qmth/eds/common/entity/SysSetting.java

@@ -60,11 +60,11 @@ public class SysSetting extends BaseEntity implements Serializable {
         List<SettingObject> settingObjects = new ArrayList<>();
 
         List<SimpleObject> basicSimpleObjects = new ArrayList<>();
-        basicSimpleObjects.add(new SimpleObject(SysSettingConstant.CLOUD_MARKING_ACCESS_KEY, "文件访问地址", "", "text", 1, true));
+        basicSimpleObjects.add(new SimpleObject(SysSettingConstant.FILE_HOST_URL, "文件访问地址", "", "text", 1, true));
         settingObjects.add(new SettingObject("访问参数设置", 1, basicSimpleObjects));
 
         String schoolCode = basicSchool.getCode();
-        if ("whu".equals(schoolCode)) {
+        if ("whdx".equals(schoolCode) || "test-school-1".equals(schoolCode)) {
             List<SimpleObject> simpleObjects1 = new ArrayList<>();
             simpleObjects1.add(new SimpleObject(SysSettingConstant.WHU_APP_KEY, "App Key", "", "text", 1, true));
             simpleObjects1.add(new SimpleObject(SysSettingConstant.WHU_APP_SECRET, "App Secret", "", "text", 2, true));

+ 13 - 0
src/main/java/com/qmth/eds/service/CommonService.java

@@ -2,6 +2,7 @@ package com.qmth.eds.service;
 
 import com.qmth.eds.bean.auth.AuthBean;
 import com.qmth.eds.bean.result.MenuResult;
+import com.qmth.eds.common.entity.ExamSyncStudent;
 import com.qmth.eds.common.entity.SysRolePrivilege;
 import com.qmth.eds.common.entity.SysUserRole;
 import com.qmth.eds.common.enums.PrivilegePropertyEnum;
@@ -75,4 +76,16 @@ public interface CommonService {
      * @return
      */
     String getSysSettingValue(Long schoolId, String code);
+
+    /**
+     * 查询云阅卷科目代码
+     *
+     * @param semesterId
+     * @param examTypeId
+     * @param courseCode
+     * @return
+     */
+    Set<String> findCloudMarkSubjectCode(Long semesterId, Long examTypeId, String courseCode);
+
+    List<ExamSyncStudent> conditionCourseQuery(Long semesterId, Long examTypeId);
 }

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

@@ -18,7 +18,7 @@ public interface ExamAssignService extends IService<ExamAssign> {
 
     IPage<ExamAssignDto> pageData(Long semesterId, Long examTypeId, String courseCode, Integer pageNumber, Integer pageSize);
 
-    boolean calcData(ExamAssign examAssign);
+    String calcData(String data);
 
     /**
      * 赋分结果预览

+ 35 - 0
src/main/java/com/qmth/eds/service/impl/CommonServiceImpl.java

@@ -50,6 +50,15 @@ public class CommonServiceImpl implements CommonService {
     @Resource
     SysRoleService sysRoleService;
 
+    @Resource
+    CloudMarkingScoreService cloudMarkingScoreService;
+
+    @Resource
+    ExamSyncStudentService examSyncStudentService;
+
+    @Resource
+    ExamSyncTotalService examSyncTotalService;
+
     /**
      * 获取用户菜单
      *
@@ -235,4 +244,30 @@ public class CommonServiceImpl implements CommonService {
         }
         return simpleObject.getValue();
     }
+
+    /**
+     * 查询云阅卷科目代码
+     *
+     * @param semesterId
+     * @param examTypeId
+     * @param courseCode
+     * @return
+     */
+    @Override
+    public List<String> findCloudMarkSubjectCode(Long semesterId, Long examTypeId, String courseCode) {
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        //先查询云阅卷科目代码
+        List<String> courseCodeList = cloudMarkingScoreService.queryBySyncCourseCode(schoolId, semesterId, examTypeId, courseCode);
+        return !CollectionUtils.isEmpty(courseCodeList) ? courseCodeList : Collections.emptyList();
+    }
+
+    @Override
+    public List<ExamSyncStudent> conditionCourseQuery(Long semesterId, Long examTypeId) {
+        Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
+        ExamSyncTotal examSyncTotal = examSyncTotalService.getBySemesterIdAndExamTypeIdAndUseFile(schoolId, semesterId, examTypeId, true);
+        if(examSyncTotal != null){
+            return examSyncStudentService.listByExamSyncTotalId(examSyncTotal);
+        }
+        return null;
+    }
 }

+ 7 - 4
src/main/java/com/qmth/eds/service/impl/ExamAssignServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.eds.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;
@@ -66,7 +67,7 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
 
             List<ExamSyncStudent> examSyncStudents = examSyncStudentService.listByExamSyncTotalId(examSyncTotal);
             if (!CollectionUtils.isEmpty(examSyncStudents)) {
-                List<ExamSyncStudent> syncStudents = examSyncStudents.stream().filter(m -> m.getCloudMarkingCourseCode().equals(courseCode)).collect(Collectors.toList());
+                List<ExamSyncStudent> syncStudents = examSyncStudents.stream().filter(m -> m.getKch().equals(record.getCourseCode())).collect(Collectors.toList());
                 actualCount = syncStudents.size();
                 List<String> kkxyList = syncStudents.stream().map(ExamSyncStudent::getKkbm).distinct().collect(Collectors.toList());
                 if (!CollectionUtils.isEmpty(kkxyList) && kkxyList.size() > 1) {
@@ -82,8 +83,10 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
     }
 
     @Override
-    public boolean calcData(ExamAssign examAssign) {
+    public String calcData(String data) {
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+
+        ExamAssign examAssign = JSON.parseObject(data, ExamAssign.class);
         // 保存赋分参数
         if (examAssign.getId() == null) {
             examAssign.setId(SystemConstant.getDbUuid());
@@ -98,7 +101,7 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
 
         // 计算赋分
         asyncTaskService.calcAssignScore(examAssign);
-        return true;
+        return String.valueOf(examAssign.getId());
     }
 
     /**
@@ -162,7 +165,7 @@ public class ExamAssignServiceImpl extends ServiceImpl<ExamAssignMapper, ExamAss
         List<String> kcxyList = new ArrayList<>();
         List<ExamSyncStudent> examSyncStudents = examSyncStudentService.listByExamSyncTotalId(examSyncTotal);
         if (!CollectionUtils.isEmpty(examSyncStudents)) {
-            List<ExamSyncStudent> syncStudents = examSyncStudents.stream().filter(m -> m.getCloudMarkingCourseCode().equals(courseCode) && m.getKkbm().equals(openCollege)).collect(Collectors.toList());
+            List<ExamSyncStudent> syncStudents = examSyncStudents.stream().filter(m -> m.getKch().equals(courseCode) && m.getKkbm().equals(openCollege)).collect(Collectors.toList());
             actualCount = syncStudents.size();
             kcxyList = syncStudents.stream().map(ExamSyncStudent::getJgmc).distinct().collect(Collectors.toList());
         }

+ 13 - 8
src/main/java/com/qmth/eds/service/impl/WhuDataSyncServiceImpl.java

@@ -334,18 +334,19 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
      * @param value                  系数
      * @param examSyncStudentDtoList 源数据
      * @param finalList              计算后数据
+     *                               备注:AviatorEvaluator.compile(formula).execute(paramMap),paramMap中的参数值不能为String类型
      */
     private void calcProgress(FormulaEnum formula, Double value, List<ExamSyncStudentDto> examSyncStudentDtoList, Double maxTotalScore, List<ExamSyncStudentDto> finalList) {
         // 公式1(赋值分=卷面成绩+ (100- 卷面成绩)/赋分系数)
         if (FormulaEnum.FORMULA1.equals(formula)) {
-            // x为卷面成绩,y为赋分系数
-            String formula1 = "a+(100-x)/b";
-            Map<String, Object> paramMap = new HashMap<>();
-            paramMap.put("b", value);
+            // a为卷面成绩,y为赋分系数
+            String formula1 = "a+(100-a)/b";
             for (ExamSyncStudentDto studentDto : examSyncStudentDtoList) {
-                paramMap.put("a", studentDto.getTotalScore());
+                Map<String, Object> paramMap = new HashMap<>();
+                paramMap.put("a", Double.parseDouble(studentDto.getTotalScore()));
+                paramMap.put("b", value);
                 String assignScore = AviatorEvaluator.compile(formula1).execute(paramMap).toString();
-                studentDto.setAssignScore(assignScore);
+                studentDto.setAssignScore(stripTrailingZeros(assignScore));
                 finalList.add(studentDto);
             }
         }
@@ -369,7 +370,7 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
                     paramMap.put("a", totalScore.doubleValue());
                     paramMap.put("b", value);
                     paramMap.put("c", maxTotalScore.doubleValue());
-                    paramMap.put("x", maxTotalScore.doubleValue());
+                    paramMap.put("x", x);
                     tempAssignScore = AviatorEvaluator.compile(formula2_1).execute(paramMap).toString();
                 } else {
                     paramMap.put("a", totalScore.doubleValue());
@@ -379,12 +380,16 @@ public class WhuDataSyncServiceImpl implements WhuDataSyncService {
 
                 BigDecimal bigDecimal = new BigDecimal(tempAssignScore).setScale(0, RoundingMode.HALF_UP);
                 String assignScore = bigDecimal.divide(new BigDecimal("2")).toString();
-                studentDto.setAssignScore(assignScore);
+                studentDto.setAssignScore(stripTrailingZeros(assignScore));
                 finalList.add(studentDto);
             }
         }
     }
 
+    private String stripTrailingZeros(String value) {
+        return new BigDecimal(value).stripTrailingZeros().toPlainString();
+    }
+
     @Transactional
     public void saveScoreData(Long schoolId, Long collegeId, Long semesterId, Long examTypeId, Integer examId, List<CloudMarkingScore> cloudMarkingScoreList) {
         // 删除旧数据

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

@@ -24,6 +24,7 @@ INSERT INTO `sys_privilege` VALUES (54, '查询考查学院列表', '/api/common
 INSERT INTO `sys_privilege` VALUES (55, '查询班级列表', '/api/common/clazz/list', 'URL', 45, 8, 'SYS', NULL, 1, 1, 1);
 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');
 
 
 

+ 1 - 1
src/main/resources/mapper/CloudMarkingScoreMapper.xml

@@ -43,7 +43,7 @@
         SELECT
             cms.id cloudMarkingScoreId,
             cms.total_score totalScore,
-            ess.jgmc,
+            ess.kkbm,
             ess.jgmc
         FROM
             cloud_marking_score cms

+ 2 - 2
src/main/resources/mapper/ExamAssignMapper.xml

@@ -8,7 +8,7 @@
             semester_id semesterId,
             exam_type_id examTypeId,
             subject_code courseCode,
-            subject_name courseName,
+            subject_name courseName
             from cloud_marking_score
         <where>
             school_id = #{schoolId}
@@ -19,7 +19,7 @@
                 and exam_type_id = #{examTypeId}
             </if>
             <if test="courseCode != null and courseCode != ''">
-                and course_code = #{courseCode}
+                and subject_code = #{courseCode}
             </if>
         </where>
     </select>

+ 3 - 3
src/test/java/com/qmth/eds/AviatorTest.java

@@ -27,11 +27,11 @@ public class AviatorTest {
     }
 
     public static void main(String[] args) {
-        String formula1 = "x+(100-x)/y";
+        String formula1 = "a+(100-a)/b";
 
         Map<String, Object> paramMap=new HashMap<>();
-        paramMap.put("x", 80);
-        paramMap.put("y", 0.5);
+        paramMap.put("a", 68.5);
+        paramMap.put("b", 0.5);
         String string = AviatorEvaluator.compile(formula1).execute(paramMap).toString();
         System.out.println(string);