|
@@ -95,11 +95,10 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
case "3": //组合项,例如:血压
|
|
|
case "4": //组合项,例如:咳嗽
|
|
|
case "5": //组合项,例如:有无治疗
|
|
|
+ case "6": // 组合项,例如:既往史
|
|
|
case "7": //化验
|
|
|
saveQuestionMapping(questionWrapper, param);
|
|
|
break;
|
|
|
- case "6": // 组合项,例如:既往史
|
|
|
- break;
|
|
|
case "8": //模板专用文字,无单独维护
|
|
|
case "9": //空标签,只维护主表信息
|
|
|
case "10": //疾病组合类型
|
|
@@ -137,37 +136,101 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
Date now = param.getNow();
|
|
|
String person = param.getPerson();
|
|
|
//先删除原明细,再插入新明细
|
|
|
- questionMappingFacade.update(new QuestionMapping(), //删除原映射关系
|
|
|
- new UpdateWrapper<QuestionMapping>()
|
|
|
- .eq("parent_question", questionInfo.getId())
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .set("gmt_modified", now)
|
|
|
- .set("modifier", person)
|
|
|
- .set("is_deleted", IsDeleteEnum.Y.getKey()));
|
|
|
+ deleteMapping(questionInfo.getId(), param);//删除原映射关系
|
|
|
List<QuestionMappingWrapper> questionMappings = questionWrapper.getQuestionMappings();
|
|
|
+ if (ListUtil.isNotEmpty(questionMappings)) {
|
|
|
+ for (QuestionMappingWrapper bean : questionMappings) {
|
|
|
+ QuestionWrapper sonQues = bean.getQuestionMappingSon();
|
|
|
+ if (ListUtil.isNotEmpty(sonQues.getQuestionMappings())) {
|
|
|
+ QuestionInfo ques = new QuestionInfo();
|
|
|
+ BeanUtil.copyProperties(sonQues, ques);
|
|
|
+ if (ques.getId() != null) {
|
|
|
+ ques = this.getOne(new QueryWrapper<QuestionInfo>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("id", ques.getId()));
|
|
|
+ if (ques == null) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "标签被修改,请刷新后重新保存");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String name = "组合项_" + DateUtil.format(DateUtil.now(), DateUtil.FORMAT_FULL);
|
|
|
+ ques.setTagName(name);
|
|
|
+ ques.setName(name);
|
|
|
+ ques.setTagType("10");
|
|
|
+ ques.setGmtCreate(now);
|
|
|
+ ques.setCreator(person);
|
|
|
+ ques.setSubType(1);
|
|
|
+ }
|
|
|
+ ques.setType(questionInfo.getType());
|
|
|
+ ques.setGmtModified(now);
|
|
|
+ ques.setModifier(person);
|
|
|
+ this.saveOrUpdate(ques);
|
|
|
+
|
|
|
+ //删除原二级映射关系
|
|
|
+ deleteMapping(ques.getId(), param);
|
|
|
+
|
|
|
+ //添加二级映射关系
|
|
|
+ saveMapping(sonQues.getQuestionMappings(), new HashMap<String, Long>(), person, now, ques.getId());
|
|
|
+
|
|
|
+ //设置主映射关系
|
|
|
+ bean.setSonQuestion(ques.getId());
|
|
|
+ bean.setParentQuestion(questionInfo.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
if (ListUtil.isNotEmpty(questionMappings)) {
|
|
|
//预处理文字标签,之后统一添加映射关系
|
|
|
Map<String, Long> map = getNameMap(questionMappings, now, person, questionInfo.getType());
|
|
|
- List<QuestionMapping> saveMapping = new ArrayList<>();
|
|
|
- int i = 1;
|
|
|
- for (QuestionMappingWrapper mapping : questionMappings) {
|
|
|
- String text = mapping.getText();
|
|
|
- if (StringUtil.isNotEmpty(text)) {
|
|
|
- mapping.setSonQuestion(map.get(text));
|
|
|
- }
|
|
|
- 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(questionInfo.getId());
|
|
|
- bean.setOrderNo(i++);
|
|
|
- saveMapping.add(bean);
|
|
|
+ saveMapping(questionMappings, map, 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 map
|
|
|
+ * @param person
|
|
|
+ * @param now
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
+ public void saveMapping(List<QuestionMappingWrapper> questionMappings, Map<String, Long> map, String person, Date now, Long id) {
|
|
|
+ List<QuestionMapping> saveMapping = new ArrayList<>();
|
|
|
+ int i = 1;
|
|
|
+ for (QuestionMappingWrapper mapping : questionMappings) {
|
|
|
+ String text = mapping.getText();
|
|
|
+ if (StringUtil.isNotEmpty(text)) {
|
|
|
+ mapping.setSonQuestion(map.get(text));
|
|
|
}
|
|
|
- questionMappingService.saveBatch(saveMapping);
|
|
|
+ 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);
|
|
|
+ bean.setOrderNo(i++);
|
|
|
+ saveMapping.add(bean);
|
|
|
}
|
|
|
+ questionMappingService.saveBatch(saveMapping);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -327,19 +390,23 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
return true;
|
|
|
}
|
|
|
List<String> idList = Arrays.asList(ids.split(","));
|
|
|
+ StringBuffer errMsg = new StringBuffer();
|
|
|
for (String id : idList) {
|
|
|
// 查询映射关系中是否存在父级
|
|
|
- List<QuestionMapping> questionMappings = questionMappingFacade.list(new QueryWrapper<QuestionMapping>()
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .eq("son_question", id));
|
|
|
- if (ListUtil.isNotEmpty(questionMappings)) {
|
|
|
- List<Long> questionIds = questionMappings.stream().map(row -> row.getParentQuestion()).collect(Collectors.toList());
|
|
|
- List<String> tagName = this.list(new QueryWrapper<QuestionInfo>()
|
|
|
- .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
- .in("id", questionIds))
|
|
|
- .stream().map(row -> "【" + row.getTagName() + "】").collect(Collectors.toList());
|
|
|
- throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请先删除标签的关联:" + String.join("、", tagName));
|
|
|
+ List<QuestionInfo> info = this.getParentQuestion(Long.parseLong(id));
|
|
|
+ for(QuestionInfo bean : info) {
|
|
|
+ if(bean.getTagType() != null && Integer.parseInt(bean.getTagType()) == TagTypeEnum.T10.getKey()) {
|
|
|
+ List<QuestionInfo> info2 = this.getParentQuestion(bean.getId());
|
|
|
+ List<String> msg = info2.stream().map(row -> "【" + row.getTagName() + "】").collect(Collectors.toList());
|
|
|
+ errMsg.append(String.join("", msg));
|
|
|
+ } else {
|
|
|
+ errMsg.append("【").append(bean.getTagName()).append("】");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty(errMsg.toString())) {
|
|
|
+ throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请先删除标签的关联:" + errMsg);
|
|
|
}
|
|
|
+
|
|
|
// 查询模板中是否存在
|
|
|
List<ModuleDetail> moduleDetails = moduleDetailFacade.list(new QueryWrapper<ModuleDetail>()
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|