|
@@ -7,6 +7,7 @@ import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -25,7 +26,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
import cn.com.qmth.examcloud.api.commons.security.bean.User;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
import cn.com.qmth.examcloud.core.basic.api.UserCloudService;
|
|
import cn.com.qmth.examcloud.core.basic.api.UserCloudService;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.bean.UserBean;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.request.GetUserListByIdsReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetUserReq;
|
|
import cn.com.qmth.examcloud.core.basic.api.request.GetUserReq;
|
|
|
|
+import cn.com.qmth.examcloud.core.basic.api.response.GetUserListByIdsResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetUserResp;
|
|
import cn.com.qmth.examcloud.core.basic.api.response.GetUserResp;
|
|
import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
|
|
import cn.com.qmth.examcloud.core.questions.base.CommonUtils;
|
|
import cn.com.qmth.examcloud.core.questions.base.Model;
|
|
import cn.com.qmth.examcloud.core.questions.base.Model;
|
|
@@ -59,6 +63,7 @@ import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.StructQuest
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.StructQuestionCountInfo;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.StructQuestionCountInfo;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.StructQuestionInfo;
|
|
import cn.com.qmth.examcloud.core.questions.service.bean.randompaper.StructQuestionInfo;
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.RandomPaperCache;
|
|
import cn.com.qmth.examcloud.core.questions.service.cache.RandomPaperCache;
|
|
|
|
+import cn.com.qmth.examcloud.core.questions.service.util.BatchGetDataUtil;
|
|
import cn.com.qmth.examcloud.core.questions.service.util.PaperUtil;
|
|
import cn.com.qmth.examcloud.core.questions.service.util.PaperUtil;
|
|
import cn.com.qmth.examcloud.question.commons.core.paper.DefaultPaper;
|
|
import cn.com.qmth.examcloud.question.commons.core.paper.DefaultPaper;
|
|
import cn.com.qmth.examcloud.question.commons.core.paper.DefaultQuestionGroup;
|
|
import cn.com.qmth.examcloud.question.commons.core.paper.DefaultQuestionGroup;
|
|
@@ -147,14 +152,36 @@ public class RandomPaperServiceImpl implements RandomPaperService {
|
|
PaperStruct paperStruct = Model.of(paperStructRepo.findById(vo.getPaperStructId()));
|
|
PaperStruct paperStruct = Model.of(paperStructRepo.findById(vo.getPaperStructId()));
|
|
vo.setPaperStructName(paperStruct.getName());
|
|
vo.setPaperStructName(paperStruct.getName());
|
|
vo.setEnableStr(vo.getEnable() ? "启用" : "禁用");
|
|
vo.setEnableStr(vo.getEnable() ? "启用" : "禁用");
|
|
- GetUserReq ureq = new GetUserReq();
|
|
|
|
- ureq.setUserId(vo.getUpdateBy());
|
|
|
|
- GetUserResp ures = userCloudService.getUser(ureq);
|
|
|
|
- vo.setUpdateByName(ures.getUserBean().getDisplayName());
|
|
|
|
}
|
|
}
|
|
|
|
+ fillUserName(paperList, req.getRootOrgId());
|
|
|
|
+
|
|
|
|
|
|
return new PageImpl<>(paperList, pageable, total);
|
|
return new PageImpl<>(paperList, pageable, total);
|
|
}
|
|
}
|
|
|
|
+ private void fillUserName(List<RandomPaperListVo> dtos, Long rootOrgId) {
|
|
|
|
+ if (dtos != null && dtos.size() > 0) {
|
|
|
|
+ List<Long> ids = dtos.stream().map(dto -> dto.getUpdateBy()).distinct().collect(Collectors.toList());
|
|
|
|
+ List<UserBean> userList = new ArrayList<UserBean>();
|
|
|
|
+ GetUserListByIdsReq req = new GetUserListByIdsReq();
|
|
|
|
+ BatchGetDataUtil<UserBean, Long> tool = new BatchGetDataUtil<UserBean, Long>() {
|
|
|
|
+ @Override
|
|
|
|
+ public List<UserBean> getData(List<Long> paramList) {
|
|
|
|
+ req.setRootOrgId(rootOrgId);
|
|
|
|
+ req.setUserIdList(paramList);
|
|
|
|
+ GetUserListByIdsResp resp = userCloudService.getUserListByIds(req);
|
|
|
|
+ return resp.getUserBeanList();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+ tool.getDataForBatch(userList, ids, 100);
|
|
|
|
+ Map<Long, UserBean> map = userList.stream()
|
|
|
|
+ .collect(Collectors.toMap(UserBean::getUserId, account -> account, (key1, key2) -> key2));
|
|
|
|
+ for (RandomPaperListVo markerBean : dtos) {
|
|
|
|
+ UserBean userBean = map.get(markerBean.getUpdateBy());
|
|
|
|
+ markerBean.setUpdateByName(userBean.getDisplayName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|