Browse Source

1.新增在线作业功能。
2.将网考中的考试类型枚举,统一改为调用公共模块中的枚举

lideyin 5 years ago
parent
commit
fb67418ed2
14 changed files with 802 additions and 17 deletions
  1. 59 0
      examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/bean/IllegallyTypeDomain.java
  2. 14 1
      examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamControlController.java
  3. 328 0
      examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/IllegallyTypeController.java
  4. 2 1
      examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/provider/ExamScoreDataCloudServiceProvider.java
  5. 21 0
      examcloud-core-oe-admin-dao/src/main/java/cn/com/qmth/examcloud/core/oe/admin/dao/IllegallyTypeRepo.java
  6. 66 0
      examcloud-core-oe-admin-dao/src/main/java/cn/com/qmth/examcloud/core/oe/admin/dao/entity/IllegallyTypeEntity.java
  7. 7 6
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamStudentService.java
  8. 37 0
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/IllegallyTypeService.java
  9. 59 0
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/bean/IllegallyTypeInfo.java
  10. 5 4
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordForMarkingServiceImpl.java
  11. 1 1
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordQuestionsServiceImpl.java
  12. 4 4
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamStudentServiceImpl.java
  13. 199 0
      examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/IllegallyTypeServiceImpl.java
  14. BIN
      examcloud-core-oe-admin-starter/src/main/resources/templates/illegallyTypeImportTemplate.xlsx

+ 59 - 0
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/bean/IllegallyTypeDomain.java

@@ -0,0 +1,59 @@
+package cn.com.qmth.examcloud.core.oe.admin.api.bean;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+
+public class IllegallyTypeDomain implements JsonSerializable {
+
+	private static final long serialVersionUID = 239263456816448160L;
+
+	private Long id;
+
+	private String code;
+
+	private String name;
+
+	private Long rootOrgId;
+
+	private Boolean enable;
+
+	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 String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
+	public Boolean getEnable() {
+		return enable;
+	}
+
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
+	}
+
+}

+ 14 - 1
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/ExamControlController.java

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.oe.admin.api.controller;
 
 import java.util.List;
 
+import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -31,6 +32,18 @@ public class ExamControlController extends ControllerSupport {
 	@GetMapping("/queryExamList")
 	public List<OnHandExamInfo> queryExamList() {
 		User user = getAccessUser();
-		return examStudentService.queryOnlineExamList(user.getUserId());
+		return examStudentService.queryOnlineExamList(user.getUserId(), ExamType.ONLINE);
+	}
+
+	/**
+	 * 获取在线考试待考列表
+	 *
+	 * @return
+	 */
+	@ApiOperation(value = "获取在线作业待考列表")
+	@GetMapping("/queryHomeworkList")
+	public List<OnHandExamInfo> queryHomeworkList() {
+		User user = getAccessUser();
+		return examStudentService.queryOnlineExamList(user.getUserId(),ExamType.ONLINE_HOMEWORK);
 	}
 }

+ 328 - 0
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/controller/IllegallyTypeController.java

