qa-prevention-gwj/src/main/java/com/zcloud/controller/videoreceive/VideoReceiveController.java

284 lines
9.5 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package com.zcloud.controller.videoreceive;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zcloud.controller.base.BaseController;
import com.zcloud.entity.Page;
import com.zcloud.entity.PageData;
import com.zcloud.service.receive.VideoReceiveService;
import com.zcloud.util.Jurisdiction;
import com.zcloud.util.Tools;
import com.zcloud.util.ys.YSUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 说明:特种设备安全巡检管理
* 作者luoxiaobao
* 时间2021-06-19
* 官网www.zcloudchina.com
*/
@Controller
@RequestMapping("/videoreceive")
public class VideoReceiveController extends BaseController {
@Autowired
private VideoReceiveService videoReceiveService;
@Autowired
private YSUtil ysUtil;
/**列表
* @throws Exception
*/
@RequestMapping(value="/listAll")
@ResponseBody
public Object listAll() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
List<PageData> varList = videoReceiveService.listAll(pd); //列出Platformvideomanagement列表
map.put("varList", varList);
map.put("result", errInfo);
return map;
}
/**列表
* @throws Exception
*/
@RequestMapping(value="/findVideo")
@ResponseBody
public Object findVideo() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
PageData pd =this.getPageData();
pd.put("ResCode",pd.getString("org"));
PageData videoByResCode = videoReceiveService.findVideoByResCode(pd);
map.put("pd",videoByResCode);
map.put("result", "success");
return map;
}
/**列表
* @param page
* @throws Exception
*/
@RequestMapping(value="/list")
@ResponseBody
public Object list(Page page) throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件
if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim());
pd.put("CORPINFO_ID", Jurisdiction.getCORPINFO_ID());
page.setPd(pd);
List<PageData> varList = videoReceiveService.list(page); //列出VideoManager列表
map.put("varList", varList);
map.put("page", page);
map.put("result", errInfo);
return map;
}
/**列表
* @throws Exception
*/
@RequestMapping(value="/platformList")
@ResponseBody
public Object platformList() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
PageData pd =this.getPageData();
JSONObject area = ysUtil.queryAreaList(pd);
JSONObject areaResult = (JSONObject) area.get("Result");
Map resultMap = areaResult.toJavaObject(Map.class);
List<PageData> list = JSONArray.parseArray(resultMap.get("InfoList").toString(), PageData.class);
ArrayList<PageData> arrayList = new ArrayList<>();
list.forEach(areaPd -> {
JSONObject resItemV1 = (JSONObject) areaPd.get("ResItemV1");
Map map1 = JSONObject.parseObject(resItemV1.toString(), Map.class);
PageData data = new PageData();
data.putAll(map1);
arrayList.add(data);
});
arrayList.forEach(pageData -> {
String resCode = pageData.getString("ResCode");
PageData condition = new PageData();
condition.put("org", resCode);
try {
//查询是否有下一级区域
JSONObject jsonObject1 = ysUtil.queryAreaList(condition);
JSONObject result = (JSONObject) jsonObject1.get("Result");
Map results = result.toJavaObject(Map.class);
List<PageData> nextList = JSONArray.parseArray(results.get("InfoList").toString(), PageData.class);
if (nextList.size()>0) {
pageData.put("hasChildren",true);
}
//查询下一级是否有摄像头
JSONObject cameraObject = ysUtil.queryCameraList(condition);
JSONObject cameraResult = (JSONObject) cameraObject.get("Result");
Map cameraMap = cameraResult.toJavaObject(Map.class);
List<PageData> cameraList = JSONArray.parseArray(cameraMap.get("InfoList").toString(), PageData.class);
if (cameraList.size()>0) {
pageData.put("hasChildren",true);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
});
//查询当前级摄像头数据
JSONObject cameraObject = ysUtil.queryCameraList(pd);
JSONObject cameraResult = (JSONObject) cameraObject.get("Result");
Map cameraMap = cameraResult.toJavaObject(Map.class);
List<PageData> cameraList = JSONArray.parseArray(cameraMap.get("InfoList").toString(), PageData.class);
cameraList.forEach(cameraPd -> {
JSONObject resItemV1 = (JSONObject) cameraPd.get("ResItemV1");
Map map1 = JSONObject.parseObject(resItemV1.toString(), Map.class);
PageData data = new PageData();
data.putAll(map1);
arrayList.add(data);
});
map.put("varList",arrayList);
map.put("result", "success");
return map;
}
/**新增
* @param
* @throws Exception
*/
@RequestMapping(value="/add")
@ResponseBody
public Object add() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("VIDEORECEIVE_ID", this.get32UUID()); //主键
videoReceiveService.save(pd);
map.put("pd",pd);
map.put("result", errInfo);
return map;
}
/**新增
* @param
* @throws Exception
*/
@RequestMapping(value="/addVideo")
@ResponseBody
public Object addVideo() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
videoReceiveService.edit(pd);
map.put("pd",pd);
map.put("result", errInfo);
return map;
}
/**新增
* @param
* @throws Exception
*/
@RequestMapping(value="/savePosition")
@ResponseBody
public Object savePosition() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("ISDELETE","0");
if(pd.get("VIDEORECEIVE_ID") != null){
videoReceiveService.edit(pd);
}else{
pd.put("VIDEORECEIVE_ID", this.get32UUID()); //主键
videoReceiveService.save(pd);
}
map.put("result", errInfo);
return map;
}
/**列表
* @throws Exception
*/
@RequestMapping(value="/delLocation")
@ResponseBody
public Object delLocation() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
videoReceiveService.delLocation(pd);
map.put("result", errInfo);
return map;
}
/**删除
* @throws Exception
*/
@RequestMapping(value="/deleteVideo")
@ResponseBody
public Object deleteVideo() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
videoReceiveService.deleteVideo(pd);
map.put("result", errInfo);
return map;
}
/**删除
* @throws Exception
*/
@RequestMapping(value="/deleteGateVideo")
@ResponseBody
public Object deleteGateVideo() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = new PageData();
pd = this.getPageData();
pd.put("ISBINDING","0");
videoReceiveService.deleteGateVideo(pd);
map.put("result", errInfo);
return map;
}
@RequestMapping(value="/listAllCameraForMap")
@ResponseBody
public Object listAllCameraForMap() throws Exception{
PageData pd = this.getPageData();
return videoReceiveService.listAllForMap(pd);
}
@RequestMapping(value="/listAllCameraForMapBinding")
@ResponseBody
public Object listAllCameraForMapBingDing() throws Exception{
PageData pd = this.getPageData();
return videoReceiveService.listAllForMapBinding(pd);
}
@RequestMapping(value="/getHlsPath")
@ResponseBody
public Object getHlsPath() throws Exception{
Map<String,Object> map = new HashMap<String,Object>();
String errInfo = "success";
PageData pd = this.getPageData();
map.put("result", errInfo);
return map;
}
}