|  | @ -63,6 +63,7 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { | 
		
	
		
			
				|  |  |             archivesCase.setDepositNum(0); |  |  |             archivesCase.setDepositNum(0); | 
		
	
		
			
				|  |  |         } |  |  |         } | 
		
	
		
			
				|  |  |         archivesCase.setCaseName(dto.getCaseName()); |  |  |         archivesCase.setCaseName(dto.getCaseName()); | 
		
	
		
			
				|  |  |  |  |  |         archivesCase.setBarcode(dto.getBarcode()); | 
		
	
		
			
				|  |  |         return caseRepository.saveAndFlush(archivesCase); |  |  |         return caseRepository.saveAndFlush(archivesCase); | 
		
	
		
			
				|  |  |     } |  |  |     } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
	
		
			
				|  | @ -222,15 +223,40 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { | 
		
	
		
			
				|  |  |     @Override |  |  |     @Override | 
		
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class) |  |  |     @Transactional(rollbackFor = Exception.class) | 
		
	
		
			
				|  |  |     public Object unpacking(List<ArchivesCaseCartoningDTO> dtos) { |  |  |     public Object unpacking(List<ArchivesCaseCartoningDTO> dtos) { | 
		
	
		
			
				|  |  |         Set<String> categoryIds = new HashSet<>(); |  |  |  | 
		
	
		
			
				|  |  |  |  |  |         ArchivesType archivesType = archivesTypeRepository.findById(dtos.get(0).getCategoryId()).get(); | 
		
	
		
			
				|  |  |  |  |  |         Set<String> caseIds = new HashSet<>(); | 
		
	
		
			
				|  |  |  |  |  |         List<String> accIds = new ArrayList<>(); | 
		
	
		
			
				|  |  |         for(ArchivesCaseCartoningDTO dto:dtos){ |  |  |         for(ArchivesCaseCartoningDTO dto:dtos){ | 
		
	
		
			
				|  |  |             categoryIds.add(dto.getCategoryId()); |  |  |  | 
		
	
		
			
				|  |  |  |  |  |             accIds.add(dto.getId()); | 
		
	
		
			
				|  |  |  |  |  |             caseIds.add(dto.getCaseId()); | 
		
	
		
			
				|  |  |  |  |  |             String sql = "update "+archivesType.getEnName()+" set case_no = null where id = '"+dto.getArchivesId()+"'"; | 
		
	
		
			
				|  |  |  |  |  |             entityManager.createNativeQuery(sql).executeUpdate(); | 
		
	
		
			
				|  |  |  |  |  |             archivesSummaryRepository.unpacking(dto.getArchivesId()); | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |         if(null != archivesType.getPid()){ | 
		
	
		
			
				|  |  |  |  |  |             ArchivesType archivesTypeP = archivesTypeRepository.findById(archivesType.getPid()).get(); | 
		
	
		
			
				|  |  |  |  |  |             String sql = "update "+archivesTypeP.getEnName()+" set case_no = null where id = '"+dtos.get(0).getArchivesParentsId()+"'"; | 
		
	
		
			
				|  |  |  |  |  |             entityManager.createNativeQuery(sql).executeUpdate(); | 
		
	
		
			
				|  |  |  |  |  |             archivesSummaryRepository.unpacking(dtos.get(0).getArchivesParentsId()); | 
		
	
		
			
				|  |  |         } |  |  |         } | 
		
	
		
			
				|  |  |         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(); |  |  |  | 
		
	
		
			
				|  |  |  |  |  |         archivesCaseCartoningRepository.deleteAllById(accIds); | 
		
	
		
			
				|  |  |  |  |  |         for(String caseId:caseIds){ | 
		
	
		
			
				|  |  |  |  |  |             caseRepository.cartoning(caseId,0,0); | 
		
	
		
			
				|  |  |         } |  |  |         } | 
		
	
		
			
				|  |  |         return null; |  |  |         return null; | 
		
	
		
			
				|  |  |     } |  |  |     } | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |     @Override | 
		
	
		
			
				|  |  |  |  |  |     public Object findInCase(String caseId) { | 
		
	
		
			
				|  |  |  |  |  |         ArchivesCase archivesCase = caseRepository.findById(caseId).get(); | 
		
	
		
			
				|  |  |  |  |  |         ArchivesCaseVO vo = new ArchivesCaseVO(); | 
		
	
		
			
				|  |  |  |  |  |         BeanUtils.copyProperties(vo,archivesCase); | 
		
	
		
			
				|  |  |  |  |  |         if(null == archivesCase.getCaseType() || archivesCase.getCaseType() == 0) | 
		
	
		
			
				|  |  |  |  |  |             return null; | 
		
	
		
			
				|  |  |  |  |  |         Integer code = archivesCase.getCaseType() == 1 ? ArchivesTypeEnum.files.getCode() : ArchivesTypeEnum.inChive.getCode(); | 
		
	
		
			
				|  |  |  |  |  |         List<ArchivesSummary> archivesSummaries = archivesSummaryRepository.findAllByCaseNoAndCategoryType(caseId, code); | 
		
	
		
			
				|  |  |  |  |  |         vo.setArchives(archivesSummaries); | 
		
	
		
			
				|  |  |  |  |  |         return vo; | 
		
	
		
			
				|  |  |  |  |  |     } | 
		
	
		
			
				|  |  | } |  |  | } |