Compare commits

..

28 Commits

Author SHA1 Message Date
玉安君 682dd2f6e0 feat commit
网关负载功能
2024-04-20 09:36:24 +08:00
玉安君 a3059cbbf7 feat commit
网关负载功能
2024-04-19 20:20:36 +08:00
玉安君 3857e3a875 feat commit
网关负载功能
2024-04-18 21:38:49 +08:00
玉安君 4d1cb943ac Merge remote-tracking branch 'origin/master' 2024-04-16 20:39:10 +08:00
玉安君 e6100a1318 feat commit
网关负载功能
2024-04-16 20:38:55 +08:00
xiaoSu 9c8131232b redis存储车辆所使用数据 2024-04-15 20:38:58 +08:00
玉安君 ac3aa82ef4 feat commit
网关节点上线,车辆上线,负载均衡功能
公共发邮件接口模块创建任务(yyh)
2024-04-12 11:43:48 +08:00
玉安君 e5be107d55 Merge remote-tracking branch 'origin/master'
# Conflicts:
#	zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/ZhilianBusinessApplication.java
2024-04-12 11:42:25 +08:00
玉安君 6454d72b8d feat commit
网关节点上线,车辆上线,负载均衡功能
公共发邮件接口模块创建任务(yyh)
2024-04-12 11:41:59 +08:00
xiaoSu 0463fde303 redis存储车辆所使用数据 2024-04-11 16:15:43 +08:00
xiaoSu b8de8285b7 Merge branch 'master' of https://gitea.qinmian.online/first-dev/smart-cloud-server
# Conflicts:
#	zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/service/impl/MarkersFenceServiceImpl.java
#	zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/service/impl/VehicleMarkersServiceImpl.java
2024-04-11 15:27:43 +08:00
JangCan 08acad4531 feat
故障日志存储redis,mysql的优化
2024-04-11 10:28:35 +08:00
JangCan a144a4d96a feat
故障日志存储redis,mysql
2024-04-10 22:40:27 +08:00
JangCan a796863e54 Merge remote-tracking branch 'origin/master' 2024-04-10 22:37:51 +08:00
YuanYh 13960a292f 故障日志更新 2024-04-10 20:42:48 +08:00
YuanYh 6fab49598e Merge remote-tracking branch 'origin/master' 2024-04-10 20:41:26 +08:00
YuanYh 46639b77a0 故障日志更新 2024-04-10 20:41:16 +08:00
JangCan 00b4350289 feat
解析故障日志添加,测试添加
2024-04-10 11:33:34 +08:00
xiaoSu 66ca1afa4a Merge remote-tracking branch 'origin/master' 2024-04-10 11:24:05 +08:00
xiaoSu 4e4e80f64d 部分注释添加 2024-04-10 11:23:42 +08:00
xiaoSu 3c1b9cef33 Merge branch 'master' of https://gitea.qinmian.online/first-dev/smart-cloud-server
# Conflicts:
#	zhilian-common/zhilian-common-business/src/main/java/com/zhilian/business/remote/RemoteVehicleService.java
#	zhilian-common/zhilian-common-business/src/main/java/com/zhilian/business/remote/factory/RemoteVehicleFallbackFactory.java
#	zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/controller/VehicleMarkersController.java
#	zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/controller/VehicleTypeController.java
#	zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/mapper/VehicleTypeMapper.java
#	zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/service/VehicleMarkersService.java
#	zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/service/impl/MarkersFenceServiceImpl.java
#	zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/service/impl/VehicleMarkersServiceImpl.java
#	zhilian-modules/zhilian-business/src/main/java/com/zhilian/business/service/impl/VehicleServiceImpl.java
2024-04-10 10:50:16 +08:00
JangCan 02f71d7baf feat
文件修改
2024-04-10 10:30:02 +08:00
xiaoSu 2c2854506e Merge branch 'master' of https://gitea.qinmian.online/first-dev/smart-cloud-server 2024-04-10 10:29:21 +08:00
玉安君 5505c3c45f Merge remote-tracking branch 'origin/server_2024_4_2_yuanyonghao' 2024-04-10 10:28:27 +08:00
xiaoSu 55d398940f 修改BUG 2024-04-09 22:33:03 +08:00
JangCan d45da7b47f feat
事件errorCar
2024-04-09 21:46:51 +08:00
JangCan 672a340cdf feat
事件geofence
2024-04-09 21:37:14 +08:00
JangCan 9478ae16c5 feat
事件
2024-04-09 21:14:09 +08:00
113 changed files with 3300 additions and 1254 deletions

103
pom.xml
View File

@ -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>

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -16,6 +16,9 @@ public class MarkersFence {
@TableField(value = "fence_id",insertStrategy = FieldStrategy.IGNORED)
private Long fenceId;
public Long getMarkerId() {
return markerId;
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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("故障日志服务调用失败");
// }
// };
}
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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
*/

View File

@ -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: Listvalue
* @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);
}
}

View File

@ -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;
}

View File

@ -12,7 +12,6 @@ import org.springframework.web.multipart.MultipartFile;
/**
*
*
* @author zhilian
*/
@FeignClient(contextId = "remoteFileService", value = ServiceNameConstants.FILE_SERVICE, fallbackFactory = RemoteFileFallbackFactory.class)

View File

@ -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>

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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));
}

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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;

View File

@ -25,6 +25,8 @@ public class BreakLog {
private String breakTime;
/** 开始报警时间 */
private String breakDate;
/** 是否报警 */
/** 故障状态 */
private String breakState;
/** 逻辑删除 */
private Integer breakDel;
}

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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
{
/**

View File

@ -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;

View File

@ -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);
}

View File

@ -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;

View File

@ -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();
}

View File

@ -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;

View File

@ -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;

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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();
}

View File

@ -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;

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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);
}
}

View File

@ -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;
}
}

View File

@ -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;

View File

@ -1,2 +1,3 @@
Spring Boot Version: ${spring-boot.version}
Spring Application Name: ${spring.application.name}

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -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(){
}
}

View File

@ -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);
}
}

View File

@ -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&SKClient
* @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;
}
}

View File

@ -100,7 +100,7 @@ public class MqttxConfig {
@PostConstruct
// @PostConstruct
public void initMqtt() {
log.info("mqttx连接中......");

View File

@ -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);
}
}

View File

@ -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,8 +26,27 @@ 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";
}

View File

@ -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;
/**
* ,线
* fluxMQhttp,线
*/
@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);
// }
// }
}

View File

@ -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));
// }
}

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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()
);
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
/**
* APIDeleteInstance
* 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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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 {
//
//
//
//}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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: 100IP 线
* @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);
}
}

View File

@ -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();
}
}

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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);
}
}

View File

@ -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));
}
}

View File

@ -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{
}

View File

@ -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{

View File

@ -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);
}

View File

@ -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