|  |  |  | 
|---|
|  |  |  | import org.springframework.web.context.request.async.DeferredResult; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Description: 异步请求处理 | 
|---|
|  |  |  | * @description: 异步请求处理 | 
|---|
|  |  |  | * @author: swwheihei | 
|---|
|  |  |  | * @date:   2020年5月8日 下午7:59:05 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String CALLBACK_CMD_PLAY = "CALLBACK_PLAY"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String CALLBACK_CMD_PLAYBACK = "CALLBACK_PLAYBACK"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String CALLBACK_CMD_DOWNLOAD = "CALLBACK_DOWNLOAD"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String CALLBACK_CMD_STOP = "CALLBACK_STOP"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String CALLBACK_ONVIF = "CALLBACK_ONVIF"; | 
|---|
|  |  |  | public static final String UPLOAD_FILE_CHANNEL = "UPLOAD_FILE_CHANNEL"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public static final String CALLBACK_CMD_MOBILEPOSITION = "CALLBACK_MOBILEPOSITION"; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public DeferredResult get(String key, String id) { | 
|---|
|  |  |  | Map<String, DeferredResult> deferredResultMap = map.get(key); | 
|---|
|  |  |  | if (deferredResultMap == null) return null; | 
|---|
|  |  |  | if (deferredResultMap == null) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return deferredResultMap.get(id); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public boolean exist(String key, String id){ | 
|---|
|  |  |  | if (key == null) return false; | 
|---|
|  |  |  | if (key == null) { | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | Map<String, DeferredResult> deferredResultMap = map.get(key); | 
|---|
|  |  |  | if (id == null) { | 
|---|
|  |  |  | return deferredResultMap != null; | 
|---|
|  |  |  | 
|---|
|  |  |  | if (result == null) { | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | result.setResult(new ResponseEntity<>(msg.getData(),HttpStatus.OK)); | 
|---|
|  |  |  | result.setResult(ResponseEntity.ok().body(msg.getData())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | map.remove(msg.getKey()); | 
|---|
|  |  |  |  | 
|---|