Merge branch 'server_five' of https://gitea.qinmian.online/five-groups/five-groups-couplet into server_five_fufanrui
commit
f9ec95317c
|
@ -4,6 +4,8 @@ server:
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: couplet-auth
|
name: couplet-auth
|
||||||
|
@ -15,11 +17,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
package com.couplet.common.core.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 列表返回结果集
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class PageResult<T> implements Serializable {
|
||||||
|
/**
|
||||||
|
* 总条数
|
||||||
|
*/
|
||||||
|
private long total;
|
||||||
|
/**
|
||||||
|
* 结果集合
|
||||||
|
*/
|
||||||
|
private List<T> list;
|
||||||
|
public PageResult() {
|
||||||
|
}
|
||||||
|
public PageResult(long total, List<T> list) {
|
||||||
|
this.total = total;
|
||||||
|
this.list = list;
|
||||||
|
}
|
||||||
|
public static <T> PageResult<T> toPageResult(long total, List<T> list){
|
||||||
|
return new PageResult(total , list);
|
||||||
|
}
|
||||||
|
public static <T> Result<PageResult<T>> toResult(long total, List<T> list){
|
||||||
|
return Result.success(PageResult.toPageResult(total,list));
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,6 +33,8 @@ public class BaseEntity implements Serializable {
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private String searchValue;
|
private String searchValue;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建者
|
* 创建者
|
||||||
*/
|
*/
|
||||||
|
@ -44,6 +46,7 @@ public class BaseEntity implements Serializable {
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
/**
|
/**
|
||||||
* 更新者
|
* 更新者
|
||||||
*/
|
*/
|
||||||
|
@ -58,6 +61,7 @@ public class BaseEntity implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 备注
|
* 备注
|
||||||
*/
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -55,4 +55,5 @@ public enum BusinessType {
|
||||||
* 清空数据
|
* 清空数据
|
||||||
*/
|
*/
|
||||||
CLEAN,
|
CLEAN,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ public class SecurityUtils {
|
||||||
* 根据request获取请求token
|
* 根据request获取请求token
|
||||||
*/
|
*/
|
||||||
public static String getToken (HttpServletRequest request) {
|
public static String getToken (HttpServletRequest request) {
|
||||||
// 从header获取token标识
|
// 从header标识
|
||||||
String token = request.getHeader(TokenConstants.AUTHENTICATION);
|
String token = request.getHeader(TokenConstants.AUTHENTICATION);
|
||||||
return replaceTokenPrefix(token);
|
return replaceTokenPrefix(token);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.couplet.common.system.domain;
|
package com.couplet.common.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.couplet.common.core.web.domain.BaseEntity;
|
import com.couplet.common.core.web.domain.BaseEntity;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -39,6 +40,10 @@ public class SysDept extends BaseEntity {
|
||||||
*/
|
*/
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String remark;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 祖级列表
|
* 祖级列表
|
||||||
*/
|
*/
|
||||||
|
@ -82,11 +87,13 @@ public class SysDept extends BaseEntity {
|
||||||
/**
|
/**
|
||||||
* 父部门名称
|
* 父部门名称
|
||||||
*/
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
private String parentName;
|
private String parentName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子部门
|
* 子部门
|
||||||
*/
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
private List<SysDept> children = new ArrayList<SysDept>();
|
private List<SysDept> children = new ArrayList<SysDept>();
|
||||||
|
|
||||||
public Long getDeptId () {
|
public Long getDeptId () {
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.couplet.common.system.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName SysFirm
|
||||||
|
* @Description 企业实体类
|
||||||
|
* @Author YuanYongH
|
||||||
|
* @Date 2024/3/28 22:14
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SysFirm {
|
||||||
|
/**
|
||||||
|
* 企业id
|
||||||
|
**/
|
||||||
|
private Integer deptId;
|
||||||
|
/**
|
||||||
|
* 企业名称
|
||||||
|
**/
|
||||||
|
private String deptName;
|
||||||
|
/**
|
||||||
|
* 企业负责人
|
||||||
|
**/
|
||||||
|
private String leader;
|
||||||
|
/**
|
||||||
|
* 企业联系电话
|
||||||
|
**/
|
||||||
|
private String phone;
|
||||||
|
/**
|
||||||
|
* 企业删除
|
||||||
|
**/
|
||||||
|
private Integer delFlag;
|
||||||
|
/**
|
||||||
|
* 企业状态
|
||||||
|
**/
|
||||||
|
private String status;
|
||||||
|
/**
|
||||||
|
* 企业创建人
|
||||||
|
**/
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>couplet-trouble-log</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.couplet.common.log.annotation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/3/28 15:39
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public @interface Record {
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.couplet.common.log.aop;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/3/28 23:12
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public class AopRecord {
|
||||||
|
}
|
|
@ -18,6 +18,7 @@
|
||||||
<module>couplet-common-datascope</module>
|
<module>couplet-common-datascope</module>
|
||||||
<module>couplet-common-datasource</module>
|
<module>couplet-common-datasource</module>
|
||||||
<module>couplet-common-system</module>
|
<module>couplet-common-system</module>
|
||||||
|
<module>couplet-trouble-log</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>couplet-common</artifactId>
|
<artifactId>couplet-common</artifactId>
|
||||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
@ -40,3 +38,5 @@ spring:
|
||||||
groupId: DEFAULT_GROUP
|
groupId: DEFAULT_GROUP
|
||||||
data-type: json
|
data-type: json
|
||||||
rule-type: gw-flow
|
rule-type: gw-flow
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,38 @@
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-electronic-fence</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
|
||||||
|
<artifactId>couplet-electronic-fence-common</artifactId>
|
||||||
|
|
||||||
|
<description>
|
||||||
|
couplet-electronic-fence-common
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,133 @@
|
||||||
|
package com.couplet.map.common.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.couplet.common.core.web.domain.BaseEntity;
|
||||||
|
import com.couplet.map.common.domain.request.FenceRequest;
|
||||||
|
import com.couplet.map.common.domain.request.FenceUpdateRequest;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
* 电子围栏类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("couplet_fence_info")
|
||||||
|
public class Fence extends BaseEntity{
|
||||||
|
|
||||||
|
@TableId(value = "fence_id", type = IdType.AUTO)
|
||||||
|
/**
|
||||||
|
* 围栏id
|
||||||
|
*/
|
||||||
|
private Long fenceId;
|
||||||
|
/**
|
||||||
|
* 围栏名称
|
||||||
|
*/
|
||||||
|
|
||||||
|
@NotEmpty(message = "围栏名称不能为空")
|
||||||
|
private String fenceName;
|
||||||
|
/**
|
||||||
|
* 围栏经纬度
|
||||||
|
*/
|
||||||
|
private String fenceLongitudeLatitude;
|
||||||
|
/**
|
||||||
|
* 围栏描述
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "围栏描述不能为空")
|
||||||
|
private String fenceDescription;
|
||||||
|
/**
|
||||||
|
* 是否删除
|
||||||
|
*/
|
||||||
|
private Integer isDelete;
|
||||||
|
/**
|
||||||
|
* 围栏状态
|
||||||
|
*/
|
||||||
|
private Integer fenceState;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "创建人不能为空")
|
||||||
|
private String createName;
|
||||||
|
/**
|
||||||
|
* 维护人
|
||||||
|
*/
|
||||||
|
@NotEmpty(message = "维护人不能为空")
|
||||||
|
private String maintainerName;
|
||||||
|
/**
|
||||||
|
* 告警状态
|
||||||
|
*/
|
||||||
|
|
||||||
|
private Integer alarmStatus;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
/**
|
||||||
|
* 标识
|
||||||
|
*/
|
||||||
|
private Integer logoId;
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String logoName;
|
||||||
|
|
||||||
|
public static Fence updateFenceStatus(FenceUpdateRequest fenceUpdateRequest) {
|
||||||
|
|
||||||
|
return Fence.builder()
|
||||||
|
.fenceName(fenceUpdateRequest.getFenceName())
|
||||||
|
.fenceDescription(fenceUpdateRequest.getFenceDescription())
|
||||||
|
.fenceState(fenceUpdateRequest.getFenceState())
|
||||||
|
.fenceLongitudeLatitude(fenceUpdateRequest.getFenceLongitudeLatitude())
|
||||||
|
.createName(fenceUpdateRequest.getCrateName())
|
||||||
|
.createTime(fenceUpdateRequest.getCreateTime())
|
||||||
|
.isDelete(fenceUpdateRequest.getIsDelete())
|
||||||
|
.maintainerName(fenceUpdateRequest.getMaintainerName())
|
||||||
|
.alarmStatus(fenceUpdateRequest.getAlarmStatus())
|
||||||
|
.updateTime(fenceUpdateRequest.getUpdateTime())
|
||||||
|
.fenceId(fenceUpdateRequest.getFenceId())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// public static Fence fenceInsert(FenceRequest fenceRequest) {
|
||||||
|
//
|
||||||
|
// return Fence.builder()
|
||||||
|
// .fenceName(fenceRequest.getFenceName())
|
||||||
|
// .fenceLongitudeLatitude(fenceRequest.getFenceLongitudeLatitude())
|
||||||
|
// .fenceState(fenceRequest.getFenceState())
|
||||||
|
// .fenceDescription(fenceRequest.getFenceDescription())
|
||||||
|
// .createTime(fenceRequest.getCreateTime())
|
||||||
|
// .updateTime(fenceRequest.getUpdateTime())
|
||||||
|
// .isDelete(fenceRequest.getIsDelete())
|
||||||
|
// .alarmStatus(fenceRequest.getAlarmStatus())
|
||||||
|
// .logoId(fenceRequest.getLogoId())
|
||||||
|
// .build();
|
||||||
|
// }
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.couplet.map.common.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/29
|
||||||
|
* 标识实体类
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@SuperBuilder
|
||||||
|
@TableName("couplet_logo_info")
|
||||||
|
public class Logo {
|
||||||
|
|
||||||
|
private Integer logoId;
|
||||||
|
private String logoName;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.couplet.map.common.domain.request;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class FenceConfig {
|
||||||
|
|
||||||
|
private String fenceName;
|
||||||
|
/**
|
||||||
|
* 围栏状态
|
||||||
|
*/
|
||||||
|
private Integer fenceState;
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package com.couplet.map.common.domain.request;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class FenceRequest {
|
||||||
|
/**
|
||||||
|
* 围栏id
|
||||||
|
*/
|
||||||
|
private Integer fenceId;
|
||||||
|
/**
|
||||||
|
* 新增电子名称
|
||||||
|
*/
|
||||||
|
private String fenceName;
|
||||||
|
/**
|
||||||
|
* 围栏经纬度
|
||||||
|
*/
|
||||||
|
private String fenceLongitudeLatitude;
|
||||||
|
/**
|
||||||
|
* 围栏描述
|
||||||
|
*/
|
||||||
|
private String fenceDescription;
|
||||||
|
/**
|
||||||
|
* 是否删除
|
||||||
|
*/
|
||||||
|
private Integer isDelete;
|
||||||
|
/**
|
||||||
|
* 围栏状态
|
||||||
|
*/
|
||||||
|
private Integer fenceState;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String crateName;
|
||||||
|
/**
|
||||||
|
* 维护人
|
||||||
|
*/
|
||||||
|
private String maintainerName;
|
||||||
|
/**
|
||||||
|
* 报警状态
|
||||||
|
*/
|
||||||
|
private Integer alarmStatus;
|
||||||
|
/**
|
||||||
|
* 标识
|
||||||
|
*/
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String[] logoIds;
|
||||||
|
}
|
|
@ -0,0 +1,80 @@
|
||||||
|
package com.couplet.map.common.domain.request;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/29
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class FenceUpdateRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增电子
|
||||||
|
*/
|
||||||
|
private Long fenceId;
|
||||||
|
/**
|
||||||
|
* 新增电子名称
|
||||||
|
*/
|
||||||
|
private String fenceName;
|
||||||
|
/**
|
||||||
|
* 围栏经纬度
|
||||||
|
*/
|
||||||
|
private String fenceLongitudeLatitude;
|
||||||
|
/**
|
||||||
|
* 围栏描述
|
||||||
|
*/
|
||||||
|
private String fenceDescription;
|
||||||
|
/**
|
||||||
|
* 是否删除
|
||||||
|
*/
|
||||||
|
private Integer isDelete;
|
||||||
|
/**
|
||||||
|
* 围栏状态
|
||||||
|
*/
|
||||||
|
private Integer fenceState;
|
||||||
|
/**
|
||||||
|
* 更新时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTime;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建人
|
||||||
|
*/
|
||||||
|
private String crateName;
|
||||||
|
/**
|
||||||
|
* 维护人
|
||||||
|
*/
|
||||||
|
private String maintainerName;
|
||||||
|
/**
|
||||||
|
* 报警状态
|
||||||
|
*/
|
||||||
|
private Integer alarmStatus;
|
||||||
|
|
||||||
|
public Integer getIsDelete() {
|
||||||
|
return isDelete;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsDelete(Integer isDelete) {
|
||||||
|
this.isDelete = isDelete;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-electronic-fence</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>couplet-electronic-fence-remote</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-electronic-fence-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,38 @@
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea/modules.xml
|
||||||
|
.idea/jarRepositories.xml
|
||||||
|
.idea/compiler.xml
|
||||||
|
.idea/libraries/
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
|
|
||||||
|
### Mac OS ###
|
||||||
|
.DS_Store
|
|
@ -0,0 +1,121 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-electronic-fence</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>couplet-electronic-fence-server</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-electronic-fence-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Swagger UI -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-swagger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-system</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.couplet.map.server;
|
||||||
|
|
||||||
|
import com.couplet.common.security.annotation.EnableCustomConfig;
|
||||||
|
import com.couplet.common.security.annotation.EnableMyFeignClients;
|
||||||
|
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统模块
|
||||||
|
*
|
||||||
|
* @author couplet
|
||||||
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
|
@EnableCustomSwagger2
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class CoupletElectronicFenceApplication {
|
||||||
|
public static void main (String[] args) {
|
||||||
|
SpringApplication.run(CoupletElectronicFenceApplication.class, args);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
package com.couplet.map.server.controller;
|
||||||
|
|
||||||
|
import com.couplet.common.core.domain.Result;
|
||||||
|
import com.couplet.common.core.web.controller.BaseController;
|
||||||
|
import com.couplet.common.log.annotation.Log;
|
||||||
|
import com.couplet.common.log.enums.BusinessType;
|
||||||
|
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.couplet.map.common.domain.Fence;
|
||||||
|
import com.couplet.map.common.domain.request.FenceConfig;
|
||||||
|
import com.couplet.map.common.domain.request.FenceRequest;
|
||||||
|
import com.couplet.map.common.domain.request.FenceUpdateRequest;
|
||||||
|
import com.couplet.map.server.service.FenceService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
* 电子围栏信息
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/fence")
|
||||||
|
public class FenceController extends BaseController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用服务
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private FenceService fenceService;
|
||||||
|
|
||||||
|
|
||||||
|
@Log(title = "电子围栏管理", businessType = BusinessType.OTHER)
|
||||||
|
@RequiresPermissions("couplet:fence:fenceList")
|
||||||
|
@PostMapping("/fenceList")
|
||||||
|
public Result<?> fenceList(@RequestBody FenceConfig fenceConfig){
|
||||||
|
startPage();
|
||||||
|
List<Fence> list = fenceService.pageQuery(fenceConfig);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电子围栏新增
|
||||||
|
* @param fenceRequest
|
||||||
|
* @return
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@PostMapping("/fenceAdd")
|
||||||
|
@RequiresPermissions("couplet:fence:fenceAdd")
|
||||||
|
@Log(title = "电子围栏新增",businessType = BusinessType.INSERT)
|
||||||
|
public Result<?> fenceInsert(HttpServletRequest request, @RequestBody FenceRequest fenceRequest){
|
||||||
|
if (!fenceService.checkFenceKeyUnique(fenceRequest.getFenceName())) {
|
||||||
|
return error("新增参数'" + fenceRequest.getFenceName() + "'失败,参数键名已存在");
|
||||||
|
}
|
||||||
|
fenceService.fenceInsert(request,fenceRequest);
|
||||||
|
return Result.success("新增成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电子围栏修改
|
||||||
|
* @param fenceUpdateRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/fenceUpdate")
|
||||||
|
@RequiresPermissions("couplet:fence:fenceUpdate")
|
||||||
|
@Log(title = "电子围栏修改",businessType = BusinessType.UPDATE)
|
||||||
|
public Result<?> fenceUpdate(@Validated @RequestBody FenceUpdateRequest fenceUpdateRequest){
|
||||||
|
if (!fenceService.checkFenceKeyUnique(fenceUpdateRequest.getFenceName())) {
|
||||||
|
return error("修改参数'" + fenceUpdateRequest.getFenceName() + "'失败,参数键名已存在");
|
||||||
|
}
|
||||||
|
fenceService.changeFenceStatus(fenceUpdateRequest);
|
||||||
|
return Result.success("修改成功");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电子围栏删除
|
||||||
|
* @param fenceId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@DeleteMapping("/{fenceId}")
|
||||||
|
@RequiresPermissions("couplet:fence:fenceDelete")
|
||||||
|
@Log(title = "电子围栏删除",businessType = BusinessType.DELETE)
|
||||||
|
public Result<?> fenceDelete(@PathVariable Long fenceId){
|
||||||
|
fenceService.removeByFenceId(fenceId);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用停用
|
||||||
|
* @param fenceUpdateRequest
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/fenceState")
|
||||||
|
@RequiresPermissions("couplet:fence:fenceState")
|
||||||
|
@Log(title = "围栏启用和停用",businessType = BusinessType.OTHER)
|
||||||
|
public Result<?> fenceState(@RequestBody FenceUpdateRequest fenceUpdateRequest){
|
||||||
|
fenceService.changeFenceStatus(fenceUpdateRequest);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.couplet.map.server.controller;
|
||||||
|
|
||||||
|
import com.couplet.common.core.domain.Result;
|
||||||
|
import com.couplet.common.core.web.controller.BaseController;
|
||||||
|
import com.couplet.common.log.annotation.Log;
|
||||||
|
import com.couplet.common.log.enums.BusinessType;
|
||||||
|
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.couplet.map.common.domain.Logo;
|
||||||
|
import com.couplet.map.common.domain.request.FenceRequest;
|
||||||
|
import com.couplet.map.common.domain.request.FenceUpdateRequest;
|
||||||
|
import com.couplet.map.server.service.LogoService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/29
|
||||||
|
* 标识信息
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/logo")
|
||||||
|
public class LogoController extends BaseController {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用服务
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private LogoService logoService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标识信息列表
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Log(title = "标识管理", businessType = BusinessType.OTHER)
|
||||||
|
@RequiresPermissions("couplet:fence:fenceList")
|
||||||
|
@PostMapping("/queryByLogo")
|
||||||
|
public Result<?> queryByLogo(){
|
||||||
|
List<Logo> list = logoService.queryByLogo();
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.couplet.map.server.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.couplet.map.common.domain.Fence;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FenAndLogoMapper extends BaseMapper<Fence> {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增
|
||||||
|
* @param fenceId
|
||||||
|
* @param logoIds
|
||||||
|
*/
|
||||||
|
void addBach(@Param("fenceId") Integer fenceId, @Param("logoIds") String[] logoIds);
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package com.couplet.map.server.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.couplet.map.common.domain.Fence;
|
||||||
|
import com.couplet.map.common.domain.request.FenceConfig;
|
||||||
|
import com.couplet.map.common.domain.request.FenceRequest;
|
||||||
|
import com.couplet.map.common.domain.request.FenceUpdateRequest;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FenceMapper extends BaseMapper<Fence> {
|
||||||
|
/**
|
||||||
|
* 改变围栏信息
|
||||||
|
* @param fenceUpdateRequest
|
||||||
|
*/
|
||||||
|
void changeFence(FenceUpdateRequest fenceUpdateRequest);
|
||||||
|
|
||||||
|
int insertFence(FenceRequest fenceRequest);
|
||||||
|
|
||||||
|
void removeByFenceId(Long fenceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询
|
||||||
|
* @param fenceConfig
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<Fence> pageQuery(FenceConfig fenceConfig);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断名字唯一
|
||||||
|
* @param fenceName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean checkFenceKeyUnique(String fenceName);
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.couplet.map.server.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.couplet.map.common.domain.Fence;
|
||||||
|
import com.couplet.map.common.domain.Logo;
|
||||||
|
import com.couplet.map.common.domain.request.FenceUpdateRequest;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface LogoMapper extends BaseMapper<Logo> {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.couplet.map.server.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.couplet.map.common.domain.Fence;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
*/
|
||||||
|
public interface FenAndLogoService extends IService<Fence> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量添加
|
||||||
|
* @param fenceId
|
||||||
|
* @param logoIds
|
||||||
|
*/
|
||||||
|
void addBach(Integer fenceId, String[] logoIds);
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.couplet.map.server.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.couplet.map.common.domain.Fence;
|
||||||
|
import com.couplet.map.common.domain.request.FenceConfig;
|
||||||
|
import com.couplet.map.common.domain.request.FenceRequest;
|
||||||
|
import com.couplet.map.common.domain.request.FenceUpdateRequest;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
*/
|
||||||
|
public interface FenceService extends IService<Fence> {
|
||||||
|
List<Fence> pageQuery(FenceConfig fenceConfig);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更改围栏状态
|
||||||
|
* @param fenceUpdateRequest
|
||||||
|
*/
|
||||||
|
void changeFenceStatus(FenceUpdateRequest fenceUpdateRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增电子围栏
|
||||||
|
*
|
||||||
|
* @param fenceRequest
|
||||||
|
*/
|
||||||
|
void fenceInsert(HttpServletRequest request,FenceRequest fenceRequest);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除电子围栏
|
||||||
|
* @param fenceId
|
||||||
|
*/
|
||||||
|
void removeByFenceId(Long fenceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断数据是否存在
|
||||||
|
*
|
||||||
|
* @param fenceName
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
boolean checkFenceKeyUnique(String fenceName);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.couplet.map.server.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.couplet.map.common.domain.Logo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
*/
|
||||||
|
public interface LogoService extends IService<Logo> {
|
||||||
|
List<Logo> queryByLogo();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.couplet.map.server.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.couplet.map.common.domain.Fence;
|
||||||
|
import com.couplet.map.server.mapper.FenAndLogoMapper;
|
||||||
|
import com.couplet.map.server.service.FenAndLogoService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
* 中间表信息
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class FenAndLogoServiceImpl extends ServiceImpl<FenAndLogoMapper, Fence> implements FenAndLogoService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用围栏mapper
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private FenAndLogoMapper fenAndLogoMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注入redis模板
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addBach(Integer fenceId, String[] logoIds) {
|
||||||
|
fenAndLogoMapper.addBach(fenceId,logoIds);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.couplet.map.server.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.couplet.map.common.domain.Fence;
|
||||||
|
import com.couplet.map.common.domain.request.FenceConfig;
|
||||||
|
import com.couplet.map.common.domain.request.FenceRequest;
|
||||||
|
import com.couplet.map.common.domain.request.FenceUpdateRequest;
|
||||||
|
import com.couplet.map.server.mapper.FenceMapper;
|
||||||
|
import com.couplet.map.server.service.FenAndLogoService;
|
||||||
|
import com.couplet.map.server.service.FenceService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements FenceService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用围栏mapper
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private FenceMapper fenceMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用围栏和标识中间表
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private FenAndLogoService fenAndLogoService;
|
||||||
|
/**
|
||||||
|
* 注入redis模板
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Fence> pageQuery(FenceConfig fenceConfig) {
|
||||||
|
List<Fence> list= fenceMapper.pageQuery(fenceConfig);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void changeFenceStatus(FenceUpdateRequest fenceUpdateRequest) {
|
||||||
|
|
||||||
|
fenceMapper.changeFence(fenceUpdateRequest);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fenceInsert(HttpServletRequest request,FenceRequest fenceRequest) {
|
||||||
|
|
||||||
|
int a= fenceMapper.insertFence(fenceRequest);
|
||||||
|
String[] logoIds = fenceRequest.getLogoIds();
|
||||||
|
String[] parts = new String[0];
|
||||||
|
for (String logoId : logoIds) {
|
||||||
|
parts = logoId.split(",");
|
||||||
|
fenAndLogoService.addBach(fenceRequest.getFenceId(),parts);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeByFenceId(Long fenceId) {
|
||||||
|
fenceMapper.removeByFenceId(fenceId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean checkFenceKeyUnique(String fenceName) {
|
||||||
|
return fenceMapper.checkFenceKeyUnique(fenceName);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.couplet.map.server.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.couplet.map.common.domain.Fence;
|
||||||
|
import com.couplet.map.common.domain.Logo;
|
||||||
|
import com.couplet.map.common.domain.request.FenceRequest;
|
||||||
|
import com.couplet.map.common.domain.request.FenceUpdateRequest;
|
||||||
|
import com.couplet.map.server.mapper.LogoMapper;
|
||||||
|
import com.couplet.map.server.service.LogoService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiJiaYao
|
||||||
|
* @Date: 2024/3/28
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class LogoServiceImpl extends ServiceImpl<LogoMapper, Logo> implements LogoService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用围栏mapper
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private LogoMapper fenceMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注入redis模板
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Logo> queryByLogo() {
|
||||||
|
LambdaQueryWrapper<Logo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9999
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: couplet-electronic-fence
|
||||||
|
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.couplet.trouble.mapper: DEBUG
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?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="com.couplet.map.server.mapper.FenAndLogoMapper">
|
||||||
|
|
||||||
|
<resultMap id="map" type="com.couplet.map.common.domain.Fence">
|
||||||
|
<id property="fenceId" column="fence_id"/>
|
||||||
|
<result property="fenceName" column="fence_name"/>
|
||||||
|
<result property="fenceDescription" column="fence_description"/>
|
||||||
|
<result property="fenceLongitudeLatitude" column="fence_longitude_latitude"/>
|
||||||
|
<result property="fenceState" column="fence_state"/>
|
||||||
|
<result property="createName" column="create_name" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="isDelete" column="is_delete" />
|
||||||
|
<result property="maintainerName" column="maintainer_name" />
|
||||||
|
</resultMap>
|
||||||
|
<resultMap id="logoMap" type="com.couplet.map.common.domain.Logo">
|
||||||
|
<id property="logoId" column="logo_id"/>
|
||||||
|
<result property="logoName" column="logo_name" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<insert id="addBach">
|
||||||
|
INSERT INTO `couplet-cloud`.`couplet_fences_and_logo`
|
||||||
|
(`fences_id`, `logo_id`)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="logoIds" item="item" separator=",">
|
||||||
|
(#{fenceId}, #{item})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,99 @@
|
||||||
|
<?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="com.couplet.map.server.mapper.FenceMapper">
|
||||||
|
|
||||||
|
<resultMap id="map" type="com.couplet.map.common.domain.Fence">
|
||||||
|
<id property="fenceId" column="fence_id"/>
|
||||||
|
<result property="fenceName" column="fence_name"/>
|
||||||
|
<result property="fenceDescription" column="fence_description"/>
|
||||||
|
<result property="fenceLongitudeLatitude" column="fence_longitude_latitude"/>
|
||||||
|
<result property="fenceState" column="fence_state"/>
|
||||||
|
<result property="createName" column="create_name" />
|
||||||
|
<result property="updateTime" column="update_time" />
|
||||||
|
<result property="isDelete" column="is_delete" />
|
||||||
|
<result property="maintainerName" column="maintainer_name" />
|
||||||
|
</resultMap>
|
||||||
|
<resultMap id="logoMap" type="com.couplet.map.common.domain.Logo">
|
||||||
|
<id property="logoId" column="logo_id"/>
|
||||||
|
<result property="logoName" column="logo_name" />
|
||||||
|
</resultMap>
|
||||||
|
<sql id="selectFence">
|
||||||
|
SELECT
|
||||||
|
f.fence_id,
|
||||||
|
fence_name,
|
||||||
|
fence_longitude_latitude,
|
||||||
|
fence_description,
|
||||||
|
is_delete,
|
||||||
|
fence_state,
|
||||||
|
create_time,
|
||||||
|
update_time,
|
||||||
|
create_name,
|
||||||
|
maintainer_name,
|
||||||
|
alarm_status,
|
||||||
|
l.logo_id,
|
||||||
|
GROUP_CONCAT(logo_name) as logoName
|
||||||
|
FROM couplet_fence_info f INNER JOIN couplet_fences_and_logo m on
|
||||||
|
f.fence_id=m.fences_id INNER JOIN couplet_logo_info l on l.logo_id=m.logo_id
|
||||||
|
</sql>
|
||||||
|
<sql id="fence">
|
||||||
|
SELECT
|
||||||
|
fence_id,
|
||||||
|
fence_name,
|
||||||
|
fence_longitude_latitude,
|
||||||
|
fence_description,
|
||||||
|
is_delete,
|
||||||
|
fence_state,
|
||||||
|
create_time,
|
||||||
|
update_time,
|
||||||
|
create_name,
|
||||||
|
maintainer_name,
|
||||||
|
alarm_status
|
||||||
|
FROM couplet_fence_info
|
||||||
|
</sql>
|
||||||
|
<insert id="insertFence" parameterType="com.couplet.map.common.domain.request.FenceRequest" keyProperty="fenceId"
|
||||||
|
useGeneratedKeys="true">
|
||||||
|
INSERT INTO `couplet-cloud`.`couplet_fence_info`
|
||||||
|
(`fence_name`, `fence_longitude_latitude`, `fence_description`, `is_delete`, `fence_state`, `create_time`,
|
||||||
|
`update_time`, `create_name`, `maintainer_name`, `alarm_status`)
|
||||||
|
VALUES
|
||||||
|
(#{fenceName}, null, #{fenceDescription}, 0, 0, now(), null, null, #{maintainerName}, 0)
|
||||||
|
|
||||||
|
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="changeFence" parameterType="com.couplet.map.common.domain.request.FenceUpdateRequest">
|
||||||
|
|
||||||
|
UPDATE `couplet-cloud`.`couplet_fence_info`
|
||||||
|
SET `fence_name` = #{fenceName},
|
||||||
|
`fence_longitude_latitude` = #{fenceLongitudeLatitude},
|
||||||
|
`fence_description` = #{fenceDescription},
|
||||||
|
`is_delete` = #{isDelete},
|
||||||
|
`fence_state` = #{fenceState},
|
||||||
|
`update_time` = now(),
|
||||||
|
`maintainer_name` = 'admin',
|
||||||
|
`alarm_status` = #{alarmStatus}
|
||||||
|
WHERE `fence_id` = #{fenceId}
|
||||||
|
|
||||||
|
</update>
|
||||||
|
<delete id="removeByFenceId" parameterType="java.lang.Long">
|
||||||
|
delete from couplet_fence_info where fence_id = #{fenceId}
|
||||||
|
</delete>
|
||||||
|
<select id="pageQuery" resultMap="map"
|
||||||
|
parameterType="com.couplet.map.common.domain.request.FenceConfig">
|
||||||
|
<include refid="selectFence"></include>
|
||||||
|
<where>
|
||||||
|
<if test="fenceName!=null and fenceName!='' ">
|
||||||
|
and fence_name like concat('%',#{fenceName},'%')
|
||||||
|
</if>
|
||||||
|
<if test="fenceState!=null">
|
||||||
|
and fence_state = #{fenceState}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
GROUP BY f.fence_id
|
||||||
|
</select>
|
||||||
|
<select id="checkFenceKeyUnique" resultType="java.lang.Boolean">
|
||||||
|
<include refid="fence"/> where fence_name = #{fenceName}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<artifactId>couplet-electronic-fence</artifactId>
|
||||||
|
|
||||||
|
<modules>
|
||||||
|
<module>couplet-electronic-fence-server</module>
|
||||||
|
<module>couplet-electronic-fence-common</module>
|
||||||
|
<module>couplet-electronic-fence-remote</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
</project>
|
|
@ -15,16 +15,18 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
namespace: 172469
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
namespace: 172469
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.couplet.system.mapper: DEBUG
|
com.couplet.system.mapper: DEBUG
|
||||||
|
|
|
@ -15,11 +15,9 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -4,6 +4,8 @@ server:
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: couplet-gen
|
name: couplet-gen
|
||||||
|
@ -15,13 +17,13 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
|
|
@ -4,6 +4,8 @@ server:
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: couplet-job
|
name: couplet-job
|
||||||
|
@ -15,13 +17,13 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
|
|
@ -0,0 +1,125 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>couplet-modules-mq</artifactId>
|
||||||
|
|
||||||
|
<!-- <properties>-->
|
||||||
|
<!-- <maven.compiler.source>17</maven.compiler.source>-->
|
||||||
|
<!-- <maven.compiler.target>17</maven.compiler.target>-->
|
||||||
|
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>-->
|
||||||
|
<!-- </properties>-->
|
||||||
|
|
||||||
|
<description>
|
||||||
|
couplet-modules-mq MQ模块
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Swagger UI -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-swagger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- mqttx依赖 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>1.2.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- RabbitMQ依赖-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.couplet.mq;
|
||||||
|
|
||||||
|
import com.couplet.common.security.annotation.EnableCustomConfig;
|
||||||
|
import com.couplet.common.security.annotation.EnableMyFeignClients;
|
||||||
|
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: Default (Template) Project
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/28
|
||||||
|
* @Description: rabbitMq模块启动类
|
||||||
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
|
@EnableCustomSwagger2
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class CoupletMqApplatcaion {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(CoupletMqApplatcaion.class, args);
|
||||||
|
System.out.println("获取报文、RabbitMQ模块启动成功");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,149 @@
|
||||||
|
package com.couplet.mq.config;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.core.*;
|
||||||
|
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||||
|
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||||
|
import org.springframework.amqp.support.converter.MessageConverter;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/29
|
||||||
|
* @Description: rabbitMQ配置类
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
@Slf4j
|
||||||
|
public class RabbitMQConfig implements RabbitTemplate.ConfirmCallback, RabbitTemplate.ReturnsCallback {
|
||||||
|
// 通过注入的方式获取队列名、交换机名和路由键
|
||||||
|
//队列名
|
||||||
|
@Value("${mq.queueName}")
|
||||||
|
public String queueName;
|
||||||
|
|
||||||
|
//交换机
|
||||||
|
@Value("${mq.exchangeName}")
|
||||||
|
public String exchangeName;
|
||||||
|
|
||||||
|
//路由键
|
||||||
|
@Value(("${mq.routingKey}"))
|
||||||
|
public String routingKey;
|
||||||
|
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/29 21:25
|
||||||
|
* @Description: 创建并返回一个消息转换器,用于转换消息体。
|
||||||
|
* @Param: []
|
||||||
|
* @Return: 返回一个Jackson2JsonMessageConverter实例,用于JSON格式的消息转换。
|
||||||
|
**/
|
||||||
|
@Bean
|
||||||
|
public MessageConverter messageConverter() {
|
||||||
|
return new Jackson2JsonMessageConverter();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/29 21:26
|
||||||
|
* @Description: 创建并返回一个持久化的队列。
|
||||||
|
* @Param: []
|
||||||
|
* @Return: 返回一个配置好的Queue实例。
|
||||||
|
**/
|
||||||
|
@Bean
|
||||||
|
public Queue queue() {
|
||||||
|
return new Queue(queueName, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/29 21:26
|
||||||
|
* @Description: 创建并返回一个直连交换机。
|
||||||
|
* @Param: []
|
||||||
|
* @Return: 返回一个配置好的DirectExchange实例。
|
||||||
|
**/
|
||||||
|
@Bean("exchange")
|
||||||
|
public DirectExchange directExchange() {
|
||||||
|
return new DirectExchange(exchangeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/29 21:27
|
||||||
|
* @Description: 配置并返回RabbitTemplate实例,用于发送消息。
|
||||||
|
* @Param: connectionFactory RabbitMQ连接工厂。
|
||||||
|
* @Return: 配置好的RabbitTemplate实例。
|
||||||
|
**/
|
||||||
|
@Primary
|
||||||
|
@Bean
|
||||||
|
public RabbitTemplate rabbitTemplate(ConnectionFactory connectionFactory) {
|
||||||
|
RabbitTemplate rabbitTempalte = new RabbitTemplate(connectionFactory);
|
||||||
|
this.rabbitTemplate = rabbitTempalte;
|
||||||
|
rabbitTempalte.setMessageConverter(messageConverter());
|
||||||
|
rabbitTempalte();
|
||||||
|
|
||||||
|
return rabbitTempalte;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/29 21:27
|
||||||
|
* @Description: 配置RabbitTemplate的回调函数。
|
||||||
|
* @Param: []
|
||||||
|
* @Return: void
|
||||||
|
**/
|
||||||
|
public void rabbitTempalte() {
|
||||||
|
rabbitTemplate.setConfirmCallback(this);
|
||||||
|
rabbitTemplate.setReturnsCallback(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/29 21:27
|
||||||
|
* @Description: 创建并返回一个绑定,将队列与交换机绑定,并指定路由键
|
||||||
|
* @Param: []
|
||||||
|
* @Return: 返回一个配置好的Binding实例
|
||||||
|
**/
|
||||||
|
@Bean
|
||||||
|
public Binding binding() {
|
||||||
|
return BindingBuilder.bind(queue()).to(directExchange()).with(routingKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/29 21:28
|
||||||
|
* @Description: 消息确认回调函数。
|
||||||
|
* 当消息被交换机成功处理后调用,或当消息未能被正确处理时调用。
|
||||||
|
* @Param: correlationData 关联数据,用于追踪消息
|
||||||
|
* @Param: ack 消息是否被成功处理
|
||||||
|
* @Param: s 附加信息
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void confirm(CorrelationData correlationData, boolean ack, String s) {
|
||||||
|
if (ack) {
|
||||||
|
log.info("{}消息到达交换机", correlationData.getId());
|
||||||
|
} else {
|
||||||
|
log.error("{}消息丢失", correlationData.getId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/29 21:29
|
||||||
|
* @Description: 消息返回回调函数。
|
||||||
|
* 当消息未能被正确路由到队列时调用
|
||||||
|
* @Param: returnedMessage 被返回的消息
|
||||||
|
* @Return: void
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public void returnedMessage(ReturnedMessage returnedMessage) {
|
||||||
|
log.error("{}消息未到达队列", returnedMessage.getMessage().getMessageProperties().getMessageId());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.couplet.mq.controller;
|
||||||
|
|
||||||
|
import com.couplet.common.core.utils.uuid.IdUtils;
|
||||||
|
import com.couplet.mq.config.RabbitMQConfig;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||||
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/29
|
||||||
|
* @Description: MQController类
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/mq")
|
||||||
|
@Slf4j
|
||||||
|
public class MqController {
|
||||||
|
@Autowired
|
||||||
|
private RabbitTemplate rabbitTemplate;
|
||||||
|
|
||||||
|
@GetMapping("/receive/{data}")
|
||||||
|
public void receive(@PathVariable("data") String data) {
|
||||||
|
//创建配置类对象,用于获取配置值
|
||||||
|
RabbitMQConfig config = new RabbitMQConfig();
|
||||||
|
|
||||||
|
rabbitTemplate.convertAndSend(config.exchangeName, config.routingKey, data , message -> {
|
||||||
|
message.getMessageProperties().setMessageId(IdUtils.randomUUID());
|
||||||
|
return message;
|
||||||
|
}, new CorrelationData(IdUtils.randomUUID()));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.couplet.mq.domain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/29
|
||||||
|
* @Description: 测试 参数类
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class Test implements Serializable {
|
||||||
|
public String data;
|
||||||
|
}
|
|
@ -0,0 +1,70 @@
|
||||||
|
package com.couplet.mq.service;
|
||||||
|
|
||||||
|
import com.rabbitmq.client.Channel;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.amqp.core.Message;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||||
|
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/28
|
||||||
|
* @Description: MQ消费者类
|
||||||
|
*/
|
||||||
|
@RabbitListener(queues = "${mq.queueName}")
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class Consumer {
|
||||||
|
@Autowired
|
||||||
|
private StringRedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@RabbitHandler
|
||||||
|
public void receive(String data, Channel channel, Message message) throws IOException {
|
||||||
|
log.info("消费者接受到数据:{}", data);
|
||||||
|
|
||||||
|
//获取信息的标记
|
||||||
|
long deliveryTag = message.getMessageProperties().getDeliveryTag();
|
||||||
|
|
||||||
|
//获取到消息的id
|
||||||
|
String messageId = message.getMessageProperties().getMessageId();
|
||||||
|
|
||||||
|
Long add = redisTemplate.opsForSet().add("set:" + messageId, "set:" + messageId);
|
||||||
|
|
||||||
|
if (!redisTemplate.hasKey("value:" + messageId)) {
|
||||||
|
redisTemplate.opsForValue().set("value:" + messageId, String.valueOf(deliveryTag), 10, TimeUnit.MINUTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (add == 1) {
|
||||||
|
log.info("---------------消费者开始消费---------------");
|
||||||
|
|
||||||
|
System.out.println(data);
|
||||||
|
|
||||||
|
log.info("---------------消费者结束消费---------------");
|
||||||
|
}else {
|
||||||
|
log.error("重复消费!");
|
||||||
|
channel.basicReject(deliveryTag, false);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// throw new RuntimeException(e);
|
||||||
|
String s = redisTemplate.opsForValue().get("value:" + messageId);
|
||||||
|
long oldTag = Long.parseLong(s);
|
||||||
|
|
||||||
|
if ((oldTag + 2) != deliveryTag) {
|
||||||
|
log.info("重新入队!");
|
||||||
|
channel.basicNack(deliveryTag, false, true);
|
||||||
|
}else {
|
||||||
|
log.error("三次无法消费,不再入队!");
|
||||||
|
channel.basicNack(deliveryTag, false, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
package com.couplet.mq.service;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
|
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/28
|
||||||
|
* @Description: mqtt客户端
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class MqttListen {
|
||||||
|
/*
|
||||||
|
* 路径
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.broker}")
|
||||||
|
private String BROKER;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 主题
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.topic}")
|
||||||
|
private String TOPIC;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 客户端id
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.clientid}")
|
||||||
|
private String CLIENTID;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 用户名
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.username}")
|
||||||
|
private String USERNAME;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 密码
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.password}")
|
||||||
|
private String PASSWORD;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* qos
|
||||||
|
* */
|
||||||
|
@Value("${mqtt.server.qos}")
|
||||||
|
private Integer QOS;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void connect() {
|
||||||
|
System.out.println("监听者启动");
|
||||||
|
try {
|
||||||
|
|
||||||
|
MqttClient client = new MqttClient(BROKER, CLIENTID, new MemoryPersistence());
|
||||||
|
MqttConnectOptions options = new MqttConnectOptions();
|
||||||
|
options.setUserName(USERNAME);
|
||||||
|
options.setPassword(PASSWORD.toCharArray());
|
||||||
|
|
||||||
|
//连接超时
|
||||||
|
options.setConnectionTimeout(60);
|
||||||
|
|
||||||
|
//心跳
|
||||||
|
options.setKeepAliveInterval(60);
|
||||||
|
|
||||||
|
log.info("连接到:"+BROKER);
|
||||||
|
|
||||||
|
client.connect(options);
|
||||||
|
log.info("连接成功");
|
||||||
|
|
||||||
|
//设置回调
|
||||||
|
client.setCallback(new MqttCallback() {
|
||||||
|
@Override
|
||||||
|
public void connectionLost(Throwable throwable) {
|
||||||
|
log.error("连接断开:" + throwable.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void messageArrived(String topic, MqttMessage message) {
|
||||||
|
log.info("消息到达");
|
||||||
|
log.info("接收消息主题:" + topic);
|
||||||
|
log.info("接收消息Qos:" + message.getQos());
|
||||||
|
log.info("接收消息内容:" + new String(message.getPayload()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deliveryComplete(IMqttDeliveryToken token) {
|
||||||
|
log.info("消息发送成功----------" + token.isComplete());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
client.subscribe(TOPIC, QOS);
|
||||||
|
|
||||||
|
|
||||||
|
} catch (MqttException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
|
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,48 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9616
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: couplet-mq
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.couplet.system.mapper: DEBUG
|
||||||
|
|
||||||
|
# 订阅端配置
|
||||||
|
mqtt:
|
||||||
|
server:
|
||||||
|
broker: tcp://115.159.47.13:1883
|
||||||
|
username:
|
||||||
|
password:
|
||||||
|
clientid: mqttx
|
||||||
|
qos: 0
|
||||||
|
topic: test
|
||||||
|
|
||||||
|
# RabbitMQ配置
|
||||||
|
mq:
|
||||||
|
queueName: queue
|
||||||
|
exchangeName: exchange
|
||||||
|
routingKey: routingKey
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="logs/couplet-system"/>
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="com.couplet" level="info"/>
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn"/>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info"/>
|
||||||
|
<appender-ref ref="file_error"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,121 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>couplet-modules-vehicle</artifactId>
|
||||||
|
|
||||||
|
<!-- <properties>-->
|
||||||
|
<!-- <maven.compiler.source>17</maven.compiler.source>-->
|
||||||
|
<!-- <maven.compiler.target>17</maven.compiler.target>-->
|
||||||
|
<!-- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>-->
|
||||||
|
<!-- </properties>-->
|
||||||
|
|
||||||
|
<description>
|
||||||
|
couplet-modules-vehicle车辆管理模块
|
||||||
|
</description>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Swagger UI -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-swagger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Pagehelper -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.pagehelper</groupId>
|
||||||
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
|
<version>1.4.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<!-- 加入maven deploy插件,当在deploy时,忽略些model-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skip>true</skip>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.couplet.vehicle;
|
||||||
|
|
||||||
|
import com.couplet.common.security.annotation.EnableCustomConfig;
|
||||||
|
import com.couplet.common.security.annotation.EnableMyFeignClients;
|
||||||
|
import com.couplet.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: Default (Template) Project
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description: 车辆管理模块启动类
|
||||||
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
|
@EnableCustomSwagger2
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class CoupletVehicleApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(CoupletVehicleApplication.class, args);
|
||||||
|
System.out.println("车辆管理模块启动成功");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,121 @@
|
||||||
|
package com.couplet.vehicle.controller;
|
||||||
|
|
||||||
|
import com.couplet.common.core.domain.Result;
|
||||||
|
import com.couplet.common.core.web.controller.BaseController;
|
||||||
|
import com.couplet.common.log.annotation.Log;
|
||||||
|
import com.couplet.common.log.enums.BusinessType;
|
||||||
|
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.couplet.vehicle.domain.Vehicle;
|
||||||
|
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
||||||
|
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||||
|
import com.couplet.vehicle.domain.req.VehicleListParams;
|
||||||
|
import com.couplet.vehicle.service.VehicleService;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description: 车辆管理
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/vehicle")
|
||||||
|
public class VehicleController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private VehicleService vehicleService;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/26 21:39
|
||||||
|
* @Description: 查询车辆列表
|
||||||
|
* @Param: [listParams]
|
||||||
|
* @Return: com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@RequiresPermissions("couplet:vehicle:list")
|
||||||
|
@PostMapping("/list")
|
||||||
|
@Log(title = "车辆列表")
|
||||||
|
public Result list(@RequestBody VehicleListParams listParams) {
|
||||||
|
PageHelper.startPage(listParams.getPageNum(), listParams.getPageSize());
|
||||||
|
|
||||||
|
List<Vehicle> list = vehicleService.list(listParams);
|
||||||
|
|
||||||
|
PageInfo<Vehicle> vehiclePageInfo = new PageInfo<>(list);
|
||||||
|
|
||||||
|
return Result.success(vehiclePageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/26 22:35
|
||||||
|
* @Description: 通过id删除车辆
|
||||||
|
* @Param: [vehicleId]
|
||||||
|
* @Return: com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@RequiresPermissions("couplet:vehicle:deleteById")
|
||||||
|
@GetMapping("/deleteById/{vehicleId}")
|
||||||
|
@Log(title = "删除车辆", businessType = BusinessType.DELETE)
|
||||||
|
public Result deleteById(@PathVariable Long vehicleId) {
|
||||||
|
String result = vehicleService.deleteById(vehicleId);
|
||||||
|
|
||||||
|
return Result.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/27 16:09
|
||||||
|
* @Description: 编辑车辆
|
||||||
|
* @Param: [editParams]
|
||||||
|
* @Return: com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@RequiresPermissions("couplet:vehicle:editById")
|
||||||
|
@PostMapping("/editById")
|
||||||
|
@Log(title = "编辑车辆", businessType = BusinessType.UPDATE)
|
||||||
|
public Result editById(@RequestBody VehicleEditParams editParams) {
|
||||||
|
|
||||||
|
String result = vehicleService.editById(editParams);
|
||||||
|
|
||||||
|
return Result.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/27 16:21
|
||||||
|
* @Description: 新增车辆
|
||||||
|
* @Param: [insertParams]
|
||||||
|
* @Return: com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@RequiresPermissions("couplet:vehicle:insert")
|
||||||
|
@PostMapping("/insert")
|
||||||
|
@Log(title = "新增车辆", businessType = BusinessType.INSERT)
|
||||||
|
public Result insert(@RequestBody @Validated VehicleInsertParams insertParams) {
|
||||||
|
System.out.println(insertParams);
|
||||||
|
String result = vehicleService.insert(insertParams);
|
||||||
|
|
||||||
|
return Result.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/31 21:34
|
||||||
|
* @Description: 获取绑定当前车辆的标识
|
||||||
|
* @Param: [vehicleId]
|
||||||
|
* @Return: com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@RequiresPermissions("couplet:vehicle:list")
|
||||||
|
@GetMapping("/getBindLogoById/{vehicleId}")
|
||||||
|
public Result getBindLogoById(@PathVariable("vehicleId") Long vehicleId) {
|
||||||
|
|
||||||
|
List<Long> bindLogoById = vehicleService.getBindLogoById(vehicleId);
|
||||||
|
|
||||||
|
|
||||||
|
return Result.success(bindLogoById);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.couplet.vehicle.controller;
|
||||||
|
|
||||||
|
import com.couplet.common.core.domain.Result;
|
||||||
|
import com.couplet.common.core.web.controller.BaseController;
|
||||||
|
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.couplet.vehicle.domain.VehicleType;
|
||||||
|
import com.couplet.vehicle.service.VehicleTypeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/31
|
||||||
|
* @Description: 车辆类型控制器
|
||||||
|
*/
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/vehicleType")
|
||||||
|
public class VehicleTypeController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private VehicleTypeService service;
|
||||||
|
|
||||||
|
//获取所有的车辆类型
|
||||||
|
@RequiresPermissions("couplet:vehicle:list")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<List<VehicleType>> list() {
|
||||||
|
List<VehicleType> vehicleTypeList = service.list();
|
||||||
|
return success(vehicleTypeList);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.couplet.vehicle.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description: 车辆信息表
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("couplet_vehicle")
|
||||||
|
public class Vehicle {
|
||||||
|
|
||||||
|
/*
|
||||||
|
*车辆id
|
||||||
|
* */
|
||||||
|
@TableId(type = IdType.AUTO, value = "vehicle_id")
|
||||||
|
private Long vehicleId;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*车辆类型
|
||||||
|
* */
|
||||||
|
@TableField(value = "vehicle_type")
|
||||||
|
private Long vehicleType;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 车辆类型名称
|
||||||
|
* */
|
||||||
|
@TableField(exist = false)
|
||||||
|
private String vehicleTypeName;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机厂商
|
||||||
|
* */
|
||||||
|
@TableField(value = "motor_manufacturer")
|
||||||
|
private String motorManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池厂商
|
||||||
|
* */
|
||||||
|
@TableField(value = "battery_manufacturer")
|
||||||
|
private String batteryManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机编号
|
||||||
|
* */
|
||||||
|
@TableField(value = "motor_number")
|
||||||
|
private String motorNumber;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池编号
|
||||||
|
* */
|
||||||
|
@TableField(value = "battery_number")
|
||||||
|
private String batteryNumber;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*vin码
|
||||||
|
* */
|
||||||
|
@TableField(value = "vin")
|
||||||
|
private String vin;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*0离线 1在线
|
||||||
|
* */
|
||||||
|
@TableField(value = "vehicle_state")
|
||||||
|
private Integer vehicleState;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*0未删除 1删除
|
||||||
|
* */
|
||||||
|
@TableField(value = "isdelete")
|
||||||
|
private Integer isdelete;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.couplet.vehicle.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/30
|
||||||
|
* @Description: 车辆和标志中间表
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("couplet_vehicle_and_logo")
|
||||||
|
public class VehicleAndLogo {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 车辆、标志中间表id
|
||||||
|
* */
|
||||||
|
@TableId(type = IdType.AUTO, value = "vehicle_logo_middle_id")
|
||||||
|
private Long vehicleLogoMiddleId;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 车辆id
|
||||||
|
* */
|
||||||
|
@TableField("vehicle_id")
|
||||||
|
private Long vehicleId;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 标志id
|
||||||
|
* */
|
||||||
|
@TableField("logo_id")
|
||||||
|
private Long logoId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.couplet.vehicle.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/31
|
||||||
|
* @Description: 车辆类型
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@TableName("couplet_vehicle_type")
|
||||||
|
public class VehicleType {
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 车辆类型id
|
||||||
|
* */
|
||||||
|
@TableId(type = IdType.AUTO, value = "vehicle_type_id")
|
||||||
|
private Long vehicleTypeId;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 车辆类型名称
|
||||||
|
* */
|
||||||
|
@TableField(value = "vehicle_type_name")
|
||||||
|
private String vehicleTypeName;
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package com.couplet.vehicle.domain.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/27
|
||||||
|
* @Description: 车辆编辑入参
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class VehicleEditParams {
|
||||||
|
/*
|
||||||
|
*车辆id
|
||||||
|
* */
|
||||||
|
@NotNull(message = "车辆id不能为空")
|
||||||
|
private Long vehicleId;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*车辆类型
|
||||||
|
* */
|
||||||
|
@NotNull(message="车辆类型不能为空")
|
||||||
|
private Integer vehicleType;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机厂商
|
||||||
|
* */
|
||||||
|
private String motorManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池厂商
|
||||||
|
* */
|
||||||
|
private String batteryManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机编号
|
||||||
|
* */
|
||||||
|
private String motorNumber;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池编号
|
||||||
|
* */
|
||||||
|
private String batteryNumber;
|
||||||
|
|
||||||
|
//标识id集合
|
||||||
|
private List<Long> logoIds;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.couplet.vehicle.domain.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/27
|
||||||
|
* @Description: 车辆插入入参
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class VehicleInsertParams {
|
||||||
|
|
||||||
|
/*
|
||||||
|
*车辆类型
|
||||||
|
* */
|
||||||
|
@NotNull(message = "车辆类型不能为空")
|
||||||
|
private Long vehicleType;
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机厂商
|
||||||
|
* */
|
||||||
|
@NotBlank(message = "电机厂商不能为空")
|
||||||
|
private String motorManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池厂商
|
||||||
|
* */
|
||||||
|
@NotBlank(message = "电池厂商不能为空")
|
||||||
|
private String batteryManufacturer;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电机编号
|
||||||
|
* */
|
||||||
|
@NotBlank(message = "电机编号不能为空")
|
||||||
|
private String motorNumber;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*电池编号
|
||||||
|
* */
|
||||||
|
@NotBlank(message = "电池编号不能为空")
|
||||||
|
private String batteryNumber;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 一辆车可以绑定多个标识
|
||||||
|
* */
|
||||||
|
private List<Long> logoIds;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.couplet.vehicle.domain.req;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description: 查询车辆列表入参
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class VehicleListParams {
|
||||||
|
/*
|
||||||
|
*车辆类型
|
||||||
|
* */
|
||||||
|
private Integer vehicleType;
|
||||||
|
|
||||||
|
/*
|
||||||
|
*0离线 1在线
|
||||||
|
* */
|
||||||
|
private Integer vehicleState;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 分页参数
|
||||||
|
* */
|
||||||
|
private Integer pageNum = 1;
|
||||||
|
private Integer pageSize = 5;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.couplet.vehicle.exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/29
|
||||||
|
* @Description: 车辆异常响应
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class VehicleException extends RuntimeException {
|
||||||
|
private int code;
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public VehicleException(int code, String message) {
|
||||||
|
this.code = code;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VehicleException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public VehicleException() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.couplet.vehicle.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.couplet.vehicle.domain.VehicleAndLogo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description: 车辆与标志Mapper
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Component
|
||||||
|
public interface VehicleAndLogoMapper extends BaseMapper<VehicleAndLogo> {
|
||||||
|
int vehicleBindLogo(@Param("vehicleId") Long vehicleId, @Param("logoIds") List<Long> logoIds);
|
||||||
|
|
||||||
|
int deleteByVehicleId(@Param("vehicleId") Long vehicleId);
|
||||||
|
|
||||||
|
List<Long> getBindLogoById(@Param("vehicleId") Long vehicleId);
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.couplet.vehicle.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.couplet.vehicle.domain.Vehicle;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description: 车辆Mapper
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Component
|
||||||
|
public interface VehicleMapper extends BaseMapper<Vehicle> {
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.couplet.vehicle.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.couplet.vehicle.domain.Vehicle;
|
||||||
|
import com.couplet.vehicle.domain.VehicleType;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description: 车辆类型Mapper
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
@Component
|
||||||
|
public interface VehicleTypeMapper extends BaseMapper<VehicleType> {
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.couplet.vehicle.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.couplet.vehicle.domain.VehicleAndLogo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/30
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface VehicleAndLogoService extends IService<VehicleAndLogo> {
|
||||||
|
int vehicleBindLogo(Long vehicleId, List<Long> logoIds);
|
||||||
|
|
||||||
|
int deleteByVehicleId(Long vehicleId);
|
||||||
|
|
||||||
|
List<Long> getBindLogoById(Long vehicleId);
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.couplet.vehicle.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.couplet.vehicle.domain.Vehicle;
|
||||||
|
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
||||||
|
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||||
|
import com.couplet.vehicle.domain.req.VehicleListParams;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description: 车辆服务
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface VehicleService extends IService<Vehicle> {
|
||||||
|
List<Vehicle> list(VehicleListParams listParams);
|
||||||
|
|
||||||
|
String deleteById(Long vehicleId);
|
||||||
|
|
||||||
|
String editById(VehicleEditParams editParams);
|
||||||
|
|
||||||
|
String insert(VehicleInsertParams insertParams);
|
||||||
|
|
||||||
|
List<Long> getBindLogoById(Long vehicleId);
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.couplet.vehicle.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.couplet.vehicle.domain.VehicleType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/31
|
||||||
|
* @Description: 车辆类型服务层
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface VehicleTypeService extends IService<VehicleType> {
|
||||||
|
List<VehicleType> list();
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package com.couplet.vehicle.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.couplet.vehicle.domain.VehicleAndLogo;
|
||||||
|
import com.couplet.vehicle.mapper.VehicleAndLogoMapper;
|
||||||
|
import com.couplet.vehicle.service.VehicleAndLogoService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/30
|
||||||
|
* @Description: 车辆和标识关联
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class VehicleAndLogoServiceImpl extends ServiceImpl<VehicleAndLogoMapper, VehicleAndLogo> implements VehicleAndLogoService {
|
||||||
|
|
||||||
|
//注入mapper
|
||||||
|
@Autowired
|
||||||
|
private VehicleAndLogoMapper mapper;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/30 11:51
|
||||||
|
* @Description: 车辆绑定标志
|
||||||
|
* @Param: [vehicleId, logoIds]
|
||||||
|
* @Return: int
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public int vehicleBindLogo(Long vehicleId, List<Long> logoIds) {
|
||||||
|
//将ids转为list
|
||||||
|
// ArrayList<Long> logoIdList = new ArrayList<>();
|
||||||
|
// String[] split = logoIds.split(",");
|
||||||
|
// for (String s : split) {
|
||||||
|
// logoIdList.add(Long.parseLong(s));
|
||||||
|
// }
|
||||||
|
|
||||||
|
//执行绑定
|
||||||
|
return mapper.vehicleBindLogo(vehicleId, logoIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/31 21:21
|
||||||
|
* @Description: 删除掉车辆绑定
|
||||||
|
* @Param: [vehicleId]
|
||||||
|
* @Return: int
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public int deleteByVehicleId(Long vehicleId) {
|
||||||
|
|
||||||
|
|
||||||
|
return mapper.deleteByVehicleId(vehicleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/31 21:35
|
||||||
|
* @Description: 获取绑定当前车辆的标识
|
||||||
|
* @Param: [vehicleId]
|
||||||
|
* @Return: java.util.List<java.lang.Long>
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public List<Long> getBindLogoById(Long vehicleId) {
|
||||||
|
|
||||||
|
|
||||||
|
return mapper.getBindLogoById(vehicleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,242 @@
|
||||||
|
package com.couplet.vehicle.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.couplet.common.core.domain.Result;
|
||||||
|
import com.couplet.common.core.utils.StringUtils;
|
||||||
|
import com.couplet.vehicle.domain.Vehicle;
|
||||||
|
import com.couplet.vehicle.domain.VehicleType;
|
||||||
|
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
||||||
|
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||||
|
import com.couplet.vehicle.domain.req.VehicleListParams;
|
||||||
|
import com.couplet.vehicle.mapper.VehicleMapper;
|
||||||
|
import com.couplet.vehicle.service.VehicleAndLogoService;
|
||||||
|
import com.couplet.vehicle.service.VehicleService;
|
||||||
|
import com.couplet.vehicle.service.VehicleTypeService;
|
||||||
|
import com.couplet.vehicle.utils.SnowflakeIdGenerator;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/26
|
||||||
|
* @Description: 车辆服务实现类
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> implements VehicleService {
|
||||||
|
//车辆mapper
|
||||||
|
@Autowired
|
||||||
|
private VehicleMapper vehicleMapper;
|
||||||
|
|
||||||
|
//车辆类型服务
|
||||||
|
@Autowired
|
||||||
|
private VehicleTypeService vehicleTypeService;
|
||||||
|
|
||||||
|
//车辆与标志关联 的mapper
|
||||||
|
@Autowired
|
||||||
|
private VehicleAndLogoService vehicleAndLogoService;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/26 22:11
|
||||||
|
* @Description: 查询列表
|
||||||
|
* @Param: [listParams]
|
||||||
|
* @Return: java.util.List<com.couplet.vehicle.domain.LyhVehicle>
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public List<Vehicle> list(VehicleListParams listParams) {
|
||||||
|
// 创建查询条件包装器
|
||||||
|
LambdaQueryWrapper<Vehicle> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
// 如果车辆类型不为空,添加车辆类型作为查询条件
|
||||||
|
if (!StringUtils.isNull(listParams.getVehicleType())) {
|
||||||
|
queryWrapper.eq(Vehicle::getVehicleType, listParams.getVehicleType());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果车辆状态不为空,添加车辆状态作为查询条件
|
||||||
|
if (!StringUtils.isNull(listParams.getVehicleState())) {
|
||||||
|
queryWrapper.eq(Vehicle::getVehicleState, listParams.getVehicleState());
|
||||||
|
}
|
||||||
|
|
||||||
|
//只查询车辆未被删除的
|
||||||
|
queryWrapper.eq(Vehicle::getIsdelete, 0);
|
||||||
|
|
||||||
|
// 执行查询
|
||||||
|
List<Vehicle> list = this.list(queryWrapper);
|
||||||
|
|
||||||
|
//调用服务,得到车辆类型
|
||||||
|
List<VehicleType> vehicleTypes = vehicleTypeService.list();
|
||||||
|
|
||||||
|
//将类型id一样的记录 名称进行赋值
|
||||||
|
list.forEach(vehicle -> {
|
||||||
|
vehicleTypes.forEach(vehicleType -> {
|
||||||
|
if (vehicle.getVehicleType() == vehicleType.getVehicleTypeId()) {
|
||||||
|
vehicle.setVehicleTypeName(vehicleType.getVehicleTypeName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/26 22:31
|
||||||
|
* @Description: 通过id删除
|
||||||
|
* @Param: [vehicleId]
|
||||||
|
* @Return: java.lang.String
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String deleteById(Long vehicleId) {
|
||||||
|
String result = "";
|
||||||
|
|
||||||
|
UpdateWrapper<Vehicle> updateWrapper = new UpdateWrapper<>();
|
||||||
|
|
||||||
|
updateWrapper.set("isdelete", 1)
|
||||||
|
.eq("vehicle_id", vehicleId);
|
||||||
|
|
||||||
|
boolean update = update(updateWrapper);
|
||||||
|
|
||||||
|
if (!update) {
|
||||||
|
result = "删除失败";
|
||||||
|
Result.error(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
result = "删除成功!";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/27 15:21
|
||||||
|
* @Description: 通过id进行编辑
|
||||||
|
* @Param: [editParams]
|
||||||
|
* @Return: java.lang.String
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String editById(VehicleEditParams editParams) {
|
||||||
|
String result = "";
|
||||||
|
|
||||||
|
if ((editParams.getLogoIds() == null || editParams.getLogoIds().isEmpty())) {
|
||||||
|
result = "未选择电子围栏";
|
||||||
|
Result.error(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateWrapper<Vehicle> updateWrapper = new UpdateWrapper<>();
|
||||||
|
|
||||||
|
//编辑车辆类型
|
||||||
|
updateWrapper.set("vehicle_type", editParams.getVehicleType())
|
||||||
|
|
||||||
|
//编辑电机厂商
|
||||||
|
.set("motor_manufacturer", editParams.getMotorManufacturer())
|
||||||
|
|
||||||
|
//编辑电池厂商
|
||||||
|
.set("battery_manufacturer", editParams.getBatteryManufacturer())
|
||||||
|
|
||||||
|
//编辑电机编号
|
||||||
|
.set("motor_number", editParams.getMotorNumber())
|
||||||
|
|
||||||
|
//编辑电池编号
|
||||||
|
.set("battery_number", editParams.getBatteryNumber())
|
||||||
|
|
||||||
|
//匹配车辆id
|
||||||
|
.eq("vehicle_id", editParams.getVehicleId());
|
||||||
|
|
||||||
|
|
||||||
|
boolean update = update(updateWrapper);
|
||||||
|
|
||||||
|
if (!update) {
|
||||||
|
result = "编辑失败";
|
||||||
|
Result.error(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除掉车辆id为入参的车辆、标识的中间表数据
|
||||||
|
int delete = vehicleAndLogoService.deleteByVehicleId(editParams.getVehicleId());
|
||||||
|
|
||||||
|
//删除绑定之后,再添加新的绑定
|
||||||
|
vehicleAndLogoService.vehicleBindLogo(editParams.getVehicleId(), editParams.getLogoIds());
|
||||||
|
|
||||||
|
result = "编辑成功!";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/27 16:34
|
||||||
|
* @Description: 新增车辆
|
||||||
|
* @Param: [insertParams]
|
||||||
|
* @Return: java.lang.String
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public String insert(VehicleInsertParams insertParams) {
|
||||||
|
String result = "";
|
||||||
|
|
||||||
|
if ((insertParams.getLogoIds() == null || insertParams.getLogoIds().isEmpty())) {
|
||||||
|
result = "未选择电子围栏";
|
||||||
|
Result.error(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//雪花算法生成随机数
|
||||||
|
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||||
|
long randomId = idGenerator.nextId();
|
||||||
|
String vin = "VIN" + randomId;
|
||||||
|
|
||||||
|
|
||||||
|
//创建入参对象
|
||||||
|
Vehicle vehicle = new Vehicle();
|
||||||
|
|
||||||
|
vehicle.setVehicleType(insertParams.getVehicleType());
|
||||||
|
vehicle.setMotorManufacturer(insertParams.getMotorManufacturer());
|
||||||
|
vehicle.setBatteryManufacturer(insertParams.getBatteryManufacturer());
|
||||||
|
vehicle.setMotorNumber(insertParams.getMotorNumber());
|
||||||
|
vehicle.setBatteryNumber(insertParams.getBatteryNumber());
|
||||||
|
vehicle.setVin(vin);
|
||||||
|
vehicle.setVehicleState(0);
|
||||||
|
vehicle.setIsdelete(0);
|
||||||
|
|
||||||
|
|
||||||
|
//执行插入操作
|
||||||
|
int insert = vehicleMapper.insert(vehicle);
|
||||||
|
|
||||||
|
if (insert == 0) {
|
||||||
|
result = "新增失败";
|
||||||
|
Result.error(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取新增的车辆id值
|
||||||
|
//执行添加电子围栏
|
||||||
|
int i = vehicleAndLogoService.vehicleBindLogo(vehicle.getVehicleId(), insertParams.getLogoIds());
|
||||||
|
|
||||||
|
|
||||||
|
result = "新增成功!";
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/31 21:34
|
||||||
|
* @Description: 获取绑定当前车辆的标识
|
||||||
|
* @Param: [vehicleId]
|
||||||
|
* @Return: java.util.List<java.lang.Long>
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public List<Long> getBindLogoById(Long vehicleId) {
|
||||||
|
List<Long> logoIds = vehicleAndLogoService.getBindLogoById(vehicleId);
|
||||||
|
|
||||||
|
return logoIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.couplet.vehicle.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.couplet.vehicle.domain.VehicleType;
|
||||||
|
import com.couplet.vehicle.mapper.VehicleTypeMapper;
|
||||||
|
import com.couplet.vehicle.service.VehicleTypeService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/31
|
||||||
|
* @Description: 车辆类型服务实现类
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class VehicleTypeServiceImpl extends ServiceImpl<VehicleTypeMapper, VehicleType> implements VehicleTypeService {
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @Date: 2024/3/31 10:17
|
||||||
|
* @Description: 获取所有的车辆类型
|
||||||
|
* @Param: []
|
||||||
|
* @Return: java.util.List<com.couplet.vehicle.domain.VehicleType>
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public List<VehicleType> list() {
|
||||||
|
LambdaQueryWrapper<VehicleType> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.couplet.vehicle.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/27
|
||||||
|
* @Description: 雪花ID生成器
|
||||||
|
* 使用方法
|
||||||
|
* SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1); // 创建一个 ID 生成器,传入机器 ID 和数据中心 ID
|
||||||
|
* long id = idGenerator.nextId(); // 生成 ID
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class SnowflakeIdGenerator {
|
||||||
|
|
||||||
|
private final long epoch = 1420041600000L; // 起始时间戳,用于缩小时间戳范围,可根据实际情况调整
|
||||||
|
private final long workerIdBits = 5L; // 机器 ID 所占位数
|
||||||
|
private final long dataCenterIdBits = 5L; // 数据中心 ID 所占位数
|
||||||
|
private final long sequenceBits = 12L; // 序列号所占位数
|
||||||
|
|
||||||
|
private final long maxWorkerId = -1L ^ (-1L << workerIdBits); // 机器 ID 最大值
|
||||||
|
private final long maxDataCenterId = -1L ^ (-1L << dataCenterIdBits); // 数据中心 ID 最大值
|
||||||
|
private final long maxSequence = -1L ^ (-1L << sequenceBits); // 序列号最大值
|
||||||
|
|
||||||
|
private final long workerIdShift = sequenceBits; // 机器 ID 向左移动位数
|
||||||
|
private final long dataCenterIdShift = sequenceBits + workerIdBits; // 数据中心 ID 向左移动位数
|
||||||
|
private final long timestampShift = sequenceBits + workerIdBits + dataCenterIdBits; // 时间戳向左移动位数
|
||||||
|
|
||||||
|
private long workerId; // 机器 ID
|
||||||
|
private long dataCenterId; // 数据中心 ID
|
||||||
|
private long sequence = 0L; // 序列号
|
||||||
|
private long lastTimestamp = -1L; // 上次生成的时间戳
|
||||||
|
|
||||||
|
public SnowflakeIdGenerator(long workerId, long dataCenterId) {
|
||||||
|
if (workerId > maxWorkerId || workerId < 0) {
|
||||||
|
throw new IllegalArgumentException("Worker ID can't be greater than " + maxWorkerId + " or less than 0");
|
||||||
|
}
|
||||||
|
if (dataCenterId > maxDataCenterId || dataCenterId < 0) {
|
||||||
|
throw new IllegalArgumentException("Data center ID can't be greater than " + maxDataCenterId + " or less than 0");
|
||||||
|
}
|
||||||
|
this.workerId = workerId;
|
||||||
|
this.dataCenterId = dataCenterId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized long nextId() {
|
||||||
|
long timestamp = timeGen();
|
||||||
|
|
||||||
|
if (timestamp < lastTimestamp) {
|
||||||
|
throw new RuntimeException("Clock moved backwards, refusing to generate ID");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timestamp == lastTimestamp) {
|
||||||
|
sequence = (sequence + 1) & maxSequence;
|
||||||
|
if (sequence == 0) {
|
||||||
|
timestamp = tilNextMillis(lastTimestamp);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sequence = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastTimestamp = timestamp;
|
||||||
|
|
||||||
|
return ((timestamp - epoch) << timestampShift) |
|
||||||
|
(dataCenterId << dataCenterIdShift) |
|
||||||
|
(workerId << workerIdShift) |
|
||||||
|
sequence;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long tilNextMillis(long lastTimestamp) {
|
||||||
|
long timestamp = timeGen();
|
||||||
|
while (timestamp <= lastTimestamp) {
|
||||||
|
timestamp = timeGen();
|
||||||
|
}
|
||||||
|
return timestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private long timeGen() {
|
||||||
|
return System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
|
Spring Application Name: ${spring.application.name}
|
||||||
|
_ _ ____ _ _ ____ ___ __ ____
|
||||||
|
( \/ )( ___)( )_( )(_ _) / __)( ) ( ___)
|
||||||
|
\ / )__) ) _ ( _)(_ ( (__ )(__ )__)
|
||||||
|
\/ (____)(_) (_)(____) \___)(____)(____)
|
|
@ -0,0 +1,32 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 9615
|
||||||
|
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: couplet-vehicle
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
|
config:
|
||||||
|
# 配置中心地址
|
||||||
|
server-addr: 121.89.211.230:8848
|
||||||
|
namespace: 172469
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.couplet.system.mapper: DEBUG
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="logs/couplet-system"/>
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="com.couplet" level="info"/>
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn"/>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info"/>
|
||||||
|
<appender-ref ref="file_error"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?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="com.couplet.vehicle.mapper.VehicleAndLogoMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="vehicleBindLogo">
|
||||||
|
INSERT INTO `couplet_vehicle_and_logo` ( `vehicle_id`, `logo_id`)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="logoIds" item="logoId" separator=",">
|
||||||
|
(#{vehicleId},#{logoId})
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<delete id="deleteByVehicleId">
|
||||||
|
DELETE
|
||||||
|
FROM `couplet_vehicle_and_logo`
|
||||||
|
WHERE `vehicle_id` = #{vehicleId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="getBindLogoById" resultType="java.lang.Long">
|
||||||
|
SELECT val.logo_id
|
||||||
|
FROM `couplet_vehicle_and_logo` val
|
||||||
|
WHERE val.vehicle_id = #{vehicleId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?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="com.couplet.vehicle.mapper.VehicleMapper">
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?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="com.couplet.vehicle.mapper.VehicleTypeMapper">
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -0,0 +1,20 @@
|
||||||
|
import com.couplet.vehicle.utils.SnowflakeIdGenerator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ProjectName: five-groups-couplet
|
||||||
|
* @Author: LiuYunHu
|
||||||
|
* @CreateTime: 2024/3/27
|
||||||
|
* @Description:
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class IdTest {
|
||||||
|
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||||
|
|
||||||
|
long l = idGenerator.nextId();
|
||||||
|
System.out.println(l);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>couplet-msg</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Swagger UI -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-swagger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,382 @@
|
||||||
|
package com.couplet.msg.domain;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/3/31 16:01
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MsgData {
|
||||||
|
/**
|
||||||
|
* VIN
|
||||||
|
*/
|
||||||
|
private String vin;
|
||||||
|
/**
|
||||||
|
* 行驶路线
|
||||||
|
*/
|
||||||
|
private String drivingRoute;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 经度
|
||||||
|
*/
|
||||||
|
private String longitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 维度
|
||||||
|
*/
|
||||||
|
private String latitude;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 速度
|
||||||
|
*/
|
||||||
|
private String speed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 里程
|
||||||
|
*/
|
||||||
|
private BigDecimal mileage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总电压
|
||||||
|
*/
|
||||||
|
private String voltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 总电流
|
||||||
|
*/
|
||||||
|
private String current;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绝缘电阻
|
||||||
|
*/
|
||||||
|
private String resistance;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 档位
|
||||||
|
*/
|
||||||
|
private String gear = "P";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加速踏板行程值
|
||||||
|
*/
|
||||||
|
private String accelerationPedal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 制动踏板行程值
|
||||||
|
*/
|
||||||
|
private String brakePedal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 燃料消耗率
|
||||||
|
*/
|
||||||
|
private String fuelConsumptionRate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机控制器温度
|
||||||
|
*/
|
||||||
|
private String motorControllerTemperature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机转速
|
||||||
|
*/
|
||||||
|
private String motorSpeed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机转矩
|
||||||
|
*/
|
||||||
|
private String motorTorque;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机温度
|
||||||
|
*/
|
||||||
|
private String motorTemperature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机电压
|
||||||
|
*/
|
||||||
|
private String motorVoltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电机电流
|
||||||
|
*/
|
||||||
|
private String motorCurrent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池剩余电量SOC
|
||||||
|
*/
|
||||||
|
private BigDecimal remainingBattery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电池总容量
|
||||||
|
*/
|
||||||
|
private BigDecimal batteryLevel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前状态允许的最大反馈功率
|
||||||
|
*/
|
||||||
|
private String maximumFeedbackPower;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前状态允许最大放电功率
|
||||||
|
*/
|
||||||
|
private String maximumDischargePower;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BMS自检计数器
|
||||||
|
*/
|
||||||
|
private String selfCheckCounter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池充放电电流
|
||||||
|
*/
|
||||||
|
private String totalBatteryCurrent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池负载端总电压V3
|
||||||
|
*/
|
||||||
|
private String totalBatteryVoltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单次最大电压
|
||||||
|
*/
|
||||||
|
private String singleBatteryMaxVoltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单体电池最低电压
|
||||||
|
*/
|
||||||
|
private String singleBatteryMinVoltage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单体电池最高温度
|
||||||
|
*/
|
||||||
|
private String singleBatteryMaxTemperature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单体电池最低温度
|
||||||
|
*/
|
||||||
|
private String singleBatteryMinTemperature;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池可用容量
|
||||||
|
*/
|
||||||
|
private String availableBatteryCapacity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆状态
|
||||||
|
*/
|
||||||
|
private int vehicleStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充电状态
|
||||||
|
*/
|
||||||
|
private int chargingStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运行状态
|
||||||
|
*/
|
||||||
|
private int operatingStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SOC
|
||||||
|
*/
|
||||||
|
private int socStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 可充电储能装置工作状态
|
||||||
|
*/
|
||||||
|
private int chargingEnergyStorageStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 驱动电机状态
|
||||||
|
*/
|
||||||
|
private int driveMotorStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定位是否有效
|
||||||
|
*/
|
||||||
|
private int positionStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EAS(汽车防盗系统)状态
|
||||||
|
*/
|
||||||
|
private int easStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PTC(电动加热器)状态
|
||||||
|
*/
|
||||||
|
private int ptcStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* EPS(电动助力系统)状态
|
||||||
|
*/
|
||||||
|
private int epsStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ABS(防抱死)状态
|
||||||
|
*/
|
||||||
|
private int absStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MCU(电机/逆变器)状态
|
||||||
|
*/
|
||||||
|
private int mcuStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池加热状态
|
||||||
|
*/
|
||||||
|
private int heatingStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池当前状态
|
||||||
|
*/
|
||||||
|
private int batteryStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 动力电池保温状态
|
||||||
|
*/
|
||||||
|
private int batteryInsulationStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DCDC(电力交换系统)状态
|
||||||
|
*/
|
||||||
|
private int dcdcStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CHG(充电机)状态
|
||||||
|
*/
|
||||||
|
private int chgStatus = 1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆状态 报文
|
||||||
|
*/
|
||||||
|
private String vehicleStatusMsg;
|
||||||
|
/**
|
||||||
|
* 智能硬件 报文
|
||||||
|
*/
|
||||||
|
private String smartHardwareMsg;
|
||||||
|
/**
|
||||||
|
* 电池报文
|
||||||
|
*/
|
||||||
|
private String batteryMsg;
|
||||||
|
|
||||||
|
public String getMsg(){
|
||||||
|
//第一位VIN
|
||||||
|
return vin +
|
||||||
|
// 当前时间戳
|
||||||
|
System.currentTimeMillis() +
|
||||||
|
//第二位经度 longitude latitude
|
||||||
|
getValue(longitude, 11) +
|
||||||
|
//第三位维度 longitude latitude
|
||||||
|
getValue(latitude, 10) +
|
||||||
|
//车速
|
||||||
|
getValue(speed, 6) +
|
||||||
|
//总里程
|
||||||
|
getValue(mileage == null ? "" : mileage.toString(), 11) +
|
||||||
|
// 总电压
|
||||||
|
getValue(voltage, 6) +
|
||||||
|
//总电流
|
||||||
|
getValue(current, 5) +
|
||||||
|
//绝缘电阻 79 - 87
|
||||||
|
getValue(resistance, 9) +
|
||||||
|
//档位
|
||||||
|
(gear == null ? "D" : gear) +
|
||||||
|
// 加速踏板行程值
|
||||||
|
getValue(accelerationPedal, 2) +
|
||||||
|
// 制动踏板行程值
|
||||||
|
getValue(brakePedal, 2) +
|
||||||
|
// 燃料消耗率
|
||||||
|
getValue(fuelConsumptionRate, 5) +
|
||||||
|
//电机控制器温度
|
||||||
|
getValue(motorControllerTemperature, 6) +
|
||||||
|
//电机转速
|
||||||
|
getValue(motorSpeed, 5) +
|
||||||
|
//点击转矩
|
||||||
|
getValue(motorTorque, 4) +
|
||||||
|
//电机温度
|
||||||
|
getValue(motorTemperature, 6) +
|
||||||
|
//电机电压
|
||||||
|
getValue(motorVoltage, 5) +
|
||||||
|
//电机电流
|
||||||
|
getValue(motorCurrent, 8) +
|
||||||
|
//动力电池剩余电量SOC
|
||||||
|
getValue(remainingBattery == null ? "" : remainingBattery.toString(), 6) +
|
||||||
|
//当前状态允许的最大反馈功率
|
||||||
|
getValue(maximumFeedbackPower, 6) +
|
||||||
|
//当前状态允许最大放电功率
|
||||||
|
getValue(maximumDischargePower, 6) +
|
||||||
|
//BMS自检计数器
|
||||||
|
getValue(selfCheckCounter, 2) +
|
||||||
|
//动力电池充放电电流
|
||||||
|
getValue(totalBatteryCurrent, 5) +
|
||||||
|
//动力电池负载端总电压V3
|
||||||
|
getValue(totalBatteryVoltage, 6) +
|
||||||
|
//单次最大电压
|
||||||
|
getValue(singleBatteryMaxVoltage, 4) +
|
||||||
|
//单体电池最低电压
|
||||||
|
getValue(singleBatteryMinVoltage, 4) +
|
||||||
|
//单体电池最高温度
|
||||||
|
getValue(singleBatteryMaxTemperature, 6) +
|
||||||
|
//单体电池最低温度
|
||||||
|
getValue(singleBatteryMinTemperature, 6) +
|
||||||
|
//动力电池可用容量
|
||||||
|
getValue(availableBatteryCapacity, 6) +
|
||||||
|
//车辆状态
|
||||||
|
vehicleStatus +
|
||||||
|
//充电状态
|
||||||
|
chargingStatus +
|
||||||
|
//运行状态
|
||||||
|
operatingStatus +
|
||||||
|
//SOC
|
||||||
|
socStatus +
|
||||||
|
//可充电储能装置工作状态
|
||||||
|
chargingEnergyStorageStatus +
|
||||||
|
//驱动电机状态
|
||||||
|
driveMotorStatus +
|
||||||
|
//定位是否有效
|
||||||
|
positionStatus +
|
||||||
|
//EAS
|
||||||
|
easStatus +
|
||||||
|
//PTC
|
||||||
|
ptcStatus +
|
||||||
|
//EPS
|
||||||
|
epsStatus +
|
||||||
|
//ABS
|
||||||
|
absStatus +
|
||||||
|
//MCU
|
||||||
|
mcuStatus +
|
||||||
|
//动力电池加热状态
|
||||||
|
heatingStatus +
|
||||||
|
//动力电池当前状态
|
||||||
|
batteryStatus +
|
||||||
|
//动力电池保温状态
|
||||||
|
batteryInsulationStatus +
|
||||||
|
//DCDC
|
||||||
|
dcdcStatus +
|
||||||
|
//CHG
|
||||||
|
chgStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(String val , int valLength){
|
||||||
|
if(val == null){
|
||||||
|
val = "";
|
||||||
|
}
|
||||||
|
int length = val.length();
|
||||||
|
if (length > valLength){
|
||||||
|
return val.substring( 0 , valLength);
|
||||||
|
}
|
||||||
|
val = val + "0".repeat(valLength - length);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.couplet.msg.domain;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/3/31 21:18
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class TroubleLog {
|
||||||
|
/**
|
||||||
|
* 故障记录Id
|
||||||
|
*/
|
||||||
|
private Integer troubleLogId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障码
|
||||||
|
*/
|
||||||
|
private String troubleLogCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障记录车辆VIN
|
||||||
|
*/
|
||||||
|
private String troubleLogVin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始预警时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date troubleLogStartTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束预警时间
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date troubleLogEndTime;
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.couplet.msg;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/3/31 16:57
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public class Main {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String msgString = "VIN123456789DIJE41711764104506116.664380039.531990072.00031.3760000022000022000852000000D00809.600940000589066790930000203002030000044282.55000014000080700007440003000400095000058000054000011111111111111111";
|
||||||
|
|
||||||
|
//使用正则表达式匹配需要的部分
|
||||||
|
String pattern = "(.{17})(.{10})(.{4})(.{2})(.{2})";
|
||||||
|
Pattern compile = Pattern.compile(pattern);
|
||||||
|
Matcher matcher = compile.matcher(msgString);
|
||||||
|
|
||||||
|
if (matcher.find()) {
|
||||||
|
for (int i = 1; i <= matcher.groupCount(); i++) {
|
||||||
|
System.out.println("Group "+ i + ":" + matcher.group(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
package com.couplet.msg;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/3/30 11:39
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
public class ParsingMsg {
|
||||||
|
private static final List<String> msgList = new ArrayList<>(){{
|
||||||
|
add("7E 56 49 4e 31 32 33 34 35 36 37 38 39 44 49 4a 45 34 31 37 31 31 37 36 34 31 30 34 35 30 36 31 31 36 2e 36 36 34 33 38 30 30 33 39 2e 35 33 31 39 39 30 30 37 32 2e 30 30 30 33 31 2e 33 37 36 30 30 30 30 30 32 32 30 30 30 30 32 32 30 30 30 38 35 32 30 30 30 30 30 30 44 30 30 38 30 39 2e 36 30 30 39 34 30 30 30 30 35 38 39 30 36 36 37 39 30 39 33 30 30 30 30 32 30 33 30 30 32 30 33 30 30 30 30 30 34 34 32 38 32 2e 35 35 30 30 30 30 31 34 30 30 30 30 38 30 37 30 30 30 30 37 34 34 30 30 30 33 30 30 30 34 30 30 30 39 35 30 30 30 30 35 38 30 30 30 30 35 34 30 30 30 30 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 31 24 7E");
|
||||||
|
}};
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
// 去头去尾
|
||||||
|
for (String string : msgList) {
|
||||||
|
String substring = string.substring(2, string.length() - 2);
|
||||||
|
System.out.println("去头去尾字符串:"+ substring);
|
||||||
|
|
||||||
|
String hexStringWithoutSpaces = substring.replaceAll("\\s+", "");
|
||||||
|
String asciiString = hexToString(hexStringWithoutSpaces);
|
||||||
|
System.out.println("16进制解析后的数据:"+asciiString);
|
||||||
|
// //截取前17位
|
||||||
|
// String substring1 = asciiString.substring(0, 17);
|
||||||
|
// System.out.println("VIN:"+substring1);
|
||||||
|
// String substring2 = asciiString.substring(17, 30);
|
||||||
|
// System.out.println("时间戳:"+substring2);
|
||||||
|
// String substring3 = asciiString.substring(30, 40);
|
||||||
|
// System.out.println("经度:" +substring3);
|
||||||
|
// String substring4 = asciiString.substring(41, 50);
|
||||||
|
// System.out.println("纬度:"+ substring4);
|
||||||
|
// String substring5 = asciiString.substring(51, 56);
|
||||||
|
// System.out.println("车速:"+ substring5);
|
||||||
|
// String substring6 = asciiString.substring(57, 67);
|
||||||
|
// System.out.println("总里程:"+ substring6);
|
||||||
|
// String substring7 = asciiString.substring(68, 73);
|
||||||
|
// System.out.println("总电压:"+ substring7);
|
||||||
|
String pattern = "(.{17})(.{10})(.{9})(.{8})(.{2})";
|
||||||
|
Pattern compile = Pattern.compile(pattern);
|
||||||
|
Matcher matcher = compile.matcher(asciiString);
|
||||||
|
if (matcher.find()) {
|
||||||
|
for (int i = 1; i < matcher.groupCount(); i++) {
|
||||||
|
System.out.println("Group "+ i + ":" + matcher.group(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将16进制字符串转换为ASCII字符串
|
||||||
|
* @param hexString 16进制字符串
|
||||||
|
* @return ASCII字符串
|
||||||
|
*/
|
||||||
|
public static String hexToString(String hexString) {
|
||||||
|
StringBuilder asciiString = new StringBuilder();
|
||||||
|
for (int i = 0; i < hexString.length(); i += 2) {
|
||||||
|
String hex = hexString.substring(i, i + 2);
|
||||||
|
int decimal = Integer.parseInt(hex, 16);
|
||||||
|
asciiString.append((char) decimal);
|
||||||
|
}
|
||||||
|
return asciiString.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,75 @@
|
||||||
|
package com.couplet.system.controller;
|
||||||
|
|
||||||
|
import com.couplet.common.core.domain.Result;
|
||||||
|
import com.couplet.common.system.domain.SysFirm;
|
||||||
|
import com.couplet.system.service.SysFirmService;
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName SysFirmController
|
||||||
|
* @Description 企业信息
|
||||||
|
* @Author YuanYongH
|
||||||
|
* @Date 2024/3/28 22:14
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("firm")
|
||||||
|
public class SysFirmController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysFirmService sysFirmService;
|
||||||
|
/**
|
||||||
|
* @Description // 管理企业列表
|
||||||
|
* @Date 2024/3/28
|
||||||
|
* @param sysFirm
|
||||||
|
* @return com.couplet.common.core.domain.Result<java.util.List<com.couplet.common.system.domain.SysFirm>>
|
||||||
|
**/
|
||||||
|
@PostMapping("firmList")
|
||||||
|
public Result<List<SysFirm>> firmList(@RequestBody SysFirm sysFirm){
|
||||||
|
List<SysFirm> list = sysFirmService.firmList(sysFirm);
|
||||||
|
Result<List<SysFirm>> result = Result.success(list);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description // 添加企业 默认未认证
|
||||||
|
* @Date 2024/3/28
|
||||||
|
* @param sysFirm
|
||||||
|
* @return com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@PostMapping("addFirm")
|
||||||
|
public Result addFirm(@RequestBody SysFirm sysFirm){
|
||||||
|
int i = sysFirmService.addFirm(sysFirm);
|
||||||
|
Result<Integer> result = Result.success(i);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description // 修改企业信息
|
||||||
|
* @Date 2024/3/28
|
||||||
|
* @param sysFirm
|
||||||
|
* @return com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@PostMapping("updateFirm")
|
||||||
|
public Result updateFirm(@RequestBody SysFirm sysFirm){
|
||||||
|
int i = sysFirmService.updateFirm(sysFirm);
|
||||||
|
Result<Integer> result = Result.success(i);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description // 删除企业 附属的员工一并删除
|
||||||
|
* @Date 2024/3/29
|
||||||
|
* @param deptId
|
||||||
|
* @return com.couplet.common.core.domain.Result
|
||||||
|
**/
|
||||||
|
@PostMapping("delFirm/{deptId}")
|
||||||
|
public Result delFirm(@PathVariable Integer deptId){
|
||||||
|
int i = sysFirmService.delFirm(deptId);
|
||||||
|
Result<Integer> success = Result.success(i);
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.couplet.system.mapper;
|
||||||
|
|
||||||
|
import com.couplet.common.system.domain.SysFirm;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName SysFirmMapper
|
||||||
|
* @Description TODO
|
||||||
|
* @Author YuanYongH
|
||||||
|
* @Date 2024/3/28 22:18
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SysFirmMapper {
|
||||||
|
List<SysFirm> firmList(SysFirm sysFirm);
|
||||||
|
|
||||||
|
int addFirm(SysFirm sysFirm);
|
||||||
|
|
||||||
|
int updateFirm(SysFirm sysFirm);
|
||||||
|
|
||||||
|
int delFirm(Integer deptId);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.couplet.system.service;
|
||||||
|
|
||||||
|
import com.couplet.common.system.domain.SysFirm;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName SysFirmService
|
||||||
|
* @Description TODO
|
||||||
|
* @Author YuanYongH
|
||||||
|
* @Date 2024/3/28 22:17
|
||||||
|
*/
|
||||||
|
public interface SysFirmService {
|
||||||
|
List<SysFirm> firmList(SysFirm sysFirm);
|
||||||
|
|
||||||
|
int addFirm(SysFirm sysFirm);
|
||||||
|
|
||||||
|
int updateFirm(SysFirm sysFirm);
|
||||||
|
|
||||||
|
int delFirm(Integer deptId);
|
||||||
|
}
|
|
@ -23,8 +23,7 @@ import java.util.Objects;
|
||||||
* @Date 2023-11-13 上午 10:06
|
* @Date 2023-11-13 上午 10:06
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig>
|
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements SysConfigService {
|
||||||
implements SysConfigService {
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RedisService redisService;
|
private RedisService redisService;
|
||||||
|
|
|
@ -224,7 +224,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateDept (SysDept dept) {
|
public int updateDept (SysDept dept) {
|
||||||
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
|
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
|
||||||
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
|
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
|
||||||
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
|
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
package com.couplet.system.service.impl;
|
||||||
|
|
||||||
|
import com.couplet.common.system.domain.SysFirm;
|
||||||
|
import com.couplet.system.mapper.SysFirmMapper;
|
||||||
|
import com.couplet.system.service.SysFirmService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName SysFirmServiceImpl
|
||||||
|
* @Description TODO
|
||||||
|
* @Author YuanYongH
|
||||||
|
* @Date 2024/3/28 22:17
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysFirmServiceImpl implements SysFirmService {
|
||||||
|
@Autowired
|
||||||
|
private SysFirmMapper sysFirmMapper;
|
||||||
|
@Override
|
||||||
|
public List<SysFirm> firmList(SysFirm sysFirm) {
|
||||||
|
return sysFirmMapper.firmList(sysFirm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int addFirm(SysFirm sysFirm) {
|
||||||
|
return sysFirmMapper.addFirm(sysFirm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateFirm(SysFirm sysFirm) {
|
||||||
|
return sysFirmMapper.updateFirm(sysFirm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int delFirm(Integer deptId) {
|
||||||
|
return sysFirmMapper.delFirm(deptId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,6 +4,8 @@ server:
|
||||||
|
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: couplet-system
|
name: couplet-system
|
||||||
|
@ -15,16 +17,16 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 121.89.211.230:8848
|
server-addr: 121.89.211.230:8848
|
||||||
namespace: 968741d4-299d-483c-8d30-ede2aff8cfd4
|
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.couplet.system.mapper: DEBUG
|
com.couplet.system.mapper: DEBUG
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?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="com.couplet.system.mapper.SysFirmMapper">
|
||||||
|
<insert id="addFirm">
|
||||||
|
INSERT INTO `ry-cloud`.`sys_dept`
|
||||||
|
( `dept_name`, `leader`, `phone`, `status`, `del_flag`, `create_by` )
|
||||||
|
VALUES ( #{deptName}, #{leader}, #{phone}, #{status}, #{delFlag}, #{createBy});
|
||||||
|
|
||||||
|
|
||||||
|
</insert>
|
||||||
|
<update id="updateFirm">
|
||||||
|
|
||||||
|
UPDATE `ry-cloud`.`sys_dept`
|
||||||
|
SET `dept_name` = #{deptName}, `leader` = #{leader}, `phone` = #{phone}, `status` = #{status}, `del_flag` = 0, `create_by` = #{createBy}
|
||||||
|
WHERE `dept_id` = #{deptId};
|
||||||
|
|
||||||
|
|
||||||
|
</update>
|
||||||
|
<delete id="delFirm">
|
||||||
|
update `sys_dept`
|
||||||
|
set del_flag = '2'
|
||||||
|
where dept_id = #{deptId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="firmList" resultType="com.couplet.common.system.domain.SysFirm">
|
||||||
|
select * from sys_dept where del_flag = 0
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,85 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>couplet-trouble</artifactId>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Swagger UI -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-swagger-ui</artifactId>
|
||||||
|
<version>${swagger.fox.version}</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Swagger -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.couplet</groupId>
|
||||||
|
<artifactId>couplet-common-swagger</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.couplet.trouble;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/3/26 21:42
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@SpringBootApplication(scanBasePackages = "com.couplet.**")
|
||||||
|
@EnableFeignClients(basePackages = "com.couplet.**")
|
||||||
|
public class CoupletTroubleApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(CoupletTroubleApplication.class);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
package com.couplet.trouble.controller;
|
||||||
|
|
||||||
|
import com.couplet.common.core.domain.PageResult;
|
||||||
|
import com.couplet.common.core.domain.Result;
|
||||||
|
import com.couplet.common.core.web.controller.BaseController;
|
||||||
|
import com.couplet.common.log.annotation.Log;
|
||||||
|
import com.couplet.common.log.enums.BusinessType;
|
||||||
|
import com.couplet.trouble.domain.CoupletTroubleCode;
|
||||||
|
import com.couplet.trouble.domain.CoupletTroubleGrade;
|
||||||
|
import com.couplet.trouble.domain.CoupletTroubleType;
|
||||||
|
import com.couplet.trouble.domain.resp.TroubleResp;
|
||||||
|
import com.couplet.trouble.service.SysTroubleService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/3/26 22:36
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("trouble")
|
||||||
|
public class SysTroubleController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private SysTroubleService troubleService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障码管理列表
|
||||||
|
*/
|
||||||
|
@PostMapping("/troubleList")
|
||||||
|
public Result<PageResult<CoupletTroubleCode>> list(@RequestBody TroubleResp troubleReq) {
|
||||||
|
PageResult<CoupletTroubleCode> result = troubleService.selectTroubleList(troubleReq);
|
||||||
|
return Result.success(result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障类型信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/troubleTypeList")
|
||||||
|
public List<CoupletTroubleType> listType() {
|
||||||
|
return troubleService.selectTroubleListByType();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障等级信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/troubleGradeList")
|
||||||
|
public List<CoupletTroubleGrade> listGrade() {
|
||||||
|
return troubleService.selectTroubleListByGrade();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增故障码数据
|
||||||
|
*/
|
||||||
|
@Log(title = "新增故障码数据", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping("insertTrouble")
|
||||||
|
public Result<?> insert(@Validated @RequestBody CoupletTroubleCode troubleAddReq) {
|
||||||
|
return toAjax(troubleService.save(troubleAddReq));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改故障码数据
|
||||||
|
*/
|
||||||
|
@Log(title = "修改故障码数据",businessType = BusinessType.UPDATE)
|
||||||
|
@PostMapping("updateTrouble")
|
||||||
|
public Result<?> edit(@Validated @RequestBody CoupletTroubleCode troubleUpdReq) {
|
||||||
|
return toAjax(troubleService.updateById(troubleUpdReq));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除故障码数据
|
||||||
|
*/
|
||||||
|
@Log(title = "删除故障码",businessType = BusinessType.DELETE)
|
||||||
|
@GetMapping("/remove/{troubleId}")
|
||||||
|
public Result<?> remove(@PathVariable Integer troubleId) {
|
||||||
|
troubleService.removeById(troubleId);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.couplet.trouble.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.couplet.common.core.annotation.Excel;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/3/26 21:49
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
//@Getter
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CoupletTroubleCode {
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
@TableId(value = "trouble_id",type = IdType.AUTO)
|
||||||
|
@Excel(name = "故障码主键", cellType = Excel.ColumnType.NUMERIC)
|
||||||
|
private Integer troubleId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障码
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障码")
|
||||||
|
private String troubleCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障位
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障位")
|
||||||
|
private String troublePosition;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障值
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障值")
|
||||||
|
private String troubleValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障标签
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障标签")
|
||||||
|
private String troubleTag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障类型Id
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障类型Id")
|
||||||
|
private Integer typeId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 故障等级Id
|
||||||
|
*/
|
||||||
|
@Excel(name = "故障等级Id")
|
||||||
|
private Integer gradeId;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package com.couplet.trouble.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongXiaoDong
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2024/3/26 21:49
|
||||||
|
* @description
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CoupletTroubleGrade {
|
||||||
|
private Integer gradeId;
|
||||||
|
private String gradeName;
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue