Compare commits

..

3 Commits
master ... dev

Author SHA1 Message Date
冷调 063dff79a1 编写故障日志的代码 2024-09-20 12:29:11 +08:00
冷调 3bc7c3c22d 对mybatisplus的依赖以及分页插件的配置进行修改 2024-09-17 22:41:48 +08:00
冷调 3fface7039 故障管理CURD 2024-09-17 22:00:38 +08:00
24 changed files with 776 additions and 56 deletions

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 47.116.173.119:8848 addr: 106.54.193.225:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one namespace: one

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 47.116.173.119:8848 addr: 106.54.193.225:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one namespace: one

View File

@ -21,16 +21,6 @@
<groupId>com.muyu</groupId> <groupId>com.muyu</groupId>
<artifactId>cloud-common-core</artifactId> <artifactId>cloud-common-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.7</version>
</dependency>
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join-boot-starter</artifactId>
<version>1.4.11</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -0,0 +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.*;
/**
* @ ToolIntelliJ IDEA
* @ AuthorCHX
* @ Date2024-09-18-15:00
* @ Version1.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;
}
}

View File

@ -5,8 +5,11 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.annotation.Excel; import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity; import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/** /**
* @author Lenovo * @author Lenovo
@ -18,6 +21,9 @@ import lombok.EqualsAndHashCode;
*/ */
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@Data @Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("sys_car_fault") @TableName("sys_car_fault")
public class BreakDown extends BaseEntity { public class BreakDown extends BaseEntity {
@ -40,11 +46,6 @@ public class BreakDown extends BaseEntity {
*/ */
@Excel(name = "故障类型") @Excel(name = "故障类型")
private String faultType; private String faultType;
/**
* VIN
*/
@Excel(name = "车辆VIN")
private String carVin;
/** /**
* *
*/ */
@ -70,14 +71,4 @@ public class BreakDown extends BaseEntity {
*/ */
@Excel(name = "报警状态") @Excel(name = "报警状态")
private String faultStatus; private String faultStatus;
/**
*
*/
@Excel(name = "故障描述信息")
private String faultDesc;
/**
* (1. 2. 3. 4.)
*/
@Excel(name = "启用状态")
private String state;
} }

View File

@ -0,0 +1,67 @@
package com.muyu.breakdown.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
/**
* fault_log
*
* @author muyu
* @date 2024-09-20
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Setter
@Getter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("fault_log")
public class FaultLog extends BaseEntity{
private static final long serialVersionUID = 1L;
/** id */
@TableId( type = IdType.AUTO)
private Long id;
/** 故障码 */
@Excel(name = "故障码")
private String faultCode;
/** 车辆VIN */
@Excel(name = "车辆VIN")
private String carVin;
/** 开始报警时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "开始报警时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date startTime;
/** 结束报警时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@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();
}
}

View File

@ -0,0 +1,52 @@
package com.muyu.breakdown.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
* @ ToolIntelliJ IDEA
* @ AuthorCHX
* @ Date2024-09-18-14:51
* @ Version1.0
* @ Description
* @author Lenovo
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_messages")
public class Messages {
@TableId(value = "id", type = IdType.AUTO)
@Excel(name = "消息ID")
private Long id;
@Excel(name = "发送者ID")
private Integer senderId;
@Excel(name = "接收者ID")
private Integer 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;
}
}

View File

@ -15,23 +15,23 @@ import org.springframework.context.annotation.Configuration;
* @ Descriptionmybatisplus * @ Descriptionmybatisplus
* @author Lenovo * @author Lenovo
*/ */
@Configuration //@Configuration
public class MybatisPlusConfig { //public class MybatisPlusConfig {
/** // /**
* // * 添加分页插件
*/ // */
@Bean // @Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() { // public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); // MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
// 如果配置多个插件, 切记分页最后添加 // // 如果配置多个插件, 切记分页最后添加
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
// 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType // // 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType
return interceptor; // return interceptor;
} // }
@Bean // @Bean
public MybatisConfiguration mybatisConfiguration(){ // public MybatisConfiguration mybatisConfiguration(){
MybatisConfiguration configuration = new MybatisConfiguration(); // MybatisConfiguration configuration = new MybatisConfiguration();
return configuration; // return configuration;
} // }
//
} //}

View File

@ -1,10 +1,20 @@
package com.muyu.breakdown.controller; package com.muyu.breakdown.controller;
import com.muyu.breakdown.domain.BreakDown;
import com.muyu.breakdown.service.BreakDownService; import com.muyu.breakdown.service.BreakDownService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.core.web.controller.BaseController; import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.security.utils.SecurityUtils;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/** /**
* @ ToolIntelliJ IDEA * @ ToolIntelliJ IDEA
@ -20,6 +30,80 @@ public class BreakDownController extends BaseController {
@Autowired @Autowired
private BreakDownService breakDownService; private BreakDownService breakDownService;
/**
*
*/
@RequiresPermissions("breakdown:breakdown:list")
@GetMapping("/list")
public Result<TableDataInfo<BreakDown>> list(BreakDown breakDown)
{
startPage();
List<BreakDown> list = breakDownService.selectBreakDownList(breakDown);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("breakdown:breakdown:export")
@PostMapping("/export")
public void export(HttpServletResponse response, BreakDown breakDown)
{
List<BreakDown> list = breakDownService.selectBreakDownList(breakDown);
ExcelUtil<BreakDown> util = new ExcelUtil<BreakDown>(BreakDown.class);
util.exportExcel(response, list, "车辆故障数据");
}
/**
*
*/
@RequiresPermissions("breakdown:breakdown:query")
@GetMapping(value = "/{id}")
public Result<List<BreakDown>> getInfo(@PathVariable("id") Long id)
{
return success(breakDownService.selectBreakDownById(id));
}
/**
*
*/
@RequiresPermissions("breakdown:breakdown:add")
@PostMapping
public Result<Integer> add(
@Validated @RequestBody BreakDown breakDown)
{
if (breakDownService.checkIdUnique(breakDown)) {
return error("新增 车辆故障 '" + breakDown + "'失败,车辆故障已存在");
}
breakDown.setCreateBy(SecurityUtils.getUsername());
return toAjax(breakDownService.save(breakDown));
}
/**
*
*/
@RequiresPermissions("breakdown:breakdown:edit")
@PutMapping
public Result<Integer> edit(
@Validated @RequestBody BreakDown breakDown)
{
if (!breakDownService.checkIdUnique(breakDown)) {
return error("修改 车辆故障 '" + breakDown + "'失败,车辆故障不存在");
}
breakDown.setUpdateBy(SecurityUtils.getUsername());
return toAjax(breakDownService.updateById(breakDown));
}
/**
*
*/
@RequiresPermissions("breakdown:breakdown:remove")
@DeleteMapping("/{ids}")
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
{
breakDownService.removeBatchByIds(Arrays.asList(ids));
return success();
}
} }

