18 changed files with 785 additions and 5 deletions
			
			
		- 
					109archives/src/main/java/com/storeroom/modules/archives/controller/BorrowController.java
- 
					10archives/src/main/java/com/storeroom/modules/archives/controller/RFIDController.java
- 
					6archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java
- 
					65archives/src/main/java/com/storeroom/modules/archives/domain/BorrowArchives.java
- 
					51archives/src/main/java/com/storeroom/modules/archives/domain/BorrowBill.java
- 
					30archives/src/main/java/com/storeroom/modules/archives/domain/BorrowBillArchives.java
- 
					23archives/src/main/java/com/storeroom/modules/archives/domain/Borrower.java
- 
					58archives/src/main/java/com/storeroom/modules/archives/domain/vo/BorrowBillDetailsVO.java
- 
					5archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java
- 
					52archives/src/main/java/com/storeroom/modules/archives/repository/BorrowArchivesRepository.java
- 
					18archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillArchivesRepository.java
- 
					34archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillRepository.java
- 
					18archives/src/main/java/com/storeroom/modules/archives/repository/BorrowerRepository.java
- 
					37archives/src/main/java/com/storeroom/modules/archives/service/BorrowService.java
- 
					23archives/src/main/java/com/storeroom/modules/archives/service/dto/RegisterBorrowDTO.java
- 
					164archives/src/main/java/com/storeroom/modules/archives/service/impl/BorrowServiceImpl.java
- 
					5common/pom.xml
- 
					82common/src/main/java/com/storeroom/utils/ChinesePinyinUtil.java
| @ -0,0 +1,65 @@ | |||
| package com.storeroom.modules.archives.domain; | |||
| 
 | |||
| import com.storeroom.base.BaseEntity; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Getter; | |||
| import lombok.Setter; | |||
| import org.hibernate.annotations.GenericGenerator; | |||
| 
 | |||
| import javax.persistence.*; | |||
| import java.io.Serializable; | |||
| import java.sql.Timestamp; | |||
| 
 | |||
| @Entity | |||
| @Getter | |||
| @Setter | |||
| @Table(name = "borrow_archives") | |||
| public class BorrowArchives implements Serializable { | |||
| 
 | |||
|     @Id | |||
|     @Column(name = "id") | |||
|     @GeneratedValue(generator = "idGenerator") | |||
|     @GenericGenerator(name = "idGenerator", strategy = "uuid") | |||
|     private String id; | |||
| 
 | |||
|     @Column(name = "archives_id") | |||
|     @ApiModelProperty(value = "档案id") | |||
|     private String archivesId; | |||
| 
 | |||
|     @Column(name = "borrow_type") | |||
|     @ApiModelProperty(value = "借阅状态 1.待登记 2.待借阅 3.待归还 4.已归还") | |||
|     private Integer borrowType; | |||
| 
 | |||
|     @Column(name = "category_id") | |||
|     @ApiModelProperty(value = "门类id") | |||
|     private String categoryId; | |||
| 
 | |||
|     @Column(name = "category_name") | |||
|     @ApiModelProperty(value = "门类名称") | |||
|     private String categoryName; | |||
| 
 | |||
|     @Column(name = "archive_no") | |||
|     @ApiModelProperty(value = "档号") | |||
|     private String archiveNo; | |||
| 
 | |||
|     @Column(name = "maintitle") | |||
|     @ApiModelProperty(value = "题名") | |||
|     private String maintitle; | |||
| 
 | |||
|     @Column(name = "case_name") | |||
|     @ApiModelProperty(value = "盒名称") | |||
|     private String caseName; | |||
| 
 | |||
|     @Column(name = "folder_location_details") | |||
|     @ApiModelProperty(value = "存放位置") | |||
|     private String folderLocationDetails; | |||
| 
 | |||
|     @Column(name = "start_time") | |||
|     @ApiModelProperty(value = "借阅时间") | |||
|     private Timestamp startTime; | |||
| 
 | |||
|     @Column(name = "end_time") | |||
|     @ApiModelProperty(value = "归还时间") | |||
|     private Timestamp endTime; | |||
| 
 | |||
| } | |||
| @ -0,0 +1,51 @@ | |||
| package com.storeroom.modules.archives.domain; | |||
| 
 | |||
