Browse Source

档案盒管理- 新增 装盒、拆盒

master
xia 3 years ago
parent
commit
27ec09ff95
  1. 18
      archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java
  2. 22
      archives/src/main/java/com/storeroom/modules/archives/domain/vo/ArchivesCaseVO.java
  3. 4
      archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseCartoningRepository.java
  4. 7
      archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java
  5. 14
      archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesSummaryRepository.java
  6. 7
      archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java
  7. 21
      archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesCaseCartoningDTO.java
  8. 82
      archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java

18
archives/src/main/java/com/storeroom/modules/archives/controller/CaseController.java

@ -3,6 +3,7 @@ package com.storeroom.modules.archives.controller;
import com.storeroom.exception.constant.ResponseStatus;
import com.storeroom.modules.archives.domain.ArchivesCaseCartoning;
import com.storeroom.modules.archives.service.ArchivesCaseService;
import com.storeroom.modules.archives.service.dto.ArchivesCaseCartoningDTO;
import com.storeroom.modules.archives.service.dto.CaseDTO;
import com.storeroom.utils.ApiResponse;
import io.swagger.annotations.Api;
@ -64,9 +65,24 @@ public class CaseController {
@ApiOperation("装盒")
@PostMapping("/cartoning")
public ApiResponse<Object> cartoning(
@Validated @RequestBody List<ArchivesCaseCartoning> dtos
@Validated @RequestBody List<ArchivesCaseCartoningDTO> dtos
){
return ApiResponse.success(caseService.cartoning(dtos));
}
@ApiOperation("预备装盒")
@PostMapping("/doUnpacking")
public ApiResponse<Object> doUnpacking(
@Validated @RequestBody ArchivesCaseCartoningDTO dto
){
return ApiResponse.success(caseService.doUnpacking(dto.getCaseId()));
}
@ApiOperation("拆盒")
@PostMapping("/unpacking")
public ApiResponse<Object> unpacking(
@Validated @RequestBody List<ArchivesCaseCartoningDTO> dtos
){
return ApiResponse.success(caseService.cartoning(dtos));
}

22
archives/src/main/java/com/storeroom/modules/archives/domain/vo/ArchivesCaseVO.java

@ -0,0 +1,22 @@
package com.storeroom.modules.archives.domain.vo;
import com.storeroom.modules.archives.domain.ArchivesSummary;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
public class ArchivesCaseVO {
private String id;
private String caseName;
private Integer caseType;
private String tid;
private String barcode;
private String folderLocation;
private String folderLocationDetails;
private Integer depositNum;
private List<ArchivesSummary> archives;
}

4
archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseCartoningRepository.java

@ -7,6 +7,10 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface ArchivesCaseCartoningRepository extends JpaRepository<ArchivesCaseCartoning, String>{
List<ArchivesCaseCartoning> findAllByCaseId(String caseId);
}

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

@ -8,6 +8,8 @@ import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
public interface ArchivesCaseRepository extends JpaRepository<ArchivesCase, String>{
Page<ArchivesCase> findAllByCaseNameLikeAndTidLikeAndBarcodeLike(String caseName, String tid,String barcode, Pageable page);
@ -18,6 +20,9 @@ public interface ArchivesCaseRepository extends JpaRepository<ArchivesCase, Stri
Integer countAllByTid(String tid);
@Query("select caseName from ArchivesCase where id in ?1")
List<String> findCaseName(List caseIds);
@Query(nativeQuery = true,
value = "update archives_case set tid = null where tid = ?1")
void unbindTag(String tid);
@ -31,4 +36,6 @@ public interface ArchivesCaseRepository extends JpaRepository<ArchivesCase, Stri
@Query(nativeQuery = true,
value = "update archives_case set case_type = ?2,deposit_num = ?3 where id = ?1")
Integer cartoning(String caseId,Integer caseType,Integer depositNum);
}

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

@ -2,7 +2,9 @@ package com.storeroom.modules.archives.repository;
import com.storeroom.modules.archives.domain.ArchivesSummary;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
@ -11,14 +13,26 @@ public interface ArchivesSummaryRepository extends JpaRepository<ArchivesSummary
Integer countAllByTagNo(String tid);
@Modifying
@Transactional(rollbackFor = Exception.class)
@Query(nativeQuery = true,
value = "update archives_summary set tag_no = null where tag_no = ?1 ")
void unbindTag(String tid);
@Modifying
@Transactional(rollbackFor = Exception.class)
@Query(nativeQuery = true,
value = "update archives_summary set tag_no ?1 where archives_id = ?2 ")
Integer bindTag(String tid,String archivesId);
@Modifying
@Transactional(rollbackFor = Exception.class)
@Query(nativeQuery = true,
value = "update archives_summary set case_no = ?2,case_name = ?3 where archives_id = ?1")
Integer cartoning(String archivesId,String caseId,String caseName);
ArchivesSummary findFirstByTagNo(String tagNo);
List<ArchivesSummary> findAllByCaseNoAndCategoryType(String caseId,Integer categoryType);
}

