master
周文涛 2 years ago
parent 5176c25d86
commit 903d4f23de

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.constant.OcrConstant;
@ -39,6 +40,7 @@ import java.util.stream.Collectors;
*/
@Service
@EnableAsync
@Slf4j
public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrIdentify> implements IOcrIdentifyService {
@Resource
IOcrRuleCheckService ocrRuleCheckService;
@ -233,9 +235,13 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
updateWrapper.eq(OcrIdentify::getId, id);
updateWrapper.set(OcrIdentify::getEndTime, new Date());
updateWrapper.set(OcrIdentify::getStatus, "1");
long time = new Date().getTime();
//回调 无量云接口
if(true){
OcrIdentify ocrIdentify = super.getById(id);
if (StringUtils.isBlank(ocrIdentify.getRequestId())) {
ocrIdentify.setRequestId(time+"");
}
if (StringUtils.isNotBlank(ocrIdentify.getRequestId())) {
LambdaQueryWrapper<OcrIdentifyDetail> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(OcrIdentifyDetail::getIdentifyId,id);
@ -275,10 +281,16 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
requestBody.put("retrieveReviewCompliance",0);
requestBody.put("failureReason","");
log.debug("请求无量云回调接口");
JSONObject semanticResponseJson = RestUtil.post("https://192.168.1.21:8686/api/task/image/ocr/callback", requestBody);
log.error(semanticResponseJson.toJSONString());
if (semanticResponseJson!=null) {
updateWrapper.set(OcrIdentify::getNoticeStatus,"1");
JSONObject semanticResponseJson=null;
try {
semanticResponseJson = RestUtil.post("https://192.168.1.21:8686/api/task/image/ocr/callback", requestBody);
}catch (Exception e){
log.error("请求无量云回调接口失败");
}finally {
log.error(semanticResponseJson.toJSONString());
if (semanticResponseJson!=null) {
updateWrapper.set(OcrIdentify::getNoticeStatus,"1");
}
}
}else{
updateWrapper.set(OcrIdentify::getNoticeStatus,"0");
@ -505,8 +517,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
//睡眠
try {
String parameter = taskModel.getParameter();
log.debug("打印taskModel:");
log.debug(taskModel.toString());
log.info("打印taskModel:");
log.info(taskModel.toString());
// 任务类型
if ("identify".equals(taskModel.getTaskType())) {
String[] parameters = parameter.split(",");
@ -527,13 +539,13 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
String collect = Arrays.asList(masterTask.split(",")).stream().filter(t -> !t.equals(task_id)).collect(Collectors.joining(","));
if (StringUtils.isBlank(collect)) {
//如果主任务下的子任务已清空删除key
redisUtil.del(masterTaskId);
redisUtil.del("identify_"+masterTaskId);
//刷新Ocr识别任务状态
updateOcrIdentifyStatus(masterTaskId,"1");
log.error("更新任务状态id:"+masterTaskId);
}else{
//主任务还存在,刷新主任务明细
redisUtil.set(masterTaskId,collect);
redisUtil.set("identify_"+masterTaskId,collect);
}
}
} else {

@ -29,13 +29,16 @@ public class FileOUtils {
if (sourceImages.indexOf("http://")!=-1||sourceImages.indexOf("https://")!=-1) {
//网络目录
try {
URL url = new URL(sourceImages);
// 返回一个 URLConnection 对象,它表示到 URL 所引用的远程对象的连接。
URLConnection uc = url.openConnection();
// 打开的连接读取的输入流。
InputStream in = uc.getInputStream();
//附件存在
files.add(sourceImages);
String[] split = sourceImages.split(",");
for (String s : split) {
URL url = new URL(s);
// 返回一个 URLConnection 对象,它表示到 URL 所引用的远程对象的连接。
URLConnection uc = url.openConnection();
// 打开的连接读取的输入流。
InputStream in = uc.getInputStream();
//附件存在
files.add(s);
}
} catch (Exception e) {
//附件不存在
return null;

Loading…
Cancel
Save