Commit 08e2fd0a authored by 廖旭伟's avatar 廖旭伟

设备告警信息查询。设备模块使用情况查询

parent b17db481
package com.mortals.xhx.common.pdu.device;
import com.mortals.framework.model.BaseEntityLong;
import java.util.Date;
public class DeviceAlarmPdu extends BaseEntityLong {
private static final long serialVersionUID = 1L;
/**
* 告警时间
*/
private Date alarmTime;
/**
* 告警设备Id
*/
private Long alarmDevice;
/**
* 站点Id,来源基础服务平台
*/
private Long siteId;
/**
* 告警类型,(0.离线)
*/
private Integer alarmType;
/**
* 告警级别(0.危险,1.次要,2.一般)
*/
private Integer alarmLevel;
/**
* 接收人员[设备管理的责任人]
*/
private String alarmReceivePersonnel;
/**
* 接收人员电话
*/
private String receivePersonnelTelephone;
/**
* 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
*/
private Integer alarmStatus;
/**
* 告警详细内容
*/
private String alarmContent;
public DeviceAlarmPdu(){}
/**
* 获取 告警时间
* @return Date
*/
public Date getAlarmTime(){
return alarmTime;
}
/**
* 设置 告警时间
* @param alarmTime
*/
public void setAlarmTime(Date alarmTime){
this.alarmTime = alarmTime;
}
/**
* 获取 告警设备Id
* @return Long
*/
public Long getAlarmDevice(){
return alarmDevice;
}
/**
* 设置 告警设备Id
* @param alarmDevice
*/
public void setAlarmDevice(Long alarmDevice){
this.alarmDevice = alarmDevice;
}
/**
* 获取 站点Id,来源基础服务平台
* @return Long
*/
public Long getSiteId(){
return siteId;
}
/**
* 设置 站点Id,来源基础服务平台
* @param siteId
*/
public void setSiteId(Long siteId){
this.siteId = siteId;
}
/**
* 获取 告警类型,(0.离线)
* @return Integer
*/
public Integer getAlarmType(){
return alarmType;
}
/**
* 设置 告警类型,(0.离线)
* @param alarmType
*/
public void setAlarmType(Integer alarmType){
this.alarmType = alarmType;
}
/**
* 获取 告警级别(0.危险,1.次要,2.一般)
* @return Integer
*/
public Integer getAlarmLevel(){
return alarmLevel;
}
/**
* 设置 告警级别(0.危险,1.次要,2.一般)
* @param alarmLevel
*/
public void setAlarmLevel(Integer alarmLevel){
this.alarmLevel = alarmLevel;
}
/**
* 获取 接收人员[设备管理的责任人]
* @return String
*/
public String getAlarmReceivePersonnel(){
return alarmReceivePersonnel;
}
/**
* 设置 接收人员[设备管理的责任人]
* @param alarmReceivePersonnel
*/
public void setAlarmReceivePersonnel(String alarmReceivePersonnel){
this.alarmReceivePersonnel = alarmReceivePersonnel;
}
/**
* 获取 接收人员电话
* @return String
*/
public String getReceivePersonnelTelephone(){
return receivePersonnelTelephone;
}
/**
* 设置 接收人员电话
* @param receivePersonnelTelephone
*/
public void setReceivePersonnelTelephone(String receivePersonnelTelephone){
this.receivePersonnelTelephone = receivePersonnelTelephone;
}
/**
* 获取 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
* @return Integer
*/
public Integer getAlarmStatus(){
return alarmStatus;
}
/**
* 设置 告警状态,来自工单系统(0.未清除,1.清除未确认,2.清除已确认)
* @param alarmStatus
*/
public void setAlarmStatus(Integer alarmStatus){
this.alarmStatus = alarmStatus;
}
/**
* 获取 告警详细内容
* @return String
*/
public String getAlarmContent(){
return alarmContent;
}
/**
* 设置 告警详细内容
* @param alarmContent
*/
public void setAlarmContent(String alarmContent){
this.alarmContent = alarmContent;
}
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof DeviceAlarmPdu) {
DeviceAlarmPdu tmp = (DeviceAlarmPdu) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",alarmTime:").append(getAlarmTime());
sb.append(",alarmDevice:").append(getAlarmDevice());
sb.append(",siteId:").append(getSiteId());
sb.append(",alarmType:").append(getAlarmType());
sb.append(",alarmLevel:").append(getAlarmLevel());
sb.append(",alarmReceivePersonnel:").append(getAlarmReceivePersonnel());
sb.append(",receivePersonnelTelephone:").append(getReceivePersonnelTelephone());
sb.append(",alarmStatus:").append(getAlarmStatus());
sb.append(",alarmContent:").append(getAlarmContent());
return sb.toString();
}
public void initAttrValue(){
this.alarmTime = null;
this.alarmDevice = null;
this.siteId = null;
this.alarmType = null;
this.alarmLevel = null;
this.alarmReceivePersonnel = "";
this.receivePersonnelTelephone = "";
this.alarmStatus = 0;
this.alarmContent = "";
}
}
package com.mortals.xhx.common.pdu.device;
import com.mortals.framework.model.BaseEntityLong;
public class DeviceModuleUsePdu extends BaseEntityLong {
private static final long serialVersionUID = 1L;
/**
* 模块名称
*/
private String moduleName;
/**
* 模块消息编码
*/
private String moduleMsgCode;
/**
* 所属设备
*/
private Long deviceId;
/**
* 调用次数
*/
private Long useNum;
public DeviceModuleUsePdu(){}
/**
* 获取 模块名称
* @return String
*/
public String getModuleName(){
return moduleName;
}
/**
* 设置 模块名称
* @param moduleName
*/
public void setModuleName(String moduleName){
this.moduleName = moduleName;
}
/**
* 获取 模块消息编码
* @return String
*/
public String getModuleMsgCode(){
return moduleMsgCode;
}
/**
* 设置 模块消息编码
* @param moduleMsgCode
*/
public void setModuleMsgCode(String moduleMsgCode){
this.moduleMsgCode = moduleMsgCode;
}
/**
* 获取 所属设备
* @return Long
*/
public Long getDeviceId(){
return deviceId;
}
/**
* 设置 所属设备
* @param deviceId
*/
public void setDeviceId(Long deviceId){
this.deviceId = deviceId;
}
/**
* 获取 调用次数
* @return Long
*/
public Long getUseNum(){
return useNum;
}
/**
* 设置 调用次数
* @param useNum
*/
public void setUseNum(Long useNum){
this.useNum = useNum;
}
@Override
public int hashCode() {
return this.getId().hashCode();
}
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
if (obj instanceof DeviceModuleUsePdu) {
DeviceModuleUsePdu tmp = (DeviceModuleUsePdu) obj;
if (this.getId() == tmp.getId()) {
return true;
}
}
return false;
}
public String toString(){
StringBuilder sb = new StringBuilder("");
sb.append(",moduleName:").append(getModuleName());
sb.append(",moduleMsgCode:").append(getModuleMsgCode());
sb.append(",deviceId:").append(getDeviceId());
sb.append(",useNum:").append(getUseNum());
return sb.toString();
}
public void initAttrValue(){
this.moduleName = "";
this.moduleMsgCode = "";
this.deviceId = null;
this.useNum = null;
}
}
package com.mortals.xhx.feign.device;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.device.DeviceAlarmPdu;
import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 设备告警信息
*/
@FeignClient(name = "device-manager", path = "/m", fallbackFactory = DeviceAlarmFeignFallbackFactory.class)
public interface IDeviceAlarmFeign extends IFeign {
/**
* 查看设备告警信息列表
*
* @param devicePdu
* @return
*/
@PostMapping(value = "/device/alarm/info/list")
Rest<RespData<List<DeviceAlarmPdu>>> list(@RequestBody DeviceAlarmPdu devicePdu);
/**
* 查看设备告警信息
*
* @param id
* @return
*/
@GetMapping(value = "/device/alarm/info")
Rest<DeviceAlarmPdu> info(@RequestParam(value = "id") Long id);
}
@Slf4j
@Component
class DeviceAlarmFeignFallbackFactory implements FallbackFactory<IDeviceAlarmFeign> {
@Override
public IDeviceAlarmFeign create(Throwable throwable) {
return new IDeviceAlarmFeign() {
@Override
public Rest<RespData<List<DeviceAlarmPdu>>> list(DeviceAlarmPdu devicePdu) {
return Rest.fail("暂时无法获取设备告警信息列表,请稍后再试!");
}
@Override
public Rest<DeviceAlarmPdu> info(Long id) {
return Rest.fail("暂时无法获取设备告警信息,请稍后再试!");
}
};
}
}
package com.mortals.xhx.feign.device;
import com.mortals.framework.common.Rest;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.device.DeviceAlarmPdu;
import com.mortals.xhx.common.pdu.device.DeviceModuleUsePdu;
import com.mortals.xhx.feign.IFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* 设备模块使用频率
*/
@FeignClient(name = "device-manager", path = "/m", fallbackFactory = DeviceModuleUseFeignFallbackFactory.class)
public interface IDeviceModuleUseFeign extends IFeign {
/**
* 查看设备模块使用频率
*
* @param devicePdu
* @return
*/
@PostMapping(value = "/device/module/use/list")
Rest<RespData<List<DeviceModuleUsePdu>>> list(@RequestBody DeviceModuleUsePdu devicePdu);
}
@Slf4j
@Component
class DeviceModuleUseFeignFallbackFactory implements FallbackFactory<IDeviceModuleUseFeign> {
@Override
public IDeviceModuleUseFeign create(Throwable throwable) {
return new IDeviceModuleUseFeign(){
@Override
public Rest<RespData<List<DeviceModuleUsePdu>>> list(DeviceModuleUsePdu devicePdu) {
return Rest.fail("暂时无法获取设备模块使用频率列表,请稍后再试!");
}
};
}
}
......@@ -8,18 +8,26 @@ import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.device.DeviceAlarmPdu;
import com.mortals.xhx.common.pdu.device.DeviceModuleUsePdu;
import com.mortals.xhx.common.pdu.device.DevicePdu;
import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.feign.device.IDeviceAlarmFeign;
import com.mortals.xhx.feign.device.IDeviceFeign;
import com.mortals.xhx.feign.device.IDeviceModuleUseFeign;
import com.mortals.xhx.module.device.model.DeviceEntity;
import com.mortals.xhx.module.device.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 设备
......@@ -35,6 +43,12 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
@Autowired
private IDeviceFeign deviceFeign;
@Autowired
private IDeviceAlarmFeign deviceAlarmFeign;
@Autowired
private IDeviceModuleUseFeign deviceModuleUseFeign;
@Override
@PostMapping({"list"})
@UnAuth
......@@ -129,4 +143,96 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
return ret.toJSONString();
}
}
@PostMapping({"alarm/list"})
@UnAuth
public Rest<Object> alarmList(@RequestBody DeviceAlarmPdu query) {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "查询设备告警信息列表";
int code=1;
try {
PageInfo pageInfo = new PageInfo();
if (!ObjectUtils.isEmpty(query) && !ObjectUtils.isEmpty(query.getPage())) {
pageInfo.setCurrPage(query.getPage());
}
if (!ObjectUtils.isEmpty(query) && !ObjectUtils.isEmpty(query.getSize())) {
pageInfo.setPrePageResult(query.getSize());
}
Result<DeviceAlarmPdu> result = new Result();
Rest<RespData<List<DeviceAlarmPdu>>> rest = deviceAlarmFeign.list(query);
if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
List<DeviceAlarmPdu> collect = rest.getData().getData();
result.setList(collect);
pageInfo.setTotalResult(collect.size());
result.setPageInfo(pageInfo);
result.setDict(rest.getDict());
}
model.put("data", result.getList());
model.put("pageInfo", result.getPageInfo());
model.put("dict", result.getDict());
this.parsePageInfo(model, result.getPageInfo());
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
this.init(model, context);
ret.setCode(code);
ret.setData(model);
ret.setDict(model.get("dict"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
@PostMapping({"module/use/list"})
@UnAuth
public Rest<Object> moduleUseList(@RequestBody DeviceModuleUsePdu query) {
Rest<Object> ret = new Rest();
Map<String, Object> model = new HashMap();
Context context = this.getContext();
String busiDesc = "查询设备模块使用频率信息列表";
int code=1;
try {
PageInfo pageInfo = new PageInfo();
if (!ObjectUtils.isEmpty(query) && !ObjectUtils.isEmpty(query.getPage())) {
pageInfo.setCurrPage(query.getPage());
}
if (!ObjectUtils.isEmpty(query) && !ObjectUtils.isEmpty(query.getSize())) {
pageInfo.setPrePageResult(query.getSize());
}
Result<DeviceModuleUsePdu> result = new Result();
Rest<RespData<List<DeviceModuleUsePdu>>> rest = deviceModuleUseFeign.list(query);
if (rest.getCode().equals(YesNoEnum.YES.getValue())) {
List<DeviceModuleUsePdu> collect = rest.getData().getData();
result.setList(collect);
pageInfo.setTotalResult(collect.size());
result.setPageInfo(pageInfo);
result.setDict(rest.getDict());
}
model.put("data", result.getList());
model.put("pageInfo", result.getPageInfo());
model.put("dict", result.getDict());
this.parsePageInfo(model, result.getPageInfo());
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception var9) {
code = -1;
this.doException(this.request, busiDesc, model, var9);
}
this.init(model, context);
ret.setCode(code);
ret.setData(model);
ret.setDict(model.get("dict"));
ret.setMsg(model.get("message_info") == null ? "" : model.remove("message_info").toString());
return ret;
}
}
\ No newline at end of file
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