| import com.storeroom.base.BaseEntity; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Getter; | |||
| import lombok.Setter; | |||
| import org.hibernate.annotations.GenericGenerator; | |||
| 
 | |||
| import javax.persistence.*; | |||
| import java.io.Serializable; | |||
| import java.sql.Timestamp; | |||
| 
 | |||
| @Entity | |||
| @Getter | |||
| @Setter | |||
| @Table(name = "borrow_bill") | |||
| public class BorrowBill extends BaseEntity implements Serializable { | |||
| 
 | |||
|     @Id | |||
|     @Column(name = "id") | |||
|     private String id; | |||
| 
 | |||
|     @Column(name = "borrow_num") | |||
|     @ApiModelProperty(value = "借阅数量") | |||
|     private Integer borrowNum; | |||
| 
 | |||
|     @Column(name = "borrower_id") | |||
|     @ApiModelProperty(value = "借阅人id") | |||
|     private String borrowerId; | |||
| 
 | |||
|     @Column(name = "borrow_type") | |||
|     @ApiModelProperty(value = "借阅状态 1.待登记 2.待借阅 3.待归还 4.已归还") | |||
|     private Integer borrowType; | |||
| 
 | |||
|     @Column(name = "purpose") | |||
|     @ApiModelProperty(value = "借阅目的") | |||
|     private String purpose; | |||
| 
 | |||
|     @Column(name = "borrower_start") | |||
|     @ApiModelProperty(value = "借阅开始时间") | |||
|     private Timestamp borrowerStart; | |||
| 
 | |||
|     @Column(name = "borrower_end") | |||
|     @ApiModelProperty(value = "借阅应归还时间") | |||
|     private Timestamp borrowerEnd; | |||
| 
 | |||
|     @Column(name = "borrower_real_end") | |||
|     @ApiModelProperty(value = "借阅实际归还时间") | |||
|     private Timestamp borrowerRealEnd; | |||
| 
 | |||
| } | |||
| @ -0,0 +1,30 @@ | |||
| package com.storeroom.modules.archives.domain; | |||
| 
 | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Getter; | |||
| import lombok.Setter; | |||
| import org.hibernate.annotations.GenericGenerator; | |||
| 
 | |||
| import javax.persistence.*; | |||
| 
 | |||
| @Entity | |||
| @Getter | |||
| @Setter | |||
| @Table(name = "borrow_bill_archives") | |||
| public class BorrowBillArchives { | |||
| 
 | |||
|     @Id | |||
|     @Column(name = "id") | |||
|     @GeneratedValue(generator = "idGenerator") | |||
|     @GenericGenerator(name = "idGenerator", strategy = "uuid") | |||
|     private String id; | |||
| 
 | |||
|     @Column(name = "bill_id") | |||
|     @ApiModelProperty(value = "清单id") | |||
|     private String billId; | |||
| 
 | |||
|     @Column(name = "ba_id") | |||
|     @ApiModelProperty(value = "借阅id") | |||
|     private String baId; | |||
| 
 | |||
| } | |||
| @ -0,0 +1,58 @@ | |||
| package com.storeroom.modules.archives.domain.vo; | |||
| 
 | |||
| import com.alibaba.fastjson.annotation.JSONField; | |||
| import com.fasterxml.jackson.annotation.JsonProperty; | |||
| import com.storeroom.modules.archives.domain.BorrowArchives; | |||
| import io.swagger.annotations.ApiModelProperty; | |||
| import lombok.Getter; | |||
| import lombok.Setter; | |||
| 
 | |||
