From 754455e4d5d839b78f35af82eed7619c6b6776a0 Mon Sep 17 00:00:00 2001 From: xia Date: Tue, 12 Jul 2022 09:09:05 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=A1=A3=E6=A1=88=E6=A8=A1=E5=9D=97=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=90=8E=E5=AD=90=E9=9B=86=E5=90=88=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5=E6=9B=B4=E6=96=B0=202.=E6=A1=A3=E6=A1=88=E7=9B=92?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=A5=E5=BA=93=E6=97=B6=E9=97=B4=203.?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=87=BA=E5=85=A5=E5=BA=93=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StorageController.java | 14 ++++- .../modules/archives/domain/ArchivesCase.java | 5 ++ .../repository/ArchivesCaseRepository.java | 25 +++++++++ .../archives/service/ArchivesCaseService.java | 5 ++ .../service/impl/ArchivesCaseServiceImpl.java | 26 +++++++++- .../service/impl/ArchivesServiceImpl.java | 52 ++++++++++++++++++- 6 files changed, 122 insertions(+), 5 deletions(-) diff --git a/archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java b/archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java index 6728450..9ff8013 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java +++ b/archives/src/main/java/com/storeroom/modules/archives/controller/StorageController.java @@ -18,12 +18,22 @@ public class StorageController { private final ArchivesCaseService caseService; - @ApiOperation("入库列表") + @ApiOperation("可入库盒列表") @GetMapping("/readyInto") public ApiResponse readyInto( String tid, String caseName,String barcode, Pageable page ){ - return ApiResponse.success(caseService.initCaseList(tid,caseName,barcode,page)); + return ApiResponse.success(caseService.readyIntoCase(tid,caseName,barcode,page)); } + @ApiOperation("已入库盒列表") + @GetMapping("/alReadyInto") + public ApiResponse alReadyInto( + String caseName,String archiveNo,String title,String location, Pageable page + ){ + return ApiResponse.success(caseService.alReadyInto(caseName,archiveNo,title,location,page)); + } + + + } diff --git a/archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java b/archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java index da17ac0..a0116b3 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java +++ b/archives/src/main/java/com/storeroom/modules/archives/domain/ArchivesCase.java @@ -10,6 +10,7 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; import java.io.Serializable; +import java.sql.Timestamp; @Entity @Getter @@ -53,4 +54,8 @@ public class ArchivesCase extends BaseEntity implements Serializable { @ApiModelProperty(value = "入库状态 0.未入 1.待入 2.已入") private Integer storageType; + @Column(name = "storage_time") + @ApiModelProperty(value = "入库时间") + private Timestamp storageTime; + } 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 eafc3be..7be9eff 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 @@ -9,6 +9,7 @@ import org.springframework.data.jpa.repository.Query; import org.springframework.transaction.annotation.Transactional; import java.util.List; +import java.util.Map; public interface ArchivesCaseRepository extends JpaRepository{ @@ -17,6 +18,30 @@ public interface ArchivesCaseRepository extends JpaRepository initCaseList(String caseName, String tid,String barcode, Pageable page); + @Query(nativeQuery = true, + value = "select * from archives_case where storage_type != 2 and if(?1 is null,1=1,case_name like ?1) and " + + "if(?2 is null,1=1,tid like ?2) and if(?3 is null,1=1,barcode like ?3) ") + Page readyIntoCase(String caseName, String tid,String barcode, Pageable page); + + @Query(nativeQuery = true, + value = "SELECT asum.archives_id as archivesId,asum.child as child,asum.category_type as categoryType,asum.category_name as categoryName," + + "asum.fonds_no as fondsNo,asum.archive_no as archiveNo,asum.archive_year as archiveYear,asum.maintitle as maintitle," + + "asum.security_class as securityClass,asum.department as department,ace.case_name as caseName," + + "dct.area_No + '-' + di.device_name + '-' + dat.position as seat,ace.storage_time as storageTime " + + "FROM archives_case ace " + + "INNER JOIN archives_case_cartoning acc ON ace.id = acc.case_id " + + "INNER JOIN archives_summary asum ON acc.archives_id = asum.archives_id " + + "INNER JOIN device_archives_tag dat on asum.shelf_id = dat.id " + + "INNER JOIN dese_cabinet dct on dat.device_info_id = dct.device_info_id " + + "INNER JOIN device_info di on dct.device_info_id = di.id " + + "WHERE ace.storage_type = 2 " + + "AND if(?1 is null,1=1,ace.case_name like ?1) " + + "AND if(?2 is null,1=1,asum.archive_no like ?2) " + + "AND if(?3 is null,1=1,asum.maintitle like ?3) " + + "AND if(?4 is null,1=1,find_in_set(?4,dct.area_No + '-' + di.device_name + '-' + dat.position)) ") + Page> alReadyInto(String caseName, String archiveNo, String title, String location, Pageable page); + + @Query(nativeQuery = true, value = "select * from archives_case where case_type in (0,?4) and " + "if(?1 is null,1=1,case_name like ?1) and " + diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java b/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java index 8d4b5f5..e41b69d 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java +++ b/archives/src/main/java/com/storeroom/modules/archives/service/ArchivesCaseService.java @@ -33,4 +33,9 @@ public interface ArchivesCaseService { //查看盒内详情 Object findInCase(String caseId); + //查看可入库盒列表 + Object readyIntoCase(String tid, String caseName,String barcode, Pageable page); + //查看已入库列表 + Object alReadyInto(String caseName,String archiveNo,String title,String location, Pageable page); + } diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java index 8721d45..a7b7421 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java +++ b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesCaseServiceImpl.java @@ -353,9 +353,12 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { @Override public Object findInCase(String caseId) { - ArchivesCase archivesCase = caseRepository.findById(caseId).get(); + Optional optional = caseRepository.findById(caseId); + if(!optional.isPresent()) + return null; + ArchivesCase archivesCase = optional.get(); ArchivesCaseVO vo = new ArchivesCaseVO(); - BeanUtils.copyProperties(vo,archivesCase); + BeanUtils.copyProperties(archivesCase,vo); if(null == archivesCase.getCaseType() || archivesCase.getCaseType() == 0) return null; Integer code = archivesCase.getCaseType() == 1 ? ArchivesTypeEnum.files.getCode() : ArchivesTypeEnum.inChive.getCode(); @@ -363,4 +366,23 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { vo.setArchives(archivesSummaries); return vo; } + + @Override + public Object readyIntoCase(String tid, String caseName, String barcode, Pageable page) { + tid = StringUtils.isEmpty(tid) ? null : "%"+ tid +"%"; + caseName = StringUtils.isEmpty(caseName) ? null : "%"+ caseName +"%"; + barcode = StringUtils.isEmpty(barcode) ? null : "%"+ barcode +"%"; + Page pageCase = caseRepository.readyIntoCase(caseName,tid,barcode,page); + return PageUtil.toPage(pageCase); + } + + @Override + public Object alReadyInto(String caseName, String archiveNo, String title, String location, Pageable page) { + caseName = StringUtils.isEmpty(caseName) ? null : "%"+ caseName +"%"; + archiveNo = StringUtils.isEmpty(archiveNo) ? null : "%"+ archiveNo +"%"; + title = StringUtils.isEmpty(title) ? null : "%"+ title +"%"; + location = StringUtils.isEmpty(location) ? null : "%"+ location +"%"; + Page> pageCase = caseRepository.alReadyInto(caseName,archiveNo,title,location,page); + return PageUtil.toPage(pageCase); + } } diff --git a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java index bfaf9d6..952f72e 100644 --- a/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java +++ b/archives/src/main/java/com/storeroom/modules/archives/service/impl/ArchivesServiceImpl.java @@ -370,6 +370,14 @@ public class ArchivesServiceImpl implements ArchivesService { }else{ archivesSummary.setArchivesId(insertId); archivesSummary.setChild(0); + //如果有父级 + if(!StringUtils.isEmpty(dto.getParentsId())){ + ArchivesType archivesTypeP = archivesTypeRepository.findByPid(archivesType.getId()); + entityManager.createNativeQuery("update "+archivesTypeP.getEnName()+" set child = (select count(1) from " + +archivesType.getEnName()+"where parent_id ='"+dto.getParentsId()+"') where id = '"+dto.getParentsId()+"'").executeUpdate(); + entityManager.createNativeQuery("update archives_summary set child = (select count(1) from " + +archivesType.getEnName()+"where parent_id ='"+dto.getParentsId()+"') where archives_id = '"+dto.getParentsId()+"'").executeUpdate(); + } } //档号 @@ -451,6 +459,7 @@ public class ArchivesServiceImpl implements ArchivesService { @Transactional(rollbackFor = Exception.class) public Object editFile(ArchivesFileDTO dto) { int result = 0; + String archiveId = ""; ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); List queryShow = archivesDictionaryRepository.findAllByCategoryIdAndIsTypeOrderByIsSequenceAsc(dto.getCategoryId(),3); ArchivesDictionary idad = new ArchivesDictionary(); @@ -477,8 +486,10 @@ public class ArchivesServiceImpl implements ArchivesService { String sql = "insert into file_"+archivesType.getEnName()+"("+queryFields+") values ("+insertValue+")"; int thisresult = entityManager.createNativeQuery(sql).executeUpdate(); result += thisresult; + archiveId = json.get("archive_id")+""; } - + entityManager.createNativeQuery("update "+archivesType.getEnName()+" set child = "+result+" where id='"+archiveId+"'").executeUpdate(); + entityManager.createNativeQuery("update archives_summary set child = "+result+" where archives_id = '"+archiveId+"'").executeUpdate(); return result; } @@ -486,6 +497,12 @@ public class ArchivesServiceImpl implements ArchivesService { @Transactional(rollbackFor = Exception.class) public Object deleteFile(ArchivesFileDTO dto,String prefixPath) { ArchivesType archivesType = archivesTypeRepository.findById(dto.getCategoryId()).get(); + String archiveId = ""; + if(dto.getIds().size()!=0){ + archiveId = entityManager.createNativeQuery("select archive_id from "+archivesType.getEnName() + +" where id = '"+dto.getIds().get(0)+"'").getResultList().get(0)+""; + } + String ids = dto.getIds().stream().map(String::valueOf).collect(Collectors.joining("','")); ids = ids.length() > 0 ? "'"+ids+"'" : ids; // ids.replaceAll("\"",""); @@ -501,6 +518,10 @@ public class ArchivesServiceImpl implements ArchivesService { } } } + entityManager.createNativeQuery("update "+archivesType.getEnName()+" set child = (select count(1) from file_"+ + archivesType.getEnName()+" where archive_id = '"+archiveId+"') where id='"+archiveId+"'").executeUpdate(); + entityManager.createNativeQuery("update archives_summary set child = (select count(1) from file_"+ + archivesType.getEnName()+" where archive_id = '"+archiveId+"') where archives_id = '"+archiveId+"'").executeUpdate(); return result; } @@ -531,7 +552,22 @@ public class ArchivesServiceImpl implements ArchivesService { ArchivesSummary archivesSummary = archivesSummaryRepository.findByArchivesId(id); archivesSummary.setIsDeleteTime(delTime); archivesSummary.setUpdateTime(new Timestamp(System.currentTimeMillis())); + archivesSummary.setChild(0); archivesSummaryRepository.saveAndFlush(archivesSummary); + + //修改父级 + Optional optional = archivesTypeRepository.findById(archivesType.getId()); + if(optional.isPresent()) { + ArchivesType archivesTypeP = optional.get(); + String updateChild = "update " + archivesTypeP.getEnName() + " set child = (select count(1) from " + archivesType.getEnName() + + " where parent_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + + "')) where id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + "')"; + String updateChild2 = "update archives_summary set child = (select count(1) from " + archivesType.getEnName() + + " where parent_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + + "')) where archives_id = (select parent_id from " + archivesType.getEnName() + " where id = '" + id + "')"; + entityManager.createNativeQuery(updateChild).executeUpdate(); + entityManager.createNativeQuery(updateChild2).executeUpdate(); + } } //若删除为项目 if(archivesType.getIsType() == 2){ @@ -636,6 +672,20 @@ public class ArchivesServiceImpl implements ArchivesService { archivesSummary.setUpdateTime(new Timestamp(System.currentTimeMillis())); archivesSummaryRepository.saveAndFlush(archivesSummary); + //修改父级 + Optional optional = archivesTypeRepository.findById(archivesType.getId()); + if(optional.isPresent()){ + ArchivesType archivesTypeP = optional.get(); + String updateChild = "update "+archivesTypeP.getEnName()+" set child = (select count(1) from "+archivesType.getEnName() + +" where parent_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id + +"')) where id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id+"')"; + String updateChild2 = "update archives_summary set child = (select count(1) from "+archivesType.getEnName() + +" where parent_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id + +"')) where archives_id = (select parent_id from "+archivesType.getEnName()+" where id = '"+id+"')"; + entityManager.createNativeQuery(updateChild).executeUpdate(); + entityManager.createNativeQuery(updateChild2).executeUpdate(); + } + success += result; }