|
|
|
@ -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,11 +281,17 @@ 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);
|
|
|
|
|
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 {
|
|
|
|
|