dxd测试
parent
757f51a2dd
commit
6c16191d90
|
@ -1,52 +0,0 @@
|
|||
package com.couplet.msg.consumer;
|
||||
|
||||
import org.apache.kafka.clients.consumer.ConsumerConfig;
|
||||
import org.apache.kafka.clients.consumer.ConsumerRecords;
|
||||
import org.apache.kafka.clients.consumer.KafkaConsumer;
|
||||
import org.apache.kafka.common.serialization.StringDeserializer;
|
||||
import org.apache.kafka.common.serialization.StringSerializer;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Collections;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/4/1 19:04
|
||||
* @description
|
||||
*/
|
||||
public class KafkaConsumerQuickStart {
|
||||
public static void main(String[] args) {
|
||||
//创建 properties 对象配置 kafka消费者的配置信息
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,"39.103.133.136:9092");
|
||||
//设置键值的反序列化方式
|
||||
properties.setProperty(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
||||
properties.setProperty(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class.getName());
|
||||
//分组
|
||||
properties.setProperty(ConsumerConfig.GROUP_ID_CONFIG, "group");
|
||||
//创建Kafka消费者对象
|
||||
KafkaConsumer<String, String> kafkaConsumer = new KafkaConsumer<>(properties);
|
||||
|
||||
//设置订阅主题
|
||||
kafkaConsumer.subscribe(Collections.singleton("couplet-kafka"));
|
||||
//拉取消息
|
||||
while (true) {
|
||||
ConsumerRecords<String, String> records = kafkaConsumer.poll(Duration.ofMillis(2000));
|
||||
|
||||
if (!records.isEmpty()) {
|
||||
// 遍历
|
||||
records.forEach(record -> {
|
||||
String key = record.key();
|
||||
String value = record.value();
|
||||
System.out.println("消息接收key成功:" + key + "消息接收value成功:" + value);
|
||||
});
|
||||
} else {
|
||||
System.out.println("未拉取到消息,等待中...");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package com.couplet.msg.contents;
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/4/2 14:05
|
||||
* @description
|
||||
*/
|
||||
public class KafkaContents {
|
||||
public static final String TOPIC = "couplet-top";
|
||||
|
||||
public static final String KAFKA_CON = "39.103.133.136:39092,39.103.133.136:29092,39.103.133.136:19092";
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package com.couplet.msg.producer;
|
||||
|
||||
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||
import org.apache.kafka.clients.producer.Producer;
|
||||
import org.apache.kafka.clients.producer.ProducerConfig;
|
||||
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||
import org.apache.kafka.common.serialization.StringSerializer;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/4/1 20:07
|
||||
* @description
|
||||
*/
|
||||
public class KafkaProducerQuickStart {
|
||||
|
||||
private static Producer<String,String> producer;
|
||||
|
||||
public static void KafkaProducer() {
|
||||
Properties props = new Properties();
|
||||
}
|
||||
|
||||
}
|
|
@ -95,24 +95,6 @@ public class MqttListen {
|
|||
log.info("接收消息Qos:" + message.getQos());
|
||||
log.info("接收消息内容:" + new String(message.getPayload()));
|
||||
|
||||
// 用来配置kafka 消息生产者对象的配置信息
|
||||
Properties properties = new Properties();
|
||||
//配置host
|
||||
properties.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "39.103.133.136:9092");
|
||||
//配置键值的序列方式
|
||||
properties.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class.getName());
|
||||
properties.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG,StringSerializer.class.getName());
|
||||
//创建消息生产者对象
|
||||
KafkaProducer<String, String> kafkaProducer = new KafkaProducer<>(properties);
|
||||
|
||||
//发送消息
|
||||
//创建消息记录
|
||||
ProducerRecord<String, String> producerRecord = new ProducerRecord<>("couplet-kafka",topic,new String(message.getPayload()));
|
||||
kafkaProducer.send(producerRecord);
|
||||
|
||||
System.out.println("发送消息成功:" +producerRecord);
|
||||
//关闭 kafkaProducer
|
||||
kafkaProducer.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9617
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: couplet-msg
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: a439ce3f-2c42-4b4c-9c4d-c8db49933c15
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
logging:
|
||||
level:
|
||||
com.couplet.system.mapper: DEBUG
|
|
@ -1,6 +1,7 @@
|
|||
package com.couplet.msg.domain;
|
||||
package com.couplet.trouble.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -12,14 +13,14 @@ import java.util.Date;
|
|||
/**
|
||||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/3/31 21:18
|
||||
* @date 2024/4/2 15:14
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TroubleLog {
|
||||
public class CoupletTroubleLog {
|
||||
/**
|
||||
* 故障记录Id
|
||||
*/
|
||||
|
@ -31,7 +32,7 @@ public class TroubleLog {
|
|||
private String troubleLogCode;
|
||||
|
||||
/**
|
||||
* 故障记录车辆VIN
|
||||
* 故障码VIN
|
||||
*/
|
||||
private String troubleLogVin;
|
||||
|
||||
|
@ -48,4 +49,5 @@ public class TroubleLog {
|
|||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date troubleLogEndTime;
|
||||
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package com.couplet.trouble.domain.req;
|
||||
|
||||
import com.couplet.common.core.annotation.Excel;
|
||||
import com.couplet.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/3/26 22:32
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TroubleAddReq {
|
||||
/**
|
||||
* 故障码
|
||||
*/
|
||||
@Excel(name = "故障码")
|
||||
private String troubleCode;
|
||||
|
||||
/**
|
||||
* 故障位
|
||||
*/
|
||||
@Excel(name = "故障位")
|
||||
private String troublePosition;
|
||||
|
||||
/**
|
||||
* 故障值
|
||||
*/
|
||||
@Excel(name = "故障值")
|
||||
private String troubleValue;
|
||||
|
||||
/**
|
||||
* 故障标签
|
||||
*/
|
||||
@Excel(name = "故障标签")
|
||||
private String troubleTag;
|
||||
|
||||
/**
|
||||
* 故障类型Id
|
||||
*/
|
||||
private Integer troubleTypeId;
|
||||
|
||||
/**
|
||||
* 故障等级Id
|
||||
*/
|
||||
private Integer troubleGradeId;
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package com.couplet.trouble.domain.req;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.couplet.common.core.annotation.Excel;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author DongXiaoDong
|
||||
* @version 1.0
|
||||
* @date 2024/3/26 22:32
|
||||
* @description
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TroubleUpdReq {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@Excel(name = "故障码主键", cellType = Excel.ColumnType.NUMERIC)
|
||||
@TableId(value = "trouble_id",type = IdType.AUTO)
|
||||
private Integer troubleId;
|
||||
|
||||
/**
|
||||
* 故障码
|
||||
*/
|
||||
@Excel(name = "故障码")
|
||||
private String troubleCode;
|
||||
|
||||
/**
|
||||
* 故障位
|
||||
*/
|
||||
@Excel(name = "故障位")
|
||||
private String troublePosition;
|
||||
|
||||
/**
|
||||
* 故障值
|
||||
*/
|
||||
@Excel(name = "故障值")
|
||||
private String troubleValue;
|
||||
|
||||
/**
|
||||
* 故障标签
|
||||
*/
|
||||
@Excel(name = "故障标签")
|
||||
private String troubleTag;
|
||||
|
||||
/**
|
||||
* 故障类型Id
|
||||
*/
|
||||
private Integer troubleTypeId;
|
||||
|
||||
/**
|
||||
* 故障等级Id
|
||||
*/
|
||||
private Integer troubleGradeId;
|
||||
}
|
|
@ -19,32 +19,6 @@
|
|||
LEFT JOIN couplet_trouble_grade g on t.grade_id = g.grade_id
|
||||
LEFT JOIN couplet_trouble_type y on t.type_id= y.type_id
|
||||
</sql>
|
||||
<!-- <insert id="addTrouble">-->
|
||||
<!-- insert into couplet_trouble_code (trouble_code,trouble_position,trouble_value,trouble_tag,trouble_type_id,trouble_grade_id)-->
|
||||
<!-- values (#{troubleCode},#{troublePosition},#{troubleValue},#{troubleTag},#{troubleTypeId},#{troubleGradeId})-->
|
||||
<!-- </insert>-->
|
||||
<!-- <update id="updateTrouble">-->
|
||||
<!-- update couplet_trouble_code set-->
|
||||
<!-- trouble_code = #{troubleCode},-->
|
||||
<!-- trouble_position = #{troublePosition},-->
|
||||
<!-- trouble_value = #{troubleValue},-->
|
||||
<!-- trouble_tag = #{troubleTag},-->
|
||||
<!-- trouble_type_id = #{troubleTypeId},-->
|
||||
<!-- trouble_grade_id = #{troubleGradeId}-->
|
||||
<!-- where trouble_id = #{troubleId}-->
|
||||
<!-- </update>-->
|
||||
<!-- <update id="updateTrouble" parameterType="com.couplet.trouble.domain.req.TroubleUpdReq">-->
|
||||
<!-- update dxd_trouble_code-->
|
||||
<!-- <set>-->
|
||||
<!-- <if test="troubleCode != null and troubleCode != ''">trouble_code = #{troubleCode},</if>-->
|
||||
<!-- <if test="troublePosition != null and troublePosition != ''">trouble_position = #{troublePosition},</if>-->
|
||||
<!-- <if test="troubleTag != null and troubleTag != ''">trouble_tag = #{troubleTag},</if>-->
|
||||
<!-- <if test="troubleTypeId != null">trouble_typeId = #{troubleTypeId},</if>-->
|
||||
<!-- <if test="troubleValue != null and troubleValue != ''">trouble_value = #{troubleValue},</if>-->
|
||||
<!-- <if test="troubleGradeId != null">trouble_gradeId = #{troubleGradeId},</if>-->
|
||||
<!-- </set>-->
|
||||
<!-- where trouble_id = #{troubleId}-->
|
||||
<!-- </update>-->
|
||||
|
||||
<select id="selectTroubleList" parameterType="com.couplet.trouble.mapper.SysTroubleMapper" resultMap="SysTroubleResult">
|
||||
<include refid="selectTroubleVo"/>
|
||||
|
@ -64,23 +38,4 @@
|
|||
select * from couplet_trouble_grade
|
||||
</select>
|
||||
|
||||
|
||||
<!-- <insert id="addTrouble" parameterType="com.couplet.trouble.domain.req.TroubleAddReq">-->
|
||||
<!-- insert into dxd_trouble_code(-->
|
||||
<!-- <if test="troubleCode != null and troubleCode != ''">trouble_code,</if>-->
|
||||
<!-- <if test="troublePosition != null and troublePosition != ''">trouble_position,</if>-->
|
||||
<!-- <if test="troubleTag != null and troubleTag != ''">trouble_tag,</if>-->
|
||||
<!-- <if test="troubleTypeId != null">trouble_typeId,</if>-->
|
||||
<!-- <if test="troubleValue != null and troubleValue != ''">trouble_value,</if>-->
|
||||
<!-- <if test="troubleGradeId != null">trouble_gradeId</if>-->
|
||||
<!-- )values(-->
|
||||
<!-- <if test="troubleCode != null and troubleCode != ''">#{troubleCode},</if>-->
|
||||
<!-- <if test="troublePosition != null and troublePosition != ''">#{troublePosition},</if>-->
|
||||
<!-- <if test="troubleTag != null and troubleTag != ''">#{troubleTag},</if>-->
|
||||
<!-- <if test="troubleTypeId != null">#{troubleTypeId},</if>-->
|
||||
<!-- <if test="troubleValue != null and troubleValue != ''">#{troubleValue},</if>-->
|
||||
<!-- <if test="troubleGradeId != null">#{troubleGradeId},</if>-->
|
||||
<!-- )-->
|
||||
<!-- </insert>-->
|
||||
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue