|
|
|
@ -78,7 +78,7 @@ public class QueryTemplateProcessorImpl implements QueryTemplateProcessor {
|
|
|
|
|
Set<String> sessionParamsNames = sessionParams.stream().filter(param->StrUtil.isNotEmpty(param.getParamValue())).map(IrSessionParam::getParamName).collect(Collectors.toSet());
|
|
|
|
|
paramsList.stream().filter(param -> Integer.valueOf(1).equals(param.getParamRequire())).forEach(param -> {
|
|
|
|
|
queryProcessDTO.notNullParam(param.getParamName(),
|
|
|
|
|
sessionParamsNames.contains(param.getParamName())? true : null, "参数[" + param.getParamName() + "]未设置!");
|
|
|
|
|
sessionParamsNames.contains(param.getParamName())? true : null, param.getParamDesc());
|
|
|
|
|
});
|
|
|
|
|
if (Integer.valueOf(1).equals(queryProcessDTO.getState())) {
|
|
|
|
|
// 参数校验不通过,返回结果
|
|
|
|
@ -90,20 +90,20 @@ public class QueryTemplateProcessorImpl implements QueryTemplateProcessor {
|
|
|
|
|
try {
|
|
|
|
|
if (Integer.valueOf(4).equals(knowledge.getResultType())){
|
|
|
|
|
Map<String, Object> params = getParams(paramsList, sessionParams);
|
|
|
|
|
// todo:测试使用
|
|
|
|
|
String path = localArchivesFilePath(rootPath, MapUtil.getStr(params, "ajid"),
|
|
|
|
|
MapUtil.getStr(params, "khrzjhm"),MapUtil.getStr(params, "khrmc"));
|
|
|
|
|
|
|
|
|
|
File tempFile = FileUtil.createTempFile();
|
|
|
|
|
generateZip(tempFile, FileUtil.loopFiles(path), true);
|
|
|
|
|
Map<String, Object> stringHashMap = new HashMap<>();
|
|
|
|
|
stringHashMap.put("fileContent", tempFile);
|
|
|
|
|
maps = CollUtil.toList(stringHashMap);
|
|
|
|
|
if (Objects.nonNull(path)){
|
|
|
|
|
File tempFile = FileUtil.createTempFile();
|
|
|
|
|
generateZip(tempFile, FileUtil.loopFiles(path), true);
|
|
|
|
|
Map<String, Object> stringHashMap = new HashMap<>();
|
|
|
|
|
stringHashMap.put("fileContent", tempFile);
|
|
|
|
|
maps = CollUtil.toList(stringHashMap);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
maps = rowSqlMapper.selectList(knowledge.getSqlTemplate(), getParams(paramsList, sessionParams));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("执行查询sql失败", e);
|
|
|
|
|
log.error("获取数据失败", e);
|
|
|
|
|
queryProcessDTO.setState(2);
|
|
|
|
|
return queryProcessDTO;
|
|
|
|
|
}
|
|
|
|
@ -123,9 +123,39 @@ public class QueryTemplateProcessorImpl implements QueryTemplateProcessor {
|
|
|
|
|
|
|
|
|
|
private void wrapperSqlResult(IrKnowledge knowledge, List<Map<String, Object>> maps, QueryProcessDTO queryProcessDTO) {
|
|
|
|
|
|
|
|
|
|
// 先处理文件类型的数据,如果文件为空,则修改处理类型位文本
|
|
|
|
|
if (Integer.valueOf(3).equals(knowledge.getResultType())) {
|
|
|
|
|
// 如果存在byte类型的数据,数据key统一命名为 byteContent
|
|
|
|
|
queryProcessDTO.setContentType(3);
|
|
|
|
|
Map<String, Object> resultMap = CollUtil.getFirst(maps);
|
|
|
|
|
if (CollUtil.isNotEmpty(resultMap)){
|
|
|
|
|
queryProcessDTO.setByteContent((byte[]) CollUtil.getFirst(maps).get("byte_content"));
|
|
|
|
|
}else {
|
|
|
|
|
knowledge.setResultType(1);
|
|
|
|
|
queryProcessDTO.setByteContent(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Integer.valueOf(4).equals(knowledge.getResultType())){
|
|
|
|
|
queryProcessDTO.setStringContent(knowledge.getResultTemplate());
|
|
|
|
|
if (CollUtil.isNotEmpty(CollUtil.getFirst(maps))){
|
|
|
|
|
queryProcessDTO.setFileContent((File) CollUtil.getFirst(maps).get("fileContent"));
|
|
|
|
|
}
|
|
|
|
|
queryProcessDTO.setContentType(6);
|
|
|
|
|
try {
|
|
|
|
|
String process = StringTemplateConfig.getInstance().process(knowledge.getResultTemplate(),
|
|
|
|
|
Objects.isNull(CollUtil.getFirst(maps)) ? new HashMap<>() : CollUtil.getFirst(maps));
|
|
|
|
|
queryProcessDTO.setStringContent(process);
|
|
|
|
|
} catch (IOException | TemplateException e) {
|
|
|
|
|
log.error("执行结果模板失败", e);
|
|
|
|
|
queryProcessDTO.setState(2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Integer.valueOf(1).equals(knowledge.getResultType())) {
|
|
|
|
|
try {
|
|
|
|
|
String process = StringTemplateConfig.getInstance().process(knowledge.getResultTemplate(), CollUtil.getFirst(maps));
|
|
|
|
|
String process = StringTemplateConfig.getInstance().process(knowledge.getResultTemplate(),
|
|
|
|
|
Objects.isNull(CollUtil.getFirst(maps)) ? new HashMap<>() : CollUtil.getFirst(maps));
|
|
|
|
|
queryProcessDTO.setStringContent(process);
|
|
|
|
|
queryProcessDTO.setContentType(1);
|
|
|
|
|
} catch (IOException | TemplateException e) {
|
|
|
|
@ -144,18 +174,6 @@ public class QueryTemplateProcessorImpl implements QueryTemplateProcessor {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Integer.valueOf(3).equals(knowledge.getResultType())) {
|
|
|
|
|
// 如果存在byte类型的数据,数据key统一命名为 byteContent
|
|
|
|
|
queryProcessDTO.setByteContent((byte[]) CollUtil.getFirst(maps).get("byteContent"));
|
|
|
|
|
queryProcessDTO.setContentType(3);
|
|
|
|
|
queryProcessDTO.setByteContentId(CollUtil.getFirst(maps).get("byteContentId").toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (Integer.valueOf(4).equals(knowledge.getResultType())){
|
|
|
|
|
queryProcessDTO.setStringContent(knowledge.getResultTemplate());
|
|
|
|
|
queryProcessDTO.setFileContent((File) CollUtil.getFirst(maps).get("fileContent"));
|
|
|
|
|
queryProcessDTO.setContentType(6);
|
|
|
|
|
}
|
|
|
|
|
// 去除回响应字符串中的特殊字符
|
|
|
|
|
if (StrUtil.isNotEmpty(queryProcessDTO.getStringContent())){
|
|
|
|
|
queryProcessDTO.setStringContent(StrUtil.cleanBlank(queryProcessDTO.getStringContent()));
|
|
|
|
|