Commit eb818d7d authored by 赵啸非's avatar 赵啸非

添加告警信息

parent b7072eec
...@@ -65,7 +65,7 @@ public class CustomerKeyExpirationListener implements MessageListener { ...@@ -65,7 +65,7 @@ public class CustomerKeyExpirationListener implements MessageListener {
public void onMessage(Message message, byte[] bytes) { public void onMessage(Message message, byte[] bytes) {
String key = message.toString(); String key = message.toString();
String subStr = StrUtil.removePrefix(key, RedisKey.KEY_DEVICE_ONLINE_CACHE); String subStr = StrUtil.removePrefix(key, RedisKey.KEY_DEVICE_ONLINE_CACHE);
if(!subStr.equals(key)){ if (!subStr.equals(key)) {
DeviceEntity deviceEntity = deviceService.getExtCache(subStr); DeviceEntity deviceEntity = deviceService.getExtCache(subStr);
if (!ObjectUtils.isEmpty(deviceEntity)) { if (!ObjectUtils.isEmpty(deviceEntity)) {
if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.在线.getValue()) { if (deviceEntity.getDeviceStatus() == DeviceStatusEnum.在线.getValue()) {
...@@ -80,32 +80,51 @@ public class CustomerKeyExpirationListener implements MessageListener { ...@@ -80,32 +80,51 @@ public class CustomerKeyExpirationListener implements MessageListener {
deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.OFFLINE); deviceService.sendThirdParty(deviceEntity, productEntity, platformEntity, DeviceMethodEnum.OFFLINE);
} }
//保存离线告警消息
DeviceAlarmInfoEntity alarmInfoEntity = new DeviceAlarmInfoEntity();
alarmInfoEntity.initAttrValue();
alarmInfoEntity.setAlarmDevice(deviceEntity.getId());
alarmInfoEntity.setSiteId(deviceEntity.getSiteId());
alarmInfoEntity.setAlarmContent(deviceEntity.getDeviceName() + "已离线!");
alarmInfoEntity.setAlarmType(AlarmTypeEnum.离线.getValue());
alarmInfoEntity.setAlarmLevel(AlarmLevelEnum.一般.getValue());
alarmInfoEntity.setAlarmStatus(AlarmStatusEnum.未清除.getValue());
alarmInfoEntity.setAlarmReceivePersonnel(deviceEntity.getLeadingOfficial());
alarmInfoEntity.setReceivePersonnelTelephone(deviceEntity.getLeadingOfficialTelephone());
alarmInfoEntity.setCreateTime(new Date());
alarmInfoEntity.setCreateUserId(1L);
deviceAlarmInfoService.save(alarmInfoEntity);
// TODO: 2022/6/23 告警信息保存与发送 // TODO: 2022/6/23 告警信息保存与发送
AlarmConfigEntity alarmConfigEntity = alarmConfigService.selectOne(new AlarmConfigQuery().productId(productEntity.getId())); AlarmConfigEntity alarmConfigEntity = alarmConfigService.selectOne(new AlarmConfigQuery().productId(productEntity.getId()));
if (!ObjectUtils.isEmpty(alarmConfigEntity)) { if (!ObjectUtils.isEmpty(alarmConfigEntity)) {
if(alarmConfigEntity.getAlarmPusW1ay()== AlarmPusW1ayEnum.短信.getValue()){ if (alarmConfigEntity.getAlarmPusW1ay() == AlarmPusW1ayEnum.短信.getValue()) {
// TODO: 2022/7/4 发送短信 // TODO: 2022/7/4 发送短信
Rest<RespData<List<SmsSetPdu>>> respDataRest = smsSetFeign.list(new SmsSetPdu().siteId(deviceEntity.getSiteId())); Rest<RespData<List<SmsSetPdu>>> respDataRest = smsSetFeign.list(new SmsSetPdu().siteId(deviceEntity.getSiteId()));
if(respDataRest.getCode()==YesNoEnum.YES.getValue()){ if (respDataRest.getCode() == YesNoEnum.YES.getValue()) {
List<SmsSetPdu> data = respDataRest.getData().getData(); List<SmsSetPdu> data = respDataRest.getData().getData();
if(!ObjectUtils.isEmpty(data)){ if (!ObjectUtils.isEmpty(data)) {
Integer messageoff = data.get(0).getMessageoff(); Integer messageoff = data.get(0).getMessageoff();
if(messageoff==YesNoEnum.YES.getValue()){ if (messageoff == YesNoEnum.YES.getValue()) {
// todo 发送短信 // todo 发送短信
DeviceAlarmInfoEntity deviceAlarmInfoEntity = deviceAlarmInfoService.selectOne(new DeviceAlarmInfoQuery().alarmDevice(deviceEntity.getId())); DeviceAlarmInfoEntity deviceAlarmInfoEntity = deviceAlarmInfoService.selectOne(new DeviceAlarmInfoQuery().alarmDevice(deviceEntity.getId()));
if(!ObjectUtils.isEmpty(deviceAlarmInfoEntity)){ if (!ObjectUtils.isEmpty(deviceAlarmInfoEntity)) {
AlarmSmsSendEntity alarmSmsSendEntity = new AlarmSmsSendEntity(); AlarmSmsSendEntity alarmSmsSendEntity = new AlarmSmsSendEntity();
alarmSmsSendEntity.initAttrValue(); alarmSmsSendEntity.initAttrValue();
alarmSmsSendEntity.setId(IdUtil.getSnowflake().nextId()); alarmSmsSendEntity.setId(IdUtil.getSnowflake().nextId());
alarmSmsSendEntity.setSiteId(deviceAlarmInfoEntity.getSiteId());
alarmSmsSendEntity.setMobile(deviceAlarmInfoEntity.getReceivePersonnelTelephone()); alarmSmsSendEntity.setMobile(deviceAlarmInfoEntity.getReceivePersonnelTelephone());
alarmSmsSendEntity.setReceiver(deviceAlarmInfoEntity.getAlarmReceivePersonnel()); alarmSmsSendEntity.setReceiver(deviceAlarmInfoEntity.getAlarmReceivePersonnel());
alarmSmsSendEntity.setSendMess(deviceAlarmInfoEntity.getAlarmContent()); alarmSmsSendEntity.setSendMess(deviceAlarmInfoEntity.getAlarmContent());
alarmSmsSendEntity.setSendStatus(SendStatusEnum.未发送.getValue()); alarmSmsSendEntity.setSendStatus(SendStatusEnum.未发送.getValue());
alarmSmsSendService.save(alarmSmsSendEntity,null); alarmSmsSendService.save(alarmSmsSendEntity, null);
} }
}else{ } else {
} }
} }
......
...@@ -82,6 +82,7 @@ public class DownMsgTask implements Runnable { ...@@ -82,6 +82,7 @@ public class DownMsgTask implements Runnable {
DeviceLogEntity deviceLogEntity = new DeviceLogEntity(); DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue(); deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(metadata.getMessageId()); deviceLogEntity.setTraceID(metadata.getMessageId());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId()); deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName()); deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode()); deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
...@@ -102,6 +103,7 @@ public class DownMsgTask implements Runnable { ...@@ -102,6 +103,7 @@ public class DownMsgTask implements Runnable {
String traceID = IdUtil.fastSimpleUUID(); String traceID = IdUtil.fastSimpleUUID();
deviceLogEntity.setTraceID(traceID); deviceLogEntity.setTraceID(traceID);
deviceLogEntity.setDeviceId(deviceEntity.getId()); deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName()); deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode()); deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
deviceLogEntity.setMessageHead(item.getMessageType()); deviceLogEntity.setMessageHead(item.getMessageType());
......
...@@ -179,6 +179,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi ...@@ -179,6 +179,7 @@ public class DeviceMsgComsumerStartedService implements IApplicationStartedServi
DeviceLogEntity deviceLogEntity = new DeviceLogEntity(); DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.initAttrValue(); deviceLogEntity.initAttrValue();
deviceLogEntity.setTraceID(IdUtil.fastSimpleUUID()); deviceLogEntity.setTraceID(IdUtil.fastSimpleUUID());
deviceLogEntity.setSiteId(deviceEntity.getSiteId());
deviceLogEntity.setDeviceId(deviceEntity.getId()); deviceLogEntity.setDeviceId(deviceEntity.getId());
deviceLogEntity.setDeviceName(deviceEntity.getDeviceName()); deviceLogEntity.setDeviceName(deviceEntity.getDeviceName());
deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode()); deviceLogEntity.setDeviceCode(deviceEntity.getDeviceCode());
......
package com.mortals.xhx.module.product.service.impl; package com.mortals.xhx.module.product.service.impl;
import com.mortals.xhx.module.product.model.ProductVersionQuery;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
...@@ -6,6 +7,10 @@ import com.mortals.framework.model.Context; ...@@ -6,6 +7,10 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.product.dao.ProductVersionDao; import com.mortals.xhx.module.product.dao.ProductVersionDao;
import com.mortals.xhx.module.product.model.ProductVersionEntity; import com.mortals.xhx.module.product.model.ProductVersionEntity;
import com.mortals.xhx.module.product.service.ProductVersionService; import com.mortals.xhx.module.product.service.ProductVersionService;
import org.springframework.util.ObjectUtils;
import java.util.Date;
/** /**
* ProductVersionService * ProductVersionService
* 产品客户端版本 service实现 * 产品客户端版本 service实现
...@@ -15,5 +20,9 @@ import com.mortals.xhx.module.product.service.ProductVersionService; ...@@ -15,5 +20,9 @@ import com.mortals.xhx.module.product.service.ProductVersionService;
*/ */
@Service("productVersionService") @Service("productVersionService")
public class ProductVersionServiceImpl extends AbstractCRUDServiceImpl<ProductVersionDao, ProductVersionEntity, Long> implements ProductVersionService { public class ProductVersionServiceImpl extends AbstractCRUDServiceImpl<ProductVersionDao, ProductVersionEntity, Long> implements ProductVersionService {
@Override
protected void saveBefore(ProductVersionEntity entity, Context context) throws AppException {
super.saveBefore(entity, context);
}
} }
\ No newline at end of file
package com.mortals.xhx.module.product.web; package com.mortals.xhx.module.product.web;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.module.product.model.ProductEntity; import com.mortals.xhx.module.product.model.ProductEntity;
import com.mortals.xhx.module.product.model.ProductVersionQuery;
import com.mortals.xhx.module.product.service.ProductService; import com.mortals.xhx.module.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -15,12 +18,10 @@ import com.mortals.xhx.module.product.model.ProductVersionEntity; ...@@ -15,12 +18,10 @@ import com.mortals.xhx.module.product.model.ProductVersionEntity;
import com.mortals.xhx.module.product.service.ProductVersionService; import com.mortals.xhx.module.product.service.ProductVersionService;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import java.util.HashMap;
import java.util.List; import java.util.*;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*; import static com.mortals.framework.ap.SysConstains.*;
...@@ -49,8 +50,17 @@ public class ProductVersionController extends BaseCRUDJsonBodyMappingController< ...@@ -49,8 +50,17 @@ public class ProductVersionController extends BaseCRUDJsonBodyMappingController<
super.init(model, context); super.init(model, context);
} }
@Override
protected void saveBefore(ProductVersionEntity entity, Map<String, Object> model, Context context) throws AppException {
ProductVersionEntity productVersionEntity = this.service.selectOne(new ProductVersionQuery().productId(entity.getProductId()).version(entity.getVersion()));
if(!ObjectUtils.isEmpty(productVersionEntity)){
entity.setId(productVersionEntity.getId());
entity.setUpdateUserId(super.getContextUserId(context));
entity.setUpdateTime(new Date());
}
super.saveBefore(entity, model, context);
}
} }
\ 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