wangliang 2 lat temu
rodzic
commit
f7b35796a5

+ 21 - 24
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateWarnInfoController.java

@@ -2,11 +2,10 @@ package com.qmth.themis.admin.api;
 
 
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.themis.business.annotation.ApiJsonObject;
-import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.bean.admin.InvigilateListWarningBean;
 import com.qmth.themis.business.bean.admin.InvigilateListWarningBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.AuthDto;
+import com.qmth.themis.business.dto.params.WarnInfoParams;
 import com.qmth.themis.business.dto.response.TIeWarningNotifyDto;
 import com.qmth.themis.business.dto.response.TIeWarningNotifyDto;
 import com.qmth.themis.business.entity.TBUser;
 import com.qmth.themis.business.entity.TBUser;
 import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
 import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
@@ -14,20 +13,24 @@ import com.qmth.themis.business.enums.RoleEnum;
 import com.qmth.themis.business.service.CacheService;
 import com.qmth.themis.business.service.CacheService;
 import com.qmth.themis.business.service.TIeInvigilateWarnInfoService;
 import com.qmth.themis.business.service.TIeInvigilateWarnInfoService;
 import com.qmth.themis.business.service.TOeExamRecordService;
 import com.qmth.themis.business.service.TOeExamRecordService;
-import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
 import com.qmth.themis.common.util.ResultUtil;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
+import org.apache.commons.collections.CollectionUtils;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.validation.BindingResult;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import javax.validation.constraints.Min;
-import java.util.*;
+import java.util.Collections;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * @Description: 监考预警信息 前端控制器
  * @Description: 监考预警信息 前端控制器
