master
周文涛 2 years ago
parent ed168416ac
commit 6c37ad5f23

@ -120,9 +120,6 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
if (StringUtils.isNotBlank(record.getTaskResultInfo())) { if (StringUtils.isNotBlank(record.getTaskResultInfo())) {
List<OcrResult2> ocrResult2s = JSONObject.parseArray(record.getTaskResultInfo()).toJavaList(OcrResult2.class); List<OcrResult2> ocrResult2s = JSONObject.parseArray(record.getTaskResultInfo()).toJavaList(OcrResult2.class);
int tagNum = ocrResult2s.size(); int tagNum = ocrResult2s.size();
if (tagNum==0) {
System.out.print("");
}
int successNum = (int) ocrResult2s.stream().filter(o -> o.getRuleValidation()).count(); int successNum = (int) ocrResult2s.stream().filter(o -> o.getRuleValidation()).count();
record.setTagNum(tagNum); record.setTagNum(tagNum);
record.setTagSuccessNum(successNum); record.setTagSuccessNum(successNum);

@ -5,12 +5,14 @@ import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.constant.OcrConstant; import org.jeecg.common.constant.OcrConstant;
import org.jeecg.common.system.vo.DictModel;
import org.jeecg.common.util.RedisUtil; import org.jeecg.common.util.RedisUtil;
import org.jeecg.common.util.RestUtil; import org.jeecg.common.util.RestUtil;
import org.jeecg.modules.ocr.entity.OcrIdentify; import org.jeecg.modules.ocr.entity.OcrIdentify;
import org.jeecg.modules.ocr.model.TaskModel; import org.jeecg.modules.ocr.model.TaskModel;
import org.jeecg.modules.ocr.service.IOcrIdentifyService; import org.jeecg.modules.ocr.service.IOcrIdentifyService;
import org.jeecg.modules.ocr.service.impl.TaskService; 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.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
@ -39,6 +41,8 @@ public class HandleCallbacklnit implements ApplicationRunner {
TaskService taskService; TaskService taskService;
@Resource @Resource
IOcrIdentifyService ocrIdentifyService; IOcrIdentifyService ocrIdentifyService;
@Resource
ISysDictService sysDictService;
@Value("${system.project.enableHandleTask}") @Value("${system.project.enableHandleTask}")
private boolean enableHandleTask; private boolean enableHandleTask;
/** /**
@ -49,11 +53,20 @@ public class HandleCallbacklnit implements ApplicationRunner {
@Async @Async
public void run(ApplicationArguments args) throws UnknownHostException { public void run(ApplicationArguments args) throws UnknownHostException {
if (false) { if (false) {
List<DictModel> callbackApiConfigs = sysDictService.queryDictItemsByCode("callback_api_config");
Integer autoPushNoticeMaxNum=10;//自动请求最大次数. 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){ while (true){
try { try {
Thread.sleep(pushTimeJoin*1000); Thread.sleep(pushTimeInterval*1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -61,11 +74,21 @@ public class HandleCallbacklnit implements ApplicationRunner {
for (OcrIdentify ocrIdentify : ocrIdentifyList) { for (OcrIdentify ocrIdentify : ocrIdentifyList) {
ocrIdentifyService.callbackWly(ocrIdentify.getId()); ocrIdentifyService.callbackWly(ocrIdentify.getId());
try { try {
Thread.sleep(pushTimeJoin*1000); Thread.sleep(pushTimeInterval*1000);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); 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) { /*if (enableHandleTask) {

Loading…
Cancel
Save