Browse Source

sup 同步考试结果

he2802 3 years ago
parent
commit
0bc2a5b3c0

+ 9 - 2
zhongzheng-admin/src/main/java/com/zhongzheng/controller/schedule/ScheduleController.java

@@ -296,8 +296,15 @@ public class ScheduleController extends BaseController {
 
     @ApiOperation("批量同步考试计划用户")
     @GetMapping("/syncApplyUserInfo")
-    public AjaxResult syncApplyUserInfo(UserQueryBo bo){
-        iScheduleService.syncApplyUserInfo(bo);
+    public AjaxResult wisdomSyncApplyUserInfo(UserQueryBo bo){
+        iScheduleService.wisdomSyncApplyUserInfo(bo);
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("同步考生考试状态信息")
+    @GetMapping("/wisdomSyncExamStatus")
+    public AjaxResult wisdomSyncExamStatus(UserQueryBo bo){
+        iScheduleService.wisdomSyncExamStatus(bo);
         return AjaxResult.success();
     }
 }

+ 13 - 0
zhongzheng-common/src/main/java/com/zhongzheng/common/utils/DateUtils.java

@@ -96,6 +96,19 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
         }
     }
 
+    public static final Long dateTimeSec(final String format, final String ts)
+    {
+        try
+        {
+            return (new SimpleDateFormat(format).parse(ts)).getTime()/1000;
+        }
+        catch (ParseException e)
+        {
+
+            throw new RuntimeException(e);
+        }
+    }
+
     public static String timestampToDateFormat(Long times){
         if(Validator.isEmpty(times)){
             return "";

+ 3 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/IScheduleService.java

@@ -73,5 +73,7 @@ public interface IScheduleService extends IService<PolyvVideo> {
 
     void wisdomExamSite(UserQueryBo bo);
 
-    void syncApplyUserInfo(UserQueryBo bo);
+    void wisdomSyncApplyUserInfo(UserQueryBo bo);
+
+    void wisdomSyncExamStatus(UserQueryBo bo);
 }

+ 6 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/schedule/service/impl/ScheduleServiceImpl.java

@@ -2113,10 +2113,15 @@ public class ScheduleServiceImpl extends ServiceImpl<PolyvVideoMapper, PolyvVide
     }
 
     @Override
-    public void syncApplyUserInfo(UserQueryBo bo) {
+    public void wisdomSyncApplyUserInfo(UserQueryBo bo) {
         iWisdomService.syncApplyUserInfo(192L);
     }
 
+    @Override
+    public void wisdomSyncExamStatus(UserQueryBo bo) {
+        iWisdomService.syncExamStatus(192L,1);
+    }
+
     private Long formatTime(Long startTime, String addTime) throws ParseException{
         Long times = startTime*1000;//时间戳
         SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");

+ 12 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserSubscribeAddBo.java

@@ -134,4 +134,16 @@ public class UserSubscribeAddBo {
     /** 考室编号 */
     @ApiModelProperty("考室编号")
     private String roomCode;
+    /** 智慧考场考试状态 未报到;已报到;缺考;替考;考试中;
+     未交卷;已交卷;作弊;正常 */
+    @ApiModelProperty("智慧考场考试状态 未报到;已报到;缺考;替考;考试中;未交卷;已交卷;作弊;正常")
+    private String wisdomExamStatus;
+
+    /** 智慧考场报到时间 */
+    @ApiModelProperty("智慧考场报到时间")
+    private Long wisdomReportTime;
+
+    /** 智慧考场体温 */
+    @ApiModelProperty("智慧考场体温")
+    private String wisdomTemperature;
 }

+ 15 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/bo/UserSubscribeEditBo.java

@@ -157,4 +157,19 @@ public class UserSubscribeEditBo {
     /** 考室编号 */
     @ApiModelProperty("考室编号")
     private String roomCode;
+    /** 智慧考场考试状态 未报到;已报到;缺考;替考;考试中;
+     未交卷;已交卷;作弊;正常 */
+    @ApiModelProperty("智慧考场考试状态 未报到;已报到;缺考;替考;考试中;未交卷;已交卷;作弊;正常")
+    private String wisdomExamStatus;
+
+    /** 智慧考场报到时间 */
+    @ApiModelProperty("智慧考场报到时间")
+    private Long wisdomReportTime;
+
+    /** 智慧考场体温 */
+    @ApiModelProperty("智慧考场体温")
+    private String wisdomTemperature;
+    /** 智慧考场同步考试结果信息 */
+    @ApiModelProperty("智慧考场同步考试结果信息")
+    private String syncExamResult;
 }

+ 9 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/domain/UserSubscribe.java

@@ -102,4 +102,13 @@ private static final long serialVersionUID=1L;
     private Long roomId;
     /** 考室编号 */
     private String roomCode;
+    /** 智慧考场考试状态 未报到;已报到;缺考;替考;考试中;
+     未交卷;已交卷;作弊;正常 */
+    private String wisdomExamStatus;
+    /** 智慧考场报到时间 */
+    private Long wisdomReportTime;
+    /** 智慧考场体温 */
+    private String wisdomTemperature;
+    /** 智慧考场同步考试结果信息 */
+    private String syncExamResult;
 }

+ 16 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/user/vo/UserSubscribeVo.java

@@ -267,4 +267,20 @@ public class UserSubscribeVo {
 	@Excel(name = "考室编号")
 	@ApiModelProperty("考室编号")
 	private String roomCode;
+	/** 智慧考场考试状态 未报到;已报到;缺考;替考;考试中;
+	 未交卷;已交卷;作弊;正常 */
+	@Excel(name = "智慧考场考试状态 未报到;已报到;缺考;替考;考试中;未交卷;已交卷;作弊;正常")
+	@ApiModelProperty("智慧考场考试状态 未报到;已报到;缺考;替考;考试中;未交卷;已交卷;作弊;正常")
+	private String wisdomExamStatus;
+	/** 智慧考场报到时间 */
+	@Excel(name = "智慧考场报到时间")
+	@ApiModelProperty("智慧考场报到时间")
+	private Long wisdomReportTime;
+	/** 智慧考场体温 */
+	@Excel(name = "智慧考场体温")
+	@ApiModelProperty("智慧考场体温")
+	private String wisdomTemperature;
+	/** 智慧考场同步考试结果信息 */
+	@ApiModelProperty("智慧考场同步考试结果信息")
+	private String syncExamResult;
 }

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/wisdom/service/IWisdomService.java

@@ -14,4 +14,6 @@ public interface IWisdomService {
     void SiteList(Integer pageNo);
 
     Map<String,Object> syncApplyUserInfo(Long applyId);
+
+    void syncExamStatus(Long applyId,Integer pageNo);
 }

+ 61 - 1
zhongzheng-system/src/main/java/com/zhongzheng/modules/wisdom/service/impl/WisdomServiceImpl.java

@@ -43,6 +43,7 @@ import com.zhongzheng.modules.exam.domain.ExamNumber;
 import com.zhongzheng.modules.exam.mapper.ExamApplyMapper;
 import com.zhongzheng.modules.exam.mapper.ExamBeforeMapper;
 import com.zhongzheng.modules.exam.mapper.ExamNumberMapper;
+import com.zhongzheng.modules.exam.service.IExamApplyService;
 import com.zhongzheng.modules.exam.service.IExamSiteService;
 import com.zhongzheng.modules.exam.vo.ExamApplyVo;
 import com.zhongzheng.modules.exam.vo.ExamBeforeVo;
@@ -103,6 +104,7 @@ import com.zhongzheng.modules.user.vo.*;
 import com.zhongzheng.modules.wisdom.service.IWisdomService;
 import com.zhongzheng.modules.wisdom.vo.CenterVo;
 import com.zhongzheng.modules.wisdom.vo.ExamineesVo;
+import com.zhongzheng.modules.wisdom.vo.WisdomResultVo;
 import com.zhongzheng.modules.wisdom.vo.WisdomRoomVo;
 import com.zhongzheng.modules.wx.service.IWxLoginService;
 import net.polyv.live.v1.entity.channel.playback.LiveChannelVideoListResponse;
@@ -143,6 +145,8 @@ public class WisdomServiceImpl  implements IWisdomService {
 
     private String batchUserUrl = "/exam/api/center-examinees";
 
+    private String examStatusUrl = "/exam/api/status";
+
     @Autowired
     private RedisCache redisCache;
 
@@ -152,6 +156,9 @@ public class WisdomServiceImpl  implements IWisdomService {
     @Autowired
     private IUserSubscribeService iUserSubscribeService;
 
+    @Autowired
+    private IExamApplyService iExamApplyService;
+
     @Autowired
     private OssService ossService;
 
@@ -345,8 +352,9 @@ public class WisdomServiceImpl  implements IWisdomService {
                         objectLambdaUpdateWrapper.set(UserSubscribe::getRoomId, vo.getRoomId());
                         success++;
                     }else{
+                        String reason = Validator.isNotEmpty(vo.getFailureReason())?vo.getFailureReason():"";
                         objectLambdaUpdateWrapper.set(UserSubscribe::getSyncStatus, 2);
-                        objectLambdaUpdateWrapper.set(UserSubscribe::getSyncResult, "同步失败:"+vo.getFailureReason()+DateUtils.getTime());
+                        objectLambdaUpdateWrapper.set(UserSubscribe::getSyncResult, "同步失败:"+reason+DateUtils.getTime());
                         fail++;
                     }
                     objectLambdaUpdateWrapper.set(UserSubscribe::getUpdateTime,DateUtils.getNowTime());
@@ -361,4 +369,56 @@ public class WisdomServiceImpl  implements IWisdomService {
         }
         return mapResult;
     }
+
+    @Override
+    public void syncExamStatus(Long applyId,Integer pageNo) {
+        ExamApplyVo applyVo = iExamApplyService.queryById(applyId);
+        String auth_code = authorization();
+        Map<String, Object> paramMap = new HashMap<>();
+        paramMap.put("examCode",applyVo.getCode());
+        paramMap.put("pageNo",pageNo);
+        paramMap.put("pageSize",20);
+        try{
+            String url = host + examStatusUrl;
+            String signature = SignatureUtil.createSignature(paramMap, appid);
+            JSONObject obj = new JSONObject();
+            obj.put("examCode",applyVo.getCode());
+            obj.put("pageNo",pageNo);
+            obj.put("pageSize",20);
+            Map<String, String> hearders = new HashMap<>();
+            hearders.put("auth_code", auth_code);
+            hearders.put("appid", appid);
+            hearders.put("sign", signature);
+            String result = HttpUtils.sendPostHeader(url,obj,hearders);
+            System.out.println(result);
+            JSONObject userInfoJSON = null;
+            userInfoJSON = JSON.parseObject(result);
+            if (userInfoJSON.containsKey("code")&&"200".equals(String.valueOf(userInfoJSON.get("code")))) {
+                Integer page = Integer.valueOf(userInfoJSON.getJSONObject("result").get("pages").toString());
+                JSONArray jsonArray = userInfoJSON.getJSONObject("result").getJSONArray("records");
+                List<WisdomResultVo> list=jsonArray.toJavaList(WisdomResultVo.class);
+                for (WisdomResultVo vo : list){
+                    LambdaUpdateWrapper<UserSubscribe> objectLambdaUpdateWrapper = Wrappers.lambdaUpdate();
+                    objectLambdaUpdateWrapper.eq(UserSubscribe::getExamineeCode, vo.getExamineeCode());
+                    if(vo.getDistributionStatus()==0){
+                        objectLambdaUpdateWrapper.set(UserSubscribe::getWisdomTemperature,vo.getTemperature());
+                        objectLambdaUpdateWrapper.set(UserSubscribe::getWisdomExamStatus,vo.getExamStatus());
+                        objectLambdaUpdateWrapper.set(UserSubscribe::getWisdomReportTime,DateUtils.dateTimeSec(DateUtils.YYYY_MM_DD_HH_MM_SS,vo.getReportTime()));
+                        objectLambdaUpdateWrapper.set(UserSubscribe::getSyncExamResult, "同步结果成功"+DateUtils.getTime());
+                    }
+                    if(vo.getDistributionStatus()==1){
+                        String reason = Validator.isNotEmpty(vo.getFailureReason())?vo.getFailureReason():"";
+                        objectLambdaUpdateWrapper.set(UserSubscribe::getSyncExamResult, "同步结果失败"+reason+DateUtils.getTime());
+                    }
+                    objectLambdaUpdateWrapper.set(UserSubscribe::getUpdateTime,DateUtils.getNowTime());
+                    iUserSubscribeService.update(null, objectLambdaUpdateWrapper);
+                }
+                if(page>pageNo){
+                    syncExamStatus(applyId,pageNo++);
+                }
+            }
+        }catch (Exception e){
+            throw new CustomException("获取考生考试状态信息失败");
+        }
+    }
 }

+ 40 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/wisdom/vo/WisdomResultVo.java

@@ -0,0 +1,40 @@
+package com.zhongzheng.modules.wisdom.vo;
+
+import lombok.Data;
+
+@Data
+public class WisdomResultVo {
+    private static final long serialVersionUID = 1L;
+
+    private Long Id;
+
+    private String centerName;
+
+    private String examCenterAddress;
+
+    private String roomId;
+
+    private String roomCode;
+
+    private String roomName;
+
+    private String roomAddress;
+
+    private Long seatNum;
+
+    private Integer useSeatNumber;
+
+    private Integer freeSeatNumber;
+
+    private String reportTime;
+
+    private String examStatus;
+
+    private String temperature;
+
+    private String examineeCode;
+
+    private Integer distributionStatus;
+
+    private String failureReason;
+}

+ 8 - 0
zhongzheng-system/src/main/resources/mapper/modules/user/UserSubscribeMapper.xml

@@ -33,6 +33,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="roomName" column="room_name"/>
         <result property="roomId" column="room_id"/>
         <result property="roomCode" column="room_code"/>
+        <result property="wisdomExamStatus" column="wisdom_exam_status"/>
+        <result property="wisdomReportTime" column="wisdom_report_time"/>
+        <result property="wisdomTemperature" column="wisdom_temperature"/>
+        <result property="syncExamResult" column="sync_exam_result"/>
     </resultMap>
 
     <resultMap type="com.zhongzheng.modules.user.vo.UserSubscribeVo" id="UserSubscribeVo">
@@ -91,6 +95,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="applyCode" column="apply_code"/>
         <result property="roomId" column="room_id"/>
         <result property="roomCode" column="room_code"/>
+        <result property="wisdomExamStatus" column="wisdom_exam_status"/>
+        <result property="wisdomReportTime" column="wisdom_report_time"/>
+        <result property="wisdomTemperature" column="wisdom_temperature"/>
+        <result property="syncExamResult" column="sync_exam_result"/>
     </resultMap>
 
     <select id="listSubscribe" parameterType="com.zhongzheng.modules.user.bo.UserSubscribeQueryBo" resultMap="UserSubscribeVo">