dev.saas.yp #11
|
@ -7,15 +7,27 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-server</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<relativePath>../../../pom.xml</relativePath>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>enterpise-client</artifactId>
|
||||
<description>
|
||||
cloud-common-cache 缓存基准
|
||||
</description>
|
||||
|
||||
<artifactId>cloud-common- </artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<maven.compiler.source>23</maven.compiler.source>
|
||||
<maven.compiler.target>23</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- redis 缓存模块-->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-redis</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,33 @@
|
|||
package com.muyu.common.cache;
|
||||
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* 抽象缓存层
|
||||
* * @className: CacheAbsBasic ️✈️
|
||||
* * @author: Yang 鹏 🦅
|
||||
* * @date: 2024/9/29 16:08 ⏰
|
||||
* * @Version: 1.0
|
||||
* * @description:
|
||||
*/
|
||||
public abstract class CacheAbsBasic <K, V> implements CacheBasic<K, V>{
|
||||
|
||||
@Autowired
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public void put(K key, V value) {
|
||||
redisService.setCacheObject(encode(key), value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public V get(K key) {
|
||||
return redisService.getCacheObject(encode(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(K key) {
|
||||
redisService.deleteObject(encode(key));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.common.cache;
|
||||
|
||||
/**
|
||||
* 缓存基础
|
||||
* * @className: CacheBasic ️✈️
|
||||
* * @author: Yang 鹏 🦅
|
||||
* * @date: 2024/9/29 16:08 ⏰
|
||||
* * @Version: 1.0
|
||||
* * @description:
|
||||
*/
|
||||
public interface CacheBasic<K,V> extends PrimaryKeyBasic<K>{
|
||||
void put(K key, V value);
|
||||
|
||||
V get(K key);
|
||||
|
||||
void remove(K key);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.common.cache;
|
||||
|
||||
/**
|
||||
* 主键基础
|
||||
* * @className: PrimaryKeyBasic ️✈️
|
||||
* * @author: Yang 鹏 🦅
|
||||
* * @date: 2024/9/29 16:08 ⏰
|
||||
* * @Version: 1.0
|
||||
* * @description:
|
||||
*/
|
||||
public interface PrimaryKeyBasic <K>{
|
||||
|
||||
/**
|
||||
* 主键前缀
|
||||
* @return
|
||||
*/
|
||||
public String keyPre();
|
||||
|
||||
/**
|
||||
* 主键编码
|
||||
* @param key 缓存建
|
||||
* @return 装修建
|
||||
*/
|
||||
public default String encode(K key){
|
||||
return keyPre() + key.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 主键解码
|
||||
* @param key 缓存建
|
||||
* @return 装修建
|
||||
*/
|
||||
public default K decode(String key) {
|
||||
return (K) key.substring(keyPre().length());
|
||||
}
|
||||
}
|
|
@ -20,4 +20,10 @@ public class ServiceNameConstants {
|
|||
* 文件服务的serviceid
|
||||
*/
|
||||
public static final String FILE_SERVICE = "cloud-file";
|
||||
|
||||
/**
|
||||
* 车辆服务的serviceid
|
||||
*/
|
||||
public static final String ENTERPRISE_SERVICE = "cloud-saas";
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
|
|||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.core.utils.PageUtils;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -19,7 +20,7 @@ import java.util.List;
|
|||
*
|
||||
* @author muyu
|
||||
*/
|
||||
public class BaseController {
|
||||
public class BaseController<M extends BaseEntity> {
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,38 +0,0 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -1,14 +0,0 @@
|
|||
package com.muyu;
|
||||
|
||||
/**
|
||||
* @Author:yan
|
||||
* @Package:com.muyu
|
||||
* @Project:Default (Template) Project
|
||||
* @name:${NAME}
|
||||
* @Date:2024/9/29 09:56
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
|
@ -3,11 +3,11 @@
|
|||
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.muyu</groupId>
|
||||
<artifactId>cloud-server</artifactId>
|
||||
<artifactId>cloud-modules-enterprise</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<relativePath>../../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>enterpise-common</artifactId>
|
||||
|
@ -19,70 +19,15 @@
|
|||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<artifactId>cloud-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>enterpise-common</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-log</artifactId>
|
||||
<artifactId>cloud-common-security</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 接口模块 -->
|
||||
|
@ -91,10 +36,9 @@
|
|||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- XllJob定时任务 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-xxl</artifactId>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations-jakarta</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.domain;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.domain.req.MessageTemplateAddReq;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.domain.req.MessageTemplateAddReq;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
/**
|
||||
* 车辆基础信息对象 sys_car
|
||||
*
|
||||
* @author Li HD
|
||||
* @author LiHD
|
||||
* @date 2024-09-18
|
||||
*/
|
||||
|
||||
|
|
|
@ -5,19 +5,18 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 车辆类型实体类
|
||||
* *@ClassName SysCarType
|
||||
* * @Description TODO
|
||||
* * @Author Li HD
|
||||
* * @Date 2024/9/22 15:48
|
||||
* @ClassName SysCarType
|
||||
* @Description TODO
|
||||
* @Author Li HD
|
||||
* @Date 2024/9/22 15:48
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
|
|
|
@ -11,7 +11,7 @@ import lombok.NoArgsConstructor;
|
|||
/**
|
||||
* @ClassName MessageTemplateAddReq
|
||||
* @Description TODO
|
||||
* @Author Li HD
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/19
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
|
|||
/**
|
||||
* @ClassName MessageValueAddReq
|
||||
* @Description TODO
|
||||
* @Author Li HD
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/19
|
||||
*/
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import lombok.NoArgsConstructor;
|
|||
/**
|
||||
* @ClassName MessageValueReq
|
||||
* @Description TODO
|
||||
* @Author Li HD
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/19
|
||||
*/
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
/**
|
||||
* 车辆基础信息对象 sys_car
|
||||
*
|
||||
* @author Li HD
|
||||
* @author LiHD
|
||||
* @date 2024-09-18
|
||||
*/
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
|
|||
/**
|
||||
* @ClassName MessageTemplateListResp
|
||||
* @Description TODO
|
||||
* @Author Li HD
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/19
|
||||
*/
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
|
|||
/**
|
||||
* @ClassName MessageValueListResp
|
||||
* @Description TODO
|
||||
* @Author Li HD
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/19
|
||||
*/
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import lombok.NoArgsConstructor;
|
|||
/**
|
||||
* @ClassName SysCarResp
|
||||
* @Description TODO
|
||||
* @Author Li HD
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/25 20:14
|
||||
*/
|
||||
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-server</artifactId>
|
||||
<artifactId>cloud-modules-enterprise</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<relativePath>../../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>enterpise-remote</artifactId>
|
||||
|
@ -18,4 +17,10 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>enterpise-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package com.muyu;
|
||||
|
||||
/**
|
||||
* @Author:yan
|
||||
* @Package:com.muyu
|
||||
* @Project:Default (Template) Project
|
||||
* @name:${NAME}
|
||||
* @Date:2024/9/29 09:55
|
||||
*/
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.remote;
|
||||
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.domain.req.MessageValueReq;
|
||||
import com.muyu.domain.resp.MessageValueListResp;
|
||||
import com.muyu.remote.factory.RemoteMessageValueFallbackFactory;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author xie ya ru
|
||||
* @Date 2024/9/28 21:00
|
||||
* @注释 vin查询报文模版类型
|
||||
*/
|
||||
@FeignClient(contextId = "remoteMessageValueService", value = ServiceNameConstants.ENTERPRISE_SERVICE, fallbackFactory = RemoteMessageValueFallbackFactory.class,path = "messageValue")
|
||||
public interface RemoteMessageValueService {
|
||||
|
||||
@PostMapping("/findByTemplateId/{stringVin}")
|
||||
@Operation(summary = "根据车辆类型查询报文模版ID",description = "根据车辆类型查询报文模版ID")
|
||||
Result<Long> findByTemplateId(@PathVariable("stringVin") String stringVin);
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.POST)
|
||||
Result<List<MessageValueListResp>> findAll(@RequestBody MessageValueReq messageValueReq);
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.muyu.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.domain.req.MessageValueReq;
|
||||
import com.muyu.domain.resp.MessageValueListResp;
|
||||
import com.muyu.remote.RemoteMessageValueService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author xie ya ru
|
||||
* @Date 2024/9/28 21:04
|
||||
* @注释
|
||||
*/
|
||||
@Log4j2
|
||||
public class RemoteMessageValueFallbackFactory implements FallbackFactory<RemoteMessageValueService> {
|
||||
@Override
|
||||
public RemoteMessageValueService create(Throwable cause) {
|
||||
log.error("文件服务调用失败:{}",cause.getMessage());
|
||||
return new RemoteMessageValueService() {
|
||||
@Override
|
||||
public Result<List<MessageValueListResp>> findAll(MessageValueReq messageValueReq) {
|
||||
return Result.error("查询数据失败:"+cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Long> findByTemplateId(String stringVin) {
|
||||
return Result.error("查询数据失败:"+cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.muyu.remote.factory.RemoteMessageValueFallbackFactory
|
|
@ -5,9 +5,8 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-server</artifactId>
|
||||
<artifactId>cloud-modules-enterprise</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<relativePath>../../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>enterpise-service</artifactId>
|
||||
|
@ -23,13 +22,6 @@
|
|||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>enterpise-common</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
|
@ -91,7 +83,6 @@
|
|||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-xxl</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -11,8 +11,10 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -31,6 +33,9 @@ public class MessageValueController extends BaseController {
|
|||
@Autowired
|
||||
private MessageValueService messageValueService;
|
||||
|
||||
@Resource
|
||||
private RedisTemplate<String,MessageValue> redisTemplate;
|
||||
|
||||
/**
|
||||
* 报文数据列表查询
|
||||
* @param messageValueReq
|
||||
|
@ -51,6 +56,7 @@ public class MessageValueController extends BaseController {
|
|||
@PostMapping("/")
|
||||
@Operation(summary = "添加报文数据", description = "新增报文数据")
|
||||
public Result<String> save(@RequestBody MessageValueAddReq messageValueAddReq){
|
||||
redisTemplate.boundValueOps("messageValue:" +messageValueAddReq.getTemplateId()).increment(1);
|
||||
messageValueService.save(MessageValue.addBuild(messageValueAddReq));
|
||||
return Result.success("添加成功");
|
||||
}
|
||||
|
@ -74,4 +80,14 @@ public class MessageValueController extends BaseController {
|
|||
public void test(String str){
|
||||
messageValueService.test(str);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping({"/findByTemplateId/{stringVin}"})
|
||||
@Operation(
|
||||
summary = "根据车辆类型查询报文模版ID",
|
||||
description = "根据车辆类型查询报文模版ID"
|
||||
)
|
||||
public Result<Long> findByTemplateId(@PathVariable("stringVin") String stringVin) {
|
||||
return Result.success(this.messageValueService.findByTemplateId(stringVin), "查询成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 车辆基础信息Controller
|
||||
* @author Li HD
|
||||
* @author LiHD
|
||||
* @date 2024-09-18
|
||||
*/
|
||||
@RestController
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.mapper;
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.domain.MessageValue;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* 消息值表(MessageValue)表数据库访问层
|
||||
|
@ -13,4 +14,6 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
*/
|
||||
@Mapper
|
||||
public interface MessageValueMapper extends BaseMapper<MessageValue> {
|
||||
@Select({"SELECT sct.message_template_id FROM sys_car sc LEFT JOIN sys_car_type sct on sct.id = sc.car_type WHERE sc.car_vin = ${stringVin}"})
|
||||
Long findByTemplateId(String stringVin);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 车辆基础信息Mapper接口
|
||||
* @author Li HD
|
||||
* @author LiHD
|
||||
* @date 2024-09-18
|
||||
*/
|
||||
@Mapper
|
||||
|
|
|
@ -27,5 +27,6 @@ public interface MessageValueService extends IService<MessageValue> {
|
|||
* @param str
|
||||
*/
|
||||
void test(String str);
|
||||
Long findByTemplateId(String stringVin);
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 车辆基础信息Service接口
|
||||
* @author Li HD
|
||||
* @author LiHD
|
||||
* @date 2024-09-18
|
||||
*/
|
||||
public interface SysCarService extends IService<SysCar> {
|
||||
|
|
|
@ -9,9 +9,12 @@ import com.muyu.domain.req.MessageValueReq;
|
|||
import com.muyu.domain.resp.MessageValueListResp;
|
||||
import com.muyu.mapper.MessageValueMapper;
|
||||
import com.muyu.service.MessageValueService;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 消息值服务实现类
|
||||
|
@ -25,6 +28,11 @@ public class MessageValueServiceImpl
|
|||
extends ServiceImpl<MessageValueMapper, MessageValue>
|
||||
implements MessageValueService {
|
||||
|
||||
@Resource
|
||||
private MessageValueMapper messageValueMapper;
|
||||
|
||||
|
||||
private RedisTemplate<String, MessageValue> redisTemplate;
|
||||
/**
|
||||
* 查询所有消息值
|
||||
* @param messageValueReq
|
||||
|
@ -46,6 +54,10 @@ public class MessageValueServiceImpl
|
|||
}
|
||||
|
||||
List<MessageValue> list = this.list(queryWrapper);
|
||||
for (MessageValue messageValue : list){
|
||||
redisTemplate.boundValueOps("messageValue:" + messageValue.getTemplateId()).set(messageValue);
|
||||
}
|
||||
|
||||
return list.stream()
|
||||
.map(messageValue -> MessageValueListResp.valueBuild(
|
||||
messageValue
|
||||
|
@ -68,5 +80,10 @@ public class MessageValueServiceImpl
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long findByTemplateId(String stringVin) {
|
||||
return messageValueMapper.findByTemplateId(stringVin);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* 车辆基础信息Service业务层处理
|
||||
* @author Li HD
|
||||
* @author LiHD
|
||||
* @date 2024-09-18
|
||||
*/
|
||||
@Service
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
</parent>
|
||||
|
||||
<artifactId>cloud-modules-enterprise</artifactId>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
<description>
|
||||
cloud-modules-enterprise
|
||||
|
@ -23,7 +22,6 @@
|
|||
</properties>
|
||||
|
||||
<modules>
|
||||
<module>enterpise-client</module>
|
||||
<module>enterpise-common</module>
|
||||
<module>enterpise-remote</module>
|
||||
<module>enterpise-service</module>
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.gen.controller;
|
|||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.text.Convert;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
|
@ -31,8 +32,7 @@ import java.util.Map;
|
|||
*/
|
||||
@RequestMapping("/gen")
|
||||
@RestController
|
||||
public class GenController extends BaseController
|
||||
{
|
||||
public class GenController extends BaseController<BaseEntity> {
|
||||
@Resource
|
||||
private IGenTableService genTableService;
|
||||
|
||||
|
|
|
@ -2,6 +2,8 @@ package ${packageName}.controller;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import javax.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
@ -33,8 +35,7 @@ import com.muyu.common.core.web.page.TableDataInfo;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/${businessName}")
|
||||
public class ${ClassName}Controller extends BaseController
|
||||
{
|
||||
public class ${ClassName}Controller extends BaseController<BaseEntity> {
|
||||
@Resource
|
||||
private I${ClassName}Service ${className}Service;
|
||||
|
||||
|
|
|
@ -0,0 +1,122 @@
|
|||
<?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.muyu</groupId>
|
||||
<artifactId>cloud-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-modules-parse</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 接口模块 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– XllJob定时任务 –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.muyu</groupId>-->
|
||||
<!-- <artifactId>cloud-common-xxl</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- mqtt监控者 -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>enterpise-remote</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>enterpise-common</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,24 @@
|
|||
package com.muyu.parse;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author xie ya ru
|
||||
* @Date 2024/9/28 12:26
|
||||
* @注释
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableCustomConfig
|
||||
//@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
|
||||
public class ParseApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ParseApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.muyu.parse.configure;
|
||||
|
||||
import com.muyu.parse.process.ProcessData;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author xie ya ru
|
||||
* @Date 2024/9/26 15:31
|
||||
* @注释
|
||||
*/
|
||||
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MqttConsumerConfig {
|
||||
|
||||
String topic = "xxx";
|
||||
String content = "Message from MqttPublishSample";
|
||||
int qos = 2;
|
||||
String broker = "tcp://123.57.152.124:1883";
|
||||
String clientId = "xyr1";
|
||||
|
||||
@PostConstruct
|
||||
public String connect() {
|
||||
final String vin= "";
|
||||
try {
|
||||
MqttClient sampleClient = new MqttClient(broker, clientId, new MemoryPersistence());
|
||||
MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||
//是否清空session
|
||||
connOpts.setCleanSession(true);
|
||||
System.out.println("Connecting to broker: " + broker);
|
||||
//连接
|
||||
sampleClient.connect(connOpts);
|
||||
sampleClient.subscribe(topic, qos);
|
||||
sampleClient.setCallback(new MqttCallback() {
|
||||
//连接丢失(报错)
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
log.error("error:{}", throwable.getMessage(), throwable);
|
||||
}
|
||||
|
||||
//消息已经接收到
|
||||
@Override
|
||||
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
||||
String s1 = new String(mqttMessage.getPayload());
|
||||
System.out.println("接收到的主题是:" + s + "内容是:{}" + s1);
|
||||
ProcessData.DataConversion(s1);
|
||||
|
||||
}
|
||||
|
||||
//交付完成
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||
|
||||
}
|
||||
});
|
||||
} catch (MqttException me) {
|
||||
System.out.println("reason " + me.getReasonCode());
|
||||
System.out.println("msg " + me.getMessage());
|
||||
System.out.println("loc " + me.getLocalizedMessage());
|
||||
System.out.println("cause " + me.getCause());
|
||||
System.out.println("excep " + me);
|
||||
me.printStackTrace();
|
||||
}
|
||||
|
||||
return vin;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.muyu.parse.process;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
|
||||
import com.muyu.domain.req.MessageValueReq;
|
||||
import com.muyu.domain.resp.MessageValueListResp;
|
||||
import com.muyu.parse.uitl.DataParseUtil;
|
||||
import com.muyu.remote.RemoteMessageValueService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author xie ya ru
|
||||
* @Date 2024/9/28 21:14
|
||||
* @注释
|
||||
*/
|
||||
@Log4j2
|
||||
public class ProcessData {
|
||||
|
||||
@Resource
|
||||
private static RemoteMessageValueService remoteMessageValueService;
|
||||
|
||||
@Resource
|
||||
private static RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
public static JSONObject DataConversion(String jsonVin ) {
|
||||
String vin = DataParseUtil.dataParsing(jsonVin);
|
||||
|
||||
Result<Long> byTemplateId = remoteMessageValueService.findByTemplateId(vin);
|
||||
|
||||
Long templateId = byTemplateId.getData();
|
||||
List<MessageValueListResp> templateList;
|
||||
try{
|
||||
//从Redis中获取报文模版信息
|
||||
if (redisTemplate.hasKey("messageValue:" + templateId)) {
|
||||
List<Object> list = redisTemplate.opsForList().range("messageValue:" + templateId, 0, -1);
|
||||
templateList = list.stream()
|
||||
.map(obj -> JSON.parseObject(obj.toString(), MessageValueListResp.class))
|
||||
.toList();
|
||||
log.info("Redis缓存查询成功");
|
||||
} else {
|
||||
|
||||
Result<List<MessageValueListResp>> byTemplate = remoteMessageValueService.findAll(MessageValueReq.builder().messageTemplateId(templateId).build());
|
||||
templateList = byTemplate.getData();
|
||||
templateList.forEach(
|
||||
listResp ->
|
||||
redisTemplate.opsForList().rightPush(
|
||||
"messageValue:" + templateId, JSON.toJSONString(listResp)
|
||||
)
|
||||
);
|
||||
}
|
||||
log.info("数据库查询成功");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("获取报文模板失败");
|
||||
}
|
||||
//判断报文模板列表不为空
|
||||
if (templateList.isEmpty()) {
|
||||
throw new RuntimeException("报文模版为空");
|
||||
}
|
||||
//存储报文模版解析后的数据
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
for (MessageValueListResp messageValue : templateList) {
|
||||
//起始位下标
|
||||
Integer startIndex = messageValue.getMessageStartIndex() - 1;
|
||||
//结束位下标
|
||||
Integer endIndex = messageValue.getMessageEndIndex();
|
||||
//根据报文模版截取数据
|
||||
String value = vin.substring(startIndex, endIndex);
|
||||
//存入数据
|
||||
System.out.println("标签"+messageValue.getMessageLabel()+"值"+value);
|
||||
jsonObject.put(messageValue.getMessageLabel(), value);
|
||||
}
|
||||
return jsonObject;
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.muyu.parse.uitl;
|
||||
|
||||
|
||||
/**
|
||||
* @version 1.0
|
||||
* @Author xie ya ru
|
||||
* @Date 2024/9/28 16:48
|
||||
* @注释
|
||||
*/
|
||||
|
||||
public class DataParseUtil {
|
||||
public static final Integer STARTPOSITION = 0;
|
||||
|
||||
public static final Integer ENDPOSITION = 18;
|
||||
|
||||
public static final Integer INDEX = 16;
|
||||
public static String dataParsing(String jsonVin){
|
||||
jsonVin = jsonVin.substring(STARTPOSITION,ENDPOSITION);
|
||||
StringBuilder asciiString = new StringBuilder();
|
||||
String[] split = jsonVin.split(" ");
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
//十六进制转换为十进制
|
||||
int decimal = Integer.parseInt(split[i],INDEX);
|
||||
//将十进制整数转换为字符
|
||||
char character =(char)decimal;
|
||||
//添加字符到ASCII 字符串
|
||||
asciiString.append(character);
|
||||
}
|
||||
System.out.println(asciiString.toString());
|
||||
return asciiString.toString();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-parse"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-parse"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.sky.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 使用gRpc将日志发送到skywalking服务端 -->
|
||||
<appender name="GRPC_LOG" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
|
||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||
<Pattern>${log.sky.pattern}</Pattern>
|
||||
</layout>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="GRPC_LOG"/>
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-parse"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.sky.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 使用gRpc将日志发送到skywalking服务端 -->
|
||||
<appender name="GRPC_LOG" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
|
||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||
<Pattern>${log.sky.pattern}</Pattern>
|
||||
</layout>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="GRPC_LOG"/>
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -3,6 +3,7 @@ package com.muyu.system.controller;
|
|||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
|
@ -28,7 +29,7 @@ import java.util.List;
|
|||
@RestController
|
||||
@RequestMapping("/config")
|
||||
@Tag(name = "SysConfigController", description = "系统参数配置")
|
||||
public class SysConfigController extends BaseController {
|
||||
public class SysConfigController extends BaseController<BaseEntity> {
|
||||
|
||||
@Autowired
|
||||
private SysConfigService configService;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.muyu.common.core.constant.UserConstants;
|
|||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
|
@ -24,7 +25,7 @@ import java.util.List;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dept")
|
||||
public class SysDeptController extends BaseController {
|
||||
public class SysDeptController extends BaseController<BaseEntity> {
|
||||
|
||||
@Autowired
|
||||
private SysDeptService deptService;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.muyu.common.core.utils.StringUtils;
|
|||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
|
@ -27,7 +28,7 @@ import java.util.List;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dict/data")
|
||||
public class SysDictDataController extends BaseController {
|
||||
public class SysDictDataController extends BaseController<BaseEntity> {
|
||||
@Autowired
|
||||
private SysDictDataService dictDataService;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.system.controller;
|
|||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
|
@ -24,7 +25,7 @@ import java.util.List;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/dict/type")
|
||||
public class SysDictTypeController extends BaseController {
|
||||
public class SysDictTypeController extends BaseController<BaseEntity> {
|
||||
@Autowired
|
||||
private SysDictTypeService dictTypeService;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.muyu.common.core.constant.CacheConstants;
|
|||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
|
@ -25,7 +26,7 @@ import java.util.List;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/logininfor")
|
||||
public class SysLogininforController extends BaseController {
|
||||
public class SysLogininforController extends BaseController<BaseEntity> {
|
||||
@Autowired
|
||||
private SysLogininforService logininforService;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.muyu.common.core.constant.UserConstants;
|
|||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||
|
@ -24,7 +25,7 @@ import java.util.List;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/menu")
|
||||
public class SysMenuController extends BaseController {
|
||||
public class SysMenuController extends BaseController<BaseEntity> {
|
||||
@Autowired
|
||||
private SysMenuService menuService;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.controller;
|
|||
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
|
@ -22,7 +23,7 @@ import java.util.List;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/notice")
|
||||
public class SysNoticeController extends BaseController {
|
||||
public class SysNoticeController extends BaseController<BaseEntity> {
|
||||
@Autowired
|
||||
private SysNoticeService noticeService;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.system.controller;
|
|||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
|
@ -23,7 +24,7 @@ import java.util.List;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/operlog")
|
||||
public class SysOperlogController extends BaseController {
|
||||
public class SysOperlogController extends BaseController<BaseEntity> {
|
||||
@Autowired
|
||||
private SysOperLogService operLogService;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.system.controller;
|
|||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
|
@ -24,7 +25,7 @@ import java.util.List;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/post")
|
||||
public class SysPostController extends BaseController {
|
||||
public class SysPostController extends BaseController<BaseEntity> {
|
||||
@Autowired
|
||||
private SysPostService postService;
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.muyu.common.core.utils.StringUtils;
|
|||
import com.muyu.common.core.utils.file.FileTypeUtils;
|
||||
import com.muyu.common.core.utils.file.MimeTypeUtils;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
import com.muyu.common.security.service.TokenService;
|
||||
|
@ -28,7 +29,7 @@ import java.util.Arrays;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user/profile")
|
||||
public class SysProfileController extends BaseController {
|
||||
public class SysProfileController extends BaseController<BaseEntity> {
|
||||
@Autowired
|
||||
private SysUserService userService;
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.system.controller;
|
|||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
|
@ -30,7 +31,7 @@ import java.util.List;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/role")
|
||||
public class SysRoleController extends BaseController {
|
||||
public class SysRoleController extends BaseController<BaseEntity> {
|
||||
@Autowired
|
||||
private SysRoleService roleService;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.muyu.common.core.domain.Result;
|
|||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
|
@ -37,7 +38,7 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class SysUserController extends BaseController {
|
||||
public class SysUserController extends BaseController<BaseEntity> {
|
||||
@Autowired
|
||||
private SysUserService userService;
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.muyu.common.core.constant.CacheConstants;
|
|||
import com.muyu.common.core.utils.StringUtils;
|
||||
import com.muyu.common.core.web.controller.BaseController;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.web.domain.BaseEntity;
|
||||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.log.annotation.Log;
|
||||
import com.muyu.common.log.enums.BusinessType;
|
||||
|
@ -27,7 +28,7 @@ import java.util.List;
|
|||
*/
|
||||
@RestController
|
||||
@RequestMapping("/online")
|
||||
public class SysUserOnlineController extends BaseController {
|
||||
public class SysUserOnlineController extends BaseController<BaseEntity> {
|
||||
@Autowired
|
||||
private SysUserOnlineService userOnlineService;
|
||||
|
||||
|
|
|
@ -0,0 +1,162 @@
|
|||
<?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.muyu</groupId>
|
||||
<artifactId>cloud-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-modules-vehicleGateway</artifactId>
|
||||
|
||||
<description>
|
||||
cloud-modules-vehicleGateway车辆网关模块
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<mqtt.version>1.2.5</mqtt.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- MQTT -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>${mqtt.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 阿里云 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ecs20140526</artifactId>
|
||||
<version>5.1.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-openapi</artifactId>
|
||||
<version>0.3.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-console</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>tea-util</artifactId>
|
||||
<version>0.2.21</version>
|
||||
</dependency>
|
||||
|
||||
<!-- <!– Cloud Gateway –>-->
|
||||
<!-- <!– SpringCloud Gateway –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.cloud</groupId>-->
|
||||
<!-- <artifactId>spring-cloud-starter-gateway</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– SpringCloud Alibaba Sentinel Gateway –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba.cloud</groupId>-->
|
||||
<!-- <artifactId>spring-cloud-alibaba-sentinel-gateway</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– Sentinel Datasource Nacos –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.alibaba.csp</groupId>-->
|
||||
<!-- <artifactId>sentinel-datasource-nacos</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– SpringCloud Loadbalancer –>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.cloud</groupId>-->
|
||||
<!-- <artifactId>spring-cloud-loadbalancer</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <!– MuYu Common Redis–>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.muyu</groupId>-->
|
||||
<!-- <artifactId>cloud-common-redis</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.github.xiaoymin</groupId>-->
|
||||
<!-- <artifactId>knife4j-gateway-spring-boot-starter</artifactId>-->
|
||||
<!-- <version>4.5.0</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- MuYu Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 接口模块 -->
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-api-doc</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,22 @@
|
|||
package com.muyu;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* 车辆网关启动程序
|
||||
*
|
||||
* @author LiHD
|
||||
*/
|
||||
@Log4j2
|
||||
@EnableCustomConfig
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class CloudVehicleGatewayApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CloudVehicleGatewayApplication.class,args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,108 @@
|
|||
package com.muyu.vehicleGateway;
|
||||
|
||||
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 清除阿里云ECS实例
|
||||
* @ClassName ClearInstance
|
||||
* @author LiHD
|
||||
* @Date 2024/9/28 22:29
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class ClearInstance implements DisposableBean {
|
||||
|
||||
/**
|
||||
* <b>description</b> :
|
||||
* <p>使用AK&SK初始化账号Client</p>
|
||||
* @return Client
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static com.aliyun.ecs20140526.Client createClient() throws Exception {
|
||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
||||
// 建议使用更安全的 STS 方式,更多鉴权访问方式请参见:https://help.aliyun.com/document_detail/378657.html。
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||
.setAccessKeyId("LTAI5tM4LSerzWQ9wUPXgybq")
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
.setAccessKeySecret("hkiPr0QwkKMZauhXucgg1SDriXUW0Q");
|
||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||
config.endpoint = "ecs.cn-beijing.aliyuncs.com";
|
||||
return new com.aliyun.ecs20140526.Client(config);
|
||||
}
|
||||
|
||||
public static void clearInstance() throws Exception {
|
||||
|
||||
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||
com.aliyun.ecs20140526.Client client = ClearInstance.createClient();
|
||||
|
||||
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
|
||||
.setRegionId("cn-beijing");
|
||||
|
||||
//创建运行时选择对象,用于配置运行时的选项参数
|
||||
RuntimeOptions runtimeOptions = new RuntimeOptions();
|
||||
|
||||
//获取实例列表
|
||||
DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtimeOptions);
|
||||
|
||||
//提取实例ID集合
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
|
||||
|
||||
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()) {
|
||||
list.add(instance.getInstanceId());
|
||||
}
|
||||
log.info("Instance IDs: " + list);
|
||||
// 创建删除实例请求对象,并设置请求参数
|
||||
com.aliyun.ecs20140526.models.DeleteInstancesRequest deleteInstancesRequest = new com.aliyun.ecs20140526.models.DeleteInstancesRequest()
|
||||
// 设置地域ID,指定删除实例的地域
|
||||
.setRegionId("cn-beijing")
|
||||
// 设置DryRun为true,用于验证请求是否可以成功,但不实际执行删除操作
|
||||
.setDryRun(false)
|
||||
// 设置Force为true,表示即使实例有正在运行的任务,也强制删除实例
|
||||
.setForce(true)
|
||||
// 设置TerminateSubscription为true,表示删除按订阅付费的实例时终止订阅
|
||||
.setTerminateSubscription(true)
|
||||
.setInstanceId(list);
|
||||
|
||||
// 创建运行时选项对象,用于配置运行时的选项参数
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
client.deleteInstancesWithOptions(deleteInstancesRequest, runtime);
|
||||
} catch (TeaException error) {
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// 错误 message
|
||||
System.out.println(error.getMessage());
|
||||
// 诊断地址
|
||||
System.out.println(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// 错误 message
|
||||
System.out.println(error.getMessage());
|
||||
// 诊断地址
|
||||
System.out.println(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
log.info("开始执行删除实例方法");
|
||||
clearInstance();
|
||||
log.info("删除实例方法执行完毕");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package com.muyu.vehicleGateway;
|
||||
|
||||
import com.aliyun.tea.TeaException;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 创建阿里云ECS实例
|
||||
* @className Sample
|
||||
* @author LiHD
|
||||
* @date 2024/9/28 19:02
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
public class CreateInstance implements ApplicationRunner{
|
||||
|
||||
/**
|
||||
* <b>description</b> :
|
||||
* <p>使用AK&SK初始化账号Client</p>
|
||||
* @return Client
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public static com.aliyun.ecs20140526.Client createClient() throws Exception {
|
||||
// 工程代码泄露可能会导致 AccessKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考。
|
||||
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_ID。
|
||||
.setAccessKeyId("LTAI5tM4LSerzWQ9wUPXgybq")
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
.setAccessKeySecret("hkiPr0QwkKMZauhXucgg1SDriXUW0Q");
|
||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||
config.endpoint = "ecs.cn-beijing.aliyuncs.com";
|
||||
return new com.aliyun.ecs20140526.Client(config);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本程序的入口点
|
||||
* 主要功能是创建阿里云ECS实例
|
||||
*
|
||||
* @throws Exception 如果执行过程中发生错误则抛出异常
|
||||
*/
|
||||
public static void sample() throws Exception {
|
||||
|
||||
// 创建阿里云ECS客户端
|
||||
com.aliyun.ecs20140526.Client client = CreateInstance.createClient();
|
||||
|
||||
// 配置系统盘参数
|
||||
com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk = new com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk()
|
||||
.setSize("40") // 设置系统盘大小为40GB
|
||||
.setCategory("cloud_essd"); // 设置系统盘类型为cloud_essd
|
||||
|
||||
// 创建创建实例请求对象并设置参数
|
||||
com.aliyun.ecs20140526.models.RunInstancesRequest runInstancesRequest = new com.aliyun.ecs20140526.models.RunInstancesRequest()
|
||||
.setRegionId("cn-beijing") // 设置地域ID
|
||||
.setImageId("m-2ze801i45fclmf1qwes5") // 设置镜像ID
|
||||
.setInstanceType("ecs.e-c1m1.large") // 设置实例类型
|
||||
.setSecurityGroupId("sg-2ze63acc0bas9vjm5gtv") // 设置安全组ID
|
||||
.setVSwitchId("vsw-2ze028qk4xpwk3i0ggket") // 设置虚拟交换机ID
|
||||
.setInstanceName("server-mqtt") // 设置实例名称
|
||||
.setInstanceChargeType("PostPaid") // 设置实例付费类型为后付费按量付费
|
||||
.setSystemDisk(systemDisk) // 设置系统盘配置
|
||||
.setHostName("root") // 设置主机名
|
||||
.setPassword("Lhd.123456") // 设置实例密码
|
||||
.setAmount(1) // 设置创建实例的数量
|
||||
.setInternetChargeType("PayByTraffic") // 设置互联网计费类型为按流量计费
|
||||
.setInternetMaxBandwidthOut(5); // 设置最大出带宽为5Mbps
|
||||
|
||||
// 创建运行时选项对象
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
|
||||
// 尝试执行创建实例请求
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
client.runInstancesWithOptions(runInstancesRequest, runtime);
|
||||
} catch (TeaException error) {
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// 错误 message
|
||||
System.out.println(error.getMessage());
|
||||
// 诊断地址
|
||||
System.out.println(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// 错误 message
|
||||
System.out.println(error.getMessage());
|
||||
// 诊断地址
|
||||
System.out.println(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
log.info("开始执行创建实例方法");
|
||||
sample();
|
||||
log.info("创建实例方法执行完毕");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.muyu.vehicleGateway;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
|
||||
@Log4j2
|
||||
@Slf4j
|
||||
public class MqttPublishSample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// 定义一个用于MQTT消息发布的示例程序
|
||||
String topic = "vehicleGateway";
|
||||
String content = "Message from MqttPublishSample";
|
||||
int qos = 2;
|
||||
String broker = "tcp://123.57.152.124:1883";
|
||||
String clientId = "JavaSample";
|
||||
|
||||
try {
|
||||
// 创建MQTT客户端并连接到指定的broker
|
||||
MqttClient sampleClient = new MqttClient(broker, clientId);
|
||||
MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||
connOpts.setCleanSession(true);
|
||||
System.out.println("Connecting to broker: "+broker);
|
||||
sampleClient.connect(connOpts);
|
||||
sampleClient.subscribe(topic,0);
|
||||
// 设置回调处理
|
||||
sampleClient.setCallback(new MqttCallback() {
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
// 连接丢失的处理
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
||||
// 消息到达的处理
|
||||
System.out.println(new String(mqttMessage.getPayload()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||
// 消息发送完成的处理
|
||||
}
|
||||
});
|
||||
} catch(MqttException me) {
|
||||
// 处理MQTT异常
|
||||
System.out.println("reason "+me.getReasonCode());
|
||||
System.out.println("msg "+me.getMessage());
|
||||
System.out.println("loc "+me.getLocalizedMessage());
|
||||
System.out.println("cause "+me.getCause());
|
||||
System.out.println("excep "+me);
|
||||
me.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,68 @@
|
|||
package com.muyu.vehicleGateway.vehicle;
|
||||
|
||||
import com.muyu.vehicleGateway.vehicle.model.VehicleData;
|
||||
import com.muyu.vehicleGateway.vehicle.thread.VehicleThread;
|
||||
import com.muyu.vehicleGateway.web.domain.VehicleInfo;
|
||||
import com.muyu.vehicleGateway.web.domain.model.PositionModel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
/**
|
||||
* 车辆实例
|
||||
* @className VehicleInstance
|
||||
* @author LiHD
|
||||
* @date 2024/9/27 20:37
|
||||
*/
|
||||
@Data
|
||||
@Log4j2
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class VehicleInstance {
|
||||
|
||||
/**
|
||||
* 路线轨迹编码
|
||||
*/
|
||||
private String postitionCode;
|
||||
|
||||
/**
|
||||
* 路径队列
|
||||
*/
|
||||
@Builder.Default
|
||||
private LinkedBlockingQueue<PositionModel> positionQueue = new LinkedBlockingQueue<>();
|
||||
|
||||
/**
|
||||
* 车辆
|
||||
*/
|
||||
private VehicleInfo vehicleInfo;
|
||||
|
||||
/**
|
||||
* 实例数据
|
||||
*/
|
||||
private VehicleData vehicleData;
|
||||
|
||||
/**
|
||||
* 上一次定位点
|
||||
*/
|
||||
private PositionModel lastPosition;
|
||||
|
||||
/**
|
||||
* 车辆工作线程
|
||||
*/
|
||||
private VehicleThread vehicleThread;
|
||||
|
||||
/**
|
||||
* 获取当前车辆VIN
|
||||
* @return VIN
|
||||
*/
|
||||
public String getVin() {
|
||||
return this.vehicleInfo.getVin();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,539 @@
|
|||
package com.muyu.vehicleGateway.vehicle.model;
|
||||
|
||||
import com.muyu.vehicleGateway.web.domain.VehicleInfo;
|
||||
import com.muyu.vehicleGateway.web.util.VehicleUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @ClassName VehicleData
|
||||
* @Description 车辆模拟数据对象
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/27 22:11
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class VehicleData {
|
||||
|
||||
/**
|
||||
* VIN
|
||||
*/
|
||||
private String vin;
|
||||
|
||||
/**
|
||||
* 行驶路线
|
||||
*/
|
||||
private String drivingRoute;
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private String longitude;
|
||||
|
||||
/**
|
||||
* 维度
|
||||
*/
|
||||
private String latitude;
|
||||
|
||||
/**
|
||||
* 速度
|
||||
*/
|
||||
private String speed;
|
||||
|
||||
/**
|
||||
* 里程
|
||||
*/
|
||||
private BigDecimal mileage;
|
||||
|
||||
/**
|
||||
* 总电压
|
||||
*/
|
||||
private String voltage;
|
||||
|
||||
/**
|
||||
* 总电流
|
||||
*/
|
||||
private String current;
|
||||
|
||||
/**
|
||||
* 绝缘电阻
|
||||
*/
|
||||
private String resistance;
|
||||
|
||||
/**
|
||||
* 档位
|
||||
*/
|
||||
@Builder.Default
|
||||
private String gear = "P";
|
||||
|
||||
/**
|
||||
* 加速踏板行程值
|
||||
*/
|
||||
private String accelerationPedal;
|
||||
|
||||
/**
|
||||
* 制动踏板行程值
|
||||
*/
|
||||
private String brakePedal;
|
||||
|
||||
/**
|
||||
* 燃料消耗率
|
||||
*/
|
||||
private String fuelConsumptionRate;
|
||||
|
||||
/**
|
||||
* 电机控制器温度
|
||||
*/
|
||||
private String motorControllerTemperature;
|
||||
|
||||
/**
|
||||
* 电机转速
|
||||
*/
|
||||
private String motorSpeed;
|
||||
|
||||
/**
|
||||
* 电机转矩
|
||||
*/
|
||||
private String motorTorque;
|
||||
|
||||
/**
|
||||
* 电机温度
|
||||
*/
|
||||
private String motorTemperature;
|
||||
|
||||
/**
|
||||
* 电机电压
|
||||
*/
|
||||
private String motorVoltage;
|
||||
|
||||
/**
|
||||
* 电机电流
|
||||
*/
|
||||
private String motorCurrent;
|
||||
|
||||
/**
|
||||
* 动力电池剩余电量SOC
|
||||
*/
|
||||
private BigDecimal remainingBattery;
|
||||
|
||||
/**
|
||||
* 电池总容量
|
||||
*/
|
||||
private BigDecimal batteryLevel;
|
||||
|
||||
/**
|
||||
* 当前状态允许的最大反馈功率
|
||||
*/
|
||||
private String maximumFeedbackPower;
|
||||
|
||||
/**
|
||||
* 当前状态允许最大放电功率
|
||||
*/
|
||||
private String maximumDischargePower;
|
||||
|
||||
/**
|
||||
* BMS自检计数器
|
||||
*/
|
||||
private String selfCheckCounter;
|
||||
|
||||
/**
|
||||
* 动力电池充放电电流
|
||||
*/
|
||||
private String totalBatteryCurrent;
|
||||
|
||||
/**
|
||||
* 动力电池负载端总电压V3
|
||||
*/
|
||||
private String totalBatteryVoltage;
|
||||
|
||||
/**
|
||||
* 单次最大电压
|
||||
*/
|
||||
private String singleBatteryMaxVoltage;
|
||||
|
||||
/**
|
||||
* 单体电池最低电压
|
||||
*/
|
||||
private String singleBatteryMinVoltage;
|
||||
|
||||
/**
|
||||
* 单体电池最高温度
|
||||
*/
|
||||
private String singleBatteryMaxTemperature;
|
||||
|
||||
/**
|
||||
* 单体电池最低温度
|
||||
*/
|
||||
private String singleBatteryMinTemperature;
|
||||
|
||||
/**
|
||||
* 动力电池可用容量
|
||||
*/
|
||||
private String availableBatteryCapacity;
|
||||
|
||||
/**
|
||||
* 车辆状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int vehicleStatus = 1;
|
||||
|
||||
/**
|
||||
* 充电状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int chargingStatus = 1;
|
||||
|
||||
/**
|
||||
* 运行状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int operatingStatus = 1;
|
||||
|
||||
/**
|
||||
* SOC
|
||||
*/
|
||||
@Builder.Default
|
||||
private int socStatus = 1;
|
||||
|
||||
/**
|
||||
* 可充电储能装置工作状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int chargingEnergyStorageStatus = 1;
|
||||
|
||||
/**
|
||||
* 驱动电机状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int driveMotorStatus = 1;
|
||||
|
||||
/**
|
||||
* 定位是否有效
|
||||
*/
|
||||
@Builder.Default
|
||||
private int positionStatus = 1;
|
||||
|
||||
/**
|
||||
* EAS(汽车防盗系统)状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int easStatus = 1;
|
||||
|
||||
/**
|
||||
* PTC(电动加热器)状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int ptcStatus = 1;
|
||||
|
||||
/**
|
||||
* EPS(电动助力系统)状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int epsStatus = 1;
|
||||
|
||||
/**
|
||||
* ABS(防抱死)状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int absStatus = 1;
|
||||
|
||||
/**
|
||||
* MCU(电机/逆变器)状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int mcuStatus = 1;
|
||||
|
||||
/**
|
||||
* 动力电池加热状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int heatingStatus = 1;
|
||||
|
||||
/**
|
||||
* 动力电池当前状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int batteryStatus = 1;
|
||||
|
||||
/**
|
||||
* 动力电池保温状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int batteryInsulationStatus = 1;
|
||||
|
||||
/**
|
||||
* DCDC(电力交换系统)状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int dcdcStatus = 1;
|
||||
|
||||
/**
|
||||
* CHG(充电机)状态
|
||||
*/
|
||||
@Builder.Default
|
||||
private int chgStatus = 1;
|
||||
|
||||
/**
|
||||
* 车辆状态 报文
|
||||
*/
|
||||
private String vehicleStatusMsg;
|
||||
/**
|
||||
* 智能硬件 报文
|
||||
*/
|
||||
private String smartHardwareMsg;
|
||||
/**
|
||||
* 电池报文
|
||||
*/
|
||||
private String batteryMsg;
|
||||
|
||||
public String getMsg(){
|
||||
//第一位VIN
|
||||
return vin +
|
||||
// 当前时间戳
|
||||
System.currentTimeMillis() +
|
||||
//第二位经度 longitude latitude
|
||||
getValue(longitude, 11) +
|
||||
//第三位维度 longitude latitude
|
||||
getValue(latitude, 10) +
|
||||
//车速
|
||||
getValue(speed, 6) +
|
||||
//总里程
|
||||
getValue(mileage == null ? "" : mileage.toString(), 11) +
|
||||
// 总电压
|
||||
getValue(voltage, 6) +
|
||||
//总电流
|
||||
getValue(current, 5) +
|
||||
//绝缘电阻 79 - 87
|
||||
getValue(resistance, 9) +
|
||||
//档位
|
||||
(gear == null ? "D" : gear) +
|
||||
// 加速踏板行程值
|
||||
getValue(accelerationPedal, 2) +
|
||||
// 制动踏板行程值
|
||||
getValue(brakePedal, 2) +
|
||||
// 燃料消耗率
|
||||
getValue(fuelConsumptionRate, 5) +
|
||||
//电机控制器温度
|
||||
getValue(motorControllerTemperature, 6) +
|
||||
//电机转速
|
||||
getValue(motorSpeed, 5) +
|
||||
//点击转矩
|
||||
getValue(motorTorque, 4) +
|
||||
//电机温度
|
||||
getValue(motorTemperature, 6) +
|
||||
//电机电压
|
||||
getValue(motorVoltage, 5) +
|
||||
//电机电流
|
||||
getValue(motorCurrent, 8) +
|
||||
//动力电池剩余电量SOC
|
||||
getValue(remainingBattery == null ? "" : remainingBattery.toString(), 6) +
|
||||
//当前状态允许的最大反馈功率
|
||||
getValue(maximumFeedbackPower, 6) +
|
||||
//当前状态允许最大放电功率
|
||||
getValue(maximumDischargePower, 6) +
|
||||
//BMS自检计数器
|
||||
getValue(selfCheckCounter, 2) +
|
||||
//动力电池充放电电流
|
||||
getValue(totalBatteryCurrent, 5) +
|
||||
//动力电池负载端总电压V3
|
||||
getValue(totalBatteryVoltage, 6) +
|
||||
//单次最大电压
|
||||
getValue(singleBatteryMaxVoltage, 4) +
|
||||
//单体电池最低电压
|
||||
getValue(singleBatteryMinVoltage, 4) +
|
||||
//单体电池最高温度
|
||||
getValue(singleBatteryMaxTemperature, 6) +
|
||||
//单体电池最低温度
|
||||
getValue(singleBatteryMinTemperature, 6) +
|
||||
//动力电池可用容量
|
||||
getValue(availableBatteryCapacity, 6) +
|
||||
//车辆状态
|
||||
vehicleStatus +
|
||||
//充电状态
|
||||
chargingStatus +
|
||||
//运行状态
|
||||
operatingStatus +
|
||||
//SOC
|
||||
socStatus +
|
||||
//可充电储能装置工作状态
|
||||
chargingEnergyStorageStatus +
|
||||
//驱动电机状态
|
||||
driveMotorStatus +
|
||||
//定位是否有效
|
||||
positionStatus +
|
||||
//EAS
|
||||
easStatus +
|
||||
//PTC
|
||||
ptcStatus +
|
||||
//EPS
|
||||
epsStatus +
|
||||
//ABS
|
||||
absStatus +
|
||||
//MCU
|
||||
mcuStatus +
|
||||
//动力电池加热状态
|
||||
heatingStatus +
|
||||
//动力电池当前状态
|
||||
batteryStatus +
|
||||
//动力电池保温状态
|
||||
batteryInsulationStatus +
|
||||
//DCDC
|
||||
dcdcStatus +
|
||||
//CHG
|
||||
chgStatus;
|
||||
}
|
||||
|
||||
public String getValue(String val , int valLength){
|
||||
if(val == null){
|
||||
val = "";
|
||||
}
|
||||
int length = val.length();
|
||||
if (length > valLength){
|
||||
return val.substring( 0 , valLength);
|
||||
}
|
||||
val = val + "0".repeat(valLength - length);
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
* 汽车对象构造企业VIN
|
||||
* @param vehicleInfo 汽车对象
|
||||
* @return 汽车数据对象
|
||||
*/
|
||||
public static VehicleData vehicleBuild (VehicleInfo vehicleInfo) {
|
||||
return VehicleData.builder()
|
||||
.vin(vehicleInfo.getVin())
|
||||
.gear("P")
|
||||
.remainingBattery(vehicleInfo.getRemainingBattery())
|
||||
.batteryLevel(vehicleInfo.getBatteryLevel())
|
||||
.mileage(vehicleInfo.getTotalMileage())
|
||||
.vehicleStatus(1)
|
||||
.chargingStatus(1)
|
||||
.operatingStatus(1)
|
||||
.socStatus(1)
|
||||
.chargingEnergyStorageStatus(1)
|
||||
.driveMotorStatus(1)
|
||||
.positionStatus(1)
|
||||
.easStatus(1)
|
||||
.ptcStatus(1)
|
||||
.epsStatus(1)
|
||||
.absStatus(1)
|
||||
.mcuStatus(1)
|
||||
.heatingStatus(1)
|
||||
.batteryStatus(1)
|
||||
.batteryInsulationStatus(1)
|
||||
.dcdcStatus(1)
|
||||
.chgStatus(1)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟基础项
|
||||
*/
|
||||
public void imitateBase(){
|
||||
// 总电压
|
||||
this.voltage = VehicleUtils.genValue(110, 750);
|
||||
// 总电流
|
||||
this.current = VehicleUtils.genValue(3, 50);
|
||||
// 绝缘电阻
|
||||
this.resistance = VehicleUtils.genValue(0,30000);
|
||||
// 加速踏板行程值
|
||||
this.accelerationPedal = VehicleUtils.genValue(0, 10);
|
||||
// 制动踏板行程值
|
||||
this.brakePedal = VehicleUtils.genValue(0, 10);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 模拟电机数据
|
||||
*/
|
||||
public void imitateMotor(){
|
||||
// 电机控制器温度
|
||||
this.motorControllerTemperature = VehicleUtils.genValue(0, 100);
|
||||
// 电机转速
|
||||
this.motorSpeed = VehicleUtils.genValue(0, 99999);
|
||||
// 电机转矩
|
||||
this.motorTorque = VehicleUtils.genValue(0, 1000);
|
||||
// 电机温度
|
||||
this.motorTemperature = VehicleUtils.genValue(0, 150);
|
||||
// 电机电压
|
||||
this.motorVoltage = VehicleUtils.genValue(110, 300);
|
||||
// 电机电流
|
||||
this.motorCurrent = VehicleUtils.genValue(0, 15000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟电池包数据
|
||||
*/
|
||||
public void imitateBatteryPack(){
|
||||
// 当前状态允许的最大反馈功率
|
||||
this.maximumFeedbackPower = VehicleUtils.genValue(0, 100);
|
||||
// 当前状态允许最大放电功率
|
||||
this.maximumDischargePower = VehicleUtils.genValue(0, 100);
|
||||
// BMS自检计数器
|
||||
this.selfCheckCounter = VehicleUtils.genValue(0, 15);
|
||||
// 动力电池充放电电流
|
||||
this.totalBatteryCurrent = VehicleUtils.genValue(0, 15);
|
||||
// 动力电池负载端总电压V3
|
||||
this.totalBatteryVoltage = VehicleUtils.genValue(220, 750);
|
||||
// 单体电池最高电压
|
||||
this.singleBatteryMaxVoltage = VehicleUtils.genValue(3, 5);
|
||||
// 单体电池最低电压
|
||||
this.singleBatteryMinVoltage = VehicleUtils.genValue(3, 5);
|
||||
// 单体电池最高温度
|
||||
this.singleBatteryMaxTemperature = VehicleUtils.genValue(0, 100);
|
||||
// 单体电池最低温度
|
||||
this.singleBatteryMinTemperature = VehicleUtils.genValue(0, 100);
|
||||
// 动力电池可用容量
|
||||
this.availableBatteryCapacity = VehicleUtils.genValue(0,100 );
|
||||
}
|
||||
/**
|
||||
车辆状态
|
||||
vehicleStatus;
|
||||
充电状态
|
||||
chargingStatus;
|
||||
运行状态
|
||||
operatingStatus;
|
||||
SOC
|
||||
socStatus;
|
||||
可充电储能装置工作状态
|
||||
chargingEnergyStorageStatus;
|
||||
驱动电机状态
|
||||
driveMotorStatus;
|
||||
定位是否有效
|
||||
positionStatus;
|
||||
*/
|
||||
|
||||
/**
|
||||
EAS(汽车防盗系统)状态
|
||||
easStatus;
|
||||
PTC(电动加热器)状态
|
||||
ptcStatus;
|
||||
EPS(电动助力系统)状态
|
||||
epsStatus;
|
||||
ABS(防抱死)状态
|
||||
absStatus;
|
||||
MCU(电机/逆变器)状态
|
||||
mcuStatus;
|
||||
*/
|
||||
|
||||
/**
|
||||
动力电池加热状态
|
||||
heatingStatus;
|
||||
动力电池当前状态
|
||||
batteryStatus;
|
||||
动力电池保温状态
|
||||
batteryInsulationStatus;
|
||||
DCDC(电力交换系统)状态
|
||||
dcdcStatus;
|
||||
CHG(充电机)状态
|
||||
chgStatus;
|
||||
*/
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.muyu.vehicleGateway.vehicle.thread;
|
||||
|
||||
import com.muyu.vehicleGateway.vehicle.VehicleInstance;
|
||||
import lombok.Data;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
/**
|
||||
* @ClassName VehicleThread
|
||||
* @Description TODO
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/27 22:44
|
||||
*/
|
||||
@Data
|
||||
@Log4j2
|
||||
public class VehicleThread implements Runnable {
|
||||
|
||||
/**
|
||||
* 是否停止线程
|
||||
*/
|
||||
private volatile boolean isStop = false;
|
||||
|
||||
/**
|
||||
* 车辆实例对象
|
||||
*/
|
||||
private VehicleInstance vehicleInstance;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (!isStop){
|
||||
log.info("{} - 上报数据",this.vehicleInstance.getVin());
|
||||
|
||||
}
|
||||
}catch (Throwable throwable){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void stop() {
|
||||
this.isStop = true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
package com.muyu.vehicleGateway.web.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.muyu.vehicleGateway.vehicle.VehicleInstance;
|
||||
import com.muyu.vehicleGateway.vehicle.model.VehicleData;
|
||||
import com.muyu.vehicleGateway.web.util.VehicleUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @ClassName VehicleInfo
|
||||
* @Description 车辆信息
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/26 23:48
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@TableName("vehicle_info")
|
||||
public class VehicleInfo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* VIN
|
||||
*/
|
||||
private String vin;
|
||||
|
||||
/**
|
||||
* VIN
|
||||
*/
|
||||
@TableField(value = "tenant_id", fill = FieldFill.INSERT)
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 报文模板id
|
||||
*/
|
||||
@TableField("message_template_id")
|
||||
private Long messageTemplateId;
|
||||
|
||||
/**
|
||||
* 电池剩余电量
|
||||
*/
|
||||
@TableField("remaining_battery")
|
||||
private BigDecimal remainingBattery;
|
||||
|
||||
/**
|
||||
* 电池电量
|
||||
*/
|
||||
@TableField("battery_level")
|
||||
private BigDecimal batteryLevel;
|
||||
|
||||
/**
|
||||
* 上一次经度
|
||||
*/
|
||||
@TableField("last_longitude")
|
||||
private String lastLongitude;
|
||||
|
||||
/**
|
||||
* 上一次纬度
|
||||
*/
|
||||
@TableField("last_latitude")
|
||||
private String lastLatitude;
|
||||
|
||||
/**
|
||||
* 总里程
|
||||
*/
|
||||
@TableField("total_mileage")
|
||||
private BigDecimal totalMileage;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 生成车辆数据
|
||||
*
|
||||
* @param messageTemplateId 报文ID
|
||||
* @return 车辆数据
|
||||
*/
|
||||
public static VehicleInfo gen(Supplier<Long> messageTemplateId) {
|
||||
return VehicleInfo.create(VehicleUtils.genVin(), messageTemplateId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成车辆数据
|
||||
*
|
||||
* @param vin
|
||||
* @param messageTemplateId
|
||||
* @return 车辆数据
|
||||
*/
|
||||
public static VehicleInfo create(String vin, Supplier<Long> messageTemplateId) {
|
||||
BigDecimal battery = VehicleUtils.genBattery();
|
||||
return VehicleInfo.builder()
|
||||
.vin(vin)
|
||||
.messageTemplateId(messageTemplateId.get())
|
||||
.createTime(new Date())
|
||||
.remainingBattery(battery)
|
||||
.batteryLevel(battery)
|
||||
.totalMileage(BigDecimal.ZERO)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static VehicleInfo instanceBuild(VehicleInstance vehicleInstance) {
|
||||
VehicleData vehicle = vehicleInstance.getVehicleData();
|
||||
return VehicleInfo.builder()
|
||||
.vin(vehicleInstance.getVin())
|
||||
.remainingBattery(vehicle.getRemainingBattery())
|
||||
.totalMileage(vehicle.getMileage())
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.muyu.vehicleGateway.web.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ClassName PositionModel
|
||||
* @Description 位置模型
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/27 20:59
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PositionModel {
|
||||
|
||||
/**
|
||||
* 经度
|
||||
*/
|
||||
private String longitude;
|
||||
|
||||
/**
|
||||
* 纬度
|
||||
*/
|
||||
private String latitude;
|
||||
|
||||
public static PositionModel strBuild(String positionStr) {
|
||||
String[] split = positionStr.split(",");
|
||||
return PositionModel.builder()
|
||||
.longitude(split[0])
|
||||
.latitude(split[1])
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.muyu.vehicleGateway.web.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.vehicleGateway.web.domain.VehicleInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @ClassName VehicleInfoMapper
|
||||
* @Description TODO
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/26 23:47
|
||||
*/
|
||||
@Mapper
|
||||
public interface VehicleInfoMapper extends BaseMapper<VehicleInfo> {
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.muyu.vehicleGateway.web.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.vehicleGateway.web.domain.VehicleInfo;
|
||||
import com.muyu.vehicleGateway.web.mapper.VehicleInfoMapper;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @ClassName VechileInfoServiceImpl
|
||||
* @Description TODO
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/26 23:46
|
||||
*/
|
||||
@Log4j2
|
||||
@Service
|
||||
public class VechileInfoServiceImpl extends ServiceImpl<VehicleInfoMapper, VehicleInfo> {
|
||||
|
||||
@Autowired
|
||||
private VehicleInfoMapper vehicleInfoMapper;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
package com.muyu.vehicleGateway.web.util;
|
||||
|
||||
import com.muyu.vehicleGateway.web.domain.model.PositionModel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @ClassName VehicleUtils
|
||||
* @Description TODO
|
||||
* @Author LiHD
|
||||
* @Date 2024/9/27 21:21
|
||||
*/
|
||||
|
||||
public class VehicleUtils {
|
||||
|
||||
/**
|
||||
* 生成VIN
|
||||
* @return 返回结果对象
|
||||
*/
|
||||
public static String genVin() {
|
||||
String characters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
Random random = new Random();
|
||||
StringBuilder sb = new StringBuilder(17);
|
||||
for (int i = 0; i < 17; i++) {
|
||||
int index = (int) (random.nextFloat() * characters.length());
|
||||
sb.append(characters.charAt(index));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static Random random = new Random();
|
||||
|
||||
/**
|
||||
* 生成电池额度
|
||||
* @return 电池额度
|
||||
*/
|
||||
public static BigDecimal genBattery(){
|
||||
return BigDecimal.valueOf(random.nextInt(60, 80) * 1000L);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 两点之间的距离
|
||||
* @param startPositionModel 开始定位点
|
||||
* @param endPositionModel 结束定位点
|
||||
* @return
|
||||
*/
|
||||
public static BigDecimal distance(PositionModel startPositionModel, PositionModel endPositionModel){
|
||||
double lon1 = Double.parseDouble(startPositionModel.getLongitude());
|
||||
double lat1 = Double.parseDouble(startPositionModel.getLatitude());
|
||||
double lon2 = Double.parseDouble(endPositionModel.getLongitude());
|
||||
double lat2 = Double.parseDouble(endPositionModel.getLatitude());
|
||||
double lon1Rad = Math.toRadians(lon1);
|
||||
double lat1Rad = Math.toRadians(lat1);
|
||||
double lon2Rad = Math.toRadians(lon2);
|
||||
double lat2Rad = Math.toRadians(lat2);
|
||||
double earthRadius = 6371; // 地球半径(以公里为单位)
|
||||
|
||||
double latDiff = lat2Rad - lat1Rad;
|
||||
double lonDiff = lon2Rad - lon1Rad;
|
||||
|
||||
double a = Math.sin(latDiff / 2) * Math.sin(latDiff / 2) +
|
||||
Math.cos(lat1Rad) * Math.cos(lat2Rad) *
|
||||
Math.sin(lonDiff / 2) * Math.sin(lonDiff / 2);
|
||||
|
||||
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
|
||||
|
||||
double distance = earthRadius * c;
|
||||
return BigDecimal.valueOf(distance).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成电池浮动
|
||||
* @return 电池浮动值
|
||||
*/
|
||||
public static BigDecimal batteryFloat(){
|
||||
Random rand = new Random();
|
||||
// 生成0.00-0.31之间的随机数
|
||||
double num = rand.nextDouble() * 0.31;
|
||||
// 加上0.90,得到0.90-1.21之间的随机数
|
||||
num += 0.90;
|
||||
// 保留两位小数
|
||||
num = (double) Math.round(num * 100) / 100;
|
||||
return BigDecimal.valueOf(num);
|
||||
}
|
||||
|
||||
/**
|
||||
* 给予开始和结束的值生成数据
|
||||
* @param start 起始范围
|
||||
* @param end 截止范围
|
||||
* @return 返回结果
|
||||
*/
|
||||
public static String genValue(int start, int end){
|
||||
Random rand = new Random();
|
||||
return String.valueOf(rand.nextInt(start, end));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,56 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9703
|
||||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 123.57.152.124:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: lhd
|
||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||
# Spring
|
||||
spring:
|
||||
amqp:
|
||||
deserialization:
|
||||
trust:
|
||||
all: true
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
application:
|
||||
# 应用名称
|
||||
name: cloud-vehicleGateway
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: ${nacos.addr}
|
||||
# nacos用户名
|
||||
username: ${nacos.user-name}
|
||||
# nacos密码
|
||||
password: ${nacos.password}
|
||||
# 命名空间
|
||||
namespace: ${nacos.namespace}
|
||||
config:
|
||||
# 服务注册地址
|
||||
server-addr: ${nacos.addr}
|
||||
# nacos用户名
|
||||
username: ${nacos.user-name}
|
||||
# nacos密码
|
||||
password: ${nacos.password}
|
||||
# 命名空间
|
||||
namespace: ${nacos.namespace}
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
# 系统共享配置
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
# 系统环境Config共享配置
|
||||
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.muyu.system.mapper: DEBUG
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-vehicleGateway"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-vehicleGateway"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.sky.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 使用gRpc将日志发送到skywalking服务端 -->
|
||||
<appender name="GRPC_LOG" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
|
||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||
<Pattern>${log.sky.pattern}</Pattern>
|
||||
</layout>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="GRPC_LOG"/>
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,81 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="logs/cloud-vehicleGateway"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.sky.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 使用gRpc将日志发送到skywalking服务端 -->
|
||||
<appender name="GRPC_LOG" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
|
||||
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||
<Pattern>${log.sky.pattern}</Pattern>
|
||||
</layout>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.muyu" level="info"/>
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn"/>
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="GRPC_LOG"/>
|
||||
<appender-ref ref="console"/>
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info"/>
|
||||
<appender-ref ref="file_error"/>
|
||||
</root>
|
||||
</configuration>
|
|
@ -13,6 +13,7 @@
|
|||
<module>cloud-modules-gen</module>
|
||||
<module>cloud-modules-file</module>
|
||||
<module>cloud-vx</module>
|
||||
<module>cloud-modules-parse</module>
|
||||
<module>cloud-modules-enterprise</module>
|
||||
</modules>
|
||||
|
||||
|
|
36
pom.xml
36
pom.xml
|
@ -23,6 +23,7 @@
|
|||
<spring-boot-admin.version>3.2.3</spring-boot-admin.version>
|
||||
<swagger.fox.version>3.0.0</swagger.fox.version>
|
||||
<swagger.core.version>1.6.2</swagger.core.version>
|
||||
<swagger.v3.version>2.2.8</swagger.v3.version>
|
||||
<tobato.version>1.27.2</tobato.version>
|
||||
<kaptcha.version>2.3.3</kaptcha.version>
|
||||
<pagehelper.boot.version>1.4.7</pagehelper.boot.version>
|
||||
|
@ -42,6 +43,8 @@
|
|||
<hutool.version>5.8.27</hutool.version>
|
||||
<knife4j-openapi3.version>4.1.0</knife4j-openapi3.version>
|
||||
<xxl-job-core.version>2.4.1</xxl-job-core.version>
|
||||
<mqtt.version>1.2.5</mqtt.version>
|
||||
<mybits-plus-business>4.1.65.Final</mybits-plus-business>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
|
@ -127,6 +130,11 @@
|
|||
<version>${swagger.core.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.swagger.core.v3</groupId>
|
||||
<artifactId>swagger-annotations-jakarta</artifactId>
|
||||
<version>${swagger.v3.version}</version>
|
||||
</dependency>
|
||||
<!-- 验证码 -->
|
||||
<dependency>
|
||||
<groupId>pro.fessional</groupId>
|
||||
|
@ -266,6 +274,33 @@
|
|||
<artifactId>cloud-common-rabbit</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>enterpise-common</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>enterpise-client</artifactId>
|
||||
<version>${muyu.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- mqtt -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>${mqtt.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- mybits-plus-business 业务依赖 -->
|
||||
<dependency>
|
||||
<groupId>io.netty</groupId>
|
||||
<artifactId>netty-all</artifactId>
|
||||
<version>${mybits-plus-business}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
@ -275,6 +310,7 @@
|
|||
<module>cloud-visual</module>
|
||||
<module>cloud-modules</module>
|
||||
<module>cloud-common</module>
|
||||
<module>cloud-common/cloud-common-cache</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
|
|
Loading…
Reference in New Issue