diff --git a/laws-modules/src/main/java/com/jero/modules/laws/documenttool/controller/DocumentSplitController.java b/laws-modules/src/main/java/com/jero/modules/laws/documenttool/controller/DocumentSplitController.java index e4622e9d..32c7701a 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/documenttool/controller/DocumentSplitController.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/documenttool/controller/DocumentSplitController.java @@ -496,6 +496,7 @@ public class DocumentSplitController { @ApiOperation(value = "标准拆分详情-查询所有拆分错误的标准") @GetMapping("/fixAllBadSplit") public Result fixAllBadSplit() { - return Result.OK(MessageUtils.getMessage(ResultCommon.OK), documentSplitService.fixAllBadSplit()); + documentSplitService.fixAllBadSplit(); + return Result.OK(MessageUtils.getMessage(ResultCommon.OK)); } } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/documenttool/service/IDocumentSplitService.java b/laws-modules/src/main/java/com/jero/modules/laws/documenttool/service/IDocumentSplitService.java index 6bf6f35d..4f79606b 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/documenttool/service/IDocumentSplitService.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/documenttool/service/IDocumentSplitService.java @@ -246,5 +246,5 @@ public interface IDocumentSplitService extends IService { */ void deleteBatchTitle(String ids); - String fixAllBadSplit(); + void fixAllBadSplit(); } diff --git a/laws-modules/src/main/java/com/jero/modules/laws/documenttool/service/impl/DocumentSplitServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/documenttool/service/impl/DocumentSplitServiceImpl.java index c55dbf21..c944f4c9 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/documenttool/service/impl/DocumentSplitServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/documenttool/service/impl/DocumentSplitServiceImpl.java @@ -106,6 +106,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.*; +import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.atomic.AtomicReference; import java.util.stream.Collectors; @@ -158,6 +159,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl data) { - if (CollectionUtils.isEmpty(data)){ + if (CollectionUtils.isEmpty(data)) { return; } // 获取标准信息 @@ -238,7 +240,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl authorList = data.stream().map(DocumentSplitInfo::getAuthor).distinct().collect(Collectors.toList()); List createByList = data.stream().map(DocumentSplitInfo::getCreateBy).distinct().collect(Collectors.toList()); List sysUserList = new ArrayList<>(); - if (!CollectionUtils.isEmpty(authorList) || !CollectionUtils.isEmpty(createByList)){ + if (!CollectionUtils.isEmpty(authorList) || !CollectionUtils.isEmpty(createByList)) { sysUserList = sysUserService.list( new LambdaQueryWrapper() .in(!CollectionUtils.isEmpty(authorList), SysUser::getId, authorList) @@ -247,16 +249,16 @@ public class DocumentSplitServiceImpl extends ServiceImpl first = sysUserList.stream() .filter(v -> v.getUsername().equals(documentSplitInfo.getCreateBy())).findFirst(); first.ifPresent(v -> documentSplitInfo.setCreateBy(v.getId())); @@ -272,7 +274,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl optionalSysUser = sysUserList.stream() .filter(v -> v.getId().equals(documentSplitInfo.getAuthor())).findFirst(); optionalSysUser.ifPresent(v -> { - if (!"云平台".equals(documentSplitInfo.getAuthor())){ + if (!"云平台".equals(documentSplitInfo.getAuthor())) { documentSplitInfo.setAuthor(v.calcNameWorkNo()); } }); @@ -295,9 +297,9 @@ public class DocumentSplitServiceImpl extends ServiceImpl updateWrapper = new LambdaUpdateWrapper<>(); List ids; // 获取id集合 - if (StringUtils.isNotBlank(documentSplitInfo.getIds())){ + if (StringUtils.isNotBlank(documentSplitInfo.getIds())) { ids = Arrays.asList(documentSplitInfo.getIds().split(",")); - }else { + } else { List documentSplitInfos = queryByList(documentSplitInfo); ids = documentSplitInfos.stream().map(DocumentSplitInfo::getId).collect(Collectors.toList()); } @@ -314,23 +316,24 @@ public class DocumentSplitServiceImpl extends ServiceImpl ids) { // 登陆人信息 LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); - if (sysUser.getRoleIds().contains("admin")){ + if (sysUser.getRoleIds().contains("admin")) { return; } List sarFileSplitInfoEOS = sarFileSplitInfoService.listByIds(ids); for (SarFileSplitInfoEO sarFileSplitInfoEO : sarFileSplitInfoEOS) { String createBy = sarFileSplitInfoEO.getCreateBy(); String author = sarFileSplitInfoEO.getAuthor(); - if (!sysUser.getUsername().equals(createBy) || !sysUser.getId().equals(author)){ - if(LanguageEnum.CN.getValue().equals(MessageUtils.getLanguage().getValue())) { + if (!sysUser.getUsername().equals(createBy) || !sysUser.getId().equals(author)) { + if (LanguageEnum.CN.getValue().equals(MessageUtils.getLanguage().getValue())) { throw new JeroBootException("只能删除有操作权限的数据!"); - }else{ + } else { throw new JeroBootException("You can delete only the data that you have permission to operate!"); } } @@ -343,7 +346,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl parameter, String selectCondition, List fieldListSelect) { StringBuilder sb = new StringBuilder(selectCondition); - if (parameter.containsKey("column")){ + if (parameter.containsKey("column")) { sb.append(" order by "); String column = (String) parameter.get("column"); String order = (String) parameter.get("order"); @@ -385,15 +388,15 @@ public class DocumentSplitServiceImpl extends ServiceImpl lawsTag = fieldListSelect.stream().filter(o -> column.equals(o.getDbFieldName())).findFirst(); lawsTag.ifPresent(l -> { // 多日期特殊处理 - if (LawsFieldTypeEnum.DATE_MANY.getValue().equals(l.getFieldShowType())){ + if (LawsFieldTypeEnum.DATE_MANY.getValue().equals(l.getFieldShowType())) { sb.append(DocumentSplitCommon.STR_TO_DATE_BEGIN + "substring_index(") .append(l.getDbFieldName()).append(", ',', -1)").append(",'%Y-%m-%d')"); - }else { + } else { sb.append(column); } }); sb.append(" ").append(order); - }else { + } else { // 默认排序 sb.append(" order by display_seq asc, sort_number is null, sort_number asc"); } @@ -430,10 +433,10 @@ public class DocumentSplitServiceImpl extends ServiceImpl map : records) { for (LawsTag lawsTag : lawsTags) { String dbFieldName = lawsTag.getDbFieldName(); - if (map.containsKey(dbFieldName)){ + if (map.containsKey(dbFieldName)) { // 字典查找 SysDict sysDict = sysDictService.getById(lawsTag.getDictId()); - if (!Objects.isNull(sysDict)){ + if (!Objects.isNull(sysDict)) { setDicText(map, dbFieldName, sysDict); } } @@ -445,13 +448,13 @@ public class DocumentSplitServiceImpl extends ServiceImpl map) { // 零部件翻译 - if (map.containsKey("applicable_components")){ + if (map.containsKey("applicable_components")) { String applicableComponents = (String) map.get("applicable_components"); List partNames = partNameService.queryEcho(applicableComponents); map.put("applicable_components_dictText", partNames.stream().map(PartName::getName).collect(Collectors.joining(","))); } // 属性标识翻译 - if (map.containsKey("property_tag")){ + if (map.containsKey("property_tag")) { String propertyTag = (String) map.get("property_tag"); List lawsLabelDatabases = lawsLabelDatabaseService.queryByCodes(propertyTag); map.put("property_tag_dictText", lawsLabelDatabases.stream().map(LawsLabelDatabase::getName).collect(Collectors.joining(","))); @@ -464,7 +467,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl list = sysDictItemService.list(queryWrapper); - if(!list.isEmpty()){ + if (!list.isEmpty()) { List itemTextList = list.stream().map(SysDictItem::getItemText).collect(Collectors.toList()); map.put(dbFieldName + DocumentSplitCommon.DIC_TEXT, String.join(",", itemTextList)); } @@ -481,10 +484,10 @@ public class DocumentSplitServiceImpl extends ServiceImpl roleIdList = Arrays.asList(sysUser.getRoleIds().split(",")); Collection intersection = CollectionUtils.intersection(adminRoleCodeList, roleIdList); - if (!intersection.isEmpty()){ + if (!intersection.isEmpty()) { // 有权限 return; } @@ -505,9 +508,9 @@ public class DocumentSplitServiceImpl extends ServiceImpl() .eq(LawsEnterpriseStandard::getStandardNumber, sarFileSplitInfoEO.getSerialNumber())); - if (!Objects.isNull(lawsEnterpriseStandard)){ + if (!Objects.isNull(lawsEnterpriseStandard)) { String id = lawsEnterpriseStandard.getId(); - if (StringUtils.isBlank(sarFileSplitInfoEO.getStandardId())){ + if (StringUtils.isBlank(sarFileSplitInfoEO.getStandardId())) { sarFileSplitInfoEO.setStandardId(id); } // 登陆人所在部门 @@ -530,13 +533,13 @@ public class DocumentSplitServiceImpl extends ServiceImpl tempAuthDeptList = enterpriseStandardAuthDeptService.list(tempAuthDeptWrapper); - if (!tempAuthDeptList.isEmpty()){ + if (!tempAuthDeptList.isEmpty()) { // 有权限 return; } tempAuthDeptWrapper.ge(EnterpriseStandardAuthDept::getAuthExpireDate, date); List authDeptExpireDateList = enterpriseStandardAuthDeptService.list(tempAuthDeptWrapper); - if (!authDeptExpireDateList.isEmpty()){ + if (!authDeptExpireDateList.isEmpty()) { // 有权限 return; } @@ -564,7 +567,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl articlesList = JSON.parseArray(JSON.toJSONString(parameter.get(INTERPRETATION_ARTICLES_LIST)), SarFileSplitItemsValEO.class); parameter.remove(INTERPRETATION_ARTICLES_LIST); parameter.putIfAbsent(INTERPRETATION_ARTICLES, ""); - parameter.forEach((k, v) ->{ + parameter.forEach((k, v) -> { // 条文内容拼接 - if (ITEM_CONTENT.equals(k)){ + if (ITEM_CONTENT.equals(k)) { v = itemContentJoin(valList, (String) parameter.get(ID)); } // 条文解读 - if (INTERPRETATION_ARTICLES.equals(k)){ + if (INTERPRETATION_ARTICLES.equals(k)) { v = articlesJoin(articlesList, (String) parameter.get(ID)); } // 修改字段 String updateValue = getUpdateValue(finalFieldList, k, (String) v); - if (StringUtils.isNotBlank(updateValue)){ + if (StringUtils.isNotBlank(updateValue)) { updateSet.append(updateValue).append(","); } }); @@ -655,7 +658,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl parameter) { - if (parameter!= null){ - parameter.forEach((k, v) ->{ - if (Objects.isNull(v)){ + if (parameter != null) { + parameter.forEach((k, v) -> { + if (Objects.isNull(v)) { parameter.put(k, ""); } }); @@ -683,9 +686,9 @@ public class DocumentSplitServiceImpl extends ServiceImpl").append(sarFileSplitItemsValEO.getItemContent()).append("

"); sarFileSplitItemsValEO.setId(UUIDUtils.randomUUID20()); sarFileSplitItemsValEO.setItemId(itemId); @@ -703,13 +706,13 @@ public class DocumentSplitServiceImpl extends ServiceImpl valList, String itemId) { StringBuilder valContent = new StringBuilder(); - if (!Objects.isNull(valList) && !valList.isEmpty()){ + if (!Objects.isNull(valList) && !valList.isEmpty()) { int index = 0; LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); for (SarFileSplitItemsValEO sarFileSplitItemsValEO : valList) { // 条文内容拼接 if (DocumentSplitCommon.TEXT.equals(sarFileSplitItemsValEO.getType())) { - if (StringUtils.isNotBlank(sarFileSplitItemsValEO.getItemContent())){ + if (StringUtils.isNotBlank(sarFileSplitItemsValEO.getItemContent())) { sarFileSplitItemsValEO.setItemContent(sarFileSplitItemsValEO.getItemContent() .replace("<", "<").replace(">", ">")); } @@ -743,10 +746,10 @@ public class DocumentSplitServiceImpl extends ServiceImpl sql = new AtomicReference<>(""); lawsTag.ifPresent(l -> { // 构建修改字段 - if (LawsFieldTypeEnum.DATE_MANY.getValue().equals(l.getFieldShowType())){ + if (LawsFieldTypeEnum.DATE_MANY.getValue().equals(l.getFieldShowType())) { // 多日期 sql.set(new DateManyConditionImpl().buildUpdate(l.getDbFieldName(), v)); - }else { + } else { sql.set(new UniversalImpl().buildUpdate(l.getDbFieldName(), v)); } }); @@ -775,12 +778,12 @@ public class DocumentSplitServiceImpl extends ServiceImpl { // 条文解读 - if (INTERPRETATION_ARTICLES.equals(k)){ + if (INTERPRETATION_ARTICLES.equals(k)) { v = articlesJoin(articlesList, (String) parameter.get(ID)); } // 修改字段 String updateValue = getUpdateValue(finalFieldList, k, (String) v); - if (StringUtils.isNotBlank(updateValue)){ + if (StringUtils.isNotBlank(updateValue)) { updateSet.append(updateValue).append(","); } }); @@ -790,11 +793,11 @@ public class DocumentSplitServiceImpl extends ServiceImpl list = Arrays.asList(ids.split(",")); updateCondition = "id in ('" + String.join("','", list) + "')"; - }else { + } else { String infoId = (String) parameter.get(INFO_ID); updateCondition = "info_id = " + "'" + infoId + "'"; } @@ -803,7 +806,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl otherIds = listMap.stream().map(v -> (String)v.get(ID)).collect(Collectors.toList()); + List otherIds = listMap.stream().map(v -> (String) v.get(ID)).collect(Collectors.toList()); // 删除旧数据 lawsDocumentSplitMapper.deleteBatchIds(otherIds); @@ -859,14 +862,14 @@ public class DocumentSplitServiceImpl extends ServiceImpl lawsDocumentSplits = documentSplitMapper.queryLawsDocumentSplitInIds(Collections.singletonList((String) firstData.get(ID))); List menuIds = documentSplitMapper.queryLawsDocumentSplitGroupByMenuId(lawsDocumentSplits.get(0).getInfoId()); - if (CollectionUtils.isNotEmpty(menuIds)){ + if (CollectionUtils.isNotEmpty(menuIds)) { menuIdList = menuIdList.stream().filter(v -> !menuIds.contains(v)).collect(Collectors.toList()); } - if (!menuIdList.isEmpty()){ + if (!menuIdList.isEmpty()) { // 删除旧数据 documentSplitMapper.sarFileSplitMenuDeleteByIdList(menuIdList); } @@ -882,7 +885,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl sarFileSplitItemsValEOS = documentSplitMapper.queryItemsValByItemId((String) firstData.get(ID), ""); // 第一条数据信息的最大的排序字段值 Optional sarFileSplitItemsValEOOptional = sarFileSplitItemsValEOS.stream().sorted(Comparator.comparing(v -> Integer.valueOf(String.valueOf(v.getDisplaySeq())))).findFirst(); - sarFileSplitItemsValEOOptional.ifPresent(v ->{ + sarFileSplitItemsValEOOptional.ifPresent(v -> { // 排序字段 Integer displaySeq = v.getDisplaySeq(); LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); @@ -895,7 +898,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl parameter) { - if (parameter.containsKey(IDS)){ + if (parameter.containsKey(IDS)) { String ids = (String) parameter.get(IDS); String[] list = ids.split(","); for (String id : list) { @@ -981,14 +984,14 @@ public class DocumentSplitServiceImpl extends ServiceImpl queryItemsValList(String itemId) { List sarFileSplitItemsValEOS = documentSplitMapper.queryItemsValByItemId(itemId, ""); - if (!Objects.isNull(sarFileSplitItemsValEOS) && !sarFileSplitItemsValEOS.isEmpty()){ + if (!Objects.isNull(sarFileSplitItemsValEOS) && !sarFileSplitItemsValEOS.isEmpty()) { for (SarFileSplitItemsValEO sarFileSplitItemsValEO : sarFileSplitItemsValEOS) { String imgPath = sarFileSplitItemsValEO.getItemContent(); if (DocumentSplitCommon.IMG.equals(sarFileSplitItemsValEO.getType()) && org.apache.commons.lang.StringUtils.isNotEmpty(imgPath)) { String imgName = imgPath.substring(imgPath.lastIndexOf("/") + 1); sarFileSplitItemsValEO.setImgName(imgName); } - if (DocumentSplitCommon.TEXT.equals(sarFileSplitItemsValEO.getType()) && org.apache.commons.lang.StringUtils.isNotEmpty(imgPath)){ + if (DocumentSplitCommon.TEXT.equals(sarFileSplitItemsValEO.getType()) && org.apache.commons.lang.StringUtils.isNotEmpty(imgPath)) { sarFileSplitItemsValEO.setItemContent(HtmlUtils.htmlUnescape(sarFileSplitItemsValEO.getItemContent())); } } @@ -1009,7 +1012,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl documentSplitInfos = queryByList(documentSplitInfo); lawsDocumentSplitView.setDocumentSplitInfo(documentSplitInfos.get(0)); - if (parameter.containsKey("item_content")){ + if (parameter.containsKey("item_content")) { itemContent = true; } // 文档拆分详情 @@ -1151,14 +1153,14 @@ public class DocumentSplitServiceImpl extends ServiceImpl menuId = documentSplitDetailByList.stream() .map(v -> String.valueOf(v.get("menu_id"))).distinct() .collect(Collectors.toList()); splitMenuEOPage.setIdList(menuId); List sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryByList(splitMenuEOPage); lawsDocumentSplitView.setSarFileSplitMenuEO(sarFileSplitMenuEOS); - }else { + } else { List sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryByList(splitMenuEOPage); // 不需要总目录层级 lawsDocumentSplitView.setSarFileSplitMenuEO(sarFileSplitMenuEOS.get(0).getChildren()); @@ -1166,6 +1168,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl processProjectAssessGetList(String ids) { List processProjectAssessTermList = new ArrayList<>(); @@ -1230,7 +1233,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl parameter, boolean b) { long l = System.currentTimeMillis(); String id = (String) parameter.get(ID); - if (b){ + if (b) { // 水平越权 isHorizontalOverstep(id); } @@ -1240,7 +1243,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl().lambda() .eq(SarFileSplitInfoEO::getPublishBeforeId, id)); - if (!Objects.isNull(sarFileSplitInfoEO)){ + if (!Objects.isNull(sarFileSplitInfoEO)) { // 删除旧发布数据 sarFileSplitInfoService.deleteById(sarFileSplitInfoEO.getId()); } @@ -1304,7 +1307,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl keyList = new ArrayList<>(map.keySet()); - List valueList = map.values().stream().map(o ->(String.valueOf(o))).collect(Collectors.toList()); + List valueList = map.values().stream().map(o -> (String.valueOf(o))).collect(Collectors.toList()); String insertField = String.join(",", keyList); documentSplitMapper.insertLawsDocumentSplit(insertField, valueList); } @@ -1317,12 +1320,12 @@ public class DocumentSplitServiceImpl extends ServiceImpl allvItemsValList) { int size = allvItemsValList.size(); - int count = (int)Math.ceil((double) size / NUMBER); + int count = (int) Math.ceil((double) size / NUMBER); for (int i = 1; i <= count; i++) { List list = allvItemsValList.stream() .skip((long) (Math.max(i, 1) - 1) * NUMBER) @@ -1348,7 +1351,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl parameter, HttpServletRequest request, HttpServletResponse response) { - try (Workbook workbook = new XSSFWorkbook()){ + try (Workbook workbook = new XSSFWorkbook()) { // 文档拆分详情数据 List> mapList = queryDocumentSplitDetailByList(parameter); // 创建工作簿 @@ -1357,7 +1360,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl keyList = new ArrayList<>(); - if(!Objects.isNull(mapList) && !mapList.isEmpty()){ + if (!Objects.isNull(mapList) && !mapList.isEmpty()) { Map map = mapList.get(0); keyList = map.entrySet().stream().map(Map.Entry::getKey).collect(Collectors.toList()); } @@ -1385,13 +1388,13 @@ public class DocumentSplitServiceImpl extends ServiceImpl(pageNo, pageSize)); @@ -1427,7 +1430,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryByList(splitMenuEOPage); - if (!sarFileSplitMenuEOS.isEmpty() && !Objects.isNull(sarFileSplitMenuEOS.get(0).getChildren())){ + if (!sarFileSplitMenuEOS.isEmpty() && !Objects.isNull(sarFileSplitMenuEOS.get(0).getChildren())) { return sarFileSplitMenuEOS.get(0).getChildren(); } return new ArrayList<>(); @@ -1439,7 +1442,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl queryWrapper = new QueryWrapper<>(); - if (StringUtils.isBlank(ids)){ + if (StringUtils.isBlank(ids)) { return; } List idList = Arrays.asList(ids.split(",")); @@ -1493,13 +1496,13 @@ public class DocumentSplitServiceImpl extends ServiceImpl", errorList)); } } @@ -1521,10 +1524,10 @@ public class DocumentSplitServiceImpl extends ServiceImpl() .eq(LawsDocumentSplit::getMenuId, menuId)); - if (!Objects.isNull(lawsDocumentSplit)){ + if (!Objects.isNull(lawsDocumentSplit)) { SarFileSplitItemsValEO sarFileSplitItemsValEO = new SarFileSplitItemsValEO(); sarFileSplitItemsValEO.setItemId(lawsDocumentSplit.getId()); sarFileSplitItemsValEO.setType("TEXT"); @@ -1634,10 +1637,10 @@ public class DocumentSplitServiceImpl extends ServiceImpl list = queryByList(documentSplitInfo); - if(!list.isEmpty()){ - if(LanguageEnum.CN.equals(MessageUtils.getLanguage())) { + if (!list.isEmpty()) { + if (LanguageEnum.CN.equals(MessageUtils.getLanguage())) { throw new JeroBootException("每个文件类型只能拆分一次!"); - }else{ + } else { throw new JeroBootException("Each file type can only be split once!"); } } @@ -1651,11 +1654,11 @@ public class DocumentSplitServiceImpl extends ServiceImpl parameter, StringBuilder selectCondition) { - if (parameter.containsKey(ID)){ + if (parameter.containsKey(ID)) { selectCondition.append(" and s.id = '").append(parameter.get(ID)).append("'"); parameter.remove(ID); } - if (parameter.containsKey(INFO_ID)){ + if (parameter.containsKey(INFO_ID)) { selectCondition.append(" and s.info_id = '").append(parameter.get(INFO_ID)).append("'"); parameter.remove(INFO_ID); } - if (parameter.containsKey(ITEM_NUM)){ + if (parameter.containsKey(ITEM_NUM)) { selectCondition.append(" and item_num = '").append(parameter.get(ITEM_NUM)).append("'"); parameter.remove(ITEM_NUM); } - if (parameter.containsKey(ITEM_TITLE)){ + if (parameter.containsKey(ITEM_TITLE)) { // 模糊匹配 selectCondition.append(likeCondition(ITEM_TITLE, (String) parameter.get(ITEM_TITLE))); parameter.remove(ITEM_TITLE); } - if (parameter.containsKey(ITEM_CONTENT)){ + if (parameter.containsKey(ITEM_CONTENT)) { // 模糊匹配 selectCondition.append(likeCondition(ITEM_CONTENT, (String) parameter.get(ITEM_CONTENT))); parameter.remove(ITEM_CONTENT); } // 树节点搜索 - if (parameter.containsKey(MENU_ID)){ + if (parameter.containsKey(MENU_ID)) { // 查询此节点下的所有子节点 SarFileSplitMenuEO sarFileSplitMenuEO = new SarFileSplitMenuEO(); - sarFileSplitMenuEO.setId( (String) parameter.get(MENU_ID)); + sarFileSplitMenuEO.setId((String) parameter.get(MENU_ID)); List sarFileSplitMenuEOS = sarFileSplitMenuEOService.queryAllChildrenById(sarFileSplitMenuEO); - if (!sarFileSplitMenuEOS.isEmpty()){ - String menuIds= sarFileSplitMenuEOS.stream() + if (!sarFileSplitMenuEOS.isEmpty()) { + String menuIds = sarFileSplitMenuEOS.stream() .map(SarFileSplitMenuEO::getId) .collect(Collectors.joining("','")); // in查询 @@ -1730,13 +1733,14 @@ public class DocumentSplitServiceImpl extends ServiceImpl lawsDomesticStandardList = lawsDomesticStandardService.list( new LambdaQueryWrapper() .like(LawsDomesticStandard::getStandardNumber, documentSplitInfo.getSerialNumber())); @@ -1782,7 +1786,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl lawsDomesticStandardList = lawsDomesticStandardService.list( new LambdaQueryWrapper() .like(LawsDomesticStandard::getStandardName, documentSplitInfo.getTitle())); @@ -1804,18 +1808,18 @@ public class DocumentSplitServiceImpl extends ServiceImpl sysUserList = sysUserService.list(new LambdaQueryWrapper().like(SysUser::getRealname, documentSplitInfo.getAuthor())); List sysUserIdList = sysUserList.stream().map(SysUser::getId).collect(Collectors.toList()); queryWrapper.and(qw -> - qw.in("author", sysUserIdList) - .or().eq("云平台".contains(documentSplitInfo.getAuthor()), "author", "云平台") + qw.in("author", sysUserIdList) + .or().eq("云平台".contains(documentSplitInfo.getAuthor()), "author", "云平台") ); } // 发布前id - if (StringUtils.isNotBlank(documentSplitInfo.getPublishBeforeId())){ + if (StringUtils.isNotBlank(documentSplitInfo.getPublishBeforeId())) { queryWrapper.eq("publish_before_id", documentSplitInfo.getPublishBeforeId()); - }else { + } else { queryWrapper.isNull("publish_before_id"); } LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); @@ -1825,7 +1829,7 @@ public class DocumentSplitServiceImpl extends ServiceImpl qwi.eq(SPLIT_STATUS, DocumentSplitCommon.SPLIT_STATUS1) .eq("author", loginUser.getId())) .or().eq(SPLIT_STATUS, DocumentSplitCommon.SPLIT_STATUS2) - .or().eq(roleIds.contains("admin"), "author", "云平台")); + .or().eq(roleIds.contains("admin"), "author", "云平台")); // 逻辑删除 queryWrapper.eq("del_flag", 0); // 排序 @@ -1834,72 +1838,81 @@ public class DocumentSplitServiceImpl extends ServiceImpl list = sarFileSplitItemsValEOService.list(); - Map> valMap = list.stream().collect(Collectors.groupingBy(SarFileSplitItemsValEO::getItemId)); - List imageOneList = list.stream().filter(val -> val.getItemContent().startsWith("图1")).collect(Collectors.toList()); - ConcurrentLinkedQueue itemIdList = new ConcurrentLinkedQueue<>(); - imageOneList.stream().parallel().forEach(one -> { - List vals = valMap.get(one.getItemId()); - if (vals.isEmpty()) { - return; - } - Map> orderMap = vals.stream().collect(Collectors.groupingBy(SarFileSplitItemsValEO::getDisplaySeq)); - List imageList = orderMap.get(one.getDisplaySeq() - 1); - if (imageList == null || imageList.isEmpty()) { - itemIdList.add(one.getItemId()); - return; - } - SarFileSplitItemsValEO image = imageList.get(0); - if (!image.getType().equals("IMG")) { - itemIdList.add(one.getItemId()); - } - }); + public void fixAllBadSplit() { + CompletableFuture.runAsync(() -> { + List list = sarFileSplitItemsValEOService.list(); + Map> valMap = list.stream().collect(Collectors.groupingBy(SarFileSplitItemsValEO::getItemId)); + List imageOneList = list.stream().filter(val -> val.getItemContent().startsWith("图1")).collect(Collectors.toList()); + ConcurrentLinkedQueue itemIdList = new ConcurrentLinkedQueue<>(); + imageOneList.stream().parallel().forEach(one -> { + List vals = valMap.get(one.getItemId()); + if (vals.isEmpty()) { + return; + } + Map> orderMap = vals.stream().collect(Collectors.groupingBy(SarFileSplitItemsValEO::getDisplaySeq)); + List imageList = orderMap.get(one.getDisplaySeq() - 1); + if (imageList == null || imageList.isEmpty()) { + itemIdList.add(one.getItemId()); + return; + } + SarFileSplitItemsValEO image = imageList.get(0); + if (!image.getType().equals("IMG")) { + itemIdList.add(one.getItemId()); + } + }); - // 找到所有infoId - LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); - lambdaQueryWrapper.in(LawsDocumentSplit::getId, itemIdList); - List documentSplistList = documentSplitService.list(lambdaQueryWrapper); - Set infoIdList = documentSplistList.stream() - .map(LawsDocumentSplit::getInfoId).collect(Collectors.toSet()); + // 找到所有infoId + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.in(LawsDocumentSplit::getId, itemIdList); + List documentSplistList = documentSplitService.list(lambdaQueryWrapper); + Set infoIdList = documentSplistList.stream() + .map(LawsDocumentSplit::getInfoId).collect(Collectors.toSet()); - // 找到所有info 并打印所有标准编号 和splitId - List esList = esService.list(); - List esStandardNoList = esList.stream().map(LawsEnterpriseStandard::getStandardNumber).collect(Collectors.toList()); - LambdaQueryWrapper infoEOLambdaQueryWrapper = new LambdaQueryWrapper<>(); - infoEOLambdaQueryWrapper.in(SarFileSplitInfoEO::getSerialNumber, esStandardNoList); - infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getDelFlag, YesOrNoEnum.NO.getValue()); - infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getSplitResult, "成功"); - infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getSplitStatus, "2"); - infoEOLambdaQueryWrapper.in(SarFileSplitInfoEO::getId, infoIdList); + // 找到所有info 并打印所有标准编号 和splitId + List esList = esService.list(); + List esStandardNoList = esList.stream().map(LawsEnterpriseStandard::getStandardNumber).collect(Collectors.toList()); + LambdaQueryWrapper infoEOLambdaQueryWrapper = new LambdaQueryWrapper<>(); + infoEOLambdaQueryWrapper.in(SarFileSplitInfoEO::getSerialNumber, esStandardNoList); + infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getDelFlag, YesOrNoEnum.NO.getValue()); + infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getSplitResult, "成功"); + infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getSplitStatus, "2"); + infoEOLambdaQueryWrapper.in(SarFileSplitInfoEO::getId, infoIdList); // infoEOLambdaQueryWrapper.eq(SarFileSplitInfoEO::getId, "19e6041480f8469bb9c2e09487ed8770"); - List infoList = sarFileSplitInfoService.list(infoEOLambdaQueryWrapper); - log.info("共发现{}条没有拆出图片的企标", infoList.size()); - // 开始重新拆分 - int count = 1; - List failedList = new ArrayList<>(); - for (SarFileSplitInfoEO info : infoList) { - try { - log.info("正在处理第{}条,企标编号{}", count, info.getSerialNumber()); - String fileId = info.getFileId(); - String infoId = info.getId(); - String author = info.getAuthor(); - // 删除拆分记录 - sarFileSplitInfoService.deleteByIds(Collections.singletonList(infoId)); - // 重新拆分 - JSONObject jsonObject = new JSONObject(); - jsonObject.put("ids", fileId); - documentSplitService.batchSplit(jsonObject, author); - log.info("第{}条处理完毕", count++); - } catch (Exception e) { - log.info("第{}条处理失败", count++); - failedList.add(info.getId()); + List infoList = sarFileSplitInfoService.list(infoEOLambdaQueryWrapper); + // 根据fileId去重 + long needSplit = infoList.stream().collect(Collectors.groupingBy(SarFileSplitInfoEO::getFileId)).entrySet().stream().count(); + log.info("共发现{}条没有拆出图片的企标", needSplit); + // 开始重新拆分 + List failedList = new ArrayList<>(); + Map alreadySplitMap = new HashMap<>(); + for (int i = 0; i < infoList.size(); i++) { + SarFileSplitInfoEO info = infoList.get(i); + try { + log.info("正在处理第{}条,企标编号{}", i, info.getSerialNumber()); + String fileId = info.getFileId(); + String infoId = info.getId(); + String author = info.getAuthor(); + // 删除拆分记录 + sarFileSplitInfoService.deleteByIds(Collections.singletonList(infoId)); + // 重新拆分 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("ids", fileId); + String s = alreadySplitMap.get(fileId); + if (s != null) { + log.info("该企标已经拆分过了,跳过{}", fileId); + continue; + } + alreadySplitMap.put(fileId, "split"); + documentSplitService.batchSplit(jsonObject, author); + log.info("第{}条处理完毕", i); + } catch (Exception e) { + log.info("第{}条处理失败", i); + failedList.add(info.getId()); + } } - } - // 将失败的标准编号打印出来,逗号拼接 - log.error("企标拆分失败企标编号:{}", StringUtils.join(failedList, ",")); - return failedList.size() + "条企标拆分失败"; + // 将失败的标准编号打印出来,逗号拼接 + log.error("企标拆分失败企标编号:{}", StringUtils.join(failedList, ",")); + }); } -} +} \ No newline at end of file