14 changed files with 409 additions and 24 deletions
-
5archives/pom.xml
-
8archives/src/main/java/com/storeroom/modules/archives/controller/ArchivesController.java
-
52archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java
-
149archives/src/main/java/com/storeroom/modules/archives/controller/RFIDController.java
-
48archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java
-
14archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java
-
1archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java
-
15archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java
-
2archives/src/main/java/com/storeroom/modules/archives/service/ArchivesService.java
-
61archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java
-
46archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java
-
8archives/src/main/java/com/storeroom/modules/dictionary/repository/ArchivesDictionaryRepository.java
-
20archives/src/main/java/com/storeroom/modules/dictionary/service/dto/CaseDTO.java
-
4system/src/main/resources/application.yml
@ -0,0 +1,52 @@ |
|||
package com.storeroom.modules.archives.controller; |
|||
|
|||
import com.storeroom.modules.archives.service.ArchivesCaseService; |
|||
import com.storeroom.modules.dictionary.service.dto.CaseDTO; |
|||
import com.storeroom.utils.ApiResponse; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@Api(tags = "盒管理") |
|||
@RequestMapping("/api/case") |
|||
public class CaseController { |
|||
|
|||
private final ArchivesCaseService caseService; |
|||
|
|||
@ApiOperation("档案盒列表") |
|||
@GetMapping("/initCaseList") |
|||
public ApiResponse<Object> initCaseList( |
|||
String tid, String caseName, Pageable page |
|||
){ |
|||
return ApiResponse.success(caseService.initCaseList(tid,caseName,page)); |
|||
} |
|||
|
|||
@ApiOperation("档案盒编辑") |
|||
@PostMapping("/edit") |
|||
public ApiResponse<Object> edit( |
|||
@Validated @RequestBody CaseDTO dto |
|||
){ |
|||
return ApiResponse.success(caseService.edit(dto)); |
|||
} |
|||
|
|||
@ApiOperation("档案盒绑定标签") |
|||
@PostMapping("/bingdingLabel") |
|||
public ApiResponse<Object> bingdingLabel( |
|||
@Validated @RequestBody CaseDTO dto |
|||
){ |
|||
Integer bindingCount = caseService.findIsBingdingLabel(dto.getTid(),dto.getLabelType()); |
|||
if(bindingCount == 0){ |
|||
return ApiResponse.success(null); |
|||
}else{ |
|||
return ApiResponse.error(); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,149 @@ |
|||
package com.storeroom.modules.archives.controller; |
|||
|
|||
|
|||
import cn.hutool.http.HttpResource; |
|||
import com.storeroom.utils.ApiResponse; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import lombok.RequiredArgsConstructor; |
|||
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.web.bind.annotation.GetMapping; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import java.io.BufferedReader; |
|||
import java.io.IOException; |
|||
import java.io.InputStreamReader; |
|||
|
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
@Api(tags = "RFID手持机") |
|||
@RequestMapping("/api/RFID") |
|||
public class RFIDController { |
|||
|
|||
@Value("${hand-held.ip}") |
|||
private String ip; |
|||
|
|||
@ApiOperation("读取epc和Tid号") |
|||
@GetMapping("/ReadEpc") |
|||
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; |
|||
HttpGet httpGet = new HttpGet(url); |
|||
httpGet.setHeader("Content-Type", "application/x-www-form-urlencoded"); |
|||
System.out.println("调用URL: " + httpGet.getURI()); |
|||
//httpClient实例化 |
|||
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|||
// 执行请求并获取返回 |
|||
HttpResponse response = httpClient.execute(httpGet); |
|||
HttpEntity entity = response.getEntity(); |
|||
System.out.println("返回状态码:" + response.getStatusLine()); |
|||
// 显示结果 |
|||
BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8")); |
|||
String line = null; |
|||
StringBuffer responseSB = new StringBuffer(); |
|||
while ((line = reader.readLine()) != null) { |
|||
if(line.contains("<!")){ |
|||
break; |
|||
} |
|||
responseSB.append(line.trim()); |
|||
} |
|||
System.out.println("返回消息:" + responseSB); |
|||
reader.close(); |
|||
httpClient.close(); |
|||
result = responseSB.toString(); |
|||
}catch (Exception e){ |
|||
System.err.println(e.toString()); |
|||
} |
|||
return ApiResponse.success(result); |
|||
} |
|||
|
|||
@ApiOperation("写epc") |
|||
@GetMapping("/WriteEPC") |
|||
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; |
|||
HttpGet httpGet = new HttpGet(url); |
|||
httpGet.setHeader("Content-Type", "application/x-www-form-urlencoded"); |
|||
System.out.println("调用URL: " + httpGet.getURI()); |
|||
//httpClient实例化 |
|||
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|||
// 执行请求并获取返回 |
|||
HttpResponse response = httpClient.execute(httpGet); |
|||
HttpEntity entity = response.getEntity(); |
|||
System.out.println("返回状态码:" + response.getStatusLine()); |
|||
// 显示结果 |
|||
BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8")); |
|||
String line = null; |
|||
StringBuffer responseSB = new StringBuffer(); |
|||
while ((line = reader.readLine()) != null) { |
|||
if(line.contains("<!")){ |
|||
break; |
|||
} |
|||
responseSB.append(line.trim()); |
|||
} |
|||
System.out.println("返回消息:" + responseSB); |
|||
reader.close(); |
|||
httpClient.close(); |
|||
result = responseSB.toString(); |
|||
}catch (Exception e){ |
|||
System.err.println(e.toString()); |
|||
} |
|||
return ApiResponse.success(result); |
|||
} |
|||
|
|||
@ApiOperation("读写器状态检测") |
|||
@GetMapping("/CheckStatus") |
|||
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; |
|||
HttpGet httpGet = new HttpGet(url); |
|||
httpGet.setHeader("Content-Type", "application/x-www-form-urlencoded"); |
|||
System.out.println("调用URL: " + httpGet.getURI()); |
|||
//httpClient实例化 |
|||
CloseableHttpClient httpClient = HttpClients.createDefault(); |
|||
// 执行请求并获取返回 |
|||
HttpResponse response = httpClient.execute(httpGet); |
|||
HttpEntity entity = response.getEntity(); |
|||
System.out.println("返回状态码:" + response.getStatusLine()); |
|||
// 显示结果 |
|||
BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent(), "UTF-8")); |
|||
String line = null; |
|||
StringBuffer responseSB = new StringBuffer(); |
|||
while ((line = reader.readLine()) != null) { |
|||
if(line.contains("<!")){ |
|||
break; |
|||
} |
|||
responseSB.append(line.trim()); |
|||
} |
|||
System.out.println("返回消息:" + responseSB); |
|||
reader.close(); |
|||
httpClient.close(); |
|||
result = responseSB.toString(); |
|||
}catch (Exception e){ |
|||
System.err.println(e.toString()); |
|||
} |
|||
return ApiResponse.success(result); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,48 @@ |
|||
package com.storeroom.modules.archives.domain; |
|||
|
|||
import com.storeroom.base.BaseEntity; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
import javax.persistence.Column; |
|||
import javax.persistence.Entity; |
|||
import javax.persistence.Id; |
|||
import javax.persistence.Table; |
|||
import java.io.Serializable; |
|||
|
|||
@Entity |
|||
@Getter |
|||
@Setter |
|||
@Table(name = "archives_case") |
|||
public class ArchivesCase extends BaseEntity implements Serializable { |
|||
|
|||
@Id |
|||
@Column(name = "id") |
|||
private String id; |
|||
|
|||
@Column(name = "case_name") |
|||
@ApiModelProperty(value = "盒名称") |
|||
private String caseName; |
|||
|
|||
@Column(name = "case_type") |
|||
@ApiModelProperty(value = "盒类别 0.未定义 1.文件 2.案卷") |
|||
private Integer caseType; |
|||
|
|||
@Column(name = "tid") |
|||
@ApiModelProperty(value = "盒标签") |
|||
private String tid; |
|||
|
|||
@Column(name = "folder_location") |
|||
@ApiModelProperty(value = "存放位置") |
|||
private String folderLocation; |
|||
|
|||
@Column(name = "folder_location_details") |
|||
@ApiModelProperty(value = "存放具体位置") |
|||
private String folderLocationDetails; |
|||
|
|||
@Column(name = "deposit_num") |
|||
@ApiModelProperty(value = "存放数量") |
|||
private Integer depositNum; |
|||
|
|||
} |
@ -0,0 +1,14 @@ |
|||
package com.storeroom.modules.archives.repository; |
|||
|
|||
import com.storeroom.modules.archives.domain.ArchivesCase; |
|||
import org.springframework.data.domain.Page; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.data.jpa.repository.JpaRepository; |
|||
|
|||
public interface ArchivesCaseRepository extends JpaRepository<ArchivesCase, String>{ |
|||
|
|||
Page<ArchivesCase> findAllByCaseNameLikeAndTidLike(String caseName, String tid, Pageable page); |
|||
|
|||
Integer countAllByTid(String tid); |
|||
|
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.storeroom.modules.archives.service; |
|||
|
|||
import com.storeroom.modules.dictionary.service.dto.CaseDTO; |
|||
import org.springframework.data.domain.Pageable; |
|||
|
|||
public interface ArchivesCaseService { |
|||
//初始化档案盒列表 |
|||
Object initCaseList(String tid, String caseName, Pageable page); |
|||
//编辑档案盒信息 |
|||
Object edit(CaseDTO dto); |
|||
//查询该标签是否绑定过 |
|||
Integer findIsBingdingLabel(String label,Integer labelType); |
|||
|
|||
|
|||
} |
@ -0,0 +1,61 @@ |
|||
package com.storeroom.modules.archives.service.impl; |
|||
|
|||
import com.storeroom.modules.archives.domain.ArchivesCase; |
|||
import com.storeroom.modules.archives.repository.ArchivesCaseRepository; |
|||
import com.storeroom.modules.archives.repository.ArchivesSummaryRepository; |
|||
import com.storeroom.modules.archives.service.ArchivesCaseService; |
|||
import com.storeroom.modules.dictionary.service.dto.CaseDTO; |
|||
import com.storeroom.utils.NanoIdUtils; |
|||
import com.storeroom.utils.PageUtil; |
|||
import com.storeroom.utils.StringUtils; |
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.data.domain.Page; |
|||
import org.springframework.data.domain.Pageable; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.sql.Timestamp; |
|||
|
|||
|
|||
@Service |
|||
@RequiredArgsConstructor |
|||
public class ArchivesCaseServiceImpl implements ArchivesCaseService { |
|||
|
|||
private final ArchivesCaseRepository caseRepository; |
|||
private final ArchivesSummaryRepository archivesSummaryRepository; |
|||
|
|||
@Override |
|||
public Object initCaseList(String tid, String caseName, Pageable page) { |
|||
tid = StringUtils.isEmpty(tid) ? "%%" : "%"+tid+"%"; |
|||
caseName = StringUtils.isEmpty(caseName) ? "%%" : "%"+caseName+"%"; |
|||
Page<ArchivesCase> pageCase = caseRepository.findAllByCaseNameLikeAndTidLike(caseName,tid,page); |
|||
return PageUtil.toPage(pageCase); |
|||
} |
|||
|
|||
@Override |
|||
public Object edit(CaseDTO dto) { |
|||
ArchivesCase archivesCase = null; |
|||
if(!StringUtils.isEmpty(dto.getId())){ |
|||
archivesCase = caseRepository.findById(dto.getId()).get(); |
|||
}else{ |
|||
archivesCase = new ArchivesCase(); |
|||
archivesCase.setId(NanoIdUtils.randomNanoId()); |
|||
archivesCase.setCaseType(0); |
|||
archivesCase.setDepositNum(0); |
|||
} |
|||
archivesCase.setCaseName(dto.getCaseName()); |
|||
return caseRepository.saveAndFlush(archivesCase); |
|||
} |
|||
|
|||
@Override |
|||
public Integer findIsBingdingLabel(String tid,Integer labelType) { |
|||
if(labelType==1){ |
|||
return archivesSummaryRepository.countAllByTagNo(tid); |
|||
}else if(labelType==2){ |
|||
return caseRepository.countAllByTid(tid); |
|||
}else if(labelType==3){ |
|||
return 0; |
|||
}else{ |
|||
return 0; |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,20 @@ |
|||
package com.storeroom.modules.dictionary.service.dto; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
@Getter |
|||
@Setter |
|||
public class CaseDTO { |
|||
//盒id |
|||
private String id; |
|||
//盒名称 |
|||
private String caseName; |
|||
//盒标签 |
|||
private String tid; |
|||
//标签类型 |
|||
private Integer labelType; |
|||
//盒架位 |
|||
private String folderLocation; |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue