|
@@ -7,25 +7,34 @@ import com.diagbot.dto.RetrievalDTO;
|
|
|
import com.diagbot.dto.StandConvertCrfBatchDTO;
|
|
|
import com.diagbot.dto.StandConvertCrfDTO;
|
|
|
import com.diagbot.dto.WordCrfDTO;
|
|
|
+import com.diagbot.entity.Ann;
|
|
|
+import com.diagbot.entity.SymptomFeature;
|
|
|
+import com.diagbot.entity.SymptomFeatureList;
|
|
|
import com.diagbot.entity.TestwordInfo;
|
|
|
import com.diagbot.entity.TestwordRes;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
+import com.diagbot.service.SymptomFeatureService;
|
|
|
import com.diagbot.service.TestwordInfoService;
|
|
|
import com.diagbot.service.TestwordResService;
|
|
|
import com.diagbot.service.impl.TestwordInfoServiceImpl;
|
|
|
import com.diagbot.util.CoreUtil;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.EntityUtil;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.StringUtil;
|
|
|
import com.diagbot.vo.RetrievalVO;
|
|
|
import com.diagbot.vo.SearchData;
|
|
|
import com.diagbot.vo.StandConvertCrfVO;
|
|
|
+import com.diagbot.vo.SymptomFeatureVO;
|
|
|
import com.diagbot.vo.TestwordInfoVO;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import java.io.BufferedReader;
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileReader;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.LinkedHashMap;
|
|
@@ -54,6 +63,9 @@ public class TestwordInfoFacade extends TestwordInfoServiceImpl {
|
|
|
@Qualifier("testwordInfoServiceImpl")
|
|
|
TestwordInfoService testwordInfoService;
|
|
|
@Autowired
|
|
|
+ @Qualifier("symptomFeatureServiceImpl")
|
|
|
+ SymptomFeatureService symptomFeatureService;
|
|
|
+ @Autowired
|
|
|
TestFacade testFacade;
|
|
|
@Autowired
|
|
|
RetrievalFacade retrievalFacade;
|
|
@@ -429,4 +441,113 @@ public class TestwordInfoFacade extends TestwordInfoServiceImpl {
|
|
|
.map(r -> (String)CoreUtil.getFieldValue(r, "detailName"))
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 症状生成API
|
|
|
+ *
|
|
|
+ * @param symptomFeatureVO
|
|
|
+ */
|
|
|
+ public void getSymptom(SymptomFeatureVO symptomFeatureVO) {
|
|
|
+ Map<String, SymptomFeatureList> listMap = new LinkedHashMap<>();
|
|
|
+ try {
|
|
|
+ // 1、获取文件目录
|
|
|
+ File[] files = new File(symptomFeatureVO.getPath()).listFiles();
|
|
|
+ for (File file : files) {
|
|
|
+ // 读取以“.ann”结尾的文件
|
|
|
+ if (!file.getName().endsWith(".ann")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 2、遍历文件
|
|
|
+ List<Ann> annList = new ArrayList<>();
|
|
|
+ FileReader fileReader = new FileReader(file);
|
|
|
+ BufferedReader br = new BufferedReader(fileReader);
|
|
|
+ String line = "";
|
|
|
+
|
|
|
+ // 3、将文件结构化
|
|
|
+ while (StringUtil.isNotBlank(line = br.readLine())) {
|
|
|
+ String[] arr = line.split(" |\\t");
|
|
|
+ Ann ann = new Ann();
|
|
|
+ ann.setId(arr[0]);
|
|
|
+ ann.setType(arr[1]);
|
|
|
+ ann.setStart(arr[2]);
|
|
|
+ ann.setEnd(arr[3]);
|
|
|
+ ann.setName(arr[4]);
|
|
|
+ annList.add(ann);
|
|
|
+ }
|
|
|
+ Map<String, List<Ann>> typeEntity = EntityUtil.makeEntityListMap(annList, "type");
|
|
|
+ Map<String, List<Ann>> endMap = EntityUtil.makeEntityListMap(annList, "end");
|
|
|
+
|
|
|
+ // 4、以最小单元为准,读取相关属性
|
|
|
+ List<Ann> symptomList = typeEntity.get("min_combination_unit");
|
|
|
+ for (Ann ann : symptomList) {
|
|
|
+ String name = ann.getName();
|
|
|
+ SymptomFeatureList symptomFeatureList = listMap.get(name);
|
|
|
+ if (symptomFeatureList == null) {
|
|
|
+ symptomFeatureList = new SymptomFeatureList();
|
|
|
+ symptomFeatureList.setMinCombineElement(name);
|
|
|
+ }
|
|
|
+ String start = ann.getStart();
|
|
|
+ List<Ann> endList = new ArrayList<>();
|
|
|
+ while (ListUtil.isNotEmpty(endList = endMap.get(start))) {
|
|
|
+ Ann annBean = endList.get(0);
|
|
|
+ start = annBean.getStart();
|
|
|
+ switch (annBean.getType()) {
|
|
|
+ case "location": // 部位
|
|
|
+ setSymptomFeature(symptomFeatureList.getBodyPartList(), annBean.getName());
|
|
|
+ break;
|
|
|
+ case "direction": // 方位
|
|
|
+ setSymptomFeature(symptomFeatureList.getPositionList(), annBean.getName());
|
|
|
+ break;
|
|
|
+ case "property": // 形状性质
|
|
|
+ setSymptomFeature(symptomFeatureList.getShapePropetyList(), annBean.getName());
|
|
|
+ break;
|
|
|
+ case "extent": // 程度
|
|
|
+ setSymptomFeature(symptomFeatureList.getDegreeList(), annBean.getName());
|
|
|
+ break;
|
|
|
+ case "color": // 颜色
|
|
|
+ setSymptomFeature(symptomFeatureList.getColorList(), annBean.getName());
|
|
|
+ break;
|
|
|
+ case "change": // 变化
|
|
|
+ setSymptomFeature(symptomFeatureList.getVarietyList(), annBean.getName());
|
|
|
+ break;
|
|
|
+ case "rediate": // 放射情况
|
|
|
+ setSymptomFeature(symptomFeatureList.getRadiationSituationList(), annBean.getName());
|
|
|
+ break;
|
|
|
+ case "frequency": // 频率
|
|
|
+ setSymptomFeature(symptomFeatureList.getFrequencyList(), annBean.getName());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ listMap.put(name, symptomFeatureList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 5、数据库全部删除
|
|
|
+ symptomFeatureService.remove(new QueryWrapper<>());
|
|
|
+ // 6、批量插入
|
|
|
+ List<SymptomFeature> symptomFeatureList = new ArrayList<>();
|
|
|
+ for (String key : listMap.keySet()) {
|
|
|
+ SymptomFeatureList sf = listMap.get(key);
|
|
|
+ SymptomFeature symptomFeature = new SymptomFeature();
|
|
|
+ symptomFeature.setMinCombineElement(key);
|
|
|
+ symptomFeature.setBodyPart(StringUtils.join(sf.getBodyPartList(), "、"));
|
|
|
+ symptomFeature.setPosition(StringUtils.join(sf.getPositionList(), "、"));
|
|
|
+ symptomFeature.setBodyPart(StringUtils.join(sf.getBodyPartList(), "、"));
|
|
|
+ symptomFeature.setShapePropety(StringUtils.join(sf.getShapePropetyList(), "、"));
|
|
|
+ symptomFeature.setDegree(StringUtils.join(sf.getDegreeList(), "、"));
|
|
|
+ symptomFeature.setColor(StringUtils.join(sf.getColorList(), "、"));
|
|
|
+ symptomFeature.setVariety(StringUtils.join(sf.getVarietyList(), "、"));
|
|
|
+ symptomFeature.setFrequency(StringUtils.join(sf.getFrequencyList(), "、"));
|
|
|
+ symptomFeatureList.add(symptomFeature);
|
|
|
+ }
|
|
|
+ symptomFeatureService.saveBatch(symptomFeatureList);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setSymptomFeature(List<String> list, String name) {
|
|
|
+ if (!list.contains(name)) {
|
|
|
+ list.add(name);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|