|
@@ -0,0 +1,482 @@
|
|
|
|
+package com.diagbot.facade;
|
|
|
|
+
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
+import com.diagbot.client.UserServiceClient;
|
|
|
|
+import com.diagbot.dto.QuestionDTO;
|
|
|
|
+import com.diagbot.dto.QuestionPageDTO;
|
|
|
|
+import com.diagbot.dto.RespDTO;
|
|
|
|
+import com.diagbot.entity.CommonParam;
|
|
|
|
+import com.diagbot.entity.QuestionDetail;
|
|
|
|
+import com.diagbot.entity.QuestionInfo;
|
|
|
|
+import com.diagbot.entity.QuestionMapping;
|
|
|
|
+import com.diagbot.entity.wrapper.QuestionInfoWrapper;
|
|
|
|
+import com.diagbot.entity.wrapper.QuestionMappingWrapper;
|
|
|
|
+import com.diagbot.entity.wrapper.QuestionWrapper;
|
|
|
|
+import com.diagbot.enums.InsertOrUpdateEnum;
|
|
|
|
+import com.diagbot.enums.IsDeleteEnum;
|
|
|
|
+import com.diagbot.enums.TagTypeEnum;
|
|
|
|
+import com.diagbot.exception.CommonErrorCode;
|
|
|
|
+import com.diagbot.exception.CommonException;
|
|
|
|
+import com.diagbot.service.QuestionDetailService;
|
|
|
|
+import com.diagbot.service.QuestionInfoService;
|
|
|
|
+import com.diagbot.service.QuestionMappingService;
|
|
|
|
+import com.diagbot.service.impl.QuestionInfoServiceImpl;
|
|
|
|
+import com.diagbot.util.BeanUtil;
|
|
|
|
+import com.diagbot.util.DateUtil;
|
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
|
+import com.diagbot.util.ListUtil;
|
|
|
|
+import com.diagbot.util.StringUtil;
|
|
|
|
+import com.diagbot.util.UserUtils;
|
|
|
|
+import com.diagbot.vo.DeleteQuestionVO;
|
|
|
|
+import com.diagbot.vo.QuestionIdsVO;
|
|
|
|
+import com.diagbot.vo.QuestionIndexSubVO;
|
|
|
|
+import com.diagbot.vo.QuestionIndexVO;
|
|
|
|
+import com.diagbot.vo.QuestionPageVO;
|
|
|
|
+import com.diagbot.vo.QuestionSaveVO;
|
|
|
|
+import com.diagbot.vo.QuestionVO;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
+
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @Description:
|
|
|
|
+ * @Author:zhoutg
|
|
|
|
+ * @time: 2018/11/23 11:37
|
|
|
|
+ */
|
|
|
|
+@Component
|
|
|
|
+public class QuestionFacade extends QuestionInfoServiceImpl {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ QuestionDetailFacade questionDetailFacade;
|
|
|
|
+ @Autowired
|
|
|
|
+ @Qualifier("questionInfoServiceImpl")
|
|
|
|
+ QuestionInfoService questionInfoService;
|
|
|
|
+ @Autowired
|
|
|
|
+ @Qualifier("questionDetailServiceImpl")
|
|
|
|
+ QuestionDetailService questionDetailService;
|
|
|
|
+ @Autowired
|
|
|
|
+ @Qualifier("questionMappingServiceImpl")
|
|
|
|
+ QuestionMappingService questionMappingService;
|
|
|
|
+ @Autowired
|
|
|
|
+ QuestionMappingFacade questionMappingFacade;
|
|
|
|
+ @Autowired
|
|
|
|
+ UserServiceClient userServiceClient;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 标签保存
|
|
|
|
+ *
|
|
|
|
+ * @param questionSaveVO
|
|
|
|
+ */
|
|
|
|
+ public void saveOrUpdate(QuestionSaveVO questionSaveVO) {
|
|
|
|
+ QuestionWrapper questionWrapper = questionSaveVO.getQuestionWrapper();
|
|
|
|
+ CommonParam param = initCommonParam();
|
|
|
|
+ saveQuestionInfo(questionWrapper, param); //保存|修改主表信息
|
|
|
|
+ switch (TagTypeEnum.getEnum(questionWrapper.getTagType())) {
|
|
|
|
+ case T1: //单项,例如:程度、体温
|
|
|
|
+ saveQuestionDetail(questionWrapper, param);
|
|
|
|
+ break;
|
|
|
|
+ case T4: //组合项,例如:咳嗽
|
|
|
|
+ case T6: // 组合项,例如:既往史
|
|
|
|
+ saveQuestionMapping(questionWrapper, param);
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请选择标签显示类型");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 初始化参数
|
|
|
|
+ *
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public CommonParam initCommonParam() {
|
|
|
|
+ CommonParam param = new CommonParam();
|
|
|
|
+ String person = UserUtils.getCurrentPrincipleID();
|
|
|
|
+ param.setNow(DateUtil.now());
|
|
|
|
+ param.setPerson(person);
|
|
|
|
+ param.setInsertOrUpdate(InsertOrUpdateEnum.Insert.getKey());
|
|
|
|
+ return param;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存映射关系
|
|
|
|
+ *
|
|
|
|
+ * @param questionWrapper
|
|
|
|
+ * @param param
|
|
|
|
+ */
|
|
|
|
+ public void saveQuestionMapping(QuestionWrapper questionWrapper, CommonParam param) {
|
|
|
|
+ QuestionInfo questionInfo = param.getQuestionInfo();
|
|
|
|
+ Date now = param.getNow();
|
|
|
|
+ String person = param.getPerson();
|
|
|
|
+ //先删除原明细,再插入新明细
|
|
|
|
+ deleteMapping(questionInfo.getId(), param);//删除原映射关系
|
|
|
|
+ List<QuestionMappingWrapper> questionMappings = questionWrapper.getQuestionMappings();
|
|
|
|
+ if (ListUtil.isNotEmpty(questionMappings)) {
|
|
|
|
+ saveMapping(questionMappings, person, now, questionInfo.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除映射关系
|
|
|
|
+ *
|
|
|
|
+ * @param questionId
|
|
|
|
+ * @param param
|
|
|
|
+ */
|
|
|
|
+ public void deleteMapping(Long questionId, CommonParam param) {
|
|
|
|
+ questionMappingFacade.update(new QuestionMapping(),
|
|
|
|
+ new UpdateWrapper<QuestionMapping>()
|
|
|
|
+ .eq("parent_question", questionId)
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .set("gmt_modified", param.getNow())
|
|
|
|
+ .set("modifier", param.getPerson())
|
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存映射关系
|
|
|
|
+ *
|
|
|
|
+ * @param questionMappings
|
|
|
|
+ * @param person
|
|
|
|
+ * @param now
|
|
|
|
+ * @param id
|
|
|
|
+ */
|
|
|
|
+ public void saveMapping(List<QuestionMappingWrapper> questionMappings, String person, Date now, Long id) {
|
|
|
|
+ List<QuestionMapping> saveMapping = new ArrayList<>();
|
|
|
|
+ for (QuestionMappingWrapper mapping : questionMappings) {
|
|
|
|
+ QuestionMapping bean = new QuestionMapping();
|
|
|
|
+ BeanUtil.copyProperties(mapping, bean);
|
|
|
|
+ bean.setId(null); //防止前端传参,将前端的id置空自动插入
|
|
|
|
+ bean.setCreator(person);
|
|
|
|
+ bean.setGmtCreate(now);
|
|
|
|
+ bean.setModifier(person);
|
|
|
|
+ bean.setGmtModified(now);
|
|
|
|
+ bean.setParentQuestion(id);
|
|
|
|
+ saveMapping.add(bean);
|
|
|
|
+ }
|
|
|
|
+ questionMappingService.saveBatch(saveMapping);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存明细
|
|
|
|
+ *
|
|
|
|
+ * @param questionWrapper
|
|
|
|
+ * @param param
|
|
|
|
+ */
|
|
|
|
+ public void saveQuestionDetail(QuestionWrapper questionWrapper, CommonParam param) {
|
|
|
|
+ QuestionInfo questionInfo = param.getQuestionInfo();
|
|
|
|
+ Date now = param.getNow();
|
|
|
|
+ String person = param.getPerson();
|
|
|
|
+ //先删除原明细,再插入新明细
|
|
|
|
+ questionDetailFacade.update(new QuestionDetail(), //删除原明细
|
|
|
|
+ new UpdateWrapper<QuestionDetail>()
|
|
|
|
+ .eq("question_id", questionInfo.getId())
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .set("gmt_modified", now)
|
|
|
|
+ .set("modifier", person)
|
|
|
|
+ .set("is_deleted", IsDeleteEnum.Y.getKey()));
|
|
|
|
+ List<QuestionDetail> questionDetails = questionWrapper.getQuestionDetails();
|
|
|
|
+ if (ListUtil.isNotEmpty(questionDetails)) {
|
|
|
|
+ List<QuestionDetail> saveDetail = new ArrayList<>();
|
|
|
|
+ int i = 1;
|
|
|
|
+ for (QuestionDetail detail : questionDetails) {
|
|
|
|
+ QuestionDetail bean = new QuestionDetail();
|
|
|
|
+ BeanUtil.copyProperties(detail, bean);
|
|
|
|
+ bean.setId(null); //防止前端传参,将前端的id置空自动插入
|
|
|
|
+ bean.setCreator(person);
|
|
|
|
+ bean.setGmtCreate(now);
|
|
|
|
+ bean.setModifier(person);
|
|
|
|
+ bean.setGmtModified(now);
|
|
|
|
+ bean.setQuestionId(questionInfo.getId());
|
|
|
|
+ bean.setOrderNo(i++);
|
|
|
|
+ saveDetail.add(bean);
|
|
|
|
+ }
|
|
|
|
+ questionDetailService.saveBatch(saveDetail);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存主表
|
|
|
|
+ *
|
|
|
|
+ * @param questionWrapper
|
|
|
|
+ * @param param
|
|
|
|
+ */
|
|
|
|
+ public void saveQuestionInfo(QuestionWrapper questionWrapper, CommonParam param) {
|
|
|
|
+ QuestionInfo questionInfo = new QuestionInfo();
|
|
|
|
+ if (questionWrapper.getId() != null) {
|
|
|
|
+ questionInfo = this.getOne(new QueryWrapper<QuestionInfo>()
|
|
|
|
+ .eq("id", questionWrapper.getId())
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey()));
|
|
|
|
+ if (questionInfo == null) { //校验
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "标签不存在");
|
|
|
|
+ }
|
|
|
|
+ param.setInsertOrUpdate(InsertOrUpdateEnum.Update.getKey());
|
|
|
|
+ }
|
|
|
|
+ BeanUtil.copyProperties(questionWrapper, questionInfo);
|
|
|
|
+ List<QuestionInfo> questionInfoList = this.list(new QueryWrapper<QuestionInfo>()
|
|
|
|
+ .eq("tag_name", questionInfo.getTagName())
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("type", questionInfo.getType())
|
|
|
|
+ .ne("id", questionInfo.getId() == null ? -1 : questionInfo.getId()));
|
|
|
|
+ if (ListUtil.isNotEmpty(questionInfoList)) { //标签type、tagName唯一
|
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "标签系统名称已重复,无法建立");
|
|
|
|
+ }
|
|
|
|
+ if (InsertOrUpdateEnum.Insert.getKey() == param.getInsertOrUpdate()) {
|
|
|
|
+ questionInfo.setCreator(param.getPerson()); //创建人
|
|
|
|
+ questionInfo.setGmtCreate(param.getNow());//创建时间
|
|
|
|
+ }
|
|
|
|
+ questionInfo.setGmtModified(param.getNow());//修改时间
|
|
|
|
+ questionInfo.setModifier(param.getPerson());//修改人
|
|
|
|
+ param.setQuestionInfo(questionInfo);
|
|
|
|
+ this.saveOrUpdate(questionInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 标签列表
|
|
|
|
+ *
|
|
|
|
+ * @param questionPageVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public IPage<QuestionPageDTO> getListFac(QuestionPageVO questionPageVO) {
|
|
|
|
+ IPage<QuestionPageDTO> res = this.getList(questionPageVO);
|
|
|
|
+ if (res.getTotal() <= 0) {
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+ List<String> personIds = res.getRecords().stream().map(row -> row.getModifier()).collect(Collectors.toList());
|
|
|
|
+ RespDTO<Map<String, String>> mapRespDTO = userServiceClient.getUserInfoByIds(personIds);
|
|
|
|
+ if (mapRespDTO == null || !CommonErrorCode.OK.getCode().equals(mapRespDTO.code)) {
|
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR, "获取操作人失败");
|
|
|
|
+ }
|
|
|
|
+ for (QuestionPageDTO bean : res.getRecords()) {
|
|
|
|
+ bean.setModifier(mapRespDTO.data.get(bean.getModifier()));
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据id删除标签
|
|
|
|
+ *
|
|
|
|
+ * @param deleteQuestionVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public Boolean deleteByIdsFac(DeleteQuestionVO deleteQuestionVO) {
|
|
|
|
+ String ids = deleteQuestionVO.getIds();
|
|
|
|
+ if (StringUtil.isEmpty(ids)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ List<String> idList = Arrays.asList(ids.split(","));
|
|
|
|
+ StringBuffer errMsg = new StringBuffer();
|
|
|
|
+ Date now = DateUtil.now();
|
|
|
|
+ String person = UserUtils.getCurrentPrincipleID();
|
|
|
|
+ for (String id : idList) {
|
|
|
|
+ Map paramMap = new HashMap<>();
|
|
|
|
+ paramMap.put("delete", IsDeleteEnum.Y.getKey());
|
|
|
|
+ paramMap.put("ids", Arrays.asList(ids.split(",")));
|
|
|
|
+ paramMap.put("gmtModified", now);
|
|
|
|
+ paramMap.put("modifier", person);
|
|
|
|
+ //删除自身
|
|
|
|
+ this.deleteByIds(paramMap);
|
|
|
|
+ //删除明细
|
|
|
|
+ questionDetailFacade.deleteByQuestionIdFac(paramMap);
|
|
|
|
+ //删除映射关系
|
|
|
|
+ questionMappingFacade.deleteByIdsFac(paramMap);
|
|
|
|
+ //TODO 删除映射关系或检查抛异常
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 检索
|
|
|
|
+ *
|
|
|
|
+ * @param questionIndexVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<QuestionInfo> indexFac(QuestionIndexVO questionIndexVO) {
|
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
+ paramMap.put("age", questionIndexVO.getAge());
|
|
|
|
+ paramMap.put("sexType", questionIndexVO.getSexType());
|
|
|
|
+ paramMap.put("tagName", questionIndexVO.getTagName());
|
|
|
|
+ paramMap.put("type", questionIndexVO.getType());
|
|
|
|
+ paramMap.put("controlType", questionIndexVO.getControlType());
|
|
|
|
+ paramMap.put("notIds", questionIndexVO.getNotIds());
|
|
|
|
+ paramMap.put("tagType", questionIndexVO.getTagType());
|
|
|
|
+ paramMap.put("existName", questionIndexVO.getExistName());
|
|
|
|
+ paramMap.put("notTagType", questionIndexVO.getNotTagType());
|
|
|
|
+ paramMap.put("notControlType", questionIndexVO.getNotControlType());
|
|
|
|
+ List<QuestionInfo> res = this.index(paramMap);
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据主标签id 检索子标签
|
|
|
|
+ *
|
|
|
|
+ * @param questionIndexSubVO
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<QuestionInfo> indexSub(QuestionIndexSubVO questionIndexSubVO) {
|
|
|
|
+ Map<String, Object> paramMap = new HashMap<>();
|
|
|
|
+ paramMap.put("age", questionIndexSubVO.getAge());
|
|
|
|
+ paramMap.put("sexType", questionIndexSubVO.getSexType());
|
|
|
|
+ paramMap.put("tagName", questionIndexSubVO.getTagName());
|
|
|
|
+ paramMap.put("type", questionIndexSubVO.getType());
|
|
|
|
+ paramMap.put("controlType", questionIndexSubVO.getControlType());
|
|
|
|
+ paramMap.put("notIds", questionIndexSubVO.getNotIds());
|
|
|
|
+ paramMap.put("tagType", questionIndexSubVO.getTagType());
|
|
|
|
+ paramMap.put("existName", questionIndexSubVO.getExistName());
|
|
|
|
+ paramMap.put("notTagType", questionIndexSubVO.getNotTagType());
|
|
|
|
+ paramMap.put("notControlType", questionIndexSubVO.getNotControlType());
|
|
|
|
+
|
|
|
|
+ QueryWrapper<QuestionMapping> questionMappingQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ questionMappingQueryWrapper.eq("is_deleted", IsDeleteEnum.N.getKey()).eq("parent_question", questionIndexSubVO.getParentId());
|
|
|
|
+ List<QuestionMapping> questionMappingList = questionMappingFacade.list(questionMappingQueryWrapper);
|
|
|
|
+ if (ListUtil.isNotEmpty(questionMappingList)) {
|
|
|
|
+ List<Long> sonIds = questionMappingList.stream().map(questionMapping -> questionMapping.getSonQuestion()).collect(Collectors.toList());
|
|
|
|
+ paramMap.put("ids", sonIds);
|
|
|
|
+ }
|
|
|
|
+ List<QuestionInfo> res = this.index(paramMap);
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据参数返回标签内容
|
|
|
|
+ *
|
|
|
|
+ * @param questionVO 获取标签内容参数
|
|
|
|
+ * @return 标签内容
|
|
|
|
+ */
|
|
|
|
+ public QuestionDTO getById(QuestionVO questionVO) {
|
|
|
|
+ Map paramMap = new HashMap<>();
|
|
|
|
+ paramMap.put("sexType", questionVO.getSexType());
|
|
|
|
+ paramMap.put("age", questionVO.getAge());
|
|
|
|
+ paramMap.put("id", questionVO.getId());
|
|
|
|
+ QuestionInfo questionInfo = this.getByParam(paramMap);
|
|
|
|
+ if (questionInfo == null) { //无数据直接返回,不通过报错的形式返回
|
|
|
|
+ return new QuestionDTO();
|
|
|
|
+ }
|
|
|
|
+ QuestionDTO res = new QuestionDTO();
|
|
|
|
+ BeanUtil.copyProperties(questionInfo, res);
|
|
|
|
+
|
|
|
|
+ //获取明细项
|
|
|
|
+ List<QuestionDetail> questionDetailList = questionDetailFacade.getByQuestionId(questionVO.getId());
|
|
|
|
+ res.setQuestionDetailList(questionDetailList);
|
|
|
|
+
|
|
|
|
+ //获取子标签
|
|
|
|
+ List<QuestionInfoWrapper> questionMapping = this.getByQuestionMapping(paramMap);
|
|
|
|
+ List<QuestionDTO> sonQuestionList = BeanUtil.listCopyTo(questionMapping, QuestionDTO.class);
|
|
|
|
+ res.setQuestionMapping(sonQuestionList);
|
|
|
|
+ //获取子标签的明细项
|
|
|
|
+ if (ListUtil.isNotEmpty(sonQuestionList)) {
|
|
|
|
+ Map paramMap1 = new HashMap<>();
|
|
|
|
+ paramMap1.put("sexType", questionVO.getSexType());
|
|
|
|
+ paramMap1.put("age", questionVO.getAge());
|
|
|
|
+ List<Long> sonQuestionIds = sonQuestionList.stream()
|
|
|
|
+ .map(artist -> artist.getId())
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ Map<Long, List<QuestionDetail>> sonQuestionMap = questionDetailFacade.getByQuestionIds(sonQuestionIds);
|
|
|
|
+ paramMap1.put("ids", sonQuestionIds);
|
|
|
|
+ //获取第二级子标签
|
|
|
|
+ List<QuestionInfoWrapper> questionMapping1 = this.getByQuestionMapping(paramMap1);
|
|
|
|
+ Map<Long, List<QuestionInfoWrapper>> qm1 = EntityUtil.makeEntityListMap(questionMapping1, "parentQuestion");
|
|
|
|
+ for (QuestionDTO bean : sonQuestionList) {
|
|
|
|
+ List<QuestionDetail> questionDetailList1 = sonQuestionMap.get(bean.getId());
|
|
|
|
+ if (ListUtil.isEmpty(questionDetailList1)) {
|
|
|
|
+ questionDetailList1 = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ bean.setQuestionDetailList(questionDetailList1);
|
|
|
|
+ List<QuestionDTO> sonQuestionList1 = new ArrayList<>();
|
|
|
|
+ if (ListUtil.isNotEmpty(qm1.get(bean.getId()))) {
|
|
|
|
+ sonQuestionList1 = BeanUtil.listCopyTo(qm1.get(bean.getId()), QuestionDTO.class);
|
|
|
|
+ }
|
|
|
|
+ bean.setQuestionMapping(sonQuestionList1);
|
|
|
|
+
|
|
|
|
+ List<Long> sonQuestionIds1 = sonQuestionList1.stream()
|
|
|
|
+ .map(artist -> artist.getId())
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+ Map<Long, List<QuestionDetail>> sonQuestionMap1 = questionDetailFacade.getByQuestionIds(sonQuestionIds1);
|
|
|
|
+ for (QuestionDTO questionDTO : sonQuestionList1) {
|
|
|
|
+ //获取二级子明细项
|
|
|
|
+ List<QuestionDetail> questionDetailList2 = sonQuestionMap1.get(questionDTO.getId());
|
|
|
|
+ if (ListUtil.isEmpty(questionDetailList2)) {
|
|
|
|
+ questionDetailList2 = new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ questionDTO.setQuestionDetailList(questionDetailList2);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查询多个id返回标签内容
|
|
|
|
+ *
|
|
|
|
+ * @param questionIdsVO 获取标签内容参数
|
|
|
|
+ * @return 标签内容
|
|
|
|
+ */
|
|
|
|
+ public Map<Long, Object> getByIds(QuestionIdsVO questionIdsVO) {
|
|
|
|
+ Map<Long, Object> data = new HashMap<>();
|
|
|
|
+ if (StringUtil.isEmpty(questionIdsVO.getIds())) {
|
|
|
|
+ return data;
|
|
|
|
+ }
|
|
|
|
+ String[] ids = questionIdsVO.getIds().split(",");
|
|
|
|
+ for (String id : ids) {
|
|
|
|
+ QuestionVO questionVO = new QuestionVO();
|
|
|
|
+ questionVO.setId(Long.parseLong(id));
|
|
|
|
+ questionVO.setAge(questionIdsVO.getAge());
|
|
|
|
+ questionVO.setSexType(questionIdsVO.getSexType());
|
|
|
|
+ QuestionDTO item = this.getById(questionVO);
|
|
|
|
+ data.put(item.getId(), item);
|
|
|
|
+ }
|
|
|
|
+ return data;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取所有需要删除的缓存id列表
|
|
|
|
+ *
|
|
|
|
+ * @param id
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ public List<Long> getDeleteId(Long id) {
|
|
|
|
+ List<Long> list = new ArrayList<>();
|
|
|
|
+ list.add(id); //添加自身id
|
|
|
|
+ getParent(id, list); //添加父级
|
|
|
|
+ return list;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public void getParent(Long id, List<Long> list) {
|
|
|
|
+ List<QuestionMapping> questionMappingList = questionMappingFacade.list(
|
|
|
|
+ new QueryWrapper<QuestionMapping>()
|
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
|
+ .eq("son_question", id)
|
|
|
|
+ );
|
|
|
|
+ if (ListUtil.isNotEmpty(questionMappingList)) {
|
|
|
|
+ for (QuestionMapping questionMapping : questionMappingList) {
|
|
|
|
+ Long parentId = questionMapping.getParentQuestion();
|
|
|
|
+ if (!list.contains(parentId)) {
|
|
|
|
+ list.add(parentId);
|
|
|
|
+ getParent(parentId, list);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|