编写故障日志的代码
parent
3bc7c3c22d
commit
063dff79a1
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -46,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;
|
|
||||||
/**
|
/**
|
||||||
* 故障标签
|
* 故障标签
|
||||||
*/
|
*/
|
||||||
|
@ -76,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;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-18-14:51
|
||||||
|
* @ Version:1.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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-18-12:01
|
||||||
|
* @ Version:1.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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -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>{
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-18-14:57
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:站内信持久层
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface StationMessageMapper extends MPJBaseMapper<Messages> {
|
||||||
|
}
|
|
@ -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);
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-18-14:56
|
||||||
|
* @ Version:1.0
|
||||||
|
* @ Description:
|
||||||
|
* @author Lenovo
|
||||||
|
*/
|
||||||
|
public interface StationMessageService extends IService<Messages> {
|
||||||
|
void sendMessage(Integer senderId, Integer receiverId, String content);
|
||||||
|
|
||||||
|
List<Messages> getUserMessages(int userId);
|
||||||
|
}
|
|
@ -53,9 +53,6 @@ public class BreakDownServiceImpl extends ServiceImpl<BreakDownMapper, BreakDown
|
||||||
if (StringUtils.isNotEmpty(breakDown.getFaultType())){
|
if (StringUtils.isNotEmpty(breakDown.getFaultType())){
|
||||||
queryWrapper.eq(BreakDown::getFaultType, breakDown.getFaultType());
|
queryWrapper.eq(BreakDown::getFaultType, breakDown.getFaultType());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotEmpty(breakDown.getCarVin())){
|
|
||||||
queryWrapper.eq(BreakDown::getCarVin, breakDown.getCarVin());
|
|
||||||
}
|
|
||||||
return this.list(queryWrapper);
|
return this.list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Tool:IntelliJ IDEA
|
||||||
|
* @ Author:CHX
|
||||||
|
* @ Date:2024-09-18-14:56
|
||||||
|
* @ Version:1.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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue