diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrAiApprovalTools.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrAiApprovalTools.java index a71e887b..aa3720d8 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrAiApprovalTools.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrAiApprovalTools.java @@ -52,7 +52,7 @@ public class OcrAiApprovalTools { UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request)); - ResultVo toolscount = iocrsearchhistoryservice.toolscount(tenantId); + ResultVo toolscount = iocrsearchhistoryservice.toolscount(tenantId,userToken.getUserid()); return toolscount; } @@ -60,10 +60,11 @@ public class OcrAiApprovalTools { ai审批工单 */ @RequestMapping(value = "/aiApprovaltools", method = RequestMethod.GET) - public ResultVo aiApprovaltools(HttpServletRequest request,@RequestParam(value = "taskid", required = true) String taskid) { + public ResultVo aiApprovaltools(HttpServletRequest request,@RequestParam(value = "taskid", required = true) String taskid, + @RequestParam(value = "nodeType", required = true) Integer nodeType) { UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request)); - Map selectaisp = iocrsearchhistoryservice.selectaisp(userToken.getUserid(), taskid); + Map selectaisp = iocrsearchhistoryservice.selectaisp(userToken.getUserid(), taskid,nodeType); return ResultVoUtil.success(selectaisp); } diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrCheckDuplicateController.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrCheckDuplicateController.java index d0dca01f..8828f0d6 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrCheckDuplicateController.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/controller/OcrCheckDuplicateController.java @@ -83,6 +83,7 @@ public class OcrCheckDuplicateController { queryWrapper = SearchParaFormatting.searchParaParse(queryWrapper, paraMap); queryWrapper.eq("tenant_id", tenantId); + queryWrapper.eq("suspiciousfile", "0"); List pageList = ocrPictureService.listPage(queryWrapper); if (null != pageList && !pageList.isEmpty()) { if (pageList.size() == 1) { diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/dataDao/OcrSearchHistoryMapper.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/dataDao/OcrSearchHistoryMapper.java index 3c78666e..ee45c32e 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/dataDao/OcrSearchHistoryMapper.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/dataDao/OcrSearchHistoryMapper.java @@ -27,9 +27,13 @@ public interface OcrSearchHistoryMapper extends BaseMapper { - Map toolscount(@Param("tenantid")String tenantid); +// Map toolscount(@Param("tenantid")String tenantid); + + Map toolscount(@Param("userId")String userId); Map selectaisp(@Param("id")String id); + List> selectaispList(@Param("id")String id); + String selectaiuser(@Param("userid")String userid); } diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/IOcrSearchHistoryService.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/IOcrSearchHistoryService.java index 5624c592..82e991e3 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/IOcrSearchHistoryService.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/IOcrSearchHistoryService.java @@ -19,9 +19,9 @@ import java.util.Map; public interface IOcrSearchHistoryService extends IService { Map>> selectsearch(String search, String assignee, String userId, String tenantId); - ResultVo toolscount(String tenantid); + ResultVo toolscount(String tenantid,String userId); - Map selectaisp(String userid,String id); + Map selectaisp(String userid,String id,Integer nodeType); ResultVo clearmark(String id); diff --git a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrCheckDuplicateServiceImpl.java b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrCheckDuplicateServiceImpl.java index 3f60c2be..cf6c2c00 100644 --- a/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrCheckDuplicateServiceImpl.java +++ b/jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrCheckDuplicateServiceImpl.java @@ -33,6 +33,8 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.io.PrintWriter; +import java.io.StringWriter; import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -104,6 +106,12 @@ public class OcrCheckDuplicateServiceImpl extends ServiceImpl map = this.getOcrPictureClassifyAndHash(ocrPicture.getLocalpictrueurl()); + String url = ocrPicture.getLocalpictrueurl(); + if(StringUtils.isBlank(url)){ + if(StringUtils.isBlank(ocrPicture.getImgurl())){ + continue; + } + url = ocrPicture.getImgurl(); + } + + Map map = this.getOcrPictureClassifyAndHash(url); if (map != null) { ocrPicture.setImgHash(map.get("hash")); ocrPicture.setClassificationid(map.get("classId")); @@ -203,7 +219,15 @@ public class OcrCheckDuplicateServiceImpl extends ServiceImpl map = this.getOcrPictureClassifyAndHash(ocrPictureNext.getLocalpictrueurl()); + logger.info("图片没有hash值,进入分类并获取hash接口:{}",JSONObject.toJSON(ocrPictureNext)); + String url = ocrPictureNext.getLocalpictrueurl(); + if(StringUtils.isBlank(url)){ + if(StringUtils.isBlank(ocrPictureNext.getImgurl())){ + continue; + } + url = ocrPictureNext.getImgurl(); + } + Map map = this.getOcrPictureClassifyAndHash(url); if (map != null) { ocrPictureNext.setImgHash(map.get("hash")); ocrPictureNext.setClassificationid(map.get("classId")); @@ -247,18 +271,26 @@ public class OcrCheckDuplicateServiceImpl extends ServiceImpl toolscount = ocrsearchhistorymapper.toolscount(tenantid); + Map toolscount = ocrsearchhistorymapper.toolscount(userId); return ResultVoUtil.success(toolscount); } +// @Override +// public Map selectaisp(String userid,String id) { +// Map selectaisp = ocrsearchhistorymapper.selectaisp(id); +// if(null==selectaisp){ +// return null; +// } +// String selectaiuser = ocrsearchhistorymapper.selectaiuser(userid); +// +// String[] cps = selectaisp.get("pictureresult").toString().split(","); +// +// List saveList = new ArrayList<>(); +// int i=0; +// for (String childpictureid : cps) { +// if (childpictureid.equals("100")){ +// i++; +// } +// } +// +// Map map=new HashMap<>(); +// map.put("taskid",id); +// map.put("tenantusername",selectaiuser); +// map.put("packagename",selectaisp.get("packagename")); +// map.put("tasks","基线任务"); +//// map.put("similarcount",selectaisp.get("similarcount")); +// map.put("createtime",selectaisp.get("createtime")); +// map.put("similarComplete",i); +// +// return map; +// } + @Override - public Map selectaisp(String userid,String id) { - Map selectaisp = ocrsearchhistorymapper.selectaisp(id); - if(null==selectaisp){ - return null; + public Map selectaisp(String userid, String id,Integer nodeType) { + List> resultList = ocrsearchhistorymapper.selectaispList(id); + if (resultList == null || resultList.isEmpty()) { + return Collections.emptyMap(); } - String selectaiuser = ocrsearchhistorymapper.selectaiuser(userid); - - String[] cps = selectaisp.get("pictureresult").toString().split(","); - List saveList = new ArrayList<>(); - int i=0; - for (String childpictureid : cps) { - if (childpictureid.equals("100")){ - i++; + Map mappedResults = new LinkedHashMap<>(); + String selectaiuser = ocrsearchhistorymapper.selectaiuser(userid); + mappedResults.put("packageId", id); + mappedResults.put("tenantUserName", selectaiuser); + mappedResults.put("packageName", resultList.get(0).get("packageName")); + mappedResults.put("createTime", resultList.get(0).get("createTime")); + int similarComplete = 0; + List pictureIds = new ArrayList<>(); // 存储所有的pictureId + for (Map selectaisp : resultList) { + Object pictureResult = selectaisp.get("pictureResult"); + String pictureResultStr = pictureResult.toString(); + if ("100.0".equals(pictureResultStr)) { + similarComplete++; + Long pictureId = (Long) selectaisp.get("pictureId"); + if (pictureId != null) { + pictureIds.add(String.valueOf(pictureId)); // 转换为String + } + } + } + if(similarComplete==0){ + return Collections.emptyMap(); + } + List pendingApprovalList = new ArrayList<>(); // 存储待审批的pictureId集合 + List approvedList = new ArrayList<>(); // 存储通过的pictureId集合 + List failedList = new ArrayList<>(); // 存储不通过的pictureId集合 + List failedPictureIds = ocrPictureService.getPictureNodeStatesList(pictureIds, nodeType); + for (OcrPicture picture : failedPictureIds) { + if (picture.getHistoryStates() == 3) { + failedList.add(picture.getPictureid()); + } else if (picture.getHistoryStates() == 1) { + pendingApprovalList.add(picture.getPictureid()); + } else if (picture.getHistoryStates() == 2) { + approvedList.add(picture.getPictureid()); } } - Map map=new HashMap<>(); - map.put("taskid",id); - map.put("tenantusername",selectaiuser); - map.put("packagename",selectaisp.get("packagename")); - map.put("tasks","基线任务"); -// map.put("similarcount",selectaisp.get("similarcount")); - map.put("createtime",selectaisp.get("createtime")); - map.put("similarComplete",i); - - return map; + int pendingApprovaCount = pendingApprovalList.size(); // 待审批的数量 + int passCount = approvedList.size(); // 通过的数量 + mappedResults.put("similarComplete", similarComplete); + mappedResults.put("passCount", passCount); + mappedResults.put("pendingApprovaCount", pendingApprovaCount); + mappedResults.put("pictureIdList", pendingApprovalList); + return mappedResults; } + @Override public ResultVo clearmark(String id) { diff --git a/jyjz-system/jyjz-system-oa/src/main/resources/mapper/oa/OcrSearchHistoryMapper.xml b/jyjz-system/jyjz-system-oa/src/main/resources/mapper/oa/OcrSearchHistoryMapper.xml index 6ea6dd23..5a91ecc4 100644 --- a/jyjz-system/jyjz-system-oa/src/main/resources/mapper/oa/OcrSearchHistoryMapper.xml +++ b/jyjz-system/jyjz-system-oa/src/main/resources/mapper/oa/OcrSearchHistoryMapper.xml @@ -59,29 +59,37 @@ + + + + + + + - - - - - - + - SELECT tp.id as id, - tp.name as packagename, - GROUP_CONCAT(IFNULL(cdr.max_similarity, 0)) as pictureresult, - tp.create_time as createtime + tp.name as packageName, + cdr.picture_id as pictureId, + IFNULL(cdr.max_similarity, 0) as pictureResult, + tp.create_time as createTime FROM ocr_task_package tp LEFT JOIN ocr_check_duplicate_result cdr ON tp.check_duplicate_id = cdr.check_duplicate_id @@ -89,6 +97,7 @@ tp.ID = #{id} +