| import javax.persistence.Column; | |||
| import java.sql.Timestamp; | |||
| import java.util.List; | |||
| 
 | |||
| @Getter | |||
| @Setter | |||
| public class BorrowBillDetailsVO { | |||
| 
 | |||
|     @JSONField(name="orderNo") | |||
|     @JsonProperty("id") | |||
|     private String id; | |||
| 
 | |||
|     @JSONField(name="borrowNum") | |||
|     @JsonProperty("borrow_num") | |||
|     private Integer borrowNum; | |||
| 
 | |||
|     @JSONField(name="borrowerId") | |||
|     @JsonProperty("borrower_id") | |||
|     private String borrowerId; | |||
| 
 | |||
|     @JSONField(name="borrowType") | |||
|     @JsonProperty("borrow_type") | |||
|     private Integer borrowType; | |||
| 
 | |||
|     @JSONField(name="purpose") | |||
|     @JsonProperty("purpose") | |||
|     private String purpose; | |||
| 
 | |||
|     @JSONField(name="borrowerStart") | |||
|     @JsonProperty("borrower_start") | |||
|     private Timestamp borrowerStart; | |||
| 
 | |||
|     @JSONField(name="borrowerEnd") | |||
|     @JsonProperty("borrower_end") | |||
|     private Timestamp borrowerEnd; | |||
| 
 | |||
|     @JSONField(name="borrowerRealEnd") | |||
|     @JsonProperty("borrower_real_end") | |||
|     private Timestamp borrowerRealEnd; | |||
| 
 | |||
|     @JSONField(name="createTime") | |||
|     @JsonProperty("create_time") | |||
|     private Timestamp createTime; | |||
| 
 | |||
|     @JSONField(name="borrowArchives") | |||
|     @JsonProperty("borrowArchives") | |||
|     private List<BorrowArchives> borrowArchives; | |||
| 
 | |||
| } | |||
| @ -0,0 +1,52 @@ | |||
| package com.storeroom.modules.archives.repository; | |||
| 
 | |||
| import com.storeroom.modules.archives.domain.BorrowArchives; | |||
| import com.storeroom.modules.archives.domain.Borrower; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.Pageable; | |||
| import org.springframework.data.jpa.repository.JpaRepository; | |||
| import org.springframework.data.jpa.repository.Modifying; | |||
| import org.springframework.data.jpa.repository.Query; | |||
| 
 | |||
| import java.util.List; | |||
| 
 | |||
| public interface BorrowArchivesRepository extends JpaRepository<BorrowArchives, String> { | |||
| 
 | |||
|     @Query(nativeQuery = true, | |||
|             value = "select * from borrow_archives where borrow_type = 1 " + | |||
|                     "and if(?1 is null,1=1,archive_no like ?1) " + | |||
|                     "and if(?2 is null,1=1,maintitle like ?2) " + | |||
|                     "and if(?3 is null,1=1,case_name like ?3) ") | |||
|     Page<BorrowArchives> initWaitRegisterList(String archiveNo, String maintitle, String caseName, Pageable page); | |||
| 
 | |||
|     @Query(nativeQuery = true, | |||
|             value = "select asy.archives_id as archivesId,1 as borrowType,asy.category_id as categoryId," + | |||
|                     "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 " + | |||
|                         "from archives_case_cartoning acc inner join archives_case ace on acc.case_id = ace.id " + | |||
|                         "inner join device_archives_tag dat on dat.id = ace.shelf_id " + | |||
|                         "inner join device_info di ON dat.device_info_id = di.id " + | |||
|                         "inner join storeroom room ON di.storeroom_id = room.id " + | |||
|                         "where acc.archives_id = asy.archives_id) as folderLocationDetails " + | |||
|                     "from archives_summary asy where asy.archives_id in ?1 ") | |||
|     List<BorrowArchives> findAllByArchivesIdss(List<String> archiveIds); | |||
| 
 | |||
|     @Modifying | |||
|     @Query("update BorrowArchives set borrowType = ?2 where id in ?1") | |||
|     void updateAllTypeByIds(List<String> ids,Integer borrowType); | |||
| 
 | |||
|     @Modifying | |||
|     @Query(nativeQuery = true, | |||
|             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); | |||
| 
 | |||
|     @Modifying | |||
|     @Query(nativeQuery = true, | |||
|             value = "delete from borrow_archives where id in (select ba_id from borrow_bill_archives where bill_id in ?1)") | |||
|     void deleteAllByOrderNos(List<String> orderNos); | |||
| 
 | |||
|     @Query(nativeQuery = true, | |||
|             value = "select * from borrow_archives where id in (select ba_id from borrow_bill_archives where bill_id = ?1)") | |||
|     List<BorrowArchives> initArchivesByOrderNo(String orderNo); | |||
| 
 | |||
| } | |||
| @ -0,0 +1,18 @@ | |||
| package com.storeroom.modules.archives.repository; | |||
| 
 | |||
