@ -22,7 +22,7 @@ public interface BorrowArchivesRepository extends JpaRepository<BorrowArchives,
Page < BorrowArchives > initWaitRegisterList ( String archiveNo , String maintitle , String caseName , String folderLocationDetails , Pageable page ) ;
Page < BorrowArchives > initWaitRegisterList ( String archiveNo , String maintitle , String caseName , String folderLocationDetails , Pageable page ) ;
@Query ( nativeQuery = true ,
@Query ( nativeQuery = true ,
value = "select asy.archives_id as archivesId,1 as borrowType,asy.category_id as categoryId," +
value = "select asy.archives_id as archivesId,1 as borrowType,asy.category_id as categoryId,asy.tag_no as tid,asy.barcode, " +
"asy.category_name as categoryName,asy.archive_no as archiveNo,asy.maintitle,asy.case_name as caseName," +
"asy.category_name as categoryName,asy.archive_no as archiveNo,asy.maintitle,asy.case_name as caseName," +
"(select GROUP_CONCAT(CONCAT(room.name ,'-' , di.device_name , '-' , dat.position_name)) as seat " +
"(select GROUP_CONCAT(CONCAT(room.name ,'-' , di.device_name , '-' , dat.position_name)) as seat " +
"from archives_case_cartoning acc inner join archives_case ace on acc.case_id = ace.id " +
"from archives_case_cartoning acc inner join archives_case ace on acc.case_id = ace.id " +
@ -42,6 +42,11 @@ public interface BorrowArchivesRepository extends JpaRepository<BorrowArchives,
value = "update borrow_archives set borrow_type = ?2 where id in (select ba_id from borrow_bill_archives where bill_id in ?1)" )
value = "update borrow_archives set borrow_type = ?2 where id in (select ba_id from borrow_bill_archives where bill_id in ?1)" )
void updateAllTypeByOrderNos ( List < String > orderNos , Integer borrowType ) ;
void updateAllTypeByOrderNos ( List < String > orderNos , Integer borrowType ) ;
@Modifying
@Query ( nativeQuery = true ,
value = "update borrow_archives set borrow_type = ?2 where id in ?1 " )
void updateAllTypeByRbIds ( 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)" )
@ -51,4 +56,81 @@ public interface BorrowArchivesRepository extends JpaRepository<BorrowArchives,
value = "select * from borrow_archives where id in (select ba_id from borrow_bill_archives where bill_id = ?1)" )
value = "select * from borrow_archives where id in (select ba_id from borrow_bill_archives where bill_id = ?1)" )
List < BorrowArchives > initArchivesByOrderNo ( String orderNo ) ;
List < BorrowArchives > initArchivesByOrderNo ( String orderNo ) ;
@Query ( nativeQuery = true ,
countQuery = "select count(1) " +
"from borrow_archives ba " +
"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 borrower br on bbl.borrower_id = br.id " +
"where ba.borrow_type = 3 " +
"and if(?1 is null,1=1,bbl.id like ?1) " +
"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(?4 is null,1=1,ba.archive_no like ?4) " +
"and if(?5 is null,1=1,ba.folder_location_details like ?5) " +
"and if(?6 is null,1=1,ba.case_name like ?6) " +
"and if(?7 is null,1=1,ba.barcode like ?7) " +
"and if(?8 is null,1=1,ba.tid like ?8) " ,
value = "select ba.id as id,bba.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," +
"bbl.borrow_start as borrowStart,bbl.borrow_end as borrowEnd,bbl.purpose,case when bbl.borrow_end<DATE(now()) then '逾期' " +
"when bbl.borrow_end>=DATE(now()) then '待归还' else '未知' end as borrowType,bbl.create_by as createBy " +
"from borrow_archives ba " +
"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 borrower br on bbl.borrower_id = br.id " +
"where ba.borrow_type = 3 " +
"and if(?1 is null,1=1,bbl.id like ?1) " +
"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(?4 is null,1=1,ba.archive_no like ?4) " +
"and if(?5 is null,1=1,ba.folder_location_details like ?5) " +
"and if(?6 is null,1=1,ba.case_name like ?6) " +
"and if(?7 is null,1=1,ba.barcode like ?7) " +
"and if(?8 is null,1=1,ba.tid like ?8) order by bbl.create_time desc " )
Page < Map < String , Object > > initReturnConfirmList ( String orderNo , String borrowerName , String phone , String archiveNo ,
String folderLocationDetails , String caseName , String barcode , String tid , Pageable page ) ;
@Query ( nativeQuery = true ,
countQuery = "select count(1) " +
"from borrow_archives ba " +
"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 borrower br on bbl.borrower_id = br.id " +
"where ba.borrow_type = 3 " +
"and if(?1 is null,1=1,bbl.id like ?1) " +
"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(?4 is null,1=1,ba.archive_no like ?4) " +
"and if(?5 is null,1=1,ba.folder_location_details like ?5) " +
"and if(?6 is null,1=1,ba.case_name like ?6) " +
"and if(?7 is null,1=1,ba.barcode like ?7) " +
"and if(?8 is null,1=1,ba.tid like ?8) " +
"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))) " ,
value = "select ba.id as id,bba.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," +
"bbl.borrow_start as borrowStart,bbl.borrow_end as borrowEnd,bbl.purpose,bbl.create_by as createBy," +
"CASE WHEN ba.borrow_type = 1 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 '待归还' " +
"WHEN bbl.borrow_type = 4 then '已归还' ELSE '未知' END AS borrowType " +
"from borrow_archives ba " +
"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 borrower br on bbl.borrower_id = br.id " +
"where ba.borrow_type = 3 " +
"and if(?1 is null,1=1,bbl.id like ?1) " +
"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(?4 is null,1=1,ba.archive_no like ?4) " +
"and if(?5 is null,1=1,ba.folder_location_details like ?5) " +
"and if(?6 is null,1=1,ba.case_name like ?6) " +
"and if(?7 is null,1=1,ba.barcode like ?7) " +
"and if(?8 is null,1=1,ba.tid like ?8) " +
"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))) " +
"order by bbl.create_time desc " )
Page < Map < String , Object > > initBorrowLog ( String orderNo , String borrowerName , String phone , String archiveNo , String folderLocationDetails ,
String caseName , String barcode , String tid , Integer borrowType , Pageable page ) ;
}
}