Browse Source

1.新增第三方接口 1.从系统服务获取档案信息

master
xia 3 years ago
parent
commit
683202477c
  1. 38
      archives/src/main/java/com/storeroom/modules/archives/controller/ExternalArchivesController.java
  2. 23
      archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java
  3. 8
      archives/src/main/java/com/storeroom/modules/archives/service/ArchivesService.java
  4. 26
      archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesExternalGetDTO.java
  5. 70
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java
  6. 4
      archives/src/main/java/com/storeroom/modules/common/ExcelUtil.java

38
archives/src/main/java/com/storeroom/modules/archives/controller/ExternalArchivesController.java

@ -0,0 +1,38 @@
package com.storeroom.modules.archives.controller;
import com.storeroom.annotaion.rest.AnonymousPostMapping;
import com.storeroom.modules.archives.service.ArchivesService;
import com.storeroom.modules.archives.service.dto.ArchivesDTO;
import com.storeroom.modules.archives.service.dto.ArchivesExternalGetDTO;
import com.storeroom.utils.ApiResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequiredArgsConstructor
@Api(tags = "外部接口-档案")
@RequestMapping("/api/Archives")
public class ExternalArchivesController {
private final ArchivesService archivesService;
@ApiOperation("1.从系统服务获取档案信息")
@AnonymousPostMapping("/get")
public Object externalGet(
@Validated @RequestBody ArchivesExternalGetDTO dto
){
return archivesService.externalGet(dto);
}
}

23
archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java

@ -3,6 +3,7 @@ package com.storeroom.modules.archives.repository;
import com.storeroom.modules.archives.domain.ArchivesSummary;
import com.storeroom.modules.archives.domain.vo.ArchivesSummaryVO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
@ -77,4 +78,26 @@ public interface ArchivesSummaryRepository extends JpaRepository<ArchivesSummary
ArchivesSummary findByTagNo(String tid);
@Query(nativeQuery = true,
countQuery = "SELECT count(1) FROM archives_summary asy " +
"INNER JOIN archives_case_cartoning acc on asy.archives_id = acc.parent_id " +
"INNER JOIN archives_case ace on acc.case_id = ace.id " +
"INNER JOIN device_archives_tag dat on ace.folder_location = dat.position " +
"INNER JOIN device_info di on dat.device_info_id = di.id " +
"INNER JOIN storeroom room on room.id = di.storeroom_id " +
"WHERE di.storeroom_code = ?1 and ace.folder_location like ?2 " +
"and if(?3 = 0,(asy.maintitle like ?4 or asy.archive_no like ?4),(asy.maintitle = ?4 or asy.archive_no = ?4))",
value = "SELECT di.storeroom_code as storeCode,asy.maintitle AS filename,asy.archive_no as fileno,asy.create_time as makedate,asy.category_id as filetype," +
"asy.barcode as filecode,asy.retention as keepday,CONCAT(room.name,' ',di.device_name,' ',ace.folder_location_details) as position," +
"ace.folder_location as location,asy.create_by as editdate,ace.storage_type as storageType,asy.child as enclosure " +
"FROM archives_summary asy " +
"INNER JOIN archives_case_cartoning acc on asy.archives_id = acc.parent_id " +
"INNER JOIN archives_case ace on acc.case_id = ace.id " +
"INNER JOIN device_archives_tag dat on ace.folder_location = dat.position " +
"INNER JOIN device_info di on dat.device_info_id = di.id " +
"INNER JOIN storeroom room on room.id = di.storeroom_id " +
"WHERE di.storeroom_code = ?1 and ace.folder_location like ?2 " +
"and if(?3 = 0,(asy.maintitle like ?4 or asy.archive_no like ?4),(asy.maintitle = ?4 or asy.archive_no = ?4))")
Page<Map<String,Object>> externalGet(String storeCode, String quCol, Integer datatype, String data, PageRequest page);
}

8
archives/src/main/java/com/storeroom/modules/archives/service/ArchivesService.java

@ -1,8 +1,10 @@
package com.storeroom.modules.archives.service;
import cn.hutool.json.JSONObject;
import com.storeroom.modules.archives.domain.ArchivesSummary;
import com.storeroom.modules.archives.domain.vo.ArchivesDetailsVO;
import com.storeroom.modules.archives.service.dto.ArchivesDTO;
import com.storeroom.modules.archives.service.dto.ArchivesExternalGetDTO;
import com.storeroom.modules.archives.service.dto.ArchivesFileDTO;
import com.storeroom.utils.ApiResponse;
import org.springframework.data.domain.Pageable;
@ -54,4 +56,10 @@ public interface ArchivesService {
boolean isShelfOccupy(String shelfId);
//根据标签id获取档案基本信息
ArchivesSummary findArchivesByTid(String tid);
//第三方接口
//从系统服务获取档案信息
JSONObject externalGet(ArchivesExternalGetDTO dto);
}

26
archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesExternalGetDTO.java

