diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java index a8375e4..5a8f46a 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/api/controller/ApiController.java @@ -7,9 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang.StringUtils; import org.jeecg.common.api.vo.Result; -import org.jeecg.common.constant.OcrConstant; import org.jeecg.common.system.vo.DictModel; import org.jeecg.common.util.AssertUtils; import org.jeecg.common.util.RedisUtil; @@ -17,22 +15,18 @@ import org.jeecg.common.util.RestUtil; import org.jeecg.modules.ocr.entity.OcrIdentify; import org.jeecg.modules.ocr.entity.OcrIdentifyDetail; import org.jeecg.modules.ocr.entity.OcrRuleCheck; -import org.jeecg.modules.ocr.model.TaskModel; import org.jeecg.modules.ocr.service.IOcrIdentifyDetailService; import org.jeecg.modules.ocr.service.IOcrIdentifyService; import org.jeecg.modules.ocr.service.IOcrRuleCheckService; import org.jeecg.modules.ocr.utils.FileOUtils; import org.jeecg.modules.ocr.vo.OcrRuleCheckVo; import org.jeecg.modules.system.service.ISysDictService; -import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; import java.util.List; import java.util.stream.Collectors; @@ -57,7 +51,6 @@ public class ApiController { @Resource private RedisUtil redisUtil; - ////===================================================================伪接口 @ApiOperation(value = "通用识别") @RequestMapping("/identify") @@ -112,7 +105,7 @@ public class ApiController { ocrIdentify.setRequestId(requestId); ocrIdentify.setStatus("0");//任务进行中 ocrIdentify.setRuleCheck(ruleId);//配置规则检查id - ocrIdentify.setStartTime(new Date());//开始时间 + //ocrIdentify.setStartTime(new Date());//开始时间 if (scenes.equals("door")) { ocrIdentify.setTaskType("1683412752926986241");//任务类型 } @@ -201,6 +194,15 @@ public class ApiController { return JSONObject.parseObject("{\"requestId\":\"10001\",\"result\":{\"retrieveReviewCompliance\":\"80\",\"imageTagRetrievePercentage\":\"66.6\",\"failureReason\":\"图片不清晰\"}}"); } //========================================================================================== + @ApiOperation(value = "刷新为完成的任务", notes = "任务完结通知") + @GetMapping("/test") + public Result test(){ + JSONObject jsonObject=new JSONObject(); + for (int i = 0; i < 100; i++) { + } + return Result.OK("111"); + } + @ApiOperation(value = "刷新为完成的任务", notes = "任务完结通知") @GetMapping("/restartTask") diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java index 82ea398..81f13bb 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyService.java @@ -16,22 +16,35 @@ import java.util.List; * @Version: V1.0 */ public interface IOcrIdentifyService extends IService { + //单条根据id,自定义返回结果对象方法 public OcrIdentifyVo findById(String id); + + /** + * 回调无量云接口 + * @param ocrIdentifyId + */ + public void callbackWly(String ocrIdentifyId); + + /** * 解析 请求 ocr识别接口的 结果 * @param responseBody */ - public void getSemanticInfo(JSONObject responseBody); + void getSemanticInfo(JSONObject responseBody); @Async void postSemantic(OcrIdentify ocrIdentify, List identifyUrlList); void updateOcrIdentifyStatus(String id,String status); + + /** * 发送执行任务计划 * @param jsonObject * @return */ Result pushTask(JSONObject jsonObject); + + void updateMasterTaskStartTime(String id); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java index b277e1c..2f8f85d 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyServiceImpl.java @@ -75,12 +75,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl().eq(OcrIdentifyDetail::getIdentifyId, identifyId).eq(OcrIdentifyDetail::getImageUrl, imgPath)); if (count > 0) { - //该图片已识别过 log.error("该图片已识别过了"); return; } @@ -243,22 +237,32 @@ public class OcrIdentifyServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper(); 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 updateWrapper = new LambdaUpdateWrapper(); + 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 queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(OcrIdentifyDetail::getIdentifyId, id); + queryWrapper.eq(OcrIdentifyDetail::getIdentifyId, ocrIdentifyId); queryWrapper.isNotNull(OcrIdentifyDetail::getDataStructured); List identifyDetails = ocrIdentifyDetailService.list(queryWrapper); if (identifyDetails != null) { @@ -313,11 +317,9 @@ public class OcrIdentifyServiceImpl extends ServiceImpl 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