|
@@ -10,11 +10,14 @@ 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.QuestionMappingWrapper;
|
|
|
import com.diagbot.entity.wrapper.QuestionWrapper;
|
|
|
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;
|
|
@@ -36,6 +39,7 @@ import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
@@ -48,6 +52,9 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
@Autowired
|
|
|
QuestionDetailFacade questionDetailFacade;
|
|
|
@Autowired
|
|
|
+ @Qualifier("questionInfoServiceImpl")
|
|
|
+ QuestionInfoService questionInfoService;
|
|
|
+ @Autowired
|
|
|
@Qualifier("questionDetailServiceImpl")
|
|
|
QuestionDetailService questionDetailService;
|
|
|
@Autowired
|
|
@@ -73,19 +80,17 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
saveQuestionDetail(questionWrapper, param);
|
|
|
break;
|
|
|
case "2": //组合项,例如:杂音,修改主表和mapping
|
|
|
+ case "3": //组合项,例如:血压
|
|
|
+ case "4": //组合项,例如:咳嗽
|
|
|
saveQuestionMapping(questionWrapper, param);
|
|
|
break;
|
|
|
- case "3":
|
|
|
- break;
|
|
|
- case "4":
|
|
|
- break;
|
|
|
- case "5":
|
|
|
+ case "5": //组合项,例如:有无治疗
|
|
|
break;
|
|
|
- case "6":
|
|
|
+ case "6": // 组合项,例如:既往史
|
|
|
break;
|
|
|
- case "7":
|
|
|
+ case "7": //化验
|
|
|
break;
|
|
|
- case "8":
|
|
|
+ case "8": //模板专用文字
|
|
|
break;
|
|
|
default:
|
|
|
throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "请选择标签显示类型");
|
|
@@ -107,12 +112,11 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
param.setNow(DateUtil.now());
|
|
|
param.setPerson(person);
|
|
|
param.setSaveOrUpdate("save");
|
|
|
- QuestionInfo questionInfo = new QuestionInfo();
|
|
|
- param.setQuestionInfo(questionInfo);
|
|
|
return param;
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 保存映射关系
|
|
|
*
|
|
@@ -131,11 +135,17 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
.set("gmt_modified", now)
|
|
|
.set("modifier", person)
|
|
|
.set("is_deleted", IsDeleteEnum.Y.getKey()));
|
|
|
- List<QuestionMapping> questionMappings = questionWrapper.getQuestionMappings();
|
|
|
+ List<QuestionMappingWrapper> questionMappings = questionWrapper.getQuestionMappings();
|
|
|
if(ListUtil.isNotEmpty(questionMappings)) {
|
|
|
+ //预处理文字标签,之后统一添加映射关系
|
|
|
+ Map<String, Long> map = getNameMap(questionMappings, now, person, questionInfo.getType());
|
|
|
List<QuestionMapping> saveMapping = new ArrayList<>();
|
|
|
int i = 1;
|
|
|
- for(QuestionMapping mapping : questionMappings) {
|
|
|
+ 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置空自动插入
|
|
@@ -143,6 +153,7 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
bean.setGmtCreate(now);
|
|
|
bean.setModifier(person);
|
|
|
bean.setGmtModified(now);
|
|
|
+ bean.setParentQuestion(questionInfo.getId());
|
|
|
bean.setOrderNo(i++);
|
|
|
saveMapping.add(bean);
|
|
|
}
|
|
@@ -151,6 +162,52 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取name对应map列表,key为name,value为id
|
|
|
+ *
|
|
|
+ * @param questionMappings
|
|
|
+ * @param now
|
|
|
+ * @param person
|
|
|
+ * @param type
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Long> getNameMap(List<QuestionMappingWrapper> questionMappings, Date now, String person, Integer type) {
|
|
|
+ List<String> nameList = questionMappings.stream().filter(row -> StringUtil.isNotEmpty(row.getText())).map(row -> row.getText()).collect(Collectors.toList());
|
|
|
+ List<QuestionInfo> questionInfos = this.list(new QueryWrapper<QuestionInfo>()
|
|
|
+ .eq("type", type)
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("tag_type", TagTypeEnum.T8.getKey())
|
|
|
+ .in("name", nameList)
|
|
|
+ );
|
|
|
+ Map<String, Long> map = questionInfos.stream().collect(Collectors.toMap(row -> row.getName(), row -> row.getId(), (k1,k2)->k1));
|
|
|
+ List<QuestionInfo> addBatch = new ArrayList<>();
|
|
|
+ List<String> nameExist = new ArrayList<>();
|
|
|
+ for(String s : nameList) {
|
|
|
+ if(map.get(s) == null && !nameExist.contains(s)) {
|
|
|
+ nameExist.add(s);
|
|
|
+ QuestionInfo bean = new QuestionInfo();
|
|
|
+ bean.setModifier(person);
|
|
|
+ bean.setCreator(person);
|
|
|
+ bean.setGmtCreate(now);
|
|
|
+ bean.setGmtModified(now);
|
|
|
+ bean.setTagType(String.valueOf(TagTypeEnum.T8.getKey()));
|
|
|
+ bean.setTagName(s);
|
|
|
+ bean.setName(s);
|
|
|
+ bean.setType(type);
|
|
|
+ bean.setSubType(1); //描述类型
|
|
|
+ addBatch.add(bean);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ questionInfoService.saveBatch(addBatch); //批量插入question
|
|
|
+ for(QuestionInfo bean : addBatch) {
|
|
|
+ if(map.get(bean.getName()) == null) {
|
|
|
+ map.put(bean.getName(), bean.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 保存明细
|
|
|
*
|
|
@@ -197,7 +254,7 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
* @param param
|
|
|
*/
|
|
|
public void saveQuestionInfo(QuestionWrapper questionWrapper, CommonParam param) {
|
|
|
- QuestionInfo questionInfo = param.getQuestionInfo();
|
|
|
+ QuestionInfo questionInfo = new QuestionInfo();
|
|
|
if(questionWrapper.getId() != null) {
|
|
|
questionInfo = this.getOne(new QueryWrapper<QuestionInfo>()
|
|
|
.eq("id", questionWrapper.getId())
|
|
@@ -222,6 +279,7 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
}
|
|
|
questionInfo.setGmtModified(param.getNow());//修改时间
|
|
|
questionInfo.setModifier(param.getPerson());//修改人
|
|
|
+ param.setQuestionInfo(questionInfo);
|
|
|
this.saveOrUpdate(questionInfo);
|
|
|
}
|
|
|
|
|
@@ -320,4 +378,45 @@ public class QuestionInfoFacade extends QuestionInfoServiceImpl {
|
|
|
List<GetQuestionInfoDTO> getQuestionInfoDTOList = this.getQuestionUsualsByDept(getQuestionUsualByDeptVO);
|
|
|
return getQuestionInfoDTOList;
|
|
|
}
|
|
|
+
|
|
|
+ public static void main(String[] args) {
|
|
|
+ List<Person> list = new ArrayList<>();
|
|
|
+ list.add(new Person(1L,"1d"));
|
|
|
+ list.add(new Person(2L,"2d"));
|
|
|
+ list.add(new Person(3L,"3d"));
|
|
|
+ list.add(new Person(4L,"4d"));
|
|
|
+ list.add(new Person(5L,"5d"));
|
|
|
+ list.add(new Person(6L,"5d"));
|
|
|
+ Map<String, Long> map = list.stream().collect(Collectors.toMap(Person::getText, Person::getId, (k1,k2)->k1));
|
|
|
+ System.out.println(map);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class Person {
|
|
|
+ private Long id;
|
|
|
+ private String text;
|
|
|
+
|
|
|
+ public Person() {
|
|
|
+ }
|
|
|
+
|
|
|
+ public Person(Long id, String text) {
|
|
|
+ this.id = id;
|
|
|
+ this.text = text;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getText() {
|
|
|
+ return text;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setText(String text) {
|
|
|
+ this.text = text;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Long getId() {
|
|
|
+ return id;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setId(Long id) {
|
|
|
+ this.id = id;
|
|
|
+ }
|
|
|
}
|