修改配置
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
package com.ruoyi.hrm.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 发票OCR服务配置
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "fad.ocr")
|
||||
public class HrmOcrProperties {
|
||||
|
||||
/** OCR服务地址,如 http://127.0.0.1:8000 */
|
||||
private String url = "http://127.0.0.1:8000";
|
||||
|
||||
/** OCR服务 API Key */
|
||||
private String apiKey = "";
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONArray;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.hrm.config.HrmOcrProperties;
|
||||
import com.ruoyi.hrm.domain.vo.HrmInvoiceOcrResultVo;
|
||||
import com.ruoyi.hrm.service.IHrmInvoiceOcrService;
|
||||
import com.ruoyi.oss.factory.OssFactory;
|
||||
@@ -14,6 +13,7 @@ import com.ruoyi.system.domain.vo.SysOssVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -34,7 +34,14 @@ import java.util.List;
|
||||
@Service
|
||||
public class HrmInvoiceOcrServiceImpl implements IHrmInvoiceOcrService {
|
||||
|
||||
private final HrmOcrProperties ocrProperties;
|
||||
|
||||
|
||||
@Value("${fad.ocr.url}")
|
||||
String ocrUrl;
|
||||
|
||||
@Value("${fad.ocr.api-key}")
|
||||
String apiKey;
|
||||
|
||||
private final SysOssMapper sysOssMapper;
|
||||
|
||||
@Override
|
||||
@@ -56,8 +63,6 @@ public class HrmInvoiceOcrServiceImpl implements IHrmInvoiceOcrService {
|
||||
}
|
||||
|
||||
private HrmInvoiceOcrResultVo callOcrService(byte[] fileBytes, String fileName, String fileSuffix) {
|
||||
String ocrUrl = ocrProperties.getUrl();
|
||||
String apiKey = ocrProperties.getApiKey();
|
||||
|
||||
if (StringUtils.isBlank(ocrUrl)) {
|
||||
throw new ServiceException("OCR服务地址未配置,请检查 fad.ocr.url");
|
||||
@@ -195,7 +200,7 @@ public class HrmInvoiceOcrServiceImpl implements IHrmInvoiceOcrService {
|
||||
|
||||
@Override
|
||||
public boolean isAlive() {
|
||||
String ocrUrl = ocrProperties.getUrl();
|
||||
|
||||
if (StringUtils.isBlank(ocrUrl)) return false;
|
||||
try {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
Reference in New Issue
Block a user