Merge branch 'cbs' of http://git.znkjfw.com/ak/zn-cloud-wcs into aikai
# Conflicts: # yudao-module-grpc/yudao-module-grpc-biz/src/main/java/cn/iocoder/yudao/module/grpc/service/geometry/GeometryServiceImpl.java
This commit is contained in:
commit
ed3e68278b
7
pom.xml
7
pom.xml
@ -46,6 +46,7 @@
|
|||||||
<spring.boot.version>2.7.18</spring.boot.version>
|
<spring.boot.version>2.7.18</spring.boot.version>
|
||||||
<mapstruct.version>1.6.2</mapstruct.version>
|
<mapstruct.version>1.6.2</mapstruct.version>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<mqtt.version>1.2.5</mqtt.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -69,6 +70,12 @@
|
|||||||
<artifactId>grpc-client-spring-boot-starter</artifactId>
|
<artifactId>grpc-client-spring-boot-starter</artifactId>
|
||||||
<version>${grpc.version}</version>
|
<version>${grpc.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>${mqtt.version}</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
|
@ -24,18 +24,46 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 依赖服务 -->
|
<!-- 依赖服务 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
|
<artifactId>yudao-module-system-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.iocoder.cloud</groupId>
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
<artifactId>yudao-module-grpc-api</artifactId>
|
<artifactId>yudao-module-grpc-api</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-collections</groupId>
|
||||||
|
<artifactId>commons-collections</artifactId>
|
||||||
|
<version>3.2.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>cn.iocoder.cloud</groupId>
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
<artifactId>yudao-module-grpc-lib</artifactId>
|
<artifactId>yudao-module-grpc-lib</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.boot</groupId>
|
||||||
|
<artifactId>nacos-config-spring-boot-starter</artifactId>
|
||||||
|
<version>0.2.12</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger.core.v3</groupId>
|
<groupId>io.swagger.core.v3</groupId>
|
||||||
<artifactId>swagger-annotations</artifactId>
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.grpc.service.api;
|
package cn.iocoder.yudao.module.grpc.api;
|
||||||
|
|
||||||
import cn.iocoder.yudao.module.grpc.api.GrpcServiceApi;
|
|
||||||
import cn.iocoder.yudao.module.grpc.service.geometry.GeometryService;
|
import cn.iocoder.yudao.module.grpc.service.geometry.GeometryService;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
@ -1,16 +1,18 @@
|
|||||||
package cn.iocoder.yudao.module.grpc.service.geometry;
|
package cn.iocoder.yudao.module.grpc.service.geometry;
|
||||||
|
|
||||||
import com.google.protobuf.DoubleValue;
|
import com.google.protobuf.DoubleValue;
|
||||||
import device.proto.api.al.robotics.universal.nav.ChassisNavigationServiceGrpc;
|
|
||||||
import device.proto.model.common.Geometry;
|
import device.proto.model.common.Geometry;
|
||||||
import device.proto.model.common.Types;
|
import device.proto.model.common.Types;
|
||||||
|
import device.proto.robotics.nav.ChassisNavigationControlService;
|
||||||
|
import device.proto.robotics.nav.ChassisNavigationServiceGrpc;
|
||||||
import io.grpc.Channel;
|
import io.grpc.Channel;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.devh.springboot.autoconfigure.grpc.client.GrpcClient;
|
import net.devh.springboot.autoconfigure.grpc.client.GrpcClient;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class GeometryServiceImpl implements GeometryService{
|
public class GeometryServiceImpl implements GeometryService{
|
||||||
|
|
||||||
@ -19,18 +21,17 @@ public class GeometryServiceImpl implements GeometryService{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String onVehiclePoseUpdated() {
|
public String onVehiclePoseUpdated() {
|
||||||
|
log.info("测试GRPC连接");
|
||||||
|
|
||||||
ChassisNavigationServiceGrpc.ChassisNavigationServiceBlockingStub myServiceStub
|
ChassisNavigationServiceGrpc.ChassisNavigationServiceBlockingStub myServiceStub
|
||||||
= ChassisNavigationServiceGrpc.newBlockingStub(this.serverChannel);
|
= ChassisNavigationServiceGrpc.newBlockingStub(this.serverChannel);
|
||||||
Iterator<Geometry.Pose2d> pose2dIterator = myServiceStub.onVehiclePoseUpdated(null);
|
Iterator<ChassisNavigationControlService.Response> responseIterator = myServiceStub.onVehiclePoseUpdated(null);
|
||||||
while (pose2dIterator.hasNext()) {
|
while (responseIterator.hasNext()) {
|
||||||
Geometry.Pose2d next = pose2dIterator.next();
|
log.info("机车推送的消息 :{}",responseIterator.next());
|
||||||
System.out.println("返回的 " + next);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DoubleValue build = DoubleValue.newBuilder().build();
|
DoubleValue build = DoubleValue.newBuilder().build();
|
||||||
Types.Nothing nothing = myServiceStub.forkControl(build);
|
ChassisNavigationControlService.Response response = myServiceStub.forkControl(build);
|
||||||
return nothing.toString();
|
return response.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,31 @@
|
|||||||
|
# grpc配置
|
||||||
|
grpc:
|
||||||
|
# grpc clienT相关配置
|
||||||
|
client:
|
||||||
|
# 是服务端配置的名字,GrpcClient注解会用到
|
||||||
|
ChassisNavigationService:
|
||||||
|
# gRPC服务端地址
|
||||||
|
host: 192.168.10.78
|
||||||
|
port: 6914
|
||||||
|
# 是否开启保持连接(长连接)
|
||||||
|
enableKeepAlive: true
|
||||||
|
# 保持连接时长(默认20s)
|
||||||
|
keepAliveTimeout: 20
|
||||||
|
# 没有RPC调用时是否保持连接(默认false,可禁用避免额外消耗CPU)
|
||||||
|
keepAliveWithoutCalls: false
|
||||||
|
# 客户端负载均衡策略(round_robin(默认), pick_first)
|
||||||
|
defaultLoadBalancingPolicy: round_robin
|
||||||
|
# 通信类型
|
||||||
|
# plaintext | plaintext_upgrade | tls
|
||||||
|
# 明文通信且http/2 | 明文通信且升级http/1.1为http/2 | 使用TLS(ALPN/NPN)通信
|
||||||
|
negotiationType: plaintext
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
cloud:
|
cloud:
|
||||||
nacos:
|
nacos:
|
||||||
server-addr: 127.0.0.1:8848 # Nacos 服务器地址
|
server-addr: localhost:8848 # Nacos 服务器地址
|
||||||
username: # Nacos 账号
|
username: # Nacos 账号
|
||||||
password: # Nacos 密码
|
password: # Nacos 密码
|
||||||
discovery: # 【配置中心】配置项
|
discovery: # 【配置中心】配置项
|
||||||
|
@ -1,26 +1,3 @@
|
|||||||
# grpc配置
|
|
||||||
grpc:
|
|
||||||
# grpc clienT相关配置
|
|
||||||
client:
|
|
||||||
# 是服务端配置的名字,GrpcClient注解会用到
|
|
||||||
ChassisNavigationService:
|
|
||||||
# gRPC服务端地址
|
|
||||||
host: 192.168.10.211
|
|
||||||
port: 6914
|
|
||||||
# 是否开启保持连接(长连接)
|
|
||||||
enableKeepAlive: true
|
|
||||||
# 保持连接时长(默认20s)
|
|
||||||
keepAliveTimeout: 20
|
|
||||||
# 没有RPC调用时是否保持连接(默认false,可禁用避免额外消耗CPU)
|
|
||||||
keepAliveWithoutCalls: false
|
|
||||||
# 客户端负载均衡策略(round_robin(默认), pick_first)
|
|
||||||
defaultLoadBalancingPolicy: round_robin
|
|
||||||
# 通信类型
|
|
||||||
# plaintext | plaintext_upgrade | tls
|
|
||||||
# 明文通信且http/2 | 明文通信且升级http/1.1为http/2 | 使用TLS(ALPN/NPN)通信
|
|
||||||
negotiationType: plaintext
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
spring:
|
spring:
|
||||||
application:
|
application:
|
||||||
@ -45,7 +22,7 @@ spring:
|
|||||||
fail-on-empty-beans: false # 允许序列化无属性的 Bean
|
fail-on-empty-beans: false # 允许序列化无属性的 Bean
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 48082
|
port: 48084
|
||||||
|
|
||||||
|
|
||||||
debug: false
|
debug: false
|
||||||
|
@ -7,7 +7,7 @@ spring:
|
|||||||
# active: prod
|
# active: prod
|
||||||
|
|
||||||
server:
|
server:
|
||||||
port: 48082
|
port: 48084
|
||||||
|
|
||||||
# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件
|
# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件
|
||||||
logging:
|
logging:
|
||||||
|
@ -1,32 +1,69 @@
|
|||||||
syntax = "proto3";
|
syntax = "proto3";
|
||||||
|
|
||||||
package device.proto.api.al.robotics.universal.nav;
|
package device.proto.robotics.nav;
|
||||||
option csharp_namespace = "Al.Proto.Api.Robotics.Nav";
|
option csharp_namespace = "Al.Proto.Api.Robotics.Nav";
|
||||||
|
|
||||||
import "google/protobuf/empty.proto";
|
import "google/protobuf/empty.proto";
|
||||||
import "google/protobuf/wrappers.proto";
|
import "google/protobuf/wrappers.proto";
|
||||||
import "model/common/geometry.proto";
|
|
||||||
import "model/common/types.proto";
|
|
||||||
import "google/protobuf/struct.proto";
|
import "google/protobuf/struct.proto";
|
||||||
|
|
||||||
//位姿数组运动请求
|
//平面2d位姿
|
||||||
|
message Pose2d {
|
||||||
|
double x = 1; //平移x
|
||||||
|
double y = 2; //平移y
|
||||||
|
double yaw = 3; //角度
|
||||||
|
}
|
||||||
|
|
||||||
message NavigateThroughPosesRequest {
|
message NavigateThroughPosesRequest {
|
||||||
//位姿数组
|
repeated Pose2d pose2ds = 1;
|
||||||
repeated device.proto.model.common.Pose2d pose2ds = 1;
|
}
|
||||||
|
|
||||||
|
//摇杆控制请求
|
||||||
|
message JoyAgvRequest {
|
||||||
|
//x方向的速度
|
||||||
|
double vx = 1;
|
||||||
|
//y方向的速度
|
||||||
|
double vy = 2;
|
||||||
|
//角速度
|
||||||
|
double angle = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Response {
|
||||||
|
//响应的状态码
|
||||||
|
string status_code = 1;
|
||||||
|
//失败时的错误原因
|
||||||
|
string message = 2;
|
||||||
|
//附带的响应内容
|
||||||
|
google.protobuf.Struct data = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
service ChassisNavigationService {
|
service ChassisNavigationService {
|
||||||
//订阅车体位姿更新
|
//订阅车体位姿更新
|
||||||
rpc OnVehiclePoseUpdated(google.protobuf.Empty) returns (stream device.proto.model.common.Pose2d) {}
|
rpc OnVehiclePoseUpdated(google.protobuf.Empty) returns (stream Response) {}
|
||||||
//订阅跟踪的物体的位姿更新
|
//订阅跟踪的物体的位姿更新
|
||||||
rpc OnTrackingPoseUpdated(google.protobuf.Empty) returns (stream device.proto.model.common.Pose2d) {}
|
rpc OnTrackingPoseUpdated(google.protobuf.Empty) returns (stream Response) {}
|
||||||
//导航到指定位姿
|
//导航到指定位姿
|
||||||
rpc NavigateToPose(device.proto.model.common.Pose2d) returns (device.proto.model.common.Nothing) {}
|
rpc NavigateToPose(Pose2d) returns (Response) {}
|
||||||
//路径导航
|
//路径导航
|
||||||
rpc NavigateThroughPoses(NavigateThroughPosesRequest) returns (device.proto.model.common.Nothing) {}
|
rpc NavigateThroughPoses(NavigateThroughPosesRequest) returns (Response) {}
|
||||||
//货叉纵向控制
|
//货叉纵向控制
|
||||||
rpc ForkControl(google.protobuf.DoubleValue) returns (device.proto.model.common.Nothing) {}
|
rpc ForkControl(google.protobuf.DoubleValue) returns (Response) {}
|
||||||
|
//订阅机器人状态更新
|
||||||
|
rpc OnRobotStateUpdated(google.protobuf.Empty) returns (stream Response) {}
|
||||||
|
//监听订阅底盘主IMU数据的更新
|
||||||
|
rpc OnChassesMainImuDataUpdated(google.protobuf.Empty) returns (stream Response) {}
|
||||||
|
//监听车体用于定位的里程计更新
|
||||||
|
rpc OnChassesOdometryUpdated(google.protobuf.Empty) returns (stream Response) {}
|
||||||
|
//监听雷达里程计更新
|
||||||
|
rpc OnPerceptionLaserOdometryUpdated(google.protobuf.Empty) returns (stream Response) {}
|
||||||
|
//监听轮式里程计更新
|
||||||
|
rpc OnWheelOdometryUpdated(google.protobuf.Empty) returns (stream Response) {}
|
||||||
|
//机器人故障状态
|
||||||
|
rpc OnRobotFaultStatusUpdated(google.protobuf.Empty) returns (stream Response) {}
|
||||||
|
//摇杆车体运动控制
|
||||||
|
rpc JoyAgvControl(JoyAgvRequest) returns (Response) {}
|
||||||
|
//摇杆货叉运动控制
|
||||||
|
rpc JoyForkControl(google.protobuf.Struct) returns (Response) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.paho</groupId>
|
<groupId>org.eclipse.paho</groupId>
|
||||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
<version>1.2.5</version>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -163,4 +163,8 @@ public interface ErrorCodeConstants {
|
|||||||
// ========== 站内信发送 1-002-028-000 ==========
|
// ========== 站内信发送 1-002-028-000 ==========
|
||||||
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失");
|
ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1_002_028_000, "模板参数({})缺失");
|
||||||
|
|
||||||
|
// ========== 设备信息 1-002-029-000 ==========
|
||||||
|
ErrorCode INFORMATION_NOT_EXISTS = new ErrorCode(1_002_029_001, "设备信息不存在");
|
||||||
|
ErrorCode INFORMATION_MAC_EXIST = new ErrorCode(1_002_029_002, "此Mac地址已经存在");
|
||||||
|
ErrorCode INFORMATION_MAC_INPUT = new ErrorCode(1_002_029_003, "请输入Mac地址");
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,11 @@
|
|||||||
<artifactId>yudao-module-infra-api</artifactId>
|
<artifactId>yudao-module-infra-api</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.iocoder.cloud</groupId>
|
||||||
|
<artifactId>yudao-module-grpc-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- 业务组件 -->
|
<!-- 业务组件 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -0,0 +1,96 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.information;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationRespVO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
|
||||||
|
import cn.iocoder.yudao.module.system.service.information.DeviceInformationService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
|
||||||
|
import javax.validation.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
||||||
|
|
||||||
|
|
||||||
|
@Tag(name = "管理后台 - 设备信息")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/system/device/information")
|
||||||
|
@Validated
|
||||||
|
public class DeviceInformationController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DeviceInformationService informationService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建设备信息")
|
||||||
|
@PreAuthorize("@ss.hasPermission('device:information:create')")
|
||||||
|
public CommonResult<Long> createInformation(@Valid @RequestBody DeviceInformationSaveReqVO createReqVO) {
|
||||||
|
return success(informationService.createInformation(createReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "更新设备信息")
|
||||||
|
@PreAuthorize("@ss.hasPermission('device:information:update')")
|
||||||
|
public CommonResult<Boolean> updateInformation(@Valid @RequestBody DeviceInformationSaveReqVO updateReqVO) {
|
||||||
|
informationService.updateInformation(updateReqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("/delete")
|
||||||
|
@Operation(summary = "删除设备信息")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('device:information:delete')")
|
||||||
|
public CommonResult<Boolean> deleteInformation(@RequestParam("id") Long id) {
|
||||||
|
informationService.deleteInformation(id);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得设备信息")
|
||||||
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
|
@PreAuthorize("@ss.hasPermission('device:information:query')")
|
||||||
|
public CommonResult<DeviceInformationRespVO> getInformation(@RequestParam("id") Long id) {
|
||||||
|
DeviceInformationDO information = informationService.getInformation(id);
|
||||||
|
return success(BeanUtils.toBean(information, DeviceInformationRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得设备信息分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('device:information:query')")
|
||||||
|
public CommonResult<PageResult<DeviceInformationRespVO>> getInformationPage(@Valid DeviceInformationPageReqVO pageReqVO) {
|
||||||
|
PageResult<DeviceInformationDO> pageResult = informationService.getInformationPage(pageReqVO);
|
||||||
|
return success(BeanUtils.toBean(pageResult, DeviceInformationRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/export-excel")
|
||||||
|
@Operation(summary = "导出设备信息 Excel")
|
||||||
|
@PreAuthorize("@ss.hasPermission('device:information:export')")
|
||||||
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
|
public void exportInformationExcel(@Valid DeviceInformationPageReqVO pageReqVO,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
|
List<DeviceInformationDO> list = informationService.getInformationPage(pageReqVO).getList();
|
||||||
|
// 导出 Excel
|
||||||
|
ExcelUtils.write(response, "设备信息.xls", "数据", DeviceInformationRespVO.class,
|
||||||
|
BeanUtils.toBean(list, DeviceInformationRespVO.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.information.vo;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 设备信息分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class DeviceInformationPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "设备类型(1:充电桩、2:输送线、 3:码垛机、4:拆垛机、5:自动门、6:提升机、7:信号灯、8:按钮盒)", example = "2")
|
||||||
|
private Integer deviceType;
|
||||||
|
|
||||||
|
@Schema(description = "设备编号")
|
||||||
|
private String deviceNo;
|
||||||
|
|
||||||
|
@Schema(description = "mac地址")
|
||||||
|
private String macAddress;
|
||||||
|
|
||||||
|
@Schema(description = "上传图片附件", example = "https://www.iocoder.cn")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@Schema(description = "图片设置(1:默认图片、2:上传图片、 3:不显示图片)")
|
||||||
|
private Integer pictureConfig;
|
||||||
|
|
||||||
|
@Schema(description = "设备状态(1:在线、2:离线、 3:异常)", example = "1")
|
||||||
|
private Integer deviceStatus;
|
||||||
|
|
||||||
|
@Schema(description = "设备启用禁用(0:禁用、1:启用)")
|
||||||
|
private Integer deviceEnable;
|
||||||
|
|
||||||
|
@Schema(description = "设备协议")
|
||||||
|
private String deviceAgreement;
|
||||||
|
|
||||||
|
@Schema(description = "设备最后通讯时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] deviceLastTime;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.information.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.alibaba.excel.annotation.*;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 设备信息 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class DeviceInformationRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14335")
|
||||||
|
@ExcelProperty("主键ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "设备类型(1:充电桩、2:输送线、 3:码垛机、4:拆垛机、5:自动门、6:提升机、7:信号灯、8:按钮盒)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
|
@ExcelProperty("设备类型(1:充电桩、2:输送线、 3:码垛机、4:拆垛机、5:自动门、6:提升机、7:信号灯、8:按钮盒)")
|
||||||
|
private Integer deviceType;
|
||||||
|
|
||||||
|
@Schema(description = "设备编号")
|
||||||
|
@ExcelProperty("设备编号")
|
||||||
|
private String deviceNo;
|
||||||
|
|
||||||
|
@Schema(description = "mac地址")
|
||||||
|
@ExcelProperty("mac地址")
|
||||||
|
private String macAddress;
|
||||||
|
|
||||||
|
@Schema(description = "上传图片附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
|
||||||
|
@ExcelProperty("上传图片附件")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@Schema(description = "图片设置(1:默认图片、2:上传图片、 3:不显示图片)")
|
||||||
|
@ExcelProperty("图片设置(1:默认图片、2:上传图片、 3:不显示图片)")
|
||||||
|
private Integer pictureConfig;
|
||||||
|
|
||||||
|
@Schema(description = "设备状态(1:在线、2:离线、 3:异常)", example = "1")
|
||||||
|
@ExcelProperty("设备状态(1:在线、2:离线、 3:异常)")
|
||||||
|
private Integer deviceStatus;
|
||||||
|
|
||||||
|
@Schema(description = "设备启用禁用(0:禁用、1:启用)")
|
||||||
|
@ExcelProperty("设备启用禁用(0:禁用、1:启用)")
|
||||||
|
private Integer deviceEnable;
|
||||||
|
|
||||||
|
@Schema(description = "设备协议")
|
||||||
|
@ExcelProperty("设备协议")
|
||||||
|
private String deviceAgreement;
|
||||||
|
|
||||||
|
@Schema(description = "设备最后通讯时间")
|
||||||
|
@ExcelProperty("设备最后通讯时间")
|
||||||
|
private LocalDateTime deviceLastTime;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.controller.admin.information.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.constraints.*;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 设备信息新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class DeviceInformationSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "主键ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "14335")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "设备类型(1:充电桩、2:输送线、 3:码垛机、4:拆垛机、5:自动门、6:提升机、7:信号灯、8:按钮盒)", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
|
@NotNull(message = "设备类型不能为空")
|
||||||
|
private Integer deviceType;
|
||||||
|
|
||||||
|
@Schema(description = "设备编号")
|
||||||
|
private String deviceNo;
|
||||||
|
|
||||||
|
@Schema(description = "mac地址")
|
||||||
|
private String macAddress;
|
||||||
|
|
||||||
|
@Schema(description = "上传图片附件", requiredMode = Schema.RequiredMode.REQUIRED, example = "https://www.iocoder.cn")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@Schema(description = "图片设置(1:默认图片、2:上传图片、 3:不显示图片)")
|
||||||
|
private Integer pictureConfig;
|
||||||
|
|
||||||
|
@Schema(description = "设备状态(1:在线、2:离线、 3:异常)", example = "1")
|
||||||
|
private Integer deviceStatus;
|
||||||
|
|
||||||
|
@Schema(description = "设备启用禁用(0:禁用、1:启用)")
|
||||||
|
private Integer deviceEnable;
|
||||||
|
|
||||||
|
@Schema(description = "设备协议")
|
||||||
|
private String deviceAgreement;
|
||||||
|
|
||||||
|
@Schema(description = "设备最后通讯时间")
|
||||||
|
private LocalDateTime deviceLastTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.dal.dataobject.information;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import java.util.*;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备信息 DO
|
||||||
|
*
|
||||||
|
* @author 陈宾顺
|
||||||
|
*/
|
||||||
|
@TableName("device_information")
|
||||||
|
@KeySequence("device_information_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DeviceInformationDO extends BaseDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键ID
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 设备类型(1:充电桩、2:输送线、 3:码垛机、4:拆垛机、5:自动门、6:提升机、7:信号灯、8:按钮盒)
|
||||||
|
*/
|
||||||
|
private Integer deviceType;
|
||||||
|
/**
|
||||||
|
* 设备编号
|
||||||
|
*/
|
||||||
|
private String deviceNo;
|
||||||
|
/**
|
||||||
|
* mac地址
|
||||||
|
*/
|
||||||
|
private String macAddress;
|
||||||
|
/**
|
||||||
|
* 上传图片附件
|
||||||
|
*/
|
||||||
|
private String url;
|
||||||
|
/**
|
||||||
|
* 图片设置(1:默认图片、2:上传图片、 3:不显示图片)
|
||||||
|
*/
|
||||||
|
private Integer pictureConfig;
|
||||||
|
/**
|
||||||
|
* 设备状态(1:在线、2:离线、 3:异常)
|
||||||
|
*/
|
||||||
|
private Integer deviceStatus;
|
||||||
|
/**
|
||||||
|
* 设备启用禁用(0:禁用、1:启用)
|
||||||
|
*/
|
||||||
|
private Integer deviceEnable;
|
||||||
|
/**
|
||||||
|
* 设备协议
|
||||||
|
*/
|
||||||
|
private String deviceAgreement;
|
||||||
|
/**
|
||||||
|
* 设备最后通讯时间
|
||||||
|
*/
|
||||||
|
private LocalDateTime deviceLastTime;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.dal.mysql.information;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备信息 Mapper
|
||||||
|
*
|
||||||
|
* @author 陈宾顺
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface DeviceInformationMapper extends BaseMapperX<DeviceInformationDO> {
|
||||||
|
|
||||||
|
default PageResult<DeviceInformationDO> selectPage(DeviceInformationPageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<DeviceInformationDO>()
|
||||||
|
.eqIfPresent(DeviceInformationDO::getDeviceType, reqVO.getDeviceType())
|
||||||
|
.eqIfPresent(DeviceInformationDO::getDeviceNo, reqVO.getDeviceNo())
|
||||||
|
.eqIfPresent(DeviceInformationDO::getMacAddress, reqVO.getMacAddress())
|
||||||
|
.eqIfPresent(DeviceInformationDO::getUrl, reqVO.getUrl())
|
||||||
|
.eqIfPresent(DeviceInformationDO::getPictureConfig, reqVO.getPictureConfig())
|
||||||
|
.eqIfPresent(DeviceInformationDO::getDeviceStatus, reqVO.getDeviceStatus())
|
||||||
|
.eqIfPresent(DeviceInformationDO::getDeviceEnable, reqVO.getDeviceEnable())
|
||||||
|
.eqIfPresent(DeviceInformationDO::getDeviceAgreement, reqVO.getDeviceAgreement())
|
||||||
|
.betweenIfPresent(DeviceInformationDO::getDeviceLastTime, reqVO.getDeviceLastTime())
|
||||||
|
.betweenIfPresent(DeviceInformationDO::getCreateTime, reqVO.getCreateTime())
|
||||||
|
.orderByDesc(DeviceInformationDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum DeviceInformationType {
|
||||||
|
|
||||||
|
CHARGING_STATION(1, "充电桩"),
|
||||||
|
Conveyor_line(2, "输送线"),
|
||||||
|
PALLETIZER(3, "码垛机"),
|
||||||
|
DISMANTLING_MACHINE(4, "拆垛机"),
|
||||||
|
AUTOMATIC_DOOR(5, "自动门"),
|
||||||
|
HOIST(6, "提升机"),
|
||||||
|
SIGNAL_LIGHT(7, "信号灯"),
|
||||||
|
BUTTON_BOX(8, "按钮盒");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类型
|
||||||
|
*/
|
||||||
|
private final Integer type;
|
||||||
|
/**
|
||||||
|
* 说明
|
||||||
|
*/
|
||||||
|
private final String source;
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.framework.grpc.config;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.module.grpc.api.GrpcServiceApi;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration(proxyBeanMethods = false)
|
||||||
|
@EnableFeignClients(clients = {GrpcServiceApi.class})
|
||||||
|
public class GrpcConfiguration {
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.information;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import javax.validation.*;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备信息 Service 接口
|
||||||
|
*
|
||||||
|
* @author 陈宾顺
|
||||||
|
*/
|
||||||
|
public interface DeviceInformationService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建设备信息
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createInformation(@Valid DeviceInformationSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新设备信息
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateInformation(@Valid DeviceInformationSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备信息
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
*/
|
||||||
|
void deleteInformation(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得设备信息
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 设备信息
|
||||||
|
*/
|
||||||
|
DeviceInformationDO getInformation(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得设备信息分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 设备信息分页
|
||||||
|
*/
|
||||||
|
PageResult<DeviceInformationDO> getInformationPage(DeviceInformationPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,100 @@
|
|||||||
|
package cn.iocoder.yudao.module.system.service.information;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.iocoder.yudao.module.grpc.api.GrpcServiceApi;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.controller.admin.information.vo.DeviceInformationSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.dataobject.information.DeviceInformationDO;
|
||||||
|
import cn.iocoder.yudao.module.system.dal.mysql.information.DeviceInformationMapper;
|
||||||
|
import cn.iocoder.yudao.module.system.enums.DeviceInformationType;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设备信息 Service 实现类
|
||||||
|
*
|
||||||
|
* @author 陈宾顺
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
public class DeviceInformationServiceImpl implements DeviceInformationService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DeviceInformationMapper informationMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GrpcServiceApi grpcServiceApi;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long createInformation(DeviceInformationSaveReqVO createReqVO) {
|
||||||
|
DeviceInformationPageReqVO pageReqVO = new DeviceInformationPageReqVO();
|
||||||
|
pageReqVO.setMacAddress(createReqVO.getMacAddress());
|
||||||
|
PageResult<DeviceInformationDO> pageResult = informationMapper.selectPage(pageReqVO);
|
||||||
|
if(ObjectUtil.isNotEmpty(pageResult.getList())){
|
||||||
|
throw exception(INFORMATION_MAC_EXIST);
|
||||||
|
}
|
||||||
|
//AGV需要判断机车是否接收到此Mac地址
|
||||||
|
if(DeviceInformationType.PALLETIZER.getType().equals(createReqVO.getDeviceType())
|
||||||
|
&& ObjectUtil.isEmpty(createReqVO.getMacAddress())){
|
||||||
|
throw exception(INFORMATION_MAC_INPUT);
|
||||||
|
}
|
||||||
|
if(DeviceInformationType.PALLETIZER.getType().equals(createReqVO.getDeviceType())){
|
||||||
|
String jiCheResponse = grpcServiceApi.onVehiclePoseUpdated();
|
||||||
|
log.info("调用GRPC查询机车信息返回 :{}",jiCheResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 插入
|
||||||
|
DeviceInformationDO information = BeanUtils.toBean(createReqVO, DeviceInformationDO.class);
|
||||||
|
information.setDeviceStatus(1);
|
||||||
|
information.setDeviceLastTime(LocalDateTime.now());
|
||||||
|
informationMapper.insert(information);
|
||||||
|
// 返回
|
||||||
|
return information.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateInformation(DeviceInformationSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
validateInformationExists(updateReqVO.getId());
|
||||||
|
// 更新
|
||||||
|
DeviceInformationDO updateObj = BeanUtils.toBean(updateReqVO, DeviceInformationDO.class);
|
||||||
|
informationMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteInformation(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateInformationExists(id);
|
||||||
|
// 删除
|
||||||
|
informationMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateInformationExists(Long id) {
|
||||||
|
if (informationMapper.selectById(id) == null) {
|
||||||
|
throw exception(INFORMATION_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceInformationDO getInformation(Long id) {
|
||||||
|
return informationMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<DeviceInformationDO> getInformationPage(DeviceInformationPageReqVO pageReqVO) {
|
||||||
|
return informationMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<?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="cn.iocoder.yudao.module.system.dal.mysql.information.DeviceInformationMapper">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
|
||||||
|
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
|
||||||
|
文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
|
||||||
|
-->
|
||||||
|
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue
Block a user