|
|
|
@ -94,13 +94,6 @@ public class IvsServerController { |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping({"/device/ptzcontrol2"}) |
|
|
|
public ResponseEntity<ResultEntity> devicePtzControl(@RequestBody SipbPtzVo ptzVo) { |
|
|
|
log.info("[GAB] devicePtzControl : {}", ptzVo.toString()); |
|
|
|
return ResponseEntity |
|
|
|
.ok() |
|
|
|
.body(ResultEntity.builder().resultCode("0").build()); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/device/deviceList2/v1.0") |
|
|
|
public ResponseEntity<ResultEntity> getDeviceList(IvsDevChanListVo chanListVo) { |
|
|
|
@ -110,160 +103,7 @@ public class IvsServerController { |
|
|
|
.body(ResultEntity.builder().resultCode("0").build()); |
|
|
|
} |
|
|
|
|
|
|
|
private static int mCount = 0; |
|
|
|
|
|
|
|
@GetMapping("/platform/platformSnapshot2/{cameraCode}/{domainCode}") |
|
|
|
public ResponseEntity<ResultEntity> getPlatformSnapshot( |
|
|
|
@PathVariable("cameraCode") String cameraCode, |
|
|
|
@PathVariable("domainCode") String domainCode, |
|
|
|
IvsDevChanSnapVo chanSnapVo |
|
|
|
) { |
|
|
|
log.info("[GAB] cameraCode: {}, domainCode: {}, platformSnapshot: {}", cameraCode, domainCode, chanSnapVo.toString()); |
|
|
|
|
|
|
|
mCount++; |
|
|
|
// if(mCount % 2 == 0) |
|
|
|
{ |
|
|
|
return ResponseEntity |
|
|
|
.ok() |
|
|
|
.body(ResultEntity |
|
|
|
.builder() |
|
|
|
.resultCode("0") |
|
|
|
.resultBody(IvsSnapshotView |
|
|
|
.builder() |
|
|
|
.taskID(TASK_CODE) |
|
|
|
.build() |
|
|
|
).build() |
|
|
|
); |
|
|
|
} |
|
|
|
// else { |
|
|
|
// return ResponseEntity |
|
|
|
// .ok().body(null); |
|
|
|
// } |
|
|
|
|
|
|
|
// return ResponseEntity |
|
|
|
// .ok() |
|
|
|
// .body(ResultEntity |
|
|
|
// .builder() |
|
|
|
// .resultCode("0") |
|
|
|
// .resultBody(IvsSnapshotView |
|
|
|
// .builder() |
|
|
|
// .taskID(TASK_CODE) |
|
|
|
// .build() |
|
|
|
// ).build() |
|
|
|
// ); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static int mCount2 = 0; |
|
|
|
|
|
|
|
@PostMapping("/platform/snapshotList2") |
|
|
|
public ResponseEntity<IvsPlatformSnapshotView> getPlatformSnapshotList(@RequestBody IvsChanSnapVo chanSnapVo) { |
|
|
|
log.info("[GAB] chanSnapVo: {}", chanSnapVo.toString()); |
|
|
|
|
|
|
|
mCount2++; |
|
|
|
// if(mCount2 % 4 == 0) |
|
|
|
{ |
|
|
|
List<IvsPlatformSnapshotView.SnapshotInfo> snapshotInfos = new ArrayList<>(); |
|
|
|
final String urlRes = platFormUrl + "/platform/snapshot/" + chanSnapVo.getCameraCode(); |
|
|
|
//final String urlRes = "http://192.168.110.184:18530/platform/snapshot/" + chanSnapVo.getCameraCode(); |
|
|
|
snapshotInfos.add( |
|
|
|
IvsPlatformSnapshotView.SnapshotInfo |
|
|
|
.builder() |
|
|
|
.cameraCode(chanSnapVo.getCameraCode()) |
|
|
|
.pictureName("test.png") |
|
|
|
.previewUrl(urlRes) |
|
|
|
.pictureUrl(urlRes) |
|
|
|
.build() |
|
|
|
); |
|
|
|
IvsPlatformSnapshotView.SnapshotInfoList snapshotInfoList = |
|
|
|
IvsPlatformSnapshotView.SnapshotInfoList |
|
|
|
.builder() |
|
|
|
.total(1) |
|
|
|
.indexRange(IndexRange.builder().fromIndex(0).toIndex(0).build()) |
|
|
|
.snapshotInfos(snapshotInfos) |
|
|
|
.build(); |
|
|
|
IvsPlatformSnapshotView snapshotView |
|
|
|
= IvsPlatformSnapshotView |
|
|
|
.builder() |
|
|
|
.resultCode("0") |
|
|
|
.snapshotInfoList(snapshotInfoList) |
|
|
|
.build(); |
|
|
|
return ResponseEntity |
|
|
|
.ok() |
|
|
|
.body(snapshotView); |
|
|
|
} |
|
|
|
// else { |
|
|
|
// return ResponseEntity |
|
|
|
// .ok() |
|
|
|
// .body(null); |
|
|
|
// } |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/platform/snapshot2/{cameraCode}") |
|
|
|
public ResponseEntity<InputStreamResource> getPlatformSnapshotByCameraCode(@PathVariable("cameraCode") String cameraCode, HttpServletResponse response) { |
|
|
|
log.info("[GAB] get stream, cameraCode: {}", cameraCode); |
|
|
|
try { |
|
|
|
final String resourcePath = String.format("images/%s.jpg", cameraCode); |
|
|
|
// InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourcePath); |
|
|
|
final String userDir = System.getProperty("user.dir"); |
|
|
|
final String absolutePath = userDir.endsWith("/") ? |
|
|
|
userDir + resourcePath : |
|
|
|
userDir + File.separator + resourcePath; |
|
|
|
log.info("absolutePath: {}", absolutePath); |
|
|
|
InputStream inputStream = Files.newInputStream(new File(absolutePath).toPath()); |
|
|
|
int length = inputStream.available(); |
|
|
|
log.info("[snapshot] inputStream length: {}", length); |
|
|
|
//byte bytes[] = new byte[length]; |
|
|
|
//response.setContentLength(length); |
|
|
|
InputStreamResource resource = new InputStreamResource(inputStream); |
|
|
|
return ResponseEntity.ok() |
|
|
|
.contentType(MediaType.IMAGE_JPEG) |
|
|
|
.body(resource) |
|
|
|
; |
|
|
|
} catch (Exception e) { |
|
|
|
//e.printStackTrace(); |
|
|
|
log.info("[GAB] get stream cameraCode: {}, exception: {}", cameraCode, e.getMessage()); |
|
|
|
return ResponseEntity.ok().body(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping("/platform/snapshot22/{cameraCode}") |
|
|
|
public ResponseEntity<InputStreamResource> getPlatformSnapshotByCameraCode2(@PathVariable("cameraCode") String cameraCode, HttpServletResponse response) { |
|
|
|
log.info("[GAB] get stream2, cameraCode: {}", cameraCode); |
|
|
|
try { |
|
|
|
File path = new File(ResourceUtils.getURL("classpath:").getPath()); |
|
|
|
if (!path.exists()) path = new File(""); |
|
|
|
log.info("path1: {}", path.getAbsolutePath()); |
|
|
|
log.info("path2: {}", System.getProperty("user.dir")); |
|
|
|
String path1 = ClassUtils.getDefaultClassLoader().getResource("").getPath(); |
|
|
|
log.info("path3: {}", URLDecoder.decode(path1, "utf-8")); |
|
|
|
String path2 = ResourceUtils.getURL("classpath:").getPath(); |
|
|
|
log.info("path4: {}", path2); |
|
|
|
ApplicationHome h = new ApplicationHome(getClass()); |
|
|
|
File jarF = h.getSource(); |
|
|
|
log.info("path5: {}", jarF.getParentFile().toString()); |
|
|
|
|
|
|
|
final String resourcePath = String.format("images/%s.jpg", cameraCode); |
|
|
|
final String userDir = System.getProperty("user.dir"); |
|
|
|
log.info("!!!!!!!!!!!!!!userDir: {}", userDir); |
|
|
|
final String absolutePath = userDir.endsWith("/") ? |
|
|
|
userDir + resourcePath : |
|
|
|
userDir + "/" + resourcePath; |
|
|
|
log.info("absolutePath2: {}", absolutePath); |
|
|
|
|
|
|
|
InputStream inputStream = Files.newInputStream(new File(absolutePath).toPath()); |
|
|
|
int length = inputStream.available(); |
|
|
|
log.info("[snapshot] inputStream2 length: {}", length); |
|
|
|
InputStreamResource resource = new InputStreamResource(inputStream); |
|
|
|
return ResponseEntity.ok() |
|
|
|
.contentType(MediaType.IMAGE_JPEG) |
|
|
|
.body(resource) |
|
|
|
; |
|
|
|
} catch (Exception e) { |
|
|
|
//e.printStackTrace(); |
|
|
|
log.info("[GAB] get stream cameraCode: {}, exception2: {}", cameraCode, e.getMessage()); |
|
|
|
return ResponseEntity.ok().body(null); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |