|
@ -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 { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |