Browse Source

bug修复

master
luogw 7 days ago
parent
commit
8ed39adfa6
  1. 11
      src/main/java/com/project/ding/utils/DingUtil.java
  2. 26
      src/main/java/com/project/exam/domain/service/impl/AssemblePaperDomainServiceImpl.java
  3. 13
      src/main/java/com/project/exam/domain/service/impl/NotifyExamRecordDomainServiceImpl.java
  4. 2
      src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java
  5. 11
      src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java
  6. 21
      src/main/java/com/project/task/domain/service/impl/NotifyTaskDomainServiceImpl.java

11
src/main/java/com/project/ding/utils/DingUtil.java

@ -21,6 +21,8 @@ import com.project.ding.config.DingProperties;
import com.project.ding.domain.dto.DepartmentDTO;
import com.project.ding.domain.dto.DingUserDTO;
import com.project.ding.domain.dto.UserDTO;
import com.project.ding.domain.entity.UserEntity;
import com.project.ding.domain.service.UserBaseService;
import io.vavr.control.Try;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -54,6 +56,9 @@ public class DingUtil {
@Autowired
private Client dingTalkClient; // 之前创建好的新版 SDK Client
@Autowired
private UserBaseService userBaseService;
@Autowired
private DingProperties dingTalkProperties;
@ -272,6 +277,12 @@ public class DingUtil {
public void sendWorkNotice(AppealDTO appealDTO) throws DtErrorException {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
UserEntity user = userBaseService.getById(appealDTO.getUserId());
if (user == null || StrUtil.isBlank(user.getDeptIdStr()) || !user.getDeptIdStr().contains("10549213")) {
return;
}
boolean approved = appealDTO.getStatus() != null && appealDTO.getStatus() == 2;
StringBuilder markdown = new StringBuilder();
markdown.append(String.format("### 【%s】中<font color=#64BCF2>第%d题</font>的申诉结果如下:\n\n" , appealDTO.getTaskName(),appealDTO.getQuestionSort()))

26
src/main/java/com/project/exam/domain/service/impl/AssemblePaperDomainServiceImpl.java

@ -112,13 +112,15 @@ public class AssemblePaperDomainServiceImpl implements AssemblePaperDomainServic
// 获取任务配置
TaskDTO taskDTO = taskBaseService.getById(taskId).toDTO(TaskDTO::new);
// 最终选定题目
List<QuestionDTO> selectedQuestionList = new ArrayList<>();
for (int attempt = 0; attempt < 5; attempt++) {
int totalQuestionNum = taskDTO.getSingleChoiceNum() + taskDTO.getMultipleChoiceNum() + taskDTO.getTrueFalseNum();
// 权重乱序种子选取
List<TaskKnowledgePointDTO> seedKpList = selectWeightedSeedKpList(taskDTO, totalQuestionNum);
// 本张试卷已覆盖的知识点ID集合
Set<Long> coveredKpPool = new HashSet<>();
// 最终选定题目
List<QuestionDTO> selectedQuestionList = new ArrayList<>();
// 分配种子:前N3个多选(过滤单知识点簇)
List<TaskKnowledgePointDTO> mcSeeds = seedKpList.stream()
.filter(kp -> Objects.nonNull(kp.getClusterSize()) && kp.getClusterSize() > 1)
@ -143,11 +145,23 @@ public class AssemblePaperDomainServiceImpl implements AssemblePaperDomainServic
pickWithLock(tfSeeds, QuestionTypeEnum.TRUE_FALSE , selectedQuestionList, coveredKpPool);
pickMultipleQuestionsWithGreedy(mcSeeds , selectedQuestionList, coveredKpPool);
selectedQuestionList.sort(Comparator.comparing(QuestionDTO::getQuestionType));
// 校验题数
if (selectedQuestionList.size() < totalQuestionNum) {
throw new BusinessErrorException("当前题库可用题目不足,请联系管理员补货");
// 校验:如果抽齐了,直接跳出重试循环
if (selectedQuestionList.size() >= totalQuestionNum) {
break;
} else {
// 释放已占用的题目
if (!selectedQuestionList.isEmpty()) {
List<Long> ids = selectedQuestionList.stream().map(QuestionDTO::getId).toList();
questionMapper.update(null, new com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper<QuestionEntity>()
.set(QuestionEntity::getUseStatus, 0)
.in(QuestionEntity::getId, ids));
}
if (attempt == 4) throw new BusinessErrorException("当前题库可用题目不足,请联系管理员补货");
}
}
selectedQuestionList.sort(Comparator.comparing(QuestionDTO::getQuestionType));
// 注册一个回调:在当前事务 commit 成功后,再触发异步补库
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override

13
src/main/java/com/project/exam/domain/service/impl/NotifyExamRecordDomainServiceImpl.java

@ -1,10 +1,13 @@
package com.project.exam.domain.service.impl;
import cn.hutool.core.util.StrUtil;
import com.github.tingyugetc520.ali.dingtalk.api.DtService;
import com.github.tingyugetc520.ali.dingtalk.bean.message.DtCorpConversationMessage;
import com.github.tingyugetc520.ali.dingtalk.bean.message.DtCorpConversationMsgSendResult;
import com.github.tingyugetc520.ali.dingtalk.bean.message.DtMessage;
import com.project.ding.config.DingProperties;
import com.project.ding.domain.entity.UserEntity;
import com.project.ding.domain.service.UserBaseService;
import com.project.ding.utils.SecurityUtils;
import com.project.exam.domain.dto.ExamRecordDTO;
import com.project.exam.domain.service.NotifyExamRecordDomainService;
@ -24,10 +27,20 @@ public class NotifyExamRecordDomainServiceImpl implements NotifyExamRecordDomain
@Autowired
private DingProperties dingProperties;
@Autowired
private UserBaseService userBaseService;
@Override
public void notifyExamRecord(ExamRecordDTO dto) {
String userId = SecurityUtils.getUserId();
UserEntity user = userBaseService.getById(userId);
if(userId.equals("17456316000834265")){
}else if (user == null || StrUtil.isBlank(user.getDeptIdStr()) || !user.getDeptIdStr().contains("10549213")) {
return;
}
// 不阻碍正常业务
try {
String markdown = String.format("### 【%s】考试成绩已公布,请留意查收\n\n", dto.getTaskDTO().getName()) +

2
src/main/java/com/project/interaction/domain/service/impl/SaveClusterDomainServiceImpl.java

@ -130,7 +130,7 @@ public class SaveClusterDomainServiceImpl implements SaveClusterDomainService {
// 批量插入
taskKnowledgePointBaseService.saveBatch(taskKpList);
// 生成目标量
int targetNum = (int) Math.ceil(1.2 * u);
int targetNum = (int) Math.ceil(2 * u);
//题目总数
int totalNum = taskEntity.getMultipleChoiceNum() + taskEntity.getSingleChoiceNum() + taskEntity.getTrueFalseNum();
//题目占比系数

11
src/main/java/com/project/question/domain/service/impl/QuestionInventoryDomainServiceImpl.java

@ -74,7 +74,7 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
int w = cluster.getClusterSize();
// 簇水位线: 1.0 * U * W
int clusterWatermark = (int) Math.ceil(watermark * w * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name()));
// 簇目标线: 1.2 * U * W
// 簇目标线: 2 * U * W
int clusterTargetLine = (int) Math.ceil(targetLine * w * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name()));
checkClusterProduce(cluster.getId(), clusterWatermark, clusterTargetLine);
@ -121,8 +121,9 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
Map<String, Double> questionTypeMap = questionTypeProportion(task);
int targetLine = getTargetLine(task);
int clusterWatermark = targetLine * cluster.getClusterSize();
int targetNum = (int) Math.ceil(clusterWatermark * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name()));
// 簇目标线: 2 * U * W
int w = cluster.getClusterSize();
int targetNum = (int) Math.ceil(targetLine * w * questionTypeMap.get(QuestionTypeEnum.MULTIPLE_CHOICE.name()));
total = total + targetNum;
if (!checkClusterInventory(cluster.getId(), targetNum)) {
flage = true;
@ -194,10 +195,10 @@ public class QuestionInventoryDomainServiceImpl implements QuestionInventoryDoma
}
/**
* 计算目标线 (targetLine = ceil(1.2 * u))
* 计算目标线 (targetLine = ceil(2 * u))
*/
private int getTargetLine(TaskEntity task) {
return (int) Math.ceil(1.2 * getUnpassedCount(task));
return (int) Math.ceil(2 * getUnpassedCount(task));
}
/**

21
src/main/java/com/project/task/domain/service/impl/NotifyTaskDomainServiceImpl.java

@ -10,6 +10,8 @@ import com.github.tingyugetc520.ali.dingtalk.bean.message.DtCorpConversationMsgS
import com.github.tingyugetc520.ali.dingtalk.bean.message.DtMessage;
import com.github.tingyugetc520.ali.dingtalk.error.DtErrorException;
import com.project.ding.config.DingProperties;
import com.project.ding.domain.entity.UserEntity;
import com.project.ding.mapper.UserMapper;
import com.project.information.application.ProductLineApplicationService;
import com.project.task.domain.dto.TaskDTO;
import com.project.task.domain.entity.TaskEntity;
@ -19,6 +21,7 @@ import com.project.task.domain.service.NotifyTaskDomainService;
import com.project.task.mapper.TaskMapper;
import com.project.task.mapper.TaskUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -26,6 +29,7 @@ import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Slf4j
@ -43,6 +47,9 @@ public class NotifyTaskDomainServiceImpl implements NotifyTaskDomainService {
@Autowired
private DingProperties dingTalkProperties;
@Autowired
private UserMapper userMapper;
private final SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
@ -63,7 +70,12 @@ public class NotifyTaskDomainServiceImpl implements NotifyTaskDomainService {
.eq(TaskUserEntity::getTaskId, task.getId()))
.stream().map(TaskUserEntity::getUserId).toList();
sendBatchNewTasks(userIds , task);
List<String> userIdFilter = userMapper.selectBatchIds(userIds).stream()
.filter(user -> ObjectUtils.isNotEmpty(user.getDeptIdStr()))
.filter(user -> user.getDeptIdStr().contains("10549213") || user.getId().equals("17456316000834265"))
.map(UserEntity::getId)
.toList();
sendBatchNewTasks(userIdFilter , task);
}
}
@Override
@ -81,7 +93,12 @@ public class NotifyTaskDomainServiceImpl implements NotifyTaskDomainService {
.eq(TaskUserEntity::getTaskId, task.getId()))
.stream().map(TaskUserEntity::getUserId).toList();
sendBatchDeadlineTasks(userIds , task);
List<String> userIdFilter = userMapper.selectBatchIds(userIds).stream()
.filter(user -> ObjectUtils.isNotEmpty(user.getDeptIdStr()))
.filter(user -> user.getDeptIdStr().contains("10549213") || user.getId().equals("17456316000834265"))
.map(UserEntity::getId)
.toList();
sendBatchDeadlineTasks(userIdFilter , task);
}
}
private void sendBatchNewTasks(List<String> userIds , TaskDTO taskDTO) {

Loading…
Cancel
Save