|
@@ -117,17 +117,17 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
public Boolean addTagRetrieval(AddTagRetrievalVO addTagRetrievalVO) {
|
|
|
if (addTagRetrievalVO.getItemList().stream().distinct().count() != addTagRetrievalVO.getItemList().size()) {
|
|
|
throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
- "同义词中存在重复数据("+addTagRetrievalVO.getQuestionName()+")!");
|
|
|
+ "导入本体/同义/子项名称重复("+addTagRetrievalVO.getQuestionName()+")!");
|
|
|
}
|
|
|
|
|
|
long typeOneCou = addTagRetrievalVO.getItemList().stream().filter(i->i.getRetrievalType()==1).count();
|
|
|
if(typeOneCou==0){
|
|
|
throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
- "本体必须传("+addTagRetrievalVO.getQuestionName()+")!");
|
|
|
+ "导入数据不完整("+addTagRetrievalVO.getQuestionName()+")!");
|
|
|
}
|
|
|
if(typeOneCou>1){
|
|
|
throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
- "本体只能有一个("+addTagRetrievalVO.getQuestionName()+")!");
|
|
|
+ "导入本体类型数据重复("+addTagRetrievalVO.getQuestionName()+")!");
|
|
|
}
|
|
|
|
|
|
Date now = DateUtil.now();
|
|
@@ -266,6 +266,7 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
*/
|
|
|
public RetrievalExcelImDTO retrievalExcelIm(MultipartFile file) {
|
|
|
List<AddTagRetrievalVO> addTagRetrievalVOList = new ArrayList<>();
|
|
|
+ List<AddTagRetrievalDetailVO> detailList = new ArrayList<>();
|
|
|
StringBuffer sbf = new StringBuffer();
|
|
|
InputStream inputStream = null;
|
|
|
Workbook wb = null;
|
|
@@ -284,7 +285,7 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
wb = new XSSFWorkbook(inputStream);
|
|
|
}
|
|
|
if (wb != null) {
|
|
|
- List<AddTagRetrievalDetailVO> detailList = new ArrayList<>();
|
|
|
+
|
|
|
Sheet sheet = wb.getSheetAt(0);
|
|
|
int count = 0;
|
|
|
String questionName, retrievalName, retrievalSpell, retrievalType;
|
|
@@ -297,9 +298,13 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
retrievalName = getValue(row.getCell(1)).trim().replace(" ", "");
|
|
|
retrievalSpell = getValue(row.getCell(2)).trim().replace(" ", "");
|
|
|
retrievalType = getValue(row.getCell(3)).trim().replace(" ", "");
|
|
|
+ if(StringUtil.isEmpty(questionName) && StringUtil.isEmpty(retrievalName)
|
|
|
+ && StringUtil.isEmpty(retrievalSpell) && StringUtil.isEmpty(retrievalType)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if (StringUtil.isEmpty(questionName) || StringUtil.isEmpty(retrievalName)
|
|
|
|| StringUtil.isEmpty(retrievalSpell) || StringUtil.isEmpty(retrievalType)) {
|
|
|
- sbf.append("第" + count + "行数据不完整!").append("<br/>");
|
|
|
+ sbf.append("第" + count + "行数据不完整;").append("<br/>");
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -310,26 +315,6 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
addTagRetrievalDetailVO.setRetrievalType(Integer.parseInt(retrievalType));
|
|
|
detailList.add(addTagRetrievalDetailVO);
|
|
|
}
|
|
|
-
|
|
|
- if (detailList.size() > 0) {
|
|
|
- List<String> questionNames = detailList.stream().map(i -> i.getQuestionName()).distinct().collect(Collectors.toList());
|
|
|
- QueryWrapper<QuestionInfo> questionInfoQe = new QueryWrapper<>();
|
|
|
- questionInfoQe.in("tag_name", questionNames);
|
|
|
- List<QuestionInfo> questionInfos = questionFacade.list(questionInfoQe);
|
|
|
- if (questionInfos.size() > 0) {
|
|
|
- Map<String, Long> questionIdMap = questionInfos.stream().collect(Collectors.toMap(QuestionInfo::getTagName, i -> i.getId()));
|
|
|
- detailList.forEach(i -> {
|
|
|
- i.setQuestionId(questionIdMap.get(i.getQuestionName()));
|
|
|
- });
|
|
|
- Map<Long, List<AddTagRetrievalDetailVO>> detailMap = detailList.stream().collect(Collectors.groupingBy(AddTagRetrievalDetailVO::getQuestionId));
|
|
|
- for (Long key : detailMap.keySet()) {
|
|
|
- AddTagRetrievalVO addTagRetrievalVO = new AddTagRetrievalVO();
|
|
|
- addTagRetrievalVO.setQuestionId(key);
|
|
|
- addTagRetrievalVO.setItemList(detailMap.get(key));
|
|
|
- addTagRetrievalVOList.add(addTagRetrievalVO);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
} else {
|
|
|
sbf.append("非excel文件无法解析!").append("<br/>");
|
|
|
}
|
|
@@ -357,6 +342,38 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
if(sbf.length()>0){
|
|
|
throw new CommonException(CommonErrorCode.RPC_ERROR,sbf.toString());
|
|
|
}
|
|
|
+
|
|
|
+ if (detailList.size() > 0) {
|
|
|
+ List<String> questionNames = detailList.stream().map(i -> i.getQuestionName()).distinct().collect(Collectors.toList());
|
|
|
+ QueryWrapper<QuestionInfo> questionInfoQe = new QueryWrapper<>();
|
|
|
+ questionInfoQe.in("tag_name", questionNames);
|
|
|
+ List<QuestionInfo> questionInfos = questionFacade.list(questionInfoQe);
|
|
|
+ Map<String, Long> questionIdMap = questionInfos.stream().collect(Collectors.toMap(QuestionInfo::getTagName, i -> i.getId()));
|
|
|
+ if(questionNames.size()==questionInfos.size()){
|
|
|
+ detailList.forEach(i -> {
|
|
|
+ i.setQuestionId(questionIdMap.get(i.getQuestionName()));
|
|
|
+ });
|
|
|
+ Map<Long, List<AddTagRetrievalDetailVO>> detailMap = detailList.stream().collect(Collectors.groupingBy(AddTagRetrievalDetailVO::getQuestionId));
|
|
|
+ for (Long key : detailMap.keySet()) {
|
|
|
+ AddTagRetrievalVO addTagRetrievalVO = new AddTagRetrievalVO();
|
|
|
+ addTagRetrievalVO.setQuestionId(key);
|
|
|
+ addTagRetrievalVO.setItemList(detailMap.get(key));
|
|
|
+ addTagRetrievalVOList.add(addTagRetrievalVO);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ sbf.append("标签数据不存在(");
|
|
|
+ int index = 0;
|
|
|
+ for(String k:questionNames){
|
|
|
+ sbf.append(k);
|
|
|
+ if(index<questionNames.size()-1){
|
|
|
+ sbf.append("、");
|
|
|
+ }
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ sbf.append(");");
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR,sbf.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
addTagRetrievalVOList.forEach(i -> {
|
|
|
addTagRetrieval(i);
|
|
@@ -365,7 +382,7 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
RetrievalExcelImDTO retrievalExcelImDTO = new RetrievalExcelImDTO();
|
|
|
return retrievalExcelImDTO;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@SuppressWarnings("deprecation")
|
|
|
private String getValue(Cell cell) {
|
|
|
try {
|