|
|
|
@ -75,12 +75,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
@Override
|
|
|
|
|
public void getSemanticInfo(JSONObject responseBody) {
|
|
|
|
|
String ocrApiCallStatisticsId = null;
|
|
|
|
|
try {
|
|
|
|
|
ocrApiCallStatisticsId = ocrApiCallStatisticsService.saveLogs("通用识别", "/ocr/ocrApi/identify", 1);
|
|
|
|
|
Thread.sleep(1000l);
|
|
|
|
|
} catch (InterruptedException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
ocrApiCallStatisticsId = ocrApiCallStatisticsService.saveLogs("通用识别", "/ocr/ocrApi/identify", 1);
|
|
|
|
|
log.debug("打印 ocr 结果:" + responseBody.toString());
|
|
|
|
|
String identifyId = responseBody.getString("identifyId");//任务id
|
|
|
|
|
String imgPath = responseBody.getString("img_path");//图片路径
|
|
|
|
@ -100,7 +95,6 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
if (semanticResult != null) {
|
|
|
|
|
long count = ocrIdentifyDetailService.count(new LambdaUpdateWrapper<OcrIdentifyDetail>().eq(OcrIdentifyDetail::getIdentifyId, identifyId).eq(OcrIdentifyDetail::getImageUrl, imgPath));
|
|
|
|
|
if (count > 0) {
|
|
|
|
|
//该图片已识别过
|
|
|
|
|
log.error("该图片已识别过了");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -243,22 +237,32 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Async
|
|
|
|
|
public void updateOcrIdentifyStatus(String id, String status) {
|
|
|
|
|
//4.更新主任务状态
|
|
|
|
|
LambdaUpdateWrapper<OcrIdentify> updateWrapper = new LambdaUpdateWrapper<OcrIdentify>();
|
|
|
|
|
updateWrapper.eq(OcrIdentify::getId, id);
|
|
|
|
|
updateWrapper.set(OcrIdentify::getEndTime, new Date());
|
|
|
|
|
updateWrapper.set(OcrIdentify::getStatus, "1");
|
|
|
|
|
super.update(updateWrapper);
|
|
|
|
|
this.callbackWly(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Async
|
|
|
|
|
public void callbackWly(String ocrIdentifyId){
|
|
|
|
|
LambdaUpdateWrapper<OcrIdentify> updateWrapper = new LambdaUpdateWrapper<OcrIdentify>();
|
|
|
|
|
updateWrapper.eq(OcrIdentify::getId, ocrIdentifyId);
|
|
|
|
|
long time = new Date().getTime();
|
|
|
|
|
//回调 无量云接口
|
|
|
|
|
if (true) {
|
|
|
|
|
OcrIdentify ocrIdentify = super.getById(id);
|
|
|
|
|
OcrIdentify ocrIdentify = super.getById(ocrIdentifyId);
|
|
|
|
|
if (ocrIdentify!=null) {
|
|
|
|
|
if (StringUtils.isBlank(ocrIdentify.getRequestId())) {
|
|
|
|
|
ocrIdentify.setRequestId(time + "");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotBlank(ocrIdentify.getRequestId())) {
|
|
|
|
|
LambdaQueryWrapper<OcrIdentifyDetail> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
queryWrapper.eq(OcrIdentifyDetail::getIdentifyId, id);
|
|
|
|
|
queryWrapper.eq(OcrIdentifyDetail::getIdentifyId, ocrIdentifyId);
|
|
|
|
|
queryWrapper.isNotNull(OcrIdentifyDetail::getDataStructured);
|
|
|
|
|
List<OcrIdentifyDetail> identifyDetails = ocrIdentifyDetailService.list(queryWrapper);
|
|
|
|
|
if (identifyDetails != null) {
|
|
|
|
@ -313,11 +317,9 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
} else {
|
|
|
|
|
updateWrapper.set(OcrIdentify::getNoticeStatus, "0");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
super.update(updateWrapper);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void mapPutIfTrue(Map map, String key, Boolean flag) {
|
|
|
|
@ -475,6 +477,15 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
return Result.OK("已追加到任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateMasterTaskStartTime(String id) {
|
|
|
|
|
LambdaUpdateWrapper<OcrIdentify> updateWrapper=new LambdaUpdateWrapper<>();
|
|
|
|
|
updateWrapper.set(OcrIdentify::getStartTime,new Date());
|
|
|
|
|
updateWrapper.isNull(OcrIdentify::getStartTime);
|
|
|
|
|
updateWrapper.eq(OcrIdentify::getId,id);
|
|
|
|
|
super.update(updateWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void executeTask() {
|
|
|
|
|
//获取任务
|
|
|
|
@ -555,6 +566,10 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
JSONObject requestBody = new JSONObject();
|
|
|
|
|
requestBody.put("task_id", task_id);
|
|
|
|
|
requestBody.put("img_path", image);
|
|
|
|
|
|
|
|
|
|
//更新主任务,正在识别中.
|
|
|
|
|
this.updateMasterTaskStartTime(task_id.split("_")[0]);
|
|
|
|
|
|
|
|
|
|
JSONObject semanticResponseJson = RestUtil.post(OcrConstant.api_test2_identify_url, requestBody);
|
|
|
|
|
semanticResponseJson.put("identifyId", masterTaskId);
|
|
|
|
|
log.info("ocr识别返回数据:");
|
|
|
|
@ -577,7 +592,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Thread.sleep(20000l);
|
|
|
|
|
Thread.sleep(2000l);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|