| import com.storeroom.modules.archives.domain.BorrowBillArchives; | |||
| import com.storeroom.modules.archives.domain.Borrower; | |||
| import org.springframework.data.jpa.repository.JpaRepository; | |||
| import org.springframework.data.jpa.repository.Modifying; | |||
| import org.springframework.data.jpa.repository.Query; | |||
| 
 | |||
| import java.util.List; | |||
| 
 | |||
| public interface BorrowBillArchivesRepository extends JpaRepository<BorrowBillArchives, String> { | |||
| 
 | |||
| 
 | |||
|     @Modifying | |||
|     @Query("delete from BorrowBillArchives where billId in ?1") | |||
|     void deleteAllByOrderNos(List<String> orderNos); | |||
| 
 | |||
| } | |||
| @ -0,0 +1,34 @@ | |||
| package com.storeroom.modules.archives.repository; | |||
| 
 | |||
| import com.storeroom.modules.archives.domain.BorrowBill; | |||
| import org.springframework.data.domain.Page; | |||
| import org.springframework.data.domain.Pageable; | |||
| import org.springframework.data.jpa.repository.JpaRepository; | |||
| import org.springframework.data.jpa.repository.Query; | |||
| 
 | |||
| import java.util.Map; | |||
| 
 | |||
| public interface BorrowBillRepository extends JpaRepository<BorrowBill, String> { | |||
| 
 | |||
|     @Query("from BorrowBill where id = ?1") | |||
|     BorrowBill findBillById(String orderNo); | |||
| 
 | |||
|     @Query(nativeQuery = true, | |||
|         value = "select CONCAT ('JY', DATE_FORMAT(now(), '%Y%m%d'),RIGHT(CONCAT " + | |||
|                 "('00000' , ifnull(max(SUBSTR(id, LENGTH(CONCAT('JY',DATE_FORMAT(now(), '%Y%m%d'))) + 1," + | |||
|                 "LENGTH(id) - LENGTH(CONCAT ('JY' , DATE_FORMAT(now(), '%Y%m%d'))))) + 1, 1)), 5)) AS id " + | |||
|                 "from borrow_bill where SUBSTR(id, 3, 8)=substr(DATE_FORMAT(now(),'%Y%m%d') , 1, 8)") | |||
|     String getOrderId(); | |||
| 
 | |||
|     @Query(nativeQuery = true, | |||
|         value = "select bbl.id as orderNo,bbl.borrow_num as borrowNum,ber.borrower_name as borrowerName,ber.department," + | |||
|                 "ber.card_type as cardType,ber.phone,bbl.borrower_start as startTime,bbl.borrower_end as endTime,bbl.purpose," + | |||
|                 "bbl.borrow_type as borrowType,bbl.create_time as createTime from borrow_bill bbl " + | |||
|                 "inner join borrower ber on bbl.borrower_id = ber.id " + | |||
|                 "where bbl.borrow_type = 2 " + | |||
|                 "and if(?1 is null,1=1,bbl.id like ?1) " + | |||
|                 "and if(?2 is null,1=1,ber.borrower_name like ?2) " + | |||
|                 "and if(?3 is null,1=1,ber.phone like ?3) ") | |||
|     Page<Map<String,Object>> initWaitBorrowList(String billNo, String borrowerName, String phone, Pageable page); | |||
| 
 | |||
| } | |||
| @ -0,0 +1,18 @@ | |||
| package com.storeroom.modules.archives.repository; | |||
| 
 | |||
