Browse Source

1.更新获取mac地址

2.更新归还确认、借还记录、借阅者管理功能
master
xia 3 years ago
parent
commit
543926dd84
  1. 74
      archives/src/main/java/com/storeroom/modules/archives/controller/BorrowController.java
  2. 139
      archives/src/main/java/com/storeroom/modules/archives/controller/RFIDController.java
  3. 4
      archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesSummary.java
  4. 34
      archives/src/main/java/com/storeroom/modules/archives/domain/BorrowArchives.java
  5. 12
      archives/src/main/java/com/storeroom/modules/archives/domain/BorrowBill.java
  6. 18
      archives/src/main/java/com/storeroom/modules/archives/domain/vo/BorrowBillDetailsVO.java
  7. 84
      archives/src/main/java/com/storeroom/modules/archives/repository/BorrowArchivesRepository.java
  8. 2
      archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillArchivesRepository.java
  9. 27
      archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillRepository.java
  10. 5
      archives/src/main/java/com/storeroom/modules/archives/repository/BorrowSettingRepository.java
  11. 7
      archives/src/main/java/com/storeroom/modules/archives/repository/BorrowerRepository.java
  12. 2
      archives/src/main/java/com/storeroom/modules/archives/service/ArchivesTagService.java
  13. 18
      archives/src/main/java/com/storeroom/modules/archives/service/BorrowService.java
  14. 22
      archives/src/main/java/com/storeroom/modules/archives/service/dto/BorrowerDTO.java
  15. 3
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java
  16. 13
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesTagServiceImpl.java
  17. 84
      archives/src/main/java/com/storeroom/modules/archives/service/impl/BorrowServiceImpl.java

74
archives/src/main/java/com/storeroom/modules/archives/controller/BorrowController.java

