Forráskód Böngészése

新建违纪/撤销违纪修改

wangliang 2 éve
szülő
commit
d9265d3516

+ 45 - 26
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateController.java

@@ -499,7 +499,8 @@ public class TIeInvigilateController {
             @ApiJsonProperty(key = "examRecordId", type = "long", example = "1", description = "考试记录id", required = true),
             @ApiJsonProperty(key = "type", description = "违规类型", required = true),
             @ApiJsonProperty(key = "description", description = "描述", required = true),
-            @ApiJsonProperty(key = "status", type = "int", example = "1", description = "新建/撤销", required = true)
+            @ApiJsonProperty(key = "status", type = "int", example = "1", description = "新建/撤销", required = true),
+            @ApiJsonProperty(key = "breachLogId", type = "long", example = "1", description = "违纪日志id", required = true)
     }) @ApiParam(value = "考试记录信息", required = true) @RequestBody Map<String, Object> mapParameter) {
         if (Objects.isNull(mapParameter.get(SystemConstant.EXAM_RECORD_ID)) || Objects.equals(mapParameter.get(SystemConstant.EXAM_RECORD_ID), "")) {
             throw new BusinessException(ExceptionResultEnum.RECORD_ID_IS_NULL);
@@ -520,7 +521,7 @@ public class TIeInvigilateController {
             Integer status = Integer.parseInt(String.valueOf(mapParameter.get(SystemConstant.STATUS)));
             TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
             List<TEExamBreachLog> teExamBreachLogList = new ArrayList<>();
-            if (status == 0) {//新建违纪
+            if (status.intValue() == 0) {//新建违纪
                 BreachTypeEnum type = BreachTypeEnum.valueOf(String.valueOf(mapParameter.get(SystemConstant.TYPE)));
                 List<TEExamBreachLog> finalTeExamBreachLogList = teExamBreachLogList;
                 for (int i = 0; i < recordIdList.size(); i++) {
@@ -541,36 +542,53 @@ public class TIeInvigilateController {
                     teExamBreachLog.setCreateId(tbUser.getId());
                     finalTeExamBreachLogList.add(teExamBreachLog);
                     if (Objects.nonNull(ExamRecordCacheUtil.getId(l))) {
-                        Long timestamp = System.currentTimeMillis();
-                        ExamRecordCacheUtil.setBreachStatus(l, status, timestamp);
-                        tOeExamRecordService.sendExamRecordDataSaveMq(l, timestamp);
+                        Integer breachStatus = Objects.nonNull(ExamRecordCacheUtil.getBreachStatus(l)) ? ExamRecordCacheUtil.getBreachStatus(l) : 1;
+                        if (breachStatus.intValue() == 1) {
+                            Long timestamp = System.currentTimeMillis();
+                            ExamRecordCacheUtil.setBreachStatus(l, status, timestamp);
+                            tOeExamRecordService.sendExamRecordDataSaveMq(l, timestamp);
+                        }
                     } else {
-                        tOeExamRecord.setBreachStatus(status);
-                        tOeExamRecordList.add(tOeExamRecord);
+                        Integer breachStatus = Objects.nonNull(tOeExamRecord.getBreachStatus()) ? tOeExamRecord.getBreachStatus() : 1;
+                        if (breachStatus.intValue() == 1) {
+                            tOeExamRecord.setBreachStatus(status);
+                            tOeExamRecordList.add(tOeExamRecord);
+                        }
                     }
                 }
             } else {//撤销违纪
+                Long breachLogId = (Long) mapParameter.get("breachLogId");
                 BreachCancelTypeEnum type = BreachCancelTypeEnum.valueOf(String.valueOf(mapParameter.get(SystemConstant.TYPE)));
-                QueryWrapper<TEExamBreachLog> teExamBreachLogQueryWrapper = new QueryWrapper<>();
-                teExamBreachLogQueryWrapper.lambda().in(TEExamBreachLog::getExamRecordId, recordIdList)
-                        .eq(TEExamBreachLog::getStatus, 0);
-                teExamBreachLogList = teExamBreachLogService.list(teExamBreachLogQueryWrapper);
-                teExamBreachLogList.forEach(s -> {
-                    TOeExamRecord tOeExamRecord = null;
-                    s.setType(type.name());
-                    s.setDescription(description);
-                    s.setStatus(status);
-                    s.setUpdateId(tbUser.getId());
-                    if (Objects.isNull(ExamRecordCacheUtil.getId(s.getExamRecordId()))) {
-                        tOeExamRecord = tOeExamRecordService.getById(s.getExamRecordId());
-                        tOeExamRecord.setBreachStatus(status);
-                        tOeExamRecordList.add(tOeExamRecord);
-                    } else {
-                        Long timestamp = System.currentTimeMillis();
-                        ExamRecordCacheUtil.setBreachStatus(s.getExamRecordId(), status, timestamp);
-                        tOeExamRecordService.sendExamRecordDataSaveMq(s.getExamRecordId(), timestamp);
+                TEExamBreachLog teExamBreachLog = teExamBreachLogService.getById(breachLogId);
+                Optional.ofNullable(teExamBreachLog).orElseThrow(() -> new BusinessException("未找到违纪记录"));
+
+                if (Objects.nonNull(teExamBreachLog.getStatus()) && teExamBreachLog.getStatus().intValue() == 1) {
+                    throw new BusinessException("该条违纪信息已处理");
+                }
+                teExamBreachLog.setType(type.name());
+                teExamBreachLog.setDescription(description);
+                teExamBreachLog.setStatus(status);
+                teExamBreachLog.setUpdateId(tbUser.getId());
+                teExamBreachLogList.add(teExamBreachLog);
+                for (int i = 0; i < recordIdList.size(); i++) {
+                    Long l = Long.parseLong(String.valueOf(recordIdList.get(i)));
+                    QueryWrapper<TEExamBreachLog> teExamBreachLogQueryWrapper = new QueryWrapper<>();
+                    teExamBreachLogQueryWrapper.lambda().eq(TEExamBreachLog::getExamRecordId, l)
+                            .eq(TEExamBreachLog::getStatus, 0);
+                    int count = teExamBreachLogService.count(teExamBreachLogQueryWrapper);
+                    if (count == 1) {//撤销违纪都处理完了这个考生的考试记录里的违纪才算取消
+                        TOeExamRecord tOeExamRecord = null;
+                        if (Objects.isNull(ExamRecordCacheUtil.getId(teExamBreachLog.getExamRecordId()))) {
+                            tOeExamRecord = tOeExamRecordService.getById(teExamBreachLog.getExamRecordId());
+                            tOeExamRecord.setBreachStatus(status);
+                            tOeExamRecordList.add(tOeExamRecord);
+                        } else {
+                            Long timestamp = System.currentTimeMillis();
+                            ExamRecordCacheUtil.setBreachStatus(teExamBreachLog.getExamRecordId(), status, timestamp);
+                            tOeExamRecordService.sendExamRecordDataSaveMq(teExamBreachLog.getExamRecordId(), timestamp);
+                        }
                     }
-                });
+                }
             }
             if (Objects.nonNull(tOeExamRecordList) && tOeExamRecordList.size() > 0) {
                 tOeExamRecordService.saveOrUpdateBatch(tOeExamRecordList);
@@ -581,6 +599,7 @@ public class TIeInvigilateController {
                 properties.put(SystemConstant.REMARK, eb.getType());
                 properties.put(SystemConstant.EXAM_STUDENT_ID, eb.getExamStudentId());
                 properties.put(SystemConstant.EXAM_RECORD_ID, eb.getExamRecordId());
+                properties.put("objId", eb.getId());
                 ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(eb.getExamStudentId());
                 MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.STUDENT.name(), eb.getStatus() == 0 ? SystemOperationEnum.BREACH_HANDLE : SystemOperationEnum.BREACH_REVOKE, MqTagEnum.STUDENT, String.valueOf(examStudentCacheBean.getStudentId()), properties, examStudentCacheBean.getIdentity());
                 mqDtoService.assembleSendOneWayMsg(mqDto);

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

@@ -109,7 +109,7 @@
 
     <select id="findLastMsg" resultType="com.qmth.themis.business.bean.admin.WarningNotifyBean">
         SELECT
-        f.identity,
+        rpad(substring(f.identity, 1, 1), char_length(f.identity), '*') as identity,
         f.name,
         f.room_code roomCode,
         tem.*

+ 5 - 0
themis-mq/src/main/java/com/qmth/themis/mq/service/impl/MqLogicServiceImpl.java

@@ -172,6 +172,7 @@ public class MqLogicServiceImpl implements MqLogicService {
                 String info = type;
                 SystemOperationEnum systemOperationEnum = SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody()));
                 String remark = String.valueOf(mqDto.getProperties().get(SystemConstant.REMARK));
+                Long objId = null;
                 if (systemOperationEnum == SystemOperationEnum.BREACH_HANDLE || systemOperationEnum == SystemOperationEnum.BREACH_REVOKE) {
                     if (systemOperationEnum == SystemOperationEnum.BREACH_HANDLE) {
                         remark = BreachTypeEnum.valueOf(remark).getCode();
@@ -179,12 +180,16 @@ public class MqLogicServiceImpl implements MqLogicService {
                         remark = BreachCancelTypeEnum.valueOf(remark).getCode();
                     }
                     info = "【" + systemOperationEnum.getTitle() + ",原因:" + remark + "】" + type;
+                    objId = Long.parseLong(String.valueOf(mqDto.getProperties().get("objId")));
                 }
                 teExamStudentLog = new TEExamStudentLog(String.valueOf(mqDto.getBody()), info, remark,
                         Long.parseLong(String.valueOf(mqDto.getObjId())),
                         Long.parseLong(String.valueOf(mqDto.getProperties().get(SystemConstant.EXAM_STUDENT_ID))),
                         Long.parseLong(String.valueOf(mqDto.getProperties().get(SystemConstant.EXAM_RECORD_ID))),
                         systemOperationEnum.getTitle());
+                if (Objects.nonNull(objId)) {
+                    teExamStudentLog.setObjId(objId);
+                }
             } else {
                 teExamStudentLog = new TEExamStudentLog(String.valueOf(mqDto.getBody()),
                         SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(),