| import com.storeroom.modules.archives.domain.Borrower; | |||
| import org.springframework.data.jpa.repository.JpaRepository; | |||
| import org.springframework.data.jpa.repository.Query; | |||
| 
 | |||
| import java.util.List; | |||
| 
 | |||
| public interface BorrowerRepository extends JpaRepository<Borrower, String> { | |||
| 
 | |||
|     @Query(nativeQuery = true, | |||
|             value = "select * from borrower where borrower_name like ?1 or borrower_name_py like ?1 or phone like ?1 ") | |||
|     List<Borrower> findBorrowerByQuery(String query); | |||
| 
 | |||
|     @Query("from Borrower where borrowerName = ?1 and phone = ?2 ") | |||
|     Borrower findBorrowerByNameAndPhone(String borrowerName,String phone); | |||
| 
 | |||
| } | |||
| @ -0,0 +1,37 @@ | |||
| package com.storeroom.modules.archives.service; | |||
| 
 | |||
| import com.storeroom.modules.archives.domain.Borrower; | |||
| import org.springframework.data.domain.Pageable; | |||
| 
 | |||
| import java.sql.Timestamp; | |||
| import java.util.List; | |||
| 
 | |||
| public interface BorrowService { | |||
| 
 | |||
|     //分页查询待借档案列表 | |||
|     Object initWaitRegisterList(String archiveNo, String maintitle, String caseName, Pageable page); | |||
|     //判断档案是否可以借阅 | |||
|     Object isExistBorrow(List<String> archiveIds); | |||
|     //档案借阅到待借阅 | |||
|     Object addArchivesWaitRegister(List<String> archiveIds); | |||
|     //移出待借阅 | |||
|     Object delWaitRegister(List<String> baIds); | |||
|     //根据姓名或联系方式检索借阅人 | |||
|     List<Borrower> findBorrowerByQuery(String query); | |||
|     //根据姓名和手机号确认是否有该借阅人  没有则新增 | |||
|     Borrower checkBorrower(Borrower borrower); | |||
|     //登记借出 | |||
|     Object registerBorrow(List<String> rbIds, Borrower borrower, Timestamp startTime,Timestamp endTime,String purpose); | |||
| 
 | |||
|     //借出确认列表 | |||
|     Object initWaitBorrowList(String billNo,String borrowerName,String phone,Pageable page); | |||
|     //根据单据获取详情信息 | |||
|     Object initBillDetailsByOrderNo(String orderNo); | |||
|     //根据单据号查询借阅档案信息 | |||
|     Object initArchivesByOrderNo(String orderNo); | |||
|     //重新登记 | |||
|     Object reRegister(List<String> orderNos); | |||
|     //移出待借阅 | |||
|     Object removeWaitBorrow(List<String> orderNos); | |||
| 
 | |||
| } | |||
| @ -0,0 +1,23 @@ | |||
| package com.storeroom.modules.archives.service.dto; | |||
| 
 | |||
| import com.storeroom.modules.archives.domain.Borrower; | |||
| import lombok.Getter; | |||
| import lombok.Setter; | |||
| 
 | |||
| import java.util.List; | |||
| 
 | |||
