@ -28,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.persistence.EntityManager ;
import javax.persistence.EntityManager ;
import javax.persistence.PersistenceContext ;
import javax.persistence.PersistenceContext ;
import java.io.File ;
import java.io.File ;
import java.sql.Timestamp ;
import java.text.SimpleDateFormat ;
import java.text.SimpleDateFormat ;
import java.util.* ;
import java.util.* ;
import java.util.stream.Collectors ;
import java.util.stream.Collectors ;
@ -522,10 +523,16 @@ public class ArchivesServiceImpl implements ArchivesService {
ArchivesType archivesType = archivesTypeRepository . findById ( dto . getCategoryId ( ) ) . get ( ) ;
ArchivesType archivesType = archivesTypeRepository . findById ( dto . getCategoryId ( ) ) . get ( ) ;
List < String > ids = dto . getIds ( ) ;
List < String > ids = dto . getIds ( ) ;
String queryTable = archivesType . getEnName ( ) ;
String queryTable = archivesType . getEnName ( ) ;
String sql = "update " + queryTable + " set is_delete_time = '" + sdf . format ( new Date ( ) ) + "',is_delete_man='" + dto . getDelMan ( )
String delTime = sdf . format ( new Date ( ) ) ;
String sql = "update " + queryTable + " set is_delete_time = '" + delTime + "',is_delete_man='" + dto . getDelMan ( )
+ "' where id in ('" + ids . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
+ "' where id in ('" + ids . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
int result = entityManager . createNativeQuery ( sql ) . executeUpdate ( ) ;
int result = entityManager . createNativeQuery ( sql ) . executeUpdate ( ) ;
for ( String id : ids ) {
ArchivesSummary archivesSummary = archivesSummaryRepository . findByArchivesId ( id ) ;
archivesSummary . setIsDeleteTime ( delTime ) ;
archivesSummary . setUpdateTime ( new Timestamp ( System . currentTimeMillis ( ) ) ) ;
archivesSummaryRepository . saveAndFlush ( archivesSummary ) ;
}
/ / 若删除为项目
/ / 若删除为项目
if ( archivesType . getIsType ( ) = = 2 ) {
if ( archivesType . getIsType ( ) = = 2 ) {
/ / 获取档案表名
/ / 获取档案表名
@ -535,22 +542,49 @@ public class ArchivesServiceImpl implements ArchivesService {
List < String > list3 = entityManager . createNativeQuery ( query3sql ) . getResultList ( ) ;
List < String > list3 = entityManager . createNativeQuery ( query3sql ) . getResultList ( ) ;
if ( null ! = list3 & & list3 . size ( ) ! = 0 ) {
if ( null ! = list3 & & list3 . size ( ) ! = 0 ) {
/ / 删除案卷
/ / 删除案卷
String update3sql = "update " + archivesType_3 . getEnName ( ) + " set is_delete_time = '" + sdf . format ( new Date ( ) ) + "',is_delete_man='" + dto . getDelMan ( )
String update3sql = "update " + archivesType_3 . getEnName ( ) + " set is_delete_time = '" + delTime + "',is_delete_man='" + dto . getDelMan ( )
+ "' where id in ('" + list3 . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
+ "' where id in ('" + list3 . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
/ / 获取卷内表名
/ / 获取卷内表名
String enName_4 = archivesTypeRepository . findEnNameByPid ( archivesType_3 . getId ( ) ) ;
String enName_4 = archivesTypeRepository . findEnNameByPid ( archivesType_3 . getId ( ) ) ;
String query4sql = "select id from " + enName_4 + " where parent_id in ('" + list3 . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
List < String > list4 = entityManager . createNativeQuery ( query4sql ) . getResultList ( ) ;
/ / 删除卷内
/ / 删除卷内
String update4sql = "update " + enName_4 + " set is_delete_time = '" + sdf . format ( new Date ( ) ) + "',is_delete_man='" + dto . getDelMan ( )
String update4sql = "update " + enName_4 + " set is_delete_time = '" + delTime + "',is_delete_man='" + dto . getDelMan ( )
+ "' where parent_id in ('" + list3 . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
+ "' where parent_id in ('" + list3 . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
entityManager . createNativeQuery ( update3sql ) . executeUpdate ( ) ;
entityManager . createNativeQuery ( update3sql ) . executeUpdate ( ) ;
entityManager . createNativeQuery ( update4sql ) . executeUpdate ( ) ;
entityManager . createNativeQuery ( update4sql ) . executeUpdate ( ) ;
for ( String id : list3 ) {
ArchivesSummary archivesSummary = archivesSummaryRepository . findByArchivesId ( id ) ;
archivesSummary . setIsDeleteTime ( delTime ) ;
archivesSummary . setUpdateTime ( new Timestamp ( System . currentTimeMillis ( ) ) ) ;
archivesSummaryRepository . saveAndFlush ( archivesSummary ) ;
}
for ( String id : list4 ) {
ArchivesSummary archivesSummary = archivesSummaryRepository . findByArchivesId ( id ) ;
archivesSummary . setIsDeleteTime ( delTime ) ;
archivesSummary . setUpdateTime ( new Timestamp ( System . currentTimeMillis ( ) ) ) ;
archivesSummaryRepository . saveAndFlush ( archivesSummary ) ;
}
}
}
/ / 若删除为案卷
/ / 若删除为案卷
} else if ( archivesType . getIsType ( ) = = 3 ) {
} else if ( archivesType . getIsType ( ) = = 3 ) {
String enName_4 = archivesTypeRepository . findEnNameByPid ( archivesType . getId ( ) ) ;
String enName_4 = archivesTypeRepository . findEnNameByPid ( archivesType . getId ( ) ) ;
String update4sql = "update " + enName_4 + " set is_delete_time = '" + sdf . format ( new Date ( ) ) + "',is_delete_man='" + dto . getDelMan ( )
String update4sql = "update " + enName_4 + " set is_delete_time = '" + delTime + "',is_delete_man='" + dto . getDelMan ( )
+ "' where parent_id in ('" + ids . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
+ "' where parent_id in ('" + ids . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
String query4sql = "select id from " + enName_4 + " where parent_id in ('" + ids . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
List < String > list4 = entityManager . createNativeQuery ( query4sql ) . getResultList ( ) ;
entityManager . createNativeQuery ( update4sql ) . executeUpdate ( ) ;
entityManager . createNativeQuery ( update4sql ) . executeUpdate ( ) ;
for ( String id : list4 ) {
ArchivesSummary archivesSummary = archivesSummaryRepository . findByArchivesId ( id ) ;
archivesSummary . setIsDeleteTime ( delTime ) ;
archivesSummary . setUpdateTime ( new Timestamp ( System . currentTimeMillis ( ) ) ) ;
archivesSummaryRepository . saveAndFlush ( archivesSummary ) ;
}
}
}
return result ;
return result ;
}
}
@ -596,6 +630,12 @@ public class ArchivesServiceImpl implements ArchivesService {
String sql = "update " + archivesType . getEnName ( ) + " set is_delete_time = null,is_delete_man = null " +
String sql = "update " + archivesType . getEnName ( ) + " set is_delete_time = null,is_delete_man = null " +
"where id = '" + id + "'" ;
"where id = '" + id + "'" ;
int result = entityManager . createNativeQuery ( sql ) . executeUpdate ( ) ;
int result = entityManager . createNativeQuery ( sql ) . executeUpdate ( ) ;
ArchivesSummary archivesSummary = archivesSummaryRepository . findByArchivesId ( id ) ;
archivesSummary . setIsDeleteTime ( null ) ;
archivesSummary . setUpdateTime ( new Timestamp ( System . currentTimeMillis ( ) ) ) ;
archivesSummaryRepository . saveAndFlush ( archivesSummary ) ;
success + = result ;
success + = result ;
}
}
@ -628,6 +668,12 @@ public class ArchivesServiceImpl implements ArchivesService {
String sql_3 = "update " + archivesType_3 . getEnName ( ) + " set is_delete_time = null,is_delete_man = null " +
String sql_3 = "update " + archivesType_3 . getEnName ( ) + " set is_delete_time = null,is_delete_man = null " +
"where id = '" + id + "'" ;
"where id = '" + id + "'" ;
int result_3 = entityManager . createNativeQuery ( sql_3 ) . executeUpdate ( ) ;
int result_3 = entityManager . createNativeQuery ( sql_3 ) . executeUpdate ( ) ;
ArchivesSummary archivesSummary = archivesSummaryRepository . findByArchivesId ( id ) ;
archivesSummary . setIsDeleteTime ( null ) ;
archivesSummary . setUpdateTime ( new Timestamp ( System . currentTimeMillis ( ) ) ) ;
archivesSummaryRepository . saveAndFlush ( archivesSummary ) ;
}
}
@ -658,6 +704,12 @@ public class ArchivesServiceImpl implements ArchivesService {
String sql_4 = "update " + archivesType_4 . getEnName ( ) + " set is_delete_time = null,is_delete_man = null " +
String sql_4 = "update " + archivesType_4 . getEnName ( ) + " set is_delete_time = null,is_delete_man = null " +
"where id = '" + id + "'" ;
"where id = '" + id + "'" ;
int result_3 = entityManager . createNativeQuery ( sql_4 ) . executeUpdate ( ) ;
int result_3 = entityManager . createNativeQuery ( sql_4 ) . executeUpdate ( ) ;
ArchivesSummary archivesSummary = archivesSummaryRepository . findByArchivesId ( id ) ;
archivesSummary . setIsDeleteTime ( null ) ;
archivesSummary . setUpdateTime ( new Timestamp ( System . currentTimeMillis ( ) ) ) ;
archivesSummaryRepository . saveAndFlush ( archivesSummary ) ;
}
}
/ / 若恢复为案卷时
/ / 若恢复为案卷时
} else if ( archivesType . getIsType ( ) = = 3 ) {
} else if ( archivesType . getIsType ( ) = = 3 ) {
@ -689,6 +741,11 @@ public class ArchivesServiceImpl implements ArchivesService {
String sql_3 = "update " + archivesType_3 . getEnName ( ) + " set is_delete_time = null,is_delete_man = null " +
String sql_3 = "update " + archivesType_3 . getEnName ( ) + " set is_delete_time = null,is_delete_man = null " +
"where id = '" + id + "'" ;
"where id = '" + id + "'" ;
int result_3 = entityManager . createNativeQuery ( sql_3 ) . executeUpdate ( ) ;
int result_3 = entityManager . createNativeQuery ( sql_3 ) . executeUpdate ( ) ;
ArchivesSummary archivesSummary = archivesSummaryRepository . findByArchivesId ( id ) ;
archivesSummary . setIsDeleteTime ( null ) ;
archivesSummary . setUpdateTime ( new Timestamp ( System . currentTimeMillis ( ) ) ) ;
archivesSummaryRepository . saveAndFlush ( archivesSummary ) ;
}
}
}
}
@ -704,7 +761,7 @@ public class ArchivesServiceImpl implements ArchivesService {
String sql = "delete from " + queryTable + " where id in ('" + ids . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
String sql = "delete from " + queryTable + " where id in ('" + ids . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
int result = entityManager . createNativeQuery ( sql ) . executeUpdate ( ) ;
int result = entityManager . createNativeQuery ( sql ) . executeUpdate ( ) ;
int result1 = 0 ;
int result1 = 0 ;
archivesSummaryRepository . deleteAllById ( ids ) ;
/ / 若删除为文件级 则删除附件
/ / 若删除为文件级 则删除附件
if ( ArchivesTypeEnum . inChive . getCode ( ) = = archivesType . getIsType ( ) | | ArchivesTypeEnum . files . getCode ( ) = = archivesType . getIsType ( ) ) {
if ( ArchivesTypeEnum . inChive . getCode ( ) = = archivesType . getIsType ( ) | | ArchivesTypeEnum . files . getCode ( ) = = archivesType . getIsType ( ) ) {
String fileSql = "select file_path from file_" + queryTable + " where archive_id in ('" + ids . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
String fileSql = "select file_path from file_" + queryTable + " where archive_id in ('" + ids . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
@ -731,8 +788,16 @@ public class ArchivesServiceImpl implements ArchivesService {
/ / 删除案卷
/ / 删除案卷
String delete3sql = "delete from " + archivesType_3 . getEnName ( ) + " where id in ('" + list3 . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
String delete3sql = "delete from " + archivesType_3 . getEnName ( ) + " where id in ('" + list3 . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
entityManager . createNativeQuery ( delete3sql ) . executeUpdate ( ) ;
entityManager . createNativeQuery ( delete3sql ) . executeUpdate ( ) ;
archivesSummaryRepository . deleteAllById ( list3 ) ;
/ / 获取卷内表名
/ / 获取卷内表名
String enName_4 = archivesTypeRepository . findEnNameByPid ( archivesType_3 . getId ( ) ) ;
String enName_4 = archivesTypeRepository . findEnNameByPid ( archivesType_3 . getId ( ) ) ;
String query4sql = "select id from " + enName_4 + " where is_delete_time is not null and parent_id in ('"
+ list3 . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
List < String > list4 = entityManager . createNativeQuery ( query4sql ) . getResultList ( ) ;
archivesSummaryRepository . deleteAllById ( list4 ) ;
/ / 删除卷内
/ / 删除卷内
String delete4sql = "delete from " + enName_4 + " where is_delete_time is not null " +
String delete4sql = "delete from " + enName_4 + " where is_delete_time is not null " +
"and parent_id in ('" + list3 . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
"and parent_id in ('" + list3 . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')" ;
@ -775,6 +840,7 @@ public class ArchivesServiceImpl implements ArchivesService {
+ " where is_delete_time is not null and parent_id in ('" + ids . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')) " ;
+ " where is_delete_time is not null and parent_id in ('" + ids . stream ( ) . map ( String : : valueOf ) . collect ( Collectors . joining ( "','" ) ) + "')) " ;
/ / 删除卷内
/ / 删除卷内
entityManager . createNativeQuery ( delete3sql ) . executeUpdate ( ) ;
entityManager . createNativeQuery ( delete3sql ) . executeUpdate ( ) ;
archivesSummaryRepository . deleteAllById ( list3 ) ;
/ / 删除卷内附件
/ / 删除卷内附件
result1 = entityManager . createNativeQuery ( sql1 ) . executeUpdate ( ) ;
result1 = entityManager . createNativeQuery ( sql1 ) . executeUpdate ( ) ;
for ( String paths : filePath ) {
for ( String paths : filePath ) {