Selaa lähdekoodia

成绩查询同步接口

wangliang 3 vuotta sitten
vanhempi
commit
539eacee3b

+ 35 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/result/TSyncExamStudentScoreResult.java

@@ -29,6 +29,17 @@ public class TSyncExamStudentScoreResult implements Serializable {
     @ApiModelProperty(value = "学期")
     String semesterName;
 
+    @ApiModelProperty(value = "云阅卷考试id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long examId;
+
+    @ApiModelProperty(value = "云阅卷考试编码")
+    String examCode;
+
+    @ApiModelProperty(value = "考生id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    Long examStudentId;
+
     @ExcelProperty(name = "姓名", width = 30, index = 2)
     @ApiModelProperty(value = "考生姓名")
     String examStudentName;
@@ -99,6 +110,30 @@ public class TSyncExamStudentScoreResult implements Serializable {
     @ApiModelProperty(value = "轨迹图是否生成,1:已生成,0:未生成")
     private Boolean trajectory;
 
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public String getExamCode() {
+        return examCode;
+    }
+
+    public void setExamCode(String examCode) {
+        this.examCode = examCode;
+    }
+
+    public Long getExamStudentId() {
+        return examStudentId;
+    }
+
+    public void setExamStudentId(Long examStudentId) {
+        this.examStudentId = examStudentId;
+    }
+
     public String getSemesterName() {
         return semesterName;
     }

+ 64 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/execute/AsyncScorePushService.java

@@ -0,0 +1,64 @@
+package com.qmth.distributed.print.business.templete.execute;
+
+import cn.hutool.core.date.DateUtil;
+import com.qmth.boot.api.exception.ApiException;
+import com.qmth.distributed.print.business.entity.TBSyncTask;
+import com.qmth.distributed.print.business.service.TBSyncTaskService;
+import com.qmth.distributed.print.business.templete.push.AsyncPushTaskTemplate;
+import com.qmth.distributed.print.business.templete.service.PushLogicService;
+import com.qmth.teachcloud.common.contant.SpringContextHolder;
+import com.qmth.teachcloud.common.contant.SystemConstant;
+import com.qmth.teachcloud.common.enums.TaskResultEnum;
+import com.qmth.teachcloud.common.enums.TaskStatusEnum;
+import com.qmth.teachcloud.common.util.Result;
+import com.qmth.teachcloud.common.util.ResultUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import java.text.MessageFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.StringJoiner;
+
+/**
+ * @Description: 成绩查询推送模板(异步任务)
+ * @Author: CaoZixuan
+ * @Date: 2021-10-31
+ */
+@Service
+public class AsyncScorePushService extends AsyncPushTaskTemplate {
+
+    private final static Logger log = LoggerFactory.getLogger(AsyncSysUserDataImportService.class);
+
+    public static final String OBJ_TITLE = "成绩信息";
+
+    @Override
+    public Result pushTask(Map<String, Object> map) {
+        TBSyncTask tbSyncTask = (TBSyncTask) map.get(SystemConstant.TB_SYNC_TASK);
+        StringJoiner stringJoinerSummary = new StringJoiner("\n")
+                .add(MessageFormat.format("{0}{1}{2}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), BEGIN_TITLE, OBJ_TITLE));
+        tbSyncTask.setStatus(TaskStatusEnum.RUNNING);
+        TBSyncTaskService tbSyncTaskService = SpringContextHolder.getBean(TBSyncTaskService.class);
+        tbSyncTaskService.updateById(tbSyncTask);
+        try {
+            PushLogicService pushLogicService = SpringContextHolder.getBean(PushLogicService.class);
+            Map<String, Object> result = pushLogicService.executeScorePushLogic(map);
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}{4}{5}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), FINISH_TITLE, Integer.parseInt(String.valueOf(result.get("count"))), SUCCESS_TITLE, Integer.parseInt(String.valueOf(result.get("correct"))), FINISH_SIZE));
+            tbSyncTask.setResult(TaskResultEnum.SUCCESS);
+        } catch (Exception e) {
+            log.error("请求出错", e);
+            stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_TITLE, EXCEPTION_DATA, e.getMessage()));
+            tbSyncTask.setResult(TaskResultEnum.ERROR);
+            if (e instanceof ApiException) {
+                ResultUtil.error((ApiException) e, e.getMessage());
+            } else {
+                ResultUtil.error(e.getMessage());
+            }
+        } finally {//生成txt文件
+            tbSyncTask.setSummary(stringJoinerSummary.toString());
+            super.createTxt(tbSyncTask);
+        }
+        return ResultUtil.ok(map);
+    }
+}