View File

@ -0,0 +1,113 @@
package com.muyu.breakdown.controller;
import java.util.Arrays;
import java.util.List;
import com.muyu.breakdown.domain.FaultLog;
import com.muyu.breakdown.service.IFaultLogService;
import jakarta.servlet.http.HttpServletResponse;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.utils.poi.ExcelUtil;
import com.muyu.common.security.utils.SecurityUtils;
import org.springframework.validation.annotation.Validated;
import com.muyu.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author muyu
* @date 2024-09-20
*/
@RestController
@RequestMapping("/log")
public class FaultLogController extends BaseController
{
@Resource
private IFaultLogService faultLogService;
/**
*
*/
@RequiresPermissions("platform:log:list")
@GetMapping("/list")
public Result<TableDataInfo<FaultLog>> list(FaultLog faultLog)
{
startPage();
List<FaultLog> list = faultLogService.selectFaultLogList(faultLog);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("platform:log:export")
@PostMapping("/export")
public void export(HttpServletResponse response, FaultLog faultLog)
{
List<FaultLog> list = faultLogService.selectFaultLogList(faultLog);
ExcelUtil<FaultLog> util = new ExcelUtil<FaultLog>(FaultLog.class);
util.exportExcel(response, list, "故障日志数据");
}
/**
*
*/
@RequiresPermissions("platform:log:query")
@GetMapping(value = "/{id}")
public Result<List<FaultLog>> getInfo(@PathVariable("id") Long id)
{
return success(faultLogService.selectFaultLogById(id));
}
/**
*
*/
@RequiresPermissions("platform:log:add")
@PostMapping
public Result<Integer> add(
@Validated @RequestBody FaultLog faultLog)
{
if (faultLogService.checkIdUnique(faultLog)) {
return error("新增 故障日志 '" + faultLog + "'失败,故障日志已存在");
}
faultLog.setCreateBy(SecurityUtils.getUsername());
return toAjax(faultLogService.save(faultLog));
}
/**
*
*/
@RequiresPermissions("platform:log:edit")
@PutMapping
public Result<Integer> edit(
@Validated @RequestBody FaultLog faultLog)
{
if (!faultLogService.checkIdUnique(faultLog)) {
return error("修改 故障日志 '" + faultLog + "'失败,故障日志不存在");
}
faultLog.setUpdateBy(SecurityUtils.getUsername());
return toAjax(faultLogService.updateById(faultLog));
}
/**
*
*/
@RequiresPermissions("platform:log:remove")
@DeleteMapping("/{ids}")
public Result<Integer> remove(@PathVariable("ids") Long[] ids)
{
faultLogService.removeBatchByIds(Arrays.asList(ids));
return success();
}
}

View File

@ -0,0 +1,37 @@
package com.muyu.breakdown.controller;
import com.muyu.breakdown.domain.Messages;
import com.muyu.breakdown.service.BreakDownService;
import com.muyu.breakdown.service.StationMessageService;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @ ToolIntelliJ IDEA
* @ AuthorCHX
* @ Date2024-09-18-12:01
* @ Version1.0
* @ Description
* @author Lenovo
*/
@RestController
@RequestMapping("/stationMessage")
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);
}
}

