@ -4,6 +4,7 @@ import com.storeroom.modules.archives.domain.ArchivesCheckBillDetails; 
		
	
		
			
				import  org.springframework.data.domain.Page ; import  org.springframework.data.domain.Page ;  
		
	
		
			
				import  org.springframework.data.domain.Pageable ; import  org.springframework.data.domain.Pageable ;  
		
	
		
			
				import  org.springframework.data.jpa.repository.JpaRepository ; import  org.springframework.data.jpa.repository.JpaRepository ;  
		
	
		
			
				import  org.springframework.data.jpa.repository.Modifying ;  
		
	
		
			
				import  org.springframework.data.jpa.repository.Query ; import  org.springframework.data.jpa.repository.Query ;  
		
	
		
			
				
 
		
	
		
			
				import  java.util.List ; import  java.util.List ;  
		
	
	
		
			
				
					
					
					
						
							 
					
				 
				@ -12,7 +13,7 @@ import java.util.Map; 
		
	
		
			
				public  interface  ArchivesCheckBillDetailsRepository  extends  JpaRepository < ArchivesCheckBillDetails ,  String > { public  interface  ArchivesCheckBillDetailsRepository  extends  JpaRepository < ArchivesCheckBillDetails ,  String > {  
		
	
		
			
				
 
		
	
		
			
				    @Query ( nativeQuery  =  true ,     @Query ( nativeQuery  =  true ,  
		
	
		
			
				            value  =  "select replace(uuid(),'-','') as id,?1 as bill_id,(select if(count(1)=0,0,3 ) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as check_result,"  +  
		
	
		
			
				            value  =  "select replace(uuid(),'-','') as id,?1 as bill_id,(select if(count(1)=0,0,4 ) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as check_result,"  +  
		
	
		
			
				                    "asy.child,asy.category_type,asy.category_name,asy.shelf_id,asy.fonds_no,asy.archives_id,"  +                     "asy.child,asy.category_type,asy.category_name,asy.shelf_id,asy.fonds_no,asy.archives_id,"  +  
		
	
		
			
				                    "asy.archive_no,asy.archive_year,asy.maintitle,asy.security_class,"  +                     "asy.archive_no,asy.archive_year,asy.maintitle,asy.security_class,"  +  
		
	
		
			
				                    "asy.department,asy.case_name,asy.folder_location_details,asy.create_time "  +                     "asy.department,asy.case_name,asy.folder_location_details,asy.create_time "  +  
		
	
	
		
			
				
					
					
					
						
							 
					
				 
				@ -23,24 +24,24 @@ public interface ArchivesCheckBillDetailsRepository extends JpaRepository<Archiv 
		
	
		
			
				    List < ArchivesCheckBillDetails >  findDetailsAll ( String  billId ) ;     List < ArchivesCheckBillDetails >  findDetailsAll ( String  billId ) ;  
		
	
		
			
				
 
		
	
		
			
				    @Query ( nativeQuery  =  true ,     @Query ( nativeQuery  =  true ,  
		
	
		
			
				            value  =  "select replace(uuid(),'-','') as id,?2 as bill_id,(select if(count(1)=0,0,3 ) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as check_result,"  +  
		
	
		
			
				            value  =  "select replace(uuid(),'-','') as id,?2 as bill_id,(select if(count(1)=0,0,4 ) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as check_result,"  +  
		
	
		
			
				                    "asy.child,asy.category_type,asy.category_name,asy.shelf_id,asy.fonds_no,asy.archives_id,"  +                     "asy.child,asy.category_type,asy.category_name,asy.shelf_id,asy.fonds_no,asy.archives_id,"  +  
		
	
		
			
				                    "asy.archive_no,asy.archive_year,asy.maintitle,asy.security_class,"  +                     "asy.archive_no,asy.archive_year,asy.maintitle,asy.security_class,"  +  
		
	
		
			
				                    "asy.department,asy.case_name,asy.folder_location_details,asy.create_time "  +                     "asy.department,asy.case_name,asy.folder_location_details,asy.create_time "  +  
		
	
		
			
				                    "from archives_summary asy where "  +                     "from archives_summary asy where "  +  
		
	
		
			
				                    "asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc "  +                     "asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc "  +  
		
	
		
			
				                    "inner join archives_case ace on acc.case_id = ace.id "  +                     "inner join archives_case ace on acc.case_id = ace.id "  +  
		
	
		
			
				                    "inner join device_archives_tag dat on ace.folder_location = dat.position where if(?1 is null,1=1, dat.device_info_id in ?1) ) "  +  
		
	
		
			
				                    "inner join device_archives_tag dat on ace.folder_location = dat.position where dat.device_info_id in ?1) "  +  
		
	
		
			
				                    "order by create_time desc" )                     "order by create_time desc" )  
		
	
		
			
				    List < ArchivesCheckBillDetails >  findDetailsAllByDeviceId ( List < String >  deviceIds , String  billId ) ;     List < ArchivesCheckBillDetails >  findDetailsAllByDeviceId ( List < String >  deviceIds , String  billId ) ;  
		
	
		
			
				
 
		
	
		
			
				    @Query ( nativeQuery  =  true ,     @Query ( nativeQuery  =  true ,  
		
	
		
			
				            value  =  "select replace(uuid(),'-','') as id,?2 as bill_id,(select if(count(1)=0,0,3 ) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as check_result,"  +  
		
	
		
			
				            value  =  "select replace(uuid(),'-','') as id,?2 as bill_id,(select if(count(1)=0,0,4 ) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as check_result,"  +  
		
	
		
			
				                    "asy.child,asy.category_type,asy.category_name,asy.shelf_id,asy.fonds_no,asy.archives_id,"  +                     "asy.child,asy.category_type,asy.category_name,asy.shelf_id,asy.fonds_no,asy.archives_id,"  +  
		
	
		
			
				                    "asy.archive_no,asy.archive_year,asy.maintitle,asy.security_class,"  +                     "asy.archive_no,asy.archive_year,asy.maintitle,asy.security_class,"  +  
		
	
		
			
				                    "asy.department,asy.case_name,asy.folder_location_details,asy.create_time "  +                     "asy.department,asy.case_name,asy.folder_location_details,asy.create_time "  +  
		
	
		
			
				                    "from archives_summary asy where "  +                     "from archives_summary asy where "  +  
		
	
		
			
				                    "if(?1 is null,1=1, category_id in ?1)  and "  +  
		
	
		
			
				                    "category_id in ?1 and "  +  
		
	
		
			
				                    "asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc "  +                     "asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc "  +  
		
	
		
			
				                    "inner join archives_case ace on acc.case_id = ace.id "  +                     "inner join archives_case ace on acc.case_id = ace.id "  +  
		
	
		
			
				                    "inner join device_archives_tag dat on ace.folder_location = dat.position) "  +                     "inner join device_archives_tag dat on ace.folder_location = dat.position) "  +  
		
	
	
		
			
				
					
					
					
						
							 
					
				 
				@ -48,21 +49,21 @@ public interface ArchivesCheckBillDetailsRepository extends JpaRepository<Archiv 
		
	
		
			
				    List < ArchivesCheckBillDetails >  findDetailsAllByCategoryId ( List < String >  categroyIds , String  billId ) ;     List < ArchivesCheckBillDetails >  findDetailsAllByCategoryId ( List < String >  categroyIds , String  billId ) ;  
		
	
		
			
				
 
		
	
		
			
				    @Query ( nativeQuery  =  true ,     @Query ( nativeQuery  =  true ,  
		
	
		
			
				            value  =  "select replace(uuid(),'-','') as id,?3 as bill_id,(select if(count(1)=0,0,3 ) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as check_result,"  +  
		
	
		
			
				            value  =  "select replace(uuid(),'-','') as id,?3 as bill_id,(select if(count(1)=0,0,4 ) from borrow_archives ba where ba.archives_id = asy.archives_id and borrow_type = 3) as check_result,"  +  
		
	
		
			
				                    "asy.child,asy.category_type,asy.category_name,asy.shelf_id,asy.fonds_no,asy.archives_id,"  +                     "asy.child,asy.category_type,asy.category_name,asy.shelf_id,asy.fonds_no,asy.archives_id,"  +  
		
	
		
			
				                    "asy.archive_no,asy.archive_year,asy.maintitle,asy.security_class,"  +                     "asy.archive_no,asy.archive_year,asy.maintitle,asy.security_class,"  +  
		
	
		
			
				                    "asy.department,asy.case_name,asy.folder_location_details,asy.create_time "  +                     "asy.department,asy.case_name,asy.folder_location_details,asy.create_time "  +  
		
	
		
			
				                    "from archives_summary asy where "  +                     "from archives_summary asy where "  +  
		
	
		
			
				                    "if(?2 is null,1=1, category_id in ?2)  and "  +  
		
	
		
			
				                    "category_id in ?2 and "  +  
		
	
		
			
				                    "asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc "  +                     "asy.archives_id in (select DISTINCT acc.parent_id from archives_case_cartoning acc "  +  
		
	
		
			
				                    "inner join archives_case ace on acc.case_id = ace.id "  +                     "inner join archives_case ace on acc.case_id = ace.id "  +  
		
	
		
			
				                    "inner join device_archives_tag dat on ace.folder_location = dat.position where if(?1 is null,1=1, dat.device_info_id in ?1) ) "  +  
		
	
		
			
				                    "inner join device_archives_tag dat on ace.folder_location = dat.position where dat.device_info_id in ?1) "  +  
		
	
		
			
				                    "order by create_time desc" )                     "order by create_time desc" )  
		
	
		
			
				    List < ArchivesCheckBillDetails >  findDetailsAllByDeviceIdAndCategoryId ( List < String >  deviceIds , List < String >  categroyIds , String  billId ) ;     List < ArchivesCheckBillDetails >  findDetailsAllByDeviceIdAndCategoryId ( List < String >  deviceIds , List < String >  categroyIds , String  billId ) ;  
		
	
		
			
				
 
		
	
		
			
				    @Query ( nativeQuery  =  true ,     @Query ( nativeQuery  =  true ,  
		
	
		
			
				            value  =  "select count(1) from archives_check_bill_details where check_result = 3  and bill_id = ?1 " )  
		
	
		
			
				    Integer  findBorrow CountByOrderId ( String  orderIds ) ;  
		
	
		
			
				            value  =  "select count(1) from archives_check_bill_details where check_result = ?2  and bill_id = ?1 " )  
		
	
		
			
				    Integer  findResult CountByOrderId ( String  orderIds , Integer  checkResult ) ;  
		
	
		
			
				
 
		
	
		
			
				    @Query ( nativeQuery  =  true ,     @Query ( nativeQuery  =  true ,  
		
	
		
			
				            value  =  "select * from archives_check_bill_details where bill_id = ?1 "  +             value  =  "select * from archives_check_bill_details where bill_id = ?1 "  +  
		
	
	
		
			
				
					
					
					
						
							 
					
				 
				@ -73,4 +74,11 @@ public interface ArchivesCheckBillDetailsRepository extends JpaRepository<Archiv 
		
	
		
			
				            value  =  "select id as checkId,bill_id as billId,check_result as checkResult,archives_id as archivesId from archives_check_bill_details where bill_id = ?1 " )             value  =  "select id as checkId,bill_id as billId,check_result as checkResult,archives_id as archivesId from archives_check_bill_details where bill_id = ?1 " )  
		
	
		
			
				    List < Map < String , Object > >  getArrangeDetailesAllToRFID ( String  orderNo ) ;     List < Map < String , Object > >  getArrangeDetailesAllToRFID ( String  orderNo ) ;  
		
	
		
			
				
 
		
	
		
			
				    @Query ( "from ArchivesCheckBillDetails where billId = ?1" )  
		
	
		
			
				    List < ArchivesCheckBillDetails >  getArrangeDetailesAll ( String  orderNo ) ;  
		
	
		
			
				
 
		
	
		
			
				    @Modifying  
		
	
		
			
				    @Query ( "delete from ArchivesCheckBillDetails where billId in ?1" )  
		
	
		
			
				    void  deleteByOrderIds ( List < String >  orderNos ) ;  
		
	
		
			
				
 
		
	
		
			
				} }