
34 changed files with 651 additions and 253 deletions
@ -0,0 +1,66 @@ |
|||||
|
package com.yxt.supervise.monitor.api.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.yxt.common.core.domain.EntityWithId; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel(value = "有ID的实体", description = "有ID的实体") |
||||
|
@TableName("y_device_image") |
||||
|
public class DeviceImage extends EntityWithId { |
||||
|
// `id`使用继承的
|
||||
|
|
||||
|
@ApiModelProperty("记录创建时间") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
||||
|
private Date createTime = new Date(); // 记录创建时间
|
||||
|
|
||||
|
@ApiModelProperty("备注说明") |
||||
|
private String remarks; // 备注说明
|
||||
|
|
||||
|
@ApiModelProperty("名称") |
||||
|
private String name; // 名称
|
||||
|
|
||||
|
@ApiModelProperty("类型") |
||||
|
private String type; |
||||
|
|
||||
|
@ApiModelProperty("状态") |
||||
|
private String status; |
||||
|
|
||||
|
@ApiModelProperty("信息状态") |
||||
|
private String state; |
||||
|
|
||||
|
@ApiModelProperty("是否删除") |
||||
|
private String isDelete; |
||||
|
|
||||
|
@ApiModelProperty("修改时间") |
||||
|
private String modifyTime; |
||||
|
|
||||
|
@ApiModelProperty("是否可用") |
||||
|
private String isEnable; |
||||
|
|
||||
|
@ApiModelProperty("创建人") |
||||
|
private String createBySid; |
||||
|
|
||||
|
@ApiModelProperty("更新人") |
||||
|
private String updateBySid; |
||||
|
|
||||
|
@ApiModelProperty("验证码") |
||||
|
private String vCode; |
||||
|
|
||||
|
@ApiModelProperty("位置") |
||||
|
private String position; |
||||
|
|
||||
|
@ApiModelProperty("序列号") |
||||
|
private String deviceSerial; |
||||
|
|
||||
|
@ApiModelProperty("拍照前") |
||||
|
private String imgBefore; |
||||
|
|
||||
|
@ApiModelProperty("拍照后") |
||||
|
private String imgAfter; |
||||
|
} |
@ -0,0 +1,54 @@ |
|||||
|
package com.yxt.supervise.monitor.api.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.TableName; |
||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||
|
import com.yxt.common.core.domain.EntityWithId; |
||||
|
import io.swagger.annotations.ApiModel; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Data |
||||
|
@ApiModel(value = "有ID的实体", description = "有ID的实体") |
||||
|
@TableName("y_message_info") |
||||
|
public class MessageInfo extends EntityWithId { |
||||
|
// `id`使用继承的
|
||||
|
|
||||
|
@ApiModelProperty("记录创建时间") |
||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") |
||||
|
private Date createTime = new Date(); // 记录创建时间
|
||||
|
|
||||
|
@ApiModelProperty("备注说明") |
||||
|
private String remarks; // 备注说明
|
||||
|
|
||||
|
@ApiModelProperty("信息状态") |
||||
|
private String state; |
||||
|
|
||||
|
@ApiModelProperty("是否删除") |
||||
|
private String isDelte; |
||||
|
|
||||
|
@ApiModelProperty("修改时间") |
||||
|
private String modifyTime; |
||||
|
|
||||
|
@ApiModelProperty("是否可用") |
||||
|
private String isEnable; |
||||
|
|
||||
|
@ApiModelProperty("创建人") |
||||
|
private String createBySid; |
||||
|
|
||||
|
@ApiModelProperty("更新人") |
||||
|
private String updateBySid; |
||||
|
|
||||
|
@ApiModelProperty("设备ID") |
||||
|
private String deviceId; |
||||
|
|
||||
|
@ApiModelProperty("信息ID") |
||||
|
private String msgId; |
||||
|
|
||||
|
@ApiModelProperty("信息类型") |
||||
|
private String msgType; |
||||
|
|
||||
|
@ApiModelProperty("信息内容") |
||||
|
private String content; |
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package com.yxt.supervise.monitor.api.vo; |
||||
|
|
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* @author Exrickx |
||||
|
*/ |
||||
|
@Data |
||||
|
public class MessageVo { |
||||
|
|
||||
|
@ApiModelProperty(value = "消息ID,每条消息的唯一ID,消费者可根据此ID进行去重处理") |
||||
|
private String msgId; |
||||
|
|
||||
|
@ApiModelProperty(value = "消息类型") |
||||
|
private String msgType; |
||||
|
|
||||
|
@ApiModelProperty(value = "消息内容") |
||||
|
private String content; |
||||
|
|
||||
|
@ApiModelProperty(value = "消息发送到消息通道时的时间戳") |
||||
|
private String timestamp; |
||||
|
|
||||
|
} |
@ -1,4 +1,4 @@ |
|||||
package com.yxt.supervise.monitor.biz.controller; |
package com.yxt.supervise.monitor.biz.callpolice; |
||||
|
|
||||
import com.alibaba.fastjson.JSONObject; |
import com.alibaba.fastjson.JSONObject; |
||||
import com.yxt.common.core.result.ResultBean; |
import com.yxt.common.core.result.ResultBean; |
@ -1,14 +1,17 @@ |
|||||
package com.yxt.supervise.monitor.biz.mapper; |
package com.yxt.supervise.monitor.biz.callpolice; |
||||
|
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.yxt.supervise.monitor.api.entity.CallPolice; |
import com.yxt.supervise.monitor.api.entity.CallPolice; |
||||
import com.yxt.supervise.monitor.api.entity.Device; |
import com.yxt.supervise.monitor.api.entity.Device; |
||||
import org.apache.ibatis.annotations.Mapper; |
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
@Mapper |
@Mapper |
||||
public interface YCallPoliceMapper extends BaseMapper<CallPolice> { |
public interface YCallPoliceMapper extends BaseMapper<CallPolice> { |
||||
|
|
||||
|
|
||||
IPage<Device> getDevicePage(); |
IPage<Device> getDevicePage(); |
||||
|
|
||||
|
Integer getByMsgId(@Param("msgId") String msgId); |
||||
} |
} |
@ -0,0 +1,30 @@ |
|||||
|
package com.yxt.supervise.monitor.biz.callpolice; |
||||
|
|
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.supervise.monitor.api.vo.PageVo; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Api(tags = "报警控制器") |
||||
|
@RestController("com.yxt.supervise.monitor.biz.callpolice.YCallPoliceRest") |
||||
|
@RequestMapping("/callPolice") |
||||
|
public class YCallPoliceRest { |
||||
|
|
||||
|
@Autowired |
||||
|
private YCallPoliceService yCallPoliceService; |
||||
|
|
||||
|
|
||||
|
@ApiOperation("分页获取报警列表") |
||||
|
@GetMapping("/getCallPolicePage") |
||||
|
public ResultBean getCallPolicePage(@RequestParam Map<String, String> searchVo, |
||||
|
@ModelAttribute PageVo pageVo) { |
||||
|
ResultBean rb = ResultBean.fireSuccess(); |
||||
|
rb.setData(yCallPoliceService.getCallPolicePage(searchVo, pageVo)); |
||||
|
return rb; |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,55 @@ |
|||||
|
package com.yxt.supervise.monitor.biz.callpolice; |
||||
|
|
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.alibaba.fastjson.JSONArray; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.supervise.monitor.api.entity.CallPolice; |
||||
|
import com.yxt.supervise.monitor.api.entity.Device; |
||||
|
import com.yxt.supervise.monitor.api.entity.DeviceLog; |
||||
|
import com.yxt.supervise.monitor.api.entity.MessageInfo; |
||||
|
import com.yxt.supervise.monitor.api.vo.MessageVo; |
||||
|
import com.yxt.supervise.monitor.api.vo.PageVo; |
||||
|
import com.yxt.supervise.monitor.biz.devicelog.YDeviceLogMapper; |
||||
|
import com.yxt.supervise.monitor.biz.messageInfo.YMessageInfoMapper; |
||||
|
import com.yxt.supervise.monitor.biz.scheduled.SyncService; |
||||
|
import com.yxt.supervise.monitor.biz.util.HttpUtils; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.Date; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Service |
||||
|
public class YCallPoliceService extends ServiceImpl<YCallPoliceMapper, CallPolice> { |
||||
|
|
||||
|
public IPage<CallPolice> getCallPolicePage(Map<String, String> searchVo, PageVo pageVo) { |
||||
|
IPage<CallPolice> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(); |
||||
|
page.setSize(pageVo.getSize()); |
||||
|
page.setCurrent((long) pageVo.getCurrent()); |
||||
|
|
||||
|
QueryWrapper<CallPolice> queryWrapper = new QueryWrapper<>(); |
||||
|
|
||||
|
if (StrUtil.isNotBlank(searchVo.get("name"))) { |
||||
|
queryWrapper.like("name", searchVo.get("name")); |
||||
|
} |
||||
|
if (StrUtil.isNotBlank(searchVo.get("type"))) { |
||||
|
queryWrapper.eq("type", searchVo.get("type")); |
||||
|
} |
||||
|
queryWrapper.eq("isDelete", 0); |
||||
|
|
||||
|
IPage<CallPolice> athleteBOIPage = null; |
||||
|
try { |
||||
|
athleteBOIPage = baseMapper.selectPage(page, queryWrapper); |
||||
|
} catch (Exception e) { |
||||
|
System.out.println(e); |
||||
|
athleteBOIPage = null; |
||||
|
} |
||||
|
return athleteBOIPage; |
||||
|
} |
||||
|
} |
@ -0,0 +1,4 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > |
||||
|
<mapper namespace="com.yxt.supervise.monitor.biz.callpolice.YCallPoliceMapper"> |
||||
|
</mapper> |
@ -1,33 +0,0 @@ |
|||||
package com.yxt.supervise.monitor.biz.controller; |
|
||||
|
|
||||
import com.yxt.supervise.monitor.api.entity.Device; |
|
||||
import com.yxt.supervise.monitor.biz.service.YDeviceLogService; |
|
||||
import com.yxt.supervise.monitor.biz.service.YDeviceService; |
|
||||
import io.swagger.annotations.Api; |
|
||||
import io.swagger.annotations.ApiOperation; |
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
|
||||
import org.springframework.web.bind.annotation.GetMapping; |
|
||||
import org.springframework.web.bind.annotation.RequestMapping; |
|
||||
import org.springframework.web.bind.annotation.RequestParam; |
|
||||
import org.springframework.web.bind.annotation.RestController; |
|
||||
|
|
||||
import java.util.Map; |
|
||||
|
|
||||
@Api(tags = "设备日志控制器") |
|
||||
@RestController("com.yxt.supervise.monitor.biz.controller.YDeviceLogRest") |
|
||||
@RequestMapping("/deviceLog") |
|
||||
public class YDeviceLogRest { |
|
||||
|
|
||||
@Autowired |
|
||||
private YDeviceLogService yDeviceLogService; |
|
||||
|
|
||||
|
|
||||
@ApiOperation("分页获取设备日志列表") |
|
||||
@GetMapping("/getDevicePage") |
|
||||
public String getDevicePage(@RequestParam Map<String,String> searchVo) { |
|
||||
yDeviceLogService.getDevicePage(searchVo); |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
|
|
||||
} |
|
@ -1,14 +1,11 @@ |
|||||
package com.yxt.supervise.monitor.biz.mapper; |
package com.yxt.supervise.monitor.biz.device; |
||||
|
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
import com.yxt.supervise.monitor.api.demoidentity.DemoIdentity; |
|
||||
import com.yxt.supervise.monitor.api.entity.Device; |
import com.yxt.supervise.monitor.api.entity.Device; |
||||
import org.apache.ibatis.annotations.Mapper; |
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
@Mapper |
@Mapper |
||||
public interface YDeviceMapper extends BaseMapper<Device> { |
public interface YDeviceMapper extends BaseMapper<Device> { |
||||
|
|
||||
|
|
||||
IPage<Device> getDevicePage(); |
IPage<Device> getDevicePage(); |
||||
} |
} |
@ -0,0 +1,12 @@ |
|||||
|
package com.yxt.supervise.monitor.biz.deviceImage; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.yxt.supervise.monitor.api.entity.Device; |
||||
|
import com.yxt.supervise.monitor.api.entity.DeviceImage; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface YDeviceImageMapper extends BaseMapper<DeviceImage> { |
||||
|
IPage<DeviceImage> getDevicePage(); |
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package com.yxt.supervise.monitor.biz.deviceImage; |
||||
|
|
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.supervise.monitor.api.vo.PageVo; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Api(tags = "设备控制器") |
||||
|
@RestController("com.yxt.supervise.monitor.biz.deviceImage.YDeviceImageRest") |
||||
|
@RequestMapping("/deviceImage") |
||||
|
public class YDeviceImageRest { |
||||
|
|
||||
|
@Autowired |
||||
|
private YDeviceImageService yDeviceService; |
||||
|
|
||||
|
|
||||
|
@ApiOperation("分页获取设备抓拍列表") |
||||
|
@GetMapping("/getDeviceImagePage") |
||||
|
public ResultBean getDeviceImagePage(@RequestParam Map<String, String> searchVo, |
||||
|
@ModelAttribute PageVo pageVo) { |
||||
|
yDeviceService.getDeviceImageBefore(); |
||||
|
ResultBean rb = ResultBean.fireSuccess(); |
||||
|
// rb.setData(yDeviceService.getDeviceImagePage(searchVo, pageVo));
|
||||
|
return rb; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,62 @@ |
|||||
|
package com.yxt.supervise.monitor.biz.deviceImage; |
||||
|
|
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.supervise.monitor.api.entity.Device; |
||||
|
import com.yxt.supervise.monitor.api.entity.DeviceImage; |
||||
|
import com.yxt.supervise.monitor.api.vo.PageVo; |
||||
|
import com.yxt.supervise.monitor.biz.scheduled.SyncService; |
||||
|
import com.yxt.supervise.monitor.biz.util.HttpUtils; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Service |
||||
|
public class YDeviceImageService extends ServiceImpl<YDeviceImageMapper, DeviceImage> { |
||||
|
|
||||
|
|
||||
|
public IPage<DeviceImage> getDeviceImagePage(Map<String, String> searchVo, PageVo pageVo) { |
||||
|
IPage<DeviceImage> page = new Page<>(); |
||||
|
page.setSize(pageVo.getSize()); |
||||
|
page.setCurrent((long) pageVo.getCurrent()); |
||||
|
|
||||
|
QueryWrapper<DeviceImage> queryWrapper = new QueryWrapper<>(); |
||||
|
|
||||
|
if (StrUtil.isNotBlank(searchVo.get("name"))) { |
||||
|
queryWrapper.like("name", searchVo.get("name")); |
||||
|
} |
||||
|
if (StrUtil.isNotBlank(searchVo.get("type"))) { |
||||
|
queryWrapper.eq("type", searchVo.get("type")); |
||||
|
} |
||||
|
queryWrapper.eq("isDelete", 0); |
||||
|
|
||||
|
IPage<DeviceImage> athleteBOIPage = null; |
||||
|
try { |
||||
|
athleteBOIPage = baseMapper.selectPage(page, queryWrapper); |
||||
|
} catch (Exception e) { |
||||
|
System.out.println(e); |
||||
|
athleteBOIPage = null; |
||||
|
} |
||||
|
return athleteBOIPage; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public void getDeviceImageBefore() { |
||||
|
String url = "https://api2.hik-cloud.com/api/v1/open/basic/channels/actions/capture"; |
||||
|
Map<String, Object> param = new HashMap<>(); |
||||
|
param.put("deviceSerial", "Q16362484"); // 设备序列号 string
|
||||
|
param.put("channelNo", "1"); // 组编号 string
|
||||
|
String paramJson = JSONObject.toJSONString(param); |
||||
|
String result = HttpUtils.sendPostJson(url, paramJson, SyncService.haiKangToken); |
||||
|
JSONObject jsonObject = JSONObject.parseObject(result); |
||||
|
System.out.println(jsonObject); |
||||
|
} |
||||
|
|
||||
|
} |
@ -1,14 +1,10 @@ |
|||||
package com.yxt.supervise.monitor.biz.mapper; |
package com.yxt.supervise.monitor.biz.devicelog; |
||||
|
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
||||
import com.yxt.supervise.monitor.api.entity.Device; |
|
||||
import com.yxt.supervise.monitor.api.entity.DeviceLog; |
import com.yxt.supervise.monitor.api.entity.DeviceLog; |
||||
import org.apache.ibatis.annotations.Mapper; |
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
@Mapper |
@Mapper |
||||
public interface YDeviceLogMapper extends BaseMapper<DeviceLog> { |
public interface YDeviceLogMapper extends BaseMapper<DeviceLog> { |
||||
|
|
||||
|
|
||||
IPage<Device> getDevicePage(); |
|
||||
} |
} |
@ -0,0 +1,31 @@ |
|||||
|
package com.yxt.supervise.monitor.biz.devicelog; |
||||
|
|
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import com.yxt.supervise.monitor.api.vo.PageVo; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Api(tags = "设备日志控制器") |
||||
|
@RestController("com.yxt.supervise.monitor.biz.devicelog.YDeviceLogRest") |
||||
|
@RequestMapping("/deviceLog") |
||||
|
public class YDeviceLogRest { |
||||
|
|
||||
|
@Autowired |
||||
|
private YDeviceLogService yDeviceLogService; |
||||
|
|
||||
|
|
||||
|
@ApiOperation("分页获取设备日志列表") |
||||
|
@GetMapping("/getDeviceLogPage") |
||||
|
public ResultBean getDeviceLogPage(@RequestParam Map<String, String> searchVo, |
||||
|
@ModelAttribute PageVo pageVo) { |
||||
|
ResultBean rb = ResultBean.fireSuccess(); |
||||
|
rb.setData(yDeviceLogService.getDeviceLogPage(searchVo, pageVo)); |
||||
|
return rb; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,41 @@ |
|||||
|
package com.yxt.supervise.monitor.biz.devicelog; |
||||
|
|
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.yxt.supervise.monitor.api.entity.CallPolice; |
||||
|
import com.yxt.supervise.monitor.api.entity.DeviceLog; |
||||
|
import com.yxt.supervise.monitor.api.vo.PageVo; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Service |
||||
|
public class YDeviceLogService extends ServiceImpl<YDeviceLogMapper, DeviceLog> { |
||||
|
|
||||
|
public IPage<DeviceLog> getDeviceLogPage(Map<String, String> searchVo, PageVo pageVo) { |
||||
|
IPage<DeviceLog> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(); |
||||
|
page.setSize(pageVo.getSize()); |
||||
|
page.setCurrent((long) pageVo.getCurrent()); |
||||
|
|
||||
|
QueryWrapper<DeviceLog> queryWrapper = new QueryWrapper<>(); |
||||
|
|
||||
|
if (StrUtil.isNotBlank(searchVo.get("name"))) { |
||||
|
queryWrapper.like("name", searchVo.get("name")); |
||||
|
} |
||||
|
if (StrUtil.isNotBlank(searchVo.get("type"))) { |
||||
|
queryWrapper.eq("type", searchVo.get("type")); |
||||
|
} |
||||
|
queryWrapper.eq("isDelete", 0); |
||||
|
|
||||
|
IPage<DeviceLog> athleteBOIPage = null; |
||||
|
try { |
||||
|
athleteBOIPage = baseMapper.selectPage(page, queryWrapper); |
||||
|
} catch (Exception e) { |
||||
|
System.out.println(e); |
||||
|
athleteBOIPage = null; |
||||
|
} |
||||
|
return athleteBOIPage; |
||||
|
} |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package com.yxt.supervise.monitor.biz.messageInfo; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
||||
|
import com.yxt.supervise.monitor.api.entity.CallPolice; |
||||
|
import com.yxt.supervise.monitor.api.entity.Device; |
||||
|
import com.yxt.supervise.monitor.api.entity.MessageInfo; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.apache.ibatis.annotations.Param; |
||||
|
|
||||
|
@Mapper |
||||
|
public interface YMessageInfoMapper extends BaseMapper<MessageInfo> { |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,83 @@ |
|||||
|
package com.yxt.supervise.monitor.biz.messageInfo; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONArray; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import com.yxt.supervise.monitor.api.entity.CallPolice; |
||||
|
import com.yxt.supervise.monitor.api.entity.DeviceLog; |
||||
|
import com.yxt.supervise.monitor.api.entity.MessageInfo; |
||||
|
import com.yxt.supervise.monitor.api.vo.MessageVo; |
||||
|
import com.yxt.supervise.monitor.biz.callpolice.YCallPoliceMapper; |
||||
|
import com.yxt.supervise.monitor.biz.devicelog.YDeviceLogMapper; |
||||
|
import com.yxt.supervise.monitor.biz.scheduled.SyncService; |
||||
|
import com.yxt.supervise.monitor.biz.util.HttpUtils; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.util.Date; |
||||
|
import java.util.HashMap; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
@Service |
||||
|
public class YMessageInfoService extends ServiceImpl<YMessageInfoMapper, MessageInfo> { |
||||
|
|
||||
|
@Resource |
||||
|
YCallPoliceMapper yCallPoliceMapper; |
||||
|
|
||||
|
@Resource |
||||
|
YDeviceLogMapper yDeviceLogMapper; |
||||
|
|
||||
|
|
||||
|
public List<CallPolice> saveMessageInfo() { |
||||
|
String url = "https://api2.hik-cloud.com/api/v1/mq/consumer/messages"; |
||||
|
Map<String, Object> param = new HashMap<>(); |
||||
|
param.put("consumerId", SyncService.haiKangMessageConsumer); // 消费者id string
|
||||
|
String result = HttpUtils.sendPostMap(url, param, SyncService.haiKangToken); |
||||
|
JSONObject jsonObject = JSONObject.parseObject(result); |
||||
|
if ("200".equals(jsonObject.get("code").toString())) { |
||||
|
JSONArray jsonArray = (JSONArray) jsonObject.get("data"); |
||||
|
String jsonStr = jsonArray.toJSONString(); |
||||
|
List<MessageVo> messageList = JSONObject.parseArray(jsonStr, MessageVo.class); |
||||
|
for (MessageVo messageVo : messageList) { |
||||
|
QueryWrapper<MessageInfo> wrapper = new QueryWrapper<>(); |
||||
|
wrapper.eq("msgId", messageVo.getMsgId()); |
||||
|
int msgCount = this.count(wrapper); |
||||
|
if (msgCount < 1) { |
||||
|
// 先添加到消息表
|
||||
|
MessageInfo messageInfo = new MessageInfo(); |
||||
|
messageInfo.setMsgId(messageVo.getMsgId()); |
||||
|
messageInfo.setMsgType(messageVo.getMsgType()); |
||||
|
messageInfo.setContent(messageVo.getContent()); |
||||
|
messageInfo.setCreateTime(new Date()); |
||||
|
this.save(messageInfo); |
||||
|
|
||||
|
// 判断是日志信息,添加到日志表
|
||||
|
if ("open_device_onoffline".equals(messageVo.getMsgType()) // 设备上下线消息
|
||||
|
|| "open_device_drop".equals(messageVo.getMsgType()) // 设备坠落事件
|
||||
|
) { |
||||
|
DeviceLog deviceLog = new DeviceLog(); |
||||
|
deviceLog.setMsgId(messageVo.getMsgId()); |
||||
|
deviceLog.setContent(messageVo.getContent()); |
||||
|
deviceLog.setCreateTime(new Date()); |
||||
|
yDeviceLogMapper.insert(deviceLog); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// 判断是报警信息,添加到报警表
|
||||
|
if ("open_device_alarm".equals(messageVo.getMsgType())) { |
||||
|
// 判断是日志信息,添加到日志表
|
||||
|
CallPolice callPolice = new CallPolice(); |
||||
|
callPolice.setMsgId(messageVo.getMsgId()); |
||||
|
callPolice.setMsgType(messageVo.getMsgType()); |
||||
|
callPolice.setContent(messageVo.getContent()); |
||||
|
callPolice.setCreateTime(new Date()); |
||||
|
yCallPoliceMapper.insert(callPolice); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
return null; |
||||
|
} |
||||
|
} |
@ -1,18 +0,0 @@ |
|||||
package com.yxt.supervise.monitor.biz.service; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
|
||||
import com.yxt.supervise.monitor.api.entity.CallPolice; |
|
||||
import com.yxt.supervise.monitor.api.entity.Device; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
|
|
||||
import java.util.Map; |
|
||||
|
|
||||
@Service |
|
||||
public interface YCallPoliceService extends IService<CallPolice> { |
|
||||
|
|
||||
IPage<Device> getDevicePage(Map<String,String> searchVo); |
|
||||
|
|
||||
|
|
||||
String createDevice(Device device); |
|
||||
} |
|
@ -1,18 +0,0 @@ |
|||||
package com.yxt.supervise.monitor.biz.service; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
|
||||
import com.yxt.supervise.monitor.api.entity.Device; |
|
||||
import com.yxt.supervise.monitor.api.entity.DeviceLog; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
|
|
||||
import java.util.Map; |
|
||||
|
|
||||
@Service |
|
||||
public interface YDeviceLogService extends IService<DeviceLog> { |
|
||||
|
|
||||
IPage<Device> getDevicePage(Map<String,String> searchVo); |
|
||||
|
|
||||
|
|
||||
String createDevice(Device device); |
|
||||
} |
|
@ -1,25 +0,0 @@ |
|||||
package com.yxt.supervise.monitor.biz.service; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
||||
import com.baomidou.mybatisplus.extension.service.IService; |
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
||||
import com.yxt.common.core.result.ResultBean; |
|
||||
import com.yxt.supervise.monitor.api.demoidentity.DemoIdentity; |
|
||||
import com.yxt.supervise.monitor.api.entity.Device; |
|
||||
import com.yxt.supervise.monitor.api.vo.PageVo; |
|
||||
import com.yxt.supervise.monitor.biz.demoidentity.DemoIdentityMapper; |
|
||||
import com.yxt.supervise.monitor.biz.mapper.YDeviceMapper; |
|
||||
import com.yxt.supervise.monitor.biz.service.impl.IYDeviceServiceImpl; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
|
|
||||
import java.util.Map; |
|
||||
|
|
||||
@Service |
|
||||
public interface YDeviceService extends IService<Device> { |
|
||||
|
|
||||
IPage<Device> getDevicePage(Map<String, String> searchVo, PageVo pageVo); |
|
||||
|
|
||||
ResultBean createDevice(Device device); |
|
||||
|
|
||||
ResultBean createDeviceGroup(Device device); |
|
||||
} |
|
@ -1,31 +0,0 @@ |
|||||
package com.yxt.supervise.monitor.biz.service.impl; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
||||
import com.yxt.supervise.monitor.api.entity.CallPolice; |
|
||||
import com.yxt.supervise.monitor.api.entity.Device; |
|
||||
import com.yxt.supervise.monitor.biz.mapper.YCallPoliceMapper; |
|
||||
import com.yxt.supervise.monitor.biz.mapper.YDeviceMapper; |
|
||||
import com.yxt.supervise.monitor.biz.service.YCallPoliceService; |
|
||||
import com.yxt.supervise.monitor.biz.service.YDeviceService; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
|
|
||||
import javax.annotation.Resource; |
|
||||
import java.util.Map; |
|
||||
|
|
||||
@Service |
|
||||
public class IYCallPoliceServiceImpl extends ServiceImpl<YCallPoliceMapper, CallPolice> implements YCallPoliceService { |
|
||||
|
|
||||
@Resource YDeviceMapper yDeviceMapper; |
|
||||
|
|
||||
|
|
||||
@Override |
|
||||
public IPage<Device> getDevicePage(Map<String,String> searchVo){ |
|
||||
return yDeviceMapper.getDevicePage(); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public String createDevice(Device device){ |
|
||||
return null; |
|
||||
} |
|
||||
} |
|
@ -1,31 +0,0 @@ |
|||||
package com.yxt.supervise.monitor.biz.service.impl; |
|
||||
|
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
||||
import com.yxt.supervise.monitor.api.entity.Device; |
|
||||
import com.yxt.supervise.monitor.api.entity.DeviceLog; |
|
||||
import com.yxt.supervise.monitor.biz.mapper.YDeviceLogMapper; |
|
||||
import com.yxt.supervise.monitor.biz.mapper.YDeviceMapper; |
|
||||
import com.yxt.supervise.monitor.biz.service.YDeviceLogService; |
|
||||
import com.yxt.supervise.monitor.biz.service.YDeviceService; |
|
||||
import org.springframework.stereotype.Service; |
|
||||
|
|
||||
import javax.annotation.Resource; |
|
||||
import java.util.Map; |
|
||||
|
|
||||
@Service |
|
||||
public class IYDeviceLogServiceImpl extends ServiceImpl<YDeviceLogMapper, DeviceLog> implements YDeviceLogService { |
|
||||
|
|
||||
@Resource YDeviceMapper yDeviceMapper; |
|
||||
|
|
||||
|
|
||||
@Override |
|
||||
public IPage<Device> getDevicePage(Map<String,String> searchVo){ |
|
||||
return yDeviceMapper.getDevicePage(); |
|
||||
} |
|
||||
|
|
||||
@Override |
|
||||
public String createDevice(Device device){ |
|
||||
return null; |
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue