master
周文涛 2 years ago
parent ad00f96e3e
commit 72f4f7bbea

@ -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<OcrIdentifyCallbackLog, IOcrIdentifyCallbackLogService> {
@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<IPage<OcrIdentifyCallbackLog>> queryPageList(OcrIdentifyCallbackLog ocrIdentifyCallbackLog,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<OcrIdentifyCallbackLog> queryWrapper = QueryGenerator.initQueryWrapper(ocrIdentifyCallbackLog, req.getParameterMap());
Page<OcrIdentifyCallbackLog> page = new Page<OcrIdentifyCallbackLog>(pageNo, pageSize);
IPage<OcrIdentifyCallbackLog> 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<String> 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<String> 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<String> 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<String> 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<OcrIdentifyCallbackLog> 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);
}
}

@ -261,10 +261,8 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
Map<String, OcrRuleCheckVo> ocrRuleCheckMap = ocrRuleCheckService.listToMap(null);
Map<String, OcrMetadataConfigVo> metadataConfigMap = ocrMetadataConfigService.listToMap(null);
Map<String, String> taskNameMap = ocrTaskTypeService.listNameToMap(null);
List<OcrIdentifyDetail> ocrIdentifyDetailList = null;
ocrIdentifyDetailList = ocrIdentifyDetailService.list(new LambdaQueryWrapper<OcrIdentifyDetail>().eq(OcrIdentifyDetail::getIdentifyId, id));
List<OcrIdentifyDetail> identifyDetailList = new ArrayList<>();
/*List<OcrIdentifyDetail> ocrIdentifyDetailList = ocrIdentifyDetailService.list(new LambdaQueryWrapper<OcrIdentifyDetail>().eq(OcrIdentifyDetail::getIdentifyId, id));
List<OcrIdentifyDetail> 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<OcrIdentify, IOcrIden
AssertUtils.isTrue("1".equals(entity.getStatus()),String.format("[任务名称]-%s 当前正在识别中,不可进行通知回调",entity.getTaskName()));
}
for (String identifyId : Arrays.asList(id.split(","))) {
ocrIdentifyService.callbackWly(identifyId);
ocrIdentifyService.callbackWlyAsync(identifyId);
}
return Result.OK("操作成功");
}

@ -11,6 +11,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.apache.shiro.SecurityUtils;
@ -24,11 +25,14 @@ 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.OcrIdentify;
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.model.OcrMetadataConfigSaveModel;
import org.jeecg.modules.ocr.service.IOcrMetadataConfigService;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.ocr.service.IOcrRuleCheckService;
import org.jeecg.modules.ocr.utils.DownloadTemplateUtil;
import org.jeecg.modules.ocr.vo.OcrMetadataConfigVo;
import org.jeecgframework.poi.excel.ExcelImportUtil;
@ -61,6 +65,8 @@ public class OcrMetadataConfigController extends JeecgController<OcrMetadataConf
@Autowired
private IOcrMetadataConfigService ocrMetadataConfigService;
@Autowired
private IOcrRuleCheckService ocrRuleCheckService;
@Autowired
private DownloadTemplateUtil downloadTemplateUtil;
@Resource
private JeecgBaseConfig jeecgBaseConfig;
@ -159,6 +165,8 @@ public class OcrMetadataConfigController extends JeecgController<OcrMetadataConf
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_metadata_config:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
long count = ocrRuleCheckService.count(new LambdaQueryWrapper<OcrRuleCheck>().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<OcrMetadataConf
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_metadata_config:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
long count = ocrRuleCheckService.count(new LambdaQueryWrapper<OcrRuleCheck>().in(OcrRuleCheck::getMetadataConfigId, Arrays.asList(ids.split(","))));
AssertUtils.notTrue(count>0, String.format("所选元数据配置不可删除,原因:[被规则检查配置使用中]"));
this.ocrMetadataConfigService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}

@ -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<OcrRuleCheck, IOcrRu
private IOcrMetadataConfigService ocrMetadataConfigService;
@Resource
private JeecgBaseConfig jeecgBaseConfig;
@Autowired
private IOcrIdentifyService ocrIdentifyService;
/**
*
*
@ -160,6 +159,8 @@ public class OcrRuleCheckController extends JeecgController<OcrRuleCheck, IOcrRu
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_rule_check:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
long count = ocrIdentifyService.count(new LambdaQueryWrapper<OcrIdentify>().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<OcrRuleCheck, IOcrRu
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_rule_check:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
long count = ocrIdentifyService.count(new LambdaQueryWrapper<OcrIdentify>().in(OcrIdentify::getRuleCheck, Arrays.asList(ids.split(","))));
AssertUtils.notTrue(count>0, String.format("所选规则配置不可删除,原因:[被识别任务使用中]"));
this.ocrRuleCheckService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}

@ -120,7 +120,7 @@ public class OcrTaskTypeController extends JeecgController<OcrTaskType, IOcrTask
@DeleteMapping(value = "/delete")
public Result<String> 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<OcrTaskType, IOcrTask
@DeleteMapping(value = "/deleteBatch")
public Result<String> 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("批量删除成功!");
}

@ -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;
}

@ -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<OcrIdentify> 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);

@ -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<OcrIdentifyCallbackLog> {
List<String> findIdentifyIdGroupLeCount(@Param(value = "autoPushNoticeMaxNum") Integer autoPushNoticeMaxNum);
List<String> findIdentifyIdGroupGtCount(@Param(value = "autoPushNoticeMaxNum") Integer autoPushNoticeMaxNum);
}

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.ocr.mapper.OcrIdentifyCallbackLogMapper">
<select id="findIdentifyIdGroupLeCount" resultType="java.lang.String">
SELECT c.identify_id FROM (SELECT count(id)as num,identify_id FROM ocr_identify_callback_log
GROUP BY identify_id)c
WHERE c.num &lt;#{autoPushNoticeMaxNum}
</select>
<select id="findIdentifyIdGroupGtCount" resultType="java.lang.String">
SELECT c.identify_id FROM (SELECT count(id)as num,identify_id FROM ocr_identify_callback_log where state='0'
GROUP BY identify_id)c
WHERE c.num &gt;#{autoPushNoticeMaxNum}
</select>
</mapper>

@ -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<OcrIdentifyCallbackLog> {
List<String> findIdentifyIdGroupLeCount(Integer autoPushNoticeMaxNum);
public List<String> findIdentifyIdGroupGtCount(Integer autoPushNoticeMaxNum);
}

@ -24,9 +24,11 @@ public interface IOcrIdentifyService extends IService<OcrIdentify> {
*
* @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<OcrIdentify> {
Result pushTask(JSONObject jsonObject);
void updateMasterTaskStartTime(String id);
/**
* ocr
* @return
*/
List<OcrIdentify> findNeNoticeList(Integer autoPushNoticeMaxNum);
}

