|
@@ -65,10 +65,10 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public List<GetRetrievalsByTagDTO> getRetrievalsByTag(GetRetrievalsByTagVO getRetrievalsByTagVO) {
|
|
|
- List<GetRetrievalsByTagDTO> retList = baseMapper.getRetrievalsByTag(getRetrievalsByTagVO);
|
|
|
- if(ListUtil.isEmpty(retList)){
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS);
|
|
|
- }
|
|
|
+ List<GetRetrievalsByTagDTO> retList = baseMapper.getRetrievalsByTag(getRetrievalsByTagVO);
|
|
|
+ if (ListUtil.isEmpty(retList)) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS);
|
|
|
+ }
|
|
|
return retList;
|
|
|
}
|
|
|
|
|
@@ -79,19 +79,19 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public Boolean delRetrievalsByQuesId(DelRetrievalsByQuesIdVO delRetrievalsByQuesIdVO) {
|
|
|
- QueryWrapper<RetrievalMapping> mappingQe = new QueryWrapper<>();
|
|
|
- mappingQe.eq("question_id", delRetrievalsByQuesIdVO.getQuestionId());
|
|
|
- if(retrievalMappingFacade.count(mappingQe)==0){
|
|
|
- throw new CommonException(CommonErrorCode.NOT_EXISTS);
|
|
|
- }
|
|
|
- String userId = UserUtils.getCurrentPrincipleID();
|
|
|
- RetrievalMapping retrievalMapping = new RetrievalMapping();
|
|
|
- retrievalMapping.setGmtModified(DateUtil.now());
|
|
|
- retrievalMapping.setModifier(userId);
|
|
|
- retrievalMapping.setIsDeleted(IsDeleteEnum.Y.getKey());
|
|
|
-
|
|
|
- retrievalMappingFacade.update(retrievalMapping, mappingQe);
|
|
|
- return true;
|
|
|
+ QueryWrapper<RetrievalMapping> mappingQe = new QueryWrapper<>();
|
|
|
+ mappingQe.eq("question_id", delRetrievalsByQuesIdVO.getQuestionId());
|
|
|
+ if (retrievalMappingFacade.count(mappingQe) == 0) {
|
|
|
+ throw new CommonException(CommonErrorCode.NOT_EXISTS);
|
|
|
+ }
|
|
|
+ String userId = UserUtils.getCurrentPrincipleID();
|
|
|
+ RetrievalMapping retrievalMapping = new RetrievalMapping();
|
|
|
+ retrievalMapping.setGmtModified(DateUtil.now());
|
|
|
+ retrievalMapping.setModifier(userId);
|
|
|
+ retrievalMapping.setIsDeleted(IsDeleteEnum.Y.getKey());
|
|
|
+
|
|
|
+ retrievalMappingFacade.update(retrievalMapping, mappingQe);
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -101,240 +101,243 @@ public class RetrievalFacade extends RetrievalServiceImpl {
|
|
|
* @return
|
|
|
*/
|
|
|
public Boolean addTagRetrieval(AddTagRetrievalVO addTagRetrievalVO) {
|
|
|
- if(addTagRetrievalVO.getItemList().stream().distinct().count()!=addTagRetrievalVO.getItemList().size()){
|
|
|
- throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
+ if (addTagRetrievalVO.getItemList().stream().distinct().count() != addTagRetrievalVO.getItemList().size()) {
|
|
|
+ throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
"同义词中存在重复数据!");
|
|
|
- }
|
|
|
-
|
|
|
- Date now = DateUtil.now();
|
|
|
- String userId = UserUtils.getCurrentPrincipleID();
|
|
|
-
|
|
|
- Map<String,AddTagRetrievalDetailVO> detailMap = addTagRetrievalVO.getItemList().stream().collect(Collectors.toMap(AddTagRetrievalDetailVO::getRetrievalName,i->i));
|
|
|
- List<String> retrievalNames = addTagRetrievalVO.getItemList().stream().map(i->i.getRetrievalName()).collect(Collectors.toList());
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ Date now = DateUtil.now();
|
|
|
+ String userId = UserUtils.getCurrentPrincipleID();
|
|
|
+
|
|
|
+ Map<String, AddTagRetrievalDetailVO> detailMap = addTagRetrievalVO.getItemList().stream().collect(Collectors.toMap(AddTagRetrievalDetailVO::getRetrievalName, i -> i));
|
|
|
+ List<String> retrievalNames = addTagRetrievalVO.getItemList().stream().map(i -> i.getRetrievalName()).collect(Collectors.toList());
|
|
|
+
|
|
|
QueryWrapper<Retrieval> retrievalQe = new QueryWrapper<Retrieval>();
|
|
|
retrievalQe.in("name", retrievalNames);
|
|
|
retrievalQe.eq("is_deleted", IsDeleteEnum.N.getKey());
|
|
|
- Map<String,Retrieval> retrievalMap = this.list(retrievalQe).stream().collect(Collectors.toMap(Retrieval::getName,i->i));
|
|
|
-
|
|
|
+ Map<String, Retrieval> retrievalMap = this.list(retrievalQe).stream().collect(Collectors.toMap(Retrieval::getName, i -> i));
|
|
|
+
|
|
|
List<Retrieval> saveOrUpdateRetrievals = new ArrayList<>();
|
|
|
List<Retrieval> retrievals = new ArrayList<>();
|
|
|
- addTagRetrievalVO.getItemList().forEach(i->{
|
|
|
- Retrieval retrieval = retrievalMap.get(i.getRetrievalName());
|
|
|
- if(retrieval==null){
|
|
|
- retrieval = new Retrieval();
|
|
|
- retrieval.setName(i.getRetrievalName());
|
|
|
- retrieval.setSpell(i.getRetrievalSpell());
|
|
|
- retrieval.setCreator(userId);
|
|
|
- retrieval.setGmtCreate(now);
|
|
|
- retrieval.setModifier(userId);
|
|
|
- retrieval.setGmtModified(now);
|
|
|
- saveOrUpdateRetrievals.add(retrieval);
|
|
|
- }else if(!retrieval.getSpell().equals(i.getRetrievalSpell())){
|
|
|
- retrieval.setSpell(i.getRetrievalSpell());
|
|
|
- retrieval.setModifier(userId);
|
|
|
- retrieval.setGmtModified(now);
|
|
|
- saveOrUpdateRetrievals.add(retrieval);
|
|
|
- }else{
|
|
|
- retrievals.add(retrieval);
|
|
|
- }
|
|
|
+ addTagRetrievalVO.getItemList().forEach(i -> {
|
|
|
+ Retrieval retrieval = retrievalMap.get(i.getRetrievalName());
|
|
|
+ if (retrieval == null) {
|
|
|
+ retrieval = new Retrieval();
|
|
|
+ retrieval.setName(i.getRetrievalName());
|
|
|
+ retrieval.setSpell(i.getRetrievalSpell());
|
|
|
+ retrieval.setCreator(userId);
|
|
|
+ retrieval.setGmtCreate(now);
|
|
|
+ retrieval.setModifier(userId);
|
|
|
+ retrieval.setGmtModified(now);
|
|
|
+ saveOrUpdateRetrievals.add(retrieval);
|
|
|
+ } else if (!retrieval.getSpell().equals(i.getRetrievalSpell())) {
|
|
|
+ retrieval.setSpell(i.getRetrievalSpell());
|
|
|
+ retrieval.setModifier(userId);
|
|
|
+ retrieval.setGmtModified(now);
|
|
|
+ saveOrUpdateRetrievals.add(retrieval);
|
|
|
+ } else {
|
|
|
+ retrievals.add(retrieval);
|
|
|
+ }
|
|
|
});
|
|
|
this.saveOrUpdateBatch(saveOrUpdateRetrievals);
|
|
|
retrievals.addAll(saveOrUpdateRetrievals);
|
|
|
- List<Long> retrievalIds = retrievals.stream().map(i->i.getId()).collect(Collectors.toList());
|
|
|
-
|
|
|
- QueryWrapper<RetrievalMapping> retrievalMappingQe = new QueryWrapper<RetrievalMapping>();
|
|
|
- retrievalMappingQe.eq("question_id", addTagRetrievalVO.getQuestionId());
|
|
|
+ List<Long> retrievalIds = retrievals.stream().map(i -> i.getId()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ QueryWrapper<RetrievalMapping> retrievalMappingQe = new QueryWrapper<RetrievalMapping>();
|
|
|
+ retrievalMappingQe.eq("question_id", addTagRetrievalVO.getQuestionId());
|
|
|
List<RetrievalMapping> retrievalMappings = retrievalMappingFacade.list(retrievalMappingQe);
|
|
|
- Map<Long,RetrievalMapping> retrievalMappingMap = retrievalMappings.stream().collect(Collectors.toMap(RetrievalMapping::getRetrievalId, i->i));
|
|
|
-
|
|
|
+ Map<Long, RetrievalMapping> retrievalMappingMap = retrievalMappings.stream().collect(Collectors.toMap(RetrievalMapping::getRetrievalId, i -> i));
|
|
|
+
|
|
|
List<RetrievalMapping> addOrUpdateRetrievalMappings = new ArrayList<>();
|
|
|
- retrievalMappings.stream().filter(i->retrievalIds.contains(i.getRetrievalId())).forEach(i->{
|
|
|
- i.setIsDeleted(IsDeleteEnum.Y.getKey());
|
|
|
- i.setGmtModified(now);
|
|
|
- i.setModifier(userId);
|
|
|
- addOrUpdateRetrievalMappings.add(i);
|
|
|
+ retrievalMappings.stream().filter(i -> retrievalIds.contains(i.getRetrievalId())).forEach(i -> {
|
|
|
+ i.setIsDeleted(IsDeleteEnum.Y.getKey());
|
|
|
+ i.setGmtModified(now);
|
|
|
+ i.setModifier(userId);
|
|
|
+ addOrUpdateRetrievalMappings.add(i);
|
|
|
});
|
|
|
-
|
|
|
- retrievals.forEach(i->{
|
|
|
- RetrievalMapping retrievalMapping = retrievalMappingMap.get(i.getId());
|
|
|
- AddTagRetrievalDetailVO detail = detailMap.get(i.getName());
|
|
|
- if(retrievalMapping==null){
|
|
|
- retrievalMapping = new RetrievalMapping();
|
|
|
- retrievalMapping.setQuestionId(addTagRetrievalVO.getQuestionId());
|
|
|
- retrievalMapping.setRetrievalId(i.getId());
|
|
|
- retrievalMapping.setGmtCreate(now);
|
|
|
- retrievalMapping.setGmtModified(now);
|
|
|
- retrievalMapping.setCreator(userId);
|
|
|
- retrievalMapping.setModifier(userId);
|
|
|
- retrievalMapping.setShowType(detail.getRetrievalType());
|
|
|
- addOrUpdateRetrievalMappings.add(retrievalMapping);
|
|
|
- }else{
|
|
|
- if(detail.getRetrievalType()!=retrievalMapping.getShowType()||retrievalMapping.getIsDeleted().equals("Y")){
|
|
|
- retrievalMapping.setShowType(detailMap.get(i.getName()).getRetrievalType());
|
|
|
- retrievalMapping.setGmtModified(now);
|
|
|
- retrievalMapping.setModifier(userId);
|
|
|
- retrievalMapping.setIsDeleted(IsDeleteEnum.N.getKey());
|
|
|
- addOrUpdateRetrievalMappings.add(retrievalMapping);
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+ retrievals.forEach(i -> {
|
|
|
+ RetrievalMapping retrievalMapping = retrievalMappingMap.get(i.getId());
|
|
|
+ AddTagRetrievalDetailVO detail = detailMap.get(i.getName());
|
|
|
+ if (retrievalMapping == null) {
|
|
|
+ retrievalMapping = new RetrievalMapping();
|
|
|
+ retrievalMapping.setQuestionId(addTagRetrievalVO.getQuestionId());
|
|
|
+ retrievalMapping.setRetrievalId(i.getId());
|
|
|
+ retrievalMapping.setGmtCreate(now);
|
|
|
+ retrievalMapping.setGmtModified(now);
|
|
|
+ retrievalMapping.setCreator(userId);
|
|
|
+ retrievalMapping.setModifier(userId);
|
|
|
+ retrievalMapping.setShowType(detail.getRetrievalType());
|
|
|
+ addOrUpdateRetrievalMappings.add(retrievalMapping);
|
|
|
+ } else {
|
|
|
+ if (detail.getRetrievalType() != retrievalMapping.getShowType()
|
|
|
+ || retrievalMapping.getIsDeleted().equals(IsDeleteEnum.Y.getKey())) {
|
|
|
+ retrievalMapping.setShowType(detailMap.get(i.getName()).getRetrievalType());
|
|
|
+ retrievalMapping.setGmtModified(now);
|
|
|
+ retrievalMapping.setModifier(userId);
|
|
|
+ retrievalMapping.setIsDeleted(IsDeleteEnum.N.getKey());
|
|
|
+ addOrUpdateRetrievalMappings.add(retrievalMapping);
|
|
|
+ }
|
|
|
+ }
|
|
|
});
|
|
|
-
|
|
|
- retrievalMappingFacade.saveOrUpdateBatch(addOrUpdateRetrievalMappings);
|
|
|
+
|
|
|
+ retrievalMappingFacade.saveOrUpdateBatch(addOrUpdateRetrievalMappings);
|
|
|
|
|
|
return true;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
- * 获取标签同义词列表
|
|
|
- * @param retrievalListVO
|
|
|
- * @return
|
|
|
- */
|
|
|
+ * 获取标签同义词列表
|
|
|
+ *
|
|
|
+ * @param retrievalListVO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public IPage<RetrievalListDTO> retrievalList(RetrievalListVO retrievalListVO) {
|
|
|
IPage<RetrievalListDTO> ipage = this.getRetrievalList(retrievalListVO);
|
|
|
-
|
|
|
+
|
|
|
List<RetrievalListDTO> retrievalListDTOList = ipage.getRecords();
|
|
|
- if(retrievalListDTOList.size()==0){
|
|
|
- return ipage;
|
|
|
+ if (retrievalListDTOList.size() == 0) {
|
|
|
+ return ipage;
|
|
|
}
|
|
|
-
|
|
|
- List<Long> questionIds = retrievalListDTOList.stream().map(i->i.getQuestionId()).collect(Collectors.toList());
|
|
|
-
|
|
|
+
|
|
|
+ List<Long> questionIds = retrievalListDTOList.stream().map(i -> i.getQuestionId()).collect(Collectors.toList());
|
|
|
+
|
|
|
QueryWrapper<RetrievalMapping> retrievalMappingQe = new QueryWrapper<RetrievalMapping>();
|
|
|
retrievalMappingQe.in("question_id", questionIds);
|
|
|
List<RetrievalMapping> retrievalMappings = retrievalMappingFacade.list(retrievalMappingQe);
|
|
|
- Map<Long,List<RetrievalMapping>> retrievalMappingListMap = retrievalMappings.stream().collect(Collectors.groupingBy(RetrievalMapping::getQuestionId));
|
|
|
-
|
|
|
- List<Long> retrievalIds = retrievalMappings.stream().map(i->i.getRetrievalId()).distinct().collect(Collectors.toList());
|
|
|
- Map<Long,Retrieval> retrievalMap = this.listByIds(retrievalIds).stream().filter(i->i.getIsDeleted().equals("N")).collect(Collectors.toMap(Retrieval::getId,i->i));
|
|
|
-
|
|
|
- retrievalListDTOList.forEach(retrievalListDTO->{
|
|
|
- List<RetrievalMapping> retrievalMappingList = retrievalMappingListMap.get(retrievalListDTO.getQuestionId());
|
|
|
- retrievalMappingList = retrievalMappingList.stream().filter(i->retrievalMap.get(i.getRetrievalId())==null).sorted((t1,t2)->t2.getGmtModified().compareTo(t1.getGmtModified())).collect(Collectors.toList());
|
|
|
- retrievalListDTO.setOperatorName(retrievalMappingList.get(0).getModifier());
|
|
|
- retrievalListDTO.setRetrievalSelfName(retrievalMappingList.stream().filter(i->i.getShowType()==1&&i.getIsDeleted().equals("N")).map(i->retrievalMap.get(i.getRetrievalId()).getName()).collect(Collectors.joining()));
|
|
|
- retrievalListDTO.setRetrievalNames(retrievalMappingList.stream().filter(i->i.getShowType()==2&&i.getIsDeleted().equals("N")).map(i->retrievalMap.get(i.getRetrievalId()).getName()).collect(Collectors.joining()));
|
|
|
- retrievalListDTO.setRetrievalSonNames(retrievalMappingList.stream().filter(i->i.getShowType()==3&&i.getIsDeleted().equals("N")).map(i->retrievalMap.get(i.getRetrievalId()).getName()).collect(Collectors.joining()));
|
|
|
+ Map<Long, List<RetrievalMapping>> retrievalMappingListMap = retrievalMappings.stream().collect(Collectors.groupingBy(RetrievalMapping::getQuestionId));
|
|
|
+
|
|
|
+ List<Long> retrievalIds = retrievalMappings.stream().map(i -> i.getRetrievalId()).distinct().collect(Collectors.toList());
|
|
|
+ Map<Long, Retrieval> retrievalMap = this.listByIds(retrievalIds).stream().filter(i -> i.getIsDeleted().equals("N")).collect(Collectors.toMap(Retrieval::getId, i -> i));
|
|
|
+
|
|
|
+ retrievalListDTOList.forEach(retrievalListDTO -> {
|
|
|
+ List<RetrievalMapping> retrievalMappingList = retrievalMappingListMap.get(retrievalListDTO.getQuestionId());
|
|
|
+ retrievalMappingList = retrievalMappingList.stream().filter(i -> retrievalMap.get(i.getRetrievalId()) == null).sorted((t1, t2) -> t2.getGmtModified().compareTo(t1.getGmtModified())).collect(Collectors.toList());
|
|
|
+ retrievalListDTO.setOperatorName(retrievalMappingList.get(0).getModifier());
|
|
|
+ retrievalListDTO.setRetrievalSelfName(retrievalMappingList.stream().filter(i -> i.getShowType() == 1 && i.getIsDeleted().equals("N")).map(i -> retrievalMap.get(i.getRetrievalId()).getName()).collect(Collectors.joining()));
|
|
|
+ retrievalListDTO.setRetrievalNames(retrievalMappingList.stream().filter(i -> i.getShowType() == 2 && i.getIsDeleted().equals("N")).map(i -> retrievalMap.get(i.getRetrievalId()).getName()).collect(Collectors.joining()));
|
|
|
+ retrievalListDTO.setRetrievalSonNames(retrievalMappingList.stream().filter(i -> i.getShowType() == 3 && i.getIsDeleted().equals("N")).map(i -> retrievalMap.get(i.getRetrievalId()).getName()).collect(Collectors.joining()));
|
|
|
});
|
|
|
-
|
|
|
- List<String> ids = retrievalListDTOList.stream().map(i->i.getOperatorName()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<String> ids = retrievalListDTOList.stream().map(i -> i.getOperatorName()).collect(Collectors.toList());
|
|
|
RespDTO<Map<String, String>> respDTO = userServiceClient.getUserInfoByIds(ids);
|
|
|
if (respDTO == null || !CommonErrorCode.OK.getCode().equals(respDTO.code)) {
|
|
|
throw new CommonException(CommonErrorCode.RPC_ERROR,
|
|
|
"获取用户信息失败");
|
|
|
}
|
|
|
-
|
|
|
- retrievalListDTOList.forEach(i->i.setOperatorName(respDTO.data.get(i.getOperatorName())));
|
|
|
+
|
|
|
+ retrievalListDTOList.forEach(i -> i.setOperatorName(respDTO.data.get(i.getOperatorName())));
|
|
|
ipage.setRecords(retrievalListDTOList);
|
|
|
return ipage;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* 同义词excel文件导入
|
|
|
+ *
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
|
- public RetrievalExcelImDTO retrievalExcelIm(MultipartFile file){
|
|
|
- List<AddTagRetrievalVO> addTagRetrievalVOList = new ArrayList<>();
|
|
|
- List<String> messages = new ArrayList<>();
|
|
|
- InputStream inputStream = null;
|
|
|
+ public RetrievalExcelImDTO retrievalExcelIm(MultipartFile file) {
|
|
|
+ List<AddTagRetrievalVO> addTagRetrievalVOList = new ArrayList<>();
|
|
|
+ List<String> messages = new ArrayList<>();
|
|
|
+ InputStream inputStream = null;
|
|
|
Workbook wb = null;
|
|
|
- try{
|
|
|
- if(!file.isEmpty()){
|
|
|
- inputStream = file.getInputStream();
|
|
|
- if(inputStream.available() > 512000){
|
|
|
+ try {
|
|
|
+ if (!file.isEmpty()) {
|
|
|
+ inputStream = file.getInputStream();
|
|
|
+ if (inputStream.available() > 512000) {
|
|
|
messages.add("文件最大支持500KB!");
|
|
|
- }else{
|
|
|
- String fileName = file.getOriginalFilename();
|
|
|
- if(fileName.lastIndexOf(".") != -1){
|
|
|
- String type = fileName.substring(fileName.lastIndexOf("."));
|
|
|
+ } else {
|
|
|
+ String fileName = file.getOriginalFilename();
|
|
|
+ if (fileName.lastIndexOf(".") != -1) {
|
|
|
+ String type = fileName.substring(fileName.lastIndexOf("."));
|
|
|
if (type.equals(".xls")) {
|
|
|
wb = new HSSFWorkbook(inputStream);
|
|
|
} else if (type.equals(".xlsx")) {
|
|
|
wb = new XSSFWorkbook(inputStream);
|
|
|
}
|
|
|
- if(wb!=null){
|
|
|
- List<AddTagRetrievalDetailVO> detailList = new ArrayList<>();
|
|
|
- Sheet sheet = wb.getSheetAt(0);
|
|
|
+ if (wb != null) {
|
|
|
+ List<AddTagRetrievalDetailVO> detailList = new ArrayList<>();
|
|
|
+ Sheet sheet = wb.getSheetAt(0);
|
|
|
int count = 0;
|
|
|
- String questionName,retrievalName,retrievalSpell,retrievalType;
|
|
|
- for(Row row : sheet){
|
|
|
- count++;
|
|
|
- if (count == 1||row==null) {
|
|
|
- continue;
|
|
|
+ String questionName, retrievalName, retrievalSpell, retrievalType;
|
|
|
+ for (Row row : sheet) {
|
|
|
+ count++;
|
|
|
+ if (count == 1 || row == null) {
|
|
|
+ continue;
|
|
|
}
|
|
|
- questionName = getValue(row.getCell(0)).trim().replace(" ", "");
|
|
|
+ questionName = getValue(row.getCell(0)).trim().replace(" ", "");
|
|
|
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)){
|
|
|
- messages.add("第"+count+"行数据不完整!");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- AddTagRetrievalDetailVO addTagRetrievalDetailVO = new AddTagRetrievalDetailVO();
|
|
|
- addTagRetrievalDetailVO.setQuestionName(questionName);
|
|
|
- addTagRetrievalDetailVO.setRetrievalName(retrievalName);
|
|
|
- addTagRetrievalDetailVO.setRetrievalSpell(retrievalSpell);
|
|
|
- addTagRetrievalDetailVO.setRetrievalType(Integer.parseInt(retrievalType));
|
|
|
- detailList.add(addTagRetrievalDetailVO);
|
|
|
+ if (StringUtil.isEmpty(questionName) || StringUtil.isEmpty(retrievalName)
|
|
|
+ || StringUtil.isEmpty(retrievalSpell) || StringUtil.isEmpty(retrievalType)) {
|
|
|
+ messages.add("第" + count + "行数据不完整!");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ AddTagRetrievalDetailVO addTagRetrievalDetailVO = new AddTagRetrievalDetailVO();
|
|
|
+ addTagRetrievalDetailVO.setQuestionName(questionName);
|
|
|
+ addTagRetrievalDetailVO.setRetrievalName(retrievalName);
|
|
|
+ addTagRetrievalDetailVO.setRetrievalSpell(retrievalSpell);
|
|
|
+ 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);
|
|
|
+
|
|
|
+ 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{
|
|
|
- messages.add("非excel文件无法解析!");
|
|
|
+ } else {
|
|
|
+ messages.add("非excel文件无法解析!");
|
|
|
}
|
|
|
- }else{
|
|
|
- messages.add("未知文件无法解析!");
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ messages.add("未知文件无法解析!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ messages.add("无文件上传!");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ messages.add("解析失败!");
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (wb != null) {
|
|
|
+ wb.close();
|
|
|
+ }
|
|
|
+ if (inputStream != null) {
|
|
|
+ inputStream.close();
|
|
|
}
|
|
|
- }else{
|
|
|
- messages.add("无文件上传!");
|
|
|
- }
|
|
|
- }catch(Exception e){
|
|
|
- messages.add("解析失败!");
|
|
|
- }finally{
|
|
|
- try{
|
|
|
- if(wb!=null){
|
|
|
- wb.close();
|
|
|
- }
|
|
|
- if(inputStream!=null){
|
|
|
- inputStream.close();
|
|
|
- }
|
|
|
- }catch(Exception e){
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- addTagRetrievalVOList.forEach(i->{
|
|
|
- addTagRetrieval(i);
|
|
|
- });
|
|
|
-
|
|
|
- RetrievalExcelImDTO retrievalExcelImDTO = new RetrievalExcelImDTO();
|
|
|
- retrievalExcelImDTO.setMessages(messages);
|
|
|
- return null;
|
|
|
+ } catch (Exception e) {
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ addTagRetrievalVOList.forEach(i -> {
|
|
|
+ addTagRetrieval(i);
|
|
|
+ });
|
|
|
+
|
|
|
+ RetrievalExcelImDTO retrievalExcelImDTO = new RetrievalExcelImDTO();
|
|
|
+ retrievalExcelImDTO.setMessages(messages);
|
|
|
+ return null;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@SuppressWarnings("deprecation")
|
|
|
- private String getValue(Cell cell) {
|
|
|
+ private String getValue(Cell cell) {
|
|
|
try {
|
|
|
Object obj = null;
|
|
|
switch (cell.getCellTypeEnum()) {
|