deason 1 miesiąc temu
rodzic
commit
c38866c742

+ 40 - 21
src/main/java/cn/com/qmth/examcloud/tool/service/exam_record_data_audit/ExamRecordDataAuditTask.java

@@ -4,17 +4,18 @@ import cn.com.qmth.examcloud.tool.config.SysProperty;
 import cn.com.qmth.examcloud.tool.entity.TaskEntity;
 import cn.com.qmth.examcloud.tool.service.CommonService;
 import cn.com.qmth.examcloud.tool.service.TaskService;
+import cn.com.qmth.examcloud.tool.service.exam_record_data_audit.vo.ExamRecordDataVO;
 import cn.com.qmth.examcloud.tool.utils.HttpHelper;
 import cn.com.qmth.examcloud.tool.vo.user.User;
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.context.AnalysisContext;
+import com.alibaba.excel.event.AnalysisEventListener;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 @Component
 public class ExamRecordDataAuditTask implements TaskService {
@@ -36,28 +37,46 @@ public class ExamRecordDataAuditTask implements TaskService {
      * 将某些考试记录重审为违纪
      */
     public void execute(User loginUser) {
-        Set<Long> examRecordDataIds = new HashSet<>();
-        // examRecordDataIds.add(56370331L);
-        // examRecordDataIds.add(56400977L);
-        // examRecordDataIds.add(56382785L);
-        // examRecordDataIds.add(56342395L);
+        String dataFilePath = "D:/home/data/illegally_list.xlsx";
+        List<ExamRecordDataVO> list = new ArrayList<>();
+        try {
+            EasyExcel.read(dataFilePath, ExamRecordDataVO.class, new AnalysisEventListener<ExamRecordDataVO>() {
+                        @Override
+                        public void invoke(ExamRecordDataVO data, AnalysisContext analysisContext) {
+                            list.add(data);
+                        }
 
+                        @Override
+                        public void doAfterAllAnalysed(AnalysisContext analysisContext) {
+                            // ignore
+                        }
+                    }
+            ).sheet().doRead();
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            throw new RuntimeException("Excel内容解析错误,请使用标准模板!");
+        }
+        log.info("待处理条数:{}", list.size());
 
-        String url = loginUser.getServerUrl() + "/api/ecs_oe_admin/exam/audit/redoAudit";
+        for (ExamRecordDataVO vo : list) {
+            Set<Long> examRecordDataIds = new HashSet<>();
+            examRecordDataIds.add(vo.getExamRecordDataId());
 
-        Map<String, String> headers = new HashMap<>();
-        headers.put("key", loginUser.getKey());
-        headers.put("token", loginUser.getToken());
+            String url = loginUser.getServerUrl() + "/api/ecs_oe_admin/exam/audit/redoAudit";
+            Map<String, String> headers = new HashMap<>();
+            headers.put("key", loginUser.getKey());
+            headers.put("token", loginUser.getToken());
 
-        Map<String, Object> params = new HashMap<>();
-        params.put("examRecordDataIds", examRecordDataIds);
-        params.put("illegallyTypeId", 89L);// 违纪ID,通过页面查询获取
-        params.put("disciplineDetail", "人工确认");// 选填
-        params.put("isPass", false);// 审核是否通过
-        params.put("fromMarking", true);
+            Map<String, Object> params = new HashMap<>();
+            params.put("examRecordDataIds", examRecordDataIds);
+            params.put("illegallyTypeId", 5L);// 违纪ID,通过页面查询获取
+            params.put("disciplineDetail", "视频替考");// 选填
+            params.put("isPass", false);// 审核是否通过
+            params.put("fromMarking", true);
 
-        String result = HttpHelper.post(url, headers, params);
-        log.info(result);
+            String result = HttpHelper.post(url, headers, params);
+            log.info("examRecordDataId:{} result:{}", vo.getExamRecordDataId(), result);
+        }
     }
 
 }

+ 18 - 0
src/main/java/cn/com/qmth/examcloud/tool/service/exam_record_data_audit/vo/ExamRecordDataVO.java

@@ -0,0 +1,18 @@
+package cn.com.qmth.examcloud.tool.service.exam_record_data_audit.vo;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serializable;
+
+@Setter
+@Getter
+public class ExamRecordDataVO implements Serializable {
+
+    private static final long serialVersionUID = -4647126917276922968L;
+
+    @ExcelProperty(value = "考试记录ID", index = 0)
+    private Long examRecordDataId;
+
+}