diff --git a/laws-module-system/src/main/java/com/jero/modules/system/entity/SysDictItem.java b/laws-module-system/src/main/java/com/jero/modules/system/entity/SysDictItem.java index a6063732..da368cc3 100644 --- a/laws-module-system/src/main/java/com/jero/modules/system/entity/SysDictItem.java +++ b/laws-module-system/src/main/java/com/jero/modules/system/entity/SysDictItem.java @@ -4,10 +4,12 @@ import com.baomidou.mybatisplus.annotation.*; import com.jero.common.aspect.annotation.Dict; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; -import java.util.Date; import lombok.Data; import org.jeecgframework.poi.excel.annotation.Excel; +import java.util.Date; +import java.util.List; + /** * @author liJiaRao * @date 2023-11-20 15:46 @@ -162,4 +164,15 @@ public class SysDictItem { private String pId; @TableField(exist = false) private String dictCode; -} \ No newline at end of file + + /** + * 层级 + */ + @TableField(exist = false) + private String levelPath; + /** + * 层级 + */ + @TableField(exist = false) + private List childrenList; +} 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 a67f0c6d..891f5bee 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 @@ -66,11 +66,8 @@ import com.jero.modules.tag.enums.TableNameEnum; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.poi.hssf.usermodel.HSSFDataFormat; import org.apache.poi.ss.usermodel.*; -import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFRichTextString; -import org.apache.poi.xssf.usermodel.XSSFSheet; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.shiro.SecurityUtils; import org.jetbrains.annotations.NotNull; @@ -81,6 +78,7 @@ import org.jsoup.select.Elements; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.io.ClassPathResource; import org.springframework.stereotype.Service; import org.springframework.transaction.PlatformTransactionManager; import org.springframework.transaction.TransactionDefinition; @@ -94,6 +92,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.atomic.AtomicReference; @@ -135,6 +134,37 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { private static final String ITEM_NUM = "item_num"; private static final String ITEM_TITLE = "item_title"; private static final String ITEM_CONTENT = "item_content"; + private static final String TRANSLATION = "translation"; + private static final String IS_SAME_AS_PREV_VERSION = "is_same_as_prev_version"; + private static final String CHANGE_DESCRIPTION = "change_description"; + private static final String REGULATORY_NOTES = "regulatory_notes"; + private static final String KEYWORDS = "keywords"; + private static final String KEY_CONTROLLER = "key_controller"; + private static final String APPLICABLE_COMPONENTS = "applicable_components"; + private static final String RESPONSIBLE_DEPARTMENT = "responsible_department"; + private static final String RESPONSIBLE_MODULE = "responsible_module"; + private static final String RELATED_DEPARTMENT = "related_department"; + private static final String RELATED_MODULE = "related_module"; + private static final String APPLICATIONS = "applications"; + private static final String POWER_TYPE = "power_type"; + private static final String DOMAIN_AREA = "domain_area"; + private static final String CONFIGURATION_REQUIREMENTS = "configuration_requirements"; + private static final String NEW_CER_IMPLEMENT_DATE = "new_cer_implement_date"; + private static final String NEW_PRODUCTION_IMPLEMENTATION = "new_production_implementation"; + private static final String REGISTRATION_DATE = "registration_date"; + private static final String ENTERPRISE_STANDARD = "enterprise_standard"; + private static final String TECHNICAL_SPECIFICATION_DESIGN_GUIDE = "technical_specification_design_guide"; + private static final String DRAWING_TEMPLATE = "drawing_template"; + private static final String TECHNICAL_AGREEMENT_TEMPLATE = "technical_agreement_template"; + private static final String VERIFICATION_REPORT_TEMPLATE_CHECKLIST = "verification_report_template_checklist"; + private static final String DVP_TEMPLATE = "dvp_template"; + private static final String DFEMA = "dfema"; + private static final String KEY_TECHNOLOGY_DECOMPOSITION_TABLE = "key_technology_decomposition_table"; + private static final String OTHER_DOCUMENTS_TEMPLATES = "other_documents_templates"; + private static final String INVESTIGATION_STAGE = "investigation_stage"; + private static final String P3 = "p3"; + private static final String P5 = "p5"; + private static final String REMARKSS = "remarkss"; private static final String INTERPRETATION_ARTICLES = "interpretation_articles"; private static final String INTERPRETATION_ARTICLES_LIST = "interpretationArticlesList"; private static final String MENU_ID = "menu_id"; @@ -372,6 +402,18 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { List partNames = partNameService.queryEcho(applicableComponents); map.put("applicable_components_dictText", partNames.stream().map(PartName::getName).collect(Collectors.joining(","))); } + // 涉及系统/部件(关键词) + if (map.containsKey("keywords")){ + String applicableComponents = (String) map.get("keywords"); + List partNames = partNameService.queryEcho(applicableComponents); + map.put("keywords_dictText", partNames.stream().map(PartName::getName).collect(Collectors.joining(","))); + } + // 关键控制器 + if (map.containsKey("key_controller")){ + String applicableComponents = (String) map.get("key_controller"); + List partNames = partNameService.queryEcho(applicableComponents); + map.put("key_controller_dictText", partNames.stream().map(PartName::getName).collect(Collectors.joining(","))); + } // 属性标识翻译 if (map.containsKey("property_tag")){ String propertyTag = (String) map.get("property_tag"); @@ -738,14 +780,76 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { // 第一条数据 Map firstData = listMap.get(0); listMap.remove(0); - // 合并数据(条文标题、条文内容) - String title = firstData.get(ITEM_TITLE) + " " + mergeData(listMap, ITEM_TITLE); - String content = firstData.get(ITEM_CONTENT) + mergeData(listMap, ITEM_CONTENT); + // 合并数据(条文标题、条文内容、等全部字段) + String title = firstData.get(ITEM_TITLE) + " " + mergeData(listMap, ITEM_TITLE, false); + String content = firstData.get(ITEM_CONTENT) + mergeData(listMap, ITEM_CONTENT, false); + listMap.add(0, firstData); + String translation = firstData.get(TRANSLATION) + mergeData(listMap, TRANSLATION, false); + String changeDescription = firstData.get(CHANGE_DESCRIPTION) + mergeData(listMap, CHANGE_DESCRIPTION, false); + String regulatoryNotes = firstData.get(REGULATORY_NOTES) + mergeData(listMap, REGULATORY_NOTES, false); + String keywords = firstData.get(KEYWORDS) + mergeData(listMap, KEYWORDS, true); + String keyController = mergeData2(listMap, KEY_CONTROLLER, true); + String applicableComponents = mergeData2(listMap, APPLICABLE_COMPONENTS, true); + String responsibleDepartment = mergeData2(listMap, RESPONSIBLE_DEPARTMENT, true); + String responsibleModule = mergeData2(listMap, RESPONSIBLE_MODULE, true); + String relatedDepartment = mergeData2(listMap, RELATED_DEPARTMENT, true); + String relatedModule = mergeData2(listMap, RELATED_MODULE, true); + String applications = mergeData2(listMap, APPLICATIONS, true); + String powerType = mergeData2(listMap, POWER_TYPE, true); + String domainArea = mergeData2(listMap, DOMAIN_AREA, true); + String configurationRequirements = mergeData2(listMap, CONFIGURATION_REQUIREMENTS, true); + String newCerImplementDate = mergeData2(listMap, NEW_CER_IMPLEMENT_DATE, true); + String newProductionImplementation = mergeData2(listMap, NEW_PRODUCTION_IMPLEMENTATION, true); + String registrationDate = mergeData2(listMap, REGISTRATION_DATE, true); + String enterpriseStandard = mergeData2(listMap, ENTERPRISE_STANDARD, true); + String technicalSpecificationDesignGuide = mergeData2(listMap, TECHNICAL_SPECIFICATION_DESIGN_GUIDE, true); + String drawingTemplate = firstData.get(DRAWING_TEMPLATE) + mergeData(listMap, DRAWING_TEMPLATE, false); + String technicalAgreementTemplate = firstData.get(TECHNICAL_AGREEMENT_TEMPLATE) + mergeData(listMap, TECHNICAL_AGREEMENT_TEMPLATE, false); + String verificationReportTemplateChecklist = firstData.get(VERIFICATION_REPORT_TEMPLATE_CHECKLIST) + mergeData(listMap, VERIFICATION_REPORT_TEMPLATE_CHECKLIST, false); + String dvpTemplate = firstData.get(DVP_TEMPLATE) + mergeData(listMap, DVP_TEMPLATE, false); + String dfema = firstData.get(DFEMA) + mergeData(listMap, DFEMA, false); + String keyTechnologyDecompositionTable = firstData.get(KEY_TECHNOLOGY_DECOMPOSITION_TABLE) + mergeData(listMap, KEY_TECHNOLOGY_DECOMPOSITION_TABLE, false); + String otherDocumentsTemplates = firstData.get(OTHER_DOCUMENTS_TEMPLATES) + mergeData(listMap, OTHER_DOCUMENTS_TEMPLATES, false); + String investigationStage = firstData.get(INVESTIGATION_STAGE) + mergeData(listMap, INVESTIGATION_STAGE, false); + String p3 = firstData.get(this.P3) + mergeData(listMap, this.P3, false); + String p5 = firstData.get(this.P5) + mergeData(listMap, this.P5, false); + String remarkss = firstData.get(REMARKSS) + mergeData(listMap, REMARKSS, false); String updateByAndUpdateTime = new UniversalImpl().getUpdateByAndUpdateTime(); String updateSet = updateByAndUpdateTime + "," + ITEM_TITLE + " = " + "' "+ title + "'" + - "," + ITEM_CONTENT + " = " + "'" + content + "'"; + "," + ITEM_CONTENT + " = " + "'" + content + "'" + + "," + TRANSLATION + " = " + "'" + translation + "'" + + "," + CHANGE_DESCRIPTION + " = " + "'" + changeDescription + "'" + + "," + REGULATORY_NOTES + " = " + "'" + regulatoryNotes + "'" + + "," + KEYWORDS + " = " + "'" + keywords + "'" + + "," + KEY_CONTROLLER + " = " + "'" + keyController + "'" + + "," + APPLICABLE_COMPONENTS + " = " + "'" + applicableComponents + "'" + + "," + RESPONSIBLE_DEPARTMENT + " = " + "'" + responsibleDepartment + "'" + + "," + RESPONSIBLE_MODULE + " = " + "'" + responsibleModule + "'" + + "," + RELATED_DEPARTMENT + " = " + "'" + relatedDepartment + "'" + + "," + RELATED_MODULE + " = " + "'" + relatedModule + "'" + + "," + APPLICATIONS + " = " + "'" + applications + "'" + + "," + POWER_TYPE + " = " + "'" + powerType + "'" + + "," + DOMAIN_AREA + " = " + "'" + domainArea + "'" + + "," + CONFIGURATION_REQUIREMENTS + " = " + "'" + configurationRequirements + "'" + + "," + NEW_CER_IMPLEMENT_DATE + " = " + "'" + newCerImplementDate + "'" + + "," + NEW_PRODUCTION_IMPLEMENTATION + " = " + "'" + newProductionImplementation + "'" + + "," + REGISTRATION_DATE + " = " + "'" + registrationDate + "'" + + "," + ENTERPRISE_STANDARD + " = " + "'" + enterpriseStandard + "'" + + "," + TECHNICAL_SPECIFICATION_DESIGN_GUIDE + " = " + "'" + technicalSpecificationDesignGuide + "'" + + "," + DRAWING_TEMPLATE + " = " + "'" + drawingTemplate + "'" + + "," + TECHNICAL_AGREEMENT_TEMPLATE + " = " + "'" + technicalAgreementTemplate + "'" + + "," + VERIFICATION_REPORT_TEMPLATE_CHECKLIST + " = " + "'" + verificationReportTemplateChecklist + "'" + + "," + DVP_TEMPLATE + " = " + "'" + dvpTemplate + "'" + + "," + DFEMA + " = " + "'" + dfema + "'" + + "," + KEY_TECHNOLOGY_DECOMPOSITION_TABLE + " = " + "'" + keyTechnologyDecompositionTable + "'" + + "," + OTHER_DOCUMENTS_TEMPLATES + " = " + "'" + otherDocumentsTemplates + "'" + + "," + INVESTIGATION_STAGE + " = " + "'" + investigationStage + "'" + + "," + P3 + " = " + "'" + p3 + "'" + + "," + P5 + " = " + "'" + p5 + "'" + + "," + REMARKSS + " = " + "'" + remarkss + "'"; String updateCondition = "id = " + "'" + firstData.get(ID) + "'"; + listMap.remove(0); // 修改数据 documentSplitMapper.editDocumentSplitDetail(updateSet, updateCondition); List otherIds = listMap.stream().map(v -> (String)v.get(ID)).collect(Collectors.toList()); @@ -908,63 +1012,53 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { public void downloadImportTemplate(HttpServletRequest request, HttpServletResponse response) { // 水平越权 isHorizontalOverstep(request.getParameter("infoId")); - - try (Workbook workbook = new XSSFWorkbook()){ - String fileName = "拆分导入模版下载.xlsx"; - // sheet页 - XSSFSheet sheet = (XSSFSheet) workbook.createSheet("拆分导入模版"); - // 列宽 - sheet.setDefaultColumnWidth(16); - // 创建第一行 - Row headerRow = sheet.createRow(0); - // 创建表头信息 - String[] titleArr = {"条文号", "条文标题", "条文内容"}; - - //样式 - CellStyle cellStyle = workbook.createCellStyle(); - // 水平、垂直居中 - cellStyle.setAlignment(HorizontalAlignment.CENTER); - cellStyle.setVerticalAlignment(VerticalAlignment.CENTER); - // 文本格式 - cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("@")); - - for (int i = 0; i < titleArr.length; i++) { - // 创建列 - Cell cell = headerRow.createCell(i); - cell.setCellValue(titleArr[i]); - cell.setCellStyle(cellStyle); + ClassPathResource resource = new ClassPathResource("excelTemplate/条款导入模板.xlsx"); + // 设置HTTP响应头,包括文件大小和内容类型 + response.setContentType("application/vnd.ms-excel"); // 根据实际文件类型设置内容类型 + response.setHeader("Content-Disposition", "attachment; filename=条款导入模板.xlsx"); + String filePath = ""; + // 将文件内容写入HTTP响应输出流中 + try (InputStream in = resource.getInputStream()) { + // 导出文件 + filePath = exportExcelTempPath + File.separator + "条款导入模板"; + String excelFilePath = filePath + File.separator + "条款导入模板.xlsx"; + writeToLocal(excelFilePath, in); + ZipUtil.toZip(filePath, response.getOutputStream(), response, true); + } catch (IOException e) { + throw new JeroBootException(e); + } finally { + // 删除文件 + if (new File(filePath).exists()) { + FileUtils.deleteFolders(filePath); } + } + } - // 创建第二行 - Row headerRowTwo = sheet.createRow(1); - // 填充说明 - Cell cell = headerRowTwo.createCell(0); - String explain = "模版说明:\n" + - "1.条文号不能为空\n" + - "2.仅支持zip格式文件夹\n" + - "3.条文内容如果导入表格类型,表格的名称需要与sheet页名称保持一致"; - - CellStyle cellStyleTwo = workbook.createCellStyle(); - cellStyleTwo.setWrapText(true); - cell.setCellStyle(cellStyleTwo); - // 行高 - headerRowTwo.setHeight((short) 1500); - cell.setCellValue(new XSSFRichTextString(explain)); - // 合并单元格(参数说明:起始行,结束行,起始列,结束列) - CellRangeAddress region = new CellRangeAddress(1, 1, 0, 2); - sheet.addMergedRegion(region); - - // excel临时保存到本地并在同级创建文件夹 - String replacePath = exportExcelTempPath.replace("exportExcelTemp", "拆分导入模版下载"); - generateExcel(workbook, fileName, replacePath); - - // 生成zip文件返回文件流 - ZipUtil.toZip(replacePath, response.getOutputStream(), response, true); - - //删除指定文件夹 - FileUtils.deleteFolders(replacePath); + /** + * 将InputStream写入本地文件 + * + * @param filePath 写入本地目录 + * @param input 输入流 + * @throws IOException + */ + public void writeToLocal(String filePath, InputStream input) + throws IOException { + // 导出路径 没有则创建 + File saveFile = new File(filePath.substring(0, filePath.lastIndexOf(File.separator))); + if (!saveFile.exists()) { + saveFile.mkdirs(); + } + int index; + byte[] bytes = new byte[1024]; + try (FileOutputStream downloadFile = new FileOutputStream(filePath)){ + while ((index = input.read(bytes)) != -1) { + downloadFile.write(bytes, 0, index); + downloadFile.flush(); + } }catch (Exception e){ - throw new JeroBootException("下载文件失败!"); + log.error("将InputStream写入本地失败:{}", e.getMessage()); + }finally { + input.close(); } } @@ -1398,15 +1492,38 @@ public class DocumentSplitServiceImpl implements IDocumentSplitService { } - private String mergeData(List> listMap, String key) { + private String mergeData(List> listMap, String key, boolean isDistinct) { StringBuilder stringBuilder = new StringBuilder(); + List list = new ArrayList<>(); for (Map map : listMap) { + if (isDistinct){ + // 去重 + String valueString = map.get(key).toString(); + if (list.contains(valueString)){ + continue; + } + list.add(valueString); + } String content = (String) map.get(key); stringBuilder.append(content); } return stringBuilder.toString(); } + private String mergeData2(List> listMap, String key, boolean isDistinct) { + List list = new ArrayList<>(); + for (Map map : listMap) { + String[] split = map.get(key).toString().split(","); + for (String s : split) { + if (isDistinct && list.contains(s)){ + continue; + } + list.add(s); + } + } + return String.join(",", list); + } + @Override public void saveDocumentSplitInfo(SarFileSplitInfoEO sarFileSplitInfoEO) { LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); diff --git a/laws-modules/src/main/java/com/jero/modules/laws/standard/entity/PartName.java b/laws-modules/src/main/java/com/jero/modules/laws/standard/entity/PartName.java index 3a6a3ac9..cd4bb4d8 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/standard/entity/PartName.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/standard/entity/PartName.java @@ -4,17 +4,16 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; - -import java.io.Serializable; -import java.util.Date; -import java.util.List; - import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.experimental.Accessors; +import java.io.Serializable; +import java.util.Date; +import java.util.List; + /** * @TableName laws_part_name */ @@ -116,4 +115,10 @@ public class PartName implements Serializable { @TableField(exist = false) private static final long serialVersionUID = 1L; + + /** + * 层级 + */ + @TableField(exist = false) + private String levelPath; } diff --git a/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java index 1f85d3e1..644568de 100644 --- a/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/split/service/impl/FileSplitItemsEOServiceImpl.java @@ -51,10 +51,10 @@ import com.jero.modules.split.service.ISarFileSplitInfoService; import com.jero.modules.split.service.ISarFileSplitItemsValEOService; import com.jero.modules.split.service.ISarFileSplitMenuEOService; import com.jero.modules.split.util.POIReadExcelToHtml; -import com.jero.modules.system.entity.SysCategory; -import com.jero.modules.system.entity.SysCategoryTreeVO; -import com.jero.modules.system.entity.SysDictItem; -import com.jero.modules.system.entity.SysUser; +import com.jero.modules.system.entity.*; +import com.jero.modules.system.service.ISysDepartService; +import com.jero.modules.system.service.ISysDictItemService; +import com.jero.modules.system.service.ISysDictService; import com.jero.modules.system.service.ISysUserService; import com.jero.modules.system.service.impl.SysCategoryServiceImpl; import com.jero.modules.system.service.impl.SysDictItemServiceImpl; @@ -146,6 +146,12 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl SPECIAL_FIELD = Arrays.asList("keywords", "key_controller", "applicable_components"); + @Value("${download.enable}") public void setEnable(boolean enable) { ENCRYPT_ENABLE = enable; @@ -1877,7 +1885,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl map = null; //获得所有数据 - //从第3行开始获取,第一行是表头,第二行是填写说明 - for (int x = 2; x <= totalRowNum; x++) { + //从第4行开始获取,第一行是表头,第二行是填写说明 + for (int x = 3; x <= totalRowNum; x++) { map = new HashMap(); //获得第i行对象 Row row= sheet.getRow(x); @@ -2031,10 +2039,15 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl sysDictTreeList = sysDictService.list(new LambdaQueryWrapper().eq(SysDict::getAttributeType, "2")); + // 组织结构 + List sysDepartList = sysDepartService.list(); + // 适用零部件 + List partNameList = new ArrayList<>(); //存放数据验证结果信息 List stringMessage = new ArrayList<>(); - int i = 2; //记录行号 + int i = 3; //记录行号 int num = 0; //记录是第几条数据 //循环验证数据 for (Map dto : datas) { @@ -2053,6 +2066,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl valueList = new ArrayList<>(); String field = ""; for (Map map : fieldList) { String fieldName = (String) map.get("db_field_txt");//中文名称/英文名称 @@ -2060,6 +2074,7 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl first = sysDepartList.stream().filter(o -> v.equals(o.getDepartName())).findFirst(); + if (!first.isPresent()) { + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) { + errorMsg += fieldName + "中组织机构" + v + "不存在;"; + } else { + errorMsg += fieldName + " " + v + "Not exist;"; + } + countError++; + valueList = Collections.emptyList(); + break; + }else { + valueList.add(first.get().getId()); + } + } + } + }else if (FieldTypeEnum.TREE_BOX.getValue().equals(fieldShowType)) { + // 树型结构(多选) + //判断是否必填 + if (IsMustEnum.YES.getValue().equals(mustInput) && StringUtils.isBlank(value)) { + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) { + errorMsg += fieldName + "为必填项,不能为空;"; + } else { + errorMsg += fieldName + " is mandatory and cannot be empty;"; + } + countError++; + } + + if (StringUtils.isNotBlank(value) && StringUtils.isNotBlank(dictField)){ + Optional firstDict = sysDictTreeList.stream().filter(o -> dictField.equals(o.getDictCode())).findFirst(); + if (firstDict.isPresent()){ + List sysDictItemLists = sysDictItemService.list(new LambdaQueryWrapper() + .eq(SysDictItem::getDictId, firstDict.get().getId())); + List sysDictItemList = getLevelPath(sysDictItemLists); + String[] treePathList = value.split(","); + for (String treePath : treePathList) { + List path = + sysDictItemList.stream().filter(o -> treePath.equals(o.getLevelPath())) + .collect(Collectors.toList()); + if (!path.isEmpty()){ + if (path.size() > 1) { + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) { + errorMsg += fieldName + "中" + treePath + "存在多个;"; + countError++; + valueList = Collections.emptyList(); + } else { + errorMsg += fieldName + " " + treePath + "Exist in multiple;"; + } + break; + } + valueList.add(path.get(0).getItemValue()); + }else { + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) { + errorMsg += fieldName + "中" + treePath + "不存在;"; + countError++; + valueList = Collections.emptyList(); + } else { + errorMsg += fieldName + " " + treePath + "Not exist;"; + } + break; + } + } + } + } + } + + // 特殊字段 + if (StringUtils.isNotBlank(value) && SPECIAL_FIELD.contains(dbfieldName)){ + if (partNameList.isEmpty()){ + List partNames = partNameService.list(new LambdaQueryWrapper().ne(PartName::getCode, "Part")); + partNameList = partNameGetLevelPath(partNames); + } + String[] treePathList = value.split(","); + for (String treePath : treePathList) { + List path = + partNameList.stream().filter(o -> treePath.equals(o.getLevelPath())) + .collect(Collectors.toList()); + if (!path.isEmpty()){ + if (path.size() > 1) { + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) { + errorMsg += fieldName + "中" + treePath + "存在多个;"; + countError++; + valueList = Collections.emptyList(); + } else { + errorMsg += fieldName + " " + treePath + "Exist in multiple;"; + } + break; + } + valueList.add(path.get(0).getCode()); + }else { + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) { + errorMsg += fieldName + "中" + treePath + "不存在;"; + countError++; + valueList = Collections.emptyList(); + } else { + errorMsg += fieldName + " " + treePath + "Not exist;"; + } + break; + } + } } } } + if (!valueList.isEmpty()){ + value = String.join(",", valueList); + } if((dto.get(key)== null && value != null) || (dto.get(key)!= null && !dto.get(key).toString().equals(value))){ dto.put(key, value); // 覆盖原来的值 } @@ -2536,6 +2667,54 @@ public class FileSplitItemsEOServiceImpl extends ServiceImpl partNameGetLevelPath(List partNames) { + List list = new ArrayList<>(); + // 一级节点 + List firstLevelList = partNames.stream().filter(o -> o.getParentCode().equals("Part")).collect(Collectors.toList()); + queryPartNameChildren(firstLevelList, partNames, "", list); + return list; + } + + private void queryPartNameChildren(List firstLevelList, List partNames, String levelPath, List list) { + for (PartName partName : firstLevelList) { + if (StringUtils.isBlank(levelPath)){ + partName.setLevelPath(partName.getName()); + }else { + partName.setLevelPath(levelPath + "/" + partName.getName()); + } + list.add(partName); + List children = partNames.stream() + .filter(v -> v.getParentCode().equals(partName.getCode())).collect(Collectors.toList()); + if (!children.isEmpty()){ + queryPartNameChildren(children, partNames, partName.getLevelPath(), list); + } + } + } + + private List getLevelPath(List sysDictItemLists) { + List list = new ArrayList<>(); + // 一级节点 + List firstLevelList = sysDictItemLists.stream().filter(v -> v.getParentId().equals("0")).collect(Collectors.toList()); + queryChildren(firstLevelList, sysDictItemLists, "", list); + return list; + } + + private void queryChildren(List treeList, List sysDictItemLists, String levelPath, List list) { + for (SysDictItem sysDictItem : treeList) { + if (StringUtils.isBlank(levelPath)){ + sysDictItem.setLevelPath(sysDictItem.getItemText()); + }else { + sysDictItem.setLevelPath(levelPath + "/" + sysDictItem.getItemText()); + } + list.add(sysDictItem); + List children = sysDictItemLists.stream() + .filter(v -> v.getParentId().equals(sysDictItem.getId())).collect(Collectors.toList()); + if (!children.isEmpty()){ + queryChildren(children, sysDictItemLists, sysDictItem.getLevelPath(), list); + } + } + } + private void createItemsInfo(Map sarFileSplitItemsEO, String menuId, String infoId){ LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); String userId = sysUser.getId(); diff --git a/laws-modules/src/main/resources/excelTemplate/条款导入模板.xlsx b/laws-modules/src/main/resources/excelTemplate/条款导入模板.xlsx new file mode 100644 index 00000000..7fad60b7 Binary files /dev/null and b/laws-modules/src/main/resources/excelTemplate/条款导入模板.xlsx differ