package com.xkrs.controller; import com.alibaba.fastjson.JSON; import com.xkrs.dao.CameraDao; import com.xkrs.dao.DeviceManagementDao; import com.xkrs.model.entity.CameraInformation; import com.xkrs.model.entity.DeviceManagement; import com.xkrs.model.vo.ADD; import com.xkrs.model.vo.DA; import com.xkrs.service.CameraService; import com.xkrs.service.FireService; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import java.io.*; import java.util.ArrayList; import java.util.List; /** * @Author: XinYi Song * @Date: 2022/3/3 11:56 */ @RestController public class CameraController { @Resource private CameraService cameraService; @Resource private CameraDao cameraDao; @Resource private DeviceManagementDao deviceManagementDao; @GetMapping("/getCameraInformation") public List getCameraInformation(){ return cameraService.SelectCameraAll(); } @GetMapping("/insertCameraInformation") public boolean insertCameraInformation(CameraInformation cameraInformation){ try { cameraService.InsertCamera(cameraInformation); return true; } catch (Exception e){ return false; } } /** * 返回全部信息 * @param * @return */ @GetMapping("/findEquipment1") public String Selectequipment(){ try { return cameraService.Selectequipment(); } catch (Exception E) { return E.getMessage(); } } /** * 查询实时视频连接 * @return */ @GetMapping("/findVideoPath1") public String selectVideotape(){ try { return cameraService.Videotape(); } catch (Exception e){ return e.getMessage(); } } /** * 添加设备信息 * @return */ @GetMapping("/SelectDeviceManagement") public String SelectDeviceManagement() { File file = new File("C:\\Users\\HP\\Desktop\\摄像头设备信息.txt"); try { BufferedReader br=new BufferedReader(new FileReader(file)); String contnetTotal=""; String s; while (( s=br.readLine())!=null){ contnetTotal+=s; } br.close(); DA tempBran = JSON.parseObject(contnetTotal, DA.class); List pageData = tempBran.getData().getPageData(); for (DA.DataDTO.PageDataDTO item: pageData) { DeviceManagement add=new DeviceManagement(); add.setDeviceName(item.getDeviceName()); add.setDeviceCode(item.getDeviceCode()); add.setDeviceSn(item.getDeviceSn()); add.setDeviceCategory(item.getDeviceCategory()); add.setDeviceManufacturer(item.getDeviceManufacturer()); add.setDeviceType(item.getDeviceType()); add.setDeviceModel(item.getDeviceModel()); add.setDeviceIp(item.getDeviceIp()); add.setDevicePort(item.getDevicePort()); add.setOwnerCode(item.getOwnerCode()); add.setLiveVideo("http://111.53.13.180:7086/live/cameraid/"+item.getDeviceCode()+ "%240/substream/1.m3u8"); add.setIsOnline(item.getIsOnline()); add.setUpdateTime(item.getOnlineUpdateTime()); deviceManagementDao.save(add); } System.out.println("111"); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return "1"; } }