View File

@ -0,0 +1,17 @@
package com.muyu.breakdown.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.breakdown.domain.FaultLog;
import org.apache.ibatis.annotations.Mapper;
/**
* Mapper
*
* @author muyu
* @date 2024-09-20
*/
@Mapper
public interface FaultLogMapper extends BaseMapper<FaultLog>{
}

View File

@ -0,0 +1,18 @@
package com.muyu.breakdown.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.github.yulichang.base.MPJBaseMapper;
import com.muyu.breakdown.domain.Messages;
import org.apache.ibatis.annotations.Mapper;
/**
* @ ToolIntelliJ IDEA
* @ AuthorCHX
* @ Date2024-09-18-14:57
* @ Version1.0
* @ Description
* @author Lenovo
*/
@Mapper
public interface StationMessageMapper extends MPJBaseMapper<Messages> {
}

View File

@ -3,6 +3,8 @@ package com.muyu.breakdown.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.breakdown.domain.BreakDown; import com.muyu.breakdown.domain.BreakDown;
import java.util.List;
/** /**
* @ ToolIntelliJ IDEA * @ ToolIntelliJ IDEA
* @ AuthorCHX * @ AuthorCHX
@ -12,4 +14,27 @@ import com.muyu.breakdown.domain.BreakDown;
* @author Lenovo * @author Lenovo
*/ */
public interface BreakDownService extends IService<BreakDown> { public interface BreakDownService extends IService<BreakDown> {
/**
*
*
* @param id
* @return
*/
public BreakDown selectBreakDownById(Long id);
/**
*
*
* @param breakDown
* @return
*/
public List<BreakDown> selectBreakDownList(BreakDown breakDown);
/**
* id
* @param breakDown
* @return
*/
Boolean checkIdUnique(BreakDown breakDown);
} }

View File

@ -0,0 +1,37 @@
package com.muyu.breakdown.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.breakdown.domain.FaultLog;
/**
* Service
*
* @author muyu
* @date 2024-09-20
*/
public interface IFaultLogService extends IService<FaultLog> {
/**
*
*
* @param id
* @return
*/
public FaultLog selectFaultLogById(Long id);
/**
*
*
* @param faultLog
* @return
*/
public List<FaultLog> selectFaultLogList(FaultLog faultLog);
/**
* id
* @param faultLog
* @return
*/
Boolean checkIdUnique(FaultLog faultLog);
}

View File

@ -0,0 +1,20 @@
package com.muyu.breakdown.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.breakdown.domain.Messages;
import java.util.List;
/**
* @ ToolIntelliJ IDEA
* @ AuthorCHX
* @ Date2024-09-18-14:56
* @ Version1.0
* @ Description
* @author Lenovo
*/
public interface StationMessageService extends IService<Messages> {
void sendMessage(Integer senderId, Integer receiverId, String content);
List<Messages> getUserMessages(int userId);
}

View File

