Compare commits
23 Commits
aeec2245c0
...
c42adb48cc
Author | SHA1 | Date |
---|---|---|
|
c42adb48cc | |
|
fe70b7d3c1 | |
|
54f0aee961 | |
|
015d7c0896 | |
|
d947e9fbff | |
|
0523876861 | |
|
f6c0b72e18 | |
|
9185f33c0c | |
|
748d4be165 | |
|
df1c9ad9e8 | |
|
1a65c83a56 | |
|
4ae60743fa | |
|
9486710ae8 | |
|
e6e7e58f95 | |
|
7063af945e | |
|
bb56bc2393 | |
|
00d1eb18d1 | |
|
6e4b268730 | |
|
43c74b9978 | |
|
f3c90ada2a | |
|
c34bec050c | |
|
a399073121 | |
|
fde90181c0 |
|
@ -34,7 +34,7 @@ public class TokenController {
|
|||
@PostMapping("login")
|
||||
public Result<?> login (@RequestBody LoginBody form) {
|
||||
// 用户登录
|
||||
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword());
|
||||
LoginUser userInfo = sysLoginService.login(form.getUsername(), form.getPassword(),form.getFirmName());
|
||||
// 获取登录token
|
||||
return Result.success(tokenService.createToken(userInfo));
|
||||
}
|
||||
|
|
|
@ -17,7 +17,18 @@ public class LoginBody {
|
|||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
private String firmName;
|
||||
|
||||
public String getFirmName() {
|
||||
return firmName;
|
||||
}
|
||||
|
||||
public void setFirmName(String firmName) {
|
||||
this.firmName = firmName;
|
||||
}
|
||||
|
||||
public String getUsername () {
|
||||
return username;
|
||||
|
|
|
@ -14,7 +14,7 @@ import com.muyu.common.core.utils.ip.IpUtils;
|
|||
import com.muyu.common.redis.service.RedisService;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.Firm;
|
||||
import com.muyu.common.system.remote.RemoteFirmService;
|
||||
import com.muyu.common.system.domain.SysUserMessage;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
|
@ -31,9 +31,6 @@ public class SysLoginService {
|
|||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
|
||||
@Autowired
|
||||
private RemoteFirmService remoteFirmService;
|
||||
|
||||
@Autowired
|
||||
private SysPasswordService passwordService;
|
||||
|
||||
|
@ -46,7 +43,7 @@ public class SysLoginService {
|
|||
/**
|
||||
* 登录
|
||||
*/
|
||||
public LoginUser login (String username, String password) {
|
||||
public LoginUser login (String username, String password,String firmName) {
|
||||
// 用户名或密码为空 错误
|
||||
if (StringUtils.isAnyBlank(username, password)) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户/密码必须填写");
|
||||
|
@ -71,7 +68,24 @@ public class SysLoginService {
|
|||
throw new ServiceException("很遗憾,访问IP已被列入系统黑名单");
|
||||
}
|
||||
// 查询用户信息
|
||||
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||
Result<LoginUser> userResult = null;
|
||||
//根据企业名称查询数据源
|
||||
if (StringUtils.isNotEmpty(firmName)){
|
||||
Result<String> result = remoteUserService.selectByfirmName(firmName);
|
||||
if (result.getData()!=null){
|
||||
SysUserMessage sysUserMessage = new SysUserMessage();
|
||||
sysUserMessage.setUsername(username);
|
||||
sysUserMessage.setPassword(password);
|
||||
sysUserMessage.setDatabaseName(result.getData());
|
||||
//查询这个数据源中的登录账号和密码
|
||||
userResult = remoteUserService.selectuser(sysUserMessage);
|
||||
}
|
||||
}
|
||||
// userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
|
||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||
|
@ -118,7 +132,7 @@ public class SysLoginService {
|
|||
throw new ServiceException("密码长度必须在5到20个字符之间");
|
||||
}
|
||||
String firmName = registerBody.getFirmName();
|
||||
Result<Firm> byFirmName = remoteFirmService.findByFirmName(firmName);
|
||||
Result<Firm> byFirmName = remoteUserService.findByFirmName(firmName);
|
||||
Firm data = byFirmName.getData();
|
||||
if (null != data){
|
||||
throw new ServiceException("公司名称已经存在");
|
||||
|
|
|
@ -7,7 +7,7 @@ nacos:
|
|||
addr: 159.75.188.178:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: xxy
|
||||
namespace: eight
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?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-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-common-cache</artifactId>
|
||||
|
||||
<description>
|
||||
cloud-modules-cache 缓存基准
|
||||
</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.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;
|
||||
|
||||
/**
|
||||
* 抽象缓存层
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.common
|
||||
* @Project:cloud-server-8
|
||||
* @name:CacheAbsBacis
|
||||
* @Date:2024/9/30 11:19
|
||||
*/
|
||||
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,18 @@
|
|||
package com.muyu.common.cache;
|
||||
|
||||
/**
|
||||
* 缓存基础
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.common.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:CacheBasic
|
||||
* @Date:2024/9/30 11:41
|
||||
*/
|
||||
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,34 @@
|
|||
package com.muyu.common.cache;
|
||||
|
||||
/**
|
||||
* 主键基础
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.common.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:PrimaryKeyBasic
|
||||
* @Date:2024/9/30 11:35
|
||||
*/
|
||||
public interface PrimaryKeyBasic <K>{
|
||||
|
||||
/**
|
||||
* key 前缀
|
||||
* @return 前缀
|
||||
*/
|
||||
public String keyPre();
|
||||
/**
|
||||
* 编码
|
||||
* @param key 缓存键
|
||||
* @return 装修键
|
||||
*/
|
||||
public default String encode(K key){
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码key
|
||||
* @param key 编码Key
|
||||
* @return 解码后的Key
|
||||
*/
|
||||
public K decode(String key);
|
||||
|
||||
}
|
|
@ -56,5 +56,5 @@ public class SecurityConstants {
|
|||
*/
|
||||
public static final String ROLE_PERMISSION = "role_permission";
|
||||
|
||||
public static final String SAAS_KEY = "ent-code";
|
||||
public static final String SAAS_KEY = "saas_key";
|
||||
}
|
||||
|
|
|
@ -17,7 +17,8 @@ import java.util.HashMap;
|
|||
* @Date:2024/9/28 12:19
|
||||
*/
|
||||
@Configuration
|
||||
public class KafkaConfig {
|
||||
public class
|
||||
KafkaConfig {
|
||||
|
||||
@Bean
|
||||
public KafkaProducer kafkaProducer(){
|
||||
|
|
|
@ -11,7 +11,8 @@ import com.muyu.cloud.common.saas.domain.model.EntInfo;
|
|||
import com.muyu.cloud.common.saas.exception.SaaSException;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.utils.SpringUtils;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.Firm;
|
||||
import com.muyu.common.system.domain.Firm;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
|
@ -36,16 +37,17 @@ public class ManyDataSource implements ApplicationRunner{
|
|||
|
||||
private List<EntInfo> dataSourceInfoList(){
|
||||
RemoteUserService remoteUserService = SpringUtils.getBean(RemoteUserService.class);
|
||||
Result<List<SysUser>> tableDataInfoResult = remoteUserService.companyList();
|
||||
Result<List<Firm>> tableDataInfoResult = remoteUserService.selectAll();
|
||||
if (tableDataInfoResult==null){
|
||||
throw new SaaSException("saas远调数据源错误");
|
||||
}
|
||||
List<SysUser> data = tableDataInfoResult.getData();
|
||||
List<Firm> data = tableDataInfoResult.getData();
|
||||
if (tableDataInfoResult.getCode() ==Result.SUCCESS && data !=null){
|
||||
List<EntInfo> list = new ArrayList<>();
|
||||
for (SysUser row : data) {
|
||||
for (Firm row : data) {
|
||||
list.add(
|
||||
EntInfo.builder()
|
||||
.firmKey(row.getFirmName())
|
||||
.entCode(row.getDatabaseName())
|
||||
.ip(DatasourceContent.IP)
|
||||
.port(DatasourceContent.PORT)
|
||||
|
@ -82,7 +84,8 @@ public class ManyDataSource implements ApplicationRunner{
|
|||
public void run(ApplicationArguments args) {
|
||||
DruidDataSourceFactory druidDataSourceFactory = SpringUtils.getBean(DruidDataSourceFactory.class);
|
||||
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
||||
for (EntInfo entInfo : dataSourceInfoList()) {
|
||||
List<EntInfo> entInfos = this.dataSourceInfoList();
|
||||
for (EntInfo entInfo : entInfos) {
|
||||
DataSourceInfo dataSourceInfo = DataSourceInfo.hostAndPortBuild(
|
||||
entInfo.getEntCode(), entInfo.getIp(), entInfo.getPort()
|
||||
);
|
||||
|
|
|
@ -8,7 +8,6 @@ import lombok.Data;
|
|||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author DongZl
|
||||
* @description: 数据源实体类
|
||||
* @Date 2023-8-1 上午 11:15
|
||||
*/
|
||||
|
|
|
@ -19,7 +19,6 @@ public class DruidDataSourceFactory {
|
|||
|
||||
/**
|
||||
* @Description: 根据传递的数据源信息测试数据库连接
|
||||
* @Author Dongzl
|
||||
*/
|
||||
public DruidDataSource create(DataSourceInfo dataSourceInfo) {
|
||||
DruidDataSource druidDataSource = new DruidDataSource();
|
||||
|
@ -33,7 +32,7 @@ public class DruidDataSourceFactory {
|
|||
log.info("{} -> 数据源连接成功", dataSourceInfo.getKey());
|
||||
return druidDataSource;
|
||||
} catch (SQLException throwables) {
|
||||
log.error("数据源 {} 连接失败,用户名:{},密码 {}",dataSourceInfo.getUrl(),dataSourceInfo.getUserName(),dataSourceInfo.getPassword());
|
||||
log.error("数据源 {} 连接失败,用户名:{},密码 {}, 四百原因:{}",dataSourceInfo.getUrl(),dataSourceInfo.getUserName(),dataSourceInfo.getPassword(),throwables);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,5 +8,5 @@ package com.muyu.cloud.common.saas.contents;
|
|||
*/
|
||||
public class SaaSConstant {
|
||||
|
||||
public final static String SAAS_KEY = "ent-code";
|
||||
public final static String SAAS_KEY = "saas_key";
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ import lombok.NoArgsConstructor;
|
|||
@AllArgsConstructor
|
||||
public class EntInfo {
|
||||
|
||||
private String firmKey;
|
||||
|
||||
private String entCode;
|
||||
|
||||
private String ip;
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.muyu.cloud.common.many.datasource.holder.DynamicDataSourceHolder;
|
|||
import com.muyu.cloud.common.many.datasource.role.DynamicDataSource;
|
||||
import com.muyu.cloud.common.saas.contents.SaaSConstant;
|
||||
import com.muyu.cloud.common.saas.exception.SaaSException;
|
||||
import com.muyu.common.core.constant.SecurityConstants;
|
||||
import com.muyu.common.core.utils.ServletUtils;
|
||||
import com.muyu.common.core.utils.SpringUtils;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
@ -25,8 +26,11 @@ public class SaaSInterceptor implements AsyncHandlerInterceptor {
|
|||
return true;
|
||||
}
|
||||
|
||||
// SaaSConstant.SAAS_KEY
|
||||
// SecurityConstants.SAAS_KEY
|
||||
|
||||
String SaaSKey = ServletUtils.getHeader(request, SaaSConstant.SAAS_KEY);
|
||||
if (SaaSKey == null) {
|
||||
if (SaaSKey == null || "".equals(SaaSKey)) {
|
||||
throw new SaaSException("SaaS非法访问");
|
||||
}else {
|
||||
DynamicDataSource dynamicDataSource = SpringUtils.getBean(DynamicDataSource.class);
|
||||
|
|
|
@ -62,6 +62,7 @@ public class TokenService {
|
|||
Map<String, Object> rspMap = new HashMap<String, Object>();
|
||||
rspMap.put("access_token", JwtUtils.createToken(claimsMap));
|
||||
rspMap.put("expires_in", expireTime);
|
||||
rspMap.put("saas_key", loginUser.getSysUser().getDatabaseName());
|
||||
|
||||
return rspMap;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.common.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -21,6 +22,7 @@ public class Firm {
|
|||
/**
|
||||
* 公司编号
|
||||
*/
|
||||
@TableId(value = "firm_id")
|
||||
private Integer firmId;
|
||||
|
||||
/**
|
||||
|
|
|
@ -63,4 +63,14 @@ public class LoginUser implements Serializable {
|
|||
*/
|
||||
private SysUser sysUser;
|
||||
|
||||
/**
|
||||
* 企业
|
||||
*/
|
||||
private Firm firm;
|
||||
|
||||
/**
|
||||
* 公司名称
|
||||
*/
|
||||
private String firmName;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.muyu.common.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.muyu.common.core.annotation.Excel;
|
||||
import com.muyu.common.core.annotation.Excel.ColumnType;
|
||||
import com.muyu.common.core.annotation.Excel.Type;
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.muyu.common.system.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**用户登录时用来查询的信息
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.system.domain
|
||||
* @Project:cloud-server-8
|
||||
* @name:SysUserMessage
|
||||
* @Date:2024/10/2 10:25
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysUserMessage {
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 数据库名
|
||||
*/
|
||||
private String databaseName;
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
package com.muyu.common.system.remote;
|
||||
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.Firm;
|
||||
import com.muyu.common.system.remote.factory.RemoteFirmFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.muyu.common.system.remote
|
||||
* @Project:cloud-server-8
|
||||
* @name:RemoteFirmService
|
||||
* @Date:2024/9/25 22:21
|
||||
*/
|
||||
@FeignClient(contextId = "remoteFirmService", value = ServiceNameConstants.SYSTEM_SERVICE,fallbackFactory = RemoteFirmFallbackFactory.class)
|
||||
public interface RemoteFirmService {
|
||||
|
||||
@RequestMapping("/firm/findByFirmName/{firmName}")
|
||||
public Result<Firm> findByFirmName(@PathVariable("firmName") String firmName);
|
||||
}
|
|
@ -3,7 +3,9 @@ package com.muyu.common.system.remote;
|
|||
import com.muyu.common.core.constant.SecurityConstants;
|
||||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.Firm;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.SysUserMessage;
|
||||
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
@ -42,4 +44,27 @@ public interface RemoteUserService {
|
|||
|
||||
@GetMapping("/user/companyList")
|
||||
public Result<List<SysUser>> companyList ();
|
||||
|
||||
@GetMapping("/user/selectByfirmName/{firmName}")
|
||||
public Result<String> selectByfirmName(@PathVariable("firmName") String firmName);
|
||||
|
||||
/**
|
||||
* 查询这个数据源中的登录账号和密码
|
||||
* @param sysUserMessage
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/user/selectuser")
|
||||
public Result<LoginUser> selectuser(@RequestBody SysUserMessage sysUserMessage );
|
||||
|
||||
/**
|
||||
* 根据企业码查询对应数据源
|
||||
* @param firmName
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping("/firm/findByFirmName/{firmName}")
|
||||
public Result<Firm> findByFirmName(@PathVariable("firmName") String firmName);
|
||||
|
||||
|
||||
@RequestMapping("/firm/selectAll")
|
||||
public Result<List<Firm>> selectAll();
|
||||
}
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
package com.muyu.common.system.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.core.exception.ServiceException;
|
||||
import com.muyu.common.system.domain.Firm;
|
||||
import com.muyu.common.system.remote.RemoteFirmService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.muyu.common.system.remote.factory
|
||||
* @Project:cloud-server-8
|
||||
* @name:RemoteFirmFallbackFactory
|
||||
* @Date:2024/9/25 22:22
|
||||
*/
|
||||
@Component
|
||||
public class RemoteFirmFallbackFactory implements FallbackFactory<RemoteFirmService> {
|
||||
@Override
|
||||
public RemoteFirmService create(Throwable cause) {
|
||||
|
||||
return new RemoteFirmService() {
|
||||
@Override
|
||||
public Result<Firm> findByFirmName(String firmName) {
|
||||
throw new ServiceException(cause.getCause().toString());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package com.muyu.common.system.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.Firm;
|
||||
import com.muyu.common.system.domain.SysUserMessage;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
|
@ -38,6 +40,26 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
public Result<List<SysUser>> companyList() {
|
||||
return Result.error("发现用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> selectByfirmName(String firmName) {
|
||||
return Result.error("信息查询失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<LoginUser> selectuser(SysUserMessage sysUserMessage) {
|
||||
return Result.error("信息查询失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Firm> findByFirmName(String firmName) {
|
||||
return Result.error("信息查询失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<Firm>> selectAll() {
|
||||
return Result.error("信息查询失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
com.muyu.common.system.remote.factory.RemoteUserFallbackFactory
|
||||
com.muyu.common.system.remote.factory.RemoteLogFallbackFactory
|
||||
com.muyu.common.system.remote.factory.RemoteFileFallbackFactory
|
||||
com.muyu.common.system.remote.factory.RemoteFirmFallbackFactory
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
<module>cloud-common-rabbit</module>
|
||||
<module>cloud-common-saas</module>
|
||||
<module>cloud-common-wechat</module>
|
||||
<module>cloud-common-kafka</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>cloud-common</artifactId>
|
||||
|
|
|
@ -4,10 +4,10 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 159.75.188.178:8848
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: xxy
|
||||
namespace: eight
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
<?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-server</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-Saas-Service</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.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-api-doc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
<version>6.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>clod-Saas-Service</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<!-- <!– 加入maven deploy插件,当在deploy时,忽略些model–> -->
|
||||
<!-- <plugin> -->
|
||||
<!-- <groupId>org.apache.maven.plugins</groupId> -->
|
||||
<!-- <artifactId>maven-deploy-plugin</artifactId> -->
|
||||
<!-- <version>3.1.1</version> -->
|
||||
<!-- <configuration> -->
|
||||
<!-- <skip>true</skip> -->
|
||||
<!-- </configuration> -->
|
||||
<!-- </plugin> -->
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -0,0 +1,20 @@
|
|||
package com.muyu;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @Author:杨闪闪
|
||||
* @Package:com.muyu.server.integration
|
||||
* @Project:cloud-integration
|
||||
* @name:Integration
|
||||
* @Date:2024/9/17 下午9:56
|
||||
*/
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class SaasServiceApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SaasServiceApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,47 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9121
|
||||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: cloud-electronic
|
||||
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}
|
|
@ -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-electronic"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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-electronic"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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-electronic"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.server.mapper.CarMiddleGroupMapper">
|
||||
|
||||
<select id="selectByIdList" resultType="com.muyu.domain.CarMiddleGroup">
|
||||
select
|
||||
*
|
||||
from
|
||||
car_middle_group
|
||||
where
|
||||
car_fence_id = #{carFenceId};
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,12 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.server.mapper.CarMiddleMapper">
|
||||
|
||||
<delete id="carDel">
|
||||
delete
|
||||
from car_middle
|
||||
where fence_group_id = #{id} and car_information_id = #{carId};
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,124 @@
|
|||
<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>
|
||||
|
||||
<description>
|
||||
cloud-modules-car-gateway车辆网关模块
|
||||
</description>
|
||||
<artifactId>cloud-modules-car-gateway</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>cloud-modules-car-gateway</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<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>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-rabbit</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>ecs20140526</artifactId>
|
||||
<version>5.4.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</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,20 @@
|
|||
package com.muyu.car;
|
||||
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car
|
||||
* @Project:cloud-server-8
|
||||
* @name:CloudCarGatewayApplication
|
||||
* @Date:2024/9/29 上午10:50
|
||||
*/
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class CloudCarGatewayApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CloudCarGatewayApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.muyu.car;
|
||||
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
|
||||
public class MqttPublishSample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
String topic = "vehicle";
|
||||
String content = "Message from MqttPublishSample";
|
||||
int qos = 2;
|
||||
String broker = "tcp://120.55.62.0:1883";
|
||||
String clientId = "JavaSample";
|
||||
|
||||
try {
|
||||
// 第三个参数为空,默认持久化策略
|
||||
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) {
|
||||
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,55 @@
|
|||
package com.muyu.car.domain.api.req;
|
||||
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 车辆连接请求参数
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.domain.api.req
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleConnectionReq
|
||||
* @Date:2024/10/2 下午4:12
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class VehicleConnectionReq {
|
||||
|
||||
/**
|
||||
* {
|
||||
* "vehicleVin": "VIN1234567894",
|
||||
* "timestamp": "11111",
|
||||
* "username": "你好",
|
||||
* "nonce": "33"
|
||||
* }
|
||||
*/
|
||||
|
||||
/**
|
||||
* vin
|
||||
*/
|
||||
@JSONField(name = "vehicleVin")
|
||||
private String vehicleVin;
|
||||
/**
|
||||
* 时间戳
|
||||
*/
|
||||
private String timestamp;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@JSONField(name = "username")
|
||||
private String username;
|
||||
/**
|
||||
* 随机字符串
|
||||
*/
|
||||
private String nonce;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.muyu.car.domain.example;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 实例基础信息
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.domain
|
||||
* @Project:cloud-server-8
|
||||
* @name:ExampleInformation
|
||||
* @Date:2024/9/29 下午10:01
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ExampleInformation {
|
||||
|
||||
/**
|
||||
* 实例ID
|
||||
*/
|
||||
private String InstanceId;
|
||||
/**
|
||||
* 实例IP
|
||||
*/
|
||||
private String IpAddress;
|
||||
/**
|
||||
* 实例状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.muyu.car.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.domain.model
|
||||
* @Project:cloud-server-8
|
||||
* @name:MqttServerModel
|
||||
* @Date:2024/10/7 下午6:40
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MqttServerModel {
|
||||
|
||||
/**
|
||||
* MQTT服务节点
|
||||
*/
|
||||
private String broker;
|
||||
/**
|
||||
* MQTT订阅主题
|
||||
*/
|
||||
private String topic;
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
package com.muyu.car.domain.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.domain.model
|
||||
* @Project:cloud-server-8
|
||||
* @name:Vehicle
|
||||
* @Date:2024/10/6 上午10:33
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class VehicleInformation {
|
||||
|
||||
/**
|
||||
* 车辆ID
|
||||
*/
|
||||
private String carInformationId ;
|
||||
/**
|
||||
* 车辆唯一VIN
|
||||
*/
|
||||
private String carInformationVIN ;
|
||||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
private String carInformationLicensePlate ;
|
||||
/**
|
||||
* 车辆品牌
|
||||
*/
|
||||
private String carInformationBrand ;
|
||||
/**
|
||||
* 车辆颜色
|
||||
*/
|
||||
private String carInformationColor ;
|
||||
/**
|
||||
* 车辆驾驶员
|
||||
*/
|
||||
private String carInformationDriver ;
|
||||
/**
|
||||
* 车检到期日期
|
||||
*/
|
||||
private String carInformationExamineEnddata ;
|
||||
/**
|
||||
* 车辆电机厂商
|
||||
*/
|
||||
private String carInformationMotorManufacturer ;
|
||||
/**
|
||||
* 车辆电机型号
|
||||
*/
|
||||
private String carInformationMotorModel ;
|
||||
/**
|
||||
* 车辆电池厂商
|
||||
*/
|
||||
private String carInformationBatteryManufacturer ;
|
||||
/**
|
||||
* 车辆电池型号
|
||||
*/
|
||||
private String carInformationBatteryModel ;
|
||||
/**
|
||||
* 车辆电子围栏外键ID
|
||||
*/
|
||||
private String carInformationFence ;
|
||||
/**
|
||||
* 车辆类型外键ID
|
||||
*/
|
||||
private String carInformationType ;
|
||||
/**
|
||||
* 是否重点车辆 (0否默认 1是 )
|
||||
*/
|
||||
private String carInformationFocus ;
|
||||
/**
|
||||
* 车辆策略id
|
||||
*/
|
||||
private String carStrategyId ;
|
||||
/**
|
||||
* 启用状态(1.在线 2.离线 3.已断开 4.待连接 5.维修中)
|
||||
*/
|
||||
private String carInformationState ;
|
||||
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.muyu.car.domain.model.properties;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.domain.model.properties
|
||||
* @Project:cloud-server-8
|
||||
* @name:MqttProperties
|
||||
* @Date:2024/10/6 下午8:24
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class MqttProperties {
|
||||
|
||||
/**
|
||||
* 节点
|
||||
*/
|
||||
private String broker;
|
||||
|
||||
/**
|
||||
* 主题
|
||||
*/
|
||||
private String topic;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 节点ID
|
||||
*/
|
||||
private String clientId;
|
||||
|
||||
/**
|
||||
* 上报级别
|
||||
*/
|
||||
private int qos = 0;
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.muyu.car.domain.model.properties;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.domain.model.properties
|
||||
* @Project:cloud-server-8
|
||||
* @name:MqttServerModel
|
||||
* @Date:2024/10/6 下午8:25
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MqttServerModel {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(MqttServerModel.class);
|
||||
/**
|
||||
* MQTT服务节点
|
||||
*/
|
||||
private String broker;
|
||||
|
||||
/**
|
||||
* MQTT订阅主题
|
||||
*/
|
||||
private String topic;
|
||||
|
||||
public String getBroker () {
|
||||
log.info("broker: {}", broker);
|
||||
return broker.contains("tcp://") ? broker : "tcp://" + broker + ":1883";
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.muyu.car.gateway.controller;
|
||||
|
||||
import com.muyu.car.domain.api.req.VehicleConnectionReq;
|
||||
import com.muyu.car.domain.model.MqttServerModel;
|
||||
import com.muyu.car.domain.model.VehicleInformation;
|
||||
import com.muyu.car.gateway.service.VehicleInformationService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 车辆获取信息
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.gateway.controller
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleInformationController
|
||||
* @Date:2024/10/6 下午2:39
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/verify")
|
||||
public class VehicleInformationController {
|
||||
|
||||
@Autowired
|
||||
private VehicleInformationService vehicleInformationService;
|
||||
|
||||
@PostMapping("/vehicleConnection")
|
||||
public Result<MqttServerModel> getVehicleData(
|
||||
@Validated @RequestBody VehicleConnectionReq vehicleConnectionReq
|
||||
) {
|
||||
|
||||
return Result.success(vehicleInformationService.getVehicleData(vehicleConnectionReq));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.muyu.car.gateway.controller;
|
||||
|
||||
import com.muyu.car.domain.model.VehicleInformation;
|
||||
import com.muyu.car.gateway.service.VehicleInstanceService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 车辆实例控制层
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.gateway.controller
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleInformation
|
||||
* @Date:2024/10/4 上午9:40
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/vehicle")
|
||||
public class VehicleInstanceController {
|
||||
|
||||
@Autowired private VehicleInstanceService vehicleInstanceService;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.muyu.car.gateway.mq;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.amqp.core.*;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.gateway.mq
|
||||
* @Project:cloud-server-8
|
||||
* @name:CreateExchange
|
||||
* @Date:2024/10/7 下午8:53
|
||||
*/
|
||||
@Log4j2
|
||||
@Component
|
||||
public class CreateExchange implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private ConnectionFactory connectionFactory;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
log.info("=====>开始创建交换机");
|
||||
|
||||
try {
|
||||
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
|
||||
|
||||
// 创建Fanout类型的交换机
|
||||
FanoutExchange exchange = new FanoutExchange("ONLINE_EXCHANGE", true, false);
|
||||
|
||||
rabbitAdmin.declareExchange(exchange);
|
||||
|
||||
// 创建队列
|
||||
Queue queue = new Queue("GO_ONLINE", true, false, false);
|
||||
|
||||
rabbitAdmin.declareQueue(queue);
|
||||
|
||||
// Fanout交换机绑定
|
||||
rabbitAdmin.declareBinding(BindingBuilder.bind(queue).to(exchange));
|
||||
|
||||
log.info("=====>交换机创建成功");
|
||||
log.info("=====>队列创建成功并绑定到交换机");
|
||||
}catch (Exception e) {
|
||||
log.info(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.muyu.car.gateway.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.car.domain.api.req.VehicleConnectionReq;
|
||||
import com.muyu.car.domain.model.MqttServerModel;
|
||||
import com.muyu.car.domain.model.VehicleInformation;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.gateway.service
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleInformationService
|
||||
* @Date:2024/10/6 下午2:40
|
||||
*/
|
||||
public interface VehicleInformationService{
|
||||
MqttServerModel getVehicleData(VehicleConnectionReq vehicleConnectionReq);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.muyu.car.gateway.service;
|
||||
|
||||
import com.muyu.car.domain.model.VehicleInformation;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.gateway.service
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleInstanceService
|
||||
* @Date:2024/10/6 上午10:05
|
||||
*/
|
||||
public interface VehicleInstanceService {
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.muyu.car.gateway.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.car.domain.api.req.VehicleConnectionReq;
|
||||
import com.muyu.car.domain.model.MqttServerModel;
|
||||
import com.muyu.car.domain.model.VehicleInformation;
|
||||
import com.muyu.car.gateway.service.VehicleInformationService;
|
||||
import com.muyu.car.mapper.VehicleInformationMapper;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.gateway.service.impl
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleInformationServiceImpl
|
||||
* @Date:2024/10/6 下午2:41
|
||||
*/
|
||||
@Log4j2
|
||||
@Service
|
||||
public class VehicleInformationServiceImpl implements VehicleInformationService{
|
||||
|
||||
@Autowired private VehicleInformationMapper vehicleInformationMapper;
|
||||
|
||||
@Override
|
||||
public MqttServerModel getVehicleData(VehicleConnectionReq vehicleConnectionReq) {
|
||||
log.info("车辆连接请求:[{}]",vehicleConnectionReq);
|
||||
vehicleConnectionReq.setPassword(vehicleConnectionReq.getVehicleVin()+vehicleConnectionReq.getTimestamp()+vehicleConnectionReq.getNonce());
|
||||
|
||||
List<String> selectVehicle =vehicleInformationMapper.selectVehicleVin(vehicleConnectionReq.getVehicleVin());
|
||||
if(selectVehicle.isEmpty()) {
|
||||
vehicleInformationMapper.addVehicleConnection(vehicleConnectionReq);
|
||||
log.info("车辆预上线成功");
|
||||
}else {
|
||||
log.info("车辆无法重复预上线");
|
||||
}
|
||||
|
||||
return new MqttServerModel("tcp://121.199.172.3:1883","vehicle");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.muyu.car.gateway.service.impl;
|
||||
|
||||
import com.muyu.car.domain.model.VehicleInformation;
|
||||
import com.muyu.car.gateway.service.VehicleInstanceService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.gateway.service.impl
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleInstanceServceImpl
|
||||
* @Date:2024/10/6 上午10:06
|
||||
*/
|
||||
@Log4j2
|
||||
@Service
|
||||
public class VehicleInstanceServiceImpl implements VehicleInstanceService {
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.muyu.car.instance;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
/**
|
||||
* 阿里云AccessKey ID Secret
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.domain
|
||||
* @Project:cloud-server-8
|
||||
* @name:CreateClient
|
||||
* @Date:2024/9/29 上午10:41
|
||||
*/
|
||||
@Component
|
||||
public class CreateClient {
|
||||
|
||||
/**
|
||||
* <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("LTAI5tFtQk1KbwRBXM5pHVWw")
|
||||
// 必填,请确保代码运行环境设置了环境变量 ALIBABA_CLOUD_ACCESS_KEY_SECRET。
|
||||
.setAccessKeySecret("GLByUZqUqgR600eTpGmfb52ZT93mu9");
|
||||
// Endpoint 请参考 https://api.aliyun.com/product/Ecs
|
||||
config.endpoint = "ecs-cn-hangzhou.aliyuncs.com";
|
||||
return new com.aliyun.ecs20140526.Client(config);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,102 @@
|
|||
package com.muyu.car.instance;
|
||||
|
||||
import com.aliyun.ecs20140526.models.DescribeInstancesRequest;
|
||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
||||
import com.aliyun.ecs20140526.models.RunInstancesResponseBody;
|
||||
import com.aliyun.tea.*;
|
||||
import com.aliyun.teautil.models.RuntimeOptions;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 项目关闭清除实例
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.domain
|
||||
* @Project:cloud-server-8
|
||||
* @name:DelInstance
|
||||
* @Date:2024/9/29 上午10:42
|
||||
*/
|
||||
@Log4j2
|
||||
@Component
|
||||
@Tag(name = "程序停止删除实例")
|
||||
public class DelInstance implements DisposableBean {
|
||||
|
||||
public static void delInstance() throws Exception {
|
||||
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||
com.aliyun.ecs20140526.Client client = CreateClient.createClient();
|
||||
DescribeInstancesRequest describeInstancesRequest = new DescribeInstancesRequest()
|
||||
.setRegionId("cn-hangzhou");
|
||||
//创建运行时选择对象,用于配置运行时的选项参数
|
||||
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-hangzhou")
|
||||
// 设置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
|
||||
log.info(error.getMessage());
|
||||
// 诊断地址
|
||||
log.info(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// 错误 message
|
||||
log.info(error.getMessage());
|
||||
// 诊断地址
|
||||
log.info(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() throws Exception {
|
||||
log.info("===============>开始执行删除实例方法");
|
||||
delInstance();
|
||||
// 连接到Redis服务器
|
||||
Jedis jedis = new Jedis("159.75.188.178", 6379);
|
||||
// 指定要删除的文件夹(命名空间)
|
||||
String namespace = "InstanceIdKey:";
|
||||
// 获取所有以namespace为前缀的键
|
||||
Set<String> keys = jedis.keys(namespace + "*");
|
||||
// 如果存在键,则删除它们
|
||||
if (keys.size() > 0) {
|
||||
jedis.del(keys.toArray(new String[0]));
|
||||
}
|
||||
// 关闭连接
|
||||
jedis.close();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
package com.muyu.car.instance;
|
||||
|
||||
import com.aliyun.ecs20140526.models.*;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.muyu.car.domain.example.ExampleInformation;
|
||||
import com.muyu.common.redis.service.RedisService;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 项目启动创建实例
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.domain
|
||||
* @Project:cloud-server-8
|
||||
* @name:GenerateInstance
|
||||
* @Date:2024/9/29 上午10:42
|
||||
*/
|
||||
@Component
|
||||
@Log4j2
|
||||
@Tag(name = "启动时创建实例")
|
||||
public class GenerateInstance implements ApplicationRunner {
|
||||
|
||||
@Autowired private RedisService redisService;
|
||||
|
||||
/**
|
||||
* 启动自动创建实例
|
||||
* @throws Exception
|
||||
*/
|
||||
public static List<String> generateInstance() throws Exception {
|
||||
|
||||
// 创建ECS客户端对象,用于后续调用ECS相关API
|
||||
com.aliyun.ecs20140526.Client client = CreateClient.createClient();
|
||||
|
||||
com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk systemDisk = new com.aliyun.ecs20140526.models.RunInstancesRequest.RunInstancesRequestSystemDisk()
|
||||
.setSize("40")
|
||||
.setCategory("cloud_essd");
|
||||
com.aliyun.ecs20140526.models.RunInstancesRequest runInstancesRequest = new com.aliyun.ecs20140526.models.RunInstancesRequest()
|
||||
// 设置地域ID
|
||||
.setRegionId("cn-hangzhou")
|
||||
// 设置镜像ID
|
||||
.setImageId("m-bp1hkxfctk751s62jqhq")
|
||||
// 设置实例类型
|
||||
.setInstanceType("ecs.t6-c1m1.large")
|
||||
// 设置安全组ID
|
||||
.setSecurityGroupId("sg-bp1a7fk8js5pn3fw9p2m")
|
||||
// 设置虚拟交换机ID
|
||||
.setVSwitchId("vsw-bp193np7r01vssqxhh24e")
|
||||
// 设置实例名称
|
||||
.setInstanceName("server-mqtt")
|
||||
// 设置实例付费类型为后付费按量付费
|
||||
.setInstanceChargeType("PostPaid")
|
||||
// 设置互联网最大出带宽为1 Mbps
|
||||
.setInternetMaxBandwidthOut(1)
|
||||
// 设置系统盘配置
|
||||
.setSystemDisk(systemDisk)
|
||||
// 设置主机名
|
||||
.setHostName("root")
|
||||
// 设置实例密码
|
||||
.setPassword("EightGroup123.")
|
||||
// 设置创建实例的数量
|
||||
.setAmount(1);
|
||||
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
RunInstancesResponse runInstancesResponse = client.runInstancesWithOptions(runInstancesRequest, runtime);
|
||||
// 获取body返回值对象
|
||||
RunInstancesResponseBody body = runInstancesResponse.getBody();
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
// 得到实例ID数组
|
||||
for (String instance : body.getInstanceIdSets().getInstanceIdSet()) {
|
||||
list.add(instance);
|
||||
}
|
||||
log.info("实例ID:{}",list);
|
||||
return list;
|
||||
} catch (TeaException error) {
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// 错误 message
|
||||
log.info(error.getMessage());
|
||||
// 诊断地址
|
||||
log.info(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
} catch (Exception _error) {
|
||||
TeaException error = new TeaException(_error.getMessage(), _error);
|
||||
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
|
||||
// 错误 message
|
||||
log.info(error.getMessage());
|
||||
// 诊断地址
|
||||
log.info(error.getData().get("Recommend"));
|
||||
com.aliyun.teautil.Common.assertAsString(error.message);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
List<String> InstanceIds = generateInstance();
|
||||
log.info("创建实例成功");
|
||||
log.info("正在加载实例");
|
||||
Thread.sleep(30000);
|
||||
List<ExampleInformation> exampleInformations = QueryInstance.queryInstance(InstanceIds);
|
||||
log.info("加载成功");
|
||||
for (ExampleInformation exampleInformation : exampleInformations) {
|
||||
redisService.setCacheObject("InstanceIdKey:"+exampleInformation.getInstanceId(),exampleInformation);
|
||||
}
|
||||
// for (ExampleInformation exampleInformation : exampleInformations) {
|
||||
// ExampleInformation cacheObject = redisService.getCacheObject(exampleInformation.getInstanceId());
|
||||
// log.info(cacheObject);
|
||||
// }
|
||||
log.info("实例信息:{}",exampleInformations);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
package com.muyu.car.instance;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponse;
|
||||
import com.aliyun.ecs20140526.models.DescribeInstancesResponseBody;
|
||||
import com.aliyun.tea.TeaException;
|
||||
import com.muyu.car.domain.example.ExampleInformation;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 启动后查询实例信息
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.instance
|
||||
* @Project:cloud-server-8
|
||||
* @name:QueryInstance
|
||||
* @Date:2024/9/29 下午8:58
|
||||
*/
|
||||
@Log4j2
|
||||
public class QueryInstance {
|
||||
|
||||
public static List<ExampleInformation> queryInstance(List<String> instanceIds) throws Exception {
|
||||
com.aliyun.ecs20140526.Client client = CreateClient.createClient();
|
||||
|
||||
com.aliyun.ecs20140526.models.DescribeInstancesRequest describeInstancesRequest = new com.aliyun.ecs20140526.models.DescribeInstancesRequest()
|
||||
.setInstanceIds(JSON.toJSONString(instanceIds))
|
||||
.setRegionId("cn-hangzhou");
|
||||
|
||||
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||
|
||||
try {
|
||||
// 复制代码运行请自行打印 API 的返回值
|
||||
DescribeInstancesResponse describeInstancesResponse = client.describeInstancesWithOptions(describeInstancesRequest, runtime);
|
||||
DescribeInstancesResponseBody body = describeInstancesResponse.getBody();
|
||||
ArrayList<ExampleInformation> exampleInformations = new ArrayList<>();
|
||||
for (DescribeInstancesResponseBody.DescribeInstancesResponseBodyInstancesInstance instance : body.getInstances().getInstance()){
|
||||
ExampleInformation exampleInformation = new ExampleInformation();
|
||||
exampleInformation.setInstanceId(instance.getInstanceId());
|
||||
log.info("实例ID:{}",exampleInformation.getInstanceId());
|
||||
exampleInformation.setStatus(instance.getStatus());
|
||||
log.info("实例状态:{}",exampleInformation.getStatus());
|
||||
exampleInformation.setIpAddress(String.valueOf(instance.getPublicIpAddress().getIpAddress()));
|
||||
log.info("实例IP:{}",exampleInformation.getIpAddress());
|
||||
exampleInformations.add(exampleInformation);
|
||||
}
|
||||
log.info("实例信息:{}",exampleInformations);
|
||||
return exampleInformations;
|
||||
} 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);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.muyu.car.mapper;
|
||||
|
||||
import com.muyu.car.domain.api.req.VehicleConnectionReq;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:蓬叁
|
||||
* @Package:com.muyu.car.mapper
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleInformationMapper
|
||||
* @Date:2024/10/6 下午2:19
|
||||
*/
|
||||
@Mapper
|
||||
public interface VehicleInformationMapper {
|
||||
void addVehicleConnection(VehicleConnectionReq vehicleConnectionReq);
|
||||
|
||||
List<String> selectVehicleVin(@Param("vehicleVin") String vehicleVin);
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.muyu.car.util;
|
||||
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
@Log4j2
|
||||
public class MD5Util {
|
||||
|
||||
private static final Integer SALT_LENGTH = 12;
|
||||
|
||||
/**
|
||||
* 将指定byte数组转换成16进制字符串
|
||||
* @param b 字节数组
|
||||
* @return 返回结果字符串
|
||||
*/
|
||||
public static String byteToHexString(byte[] b) {
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte value : b) {
|
||||
String hex = Integer.toHexString(value & 0xFF);
|
||||
if (hex.length() == 1) {
|
||||
hex = '0' + hex;
|
||||
}
|
||||
hexString.append(hex.toUpperCase());
|
||||
}
|
||||
return hexString.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得加密后的口令
|
||||
* @param str 需要加密的字符串
|
||||
* @return 加密后的字符串
|
||||
*/
|
||||
public static String encrypted (String str) {
|
||||
try {
|
||||
// 声明加密后的口令数组变量
|
||||
byte[] pwd = null;
|
||||
// 随机数生成器
|
||||
SecureRandom random = new SecureRandom();
|
||||
// 声明盐数组变量
|
||||
byte[] salt = new byte[SALT_LENGTH];
|
||||
// 将随机数放入盐变量中
|
||||
random.nextBytes(salt);
|
||||
|
||||
// 声明消息摘要对象
|
||||
MessageDigest md = null;
|
||||
// 创建消息摘要
|
||||
md = MessageDigest.getInstance("MD5");
|
||||
// 将盐数据传入消息摘要对象
|
||||
md.update(salt);
|
||||
// 将口令的数据传给消息摘要对象
|
||||
md.update(str.getBytes(StandardCharsets.UTF_8));
|
||||
// 获得消息摘要的字节数组
|
||||
byte[] digest = md.digest();
|
||||
|
||||
// 因为要在口令的字节数组中存放盐,所以加上盐的字节长度
|
||||
pwd = new byte[digest.length + SALT_LENGTH];
|
||||
// 将盐的字节拷贝到生成的加密口令字节数组的前12个字节,以便在验证口令时取出盐
|
||||
System.arraycopy(salt, 0, pwd, 0, SALT_LENGTH);
|
||||
// 将消息摘要拷贝到加密口令字节数组从第13个字节开始的字节
|
||||
System.arraycopy(digest, 0, pwd, SALT_LENGTH, digest.length);
|
||||
// 将字节数组格式加密后的口令转化为16进制字符串格式的口令
|
||||
return byteToHexString(pwd);
|
||||
}catch (Exception exception){
|
||||
log.info("md5加密失败:[{}]", str, exception);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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-car-gateway"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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-wechat"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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-wechat"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.@//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.car.mapper.VehicleInformationMapper">
|
||||
<insert id="addVehicleConnection">
|
||||
INSERT INTO `vehicle_connection` (`vin`, `timestamp`, `username`, `nonce`,`password`) VALUES (#{vehicleVin}, #{timestamp}, #{username}, #{nonce},#{password});
|
||||
</insert>
|
||||
<select id="selectVehicleVin" resultType="java.lang.String">
|
||||
select
|
||||
`vin`, `timestamp`, `username`, `nonce`,`password`
|
||||
from
|
||||
`vehicle_connection`
|
||||
where `vin` = #{vehicleVin}
|
||||
</select>
|
||||
</mapper>
|
|
@ -8,12 +8,10 @@
|
|||
<artifactId>cloud-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-modules-carData</artifactId>
|
||||
|
||||
<description>
|
||||
数据处理模块
|
||||
cloud-modules-carData数据处理模块
|
||||
</description>
|
||||
<artifactId>cloud-modules-carData</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
|
@ -21,7 +19,10 @@
|
|||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-enterprise-cache</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package com.muyu.carData.consumer;
|
||||
|
||||
import com.muyu.carData.util.CacheUtil;
|
||||
import com.muyu.domain.FaultCodeCache;
|
||||
import com.muyu.enterprise.cache.car.VehicleCacheCarInformationAddService;
|
||||
import com.muyu.enterprise.cache.car.VehicleCacheCarInformationFenceRespService;
|
||||
import com.muyu.enterprise.cache.faultCode.VehicleCacheFaultCodeAddService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
|
@ -23,11 +27,20 @@ public class CarOnlineConsumer {
|
|||
@Autowired
|
||||
private CacheUtil cacheUtil;
|
||||
|
||||
@Autowired
|
||||
private VehicleCacheFaultCodeAddService vehicleCacheCarInformationAddService;
|
||||
|
||||
|
||||
|
||||
|
||||
@RabbitListener(bindings = @QueueBinding(
|
||||
value = @Queue(value = "CAR_ONLINE",durable = "true"),
|
||||
exchange = @Exchange(value = "ONLINE_EXCHANGE",type = "fanout")
|
||||
))
|
||||
public void online(String vin){
|
||||
log.info("车辆vin:{},已上线,开始消费",vin);
|
||||
FaultCodeCache faultCodeCache = vehicleCacheCarInformationAddService
|
||||
.get(vehicleCacheCarInformationAddService.keyPre()+vin);
|
||||
cacheUtil.put(vin,faultCodeCache);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/*
|
||||
package com.muyu.carData.controller;
|
||||
|
||||
import com.muyu.carData.config.lotdbconfig.IotDBSessionConfig;
|
||||
|
@ -17,13 +18,15 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
*/
|
||||
/**
|
||||
* @Author:张腾
|
||||
* @Package:com.muyu.carData.testcontroller
|
||||
* @Project:cloud-server-8
|
||||
* @name:IotDBController
|
||||
* @Date:2024/9/28 23:58
|
||||
*/
|
||||
*//*
|
||||
|
||||
@RequestMapping("/iotdb")
|
||||
@RestController
|
||||
@Log4j2
|
||||
|
@ -33,6 +36,7 @@ public class IotDBController {
|
|||
@Autowired
|
||||
private IotDBSessionConfig iotDBSessionConfig;
|
||||
|
||||
*/
|
||||
/**
|
||||
* 批量插入数据
|
||||
* @param insertSize 每次插入的条数
|
||||
|
@ -40,7 +44,8 @@ public class IotDBController {
|
|||
* @return
|
||||
* @throws IoTDBConnectionException
|
||||
* @throws StatementExecutionException
|
||||
*/
|
||||
*//*
|
||||
|
||||
@GetMapping("/insertData/{insertSize}/{count}")
|
||||
public String insert(@PathVariable(name = "insertSize") int insertSize,@PathVariable(name = "count") int count) throws IoTDBConnectionException, StatementExecutionException {
|
||||
Session session = iotDBSessionConfig.iotSession();
|
||||
|
@ -82,7 +87,7 @@ public class IotDBController {
|
|||
}
|
||||
|
||||
|
||||
/* @GetMapping("/batchInsertRecords/{num}")
|
||||
@GetMapping("/batchInsertRecords/{num}")
|
||||
public String batchInsertRecords(@PathVariable Integer num){
|
||||
String deviceId = "root.yang";
|
||||
|
||||
|
@ -109,5 +114,6 @@ public class IotDBController {
|
|||
for (int i = 0; i < num; i++) {
|
||||
deviceIds.add()
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.muyu.carData.listener;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.muyu.carData.event.EsSaveEvent;
|
||||
import com.muyu.carData.event.EventListener;
|
||||
import com.muyu.carData.util.CacheUtil;
|
||||
import com.muyu.domain.FaultCodeCache;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/** 判断故障信息
|
||||
* @Author:张腾
|
||||
* @Package:com.muyu.carData.listener
|
||||
* @Project:cloud-server-8
|
||||
* @name:IdentifyingFailuresListener
|
||||
* @Date:2024/10/8 11:22
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class IdentifyingFailuresListener implements EventListener {
|
||||
|
||||
|
||||
@Autowired
|
||||
private CacheUtil cacheUtil;
|
||||
|
||||
@Override
|
||||
public void onEvent(EsSaveEvent event) {
|
||||
log.info("规则预警事件开始...");
|
||||
JSONObject data = event.getData();
|
||||
String vin = (String) data.get("vin");
|
||||
String str = cacheUtil.get(vin).toString();
|
||||
FaultCodeCache faultCodeCache = JSON.parseObject(str, FaultCodeCache.class);
|
||||
faultCodeCache.getFaultCode().forEach(faultCode -> {
|
||||
|
||||
});
|
||||
log.info("规则预警事件结束...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(EsSaveEvent event) {
|
||||
onEvent(event);
|
||||
}
|
||||
}
|
|
@ -4,7 +4,7 @@ server:
|
|||
|
||||
# nacos线上地址
|
||||
nacos:
|
||||
addr: 159.75.188.178:8848
|
||||
addr: 127.0.0.1:8848
|
||||
user-name: nacos
|
||||
password: nacos
|
||||
namespace: eight
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
<?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-enterprise</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>cloud-modules-enterprise-cache</artifactId>
|
||||
<description>
|
||||
cloud-modules-enterprise-cache 缓存模块
|
||||
</description>
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-enterprise-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-cache</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-auth</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.enterprise.cache.car;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.CarInformation;
|
||||
import com.muyu.domain.req.CarInformationAddReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 添加车辆信息
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleCacheService
|
||||
* @Date:2024/9/30 11:50
|
||||
*/
|
||||
public class VehicleCacheCarInformationAddService extends CacheAbsBasic<String, CarInformationAddReq> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarInformationAddReq:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.enterprise.cache.car;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.req.CarInformationAddReq;
|
||||
import com.muyu.domain.resp.CarInformationResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆基础信息列表缓存
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleCacheService
|
||||
* @Date:2024/9/30 11:50
|
||||
*/
|
||||
public class VehicleCacheCarInformationFenceRespService extends CacheAbsBasic<String, List<CarInformationResp>> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarInformationFenceResp:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.muyu.enterprise.cache.car;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.CarInformation;
|
||||
import com.muyu.domain.resp.CarInformationResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页查询车辆信息
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleCacheService
|
||||
* @Date:2024/9/30 11:50
|
||||
*/
|
||||
public class VehicleCacheCarInformationRespService extends CacheAbsBasic<String, Page<CarInformationResp>> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarInformationResp:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.enterprise.cache.car;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.CarInformation;
|
||||
import com.muyu.domain.resp.CarFenceGroupResp;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 查询车辆
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleCacheService
|
||||
* @Date:2024/9/30 11:50
|
||||
*/
|
||||
public class VehicleCacheCarInformationService extends CacheAbsBasic<String, List<CarInformation>> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarInformation:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.muyu.enterprise.cache.car;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.req.CarInformationAddReq;
|
||||
import com.muyu.domain.req.CarInformationUpdReq;
|
||||
|
||||
/**
|
||||
* 修改车辆信息
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleCacheService
|
||||
* @Date:2024/9/30 11:50
|
||||
*/
|
||||
public class VehicleCacheCarInformationUpdService extends CacheAbsBasic<String, CarInformationUpdReq> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "CarInformationUpdReq:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.muyu.enterprise.cache.faultCode;
|
||||
|
||||
import com.muyu.common.cache.CacheAbsBasic;
|
||||
import com.muyu.domain.FaultCodeCache;
|
||||
import com.muyu.domain.req.CarInformationAddReq;
|
||||
import com.muyu.domain.req.FaultCodeAddReq;
|
||||
|
||||
/**
|
||||
* 添加车辆信息
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.cache
|
||||
* @Project:cloud-server-8
|
||||
* @name:VehicleCacheService
|
||||
* @Date:2024/9/30 11:50
|
||||
*/
|
||||
public class VehicleCacheFaultCodeAddService extends CacheAbsBasic<String, FaultCodeCache> {
|
||||
@Override
|
||||
public String keyPre() {
|
||||
return "FaultCodeCache:info:";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String decode(String key) {
|
||||
return key.replace("vehicle:info:","");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
com.muyu.enterprise.cache.car.VehicleCacheCarInformationService
|
||||
com.muyu.enterprise.cache.car.VehicleCacheCarInformationRespService
|
||||
com.muyu.enterprise.cache.car.VehicleCacheCarInformationAddService
|
||||
com.muyu.enterprise.cache.car.VehicleCacheCarInformationUpdService
|
||||
com.muyu.enterprise.cache.car.VehicleCacheCarInformationFenceRespService
|
||||
com.muyu.enterprise.cache.faultCode.VehicleCacheFaultCodeAddService
|
|
@ -15,8 +15,8 @@
|
|||
cloud-modules-enterprise-common 企业业务common
|
||||
</description>
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
|
|
|
@ -71,8 +71,8 @@ public class CarInformation {
|
|||
/**
|
||||
* 车辆类型外键ID
|
||||
*/
|
||||
@Schema(title = "车辆类型外键ID", type = "Integer")
|
||||
private Integer carInformationType;
|
||||
// @Schema(title = "车辆类型外键ID", type = "Long")
|
||||
private Long carInformationType;
|
||||
/**
|
||||
* 车辆品牌
|
||||
*/
|
||||
|
@ -107,6 +107,13 @@ public class CarInformation {
|
|||
*/
|
||||
private Integer carInformationState;
|
||||
|
||||
/**
|
||||
* 车辆策略id
|
||||
*/
|
||||
private Integer carStrategyId;
|
||||
|
||||
|
||||
|
||||
public static CarInformation carInformationBuilder(CarInformation carInformation) {
|
||||
return CarInformation.builder()
|
||||
.carInformationId(carInformation.getCarInformationId())
|
||||
|
@ -147,4 +154,23 @@ public class CarInformation {
|
|||
.carInformationMotorModel(carInformation.getCarInformationMotorModel())
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CarInformation carInformationListBuilder(CarInformation carInformation) {
|
||||
return CarInformation.builder()
|
||||
.carInformationId(carInformation.getCarInformationId())
|
||||
.carInformationVIN(carInformation.getCarInformationVIN())
|
||||
.carInformationLicensePlate(carInformation.getCarInformationLicensePlate())
|
||||
.carInformationBrand(carInformation.getCarInformationBrand())
|
||||
.carInformationColor(carInformation.getCarInformationColor())
|
||||
.carInformationDriver(carInformation.getCarInformationDriver())
|
||||
.carInformationMotorManufacturer(carInformation.getCarInformationMotorManufacturer())
|
||||
.carInformationMotorModel(carInformation.getCarInformationMotorModel())
|
||||
.carInformationBatteryManufacturer(carInformation.getCarInformationBatteryManufacturer())
|
||||
.carInformationBatteryModel(carInformation.getCarInformationBatteryModel())
|
||||
.carInformationFence(carInformation.getCarInformationFence())
|
||||
.carInformationType(carInformation.getCarInformationType())
|
||||
.carInformationMotorModel(carInformation.getCarInformationMotorModel())
|
||||
.carStrategyId(carInformation.getCarStrategyId())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class FaultCode {
|
|||
|
||||
public static FaultCode addfaultcode(FaultCodeAddReq faultCodeAddReq){
|
||||
return FaultCode.builder()
|
||||
.faultcodeId(0)
|
||||
.faultcodeId(faultCodeAddReq.getFaultcodeId())
|
||||
.messageTypeId(faultCodeAddReq.getMessageTypeId())
|
||||
.faultcodeNumber(faultCodeAddReq.getFaultcodeNumber())
|
||||
.faultGroup(faultCodeAddReq.getFaultGroup())
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.muyu.domain;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 故障码,电子围栏,车辆,报文
|
||||
* @Author:yang
|
||||
* @Package:com.muyu.domain
|
||||
* @Project:cloud-server-8
|
||||
* @name:FaultCodeCache
|
||||
* @Date:2024/10/6 16:07
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@Tag(name = "故障码,电子围栏,车辆,报文")
|
||||
public class FaultCodeCache {
|
||||
|
||||
/**
|
||||
* 电子围栏信息
|
||||
*/
|
||||
private List<CarFence> carFences;
|
||||
|
||||
/**
|
||||
* 故障标签信息
|
||||
*/
|
||||
private WarnStrategy warnStrategies;
|
||||
|
||||
/**
|
||||
* 车辆信息
|
||||
*/
|
||||
public List<CarInformation> carInformation;
|
||||
|
||||
/**
|
||||
* 故障码信息
|
||||
*/
|
||||
private List<FaultCode> faultCode;
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
|||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.muyu.domain.req.FaultConditionAddReq;
|
||||
import com.muyu.domain.req.FaultConditionUpdReq;
|
||||
import com.muyu.domain.resp.FaultConditionTotalListResp;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
@ -39,7 +40,7 @@ public class FaultCondition {
|
|||
/**
|
||||
* 车辆类型Id
|
||||
*/
|
||||
private long carTypeId;
|
||||
private Long carTypeId;
|
||||
/**
|
||||
*故障名称Id
|
||||
*/
|
||||
|
@ -89,7 +90,11 @@ public class FaultCondition {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static FaultCondition faultConditionBuilder(FaultCondition faultCondition) {
|
||||
return FaultCondition.builder()
|
||||
.carconditionId(faultCondition.getCarconditionId())
|
||||
.carTypeId(faultCondition.getCarTypeId())
|
||||
.messageTypeId(faultCondition.getMessageTypeId())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,16 +47,22 @@ public class FaultLabel {
|
|||
private String messageTypeBelongs;
|
||||
|
||||
|
||||
public static FaultLabel addfaultLabel(FaultCodeAddReq faultCodeAddReq){
|
||||
public static FaultLabel addfaultLabel(FaultLabel faultLabel){
|
||||
return FaultLabel.builder()
|
||||
.messageTypeId(0)
|
||||
.messageTypeId(faultCodeAddReq.getMessageTypeId())
|
||||
.messageTypeCode(faultCodeAddReq.getMessageTypeCode())
|
||||
.messageTypeName(faultCodeAddReq.getMessageTypeName())
|
||||
.messageTypeBelongs(faultCodeAddReq.getMessageTypeBelongs())
|
||||
.messageTypeId(faultLabel.getMessageTypeId())
|
||||
.messageTypeCode(faultLabel.getMessageTypeCode())
|
||||
.messageTypeName(faultLabel.getMessageTypeName())
|
||||
.messageTypeBelongs(faultLabel.getMessageTypeBelongs())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static FaultLabel selectFaultLabel(FaultLabel faultLabel) {
|
||||
return FaultLabel.builder()
|
||||
.messageTypeId(faultLabel.messageTypeId)
|
||||
.messageTypeCode(faultLabel.messageTypeCode)
|
||||
.messageTypeName(faultLabel.messageTypeName)
|
||||
.messageTypeBelongs(faultLabel.messageTypeBelongs)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,12 +29,14 @@ public class Firm {
|
|||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String firmName;
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
private String databaseName;
|
||||
|
||||
/**
|
||||
* 企业权限Id
|
||||
*/
|
||||
private long permissionId;
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
package com.muyu.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 企业权限
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.domain
|
||||
* @Project:cloud-server-8
|
||||
* @name:FirmPermission
|
||||
* @Date:2024/10/7 9:13
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class FirmPermission {
|
||||
|
||||
/**
|
||||
* 企业权限Id
|
||||
*/
|
||||
@TableId(value = "permission_id")
|
||||
private long permissionId;
|
||||
|
||||
/**
|
||||
* 权限等级
|
||||
*/
|
||||
private String permissionLevel;
|
||||
|
||||
/**
|
||||
* 车辆数目
|
||||
*/
|
||||
private Integer carNumber;
|
||||
|
||||
/**
|
||||
* 车辆类型数目
|
||||
*/
|
||||
private Integer carTypeNumber;
|
||||
|
||||
|
||||
}
|
|
@ -78,7 +78,7 @@ public class CarInformationAddReq {
|
|||
/**
|
||||
* 车辆类型外键ID
|
||||
*/
|
||||
private Integer carInformationType;
|
||||
private Long carInformationType;
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class CarInformationUpdReq {
|
|||
* 车辆类型外键ID
|
||||
*/
|
||||
@Schema(title = "车辆类型外键ID", type = "Integer")
|
||||
private Integer carInformationType;
|
||||
private Long carInformationType;
|
||||
|
||||
/**
|
||||
* 是否重点车辆 (0否默认 1是 )
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.muyu.domain.req;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -21,6 +23,10 @@ import lombok.experimental.SuperBuilder;
|
|||
@Builder
|
||||
public class FaultCodeAddReq {
|
||||
|
||||
/**
|
||||
*故障码Id
|
||||
*/
|
||||
private long faultcodeId;
|
||||
/**
|
||||
*故障名称Id
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
package com.muyu.domain.req;
|
||||
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 修改企业权限请求对象
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.domain.req
|
||||
* @Project:cloud-server-8
|
||||
* @name:FirmUpdPermissionReq
|
||||
* @Date:2024/10/7 22:22
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Tag(name = "修改权限请求对象",description = "修改权限请求对象")
|
||||
public class FirmUpdPermissionReq {
|
||||
/**
|
||||
* 企业Id
|
||||
*/
|
||||
private Integer firmId;
|
||||
|
||||
/**
|
||||
* 企业权限等级
|
||||
*/
|
||||
private String permissionLevel;
|
||||
}
|
|
@ -38,7 +38,7 @@ public class CarInformationResp {
|
|||
*/
|
||||
// @TableName(value = "car_information_VIN")
|
||||
@TableField(value = "car_information_VIN")
|
||||
private String carInformationVin;
|
||||
private String carInformationVIN;
|
||||
/**
|
||||
* 车牌号
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.domain.resp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.muyu.domain.SysUser;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
@ -108,8 +109,28 @@ public class FirmListResp {
|
|||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
// @TableField(exist = false)
|
||||
private String firmName;
|
||||
/**
|
||||
* 企业权限Id
|
||||
*/
|
||||
private long permissionId;
|
||||
|
||||
/**
|
||||
* 权限等级
|
||||
*/
|
||||
private String permissionLevel;
|
||||
|
||||
/**
|
||||
* 车辆数目
|
||||
*/
|
||||
private Integer carNumber;
|
||||
|
||||
/**
|
||||
* 车辆类型数目
|
||||
*/
|
||||
private Integer carTypeNumber;
|
||||
|
||||
|
||||
/**
|
||||
* 数据库对象构建为返回结果对象
|
||||
|
|
|
@ -14,11 +14,16 @@
|
|||
cloud-modules-enterprise-server 企业业务服务
|
||||
</description>
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
<maven.compiler.target>21</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-saas</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- <dependency> -->
|
||||
<!-- <groupId>com.muyu</groupId> -->
|
||||
<!-- <artifactId>cloud-common-rabbit</artifactId> -->
|
||||
|
@ -39,10 +44,10 @@
|
|||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<!--apache.kafka<-->
|
||||
<dependency>
|
||||
<groupId>org.apache.kafka</groupId>
|
||||
<artifactId>kafka-clients</artifactId>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-carData</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
|
@ -96,9 +101,13 @@
|
|||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-common-kafka</artifactId>
|
||||
<artifactId>cloud-modules-carData</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>cloud-modules-enterprise-cache</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>cloud-electronic</finalName>
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package com.muyu.server;
|
||||
|
||||
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
||||
import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration;
|
||||
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
|
||||
/**
|
||||
* @Author:杨闪闪
|
||||
|
@ -13,7 +16,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
* @Date:2024/9/17 下午9:56
|
||||
*/
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = {
|
||||
DataSourceAutoConfiguration.class,
|
||||
DruidDataSourceAutoConfigure.class,
|
||||
DynamicDataSourceAutoConfiguration.class
|
||||
})
|
||||
@MapperScan("com.muyu.server.mapper")
|
||||
public class IntegrationApplication {
|
||||
public static void main(String[] args) {
|
||||
|
|
|
@ -36,10 +36,10 @@ public class CarFenceClazzController {
|
|||
@PostMapping("/selectClazz")
|
||||
@Operation(summary = "查询数据",description = "查询数据")
|
||||
public Result<List<CarFenceClazz>> selectConnect(){
|
||||
|
||||
List<CarFenceClazz> connects = carFenceClazzService.list();
|
||||
log.info("查询数据成功");
|
||||
return Result.success(
|
||||
|
||||
connects, "操作成功"
|
||||
);
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ public class CarFenceController {
|
|||
){
|
||||
Page<CarFenceResp> connects = carFenceService.selectCarFence(req);
|
||||
log.info("查询数据:"+ connects);
|
||||
|
||||
return Result.success(
|
||||
connects, "操作成功"
|
||||
);
|
||||
|
@ -58,13 +59,13 @@ public class CarFenceController {
|
|||
@Validated @RequestBody CarFence carFence
|
||||
){
|
||||
Boolean connects = carFenceService.addCarFence(carFence);
|
||||
|
||||
log.info("shd");
|
||||
return connects?Result.success(
|
||||
null, "操作成功"
|
||||
):Result.success(
|
||||
null, "操作失败"
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,6 +95,7 @@ public class CarFenceController {
|
|||
@Validated @RequestBody FenceGroupReq req
|
||||
){
|
||||
Boolean connects = carFenceService.addFenceGroup(req);
|
||||
|
||||
return connects?Result.success(
|
||||
null, "操作成功"
|
||||
):Result.success(
|
||||
|
@ -138,6 +140,7 @@ public class CarFenceController {
|
|||
@PostMapping("/carGroupList")
|
||||
@Operation(summary = "查询车辆围栏组数据",description = "查询车辆围栏组信息")
|
||||
public Result<List<CarFenceGroupsResp>> carGroupList(@RequestBody CarFenceGroupReq req){
|
||||
|
||||
List<CarFenceGroupsResp> connects = carFenceService.carGroupList(req);
|
||||
return Result.success(
|
||||
connects, "操作成功"
|
||||
|
|
|
@ -36,7 +36,9 @@ public class CarFenceTypeController {
|
|||
@PostMapping("/selectType")
|
||||
@Operation(summary = "查询数据",description = "查询数据")
|
||||
public Result<List<CarFenceType>> selectConnect(){
|
||||
|
||||
List<CarFenceType> connects = carFenceTypeService.list();
|
||||
|
||||
return Result.success(
|
||||
connects, "操作成功"
|
||||
);
|
||||
|
|
|
@ -4,15 +4,19 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.domain.CarFenceType;
|
||||
import com.muyu.domain.CarInformation;
|
||||
import com.muyu.domain.req.CarInformationAddReq;
|
||||
import com.muyu.domain.req.CarInformationListReq;
|
||||
import com.muyu.domain.req.CarInformationUpdReq;
|
||||
import com.muyu.domain.resp.CarInformationResp;
|
||||
import com.muyu.enterprise.cache.car.*;
|
||||
import com.muyu.server.service.CarInformationService;
|
||||
import com.muyu.server.util.ObtainRootLogin;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
@ -30,6 +34,11 @@ import java.util.List;
|
|||
public class CarInformationController {
|
||||
@Resource
|
||||
private CarInformationService carInformationService;
|
||||
private VehicleCacheCarInformationService vehicleCacheCarInformationService;
|
||||
private VehicleCacheCarInformationRespService vehicleCacheCarInformationRespService;
|
||||
private VehicleCacheCarInformationAddService vehicleCacheCarInformationAddService;
|
||||
private VehicleCacheCarInformationUpdService vehicleCacheCarInformationUpdService;
|
||||
private VehicleCacheCarInformationFenceRespService vehicleCacheCarInformationFenceRespService;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -38,10 +47,20 @@ public class CarInformationController {
|
|||
@PostMapping("/selectCarInformation")
|
||||
@Operation(summary = "查询数据",description = "查询数据")
|
||||
public Result<List<CarInformation>> selectConnect(){
|
||||
List<CarInformation> carFenceRespPage = vehicleCacheCarInformationService
|
||||
.get(vehicleCacheCarInformationService
|
||||
.keyPre()+ ObtainRootLogin
|
||||
.obtain());
|
||||
if (CollectionUtils.isEmpty(carFenceRespPage)) {
|
||||
return Result.success(carFenceRespPage);
|
||||
}
|
||||
List<CarInformation> connects = carInformationService.list()
|
||||
.stream()
|
||||
.map(CarInformation::carInformationBuilder)
|
||||
.toList();
|
||||
vehicleCacheCarInformationService.put(
|
||||
vehicleCacheCarInformationService.keyPre()+ObtainRootLogin.obtain()
|
||||
,connects);
|
||||
return Result.success(
|
||||
connects, "操作成功"
|
||||
);
|
||||
|
@ -68,8 +87,19 @@ public class CarInformationController {
|
|||
@PostMapping("/selectCarInformationList")
|
||||
@Operation(summary = "企业车辆管理列表")
|
||||
public Result<Page<CarInformationResp>> selectCarInformationList(@Validated @RequestBody CarInformationListReq carInformationListReq) {
|
||||
|
||||
Page<CarInformationResp> carFenceRespPage = vehicleCacheCarInformationRespService
|
||||
.get(vehicleCacheCarInformationRespService
|
||||
.keyPre()+ ObtainRootLogin
|
||||
.obtain());
|
||||
if (CollectionUtils.isEmpty(carFenceRespPage.getRecords())) {
|
||||
return Result.success(carFenceRespPage);
|
||||
}
|
||||
Page<CarInformationResp> pageInfo = carInformationService.selectCarInformationList(carInformationListReq);
|
||||
log.info("企业车辆管理列表查询",carInformationListReq,pageInfo);
|
||||
vehicleCacheCarInformationRespService.put(
|
||||
vehicleCacheCarInformationRespService.keyPre()+ObtainRootLogin.obtain()
|
||||
,pageInfo);
|
||||
return Result.success(pageInfo);
|
||||
|
||||
}
|
||||
|
@ -83,6 +113,10 @@ public class CarInformationController {
|
|||
@PostMapping("/addCarInformation")
|
||||
@Operation(summary = "企业车辆添加管理")
|
||||
public Result addCarInformation(@Validated @RequestBody CarInformationAddReq carInformationAddReq){
|
||||
|
||||
vehicleCacheCarInformationAddService.put(
|
||||
vehicleCacheCarInformationAddService
|
||||
.keyPre()+ObtainRootLogin.obtain(), carInformationAddReq);
|
||||
return carInformationService.addCarInformation(carInformationAddReq)
|
||||
?Result.success("添加车辆成功")
|
||||
:Result.error(402,"添加车辆失败");
|
||||
|
@ -114,7 +148,9 @@ public class CarInformationController {
|
|||
public Result updateCarMessage(@Validated @RequestBody CarInformationUpdReq carInformationUpdReq){
|
||||
boolean updatecarInformation = carInformationService.updatecarInformation(carInformationUpdReq);
|
||||
log.info(updatecarInformation);
|
||||
System.out.println("我在这个里:"+updatecarInformation);
|
||||
vehicleCacheCarInformationUpdService.put(
|
||||
vehicleCacheCarInformationUpdService
|
||||
.keyPre()+ObtainRootLogin.obtain(), carInformationUpdReq);
|
||||
if(updatecarInformation)
|
||||
{
|
||||
return Result.success(carInformationUpdReq,"修改成功");
|
||||
|
@ -133,7 +169,17 @@ public class CarInformationController {
|
|||
@GetMapping("/selectCarInformationIdAndLicensePlate")
|
||||
@Operation(summary = "查询企业车辆 carInformationID 和 carInformationLicensePlate")
|
||||
public Result<List<CarInformationResp>> selectCarInformationIdAndLicensePlate(){
|
||||
List<CarInformationResp> carFenceRespPage = vehicleCacheCarInformationFenceRespService
|
||||
.get(vehicleCacheCarInformationFenceRespService
|
||||
.keyPre()+ ObtainRootLogin
|
||||
.obtain());
|
||||
if (CollectionUtils.isEmpty(carFenceRespPage)) {
|
||||
return Result.success(carFenceRespPage);
|
||||
}
|
||||
List<CarInformationResp> carInformations = carInformationService.selectBycarInformationIDAndLicensePlate();
|
||||
vehicleCacheCarInformationFenceRespService.put(
|
||||
vehicleCacheCarInformationFenceRespService.keyPre()+ObtainRootLogin.obtain()
|
||||
,carInformations);
|
||||
return Result.success(carInformations);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ public class CarMessageController {
|
|||
@PostMapping("/selectCarMessageList")
|
||||
@Operation(summary = "报文模板展示列表")
|
||||
public Result<List<CarMessage>> selectCarMessageList(){
|
||||
|
||||
List<CarMessage> carMessages = carMessageService.selectCarMessageList();
|
||||
return Result.success(carMessages);
|
||||
}
|
||||
|
@ -42,10 +43,8 @@ public class CarMessageController {
|
|||
@PostMapping("/insertCarMessage")
|
||||
@Operation(summary = "添加报文信息")
|
||||
public Result<Integer> insertCarMessage(@Validated @RequestBody CarMessage carMessage){
|
||||
|
||||
int inserted = carMessageService.insertCarMessage(carMessage);
|
||||
if (inserted>0){
|
||||
return Result.success(200,"添加成功");
|
||||
}
|
||||
return Result.error(402,"添加失败");
|
||||
}
|
||||
|
||||
|
@ -57,6 +56,7 @@ public class CarMessageController {
|
|||
@Operation(summary = "删除报文信息")
|
||||
public Result<Integer> delectByCarMessageId(@RequestParam(name = "carMessageId") Integer carMessageId){
|
||||
int deleteByCarMessageId = carMessageService.delectByCarMessageId(carMessageId);
|
||||
|
||||
if (deleteByCarMessageId>0){
|
||||
return Result.success(200,"删除成功");
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ public class CarMessageController {
|
|||
@PostMapping("/updateCarMessage")
|
||||
@Operation(summary = "修改报文信息")
|
||||
public Result<Integer> updateCarMessage(@Validated @RequestBody CarMessage carMessage){
|
||||
|
||||
int updateCarMessage = carMessageService.updateCarMessage(carMessage);
|
||||
if(updateCarMessage>0)
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue