From 543926dd8469dec26063fb7dcba240c38789c6c0 Mon Sep 17 00:00:00 2001 From: xia Date: Tue, 26 Jul 2022 16:08:06 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9B=B4=E6=96=B0=E8=8E=B7=E5=8F=96mac?= =?UTF-8?q?=E5=9C=B0=E5=9D=80=202.=E6=9B=B4=E6=96=B0=E5=BD=92=E8=BF=98?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E3=80=81=E5=80=9F=E8=BF=98=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E3=80=81=E5=80=9F=E9=98=85=E8=80=85=E7=AE=A1=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../archives/controller/BorrowController.java | 74 +++++++++- .../archives/controller/RFIDController.java | 139 +++++++++++------- .../archives/domain/ArchivesSummary.java | 4 + .../archives/domain/BorrowArchives.java | 34 +++++ .../modules/archives/domain/BorrowBill.java | 12 +- .../domain/vo/BorrowBillDetailsVO.java | 18 +-- .../repository/BorrowArchivesRepository.java | 84 ++++++++++- .../BorrowBillArchivesRepository.java | 2 + .../repository/BorrowBillRepository.java | 27 +++- .../repository/BorrowSettingRepository.java | 5 + .../repository/BorrowerRepository.java | 7 + .../archives/service/ArchivesTagService.java | 2 + .../archives/service/BorrowService.java | 18 +++ .../archives/service/dto/BorrowerDTO.java | 22 +++ .../service/impl/ArchivesServiceImpl.java | 3 + .../service/impl/ArchivesTagServiceImpl.java | 13 ++ .../service/impl/BorrowServiceImpl.java | 84 ++++++++++- 17 files changed, 469 insertions(+), 79 deletions(-) create mode 100644 archives/src/main/java/com/storeroom/modules/archives/service/dto/BorrowerDTO.java diff --git a/archives/src/main/java/com/storeroom/modules/archives/controller/BorrowController.java b/archives/src/main/java/com/storeroom/modules/archives/controller/BorrowController.java index 892fa15..41cf2e7 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/controller/BorrowController.java +++ b/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 initBorrowRule(){ + return ApiResponse.success(borrowService.initBorrowRule()); + } + + @ApiOperation("更改借阅流程管理在线离线") + @PostMapping("/updateBorrowRule") + public ApiResponse updateBorrowRule( + @Validated @RequestBody boolean isType + ){ + borrowService.updateBorrowRule(isType); + return ApiResponse.success(isType); + } + @ApiOperation("待登记列表") @GetMapping("/initWaitRegisterList") public ApiResponse initWaitRegisterList( @@ -118,13 +135,7 @@ public class BorrowController { return ApiResponse.success(borrowService.removeWaitBorrow(orderNos)); } - @ApiOperation("判断借阅流程管理在线离线") - @GetMapping("/initBorrowRule") - public ApiResponse initBorrowRule(){ - return ApiResponse.success(borrowService.initBorrowRule()); - } - - @ApiOperation("预借出显示标签") + @ApiOperation("根据单据号显示标签") @PostMapping("/readyBorrowShowTid") public ApiResponse readyBorrowShowTid( @Validated @RequestBody List orderNos @@ -132,6 +143,15 @@ public class BorrowController { return ApiResponse.success(borrowService.readyBorrowShowTid(orderNos)); } + + @ApiOperation("根据借阅档案id显示标签") + @PostMapping("/readyReturnShowTid") + public ApiResponse readyReturnShowTid( + @Validated @RequestBody List rbIds + ){ + return ApiResponse.success(borrowService.readyReturnShowTid(rbIds)); + } + @ApiOperation("借出确认") @PostMapping("/billBorrowConfirm") public ApiResponse billBorrowConfirm( @@ -140,6 +160,46 @@ public class BorrowController { return ApiResponse.success(borrowService.billBorrowConfirm(orderNos)); } + @ApiOperation("归还确认列表") + @GetMapping("/initReturnConfirmList") + public ApiResponse 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 archivesReturnConfirm( + @Validated @RequestBody List rbIds + ){ + return ApiResponse.success(borrowService.archivesReturnConfirm(rbIds)); + } + + @ApiOperation("借还记录") + @GetMapping("/initBorrowLog") + public ApiResponse 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 initBorrower( + String query,String phone,Pageable page + ){ + return ApiResponse.success(borrowService.initBorrower(query,phone,page)); + } + @ApiOperation("编辑借阅者") + @PostMapping("/editBorrower") + public ApiResponse editBorrower( + @Validated @RequestBody BorrowerDTO dto + ){ + return ApiResponse.success(borrowService.editBorrower(dto)); + } } diff --git a/archives/src/main/java/com/storeroom/modules/archives/controller/RFIDController.java b/archives/src/main/java/com/storeroom/modules/archives/controller/RFIDController.java index 5aded20..fcc4485 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/controller/RFIDController.java +++ b/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 ReadEpc(String op,String sDevID) throws IOException { + public ApiResponse 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(" WriteEPC(String op,String sDevID,String EAS,String Type,String Code,String Tid) throws IOException { + public ApiResponse 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(" ReadEpc(String mac){ + public ApiResponse 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 CheckStatus(String op,String sDevID) throws IOException { + public ApiResponse 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(" 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 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(); } diff --git a/archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesSummary.java b/archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesSummary.java index b320e33..5f1351d 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesSummary.java +++ b/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; diff --git a/archives/src/main/java/com/storeroom/modules/archives/domain/BorrowArchives.java b/archives/src/main/java/com/storeroom/modules/archives/domain/BorrowArchives.java index b79b962..1ee07f5 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/domain/BorrowArchives.java +++ b/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; + } diff --git a/archives/src/main/java/com/storeroom/modules/archives/domain/BorrowBill.java b/archives/src/main/java/com/storeroom/modules/archives/domain/BorrowBill.java index 2f9a5b3..0824b72 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/domain/BorrowBill.java +++ b/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; } diff --git a/archives/src/main/java/com/storeroom/modules/archives/domain/vo/BorrowBillDetailsVO.java b/archives/src/main/java/com/storeroom/modules/archives/domain/vo/BorrowBillDetailsVO.java index e646461..1dac83a 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/domain/vo/BorrowBillDetailsVO.java +++ b/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") diff --git a/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowArchivesRepository.java b/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowArchivesRepository.java index 1e7a870..2258214 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowArchivesRepository.java +++ b/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowArchivesRepository.java @@ -22,7 +22,7 @@ public interface BorrowArchivesRepository extends JpaRepository 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 orderNos,Integer borrowType); + @Modifying + @Query(nativeQuery = true, + value = "update borrow_archives set borrow_type = ?2 where id in ?1 ") + void updateAllTypeByRbIds(List 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 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 '待归还' 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> 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> initBorrowLog(String orderNo, String borrowerName, String phone, String archiveNo,String folderLocationDetails, + String caseName, String barcode, String tid,Integer borrowType, Pageable page); + } diff --git a/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillArchivesRepository.java b/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillArchivesRepository.java index ee6fcbb..74e451c 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillArchivesRepository.java +++ b/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 { diff --git a/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillRepository.java b/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillRepository.java index 105b93d..f4ae742 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowBillRepository.java +++ b/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 @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 Page> 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> findArchivesTidByOrderNos(List 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> findArchivesTidByRbIds(List 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 "(select ba_id from borrow_bill_archives bba where bba.bill_id in ?1))) ") List> findCaseidByOrderNos(List orderNo); + @Modifying + @Query("update BorrowBill set borrowType = ?2 where id in ?1 ") + void updateBorrowTypeByOrderNos(List 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 findOrderIdsByRbId(List 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); + } diff --git a/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowSettingRepository.java b/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowSettingRepository.java index f16da19..9f2c77b 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/repository/BorrowSettingRepository.java +++ b/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 { @@ -9,4 +10,8 @@ public interface BorrowSettingRepository extends JpaRepository { @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 initBorrower(String query, String phone, Pageable page); + } diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesTagService.java b/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesTagService.java index d4d9365..36d03ed 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesTagService.java +++ b/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesTagService.java @@ -22,5 +22,7 @@ public interface ArchivesTagService { Object unbindTag(List dtos); //根据标签id更改报警状态 Object updateEasByTid(List dtos); + //根据标签id更改报警状态 + Object updateEasByTid(String eas,String tid); } diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/BorrowService.java b/archives/src/main/java/com/storeroom/modules/archives/service/BorrowService.java index 6a4f3c9..85bd37b 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/BorrowService.java +++ b/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 orderNos); //判断借阅流程管理在线离线 Object initBorrowRule(); + //更改借阅流程管理在线离线 + void updateBorrowRule(boolean isType); //预借出显示标签 Object readyBorrowShowTid(List orderNos); + //归还显示标签 + Object readyReturnShowTid(List rbIds); //档案借出确认 Object billBorrowConfirm(List orderNos); + //初始化归还确认列表 + Object initReturnConfirmList(String orderNo,String borrowerName,String phone,String archiveNo,String folderLocationDetails, + String caseName,String barcode,String tid,Pageable page); + //档案归还 + Object archivesReturnConfirm(List 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); } diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/dto/BorrowerDTO.java b/archives/src/main/java/com/storeroom/modules/archives/service/dto/BorrowerDTO.java new file mode 100644 index 0000000..64ed74d --- /dev/null +++ b/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; + +} diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java index 7afa057..27059f8 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java +++ b/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 diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesTagServiceImpl.java b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesTagServiceImpl.java index a02ac4a..c76f3a6 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesTagServiceImpl.java +++ b/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; + } + } diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/impl/BorrowServiceImpl.java b/archives/src/main/java/com/storeroom/modules/archives/service/impl/BorrowServiceImpl.java index ce7284e..2b54921 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/impl/BorrowServiceImpl.java +++ b/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 orderNos) { Map map = new HashMap<>(); @@ -167,7 +172,82 @@ public class BorrowServiceImpl implements BorrowService { } @Override + public Object readyReturnShowTid(List rbIds) { + List> archives = borrowBillRepository.findArchivesTidByRbIds(rbIds); + return archives; + } + + @Override + @Transactional public Object billBorrowConfirm(List 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 rbIds) { + try { + //更新关联档案状态 + borrowArchivesRepository.updateAllTypeByRbIds(rbIds,4); + //根据关联档案id获取相关所有单据 + List 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);