@@ -0,0 +1,328 @@
+package cn.com.qmth.examcloud.core.oe.admin.api.controller;
+
+import cn.com.qmth.examcloud.api.commons.security.bean.User;
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.commons.helpers.poi.ExcelWriter;
+import cn.com.qmth.examcloud.commons.util.PathUtil;
+import cn.com.qmth.examcloud.core.oe.admin.api.bean.IllegallyTypeDomain;
+import cn.com.qmth.examcloud.core.oe.admin.dao.IllegallyTypeRepo;
+import cn.com.qmth.examcloud.core.oe.admin.dao.entity.IllegallyTypeEntity;
+import cn.com.qmth.examcloud.core.oe.admin.service.IllegallyTypeService;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.IllegallyTypeInfo;
+import cn.com.qmth.examcloud.web.config.SystemProperties;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
+import cn.com.qmth.examcloud.web.support.ControllerSupport;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import io.swagger.annotations.ApiOperation;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.fileupload.disk.DiskFileItem;
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.domain.Sort.Direction;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
+
+import javax.persistence.criteria.Predicate;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * @Description 违纪类型
+ * @Author lideyin
+ * @Date 2020/2/20 18:56
+ * @Version 1.0
+ */
+@RestController
+@RequestMapping("${$rmp.ctr.oe}/illegallyType")
+public class IllegallyTypeController extends ControllerSupport {
+
+    @Autowired
+    IllegallyTypeService illegallyTypeService;
+
+    @Autowired
+    SystemProperties systemConfig;
+
+    @Autowired
+    IllegallyTypeRepo illegallyTypeRepo;
+
+    private static final String[] EXCEL_HEADER = new String[]{"违纪类型名称", "违纪类型代码"};
+
+    /**
+     * 方法注释
+     *
+     * @param curPage
+     * @param pageSize
+     * @param name
+     * @param code
+     * @param enable
+     * @param courseId
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "分页查询违纪类型")
+    @GetMapping("specialtyPage/{curPage}/{pageSize}")
+    public Page<IllegallyTypeEntity> getSpecialtyPage(@PathVariable Integer curPage,
+                                                      @PathVariable Integer pageSize, @RequestParam(required = false) String name,
+                                                      @RequestParam(required = false) String code,
+                                                      @RequestParam(required = false) Boolean enable,
+                                                      @RequestParam(required = false) Long courseId) {
+        User accessUser = getAccessUser();
+
+        Specification<IllegallyTypeEntity> specification = (root, query, cb) -> {
+            List<Predicate> predicates = new ArrayList<>();
+
+            predicates.add(cb.equal(root.get("rootOrgId"), accessUser.getRootOrgId()));
+
+            if (StringUtils.isNotBlank(name)) {
+                predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
+            }
+            if (StringUtils.isNotBlank(code)) {
+                predicates.add(cb.like(root.get("code"), toSqlSearchPattern(code)));
+            }
+            if (null != enable) {
+                predicates.add(cb.equal(root.get("enable"), enable));
+            }
+
+            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+
+        PageRequest pageRequest = PageRequest.of(curPage, pageSize,
+                new Sort(Direction.DESC, "updateTime", "id"));
+
+        Page<IllegallyTypeEntity> page = illegallyTypeRepo.findAll(specification, pageRequest);
+        return page;
+    }
+
+    @ApiOperation(value = "查询违纪类型")
+    @GetMapping("query")
+    public List<IllegallyTypeEntity> query(@RequestParam(required = false) String name,
+                                           @RequestParam(required = false) String code,
+                                           @RequestParam(required = false) Boolean enable,
+                                           @RequestParam(required = false) Long courseId) {
+
+        User accessUser = getAccessUser();
+        Long rootOrgId = accessUser.getRootOrgId();
+
+        Specification<IllegallyTypeEntity> specification = (root, query, cb) -> {
+            List<Predicate> predicates = new ArrayList<>();
+
+            predicates.add(cb.equal(root.get("rootOrgId"), rootOrgId));
+
+            if (StringUtils.isNotBlank(name)) {
+                predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
+            }
+            if (StringUtils.isNotBlank(code)) {
+                predicates.add(cb.like(root.get("code"), toSqlSearchPattern(code)));
+            }
+            if (null != enable) {
+                predicates.add(cb.equal(root.get("enable"), enable));
+            }
+
+            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+
+        // 过载保护
+        long total = illegallyTypeRepo.count(specification);
+        if (total > 1000) {
+            List<IllegallyTypeEntity> list = Lists.newArrayList();
+            return list;
+        }
+
+        List<IllegallyTypeEntity> list = illegallyTypeRepo.findAll(specification,
+                new Sort(Direction.DESC, "updateTime"));
+        return list;
+    }
+
+    /**
+     * 方法注释
+     *
+     * @param orgId
+     * @param code
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "查询违纪类型")
+    @GetMapping("byCode")
+    public IllegallyTypeEntity getByCode(@RequestParam Long orgId, @RequestParam String code) {
+        IllegallyTypeEntity specialty = illegallyTypeRepo.findByRootOrgIdAndCode(orgId, code);
+        if (null == specialty) {
+            throw new StatusException("620002", "违纪类型不存在");
+        }
+        validateRootOrgIsolation(specialty.getRootOrgId());
+        return specialty;
+    }
+
+    /**
+     * 修正
+     *
+     * @param domain
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "新增违纪类型", notes = "新增")
+    @PostMapping
+    @Transactional
+    public Long addSpecialty(@RequestBody IllegallyTypeDomain domain) {
+        trim(domain, true);
+
+        User accessUser = getAccessUser();
+        Long rootOrgId = accessUser.getRootOrgId();
+
+        String code = domain.getCode();
+        if (StringUtils.isBlank(code)) {
+            throw new StatusException("620001", "code is blank");
+        }
+        IllegallyTypeEntity course = illegallyTypeRepo.findByRootOrgIdAndCode(rootOrgId, code);
+        if (null != course) {
+            throw new StatusException("620002", "违纪类型编码已被占用");
+        }
+
+        IllegallyTypeInfo info = new IllegallyTypeInfo();
+        info.setRootOrgId(rootOrgId);
+        info.setCode(domain.getCode());
+        info.setEnable(domain.getEnable());
+        info.setId(domain.getId());
+        info.setName(domain.getName());
+        info.setEnable(domain.getEnable());
+
+        IllegallyTypeEntity saved = illegallyTypeService.saveIllegallyType(info);
+        return saved.getId();
+    }
+
+    /**
+     * 修正
+     *
+     * @param domain
+     * @return
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "修改违纪类型", notes = "新增")
+    @PutMapping
+    @Transactional
+    public Long updateSpecialty(@RequestBody IllegallyTypeDomain domain) {
+        trim(domain, true);
+
+        User accessUser = getAccessUser();
+        Long rootOrgId = accessUser.getRootOrgId();
+
+        IllegallyTypeInfo info = new IllegallyTypeInfo();
+        info.setId(info.getId());
+        info.setRootOrgId(rootOrgId);
+        info.setCode(domain.getCode());
+        info.setEnable(domain.getEnable());
+        info.setId(domain.getId());
+        info.setName(domain.getName());
+        info.setEnable(domain.getEnable());
+
+        IllegallyTypeEntity saved = illegallyTypeService.saveIllegallyType(info);
+        return saved.getId();
+    }
+
+    /**
+     * 方法注释
+     *
+     * @param ids
+     * @author WANGWEI
+     */
+    @ApiOperation(value = "删除违纪类型")
+    @DeleteMapping("{ids}")
+    @Transactional
+    public void delete(@PathVariable String ids) {
+        List<Long> typeIds = Stream.of(ids.split(",")).map(s -> Long.parseLong(s.trim()))
+                .collect(Collectors.toList());
+        for (Long typeId : typeIds) {
+            IllegallyTypeEntity one = GlobalHelper.getEntity(illegallyTypeRepo, typeId,
+                    IllegallyTypeEntity.class);
+            if (null == one) {
+                continue;
+            }
+            validateRootOrgIsolation(one.getRootOrgId());
+            illegallyTypeRepo.delete(one);
+
+        }
+    }
+
+    @ApiOperation(value = "下载导入模板", notes = "下载导入模板")
+    @GetMapping("importTemplate")
+    public void getDownloadTemplate(HttpServletResponse response) {
+        String resoucePath = PathUtil.getResoucePath("templates/illegallyTypeImportTemplate.xlsx");
+        exportFile("违纪类型导入模板.xlsx", new File(resoucePath));
+    }
+
+    @ApiOperation(value = "导入", notes = "导入")
+    @PostMapping("import")
+    @Transactional
+    public Map<String, Object> importSpecialty(@RequestParam CommonsMultipartFile file) {
+        DiskFileItem item = (DiskFileItem) file.getFileItem();
+        File storeLocation = item.getStoreLocation();
+        List<Map<String, Object>> failRecords = illegallyTypeService.importIllegallyType(getRootOrgId(),
+                storeLocation);
+        Map<String, Object> map = Maps.newHashMap();
+        map.put("hasError", CollectionUtils.isNotEmpty(failRecords));
+        map.put("failRecords", failRecords);
+        return map;
+    }
+
+    @ApiOperation(value = "导出违纪类型")
+    @GetMapping("export")
+    public void export(@RequestParam(required = false) String name,
+                       @RequestParam(required = false) String code,
+                       @RequestParam(required = false) Boolean enable,
+                       @RequestParam(required = false) Long courseId) {
+        User accessUser = getAccessUser();
+
+        Specification<IllegallyTypeEntity> specification = (root, query, cb) -> {
+            List<Predicate> predicates = new ArrayList<>();
+
+            predicates.add(cb.equal(root.get("rootOrgId"), accessUser.getRootOrgId()));
+
+            if (StringUtils.isNotBlank(name)) {
+                predicates.add(cb.like(root.get("name"), toSqlSearchPattern(name)));
+            }
+            if (StringUtils.isNotBlank(code)) {
+                predicates.add(cb.like(root.get("code"), toSqlSearchPattern(code)));
+            }
+            if (null != enable) {
+                predicates.add(cb.equal(root.get("enable"), enable));
+            }
+
+            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+
+        long count = illegallyTypeRepo.count(specification);
+        if (100000 < count) {
+            throw new StatusException("620200", "数据量过大,无法导出");
+        }
+
+        List<IllegallyTypeEntity> list = illegallyTypeRepo.findAll(specification);
+
+        List<Object[]> datas = Lists.newArrayList();
+
+        for (IllegallyTypeEntity cur : list) {
+            datas.add(new Object[]{cur.getName(), cur.getCode()});
+        }
+
+        String filePath = systemConfig.getTempDataDir() + File.separator
+                + System.currentTimeMillis() + ".xlsx";
+        File file = new File(filePath);
+
+        ExcelWriter.write(EXCEL_HEADER, new Class[]{String.class, String.class}, datas,
+                new File(filePath));
+
+        exportFile("违纪类型列表-" + getRootOrgId() + ".xlsx", file);
+
+        FileUtils.deleteQuietly(file);
+    }
+}

+ 2 - 1
examcloud-core-oe-admin-api-provider/src/main/java/cn/com/qmth/examcloud/core/oe/admin/api/provider/ExamScoreDataCloudServiceProvider.java

@@ -370,7 +370,8 @@ public class ExamScoreDataCloudServiceProvider extends ControllerSupport impleme
         //只支持离线和在线考试
         ExamBean examSettings = ExamCacheTransferHelper.getDefaultCachedExam(req.getExamId());
         if (!(ExamType.ONLINE.toString().equals(examSettings.getExamType()) ||
-                ExamType.OFFLINE.toString().equals(examSettings.getExamType()))) {
+                ExamType.OFFLINE.toString().equals(examSettings.getExamType()) ||
+                ExamType.ONLINE_HOMEWORK.toString().equals(examSettings.getExamType()))) {
             throw new StatusException("100009", "不支持的考试类型");
         }
 