@ -1,7 +1,9 @@
package com.storeroom.modules.archives.controller;
import com.storeroom.modules.archives.domain.Borrower;
import com.storeroom.modules.archives.service.ArchivesTagService;
import com.storeroom.modules.archives.service.BorrowService;
import com.storeroom.modules.archives.service.dto.BorrowerDTO;
import com.storeroom.modules.archives.service.dto.RegisterBorrowDTO;
import com.storeroom.utils.ApiResponse;
import io.swagger.annotations.Api;
@ -23,6 +25,21 @@ public class BorrowController {
private final BorrowService borrowService;
@ApiOperation("判断借阅流程管理在线离线")
@GetMapping("/initBorrowRule")
public ApiResponse<Object> initBorrowRule(){
return ApiResponse.success(borrowService.initBorrowRule());
}
@ApiOperation("更改借阅流程管理在线离线")
@PostMapping("/updateBorrowRule")
public ApiResponse<Object> updateBorrowRule(
@Validated @RequestBody boolean isType
){
borrowService.updateBorrowRule(isType);
return ApiResponse.success(isType);
}
@ApiOperation("待登记列表")
@GetMapping("/initWaitRegisterList")
public ApiResponse<Object> initWaitRegisterList(
@ -118,13 +135,7 @@ public class BorrowController {
return ApiResponse.success(borrowService.removeWaitBorrow(orderNos));
}
@ApiOperation("判断借阅流程管理在线离线")
@GetMapping("/initBorrowRule")
public ApiResponse<Object> initBorrowRule(){
return ApiResponse.success(borrowService.initBorrowRule());
}
@ApiOperation("预借出显示标签")
@ApiOperation("根据单据号显示标签")
@PostMapping("/readyBorrowShowTid")
public ApiResponse<Object> readyBorrowShowTid(
@Validated @RequestBody List<String> orderNos
@ -132,6 +143,15 @@ public class BorrowController {
return ApiResponse.success(borrowService.readyBorrowShowTid(orderNos));
}
@ApiOperation("根据借阅档案id显示标签")
@PostMapping("/readyReturnShowTid")
public ApiResponse<Object> readyReturnShowTid(
@Validated @RequestBody List<String> rbIds
){
return ApiResponse.success(borrowService.readyReturnShowTid(rbIds));
}
@ApiOperation("借出确认")
@PostMapping("/billBorrowConfirm")
public ApiResponse<Object> billBorrowConfirm(
@ -140,6 +160,46 @@ public class BorrowController {
return ApiResponse.success(borrowService.billBorrowConfirm(orderNos));
}
@ApiOperation("归还确认列表")
@GetMapping("/initReturnConfirmList")
public ApiResponse<Object> initReturnConfirmList(
String orderNo,String borrowerName,String phone,String archiveNo,String folderLocationDetails,
String caseName,String barcode,String tid,Pageable page
){
return ApiResponse.success(borrowService.initReturnConfirmList(orderNo,borrowerName,phone,archiveNo,folderLocationDetails,caseName,barcode,tid,page));
}
@ApiOperation("归还确认")
@PostMapping("/archivesReturnConfirm")
public ApiResponse<Object> archivesReturnConfirm(
@Validated @RequestBody List<String> rbIds
){
return ApiResponse.success(borrowService.archivesReturnConfirm(rbIds));
}
@ApiOperation("借还记录")
@GetMapping("/initBorrowLog")
public ApiResponse<Object> initBorrowLog(
String orderNo,String borrowerName,String phone,String archiveNo,String folderLocationDetails,
String caseName,String barcode,String tid,Integer borrowType,Pageable page
){
return ApiResponse.success(borrowService.initBorrowLog(orderNo,borrowerName,phone,archiveNo,folderLocationDetails,caseName,barcode,tid,borrowType,page));
}
@ApiOperation("借阅者列表")
@GetMapping("/initBorrower")
public ApiResponse<Object> initBorrower(
String query,String phone,Pageable page
){
return ApiResponse.success(borrowService.initBorrower(query,phone,page));
}
@ApiOperation("编辑借阅者")
@PostMapping("/editBorrower")
public ApiResponse<Object> editBorrower(
@Validated @RequestBody BorrowerDTO dto
){
return ApiResponse.success(borrowService.editBorrower(dto));
}
}

139
archives/src/main/java/com/storeroom/modules/archives/controller/RFIDController.java

@ -2,7 +2,10 @@ package com.storeroom.modules.archives.controller;
import cn.hutool.http.HttpResource;
import com.alibaba.fastjson.JSONObject;
import com.google.common.base.Strings;
import com.storeroom.annotaion.rest.AnonymousGetMapping;
import com.storeroom.modules.archives.service.ArchivesTagService;
import com.storeroom.modules.device.service.DeviceService;
import com.storeroom.modules.device.service.DeviceSpecParamService;
import com.storeroom.modules.device.service.dto.DeviceSpecParamDto;
@ -14,21 +17,17 @@ import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.*;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -43,14 +42,15 @@ public class RFIDController {
private final DeviceService deviceService;
private final DeviceSpecParamService deviceSpecParamService;
private final ArchivesTagService archivesTagService;
@ApiOperation("读取epc和Tid号")
@GetMapping("/ReadEpc")
public ApiResponse<Object> ReadEpc(String op,String sDevID) throws IOException {
public ApiResponse<Object> ReadEpc(String op, String sDevID) throws IOException {
String result = "";
try {
HttpClient client = HttpClients.createDefault();
String url = "http://"+ip+"/RFIDInterface.aspx?op="+op+"&sDevID="+sDevID;
String url = "http://" + ip + "/RFIDInterface.aspx?op=" + op + "&sDevID=" + sDevID;
HttpGet httpGet = new HttpGet(url);
httpGet.setHeader("Content-Type", "application/x-www-form-urlencoded");
System.out.println("调用URL: " + httpGet.getURI());
@ -65,7 +65,7 @@ public class RFIDController {
String line = null;
StringBuffer responseSB = new StringBuffer();
while ((line = reader.readLine()) != null) {
if(line.contains("<!")){
if (line.contains("<!")) {
break;
}
responseSB.append(line.trim());
@ -74,7 +74,7 @@ public class RFIDController {
reader.close();
httpClient.close();
result = responseSB.toString();
}catch (Exception e){
} catch (Exception e) {
System.err.println(e.toString());
}
return ApiResponse.success(result);
@ -82,16 +82,16 @@ public class RFIDController {
@ApiOperation("写epc")
@GetMapping("/WriteEPC")
public ApiResponse<Object> WriteEPC(String op,String sDevID,String EAS,String Type,String Code,String Tid) throws IOException {
public ApiResponse<Object> WriteEPC(String op, String sDevID, String EAS, String Type, String Code, String Tid) throws IOException {
String result = "";
try {
HttpClient client = HttpClients.createDefault();
String url = "http://"+ip+"/RFIDInterface.aspx?op="+op
+"&sDevID="+sDevID
+"&EAS="+EAS
+"&Type="+Type
+"&Code="+Code
+"&Tid="+Tid;
String url = "http://" + ip + "/RFIDInterface.aspx?op=" + op
+ "&sDevID=" + sDevID
+ "&EAS=" + EAS
+ "&Type=" + Type
+ "&Code=" + Code
+ "&Tid=" + Tid;
HttpGet httpGet = new HttpGet(url);
httpGet.setHeader("Content-Type", "application/x-www-form-urlencoded");
System.out.println("调用URL: " + httpGet.getURI());
@ -106,7 +106,7 @@ public class RFIDController {
String line = null;
StringBuffer responseSB = new StringBuffer();
while ((line = reader.readLine()) != null) {
if(line.contains("<!")){
if (line.contains("<!")) {
break;
}
responseSB.append(line.trim());
@ -115,7 +115,12 @@ public class RFIDController {
reader.close();
httpClient.close();
result = responseSB.toString();
}catch (Exception e){
if (null != result) {
JSONObject json = JSONObject.parseObject(result);
if ("0".equals(json.get("code") + ""))
archivesTagService.updateEasByTid(EAS, Tid);
}
} catch (Exception e) {
System.err.println(e.toString());
}
return ApiResponse.success(result);
@ -123,20 +128,20 @@ public class RFIDController {
@ApiOperation("根据mac地址获取设备id")
@GetMapping("/getDeviceIdByMac")
public ApiResponse<Object> ReadEpc(String mac){
public ApiResponse<Object> ReadEpc(String mac) {
DeviceSpecParamDto deviceSpecParamDto = deviceSpecParamService.findMacAddress(mac);
if(null == deviceSpecParamDto)
if (null == deviceSpecParamDto)
return ApiResponse.success(null);
return ApiResponse.success(deviceService.findById(deviceSpecParamDto.getDeviceInfoId()));
}
@ApiOperation("读写器状态检测")
@GetMapping("/CheckStatus")
public ApiResponse<Object> CheckStatus(String op,String sDevID) throws IOException {
public ApiResponse<Object> CheckStatus(String op, String sDevID) throws IOException {
String result = "";
try {
HttpClient client = HttpClients.createDefault();
String url = "http://"+ip+"/RFIDInterface.aspx?op="+op+"&sDevID="+sDevID;
String url = "http://" + ip + "/RFIDInterface.aspx?op=" + op + "&sDevID=" + sDevID;
HttpGet httpGet = new HttpGet(url);
httpGet.setHeader("Content-Type", "application/x-www-form-urlencoded");
System.out.println("调用URL: " + httpGet.getURI());
@ -151,7 +156,7 @@ public class RFIDController {
String line = null;
StringBuffer responseSB = new StringBuffer();
while ((line = reader.readLine()) != null) {
if(line.contains("<!")){
if (line.contains("<!")) {
break;
}
responseSB.append(line.trim());
@ -160,7 +165,7 @@ public class RFIDController {
reader.close();
httpClient.close();
result = responseSB.toString();
}catch (Exception e){
} catch (Exception e) {
System.err.println(e.toString());
}
return ApiResponse.success(result);
@ -168,42 +173,72 @@ public class RFIDController {
@ApiOperation("获取设备mac地址")
@AnonymousGetMapping("/getDeviceMac")
public ApiResponse<Object> getDeviceMac(HttpServletRequest request){
String ip = request.getHeader("X-real-ip");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("x-forwarded-for");
public ApiResponse<Object> getDeviceMac(HttpServletRequest request) {
String Xip = request.getHeader("X-Real-IP");
String XFor = request.getHeader("X-Forwarded-For");
if (!Strings.isNullOrEmpty(XFor) && !"unKnown".equalsIgnoreCase(XFor)) {
//多次反向代理后会有多个ip值第一个ip才是真实ip
int index = XFor.indexOf(",");
if(!"127.0.0.1".equals(XFor)){
if (index != -1) {
return ApiResponse.success(XFor.substring(0, index));
} else {
return ApiResponse.success(XFor);
}
}
XFor = null;
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
XFor = Xip;
if (!Strings.isNullOrEmpty(XFor) && !"unKnown".equalsIgnoreCase(XFor)) {
//String mac = MacUtil.getMacInWindows(XFor);
return ApiResponse.success(XFor);
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
if (Strings.nullToEmpty(XFor).trim().isEmpty() || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_CLIENT_IP");
if (Strings.nullToEmpty(XFor).trim().isEmpty() || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("HTTP_X_FORWARDED_FOR");
if (Strings.nullToEmpty(XFor).trim().isEmpty() || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("HTTP_CLIENT_IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
if (Strings.nullToEmpty(XFor).trim().isEmpty() || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getHeader("HTTP_X_FORWARDED_FOR");
}
if (Strings.nullToEmpty(XFor).trim().isEmpty() || "unknown".equalsIgnoreCase(XFor)) {
XFor = request.getRemoteAddr();
}
String macAddr = null;
try {
Process process = Runtime.getRuntime().exec("nbtstat -a " + ip);
BufferedReader br = new BufferedReader(
new InputStreamReader(process.getInputStream()));
Pattern pattern = Pattern.compile("([A-F0-9]{2}-){5}[A-F0-9]{2}");
Matcher matcher;
for (String strLine = br.readLine(); strLine != null;
strLine = br.readLine()) {
matcher = pattern.matcher(strLine);
if (matcher.find()) {
macAddr = matcher.group();
break;
// Process process = Runtime.getRuntime().exec("nbtstat -a " + XFor);
// BufferedReader br = new BufferedReader(
// new InputStreamReader(process.getInputStream()));
// Pattern pattern = Pattern.compile("([A-F0-9]{2}-){5}[A-F0-9]{2}");
// Matcher matcher;
// for (String strLine = br.readLine(); strLine != null;
// strLine = br.readLine()) {
// matcher = pattern.matcher(strLine);
// if (matcher.find()) {
// macAddr = matcher.group();
// break;
// }
// }
String str = "";
Process process = Runtime.getRuntime().exec("nbtstat -a " + XFor);
InputStreamReader ir = new InputStreamReader(process.getInputStream(),"gbk");
LineNumberReader input = new LineNumberReader(ir);
for(int i = 0;i<100;i++){
str = input.readLine();
if(null != str){
if(str.indexOf("MAC 地址")>1){
macAddr = str.substring(str.indexOf("MAC 地址")+9);
break;
}
}
}
} catch (IOException e) {
e.printStackTrace();
}

4
archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesSummary.java

@ -125,6 +125,10 @@ public class ArchivesSummary extends BaseEntity implements Serializable {
@ApiModelProperty(value = "子条目数")
private Integer child;
@Column(name = "barcode")
@ApiModelProperty(value = "条形码")
private String barcode;
@Column(name = "is_delete_time")
@ApiModelProperty(value = "删除时间")
private String isDeleteTime;

34
archives/src/main/java/com/storeroom/modules/archives/domain/BorrowArchives.java

@ -1,10 +1,16 @@
package com.storeroom.modules.archives.domain;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.storeroom.base.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.UpdateTimestamp;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.LastModifiedBy;
import javax.persistence.*;
import java.io.Serializable;
@ -54,6 +60,14 @@ public class BorrowArchives implements Serializable {
@ApiModelProperty(value = "存放位置")
private String folderLocationDetails;
@Column(name = "tid")
@ApiModelProperty(value = "标签id")
private String tid;
@Column(name = "barcode")
@ApiModelProperty(value = "条形码")
private String barcode;
@Column(name = "start_time")
@ApiModelProperty(value = "借阅时间")
private Timestamp startTime;
@ -62,4 +76,24 @@ public class BorrowArchives implements Serializable {
@ApiModelProperty(value = "归还时间")
private Timestamp endTime;
@CreatedBy
@Column(name = "create_by", updatable = false)
@ApiModelProperty(value = "创建人", hidden = true)
private String createBy;
@LastModifiedBy
@Column(name = "update_by")
@ApiModelProperty(value = "更新人", hidden = true)
private String updatedBy;
@CreationTimestamp
@Column(name = "create_time", updatable = false)
@ApiModelProperty(value = "创建时间", hidden = true)
private Timestamp createTime;
@UpdateTimestamp
@Column(name = "update_time")
@ApiModelProperty(value = "更新时间", hidden = true)
private Timestamp updateTime;
}

12
archives/src/main/java/com/storeroom/modules/archives/domain/BorrowBill.java

@ -36,16 +36,16 @@ public class BorrowBill extends BaseEntity implements Serializable {
@ApiModelProperty(value = "借阅目的")
private String purpose;
@Column(name = "borrower_start")
@Column(name = "borrow_start")
@ApiModelProperty(value = "借阅开始时间")
private Timestamp borrowerStart;
private Timestamp borrowStart;
@Column(name = "borrower_end")
@Column(name = "borrow_end")
@ApiModelProperty(value = "借阅应归还时间")
private Timestamp borrowerEnd;
private Timestamp borrowEnd;
@Column(name = "borrower_real_end")
@Column(name = "borrow_real_end")
@ApiModelProperty(value = "借阅实际归还时间")
private Timestamp borrowerRealEnd;
private Timestamp borrowRealEnd;
}

18
archives/src/main/java/com/storeroom/modules/archives/domain/vo/BorrowBillDetailsVO.java

@ -35,17 +35,17 @@ public class BorrowBillDetailsVO {
@JsonProperty("purpose")
private String purpose;
@JSONField(name="borrowerStart")
@JsonProperty("borrower_start")
private Timestamp borrowerStart;
@JSONField(name="borrowStart")
@JsonProperty("borrow_start")
private Timestamp borrowStart;
@JSONField(name="borrowerEnd")
@JsonProperty("borrower_end")
private Timestamp borrowerEnd;
@JSONField(name="borrowEnd")
@JsonProperty("borrow_end")
private Timestamp borrowEnd;
@JSONField(name="borrowerRealEnd")
@JsonProperty("borrower_real_end")
private Timestamp borrowerRealEnd;
@JSONField(name="borrowRealEnd")
@JsonProperty("borrow_real_end")
private Timestamp borrowRealEnd;
@JSONField(name="createTime")
@JsonProperty("create_time")

84
archives/src/main/java/com/storeroom/modules/archives/repository/BorrowArchivesRepository.java

@ -22,7 +22,7 @@ public interface BorrowArchivesRepository extends JpaRepository<BorrowArchives,
Page<BorrowArchives> initWaitRegisterList(String archiveNo, String maintitle, String caseName,String folderLocationDetails, Pageable page);
@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," +
"(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 " +
@ -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)")
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
@Query(nativeQuery = true,
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)")
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);
}

2
archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillArchivesRepository.java

@ -2,11 +2,13 @@ package com.storeroom.modules.archives.repository;
import com.storeroom.modules.archives.domain.BorrowBillArchives;
import com.storeroom.modules.archives.domain.Borrower;
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;
import java.util.Map;
public interface BorrowBillArchivesRepository extends JpaRepository<BorrowBillArchives, String> {

27
archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillRepository.java

@ -4,6 +4,7 @@ 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.Modifying;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
@ -23,7 +24,7 @@ public interface BorrowBillRepository extends JpaRepository<BorrowBill, String>
@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," +
"ber.card_type as cardType,ber.idcard,ber.phone,bbl.borrow_start as startTime,bbl.borrow_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 " +
@ -33,12 +34,18 @@ public interface BorrowBillRepository extends JpaRepository<BorrowBill, String>
Page<Map<String,Object>> initWaitBorrowList(String billNo, String borrowerName, String phone, Pageable page);
@Query(nativeQuery = true,
value = "select asy.maintitle as maintitle,asy.tag_no as tid,1 as tagType,tag.eas from archives_summary asy " +
value = "select asy.archives_id as archivesId,asy.maintitle as maintitle,asy.tag_no as tid,1 as tagType,tag.eas from archives_summary asy " +
"inner join archives_tag tag on asy.tag_no = tag.tid where asy.tag_no is not null " +
"and asy.archives_id in (select archives_id from borrow_archives bas where bas.id in " +
"(select ba_id from borrow_bill_archives bba where bba.bill_id in ?1))")
List<Map<String,Object>> findArchivesTidByOrderNos(List<String> orderNo);
@Query(nativeQuery = true,
value = "select asy.archives_id as archivesId,asy.maintitle as maintitle,asy.tag_no as tid,1 as tagType,tag.eas from borrow_archives ba " +
"inner join archives_summary asy on ba.archives_id = asy.archives_id " +
"inner join archives_tag tag on asy.tag_no = tag.tid where id in ?1 ")
List<Map<String,Object>> findArchivesTidByRbIds(List<String> rbIds);
@Query(nativeQuery = true,
value = "select ace.case_name as maintitle,ace.tid,2 as tagType,tag.eas from archives_case ace " +
"inner join archives_tag tag on ace.tid = tag.tid where ace.tid is not null " +
@ -47,4 +54,20 @@ public interface BorrowBillRepository extends JpaRepository<BorrowBill, String>
"(select ba_id from borrow_bill_archives bba where bba.bill_id in ?1))) ")
List<Map<String,Object>> findCaseidByOrderNos(List<String> orderNo);
@Modifying
@Query("update BorrowBill set borrowType = ?2 where id in ?1 ")
void updateBorrowTypeByOrderNos(List<String> orderNo,Integer borrowType);
@Modifying
@Query("update BorrowBill set borrowType = ?2 where id = ?1 ")
void updateBorrowTypeByOrderNo(String orderNo,Integer borrowType);
@Query(nativeQuery = true,
value = "select bill_id from borrow_bill_archives where ba_id in ?1 group by bill_id")
List<String> findOrderIdsByRbId(List<String> rbIds);
@Query(nativeQuery = true,
value = "select count(1) from borrow_bill_archives bba inner join borrow_archives ba on bba.ba_id = ba.id where ba.borrow_type != 4 and bill_id = ?1 limit 0,1")
Integer getNotReturnedNum(String orderNo);
}

5
archives/src/main/java/com/storeroom/modules/archives/repository/BorrowSettingRepository.java

@ -2,6 +2,7 @@ package com.storeroom.modules.archives.repository;
import com.storeroom.modules.archives.domain.BorrowSetting;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
public interface BorrowSettingRepository extends JpaRepository<BorrowSetting, Integer> {
@ -9,4 +10,8 @@ public interface BorrowSettingRepository extends JpaRepository<BorrowSetting, In
@Query(nativeQuery = true,
value = "select is_type from borrow_setting limit 0,1")
String findFirstToIsType();
@Modifying
@Query("update BorrowSetting set isType = ?1 where id = 1")
void updateBorrowRule(boolean isType);
}

7
archives/src/main/java/com/storeroom/modules/archives/repository/BorrowerRepository.java

@ -1,6 +1,8 @@
package com.storeroom.modules.archives.repository;
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.Query;
@ -15,4 +17,9 @@ public interface BorrowerRepository extends JpaRepository<Borrower, String> {
@Query("from Borrower where borrowerName = ?1 and phone = ?2 ")
Borrower findBorrowerByNameAndPhone(String borrowerName,String phone);
@Query(nativeQuery = true,
value = "select * from borrower where if(?1 is null,1=1,(borrower_name like ?1 or borrower_name_py like ?1)) " +
"and if(?2 is null,1=1,phone like ?2) order by create_by desc ")
Page<Borrower> initBorrower(String query, String phone, Pageable page);
}

2
archives/src/main/java/com/storeroom/modules/archives/service/ArchivesTagService.java

@ -22,5 +22,7 @@ public interface ArchivesTagService {
Object unbindTag(List<CaseDTO> dtos);
//根据标签id更改报警状态
Object updateEasByTid(List<CaseDTO> dtos);
//根据标签id更改报警状态
Object updateEasByTid(String eas,String tid);
}

18
archives/src/main/java/com/storeroom/modules/archives/service/BorrowService.java

@ -1,6 +1,7 @@
package com.storeroom.modules.archives.service;
import com.storeroom.modules.archives.domain.Borrower;
import com.storeroom.modules.archives.service.dto.BorrowerDTO;
import org.springframework.data.domain.Pageable;
import java.sql.Timestamp;
@ -35,9 +36,26 @@ public interface BorrowService {
Object removeWaitBorrow(List<String> orderNos);
//判断借阅流程管理在线离线
Object initBorrowRule();
//更改借阅流程管理在线离线
void updateBorrowRule(boolean isType);
//预借出显示标签
Object readyBorrowShowTid(List<String> orderNos);
//归还显示标签
Object readyReturnShowTid(List<String> rbIds);
//档案借出确认
Object billBorrowConfirm(List<String> orderNos);
//初始化归还确认列表
Object initReturnConfirmList(String orderNo,String borrowerName,String phone,String archiveNo,String folderLocationDetails,
String caseName,String barcode,String tid,Pageable page);
//档案归还
Object archivesReturnConfirm(List<String> rbIds);
//初始化借还记录
Object initBorrowLog(String orderNo,String borrowerName,String phone,String archiveNo,String folderLocationDetails,
String caseName,String barcode,String tid,Integer borrowType,Pageable page);
//初始化借阅人列表
Object initBorrower(String query,String phone,Pageable page);
//编辑借阅者信息
Object editBorrower(BorrowerDTO dto);
}

22
archives/src/main/java/com/storeroom/modules/archives/service/dto/BorrowerDTO.java

@ -0,0 +1,22 @@
package com.storeroom.modules.archives.service.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class BorrowerDTO {
//借阅者id
private String id;
//借阅者姓名
private String borrowerName;
//联系方式
private String phone;
//部门名称
private String department;
//证件类别
private String cardType;
//证件号
private String idcard;
}

3
archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java

@ -424,6 +424,9 @@ public class ArchivesServiceImpl implements ArchivesService {
//立卷时间
if(filedNameList.contains("filing_date"))
archivesSummary.setFilingDate(json.get("filing_date")==null?null:json.get("filing_date")+"");
//条形码
if(filedNameList.contains("barcode"))
archivesSummary.setBarcode(json.get("barcode")==null?null:json.get("barcode")+"");
archivesSummary.setCategoryId(archivesType.getId());//门类id

13
archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesTagServiceImpl.java

@ -204,5 +204,18 @@ public class ArchivesTagServiceImpl implements ArchivesTagService {
return result;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Object updateEasByTid(String eas, String tid) {
Integer writeEas = 0;
try {
writeEas = Integer.parseInt(eas);
}catch (Exception e){
writeEas=0;
}
archivesTagRepository.updateEasByTid(tid,writeEas);
return writeEas;
}
}

84
archives/src/main/java/com/storeroom/modules/archives/service/impl/BorrowServiceImpl.java

@ -9,6 +9,7 @@ import com.storeroom.modules.archives.domain.Borrower;
import com.storeroom.modules.archives.domain.vo.BorrowBillDetailsVO;
import com.storeroom.modules.archives.repository.*;
import com.storeroom.modules.archives.service.BorrowService;
import com.storeroom.modules.archives.service.dto.BorrowerDTO;
import com.storeroom.utils.ChinesePinyinUtil;
import com.storeroom.utils.PageUtil;
import com.storeroom.utils.StringUtils;
@ -154,6 +155,10 @@ public class BorrowServiceImpl implements BorrowService {
return borrowSettingRepository.findFirstToIsType();
}
@Override
@Transactional
public void updateBorrowRule(boolean isType) {borrowSettingRepository.updateBorrowRule(isType);}
@Override
public Object readyBorrowShowTid(List<String> orderNos) {
Map<String,Object> map = new HashMap<>();
@ -167,7 +172,82 @@ public class BorrowServiceImpl implements BorrowService {
}
@Override
public Object readyReturnShowTid(List<String> rbIds) {
List<Map<String,Object>> archives = borrowBillRepository.findArchivesTidByRbIds(rbIds);
return archives;
}
@Override
@Transactional
public Object billBorrowConfirm(List<String> orderNos) {
//更改清单内档案状态
borrowArchivesRepository.updateAllTypeByOrderNos(orderNos,3);
//更改清单状态
borrowBillRepository.updateBorrowTypeByOrderNos(orderNos,3);
return orderNos.size();
}
@Override
public Object initReturnConfirmList(String orderNo, String borrowerName, String phone, String archiveNo,
String folderLocationDetails, String caseName, String barcode, String tid, Pageable page) {
orderNo = StringUtils.isEmpty(orderNo) ? null : "%"+ orderNo +"%";
borrowerName = StringUtils.isEmpty(borrowerName) ? null : "%"+ borrowerName +"%";
phone = StringUtils.isEmpty(phone) ? null : "%"+ phone +"%";
archiveNo = StringUtils.isEmpty(archiveNo) ? null : "%"+ archiveNo +"%";
folderLocationDetails = StringUtils.isEmpty(folderLocationDetails) ? null : "%"+ folderLocationDetails +"%";
caseName = StringUtils.isEmpty(caseName) ? null : "%"+ caseName +"%";
barcode = StringUtils.isEmpty(barcode) ? null : "%"+ barcode +"%";
tid = StringUtils.isEmpty(tid) ? null : "%"+ tid +"%";
return PageUtil.toPage(borrowArchivesRepository.initReturnConfirmList(orderNo,borrowerName,phone,archiveNo
,folderLocationDetails,caseName,barcode,tid,page));
}
@Override
@Transactional
public Object archivesReturnConfirm(List<String> rbIds) {
try {
//更新关联档案状态
borrowArchivesRepository.updateAllTypeByRbIds(rbIds,4);
//根据关联档案id获取相关所有单据
List<String> orderNos = borrowBillRepository.findOrderIdsByRbId(rbIds);
//更新相关单据状态
for (String orderNo:orderNos){
//当清单号下借阅全为已归还时更改清单状态
Integer returnCount = borrowBillRepository.getNotReturnedNum(orderNo);
if(0 == returnCount)
borrowBillRepository.updateBorrowTypeByOrderNo(orderNo,4);
}
return rbIds.size();
}catch (Exception e){
return 0;
}
}
@Override
public Object initBorrowLog(String orderNo, String borrowerName, String phone, String archiveNo, String folderLocationDetails, String caseName, String barcode, String tid, Integer borrowType, Pageable page) {
orderNo = StringUtils.isEmpty(orderNo) ? null : "%"+ orderNo +"%";
borrowerName = StringUtils.isEmpty(borrowerName) ? null : "%"+ borrowerName +"%";
phone = StringUtils.isEmpty(phone) ? null : "%"+ phone +"%";
archiveNo = StringUtils.isEmpty(archiveNo) ? null : "%"+ archiveNo +"%";
folderLocationDetails = StringUtils.isEmpty(folderLocationDetails) ? null : "%"+ folderLocationDetails +"%";
caseName = StringUtils.isEmpty(caseName) ? null : "%"+ caseName +"%";
barcode = StringUtils.isEmpty(barcode) ? null : "%"+ barcode +"%";
tid = StringUtils.isEmpty(tid) ? null : "%"+ tid +"%";
return PageUtil.toPage(borrowArchivesRepository.initBorrowLog(orderNo,borrowerName,phone,archiveNo
,folderLocationDetails,caseName,barcode,tid,borrowType,page));
}
@Override
public Object initBorrower(String query, String phone, Pageable page) {
query = StringUtils.isEmpty(query) ? null : "%"+ query +"%";
phone = StringUtils.isEmpty(phone) ? null : "%"+ phone +"%";
return PageUtil.toPage(borrowerRepository.initBorrower(query,phone,page));
}
@Override
@Transactional
public Object editBorrower(BorrowerDTO dto) {
Borrower borrower = null;
return null;
}
@ -182,8 +262,8 @@ public class BorrowServiceImpl implements BorrowService {
bill.setId(borrowBillRepository.getOrderId());
bill.setBorrowNum(borrowNum);
bill.setBorrowerId(borrowerId);
bill.setBorrowerStart(startTime);
bill.setBorrowerEnd(endTime);
bill.setBorrowStart(startTime);
bill.setBorrowEnd(endTime);
bill.setBorrowType(2);
bill.setPurpose(purpose);
bill = borrowBillRepository.save(bill);

Loading…
Cancel
Save