+ 0 - 4
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/push/AsyncPushTaskTemplate.java

@@ -116,10 +116,6 @@ public abstract class AsyncPushTaskTemplate {
             stringJoinerSummary.add(MessageFormat.format("{0}{1}{2}{3}", DateUtil.format(new Date(), SystemConstant.DEFAULT_DATE_PATTERN), EXCEPTION_CREATE_TXT_TITLE, EXCEPTION_DATA, e.getMessage()));
             tbSyncTask.setSummary(stringJoinerSummary.toString());
             tbSyncTask.setResult(TaskResultEnum.ERROR);
-//            TBTask dbTask = tbTaskService.getById(tbTask.getId());
-//            if (tbTask.getVersion() == dbTask.getVersion()) {
-//                tbTask.setResetCount(new AtomicInteger(tbTask.getResetCount()).incrementAndGet());
-//            }
             if (e instanceof ApiException) {
                 ResultUtil.error((ApiException) e, e.getMessage());
             } else {

+ 10 - 1
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/PushLogicService.java

@@ -11,8 +11,17 @@ public interface PushLogicService {
 
     /**
      * 用户推送异步任务处理方法
+     *
      * @param map 任务源
      * @return 结果
      */
-    Map<String,Object> executeUserPushLogic(Map<String, Object> map) throws IllegalAccessException;
+    Map<String, Object> executeUserPushLogic(Map<String, Object> map) throws IllegalAccessException;
+
+    /**
+     * 成绩查询推送异步任务处理方法
+     *
+     * @param map 任务源
+     * @return 结果
+     */
+    Map<String, Object> executeScorePushLogic(Map<String, Object> map) throws Exception;
 }

+ 62 - 8
distributed-print-business/src/main/java/com/qmth/distributed/print/business/templete/service/impl/PushLogicServiceImpl.java

@@ -2,6 +2,8 @@ package com.qmth.distributed.print.business.templete.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.qmth.distributed.print.business.service.DataSyncService;
+import com.qmth.distributed.print.business.service.impl.DataSyncServiceImpl;
 import com.qmth.distributed.print.business.templete.service.PushLogicService;
 import com.qmth.teachcloud.common.base.BaseEntity;
 import com.qmth.teachcloud.common.bean.params.PushBeforeRoleParam;
@@ -12,11 +14,15 @@ import com.qmth.teachcloud.common.enums.userPush.BeforeJudgeEnum;
 import com.qmth.teachcloud.common.enums.userPush.SyncStatusEnum;
 import com.qmth.teachcloud.common.service.SysUserRoleService;
 import com.qmth.teachcloud.common.service.SysUserService;
+import com.qmth.teachcloud.common.sync.StmmsUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -27,11 +33,17 @@ import java.util.stream.Collectors;
  */
 @Service
 public class PushLogicServiceImpl implements PushLogicService {
+    private final static Logger log = LoggerFactory.getLogger(PushLogicServiceImpl.class);
+
     @Resource
     private SysUserService sysUserService;
+
     @Resource
     private SysUserRoleService sysUserRoleService;
 
+    @Resource
+    StmmsUtils stmmsUtils;
+
     @Override
     public Map<String, Object> executeUserPushLogic(Map<String, Object> map) throws IllegalAccessException {
         int correct = 0;
@@ -40,23 +52,65 @@ public class PushLogicServiceImpl implements PushLogicService {
         Long schoolId = sysUser.getSchoolId();
         // 需要同步的用户
         List<SysUser> sysUserList = sysUserService.list(new QueryWrapper<SysUser>().lambda()
-                .eq(SysUser::getSchoolId,schoolId)
+                .eq(SysUser::getSchoolId, schoolId)
                 .eq(SysUser::getSyncStatus, SyncStatusEnum.NEED_PUSH_AGAIN));
         count = sysUserList.size();
         for (SysUser user : sysUserList) {
             Set<Long> roleIdSet = sysUserRoleService.listRoleByUserId(user.getId()).stream().map(BaseEntity::getId).collect(Collectors.toSet());
             PushBeforeRoleParam pushBeforeRoleParam = new PushBeforeRoleParam(null, BeforeJudgeEnum.FORBIDDEN_NECESSARY);
-            List<UserPushParam> userPushParamList = sysUserService.analyzeUserPushSpecialPrivilege(user.getId(),user.getSchoolId(),user.getCode(), user.getRealName(),user.getPassword(),roleIdSet,pushBeforeRoleParam,user.getEnable());
-            boolean syncResult = sysUserService.userPushService(userPushParamList,sysUser);
-            if (syncResult){
-                correct ++;
+            List<UserPushParam> userPushParamList = sysUserService.analyzeUserPushSpecialPrivilege(user.getId(), user.getSchoolId(), user.getCode(), user.getRealName(), user.getPassword(), roleIdSet, pushBeforeRoleParam, user.getEnable());
+            boolean syncResult = sysUserService.userPushService(userPushParamList, sysUser);
+            if (syncResult) {
+                correct++;
             }
             UpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<>();
-            updateWrapper.lambda().set(SysUser::getSyncStatus,null).eq(SysUser::getId,user.getId());
+            updateWrapper.lambda().set(SysUser::getSyncStatus, null).eq(SysUser::getId, user.getId());
             sysUserService.update(updateWrapper);
         }
-        map.put("correct",correct);
-        map.put("count",count);
+        map.put("correct", correct);
+        map.put("count", count);
+        return map;
+    }
+
+    /**
+     * 成绩查询推送异步任务处理方法
+     *
+     * @param map 任务源
+     * @return
+     * @throws IllegalAccessException
+     */
+    @Override
+    public Map<String, Object> executeScorePushLogic(Map<String, Object> map) throws Exception {
+        Integer examId = (Integer) map.get("examId");
+        String examCode = (String) map.get("examCode");
+        try {
+            int totalCount = stmmsUtils.getStudentCount(examId, examCode, null, null, null, null, null, null);
+            log.info("云阅卷:考试成绩考生数量查询接口调用,返回数量:{}", totalCount);
+//            List<Map> paramList = new ArrayList<>();
+            if (totalCount > 0) {
+                int pageSize = stmmsUtils.getDefaultPageSize();
+                int mod = totalCount % pageSize;
+                int pageNos = mod == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
+                for (int i = 1; i <= pageNos; i++) {
+                    List<Map> students = stmmsUtils.getStudentScore(examId, examCode, null, null, null, null, null, null, i, pageSize);
+                    for (Map student : students) {
+                        String jxbId = String.valueOf(student.get("className"));
+                        String xhId = String.valueOf(student.get("studentCode"));
+                        String xmcj = String.valueOf(student.get("totalScore"));
+//                        Map<String, String> stringMap = new HashMap<>();
+//                        stringMap.put("jxb_id", jxbId);
+//                        stringMap.put("xh_id", xhId);
+//                        stringMap.put("xmcj", xmcj);
+//                        paramList.add(stringMap);
+                    }
+                }
+            }
+            map.computeIfAbsent("count", v -> totalCount);
+            map.computeIfAbsent("correct", v -> 0);
+        } catch (Exception e) {
+            log.info("云阅卷:接口调用失败:{}", e.getMessage());
+            throw new RuntimeException("云阅卷:接口调用失败:" + e.getMessage());
+        }
         return map;
     }
 }

+ 3 - 0
distributed-print-business/src/main/resources/mapper/TSyncExamStudentScoreMapper.xml

@@ -7,6 +7,9 @@
             tsess.id,
             bs.id as semesterId,
             bs.name as semesterName,
+            tsess.exam_id as examId,
+            tsess.exam_code as examCode,
+            tsess.exam_student_id as examStudentId,
             tsess.name as examStudentName,
             tsess.student_code as studentCode,
             so.id as orgId,

+ 22 - 3
distributed-print/src/main/java/com/qmth/distributed/print/api/TSyncExamStudentScoreController.java

@@ -5,13 +5,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.annotation.BOOL;
 import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.distributed.print.business.entity.TFFlow;
+import com.qmth.distributed.print.business.bean.result.TSyncExamStudentScoreResult;
+import com.qmth.distributed.print.business.entity.TBSyncTask;
 import com.qmth.distributed.print.business.service.PrintCommonService;
 import com.qmth.distributed.print.business.service.TSyncExamStudentScoreService;
 import com.qmth.distributed.print.business.templete.execute.AsyncScoreExportService;
+import com.qmth.distributed.print.business.templete.execute.AsyncScorePushService;
 import com.qmth.teachcloud.common.config.DictionaryConfig;
 import com.qmth.teachcloud.common.contant.SystemConstant;
 import com.qmth.teachcloud.common.entity.TBTask;
+import com.qmth.teachcloud.common.enums.PushTypeEnum;
 import com.qmth.teachcloud.common.enums.TaskTypeEnum;
 import com.qmth.teachcloud.common.util.Result;
 import com.qmth.teachcloud.common.util.ResultUtil;
@@ -55,8 +58,11 @@ public class TSyncExamStudentScoreController {
     @Resource
     DictionaryConfig dictionaryConfig;
 
+    @Resource
+    AsyncScorePushService asyncScorePushService;
+
     @ApiOperation(value = "成绩归档查询列表")
-    @ApiResponses({@ApiResponse(code = 200, message = "流程信息", response = TFFlow.class)})
+    @ApiResponses({@ApiResponse(code = 200, message = "成绩查询信息", response = TSyncExamStudentScoreResult.class)})
     @RequestMapping(value = "/score/list", method = RequestMethod.POST)
     public Result list(@ApiParam(value = "学期id", required = true) @RequestParam String semesterId,
                        @ApiParam(value = "学院id", required = true) @RequestParam String orgId,
@@ -74,7 +80,7 @@ public class TSyncExamStudentScoreController {
     }
 
     @ApiOperation(value = "成绩导出")
-    @ApiResponses({@ApiResponse(code = 200, message = "流程信息", response = TFFlow.class)})
+    @ApiResponses({@ApiResponse(code = 200, message = "成绩查询信息", response = TSyncExamStudentScoreResult.class)})
     @RequestMapping(value = "/score/export", method = RequestMethod.POST)
     public Result export(@ApiParam(value = "学期id", required = true) @RequestParam String semesterId,
                          @ApiParam(value = "学院id", required = true) @RequestParam String orgId,
@@ -92,4 +98,17 @@ public class TSyncExamStudentScoreController {
         TBTask tbTask = Objects.nonNull(map.get(SystemConstant.TASK)) ? (TBTask) map.get(SystemConstant.TASK) : null;
         return Objects.nonNull(tbTask) ? ResultUtil.ok(tbTask.getId()) : ResultUtil.error("创建任务失败");
     }
+
+    @ApiOperation(value = "成绩查询同步")
+    @ApiResponses({@ApiResponse(code = 200, message = "同步异步任务信息", response = TBSyncTask.class)})
+    @RequestMapping(value = "/score/sync", method = RequestMethod.POST)
+    public Result sync(@ApiParam(value = "考试id", required = true) @RequestParam String examId,
+                       @ApiParam(value = "考试编码", required = false) @RequestParam(required = false) String examCode)  {
+        Map<String, Object> map = printCommonService.savePush(PushTypeEnum.USER_PUSH);
+        map.computeIfAbsent("examId", v -> SystemConstant.convertIdToInteger(examId));
+        map.computeIfAbsent("examCode", v -> examCode);
+        asyncScorePushService.pushTask(map);
+        TBSyncTask tbSyncTask = Objects.nonNull(map.get(SystemConstant.TB_SYNC_TASK)) ? (TBSyncTask) map.get(SystemConstant.TB_SYNC_TASK) : null;
+        return Objects.nonNull(tbSyncTask) ? ResultUtil.ok(tbSyncTask.getId()) : ResultUtil.error("创建同步推送任务失败");
+    }
 }

+ 9 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/contant/SystemConstant.java

@@ -246,6 +246,15 @@ public class SystemConstant {
         return Objects.nonNull(id) && id.length() > 0 ? Long.parseLong(id) : null;
     }
 
+    /**
+     * id转换为Integer
+     *
+     * @return
+     */
+    public static Integer convertIdToInteger(String id) {
+        return Objects.nonNull(id) && id.length() > 0 ? Integer.parseInt(id) : null;
+    }
+
     /**
      * 获取全局uuid
      *

+ 103 - 1
teachcloud-common/src/main/java/com/qmth/teachcloud/common/sync/StmmsUtils.java

@@ -15,6 +15,8 @@ import com.qmth.teachcloud.common.util.HttpKit;
 import com.qmth.teachcloud.common.util.ServletUtil;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
@@ -23,6 +25,7 @@ import java.io.FileInputStream;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * 同步云阅卷接口工具类
@@ -31,12 +34,15 @@ import java.util.Map;
  */
 @Component
 public class StmmsUtils {
+    private final static Logger log = LoggerFactory.getLogger(StmmsUtils.class);
 
     // 考试类型(逸教云默认是纸笔"SCAN_IMAGE")
     private static final String SAVE_EXAM_TYPE = "SCAN_IMAGE";
     // 所有请求方法默认为"POST"
     private static final String POST_METHOD = "POST";
 
+    private final int defaultPageSize = 100;
+
     @Autowired
     private CommonCacheService commonCacheService;
 
@@ -206,7 +212,7 @@ public class StmmsUtils {
 
             String jsonData = JSONObject.toJSONString(map);
 
-            String result = HttpKit.sendPost(postUrl, jsonData, getHeaders(postUrl));
+            String result = HttpKit.sendPost(postUrl, jsonData, getHeaders(structureUrl));
             JSONObject jsonObject = JSONObject.parseObject(result);
             if (jsonObject.containsKey("updateTime")) {
                 return true;
@@ -361,4 +367,100 @@ public class StmmsUtils {
             throw ExceptionResultEnum.ERROR.exception("云阅卷同步接口未正确配置");
         }
     }
+
+    /**
+     * 考试成绩考生数量查询接口
+     *
+     * @param examId
+     * @param examCode
+     * @param examNumber
+     * @param studentCode
+     * @param subjectCode
+     * @param college
+     * @param className
+     * @param teacher
+     * @return
+     */
+    public int getStudentCount(Integer examId, String examCode, String examNumber, String studentCode, String subjectCode, String college, String className, String teacher) {
+        Map<String, String> map = new HashMap<>();
+        map.put("examId", validParam(String.valueOf(examId), null, true, "考试ID"));
+        map.put("examCode", validParam(examCode, null, false, "考试编码"));
+        map.put("examNumber", validParam(examNumber, null, false, "准考证号"));
+        map.put("studentCode", validParam(studentCode, null, false, "学号"));
+        map.put("subjectCode", validParam(subjectCode, null, false, "课程编码"));
+        map.put("college", validParam(college, null, false, "学院"));
+        map.put("className", validParam(className, null, false, "班级"));
+        map.put("teacher", validParam(teacher, null, false, "教师"));
+
+        String hostUrl = dictionaryConfig.syncDataDomain().getHostUrl();
+        String studentCountUrl = dictionaryConfig.syncDataDomain().getStudentCountUrl();
+        validUrl(hostUrl, studentCountUrl);
+        String postUrl = hostUrl.concat(studentCountUrl);
+
+        //请求
+        String res;
+        try {
+            res = HttpKit.sendPost(postUrl, getHeaders(studentCountUrl), map, null, null, null);
+        } catch (Exception e) {
+            log.info("云阅卷:调用考试成绩考生数量查询接口请求异常,{}", e.getMessage());
+            throw new RuntimeException("云阅卷:调用考试成绩考生数量查询接口请求异常," + e.getMessage());
+        }
+        if (Objects.isNull(res)) {
+            log.info("云阅卷:调用考试成绩考生数量查询接口返回值为null");
+            throw new RuntimeException("云阅卷:调用考试成绩考生数量查询接口返回值为null");
+        }
+        JSONObject object = JSONObject.parseObject(res);
+        return Integer.parseInt(object.get("totalCount").toString());
+    }
+
+    /**
+     * 考试成绩考生查询接口
+     *
+     * @param examId
+     * @param examCode
+     * @param examNumber
+     * @param studentCode
+     * @param subjectCode
+     * @param college
+     * @param className
+     * @param teacher
+     * @param pageNo
+     * @param pageSize
+     * @return
+     */
+    public List<Map> getStudentScore(Integer examId, String examCode, String examNumber, String studentCode, String subjectCode, String college, String className, String teacher, int pageNo, int pageSize) {
+        Map<String, String> map = new HashMap<>();
+        map.put("examId", validParam(String.valueOf(examId), null, true, "考试ID"));
+        map.put("examCode", validParam(examCode, null, false, "考试编码"));
+        map.put("examNumber", validParam(examNumber, null, false, "准考证号"));
+        map.put("studentCode", validParam(studentCode, null, false, "学号"));
+        map.put("subjectCode", validParam(subjectCode, null, false, "课程编码"));
+        map.put("college", validParam(college, null, false, "学院"));
+        map.put("className", validParam(className, null, false, "班级"));
+        map.put("teacher", validParam(teacher, null, false, "教师"));
+        map.put("pageNumber", validParam(teacher, null, true, "页码"));
+        map.put("pageSize", validParam(teacher, null, true, "数量"));
+
+        String hostUrl = dictionaryConfig.syncDataDomain().getHostUrl();
+        String studentScoreUrl = dictionaryConfig.syncDataDomain().getStudentScoreUrl();
+        validUrl(hostUrl, studentScoreUrl);
+        String postUrl = hostUrl.concat(studentScoreUrl);
+        //请求
+        String res;
+        try {
+            res = HttpKit.sendPost(postUrl, getHeaders(studentScoreUrl), map, null, null, null);
+        } catch (Exception e) {
+            log.info("云阅卷:调用考试成绩考生查询接口请求异常,{}", e.getMessage());
+            throw new RuntimeException("云阅卷:调用考试成绩考生查询接口请求异常," + e.getMessage());
+        }
+        if (Objects.isNull(res)) {
+            log.info("云阅卷:调用考试成绩考生查询接口返回值为null");
+            throw new RuntimeException("云阅卷:调用考试成绩考生查询接口返回值为null");
+        }
+        return JSONObject.parseArray(JSONObject.toJSON(res).toString(), Map.class);
+    }
+
+    public int getDefaultPageSize() {
+        return defaultPageSize;
+    }
 }

+ 31 - 0
teachcloud-common/src/main/java/com/qmth/teachcloud/common/util/HttpUtil.java

@@ -6,8 +6,11 @@ import org.apache.http.HttpResponse;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.client.methods.HttpUriRequest;
+import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.HttpClients;
+import org.apache.http.message.BasicHeader;
 import org.apache.http.message.BasicNameValuePair;
+import org.apache.http.protocol.HTTP;
 import org.apache.tomcat.util.http.fileupload.IOUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -16,6 +19,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
@@ -32,6 +36,33 @@ import java.util.Objects;
 public class HttpUtil {
     private final static Logger log = LoggerFactory.getLogger(HttpUtil.class);
 
+    /**
+     * post json
+     *
+     * @param url
+     * @param json
+     * @param secret
+     * @param timestamp
+     * @return
+     * @throws IOException
+     */
+    public static String postJson(String url, String json, String secret, Long timestamp) throws IOException {
+        // 构建post请求
+        HttpPost post = new HttpPost(url);
+        post.setHeader("authorization-token", secret);
+        post.setHeader(SystemConstant.HEADER_TIME, String.valueOf(timestamp));
+        post.setHeader(HTTP.CONTENT_TYPE, "application/json; charset=utf-8");
+        post.setHeader("Accept", "application/json");
+
+        String encoderJson = URLEncoder.encode(json, SystemConstant.CHARSET_NAME);
+        StringEntity se = new StringEntity(encoderJson);
+        se.setContentType("text/json");
+        se.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json"));
+        post.setEntity(se);
+        // 执行请求,获取响应
+        return getRespString(post);
+    }
+
     /**
      * post 请求
      *