From 1c0e3adad284048acc9debc6d0ee39310dadc74a Mon Sep 17 00:00:00 2001 From: liu_li <421691338@qq.com> Date: Sun, 18 Sep 2022 21:36:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ArchivesTypeServiceImpl.java | 89 +++++-------------- .../service/impl/DynamicTableImpl.java | 2 +- 2 files changed, 21 insertions(+), 70 deletions(-) diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java index 7547af8..2282e20 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java @@ -17,6 +17,7 @@ import com.storeroom.utils.ValidationUtil; import lombok.RequiredArgsConstructor; +import org.apache.poi.util.LittleEndian; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -51,7 +52,12 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService { } //如果类型为模版 if (archivesType.getIsType() == 6) { - createProject(archivesType, tableName); + if (archivesType.getChildren().size() != 0) { + String cnName = archivesType.getCnName(); + archivesType.getChildren().forEach(item -> { + + }); + } return archivesType; } @@ -64,82 +70,27 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService { } else { throw new BaseException("门类名称不能重复"); } + return archivesType; } - /** - * 创建项目级门类 - */ - private void createProject(ArchivesType archivesType, String tableName) { - String cnName = archivesType.getCnName(); - tableName += DateUtils.getNowDateTime(); - archivesType.setId(NanoIdUtils.randomNanoId()); - archivesType.setEnName(tableName); - archivesType = archivesTypeRepository.save(archivesType); - dynamicTableService.DynamicCreate(archivesType.getIsType(), archivesType.getId(), tableName); - - //获取项目级ID - String pid = archivesType.getId(); - //重新赋值表名 - tableName = "tb_"; - tableName += DateUtils.getNowDateTime(); - - archivesType.setId(NanoIdUtils.randomNanoId()); - archivesType.setCnName(cnName + "(案卷)"); - archivesType.setEnName(tableName); - archivesType.setPid(pid); - //修改门类类型为案卷 - archivesType.setIsType(3); - //保存案卷级 - archivesTypeRepository.save(archivesType); - dynamicTableService.DynamicCreate(archivesType.getIsType(), archivesType.getId(), tableName); - - //重新赋值表名 - tableName = "tb_"; - tableName += DateUtils.getNowDateTime(); - - archivesType.setId(NanoIdUtils.randomNanoId()); - archivesType.setCnName(cnName + "(卷内)"); - archivesType.setEnName(tableName); - archivesType.setPid(pid); - //修改门类类型为案卷 - archivesType.setIsType(4); - //保存案卷级 - archivesTypeRepository.save(archivesType); - dynamicTableService.DynamicCreate(archivesType.getIsType(), archivesType.getId(), tableName); - } /** - * 创建案卷级门类 + * 创建模版门类 * * @param archivesType - * @param tableName */ - private void createArchives(ArchivesType archivesType, String tableName) { - //获取门类名称方便创建子集门类 - String cnName = archivesType.getCnName(); - - tableName += DateUtils.getNowDateTime(); - archivesType.setId(NanoIdUtils.randomNanoId()); - archivesType.setEnName(tableName); - archivesType = archivesTypeRepository.save(archivesType); - dynamicTableService.DynamicCreate(archivesType.getIsType(), archivesType.getId(), tableName); - - //获取项目级ID - String pid = archivesType.getId(); - //重新赋值表名 - tableName = "tb_"; - tableName += DateUtils.getNowDateTime(); - - archivesType.setId(NanoIdUtils.randomNanoId()); - archivesType.setCnName(cnName + "(卷内)"); - archivesType.setEnName(tableName); - archivesType.setPid(pid); - //修改门类类型为案卷 - archivesType.setIsType(4); - //保存案卷级 - archivesTypeRepository.save(archivesType); - dynamicTableService.DynamicCreate(archivesType.getIsType(), archivesType.getId(), tableName); + private void createTemplate(String pid,String cnName,ArchivesType archivesType) { + + archivesType.getChildren().forEach(item -> { + ArchivesType archivesType1=new ArchivesType(); + archivesType1.setId(NanoIdUtils.randomNanoId()); + archivesType1.setPid(pid); + archivesType1.setCnName(cnName+"案卷"); + getChildren(item.getId(), item.getChildren()); + }); + List list = archivesType.getChildren().stream().map(item -> item.setChildren(getChildren(item.getId(), item.getChildren()))) + .sorted(Comparator.comparingInt(menu -> (menu.getCategorySeq() == null ? 0 : menu.getCategorySeq()))).toList(); } diff --git a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java index c723a2b..346d9c2 100644 --- a/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java +++ b/archives/src/main/java/com/storeroom/modules/dictionary/service/impl/DynamicTableImpl.java @@ -49,7 +49,7 @@ public class DynamicTableImpl implements DynamicTableService { DynamicInsert(fieldList, archiveTypeId); //生成表和表名创建表名 DynamicCreateFileTable(fieldList, tableName); - //清楚数组 + //清除数组 integerList.clear(); //查询类型为3的字段 integerList.add(3);