@ -1,11 +1,16 @@
package com.muyu.breakdown.service.impl; 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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.breakdown.domain.BreakDown; import com.muyu.breakdown.domain.BreakDown;
import com.muyu.breakdown.mapper.BreakDownMapper; import com.muyu.breakdown.mapper.BreakDownMapper;
import com.muyu.breakdown.service.BreakDownService; import com.muyu.breakdown.service.BreakDownService;
import com.muyu.common.core.utils.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* @ ToolIntelliJ IDEA * @ ToolIntelliJ IDEA
* @ AuthorCHX * @ AuthorCHX
@ -16,4 +21,52 @@ import org.springframework.stereotype.Service;
*/ */
@Service @Service
public class BreakDownServiceImpl extends ServiceImpl<BreakDownMapper, BreakDown> implements BreakDownService { public class BreakDownServiceImpl extends ServiceImpl<BreakDownMapper, BreakDown> implements BreakDownService {
/**
*
*
* @param id
* @return
*/
@Override
public BreakDown selectBreakDownById(Long id)
{
LambdaQueryWrapper<BreakDown> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(id, "id不可为空");
queryWrapper.eq(BreakDown::getId, id);
return this.getOne(queryWrapper);
}
/**
*
*
* @param breakDown
* @return
*/
@Override
public List<BreakDown> selectBreakDownList(BreakDown breakDown)
{
LambdaQueryWrapper<BreakDown> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(breakDown.getFaultCode())){
queryWrapper.eq(BreakDown::getFaultCode, breakDown.getFaultCode());
}
if (StringUtils.isNotEmpty(breakDown.getFaultType())){
queryWrapper.eq(BreakDown::getFaultType, breakDown.getFaultType());
}
return this.list(queryWrapper);
}
/**
*
* @param breakDown
* @return
*/
@Override
public Boolean checkIdUnique(BreakDown breakDown) {
LambdaQueryWrapper<BreakDown> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BreakDown::getId, breakDown.getId());
return this.count(queryWrapper) > 0;
}
} }

View File

@ -0,0 +1,78 @@
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.domain.FaultLog;
import com.muyu.breakdown.mapper.FaultLogMapper;
import com.muyu.breakdown.service.IFaultLogService;
import com.muyu.common.core.utils.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.util.List;
/**
* Service
*
* @author muyu
* @date 2024-09-20
*/
@Service
public class FaultLogServiceImpl
extends ServiceImpl<FaultLogMapper, FaultLog>
implements IFaultLogService {
/**
*
*
* @param id
* @return
*/
@Override
public FaultLog selectFaultLogById(Long id)
{
LambdaQueryWrapper<FaultLog> queryWrapper = new LambdaQueryWrapper<>();
Assert.notNull(id, "id不可为空");
queryWrapper.eq(FaultLog::getId, id);
return this.getOne(queryWrapper);
}
/**
*
*
* @param faultLog
* @return
*/
@Override
public List<FaultLog> selectFaultLogList(FaultLog faultLog)
{
LambdaQueryWrapper<FaultLog> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotEmpty(faultLog.getFaultCode())){
queryWrapper.eq(FaultLog::getFaultCode, faultLog.getFaultCode());
}
if (StringUtils.isNotEmpty(faultLog.getCarVin())){
queryWrapper.eq(FaultLog::getCarVin, faultLog.getCarVin());
}
if (faultLog.getStartTime()!=null){
queryWrapper.eq(FaultLog::getStartTime, faultLog.getStartTime());
}
if (faultLog.getEndTime()!=null){
queryWrapper.eq(FaultLog::getEndTime, faultLog.getEndTime());
}
return this.list(queryWrapper);
}
/**
*
* @param faultLog
* @return
*/
@Override
public Boolean checkIdUnique(FaultLog faultLog) {
LambdaQueryWrapper<FaultLog> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(FaultLog::getId, faultLog.getId());
return this.count(queryWrapper) > 0;
}
}

View File

@ -0,0 +1,45 @@
package com.muyu.breakdown.service.impl;
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;
/**
* @ ToolIntelliJ IDEA
* @ AuthorCHX
* @ Date2024-09-18-14:56
* @ Version1.0
* @ Description
* @author Lenovo
*/
@Service
public class StationMessageServiceImpl
extends ServiceImpl<StationMessageMapper, Messages>
implements StationMessageService {
@Autowired
private MessageDTO messageDTO;
@Override
public void sendMessage(Integer senderId, Integer receiverId, String content) {
Messages message = new Messages(senderId, receiverId, content);
// 保存消息到数据库
messageDTO.saveMessage(message);
}
@Override
public List<Messages> getUserMessages(int userId) {
// 获取用户收到的消息
return messageDTO.getAllMessages(userId);
}
}

View File

@ -1,10 +1,10 @@
# Tomcat # Tomcat
server: server:
port: 9701 port: 9702
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 47.116.173.119:8848 addr: 106.54.193.225:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one namespace: one
@ -57,4 +57,4 @@ spring:
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
logging: logging:
level: level:
com.muyu.system.mapper: DEBUG com.muyu.breakdown.mapper: DEBUG

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 47.116.173.119:8848 addr: 106.54.193.225:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one namespace: one

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 47.116.173.119:8848 addr: 106.54.193.225:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one namespace: one

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 47.116.173.119:8848 addr: 106.54.193.225:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one namespace: one

View File

@ -4,7 +4,7 @@ server:
# nacos线上地址 # nacos线上地址
nacos: nacos:
addr: 47.116.173.119:8848 addr: 106.54.193.225:8848
user-name: nacos user-name: nacos
password: nacos password: nacos
namespace: one namespace: one