|
|
|
@ -14,6 +14,7 @@ import com.project.information.domain.service.InformationBaseService; |
|
|
|
import com.project.information.domain.service.KnowledgePointBaseService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.core.io.ByteArrayResource; |
|
|
|
@ -66,6 +67,8 @@ public class KnowledgePointApplicationServiceImpl implements KnowledgePointAppli |
|
|
|
uploadToPython(fileMap.get(id),id); |
|
|
|
} catch (Exception e) { |
|
|
|
log.error("文件解析失败:{}", fileMap.get(id).getOriginalFilename(), e); |
|
|
|
//更新资料状态
|
|
|
|
updateStatuInformation(null,InformationParseStatusEnum.Fail.getValue(),id); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -95,17 +98,17 @@ public class KnowledgePointApplicationServiceImpl implements KnowledgePointAppli |
|
|
|
ResponseEntity<String> response = |
|
|
|
restTemplate.postForEntity("http://"+analysisHost+":"+analysisPort+analysisUrl, requestEntity, String.class); |
|
|
|
|
|
|
|
log.info("文件 [{}] 解析完成,返回结果:{}", file.getOriginalFilename(), response.getBody()); |
|
|
|
log.info("文件 [{}] 解析请求成功,返回结果:{}", file.getOriginalFilename(), response.getBody()); |
|
|
|
|
|
|
|
List<KnowledgePointEntity> knowledgePointEntities = parseAnalysisResponse(response,id); |
|
|
|
if(!CollectionUtils.isEmpty(knowledgePointEntities)){ |
|
|
|
knowledgePointBaseService.saveBatch(knowledgePointEntities); |
|
|
|
//向资料中冗余pareName字段值
|
|
|
|
InformationEntity informationEntity = new InformationEntity(); |
|
|
|
informationEntity.setId(id); |
|
|
|
informationEntity.setParseStatus(InformationParseStatusEnum.Success.getValue()); |
|
|
|
informationEntity.setParseName(knowledgePointEntities.get(0).getParseName()); |
|
|
|
informationBaseService.updateById(informationEntity); |
|
|
|
//更新状态
|
|
|
|
updateStatuInformation(knowledgePointEntities.get(0).getParseName(),InformationParseStatusEnum.Success.getValue(),id); |
|
|
|
}else{ |
|
|
|
log.error("获取知识点失败:{}", "不存在知识点"); |
|
|
|
//更新状态
|
|
|
|
updateStatuInformation(null,InformationParseStatusEnum.Fail.getValue(),id); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -132,7 +135,6 @@ public class KnowledgePointApplicationServiceImpl implements KnowledgePointAppli |
|
|
|
if (dataObj instanceof List && ObjectUtils.isNotEmpty(dataObj)) { |
|
|
|
data = (List<Map<String, Object>>) dataObj; |
|
|
|
}else{ |
|
|
|
log.error("文件解析失败"); |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -172,4 +174,17 @@ public class KnowledgePointApplicationServiceImpl implements KnowledgePointAppli |
|
|
|
return entity; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更新文件解析状态 |
|
|
|
*/ |
|
|
|
private void updateStatuInformation(String pareName,Integer status,Long id){ |
|
|
|
InformationEntity informationEntity = new InformationEntity(); |
|
|
|
informationEntity.setId(id); |
|
|
|
if (StringUtils.isNotBlank(pareName)){ |
|
|
|
informationEntity.setParseName(pareName); |
|
|
|
} |
|
|
|
informationEntity.setParseStatus(status); |
|
|
|
informationBaseService.updateById(informationEntity); |
|
|
|
} |
|
|
|
} |
|
|
|
|