parent
99d8f668be
commit
7c89c400bf
|
@ -4,11 +4,13 @@ import com.alibaba.fastjson.JSONObject;
|
|||
import com.dispose.common.Constants;
|
||||
import com.dispose.common.ErrorCode;
|
||||
import com.dispose.config.KafkaConfiguration;
|
||||
import com.dispose.manager.AlarmInfoManager;
|
||||
import com.dispose.pojo.dto.protocol.base.BaseRespStatus;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolReqDTO;
|
||||
import com.dispose.pojo.dto.protocol.base.ProtocolRespDTO;
|
||||
import com.dispose.pojo.dto.protocol.kafka.EmosAlarmInfo;
|
||||
import com.dispose.pojo.dto.protocol.kafka.AlarmInfoReq;
|
||||
import com.dispose.pojo.entity.AlarmInformation;
|
||||
import com.dispose.pojo.entity.MsgSerial;
|
||||
import com.dispose.pojo.po.MulReturnType;
|
||||
import com.dispose.security.annotation.Decryption;
|
||||
|
@ -59,6 +61,12 @@ public class kafkaController {
|
|||
@Resource
|
||||
private MsgSerialService msgSerialService;
|
||||
|
||||
/**
|
||||
* The alarm information manager.
|
||||
*/
|
||||
@Resource
|
||||
private AlarmInfoManager alarmInfoManager;
|
||||
|
||||
/**
|
||||
* Dispatch command sent to kafka.
|
||||
*
|
||||
|
@ -86,6 +94,8 @@ public class kafkaController {
|
|||
|
||||
//保存数据格式到数据库
|
||||
log.info("send alarm :{}", content);
|
||||
AlarmInformation alarmInformation = AlarmInformation.builder().alarmInfo(content).build();
|
||||
alarmInfoManager.addAlarmInfo(alarmInformation);
|
||||
|
||||
//推动数据格式到kafka
|
||||
ListenableFuture<SendResult<String, String>> sendResult = kafkaConfiguration
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package com.dispose.manager;
|
||||
|
||||
import com.dispose.pojo.entity.AlarmInformation;
|
||||
|
||||
/**
|
||||
* The interface alarm information manager.
|
||||
*
|
||||
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface AlarmInfoManager {
|
||||
/**
|
||||
* Add alarm information.
|
||||
*
|
||||
* @param alarmInformation the alarm information
|
||||
*/
|
||||
void addAlarmInfo(AlarmInformation alarmInformation);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.dispose.manager.impl;
|
||||
|
||||
import com.dispose.manager.AlarmInfoManager;
|
||||
import com.dispose.mapper.AlarmInformationMapper;
|
||||
import com.dispose.pojo.entity.AlarmInformation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* The interface alarm information manager.
|
||||
*
|
||||
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class AlarmInfoManagerImpl implements AlarmInfoManager {
|
||||
/**
|
||||
* The alarm information mapper.
|
||||
*/
|
||||
@Resource
|
||||
private AlarmInformationMapper alarmInformationMapper;
|
||||
|
||||
/**
|
||||
* Add alarm information.
|
||||
*
|
||||
* @param alarmInformation the alarm information
|
||||
*/
|
||||
@Override
|
||||
public void addAlarmInfo(AlarmInformation alarmInformation) {
|
||||
alarmInformationMapper.addAlarmInfo(alarmInformation);
|
||||
}
|
||||
}
|
|
@ -9,6 +9,11 @@ import org.springframework.stereotype.Component;
|
|||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* The interface message serial manager.
|
||||
*
|
||||
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class MsgSerialManagerImpl implements MsgSerialManager {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.dispose.mapper;
|
||||
|
||||
import com.dispose.pojo.entity.AlarmInformation;
|
||||
|
||||
/**
|
||||
* The interface alarm information mapper.
|
||||
*
|
||||
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface AlarmInformationMapper {
|
||||
/**
|
||||
* Add alarm information.
|
||||
*
|
||||
* @param alarmInformation the alarm information
|
||||
* @return the int
|
||||
*/
|
||||
int addAlarmInfo(AlarmInformation alarmInformation);
|
||||
}
|
|
@ -2,6 +2,11 @@ package com.dispose.mapper;
|
|||
|
||||
import com.dispose.pojo.entity.MsgSerial;
|
||||
|
||||
/**
|
||||
* The interface message serial mapper.
|
||||
*
|
||||
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||
*/
|
||||
public interface MsgSerialMapper {
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package com.dispose.pojo.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import tk.mybatis.mapper.annotation.KeySql;
|
||||
import tk.mybatis.mapper.annotation.NameStyle;
|
||||
import tk.mybatis.mapper.code.Style;
|
||||
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The emos alarm information.
|
||||
*
|
||||
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Table(name = "alarm_information")
|
||||
@NameStyle(Style.normal)
|
||||
public class AlarmInformation implements Serializable {
|
||||
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The id.
|
||||
*/
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* The alarm information.
|
||||
*/
|
||||
private String alarmInfo;
|
||||
|
||||
/**
|
||||
* The creating time.
|
||||
*/
|
||||
private String createTime;
|
||||
}
|
|
@ -14,9 +14,9 @@ import javax.persistence.Table;
|
|||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* The type Dispose capacity.
|
||||
* The message serial.
|
||||
*
|
||||
* @author <huangxin@cmhi.chinamoblie.com>
|
||||
* @author <chenlinghy@cmhi.chinamoblie.com>
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
|
@ -33,16 +33,14 @@ public class MsgSerial implements Serializable {
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* The Id.
|
||||
* The id.
|
||||
*/
|
||||
@Id
|
||||
@KeySql(useGeneratedKeys = true)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* The Device id.
|
||||
* The message serial.
|
||||
*/
|
||||
private Long msgSerial;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -182,6 +182,20 @@ DROP TABLE IF EXISTS `msg_serial`;
|
|||
CREATE TABLE `msg_serial`
|
||||
(
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`msgSerial` bigint(20) NOT NULL DEFAULT '1',
|
||||
`msgSerial` bigint(20) NOT NULL DEFAULT '1' COMMENT '连续消息序号',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=50 DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for alarm_information
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `alarm_information`;
|
||||
CREATE TABLE `alarm_information`
|
||||
(
|
||||
`id` bigint(11) NOT NULL AUTO_INCREMENT,
|
||||
`alarmInfo` varchar(255) NOT NULL COMMENT 'emos告警内容',
|
||||
`createTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?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.dispose.mapper.AlarmInformationMapper">
|
||||
<resultMap id="msg_serial" type="com.dispose.pojo.entity.AlarmInformation">
|
||||
<id column="id" property="id"/>
|
||||
<result column="alarmInfo" property="alarmInfo"/>
|
||||
<result column="createTime" property="createTime"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="addAlarmInfo" useGeneratedKeys="true" keyProperty="id"
|
||||
parameterType="com.dispose.pojo.entity.AlarmInformation">
|
||||
INSERT
|
||||
IGNORE INTO alarm_information(alarmInfo)
|
||||
VALUES (
|
||||
#{alarmInfo}
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue