diff --git a/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java b/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java index 5bdce48..1b90cff 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java +++ b/archives/src/main/java/com/storeroom/modules/archives/repository/ArchivesCaseRepository.java @@ -4,7 +4,9 @@ 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; +import org.springframework.data.jpa.repository.Modifying; import org.springframework.data.jpa.repository.Query; +import org.springframework.transaction.annotation.Transactional; public interface ArchivesCaseRepository extends JpaRepository{ @@ -23,4 +25,10 @@ public interface ArchivesCaseRepository extends JpaRepository dtos) { Set caseIds = new HashSet<>(); -// Map dtos = archivesCaseCartoningRepository.saveAllAndFlush(dtos); + ArchivesType archivesType = new ArchivesType(); Integer caseType = 0; for(ArchivesCaseCartoning archivesCaseCartoning:dtos){ caseIds.add(archivesCaseCartoning.getCaseId()); //判断档案是案卷还是文件 - ArchivesType archivesType = archivesTypeRepository.findById(archivesCaseCartoning.getCategoryId()).get(); + 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(); } for (String caseId:caseIds){ - + Integer count = 0; + for(ArchivesCaseCartoning archivesCaseCartoning:dtos){ + if(caseId.equals(archivesCaseCartoning.getCaseId())){ + count++; + } + } + caseRepository.cartoning(caseId,caseType,count); + } + String caseIdArr = caseIds.stream().collect(Collectors.joining(",")); + //当装盒为案卷 + 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)"; + entityManager.createNativeQuery(psql).executeUpdate(); } + return null; } }