Commit 7e565c7d authored by 王晓倩's avatar 王晓倩

Merge remote-tracking branch 'origin/master'

parents 47d9311a 0d3ca84d
package com.zehong.web.controller.dataMonitoring;
import java.util.List;
import com.zehong.common.core.domain.entity.SysDictData;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.vo.DeviceAlarmVo;
import com.zehong.system.service.ISysDictTypeService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.system.domain.TDeviceAlarm;
import com.zehong.system.domain.vo.DeviceAlarmVo;
import com.zehong.system.service.ITDeviceAlarmService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 报警信息Controller
......@@ -38,8 +27,6 @@ public class TDeviceAlarmController extends BaseController
@Autowired
private ITDeviceAlarmService tDeviceAlarmService;
@Autowired
private ISysDictTypeService iSysDictTypeService;
/**
* 查询报警信息列表
......@@ -52,18 +39,6 @@ public class TDeviceAlarmController extends BaseController
List<DeviceAlarmVo> list = null;
try {
list = tDeviceAlarmService.selectTDeviceAlarmList(tDeviceAlarm);
List<SysDictData> sysDictDataList = iSysDictTypeService.selectDictDataByType("t_alarm_type");
for(DeviceAlarmVo deviceAlarmVo : list){
for(SysDictData sysDictData : sysDictDataList){
if(StringUtils.isNotEmpty(deviceAlarmVo.getAlarmType())){
if(deviceAlarmVo.getAlarmType().equals(sysDictData.getDictValue())){
deviceAlarmVo.setAlarmType(sysDictData.getDictLabel());
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
throw new Exception("查询报警信息列表出错");
......
......@@ -3,8 +3,6 @@ package com.zehong.web.controller.websocket;
import com.alibaba.fastjson.JSONObject;
import com.zehong.system.domain.vo.DeviceAlarmVo;
import com.zehong.system.service.ITDeviceAlarmService;
import com.zehong.system.service.ITDeviceInfoService;
import com.zehong.system.service.ITPipeService;
import com.zehong.system.service.WebSocketServer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -25,25 +23,11 @@ public class WebSocketController {
@Autowired
private ITDeviceAlarmService itDeviceAlarmService;
@Autowired
private ITDeviceInfoService itDeviceInfoService;
@Autowired
private ITPipeService itPipeService;
private final static String PIPE_TYPE = "0";
@GetMapping("/send")
public void send(int alarmId){
try {
DeviceAlarmVo alarm = itDeviceAlarmService.selectTDeviceAlarmById(alarmId);
/*JSONObject json = new JSONObject();
json.put("alarmInfo",alarm);*/
/*if(PIPE_TYPE.equals(alarm.getAlarmType())){
json.put("deviceInfo",itPipeService.selectTPipeById(alarm.getDeviceId()));
}else{
json.put("deviceInfo",itDeviceInfoService.selectTDeviceInfoById(alarm.getDeviceId()));
}*/
webSocketServer.batchSendMessage(JSONObject.toJSONString(alarm));
} catch (Exception e) {
log.error("wesocket发送失败!");
......
......@@ -2,12 +2,16 @@ package com.zehong.system.service.impl;
import java.util.ArrayList;
import java.util.List;
import com.zehong.common.core.domain.entity.SysDictData;
import com.zehong.common.utils.DateUtils;
import com.zehong.common.utils.StringUtils;
import com.zehong.system.domain.TDeviceInfo;
import com.zehong.system.domain.TPipe;
import com.zehong.system.domain.vo.DeviceAlarmVo;
import com.zehong.system.mapper.TDeviceInfoMapper;
import com.zehong.system.mapper.TPipeMapper;
import com.zehong.system.service.ISysDictTypeService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -31,6 +35,9 @@ public class TDeviceAlarmServiceImpl implements ITDeviceAlarmService
@Autowired
private TPipeMapper tPipeMapper;
@Autowired
private ISysDictTypeService iSysDictTypeService;
/**
* 查询报警信息
*
......@@ -75,7 +82,7 @@ public class TDeviceAlarmServiceImpl implements ITDeviceAlarmService
DeviceAlarmVo deviceAlarmVo = new DeviceAlarmVo();
BeanUtils.copyProperties(alarm, deviceAlarmVo);
if("0".equals(tDeviceAlarm.getDeviceType())){
if("0".equals(alarm.getDeviceType())){
TPipe pipe = tPipeMapper.selectTPipeById(alarm.getDeviceId());
if(pipe != null) {
deviceAlarmVo.setDeviceCode(pipe.getPipeCode());
......@@ -89,6 +96,16 @@ public class TDeviceAlarmServiceImpl implements ITDeviceAlarmService
}
}
List<SysDictData> sysDictDataList = iSysDictTypeService.selectDictDataByType("t_alarm_type");
for(SysDictData sysDictData : sysDictDataList){
if(StringUtils.isNotEmpty(alarm.getAlarmType())){
if(alarm.getAlarmType().equals(sysDictData.getDictValue())){
deviceAlarmVo.setAlarmType(sysDictData.getDictLabel());
}
}
}
list.add(deviceAlarmVo);
}
return list;
......
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