@ -47,6 +47,16 @@ public interface BorrowArchivesRepository extends JpaRepository<BorrowArchives, 
		
	
		
			
				            value  =  "update borrow_archives set borrow_type = ?2 where id in ?1 " )             value  =  "update borrow_archives set borrow_type = ?2 where id in ?1 " )  
		
	
		
			
				    void  updateAllTypeByRbIds ( List < String >  rbIds , Integer  borrowType ) ;     void  updateAllTypeByRbIds ( List < String >  rbIds , Integer  borrowType ) ;  
		
	
		
			
				
 
		
	
		
			
				    @Modifying  
		
	
		
			
				    @Query ( nativeQuery  =  true ,  
		
	
		
			
				            value  =  "update borrow_archives set borrow_type = ?2,start_time = now() where id in (select ba_id from borrow_bill_archives where bill_id in ?1)" )  
		
	
		
			
				    void  billBorrowConfirm ( List < String >  rbIds , Integer  borrowType ) ;  
		
	
		
			
				
 
		
	
		
			
				    @Modifying  
		
	
		
			
				    @Query ( nativeQuery  =  true ,  
		
	
		
			
				            value  =  "update borrow_archives set borrow_type = ?2,end_time = now() where id in ?1 " )  
		
	
		
			
				    void  archivesReturnConfirm ( List < String >  rbIds , Integer  borrowType ) ;  
		
	
		
			
				
 
		
	
		
			
				    @Modifying     @Modifying  
		
	
		
			
				    @Query ( nativeQuery  =  true ,     @Query ( nativeQuery  =  true ,  
		
	
		
			
				            value  =  "delete from borrow_archives where id in (select ba_id from borrow_bill_archives where bill_id in ?1)" )             value  =  "delete from borrow_archives where id in (select ba_id from borrow_bill_archives where bill_id in ?1)" )  
		
	
	
		
			
				
					
						
							 
					
					
						
							 
					
					
				 
				@ -97,8 +107,8 @@ public interface BorrowArchivesRepository extends JpaRepository<BorrowArchives, 
		
	
		
			
				                    "inner join borrow_bill_archives bba on ba.id = bba.ba_id "  +                     "inner join borrow_bill_archives bba on ba.id = bba.ba_id "  +  
		
	
		
			
				                    "inner join borrow_bill bbl on bba.bill_id = bbl.id "  +                     "inner join borrow_bill bbl on bba.bill_id = bbl.id "  +  
		
	
		
			
				                    "inner join borrower br on bbl.borrower_id = br.id "  +                     "inner join borrower br on bbl.borrower_id = br.id "  +  
		
	
		
			
				                    "where ba.borrow_type = 3  "  +  
		
	
		
			
				                    "and  if(?1 is null,1=1,bbl.id like ?1) "  +  
		
	
		
			
				                    "where "  +  
		
	
		
			
				                    "if(?1 is null,1=1,bbl.id like ?1) "  +  
		
	
		
			
				                    "and if(?2 is null,1=1,br.borrower_name like ?2) "  +                     "and if(?2 is null,1=1,br.borrower_name like ?2) "  +  
		
	
		
			
				                    "and if(?3 is null,1=1,br.phone like ?3) "  +                     "and if(?3 is null,1=1,br.phone like ?3) "  +  
		
	
		
			
				                    "and if(?4 is null,1=1,ba.archive_no like ?4) "  +                     "and if(?4 is null,1=1,ba.archive_no like ?4) "  +  
		
	
	
		
			
				
					
					
					
						
							 
					
				 
				@ -107,11 +117,11 @@ public interface BorrowArchivesRepository extends JpaRepository<BorrowArchives, 
		
	
		
			
				                    "and if(?7 is null,1=1,ba.barcode like ?7) "  +                     "and if(?7 is null,1=1,ba.barcode like ?7) "  +  
		
	
		
			
				                    "and if(?8 is null,1=1,ba.tid like ?8) "  +                     "and if(?8 is null,1=1,ba.tid like ?8) "  +  
		
	
		
			
				                    "and if(?10 is null,1=1,ba.maintitle like ?10) "  +                     "and if(?10 is null,1=1,ba.maintitle like ?10) "  +  
		
	
		
			
				                    "and if(?9 is null,1=1,if(?9 = 5,bbl.borrow_end < DATE(now()),if(?9 = 4,bbl.borrow_type = ?9,ba.borrow_type = ?9))) " ,  
		
	
		
			
				                    "and if(?9 is null,1=1,if(?9 = 5,bbl.borrow_type = 3 and bbl.borrow_ end < DATE(now()),if(?9 = 4,bbl.borrow_type = ?9,ba.borrow_type = ?9))) " ,  
		
	
		
			
				            value  =  "select ba.id as id,bbl.id as orderNo,ba.category_name as categoryName,ba.archive_no as archiveNo,ba.maintitle,"  +             value  =  "select ba.id as id,bbl.id as orderNo,ba.category_name as categoryName,ba.archive_no as archiveNo,ba.maintitle,"  +  
		
	
		
			
				                    "ba.case_name as caseName,ba.folder_location_details as folderLocationDetails,br.borrower_name as borrowerName,"  +                     "ba.case_name as caseName,ba.folder_location_details as folderLocationDetails,br.borrower_name as borrowerName,"  +  
		
	
		
			
				                    "bbl.borrow_start as borrowStart,bbl.borrow_end as borrowEnd,bbl.purpose,bbl.create_by as createBy,bbl.create_time as createTime,"  +                     "bbl.borrow_start as borrowStart,bbl.borrow_end as borrowEnd,bbl.purpose,bbl.create_by as createBy,bbl.create_time as createTime,"  +  
		
	
		
			
				                    "ba.end_time as endTime,"  +  
		
	
		
			
				                    "ba.start_time as startTime,ba. end_time as endTime,"  +  
		
	
		
			
				                    "CASE WHEN ba.borrow_type = 1 then '待登记' "  +                     "CASE WHEN ba.borrow_type = 1 then '待登记' "  +  
		
	
		
			
				                    "WHEN ba.borrow_type = 2 then '待借阅' "  +                     "WHEN ba.borrow_type = 2 then '待借阅' "  +  
		
	
		
			
				                    "WHEN ba.borrow_type = 3 && bbl.borrow_end < DATE(now()) THEN '逾期' "  +                     "WHEN ba.borrow_type = 3 && bbl.borrow_end < DATE(now()) THEN '逾期' "  +  
		
	
	
		
			
				
					
					
					
						
							 
					
				 
				@ -121,8 +131,8 @@ public interface BorrowArchivesRepository extends JpaRepository<BorrowArchives, 
		
	
		
			
				                    "inner join borrow_bill_archives bba on ba.id = bba.ba_id "  +                     "inner join borrow_bill_archives bba on ba.id = bba.ba_id "  +  
		
	
		
			
				                    "inner join borrow_bill bbl on bba.bill_id = bbl.id "  +                     "inner join borrow_bill bbl on bba.bill_id = bbl.id "  +  
		
	
		
			
				                    "inner join borrower br on bbl.borrower_id = br.id "  +                     "inner join borrower br on bbl.borrower_id = br.id "  +  
		
	
		
			
				                    "where ba.borrow_type = 3  "  +  
		
	
		
			
				                    "and  if(?1 is null,1=1,bbl.id like ?1) "  +  
		
	
		
			
				                    "where "  +  
		
	
		
			
				                    "if(?1 is null,1=1,bbl.id like ?1) "  +  
		
	
		
			
				                    "and if(?2 is null,1=1,br.borrower_name like ?2) "  +                     "and if(?2 is null,1=1,br.borrower_name like ?2) "  +  
		
	
		
			
				                    "and if(?3 is null,1=1,br.phone like ?3) "  +                     "and if(?3 is null,1=1,br.phone like ?3) "  +  
		
	
		
			
				                    "and if(?4 is null,1=1,ba.archive_no like ?4) "  +                     "and if(?4 is null,1=1,ba.archive_no like ?4) "  +  
		
	
	
		
			
				
					
					
					
						
							 
					
				 
				@ -131,7 +141,7 @@ public interface BorrowArchivesRepository extends JpaRepository<BorrowArchives, 
		
	
		
			
				                    "and if(?7 is null,1=1,ba.barcode like ?7) "  +                     "and if(?7 is null,1=1,ba.barcode like ?7) "  +  
		
	
		
			
				                    "and if(?8 is null,1=1,ba.tid like ?8) "  +                     "and if(?8 is null,1=1,ba.tid like ?8) "  +  
		
	
		
			
				                    "and if(?10 is null,1=1,ba.maintitle like ?10) "  +                     "and if(?10 is null,1=1,ba.maintitle like ?10) "  +  
		
	
		
			
				                    "and if(?9 is null,1=1,if(?9 = 5,bbl.borrow_end < DATE(now()),if(?9 = 4,bbl.borrow_type = ?9,ba.borrow_type = ?9))) " +  
		
	
		
			
				                    "and if(?9 is null,1=1,if(?9 = 5,bbl.borrow_type = 3 and bbl.borrow_ end < DATE(now()),if(?9 = 4,bbl.borrow_type = ?9,ba.borrow_type = ?9))) " +  
		
	
		
			
				                    "order by bbl.create_time desc " )                     "order by bbl.create_time desc " )  
		
	
		
			
				    Page < Map < String , Object > >  initBorrowLog ( String  orderNo ,  String  borrowerName ,  String  phone ,  String  archiveNo , String  folderLocationDetails ,     Page < Map < String , Object > >  initBorrowLog ( String  orderNo ,  String  borrowerName ,  String  phone ,  String  archiveNo , String  folderLocationDetails ,  
		
	
		
			
				                                           String  caseName ,  String  barcode ,  String  tid , Integer  borrowType , String  maintitle ,  Pageable  page ) ;                                            String  caseName ,  String  barcode ,  String  tid , Integer  borrowType , String  maintitle ,  Pageable  page ) ;