|
|
@ -370,6 +370,14 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
}else{ |
|
|
|
archivesSummary.setArchivesId(insertId); |
|
|
|
archivesSummary.setChild(0); |
|
|
|
//如果有父级 |
|
|
|
if(!StringUtils.isEmpty(dto.getParentsId())){ |
|
|
|
ArchivesType archivesTypeP = archivesTypeRepository.findByPid(archivesType.getId()); |
|
|
|
entityManager.createNativeQuery("update "+archivesTypeP.getEnName()+" set child = (select count(1) from " |
|
|
|
+archivesType.getEnName()+"where parent_id ='"+dto.getParentsId()+"') where id = '"+dto.getParentsId()+"'").executeUpdate(); |
|
|
|
entityManager.createNativeQuery("update archives_summary set child = (select count(1) from " |
|
|
|
+archivesType.getEnName()+"where parent_id ='"+dto.getParentsId()+"') where archives_id = '"+dto.getParentsId()+"'").executeUpdate(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//档号 |
|
|
@ -451,6 +459,7 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Object editFile(ArchivesFileDTO dto) { |
|
|
|
int result = 0; |
|
|
|
String archiveId = ""; |
|
|
|
ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); |
|
|
|
List<ArchivesDictionary> queryShow = archivesDictionaryRepository.findAllByCategoryIdAndIsTypeOrderByIsSequenceAsc(dto.getCategoryId(),3); |
|
|
|
ArchivesDictionary idad = new ArchivesDictionary(); |
|
|
@ -477,8 +486,10 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
String sql = "insert into file_"+archivesType.getEnName()+"("+queryFields+") values ("+insertValue+")"; |
|
|
|
int thisresult = entityManager.createNativeQuery(sql).executeUpdate(); |
|
|
|
result += thisresult; |
|
|
|
archiveId = json.get("archive_id")+""; |
|
|
|
} |
|
|
|
|
|
|
|
entityManager.createNativeQuery("update "+archivesType.getEnName()+" set child = "+result+" where id='"+archiveId+"'").executeUpdate(); |
|
|
|
entityManager.createNativeQuery("update archives_summary set child = "+result+" where archives_id = '"+archiveId+"'").executeUpdate(); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@ -486,6 +497,12 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public Object deleteFile(ArchivesFileDTO dto,String prefixPath) { |
|
|
|
ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); |
|
|
|
String archiveId = ""; |
|
|
|
if(dto.getIds().size()!=0){ |
|
|
|
archiveId = entityManager.createNativeQuery("select archive_id from "+archivesType.getEnName() |
|
|
|
+" where id = '"+dto.getIds().get(0)+"'").getResultList().get(0)+""; |
|
|
|
} |
|
|
|
|
|
|
|
String ids = dto.getIds().stream().map(String::valueOf).collect(Collectors.joining("','")); |
|
|
|
ids = ids.length() > 0 ? "'"+ids+"'" : ids; |
|
|
|
// ids.replaceAll("\"",""); |
|
|
@ -501,6 +518,10 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
entityManager.createNativeQuery("update "+archivesType.getEnName()+" set child = (select count(1) from file_"+ |
|
|
|
archivesType.getEnName()+" where archive_id = '"+archiveId+"') where id='"+archiveId+"'").executeUpdate(); |
|
|
|
entityManager.createNativeQuery("update archives_summary set child = (select count(1) from file_"+ |
|
|
|
archivesType.getEnName()+" where archive_id = '"+archiveId+"') where archives_id = '"+archiveId+"'").executeUpdate(); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
@ -531,7 +552,22 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
ArchivesSummary archivesSummary = archivesSummaryRepository.findByArchivesId(id); |
|
|
|
archivesSummary.setIsDeleteTime(delTime); |
|
|
|
archivesSummary.setUpdateTime(new Timestamp(System.currentTimeMillis())); |
|
|
|
archivesSummary.setChild(0); |
|
|
|
archivesSummaryRepository.saveAndFlush(archivesSummary); |
|
|
|
|
|
|
|
//修改父级 |
|
|
|
Optional<ArchivesType> optional = archivesTypeRepository.findById(archivesType.getId()); |
|
|
|
if(optional.isPresent()) { |
|
|
|
ArchivesType archivesTypeP = optional.get(); |
|
|
|
String updateChild = "update " + archivesTypeP.getEnName() + " set child = (select count(1) from " + archivesType.getEnName() |
|
|
|
+ " where parent_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id |
|
|
|
+ "')) where id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + "')"; |
|
|
|
String updateChild2 = "update archives_summary set child = (select count(1) from " + archivesType.getEnName() |
|
|
|
+ " where parent_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id |
|
|
|
+ "')) where archives_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + "')"; |
|
|
|
entityManager.createNativeQuery(updateChild).executeUpdate(); |
|
|
|
entityManager.createNativeQuery(updateChild2).executeUpdate(); |
|
|
|
} |
|
|
|
} |
|
|
|
//若删除为项目 |
|
|
|
if(archivesType.getIsType() == 2){ |
|
|
@ -636,6 +672,20 @@ public class ArchivesServiceImpl implements ArchivesService { |
|
|
|
archivesSummary.setUpdateTime(new Timestamp(System.currentTimeMillis())); |
|
|
|
archivesSummaryRepository.saveAndFlush(archivesSummary); |
|
|
|
|
|
|
|
//修改父级 |
|
|
|
Optional<ArchivesType> optional = archivesTypeRepository.findById(archivesType.getId()); |
|
|
|
if(optional.isPresent()){ |
|
|
|
ArchivesType archivesTypeP = optional.get(); |
|
|
|
String updateChild = "update "+archivesTypeP.getEnName()+" set child = (select count(1) from "+archivesType.getEnName() |
|
|
|
+" where parent_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id |
|
|
|
+"')) where id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id+"')"; |
|
|
|
String updateChild2 = "update archives_summary set child = (select count(1) from "+archivesType.getEnName() |
|
|
|
+" where parent_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id |
|
|
|
+"')) where archives_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id+"')"; |
|
|
|
entityManager.createNativeQuery(updateChild).executeUpdate(); |
|
|
|
entityManager.createNativeQuery(updateChild2).executeUpdate(); |
|
|
|
} |
|
|
|
|
|
|
|
success += result; |
|
|
|
} |
|
|
|
|
|
|
|