Browse Source

归档考试

xiatian 7 months ago
parent
commit
31cd937279

+ 95 - 115
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/ExamController.java

@@ -193,15 +193,14 @@ public class ExamController extends ControllerSupport {
     @Autowired
     ExamSettingsCache examSettingsCache;
 
-    private static final String[] EXAM_ORG_SETTINGS_EXCEL_HEADER = new String[]{"学习中心ID", "学习中心代码",
-            "学习中心名称", "是否可以考试(是/否)", "开始考试时间 yyyy-MM-dd hh:mm:ss", "结束考试时间 yyyy-MM-dd hh:mm:ss"};
+    private static final String[] EXAM_ORG_SETTINGS_EXCEL_HEADER = new String[] { "学习中心ID", "学习中心代码", "学习中心名称",
+            "是否可以考试(是/否)", "开始考试时间 yyyy-MM-dd hh:mm:ss", "结束考试时间 yyyy-MM-dd hh:mm:ss" };
 
-    private static final String[] EXCEL_IP_LIMIT_HEADER = new String[]{"IP地址", "限制类型", "备注"};
+    private static final String[] EXCEL_IP_LIMIT_HEADER = new String[] { "IP地址", "限制类型", "备注" };
 
     @ApiOperation(value = "查询考试课程的试卷类型集合")
     @GetMapping("queryExamCoursePaperTypeList")
-    public List<ExamPaperTypeRelationEntity> queryExamCoursePaperTypeList(
-            @RequestParam(required = true) Long examId,
+    public List<ExamPaperTypeRelationEntity> queryExamCoursePaperTypeList(@RequestParam(required = true) Long examId,
             @RequestParam(required = true) Long courseId) {
 
         if (null == examId) {
@@ -217,18 +216,15 @@ public class ExamController extends ControllerSupport {
 
         validateRootOrgIsolation(one.getRootOrgId());
 
-        List<ExamPaperTypeRelationEntity> list = examPaperTypeRelationRepo
-                .findByExamIdAndCourseId(examId, courseId);
+        List<ExamPaperTypeRelationEntity> list = examPaperTypeRelationRepo.findByExamIdAndCourseId(examId, courseId);
 
         return list;
     }
 
     @ApiOperation(value = "查询考试的课程集合")
     @GetMapping("queryExamCourseList")
-    public List<ExamCourseRelationEntity> getExamCourseList(
-            @RequestParam(required = true) Long examId,
-            @RequestParam(required = false) String name,
-            @RequestParam(required = false) String level,
+    public List<ExamCourseRelationEntity> getExamCourseList(@RequestParam(required = true) Long examId,
+            @RequestParam(required = false) String name, @RequestParam(required = false) String level,
             @RequestParam(required = false) Boolean enable) {
 
         ExamEntity one = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
@@ -276,13 +272,11 @@ public class ExamController extends ControllerSupport {
     @DataRule(type = DataRuleType.EXAM)
     @ApiOperation(value = "分页查询考试批次")
     @GetMapping("queryPage/{curPage}/{pageSize}")
-    public PageInfo<ExamDomain> queryPage(@PathVariable Integer curPage,
-                                          @PathVariable Integer pageSize,
-                                          @RequestParam(required = false) String name,
-                                          @RequestParam(required = false) String examType,
-                                          @RequestParam(required = false) Boolean enable,
-                                          @RequestParam(required = false) String propertyKeys,
-                                          @RequestParam(required = false) Long rootOrgId) {
+    public PageInfo<ExamDomain> queryPage(@PathVariable Integer curPage, @PathVariable Integer pageSize,
+            @RequestParam(required = false) String name, @RequestParam(required = false) String examType,
+            @RequestParam(required = false) Boolean enable, @RequestParam(required = false) String propertyKeys,
+            @RequestParam(required = false) Long rootOrgId, @RequestParam(required = false) Boolean archived,
+            @RequestParam(required = false) Boolean ignoreArchived) {
         User accessUser = getAccessUser();
         PageRequest pageable = PageRequest.of(curPage, pageSize, Sort.by(Direction.DESC, "updateTime", "id"));
 
@@ -297,10 +291,10 @@ public class ExamController extends ControllerSupport {
             if (userDataRule.assertNeedQueryRefIds()) {
                 predicates.add(root.get("id").in(userDataRule.getRefIds()));
             }
-            if(rootOrgId!=null) {
-            	predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
-            }else {
-            	predicates.add(cb.equal(root.get("rootOrgId"), accessUser.getRootOrgId()));
+            if (rootOrgId != null) {
+                predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
+            } else {
+                predicates.add(cb.equal(root.get("rootOrgId"), accessUser.getRootOrgId()));
             }
             if (StringUtils.isNotBlank(name)) {
                 predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
@@ -311,7 +305,13 @@ public class ExamController extends ControllerSupport {
             if (StringUtils.isNotBlank(examType)) {
                 predicates.add(cb.equal(root.get("examType"), ExamType.valueOf(examType)));
             }
-
+            if (ignoreArchived == null || !ignoreArchived) {
+                predicates.add(cb.equal(root.get("archived"), false));
+            } else {
+                if (archived != null) {
+                    predicates.add(cb.equal(root.get("archived"), archived));
+                }
+            }
             return cb.and(predicates.toArray(new Predicate[predicates.size()]));
         };
 
@@ -328,7 +328,6 @@ public class ExamController extends ControllerSupport {
         propertyKeyList.add(ExamProperties.IP_LIMIT.name());
         propertyKeyList.add(ExamProperties.WEIXIN_ANSWER_ENABLED.name());
 
-
         Iterator<ExamEntity> iterator = page.iterator();
         List<ExamDomain> list = Lists.newArrayList();
         while (iterator.hasNext()) {
@@ -357,9 +356,11 @@ public class ExamController extends ControllerSupport {
             Map<String, String> properties = this.getProperties(bean.getId(), propertyKeyList);
             bean.setProperties(properties);
 
-            // String weixinAnswerEnabled = properties.get(ExamProperties.WEIXIN_ANSWER_ENABLED.name());
+            // String weixinAnswerEnabled =
+            // properties.get(ExamProperties.WEIXIN_ANSWER_ENABLED.name());
             String ipLimitValue = properties.get(ExamProperties.IP_LIMIT.name());
             bean.setIpLimitSettingsEnabled(StringUtil.isTrue(ipLimitValue));
+            bean.setArchived(next.getArchived());
         }
 
         return PageUtils.toPageInfo(page, list);
@@ -371,7 +372,8 @@ public class ExamController extends ControllerSupport {
      * @param name
      * @param examTypes
      * @param enable
-     * @param studentId 筛选学生关联的考试
+     * @param studentId
+     *            筛选学生关联的考试
      * @return
      * @author WANGWEI
      */
@@ -379,11 +381,9 @@ public class ExamController extends ControllerSupport {
     @ApiOperation(value = "查询考试批次")
     @GetMapping("queryByNameLike")
     public List<ExamDomain> query(@RequestParam(required = false) String name,
-                                  @RequestParam(required = false) String examTypes,
-                                  @RequestParam(required = false) Boolean enable,
-                                  @RequestParam(required = false) String propertyKeys,
-                                  @RequestParam(required = false) Long studentId,
-                                  @RequestParam(required = false) Long rootOrgId) {
+            @RequestParam(required = false) String examTypes, @RequestParam(required = false) Boolean enable,
+            @RequestParam(required = false) String propertyKeys, @RequestParam(required = false) Long studentId,
+            @RequestParam(required = false) Long rootOrgId) {
         if (null == rootOrgId) {
             rootOrgId = getRootOrgId();
         }
@@ -396,7 +396,7 @@ public class ExamController extends ControllerSupport {
 
         Specification<ExamEntity> specification = (root, query, cb) -> {
             List<Predicate> predicates = new ArrayList<>();
-
+            predicates.add(cb.equal(root.get("archived"), false));
             if (userDataRule.assertNeedQueryRefIds()) {
                 predicates.add(root.get("id").in(userDataRule.getRefIds()));
             }
@@ -433,7 +433,8 @@ public class ExamController extends ControllerSupport {
                 Root<ExamStudentEntity> subRoot = subquery.from(ExamStudentEntity.class);
                 // subquery.select(subRoot.get("id"));
                 // Predicate p1 = cb.equal(subRoot.get("studentId"), studentId);
-                // Predicate p2 = cb.equal(subRoot.get("examId"), root.get("id"));
+                // Predicate p2 = cb.equal(subRoot.get("examId"),
+                // root.get("id"));
                 // subquery.where(cb.and(p1, p2));
                 // predicates.add(cb.exists(subquery));
                 subquery.distinct(true).select(subRoot.get("examId"));
@@ -445,8 +446,7 @@ public class ExamController extends ControllerSupport {
             return cb.and(predicates.toArray(new Predicate[predicates.size()]));
         };
 
-        PageRequest pageRequest = PageRequest.of(0, 100,
-                Sort.by(Direction.DESC, "updateTime", "id"));
+        PageRequest pageRequest = PageRequest.of(0, 100, Sort.by(Direction.DESC, "updateTime", "id"));
         Page<ExamEntity> page = examRepo.findAll(specification, pageRequest);
 
         Iterator<ExamEntity> iterator = page.iterator();
@@ -632,7 +632,8 @@ public class ExamController extends ControllerSupport {
 
         if (CURD.CREATION == es) {
             // 用户与考试的数据权限
-            userDataRuleCloudService.addUserDataRule(new AddUserDataRuleReq(accessUser.getUserId(), DataRuleType.EXAM, saved.getId()));
+            userDataRuleCloudService
+                    .addUserDataRule(new AddUserDataRuleReq(accessUser.getUserId(), DataRuleType.EXAM, saved.getId()));
         }
 
         return saved;
@@ -757,8 +758,7 @@ public class ExamController extends ControllerSupport {
 
             if (specialSettingsType.equals(ExamSpecialSettingsType.ORG_BASED)) {
 
-                ExamOrgSettingsCacheBean examOrgSettings = CacheHelper.getExamOrgSettings(examId,
-                        orgId);
+                ExamOrgSettingsCacheBean examOrgSettings = CacheHelper.getExamOrgSettings(examId, orgId);
 
                 if (null != examOrgSettings.getBeginTime()) {
                     domain.setBeginTime(examOrgSettings.getBeginTime());
@@ -779,8 +779,8 @@ public class ExamController extends ControllerSupport {
 
             } else if (specialSettingsType.equals(ExamSpecialSettingsType.STUDENT_BASED)) {
 
-                ExamStudentSettingsCacheBean examStudentSettings = CacheHelper
-                        .getExamStudentSettings(examId, studentId);
+                ExamStudentSettingsCacheBean examStudentSettings = CacheHelper.getExamStudentSettings(examId,
+                        studentId);
 
                 if (null != examStudentSettings.getBeginTime()) {
                     domain.setBeginTime(examStudentSettings.getBeginTime());
@@ -808,7 +808,7 @@ public class ExamController extends ControllerSupport {
     @ApiOperation(value = "查询考生的考试批次属性集")
     @GetMapping("getExamPropertyFromCacheByStudentSession/{examId}/{keys}")
     public Map<String, String> getExamPropertyFromCacheByStudentSession(@PathVariable Long examId,
-                                                                        @PathVariable String keys) {
+            @PathVariable String keys) {
 
         String[] keyArray = StringUtils.splitByWholeSeparator(keys, ",");
 
@@ -837,16 +837,14 @@ public class ExamController extends ControllerSupport {
         if (specialSettingsEnabled || null != specialSettingsType) {
             if (specialSettingsType.equals(ExamSpecialSettingsType.ORG_BASED)) {
                 for (String key : keyArray) {
-                    ExamOrgPropertyCacheBean propCache = CacheHelper.getExamOrgProperty(examId,
-                            orgId, key);
+                    ExamOrgPropertyCacheBean propCache = CacheHelper.getExamOrgProperty(examId, orgId, key);
                     if (StringUtils.isNotBlank(propCache.getValue())) {
                         map.put(key, propCache.getValue());
                     }
                 }
             } else if (specialSettingsType.equals(ExamSpecialSettingsType.STUDENT_BASED)) {
                 for (String key : keyArray) {
-                    ExamStudentPropertyCacheBean propCache = CacheHelper
-                            .getExamStudentProperty(examId, studentId, key);
+                    ExamStudentPropertyCacheBean propCache = CacheHelper.getExamStudentProperty(examId, studentId, key);
                     if (StringUtils.isNotBlank(propCache.getValue())) {
                         map.put(key, propCache.getValue());
                     }
@@ -890,8 +888,7 @@ public class ExamController extends ControllerSupport {
      */
     @ApiOperation(value = "查询考试批次多个属性")
     @GetMapping("propertys/{examId}/{keys}")
-    public Map<String, String> getExamPropertyList(@PathVariable Long examId,
-                                                   @PathVariable String keys) {
+    public Map<String, String> getExamPropertyList(@PathVariable Long examId, @PathVariable String keys) {
         String[] keyArray = StringUtils.splitByWholeSeparator(keys, ",");
         ExamEntity examEntity = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
         if (null == examEntity) {
@@ -920,8 +917,7 @@ public class ExamController extends ControllerSupport {
      */
     @ApiOperation(value = "查询考试批次机构属性")
     @GetMapping("examOrgProperty/{examId}/{orgId}/{key}")
-    public String getExamOrgProperty(@PathVariable Long examId, @PathVariable Long orgId,
-                                     @PathVariable String key) {
+    public String getExamOrgProperty(@PathVariable Long examId, @PathVariable Long orgId, @PathVariable String key) {
         ExamEntity examEntity = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
         if (null == examEntity) {
             throw new StatusException("001250", "examId is wrong");
@@ -944,8 +940,7 @@ public class ExamController extends ControllerSupport {
     @PutMapping("enable/{ids}")
     @Transactional
     public void enableExam(@PathVariable String ids) {
-        List<Long> examIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
-                .collect(Collectors.toList());
+        List<Long> examIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
         for (Long examId : examIds) {
             ExamEntity exam = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
             exam.setEnable(true);
@@ -988,8 +983,7 @@ public class ExamController extends ControllerSupport {
     @PutMapping("disable/{ids}")
     @Transactional
     public void disableExam(@PathVariable String ids) {
-        List<Long> examIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
-                .collect(Collectors.toList());
+        List<Long> examIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
         for (Long examId : examIds) {
             ExamEntity exam = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
             exam.setEnable(false);
@@ -1040,8 +1034,7 @@ public class ExamController extends ControllerSupport {
     @ApiOperation(value = "查询考试相关的学习中心设置", notes = "")
     @GetMapping("getExamOrgSettingsList/{curPage}/{pageSize}")
     public PageInfo<ExamOrgSettingsDomain> getExamOrgSettingsList(@PathVariable Integer curPage,
-                                                                  @PathVariable Integer pageSize,
-                                                                  @ModelAttribute ExamOrgSettingsDomain examOrgDomain) {
+            @PathVariable Integer pageSize, @ModelAttribute ExamOrgSettingsDomain examOrgDomain) {
 
         Long examId = examOrgDomain.getExamId();
         if (null == examOrgDomain.getExamId()) {
@@ -1068,10 +1061,8 @@ public class ExamController extends ControllerSupport {
             return cb.and(predicates.toArray(new Predicate[predicates.size()]));
         };
 
-        Pageable pageable = PageRequest.of(curPage, pageSize, Sort.Direction.DESC, "updateTime",
-                "id");
-        Page<ExamSpecialSettingsEntity> page = examSpecialSettingsRepo.findAll(specification,
-                pageable);
+        Pageable pageable = PageRequest.of(curPage, pageSize, Sort.Direction.DESC, "updateTime", "id");
+        Page<ExamSpecialSettingsEntity> page = examSpecialSettingsRepo.findAll(specification, pageable);
 
         Iterator<ExamSpecialSettingsEntity> iterator = page.iterator();
         List<ExamOrgSettingsDomain> domainList = Lists.newArrayList();
@@ -1097,8 +1088,8 @@ public class ExamController extends ControllerSupport {
             bean.setOrgName(org.getName());
             bean.setOrgCode(org.getCode());
 
-            List<ExamOrgPropertyEntity> propList = examOrgPropertyRepo
-                    .findByExamIdAndOrgId(next.getExamId(), next.getOrgId());
+            List<ExamOrgPropertyEntity> propList = examOrgPropertyRepo.findByExamIdAndOrgId(next.getExamId(),
+                    next.getOrgId());
 
             Map<String, String> map = Maps.newHashMap();
             DynamicEnumManager manager = ExamProperty.getDynamicEnumManager();
@@ -1140,8 +1131,7 @@ public class ExamController extends ControllerSupport {
     @ApiOperation(value = "更新考试相关的学习中心设置", notes = "")
     @PutMapping("examOrgSettings")
     @Transactional
-    public ExamSpecialSettingsEntity updateExamOrgSettings(
-            @RequestBody ExamOrgSettingsDomain domain) {
+    public ExamSpecialSettingsEntity updateExamOrgSettings(@RequestBody ExamOrgSettingsDomain domain) {
         return saveExamOrgSettings(domain);
     }
 
@@ -1228,14 +1218,12 @@ public class ExamController extends ControllerSupport {
             orgIdSet.add(cur.getOrgId());
             OrgBean orgBean = orgMap.get(cur.getOrgId());
             String examLimit = null == cur.getExamLimit() ? "否" : cur.getExamLimit() ? "否" : "是";
-            String beginTime = null == cur.getBeginTime()
-                    ? null
+            String beginTime = null == cur.getBeginTime() ? null
                     : DateUtil.format(cur.getBeginTime(), DatePatterns.CHINA_DEFAULT);
-            String endTime = null == cur.getEndTime()
-                    ? null
+            String endTime = null == cur.getEndTime() ? null
                     : DateUtil.format(cur.getEndTime(), DatePatterns.CHINA_DEFAULT);
-            datas.add(new Object[]{String.valueOf(orgBean.getId()), orgBean.getCode(),
-                    orgBean.getName(), examLimit, beginTime, endTime});
+            datas.add(new Object[] { String.valueOf(orgBean.getId()), orgBean.getCode(), orgBean.getName(), examLimit,
+                    beginTime, endTime });
         }
 
         for (Entry<Long, OrgBean> entry : orgMap.entrySet()) {
@@ -1248,17 +1236,15 @@ public class ExamController extends ControllerSupport {
                 continue;
             }
 
-            datas.add(new Object[]{String.valueOf(orgBean.getId()), orgBean.getCode(),
-                    orgBean.getName(), null, null, null});
+            datas.add(new Object[] { String.valueOf(orgBean.getId()), orgBean.getCode(), orgBean.getName(), null, null,
+                    null });
         }
 
-        String filePath = systemConfig.getTempDataDir() + File.separator
-                + System.currentTimeMillis() + ".xlsx";
+        String filePath = systemConfig.getTempDataDir() + File.separator + System.currentTimeMillis() + ".xlsx";
         File file = new File(filePath);
 
-        ExcelWriter.write(
-                EXAM_ORG_SETTINGS_EXCEL_HEADER, new Class[]{String.class, String.class,
-                        String.class, String.class, String.class, String.class},
+        ExcelWriter.write(EXAM_ORG_SETTINGS_EXCEL_HEADER,
+                new Class[] { String.class, String.class, String.class, String.class, String.class, String.class },
                 datas, new File(filePath));
 
         exportFile("学习中心特殊设置-" + getRootOrgId() + ".xlsx", file);
@@ -1270,7 +1256,7 @@ public class ExamController extends ControllerSupport {
     @PostMapping("importExamOrgSettings/{examId}")
     @Transactional
     public Map<String, Object> importExamOrgSettings(@PathVariable Long examId,
-                                                     @RequestParam CommonsMultipartFile file) {
+            @RequestParam CommonsMultipartFile file) {
 
         ExamEntity exam = GlobalHelper.getEntity(examRepo, examId, ExamEntity.class);
         if (null == exam) {
@@ -1281,8 +1267,7 @@ public class ExamController extends ControllerSupport {
 
         DiskFileItem item = (DiskFileItem) file.getFileItem();
         File storeLocation = item.getStoreLocation();
-        List<Map<String, Object>> failRecords = examService.importExamOrgSettings(examId,
-                storeLocation);
+        List<Map<String, Object>> failRecords = examService.importExamOrgSettings(examId, storeLocation);
         Map<String, Object> map = Maps.newHashMap();
         map.put("hasError", CollectionUtils.isNotEmpty(failRecords));
         map.put("failRecords", failRecords);
@@ -1359,7 +1344,7 @@ public class ExamController extends ControllerSupport {
     @ApiOperation(value = "ip限制分页", notes = "ip限制分页")
     @GetMapping("ipLimited/page/{curPage}/{pageSize}")
     public PageInfo<ExamIpLimitInfo> ipLimited(@PathVariable Integer curPage, @PathVariable Integer pageSize,
-                                               Long examId, IpLimitType limitType, String ip) {
+            Long examId, IpLimitType limitType, String ip) {
         return examService.pageIpLimited(curPage, pageSize, examId, limitType, ip);
     }
 
@@ -1402,8 +1387,7 @@ public class ExamController extends ControllerSupport {
 
     @ApiOperation(value = "导入考试ip限制", notes = "导入")
     @PostMapping("ipLimited/import/{examId}")
-    public Map<String, Object> importExamIpLimit(@PathVariable Long examId,
-                                                 @RequestParam CommonsMultipartFile file) {
+    public Map<String, Object> importExamIpLimit(@PathVariable Long examId, @RequestParam CommonsMultipartFile file) {
         DiskFileItem item = (DiskFileItem) file.getFileItem();
         File storeLocation = item.getStoreLocation();
 
@@ -1442,22 +1426,23 @@ public class ExamController extends ControllerSupport {
                 msg.append("  IP地址不能为空");
                 hasError = true;
             } else {
-//                String reg = "^(?:(?:1[0-9][0-9]\\.)|(?:2[0-4][0-9]\\.)|(?:25[0-5]\\.)|(?:[1-9][0-9]\\.)|(?:[0-9/*]\\.)){3}(?:(?:1[0-9][0-9])|(?:2[0-4][0-9])|(?:25[0-5])|(?:[1-9][0-9])|(?:[0-9/*]))$";
-//                Pattern pattern = Pattern.compile(reg);
-//                Matcher matcher = pattern.matcher(ip);
-//                if (matcher.find()) {
-//                    entity.setIp(ip);
-//                } else {
-//                    msg.append("  ip格式不正确");
-//                    hasError = true;
-//                }
-            	try {
-					IpUtil.checkIp(ip);
-					entity.setIp(ip);
-				} catch (StatusException e) {
-					msg.append("  "+e.getDesc());
-					hasError = true;
-				}
+                // String reg =
+                // "^(?:(?:1[0-9][0-9]\\.)|(?:2[0-4][0-9]\\.)|(?:25[0-5]\\.)|(?:[1-9][0-9]\\.)|(?:[0-9/*]\\.)){3}(?:(?:1[0-9][0-9])|(?:2[0-4][0-9])|(?:25[0-5])|(?:[1-9][0-9])|(?:[0-9/*]))$";
+                // Pattern pattern = Pattern.compile(reg);
+                // Matcher matcher = pattern.matcher(ip);
+                // if (matcher.find()) {
+                // entity.setIp(ip);
+                // } else {
+                // msg.append(" ip格式不正确");
+                // hasError = true;
+                // }
+                try {
+                    IpUtil.checkIp(ip);
+                    entity.setIp(ip);
+                } catch (StatusException e) {
+                    msg.append("  " + e.getDesc());
+                    hasError = true;
+                }
             }
 
             if (StringUtils.isBlank(line[1])) {
@@ -1472,9 +1457,9 @@ public class ExamController extends ControllerSupport {
             entity.setLimitType(ipLimitType);
 
             // 备注
-            if(line.length == columnCount && line[2] != null){
+            if (line.length == columnCount && line[2] != null) {
                 String remark = line[2];
-                if(StringUtils.length(remark) > 30){
+                if (StringUtils.length(remark) > 30) {
                     msg.append("  备注长度不能超过30个字");
                     hasError = true;
                 }
@@ -1518,14 +1503,13 @@ public class ExamController extends ControllerSupport {
 
         for (ExamIpLimitEntity cur : list) {
             String type = cur.getLimitType() == null ? "" : cur.getLimitType().getTitle();
-            datas.add(new Object[]{cur.getIp(), type, cur.getRemark()});
+            datas.add(new Object[] { cur.getIp(), type, cur.getRemark() });
         }
 
-        String filePath = systemConfig.getTempDataDir() + File.separator
-                + System.currentTimeMillis() + ".xlsx";
+        String filePath = systemConfig.getTempDataDir() + File.separator + System.currentTimeMillis() + ".xlsx";
         File file = new File(filePath);
 
-        ExcelWriter.write(EXCEL_IP_LIMIT_HEADER, new Class[]{String.class, String.class, String.class}, datas,
+        ExcelWriter.write(EXCEL_IP_LIMIT_HEADER, new Class[] { String.class, String.class, String.class }, datas,
                 new File(filePath));
 
         exportFile("Ip访问限制列表-" + getRootOrgId() + ".xlsx", file);
@@ -1633,10 +1617,9 @@ public class ExamController extends ControllerSupport {
             return false;
         }
 
-        String IdentificationOfLivingBody =
-                PrivilegeDefine.RootOrgFunctions.OnlineExamFunctions.IdentificationOfLivingBody.CODE;
-        Boolean hasIdentificationOfLivingBodyFunction = PrivilegeManager
-                .judge(examSettings.getRootOrgId(), IdentificationOfLivingBody);
+        String IdentificationOfLivingBody = PrivilegeDefine.RootOrgFunctions.OnlineExamFunctions.IdentificationOfLivingBody.CODE;
+        Boolean hasIdentificationOfLivingBodyFunction = PrivilegeManager.judge(examSettings.getRootOrgId(),
+                IdentificationOfLivingBody);
 
         ExamPropertyCacheBean examConf = CacheHelper.getExamProperty(examId, "IS_FACE_VERIFY");
         String examValue = examConf.getValue();
@@ -1658,9 +1641,8 @@ public class ExamController extends ControllerSupport {
 
     @ApiOperation(value = "查询考试相关的学生设置", notes = "")
     @GetMapping("getStudentSpecialSettingsList/{curPage}/{pageSize}")
-    public PageInfo<StudentSpecialSettingsDomain> getStudentSpecialSettingsList(
-            @PathVariable Integer curPage, @PathVariable Integer pageSize,
-            @ModelAttribute StudentSpecialSettingsDomain domain) {
+    public PageInfo<StudentSpecialSettingsDomain> getStudentSpecialSettingsList(@PathVariable Integer curPage,
+            @PathVariable Integer pageSize, @ModelAttribute StudentSpecialSettingsDomain domain) {
 
         Long examId = domain.getExamId();
         if (null == domain.getExamId()) {
@@ -1693,10 +1675,8 @@ public class ExamController extends ControllerSupport {
             return cb.and(predicates.toArray(new Predicate[predicates.size()]));
         };
 
-        Pageable pageable = PageRequest.of(curPage, pageSize, Sort.Direction.DESC, "updateTime",
-                "id");
-        Page<ExamSpecialSettingsEntity> page = examSpecialSettingsRepo.findAll(specification,
-                pageable);
+        Pageable pageable = PageRequest.of(curPage, pageSize, Sort.Direction.DESC, "updateTime", "id");
+        Page<ExamSpecialSettingsEntity> page = examSpecialSettingsRepo.findAll(specification, pageable);
 
         Iterator<ExamSpecialSettingsEntity> iterator = page.iterator();
         List<StudentSpecialSettingsDomain> domainList = Lists.newArrayList();

+ 235 - 226
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/controller/bean/ExamDomain.java

@@ -20,251 +20,260 @@ import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
  */
 public class ExamDomain implements JsonSerializable {
 
-	private static final long serialVersionUID = 4009839764353162256L;
-
-	private Long id;
-
-	/**
-	 * 考试编码
-	 */
-	private String code;
-
-	/**
-	 * 顶级机构Id
-	 */
-	private Long rootOrgId;
-
-	/**
-	 * 考试批次开始时间
-	 */
-	private Date beginTime;
-
-	/**
-	 * 考试批次结束时间
-	 */
-	private Date endTime;
-
-	/**
-	 * 考试名称
-	 */
-	@NotNull
-	private String name;
-
-	/**
-	 * 考试类型
-	 */
-	@Enumerated(EnumType.STRING)
-	private ExamType examType;
-
-	/**
-	 * 考试时长
-	 */
-	private Integer duration;
-
-	/**
-	 * 是否可用
-	 */
-	private Boolean enable;
-
-	/**
-	 * 考试备注
-	 */
-	private String remark;
-
-	/**
-	 * 考试次数
-	 */
-	private Long examTimes;
-
-	/**
-	 * 更新时间
-	 */
-	private Date updateTime;
-
-	/**
-	 * 创建时间
-	 */
-	private Date creationTime;
-
-	/**
-	 * 是否开考
-	 */
-	private Boolean started;
-
-	/**
-	 * 是否禁止考试
-	 */
-	private Boolean examLimit;
-
-	/**
-	 * 是否开启特殊设置
-	 */
-	private Boolean specialSettingsEnabled;
-
-	/**
-	 * 是否开启特殊设置
-	 */
-	private Boolean ipLimitSettingsEnabled;
-
-	/**
-	 * 特殊设置类型
-	 */
-	@Enumerated(EnumType.STRING)
-	private ExamSpecialSettingsType specialSettingsType;
-
-	private Map<String, String> properties;
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public String getCode() {
-		return code;
-	}
-
-	public void setCode(String code) {
-		this.code = code;
-	}
-
-	public Long getRootOrgId() {
-		return rootOrgId;
-	}
-
-	public void setRootOrgId(Long rootOrgId) {
-		this.rootOrgId = rootOrgId;
-	}
-
-	public Date getBeginTime() {
-		return beginTime;
-	}
-
-	public void setBeginTime(Date beginTime) {
-		this.beginTime = beginTime;
-	}
-
-	public Date getEndTime() {
-		return endTime;
-	}
-
-	public void setEndTime(Date endTime) {
-		this.endTime = endTime;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public ExamType getExamType() {
-		return examType;
-	}
-
-	public void setExamType(ExamType examType) {
-		this.examType = examType;
-	}
-
-	public Integer getDuration() {
-		return duration;
-	}
-
-	public void setDuration(Integer duration) {
-		this.duration = duration;
-	}
-
-	public Boolean getEnable() {
-		return enable;
-	}
-
-	public void setEnable(Boolean enable) {
-		this.enable = enable;
-	}
+    private static final long serialVersionUID = 4009839764353162256L;
+
+    private Long id;
+
+    /**
+     * 考试编码
+     */
+    private String code;
+
+    /**
+     * 顶级机构Id
+     */
+    private Long rootOrgId;
+
+    /**
+     * 考试批次开始时间
+     */
+    private Date beginTime;
+
+    /**
+     * 考试批次结束时间
+     */
+    private Date endTime;
+
+    /**
+     * 考试名称
+     */
+    @NotNull
+    private String name;
+
+    /**
+     * 考试类型
+     */
+    @Enumerated(EnumType.STRING)
+    private ExamType examType;
+
+    /**
+     * 考试时长
+     */
+    private Integer duration;
+
+    /**
+     * 是否可用
+     */
+    private Boolean enable;
+
+    /**
+     * 考试备注
+     */
+    private String remark;
+
+    /**
+     * 考试次数
+     */
+    private Long examTimes;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 创建时间
+     */
+    private Date creationTime;
+
+    /**
+     * 是否开考
+     */
+    private Boolean started;
+
+    /**
+     * 是否禁止考试
+     */
+    private Boolean examLimit;
+
+    /**
+     * 是否开启特殊设置
+     */
+    private Boolean specialSettingsEnabled;
+
+    /**
+     * 是否开启特殊设置
+     */
+    private Boolean ipLimitSettingsEnabled;
+
+    /**
+     * 特殊设置类型
+     */
+    @Enumerated(EnumType.STRING)
+    private ExamSpecialSettingsType specialSettingsType;
+
+    private Map<String, String> properties;
+
+    private Boolean archived;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public Long getRootOrgId() {
+        return rootOrgId;
+    }
+
+    public void setRootOrgId(Long rootOrgId) {
+        this.rootOrgId = rootOrgId;
+    }
+
+    public Date getBeginTime() {
+        return beginTime;
+    }
+
+    public void setBeginTime(Date beginTime) {
+        this.beginTime = beginTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public ExamType getExamType() {
+        return examType;
+    }
+
+    public void setExamType(ExamType examType) {
+        this.examType = examType;
+    }
+
+    public Integer getDuration() {
+        return duration;
+    }
+
+    public void setDuration(Integer duration) {
+        this.duration = duration;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
 
-	public String getRemark() {
-		return remark;
-	}
+    public Long getExamTimes() {
+        return examTimes;
+    }
 
-	public void setRemark(String remark) {
-		this.remark = remark;
-	}
+    public void setExamTimes(Long examTimes) {
+        this.examTimes = examTimes;
+    }
 
-	public Long getExamTimes() {
-		return examTimes;
-	}
+    public Map<String, String> getProperties() {
+        return properties;
+    }
 
-	public void setExamTimes(Long examTimes) {
-		this.examTimes = examTimes;
-	}
+    public void setProperties(Map<String, String> properties) {
+        this.properties = properties;
+    }
 
-	public Map<String, String> getProperties() {
-		return properties;
-	}
+    public Boolean getStarted() {
+        return started;
+    }
 
-	public void setProperties(Map<String, String> properties) {
-		this.properties = properties;
-	}
+    public void setStarted(Boolean started) {
+        this.started = started;
+    }
 
-	public Boolean getStarted() {
-		return started;
-	}
+    public Date getUpdateTime() {
+        return updateTime;
+    }
 
-	public void setStarted(Boolean started) {
-		this.started = started;
-	}
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
 
-	public Date getUpdateTime() {
-		return updateTime;
-	}
+    public Date getCreationTime() {
+        return creationTime;
+    }
 
-	public void setUpdateTime(Date updateTime) {
-		this.updateTime = updateTime;
-	}
+    public void setCreationTime(Date creationTime) {
+        this.creationTime = creationTime;
+    }
 
-	public Date getCreationTime() {
-		return creationTime;
-	}
+    public Boolean getExamLimit() {
+        return examLimit;
+    }
 
-	public void setCreationTime(Date creationTime) {
-		this.creationTime = creationTime;
-	}
+    public void setExamLimit(Boolean examLimit) {
+        this.examLimit = examLimit;
+    }
 
-	public Boolean getExamLimit() {
-		return examLimit;
-	}
+    public ExamSpecialSettingsType getSpecialSettingsType() {
+        return specialSettingsType;
+    }
 
-	public void setExamLimit(Boolean examLimit) {
-		this.examLimit = examLimit;
-	}
+    public void setSpecialSettingsType(ExamSpecialSettingsType specialSettingsType) {
+        this.specialSettingsType = specialSettingsType;
+    }
 
-	public ExamSpecialSettingsType getSpecialSettingsType() {
-		return specialSettingsType;
-	}
+    public Boolean getSpecialSettingsEnabled() {
+        return specialSettingsEnabled;
+    }
 
-	public void setSpecialSettingsType(ExamSpecialSettingsType specialSettingsType) {
-		this.specialSettingsType = specialSettingsType;
-	}
+    public void setSpecialSettingsEnabled(Boolean specialSettingsEnabled) {
+        this.specialSettingsEnabled = specialSettingsEnabled;
+    }
 
-	public Boolean getSpecialSettingsEnabled() {
-		return specialSettingsEnabled;
-	}
+    public Boolean getIpLimitSettingsEnabled() {
+        return ipLimitSettingsEnabled;
+    }
 
-	public void setSpecialSettingsEnabled(Boolean specialSettingsEnabled) {
-		this.specialSettingsEnabled = specialSettingsEnabled;
-	}
+    public void setIpLimitSettingsEnabled(Boolean ipLimitSettingsEnabled) {
+        this.ipLimitSettingsEnabled = ipLimitSettingsEnabled;
+    }
 
-	public Boolean getIpLimitSettingsEnabled() {
-		return ipLimitSettingsEnabled;
-	}
-
-	public void setIpLimitSettingsEnabled(Boolean ipLimitSettingsEnabled) {
-		this.ipLimitSettingsEnabled = ipLimitSettingsEnabled;
-	}
+    public Boolean getArchived() {
+        return archived;
+    }
 
+    public void setArchived(Boolean archived) {
+        this.archived = archived;
+    }
 
 }

+ 97 - 91
examcloud-core-examwork-api-provider/src/main/java/cn/com/qmth/examcloud/core/examwork/api/provider/ExamCloudServiceProvider.java

@@ -126,11 +126,13 @@ import io.swagger.annotations.ApiOperation;
 public class ExamCloudServiceProvider extends ControllerSupport implements ExamCloudService {
 
     private static final long serialVersionUID = 6850508158980856785L;
-    
+
     @Autowired
     RedisClient redisClient;
+
     @Autowired
     private ExamStageRepo examStageRepo;
+
     @Autowired
     private ExamService examService;
 
@@ -157,7 +159,7 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
 
     @Autowired
     OnGoingExamService onGoingExamService;
-    
+
     @Autowired
     private ExamIpLimitRepo examIpLimitRepo;
 
@@ -182,68 +184,69 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
         examInfo.setExamLimit(req.getExamLimit());
 
         Map<String, String> properties = req.getProperties();
-        if(properties == null){
+        if (properties == null) {
             properties = new HashMap<>();
         }
 
-        if(properties.get(ExamProperties.FREEZE_TIME.name())==null) {
-        	properties.put(ExamProperties.FREEZE_TIME.name(),"0");
+        if (properties.get(ExamProperties.FREEZE_TIME.name()) == null) {
+            properties.put(ExamProperties.FREEZE_TIME.name(), "0");
+        }
+        String freezeTimeTypeVal = properties.get(ExamProperties.FREEZE_TIME_TYPE.name());
+        if (StringUtils.isBlank(freezeTimeTypeVal)) {
+            properties.put(ExamProperties.FREEZE_TIME_TYPE.name(), FreezeTimeType.DURATION.name());
+        } else {
+            try {
+                FreezeTimeType.valueOf(freezeTimeTypeVal);
+            } catch (Exception e) {
+                throw new StatusException("FREEZE_TIME_TYPE 参数值错误,只能是DURATION、BEGINTIME");
+            }
         }
-        String freezeTimeTypeVal=properties.get(ExamProperties.FREEZE_TIME_TYPE.name());
-        if(StringUtils.isBlank(freezeTimeTypeVal)) {
-        	properties.put(ExamProperties.FREEZE_TIME_TYPE.name(),FreezeTimeType.DURATION.name());
-        }else {
-        	try {
-				FreezeTimeType.valueOf(freezeTimeTypeVal);
-			} catch (Exception e) {
-				throw new StatusException("FREEZE_TIME_TYPE 参数值错误,只能是DURATION、BEGINTIME");
-			}
+        if (properties.get(ExamProperties.EXAM_RECONNECT_TIME.name()) == null) {
+            properties.put(ExamProperties.EXAM_RECONNECT_TIME.name(), "30");
         }
-        if(properties.get(ExamProperties.EXAM_RECONNECT_TIME.name())==null) {
-        	properties.put(ExamProperties.EXAM_RECONNECT_TIME.name(),"30");
+        if (properties.get(ExamProperties.IS_OBJ_SCORE_VIEW.name()) == null) {
+            properties.put(ExamProperties.IS_OBJ_SCORE_VIEW.name(), "true");
         }
-        if(properties.get(ExamProperties.IS_OBJ_SCORE_VIEW.name())==null) {
-        	properties.put(ExamProperties.IS_OBJ_SCORE_VIEW.name(),"true");
+        if ("true".equals(properties.get(ExamProperties.IP_LIMIT.name()))
+                && CollectionUtils.isNotEmpty(req.getIpWhitelist())) {
+            properties.put(ExamProperties.IP_TOTAL_LIMIT.name(), "true");
         }
-        if("true".equals(properties.get(ExamProperties.IP_LIMIT.name()))&&CollectionUtils.isNotEmpty(req.getIpWhitelist())) {
-        	properties.put(ExamProperties.IP_TOTAL_LIMIT.name(),"true");
+        if (properties.get(ExamProperties.AUDIT_ALL_PASS.name()) == null) {
+            properties.put(ExamProperties.AUDIT_ALL_PASS.name(), "false");
         }
-        if(properties.get(ExamProperties.AUDIT_ALL_PASS.name())==null) {
-    		properties.put(ExamProperties.AUDIT_ALL_PASS.name(),"false");
-    	}
-        if("true".equals(properties.get(ExamProperties.IS_FACE_ENABLE.name()))) {
-        	if(properties.get(ExamProperties.IS_FACE_CHECK.name())==null) {
-        		properties.put(ExamProperties.IS_FACE_CHECK.name(),"true");
-        	}
-    		if(properties.get(ExamProperties.SNAPSHOT_INTERVAL.name())==null) {
-        		properties.put(ExamProperties.SNAPSHOT_INTERVAL.name(),"30");
-        	}else {
-        		try {
-					int tem=Integer.valueOf(properties.get(ExamProperties.SNAPSHOT_INTERVAL.name()));
-					if(tem<0) {
-						throw new StatusException("SNAPSHOT_INTERVAL 参数必须大于零");
-					}
-				} catch (NumberFormatException e) {
-					throw new StatusException("SNAPSHOT_INTERVAL 参数只能是整数");
-				}
-        	}
-    		if(properties.get(ExamProperties.WARN_THRESHOLD.name())==null) {
-        		properties.put(ExamProperties.WARN_THRESHOLD.name(),"50");
-        	}
-    		if(properties.get(ExamProperties.LIVING_WARN_THRESHOLD.name())==null) {
-        		properties.put(ExamProperties.LIVING_WARN_THRESHOLD.name(),"50");
-        	}
+        if ("true".equals(properties.get(ExamProperties.IS_FACE_ENABLE.name()))) {
+            if (properties.get(ExamProperties.IS_FACE_CHECK.name()) == null) {
+                properties.put(ExamProperties.IS_FACE_CHECK.name(), "true");
+            }
+            if (properties.get(ExamProperties.SNAPSHOT_INTERVAL.name()) == null) {
+                properties.put(ExamProperties.SNAPSHOT_INTERVAL.name(), "30");
+            } else {
+                try {
+                    int tem = Integer.valueOf(properties.get(ExamProperties.SNAPSHOT_INTERVAL.name()));
+                    if (tem < 0) {
+                        throw new StatusException("SNAPSHOT_INTERVAL 参数必须大于零");
+                    }
+                } catch (NumberFormatException e) {
+                    throw new StatusException("SNAPSHOT_INTERVAL 参数只能是整数");
+                }
+            }
+            if (properties.get(ExamProperties.WARN_THRESHOLD.name()) == null) {
+                properties.put(ExamProperties.WARN_THRESHOLD.name(), "50");
+            }
+            if (properties.get(ExamProperties.LIVING_WARN_THRESHOLD.name()) == null) {
+                properties.put(ExamProperties.LIVING_WARN_THRESHOLD.name(), "50");
+            }
         }
-        if(properties.get(ExamProperties.MARKING_TYPE.name())==null) {
-        	properties.put(ExamProperties.MARKING_TYPE.name(),"ALL");
+        if (properties.get(ExamProperties.MARKING_TYPE.name()) == null) {
+            properties.put(ExamProperties.MARKING_TYPE.name(), "ALL");
         }
 
         examInfo.setProperties(properties);
-        if(req.getEnableExamStage()!=null&&req.getEnableExamStage()) {
-        	examInfo.setSpecialSettingsEnabled(true);
-        	examInfo.setSpecialSettingsType(ExamSpecialSettingsType.STAGE_BASED);
-        }else {
-        	examInfo.setSpecialSettingsEnabled(false);
+        if (req.getEnableExamStage() != null && req.getEnableExamStage()) {
+            examInfo.setSpecialSettingsEnabled(true);
+            examInfo.setSpecialSettingsType(ExamSpecialSettingsType.STAGE_BASED);
+        } else {
+            examInfo.setSpecialSettingsEnabled(false);
         }
         ExamEntity saved = examService.saveExam(examInfo, CURD.CREATION_OR_UPDATE);
         disposeStage(req, saved);
@@ -269,55 +272,55 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
 
         return resp;
     }
-    
+
     private void disposeIpLimit(SaveExamReq req, ExamEntity saved) {
-    	String iplimit=req.getProperties().get(ExamProperties.IP_LIMIT.name());
-    	if("true".equals(iplimit)) {
-    		examIpLimitRepo.deleteAllByExamId(saved.getId());
-    		if(CollectionUtils.isNotEmpty(req.getIpWhitelist())) {
-    			List<ExamIpLimitEntity> ips=new ArrayList<>();
-    			for(String ip:req.getIpWhitelist()) {
-    				IpUtil.checkIp(ip);
-    				ExamIpLimitEntity tem=new ExamIpLimitEntity();
-    				tem.setExamId(saved.getId());
-    				tem.setIp(ip);
-    				tem.setLimitType(IpLimitType.HAS_ACCESS);
-    				ips.add(tem);
-    			}
-    			examIpLimitRepo.saveAll(ips);
-    		}
+        String iplimit = req.getProperties().get(ExamProperties.IP_LIMIT.name());
+        if ("true".equals(iplimit)) {
+            examIpLimitRepo.deleteAllByExamId(saved.getId());
+            if (CollectionUtils.isNotEmpty(req.getIpWhitelist())) {
+                List<ExamIpLimitEntity> ips = new ArrayList<>();
+                for (String ip : req.getIpWhitelist()) {
+                    IpUtil.checkIp(ip);
+                    ExamIpLimitEntity tem = new ExamIpLimitEntity();
+                    tem.setExamId(saved.getId());
+                    tem.setIp(ip);
+                    tem.setLimitType(IpLimitType.HAS_ACCESS);
+                    ips.add(tem);
+                }
+                examIpLimitRepo.saveAll(ips);
+            }
         }
-	}
+    }
 
-	private void disposeStage(SaveExamReq req,ExamEntity exam) {
-    	if(req.getEnableExamStage()!=null&&!req.getEnableExamStage()) {
-    		return;
-    	}
+    private void disposeStage(SaveExamReq req, ExamEntity exam) {
+        if (req.getEnableExamStage() != null && !req.getEnableExamStage()) {
+            return;
+        }
         Date examStartTime = req.getBeginTime();
         Date examEndTime = req.getEndTime();
 
         ExamStageEntity esEntity = examStageRepo.findByExamIdAndStageOrder(exam.getId(), 1);
-        if(esEntity==null) {
-        	esEntity=new ExamStageEntity();
+        if (esEntity == null) {
+            esEntity = new ExamStageEntity();
         }
         esEntity.setStartTime(examStartTime);
-        if(req.getLateMinuteLimit()==null) {
-        	esEntity.setEndTime(examEndTime);
-        }else {
-        	Date temEnd=DateUtils.addMinutes(examStartTime, req.getLateMinuteLimit());
-        	if(temEnd.getTime()>examEndTime.getTime()) {
-        		esEntity.setEndTime(examEndTime);
-        	}else {
-        		esEntity.setEndTime(temEnd);
-        	}
+        if (req.getLateMinuteLimit() == null) {
+            esEntity.setEndTime(examEndTime);
+        } else {
+            Date temEnd = DateUtils.addMinutes(examStartTime, req.getLateMinuteLimit());
+            if (temEnd.getTime() > examEndTime.getTime()) {
+                esEntity.setEndTime(examEndTime);
+            } else {
+                esEntity.setEndTime(temEnd);
+            }
         }
-        
-        if(req.getEnableTimingEnd()!=null&&req.getEnableTimingEnd()) {
-        	esEntity.setSubmitType(SubmitType.TIMING_END);
-        	esEntity.setSpecialSetting(true);
-        }else {
-        	esEntity.setSubmitType(SubmitType.NORMAL);
-        	esEntity.setSpecialSetting(false);
+
+        if (req.getEnableTimingEnd() != null && req.getEnableTimingEnd()) {
+            esEntity.setSubmitType(SubmitType.TIMING_END);
+            esEntity.setSpecialSetting(true);
+        } else {
+            esEntity.setSubmitType(SubmitType.NORMAL);
+            esEntity.setSpecialSetting(false);
         }
         esEntity.setRootOrgId(exam.getRootOrgId());
         esEntity.setExamId(exam.getId());
@@ -566,6 +569,9 @@ public class ExamCloudServiceProvider extends ControllerSupport implements ExamC
             if (null != enable) {
                 predicates.add(cb.equal(root.get("enable"), enable));
             }
+            if (null != req.getArchived()) {
+                predicates.add(cb.equal(root.get("archived"), req.getArchived()));
+            }
             if (CollectionUtils.isNotEmpty(examTypes)) {
                 if (1 == examTypeList.size()) {
                     predicates.add(cb.equal(root.get("examType"), examTypes.get(0)));

+ 208 - 198
examcloud-core-examwork-dao/src/main/java/cn/com/qmth/examcloud/core/examwork/dao/entity/ExamEntity.java

@@ -23,213 +23,223 @@ import cn.com.qmth.examcloud.web.jpa.JpaEntity;
  */
 @Entity
 @Table(name = "EC_E_EXAM", indexes = { @Index(name = "IDX_E_E_001001", columnList = "rootOrgId,name", unique = true),
-		@Index(name = "IDX_E_E_001002", columnList = "rootOrgId,code", unique = true) })
+        @Index(name = "IDX_E_E_001002", columnList = "rootOrgId,code", unique = true) })
 public class ExamEntity extends JpaEntity {
 
-	private static final long serialVersionUID = 4009839764353162256L;
-
-	@Id
-	@GeneratedValue(strategy = GenerationType.IDENTITY)
-	private Long id;
-
-	/**
-	 * 顶级机构Id
-	 */
-	@Column(nullable = false)
-	private Long rootOrgId;
-
-	/**
-	 * 考试批次开始时间
-	 */
-	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	private Date beginTime;
-
-	/**
-	 * 考试批次结束时间
-	 */
-	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-	private Date endTime;
-
-	/**
-	 * 考试名称
-	 */
-	@Column(nullable = false)
-	private String name;
-
-	/**
-	 * 考试编码
-	 */
-	@Column(nullable = false)
-	private String code;
-
-	/**
-	 * 考试类型
-	 */
-	@Column(nullable = false)
-	@Enumerated(EnumType.STRING)
-	private ExamType examType;
-
-	/**
-	 * 考试时长
-	 */
-	private Integer duration;
-
-	@Column(nullable = false)
-	private Boolean enable;
-
-	/**
-	 * 考试备注
-	 */
-	private String remark;
-
-	/**
-	 * 考试次数
-	 */
-	private Long examTimes;
-
-	/**
-	 * 考生锁定(为true时,不能更新考生)
-	 */
-	private Boolean examStudentLocked;
-
-	/**
-	 * 是否禁止考试
-	 */
-	private Boolean examLimit;
-
-	/**
-	 * 开启特殊设置
-	 */
-	@Column(nullable = false)
-	private Boolean specialSettingsEnabled;
-
-	/**
-	 * 特殊设置类型
-	 */
-	@Column(nullable = true)
-	@Enumerated(EnumType.STRING)
-	private ExamSpecialSettingsType specialSettingsType;
-
-
-	public Long getId() {
-		return id;
-	}
-
-	public void setId(Long id) {
-		this.id = id;
-	}
-
-	public Long getRootOrgId() {
-		return rootOrgId;
-	}
-
-	public void setRootOrgId(Long rootOrgId) {
-		this.rootOrgId = rootOrgId;
-	}
-
-	public Date getBeginTime() {
-		return beginTime;
-	}
-
-	public void setBeginTime(Date beginTime) {
-		this.beginTime = beginTime;
-	}
-
-	public Date getEndTime() {
-		return endTime;
-	}
-
-	public void setEndTime(Date endTime) {
-		this.endTime = endTime;
-	}
-
-	public String getName() {
-		return name;
-	}
-
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	public String getCode() {
-		return code;
-	}
-
-	public void setCode(String code) {
-		this.code = code;
-	}
-
-	public ExamType getExamType() {
-		return examType;
-	}
-
-	public void setExamType(ExamType examType) {
-		this.examType = examType;
-	}
-
-	public Integer getDuration() {
-		return duration;
-	}
-
-	public void setDuration(Integer duration) {
-		this.duration = duration;
-	}
-
-	public Boolean getEnable() {
-		return enable;
-	}
-
-	public void setEnable(Boolean enable) {
-		this.enable = enable;
-	}
-
-	public String getRemark() {
-		return remark;
-	}
+    private static final long serialVersionUID = 4009839764353162256L;
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    private Long id;
+
+    /**
+     * 顶级机构Id
+     */
+    @Column(nullable = false)
+    private Long rootOrgId;
+
+    /**
+     * 考试批次开始时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date beginTime;
+
+    /**
+     * 考试批次结束时间
+     */
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date endTime;
+
+    /**
+     * 考试名称
+     */
+    @Column(nullable = false)
+    private String name;
+
+    /**
+     * 考试编码
+     */
+    @Column(nullable = false)
+    private String code;
+
+    /**
+     * 考试类型
+     */
+    @Column(nullable = false)
+    @Enumerated(EnumType.STRING)
+    private ExamType examType;
+
+    /**
+     * 考试时长
+     */
+    private Integer duration;
+
+    @Column(nullable = false)
+    private Boolean enable;
+
+    /**
+     * 考试备注
+     */
+    private String remark;
+
+    /**
+     * 考试次数
+     */
+    private Long examTimes;
+
+    /**
+     * 考生锁定(为true时,不能更新考生)
+     */
+    private Boolean examStudentLocked;
+
+    /**
+     * 是否禁止考试
+     */
+    private Boolean examLimit;
+
+    /**
+     * 开启特殊设置
+     */
+    @Column(nullable = false)
+    private Boolean specialSettingsEnabled;
+
+    /**
+     * 特殊设置类型
+     */
+    @Column(nullable = true)
+    @Enumerated(EnumType.STRING)
+    private ExamSpecialSettingsType specialSettingsType;
+
+    // 是否归档
+    @Column(nullable = false)
+    private Boolean archived;
+
+    public Boolean getArchived() {
+        return archived;
+    }
+
+    public void setArchived(Boolean archived) {
+        this.archived = archived;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getRootOrgId() {
+        return rootOrgId;
+    }
+
+    public void setRootOrgId(Long rootOrgId) {
+        this.rootOrgId = rootOrgId;
+    }
+
+    public Date getBeginTime() {
+        return beginTime;
+    }
+
+    public void setBeginTime(Date beginTime) {
+        this.beginTime = beginTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public ExamType getExamType() {
+        return examType;
+    }
+
+    public void setExamType(ExamType examType) {
+        this.examType = examType;
+    }
+
+    public Integer getDuration() {
+        return duration;
+    }
+
+    public void setDuration(Integer duration) {
+        this.duration = duration;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public Long getExamTimes() {
+        return examTimes;
+    }
+
+    public void setExamTimes(Long examTimes) {
+        this.examTimes = examTimes;
+    }
 
-	public void setRemark(String remark) {
-		this.remark = remark;
-	}
+    public Boolean getExamStudentLocked() {
+        return examStudentLocked;
+    }
 
-	public Long getExamTimes() {
-		return examTimes;
-	}
+    public void setExamStudentLocked(Boolean examStudentLocked) {
+        this.examStudentLocked = examStudentLocked;
+    }
 
-	public void setExamTimes(Long examTimes) {
-		this.examTimes = examTimes;
-	}
+    public Boolean getExamLimit() {
+        return examLimit;
+    }
 
-	public Boolean getExamStudentLocked() {
-		return examStudentLocked;
-	}
+    public void setExamLimit(Boolean examLimit) {
+        this.examLimit = examLimit;
+    }
 
-	public void setExamStudentLocked(Boolean examStudentLocked) {
-		this.examStudentLocked = examStudentLocked;
-	}
+    public Boolean getSpecialSettingsEnabled() {
+        return specialSettingsEnabled;
+    }
 
-	public Boolean getExamLimit() {
-		return examLimit;
-	}
+    public void setSpecialSettingsEnabled(Boolean specialSettingsEnabled) {
+        this.specialSettingsEnabled = specialSettingsEnabled;
+    }
 
-	public void setExamLimit(Boolean examLimit) {
-		this.examLimit = examLimit;
-	}
-
-	public Boolean getSpecialSettingsEnabled() {
-		return specialSettingsEnabled;
-	}
-
-	public void setSpecialSettingsEnabled(Boolean specialSettingsEnabled) {
-		this.specialSettingsEnabled = specialSettingsEnabled;
-	}
-
-	public ExamSpecialSettingsType getSpecialSettingsType() {
-		return specialSettingsType;
-	}
-
-	public void setSpecialSettingsType(ExamSpecialSettingsType specialSettingsType) {
-		this.specialSettingsType = specialSettingsType;
-	}
+    public ExamSpecialSettingsType getSpecialSettingsType() {
+        return specialSettingsType;
+    }
 
+    public void setSpecialSettingsType(ExamSpecialSettingsType specialSettingsType) {
+        this.specialSettingsType = specialSettingsType;
+    }
 
 }