| @Getter | |||
| @Setter | |||
| public class RegisterBorrowDTO { | |||
|     //待借id | |||
|     private List<String> rbIds; | |||
|     //登记人信息 | |||
|     private Borrower borrower; | |||
|     //借阅开始时间 | |||
|     private String borrowerStart; | |||
|     //借阅结束时间 | |||
|     private String borrowerEnd; | |||
|     //借阅目的 | |||
|     private String purpose; | |||
| 
 | |||
| } | |||
| @ -0,0 +1,164 @@ | |||
| package com.storeroom.modules.archives.service.impl; | |||
| 
 | |||
| import com.storeroom.modules.archives.domain.BorrowArchives; | |||
| import com.storeroom.modules.archives.domain.BorrowBill; | |||
| import com.storeroom.modules.archives.domain.BorrowBillArchives; | |||
| import com.storeroom.modules.archives.domain.Borrower; | |||
| import com.storeroom.modules.archives.repository.*; | |||
| import com.storeroom.modules.archives.service.BorrowService; | |||
| import com.storeroom.utils.ChinesePinyinUtil; | |||
| import com.storeroom.utils.PageUtil; | |||
| import com.storeroom.utils.StringUtils; | |||
| import lombok.RequiredArgsConstructor; | |||
| import org.springframework.data.domain.Pageable; | |||
| import org.springframework.stereotype.Service; | |||
| 
 | |||
| import javax.transaction.Transactional; | |||
| import java.beans.Transient; | |||
| import java.sql.Timestamp; | |||
| import java.util.ArrayList; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| 
 | |||
