From 918676fb35b4b91b12149b5543224e5e1cdf99ca Mon Sep 17 00:00:00 2001 From: DELL Date: Mon, 8 Apr 2024 18:57:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=98=BE=E7=A4=BA=E5=8F=AF=E7=96=91?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=88=97=E8=A1=A8=E6=96=B0=E5=A2=9E=E6=8F=90?= =?UTF-8?q?=E6=8A=A5=E6=97=B6=E9=97=B4=E6=8E=92=E5=BA=8F=E5=92=8C=E9=98=88?= =?UTF-8?q?=E5=80=BC=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OcrTaskchildDubiousFileController.java | 9 ++-- .../IOcrTaskchildDubiousFileService.java | 2 +- .../OcrTaskchildDubiousFileServiceImpl.java | 44 ++++++++++++++++--- 3 files changed, 43 insertions(+), 12 deletions(-) diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrTaskchildDubiousFileController.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrTaskchildDubiousFileController.java index adbcfa9d..e80278c2 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrTaskchildDubiousFileController.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrTaskchildDubiousFileController.java @@ -65,9 +65,10 @@ public class OcrTaskchildDubiousFileController { @ApiOperation(value="可疑文件列表查询", notes="可疑文件列表查询") @RequestMapping(value = "/dubiousfilelist", method = RequestMethod.GET) public ResultVo> dubiousfilelist(HttpServletRequest request, - @RequestParam(value = "pageNo", required = false, defaultValue = "0") Integer pageNo, - @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize, - @RequestParam(value = "orderbyname", required = true, defaultValue = "asc") String orderbyname) { + @RequestParam(value = "pageNo", required = false, defaultValue = "0") Integer pageNo, + @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize, + @RequestParam(value = "orderByUptime",required = false) String orderByUptime, + @RequestParam(value = "orderBysimilarity",required = false) String orderBysimilarity) { String tenantId = request.getHeader("X-Tenant-Id"); @@ -97,7 +98,7 @@ public class OcrTaskchildDubiousFileController { // // //IPage page = ocrpictureservice.page(iPage, wrapper); - Page page = ocrTaskchildDubiousFileService.dubiousfilelist(pageNo,pageSize,orderbyname,userToken,tenantId); + Page page = ocrTaskchildDubiousFileService.dubiousfilelist(pageNo,pageSize,orderByUptime,orderBysimilarity,userToken,tenantId); return ResultVoUtil.success(page); } diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/IOcrTaskchildDubiousFileService.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/IOcrTaskchildDubiousFileService.java index 50b579a2..fd361fb5 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/IOcrTaskchildDubiousFileService.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/IOcrTaskchildDubiousFileService.java @@ -17,6 +17,6 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface IOcrTaskchildDubiousFileService extends IService { - Page dubiousfilelist(Integer pageNo, Integer pageSize, String orderbyname, UserToken userToken, String tenantId); + Page dubiousfilelist(Integer pageNo, Integer pageSize,String orderByUptime,String orderBysimilarity,UserToken userToken, String tenantId); } diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrTaskchildDubiousFileServiceImpl.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrTaskchildDubiousFileServiceImpl.java index 2b07400e..df425f2f 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrTaskchildDubiousFileServiceImpl.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrTaskchildDubiousFileServiceImpl.java @@ -2,6 +2,7 @@ package cn.jyjz.xiaoyao.ocr.service.impl; import cn.hutool.core.collection.CollUtil; import cn.jyjz.flowable.common.ProcessConstant; +import cn.jyjz.xiaoyao.common.base.util.StringUtils; import cn.jyjz.xiaoyao.common.base.vo.ResultVoUtil; import cn.jyjz.xiaoyao.common.base.vo.UserToken; import cn.jyjz.xiaoyao.ocr.dataDao.OcrTaskchildDubiousFileMapper; @@ -47,13 +48,14 @@ public class OcrTaskchildDubiousFileServiceImpl extends ServiceImpl dubiousfilelist(Integer pageNo, Integer pageSize, String orderbyname, UserToken userToken, String tenantId) { + public Page dubiousfilelist(Integer pageNo, Integer pageSize,String orderByUptime,String orderBysimilarity,UserToken userToken, String tenantId) { Page objectPage = new Page<>(Integer.valueOf(pageNo), Integer.valueOf(pageSize)); @@ -74,13 +76,41 @@ public class OcrTaskchildDubiousFileServiceImpl extends ServiceImpl taskChildPictures = ocrTaskchildPictureService.getDubiousfileList(new ArrayList<>(pictureIdList), userNodeType); if (CollUtil.isNotEmpty(taskChildPictures)) { - //按时间字段排序 - if ("desc".equals(orderbyname)) { - taskChildPictures.sort(Comparator.comparing(OcrTaskChildPictureVo::getSubmitDateTimestamp).reversed()); - } else { - taskChildPictures.sort(Comparator.comparing(OcrTaskChildPictureVo::getSubmitDateTimestamp)); + + Comparator comparator = null; + + // 判断 orderByUptime 是否不为空 + if (orderByUptime != null && StringUtils.isNotEmpty(orderByUptime)) { + if ("asc".equals(orderByUptime)) { + comparator = Comparator.comparing(OcrTaskChildPictureVo::getSubmitDateTimestamp); + } else if ("desc".equals(orderByUptime)) { + comparator = Comparator.comparing(OcrTaskChildPictureVo::getSubmitDateTimestamp).reversed(); + } + } + + // 判断 orderBysimilarity 是否不为空 + if (orderBysimilarity != null && StringUtils.isNotEmpty(orderBysimilarity)) { + Comparator similarityComparator = null; + if ("asc".equals(orderBysimilarity)) { + similarityComparator = Comparator.comparing(OcrTaskChildPictureVo::getSimilarityScore); + } else if ("desc".equals(orderBysimilarity)) { + similarityComparator = Comparator.comparing(OcrTaskChildPictureVo::getSimilarityScore).reversed(); + } + + // 如果 orderByUptime 和 orderBysimilarity 都不为空,则先按照 orderBysimilarity 排序 + if (comparator != null) { + comparator = comparator.thenComparing(similarityComparator); + } else { + comparator = similarityComparator; + } + } + + // 进行排序 + if (comparator != null) { + taskChildPictures.sort(comparator); } + List records = taskChildPictures.stream().skip((pageNo - 1) * pageSize).limit(pageSize).collect(Collectors.toList()); objectPage.setRecords(records); objectPage.setTotal(taskChildPictures.size());