Parcourir la source

Merge remote-tracking branch 'origin/hotfixes_v5.0.2_20240311_updates' into dev_v5.0.3

deason il y a 1 an
Parent
commit
cc8e833bf9

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

@@ -197,7 +197,7 @@ public class ExamController extends ControllerSupport {
     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")
@@ -1407,9 +1407,11 @@ public class ExamController extends ControllerSupport {
                                                  @RequestParam CommonsMultipartFile file) {
         DiskFileItem item = (DiskFileItem) file.getFileItem();
         File storeLocation = item.getStoreLocation();
+
+        int columnCount = 3;
         List<String[]> lineList;
         try {
-            lineList = ExcelReader.readSheetBySax(PathUtil.getCanonicalPath(storeLocation), 1, 2);
+            lineList = ExcelReader.readSheetBySax(PathUtil.getCanonicalPath(storeLocation), 1, columnCount);
         } catch (Exception e) {
             throw new StatusException("100110", "Excel 解析失败");
         }
@@ -1463,6 +1465,11 @@ public class ExamController extends ControllerSupport {
             }
             entity.setLimitType(ipLimitType);
 
+            // 备注
+            if(line.length == columnCount && line[2] != null){
+                entity.setRemark(line[2]);
+            }
+
             Date date = new Date();
             entity.setCreationTime(date);
             entity.setUpdateTime(date);
@@ -1500,14 +1507,14 @@ public class ExamController extends ControllerSupport {
 
         for (ExamIpLimitEntity cur : list) {
             String type = cur.getLimitType() == null ? "" : cur.getLimitType().getTitle();
-            datas.add(new Object[]{cur.getIp(), type});
+            datas.add(new Object[]{cur.getIp(), type, cur.getRemark()});
         }
 
         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}, datas,
+        ExcelWriter.write(EXCEL_IP_LIMIT_HEADER, new Class[]{String.class, String.class, String.class}, datas,
                 new File(filePath));
 
         exportFile("Ip访问限制列表-" + getRootOrgId() + ".xlsx", file);

+ 10 - 0
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/bean/ExamIpLimitInfo.java

@@ -35,6 +35,8 @@ public class ExamIpLimitInfo implements JsonSerializable {
 
 	private String limitType;
 
+	private String remark;
+
 	/**
 	 * 创建时间
 	 */
@@ -100,4 +102,12 @@ public class ExamIpLimitInfo implements JsonSerializable {
 	public void setUpdateTime(Date updateTime) {
 		this.updateTime = updateTime;
 	}
+
+	public String getRemark() {
+		return remark;
+	}
+
+	public void setRemark(String remark) {
+		this.remark = remark;
+	}
 }

+ 12 - 1
examcloud-core-examwork-service/src/main/java/cn/com/qmth/examcloud/core/examwork/service/impl/ExamServiceImpl.java

@@ -861,8 +861,14 @@ public class ExamServiceImpl implements ExamService {
         List<ExamIpLimitInfo> list = new ArrayList<>();
         pages.getList().forEach(e -> {
             ExamIpLimitInfo domain = new ExamIpLimitInfo();
-            BeanUtils.copyProperties(e, domain);
+            domain.setId(e.getId());
+            domain.setIp(e.getIp());
+            domain.setExamId(e.getExamId());
             domain.setLimitType(e.getLimitType() == null ? "" : e.getLimitType().getTitle());
+            domain.setRemark(e.getRemark());
+            domain.setCreationTime(e.getCreationTime());
+            domain.setUpdateTime(e.getUpdateTime());
+
             Optional<ExamEntity> byId = examRepo.findById(examId);
             byId.ifPresent(examEntity -> domain.setExamName(examEntity.getName()));
             list.add(domain);
@@ -976,6 +982,11 @@ public class ExamServiceImpl implements ExamService {
                     if (entity.getLimitType() != null) {
                         ipLimitEntity.setLimitType(entity.getLimitType());
                     }
+
+                    if (StringUtils.isNotEmpty(entity.getRemark())) {
+                        ipLimitEntity.setRemark(entity.getRemark());
+                    }
+
                     ipLimitEntity.setUpdateTime(now);
                     examIpLimitRepo.save(ipLimitEntity);
                 }

BIN
examcloud-core-examwork-starter/src/main/resources/templates/ipLimitImportTemplate.xlsx