|
@@ -7,7 +7,7 @@ import com.qmth.boot.tools.io.FileUtils;
|
|
|
import com.qmth.ops.biz.ai.client.DocApiClient;
|
|
|
import com.qmth.ops.biz.ai.client.DocApiConfig;
|
|
|
import com.qmth.ops.biz.ai.exception.DocClientNotFound;
|
|
|
-import com.qmth.ops.biz.domain.OcrSupplier;
|
|
|
+import com.qmth.ops.biz.domain.DocSupplier;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -27,19 +27,19 @@ public class DocClientService {
|
|
|
private Map<Long, DocApiClient> clientMap;
|
|
|
|
|
|
@Resource
|
|
|
- private OcrSupplierService ocrSupplierService;
|
|
|
+ private DocSupplierService docSupplierService;
|
|
|
|
|
|
public synchronized void init() {
|
|
|
defaultClient = null;
|
|
|
clientMap = new HashMap<>();
|
|
|
|
|
|
- List<OcrSupplier> list = ocrSupplierService.list();
|
|
|
- for (OcrSupplier supplier : list) {
|
|
|
+ List<DocSupplier> list = docSupplierService.list();
|
|
|
+ for (DocSupplier supplier : list) {
|
|
|
initApiClient(supplier);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void initApiClient(OcrSupplier supplier) {
|
|
|
+ private void initApiClient(DocSupplier supplier) {
|
|
|
try {
|
|
|
String className = DocApiClient.class.getName().replace(DocApiClient.class.getSimpleName(), supplier.getClientClass());
|
|
|
DocApiConfig config = new DocApiConfig(supplier);
|
|
@@ -51,7 +51,7 @@ public class DocClientService {
|
|
|
clientMap.put(supplier.getId(), client);
|
|
|
|
|
|
// 取第一个enable=true的为默认客户端
|
|
|
- if (defaultClient == null) {
|
|
|
+ if (supplier.getEnable() && defaultClient == null) {
|
|
|
defaultClient = client;
|
|
|
}
|
|
|
}
|
|
@@ -67,7 +67,7 @@ public class DocClientService {
|
|
|
|
|
|
String fileSuffix = FileUtils.getFileSuffix(fileName);
|
|
|
if (!FileUtils.matchSuffix("(.txt|.pdf|.doc|.docx|.xls|.xlsx|.ppt|.pptx)$", fileSuffix)) {
|
|
|
- throw new StatusException(fileName + "暂不支持该文件类型");
|
|
|
+ throw new StatusException("暂不支持文件类型" + fileSuffix);
|
|
|
}
|
|
|
|
|
|
return defaultClient.parseDocTask(fileData, fileName);
|