|
|
@ -97,15 +97,9 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { |
|
|
|
return response; |
|
|
|
return response; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
String getSendUrl(ZhipuAnalysisFileRequest request) { |
|
|
|
public String getSendUrl(ZhipuAnalysisFileRequest request) { |
|
|
|
if (StringUtil.isNotBlank(request.getUrl())) { |
|
|
|
if (StringUtil.isNotBlank(request.getUrl())) { |
|
|
|
String base64 = null; |
|
|
|
return getBase64FromUrl(request.getUrl()); |
|
|
|
try { |
|
|
|
|
|
|
|
base64 = FileUtil.getBase64(FileUtil.getUrlByteByRequest(request.getUrl())); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.info("get base64 error", e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return StringUtil.isBlank(base64) ? request.getUrl() : base64; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()), () -> { |
|
|
|
Assert.isTrue(StringUtil.isNotBlank(request.getFilePath()), () -> { |
|
|
|
throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); |
|
|
|
throw ErrorCode.GET_FILE_CONTENT_FAILURE.throwException(); |
|
|
@ -117,6 +111,16 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getBase64FromUrl(String url) { |
|
|
|
|
|
|
|
String base64 = null; |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
base64 = FileUtil.getBase64(FileUtil.getUrlByteByRequest(url)); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.info("get base64 error", e); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return StringUtil.isBlank(base64) ? url : base64; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request) { |
|
|
|
public ZhipuAnalysisInfoEntity getAnalysisInfo(ZhipuAnalysisFileRequest request) { |
|
|
|
ZhipuAnalysisInfoEntity result = null; |
|
|
|
ZhipuAnalysisInfoEntity result = null; |
|
|
@ -151,7 +155,7 @@ public class ZhipuAnalysisServiceImpl implements ZhipuAnalysisService { |
|
|
|
ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(infoList.get(0).getModel()); |
|
|
|
ZhipuAnalyser analyser = analysisFactory.getAnalysisStrategy(infoList.get(0).getModel()); |
|
|
|
|
|
|
|
|
|
|
|
String text = getMultiAnalyserText(infoList); |
|
|
|
String text = getMultiAnalyserText(infoList); |
|
|
|
Map<String, Object> resultMap = analyser.getResultMap(text, request.getUrl()); |
|
|
|
Map<String, Object> resultMap = analyser.getResultMap(text, getBase64FromUrl(request.getUrl())); |
|
|
|
|
|
|
|
|
|
|
|
if (null == resultMap) { |
|
|
|
if (null == resultMap) { |
|
|
|
response.setCode(ResultCode.FAILURE.getCode()); |
|
|
|
response.setCode(ResultCode.FAILURE.getCode()); |
|
|
|