| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.camera.domain.CameraCmd; |
| | | import com.ruoyi.device.camera.service.IArdCamerasService; |
| | | import com.ruoyi.device.dhsdk.service.IDhClientService; |
| | | import com.ruoyi.device.hiksdk.service.IHikClientService; |
| | | import com.ruoyi.device.hiksdk.service.impl.HikClientServiceImpl; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.poi.ExcelUtil; |
| | | import com.ruoyi.inspect.service.IArdVideoInspectTaskService; |
| | | import com.ruoyi.media.service.IVtduService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | import com.ruoyi.common.enums.BusinessType; |
| | | import com.ruoyi.common.core.page.TableDataInfo; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 相机设备Controller |
| | |
| | | @Api(tags = "相机管理接口") |
| | | public class ArdCamerasController extends BaseController { |
| | | @Resource |
| | | private HikClientServiceImpl sdk; |
| | | private IHikClientService hikSdk; |
| | | @Resource |
| | | private IDhClientService dhSdk; |
| | | @Resource |
| | | private IArdCamerasService ardCamerasService; |
| | | @Resource |
| | | private IArdVideoInspectTaskService ardVideoInspectTaskService; |
| | | |
| | | /** |
| | | * 查询相机设备列表 |
| | |
| | | @Log(title = "相机设备", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody ArdCameras camera) { |
| | | //注销 |
| | | sdk.loginOut(camera.getId()); |
| | | //登录 |
| | | camera = sdk.login(camera); |
| | | if (camera.getLoginId() >= 0) { |
| | | log.info("相机" + camera.getIp() + ":" + camera.getPort() + "登录成功:" + camera.getLoginId()); |
| | | camera.setUpdateBy(SecurityUtils.getUsername()); |
| | | ardCamerasService.updateArdCameras(camera); |
| | | int i = ardCamerasService.insertArdCameras(camera); |
| | | if (i > 0) { |
| | | if (camera.getFactory().equals("1")) { |
| | | //注销 |
| | | hikSdk.logout(camera.getId()); |
| | | //异步登录 |
| | | hikSdk.asyncLogin(camera); |
| | | } |
| | | else if(camera.getFactory().equals("2")) |
| | | { |
| | | dhSdk.logout(camera.getId()); |
| | | dhSdk.login(camera); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | log.info("相机" + camera.getIp() + ":" + camera.getPort() + "登录失败:" + camera.getLoginId()); |
| | | } |
| | | return toAjax(ardCamerasService.insertArdCameras(camera)); |
| | | return toAjax(i); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody ArdCameras camera) { |
| | | int i = ardCamerasService.updateArdCameras(camera); |
| | | if(i>0) |
| | | { |
| | | ArdCameras cameras = ardCamerasService.selectArdCamerasById(camera.getId()); |
| | | sdk.loginOut(cameras.getId()); |
| | | camera = sdk.login(cameras); |
| | | if (camera.getLoginId() >= 0) { |
| | | log.info("相机" + camera.getIp() + ":" + camera.getPort() + "登录成功:" + camera.getLoginId()); |
| | | ardCamerasService.updateArdCameras(camera); |
| | | if (i > 0) { |
| | | camera= ardCamerasService.selectArdCamerasById(camera.getId()); |
| | | if(camera.getFactory().equals("1")) { |
| | | hikSdk.logout(camera.getId()); |
| | | hikSdk.asyncLogin(camera); |
| | | } |
| | | else |
| | | { |
| | | log.info("相机" + camera.getIp() + ":" + camera.getPort() + "登录失败:" + camera.getLoginId()); |
| | | else if(camera.getFactory().equals("2")) { |
| | | dhSdk.logout(camera.getId()); |
| | | dhSdk.login(camera); |
| | | } |
| | | } |
| | | return toAjax(i); |
| | |
| | | @DeleteMapping("/{ids}") |
| | | public AjaxResult remove(@PathVariable String[] ids) { |
| | | for (String id : ids) { |
| | | sdk.loginOut(id); |
| | | } |
| | | hikSdk.logout(id); |
| | | dhSdk.logout(id); |
| | | } |
| | | return toAjax(ardCamerasService.deleteArdCamerasByIds(ids)); |
| | | } |
| | | |
| | | @GetMapping("/options") |
| | | @ApiOperation("选择相机数据") |
| | | public List options(ArdCameras ardCameras) { |
| | |
| | | Map option = new HashMap(); |
| | | option.put("value", item.getId()); |
| | | option.put("label", item.getName()); |
| | | // option.put("description", item.getOilProduction()); |
| | | option.put("channel", item.getChanNo()); |
| | | List timeList = ardVideoInspectTaskService.getCameraIdleTimeList(item.getId()); |
| | | option.put("idleTimeList", timeList);//空闲时间段 |
| | | options.add(option); |
| | | } |
| | | return options; |
| | | } |
| | | |
| | | @GetMapping("/getDeptAndCamera") |
| | | @ApiOperation("获取部门和相机") |
| | | public AjaxResult getDeptAndCamera() { |
| | | Map deptAndCamera = ardCamerasService.getChildDeptAndCamera(true); |
| | | return AjaxResult.success(deptAndCamera); |
| | | } |
| | | |
| | | @GetMapping("/getDeptAndCameraWithCheckBox") |
| | | @ApiOperation("获取部门和相机(开启复选框)") |
| | | public AjaxResult getDeptAndCameraWithCheckBox() { |
| | | Map deptAndCamera = ardCamerasService.getChildDeptAndCamera(false); |
| | | return AjaxResult.success(deptAndCamera); |
| | | } |
| | | |
| | | @PostMapping("/getNearCamerasBycoordinate") |
| | | @ApiOperation("获取附近的相机") |
| | | @ApiOperationSupport(includeParameters = {"targetPosition"}) |
| | | public AjaxResult getNearCamerasBycoordinate(@RequestBody CameraCmd cmd) { |
| | | TreeMap nearCamerasBycoordinate = ardCamerasService.getNearCamerasBycoordinate(cmd); |
| | | return AjaxResult.success(nearCamerasBycoordinate); |
| | | } |
| | | } |