|
|
@ -8,8 +8,10 @@ import cn.hutool.core.util.StrUtil; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.project.base.domain.exception.BusinessErrorException; |
|
|
import com.project.base.domain.exception.BusinessErrorException; |
|
|
import com.project.base.domain.result.Result; |
|
|
import com.project.base.domain.result.Result; |
|
|
|
|
|
import com.project.ding.domain.dto.UserDTO; |
|
|
import com.project.ding.domain.entity.UserEntity; |
|
|
import com.project.ding.domain.entity.UserEntity; |
|
|
import com.project.ding.domain.service.UserBaseService; |
|
|
import com.project.ding.domain.service.UserBaseService; |
|
|
|
|
|
import com.project.ding.utils.DingUtil; |
|
|
import com.project.information.domain.dto.KnowledgePointStatisticsDTO; |
|
|
import com.project.information.domain.dto.KnowledgePointStatisticsDTO; |
|
|
import com.project.information.domain.entity.ProductLineEntity; |
|
|
import com.project.information.domain.entity.ProductLineEntity; |
|
|
import com.project.information.domain.service.GetStatisticsKnowledgePointDomainService; |
|
|
import com.project.information.domain.service.GetStatisticsKnowledgePointDomainService; |
|
|
@ -47,6 +49,9 @@ public class SaveOrUpdateTaskDomainServiceImpl implements SaveOrUpdateTaskDomain |
|
|
@Autowired |
|
|
@Autowired |
|
|
private TaskBaseService taskBaseService; |
|
|
private TaskBaseService taskBaseService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private DingUtil dingUtil; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private UserBaseService userBaseService; |
|
|
private UserBaseService userBaseService; |
|
|
|
|
|
|
|
|
@ -114,7 +119,16 @@ public class SaveOrUpdateTaskDomainServiceImpl implements SaveOrUpdateTaskDomain |
|
|
.stream() |
|
|
.stream() |
|
|
.collect(Collectors.toMap(UserEntity::getId, UserEntity::getName)); |
|
|
.collect(Collectors.toMap(UserEntity::getId, UserEntity::getName)); |
|
|
|
|
|
|
|
|
for (String userId : dto.getParticipantUserIdList()) { |
|
|
// 处理用户ID在系统中不存在的情况
|
|
|
|
|
|
List<String> nonExistentUserIds = participantUserIdList.stream() |
|
|
|
|
|
.filter(userId -> !userMap.containsKey(userId)) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
if (!nonExistentUserIds.isEmpty()) { |
|
|
|
|
|
//查询钉钉用户信息
|
|
|
|
|
|
dingGetUserInfo(nonExistentUserIds,userMap); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (String userId : participantUserIdList) { |
|
|
TaskUserEntity taskUserEntity = new TaskUserEntity(); |
|
|
TaskUserEntity taskUserEntity = new TaskUserEntity(); |
|
|
taskUserEntity.setTaskId(saveEntity.getId()); |
|
|
taskUserEntity.setTaskId(saveEntity.getId()); |
|
|
taskUserEntity.setUserId(userId); |
|
|
taskUserEntity.setUserId(userId); |
|
|
@ -125,6 +139,20 @@ public class SaveOrUpdateTaskDomainServiceImpl implements SaveOrUpdateTaskDomain |
|
|
return Result.success(saveEntity.toDTO(TaskDTO::new)); |
|
|
return Result.success(saveEntity.toDTO(TaskDTO::new)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void dingGetUserInfo(List<String> nonExistentUserIds, Map<String, String> userMap) { |
|
|
|
|
|
for (String nonExistentUserId : nonExistentUserIds) { |
|
|
|
|
|
UserDTO user = dingUtil.getUserById(nonExistentUserId); |
|
|
|
|
|
if (Objects.nonNull(user)) { |
|
|
|
|
|
userMap.put(user.getId(), user.getName()); |
|
|
|
|
|
// 同步到本地数据库
|
|
|
|
|
|
UserEntity userEntity = user.toEntity(UserEntity::new); |
|
|
|
|
|
userBaseService.saveOrUpdate(userEntity); |
|
|
|
|
|
} else { |
|
|
|
|
|
throw new BusinessErrorException("用户ID " + nonExistentUserId + " 在系统中不存在,且无法从钉钉获取到用户信息,请核实后重试"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private void checkDTO(TaskDTO dto) throws Exception { |
|
|
private void checkDTO(TaskDTO dto) throws Exception { |
|
|
if (StrUtil.isBlank(dto.getName())) { |
|
|
if (StrUtil.isBlank(dto.getName())) { |
|
|
throw new BusinessErrorException("考试任务名称不能为空"); |
|
|
throw new BusinessErrorException("考试任务名称不能为空"); |
|
|
|