@@ -113,32 +116,26 @@ public class TIeInvigilateWarnInfoController {
     @RequestMapping(value = "/save/status", method = RequestMethod.POST)
     @RequestMapping(value = "/save/status", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
     @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
     @Transactional
     @Transactional
-    public Result saveWarnStatus(@ApiJsonObject(name = "saveWarnStatus", value = {
-            @ApiJsonProperty(key = "warningIds", description = "预警id数组", required = true),
-            @ApiJsonProperty(key = "approveStatus", type = "long", example = "1", description = "审阅状态,0:未阅,1:已阅", required = true)
-    }) @ApiParam(value = "监考员信息", required = true) @RequestBody Map<String, Object> mapParameter) {
-        if (Objects.isNull(mapParameter.get("warningIds")) || Objects.equals(mapParameter.get("warningIds"), "")) {
-            throw new BusinessException("预警id不能为空");
+    public Result saveWarnStatus(@Validated @RequestBody WarnInfoParams warnInfoParams, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
         }
         //2020/11/24新增管理员不清除预警状态
         //2020/11/24新增管理员不清除预警状态
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         AuthDto authDto = cacheService.addAccountAuthCache(tbUser.getId());
         AuthDto authDto = cacheService.addAccountAuthCache(tbUser.getId());
         if (!authDto.getRoleCodes().toString().contains(RoleEnum.ADMIN.name())) {
         if (!authDto.getRoleCodes().toString().contains(RoleEnum.ADMIN.name())) {
-            List<String> warningIds = (List<String>) mapParameter.get("warningIds");
-            if (warningIds.size() > 0) {
-                if (Objects.isNull(mapParameter.get("approveStatus")) || Objects.equals(mapParameter.get("approveStatus"), "")) {
-                    throw new BusinessException("审阅状态不能为空");
-                }
-                List<Long> warningTranIds = new ArrayList<>();
-                warningIds.forEach(s -> {
-                    warningTranIds.add(Long.parseLong(s));
-                });
-                Integer approveStatus = Integer.parseInt(String.valueOf(mapParameter.get("approveStatus")));
-                UpdateWrapper<TIeInvigilateWarnInfo> tIeInvigilateWarnInfoUpdateWrapper = new UpdateWrapper<>();
-                tIeInvigilateWarnInfoUpdateWrapper.lambda().set(TIeInvigilateWarnInfo::getApproveStatus, approveStatus)
-                        .in(TIeInvigilateWarnInfo::getId, warningTranIds);
-                tIeInvigilateWarnInfoService.update(tIeInvigilateWarnInfoUpdateWrapper);
+            if (CollectionUtils.isEmpty(warnInfoParams.getWarningIds()) && Objects.isNull(warnInfoParams.getExamRecordId())) {
+                throw new BusinessException("预警id数组或考试记录id不能同时为空");
             }
             }
+            UpdateWrapper<TIeInvigilateWarnInfo> tIeInvigilateWarnInfoUpdateWrapper = new UpdateWrapper<>();
+            tIeInvigilateWarnInfoUpdateWrapper.lambda().set(TIeInvigilateWarnInfo::getApproveStatus, warnInfoParams.getApproveStatus());
+            if (!CollectionUtils.isEmpty(warnInfoParams.getWarningIds())) {
+                List<Long> warningTranIds = warnInfoParams.getWarningIds().stream().map(x -> Long.parseLong(x)).collect(Collectors.toList());
+                tIeInvigilateWarnInfoUpdateWrapper.lambda().in(TIeInvigilateWarnInfo::getId, warningTranIds);
+            } else if (Objects.nonNull(warnInfoParams.getExamRecordId())) {
+                tIeInvigilateWarnInfoUpdateWrapper.lambda().eq(TIeInvigilateWarnInfo::getExamRecordId, warnInfoParams.getExamRecordId());
+            }
+            tIeInvigilateWarnInfoService.update(tIeInvigilateWarnInfoUpdateWrapper);
         }
         }
         return ResultUtil.ok(true);
         return ResultUtil.ok(true);
     }
     }

+ 54 - 0
themis-business/src/main/java/com/qmth/themis/business/dto/params/WarnInfoParams.java

@@ -0,0 +1,54 @@
+package com.qmth.themis.business.dto.params;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @Description: 预警消息
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/9/3
+ */
+public class WarnInfoParams implements Serializable {
+
+    @ApiModelProperty(value = "预警id数组")
+    List<String> warningIds;
+
+    @ApiModelProperty(value = "审阅状态,0:未阅,1:已阅")
+    @NotNull(message = "审阅状态不能为空")
+    Integer approveStatus;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "考试记录id")
+    Long examRecordId;
+
+    public Long getExamRecordId() {
+        return examRecordId;
+    }
+
+    public void setExamRecordId(Long examRecordId) {
+        this.examRecordId = examRecordId;
+    }
+
+    public List<String> getWarningIds() {
+        return warningIds;
+    }
+
+    public void setWarningIds(List<String> warningIds) {
+        this.warningIds = warningIds;
+    }
+
+    public Integer getApproveStatus() {
+        return approveStatus;
+    }
+
+    public void setApproveStatus(Integer approveStatus) {
+        this.approveStatus = approveStatus;
+    }
+}

+ 17 - 1
themis-business/src/main/resources/mapper/TIeInvigilateWarnInfoMapper.xml

@@ -8,6 +8,7 @@
         left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
         left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
         left join t_e_exam tee on tee.id = tees.exam_id
         left join t_e_exam tee on tee.id = tees.exam_id
         <where> 1 = 1
         <where> 1 = 1
+            and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
             <if test="examId != null and examId != ''">
             <if test="examId != null and examId != ''">
                 and tiiwi.exam_id = #{examId}
                 and tiiwi.exam_id = #{examId}
             </if>
             </if>
@@ -42,12 +43,27 @@
         tiiwi.exam_record_id as examRecordId
         tiiwi.exam_record_id as examRecordId
         from
         from
         t_ie_invigilate_warn_info tiiwi
         t_ie_invigilate_warn_info tiiwi
+        <!--2022/09/03新增 start
+        join
+        (
+        select
+        distinct tiiwi.exam_record_id as examRecordId,
+        max(tiiwi.create_time) as createTime,
+        max(tiiwi.id) as warningId
+        from
+        t_ie_invigilate_warn_info tiiwi
+        group by
+        tiiwi.exam_record_id) temp on
+        temp.warningId = tiiwi.id
+        2022/09/03新增 end-->
         left join t_e_exam_student tees on
         left join t_e_exam_student tees on
         tees.id = tiiwi.exam_student_id
         tees.id = tiiwi.exam_student_id
         left join t_b_exam_invigilate_user tbeiu on
         left join t_b_exam_invigilate_user tbeiu on
         tbeiu.exam_id = tiiwi.exam_id
         tbeiu.exam_id = tiiwi.exam_id
         and tbeiu.room_code = tees.room_code
         and tbeiu.room_code = tees.room_code
-        <where>
+        join t_e_exam tee on tee.id = tiiwi.exam_id
+        <where> 1 = 1
+            and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
             <if test="examId != null and examId != ''">
             <if test="examId != null and examId != ''">
                 and tiiwi.exam_id = #{examId}
                 and tiiwi.exam_id = #{examId}
             </if>
             </if>

+ 2 - 1
themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml

@@ -449,7 +449,8 @@
         left join t_e_exam_activity teea on teea.id = tiiwi.exam_activity_id
         left join t_e_exam_activity teea on teea.id = tiiwi.exam_activity_id
         left join t_oe_exam_record toer on toer.id = tiiwi.exam_record_id
         left join t_oe_exam_record toer on toer.id = tiiwi.exam_record_id
         left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
         left join t_e_exam_student tees on tees.id = tiiwi.exam_student_id
-        <where>1 = 1
+        <where> 1 = 1
+            and tee.monitor_status <![CDATA[ <> ]]> 'FINISHED'
             <if test="examId != null and examId != ''">
             <if test="examId != null and examId != ''">
                 and tiiwi.exam_id = #{examId}
                 and tiiwi.exam_id = #{examId}
             </if>
             </if>