编写故障日志的代码与站内信的代码
parent
4f3db278a5
commit
cc7d2db478
|
@ -1,93 +1,93 @@
|
|||
package com.muyu.breakdown.DTO;
|
||||
|
||||
|
||||
import com.muyu.breakdown.domain.Messages;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-09-18-15:00
|
||||
* @ Version:1.0
|
||||
* @ Description:数据库连接层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Component
|
||||
public class MessageDTO {
|
||||
private static final String DB_URL = "jdbc:mysql://106.54.193.225:3306/one";
|
||||
private static final String USER = "root";
|
||||
private static final String PASSWORD = "bawei2112A";
|
||||
|
||||
// 2. 建立数据库连接
|
||||
Connection connection;
|
||||
// 构造函数,初始化数据库连接
|
||||
// 保存消息到数据库
|
||||
public void saveMessage(Messages message) {
|
||||
String sql = "INSERT INTO sys_messages (sender_id, receiver_id, content) VALUES (?, ?, ?)";
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
connection = DriverManager.getConnection(DB_URL, USER, PASSWORD);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||
preparedStatement.setInt(1, message.getSenderId());
|
||||
preparedStatement.setInt(2, message.getReceiverId());
|
||||
preparedStatement.setString(3, message.getContent());
|
||||
// 执行添加操作
|
||||
preparedStatement.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取所有消息
|
||||
public List<Messages> getAllMessages(int receiverId){
|
||||
String sql = "SELECT * FROM sys_messages WHERE receiver_id = ?";
|
||||
try {
|
||||
Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
List<Messages> messages = new ArrayList<>();
|
||||
try {
|
||||
connection = DriverManager.getConnection(DB_URL, USER, PASSWORD);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||
preparedStatement.setInt(1, receiverId);
|
||||
// 执行查询操作
|
||||
ResultSet rs = preparedStatement.executeQuery();
|
||||
while (rs.next()) {
|
||||
Messages message = new Messages(rs.getInt("sender_id"), receiverId, rs.getString("content"));
|
||||
|
||||
// 添加到消息列表
|
||||
messages.add(message);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
connection.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// 返回消息列表
|
||||
return messages;
|
||||
}
|
||||
|
||||
}
|
||||
//package com.muyu.breakdown.DTO;
|
||||
//
|
||||
//
|
||||
//import com.muyu.breakdown.domain.Messages;
|
||||
//import org.springframework.beans.factory.annotation.Autowired;
|
||||
//import org.springframework.stereotype.Component;
|
||||
//
|
||||
//import java.sql.*;
|
||||
//import java.util.*;
|
||||
//
|
||||
///**
|
||||
// * @ Tool:IntelliJ IDEA
|
||||
// * @ Author:CHX
|
||||
// * @ Date:2024-09-18-15:00
|
||||
// * @ Version:1.0
|
||||
// * @ Description:数据库连接层
|
||||
// * @author Lenovo
|
||||
// */
|
||||
//@Component
|
||||
//public class MessageDTO {
|
||||
// private static final String DB_URL = "jdbc:mysql://106.54.193.225:3306/one";
|
||||
// private static final String USER = "root";
|
||||
// private static final String PASSWORD = "bawei2112A";
|
||||
//
|
||||
// // 2. 建立数据库连接
|
||||
// Connection connection;
|
||||
// // 构造函数,初始化数据库连接
|
||||
// // 保存消息到数据库
|
||||
// public void saveMessage(Messages message) {
|
||||
// String sql = "INSERT INTO sys_messages (sender_id, receiver_id, content) VALUES (?, ?, ?)";
|
||||
// try {
|
||||
// Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
// } catch (ClassNotFoundException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// try {
|
||||
// connection = DriverManager.getConnection(DB_URL, USER, PASSWORD);
|
||||
// } catch (SQLException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||
// preparedStatement.setInt(1, message.getSenderId());
|
||||
// preparedStatement.setInt(2, message.getReceiverId());
|
||||
// preparedStatement.setString(3, message.getContent());
|
||||
// // 执行添加操作
|
||||
// preparedStatement.executeUpdate();
|
||||
// } catch (SQLException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// try {
|
||||
// connection.close();
|
||||
// } catch (SQLException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// // 获取所有消息
|
||||
// public List<Messages> getAllMessages(int receiverId){
|
||||
// String sql = "SELECT * FROM sys_messages WHERE receiver_id = ?";
|
||||
// try {
|
||||
// Class.forName("com.mysql.cj.jdbc.Driver");
|
||||
// } catch (ClassNotFoundException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// List<Messages> messages = new ArrayList<>();
|
||||
// try {
|
||||
// connection = DriverManager.getConnection(DB_URL, USER, PASSWORD);
|
||||
// } catch (SQLException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
|
||||
// preparedStatement.setInt(1, receiverId);
|
||||
// // 执行查询操作
|
||||
// ResultSet rs = preparedStatement.executeQuery();
|
||||
// while (rs.next()) {
|
||||
// Messages message = new Messages(rs.getInt("sender_id"), receiverId, rs.getString("content"));
|
||||
//
|
||||
// // 添加到消息列表
|
||||
// messages.add(message);
|
||||
// }
|
||||
// } catch (SQLException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// try {
|
||||
// connection.close();
|
||||
// } catch (SQLException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// // 返回消息列表
|
||||
// return messages;
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
|
|
@ -52,16 +52,4 @@ public class FaultLog extends BaseEntity{
|
|||
@Excel(name = "结束报警时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date endTime;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("faultCode", getFaultCode())
|
||||
.append("carVin", getCarVin())
|
||||
.append("startTime", getStartTime())
|
||||
.append("endTime", getEndTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.muyu.breakdown.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-09-20-15:31
|
||||
* @ Version:1.0
|
||||
* @ Description:
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class MessageMap {
|
||||
private String key;
|
||||
private String value;
|
||||
}
|
|
@ -27,26 +27,13 @@ public class Messages {
|
|||
@Excel(name = "消息ID")
|
||||
private Long id;
|
||||
@Excel(name = "发送者ID")
|
||||
private Integer senderId;
|
||||
private String senderId;
|
||||
@Excel(name = "接收者ID")
|
||||
private Integer receiverId;
|
||||
private String receiverId;
|
||||
@Excel(name = "消息内容")
|
||||
private String content;
|
||||
@Excel(name = "发送时间")
|
||||
private Date createTime;
|
||||
@Excel(name = "消息状态")
|
||||
private String status;
|
||||
|
||||
public Messages(int senderId, int receiverId, String content) {
|
||||
this.senderId = senderId;
|
||||
this.receiverId = receiverId;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public Messages(Integer senderId, Integer receiverId, String content, Date createTime) {
|
||||
this.senderId = senderId;
|
||||
this.receiverId = receiverId;
|
||||
this.content = content;
|
||||
this.createTime = createTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package com.muyu.breakdown.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-09-20-15:35
|
||||
* @ Version:1.0
|
||||
* @ Description:报文
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@TableName("sys_car_message")
|
||||
public class SysCarMessage {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 车辆型号编码
|
||||
*/
|
||||
private String modelCode;
|
||||
/**
|
||||
* 车辆报文类型编码
|
||||
*/
|
||||
private String messageTypeCode;
|
||||
/**
|
||||
* 开始位下标
|
||||
*/
|
||||
private String messageStartIndex;
|
||||
/**
|
||||
* 结束位下标
|
||||
*/
|
||||
private String messageEndIndex;
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.muyu.breakdown.config;
|
||||
|
||||
import org.springframework.amqp.core.Binding;
|
||||
import org.springframework.amqp.core.BindingBuilder;
|
||||
import org.springframework.amqp.core.FanoutExchange;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
/**
|
||||
* 绑定交换机与队列
|
||||
* */
|
||||
@Configuration
|
||||
public class RabbitMQConfig {
|
||||
|
||||
// 1.生命注册fanout模式的交换机
|
||||
@Bean
|
||||
public FanoutExchange fanoutExchange(){
|
||||
//1.fanout模式的路由名称 2.是否持久化 3. 是否自动删除
|
||||
return new FanoutExchange("fanout",true,false);
|
||||
}
|
||||
// 2.生命队列 sms.fanout.queue email.fanout.queue,duanxin.fanout.queue
|
||||
@Bean
|
||||
public Queue duanxinQueue(){
|
||||
return new Queue("duanxin",true);
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public Queue emailQueue(){
|
||||
return new Queue("email",false);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue smsQueue(){
|
||||
return new Queue("sms",false);
|
||||
}
|
||||
|
||||
// 3.完成绑定关系(队列和交换机完成绑定关系
|
||||
@Bean
|
||||
public Binding duanxinExchange(){
|
||||
return BindingBuilder.bind(duanxinQueue()).to(fanoutExchange());
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public Binding emailExchange(){
|
||||
return BindingBuilder.bind(emailQueue()).to(fanoutExchange());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding smsExchange(){
|
||||
return BindingBuilder.bind(smsQueue()).to(fanoutExchange());
|
||||
}
|
||||
|
||||
// 4.生命注册fanout模式的交换机
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.muyu.breakdown.config;
|
||||
|
||||
import org.springframework.amqp.core.*;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* 绑定交换机与队列
|
||||
* */
|
||||
@Configuration
|
||||
public class RabbitMQDirectConfig {
|
||||
/**
|
||||
* 与fanout发布订阅模式不同的是 Direct 需要在Binding规定对应的 路由名称
|
||||
* */
|
||||
// 1.生命注册fanout模式的交换机
|
||||
@Bean
|
||||
public DirectExchange directExchange(){
|
||||
//1.fanout模式的路由名称 2.是否持久化 3. 是否自动删除
|
||||
return new DirectExchange("direct",true,false);
|
||||
}
|
||||
// 2.生命队列 sms.fanout.queue email.fanout.queue,duanxin.fanout.queue
|
||||
@Bean
|
||||
public Queue directduanxinQueue(){
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("x-delayed-letter-exchange","direct");
|
||||
map.put("x-delayed-routing-key","directduanxin");
|
||||
map.put("x-message-ttl",10000);
|
||||
return QueueBuilder.durable("directduanxin").withArguments(map).build();
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public Queue directemailQueue(){
|
||||
return new Queue("directemail",false);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue directsmsQueue(){
|
||||
return new Queue("directsms",false);
|
||||
}
|
||||
|
||||
// 3.完成绑定关系(队列和交换机完成绑定关系
|
||||
@Bean
|
||||
public Binding directduanxinExchange(){
|
||||
return BindingBuilder.bind(directduanxinQueue()).to(directExchange()).with("directduanxin");
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public Binding directemailExchange(){
|
||||
return BindingBuilder.bind(directemailQueue()).to(directExchange()).with("directemail");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding directsmsExchange(){
|
||||
return BindingBuilder.bind(directsmsQueue()).to(directExchange()).with("directsms");
|
||||
}
|
||||
|
||||
// 4.生命注册fanout模式的交换机
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.muyu.breakdown.config;
|
||||
|
||||
import org.springframework.amqp.core.Binding;
|
||||
import org.springframework.amqp.core.BindingBuilder;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.core.TopicExchange;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 绑定交换机与队列
|
||||
* */
|
||||
@Configuration
|
||||
public class RabbitMQTopicConfig {
|
||||
/**
|
||||
* 与fanout发布订阅模式不同的是 Direct 需要在Binding规定对应的 路由名称
|
||||
* */
|
||||
// 1.生命注册fanout模式的交换机
|
||||
@Bean
|
||||
public TopicExchange topicExchange(){
|
||||
//1.fanout模式的路由名称 2.是否持久化 3. 是否自动删除
|
||||
return new TopicExchange("topic",true,false);
|
||||
}
|
||||
// 2.生命队列 sms.fanout.queue email.fanout.queue,duanxin.fanout.queue
|
||||
@Bean
|
||||
public Queue topicduanxinQueue(){
|
||||
return new Queue("topicduanxin.test.one",true);
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public Queue topicemailQueue(){
|
||||
return new Queue("topicemail.test.two",false);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Queue topicsmsQueue(){
|
||||
return new Queue("topicsms.test.three",false);
|
||||
}
|
||||
|
||||
// 3.完成绑定关系(队列和交换机完成绑定关系
|
||||
@Bean
|
||||
public Binding topicduanxinExchange(){
|
||||
return BindingBuilder.bind(topicduanxinQueue()).to(topicExchange()).with("topic.#");
|
||||
}
|
||||
|
||||
|
||||
@Bean
|
||||
public Binding topicemailExchange(){
|
||||
return BindingBuilder.bind(topicemailQueue()).to(topicExchange()).with("topic.*");
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding topicsmsExchange(){
|
||||
return BindingBuilder.bind(topicsmsQueue()).to(topicExchange()).with("topic.test.#");
|
||||
}
|
||||
|
||||
// 4.生命注册fanout模式的交换机
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.breakdown.controller;
|
||||
|
||||
import com.muyu.breakdown.domain.BreakDown;
|
||||
import com.muyu.breakdown.domain.MessageMap;
|
||||
import com.muyu.breakdown.service.BreakDownService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
|
@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ Tool:IntelliJ IDEA
|
||||
|
@ -105,5 +107,9 @@ public class BreakDownController extends BaseController {
|
|||
return success();
|
||||
}
|
||||
|
||||
public Result getMessages(MessageMap messageMap) {
|
||||
Map<String,String> messages =breakDownService.getMessages(messageMap);
|
||||
return Result.success(messages);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.breakdown.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.muyu.breakdown.domain.Messages;
|
||||
import com.muyu.breakdown.service.BreakDownService;
|
||||
import com.muyu.breakdown.service.StationMessageService;
|
||||
|
@ -23,15 +24,19 @@ import java.util.List;
|
|||
public class StationMessageController extends BaseController {
|
||||
@Autowired
|
||||
private StationMessageService stationMessageService;
|
||||
@PostMapping("/send")
|
||||
public void sendMessage(@RequestBody Messages messages) {
|
||||
stationMessageService.sendMessage(messages.getSenderId(), messages.getReceiverId(), messages.getContent());
|
||||
}
|
||||
|
||||
@GetMapping("/{userId}")
|
||||
public List<Messages> getMessages(@PathVariable("userId") int userId) {
|
||||
return stationMessageService.getUserMessages(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前用户id获取站内信列表
|
||||
* @param receiverId 当前用户id
|
||||
* @return 站内信列表
|
||||
*/
|
||||
@GetMapping("/getMessageList")
|
||||
public Result<List<Messages>> list(@RequestParam("receiverId") String receiverId){
|
||||
List<Messages> list = stationMessageService.list(new LambdaQueryWrapper<>() {{
|
||||
eq(Messages::getReceiverId, receiverId);
|
||||
}});
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.muyu.breakdown.controller;
|
||||
|
||||
import com.muyu.breakdown.service.SysCarMessageService;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-09-20-15:41
|
||||
* @ Version:1.0
|
||||
* @ Description:报文模版控制层
|
||||
* @author Lenovo
|
||||
*/
|
||||
@RestController
|
||||
public class SysCarMessageController extends BaseController {
|
||||
@Autowired
|
||||
private SysCarMessageService sysCarMessageService;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.breakdown.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.muyu.breakdown.domain.SysCarMessage;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-09-20-15:54
|
||||
* @ Version:1.0
|
||||
* @ Description:
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysCarMessageMapper extends MPJBaseMapper<SysCarMessage> {
|
||||
}
|
|
@ -2,8 +2,10 @@ package com.muyu.breakdown.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.breakdown.domain.BreakDown;
|
||||
import com.muyu.breakdown.domain.MessageMap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ Tool:IntelliJ IDEA
|
||||
|
@ -37,4 +39,5 @@ public interface BreakDownService extends IService<BreakDown> {
|
|||
*/
|
||||
Boolean checkIdUnique(BreakDown breakDown);
|
||||
|
||||
Map<String, String> getMessages(MessageMap messageMap);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import java.util.List;
|
|||
* @author Lenovo
|
||||
*/
|
||||
public interface StationMessageService extends IService<Messages> {
|
||||
void sendMessage(Integer senderId, Integer receiverId, String content);
|
||||
|
||||
List<Messages> getUserMessages(int userId);
|
||||
List<Messages> getMessageList(String receiverId);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
package com.muyu.breakdown.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.breakdown.domain.SysCarMessage;
|
||||
|
||||
/**
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-09-20-15:42
|
||||
* @ Version:1.0
|
||||
* @ Description:
|
||||
* @author Lenovo
|
||||
*/
|
||||
public interface SysCarMessageService extends IService<SysCarMessage> {
|
||||
}
|
|
@ -3,13 +3,22 @@ package com.muyu.breakdown.service.impl;
|
|||
import cn.hutool.core.lang.Assert;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.muyu.breakdown.domain.BreakDown;
|
||||
import com.muyu.breakdown.domain.MessageMap;
|
||||
import com.muyu.breakdown.domain.SysCarMessage;
|
||||
import com.muyu.breakdown.mapper.BreakDownMapper;
|
||||
import com.muyu.breakdown.service.BreakDownService;
|
||||
import com.muyu.breakdown.service.SysCarMessageService;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ Tool:IntelliJ IDEA
|
||||
|
@ -21,6 +30,11 @@ import java.util.List;
|
|||
*/
|
||||
@Service
|
||||
public class BreakDownServiceImpl extends ServiceImpl<BreakDownMapper, BreakDown> implements BreakDownService {
|
||||
|
||||
@Autowired
|
||||
private SysCarMessageService sysCarMessageService;
|
||||
@Autowired
|
||||
private RabbitTemplate rabbitTemplate;
|
||||
/**
|
||||
* 精确查询车辆故障
|
||||
*
|
||||
|
@ -68,5 +82,16 @@ public class BreakDownServiceImpl extends ServiceImpl<BreakDownMapper, BreakDown
|
|||
return this.count(queryWrapper) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMessages(MessageMap messageMap) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// @RabbitListener(queues = "car.message.queue")
|
||||
// private void sendMessage(String message) {
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
package com.muyu.breakdown.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.breakdown.DTO.MessageDTO;
|
||||
import com.muyu.breakdown.domain.Messages;
|
||||
import com.muyu.breakdown.mapper.StationMessageMapper;
|
||||
import com.muyu.breakdown.service.StationMessageService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -26,20 +23,13 @@ import java.util.List;
|
|||
public class StationMessageServiceImpl
|
||||
extends ServiceImpl<StationMessageMapper, Messages>
|
||||
implements StationMessageService {
|
||||
|
||||
@Autowired
|
||||
private MessageDTO messageDTO;
|
||||
private StationMessageMapper stationMessageMapper;
|
||||
|
||||
@Override
|
||||
public void sendMessage(Integer senderId, Integer receiverId, String content) {
|
||||
Messages message = new Messages(senderId, receiverId, content);
|
||||
// 保存消息到数据库
|
||||
messageDTO.saveMessage(message);
|
||||
public List<Messages> getMessageList(String receiverId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Messages> getUserMessages(int userId) {
|
||||
// 获取用户收到的消息
|
||||
return messageDTO.getAllMessages(userId);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.breakdown.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.breakdown.domain.SysCarMessage;
|
||||
import com.muyu.breakdown.mapper.SysCarMessageMapper;
|
||||
import com.muyu.breakdown.service.SysCarMessageService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ Tool:IntelliJ IDEA
|
||||
* @ Author:CHX
|
||||
* @ Date:2024-09-20-15:42
|
||||
* @ Version:1.0
|
||||
* @ Description:
|
||||
* @author Lenovo
|
||||
*/
|
||||
@Service
|
||||
public class SysCarMessageServiceImpl extends ServiceImpl<SysCarMessageMapper, SysCarMessage> implements SysCarMessageService {
|
||||
}
|
Loading…
Reference in New Issue