package com.zcloud.controller.alarm; import com.zcloud.controller.base.BaseController; import com.zcloud.entity.Page; import com.zcloud.entity.PageData; import com.zcloud.logs.LogAnno; import com.zcloud.service.alarm.DBAlarmService; import com.zcloud.util.ObjectExcelView; import com.zcloud.util.Tools; import org.apache.shiro.authz.annotation.RequiresPermissions; 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 org.springframework.web.servlet.ModelAndView; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * 说明:报警管理 * 作者:shaojie * 时间:2022-05-28 * 官网:www.qdkjchina.com */ @Controller @RequestMapping("/dbalarm") public class DBAlarmController extends BaseController { @Autowired private DBAlarmService dbalarmService; /**新增 * @param * @throws Exception */ @RequestMapping(value="/add") @RequiresPermissions("dbalarm:add") @ResponseBody public Object add() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd.put("DBALARM_ID", this.get32UUID()); //主键 dbalarmService.save(pd); map.put("result", errInfo); return map; } /**删除 * @param out * @throws Exception */ @RequestMapping(value="/delete") @RequiresPermissions("dbalarm:del") @ResponseBody public Object delete() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); dbalarmService.delete(pd); map.put("result", errInfo); //返回结果 return map; } /**修改 * @param * @throws Exception */ @RequestMapping(value="/edit") @RequiresPermissions("dbalarm:edit") @ResponseBody public Object edit() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); dbalarmService.edit(pd); map.put("result", errInfo); return map; } /**列表 * @param page * @throws Exception */ @RequestMapping(value="/list") @RequiresPermissions("dbalarm:list") @ResponseBody @LogAnno(menuType= "监测预警",menuServer= "在线监测",instructionsOperate = "智能预警",instructionsType = "列表") public Object list(Page page) throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String KEYWORDS = pd.getString("KEYWORDS"); //关键词检索条件 if(Tools.notEmpty(KEYWORDS))pd.put("KEYWORDS", KEYWORDS.trim()); page.setPd(pd); List varList = dbalarmService.list(page); //列出DBAlarm列表 map.put("varList", varList); map.put("page", page); map.put("result", errInfo); return map; } /**去修改页面获取数据 * @param * @throws Exception */ @RequestMapping(value="/goEdit") @RequiresPermissions("dbalarm:edit") @ResponseBody @LogAnno(menuType= "监测预警",menuServer= "在线监测",instructionsOperate = "智能预警",instructionsType = "去修改页面获取数据") public Object goEdit() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); pd = dbalarmService.findById(pd); //根据ID读取 map.put("pd", pd); map.put("result", errInfo); return map; } /**批量删除 * @param * @throws Exception */ @RequestMapping(value="/deleteAll") @RequiresPermissions("dbalarm:del") @ResponseBody public Object deleteAll() throws Exception{ Map map = new HashMap(); String errInfo = "success"; PageData pd = new PageData(); pd = this.getPageData(); String DATA_IDS = pd.getString("DATA_IDS"); if(Tools.notEmpty(DATA_IDS)){ String ArrayDATA_IDS[] = DATA_IDS.split(","); dbalarmService.deleteAll(ArrayDATA_IDS); errInfo = "success"; }else{ errInfo = "error"; } map.put("result", errInfo); //返回结果 return map; } /**导出到excel * @param * @throws Exception */ @RequestMapping(value="/excel") @RequiresPermissions("toExcel") public ModelAndView exportExcel() throws Exception{ ModelAndView mv = new ModelAndView(); PageData pd = new PageData(); pd = this.getPageData(); Map dataMap = new HashMap(); List titles = new ArrayList(); titles.add("AlarmID"); //1 titles.add("ScannerAlarmID"); //2 titles.add("IntellexAlarmID"); //3 titles.add("分析设备编号"); //4 titles.add("分析通道号"); //5 titles.add("分析设备IP"); //6 titles.add("VideoSourceSystemID"); //7 titles.add("VideoSourceChannelID"); //8 titles.add("报警类型"); //9 titles.add("服务端收到开始报警的时间"); //10 titles.add("服务端收到开始报警的时间"); //11 titles.add("服务端收到结束报警的时间"); //12 titles.add("VideoSourceAlarmStartTime"); //13 titles.add("VideoSourceAlarmTime"); //14 titles.add("VideoSourceAlarmEndTime"); //15 titles.add("报警视频路径"); //16 titles.add("Thumbnail"); //17 titles.add("ThumbnailRows"); //18 titles.add("ThumbnailCols"); //19 titles.add("ThumbnailSize"); //20 titles.add("报警图片路径"); //21 titles.add("分析设备名称"); //22 titles.add("spareInt1"); //23 titles.add("spareInt2"); //24 titles.add("状态"); //25 titles.add("设备类型"); //26 titles.add("spareStr32_2"); //27 titles.add("unicode编码的摄像机名称"); //28 titles.add("spareStr64_2"); //29 titles.add("转码后的报警名称 "); //30 titles.add("AlarmLevelID"); //31 titles.add("UserID"); //32 titles.add("ackTime"); //33 titles.add("报警中文名称 ,根据此字段区分告警类型"); //34 titles.add("预置位编号"); //35 titles.add("SpeciesID"); //36 titles.add("DVUID"); //37 titles.add("相机编号"); //38 dataMap.put("titles", titles); List varOList = dbalarmService.listAll(pd); List varList = new ArrayList(); for(int i=0;i