package com.inspect.nvr.controller;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.inspect.nvr.domain.Infrared.*;
|
|
import com.inspect.nvr.service.HikVisionService;
|
|
import com.inspect.nvr.hikVision.utils.AjaxResult;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.core.io.InputStreamResource;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import java.io.InputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
|
|
@RestController
|
|
@CrossOrigin
|
|
public class InfraredController {
|
|
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
|
|
|
@Autowired
|
|
private HikVisionService hikVisionService;
|
|
|
|
/**
|
|
* ----登录----
|
|
* nvrIp nvrIp
|
|
* serverPort 端口
|
|
* password 密码
|
|
* account 账号
|
|
*/
|
|
@PostMapping("/login")
|
|
@ResponseBody
|
|
public AjaxResult login(@RequestBody NvrInfo nvrInfo) {
|
|
return hikVisionService.login(nvrInfo);
|
|
}
|
|
|
|
/**
|
|
* ----红外相机全屏测温抓图--海康微影----
|
|
* ip 相机Ip
|
|
* port 端口
|
|
* password 密码
|
|
* userName 账号
|
|
*/
|
|
|
|
// @PostMapping("/cameraHongWaiHk")
|
|
// @ResponseBody
|
|
// public AjaxResult cameraHongWaiHk(@RequestBody Camera camera) {
|
|
// return hikVisionService.cameraHongWaiHk(camera);
|
|
// }
|
|
@PostMapping("/cameraHong")
|
|
@ResponseBody
|
|
public AjaxResult cameraHong(@RequestBody Camera camera) {
|
|
TemperatureData temperatureData = hikVisionService.StartRemote(camera);
|
|
|
|
return AjaxResult.success().put("data", temperatureData);
|
|
}
|
|
@PostMapping("/cameraAngleJump")
|
|
@ResponseBody
|
|
public AjaxResult cameraAngleJump(@RequestBody Camera camera) {
|
|
|
|
return hikVisionService.NvrCameraAngleJump(camera);
|
|
}
|
|
|
|
|
|
@PostMapping("/camera")
|
|
@ResponseBody
|
|
public AjaxResult camera(@RequestBody Camera camera) throws Exception {
|
|
// Camera cameraPictrue = hikVisionService.cameraPictrue(camera);
|
|
// return AjaxResult.success().put("data", cameraPictrue) ;
|
|
return hikVisionService.NvrCameraPictrue(camera);
|
|
}
|
|
@PostMapping("/cameraHk")
|
|
@ResponseBody
|
|
public AjaxResult cameraHk(@RequestBody Camera camera) throws Exception {
|
|
InfraredInfo infraredInfo = hikVisionService.cameraCalculatePicture(camera);
|
|
return AjaxResult.success().put("data", infraredInfo) ;
|
|
}
|
|
//图谱解析
|
|
@PostMapping("/ir/capturePicture")
|
|
@ResponseBody
|
|
public AjaxResult setCapturePicture(@RequestBody InfraPictureInfo infraPictureInfo) {
|
|
|
|
return hikVisionService.capturePicture(infraPictureInfo);
|
|
}
|
|
|
|
//图谱解析
|
|
@PostMapping("/ir/picAnalyse")
|
|
@ResponseBody
|
|
public ResponseEntity<String> irPicAnalyse(@RequestBody final String analyseRequest) {
|
|
return hikVisionService.irPicAnalyse(analyseRequest);
|
|
}
|
|
|
|
@GetMapping("/device/radiometry-temper/{cameraCode}")
|
|
public ResponseEntity<String> deviceRadiometryTemper(
|
|
@PathVariable("cameraCode") String cameraCode,
|
|
@RequestParam("presetId") Integer presetId,
|
|
@RequestParam("ruleId") Integer ruleId,
|
|
@RequestParam("meterType") Integer meterType
|
|
) {
|
|
log.info("deviceRadiometryTemper, cameraCode: {}, presetId: {}, ruleId: {}, meterType: {}",
|
|
cameraCode, presetId, ruleId, meterType);
|
|
|
|
JSONObject subJsonObject = new JSONObject();
|
|
subJsonObject.put("meterType", 2);
|
|
subJsonObject.put("temperUnit", 1);
|
|
subJsonObject.put("temperAver", 60.0);
|
|
subJsonObject.put("temperMax", 100.0);
|
|
subJsonObject.put("temperMin", 50.0);
|
|
subJsonObject.put("temperMid", 60.0);
|
|
subJsonObject.put("temperStd", 1);
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("resultCode", 0);
|
|
jsonObject.put("resultMsg", "success");
|
|
jsonObject.put("radiometryInfo", subJsonObject);
|
|
|
|
return ResponseEntity.ok(jsonObject.toJSONString());
|
|
}
|
|
|
|
|
|
//csv文件下载
|
|
@PostMapping("/ir/downloadCsv")
|
|
@ResponseBody
|
|
public ResponseEntity<InputStreamResource> downloadCsv(@RequestBody InfraPictureInfo infraPictureInfo) {
|
|
InputStream csvStream = hikVisionService.downloadCsv(infraPictureInfo.getFilePath());
|
|
return ResponseEntity.ok()
|
|
.header("Content-Type", "text/csv; charset=utf-8")
|
|
.header("Content-Disposition", "attachment; filename=data.csv")
|
|
.body(new InputStreamResource(csvStream));
|
|
|
|
}
|
|
|
|
|
|
//添加画框数据
|
|
@PostMapping("/ir/addBoxData")
|
|
@ResponseBody
|
|
public AjaxResult addBoxData(@RequestBody InfraPictureInfo infraPictureInfo) {
|
|
|
|
return AjaxResult.success().put("data", 0);
|
|
}
|
|
|
|
//删除选择图片的全部框
|
|
@PostMapping("/ir/deleteBoxData")
|
|
@ResponseBody
|
|
public AjaxResult deleteBoxData(@RequestBody InfraredBox infraredBox) {
|
|
int i = -1;
|
|
|
|
return AjaxResult.success().put("data", i);
|
|
}
|
|
|
|
//获取选择图片的全部框
|
|
@PostMapping("/ir/selectBoxData")
|
|
@ResponseBody
|
|
public AjaxResult selectBoxData(@RequestBody InfraredBox infraredBox) {
|
|
List<InfraredBox> list=new ArrayList<>();
|
|
return AjaxResult.success().put("data", list);
|
|
}
|
|
|
|
@PostMapping("/ir/status")
|
|
public Map<String, Integer> getStatus() {
|
|
log.info("stream close interface!!!");
|
|
Map<String, Integer> response = new HashMap<>();
|
|
response.put("code", 0);
|
|
response.put("close", 1);
|
|
return response;
|
|
}
|
|
}
|