|  | @ -1,9 +1,12 @@ | 
		
	
		
			
				|  |  | package com.storeroom.modules.archives.controller; |  |  | package com.storeroom.modules.archives.controller; | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  | import com.storeroom.modules.archives.domain.ArchivesCase; | 
		
	
		
			
				|  |  | import com.storeroom.modules.archives.service.ArchivesCaseService; |  |  | import com.storeroom.modules.archives.service.ArchivesCaseService; | 
		
	
		
			
				|  |  | import com.storeroom.modules.archives.service.ArchivesService; |  |  | import com.storeroom.modules.archives.service.ArchivesService; | 
		
	
		
			
				|  |  | import com.storeroom.modules.archives.service.dto.CaseDTO; |  |  | import com.storeroom.modules.archives.service.dto.CaseDTO; | 
		
	
		
			
				|  |  | import com.storeroom.modules.archives.service.dto.CollectDTO; |  |  | import com.storeroom.modules.archives.service.dto.CollectDTO; | 
		
	
		
			
				|  |  |  |  |  | import com.storeroom.modules.device.domain.OperatingState; | 
		
	
		
			
				|  |  |  |  |  | import com.storeroom.modules.device.service.OperatingStateService; | 
		
	
		
			
				|  |  | import com.storeroom.utils.ApiResponse; |  |  | import com.storeroom.utils.ApiResponse; | 
		
	
		
			
				|  |  | import com.storeroom.utils.enums.ResponseStatus; |  |  | import com.storeroom.utils.enums.ResponseStatus; | 
		
	
		
			
				|  |  | import io.swagger.annotations.Api; |  |  | import io.swagger.annotations.Api; | 
		
	
	
		
			
				|  | @ -23,6 +26,7 @@ public class StorageController { | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |     private final ArchivesCaseService caseService; |  |  |     private final ArchivesCaseService caseService; | 
		
	
		
			
				|  |  |     private final ArchivesService archivesService; |  |  |     private final ArchivesService archivesService; | 
		
	
		
			
				|  |  |  |  |  |     private final OperatingStateService operatingStateService; | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  |     @ApiOperation("可入库盒列表") |  |  |     @ApiOperation("可入库盒列表") | 
		
	
		
			
				|  |  |     @GetMapping("/readyInto") |  |  |     @GetMapping("/readyInto") | 
		
	
	
		
			
				|  | @ -63,11 +67,37 @@ public class StorageController { | 
		
	
		
			
				|  |  |     ){ |  |  |     ){ | 
		
	
		
			
				|  |  |         if(null == dtos || dtos.size()==0) |  |  |         if(null == dtos || dtos.size()==0) | 
		
	
		
			
				|  |  |             return ApiResponse.error(ResponseStatus.DEVICE_IS_NULL); |  |  |             return ApiResponse.error(ResponseStatus.DEVICE_IS_NULL); | 
		
	
		
			
				|  |  |         String device = dtos.get(0).getDeviceId(); |  |  |  | 
		
	
		
			
				|  |  |  |  |  |         String deviceId = dtos.get(0).getDeviceId(); | 
		
	
		
			
				|  |  |         //判断设备是否有回调 |  |  |         //判断设备是否有回调 | 
		
	
		
			
				|  |  |         boolean isCallback = false; |  |  |  | 
		
	
		
			
				|  |  |         Integer result = caseService.collect(isCallback,dtos); |  |  |  | 
		
	
		
			
				|  |  |         return ApiResponse.success(result); |  |  |  | 
		
	
		
			
				|  |  |  |  |  |         OperatingState callback = operatingStateService.findByDeviceIdAndStateType(deviceId,2); | 
		
	
		
			
				|  |  |  |  |  |         boolean isCallback = callback == null ? false : callback.getInBound(); | 
		
	
		
			
				|  |  |  |  |  |         List<ArchivesCase> cases = caseService.collect(isCallback,dtos); | 
		
	
		
			
				|  |  |  |  |  |         //判断设备是否有联动 | 
		
	
		
			
				|  |  |  |  |  |         OperatingState linkage = operatingStateService.findByDeviceIdAndStateType(deviceId,1); | 
		
	
		
			
				|  |  |  |  |  |         if(null != linkage && linkage.getInBound()){ | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  |         return ApiResponse.success(cases.size()); | 
		
	
		
			
				|  |  |  |  |  |     } | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |     @ApiOperation("出库") | 
		
	
		
			
				|  |  |  |  |  |     @PostMapping("/grant") | 
		
	
		
			
				|  |  |  |  |  |     public ApiResponse<Object> grant( | 
		
	
		
			
				|  |  |  |  |  |             @Validated @RequestBody List<CollectDTO> dtos | 
		
	
		
			
				|  |  |  |  |  |     ){ | 
		
	
		
			
				|  |  |  |  |  |         if(null == dtos || dtos.size()==0) | 
		
	
		
			
				|  |  |  |  |  |             return ApiResponse.error(ResponseStatus.DEVICE_IS_NULL); | 
		
	
		
			
				|  |  |  |  |  |         String deviceId = dtos.get(0).getDeviceId(); | 
		
	
		
			
				|  |  |  |  |  |         //判断设备是否有回调 | 
		
	
		
			
				|  |  |  |  |  |         OperatingState callback = operatingStateService.findByDeviceIdAndStateType(deviceId,2); | 
		
	
		
			
				|  |  |  |  |  |         boolean isCallback = callback == null ? false : callback.getInBound(); | 
		
	
		
			
				|  |  |  |  |  |         List<ArchivesCase> cases = caseService.collect(isCallback,dtos); | 
		
	
		
			
				|  |  |  |  |  |         //判断设备是否有联动 | 
		
	
		
			
				|  |  |  |  |  |         OperatingState linkage = operatingStateService.findByDeviceIdAndStateType(deviceId,1); | 
		
	
		
			
				|  |  |  |  |  |         if(null != linkage && linkage.getInBound()){ | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  |         return ApiResponse.success(cases.size()); | 
		
	
		
			
				|  |  |     } |  |  |     } | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | } |  |  | } |