|
|
|
@ -5,12 +5,14 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.jeecg.common.constant.OcrConstant;
|
|
|
|
|
import org.jeecg.common.system.vo.DictModel;
|
|
|
|
|
import org.jeecg.common.util.RedisUtil;
|
|
|
|
|
import org.jeecg.common.util.RestUtil;
|
|
|
|
|
import org.jeecg.modules.ocr.entity.OcrIdentify;
|
|
|
|
|
import org.jeecg.modules.ocr.model.TaskModel;
|
|
|
|
|
import org.jeecg.modules.ocr.service.IOcrIdentifyService;
|
|
|
|
|
import org.jeecg.modules.ocr.service.impl.TaskService;
|
|
|
|
|
import org.jeecg.modules.system.service.ISysDictService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.boot.ApplicationArguments;
|
|
|
|
|
import org.springframework.boot.ApplicationRunner;
|
|
|
|
@ -39,6 +41,8 @@ public class HandleCallbacklnit implements ApplicationRunner {
|
|
|
|
|
TaskService taskService;
|
|
|
|
|
@Resource
|
|
|
|
|
IOcrIdentifyService ocrIdentifyService;
|
|
|
|
|
@Resource
|
|
|
|
|
ISysDictService sysDictService;
|
|
|
|
|
@Value("${system.project.enableHandleTask}")
|
|
|
|
|
private boolean enableHandleTask;
|
|
|
|
|
/**
|
|
|
|
@ -49,11 +53,20 @@ public class HandleCallbacklnit implements ApplicationRunner {
|
|
|
|
|
@Async
|
|
|
|
|
public void run(ApplicationArguments args) throws UnknownHostException {
|
|
|
|
|
if (false) {
|
|
|
|
|
List<DictModel> callbackApiConfigs = sysDictService.queryDictItemsByCode("callback_api_config");
|
|
|
|
|
Integer autoPushNoticeMaxNum=10;//自动请求最大次数.
|
|
|
|
|
Integer pushTimeJoin=30;//请求间隔时间.秒
|
|
|
|
|
Integer pushTimeInterval=30;//请求间隔时间.秒
|
|
|
|
|
for (DictModel callbackApiConfig : callbackApiConfigs) {
|
|
|
|
|
if (callbackApiConfig.getText().equals("pushTimeInterval") && StringUtils.isNumeric(callbackApiConfig.getValue())) {
|
|
|
|
|
pushTimeInterval = Integer.valueOf(callbackApiConfig.getValue());
|
|
|
|
|
}else if (callbackApiConfig.getText().equals("autoPushNoticeMaxNum") && StringUtils.isNumeric(callbackApiConfig.getValue())) {
|
|
|
|
|
autoPushNoticeMaxNum = Integer.valueOf(callbackApiConfig.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (true){
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(pushTimeJoin*1000);
|
|
|
|
|
Thread.sleep(pushTimeInterval*1000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
@ -61,11 +74,21 @@ public class HandleCallbacklnit implements ApplicationRunner {
|
|
|
|
|
for (OcrIdentify ocrIdentify : ocrIdentifyList) {
|
|
|
|
|
ocrIdentifyService.callbackWly(ocrIdentify.getId());
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(pushTimeJoin*1000);
|
|
|
|
|
Thread.sleep(pushTimeInterval*1000);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
///TODO 优化下代码,重复执行了这段 获取请求时间间隔的代码了。
|
|
|
|
|
callbackApiConfigs = sysDictService.queryDictItemsByCode("callback_api_config");
|
|
|
|
|
for (DictModel callbackApiConfig : callbackApiConfigs) {
|
|
|
|
|
if (callbackApiConfig.getText().equals("pushTimeInterval") && StringUtils.isNumeric(callbackApiConfig.getValue())) {
|
|
|
|
|
pushTimeInterval = Integer.valueOf(callbackApiConfig.getValue());
|
|
|
|
|
}else if (callbackApiConfig.getText().equals("autoPushNoticeMaxNum") && StringUtils.isNumeric(callbackApiConfig.getValue())) {
|
|
|
|
|
autoPushNoticeMaxNum = Integer.valueOf(callbackApiConfig.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*if (enableHandleTask) {
|
|
|
|
|