From 3d71a7fca9e7720e980941df9e2f519f47a758e5 Mon Sep 17 00:00:00 2001 From: DELL Date: Sun, 7 Apr 2024 19:24:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E8=A7=A3=E5=86=B3=E9=AB=98=E7=BA=A7?= =?UTF-8?q?=E7=AD=9B=E9=80=89sql=E6=9F=A5=E8=AF=A2=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=88=E5=85=B3=E4=BA=8E=E6=97=B6=E9=97=B4=E5=8C=BA=E9=97=B4?= =?UTF-8?q?or=E7=9A=84=E6=83=85=E5=86=B5=EF=BC=89=EF=BC=8C=E8=A7=A3?= =?UTF-8?q?=E5=86=B3=E6=97=A0=E9=87=8F=E4=BA=91=E6=89=B9=E9=87=8F=E6=8B=89?= =?UTF-8?q?=E5=8F=96=E6=95=B0=E6=8D=AE=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/FlowTaskServiceImpl.java | 2 + .../ocr/controller/ApiTestController.java | 135 ++++++++++-------- .../mapper/oa/OcrTaskchildPictureMapper.xml | 25 +++- 3 files changed, 102 insertions(+), 60 deletions(-) diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/service/impl/FlowTaskServiceImpl.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/service/impl/FlowTaskServiceImpl.java index 9defc3aa..9310fe8e 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/service/impl/FlowTaskServiceImpl.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/flowable/service/impl/FlowTaskServiceImpl.java @@ -2039,6 +2039,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask break; } //不相等 + searchQuery.addLess(usersearchchild.getSearchfield(), sectionInts.get(0)); searchQuery.addGreater(usersearchchild.getSearchfield(), sectionInts.get(1)); break; @@ -2066,6 +2067,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask break; } //不相等 + searchQuery.addRulesOp(usersearchchild.getSearchfield()+"Start","or"); searchQuery.addLess(usersearchchild.getSearchfield()+"Start", beginTime.getTime()); searchQuery.addGreater(usersearchchild.getSearchfield()+"End", endTime.getTime()); break; diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/ApiTestController.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/ApiTestController.java index b47208a0..5e6dec72 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/ApiTestController.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/ApiTestController.java @@ -8,12 +8,14 @@ import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceParameter; import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult; import cn.jyjz.xiaoyao.ocr.api.utils.ApiPage; import cn.jyjz.xiaoyao.ocr.thread.TaskQueue; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletRequest; import java.time.Instant; +import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -24,6 +26,7 @@ import java.util.List; * @version 1.0 * @date 2024/3/14 19:47 */ +@Slf4j @RestController @RequestMapping("/test/api") public class ApiTestController { @@ -85,65 +88,85 @@ public class ApiTestController { pictureSourceParameter.setTenantNo(1714548920583360512L); pictureSourceParameter.setAccountNo(1714887674875514880L); - DateTime startDate = DateUtil.parse(beginStr + " 00:00:00", "yyyy-MM-dd HH:mm:ss"); - DateTime endDate = DateUtil.parse(endStr + " 23:59:59", "yyyy-MM-dd HH:mm:ss"); - - try { - int totalCount = 0; - int totalLocalCount = 0; - int totalSize = 0; - - while (startDate.isBefore(endDate) || startDate.compareTo(endDate) == 0) { - int currentPage = Integer.parseInt(pageNo); - boolean hasNextPage = true; - - while (hasNextPage) { - // 设置当天的开始和结束时间 - Instant startInstant = startDate.toInstant(); - Instant endInstant = startDate.offsetNew(DateField.DAY_OF_YEAR, 1).toInstant(); - pictureSourceParameter.setStartTime(Date.from(startInstant)); - pictureSourceParameter.setEndTime(Date.from(endInstant)); - pictureSourceParameter.setPageNo(currentPage); - - ApiPage apiPage = prevailCloudApi.pullPictureSource(pictureSourceParameter); - List listResult = apiPage.getRecords(); - int count = apiPage.getTotal(); - int localCount = listResult.size(); - int size = 0; - - for (PictureSourceResult pictureSourceResult : listResult) { - if (pictureSourceResult.getLivePhoto() != null) { - size++; - //将可以处理数据放入处理队列中 - TaskQueue.pictureDisposePushData(pictureSourceResult); + List notAddedToQueueTaskIds = new ArrayList<>(); + + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + try { + int totalCount = 0; + int totalLocalCount = 0; + int totalSize = 0; + DateTime startDate = DateUtil.parse(beginStr + " 00:00:00", "yyyy-MM-dd HH:mm:ss"); + DateTime endDate = DateUtil.parse(endStr + " 23:59:59", "yyyy-MM-dd HH:mm:ss"); + while (startDate.isBefore(endDate) || startDate.compareTo(endDate) == 0) { + int currentPage = Integer.parseInt(pageNo); + boolean hasNextPage = true; + boolean isCountAdded = false; + + while (hasNextPage) { + // 设置当天的开始和结束时间 + Instant startInstant = startDate.toInstant(); + Instant endInstant = startDate.offsetNew(DateField.DAY_OF_YEAR, 1).toInstant(); + pictureSourceParameter.setStartTime(Date.from(startInstant)); + pictureSourceParameter.setEndTime(Date.from(endInstant)); + pictureSourceParameter.setPageNo(currentPage); + + ApiPage apiPage = prevailCloudApi.pullPictureSource(pictureSourceParameter); + List listResult = apiPage.getRecords(); + int count = apiPage.getTotal(); + int localCount = listResult.size(); + int size = 0; + + for (PictureSourceResult pictureSourceResult : listResult) { + int retryCount = 0; + boolean addedToQueue = false; + if (pictureSourceResult.getLivePhoto() != null && !pictureSourceResult.getLivePhoto().isEmpty()) { + size++; + // 尝试将数据加入队列 + while (!addedToQueue && retryCount < 5) { // 最多重试5次 + addedToQueue = TaskQueue.pictureDisposePushData(pictureSourceResult); + if (!addedToQueue) { + Thread.sleep(60000); + retryCount++; + } + } + if (!addedToQueue) { + log.error("无法将数据添加到队列,开始时间:{},任务ID:{}",startDate.toString("yyyy-MM-dd HH:mm:ss"),pictureSourceResult.getTaskId().toString()); + notAddedToQueueTaskIds.add(pictureSourceResult.getTaskId().toString()); + } + } + } + + totalLocalCount += localCount; + totalSize += size; + + if (!isCountAdded) { + totalCount += count; + isCountAdded = true; // 标记当天的统计信息已经被累加过了 + } + + // 输出当前日期范围内的统计信息 + log.error("{}图片总数:{}条,本次获取:{}条,可处理数据:{}条",startDate.toString("yyyy-MM-dd"),count,localCount,size); + // 准备处理下一页的数据 + currentPage++; + // 检查是否有下一页 + if (localCount < Integer.parseInt(pageSize)) { + hasNextPage = false; + } } + // 准备处理下一天的数据 + startDate = startDate.offsetNew(DateField.DAY_OF_YEAR, 1); } - - totalCount += count; - totalLocalCount += localCount; - totalSize += size; - - // 输出当前日期范围内的统计信息 - System.out.println(startDate.toString("yyyy-MM-dd") + " 图片总数:" + count + "条,本次获取:" + localCount + "条,可处理数据:" + size + "条"); - - // 准备处理下一页的数据 - currentPage++; - - // 检查是否有下一页 - if (localCount < Integer.parseInt(pageSize)) { - hasNextPage = false; - } + log.error("未加入队列的任务ID列表:{}",notAddedToQueueTaskIds); + log.error("当前区间内图片总数:{}条,本次获取:{}条,可处理数据:{}条",totalCount,totalLocalCount,totalSize); + } catch (Exception e) { + e.printStackTrace(); } - - // 准备处理下一天的数据 - startDate = startDate.offsetNew(DateField.DAY_OF_YEAR, 1); } - - return "当前区间内图片总数:" + totalCount + "条,本次获取:" + totalLocalCount + "条,可处理数据:" + totalSize + "条"; - } catch (Exception e) { - e.printStackTrace(); - } - - return "处理失败"; + }); + thread.start(); + return "开启入库"; } } + diff --git a/jyjz-system/jyjz-system-oa/src/main/resources/mapper/oa/OcrTaskchildPictureMapper.xml b/jyjz-system/jyjz-system-oa/src/main/resources/mapper/oa/OcrTaskchildPictureMapper.xml index 5c9db2a4..e62cbb75 100644 --- a/jyjz-system/jyjz-system-oa/src/main/resources/mapper/oa/OcrTaskchildPictureMapper.xml +++ b/jyjz-system/jyjz-system-oa/src/main/resources/mapper/oa/OcrTaskchildPictureMapper.xml @@ -540,12 +540,29 @@ + + + + + + - and tcp.FROMUPTIME >= '${izuptimeStart.value}' - - - and tcp.FROMUPTIME <= '${izuptimeEnd.value}' + + + + + and (tcp.FROMUPTIME ${izuptimeStart.dataOp} '${izuptimeStart.value}' or tcp.FROMUPTIME ${izuptimeEnd.dataOp} '${izuptimeEnd.value}') + + + + + and tcp.FROMUPTIME ${izuptimeStart.dataOp} '${izuptimeStart.value}' + + and tcp.FROMUPTIME ${izuptimeEnd.dataOp} '${izuptimeEnd.value}' + + +