| @Service | |||
| @RequiredArgsConstructor | |||
| public class BorrowServiceImpl implements BorrowService { | |||
| 
 | |||
|     private final BorrowerRepository borrowerRepository; | |||
|     private final BorrowBillRepository borrowBillRepository; | |||
|     private final BorrowArchivesRepository borrowArchivesRepository; | |||
|     private final BorrowSettingRepository borrowSettingRepository; | |||
|     private final BorrowBillArchivesRepository borrowBillArchivesRepository; | |||
|     private final ArchivesSummaryRepository archivesSummaryRepository; | |||
| 
 | |||
|     @Override | |||
|     public Object initWaitRegisterList(String archiveNo, String maintitle, String caseName, Pageable page) { | |||
|         archiveNo = StringUtils.isEmpty(archiveNo) ? null : "%"+ archiveNo +"%"; | |||
|         maintitle = StringUtils.isEmpty(maintitle) ? null : "%"+ maintitle +"%"; | |||
|         caseName = StringUtils.isEmpty(caseName) ? null : "%"+ caseName +"%"; | |||
|         return PageUtil.toPage(borrowArchivesRepository.initWaitRegisterList(archiveNo,maintitle,caseName,page)); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public Object isExistBorrow(List<String> archiveIds) { | |||
|         return archivesSummaryRepository.isExistBorrow(archiveIds); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public Object addArchivesWaitRegister(List<String> archiveIds) { | |||
|         List<BorrowArchives> addBorrowArchives = borrowArchivesRepository.findAllByArchivesIdss(archiveIds); | |||
|         addBorrowArchives = borrowArchivesRepository.saveAll(addBorrowArchives); | |||
|         return addBorrowArchives; | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public Object delWaitRegister(List<String> baIds) { | |||
|         borrowArchivesRepository.deleteAllById(baIds); | |||
|         return baIds.size(); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public List<Borrower> findBorrowerByQuery(String query) { | |||
|         if(StringUtils.isEmpty(query)) | |||
|             return null; | |||
|         query =  "%"+ query +"%"; | |||
|         return borrowerRepository.findBorrowerByQuery(query); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public Borrower checkBorrower(Borrower borrower) { | |||
|         Borrower query = borrowerRepository.findBorrowerByNameAndPhone(borrower.getBorrowerName(),borrower.getPhone()); | |||
|         //如果姓名/电话找到借阅人 则返回 否则新增借阅人 | |||
|         if(null != query) | |||
|             return query; | |||
|         borrower.setBorrowerNamePy(ChinesePinyinUtil.getPinYinHeadChar(borrower.getBorrowerName())); | |||
|         return borrowerRepository.save(borrower); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     @Transactional | |||
|     public Object registerBorrow(List<String> rbIds, Borrower borrower,Timestamp startTime,Timestamp endTime,String purpose) { | |||
|         //生成清单 | |||
|         BorrowBill bill = this.createBill(rbIds.size(),borrower.getId(),startTime,endTime,purpose,0); | |||
|         if(null == bill) | |||
|             return null; | |||
|         //将待借阅档案关联到清单 | |||
|         List<BorrowBillArchives> bbas = new ArrayList<>(); | |||
|         for(String rbId:rbIds){ | |||
|             BorrowBillArchives borrowBillArchive = new BorrowBillArchives(); | |||
|             borrowBillArchive.setBillId(bill.getId()); | |||
|             borrowBillArchive.setBaId(rbId); | |||
|             bbas.add(borrowBillArchive); | |||
|         } | |||
|         borrowBillArchivesRepository.saveAll(bbas); | |||
|         //批量修改借阅档案状态 待登记 | |||
|         borrowArchivesRepository.updateAllTypeByIds(rbIds,2); | |||
|         return bill; | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public Object initWaitBorrowList(String billNo, String borrowerName, String phone, Pageable page) { | |||
|         billNo = StringUtils.isEmpty(billNo) ? null : "%"+ billNo +"%"; | |||
|         borrowerName = StringUtils.isEmpty(borrowerName) ? null : "%"+ borrowerName +"%"; | |||
|         phone = StringUtils.isEmpty(phone) ? null : "%"+ phone +"%"; | |||
|         return PageUtil.toPage(borrowBillRepository.initWaitBorrowList(billNo,borrowerName,phone,page)); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public Object initBillDetailsByOrderNo(String orderNo) { | |||
|         BorrowBill bill = borrowBillRepository.findBillById(orderNo); | |||
| 
 | |||
|         return null; | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public Object initArchivesByOrderNo(String orderNo) { | |||
|         return borrowArchivesRepository.initArchivesByOrderNo(orderNo); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     @Transactional | |||
|     public Object reRegister(List<String> orderNos) { | |||
|         //将档案借阅状态改为待登记 | |||
|         borrowArchivesRepository.updateAllTypeByOrderNos(orderNos,1); | |||
|         //删除关联信息 | |||
|         borrowBillArchivesRepository.deleteAllByOrderNos(orderNos); | |||
|         //删除清单信息 | |||
|         borrowBillRepository.deleteAllById(orderNos); | |||
|         return orderNos.size(); | |||
|     } | |||
| 
 | |||
|     @Override | |||
|     public Object removeWaitBorrow(List<String> orderNos) { | |||
|         //删除待借阅档案 | |||
|         borrowArchivesRepository.deleteAllByOrderNos(orderNos); | |||
|         //删除关联信息 | |||
|         borrowBillArchivesRepository.deleteAllByOrderNos(orderNos); | |||
|         //删除清单信息 | |||
|         borrowBillRepository.deleteAllById(orderNos); | |||
|         return orderNos.size(); | |||
|     } | |||
| 
 | |||
| 
 | |||
|     //生成清单 | |||
|     public BorrowBill createBill(Integer borrowNum,String borrowerId,Timestamp startTime,Timestamp endTime,String purpose,Integer loop){ | |||
|         BorrowBill bill = null; | |||
|         loop++; | |||
|         try { | |||
|             bill = new BorrowBill(); | |||
|             bill.setId(borrowBillRepository.getOrderId()); | |||
|             bill.setBorrowNum(borrowNum); | |||
|             bill.setBorrowerId(borrowerId); | |||
|             bill.setBorrowerStart(startTime); | |||
|             bill.setBorrowerEnd(endTime); | |||
|             bill.setBorrowType(2); | |||
|             bill.setPurpose(purpose); | |||
|             bill = borrowBillRepository.save(bill); | |||
|         }catch (Exception e){ | |||
|             if(loop==4) | |||
|                 return null; | |||
|             bill = this.createBill(borrowNum,borrowerId,startTime,endTime,purpose,loop); | |||
|         } | |||
|         return bill; | |||
|     } | |||
| } | |||
| @ -0,0 +1,82 @@ | |||
| package com.storeroom.utils; | |||
| 
 | |||
| import net.sourceforge.pinyin4j.PinyinHelper; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; | |||
| import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; | |||
| import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; | |||
| 
 | |||
| /** | |||
|  * @description: 获取首字母 汉字全拼音 | |||
|  * @author: admin | |||
|  * @date: Created in 2019/8/30 15:19 | |||
|  * @version: | |||
|  * @modified By: | |||
|  */ | |||
| public class ChinesePinyinUtil { | |||
|     /** | |||
|      * 得到 汉字的全拼 | |||
|      * | |||
|      * @param src 中文字符串 | |||
|      * @return 汉字的全拼 | |||
|      */ | |||
|     public static String getPingYin(String src) { | |||
|         HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat(); | |||
|         format.setCaseType(HanyuPinyinCaseType.LOWERCASE); | |||
|         format.setToneType(HanyuPinyinToneType.WITHOUT_TONE); | |||
|         format.setVCharType(HanyuPinyinVCharType.WITH_V); | |||
|         StringBuilder sb = new StringBuilder(); | |||
|         char[] srcArray = src.toCharArray(); | |||
|         try { | |||
|             for (int i = 0; i < srcArray.length; i++) { | |||
|                 // 判断是否为汉字字符 | |||
|                 if (Character.toString(srcArray[i]).matches("[\\u4E00-\\u9FA5]+")) { | |||
|                     String[] targetArray = PinyinHelper.toHanyuPinyinStringArray(srcArray[i], format); | |||
|                     sb.append(targetArray[0]); | |||
|                 } else { | |||
|                     sb.append(Character.toString(srcArray[i])); | |||
|                 } | |||
|             } | |||
|             return sb.toString(); | |||
|         } catch (BadHanyuPinyinOutputFormatCombination e1) { | |||
|             e1.printStackTrace(); | |||
|         } | |||
|         return sb.toString(); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 得到中文首字母,例如"专科"得到zk返回 | |||
|      * | |||
|      * @param str 中文字符串 | |||
|      * @return 得到中文首字母 | |||
|      */ | |||
|     public static String getPinYinHeadChar(String str) { | |||
|         StringBuilder sb = new StringBuilder(); | |||
|         for (int i = 0; i < str.length(); i++) { | |||
|             char word = str.charAt(i); | |||
|             String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(word); | |||
|             if (pinyinArray != null) { | |||
|                 sb.append(pinyinArray[0].charAt(0)); | |||
|             } else { | |||
|                 sb.append(word); | |||
|             } | |||
|         } | |||
|         return sb.toString().toUpperCase(); | |||
|     } | |||
| 
 | |||
|     /** | |||
|      * 将字符串转移为ASCII码 | |||
|      * | |||
|      * @param cnStr 中文字符串 | |||
|      * @return ASCII码 | |||
|      */ | |||
|     public static String getCnASCII(String cnStr) { | |||
|         StringBuilder sb = new StringBuilder(); | |||
|         byte[] bGBK = cnStr.getBytes(); | |||
|         for (int i = 0; i < bGBK.length; i++) { | |||
|             sb.append(Integer.toHexString(bGBK[i] & 0xff)); | |||
|         } | |||
|         return sb.toString(); | |||
|     } | |||
| } | |||
						Write
						Preview
					
					
					Loading…
					
					Cancel
						Save
					
		Reference in new issue