@ -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<OcrIdentifyCallbackLogMapper, OcrIdentifyCallbackLog> implements IOcrIdentifyCallbackLogService {
@Override
public List<String> findIdentifyIdGroupLeCount(Integer autoPushNoticeMaxNum) {
return baseMapper.findIdentifyIdGroupLeCount(autoPushNoticeMaxNum);
}
@Override
public List<String> findIdentifyIdGroupGtCount(Integer autoPushNoticeMaxNum) {
return baseMapper.findIdentifyIdGroupGtCount(autoPushNoticeMaxNum);
}
}

@ -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<OcrIdentifyMapper, OcrId
IOcrApiCallStatisticsService ocrApiCallStatisticsService;
@Resource
RedisUtil redisUtil;
@Resource
IOcrIdentifyCallbackLogService ocrIdentifyCallbackLogService;
@Override
public OcrIdentifyVo findById(String id) {
OcrIdentifyVo ocrIdentifyVo = baseMapper.findById(id);
@ -282,8 +284,6 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
}
}
super.update(updateWrapper);
this.callbackWly(id);
/*System.out.println("已通过一条!");*/
}
@Override
@ -424,13 +424,7 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
}
@Override
@Async
public void callbackWly(String ocrIdentifyId){
try {
Thread.sleep(10000l);
} catch (InterruptedException e) {
e.printStackTrace();
}
LambdaUpdateWrapper<OcrIdentify> updateWrapper = new LambdaUpdateWrapper<OcrIdentify>();
updateWrapper.eq(OcrIdentify::getId, ocrIdentifyId);
long time = new Date().getTime();
@ -504,6 +498,12 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
}
}
@Override
@Async
public void callbackWlyAsync(String ocrIdentifyId) {
callbackWly(ocrIdentifyId);
}
public static void mapPutIfTrue(Map map, String key, Boolean flag) {
if (map.containsKey(key) && (Boolean) map.get(key).equals(true)) {
} else {
@ -673,6 +673,20 @@ public class OcrIdentifyServiceImpl extends ServiceImpl<OcrIdentifyMapper, OcrId
super.update(updateWrapper);
}
@Override
public List<OcrIdentify> findNeNoticeList(Integer autoPushNoticeMaxNum) {
//执行次数已达到指定次数的任务id
List<String> identifyIdList = ocrIdentifyCallbackLogService.findIdentifyIdGroupGtCount(autoPushNoticeMaxNum);
//获取 待通知的任务,排除已达到指定次数的任务
LambdaQueryWrapper<OcrIdentify> queryWrapper=new LambdaQueryWrapper<>();
if (identifyIdList!=null&&identifyIdList.size()>0) {
queryWrapper.notIn(OcrIdentify::getId,identifyIdList);
}
queryWrapper.eq(OcrIdentify::getNoticeStatus,0);
List<OcrIdentify> list = super.list(queryWrapper);
return list;
}
@Transactional(rollbackFor = Exception.class)
public void executeTask() {
//获取任务

Loading…
Cancel
Save