Browse Source

修改门类模版生成方法

master
liu_li 2 years ago
parent
commit
ac8a118868
  1. 1
      archives/src/main/java/com/storeroom/modules/common/ArchivesTypeEnum.java
  2. 3
      archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java
  3. 91
      archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java

1
archives/src/main/java/com/storeroom/modules/common/ArchivesTypeEnum.java

@ -8,6 +8,7 @@ public enum ArchivesTypeEnum {
folder(1, "文件夹"), folder(1, "文件夹"),
project(2, "项目"), project(2, "项目"),
archives(3, "案卷"), archives(3, "案卷"),
inChive(4, "卷内"), inChive(4, "卷内"),
files(5, "文件"), files(5, "文件"),

3
archives/src/main/java/com/storeroom/modules/dictionary/controller/ArchivesTypeController.java

@ -62,6 +62,9 @@ public class ArchivesTypeController {
if (StringUtils.isEmpty(archivesTypeDTO.getCnName())) { if (StringUtils.isEmpty(archivesTypeDTO.getCnName())) {
throw new BaseException("名称不能为空"); throw new BaseException("名称不能为空");
} }
if (archivesTypeDTO.getIsType() == 1 || archivesTypeDTO.getIsType() == 4) {
throw new BaseException("文件夹或卷内不能被选中");
}
return ApiResponse.success(archivesTypeService.create(archivesTypeDTO)); return ApiResponse.success(archivesTypeService.create(archivesTypeDTO));
} }

91
archives/src/main/java/com/storeroom/modules/dictionary/service/impl/ArchivesTypeServiceImpl.java

@ -44,20 +44,105 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
ArchivesType archivesType = archivesTypeMapper.toEntity(archivesTypeDTO); ArchivesType archivesType = archivesTypeMapper.toEntity(archivesTypeDTO);
List<ArchivesType> archivesType1 = archivesTypeRepository.findByCnName(archivesType.getCnName()); List<ArchivesType> archivesType1 = archivesTypeRepository.findByCnName(archivesType.getCnName());
if (archivesType1.size() == 0) { if (archivesType1.size() == 0) {
tableName += DateUtils.getNowDateTime();
//如果pid 为空就是顶级菜单
if (archivesType.getPid() == null) { if (archivesType.getPid() == null) {
archivesType.setPid("0"); archivesType.setPid("0");
} }
//如果类型为模版
if (archivesType.getIsType() == 6) {
createProject(archivesType, tableName);
return archivesType;
}
tableName += DateUtils.getNowDateTime();
archivesType.setId(NanoIdUtils.randomNanoId()); archivesType.setId(NanoIdUtils.randomNanoId());
archivesType.setEnName(tableName); archivesType.setEnName(tableName);
archivesType = archivesTypeRepository.save(archivesType); archivesType = archivesTypeRepository.save(archivesType);
dynamicTableService.DynamicCreate(archivesType.getIsType(), archivesType.getId(), tableName); dynamicTableService.DynamicCreate(archivesType.getIsType(), archivesType.getId(), tableName);
} else { } else {
throw new BaseException("门类名称不能重复"); throw new BaseException("门类名称不能重复");
} }
return archivesType; 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);
}
@Override @Override
public List<ArchivesType> buildTree() { public List<ArchivesType> buildTree() {
@ -109,8 +194,7 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
throw new BaseException("该门类存在档案信息,不可删除"); throw new BaseException("该门类存在档案信息,不可删除");
//查询子类 //查询子类
if(archivesType.getIsType()!=ArchivesTypeEnum.files.getCode() && archivesType.getIsType() != ArchivesTypeEnum.inChive.getCode())
{
if (archivesType.getIsType() != ArchivesTypeEnum.files.getCode() && archivesType.getIsType() != ArchivesTypeEnum.inChive.getCode()) {
Integer sonCount = archivesTypeRepository.findSonContextCount(archivesType.getId()); Integer sonCount = archivesTypeRepository.findSonContextCount(archivesType.getId());
if (sonCount > 0) if (sonCount > 0)
throw new BaseException("该门类其子级门类存在档案信息,不可删除"); throw new BaseException("该门类其子级门类存在档案信息,不可删除");
@ -235,5 +319,4 @@ public class ArchivesTypeServiceImpl implements ArchivesTypeService {
} }
} }
Loading…
Cancel
Save