7
archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java

@ -1,6 +1,7 @@
package com.storeroom.modules.archives.service;
import com.storeroom.modules.archives.domain.ArchivesCaseCartoning;
import com.storeroom.modules.archives.service.dto.ArchivesCaseCartoningDTO;
import com.storeroom.modules.archives.service.dto.CaseDTO;
import org.springframework.data.domain.Pageable;
@ -18,7 +19,11 @@ public interface ArchivesCaseService {
//档案盒装盒列表
Object initCartoningList(String tid, String caseName,String barcode,Integer caseType, Pageable page);
//装盒
Object cartoning(List<ArchivesCaseCartoning> dtos);
Object cartoning(List<ArchivesCaseCartoningDTO> dtos);
//预拆盒
Object doUnpacking(String caseId);
//拆盒
Object unpacking(List<ArchivesCaseCartoningDTO> dtos);
}

21
archives/src/main/java/com/storeroom/modules/archives/service/dto/ArchivesCaseCartoningDTO.java

@ -0,0 +1,21 @@
package com.storeroom.modules.archives.service.dto;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ArchivesCaseCartoningDTO {
private String id;
private String archivesId;
private String archivesParentsId;
private String caseId;
private String caseName;
private String categoryId;
}

82
archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java

@ -7,13 +7,17 @@ import com.storeroom.modules.archives.repository.ArchivesCaseCartoningRepository
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.archives.service.dto.ArchivesCaseCartoningDTO;
import com.storeroom.modules.archives.domain.vo.ArchivesCaseVO;
import com.storeroom.modules.archives.service.dto.CaseDTO;
import com.storeroom.modules.common.ArchivesTypeEnum;
import com.storeroom.modules.dictionary.domain.ArchivesType;
import com.storeroom.modules.dictionary.repository.ArchivesTypeRepository;
import com.storeroom.utils.NanoIdUtils;
import com.storeroom.utils.PageUtil;
import com.storeroom.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
@ -130,22 +134,31 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService {
@Override
@Transactional(rollbackFor = Exception.class)
public Object cartoning(List<ArchivesCaseCartoning> dtos) {
public Object cartoning(List<ArchivesCaseCartoningDTO> dtos) {
Set<String> caseIds = new HashSet<>();
dtos = archivesCaseCartoningRepository.saveAllAndFlush(dtos);
Set<String> caseNames = new HashSet<>();
List<ArchivesCaseCartoning> archivesCaseCartonings = dtos.stream().map(archivesCaseCartoning ->{
ArchivesCaseCartoning Cartoning = new ArchivesCaseCartoning();
caseIds.add(archivesCaseCartoning.getCaseId());
caseNames.add(archivesCaseCartoning.getCaseName());
BeanUtils.copyProperties(Cartoning,archivesCaseCartoning);
return Cartoning;
}).collect(Collectors.toList());
archivesCaseCartonings = archivesCaseCartoningRepository.saveAllAndFlush(archivesCaseCartonings);
ArchivesType archivesType = new ArchivesType();
Integer caseType = 0;
for(ArchivesCaseCartoning archivesCaseCartoning:dtos){
caseIds.add(archivesCaseCartoning.getCaseId());
for(int i = 0;i<archivesCaseCartonings.size();i++){
ArchivesCaseCartoning archivesCaseCartoning = archivesCaseCartonings.get(i);
//判断档案是案卷还是文件
archivesType = archivesTypeRepository.findById(archivesCaseCartoning.getCategoryId()).get();
caseType = archivesType.getIsType() == 4 ? 2 : archivesType.getIsType() == 5 ? 1 : 0;
String sql = "update "+archivesType.getEnName()+" set case_no = '"+archivesCaseCartoning.getCaseId()+"' where id = '"+archivesCaseCartoning.getArchivesId()+"'";
entityManager.createNativeQuery(sql).executeUpdate();
archivesSummaryRepository.cartoning(archivesCaseCartoning.getArchivesId(),archivesCaseCartoning.getCaseId(),dtos.get(i).getCaseName());
}
for (String caseId:caseIds){
Integer count = 0;
for(ArchivesCaseCartoning archivesCaseCartoning:dtos){
for(ArchivesCaseCartoning archivesCaseCartoning:archivesCaseCartonings){
if(caseId.equals(archivesCaseCartoning.getCaseId())){
count++;
}
@ -157,10 +170,67 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService {
if(caseType == 2){
ArchivesType archivesTypeP = archivesTypeRepository.findById(archivesType.getPid()).get();
String psql = "update "+archivesTypeP.getEnName()+" set case_no = '"+caseIdArr
+"' where id = (select pid from "+archivesType.getEnName()+" where id = '"+dtos.get(0).getArchivesId()+"' limit 0,1)";
+"' where id = '"+dtos.get(0).getArchivesParentsId()+"'";
entityManager.createNativeQuery(psql).executeUpdate();
archivesSummaryRepository.cartoning(dtos.get(0).getArchivesParentsId(),caseIdArr,caseNames.stream().collect(Collectors.joining(",")));
}
return null;
}
@Override
public Object doUnpacking(String caseId) {
ArchivesCase archivesCase = caseRepository.findById(caseId).get();
List returnList = new ArrayList();
//文件类型档案盒
if(archivesCase.getCaseType()==1){
ArchivesCaseVO vo = new ArchivesCaseVO();
BeanUtils.copyProperties(vo,archivesCase);
List<ArchivesSummary> archivesSummaries = archivesSummaryRepository.findAllByCaseNoAndCategoryType(caseId, ArchivesTypeEnum.files.getCode());
vo.setArchives(archivesSummaries);
returnList.add(vo);
//案卷类型盒
}else if(archivesCase.getCaseType()==2){
List<ArchivesSummary> archivesSummaries = archivesSummaryRepository.findAllByCaseNoAndCategoryType(caseId,ArchivesTypeEnum.inChive.getCode());
Set<String> caseIds = new HashSet<>();
for(ArchivesSummary archivesSummary:archivesSummaries){
caseIds.add(archivesSummary.getCaseNo());
}
if(caseIds.size()==1){
ArchivesCaseVO vo = new ArchivesCaseVO();
BeanUtils.copyProperties(vo,archivesCase);
vo.setArchives(archivesSummaries);
returnList.add(vo);
}else{
for (String thisCaseId:caseIds){
ArchivesCase newCase = caseRepository.findById(thisCaseId).get();
ArchivesCaseVO thisVo = new ArchivesCaseVO();
BeanUtils.copyProperties(thisVo,newCase);
List<ArchivesSummary> newSummary = new ArrayList<>();
for(ArchivesSummary thisSummary:archivesSummaries){
if(thisCaseId.equals(thisSummary.getCaseNo())){
newSummary.add(thisSummary);
}
}
returnList.add(thisVo);
}
}
}
return returnList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public Object unpacking(List<ArchivesCaseCartoningDTO> dtos) {
Set<String> categoryIds = new HashSet<>();
for(ArchivesCaseCartoningDTO dto:dtos){
categoryIds.add(dto.getCategoryId());
}
for(String categoryId:categoryIds){
ArchivesType archivesType = archivesTypeRepository.findById(categoryId).get();
// String sql = "update "+archivesType.getEnName()+" set case_no = null where id = '"+archivesCaseCartoning.getArchivesId()+"'";
// entityManager.createNativeQuery(sql).executeUpdate();
}
return null;
}
}
Loading…
Cancel
Save