From af61b8413eacedbc0af0bcec334ce4f7cc487065 Mon Sep 17 00:00:00 2001 From: xia Date: Mon, 18 Jul 2022 10:54:00 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9B=B4=E6=96=B0=E5=87=BA=E5=BA=93=E5=88=97?= =?UTF-8?q?=E8=A1=A8=202.=E6=96=B0=E5=A2=9E=E5=88=A4=E6=96=AD=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E5=86=85=E6=98=AF=E5=90=A6=E6=9C=89=E6=A1=A3=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StorageController.java | 30 ++++++++++---- .../repository/ArchivesCaseRepository.java | 12 +++++- .../archives/service/ArchivesCaseService.java | 7 ++++ .../service/impl/ArchivesCaseServiceImpl.java | 40 ++++++++++++++++++- .../storeroom/utils/enums/ResponseStatus.java | 4 +- 5 files changed, 81 insertions(+), 12 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 617a956..76aacbf 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 @@ -58,12 +58,21 @@ public class StorageController { 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)); +// } + @ApiOperation("已入库盒列表") @GetMapping("/alReadyInto") public ApiResponse alReadyInto( - String caseName,String archiveNo,String title,String location, Pageable page + String tid, String caseName,String barcode, Pageable page ){ - return ApiResponse.success(caseService.alReadyInto(caseName,archiveNo,title,location,page)); + return ApiResponse.success(caseService.alReadyInto(tid,caseName,barcode,page)); } @ApiOperation("初始化档案装盒信息") @@ -81,10 +90,14 @@ public class StorageController { ){ DeviceArchivesTag deviceArchivesTag = deviceArchivesTagService.findByDeviceInfoIdAndPosition(deviceId,position); if(null == deviceArchivesTag) - return ApiResponse.error(ResponseStatus.Shelf_IS_NULL); + return ApiResponse.error(ResponseStatus.SHEIF_IS_NULL); if(1==deviceType) - ApiResponse.success(true); - return ApiResponse.success(archivesService.isShelfOccupy(deviceArchivesTag.getId())); + return ApiResponse.success(deviceArchivesTag); + if(archivesService.isShelfOccupy(deviceArchivesTag.getId())){ + return ApiResponse.success(deviceArchivesTag); + }else{ + return ApiResponse.error(ResponseStatus.SHEIF_OCCUPY); + } } @ApiOperation("入库") @@ -184,9 +197,12 @@ public class StorageController { @ApiOperation("外部回调-确认出入库") @AnonymousPostMapping("/externalCallback") public ApiResponse externalCallback( - @Validated @RequestBody List archivesIds + @Validated @RequestBody String json ){ - return ApiResponse.success(caseService.grantConfirm(archivesIds)); + JSONObject jsonObject = JSONObject.parseObject(json); + String caseId = jsonObject.get("id") +""; + String storageType = jsonObject.get("type")+""; + return ApiResponse.success(caseService.externalCallback(caseId,storageType)); } @ApiOperation("出入库记录") 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 32bf9b1..e0b523b 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 @@ -14,15 +14,18 @@ import java.util.Set; public interface ArchivesCaseRepository extends JpaRepository{ + @Query("from ArchivesCase where id = ?1") + ArchivesCase findCaseById(String caseId); + @Query(nativeQuery = true, value = "select * from archives_case where 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 initCaseList(String caseName, String tid,String barcode, Pageable page); @Query(nativeQuery = true, - value = "select * from archives_case where storage_type != 2 and deposit_num != 0 and if(?1 is null,1=1,case_name like ?1) and " + + value = "select * from archives_case where storage_type in ?4 and deposit_num != 0 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); + Page readyIntoCase(String caseName, String tid,String barcode,List storageType, Pageable page); @Query(nativeQuery = true, value = "SELECT distinct asum.archives_id as archivesId,ace.storage_type as storageType,asum.child as child,asum.category_type as categoryType," + @@ -55,6 +58,11 @@ public interface ArchivesCaseRepository extends JpaRepository findCaseName(List caseIds); + @Query(nativeQuery = true, + value = "select count(1) from archives_case ace where ace.shelf_id in " + + "(select id from device_archives_tag dat where dat.device_info_id in (?1)) ") + Integer isHaveArchives(List deviceId); + @Modifying @Query(value = "update ArchivesCase set tid = null where tid = ?1") void unbindTag(String tid); 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 77fe5c9..008a970 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 @@ -38,10 +38,15 @@ public interface ArchivesCaseService { //查看盒内详情 Object findInCase(String caseId); + //设备删除 设备内是否有档案 + Boolean isHaveArchives(List deviceId); + //查看可入库盒列表 Object readyIntoCase(String tid, String caseName,String barcode, Pageable page); //查看已入库列表 Object alReadyInto(String caseName,String archiveNo,String title,String location, Pageable page); + //查看已入库列表 + Object alReadyInto(String tid, String caseName,String barcode, Pageable page); //根据档案初始化装盒信息 Object initCaseByArchives(String archivesId); //入库 @@ -58,4 +63,6 @@ public interface ArchivesCaseService { Object initStorageLogList(Integer storageType, String caseName,String tid,String barcode, Pageable page); //根据id集合获取出入库列表 List initStorageLogList(List logs); + //第三方回调 + Integer externalCallback(String caseId,String storageType); } 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 a2b23d8..8414bc9 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 @@ -400,12 +400,20 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { return vo; } + @Override + public Boolean isHaveArchives(List deviceId) { + Integer count = caseRepository.isHaveArchives(deviceId); + return count>0?false:true; + } + @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); + List storageType = new ArrayList<>(); + storageType.add(0);storageType.add(1); + Page pageCase = caseRepository.readyIntoCase(caseName,tid,barcode,storageType,page); return PageUtil.toPage(pageCase); } @@ -419,6 +427,17 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { return PageUtil.toPage(pageCase); } + @Override + public Object alReadyInto(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 +"%"; + List storageType = new ArrayList<>(); + storageType.add(2);storageType.add(3); + Page pageCase = caseRepository.readyIntoCase(caseName,tid,barcode,storageType,page); + return PageUtil.toPage(pageCase); + } + @Override public Object initCaseByArchives(String caseId) { return caseRepository.initCaseAllByCaseId(caseId); @@ -452,7 +471,7 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { } } } - if(resultOk>1){ + if(resultOk>0){ newShelfId = newShelfId.substring(0,newShelfId.length()-1); newLocation = newLocation.substring(0,newLocation.length()-1); newLocationName = newLocationName.substring(0,newLocationName.length()-1); @@ -560,4 +579,21 @@ public class ArchivesCaseServiceImpl implements ArchivesCaseService { public List initStorageLogList(List logs) { return storageLogRepository.findAllById(logs); } + + @Override + public Integer externalCallback(String caseId, String type) { + Integer storageType = "1".equals(type)? 2:0; + ArchivesCase archivesCase = caseRepository.findCaseById(caseId); + if(null == archivesCase) + return 0; + //入库回调 + if("1".equals(type)){ + archivesCase.setStorageType(storageType); + //出库回调 + }else{ + + } + caseRepository.saveAndFlush(archivesCase); + return null; + } } diff --git a/common/src/main/java/com/storeroom/utils/enums/ResponseStatus.java b/common/src/main/java/com/storeroom/utils/enums/ResponseStatus.java index e4c9ef3..232407b 100644 --- a/common/src/main/java/com/storeroom/utils/enums/ResponseStatus.java +++ b/common/src/main/java/com/storeroom/utils/enums/ResponseStatus.java @@ -28,7 +28,9 @@ public enum ResponseStatus { //设备 为空 DEVICE_IS_NULL(7001,"找不到当前设备"), //层架位不存在 - Shelf_IS_NULL(7010,"层架位不存在"), + SHEIF_IS_NULL(7010,"层架位不存在"), + //层架位已被占用 + SHEIF_OCCUPY(7011,"层架位已被占用"), //档案未入库 ARCHIVES_NOT_COLLECT(8001,"该档案未入库");