+ 21 - 0
examcloud-core-oe-admin-dao/src/main/java/cn/com/qmth/examcloud/core/oe/admin/dao/IllegallyTypeRepo.java

@@ -0,0 +1,21 @@
+package cn.com.qmth.examcloud.core.oe.admin.dao;
+
+import cn.com.qmth.examcloud.core.oe.admin.dao.entity.IllegallyTypeEntity;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
+
+import java.util.List;
+
+public interface IllegallyTypeRepo
+		extends
+			JpaRepository<IllegallyTypeEntity, Long>,
+			QueryByExampleExecutor<IllegallyTypeEntity>,
+			JpaSpecificationExecutor<IllegallyTypeEntity> {
+
+	IllegallyTypeEntity findByRootOrgIdAndCode(Long rootOrgId, String code);
+
+	List<IllegallyTypeEntity> findByRootOrgId(Long rootOrgId);
+
+	int countByRootOrgIdAndNameLike(Long rootOrgId, String name);
+}

+ 66 - 0
examcloud-core-oe-admin-dao/src/main/java/cn/com/qmth/examcloud/core/oe/admin/dao/entity/IllegallyTypeEntity.java

@@ -0,0 +1,66 @@
+package cn.com.qmth.examcloud.core.oe.admin.dao.entity;
+
+import cn.com.qmth.examcloud.web.jpa.WithIdJpaEntity;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Index;
+import javax.persistence.Table;
+
+/**
+ * @Description 违纪类型
+ * @Author lideyin
+ * @Date 2020/2/20 15:06
+ * @Version 1.0
+ */
+@Entity
+@Table(name = "EC_OE_ILLEGALLY_TYPE", indexes = {
+        @Index(name = "IDX_E_O_I_T_001", columnList = "rootOrgId,code", unique = true)})
+public class IllegallyTypeEntity extends WithIdJpaEntity {
+    private static final long serialVersionUID = 2612362994854920896L;
+
+    @Column(nullable = false)
+    private String code;
+
+    @Column(nullable = false)
+    private String name;
+
+    @Column(nullable = false)
+    private Long rootOrgId;
+
+    @Column(nullable = false)
+    private Boolean enable;
+
+    public String getCode() {
+        return code;
+    }
+
+    public void setCode(String code) {
+        this.code = code;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public Long getRootOrgId() {
+        return rootOrgId;
+    }
+
+    public void setRootOrgId(Long rootOrgId) {
+        this.rootOrgId = rootOrgId;
+    }
+
+    public Boolean getEnable() {
+        return enable;
+    }
+
+    public void setEnable(Boolean enable) {
+        this.enable = enable;
+    }
+
+}

+ 7 - 6
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/ExamStudentService.java

@@ -9,6 +9,7 @@ package cn.com.qmth.examcloud.core.oe.admin.service;
 
 import java.util.List;
 
+import cn.com.qmth.examcloud.api.commons.enums.ExamType;
 import org.springframework.data.domain.Page;
 
 import cn.com.qmth.examcloud.core.oe.admin.service.bean.OnHandExamInfo;
@@ -124,11 +125,11 @@ public interface ExamStudentService {
 	public List<ExamStudentInfo> getLimitExamStudentList(Long examId,Long startId,Integer size);
 
 	/**
-     * 获取在线考试待考列表
-     * @param studentId
-     * @return
-     */
-    public List<OnHandExamInfo> queryOnlineExamList(Long studentId);
-    
+	 * 获取在线考试待考列表
+	 * @param studentId 学生id
+	 * @param examType 考试类型
+	 * @return
+	 */
+    public List<OnHandExamInfo> queryOnlineExamList(Long studentId, ExamType examType);
 
 }

+ 37 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/IllegallyTypeService.java

@@ -0,0 +1,37 @@
+package cn.com.qmth.examcloud.core.oe.admin.service;
+
+import cn.com.qmth.examcloud.core.oe.admin.dao.entity.IllegallyTypeEntity;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.IllegallyTypeInfo;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description 违纪类型
+ * @Author lideyin
+ * @Date 2020/2/20 15:23
+ * @Version 1.0
+ */
+public interface IllegallyTypeService {
+
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param info
+	 * @return
+	 */
+	IllegallyTypeEntity saveIllegallyType(IllegallyTypeInfo info);
+
+	/**
+	 * 导入专业
+	 *
+	 * @author WANGWEI
+	 * @param rootOrgId
+	 * @param file
+	 * @return
+	 */
+	List<Map<String, Object>> importIllegallyType(Long rootOrgId, File file);
+
+}

+ 59 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/bean/IllegallyTypeInfo.java

@@ -0,0 +1,59 @@
+package cn.com.qmth.examcloud.core.oe.admin.service.bean;
+
+import cn.com.qmth.examcloud.api.commons.exchange.JsonSerializable;
+
+public class IllegallyTypeInfo implements JsonSerializable {
+
+	private static final long serialVersionUID = 239263456816448160L;
+
+	private Long id;
+
+	private String code;
+
+	private String name;
+
+	private Long rootOrgId;
+
+	private Boolean enable;
+
+	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 String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	public Long getRootOrgId() {
+		return rootOrgId;
+	}
+
+	public void setRootOrgId(Long rootOrgId) {
+		this.rootOrgId = rootOrgId;
+	}
+
+	public Boolean getEnable() {
+		return enable;
+	}
+
+	public void setEnable(Boolean enable) {
+		this.enable = enable;
+	}
+
+}

+ 5 - 4
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordForMarkingServiceImpl.java

@@ -84,8 +84,9 @@ public class ExamRecordForMarkingServiceImpl implements ExamRecordForMarkingServ
             examRecordForMarkingList =
                     examRecordForMarkingRepo.findByExamIdAndCourseIdAndExamStudentIds(examId, courseId, examStudentIds);
         } else {
-            if (examType == ExamType.ONLINE && (markingType.equals(MarkingType.OBJECT_SCORE_MAX.name())
-                    || markingType.equals(MarkingType.LAST_SUBMIT.name()))) {
+            if ((ExamType.ONLINE == examType || ExamType.ONLINE_HOMEWORK == examType) &&
+                    (MarkingType.OBJECT_SCORE_MAX.name().equals(markingType) ||
+                            MarkingType.LAST_SUBMIT.name().equals(markingType))) {
                 examRecordForMarkingList =
                         examRecordForMarkingRepo.findByExamIdAndCourseIdAndExamStudentIds(examId, courseId, examStudentIds);
             } else {
@@ -95,7 +96,7 @@ public class ExamRecordForMarkingServiceImpl implements ExamRecordForMarkingServ
         }
         if (examType == ExamType.OFFLINE) {
             return examRecordForMarkingList;
-        } else if (examType == ExamType.ONLINE) {
+        } else if (ExamType.ONLINE == examType || ExamType.ONLINE_HOMEWORK == examType) {
             if (markingType.equals(MarkingType.ALL.name())) {
                 return examRecordForMarkingList;
             } else if (markingType.equals(MarkingType.OBJECT_SCORE_MAX.name())) {
@@ -117,7 +118,7 @@ public class ExamRecordForMarkingServiceImpl implements ExamRecordForMarkingServ
         List<ExamRecordForMarkingEntity> examRecordForMarkingList = examRecordForMarkingRepo.findByExamIdAndCourseId(examId, courseId);
         if (examType == ExamType.OFFLINE) {
             return examRecordForMarkingList;
-        } else if (examType == ExamType.ONLINE) {
+        } else if (ExamType.ONLINE == examType || ExamType.ONLINE_HOMEWORK == examType) {
             GetExamPropertyReq getExamPropertyReq = new GetExamPropertyReq();
             getExamPropertyReq.setExamId(examId);
             getExamPropertyReq.setKey("MARKING_TYPE");

+ 1 - 1
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamRecordQuestionsServiceImpl.java

@@ -62,7 +62,7 @@ public class ExamRecordQuestionsServiceImpl implements ExamRecordQuestionsServic
     @Override
     public void saveSubjectiveQuestionScore(Long examRecordDataId, List<SubjectiveQuestionScoreInfo> subjectiveQuestionScoreInfoList) {
         ExamRecordDataEntity examRecordData = GlobalHelper.getEntity(examRecordDataRepo, examRecordDataId, ExamRecordDataEntity.class);
-        if (examRecordData.getExamType() == ExamType.ONLINE) {
+        if (ExamType.ONLINE == examRecordData.getExamType() || ExamType.ONLINE_HOMEWORK==examRecordData.getExamType()) {
             ExamRecordQuestionsEntity examRecordQuestionsEntity = examRecordQuestionsRepo.findByExamRecordDataId(examRecordDataId);
             List<ExamQuestionEntity> examRecordQuestionList = examRecordQuestionsEntity.getExamQuestionEntities();
 

+ 4 - 4
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/ExamStudentServiceImpl.java

@@ -311,7 +311,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
             sql.append(" and course_level= '" + query.getCourseLevel() + "'");
         }
         if (query.getFinished() != null) {
-            if (ExamType.ONLINE.name().equals(examType)) {
+            if (ExamType.ONLINE.name().equals(examType) || ExamType.ONLINE_HOMEWORK.name().equals(examType)) {
                 sql.append(" and finished = " + query.getFinished());
             } else if (ExamType.OFFLINE.name().equals(examType)) {
                 //如果忽略是否上传答案时,只要是已抽题则认为已参加考试
@@ -347,7 +347,7 @@ public class ExamStudentServiceImpl implements ExamStudentService {
         String photoNumber = localCacheService.getStudentPhotoNumber(cahcheMap, examStudentInfo.getStudentId());
         examStudentInfo.setPhone(photoNumber);//电话号码
 
-        if (ExamType.ONLINE.name().equals(examType)) {
+        if (ExamType.ONLINE.name().equals(examType) || ExamType.ONLINE_HOMEWORK.name().equals(examType)) {
             //完成状态
             examStudentInfo.setFinishedStatus(examStudentEntity.getFinished() ? FinishStatus.已完成.name() : FinishStatus.未完成.name());
         } else if (ExamType.OFFLINE.name().equals(examType)) {
@@ -705,12 +705,12 @@ public class ExamStudentServiceImpl implements ExamStudentService {
      * @param studentId 学生id
      */
     @Override
-    public List<OnHandExamInfo> queryOnlineExamList(Long studentId) {
+    public List<OnHandExamInfo> queryOnlineExamList(Long studentId,ExamType examType) {
         StudentCacheBean studentBean = CacheHelper.getStudent(studentId);
 
         //获取可以考的和即将考的考试Id
         GetOngoingExamListReq getOngoingExamListReq = new GetOngoingExamListReq();
-        getOngoingExamListReq.setExamType(ExamType.ONLINE.name());
+        getOngoingExamListReq.setExamType(examType.name());
         getOngoingExamListReq.setRootOrgId(studentBean.getRootOrgId());
         getOngoingExamListReq.setOrgId(studentBean.getOrgId());
         getOngoingExamListReq.setStudentId(studentId);

+ 199 - 0
examcloud-core-oe-admin-service/src/main/java/cn/com/qmth/examcloud/core/oe/admin/service/impl/IllegallyTypeServiceImpl.java

@@ -0,0 +1,199 @@
+package cn.com.qmth.examcloud.core.oe.admin.service.impl;
+
+import cn.com.qmth.examcloud.commons.exception.StatusException;
+import cn.com.qmth.examcloud.commons.helpers.poi.ExcelReader;
+import cn.com.qmth.examcloud.commons.util.PathUtil;
+import cn.com.qmth.examcloud.core.oe.admin.dao.IllegallyTypeRepo;
+import cn.com.qmth.examcloud.core.oe.admin.dao.entity.IllegallyTypeEntity;
+import cn.com.qmth.examcloud.core.oe.admin.service.IllegallyTypeService;
+import cn.com.qmth.examcloud.core.oe.admin.service.bean.IllegallyTypeInfo;
+import cn.com.qmth.examcloud.web.helpers.GlobalHelper;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class IllegallyTypeServiceImpl implements IllegallyTypeService {
+
+	@Autowired
+	IllegallyTypeRepo illegallyTypeRepo;
+
+	private static final String[] EXCEL_HEADER = new String[]{"违纪类型名称", "违纪类型代码"};
+
+	@Override
+	public IllegallyTypeEntity saveIllegallyType(IllegallyTypeInfo info) {
+		Long id = info.getId();
+		String code = info.getCode();
+		Boolean enable = info.getEnable();
+		Long rootOrgId = info.getRootOrgId();
+		String name = info.getName();
+
+		if (null == rootOrgId) {
+			throw new StatusException("620001", "rootOrgId is null");
+		}
+		IllegallyTypeEntity entity = null;
+
+		if (null != id) {
+			entity = GlobalHelper.getEntity(illegallyTypeRepo, id, IllegallyTypeEntity.class);
+			if (null == entity) {
+				throw new StatusException("620001", "id is wrong");
+			}
+			if (!entity.getRootOrgId().equals(rootOrgId)) {
+				throw new StatusException("620001", "rootOrgId or id is worng");
+			}
+		} else if (StringUtils.isNotBlank(code)) {
+			entity = illegallyTypeRepo.findByRootOrgIdAndCode(rootOrgId, code);
+			if (null == entity) {
+				if (StringUtils.isBlank(name)) {
+					throw new StatusException("620001", "name is blank");
+				}
+				entity = new IllegallyTypeEntity();
+				entity.setCode(code);
+				entity.setName(name);
+				entity.setRootOrgId(rootOrgId);
+				entity.setEnable(true);
+			}
+		} else {
+			throw new StatusException("620001", "id and code can not be all null");
+		}
+
+		if (null != enable) {
+			entity.setEnable(enable);
+		}
+		if (StringUtils.isNotBlank(name)) {
+			entity.setName(name);
+		}
+
+		IllegallyTypeEntity saved = illegallyTypeRepo.save(entity);
+
+		return saved;
+	}
+
+	@Override
+	public List<Map<String, Object>> importIllegallyType(Long rootOrgId, File file) {
+		List<String[]> lineList = null;
+		try {
+			lineList = ExcelReader.readSheetBySax(PathUtil.getCanonicalPath(file), 1, 2);
+		} catch (Exception e) {
+			throw new StatusException("100110", "Excel 解析失败");
+		}
+
+		if (CollectionUtils.isEmpty(lineList)) {
+			throw new StatusException("100111", "Excel无内容");
+		}
+
+		if (10001 < lineList.size()) {
+			throw new StatusException("100112", "数据行数不能超过10000");
+		}
+
+		List<Map<String, Object>> failRecords = Collections
+				.synchronizedList(new ArrayList<Map<String, Object>>());
+
+		List<IllegallyTypeEntity> illegallyTypeList = Lists.newArrayList();
+
+		for (int i = 0; i < lineList.size(); i++) {
+			String[] line = lineList.get(i);
+			if (0 == i) {
+				if (headerError(line)) {
+					throw new StatusException("100111", "Excel表头错误");
+				}
+				continue;
+			}
+
+			boolean hasError = false;
+			StringBuilder msg = new StringBuilder();
+
+			IllegallyTypeEntity illegallyType = new IllegallyTypeEntity();
+			illegallyType.setRootOrgId(rootOrgId);
+			illegallyType.setEnable(true);
+
+			String name = trimAndNullIfBlank(line[0]);
+			if (StringUtils.isBlank(name)) {
+				msg.append("  违纪类型名称不能为空");
+				hasError = true;
+			} else if (name.length() > 30) {
+				msg.append("  违纪类型名称不能超过30个字符");
+				hasError = true;
+			}
+			illegallyType.setName(name);
+
+			String code = trimAndNullIfBlank(line[1]);
+			if (StringUtils.isBlank(code)) {
+				msg.append("  违纪类型代码不能为空");
+				hasError = true;
+			} else if (code.length() > 30) {
+				msg.append("  违纪类型代码不能超过30个字符");
+				hasError = true;
+			}
+
+			illegallyType.setCode(code);
+
+			if (hasError) {
+				failRecords.add(newError(i + 1, msg.toString()));
+			} else {
+				illegallyTypeList.add(illegallyType);
+			}
+
+		}
+
+		if (CollectionUtils.isNotEmpty(failRecords)) {
+			return failRecords;
+		}
+
+		for (IllegallyTypeEntity cur : illegallyTypeList) {
+			IllegallyTypeEntity query = illegallyTypeRepo.findByRootOrgIdAndCode(cur.getRootOrgId(),
+					cur.getCode());
+
+			if (null != query) {
+				query.setName(cur.getName());
+				illegallyTypeRepo.save(query);
+			} else {
+				illegallyTypeRepo.save(cur);
+			}
+		}
+
+		return failRecords;
+	}
+
+	private Map<String, Object> newError(int lineNum, String msg) {
+		Map<String, Object> map = Maps.newHashMap();
+		map.put("lineNum", lineNum);
+		map.put("msg", msg);
+		return map;
+	}
+
+	private String trimAndNullIfBlank(String s) {
+		if (StringUtils.isBlank(s)) {
+			return null;
+		}
+		return s.trim();
+	}
+
+	/**
+	 * 方法注释
+	 *
+	 * @author WANGWEI
+	 * @param header
+	 */
+	private boolean headerError(String[] header) {
+		for (int i = 0; i < EXCEL_HEADER.length; i++) {
+			if (null == header[i]) {
+				return true;
+			}
+			if (!EXCEL_HEADER[i].equals(header[i].trim())) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+}

BIN
examcloud-core-oe-admin-starter/src/main/resources/templates/illegallyTypeImportTemplate.xlsx