From 72f4f7bbea517075e5921c156132f8431b2f3dc8 Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Mon, 7 Aug 2023 18:35:53 +0800 Subject: [PATCH] updates --- .../OcrIdentifyCallbackLogController.java | 178 ++++++++++++++++++ .../ocr/controller/OcrIdentifyController.java | 8 +- .../OcrMetadataConfigController.java | 10 + .../controller/OcrRuleCheckController.java | 13 +- .../ocr/controller/OcrTaskTypeController.java | 4 +- .../ocr/entity/OcrIdentifyCallbackLog.java | 64 +++++++ .../modules/ocr/init/HandleCallbacklnit.java | 25 ++- .../mapper/OcrIdentifyCallbackLogMapper.java | 20 ++ .../xml/OcrIdentifyCallbackLogMapper.xml | 15 ++ .../IOcrIdentifyCallbackLogService.java | 19 ++ .../ocr/service/IOcrIdentifyService.java | 10 +- .../OcrIdentifyCallbackLogServiceImpl.java | 31 +++ .../service/impl/OcrIdentifyServiceImpl.java | 32 +++- 13 files changed, 404 insertions(+), 25 deletions(-) create mode 100644 jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyCallbackLogController.java create mode 100644 jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/entity/OcrIdentifyCallbackLog.java create mode 100644 jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/mapper/OcrIdentifyCallbackLogMapper.java create mode 100644 jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/mapper/xml/OcrIdentifyCallbackLogMapper.xml create mode 100644 jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyCallbackLogService.java create mode 100644 jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyCallbackLogServiceImpl.java diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyCallbackLogController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyCallbackLogController.java new file mode 100644 index 0000000..5f2f54d --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyCallbackLogController.java @@ -0,0 +1,178 @@ +package org.jeecg.modules.ocr.controller; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.jeecg.common.api.vo.Result; +import org.jeecg.common.system.query.QueryGenerator; +import org.jeecg.common.util.oConvertUtils; +import org.jeecg.modules.ocr.entity.OcrIdentifyCallbackLog; +import org.jeecg.modules.ocr.service.IOcrIdentifyCallbackLogService; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import lombok.extern.slf4j.Slf4j; + +import org.jeecgframework.poi.excel.ExcelImportUtil; +import org.jeecgframework.poi.excel.def.NormalExcelConstants; +import org.jeecgframework.poi.excel.entity.ExportParams; +import org.jeecgframework.poi.excel.entity.ImportParams; +import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; +import org.jeecg.common.system.base.controller.JeecgController; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import org.springframework.web.multipart.MultipartHttpServletRequest; +import org.springframework.web.servlet.ModelAndView; +import com.alibaba.fastjson.JSON; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.jeecg.common.aspect.annotation.AutoLog; +import org.apache.shiro.authz.annotation.RequiresPermissions; + + /** + * @Description: ocr识别无量云回调记录 + * @Author: jeecg-boot + * @Date: 2023-08-07 + * @Version: V1.0 + */ +@Api(tags="ocr识别无量云回调记录") +@RestController +@RequestMapping("/ocr/ocrIdentifyCallbackLog") +@Slf4j +public class OcrIdentifyCallbackLogController extends JeecgController { + @Autowired + private IOcrIdentifyCallbackLogService ocrIdentifyCallbackLogService; + + /** + * 分页列表查询 + * + * @param ocrIdentifyCallbackLog + * @param pageNo + * @param pageSize + * @param req + * @return + */ + //@AutoLog(value = "ocr识别无量云回调记录-分页列表查询") + @ApiOperation(value="ocr识别无量云回调记录-分页列表查询", notes="ocr识别无量云回调记录-分页列表查询") + @GetMapping(value = "/list") + public Result> queryPageList(OcrIdentifyCallbackLog ocrIdentifyCallbackLog, + @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, + @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, + HttpServletRequest req) { + QueryWrapper queryWrapper = QueryGenerator.initQueryWrapper(ocrIdentifyCallbackLog, req.getParameterMap()); + Page page = new Page(pageNo, pageSize); + IPage pageList = ocrIdentifyCallbackLogService.page(page, queryWrapper); + return Result.OK(pageList); + } + + /** + * 添加 + * + * @param ocrIdentifyCallbackLog + * @return + */ + @AutoLog(value = "ocr识别无量云回调记录-添加") + @ApiOperation(value="ocr识别无量云回调记录-添加", notes="ocr识别无量云回调记录-添加") + @RequiresPermissions("ocr:ocr_identify_callback_log:add") + @PostMapping(value = "/add") + public Result add(@RequestBody OcrIdentifyCallbackLog ocrIdentifyCallbackLog) { + ocrIdentifyCallbackLogService.save(ocrIdentifyCallbackLog); + return Result.OK("添加成功!"); + } + + /** + * 编辑 + * + * @param ocrIdentifyCallbackLog + * @return + */ + @AutoLog(value = "ocr识别无量云回调记录-编辑") + @ApiOperation(value="ocr识别无量云回调记录-编辑", notes="ocr识别无量云回调记录-编辑") + @RequiresPermissions("ocr:ocr_identify_callback_log:edit") + @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) + public Result edit(@RequestBody OcrIdentifyCallbackLog ocrIdentifyCallbackLog) { + ocrIdentifyCallbackLogService.updateById(ocrIdentifyCallbackLog); + return Result.OK("编辑成功!"); + } + + /** + * 通过id删除 + * + * @param id + * @return + */ + @AutoLog(value = "ocr识别无量云回调记录-通过id删除") + @ApiOperation(value="ocr识别无量云回调记录-通过id删除", notes="ocr识别无量云回调记录-通过id删除") + @RequiresPermissions("ocr:ocr_identify_callback_log:delete") + @DeleteMapping(value = "/delete") + public Result delete(@RequestParam(name="id",required=true) String id) { + ocrIdentifyCallbackLogService.removeById(id); + return Result.OK("删除成功!"); + } + + /** + * 批量删除 + * + * @param ids + * @return + */ + @AutoLog(value = "ocr识别无量云回调记录-批量删除") + @ApiOperation(value="ocr识别无量云回调记录-批量删除", notes="ocr识别无量云回调记录-批量删除") + @RequiresPermissions("ocr:ocr_identify_callback_log:deleteBatch") + @DeleteMapping(value = "/deleteBatch") + public Result deleteBatch(@RequestParam(name="ids",required=true) String ids) { + this.ocrIdentifyCallbackLogService.removeByIds(Arrays.asList(ids.split(","))); + return Result.OK("批量删除成功!"); + } + + /** + * 通过id查询 + * + * @param id + * @return + */ + //@AutoLog(value = "ocr识别无量云回调记录-通过id查询") + @ApiOperation(value="ocr识别无量云回调记录-通过id查询", notes="ocr识别无量云回调记录-通过id查询") + @GetMapping(value = "/queryById") + public Result queryById(@RequestParam(name="id",required=true) String id) { + OcrIdentifyCallbackLog ocrIdentifyCallbackLog = ocrIdentifyCallbackLogService.getById(id); + if(ocrIdentifyCallbackLog==null) { + return Result.error("未找到对应数据"); + } + return Result.OK(ocrIdentifyCallbackLog); + } + + /** + * 导出excel + * + * @param request + * @param ocrIdentifyCallbackLog + */ + @RequiresPermissions("ocr:ocr_identify_callback_log:exportXls") + @RequestMapping(value = "/exportXls") + public ModelAndView exportXls(HttpServletRequest request, OcrIdentifyCallbackLog ocrIdentifyCallbackLog) { + return super.exportXls(request, ocrIdentifyCallbackLog, OcrIdentifyCallbackLog.class, "ocr识别无量云回调记录"); + } + + /** + * 通过excel导入数据 + * + * @param request + * @param response + * @return + */ + @RequiresPermissions("ocr:ocr_identify_callback_log:importExcel") + @RequestMapping(value = "/importExcel", method = RequestMethod.POST) + public Result importExcel(HttpServletRequest request, HttpServletResponse response) { + return super.importExcel(request, response, OcrIdentifyCallbackLog.class); + } + +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java index ed2374d..93e90ff 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrIdentifyController.java @@ -261,10 +261,8 @@ public class OcrIdentifyController extends JeecgController ocrRuleCheckMap = ocrRuleCheckService.listToMap(null); Map metadataConfigMap = ocrMetadataConfigService.listToMap(null); Map taskNameMap = ocrTaskTypeService.listNameToMap(null); - List ocrIdentifyDetailList = null; - ocrIdentifyDetailList = ocrIdentifyDetailService.list(new LambdaQueryWrapper().eq(OcrIdentifyDetail::getIdentifyId, id)); - List identifyDetailList = new ArrayList<>(); - + /*List ocrIdentifyDetailList = ocrIdentifyDetailService.list(new LambdaQueryWrapper().eq(OcrIdentifyDetail::getIdentifyId, id)); + List identifyDetailList = new ArrayList<>();*/ /* if ("1".equals(ocrIdentify.getStatus()) &&ocrIdentifyDetailList!=null&&ocrIdentifyDetailList.size()>0) { //判断明细是否识别成功 identifyDetailList = ocrIdentifyDetailList.stream().filter(o -> o.getIdentifyId().equals(ocrIdentify.getId())).collect(Collectors.toList()); @@ -347,7 +345,7 @@ public class OcrIdentifyController extends JeecgController delete(@RequestParam(name = "id", required = true) String id) { + long count = ocrRuleCheckService.count(new LambdaQueryWrapper().eq(OcrRuleCheck::getMetadataConfigId, id)); + AssertUtils.notTrue(count>0, String.format("所选元数据配置不可删除,原因:[被规则检查配置使用中]")); ocrMetadataConfigService.removeById(id); return Result.OK("删除成功!"); } @@ -174,6 +182,8 @@ public class OcrMetadataConfigController extends JeecgController deleteBatch(@RequestParam(name = "ids", required = true) String ids) { + long count = ocrRuleCheckService.count(new LambdaQueryWrapper().in(OcrRuleCheck::getMetadataConfigId, Arrays.asList(ids.split(",")))); + AssertUtils.notTrue(count>0, String.format("所选元数据配置不可删除,原因:[被规则检查配置使用中]")); this.ocrMetadataConfigService.removeByIds(Arrays.asList(ids.split(","))); return Result.OK("批量删除成功!"); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrRuleCheckController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrRuleCheckController.java index bd99f2d..af2f336 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrRuleCheckController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrRuleCheckController.java @@ -24,12 +24,10 @@ import org.jeecg.common.system.vo.LoginUser; import org.jeecg.common.util.AssertUtils; import org.jeecg.common.util.oConvertUtils; import org.jeecg.config.JeecgBaseConfig; -import org.jeecg.modules.ocr.entity.OcrMetadataConfig; -import org.jeecg.modules.ocr.entity.OcrMetadataConfigDetail; -import org.jeecg.modules.ocr.entity.OcrRuleCheck; -import org.jeecg.modules.ocr.entity.OcrTaskType; +import org.jeecg.modules.ocr.entity.*; import org.jeecg.modules.ocr.model.OcrMetadataConfigSaveModel; import org.jeecg.modules.ocr.model.OcrRuleCheckSaveModel; +import org.jeecg.modules.ocr.service.IOcrIdentifyService; import org.jeecg.modules.ocr.service.IOcrMetadataConfigService; import org.jeecg.modules.ocr.service.IOcrRuleCheckService; import org.jeecg.common.system.base.controller.JeecgController; @@ -70,7 +68,8 @@ public class OcrRuleCheckController extends JeecgController delete(@RequestParam(name = "id", required = true) String id) { + long count = ocrIdentifyService.count(new LambdaQueryWrapper().eq(OcrIdentify::getRuleCheck, id)); + AssertUtils.notTrue(count>0, String.format("所选规则配置不可删除,原因:[被识别任务使用中]")); ocrRuleCheckService.removeById(id); return Result.OK("删除成功!"); } @@ -175,6 +176,8 @@ public class OcrRuleCheckController extends JeecgController deleteBatch(@RequestParam(name = "ids", required = true) String ids) { + long count = ocrIdentifyService.count(new LambdaQueryWrapper().in(OcrIdentify::getRuleCheck, Arrays.asList(ids.split(",")))); + AssertUtils.notTrue(count>0, String.format("所选规则配置不可删除,原因:[被识别任务使用中]")); this.ocrRuleCheckService.removeByIds(Arrays.asList(ids.split(","))); return Result.OK("批量删除成功!"); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrTaskTypeController.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrTaskTypeController.java index badebe3..b82a475 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrTaskTypeController.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/controller/OcrTaskTypeController.java @@ -120,7 +120,7 @@ public class OcrTaskTypeController extends JeecgController delete(@RequestParam(name="id",required=true) String id) { boolean flag=ocrTaskTypeService.checkMetadataConfigUse(Arrays.asList(id)); - AssertUtils.notTrue(flag,"任务类型不可删除,原因:被元数据配置使用中"); + AssertUtils.notTrue(flag,"任务类型不可删除,原因:[被元数据配置使用中]"); ocrTaskTypeService.removeById(id); return Result.OK("删除成功!"); } @@ -137,7 +137,7 @@ public class OcrTaskTypeController extends JeecgController deleteBatch(@RequestParam(name="ids",required=true) String ids) { boolean flag=ocrTaskTypeService.checkMetadataConfigUse(Arrays.asList(ids.split(","))); - AssertUtils.notTrue(flag,"任务类型不可删除,原因:被元数据配置使用中"); + AssertUtils.notTrue(flag,"任务类型不可删除,原因:[被元数据配置使用中]"); this.ocrTaskTypeService.removeByIds(Arrays.asList(ids.split(","))); return Result.OK("批量删除成功!"); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/entity/OcrIdentifyCallbackLog.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/entity/OcrIdentifyCallbackLog.java new file mode 100644 index 0000000..67e0ee0 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/entity/OcrIdentifyCallbackLog.java @@ -0,0 +1,64 @@ +package org.jeecg.modules.ocr.entity; + +import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.util.Date; +import java.math.BigDecimal; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.baomidou.mybatisplus.annotation.TableLogic; +import lombok.Data; +import com.fasterxml.jackson.annotation.JsonFormat; +import org.springframework.format.annotation.DateTimeFormat; +import org.jeecgframework.poi.excel.annotation.Excel; +import org.jeecg.common.aspect.annotation.Dict; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + * @Description: ocr识别无量云回调记录 + * @Author: jeecg-boot + * @Date: 2023-08-07 + * @Version: V1.0 + */ +@Data +@TableName("ocr_identify_callback_log") +@Accessors(chain = true) +@EqualsAndHashCode(callSuper = false) +@ApiModel(value="ocr_identify_callback_log对象", description="ocr识别无量云回调记录") +public class OcrIdentifyCallbackLog implements Serializable { + private static final long serialVersionUID = 1L; + + /**主键*/ + @TableId(type = IdType.ASSIGN_ID) + @ApiModelProperty(value = "主键") + private java.lang.String id; + /**创建日期*/ + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "创建日期") + private java.util.Date createTime; + /**请求开始时间*/ + @Excel(name = "请求开始时间", width = 20, format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "请求开始时间") + private java.util.Date startTime; + /**请求结束时间*/ + @Excel(name = "请求结束时间", width = 20, format = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ApiModelProperty(value = "请求结束时间") + private java.util.Date endTime; + /**ocr识别任务主键*/ + @Excel(name = "ocr识别任务主键", width = 15) + @ApiModelProperty(value = "ocr识别任务主键") + private java.lang.String identifyId; + /**请求结果 0失败 1成功*/ + @Excel(name = "请求结果 0失败 1成功", width = 15) + @ApiModelProperty(value = "请求结果 0失败 1成功") + private java.lang.Integer status; +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java index c6639d7..169d365 100644 --- a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/init/HandleCallbacklnit.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils; import org.jeecg.common.constant.OcrConstant; import org.jeecg.common.util.RedisUtil; import org.jeecg.common.util.RestUtil; +import org.jeecg.modules.ocr.entity.OcrIdentify; import org.jeecg.modules.ocr.model.TaskModel; import org.jeecg.modules.ocr.service.IOcrIdentifyService; import org.jeecg.modules.ocr.service.impl.TaskService; @@ -31,6 +32,7 @@ import java.util.stream.Collectors; @Configuration @Slf4j public class HandleCallbacklnit implements ApplicationRunner { + @Resource RedisUtil redisUtil; @Resource @@ -39,9 +41,6 @@ public class HandleCallbacklnit implements ApplicationRunner { IOcrIdentifyService ocrIdentifyService; @Value("${system.project.enableHandleTask}") private boolean enableHandleTask; - public static void main(String[] args) { - - } /** * * @param args @@ -49,6 +48,26 @@ public class HandleCallbacklnit implements ApplicationRunner { @Override @Async public void run(ApplicationArguments args) throws UnknownHostException { + if (enableHandleTask) { + Integer autoPushNoticeMaxNum=10;//自动请求最大次数. + Integer pushTimeJoin=30;//请求间隔时间.秒 + while (true){ + try { + Thread.sleep(pushTimeJoin*1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + List ocrIdentifyList = ocrIdentifyService.findNeNoticeList(autoPushNoticeMaxNum); + for (OcrIdentify ocrIdentify : ocrIdentifyList) { + ocrIdentifyService.callbackWly(ocrIdentify.getId()); + try { + Thread.sleep(pushTimeJoin*1000); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + } + } /*if (enableHandleTask) { try { Thread.sleep(5000l); diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/mapper/OcrIdentifyCallbackLogMapper.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/mapper/OcrIdentifyCallbackLogMapper.java new file mode 100644 index 0000000..054eba4 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/mapper/OcrIdentifyCallbackLogMapper.java @@ -0,0 +1,20 @@ +package org.jeecg.modules.ocr.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Param; +import org.jeecg.modules.ocr.entity.OcrIdentifyCallbackLog; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + * @Description: ocr识别无量云回调记录 + * @Author: jeecg-boot + * @Date: 2023-08-07 + * @Version: V1.0 + */ +public interface OcrIdentifyCallbackLogMapper extends BaseMapper { + + List findIdentifyIdGroupLeCount(@Param(value = "autoPushNoticeMaxNum") Integer autoPushNoticeMaxNum); + List findIdentifyIdGroupGtCount(@Param(value = "autoPushNoticeMaxNum") Integer autoPushNoticeMaxNum); + +} diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/mapper/xml/OcrIdentifyCallbackLogMapper.xml b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/mapper/xml/OcrIdentifyCallbackLogMapper.xml new file mode 100644 index 0000000..2e7e227 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/mapper/xml/OcrIdentifyCallbackLogMapper.xml @@ -0,0 +1,15 @@ + + + + + + + \ No newline at end of file diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyCallbackLogService.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyCallbackLogService.java new file mode 100644 index 0000000..0c87972 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/IOcrIdentifyCallbackLogService.java @@ -0,0 +1,19 @@ +package org.jeecg.modules.ocr.service; + +import org.jeecg.modules.ocr.entity.OcrIdentifyCallbackLog; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** + * @Description: ocr识别无量云回调记录 + * @Author: jeecg-boot + * @Date: 2023-08-07 + * @Version: V1.0 + */ +public interface IOcrIdentifyCallbackLogService extends IService { + + List findIdentifyIdGroupLeCount(Integer autoPushNoticeMaxNum); + + public List findIdentifyIdGroupGtCount(Integer autoPushNoticeMaxNum); +} 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 698e0aa..3743e73 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 @@ -24,9 +24,11 @@ public interface IOcrIdentifyService extends IService { * 回调无量云接口 * @param ocrIdentifyId */ - @Async public void callbackWly(String ocrIdentifyId); + @Async + public void callbackWlyAsync(String ocrIdentifyId); + public void updateTaskResultInfo(String id); /** @@ -50,4 +52,10 @@ public interface IOcrIdentifyService extends IService { Result pushTask(JSONObject jsonObject); void updateMasterTaskStartTime(String id); + + /** + * 获取需要自动请求回调的ocr任务 + * @return + */ + List findNeNoticeList(Integer autoPushNoticeMaxNum); } diff --git a/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyCallbackLogServiceImpl.java b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyCallbackLogServiceImpl.java new file mode 100644 index 0000000..f8133b6 --- /dev/null +++ b/jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/ocr/service/impl/OcrIdentifyCallbackLogServiceImpl.java @@ -0,0 +1,31 @@ +package org.jeecg.modules.ocr.service.impl; + +import org.jeecg.modules.ocr.entity.OcrIdentifyCallbackLog; +import org.jeecg.modules.ocr.mapper.OcrIdentifyCallbackLogMapper; +import org.jeecg.modules.ocr.service.IOcrIdentifyCallbackLogService; +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import java.util.List; + +/** + * @Description: ocr识别无量云回调记录 + * @Author: jeecg-boot + * @Date: 2023-08-07 + * @Version: V1.0 + */ +@Service +public class OcrIdentifyCallbackLogServiceImpl extends ServiceImpl implements IOcrIdentifyCallbackLogService { + + @Override + public List findIdentifyIdGroupLeCount(Integer autoPushNoticeMaxNum) { + return baseMapper.findIdentifyIdGroupLeCount(autoPushNoticeMaxNum); + } + + @Override + public List findIdentifyIdGroupGtCount(Integer autoPushNoticeMaxNum) { + return baseMapper.findIdentifyIdGroupGtCount(autoPushNoticeMaxNum); + } + +} 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 93fad51..750a28b 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 @@ -12,6 +12,7 @@ import org.jeecg.common.util.CommonUtils; import org.jeecg.common.util.RedisUtil; import org.jeecg.common.util.RestUtil; import org.jeecg.modules.ocr.entity.OcrIdentify; +import org.jeecg.modules.ocr.entity.OcrIdentifyCallbackLog; import org.jeecg.modules.ocr.entity.OcrIdentifyDetail; import org.jeecg.modules.ocr.mapper.OcrIdentifyMapper; import org.jeecg.modules.ocr.model.*; @@ -50,7 +51,8 @@ public class OcrIdentifyServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper(); updateWrapper.eq(OcrIdentify::getId, ocrIdentifyId); long time = new Date().getTime(); @@ -504,6 +498,12 @@ public class OcrIdentifyServiceImpl extends ServiceImpl findNeNoticeList(Integer autoPushNoticeMaxNum) { + //执行次数已达到指定次数的任务id + List identifyIdList = ocrIdentifyCallbackLogService.findIdentifyIdGroupGtCount(autoPushNoticeMaxNum); + //获取 待通知的任务,排除已达到指定次数的任务 + LambdaQueryWrapper queryWrapper=new LambdaQueryWrapper<>(); + if (identifyIdList!=null&&identifyIdList.size()>0) { + queryWrapper.notIn(OcrIdentify::getId,identifyIdList); + } + queryWrapper.eq(OcrIdentify::getNoticeStatus,0); + List list = super.list(queryWrapper); + return list; + } + @Transactional(rollbackFor = Exception.class) public void executeTask() { //获取任务