@ -0,0 +1,26 @@
package com.storeroom.modules.archives.service.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ArchivesExternalGetDTO {
@ApiModelProperty("页码")
private Integer pn;
@ApiModelProperty("每页数量")
private Integer ps;
@ApiModelProperty("库房编号")
private String storeCode;
@ApiModelProperty("区编号")
private Integer quNo;
@ApiModelProperty("列编号")
private Integer colNo;
@ApiModelProperty("模糊查询档案(名称、档案号)")
private String data;
@ApiModelProperty("当模糊查询时赋值为 0")
private Integer datatype;
}

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

@ -7,6 +7,7 @@ import com.storeroom.modules.archives.domain.vo.ArchivesDetailsVO;
import com.storeroom.modules.archives.repository.ArchivesSummaryRepository;
import com.storeroom.modules.archives.service.ArchivesService;
import com.storeroom.modules.archives.service.dto.ArchivesDTO;
import com.storeroom.modules.archives.service.dto.ArchivesExternalGetDTO;
import com.storeroom.modules.archives.service.dto.ArchivesFileDTO;
import com.storeroom.modules.common.ArchivesTypeEnum;
import com.storeroom.modules.dictionary.domain.ArchivesDictionary;
@ -20,6 +21,7 @@ import com.storeroom.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
@ -961,4 +963,72 @@ public class ArchivesServiceImpl implements ArchivesService {
public ArchivesSummary findArchivesByTid(String tid) {
return archivesSummaryRepository.findByTagNo(tid);
}
@Override
public JSONObject externalGet(ArchivesExternalGetDTO dto) {
JSONObject json = new JSONObject();
PageRequest page = PageRequest.of(dto.getPn()-1,dto.getPs());
String quCol = dto.getQuNo() +"-"+dto.getColNo()+"%";
String data = dto.getData();
if(dto.getDatatype() == 0){
data = StringUtils.isEmpty(data) ? "%%": "%"+data+"%";
}
//分页查询
Page<Map<String,Object>> pageMap = archivesSummaryRepository.externalGet(dto.getStoreCode(),quCol,dto.getDatatype(),data,page);
json.put("protocal",1001);
json.put("code",0);
JSONArray jsonArray = new JSONArray();
List<Map<String,Object>> resultMap = pageMap.getContent();
for(Map<String,Object> map : resultMap){
JSONObject resultJson = new JSONObject();
resultJson.put("filename",map.get("filename"));
resultJson.put("fileno",map.get("fileno"));
resultJson.put("makedate",map.get("makedate"));
resultJson.put("filetype",map.get("filetype"));
resultJson.put("filecode",map.get("filecode"));
resultJson.put("keepday",map.get("keepday"));
resultJson.put("position",map.get("position").toString().replaceAll("-"," "));
resultJson.put("storeCode",map.get("storeCode"));
resultJson.put("editdate",map.get("editdate"));
resultJson.put("enclosure",map.get("enclosure"));
Integer filestatus = map.get("filestatus") == null ? 0 : Integer.parseInt(map.get("filestatus").toString());
Integer inputFilestatus = 8;
if(filestatus==1){
inputFilestatus = 2;
}else if(filestatus==2){
inputFilestatus = 4;
}else if(filestatus == 3){
inputFilestatus = 6;
}
resultJson.put("filestatus",inputFilestatus);
String[] splitPostion = map.get("location").toString().split("-");
resultJson.put("quNo",splitPostion[0]);
resultJson.put("colNo",splitPostion[1]);
resultJson.put("leNo",splitPostion[2]);
resultJson.put("divNo",splitPostion[3]);
resultJson.put("zyNo",splitPostion[4]);
JSONObject positionKeyJson = new JSONObject();
positionKeyJson.put("quNo",splitPostion[0]);
positionKeyJson.put("colNo",splitPostion[1]);
positionKeyJson.put("leNo",splitPostion[2]);
positionKeyJson.put("divNo",splitPostion[3]);
positionKeyJson.put("zyNo",splitPostion[4]);
positionKeyJson.put("storeCode",map.get("storeCode"));
resultJson.put("positionKey",positionKeyJson);
jsonArray.add(resultJson);
}
JSONObject jsonContext = new JSONObject();
jsonContext.put("list",jsonArray);
jsonContext.put("count",jsonArray.size());
json.put("result",jsonContext);
json.put("errorinfo",null);
return json;
}
}

4
archives/src/main/java/com/storeroom/modules/common/ExcelUtil.java

@ -180,9 +180,9 @@ public class ExcelUtil {
String showBorrowArchiType = "";
if(borrowArchiType==2){
showBorrowArchiType = "待借阅";
}else if(borrowArchiType==3 && borrowArchive.getEndTime().getTime() >= new Timestamp(System.currentTimeMillis()).getTime()){
}else if(borrowArchiType==3 && vo.getBorrowEnd().getTime() >= new Timestamp(System.currentTimeMillis()).getTime()){
showBorrowArchiType = "待归还";
}else if(borrowArchiType==3 && borrowArchive.getEndTime().getTime() < new Timestamp(System.currentTimeMillis()).getTime()){
}else if(borrowArchiType==3 && vo.getBorrowEnd().getTime() < new Timestamp(System.currentTimeMillis()).getTime()){
showBorrowArchiType = "逾期";
}else if(borrowArchiType == 4){
showBorrowArchiType = "已归还";

Loading…
Cancel
Save