Compare commits
28 Commits
server_202
...
master
Author | SHA1 | Date |
---|---|---|
|
682dd2f6e0 | |
|
a3059cbbf7 | |
|
3857e3a875 | |
|
4d1cb943ac | |
|
e6100a1318 | |
|
9c8131232b | |
|
ac3aa82ef4 | |
|
e5be107d55 | |
|
6454d72b8d | |
|
0463fde303 | |
|
b8de8285b7 | |
|
08acad4531 | |
|
a144a4d96a | |
|
a796863e54 | |
|
13960a292f | |
|
6fab49598e | |
|
46639b77a0 | |
|
00b4350289 | |
|
66ca1afa4a | |
|
4e4e80f64d | |
|
3c1b9cef33 | |
|
02f71d7baf | |
|
2c2854506e | |
|
5505c3c45f | |
|
55d398940f | |
|
d45da7b47f | |
|
672a340cdf | |
|
9478ae16c5 |
103
pom.xml
103
pom.xml
|
@ -38,6 +38,7 @@
|
|||
<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
|
||||
<mqttv3.version>1.2.5</mqttv3.version>
|
||||
<spring-kafka.version>2.8.0</spring-kafka.version>
|
||||
<aliyun.ecs.version>3.1.12</aliyun.ecs.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
|
@ -263,7 +264,17 @@
|
|||
<artifactId>zhilian-common-business</artifactId>
|
||||
<version>${zhilian.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里云ESC服务版本控制-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ecs20140526</artifactId>
|
||||
<version>${aliyun.ecs.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
</dependencyManagement>
|
||||
|
||||
<modules>
|
||||
|
@ -317,57 +328,57 @@
|
|||
</executions>
|
||||
</plugin>
|
||||
<!-- 要将源码放上去,需要加入这个插件 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-source-plugin</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<configuration>
|
||||
<attach>true</attach>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- <plugin>-->
|
||||
<!-- <groupId>org.apache.maven.plugins</groupId>-->
|
||||
<!-- <artifactId>maven-source-plugin</artifactId>-->
|
||||
<!-- <version>3.0.1</version>-->
|
||||
<!-- <configuration>-->
|
||||
<!-- <attach>true</attach>-->
|
||||
<!-- </configuration>-->
|
||||
<!-- <executions>-->
|
||||
<!-- <execution>-->
|
||||
<!-- <phase>compile</phase>-->
|
||||
<!-- <goals>-->
|
||||
<!-- <goal>jar</goal>-->
|
||||
<!-- </goals>-->
|
||||
<!-- </execution>-->
|
||||
<!-- </executions>-->
|
||||
<!-- </plugin>-->
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>releases</id>
|
||||
<name>releases</name>
|
||||
<url>http://nexus.zhilian.com:8081/repository/maven-releases/</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<!-- <distributionManagement>-->
|
||||
<!-- <repository>-->
|
||||
<!-- <id>releases</id>-->
|
||||
<!-- <name>releases</name>-->
|
||||
<!-- <url>http://nexus.zhilian.com:8081/repository/maven-releases/</url>-->
|
||||
<!-- </repository>-->
|
||||
<!-- </distributionManagement>-->
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://nexus.zhilian.com:8081/repository/maven-public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
<!-- <repositories>-->
|
||||
<!-- <repository>-->
|
||||
<!-- <id>public</id>-->
|
||||
<!-- <name>aliyun nexus</name>-->
|
||||
<!-- <url>http://nexus.zhilian.com:8081/repository/maven-public/</url>-->
|
||||
<!-- <releases>-->
|
||||
<!-- <enabled>true</enabled>-->
|
||||
<!-- </releases>-->
|
||||
<!-- </repository>-->
|
||||
<!-- </repositories>-->
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>public</id>
|
||||
<name>aliyun nexus</name>
|
||||
<url>http://nexus.zhilian.com:8081/repository/maven-public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<!-- <pluginRepositories>-->
|
||||
<!-- <pluginRepository>-->
|
||||
<!-- <id>public</id>-->
|
||||
<!-- <name>aliyun nexus</name>-->
|
||||
<!-- <url>http://nexus.zhilian.com:8081/repository/maven-public/</url>-->
|
||||
<!-- <releases>-->
|
||||
<!-- <enabled>true</enabled>-->
|
||||
<!-- </releases>-->
|
||||
<!-- <snapshots>-->
|
||||
<!-- <enabled>false</enabled>-->
|
||||
<!-- </snapshots>-->
|
||||
<!-- </pluginRepository>-->
|
||||
<!-- </pluginRepositories>-->
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package com.zhilian.business.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName Break
|
||||
* @Description 故障实体类
|
||||
* @Author YuanYongH
|
||||
* @Date 2024/4/4 9:40
|
||||
*/
|
||||
@Data
|
||||
public class Break {
|
||||
/**
|
||||
* 故障id
|
||||
**/
|
||||
private Integer breakId;
|
||||
/**
|
||||
* 故障码
|
||||
**/
|
||||
private String breakCode;
|
||||
/**
|
||||
* 车辆VIN
|
||||
**/
|
||||
private String breakVin;
|
||||
/**
|
||||
* 开始报警时间
|
||||
**/
|
||||
private Date breakDate;
|
||||
/**
|
||||
* 结束报警时间
|
||||
**/
|
||||
private Date breakTime;
|
||||
/**
|
||||
* 故障类型
|
||||
**/
|
||||
private String breakType;
|
||||
/**
|
||||
* 故障状态 是否警告
|
||||
**/
|
||||
private Integer breakState;
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.zhilian.business.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName BreakLog
|
||||
* @Description TODO
|
||||
* @Author YuanYongH
|
||||
* @Date 2024/4/8 15:07
|
||||
*/
|
||||
@Data
|
||||
public class BreakLog {
|
||||
|
||||
/** 故障日志id */
|
||||
private Integer breakLogId;
|
||||
/** 故障码 */
|
||||
private String breakCode;
|
||||
/** 车辆VIN */
|
||||
private String breakVin;
|
||||
/** 故障类型 */
|
||||
private String breakType;
|
||||
/** 结束报警时间 */
|
||||
private Date breakTime;
|
||||
/** 开始报警时间 */
|
||||
private Date breakDate;
|
||||
/** 是否报警 */
|
||||
private String breakState;
|
||||
/** 逻辑删除 */
|
||||
private Integer breakDel;
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package com.zhilian.business.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.zhilian.common.core.annotation.Excel;
|
||||
import com.zhilian.common.core.web.domain.BaseEntity;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 故障对象 business_break
|
||||
*
|
||||
* @author Yy
|
||||
* @date 2024-04-07
|
||||
*/
|
||||
@Data
|
||||
public class BusinessBreak extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** id */
|
||||
private Long breakId;
|
||||
|
||||
/** 故障码 */
|
||||
@Excel(name = "故障码")
|
||||
private String breakCode;
|
||||
|
||||
/** 车辆VIN */
|
||||
@Excel(name = "车辆VIN")
|
||||
private String breakVin;
|
||||
|
||||
/** 结束报警时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "结束报警时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date breakTime;
|
||||
|
||||
/** 故障类型 */
|
||||
@Excel(name = "故障类型")
|
||||
private String breakType;
|
||||
|
||||
/** 开始报警时间 */
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@Excel(name = "开始报警时间", width = 30, dateFormat = "yyyy-MM-dd")
|
||||
private Date breakDate;
|
||||
|
||||
/** 是否警告 */
|
||||
@Excel(name = "是否警告")
|
||||
private String breakState;
|
||||
|
||||
public void setBreakId(Long breakId)
|
||||
{
|
||||
this.breakId = breakId;
|
||||
}
|
||||
|
||||
public Long getBreakId()
|
||||
{
|
||||
return breakId;
|
||||
}
|
||||
public void setBreakCode(String breakCode)
|
||||
{
|
||||
this.breakCode = breakCode;
|
||||
}
|
||||
|
||||
public String getBreakCode()
|
||||
{
|
||||
return breakCode;
|
||||
}
|
||||
public void setBreakVin(String breakVin)
|
||||
{
|
||||
this.breakVin = breakVin;
|
||||
}
|
||||
|
||||
public String getBreakVin()
|
||||
{
|
||||
return breakVin;
|
||||
}
|
||||
|
||||
|
||||
public void setBreakType(String breakType)
|
||||
{
|
||||
this.breakType = breakType;
|
||||
}
|
||||
|
||||
public String getBreakType()
|
||||
{
|
||||
return breakType;
|
||||
}
|
||||
|
||||
public void setBreakState(String breakState)
|
||||
{
|
||||
this.breakState = breakState;
|
||||
}
|
||||
|
||||
public String getBreakState()
|
||||
{
|
||||
return breakState;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("breakId", getBreakId())
|
||||
.append("breakCode", getBreakCode())
|
||||
.append("breakVin", getBreakVin())
|
||||
.append("breakTime", getBreakTime())
|
||||
.append("breakType", getBreakType())
|
||||
.append("breakDate", getBreakDate())
|
||||
.append("breakState", getBreakState())
|
||||
.toString();
|
||||
}
|
||||
}
|
|
@ -16,6 +16,9 @@ public class MarkersFence {
|
|||
@TableField(value = "fence_id",insertStrategy = FieldStrategy.IGNORED)
|
||||
private Long fenceId;
|
||||
|
||||
|
||||
|
||||
|
||||
public Long getMarkerId() {
|
||||
return markerId;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package com.zhilian.business.remote;
|
||||
|
||||
import com.zhilian.business.domain.Break;
|
||||
import com.zhilian.business.domain.BreakLog;
|
||||
import com.zhilian.business.domain.BusinessBreak;
|
||||
import com.zhilian.business.remote.factory.RemoteBreakFallbackFactory;
|
||||
import com.zhilian.common.core.constant.ServiceNameConstants;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import lombok.extern.java.Log;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(contextId = "remoteBreakService", value = ServiceNameConstants.BUSINESS_SERVICE, fallbackFactory = RemoteBreakFallbackFactory.class)
|
||||
public interface RemoteBreakService {
|
||||
/**
|
||||
* 新增故障
|
||||
*/
|
||||
@PostMapping("logAdd")
|
||||
public Result logAdd(@RequestBody BreakLog breakLog);
|
||||
|
||||
@GetMapping("/checkIfBreakLogExists/{breakCode}/{breakVin}")
|
||||
public ResponseEntity<Boolean> checkIfBreakLogExists(@PathVariable("breakCode") String breakCode, @PathVariable("breakVin") String breakVin);
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.common.business.remote;
|
||||
package com.zhilian.business.remote;
|
||||
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.remote.factory.RemoteVehicleFallbackFactory;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.remote.factory.RemoteVehicleFallbackFactory;
|
||||
import com.zhilian.common.core.constant.ServiceNameConstants;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
|
@ -0,0 +1,38 @@
|
|||
package com.zhilian.business.remote.factory;
|
||||
|
||||
import com.zhilian.business.domain.BreakLog;
|
||||
import com.zhilian.business.domain.BusinessBreak;
|
||||
import com.zhilian.business.remote.RemoteBreakService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
@Slf4j
|
||||
@Component
|
||||
public class RemoteBreakFallbackFactory implements FallbackFactory<RemoteBreakService> {
|
||||
@Override
|
||||
public RemoteBreakService create(Throwable cause) {
|
||||
return new RemoteBreakService() {
|
||||
@Override
|
||||
public Result logAdd(BreakLog breakLog) {
|
||||
log.error("故障日志服务调用失败");
|
||||
return Result.error(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Boolean> checkIfBreakLogExists(String breakCode, String breakVin) {
|
||||
log.error("根据VIN和故障码查询服务调用失败");
|
||||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(false);
|
||||
}
|
||||
};
|
||||
// return new RemoteBreakService() {
|
||||
// @Override
|
||||
// public Result add(BusinessBreak businessBreak) {
|
||||
// log.error("故障日志服务调用失败");
|
||||
// return Result.error("故障日志服务调用失败");
|
||||
// }
|
||||
// };
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package com.zhilian.common.business.remote.factory;
|
||||
package com.zhilian.business.remote.factory;
|
||||
|
||||
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.remote.RemoteVehicleService;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.remote.RemoteVehicleService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
|
@ -1,64 +0,0 @@
|
|||
package com.zhilian.common.business.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.zhilian.common.core.annotation.Excel;
|
||||
import com.zhilian.common.core.web.domain.BaseEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName Fence
|
||||
* @Description 电子围栏实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:28 2024/4/8
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("business_fence")
|
||||
public class Fence extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 电子围栏编号
|
||||
*/
|
||||
@Excel(name = "参数主键", cellType = Excel.ColumnType.NUMERIC)
|
||||
@TableId(value = "fence_id", type = IdType.AUTO)
|
||||
private Long fenceId;
|
||||
/**
|
||||
* 电子围栏名称
|
||||
*/
|
||||
@Excel(name = "电子围栏名称")
|
||||
@TableField("fence_name")
|
||||
private String fenceName;
|
||||
/**
|
||||
* 电子围栏类型编号
|
||||
*/
|
||||
@Excel(name = "电子围栏类型编号")
|
||||
@TableField("fence_type_id")
|
||||
private Long fenceTypeId;
|
||||
/**
|
||||
* 电子围栏状态
|
||||
*/
|
||||
@Excel(name = "电子围栏状态")
|
||||
@TableField("fence_state")
|
||||
private Long fenceState;
|
||||
/**
|
||||
* 电子围栏经纬度信息
|
||||
*/
|
||||
@Excel(name = "电子围栏经纬度信息")
|
||||
@TableField("fence_message")
|
||||
private String fenceMessage;
|
||||
@TableField(exist = false)
|
||||
List<Markers> markersList;
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
package com.zhilian.common.business.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.zhilian.common.core.annotation.Excel;
|
||||
import com.zhilian.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* @ClassName Markers
|
||||
* @Description 车辆标识实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:29 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("business_markers")
|
||||
public class Markers extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 车辆标识编号
|
||||
*/
|
||||
@TableId(value = "markers_id", type = IdType.AUTO)
|
||||
private Long markersId;
|
||||
|
||||
/**
|
||||
* 车辆标识名称
|
||||
*/
|
||||
@TableField("markers_name")
|
||||
private String markersName;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
List<Long> fenceIds;
|
||||
|
||||
}
|
|
@ -1,74 +0,0 @@
|
|||
package com.zhilian.common.business.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.zhilian.common.core.annotation.Excel;
|
||||
import com.zhilian.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName Vehicle
|
||||
* @Description 车辆信息实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:27 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("business_vehicle")
|
||||
public class Vehicle extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 车辆ID
|
||||
*/
|
||||
@Excel(name = "车辆ID",cellType = Excel.ColumnType.NUMERIC)
|
||||
@TableId(value = "vehicle_id",type = IdType.AUTO)
|
||||
private Long vehicleId;
|
||||
/**
|
||||
* 车辆VIN
|
||||
*/
|
||||
@TableField("vehicle_vin")
|
||||
private String vehicleVIN;
|
||||
/**
|
||||
* 车辆类型编号
|
||||
*/
|
||||
private Long vehicleTypeId;
|
||||
|
||||
|
||||
@TableField(exist = false)
|
||||
private Long vehicleTypeName;
|
||||
|
||||
/**
|
||||
* 电机厂商
|
||||
*/
|
||||
private String vehicleMotor;
|
||||
/**
|
||||
* 电池厂商
|
||||
*/
|
||||
private String vehicleBattery;
|
||||
/**
|
||||
* 电机ID
|
||||
*/
|
||||
private String motorId;
|
||||
/**
|
||||
* 电池ID
|
||||
*/
|
||||
private String batteryId;
|
||||
|
||||
/**
|
||||
* 车辆状态
|
||||
*/
|
||||
private Long vehicleState;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<Long> markersIds;
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package com.zhilian.common.business.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.zhilian.common.core.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
/**
|
||||
* @ClassName VehicleType
|
||||
* @Description 车辆类型实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:30 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@TableName(value = "business_vehicle_type")
|
||||
public class VehicleType {
|
||||
|
||||
@TableId(value = "vehicle_type_id", type = IdType.AUTO)
|
||||
@Excel(name = "车型ID")
|
||||
private Long vehicleTypeId;
|
||||
|
||||
@Excel(name = "车型名称")
|
||||
@TableField(value = "vehicle_type_name")
|
||||
private String vehicleTypeName;
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package com.zhilian.common.business.domain.middle;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
/**
|
||||
* @ClassName MarkersFence
|
||||
* @Description 车辆标识与电子围栏中间表
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:30 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@TableName("business_markers_fence")
|
||||
public class MarkersFence {
|
||||
/**
|
||||
* 车辆标识编号
|
||||
*/
|
||||
@TableId(value = "markers_id",type = IdType.INPUT)
|
||||
private Long markerId;
|
||||
/**
|
||||
* 电子围栏编号
|
||||
*/
|
||||
@TableField(value = "fence_id",insertStrategy = FieldStrategy.IGNORED)
|
||||
private Long fenceId;
|
||||
|
||||
public Long getMarkerId() {
|
||||
return markerId;
|
||||
}
|
||||
|
||||
public void setMarkerId(Long markerId) {
|
||||
this.markerId = markerId;
|
||||
}
|
||||
|
||||
public Long getFenceId() {
|
||||
return fenceId;
|
||||
}
|
||||
|
||||
public void setFenceId(Long fenceId) {
|
||||
this.fenceId = fenceId;
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package com.zhilian.common.business.domain.middle;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
/**
|
||||
* @ClassName VehicleMarkers
|
||||
* @Description 车辆管理与车辆标识 中间表
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:27 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@ToString
|
||||
@TableName("business_vehicle_markers")
|
||||
public class VehicleMarkers {
|
||||
/**
|
||||
* 车辆编号
|
||||
*/
|
||||
@TableId(value = "vehicle_id",type = IdType.INPUT)
|
||||
private Long vehicleId;
|
||||
/**
|
||||
* 车辆标识编号
|
||||
*/
|
||||
@TableField(value = "markers_id",insertStrategy = FieldStrategy.IGNORED)
|
||||
private Long markersId;
|
||||
|
||||
public Long getVehicleId() {
|
||||
return vehicleId;
|
||||
}
|
||||
|
||||
public void setVehicleId(Long vehicleId) {
|
||||
this.vehicleId = vehicleId;
|
||||
}
|
||||
|
||||
public Long getMarkersId() {
|
||||
return markersId;
|
||||
}
|
||||
|
||||
public void setMarkersId(Long markersId) {
|
||||
this.markersId = markersId;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
|
||||
package com.zhilian.common.business.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
/**
|
||||
* @ClassName FenceVo
|
||||
* @Description 电子围栏查询信息实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:27 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class FenceVo {
|
||||
|
||||
|
||||
/**
|
||||
* 围栏名称
|
||||
*/
|
||||
private String fenceName;
|
||||
|
||||
/**
|
||||
* 围栏类型
|
||||
*/
|
||||
private Long fenceTypeId;
|
||||
|
||||
/**
|
||||
* 围栏状态
|
||||
*/
|
||||
private Long fenceState;
|
||||
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package com.zhilian.common.business.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
/**
|
||||
* @ClassName VehicleVo
|
||||
* @Description 车辆管理查询信息实体类
|
||||
* @Author ZeJinG.Su
|
||||
* @Date 15:28 2024/4/8
|
||||
*/
|
||||
@Data
|
||||
public class VehicleVo {
|
||||
/**
|
||||
* 车辆VIN
|
||||
*/
|
||||
private String vehicleVIN;
|
||||
/**
|
||||
* 车辆类型编号
|
||||
*/
|
||||
private Long vehicleTypeId;
|
||||
/**
|
||||
* 电子围栏编号
|
||||
*/
|
||||
private Long fenceId;
|
||||
/**
|
||||
* 电机厂商
|
||||
*/
|
||||
private String motorBusiness;
|
||||
/**
|
||||
* 电池厂商
|
||||
*/
|
||||
private String batteryBusiness;
|
||||
/**
|
||||
* 电机ID
|
||||
*/
|
||||
private String motorID;
|
||||
/**
|
||||
* 电池ID
|
||||
*/
|
||||
private String batteryID;
|
||||
}
|
|
@ -1 +1,3 @@
|
|||
com.zhilian.common.business.remote.factory.RemoteVehicleFallbackFactory
|
||||
com.zhilian.business.remote.factory.RemoteBreakFallbackFactory
|
||||
com.zhilian.business.remote.factory.RemoteFenceFallbackFactory
|
||||
com.zhilian.business.remote.factory.RemoteVehicleFallbackFactory
|
||||
|
|
|
@ -20,6 +20,11 @@ public class ServiceNameConstants {
|
|||
* 文件服务的serviceid
|
||||
*/
|
||||
public static final String FILE_SERVICE = "zhilian-file";
|
||||
|
||||
/**
|
||||
* 业务服务的serviceid
|
||||
*/
|
||||
public static final String BUSINESS_SERVICE = "zhilian-business";
|
||||
/**
|
||||
* 车辆服务的serviceid
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.zhilian.common.redis.service;
|
||||
|
||||
import io.lettuce.core.output.DoubleListOutput;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.*;
|
||||
|
@ -157,13 +156,13 @@ public class RedisService {
|
|||
/**
|
||||
* 缓存Set
|
||||
*
|
||||
* @param key 缓存键值
|
||||
* @param key 缓存键值
|
||||
* @param setValue 缓存的数据
|
||||
* @return 缓存数据的对象
|
||||
*/
|
||||
public <T> BoundSetOperations<String, T> setCacheSet(final String key, final T setValue) {
|
||||
BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
|
||||
setOperation.add(setValue);
|
||||
setOperation.add(setValue);
|
||||
return setOperation;
|
||||
}
|
||||
|
||||
|
@ -272,6 +271,7 @@ public class RedisService {
|
|||
redisTemplate.opsForZSet().add(zkey, collect);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取Zset集合大小
|
||||
*
|
||||
|
@ -308,6 +308,7 @@ public class RedisService {
|
|||
|
||||
/**
|
||||
* 范围查询集合携带分数
|
||||
*
|
||||
* @param zkey
|
||||
* @param start
|
||||
* @param end
|
||||
|
@ -326,57 +327,62 @@ public class RedisService {
|
|||
}
|
||||
|
||||
/**
|
||||
* 增加分数
|
||||
* 修改对应键值分数,delta为正数则增加,为负数则减少
|
||||
*
|
||||
* @param zkey
|
||||
* @param value
|
||||
* @param delta
|
||||
* @param <T>
|
||||
*/
|
||||
public <T> Double incrementScore(final String zkey, final T value, final Double delta){
|
||||
return redisTemplate.opsForZSet().incrementScore(zkey,value,delta);
|
||||
public <T> Double incrementScore(final String zkey, final T value, final Double delta) {
|
||||
return redisTemplate.opsForZSet().incrementScore(zkey, value, delta);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除元素
|
||||
*
|
||||
* @param zkey
|
||||
* @param values
|
||||
* @return
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
public <T> Long removeCacheZsetBatch(final String zkey,final T... values){
|
||||
return redisTemplate.opsForZSet().remove(zkey,values);
|
||||
public <T> Long removeCacheZsetBatch(final String zkey, final T... values) {
|
||||
return redisTemplate.opsForZSet().remove(zkey, values);
|
||||
}
|
||||
|
||||
/**
|
||||
* 排序并限制结果集大小,按降序返回有序集合的部分元素,支持指定索引范围。
|
||||
*
|
||||
* @param zkey
|
||||
* @param start
|
||||
* @param end
|
||||
* @return
|
||||
*/
|
||||
public Set<Double> reverseRange(final String zkey,final Long start,final Long end){
|
||||
return redisTemplate.opsForZSet().reverseRange(zkey,start,end);
|
||||
public Set<Double> reverseRange(final String zkey, final Long start, final Long end) {
|
||||
return redisTemplate.opsForZSet().reverseRange(zkey, start, end);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按分数范围查询
|
||||
*
|
||||
* @param zkey
|
||||
* @param min
|
||||
* @param max
|
||||
* @return
|
||||
*/
|
||||
public Set<Double> rangeByScore(final String zkey,final Double min,final Double max){
|
||||
return redisTemplate.opsForZSet().rangeByScore(zkey,min,max);
|
||||
public Set<Double> rangeByScore(final String zkey, final Double min, final Double max) {
|
||||
return redisTemplate.opsForZSet().rangeByScore(zkey, min, max);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取最小值
|
||||
*
|
||||
* @param zkey
|
||||
* @return
|
||||
*/
|
||||
public Map<Object, Double> getCacheZsetMin(final String zkey){
|
||||
public ZSetOperations.TypedTuple getCacheZsetMin(final String zkey) {
|
||||
ZSetOperations.TypedTuple typedTuple = redisTemplate.opsForZSet().popMin(zkey);
|
||||
return new HashMap<Object,Double>(){{put(typedTuple.getValue(),typedTuple.getScore());}};
|
||||
return typedTuple;
|
||||
}
|
||||
|
||||
|
||||
|
@ -390,8 +396,43 @@ public class RedisService {
|
|||
return redisTemplate.keys(pattern);
|
||||
}
|
||||
|
||||
public void deleteCacheSet(String s) {
|
||||
public void deleteCacheSet(final String key) {
|
||||
SetOperations setOperations = redisTemplate.opsForSet();
|
||||
setOperations.remove(s);
|
||||
setOperations.remove(key);
|
||||
}
|
||||
|
||||
public <T> void deleteCacheSetValue(final String key, final T value) {
|
||||
SetOperations setOperations = redisTemplate.opsForSet();
|
||||
setOperations.remove(key, value);
|
||||
}
|
||||
|
||||
|
||||
public <T> void deleteCacheZsetValue(final String key, final T value) {
|
||||
ZSetOperations zSetOperations = redisTemplate.opsForZSet();
|
||||
zSetOperations.remove(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 根据下标获取List中value
|
||||
* @author: LiYuan
|
||||
* @param: key ,index 下标
|
||||
* @return: value
|
||||
**/
|
||||
public <T> T getcacheListValue(final String key, final Long index) {
|
||||
ListOperations listOperations = redisTemplate.opsForList();
|
||||
|
||||
return (T) listOperations.index(key, index);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 增加String类型中缓存值
|
||||
* @author: LiYuan
|
||||
* @param: key,number
|
||||
* @return: Long 增加后的值
|
||||
**/
|
||||
public Long increment(final String key,final Long number) {
|
||||
ValueOperations valueOperations = redisTemplate.opsForValue();
|
||||
return valueOperations.increment(key,number);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
package com.zhilian.common.resolver.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ClassName ErrorCar
|
||||
* @Description 描述
|
||||
* @Author Can.J
|
||||
* @Date 2024/4/8 12:50
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class ErrorCar {
|
||||
|
||||
private Long id;
|
||||
private String vin;
|
||||
private String code;
|
||||
private int level;
|
||||
|
||||
}
|
|
@ -12,7 +12,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
|
||||
/**
|
||||
* 文件服务
|
||||
*
|
||||
* @author zhilian
|
||||
*/
|
||||
@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<module>zhilian-resolver</module>
|
||||
<module>zhilian-business</module>
|
||||
<module>zhilian-manager</module>
|
||||
<module>zhilian-message</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>zhilian-modules</artifactId>
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
package com.zhilian.business;
|
||||
|
||||
import com.zhilian.business.controller.FenceController;
|
||||
import com.zhilian.business.controller.VehicleController;
|
||||
import com.zhilian.common.security.annotation.EnableCustomConfig;
|
||||
import com.zhilian.common.security.annotation.EnableMyFeignClients;
|
||||
import com.zhilian.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.business
|
||||
* @Description 启动类
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-03-31 10:13
|
||||
* @Description: 业务模块启动类
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class ZhiLianBusinessApplication implements ApplicationRunner {
|
||||
@Autowired
|
||||
private VehicleController vehicleController;
|
||||
|
||||
@Autowired
|
||||
private FenceController fenceController;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ZhiLianBusinessApplication.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
fenceController.fenceRedisData();
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package com.zhilian.business;
|
||||
|
||||
import com.zhilian.common.security.annotation.EnableCustomConfig;
|
||||
import com.zhilian.common.security.annotation.EnableMyFeignClients;
|
||||
import com.zhilian.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.business
|
||||
* @Description 启动类
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-03-31 10:13
|
||||
* @Description: TODO
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class ZhilianBusinessApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ZhilianBusinessApplication.class);
|
||||
}
|
||||
}
|
|
@ -3,10 +3,10 @@ package com.zhilian.business.controller;
|
|||
import com.zhilian.business.domain.BreakLog;
|
||||
import com.zhilian.business.service.BreakLogService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -60,4 +60,23 @@ public class BreakLogController {
|
|||
return success;
|
||||
}
|
||||
|
||||
@PostMapping("logDel/{breakLogId}")
|
||||
public Result logDel(@PathVariable Integer breakLogId){
|
||||
int del = breakLogService.logDel(breakLogId);
|
||||
Result<Integer> success = Result.success(del);
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据故障码和vin判断数据库中是否有数据
|
||||
* @param breakCode
|
||||
* @param breakVin
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/checkIfBreakLogExists/{breakCode}/{breakVin}")
|
||||
public ResponseEntity <Boolean> checkIfBreakLogExists(@PathVariable("breakCode") String breakCode,@PathVariable("breakVin") String breakVin){
|
||||
boolean exists =breakLogService.checkIfBreakLogExists(breakCode,breakVin);
|
||||
return ResponseEntity.ok(exists);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,8 +32,7 @@ import com.zhilian.common.core.web.page.*;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/break")
|
||||
public class BusinessBreakController extends BaseController
|
||||
{
|
||||
public class BusinessBreakController extends BaseController{
|
||||
@Autowired
|
||||
private IBusinessBreakService businessBreakService;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.zhilian.business.controller;
|
||||
|
||||
import com.zhilian.business.domain.Fence;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.core.web.controller.BaseController;
|
||||
import com.zhilian.common.business.domain.Fence;
|
||||
import com.zhilian.business.service.FenceService;
|
||||
import com.zhilian.common.core.web.page.TableDataInfo;
|
||||
import com.zhilian.common.security.utils.SecurityUtils;
|
||||
|
@ -36,6 +36,14 @@ public class FenceController extends BaseController {
|
|||
return getDataTable(result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加所有围栏信息进入redis
|
||||
*/
|
||||
public void fenceRedisData() {
|
||||
fenceService.fenceRedisData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增围栏
|
||||
* @param fence
|
||||
|
@ -45,7 +53,7 @@ public class FenceController extends BaseController {
|
|||
public Result fenceAdd(@RequestBody Fence fence) {
|
||||
fence.setUpdateBy(SecurityUtils.getUsername());
|
||||
fence.setUpdateTime(new Date());
|
||||
return toAjax(fenceService.save(fence));
|
||||
return toAjax(fenceService.saveFence(fence));
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,7 +78,7 @@ public class FenceController extends BaseController {
|
|||
public Result fenceUpdateMap(@RequestBody Fence fence) {
|
||||
fence.setUpdateBy(SecurityUtils.getUsername());
|
||||
fence.setUpdateTime(new Date());
|
||||
return toAjax(fenceService.updateById(fence));
|
||||
return toAjax(fenceService.updateByMap(fence));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,8 +87,8 @@ public class FenceController extends BaseController {
|
|||
* @return
|
||||
*/
|
||||
@PostMapping("/fenceDelete/{fenceId}")
|
||||
public Result fenceDelete(@PathVariable String fenceId) {
|
||||
return toAjax(fenceService.removeById(fenceId));
|
||||
public Result fenceDelete(@PathVariable Long fenceId) {
|
||||
return toAjax(fenceService.removeByFence(fenceId));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package com.zhilian.business.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
import com.zhilian.common.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.domain.Markers;
|
||||
import com.zhilian.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.service.MarkersFenceService;
|
||||
import com.zhilian.business.service.MarkersService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.zhilian.business.controller;
|
||||
|
||||
import com.zhilian.common.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.service.MarkersFenceService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.core.web.controller.BaseController;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.zhilian.business.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.VehicleFence;
|
||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.business.service.MarkersService;
|
||||
import com.zhilian.business.service.VehicleMarkersService;
|
||||
import com.zhilian.business.service.VehicleService;
|
||||
|
@ -46,6 +47,12 @@ public class VehicleController extends BaseController {
|
|||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@GetMapping("/vehicleSelectAllData")
|
||||
public List<VehicleFence> vehicleSelectAllData(){
|
||||
List<VehicleFence> selectSelectAllData = vehicleService.selectSelectAllData();
|
||||
return selectSelectAllData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增车辆
|
||||
* @param vehicle
|
||||
|
@ -76,6 +83,9 @@ public class VehicleController extends BaseController {
|
|||
|
||||
//重新添加中间表数据
|
||||
vehicleMarkersService.insert(vehicle);
|
||||
|
||||
//判断添加完成后的标识与围栏是否绑定事件 如果没有绑定全部删除围栏事件 然后进行给予绑定
|
||||
vehicleService.selectRedisData(vehicle);
|
||||
return toAjax(update);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.zhilian.business.controller;
|
||||
|
||||
import com.zhilian.common.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.business.service.VehicleMarkersService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.core.web.controller.BaseController;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package com.zhilian.business.controller;
|
||||
|
||||
import com.zhilian.common.business.domain.VehicleType;
|
||||
import com.zhilian.business.domain.VehicleType;
|
||||
import com.zhilian.business.service.VehicleTypeService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.core.web.controller.BaseController;
|
||||
|
|
|
@ -25,6 +25,8 @@ public class BreakLog {
|
|||
private String breakTime;
|
||||
/** 开始报警时间 */
|
||||
private String breakDate;
|
||||
/** 是否报警 */
|
||||
/** 故障状态 */
|
||||
private String breakState;
|
||||
/** 逻辑删除 */
|
||||
private Integer breakDel;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.zhilian.business.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@ToString
|
||||
@SuperBuilder
|
||||
public class VehicleFence {
|
||||
private Long vehicleId;
|
||||
private String vehicleVIN;
|
||||
private String fences;
|
||||
|
||||
private List<String> fenceIds;
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.zhilian.business.mapper;
|
|||
|
||||
import com.zhilian.business.domain.BreakLog;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -18,4 +19,14 @@ public interface BreakLogMapper {
|
|||
int logAdd(BreakLog breakLog);
|
||||
|
||||
int updLog(BreakLog breakLog);
|
||||
|
||||
int logDel(Integer breakLogId);
|
||||
|
||||
/**
|
||||
* 根据故障码和vin判断数据库中是否有数据
|
||||
* @param breakCode
|
||||
* @param breakVin
|
||||
* @return
|
||||
*/
|
||||
BreakLog findByBreakCodeAndBreakVin(@Param("breakCode") String breakCode, @Param("breakVin") String breakVin);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import com.zhilian.business.domain.BreakLog;
|
||||
import com.zhilian.business.domain.BusinessBreak;
|
||||
import com.zhilian.business.domain.request.BreakReq;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 故障Mapper接口
|
||||
|
@ -12,6 +13,7 @@ import com.zhilian.business.domain.request.BreakReq;
|
|||
* @author Yy
|
||||
* @date 2024-04-07
|
||||
*/
|
||||
@Mapper
|
||||
public interface BusinessBreakMapper
|
||||
{
|
||||
/**
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.common.business.domain.Fence;
|
||||
import com.zhilian.business.domain.Fence;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.common.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.domain.middle.MarkersFence;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface MarkersFenceMapper extends BaseMapper<MarkersFence> {
|
||||
boolean deleteBatchFenceIds(List<Long> longs);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
import com.zhilian.business.domain.Markers;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.VehicleFence;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
@Component
|
||||
public interface VehicleMapper extends BaseMapper<Vehicle> {
|
||||
|
||||
List<VehicleFence> selectListAll();
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.common.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.zhilian.business.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.common.business.domain.VehicleType;
|
||||
|
||||
import com.zhilian.business.domain.VehicleType;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
|
|
@ -16,4 +16,14 @@ public interface BreakLogService {
|
|||
int logAdd(BreakLog breakLog);
|
||||
|
||||
int updLog(BreakLog breakLog);
|
||||
|
||||
int logDel(Integer breakLogId);
|
||||
|
||||
/**
|
||||
* 根据故障码和vin判断数据库中是否有数据
|
||||
* @param breakCode
|
||||
* @param breakVin
|
||||
* @return
|
||||
*/
|
||||
boolean checkIfBreakLogExists(String breakCode, String breakVin);
|
||||
}
|
||||
|
|
|
@ -1,10 +1,18 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.common.business.domain.Fence;
|
||||
import com.zhilian.business.domain.Fence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface FenceService extends IService<Fence> {
|
||||
List<Fence> fenceList(Fence fence);
|
||||
|
||||
void fenceRedisData();
|
||||
|
||||
boolean saveFence(Fence fence);
|
||||
|
||||
boolean updateByMap(Fence fence);
|
||||
|
||||
boolean removeByFence(Long fenceId);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
import com.zhilian.common.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.domain.Markers;
|
||||
import com.zhilian.business.domain.middle.MarkersFence;
|
||||
|
||||
public interface MarkersFenceService extends IService<MarkersFence> {
|
||||
boolean insert(Markers markers);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
import com.zhilian.business.domain.Markers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.domain.middle.VehicleMarkers;
|
||||
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.VehicleFence;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -12,4 +13,8 @@ public interface VehicleService extends IService<Vehicle> {
|
|||
Vehicle getVehicleByVIN(String vehicleVIN);
|
||||
|
||||
boolean updateState(Vehicle vehicle);
|
||||
|
||||
void selectRedisData(Vehicle vehicle);
|
||||
|
||||
List<VehicleFence> selectSelectAllData();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.zhilian.business.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.common.business.domain.VehicleType;
|
||||
import com.zhilian.business.domain.VehicleType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -74,4 +74,23 @@ public class BreakLogServiceImpl implements BreakLogService {
|
|||
public int updLog(BreakLog breakLog) {
|
||||
return breakLogMapper.updLog(breakLog);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int logDel(Integer breakLogId) {
|
||||
return breakLogMapper.logDel(breakLogId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据故障码和vin判断数据库中是否有数据
|
||||
* @param breakCode
|
||||
* @param breakVin
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean checkIfBreakLogExists(String breakCode, String breakVin) {
|
||||
BreakLog breakLog =breakLogMapper.findByBreakCodeAndBreakVin(breakCode,breakVin);
|
||||
return breakLog!=null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,17 +1,34 @@
|
|||
package com.zhilian.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.segments.MergeSegments;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.common.business.domain.Fence;
|
||||
import com.zhilian.business.domain.Fence;
|
||||
import com.zhilian.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.mapper.FenceMapper;
|
||||
import com.zhilian.business.mapper.MarkersFenceMapper;
|
||||
import com.zhilian.business.mapper.MarkersMapper;
|
||||
import com.zhilian.business.service.FenceService;
|
||||
import com.zhilian.common.core.utils.StringUtils;
|
||||
import com.zhilian.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements FenceService {
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private MarkersFenceMapper markersFenceMapper;
|
||||
|
||||
private static final String FENCE_INFO_KEY = "fence_info:";
|
||||
//电子围栏信息查询
|
||||
@Override
|
||||
public List<Fence> fenceList(Fence fence) {
|
||||
if (fence.getFenceName() == null && fence.getFenceTypeId() == null && fence.getFenceState() == null) {
|
||||
|
@ -34,7 +51,64 @@ public class FenceServiceImpl extends ServiceImpl<FenceMapper, Fence> implements
|
|||
if (fence.getFenceState() != null) {
|
||||
queryWrapper.eq(Fence::getFenceState, fence.getFenceState());
|
||||
}
|
||||
|
||||
if(!redisService.hasKey(FENCE_INFO_KEY)){
|
||||
fenceRedisData();
|
||||
}
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
//缓存电子围栏信息
|
||||
@Override
|
||||
public void fenceRedisData() {
|
||||
List<Fence> list = this.list();
|
||||
for (Fence fence : list) {
|
||||
if(!redisService.hasKey(FENCE_INFO_KEY+fence.getFenceId())){
|
||||
redisService.setCacheSet(FENCE_INFO_KEY+fence.getFenceId(),fence.getFenceMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
//删除电子围栏全部数据
|
||||
private void fenceRedisDelete(){
|
||||
List<Fence> list = this.list();
|
||||
for (Fence fence : list) {
|
||||
redisService.deleteObject(FENCE_INFO_KEY+fence.getFenceId());
|
||||
}
|
||||
}
|
||||
//添加电子围栏信息
|
||||
@Override
|
||||
public boolean saveFence(Fence fence) {
|
||||
boolean save = this.save(fence);
|
||||
return save;
|
||||
}
|
||||
//绑定经纬度地图
|
||||
@Override
|
||||
public boolean updateByMap(Fence fence) {
|
||||
boolean updateByMap = this.updateById(fence);
|
||||
if(redisService.hasKey(FENCE_INFO_KEY+fence.getFenceId())){
|
||||
redisService.deleteObject(FENCE_INFO_KEY+fence.getFenceId());
|
||||
}
|
||||
redisService.setCacheSet(FENCE_INFO_KEY+fence.getFenceId(),fence.getFenceMessage());
|
||||
return updateByMap;
|
||||
}
|
||||
|
||||
|
||||
//删除电子围栏
|
||||
@Override
|
||||
public boolean removeByFence(Long fenceId) {
|
||||
boolean remove = this.removeById(fenceId);
|
||||
if(redisService.hasKey(FENCE_INFO_KEY+fenceId)){
|
||||
redisService.deleteObject(FENCE_INFO_KEY+fenceId);
|
||||
}
|
||||
QueryWrapper<MarkersFence> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("fence_id", fenceId);
|
||||
List<MarkersFence> markersFences = markersFenceMapper.selectList(queryWrapper);
|
||||
List<Long> longs = new ArrayList<>();
|
||||
markersFences.stream().forEach(markersFence -> {
|
||||
longs.add(markersFence.getMarkerId());
|
||||
});
|
||||
markersFenceMapper.deleteBatchFenceIds(longs);
|
||||
return remove;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,13 +2,15 @@ package com.zhilian.business.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
import com.zhilian.common.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.domain.Markers;
|
||||
import com.zhilian.business.domain.middle.MarkersFence;
|
||||
import com.zhilian.business.service.FenceService;
|
||||
import com.zhilian.business.mapper.MarkersFenceMapper;
|
||||
import com.zhilian.business.service.MarkersFenceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -19,20 +21,19 @@ public class MarkersFenceServiceImpl extends ServiceImpl<MarkersFenceMapper, Mar
|
|||
|
||||
@Override
|
||||
public boolean insert(Markers markers) {
|
||||
ArrayList<MarkersFence> markersFences = new ArrayList<>();
|
||||
markers.getFenceIds().forEach(fenceId -> {
|
||||
MarkersFence markersFence = new MarkersFence();
|
||||
markersFence.setMarkerId(markers.getMarkersId());
|
||||
markersFence.setFenceId(fenceId);
|
||||
markersFenceMapper.insert(markersFence);
|
||||
markersFences.add(markersFence);
|
||||
});
|
||||
return true;
|
||||
return this.saveBatch(markersFences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllFence(Markers markers) {
|
||||
List<MarkersFence> list = this.list(new LambdaQueryWrapper<MarkersFence>().eq(MarkersFence::getMarkerId, markers.getMarkersId()));
|
||||
list.forEach(item -> {
|
||||
this.removeById(item.getMarkerId());
|
||||
});
|
||||
this.removeBatchByIds(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.zhilian.business.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.common.business.domain.Markers;
|
||||
import com.zhilian.business.domain.Markers;
|
||||
import com.zhilian.business.mapper.MarkersMapper;
|
||||
import com.zhilian.business.service.MarkersService;
|
||||
import com.zhilian.common.core.utils.StringUtils;
|
||||
|
|
|
@ -2,35 +2,73 @@ package com.zhilian.business.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.common.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.business.mapper.VehicleMarkersMapper;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.middle.VehicleMarkers;
|
||||
import com.zhilian.business.mapper.*;
|
||||
import com.zhilian.business.service.VehicleMarkersService;
|
||||
import com.zhilian.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class VehicleMarkersServiceImpl extends ServiceImpl<VehicleMarkersMapper, VehicleMarkers> implements VehicleMarkersService {
|
||||
// @Autowired
|
||||
// private VehicleMapper vehicleMapper;
|
||||
//
|
||||
// @Autowired
|
||||
// private VehicleMarkersMapper vehicleMarkersMapper;
|
||||
//
|
||||
// @Autowired
|
||||
// private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private MarkersMapper markersMapper;
|
||||
|
||||
@Autowired
|
||||
private MarkersFenceMapper markersFenceMapper;
|
||||
|
||||
@Autowired
|
||||
private FenceMapper fenceMapper;
|
||||
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
@Override
|
||||
public boolean insert(Vehicle vehicle) {
|
||||
ArrayList<VehicleMarkers> list = new ArrayList<>();
|
||||
vehicle.getMarkersIds().forEach(markerId -> {
|
||||
VehicleMarkers vehicleMarkers = new VehicleMarkers();
|
||||
vehicleMarkers.setVehicleId(vehicle.getVehicleId());
|
||||
vehicleMarkers.setMarkersId(markerId);
|
||||
this.save(vehicleMarkers);
|
||||
list.add(vehicleMarkers);
|
||||
});
|
||||
return true;
|
||||
return this.saveBatch(list);
|
||||
|
||||
// String vehicleVIN = vehicle.getVehicleVIN();
|
||||
// //标识
|
||||
// List<Markers> markers = markersMapper.selectBatchIds(vehicle.getMarkersIds());
|
||||
// //中间表
|
||||
// List<MarkersFence> markersFences = markersFenceMapper.selectBatchIds(markers);
|
||||
// //围栏
|
||||
// List<Long> fenceIds = markersFences.stream().map(MarkersFence::getFenceId).collect(Collectors.toList());
|
||||
// List<Fence> fences = fenceMapper.selectBatchIds(fenceIds);
|
||||
//
|
||||
// System.out.println("**********************"+fences);
|
||||
// List<MarkersFence> markersFences = markersFenceMapper.selectList(new LambdaQueryWrapper<MarkersFence>().in(MarkersFence::getMarkersId, vehicle.getMarkersIds()));
|
||||
// List<Fence> fences = fenceMapper.selectBatchIds(markersFences.stream().map(MarkersFence::getFenceId).distinct().toArray(Long[]::new));
|
||||
// markersFences.forEach(markersFence -> {
|
||||
// markersFence.setFence(fences.stream().filter(fence -> fence.getFenceId().equals(markersFence.getFenceId())).findFirst().get());
|
||||
// });
|
||||
//
|
||||
// redisService.set(vehicle.getVehicleId(), markersFences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeAllVehicle(Vehicle vehicle) {
|
||||
List<VehicleMarkers> list = this.list(new LambdaQueryWrapper<VehicleMarkers>().eq(VehicleMarkers::getVehicleId, vehicle.getVehicleId()));
|
||||
list.forEach(item -> {
|
||||
this.removeById(item.getVehicleId());
|
||||
});
|
||||
this.removeByIds(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,20 +2,30 @@ package com.zhilian.business.service.impl;
|
|||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.common.business.domain.Vehicle;
|
||||
import com.zhilian.business.mapper.VehicleMapper;
|
||||
import com.zhilian.business.domain.Vehicle;
|
||||
import com.zhilian.business.domain.VehicleFence;
|
||||
import com.zhilian.business.mapper.*;
|
||||
import com.zhilian.business.service.VehicleService;
|
||||
import com.zhilian.common.core.utils.StringUtils;
|
||||
import com.zhilian.common.redis.service.RedisService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Log4j2
|
||||
public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> implements VehicleService {
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
private final String VEHICLE_PEOPLE_KEY = "vehicle_fence:";
|
||||
@Override
|
||||
public List<Vehicle> selectVehicleList(Vehicle vehicle) {
|
||||
LambdaQueryWrapper<Vehicle> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
@ -74,4 +84,26 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectRedisData(Vehicle vehicle) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VehicleFence> selectSelectAllData() {
|
||||
List<VehicleFence> vehicleMarkersFence = vehicleMapper.selectListAll();
|
||||
for (VehicleFence vehicleFence : vehicleMarkersFence) {
|
||||
String[] fenceIdsArray = vehicleFence.getFences().split(",");
|
||||
ArrayList<String> fenceIdsArrayList = new ArrayList<>(Arrays.asList( fenceIdsArray));
|
||||
vehicleFence.setFenceIds(fenceIdsArrayList);
|
||||
}
|
||||
for (VehicleFence vehicleFence : vehicleMarkersFence) {
|
||||
redisService.setCacheList(VEHICLE_PEOPLE_KEY + vehicleFence.getVehicleVIN(), vehicleFence.getFenceIds());
|
||||
}
|
||||
|
||||
log.info(vehicleMarkersFence);
|
||||
return vehicleMarkersFence;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.zhilian.business.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.common.business.domain.VehicleType;
|
||||
import com.zhilian.business.domain.VehicleType;
|
||||
import com.zhilian.business.mapper.VehicleTypeMapper;
|
||||
import com.zhilian.business.service.VehicleTypeService;
|
||||
import com.zhilian.common.redis.service.RedisService;
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
||||
|
||||
|
|
|
@ -3,21 +3,45 @@
|
|||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhilian.business.mapper.BreakLogMapper">
|
||||
|
||||
<!-- 查询-->
|
||||
<resultMap type="com.zhilian.business.domain.BreakLog" id="BaseResultMap">
|
||||
<result property="breakLogId" column="break_log_id"/>
|
||||
<result property="breakCode" column="break_code"/>
|
||||
<result property="breakVin" column="break_vin"/>
|
||||
<result property="breakType" column="break_time"/>
|
||||
<result property="breakTime" column="break_type"/>
|
||||
<result property="breakDate" column="break_date"/>
|
||||
<result property="breakState" column="break_state"/>
|
||||
<result property="breakDel" column="break_del"/>
|
||||
</resultMap>
|
||||
|
||||
<insert id="logAdd">
|
||||
|
||||
INSERT INTO `zhilian-business`.`business_break_log`
|
||||
( `break_code`, `break_vin`, `break_time`, `break_type`, `break_date`, `break_state`)
|
||||
( `break_code`, `break_vin`, `break_time`, `break_type`, `break_date`, `break_state`,`break_del`)
|
||||
VALUES
|
||||
(#{breakCode}, #{breakVin}, NOW(), #{breakType}, NOW(), #{breakState});
|
||||
(#{breakCode}, #{breakVin},#{breakTime}, #{breakType},DATE_ADD(NOW(),INTERVAL 8 HOUR), #{breakState},0);
|
||||
</insert>
|
||||
<update id="updLog">
|
||||
UPDATE `zhilian-business`.`business_break_log`
|
||||
SET `break_code` = #{breakCode}, `break_vin` = #{breakVin}, `break_time` = NOW(), `break_type` = #{breakType}, `break_date` = NOW(), `break_state` = #{breakState}
|
||||
SET `break_code` = #{breakCode}, `break_vin` = #{breakVin}, `break_time` = NOW(), `break_type` = #{breakType}, `break_date` = NOW(), `break_state` = #{breakState}, `break_del` = #{breakDel}
|
||||
WHERE `break_log_id` = #{breakLogId};
|
||||
|
||||
</update>
|
||||
<update id="logDel">
|
||||
UPDATE `zhilian-business`.`business_break_log`
|
||||
SET break_del = 1
|
||||
WHERE break_log_id = #{breakLogId}
|
||||
</update>
|
||||
|
||||
<select id="breakLog" resultType="com.zhilian.business.domain.BreakLog">
|
||||
select * from business_break_log
|
||||
select * from business_break_log where break_del = 0
|
||||
</select>
|
||||
|
||||
<!-- 根据故障码和vin判断数据库中是否有数据-->
|
||||
<select id="findByBreakCodeAndBreakVin" resultMap="BaseResultMap">
|
||||
select * from business_break_log where break_code =#{breakCode} and break_vin =#{breakVin} and break_del =0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhilian.business.mapper.FenceMapper">
|
||||
<mapper namespace="com.zhilian.business.mapper.MarkersFenceMapper">
|
||||
|
||||
<delete id="deleteBatchFenceIds">
|
||||
|
||||
</delete>
|
||||
</mapper>
|
|
@ -4,4 +4,21 @@
|
|||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhilian.business.mapper.VehicleMapper">
|
||||
|
||||
|
||||
<select id="selectListAll" resultType="com.zhilian.business.domain.VehicleFence">
|
||||
SELECT
|
||||
BV.vehicle_id,
|
||||
BV.vehicle_vin,
|
||||
GROUP_CONCAT(BF.fence_id) AS fenceIds
|
||||
FROM
|
||||
business_vehicle AS BV
|
||||
JOIN
|
||||
business_vehicle_markers AS BVM ON BV.vehicle_id = BVM.vehicle_id
|
||||
JOIN
|
||||
business_markers_fence AS BMF ON BVM.markers_id = BMF.markers_id
|
||||
JOIN
|
||||
business_fence AS BF ON BMF.fence_id = BF.fence_id
|
||||
GROUP BY
|
||||
BV.vehicle_id, BV.vehicle_vin
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
<?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.zhilian.business.mapper.VehicleMarkersMapper">
|
||||
|
||||
</mapper>
|
|
@ -8,7 +8,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
* @BelongsPackage: com.zhilian.manager
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-03-31 10:17
|
||||
* @Description: TODO
|
||||
* @Description: 管理模块启动类
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@SpringBootApplication
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?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.zhilian</groupId>
|
||||
<artifactId>zhilian-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>zhilian-message</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.zhilian</groupId>
|
||||
<artifactId>zhilian-common-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -98,12 +98,18 @@
|
|||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 业务系统远程调用-->
|
||||
<dependency>
|
||||
<groupId>com.zhilian</groupId>
|
||||
<artifactId>zhilian-common-business</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里云Ecs服务依赖(openAPI)-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ecs20140526</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.zhilian.online.Timer;
|
||||
|
||||
import com.zhilian.online.uitls.AliyunOpenAPIUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.Timer
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-17 21:53
|
||||
* @Description: 收集节点监视者
|
||||
* @Option: 监视节点负载量来决定是否需要扩容
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class LoadObserver {
|
||||
|
||||
/**
|
||||
* 阿里云api接口类
|
||||
*/
|
||||
@Autowired
|
||||
private AliyunOpenAPIUtils aliyunOpenAPIUtils;
|
||||
|
||||
/**
|
||||
* 监视负载量是否需要扩容
|
||||
*/
|
||||
@Scheduled(cron = "0/10 * * * * ?")
|
||||
public void addInstance(){
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 监视负载量是否需要缩容
|
||||
*/
|
||||
@Scheduled(cron = "0/10 * * * * ?")
|
||||
public void ReduceInstance(){
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -3,8 +3,19 @@ package com.zhilian.online;
|
|||
import com.zhilian.common.security.annotation.EnableCustomConfig;
|
||||
import com.zhilian.common.security.annotation.EnableMyFeignClients;
|
||||
import com.zhilian.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import com.zhilian.online.controller.OnlineLoadCenterController;
|
||||
import com.zhilian.online.domain.EcsInstance;
|
||||
import com.zhilian.online.domain.req.EcsCreateReq;
|
||||
import com.zhilian.online.uitls.AliyunOpenAPIUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import com.aliyun.ecs20140526.models.RunInstancesRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version:
|
||||
|
@ -16,11 +27,45 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class ZhiLianOnlineApplication{
|
||||
@Slf4j
|
||||
public class ZhiLianOnlineApplication implements ApplicationRunner {
|
||||
@Autowired
|
||||
private AliyunOpenAPIUtils aliyunOpenAPIUtils;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ZhiLianOnlineApplication.class,args);
|
||||
SpringApplication.run(ZhiLianOnlineApplication.class, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
log.info("项目启动,调用创建实例方法");
|
||||
RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk = new RunInstancesRequest.RunInstancesRequestSystemDisk();
|
||||
systemDisk = systemDisk.setSize("20").setCategory("cloud_efficiency");
|
||||
EcsCreateReq ecs = EcsCreateReq.builder()
|
||||
.regionId("cn-zhangjiakou")
|
||||
.imageId("m-8vbfx0e48cekro0f13bx")
|
||||
.instanceType("ecs.t6-c1m1.large")
|
||||
.securityGroupId("sg-8vb49jd1c1lsa3akwo02")
|
||||
.vSwitchId("vsw-8vb0krtyfdmb27nhcmzc2")
|
||||
.instanceName("gather-node")
|
||||
.internetMaxBandwidthIn(80)
|
||||
.internetMaxBandwidthOut(10)
|
||||
.uniqueSuffix(true)
|
||||
.password("142730.Ly")
|
||||
.zoneId("cn-zhangjiakou-c")
|
||||
.internetChargeType("PayByTraffic")
|
||||
.systemDiskSize("20")
|
||||
.systemDickCategory("cloud_efficiency")
|
||||
.amount(1)
|
||||
.minAmount(1)
|
||||
.periodUnit("Week")
|
||||
.period(1)
|
||||
.instanceChargeType("PostPaid")
|
||||
// .privateIpAddress("10.10.27.1")
|
||||
.build();
|
||||
List<String> instance = aliyunOpenAPIUtils.createInstance(ecs);
|
||||
|
||||
|
||||
List<EcsInstance> ecsInstances = aliyunOpenAPIUtils.queryEcsInstances(instance);
|
||||
log.info("创建的实例信息为{}" , ecsInstances);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package com.zhilian.online.config;
|
||||
|
||||
import com.aliyun.ecs20140526.Client;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.stereotype.Component;
|
||||
import com.aliyun.ecs20140526.Client;
|
||||
import com.aliyun.teaopenapi.models.Config;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.config
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-12 14:43
|
||||
* @Description: 阿里云Ecs服务账号配置
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Configuration
|
||||
@ConfigurationProperties("aliyun.ecs")
|
||||
@Data
|
||||
@Slf4j
|
||||
public class AliyunEcsConfig {
|
||||
|
||||
/**
|
||||
* 令牌账号
|
||||
*/
|
||||
private String accessKeyId;
|
||||
|
||||
/**
|
||||
* 令牌密码
|
||||
*/
|
||||
private String accessKeySecret;
|
||||
|
||||
/**
|
||||
* 阿里云端点地址
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
* 地域
|
||||
*/
|
||||
private String regionId;
|
||||
|
||||
/**
|
||||
* 使用AK&SK初始化账号Client
|
||||
* @return Client
|
||||
* @throws Exception
|
||||
*/
|
||||
@Bean()
|
||||
public Client createClient() throws Exception {
|
||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
||||
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
||||
Config config = new Config()
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||
.setAccessKeyId(accessKeyId)
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
.setAccessKeySecret(accessKeySecret)
|
||||
.setRegionId(regionId);
|
||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||
config.endpoint = endpoint;
|
||||
Client aliyunClient = new Client(config);
|
||||
return aliyunClient;
|
||||
}
|
||||
|
||||
}
|
|
@ -100,7 +100,7 @@ public class MqttxConfig {
|
|||
|
||||
|
||||
|
||||
@PostConstruct
|
||||
// @PostConstruct
|
||||
public void initMqtt() {
|
||||
log.info("mqttx连接中......");
|
||||
|
||||
|
|
|
@ -63,6 +63,36 @@ public class RabbitConfig {
|
|||
*/
|
||||
public static final String DEAD_ROUTING_KEY = "dead_routing";
|
||||
|
||||
/**
|
||||
* 延迟队列名称
|
||||
*/
|
||||
public static final String DELAY_QUEUE_FOR_CAR = "delay_queue_for_car";
|
||||
|
||||
/**
|
||||
* 延迟交换机名称
|
||||
*/
|
||||
public static final String DELAY_EXCHANGE_FOR_CAR = "delay_exchange_for_car";
|
||||
|
||||
/**
|
||||
* 延迟路由键
|
||||
*/
|
||||
public static final String DELAY_ROUTING_FOR_CAR = "delay_routing_for_car";
|
||||
|
||||
/**
|
||||
* 死信队列名称
|
||||
*/
|
||||
public static final String DEAD_QUEUE_FOR_CAR = "dead_queue_for_car";
|
||||
|
||||
/**
|
||||
* 死信交换机名称
|
||||
*/
|
||||
public static final String DEAD_EXCHANGE_FOR_CAR = "dead_exchange_for_car";
|
||||
|
||||
/**
|
||||
* 死信路由键
|
||||
*/
|
||||
public static final String DEAD_ROUTING_FOR_CAR = "dead_routing_for_car";
|
||||
|
||||
/**
|
||||
* 注入死信队列实例
|
||||
*
|
||||
|
@ -153,11 +183,89 @@ public class RabbitConfig {
|
|||
// }
|
||||
|
||||
|
||||
|
||||
// @Bean
|
||||
// public MessageConverter jsonMessageConverter(){
|
||||
// return new Jackson2JsonMessageConverter();
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 注入死信队列实例
|
||||
*
|
||||
* @return Queue
|
||||
*/
|
||||
@Bean
|
||||
Queue deadQueueForCar() {
|
||||
log.info("死信队列ForCar创建成功");
|
||||
return new Queue(DEAD_QUEUE_FOR_CAR, true, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注入死信交换机实例
|
||||
*
|
||||
* @return DirectExchange
|
||||
*/
|
||||
@Bean
|
||||
DirectExchange deadExchangeForCar() {
|
||||
log.info("死信交换机ForCar创建成功");
|
||||
return new DirectExchange(DEAD_EXCHANGE_FOR_CAR, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将死信队列与死信交换机绑定
|
||||
*
|
||||
* @return Binding
|
||||
*/
|
||||
@Bean
|
||||
Binding deadBindingForCar() {
|
||||
log.info("死信通道ForCar建立成功");
|
||||
return BindingBuilder.bind(deadQueue())
|
||||
.to(deadExchange())
|
||||
.with(DEAD_ROUTING_FOR_CAR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 注入延迟队列实例
|
||||
*
|
||||
* @return Queue
|
||||
*/
|
||||
@Bean
|
||||
Queue delayQueueForCar() {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
//设置消息过期时间为30秒
|
||||
map.put("x-message-ttl", 1000 * 30);
|
||||
//设置消息过期后存储的死信交换机
|
||||
map.put("x-dead-letter-exchange", DEAD_EXCHANGE_FOR_CAR);
|
||||
//设置死信路由键
|
||||
map.put("x-dead-letter-routing-key", DEAD_ROUTING_FOR_CAR);
|
||||
log.info("延迟队列ForCar创建成功");
|
||||
return new Queue(DELAY_QUEUE_FOR_CAR, true, false, false, map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注入延迟交换机实例
|
||||
*
|
||||
* @return DirectExchange
|
||||
*/
|
||||
@Bean
|
||||
DirectExchange delayExchangeForCar() {
|
||||
log.info("延迟交换机ForCar创建成功");
|
||||
return new DirectExchange(DELAY_EXCHANGE_FOR_CAR, true, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将延迟队列与延迟交换机绑定
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
Binding delayBindingForCar() {
|
||||
log.info("延迟通道ForCar创建成功");
|
||||
return BindingBuilder.bind(deadQueue())
|
||||
.to(delayExchange())
|
||||
.with(DELAY_ROUTING_FOR_CAR);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.zhilian.online.constans;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
|
@ -17,7 +16,7 @@ public class OnlineConstants {
|
|||
/**
|
||||
* 申请注册令牌缓存前缀
|
||||
*/
|
||||
public static final String ONLINE_TOKEN_PREFIX = "online_token:";
|
||||
public static final String NODE_TOKEN_PREFIX = "node_token:";
|
||||
|
||||
/**
|
||||
* 申请令牌过期时间
|
||||
|
@ -27,7 +26,26 @@ public class OnlineConstants {
|
|||
/**
|
||||
* 节点负载前缀
|
||||
*/
|
||||
public static final String NODE_LOAD_PREFIX = "node_load";
|
||||
public static final String GATHER_LOAD_PREFIX = "gather:load:";
|
||||
/**
|
||||
* 在线节点前缀
|
||||
*/
|
||||
public static final String ONLINE_GATHER_PREFIX = "online_vehicle:";
|
||||
|
||||
/**
|
||||
* http请求前缀
|
||||
*/
|
||||
public static final String HTTP_PREFIX = "http://";
|
||||
|
||||
/**
|
||||
* https请求前缀
|
||||
*/
|
||||
public static final String HTTPS_PREFIX = "https://";
|
||||
|
||||
/**
|
||||
* fluxMQ请求地址
|
||||
*/
|
||||
public static final String FLUXMQ_INFO_URL = ":8080/public/cluster";
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
package com.zhilian.online.consumer;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.zhilian.online.config.RabbitConfig;
|
||||
import com.zhilian.online.domain.req.GatherRegReq;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.zhilian.common.core.constant.Constants;
|
||||
import com.zhilian.common.redis.service.RedisService;
|
||||
import com.zhilian.online.constans.OnlineConstants;
|
||||
import com.zhilian.online.domain.model.GatewayNodeInfo;
|
||||
import com.zhilian.online.load.cache.GatewayNodeInfoCache;
|
||||
import com.zhilian.online.load.cache.GatewayNodeWeightCache;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.consumer
|
||||
|
@ -19,21 +27,79 @@ import org.springframework.stereotype.Component;
|
|||
@Slf4j
|
||||
public class DeadQueueConsumer {
|
||||
|
||||
/**
|
||||
* redis服务
|
||||
*/
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Autowired
|
||||
private GatewayNodeInfoCache gatewayNodeInfoCache;
|
||||
|
||||
@Autowired
|
||||
private GatewayNodeWeightCache gatewayNodeWeightCache;
|
||||
|
||||
|
||||
/**
|
||||
* 消费死信队列中的消息,确保车辆上线成功
|
||||
* 向节点地址的fluxMQ发送http请求,通过响应码来确定节点是否成功上线
|
||||
*/
|
||||
@RabbitListener(queues = RabbitConfig.DEAD_QUEUE_NAME)
|
||||
public void SecureOnline(String gatherRegReqMsg) {
|
||||
GatherRegReq gatherRegReq = JSON.parseObject(gatherRegReqMsg, GatherRegReq.class);
|
||||
log.info("开始检查节点{}的上线状态......",
|
||||
gatherRegReq.getClientId());
|
||||
// @RabbitListener(queues = RabbitConfig.DEAD_QUEUE_NAME)
|
||||
public void SecureOnline(String gatherMsg) {
|
||||
log.info("开始检查节点{}的上线状态......", gatherMsg);
|
||||
GatewayNodeInfo gatewayNodeInfo = JSONObject.parseObject(gatherMsg, GatewayNodeInfo.class);
|
||||
|
||||
String ipAddress = "";
|
||||
HttpURLConnection connection = null;
|
||||
try {
|
||||
ipAddress = OnlineConstants.HTTP_PREFIX + ipAddress + OnlineConstants.FLUXMQ_INFO_URL;
|
||||
URL url = new URL(ipAddress);
|
||||
connection = (HttpURLConnection)url.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
|
||||
log.info("节点上线成功");
|
||||
|
||||
log.info("节点上线失败");
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (Constants.SUCCESS == responseCode){
|
||||
log.info("节点上线成功");
|
||||
}
|
||||
if (Constants.FAIL == responseCode){
|
||||
log.error("节点{}上线失败",gatherMsg);
|
||||
//删除节点数据
|
||||
gatewayNodeInfoCache.remove(gatewayNodeInfo.getNodeId());
|
||||
//上线失败需要将该节点的负载均衡缓存删除
|
||||
gatewayNodeWeightCache.remove(gatewayNodeInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("节点上线失败{}",e.getMessage());
|
||||
e.printStackTrace();
|
||||
}finally {
|
||||
if (null != connection){
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 确定车辆上线成功
|
||||
// * @param vin
|
||||
// */
|
||||
// @RabbitListener(queues = RabbitConfig.DEAD_QUEUE_FOR_CAR)
|
||||
// public void checkedConnectionOfVehicle(String vin){
|
||||
// Set<Object> cacheSet = redisService.getCacheSet(OnlineConstants.ONLINE_VEHICLE);
|
||||
// List<String> list= cacheSet.stream().map(item -> {
|
||||
// return String.valueOf(item);
|
||||
// }).collect(Collectors.toList());
|
||||
// if (list.contains(vin)){
|
||||
// log.info("{}车辆上线成功",vin);
|
||||
// }else {
|
||||
// log.error("{}车辆上线失败",vin);
|
||||
//
|
||||
//
|
||||
// String clientId = (String) redisService.getCacheObject(OnlineConstants.ONLINE_VEHICLE + vin);
|
||||
//
|
||||
// redisService.deleteObject(OnlineConstants.ONLINE_VEHICLE+vin);
|
||||
// redisService.getCacheZsetMin(OnlineConstants.GATHER_LOAD_CONTROL);
|
||||
// redisService.incrementScore(OnlineConstants.GATHER_LOAD_CONTROL + clientId ,gather,-1.0);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ import java.util.function.Consumer;
|
|||
@Slf4j
|
||||
public class KafkaConsumer {
|
||||
|
||||
@KafkaListener(topics = "test-topic")
|
||||
public void handlerMsg(ConsumerRecord<Object,Object> record){
|
||||
log.info("消费者消费消息信息为:{}", JSON.toJSONString(record));
|
||||
}
|
||||
// @KafkaListener(topics = "test-topic")
|
||||
// public void handlerMsg(ConsumerRecord<Object,Object> record){
|
||||
// log.info("消费者消费消息信息为:{}", JSON.toJSONString(record));
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
package com.zhilian.online.controller;
|
||||
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
|
||||
import com.zhilian.online.service.OnlineGatherService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @version:
|
||||
* @Author: LiYuan
|
||||
* @description: 车辆收集节点控制层
|
||||
* @date: 2024/3/29 20:46
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/gather")
|
||||
public class OnlineGatherController {
|
||||
|
||||
/**
|
||||
* 车辆收集节点
|
||||
*/
|
||||
@Autowired
|
||||
private OnlineGatherService onlineGatherService;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,18 +1,16 @@
|
|||
package com.zhilian.online.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.common.core.utils.ip.IpUtils;
|
||||
import com.zhilian.common.core.web.controller.BaseController;
|
||||
|
||||
import com.zhilian.online.domain.Gather;
|
||||
import com.zhilian.online.domain.ApifoxModel;
|
||||
import com.zhilian.online.service.OnlineLoadCenterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
|
@ -41,15 +39,15 @@ public class OnlineLoadCenterController extends BaseController {
|
|||
|
||||
|
||||
/**
|
||||
* @description: 节点申请注解令牌接口,仅限内网访问
|
||||
* @description: 节点申请注解令牌接口, 仅限内网访问
|
||||
* @author: LiYuan
|
||||
* @param: vehicle
|
||||
* @return: Result<OnlineAccount>
|
||||
**/
|
||||
@GetMapping("/applyForReg")
|
||||
public Result<String> applyForReg(){
|
||||
log.info("申请注册令牌");
|
||||
return onlineLoadCenterService.applyForReg();
|
||||
public Result<String> applyForReg(String clusterId) {
|
||||
log.info("节点{}申请注册令牌",clusterId);
|
||||
return onlineLoadCenterService.applyForReg(clusterId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,21 +58,36 @@ public class OnlineLoadCenterController extends BaseController {
|
|||
* @return: Result
|
||||
**/
|
||||
@PostMapping("/regGather")
|
||||
public Result regGather(@Validated Gather gather){
|
||||
String ipAddr = IpUtils.getIpAddr(request);
|
||||
gather.setIpAddress(ipAddr);
|
||||
log.info("节点{}正在上线",gather);
|
||||
return onlineLoadCenterService.regGather(gather);
|
||||
public Result regGather(@Validated @RequestBody ApifoxModel apifoxModel) {
|
||||
log.info("节点{}正在上线", JSON.toJSONString(apifoxModel));
|
||||
return onlineLoadCenterService.regGather(apifoxModel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 车辆上线至收集节点
|
||||
* @return null
|
||||
* 车辆申请上线收集节点
|
||||
*
|
||||
* @return gather
|
||||
* @author: LiYuan
|
||||
* @param: vin
|
||||
* @return: Result
|
||||
*/
|
||||
public Result getConnectionOption(){
|
||||
@GetMapping("/applyForConnectToGather")
|
||||
public Result applyForConnectToGather(@RequestParam("vin") String vin) {
|
||||
onlineLoadCenterService.applyForConnectToGather(vin);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
return null;
|
||||
/**
|
||||
* @description:车辆下线接口
|
||||
* @author: LiYuan
|
||||
* @param: vin
|
||||
* @return: Result
|
||||
**/
|
||||
@GetMapping("/applyForDisconnectToGather")
|
||||
public Result applyForDisconnectToGather(@RequestParam("vin") String vin) {
|
||||
onlineLoadCenterService.applyForDisconnectToGather(vin);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
package com.zhilian.online.controller;/**
|
||||
* @version:
|
||||
* @Author: LiYuan
|
||||
* @description:
|
||||
* @date: 2024/3/30 11:18
|
||||
*/
|
||||
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.online.domain.model.MqttServerModel;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.controller
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-03-30 11:18
|
||||
* @Description: 新增车辆上线验证控制器
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/verify")
|
||||
public class OnlineVerifyController {
|
||||
|
||||
/**
|
||||
* 读取配置文件中的mqtt服务地址
|
||||
*/
|
||||
@Value("${mqtt.server.broker}")
|
||||
private String broker;
|
||||
|
||||
/**
|
||||
* 读取配置文件中的订阅主题
|
||||
*/
|
||||
@Value("${mqtt.server.topic}")
|
||||
private String topic;
|
||||
|
||||
@PostMapping("/vehicleConnection")
|
||||
public Result<MqttServerModel> vehicleConnection() {
|
||||
return Result.success(
|
||||
MqttServerModel.builder()
|
||||
.broker(broker)
|
||||
.topic(topic)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.zhilian.online.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ApifoxModel {
|
||||
/**
|
||||
* 节点ID
|
||||
*/
|
||||
private String clusterId;
|
||||
/**
|
||||
* CPU使用信息
|
||||
*/
|
||||
private CPUInfo cpuInfo;
|
||||
/**
|
||||
* 节点状态
|
||||
*/
|
||||
private FlowInfo flowInfo;
|
||||
/**
|
||||
* HTTP请求地址
|
||||
*/
|
||||
private String httpUrl;
|
||||
/**
|
||||
* JVM使用信息
|
||||
*/
|
||||
private JVMInfo jvmInfo;
|
||||
/**
|
||||
* MQTT事件信息
|
||||
*/
|
||||
private MqttInfo mqttInfo;
|
||||
/**
|
||||
* MQTTS请求地址
|
||||
*/
|
||||
private String mqttsUrl;
|
||||
/**
|
||||
* MQTT请求地址
|
||||
*/
|
||||
private String mqttUrl;
|
||||
/**
|
||||
* 节点名称
|
||||
*/
|
||||
private String nodeName;
|
||||
/**
|
||||
* 启动时间
|
||||
*/
|
||||
private String startJvmTime;
|
||||
/**
|
||||
* 节点版本
|
||||
*/
|
||||
private String version;
|
||||
/**
|
||||
* websocket请求地址
|
||||
*/
|
||||
private String websocketUrl;
|
||||
|
||||
/**
|
||||
* 公网地址
|
||||
*/
|
||||
private String publicIpAddress;
|
||||
|
||||
/**
|
||||
* 内网地址
|
||||
*/
|
||||
private String privateIpAddress;
|
||||
|
||||
/**
|
||||
* 申请令牌
|
||||
*/
|
||||
private String token;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.zhilian.online.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* CPU使用信息
|
||||
*/
|
||||
@Data
|
||||
public class CPUInfo {
|
||||
/**
|
||||
* CPU核数
|
||||
*/
|
||||
private long cpuNum;
|
||||
/**
|
||||
* 内核态使用率
|
||||
*/
|
||||
private String cSys;
|
||||
/**
|
||||
* 空闲率
|
||||
*/
|
||||
private String idle;
|
||||
/**
|
||||
* I/O等待
|
||||
*/
|
||||
private String iowait;
|
||||
/**
|
||||
* 用户态使用率
|
||||
*/
|
||||
private String user;
|
||||
}
|
|
@ -0,0 +1,261 @@
|
|||
package com.zhilian.online.domain;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.domain
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-12 15:01
|
||||
* @Description: 阿里云ECS服务器实体类
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@ToString
|
||||
public class EcsInstance {
|
||||
|
||||
/**
|
||||
* 实例创建时间。以 ISO 8601 为标准,并使用 UTC+0 时间,格式为 yyyy-MM-ddTHH:mmZ
|
||||
*/
|
||||
private String creationTime;
|
||||
|
||||
/**
|
||||
* 实例序列号
|
||||
*/
|
||||
private String serialNumber;
|
||||
|
||||
/**
|
||||
* 实例状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 部署集ID
|
||||
*/
|
||||
private String deploymentSetId;
|
||||
|
||||
/**
|
||||
* 密钥对名称。
|
||||
*/
|
||||
private String keyPairName;
|
||||
|
||||
/**
|
||||
* 按量实例的竞价策略。可能值:
|
||||
* NoSpot:正常按量付费实例。
|
||||
* SpotWithPriceLimit:设置上限价格的抢占式实例。
|
||||
* SpotAsPriceGo:系统自动出价
|
||||
*/
|
||||
private String spotStrategy;
|
||||
|
||||
/**
|
||||
* 实例是否支持挂载磁盘。
|
||||
*/
|
||||
private Boolean deviceAvailable;
|
||||
|
||||
/**
|
||||
* 实例挂载的本地存储容量。单位:GiB
|
||||
*/
|
||||
private Long localStorageCapacity;
|
||||
|
||||
/**
|
||||
* 实例描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 抢占式实例的保留时长,单位为小时。可能值:
|
||||
* 1:创建后阿里云会保证实例运行 1 小时不会被自动释放;超过 1 小时后,系统会自动比较出价与市场价格、检查资源库存,来决定实例的持有和回收。
|
||||
* 0:创建后,阿里云不保证实例运行 1 小时,系统会自动比较出价与市场价格、检查资源库存,来决定实例的持有和回收。
|
||||
*/
|
||||
private Integer spotDuration;
|
||||
|
||||
/**
|
||||
* 实例网络类型。可能值:
|
||||
* classic:经典网络。
|
||||
* vpc:专有网络 VPC。
|
||||
*/
|
||||
private String instanceNetworkType;
|
||||
|
||||
/**
|
||||
* 实例名称
|
||||
*/
|
||||
private String instanceName;
|
||||
|
||||
/**
|
||||
* 实例ID
|
||||
*/
|
||||
private String instanceId;
|
||||
|
||||
/**
|
||||
* 实例操作系统的英文名称
|
||||
*/
|
||||
private String osNameEn;
|
||||
|
||||
/**
|
||||
*实例所属的 HPC 集群 ID。
|
||||
*/
|
||||
private String hpcClusterId;
|
||||
|
||||
/**
|
||||
* 实例的每小时最高价格。支持最大 3 位小数,参数 SpotStrategy=SpotWithPriceLimit 时,该参数生效。
|
||||
*/
|
||||
private Number spotPriceLimit;
|
||||
|
||||
/**
|
||||
* 内存大小,单位为 MiB。
|
||||
*/
|
||||
private Integer memory;
|
||||
|
||||
/**
|
||||
* 实例的操作系统名称
|
||||
*/
|
||||
private String osName;
|
||||
|
||||
/**
|
||||
* ECS 实例绑定部署集分散部署时,实例在部署集中的分组位置。
|
||||
*/
|
||||
private String deploymentSetGroupNo;
|
||||
|
||||
/**
|
||||
* 实例运行的镜像 ID。
|
||||
*/
|
||||
private String imageId;
|
||||
|
||||
/**
|
||||
* 实例的 GPU 类型。
|
||||
*/
|
||||
private String gpuSpec;
|
||||
|
||||
/**
|
||||
* 实例释放保护属性,指定是否支持通过控制台或 API(DeleteInstance)释放实例。
|
||||
* true:已开启实例释放保护。
|
||||
* false:未开启实例释放保护。
|
||||
*/
|
||||
private Boolean deletionProtection;
|
||||
|
||||
/**
|
||||
* 实例停机后是否继续收费。可能值:
|
||||
* KeepCharging:停机后继续收费,为您继续保留库存资源。
|
||||
* StopCharging:停机后不收费。停机后,我们释放实例对应的资源,例如 vCPU、内存和公网 IP 等资源。重启是否成功依赖于当前地域中是否仍有资源库存。
|
||||
* Not-applicable:本实例不支持停机不收费功能。
|
||||
*/
|
||||
private String stoppedMode;
|
||||
|
||||
/**
|
||||
* 实例规格附带的 GPU 数量。
|
||||
*/
|
||||
private Integer gpuAmount;
|
||||
|
||||
/**
|
||||
* 实例主机名
|
||||
*/
|
||||
private String hostName;
|
||||
|
||||
/**
|
||||
* 公网出带宽最大值,单位:Mbit/s
|
||||
*/
|
||||
private Integer internetMaxBandwidthOut;
|
||||
|
||||
/**
|
||||
* 公网入带宽最大值,单位:Mbit/s
|
||||
*/
|
||||
private Integer internetMaxBandwidthIn;
|
||||
|
||||
/**
|
||||
* 实例规格
|
||||
*/
|
||||
private String instanceType;
|
||||
|
||||
/**
|
||||
* 实例的计费方式。可能值:
|
||||
* PrePaid:包年包月。
|
||||
* PostPaid:按量付费。
|
||||
*/
|
||||
private String instanceChargeType;
|
||||
|
||||
/**
|
||||
* 实例所属地域 ID。
|
||||
*/
|
||||
private String regionId;
|
||||
|
||||
/**
|
||||
* 是否为 I/O 优化型实例。
|
||||
*/
|
||||
private Boolean ioOptimized;
|
||||
|
||||
/**
|
||||
* 实例最近一次的启动时间。以 ISO 8601 为标准,并使用 UTC+0 时间,格式为 yyyy-MM-ddTHH:mmZ
|
||||
*/
|
||||
private String startTime;
|
||||
|
||||
/**
|
||||
* vCPU 数
|
||||
*/
|
||||
private Integer cpu;
|
||||
|
||||
/**
|
||||
* 实例挂载的本地存储数量。
|
||||
*/
|
||||
private Integer localStorageAmount;
|
||||
|
||||
/**
|
||||
* 过期时间。以 ISO 8601 为标准,并使用 UTC+0 时间,格式为 yyyy-MM-ddTHH:mmZ
|
||||
*/
|
||||
private String expiredTime;
|
||||
|
||||
/**
|
||||
* 实例所属可用区。
|
||||
*/
|
||||
private String zoneId;
|
||||
|
||||
/**
|
||||
* 实例是否可以回收。
|
||||
*/
|
||||
private Boolean recyclable;
|
||||
|
||||
/**
|
||||
* 突发性能实例的运行模式。可能值:
|
||||
* Standard:标准模式。有关实例性能的更多信息,请参见什么是突发性能实例中的性能约束模式章节。
|
||||
* Unlimited:无性能约束模式,有关实例性能的更多信息,请参见什么是突发性能实例中的无性能约束模式章节。
|
||||
*/
|
||||
private String creditSpecification;
|
||||
|
||||
/**
|
||||
* 实例规格族。
|
||||
*/
|
||||
private String instanceTypeFamily;
|
||||
|
||||
/**
|
||||
* 实例的操作系统类型,分为 Windows Server 和 Linux 两种。可能值:
|
||||
* windows。
|
||||
* linux。
|
||||
*/
|
||||
private String osType;
|
||||
|
||||
/**
|
||||
* 公网IP地址
|
||||
*/
|
||||
private String publicIpAddress;
|
||||
|
||||
/**
|
||||
* 内网IP地址
|
||||
*/
|
||||
private String privateIpAddress;
|
||||
|
||||
/**
|
||||
* 专有网络ID
|
||||
*/
|
||||
private String vpcId;
|
||||
|
||||
/**
|
||||
* 安全组ID
|
||||
*/
|
||||
private List<String> securityGroupIds;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.zhilian.online.domain;
|
||||
|
||||
import lombok.Data; /**
|
||||
* 节点状态
|
||||
*/
|
||||
@Data
|
||||
public class FlowInfo {
|
||||
/**
|
||||
* 上次读取吞吐量
|
||||
*/
|
||||
private String lastReadThroughput;
|
||||
/**
|
||||
* 上次写入吞吐量
|
||||
*/
|
||||
private String lastWriteThroughput;
|
||||
/**
|
||||
* 读取总吞吐量
|
||||
*/
|
||||
private String readBytesHistory;
|
||||
/**
|
||||
* 实写字节
|
||||
*/
|
||||
private String realWriteBytes;
|
||||
/**
|
||||
* 写入总吞吐量
|
||||
*/
|
||||
private String writeBytesHistory;
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package com.zhilian.online.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.zhilian.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
import org.bouncycastle.util.IPAddress;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.domain
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-03-31 08:58
|
||||
* @Description: 收集节点实体类
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class Gather extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 收集节点ID
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String clientId;
|
||||
|
||||
// /**
|
||||
// * 收集节点登录令牌
|
||||
// */
|
||||
// @NotBlank
|
||||
// private String token;
|
||||
|
||||
/**
|
||||
* broker
|
||||
*/
|
||||
@NotBlank
|
||||
private String broker;
|
||||
|
||||
/**
|
||||
* username
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* password
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* qos
|
||||
*/
|
||||
private Integer qos;
|
||||
|
||||
/**
|
||||
* topic
|
||||
*/
|
||||
@NotBlank
|
||||
private String topic;
|
||||
|
||||
/**
|
||||
* ip地址
|
||||
*/
|
||||
private String ipAddress;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package com.zhilian.online.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* JVM使用信息
|
||||
*/
|
||||
@Data
|
||||
public class JVMInfo {
|
||||
/**
|
||||
* 文件描述(句柄)
|
||||
*/
|
||||
private String fileDescriptors;
|
||||
/**
|
||||
* 堆内存
|
||||
*/
|
||||
private String heapCommit;
|
||||
/**
|
||||
* 堆初始化空间
|
||||
*/
|
||||
private String heapInit;
|
||||
/**
|
||||
* 堆最大内存
|
||||
*/
|
||||
private String heapMax;
|
||||
/**
|
||||
* 堆使用空间
|
||||
*/
|
||||
private String heapUsed;
|
||||
/**
|
||||
* JAVA目录
|
||||
*/
|
||||
private String jdkHome;
|
||||
/**
|
||||
* JDK版本
|
||||
*/
|
||||
private String jdkVersion;
|
||||
/**
|
||||
* 非堆空间
|
||||
*/
|
||||
private String noHeapCommit;
|
||||
/**
|
||||
* 非堆初始化空间
|
||||
*/
|
||||
private String noHeapInit;
|
||||
/**
|
||||
* 非堆最大空间
|
||||
*/
|
||||
private String noHeapMax;
|
||||
/**
|
||||
* 非堆使用空间
|
||||
*/
|
||||
private String noHeapUsed;
|
||||
/**
|
||||
* 线程数量
|
||||
*/
|
||||
private long threadCount;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.zhilian.online.domain;// ApifoxModel.java
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
// JVMInfo.java
|
||||
|
||||
|
||||
// MqttInfo.java
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* MQTT事件信息
|
||||
*/
|
||||
@Data
|
||||
public class MqttInfo {
|
||||
/**
|
||||
* 关闭事件数量
|
||||
*/
|
||||
private long closeEventSize;
|
||||
/**
|
||||
* 连接事件数量
|
||||
*/
|
||||
private long connectEventSize;
|
||||
/**
|
||||
* 链接总数
|
||||
*/
|
||||
private long connectSize;
|
||||
/**
|
||||
* 断开链接数量
|
||||
*/
|
||||
private long disconnectEventSize;
|
||||
/**
|
||||
* 推送数量
|
||||
*/
|
||||
private long publishEventSize;
|
||||
/**
|
||||
* 发布重试事件数量
|
||||
*/
|
||||
private long publishRetryEventSize;
|
||||
/**
|
||||
* 保留消息数量
|
||||
*/
|
||||
private long retainSize;
|
||||
/**
|
||||
* 订阅事件数量
|
||||
*/
|
||||
private long subscribeEventSize;
|
||||
/**
|
||||
* 订阅数量
|
||||
*/
|
||||
private long subscribeSize;
|
||||
/**
|
||||
* 主题数量
|
||||
*/
|
||||
private long topicSize;
|
||||
/**
|
||||
* 取消订阅数量
|
||||
*/
|
||||
private long unSubscribeEventSize;
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
//package com.zhilian.online.domain;/**
|
||||
// * @version:
|
||||
// * @Author: LiYuan
|
||||
// * @description:
|
||||
// * @date: 2024/3/29 21:44
|
||||
// */
|
||||
//
|
||||
//import com.baomidou.mybatisplus.annotation.IdType;
|
||||
//import com.baomidou.mybatisplus.annotation.TableId;
|
||||
//import com.baomidou.mybatisplus.annotation.TableName;
|
||||
//import com.zhilian.common.core.web.domain.BaseEntity;
|
||||
//import lombok.*;
|
||||
//
|
||||
//import javax.validation.constraints.NotBlank;
|
||||
//import javax.validation.constraints.NotNull;
|
||||
//import java.util.Date;
|
||||
//
|
||||
///**
|
||||
// *@BelongsProject: smart-cloud-server
|
||||
// *@BelongsPackage: com.zhilian.online.domain
|
||||
// *@Author: LiYuan
|
||||
// *@CreateTime: 2024-03-29 21:44
|
||||
// *@Description: 汽车类,测试使用
|
||||
// *@Version: 1.0
|
||||
// */
|
||||
//@Data
|
||||
////@AllArgsConstructor
|
||||
////@NoArgsConstructor
|
||||
//@Builder
|
||||
//@ToString
|
||||
//@EqualsAndHashCode(callSuper = true)
|
||||
//@TableName("vehicle")
|
||||
//public class Vehicle extends BaseEntity {
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
|
@ -1,70 +0,0 @@
|
|||
package com.zhilian.online.domain;/**
|
||||
* @version:
|
||||
* @Author: LiYuan
|
||||
* @description:
|
||||
* @date: 2024/3/29 21:49
|
||||
*/
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.zhilian.common.core.web.domain.BaseEntity;
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*@BelongsProject: smart-cloud-server
|
||||
*@BelongsPackage: com.zhilian.online.domain
|
||||
*@Author: LiYuan
|
||||
*@CreateTime: 2024-03-29 21:49
|
||||
*@Description: 车辆申请注册成功后返回的一次性账户数据
|
||||
*@Version: 1.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NotBlank
|
||||
@ToString
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("vehicle_account")
|
||||
public class VehicleAccount extends BaseEntity{
|
||||
|
||||
|
||||
/**
|
||||
* 车辆VIN
|
||||
*/
|
||||
@TableId(type = IdType.INPUT)
|
||||
private String vin;
|
||||
|
||||
|
||||
/**
|
||||
* 申请时间
|
||||
*/
|
||||
@NotNull
|
||||
private Date applyTime;
|
||||
|
||||
/**
|
||||
* 申请唯一标识
|
||||
*/
|
||||
@NotBlank
|
||||
private String applyCode;
|
||||
|
||||
/**
|
||||
* 一次性用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 一次性密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 可以进行连接的收集节点id
|
||||
*/
|
||||
private String clientId;
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.zhilian.online.domain.model;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.domain.model
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-18 19:47
|
||||
* @Description: 收集节点信息
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
@Builder
|
||||
public class GatewayNodeInfo {
|
||||
|
||||
/**
|
||||
* 节点id
|
||||
*/
|
||||
private String nodeId;
|
||||
|
||||
/**
|
||||
* 公网IP
|
||||
*/
|
||||
private String publicIpAddress;
|
||||
|
||||
/**
|
||||
* 内网IP
|
||||
*/
|
||||
private String privateIpAddress;
|
||||
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
package com.zhilian.online.domain.req;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.domain.req
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-16 20:23
|
||||
* @Description: 阿里openAPI创建实例请求
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
@Builder
|
||||
public class EcsCreateReq {
|
||||
|
||||
|
||||
/**
|
||||
* 磁盘大小
|
||||
*/
|
||||
private String systemDiskSize;
|
||||
|
||||
/**
|
||||
* 磁盘类型
|
||||
*/
|
||||
private String systemDickCategory;
|
||||
|
||||
/**
|
||||
* 地域ID
|
||||
*/
|
||||
private String regionId;
|
||||
|
||||
/**
|
||||
* 镜像ID
|
||||
*/
|
||||
private String imageId;
|
||||
|
||||
/**
|
||||
* 实例规格
|
||||
*/
|
||||
private String instanceType;
|
||||
|
||||
/**
|
||||
* 安全组ID
|
||||
*/
|
||||
private String securityGroupId;
|
||||
|
||||
/**
|
||||
* 专有网络ID
|
||||
*/
|
||||
private String vSwitchId;
|
||||
|
||||
|
||||
/**
|
||||
* 实例名称
|
||||
*/
|
||||
private String instanceName;
|
||||
|
||||
/**
|
||||
* 公网入网流量大小
|
||||
*/
|
||||
private Integer internetMaxBandwidthIn;
|
||||
|
||||
/**
|
||||
* 公网出网流量大小
|
||||
*/
|
||||
private Integer internetMaxBandwidthOut;
|
||||
|
||||
/**
|
||||
* 唯一后缀
|
||||
*/
|
||||
private Boolean uniqueSuffix;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 专有网络ID
|
||||
*/
|
||||
private String zoneId;
|
||||
|
||||
/**
|
||||
* 网络计费类型
|
||||
*/
|
||||
private String internetChargeType;
|
||||
|
||||
/**
|
||||
* 购买数量
|
||||
*/
|
||||
private Integer amount;
|
||||
|
||||
/**
|
||||
* 最小购买数量
|
||||
*/
|
||||
private Integer minAmount;
|
||||
|
||||
/**
|
||||
* 购买时长单位
|
||||
*/
|
||||
private String periodUnit;
|
||||
|
||||
/**
|
||||
* 购买时长
|
||||
*/
|
||||
private Integer period;
|
||||
|
||||
/**
|
||||
* 实例付费类型
|
||||
*/
|
||||
private String instanceChargeType;
|
||||
|
||||
/**
|
||||
* 私网IP
|
||||
*/
|
||||
private String privateIpAddress;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package com.zhilian.online.domain.req;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.domain.req
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-12 15:37
|
||||
* @Description: 阿里云openAPI查询实例请求
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
@Builder
|
||||
public class EcsQueryReq {
|
||||
|
||||
/**
|
||||
* 实例所属地域 ID。
|
||||
*/
|
||||
@NotBlank
|
||||
private String regionId;
|
||||
|
||||
/**
|
||||
* 专有网络ID
|
||||
*/
|
||||
private String vpcId;
|
||||
|
||||
/**
|
||||
* 交换机ID
|
||||
*/
|
||||
private String vSwitchId;
|
||||
|
||||
/**
|
||||
* 可用区ID。
|
||||
*/
|
||||
private String zoneId;
|
||||
|
||||
/**
|
||||
* 实例网络类型。可能值:
|
||||
* classic:经典网络。
|
||||
* vpc:专有网络 VPC。
|
||||
*/
|
||||
private String instanceNetworkType;
|
||||
|
||||
/**
|
||||
* 安全组ID
|
||||
*/
|
||||
private String securityGroupId;
|
||||
|
||||
/**
|
||||
* 实例ID ["i-bp67acfmxazb4p****", "i-bp67acfmxazb4p****", … "i-bp67acfmxazb4p****"]
|
||||
*/
|
||||
private List<String> instanceIds;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
private Integer pageNumber = 1;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
private Integer pageSize = 10;
|
||||
|
||||
/**
|
||||
* 内网IP地址集 ["172.16.1.1", "172.16.2.1", … "172.16.10.1"]
|
||||
*/
|
||||
private String privateIpAddresses;
|
||||
|
||||
/**
|
||||
* 内网IP地址集 ["172.16.1.1", "172.16.2.1", … "172.16.10.1"]
|
||||
*/
|
||||
private String publicIpAddresses;
|
||||
|
||||
/**
|
||||
* 实例名称,支持使用通配符*进行模糊搜索。
|
||||
*/
|
||||
private String instanceName;
|
||||
|
||||
/**
|
||||
* 镜像ID
|
||||
*/
|
||||
private String imageId;
|
||||
|
||||
/**
|
||||
* 实例状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 实例规格
|
||||
*/
|
||||
private String instanceType;
|
||||
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
package com.zhilian.online.domain.req;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.domain.req
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-03-31 09:03
|
||||
* @Description: 节点申请注册请求体
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
@Builder
|
||||
public class GatherRegReq {
|
||||
|
||||
/**
|
||||
* 客户端ID
|
||||
*/
|
||||
@NotBlank
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
* 令牌
|
||||
*/
|
||||
private String token;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.zhilian.online.load.abs;
|
||||
|
||||
import com.zhilian.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.load.abs
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-18 19:09
|
||||
* @Description: 网关负载均衡缓存抽象类
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public abstract class GatewayCacheAbs<K> {
|
||||
|
||||
@Autowired
|
||||
public RedisService redisService;
|
||||
|
||||
public abstract String getPre();
|
||||
|
||||
public String encode(K key) {
|
||||
return getPre() + key;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.zhilian.online.load.cache;
|
||||
|
||||
import com.zhilian.common.redis.service.RedisService;
|
||||
import com.zhilian.online.load.abs.GatewayCacheAbs;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.load.cache
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-18 19:11
|
||||
* @Description: 加权轮询的100个节点IP 为之后车辆上线取用
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
public class GatewayLoadNodeCache extends GatewayCacheAbs<String> {
|
||||
|
||||
|
||||
|
||||
private final static String gatewayLoadNodeKey = "node";
|
||||
|
||||
@Override
|
||||
public String getPre() {
|
||||
return "gateway:load:";
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 存放
|
||||
* @author: LiYuan
|
||||
* @param: nodeList
|
||||
* @return: void
|
||||
**/
|
||||
public void put(List<String> nodeList) {
|
||||
redisService.deleteObject(encode(gatewayLoadNodeKey));
|
||||
redisService.setCacheList(encode(gatewayLoadNodeKey), nodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取所有负载节点
|
||||
* @author: LiYuan
|
||||
* @param: null
|
||||
* @return: List<String>
|
||||
**/
|
||||
public List<String> get() {
|
||||
return redisService.getCacheList(encode(gatewayLoadNodeKey));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 通过下标获取节点
|
||||
* @author: LiYuan
|
||||
* @param: index 下标
|
||||
* @return: String node 节点
|
||||
**/
|
||||
public String getByIndex(Long index){
|
||||
if (null == index || index > 100){
|
||||
throw new RuntimeException("下标违法,不在[0-100]内");
|
||||
}
|
||||
return redisService.getcacheListValue(encode(gatewayLoadNodeKey),index);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.zhilian.online.load.cache;
|
||||
|
||||
import com.zhilian.online.load.abs.GatewayCacheAbs;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.load.cache
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-18 19:34
|
||||
* @Description: 网关负载自增序列
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
public class GatewayLoadSeriesCache extends GatewayCacheAbs<String> {
|
||||
|
||||
private final static String gatewayLoadSeriesKey = "series";
|
||||
|
||||
|
||||
@Override
|
||||
public String getPre() {
|
||||
return "gateway:load:";
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 创建Bean后初始化自增序列
|
||||
* @author: LiYuan
|
||||
* @param:
|
||||
* @return:
|
||||
**/
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
redisService.setCacheObject(encode(gatewayLoadSeriesKey), 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 获取自增序列的值
|
||||
* @author: LiYuan
|
||||
* @param:
|
||||
* @return: Long
|
||||
**/
|
||||
public Long incrementAndGet() {
|
||||
return redisService.increment(encode(gatewayLoadSeriesKey), 1L);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 获取当前序列的值
|
||||
* @author: LiYuan
|
||||
* @param:
|
||||
* @return:
|
||||
**/
|
||||
public Long get() {
|
||||
return redisService.getCacheObject(encode(gatewayLoadSeriesKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 重置序列中的值
|
||||
* @author: LiYuan
|
||||
* @param:
|
||||
* @return:
|
||||
**/
|
||||
public void reset() {
|
||||
this.init();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.zhilian.online.load.cache;
|
||||
|
||||
import com.zhilian.online.load.abs.GatewayCacheAbs;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.load.cache
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-19 19:42
|
||||
* @Description: 节点负载的车辆数据操作
|
||||
* @Version: 1.0
|
||||
*/
|
||||
public class GatewayNodeCarsCache extends GatewayCacheAbs<String> {
|
||||
@Override
|
||||
public String getPre() {
|
||||
return "gateway:node:cars";
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 车辆上线添加数据
|
||||
* @author: LiYuan
|
||||
* @param: String nodeId, String vin
|
||||
* @return: void
|
||||
**/
|
||||
public void put(String nodeId, String vin) {
|
||||
redisService.setCacheSet(encode(nodeId), vin);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 根据节点获取其负载车辆vin列表
|
||||
* @author: LiYuan
|
||||
* @param: String nodeId
|
||||
* @return: void
|
||||
**/
|
||||
public List<String> get(String nodeId) {
|
||||
Set<String> res = redisService.getCacheSet(encode(nodeId));
|
||||
return res.stream().map(String::valueOf).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 删除下线车辆
|
||||
* @author: LiYuan
|
||||
* @param: String nodeId, String vin
|
||||
* @return: void
|
||||
**/
|
||||
public void remove(String nodeId, String vin) {
|
||||
redisService.deleteCacheSetValue(encode(nodeId), vin);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.zhilian.online.load.cache;
|
||||
|
||||
import com.zhilian.online.domain.model.GatewayNodeInfo;
|
||||
import com.zhilian.online.load.abs.GatewayCacheAbs;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.load.cache
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-18 19:44
|
||||
* @Description: 网关负载中心节点数据缓存 String key(节点ID) + 节点 对象
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
public class GatewayNodeInfoCache extends GatewayCacheAbs<String > {
|
||||
|
||||
|
||||
@Override
|
||||
public String getPre() {
|
||||
return "gateway:node:info:";
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 增加节点数据
|
||||
* @author: LiYuan
|
||||
* @param: GatewayNodeInfo 节点数据
|
||||
* @return:
|
||||
**/
|
||||
public void put(GatewayNodeInfo gatewayNodeInfo){
|
||||
redisService.setCacheObject(encode(gatewayNodeInfo.getNodeId()),gatewayNodeInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取节点缓存数据
|
||||
* @author: LiYuan
|
||||
* @param: nodeId 节点Id
|
||||
* @return:
|
||||
**/
|
||||
public GatewayNodeInfo get(String nodeId){
|
||||
return redisService.getCacheObject(encode(nodeId));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 获取所有节点数据
|
||||
* @author: LiYuan
|
||||
* @param:
|
||||
* @return:
|
||||
**/
|
||||
public List<GatewayNodeInfo> get(){
|
||||
return redisService.getCacheObject(encode(getPre()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 删除网关节点
|
||||
* @author: LiYuan
|
||||
* @param:
|
||||
* @return:
|
||||
**/
|
||||
public void remove(String nodeId){
|
||||
redisService.deleteObject(encode(nodeId));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.zhilian.online.load.cache;
|
||||
|
||||
import com.zhilian.online.domain.model.GatewayNodeInfo;
|
||||
import com.zhilian.online.load.abs.GatewayCacheAbs;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.load.cache
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-18 20:03
|
||||
* @Description: 节点权重数据
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
public class GatewayNodeWeightCache extends GatewayCacheAbs<String > {
|
||||
|
||||
private final static String gatewayNodeLoadKey = "weight";
|
||||
|
||||
@Override
|
||||
public String getPre() {
|
||||
return "gateway:node:";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description: 获取所有Zset集合
|
||||
* @author: LiYuan
|
||||
* @param: void
|
||||
* @return: Map<Object,Double>
|
||||
**/
|
||||
public Map<Object,Double> get(){
|
||||
return redisService.getCacheObject(encode(gatewayNodeLoadKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取指定节点分数
|
||||
* @author: LiYuan
|
||||
* @param: gatewayNodeInfo
|
||||
* @return: score
|
||||
**/
|
||||
public Double get(GatewayNodeInfo gatewayNodeInfo){
|
||||
return redisService.getCacheZsetScore(encode(gatewayNodeLoadKey),gatewayNodeInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: LiYuan
|
||||
* @param:
|
||||
* @return:
|
||||
**/
|
||||
public void put(GatewayNodeInfo gatewayNodeInfo){
|
||||
redisService.setCacheZsetValue(encode(gatewayNodeLoadKey),gatewayNodeInfo,0.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: LiYuan
|
||||
* @param:
|
||||
* @return:
|
||||
**/
|
||||
public void increment(GatewayNodeInfo gatewayNodeInfo,Double score){
|
||||
redisService.incrementScore(encode(gatewayNodeLoadKey),gatewayNodeInfo,score);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description:
|
||||
* @author: LiYuan
|
||||
* @param:
|
||||
* @return:
|
||||
**/
|
||||
public void remove(GatewayNodeInfo gatewayNodeInfo) {
|
||||
redisService.deleteCacheZsetValue(encode(gatewayNodeLoadKey),gatewayNodeInfo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.zhilian.online.load.cache;
|
||||
|
||||
import com.zhilian.online.load.abs.GatewayCacheAbs;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @BelongsProject: smart-cloud-server
|
||||
* @BelongsPackage: com.zhilian.online.load.cache
|
||||
* @Author: LiYuan
|
||||
* @CreateTime: 2024-04-18 19:58
|
||||
* @Description: 车辆连接数据
|
||||
* @Version: 1.0
|
||||
*/
|
||||
@Component
|
||||
public class GatewayVehicleNodeCaChe extends GatewayCacheAbs<String> {
|
||||
|
||||
|
||||
@Override
|
||||
public String getPre() {
|
||||
return "gateway:car:";
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 存放车辆数据
|
||||
* @author: LiYuan
|
||||
* @param: String vin, String nodeId
|
||||
* @return:
|
||||
**/
|
||||
public void put(String vin, String nodeId) {
|
||||
redisService.setCacheObject(encode(vin),nodeId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @description:删除车辆数据
|
||||
* @author: LiYuan
|
||||
* @param: String vin
|
||||
* @return:
|
||||
**/
|
||||
public void remove(String vin){
|
||||
redisService.deleteObject(encode(vin));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description: 获取车辆连接数据
|
||||
* @author: LiYuan
|
||||
* @param: String vin
|
||||
* @return:
|
||||
**/
|
||||
public String get(String vin){
|
||||
return redisService.getCacheObject(encode(vin));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.zhilian.online.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @version:
|
||||
* @Author: LiYuan
|
||||
* @description: 车辆收集节点数据层
|
||||
* @date: 2024/3/29 20:48
|
||||
*/
|
||||
@Mapper
|
||||
public interface OnlineGatherMapper{
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,7 +1,6 @@
|
|||
package com.zhilian.online.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhilian.online.domain.VehicleAccount;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
|
@ -11,7 +10,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
* @date: 2024/3/29 20:45
|
||||
*/
|
||||
@Mapper
|
||||
public interface OnlineLoadCenterMapper extends BaseMapper<VehicleAccount> {
|
||||
public interface OnlineLoadCenterMapper{
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
package com.zhilian.online.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.online.domain.Gather;
|
||||
import com.zhilian.online.domain.VehicleAccount;
|
||||
import com.zhilian.online.domain.req.GatherRegReq;
|
||||
import com.zhilian.online.domain.ApifoxModel;
|
||||
|
||||
/**
|
||||
* @version:
|
||||
|
@ -12,7 +9,7 @@ import com.zhilian.online.domain.req.GatherRegReq;
|
|||
* @description: 车辆负载中心服务接口
|
||||
* @date: 2024/3/29 20:42
|
||||
*/
|
||||
public interface OnlineLoadCenterService extends IService<VehicleAccount> {
|
||||
public interface OnlineLoadCenterService{
|
||||
|
||||
/**
|
||||
* @description: 车辆申请注解令牌接口,仅限内网访问
|
||||
|
@ -20,7 +17,7 @@ public interface OnlineLoadCenterService extends IService<VehicleAccount> {
|
|||
* @param: vehicle
|
||||
* @return: Result<OnlineAccount>
|
||||
**/
|
||||
Result<String> applyForReg();
|
||||
Result<String> applyForReg(String clusterId);
|
||||
|
||||
/**
|
||||
* @description: 车辆使用申请的一次性账户连接收集节点
|
||||
|
@ -28,5 +25,23 @@ public interface OnlineLoadCenterService extends IService<VehicleAccount> {
|
|||
* @param:
|
||||
* @return: Result
|
||||
**/
|
||||
Result regGather(Gather gather);
|
||||
Result regGather(ApifoxModel apifoxModel);
|
||||
|
||||
|
||||
/**
|
||||
* 车辆申请上线收集节点
|
||||
* @author: LiYuan
|
||||
* @param: vin
|
||||
* @return gather
|
||||
*/
|
||||
void applyForConnectToGather(String vin);
|
||||
|
||||
|
||||
/**
|
||||
* @description:车辆下线接口
|
||||
* @author: LiYuan
|
||||
* @param: vin
|
||||
* @return: Result
|
||||
**/
|
||||
void applyForDisconnectToGather(String vin);
|
||||
}
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
package com.zhilian.online.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhilian.common.core.domain.Result;
|
||||
import com.zhilian.online.mapper.OnlineGatherMapper;
|
||||
import com.zhilian.online.service.OnlineGatherService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @version:
|
||||
* @Author: LiYuan
|
||||
* @description: 车辆收集节点服务层
|
||||
* @date: 2024/3/29 20:48
|
||||
*/
|
||||
@Service
|
||||
public class OnlineGatherServiceImpl implements OnlineGatherService {
|
||||
|
||||
@Autowired
|
||||
private OnlineGatherMapper onlineGatherMapper;
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue