Commit f27cbb44 authored by 王晓倩's avatar 王晓倩

大屏预警信息列表接口,泽宏云数据同步接口

parent e70a2511
package com.zehong.web.controller.supervise;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.core.page.TableDataInfo;
import com.zehong.common.enums.BusinessType;
import com.zehong.common.enums.ResultEnum;
import com.zehong.common.exception.IOCException;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.system.domain.TDetectorInfo;
import com.zehong.system.domain.vo.TDetectorAlarmInfoVO;
import com.zehong.system.service.ITDetectorInfoService;
import com.zehong.system.service.ITDetectorReportDataService;
import com.zehong.system.service.ITDetectorUserService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 探测器Controller
*
* @author zehong
* @date 2021-11-02
*/
@RestController
@RequestMapping("/detector/detectorInfo")
@Slf4j
public class TDetectorInfoController extends BaseController
{
@Autowired
private ITDetectorInfoService tDetectorInfoService;
@Autowired
private ITDetectorUserService tDetectorUserService;
@Autowired
private ITDetectorReportDataService tDetectorReportDataService;
/**
* 查询探测器列表
*/
@GetMapping("/list")
public TableDataInfo list(TDetectorInfo tDetectorInfo)
{
startPage();
List<TDetectorInfo> list = tDetectorInfoService.selectTDetectorInfoList(tDetectorInfo);
return getDataTable(list);
}
/**
* 获取探测器列表
* @param tDetectorInfo
* @return
*/
@GetMapping("/detectorInfoList")
public AjaxResult detectorInfoList(TDetectorInfo tDetectorInfo){
return AjaxResult.success(tDetectorInfoService.selectTDetectorInfoList(tDetectorInfo));
}
/**
* 导出探测器列表
*/
@Log(title = "探测器", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TDetectorInfo tDetectorInfo)
{
List<TDetectorInfo> list = tDetectorInfoService.selectTDetectorInfoList(tDetectorInfo);
ExcelUtil<TDetectorInfo> util = new ExcelUtil<TDetectorInfo>(TDetectorInfo.class);
return util.exportExcel(list, "探测器数据");
}
/**
* 获取探测器详细信息
*/
@GetMapping(value = "/{detectorId}")
public AjaxResult getInfo(@PathVariable("detectorId") Long detectorId)
{
return AjaxResult.success(tDetectorInfoService.selectTDetectorInfoById(detectorId));
}
/**
* 新增探测器
*/
@Log(title = "探测器", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TDetectorInfo tDetectorInfo)
{
return toAjax(tDetectorInfoService.insertTDetectorInfo(tDetectorInfo));
}
/**
* 修改探测器
*/
@Log(title = "探测器", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TDetectorInfo tDetectorInfo)
{
return toAjax(tDetectorInfoService.updateTDetectorInfo(tDetectorInfo));
}
/**
* 删除探测器
*/
@Log(title = "探测器", businessType = BusinessType.DELETE)
@DeleteMapping("/{detectorIds}")
public AjaxResult remove(@PathVariable Long[] detectorIds)
{
return toAjax(tDetectorInfoService.deleteTDetectorInfoByIds(detectorIds));
}
@ApiOperation(value = "大屏数据初始化时主动查询的感知设备报警信息前50条")
@GetMapping("/getAlarmData")
public AjaxResult getAlarmData(){
ModelMap map = new ModelMap();
try {
TDetectorInfo detector = new TDetectorInfo();
detector.setIsDel("0");
detector.setDetectorStatus("0");
List<TDetectorInfo> onlineList = tDetectorInfoService.selectTDetectorInfoList(detector);
int onlineNum = onlineList.size();
detector.setDetectorStatus("1");
List<TDetectorInfo> offlineList = tDetectorInfoService.selectTDetectorInfoList(detector);
int offlineNum = offlineList.size();
detector.setDetectorStatus("2");
List<TDetectorInfo> alarmList = tDetectorInfoService.selectTDetectorInfoList(detector);
int alarmNum = alarmList.size();
List<TDetectorAlarmInfoVO> alarmVO = tDetectorReportDataService.selectTDetectorAlarm();
for(TDetectorAlarmInfoVO alarm : alarmVO){
if("1".equals(alarm.getDetectorType())){
alarm.setDetectorType("家用探测器");
} else if ("2".equals(alarm.getDetectorType())){
alarm.setDetectorType("工业探测器");
}
}
map.put("alarmNum", alarmNum);
map.put("onlineNum", onlineNum);
map.put("offlineNum", offlineNum);
map.put("pageData", alarmVO);
} catch (Exception ie){
ie.printStackTrace();
log.error("【查询报警数据】操作出错,error={}",ie.getMessage());
throw new IOCException(ResultEnum.OPERATION_FAIL.getCode(), "查询报警数据操作出错");
}
return AjaxResult.success(map);
}
}
......@@ -118,6 +118,10 @@
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
</dependencies>
......
package com.zehong.common.enums;
import lombok.Getter;
@Getter
public enum ResultEnum {
SUCCESS(0,"成功"),
PARAM_ERROR(10000,"参数不正确"),
NOT_EXIST(20000,"记录不存在"),
ACCOUNT_EXIST(20001,"帐号已存在"),
LOGIN_FAIL(30000,"登录失败"),
ACCOUNT_NO(30001,"账号不存在"),
ACCOUNT_PWD_ERROR(30002,"登录失败,账号或密码错误"),
ACCOUNT_LOCKED(30003,"账号冻结"),
LOGOUT_FAIL(30004,"登出失败"),
AUTH_FAIL(30005,"认证失败"),
AUTH_INFO_ERROR(30006,"认证信息异常"),
ERROR_PERMISSION(30007,"权限不足"),
ERROR_JWT(30008,"凭证认证失败"),
EXPIRED_JWT(30009,"失效的jwtToken"),
ACCOUNT_PWD_EMPTY(30010,"登录失败,帐号或密码不能为空"),
ACCOUNT_OLD_PWD_ERROR(30011,"旧密码错误"),
OPERATION_FAIL(4000,"操作失败"),
INDICATOR_CREATE_FAIL(4001,"新增失败,最多添加3个引领性指标!"),
ORG_CREATE_FAIL(4002,"新增失败,该主管在该时间段内已存在至关重要指标!"),
REQUEST_METHOD_SUPPORT_ERROR(4003,"当前请求方法不支持"),
MEETING_CREATE_FAIL(4004,"本周已填写至关重要目标会议!"),
SERVER_FAIL(5000,"服务器开小差了~~"),
INTERNAL_SERVER_ERROR(5001, "服务器内部错误!"),
SERVER_BUSY(5002, "服务器正忙,请稍后再试!"),
ENTERPRISE_EXIST(6000, "企业机构代码已注册!"),
ENTERPRISE_NOEXIST(6001, "企业机构代码不存在!"),
DETECTOR_NOEXIST(7000, "探测器编号不存在!")
;
private Integer code;
private String message;
ResultEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
}
package com.zehong.common.exception;
import com.zehong.common.enums.ResultEnum;
import lombok.Getter;
@Getter
public class IOCException extends RuntimeException {
private static final long serialVersionUID = 7272332822781740888L;
private Integer code;
public IOCException(ResultEnum resultEnum){
super(resultEnum.getMessage());
this.code = resultEnum.getCode();
}
public IOCException(Integer code, String message){
super(message);
this.code = code;
}
}
package com.zehong.system.domain;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
import java.math.BigDecimal;
import java.util.Date;
/**
* 探测器对象 t_detector_info
*
* @author zehong
* @date 2021-11-02
*/
public class TDetectorInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 设备id */
private Long detectorId;
/** 企业id */
private Integer enterpriseId;
/** 用户id */
@Excel(name = "用户id")
private Long userId;
/** 设备名称 */
@Excel(name = "设备名称")
private String detectorName;
/** 设备编号 */
@Excel(name = "设备编号")
private String detectorCode;
/** 设备地址 */
@Excel(name = "设备地址")
private String detectorAddr;
/** 设备类型(1家用报警器,2工业报警器) */
@Excel(name = "设备类型", readConverterExp = "1家用报警器,2工业报警器")
private String detectorType;
/** 检测介质(1甲烷,2氨气,3一氧化碳,4可燃气体,5有毒气体) */
@Excel(name = "检测介质", readConverterExp = "1甲烷,2氨气,3一氧化碳,4可燃气体,5有毒气体")
private String medium;
/** 经度 */
@Excel(name = "经度")
private BigDecimal longitude;
/** 纬度 */
@Excel(name = "纬度")
private BigDecimal latitude;
/** 物联网编号 */
@Excel(name = "物联网编号")
private String iotNo;
/** 联系人 */
@Excel(name = "联系人")
private String linkman;
/** 电话 */
@Excel(name = "电话")
private String phone;
/** 创建时间 */
private Date creatTime;
/** 报警时间 */
private String alarmTime;
/** 设备状态(0正常,1离线,2报警) */
@Excel(name = "设备状态")
private String detectorStatus;
/** 是否删除(0正常,1删除) */
@Excel(name = "是否删除(0正常,1删除)")
private String isDel;
/** 备注 */
@Excel(name = "备注")
private String remarks;
public void setDetectorId(Long detectorId)
{
this.detectorId = detectorId;
}
public Long getDetectorId()
{
return detectorId;
}
public Integer getEnterpriseId() {
return enterpriseId;
}
public void setEnterpriseId(Integer enterpriseId) {
this.enterpriseId = enterpriseId;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setDetectorName(String detectorName)
{
this.detectorName = detectorName;
}
public String getDetectorName()
{
return detectorName;
}
public void setDetectorCode(String detectorCode)
{
this.detectorCode = detectorCode;
}
public String getDetectorCode()
{
return detectorCode;
}
public void setDetectorAddr(String detectorAddr)
{
this.detectorAddr = detectorAddr;
}
public String getDetectorAddr()
{
return detectorAddr;
}
public void setDetectorType(String detectorType)
{
this.detectorType = detectorType;
}
public String getDetectorType()
{
return detectorType;
}
public void setMedium(String medium)
{
this.medium = medium;
}
public String getMedium()
{
return medium;
}
public void setLongitude(BigDecimal longitude)
{
this.longitude = longitude;
}
public BigDecimal getLongitude()
{
return longitude;
}
public void setLatitude(BigDecimal latitude)
{
this.latitude = latitude;
}
public BigDecimal getLatitude()
{
return latitude;
}
public void setIotNo(String iotNo)
{
this.iotNo = iotNo;
}
public String getIotNo()
{
return iotNo;
}
public void setLinkman(String linkman)
{
this.linkman = linkman;
}
public String getLinkman()
{
return linkman;
}
public void setPhone(String phone)
{
this.phone = phone;
}
public String getPhone()
{
return phone;
}
public Date getCreatTime() {
return creatTime;
}
public void setCreatTime(Date creatTime) {
this.creatTime = creatTime;
}
public String getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(String alarmTime) {
this.alarmTime = alarmTime;
}
public void setIsDel(String isDel)
{
this.isDel = isDel;
}
public String getIsDel()
{
return isDel;
}
public String getDetectorStatus() {
return detectorStatus;
}
public void setDetectorStatus(String detectorStatus) {
this.detectorStatus = detectorStatus;
}
public void setRemarks(String remarks)
{
this.remarks = remarks;
}
public String getRemarks()
{
return remarks;
}
}
package com.zehong.system.domain;
import java.io.Serializable;
import java.util.Date;
public class TDetectorReportData implements Serializable {
private Integer id;
private String sourceId;
private String detectorCode;
private String detectorStatusId;
private String statusName;
private Float reportValue;
private Integer zhHostStatusId;
private Integer netPoint;
private Integer signalStrength;
private String ipAddress;
private Date createTime;
// 是否销警,默认0, 1自动销警,2手动销警
private String isCancelAlarm;
private Date cancelTime;
private static final long serialVersionUID = 1L;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getSourceId() {
return sourceId;
}
public void setSourceId(String sourceId) {
this.sourceId = sourceId == null ? null : sourceId.trim();
}
public String getDetectorCode() {
return detectorCode;
}
public void setDetectorCode(String detectorCode) {
this.detectorCode = detectorCode;
}
public String getDetectorStatusId() {
return detectorStatusId;
}
public void setDetectorStatusId(String detectorStatusId) {
this.detectorStatusId = detectorStatusId;
}
public String getStatusName() {
return statusName;
}
public void setStatusName(String statusName) {
this.statusName = statusName;
}
public Float getReportValue() {
return reportValue;
}
public void setReportValue(Float reportValue) {
this.reportValue = reportValue;
}
public Integer getZhHostStatusId() {
return zhHostStatusId;
}
public void setZhHostStatusId(Integer zhHostStatusId) {
this.zhHostStatusId = zhHostStatusId;
}
public Integer getNetPoint() {
return netPoint;
}
public void setNetPoint(Integer netPoint) {
this.netPoint = netPoint;
}
public Integer getSignalStrength() {
return signalStrength;
}
public void setSignalStrength(Integer signalStrength) {
this.signalStrength = signalStrength;
}
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress == null ? null : ipAddress.trim();
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getIsCancelAlarm() {
return isCancelAlarm;
}
public void setIsCancelAlarm(String isCancelAlarm) {
this.isCancelAlarm = isCancelAlarm == null ? null : isCancelAlarm.trim();
}
public Date getCancelTime() {
return cancelTime;
}
public void setCancelTime(Date cancelTime) {
this.cancelTime = cancelTime;
}
}
\ No newline at end of file
package com.zehong.system.domain.dto;
import lombok.Data;
@Data
public class TDetectorInfoDTO {
private String deviceType; // 1探测器、2安全用电设备
private String deviceCode;
//探测器 推送数据(1正常,7、9离线,其他值预警) 用电推送数据(E正常,0正常,1故障,2预警)
private String deviceStatus;
private String alarmTime;
}
package com.zehong.system.domain.form;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@Data
public class TDetectorReportDataForm {
//数据上报原始ID必填 正常数据为用户名,报警数据为用户名+主键id
@NotEmpty(message="数据上报原始ID必填")
private String sourceId;
@NotEmpty(message="设备编号必填")
private String deviceNo;
//报警设备类型,1探测器,2智慧用电
private String deviceType;
//探测器 推送数据(1正常,7、9离线,其他值预警)
private String deviceStatusId;
//状态名称
private String statusName;
private String reportValue;
private String zhHostStatusId;
private String netPoint;
private String signalStrength;
private String ipAddress;
//创建时间
@NotEmpty(message="上报时间必填")
private String createTime;
}
package com.zehong.system.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
* 推送的报警数据信息
* @author zhangzhizhong
*
*/
public class TDetectorAlarmInfoVO {
// 设备编号
private String detectorCode;
// 监测单位
private String unitName;
// 设备类型
private String detectorType;
// 预警类型
private String statusName;
// 预警时间
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date alarmTime;
// 处理状态
private String handledStatus;
public String getDetectorCode() {
return detectorCode;
}
public void setDetectorCode(String detectorCode) {
this.detectorCode = detectorCode;
}
public String getUnitName() {
return unitName;
}
public void setUnitName(String unitName) {
this.unitName = unitName;
}
public String getDetectorType() {
return detectorType;
}
public void setDetectorType(String detectorType) {
this.detectorType = detectorType;
}
public String getStatusName() {
return statusName;
}
public void setStatusName(String statusName) {
this.statusName = statusName;
}
public Date getAlarmTime() {
return alarmTime;
}
public void setAlarmTime(Date alarmTime) {
this.alarmTime = alarmTime;
}
public String getHandledStatus() {
return handledStatus;
}
public void setHandledStatus(String handledStatus) {
this.handledStatus = handledStatus;
}
}
package com.zehong.system.domain.vo;
import lombok.Data;
import java.math.BigDecimal;
/**
* 探测器用户对象 t_detector_user
*
* @author zehong
* @date 2021-11-02
*/
@Data
public class TDetectorUserVO
{
private static final long serialVersionUID = 1L;
/** 用户id */
private Long userId;
/** 用户账号 */
private String username;
/** 用户名称 */
private String nickName;
/** 用户类型(1居民用户,2商业用户,3工业用户) */
private String userType;
/** 探测器总数 */
private Integer detectorCount;
/** 在线数量 */
private Integer onLineNum;
/** 离线数量 */
private Integer offLineNum;
/** 历史报警数 */
private Integer historyAlarmNum;
/** 已处理报警 */
private Integer cancelAlarmNum;
/** 报警中 */
private Integer processingAlarmNum;
/** 地址 */
private String address;
/** 经度 */
private BigDecimal longitude;
/** 纬度 */
private BigDecimal latitude;
/** 联系人 */
private String linkman;
/** 电话 */
private String phone;
/** 邮箱 */
private String email;
/** 是否删除(0正常,1删除) */
private String isDel;
/** 备注 */
private String remarks;
}
package com.zehong.system.mapper;
import com.zehong.system.domain.TDetectorInfo;
import java.util.List;
/**
* 探测器Mapper接口
*
* @author zehong
* @date 2021-11-02
*/
public interface TDetectorInfoMapper
{
/**
* 查询探测器
*
* @param detectorId 探测器ID
* @return 探测器
*/
public TDetectorInfo selectTDetectorInfoById(Long detectorId);
/**
* 查询探测器
*
* @param detectorCode 探测器编号
* @return 探测器
*/
public TDetectorInfo selectTDetectorInfoByCode(String detectorCode);
/**
* 查询探测器列表
*
* @param tDetectorInfo 探测器
* @return 探测器集合
*/
public List<TDetectorInfo> selectTDetectorInfoList(TDetectorInfo tDetectorInfo);
/**
* 新增探测器
*
* @param tDetectorInfo 探测器
* @return 结果
*/
public int insertTDetectorInfo(TDetectorInfo tDetectorInfo);
public int insertBatch(List<TDetectorInfo> detectorList);
public int updateBatch(List<TDetectorInfo> detectorList);
/**
* 修改探测器
*
* @param tDetectorInfo 探测器
* @return 结果
*/
public int updateTDetectorInfo(TDetectorInfo tDetectorInfo);
/**
* 删除探测器
*
* @param detectorId 探测器ID
* @return 结果
*/
public int deleteTDetectorInfoById(Long detectorId);
/**
* 批量删除探测器
*
* @param detectorIds 需要删除的数据ID
* @return 结果
*/
public int deleteTDetectorInfoByIds(Long[] detectorIds);
}
package com.zehong.system.mapper;
import com.zehong.system.domain.TDetectorInfo;
import com.zehong.system.domain.TDetectorReportData;
import com.zehong.system.domain.vo.TDetectorAlarmInfoVO;
import java.util.List;
/**
* 设备上报的数据Mapper接口
*
* @author zehong
* @date 2021-11-08
*/
public interface TDetectorReportDataMapper
{
/**
* 查询设备上报的数据
*
* @param id 设备上报的数据ID
* @return 设备上报的数据
*/
public TDetectorReportData selectTDetectorReportDataById(Long id);
public List<TDetectorReportData> selectTDetectorReportDataByCode(String detectorCode);
public List<TDetectorReportData> countDetectorByUserId(TDetectorInfo tDetectorInfo);
public List<TDetectorAlarmInfoVO> selectTDetectorAlarm();
public List<TDetectorReportData> selectRealtimeDataList();
/**
* 查询设备上报的数据列表
*
* @param tDetectorReportData 设备上报的数据
* @return 设备上报的数据集合
*/
public List<TDetectorReportData> selectTDetectorReportDataList(TDetectorReportData tDetectorReportData);
/**
* 新增设备上报的数据
*
* @param tDetectorReportData 设备上报的数据
* @return 结果
*/
public int insertTDetectorReportData(TDetectorReportData tDetectorReportData);
/**
* 修改设备上报的数据
*
* @param tDetectorReportData 设备上报的数据
* @return 结果
*/
public int updateTDetectorReportData(TDetectorReportData tDetectorReportData);
/**
* 删除设备上报的数据
*
* @param id 设备上报的数据ID
* @return 结果
*/
public int deleteTDetectorReportDataById(Long id);
/**
* 批量删除设备上报的数据
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteTDetectorReportDataByIds(Long[] ids);
}
package com.zehong.system.service;
import com.github.pagehelper.PageInfo;
import com.zehong.system.domain.TDetectorInfo;
import java.util.List;
/**
* 探测器Service接口
*
* @author zehong
* @date 2021-11-02
*/
public interface ITDetectorInfoService
{
/**
* 查询探测器
*
* @param detectorId 探测器ID
* @return 探测器
*/
public TDetectorInfo selectTDetectorInfoById(Long detectorId);
/**
* 查询探测器
*
* @param detectorCode 探测器编号
* @return 探测器
*/
public TDetectorInfo selectTDetectorInfoByCode(String detectorCode);
/**
* 查询探测器列表
*
* @param tDetectorInfo 探测器
* @return 探测器集合
*/
public List<TDetectorInfo> selectTDetectorInfoList(TDetectorInfo tDetectorInfo);
/**
* 查询探测器分页列表
*
* @param tDetectorInfo 探测器
* @return 探测器分页集合
*/
public PageInfo<TDetectorInfo> selectTDetectorInfoPage(TDetectorInfo tDetectorInfo);
/**
* 新增探测器
*
* @param tDetectorInfo 探测器
* @return 结果
*/
public int insertTDetectorInfo(TDetectorInfo tDetectorInfo);
public int insertBatch(List<TDetectorInfo> detectorList);
public int updateBatch(List<TDetectorInfo> detectorList);
/**
* 修改探测器
*
* @param tDetectorInfo 探测器
* @return 结果
*/
public int updateTDetectorInfo(TDetectorInfo tDetectorInfo);
/**
* 批量删除探测器
*
* @param detectorIds 需要删除的探测器ID
* @return 结果
*/
public int deleteTDetectorInfoByIds(Long[] detectorIds);
/**
* 删除探测器信息
*
* @param detectorId 探测器ID
* @return 结果
*/
public int deleteTDetectorInfoById(Long detectorId);
}
package com.zehong.system.service;
import com.github.pagehelper.PageInfo;
import com.zehong.system.domain.TDetectorInfo;
import com.zehong.system.domain.TDetectorReportData;
import com.zehong.system.domain.vo.TDetectorAlarmInfoVO;
import java.util.List;
/**
* 设备上报的数据Service接口
*
* @author zehong
* @date 2021-11-08
*/
public interface ITDetectorReportDataService
{
/**
* 查询设备上报的数据
*
* @param id 设备上报的数据ID
* @return 设备上报的数据
*/
public TDetectorReportData selectTDetectorReportDataById(Long id);
public List<TDetectorReportData> selectTDetectorReportDataByCode(String detectorCode);
public List<TDetectorReportData> selectRealtimeDataList();
public List<TDetectorAlarmInfoVO> selectTDetectorAlarm();
public List<TDetectorReportData> countDetectorByUserId(TDetectorInfo tDetectorInfo);
/**
* 查询设备上报的数据列表
*
* @param tDetectorReportData 设备上报的数据
* @return 设备上报的数据集合
*/
public List<TDetectorReportData> selectTDetectorReportDataList(TDetectorReportData tDetectorReportData);
/**
* 查询设备上报的数据分页列表
*
* @param tDetectorReportData 设备上报的数据
* @return 设备上报的数据分页集合
*/
public PageInfo<TDetectorReportData> selectTDetectorReportDataPage(TDetectorReportData tDetectorReportData);
/**
* 新增设备上报的数据
*
* @param tDetectorReportData 设备上报的数据
* @return 结果
*/
public int insertTDetectorReportData(TDetectorReportData tDetectorReportData);
/**
* 修改设备上报的数据
*
* @param tDetectorReportData 设备上报的数据
* @return 结果
*/
public int updateTDetectorReportData(TDetectorReportData tDetectorReportData);
/**
* 批量删除设备上报的数据
*
* @param ids 需要删除的设备上报的数据ID
* @return 结果
*/
public int deleteTDetectorReportDataByIds(Long[] ids);
/**
* 删除设备上报的数据信息
*
* @param id 设备上报的数据ID
* @return 结果
*/
public int deleteTDetectorReportDataById(Long id);
}
......@@ -2,6 +2,7 @@ package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.TDetectorUser;
import com.zehong.system.domain.vo.TDetectorUserVO;
/**
* 燃气用户Service接口
......@@ -11,6 +12,15 @@ import com.zehong.system.domain.TDetectorUser;
*/
public interface ITDetectorUserService
{
/**
* 查询探测器用户列表
*
* @param tDetectorUser 探测器用户
* @return 探测器用户集合
*/
public List<TDetectorUserVO> detectorUserList(TDetectorUser tDetectorUser);
/**
* 查询燃气用户
*
......
package com.zehong.system.service.impl;
import com.github.pagehelper.PageInfo;
import com.zehong.system.domain.TDetectorInfo;
import com.zehong.system.mapper.TDetectorInfoMapper;
import com.zehong.system.service.ITDetectorInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 探测器Service业务层处理
*
* @author zehong
* @date 2021-11-02
*/
@Service
public class TDetectorInfoServiceImpl implements ITDetectorInfoService
{
@Autowired
private TDetectorInfoMapper tDetectorInfoMapper;
/**
* 查询探测器
*
* @param detectorId 探测器ID
* @return 探测器
*/
@Override
public TDetectorInfo selectTDetectorInfoById(Long detectorId)
{
return tDetectorInfoMapper.selectTDetectorInfoById(detectorId);
}
/**
* 查询探测器
*
* @param detectorCode 探测器编号
* @return 探测器
*/
public TDetectorInfo selectTDetectorInfoByCode(String detectorCode) {
return tDetectorInfoMapper.selectTDetectorInfoByCode(detectorCode);
}
/**
* 查询探测器列表
*
* @param tDetectorInfo 探测器
* @return 探测器
*/
@Override
public List<TDetectorInfo> selectTDetectorInfoList(TDetectorInfo tDetectorInfo)
{
List<TDetectorInfo> list = tDetectorInfoMapper.selectTDetectorInfoList(tDetectorInfo);
for(TDetectorInfo detector : list){
if("0".equals(detector.getDetectorStatus())){
detector.setDetectorStatus("正常");
} else {
detector.setDetectorStatus("离线");
}
}
return list;
}
/**
* 查询探测器分页列表
*
* @param tDetectorInfo 探测器
* @return 探测器
*/
@Override
public PageInfo<TDetectorInfo> selectTDetectorInfoPage(TDetectorInfo tDetectorInfo)
{
List<TDetectorInfo> list = tDetectorInfoMapper.selectTDetectorInfoList(tDetectorInfo);
for(TDetectorInfo detector : list){
if("0".equals(detector.getDetectorStatus())){
detector.setDetectorStatus("正常");
} else {
detector.setDetectorStatus("离线");
}
}
return new PageInfo(list);
}
/**
* 新增探测器
*
* @param tDetectorInfo 探测器
* @return 结果
*/
@Override
public int insertTDetectorInfo(TDetectorInfo tDetectorInfo)
{
return tDetectorInfoMapper.insertTDetectorInfo(tDetectorInfo);
}
@Override
public int insertBatch(List<TDetectorInfo> detectorList) {
// TODO Auto-generated method stub
return tDetectorInfoMapper.insertBatch(detectorList);
}
@Override
public int updateBatch(List<TDetectorInfo> detectorList) {
// TODO Auto-generated method stub
return tDetectorInfoMapper.updateBatch(detectorList);
}
/**
* 修改探测器
*
* @param tDetectorInfo 探测器
* @return 结果
*/
@Override
public int updateTDetectorInfo(TDetectorInfo tDetectorInfo)
{
return tDetectorInfoMapper.updateTDetectorInfo(tDetectorInfo);
}
/**
* 批量删除探测器
*
* @param detectorIds 需要删除的探测器ID
* @return 结果
*/
@Override
public int deleteTDetectorInfoByIds(Long[] detectorIds)
{
return tDetectorInfoMapper.deleteTDetectorInfoByIds(detectorIds);
}
/**
* 删除探测器信息
*
* @param detectorId 探测器ID
* @return 结果
*/
@Override
public int deleteTDetectorInfoById(Long detectorId)
{
return tDetectorInfoMapper.deleteTDetectorInfoById(detectorId);
}
}
package com.zehong.system.service.impl;
import com.github.pagehelper.PageInfo;
import com.zehong.common.utils.DateUtils;
import com.zehong.system.domain.TDetectorInfo;
import com.zehong.system.domain.TDetectorReportData;
import com.zehong.system.domain.vo.TDetectorAlarmInfoVO;
import com.zehong.system.mapper.TDetectorReportDataMapper;
import com.zehong.system.service.ITDetectorReportDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 设备上报的数据Service业务层处理
*
* @author zehong
* @date 2021-11-08
*/
@Service
public class TDetectorReportDataServiceImpl implements ITDetectorReportDataService
{
@Autowired
private TDetectorReportDataMapper tDetectorReportDataMapper;
/**
* 查询设备上报的数据
*
* @param id 设备上报的数据ID
* @return 设备上报的数据
*/
@Override
public TDetectorReportData selectTDetectorReportDataById(Long id)
{
return tDetectorReportDataMapper.selectTDetectorReportDataById(id);
}
@Override
public List<TDetectorReportData> selectTDetectorReportDataByCode(String detectorCode)
{
return tDetectorReportDataMapper.selectTDetectorReportDataByCode(detectorCode);
}
@Override
public List<TDetectorAlarmInfoVO> selectTDetectorAlarm()
{
return tDetectorReportDataMapper.selectTDetectorAlarm();
}
@Override
public List<TDetectorReportData> selectRealtimeDataList()
{
return tDetectorReportDataMapper.selectRealtimeDataList();
}
@Override
public List<TDetectorReportData> countDetectorByUserId(TDetectorInfo tDetectorInfo){
return tDetectorReportDataMapper.countDetectorByUserId(tDetectorInfo);
}
/**
* 查询设备上报的数据列表
*
* @param tDetectorReportData 设备上报的数据
* @return 设备上报的数据
*/
@Override
public List<TDetectorReportData> selectTDetectorReportDataList(TDetectorReportData tDetectorReportData)
{
return tDetectorReportDataMapper.selectTDetectorReportDataList(tDetectorReportData);
}
/**
* 查询设备上报的数据分页列表
*
* @param tDetectorReportData 设备上报的数据
* @return 设备上报的数据
*/
@Override
public PageInfo<TDetectorReportData> selectTDetectorReportDataPage(TDetectorReportData tDetectorReportData)
{
return new PageInfo(tDetectorReportDataMapper.selectTDetectorReportDataList(tDetectorReportData));
}
/**
* 新增设备上报的数据
*
* @param tDetectorReportData 设备上报的数据
* @return 结果
*/
@Override
public int insertTDetectorReportData(TDetectorReportData tDetectorReportData)
{
tDetectorReportData.setCreateTime(DateUtils.getNowDate());
return tDetectorReportDataMapper.insertTDetectorReportData(tDetectorReportData);
}
/**
* 修改设备上报的数据
*
* @param tDetectorReportData 设备上报的数据
* @return 结果
*/
@Override
public int updateTDetectorReportData(TDetectorReportData tDetectorReportData)
{
return tDetectorReportDataMapper.updateTDetectorReportData(tDetectorReportData);
}
/**
* 批量删除设备上报的数据
*
* @param ids 需要删除的设备上报的数据ID
* @return 结果
*/
@Override
public int deleteTDetectorReportDataByIds(Long[] ids)
{
return tDetectorReportDataMapper.deleteTDetectorReportDataByIds(ids);
}
/**
* 删除设备上报的数据信息
*
* @param id 设备上报的数据ID
* @return 结果
*/
@Override
public int deleteTDetectorReportDataById(Long id)
{
return tDetectorReportDataMapper.deleteTDetectorReportDataById(id);
}
}
package com.zehong.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.zehong.system.domain.TDetectorInfo;
import com.zehong.system.domain.TDetectorReportData;
import com.zehong.system.domain.vo.TDetectorUserVO;
import com.zehong.system.mapper.TDetectorInfoMapper;
import com.zehong.system.mapper.TDetectorReportDataMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TDetectorUserMapper;
import com.zehong.system.domain.TDetectorUser;
import com.zehong.system.service.ITDetectorUserService;
import org.springframework.util.StringUtils;
/**
* 燃气用户Service业务层处理
......@@ -18,6 +27,69 @@ public class TDetectorUserServiceImpl implements ITDetectorUserService
{
@Autowired
private TDetectorUserMapper tDetectorUserMapper;
@Autowired
private TDetectorInfoMapper tDetectorInfoMapper;
@Autowired
private TDetectorReportDataMapper tDetectorReportDataMapper;
/**
* 查询探测器用户列表
*
* @param tDetectorUser 探测器用户
* @return 探测器用户
*/
@Override
public List<TDetectorUserVO> detectorUserList(TDetectorUser tDetectorUser)
{
List<TDetectorUserVO> list = new ArrayList<>();
List<TDetectorUser> tDetectorUserList = tDetectorUserMapper.selectTDetectorUserList(tDetectorUser);
TDetectorInfo detector = new TDetectorInfo();
for(TDetectorUser user : tDetectorUserList){
TDetectorUserVO userVO = new TDetectorUserVO();
BeanUtils.copyProperties(user, userVO);
detector.setUserId(user.getUserId());
detector.setIsDel("0");
List<TDetectorInfo> tDetectorInfoList = tDetectorInfoMapper.selectTDetectorInfoList(detector);
int onLineNum = 0;
int offLineNum = 0;
int cancelAlarmNum = 0;
int historyAlarmNum = 0;
if(tDetectorInfoList.size() > 0){
for(TDetectorInfo info : tDetectorInfoList){
if(!StringUtils.isEmpty(info.getDetectorStatus()) && info.getDetectorStatus().equals("0")){
++onLineNum;
}else{
++offLineNum;
}
}
List<TDetectorReportData> dataList = tDetectorReportDataMapper.countDetectorByUserId(detector);
historyAlarmNum = dataList.size();
for(TDetectorReportData data : dataList){
if(!StringUtils.isEmpty(data.getIsCancelAlarm()) && data.getIsCancelAlarm().equals("1")){
++cancelAlarmNum;
}
}
}
userVO.setDetectorCount(tDetectorInfoList.size());
userVO.setOnLineNum(onLineNum);
userVO.setOffLineNum(offLineNum);
userVO.setHistoryAlarmNum(historyAlarmNum);
userVO.setCancelAlarmNum(cancelAlarmNum);
userVO.setProcessingAlarmNum(Math.abs(historyAlarmNum - cancelAlarmNum));
list.add(userVO);
}
return list;
}
/**
* 查询燃气用户
......
<?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.zehong.system.mapper.TDetectorReportDataMapper">
<resultMap type="TDetectorReportData" id="TDetectorReportDataResult">
<result property="id" column="id" />
<result property="sourceId" column="source_id" />
<result property="detectorCode" column="detector_code" />
<result property="detectorStatusId" column="detector_status_id" />
<result property="statusName" column="status_name" />
<result property="reportValue" column="report_value" />
<result property="zhHostStatusId" column="zh_host_status_id" />
<result property="netPoint" column="net_point" />
<result property="signalStrength" column="signal_strength" />
<result property="ipAddress" column="ip_address" />
<result property="createTime" column="create_time" />
<result property="isCancelAlarm" column="is_cancel_alarm" />
<result property="cancelTime" column="cancel_time" />
</resultMap>
<sql id="selectTDetectorReportDataVo">
select id, source_id, detector_code, detector_status_id, status_name, report_value, zh_host_status_id, net_point, signal_strength, ip_address, create_time, is_cancel_alarm, cancel_time from t_detector_report_data
</sql>
<select id="selectTDetectorReportDataList" parameterType="TDetectorReportData" resultMap="TDetectorReportDataResult">
<include refid="selectTDetectorReportDataVo"/>
<where>
<if test="sourceId != null and sourceId != ''"> and source_id = #{sourceId}</if>
<if test="detectorCode != null and detectorCode != ''"> and detector_code = #{detectorCode}</if>
<if test="detectorStatusId != null and detectorStatusId != ''"> and detector_status_id = #{detectorStatusId}</if>
<if test="statusName != null and statusName != ''"> and status_name = #{statusName}</if>
<if test="reportValue != null "> and report_value = #{reportValue}</if>
<if test="zhHostStatusId != null "> and zh_host_status_id = #{zhHostStatusId}</if>
<if test="netPoint != null "> and net_point = #{netPoint}</if>
<if test="signalStrength != null "> and signal_strength = #{signalStrength}</if>
<if test="ipAddress != null and ipAddress != ''"> and ip_address = #{ipAddress}</if>
<if test="isCancelAlarm != null and isCancelAlarm != ''"> and is_cancel_alarm = #{isCancelAlarm}</if>
<if test="cancelTime != null "> and cancel_time = #{cancelTime}</if>
</where>
</select>
<select id="selectTDetectorReportDataById" parameterType="Long" resultMap="TDetectorReportDataResult">
<include refid="selectTDetectorReportDataVo"/>
where id = #{id}
</select>
<select id="selectTDetectorReportDataByCode" parameterType="String" resultMap="TDetectorReportDataResult">
<include refid="selectTDetectorReportDataVo"/>
where detector_code = #{detectorCode}
and is_cancel_alarm = '0'
ORDER BY create_time DESC
</select>
<select id="selectTDetectorAlarm" resultType="TDetectorAlarmInfoVO">
SELECT
rd.detector_code detectorCode,
CONCAT_WS("#",IFNULL(u.nick_name,IFNULL(di.linkman,di.detector_addr)),di.linkman) unitName,
di.detector_type detectorType,
rd.status_name statusName,
rd.create_time alarmTime,
IF (
rd.is_cancel_alarm = 0,
'未消除',
'已消除'
) handledStatus
FROM
t_detector_report_data rd
LEFT JOIN t_detector_info di ON rd.detector_code = di.detector_code
LEFT JOIN t_detector_user u ON u.user_id = di.user_id
WHERE u.is_del = '0'
ORDER BY rd.create_time DESC LIMIT 50
</select>
<select id="selectRealtimeDataList" resultMap="TDetectorReportDataResult">
SELECT * FROM
(
SELECT
t.source_id,
t.detector_code,
t.detector_status_id,
t.status_name,
t.report_value,
t.zh_host_status_id,
t.net_point,
t.signal_strength,
t.ip_address,
t.create_time,
t.is_cancel_alarm,
t.cancel_time,
d.detector_id,
d.detector_name,
d.detector_type
FROM
t_detector_report_data t
LEFT JOIN t_detector_info d ON t.detector_code = d.detector_code
WHERE
t.detector_status_id != '1'
ORDER BY t.create_time DESC
)data
GROUP BY data.detector_id LIMIT 50
</select>
<select id="countDetectorByUserId" parameterType="TDetectorInfo" resultMap="TDetectorReportDataResult" >
select r.id, r.source_id, r.detector_code, r.detector_status_id, r.is_cancel_alarm, r.cancel_time
from t_detector_report_data r
left join t_detector_info d on r.detector_code = d.detector_code
where r.detector_status_id != '1' and d.user_id = #{userId} and d.is_del = #{isDel}
</select>
<insert id="insertTDetectorReportData" parameterType="TDetectorReportData" useGeneratedKeys="true" keyProperty="id">
insert into t_detector_report_data
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sourceId != null">source_id,</if>
<if test="detectorCode != null and detectorCode != ''">detector_code,</if>
<if test="detectorStatusId != null">detector_status_id,</if>
<if test="statusName != null">status_name,</if>
<if test="reportValue != null">report_value,</if>
<if test="zhHostStatusId != null">zh_host_status_id,</if>
<if test="netPoint != null">net_point,</if>
<if test="signalStrength != null">signal_strength,</if>
<if test="ipAddress != null">ip_address,</if>
<if test="createTime != null">create_time,</if>
<if test="isCancelAlarm != null">is_cancel_alarm,</if>
<if test="cancelTime != null">cancel_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="sourceId != null">#{sourceId},</if>
<if test="detectorCode != null and detectorCode != ''">#{detectorCode},</if>
<if test="detectorStatusId != null">#{detectorStatusId},</if>
<if test="statusName != null">#{statusName},</if>
<if test="reportValue != null">#{reportValue},</if>
<if test="zhHostStatusId != null">#{zhHostStatusId},</if>
<if test="netPoint != null">#{netPoint},</if>
<if test="signalStrength != null">#{signalStrength},</if>
<if test="ipAddress != null">#{ipAddress},</if>
<if test="createTime != null">#{createTime},</if>
<if test="isCancelAlarm != null">#{isCancelAlarm},</if>
<if test="cancelTime != null">#{cancelTime},</if>
</trim>
</insert>
<update id="updateTDetectorReportData" parameterType="TDetectorReportData">
update t_detector_report_data
<trim prefix="SET" suffixOverrides=",">
<if test="sourceId != null">source_id = #{sourceId},</if>
<if test="detectorCode != null and detectorCode != ''">detector_code = #{detectorCode},</if>
<if test="detectorStatusId != null">detector_status_id = #{detectorStatusId},</if>
<if test="statusName != null">status_name = #{statusName},</if>
<if test="reportValue != null">report_value = #{reportValue},</if>
<if test="zhHostStatusId != null">zh_host_status_id = #{zhHostStatusId},</if>
<if test="netPoint != null">net_point = #{netPoint},</if>
<if test="signalStrength != null">signal_strength = #{signalStrength},</if>
<if test="ipAddress != null">ip_address = #{ipAddress},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="isCancelAlarm != null">is_cancel_alarm = #{isCancelAlarm},</if>
<if test="cancelTime != null">cancel_time = #{cancelTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteTDetectorReportDataById" parameterType="Long">
delete from t_detector_report_data where id = #{id}
</delete>
<delete id="deleteTDetectorReportDataByIds" parameterType="String">
delete from t_detector_report_data where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
......@@ -25,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectTDetectorUserList" parameterType="TDetectorUser" resultMap="TDetectorUserResult">
select user_id, username, nick_name, (CASE user_type WHEN '1' THEN '居民用户' WHEN '2' THEN '商业用户'WHEN '3' THEN '工业用户'end) as user_type , address, longitude, latitude, linkman, phone, email, is_del, remarks from t_detector_user
<where>
<where> is_del = '0'
<if test="username != null and username != ''"> and username like concat('%', #{username}, '%')</if>
<if test="nickName != null and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
</where>
......
import request from '@/utils/request'
// 查询探测器列表
export function listDetectorInfo(query) {
return request({
url: '/detector/detectorInfo/list',
method: 'get',
params: query
})
}
// 探测器列表
export function detectorInfoList(query) {
return request({
url: '/detector/detectorInfo/detectorInfoList',
method: 'get',
params: query
})
}
// 新增探测器
export function addDetectorInfo(data) {
return request({
url: '/detector/detectorInfo',
method: 'post',
data: data
})
}
// 修改探测器
export function updateDetectorInfo(data) {
return request({
url: '/detector/detectorInfo',
method: 'put',
data: data
})
}
// 删除探测器
export function delDetectorInfo(detectorId) {
return request({
url: '/detector/detectorInfo/' + detectorId,
method: 'delete'
})
}
// 导出探测器
export function exportDetectorInfo(query) {
return request({
url: '/detector/detectorInfo/export',
method: 'get',
params: query
})
}
import request from '@/utils/request'
// 查询探测器用户列表
export function listDetectorUser(query) {
return request({
url: '/detector/detectorUser/list',
method: 'get',
params: query
})
}
// 探测器用户列表
export function detectorUserList(query) {
return request({
url: '/detector/detectorUser/detectorUserList',
method: 'get',
params: query
})
}
// 查询探测器用户详细
export function getDetectorUser(userId) {
return request({
url: '/detector/detectorUser/' + userId,
method: 'get'
})
}
// 新增探测器用户
export function addDetectorUser(data) {
return request({
url: '/detector/detectorUser',
method: 'post',
data: data
})
}
// 修改探测器用户
export function updateDetectorUser(data) {
return request({
url: '/detector/detectorUser',
method: 'put',
data: data
})
}
// 删除探测器用户
export function delDetectorUser(userId) {
return request({
url: '/detector/detectorUser/' + userId,
method: 'delete'
})
}
// 导出探测器用户
export function exportDetectorUser(query) {
return request({
url: '/detector/detectorUser/export',
method: 'get',
params: query
})
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment