Compare commits
7 Commits
bbd9e52302
...
6ab26976d6
Author | SHA1 | Date |
---|---|---|
|
6ab26976d6 | |
|
de572170ec | |
|
c7443b81d7 | |
|
ffa06bc02e | |
|
4b80034baf | |
|
831ba2668c | |
|
f9ec95317c |
|
@ -17,9 +17,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -20,4 +20,14 @@ public class ServiceNameConstants {
|
|||
* 文件服务的serviceid
|
||||
*/
|
||||
public static final String FILE_SERVICE = "couplet-file";
|
||||
|
||||
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description 车辆管理模块
|
||||
* @date
|
||||
*/
|
||||
public static final String VEHICLE_SERVICE = "couplet-vehicle";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>couplet-common-vehicle</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- MuYu Common Core-->
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common-core</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,89 @@
|
|||
package com.couplet.common.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
* @Author: LiuYunHu
|
||||
* @CreateTime: 2024/3/26
|
||||
* @Description: 车辆信息表
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("couplet_vehicle")
|
||||
public class Vehicle{
|
||||
/*
|
||||
*车辆id
|
||||
* */
|
||||
@TableId(type = IdType.AUTO, value = "vehicle_id")
|
||||
private Long vehicleId;
|
||||
|
||||
/*
|
||||
*车辆类型
|
||||
* */
|
||||
@TableField(value = "vehicle_type")
|
||||
private Long vehicleType;
|
||||
|
||||
/*
|
||||
* 车辆类型名称
|
||||
* */
|
||||
@TableField(exist = false)
|
||||
private String vehicleTypeName;
|
||||
|
||||
|
||||
/*
|
||||
*电机厂商
|
||||
* */
|
||||
@TableField(value = "motor_manufacturer")
|
||||
private String motorManufacturer;
|
||||
|
||||
/*
|
||||
*电池厂商
|
||||
* */
|
||||
@TableField(value = "battery_manufacturer")
|
||||
private String batteryManufacturer;
|
||||
|
||||
/*
|
||||
*电机编号
|
||||
* */
|
||||
@TableField(value = "motor_number")
|
||||
private String motorNumber;
|
||||
|
||||
/*
|
||||
*电池编号
|
||||
* */
|
||||
@TableField(value = "battery_number")
|
||||
private String batteryNumber;
|
||||
|
||||
/*
|
||||
*vin码
|
||||
* */
|
||||
@TableField(value = "vin")
|
||||
private String vin;
|
||||
|
||||
/*
|
||||
*0离线 1在线
|
||||
* */
|
||||
@TableField(value = "vehicle_state")
|
||||
private Integer vehicleState;
|
||||
|
||||
/*
|
||||
*0未删除 1删除
|
||||
* */
|
||||
@TableField(value = "isdelete")
|
||||
private Integer isdelete;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.couplet.common.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
* @Author: LiuYunHu
|
||||
* @CreateTime: 2024/3/30
|
||||
* @Description: 车辆和标志中间表
|
||||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("couplet_vehicle_and_logo")
|
||||
public class VehicleAndLogo {
|
||||
|
||||
/*
|
||||
* 车辆、标志中间表id
|
||||
* */
|
||||
@TableId(type = IdType.AUTO, value = "vehicle_logo_middle_id")
|
||||
private Long vehicleLogoMiddleId;
|
||||
|
||||
/*
|
||||
* 车辆id
|
||||
* */
|
||||
@TableField("vehicle_id")
|
||||
private Long vehicleId;
|
||||
|
||||
/*
|
||||
* 标志id
|
||||
* */
|
||||
@TableField("logo_id")
|
||||
private Long logoId;
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.couplet.common.system.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: TODO
|
||||
* @date 2024/4/2 11:22
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
@ToString
|
||||
public class VehicleMiddle{
|
||||
|
||||
private Long middleId;
|
||||
private Long userId;
|
||||
private Long vehicleId;
|
||||
private Long delFlag;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.couplet.common.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
* @Author: LiuYunHu
|
||||
* @CreateTime: 2024/3/31
|
||||
* @Description: 车辆类型
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("couplet_vehicle_type")
|
||||
public class VehicleType {
|
||||
|
||||
/*
|
||||
* 车辆类型id
|
||||
* */
|
||||
@TableId(type = IdType.AUTO, value = "vehicle_type_id")
|
||||
private Long vehicleTypeId;
|
||||
|
||||
/*
|
||||
* 车辆类型名称
|
||||
* */
|
||||
@TableField(value = "vehicle_type_name")
|
||||
private String vehicleTypeName;
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.couplet.common.system.remote;
|
||||
|
||||
import com.couplet.common.core.constant.ServiceNameConstants;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.system.domain.Vehicle;
|
||||
import com.couplet.common.system.domain.VehicleMiddle;
|
||||
import com.couplet.common.system.remote.factory.RemoteVehicleFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(contextId = "remoteVehicleService" ,
|
||||
value = ServiceNameConstants.VEHICLE_SERVICE,
|
||||
fallbackFactory = RemoteVehicleFallbackFactory.class,
|
||||
path = "/vehicle"
|
||||
)
|
||||
public interface RemoteVehicleService {
|
||||
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description 根据员工id查询员工下有哪些车
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("UserUnderTheVehicle/{userId}")
|
||||
public Result<List<Vehicle>> UserUnderTheVehicleList(@PathVariable(value = "userId") Long userId);
|
||||
|
||||
|
||||
/*
|
||||
* @param middleId:
|
||||
* @return Result<Integer>
|
||||
* @author 付凡芮
|
||||
* @description 删除员工管理的车辆
|
||||
* @date
|
||||
*/
|
||||
@DeleteMapping("/{middleId}")
|
||||
public Result<Integer> deleteVehicle(@PathVariable(value = "middleId") Long middleId);
|
||||
|
||||
|
||||
@PostMapping
|
||||
public Result<Integer> addVehicle(@RequestBody VehicleMiddle vehicleMiddle);
|
||||
|
||||
|
||||
|
||||
@PostMapping("vehicleAll")
|
||||
public Result<List<Vehicle>> VehicleManageList();
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.couplet.common.system.remote.factory;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.system.domain.Vehicle;
|
||||
import com.couplet.common.system.domain.VehicleMiddle;
|
||||
import com.couplet.common.system.remote.RemoteVehicleService;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: TODO
|
||||
* @date 2024/4/2 14:46
|
||||
*/
|
||||
public class RemoteVehicleFallbackFactory implements FallbackFactory<RemoteVehicleService> {
|
||||
|
||||
|
||||
@Override
|
||||
public RemoteVehicleService create(Throwable cause) {
|
||||
return new RemoteVehicleService() {
|
||||
@Override
|
||||
public Result<List<Vehicle>> UserUnderTheVehicleList(Long userId) {
|
||||
return Result.error("调用失败...."+cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Integer> deleteVehicle(Long middleId) {
|
||||
return Result.error("调用失败...."+cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Integer> addVehicle(VehicleMiddle vehicleMiddle) {
|
||||
return Result.error("调用失败....."+cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<List<Vehicle>> VehicleManageList() {
|
||||
return Result.error("调用失败....."+cause.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
com.couplet.common.system.remote.factory.RemoteVehicleFallbackFactory
|
|
@ -19,6 +19,7 @@
|
|||
<module>couplet-common-datasource</module>
|
||||
<module>couplet-common-system</module>
|
||||
<module>couplet-trouble-log</module>
|
||||
<module>couplet-common-vehicle</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>couplet-common</artifactId>
|
||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -82,6 +82,17 @@
|
|||
<artifactId>couplet-common-swagger</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-modules-vehicle</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common-vehicle</artifactId>
|
||||
<version>3.6.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
package com.couplet.server.controller;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.system.domain.Vehicle;
|
||||
import com.couplet.common.system.domain.VehicleMiddle;
|
||||
import com.couplet.server.service.VehicleManageService;
|
||||
import io.swagger.v3.oas.annotations.parameters.RequestBody;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: 车辆管理控制层
|
||||
* @date 2024/4/2 9:05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/VehicleManage")
|
||||
public class VehicleManageController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private VehicleManageService vehicleManageService;
|
||||
|
||||
/*
|
||||
* @param :
|
||||
* @return Result<List<Vehicle>>
|
||||
* @author 付凡芮
|
||||
* @description Y管理车辆列表
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("/VehicleManageList")
|
||||
public Result<List<Vehicle>> VehicleManageList(){
|
||||
List<Vehicle> vehicles = vehicleManageService.VehicleManageList();
|
||||
Result<List<Vehicle>> success = Result.success(vehicles);
|
||||
return success;
|
||||
}
|
||||
/*
|
||||
* @param middleId:
|
||||
* @return Result<Integer>
|
||||
* @author 付凡芮
|
||||
* @description 删除员工管理的车辆
|
||||
* @date
|
||||
*/
|
||||
|
||||
@DeleteMapping("/{middleId}")
|
||||
public Result deleteVehicle(@PathVariable(value = "middleId") Long middleId){
|
||||
return vehicleManageService.deleteVehicle(middleId);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param middle:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 添加车辆
|
||||
* @date
|
||||
*/
|
||||
@PostMapping
|
||||
public Result addVehicle(@RequestBody VehicleMiddle middle){
|
||||
return vehicleManageService.addVehicle(middle);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("vehicleAll")
|
||||
public Result<List<Vehicle>> vehicleAll(){
|
||||
List<Vehicle> vehicles = vehicleManageService.vehicleAll();
|
||||
return Result.success(vehicles);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.couplet.server.service;
|
||||
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.system.domain.Vehicle;
|
||||
import com.couplet.common.system.domain.VehicleMiddle;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface VehicleManageService {
|
||||
List<Vehicle> VehicleManageList();
|
||||
|
||||
|
||||
Result deleteVehicle(Long middleId);
|
||||
|
||||
Result addVehicle(VehicleMiddle middle);
|
||||
|
||||
List<Vehicle> vehicleAll();
|
||||
|
||||
}
|
|
@ -91,6 +91,14 @@ public class EmployeeServiceImpl implements EmployeeService{
|
|||
return remoteEmployeeService.changeStatus(user);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param user:
|
||||
* @return List<SysUser>
|
||||
* @author 付凡芮
|
||||
* @description 员工管理列表
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> userList(SysUser user) {
|
||||
String username = SecurityUtils.getUsername();
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
package com.couplet.server.service.impl;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import com.couplet.common.system.domain.Vehicle;
|
||||
import com.couplet.common.system.domain.VehicleMiddle;
|
||||
import com.couplet.common.system.remote.RemoteVehicleService;
|
||||
import com.couplet.server.service.VehicleManageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: 车辆管理服务实现类
|
||||
* @date 2024/4/2 9:05
|
||||
*/
|
||||
@Service
|
||||
public class VehicleManageServiceImpl implements VehicleManageService{
|
||||
|
||||
|
||||
@Autowired
|
||||
private RemoteVehicleService remoteVehicleService;
|
||||
|
||||
/*
|
||||
* @description: 车辆管理列表
|
||||
* @param: []
|
||||
* @return: com.couplet.common.core.domain.Result<java.util.List<com.couplet.common.system.domain.Vehicle>>
|
||||
*/
|
||||
@Override
|
||||
public List<Vehicle> VehicleManageList() {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
Result<List<Vehicle>> listResult = remoteVehicleService.UserUnderTheVehicleList(userId);
|
||||
List<Vehicle> list = listResult.getData();
|
||||
return list;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param middleId:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 删除员工管理车辆
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result deleteVehicle(Long middleId) {
|
||||
Result<Integer> integerResult = remoteVehicleService.deleteVehicle(middleId);
|
||||
Integer resultData = integerResult.getData();
|
||||
|
||||
return resultData==1?Result.success():Result.error("删除失败");
|
||||
}
|
||||
|
||||
/*
|
||||
* @param middle:
|
||||
* @return Result
|
||||
* @author 付凡芮
|
||||
* @description 添加车辆
|
||||
* @date
|
||||
*/
|
||||
@Override
|
||||
public Result addVehicle(VehicleMiddle middle) {
|
||||
Long userId = SecurityUtils.getUserId();
|
||||
middle.setUserId(userId);
|
||||
Result<Integer> integerResult = remoteVehicleService.addVehicle(middle);
|
||||
Integer resultData = integerResult.getData();
|
||||
return resultData==1?Result.success():Result.error("添加失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vehicle> vehicleAll() {
|
||||
Result<List<Vehicle>> listResult = remoteVehicleService.VehicleManageList();
|
||||
return listResult.getData();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -17,9 +17,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -17,9 +17,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -91,6 +91,12 @@
|
|||
<version>1.2.5</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 注入车辆服务,调用接口-->
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-modules-vehicle</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
//@EnableFeignClients
|
||||
public class OnlineApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(OnlineApplication.class);
|
||||
|
|
|
@ -1,12 +1,18 @@
|
|||
package com.couplet.online.utils;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.couplet.common.redis.service.RedisService;
|
||||
import com.couplet.vehicle.domain.Vehicle;
|
||||
import com.couplet.vehicle.remote.RemoteVehicleService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.*;
|
||||
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
|
@ -54,6 +60,14 @@ public class MqttMonitor {
|
|||
@Value("${mqtt.server.qos}")
|
||||
private Integer qos;
|
||||
|
||||
//远程调用
|
||||
@Autowired
|
||||
private RemoteVehicleService remoteVehicleService;
|
||||
|
||||
//redis
|
||||
@Autowired
|
||||
private RedisService redis;
|
||||
|
||||
|
||||
//随项目启动而执行这个方法
|
||||
@PostConstruct
|
||||
|
@ -81,7 +95,21 @@ public class MqttMonitor {
|
|||
client.setCallback(new MqttCallback() {
|
||||
@Override
|
||||
public void connectionLost(Throwable throwable) {
|
||||
// 处理连接断开的情况
|
||||
// 在这里执行重连操作
|
||||
log.error("连接丢失:{}", throwable.getMessage());
|
||||
while (!client.isConnected()) {
|
||||
try {
|
||||
//等待五秒后重新连接
|
||||
Thread.sleep(5000);
|
||||
//重新连接
|
||||
client.reconnect();
|
||||
log.info("重连中...");
|
||||
} catch (InterruptedException | MqttException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,14 +121,42 @@ public class MqttMonitor {
|
|||
//接收到的原始报文
|
||||
String message = new String(mqttMessage.getPayload());
|
||||
|
||||
log.info("接收消息原始内容:{}", message);
|
||||
// log.info("接收消息原始内容:{}", message);
|
||||
|
||||
//去除空格 得到16进制字符串
|
||||
String replaced = message.replaceAll(" ", "");
|
||||
log.info("接收消息剪切后内容:{}", replaced);
|
||||
//解析后的字符串
|
||||
String parseMsg = ParseMessageUtil.parseMsg(message);
|
||||
|
||||
//拿到前17位(车辆vin码)
|
||||
String start17 = parseMsg.substring(0, 17);
|
||||
|
||||
|
||||
log.info("当前车辆的vin码为:" + start17);
|
||||
|
||||
//判断缓存中是否有这个vin
|
||||
if (redis.hasKey("不存在的车辆VIN:" + start17)) {
|
||||
|
||||
//可使用RabbitMQ发送消息
|
||||
log.error("vin码为" + start17 + "的车辆不属于本系统!");
|
||||
}
|
||||
|
||||
//调取接口,通过vin查询车辆
|
||||
List<Vehicle> vehicles = remoteVehicleService.findByVIN(start17).getData();
|
||||
|
||||
//如果不存在这个车
|
||||
if (vehicles.isEmpty()) {
|
||||
//将不属于自己系统的车辆存入缓存,便于提前进行拒绝提示
|
||||
redis.setCacheObject("不存在的车辆VIN:" + start17, start17);
|
||||
log.error("未找到vin码为" + start17 + "的车辆信息");
|
||||
} else {
|
||||
//如果存在这个车
|
||||
Vehicle vehicle = vehicles.get(0);
|
||||
System.out.println("***********" + vehicle + "***********");
|
||||
//存入redis
|
||||
redis.setCacheObject("存在的车辆VIN:" + start17, JSON.toJSONString(vehicle));
|
||||
|
||||
log.info("vin码为" + start17 + "的车辆属于本系统,允许上线!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package com.couplet.online.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
* @Author: LiuYunHu
|
||||
* @CreateTime: 2024/4/2
|
||||
* @Description: 初步解析报文工具类
|
||||
*/
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class ParseMessageUtil {
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/4/2 14:58
|
||||
* @Description: 将16进制字符串转换为ASCII字符串
|
||||
* @Param: [hexString]
|
||||
* @Return: java.lang.String
|
||||
**/
|
||||
public static String hexToString(String hexString) {
|
||||
StringBuffer asciiString = new StringBuffer();
|
||||
|
||||
for (int i = 0; i < hexString.length(); i += 2) {
|
||||
String hex = hexString.substring(i, i + 2);
|
||||
int decimal = Integer.parseInt(hex, 16);
|
||||
asciiString.append((char) decimal);
|
||||
}
|
||||
return asciiString.toString();
|
||||
}
|
||||
|
||||
public static String parseMsg(String msg) {
|
||||
//去头去尾
|
||||
String substring = msg.substring(2, msg.length() - 2);
|
||||
// log.info("去头去尾的报文:" + substring);
|
||||
|
||||
//去空格
|
||||
String hexStringWithoutSpaces = substring.replaceAll("\\s+", "");
|
||||
|
||||
//转换为ASCII字符串
|
||||
String asciiString = hexToString(hexStringWithoutSpaces);
|
||||
|
||||
// log.info("解析后报文:" + asciiString);
|
||||
|
||||
return asciiString;
|
||||
}
|
||||
}
|
|
@ -35,9 +35,10 @@ logging:
|
|||
mqtt:
|
||||
server:
|
||||
broker: tcp://115.159.47.13:1883
|
||||
# broker: mqtt://115.159.47.13:1883
|
||||
username:
|
||||
password:
|
||||
clientId: lyh
|
||||
clientId: fluxmq
|
||||
qos: 0
|
||||
topic: test
|
||||
|
||||
|
|
|
@ -91,6 +91,11 @@
|
|||
<version>1.4.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.couplet</groupId>
|
||||
<artifactId>couplet-common-core</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.couplet.common.log.annotation.Log;
|
|||
import com.couplet.common.log.enums.BusinessType;
|
||||
import com.couplet.common.security.annotation.RequiresPermissions;
|
||||
import com.couplet.vehicle.domain.Vehicle;
|
||||
import com.couplet.vehicle.domain.VehicleMiddle;
|
||||
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
||||
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||
import com.couplet.vehicle.domain.req.VehicleListParams;
|
||||
|
@ -60,7 +61,7 @@ public class VehicleController extends BaseController {
|
|||
@RequiresPermissions("couplet:vehicle:deleteById")
|
||||
@GetMapping("/deleteById/{vehicleId}")
|
||||
@Log(title = "删除车辆", businessType = BusinessType.DELETE)
|
||||
public Result deleteById(@PathVariable Long vehicleId) {
|
||||
public Result<String> deleteById(@PathVariable Long vehicleId) {
|
||||
String result = vehicleService.deleteById(vehicleId);
|
||||
|
||||
return Result.success(result);
|
||||
|
@ -77,7 +78,7 @@ public class VehicleController extends BaseController {
|
|||
@RequiresPermissions("couplet:vehicle:editById")
|
||||
@PostMapping("/editById")
|
||||
@Log(title = "编辑车辆", businessType = BusinessType.UPDATE)
|
||||
public Result editById(@RequestBody VehicleEditParams editParams) {
|
||||
public Result<String> editById(@RequestBody VehicleEditParams editParams) {
|
||||
|
||||
String result = vehicleService.editById(editParams);
|
||||
|
||||
|
@ -94,7 +95,7 @@ public class VehicleController extends BaseController {
|
|||
@RequiresPermissions("couplet:vehicle:insert")
|
||||
@PostMapping("/insert")
|
||||
@Log(title = "新增车辆", businessType = BusinessType.INSERT)
|
||||
public Result insert(@RequestBody @Validated VehicleInsertParams insertParams) {
|
||||
public Result<String> insert(@RequestBody @Validated VehicleInsertParams insertParams) {
|
||||
System.out.println(insertParams);
|
||||
String result = vehicleService.insert(insertParams);
|
||||
|
||||
|
@ -111,11 +112,26 @@ public class VehicleController extends BaseController {
|
|||
**/
|
||||
@RequiresPermissions("couplet:vehicle:list")
|
||||
@GetMapping("/getBindLogoById/{vehicleId}")
|
||||
public Result getBindLogoById(@PathVariable("vehicleId") Long vehicleId) {
|
||||
public Result<List<Long>> getBindLogoById(@PathVariable("vehicleId") Long vehicleId) {
|
||||
|
||||
List<Long> bindLogoById = vehicleService.getBindLogoById(vehicleId);
|
||||
|
||||
|
||||
return Result.success(bindLogoById);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @Author: LiuYunHu
|
||||
* @Date: 2024/4/2 15:35
|
||||
* @Description: 通过vin码查询车辆
|
||||
* @Param: [vin]
|
||||
* @Return: com.couplet.common.core.domain.Result<java.util.List<com.couplet.vehicle.domain.Vehicle>>
|
||||
**/
|
||||
@GetMapping("/findByVIN/{vin}")
|
||||
public Result<List<Vehicle>> findByVIN(@PathVariable("vin") String vin) {
|
||||
List<Vehicle> list = vehicleService.findByVIN(vin);
|
||||
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,11 +17,11 @@ import lombok.experimental.SuperBuilder;
|
|||
*/
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("couplet_vehicle")
|
||||
public class Vehicle {
|
||||
public class Vehicle{
|
||||
|
||||
|
||||
/*
|
||||
*车辆id
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package com.couplet.vehicle.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* @author fufanrui
|
||||
* @version 1.0
|
||||
* @description: TODO
|
||||
* @date 2024/4/2 11:22
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class VehicleMiddle{
|
||||
|
||||
private Long middleId;
|
||||
private Long userId;
|
||||
private Long vehicleId;
|
||||
private Long delFlag;
|
||||
}
|
|
@ -7,7 +7,6 @@ import lombok.experimental.SuperBuilder;
|
|||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Size;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,9 +2,12 @@ package com.couplet.vehicle.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.couplet.vehicle.domain.Vehicle;
|
||||
import com.couplet.vehicle.domain.VehicleMiddle;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
* @Author: LiuYunHu
|
||||
|
@ -14,4 +17,11 @@ import org.springframework.stereotype.Component;
|
|||
@Mapper
|
||||
@Component
|
||||
public interface VehicleMapper extends BaseMapper<Vehicle> {
|
||||
List<Vehicle> UserUnderTheVehicleList(Long userId);
|
||||
|
||||
Integer deleteVehicle(Long middleId);
|
||||
|
||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
||||
|
||||
List<Vehicle> vehicleAll();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.couplet.vehicle.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.couplet.vehicle.domain.Vehicle;
|
||||
import com.couplet.vehicle.domain.VehicleType;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package com.couplet.vehicle.remote;
|
||||
|
||||
import com.couplet.common.core.constant.ServiceNameConstants;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.vehicle.domain.Vehicle;
|
||||
import com.couplet.vehicle.remote.factory.RemoteVehicleFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆服务
|
||||
*
|
||||
* @author couplet
|
||||
*/
|
||||
@FeignClient(contextId = "remoteVehicleService",value = ServiceNameConstants.VEHICLE_SERVICE, fallbackFactory = RemoteVehicleFallbackFactory.class, path = "/vehicle")
|
||||
@Component
|
||||
public interface RemoteVehicleService {
|
||||
|
||||
@GetMapping("/findByVIN/{vin}")
|
||||
public Result<List<Vehicle>> findByVIN(@PathVariable("vin") String vin);
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.couplet.vehicle.remote.factory;
|
||||
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.vehicle.domain.Vehicle;
|
||||
import com.couplet.vehicle.remote.RemoteVehicleService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 车辆服务降级处理
|
||||
*
|
||||
* @author couplet
|
||||
*/
|
||||
@Component
|
||||
public class RemoteVehicleFallbackFactory implements FallbackFactory<RemoteVehicleService> {
|
||||
private static final Logger log = LoggerFactory.getLogger(RemoteVehicleFallbackFactory.class);
|
||||
|
||||
@Override
|
||||
public RemoteVehicleService create(Throwable throwable) {
|
||||
log.error("车辆服务调用失败:{}", throwable.getMessage());
|
||||
return new RemoteVehicleService() {
|
||||
|
||||
@Override
|
||||
public Result<List<Vehicle>> findByVIN(String vin) {
|
||||
return Result.error("车辆服务调用失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@ package com.couplet.vehicle.service;
|
|||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.couplet.vehicle.domain.Vehicle;
|
||||
import com.couplet.vehicle.domain.VehicleMiddle;
|
||||
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
||||
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||
import com.couplet.vehicle.domain.req.VehicleListParams;
|
||||
|
@ -25,4 +26,15 @@ public interface VehicleService extends IService<Vehicle> {
|
|||
String insert(VehicleInsertParams insertParams);
|
||||
|
||||
List<Long> getBindLogoById(Long vehicleId);
|
||||
|
||||
List<Vehicle> findByVIN(String vin);
|
||||
|
||||
List<Vehicle> UserUnderTheVehicleList(Long userId);
|
||||
|
||||
Integer deleteVehicle(Long middleId);
|
||||
|
||||
Integer addVehicle(VehicleMiddle vehicleMiddle);
|
||||
|
||||
List<Vehicle> vehicleAll();
|
||||
|
||||
}
|
||||
|
|
|
@ -8,7 +8,6 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,7 +5,10 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.couplet.common.core.domain.Result;
|
||||
import com.couplet.common.core.utils.StringUtils;
|
||||
import com.couplet.common.core.utils.uuid.UUID;
|
||||
import com.couplet.common.security.utils.SecurityUtils;
|
||||
import com.couplet.vehicle.domain.Vehicle;
|
||||
import com.couplet.vehicle.domain.VehicleMiddle;
|
||||
import com.couplet.vehicle.domain.VehicleType;
|
||||
import com.couplet.vehicle.domain.req.VehicleEditParams;
|
||||
import com.couplet.vehicle.domain.req.VehicleInsertParams;
|
||||
|
@ -14,7 +17,6 @@ import com.couplet.vehicle.mapper.VehicleMapper;
|
|||
import com.couplet.vehicle.service.VehicleAndLogoService;
|
||||
import com.couplet.vehicle.service.VehicleService;
|
||||
import com.couplet.vehicle.service.VehicleTypeService;
|
||||
import com.couplet.vehicle.utils.SnowflakeIdGenerator;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -187,6 +189,14 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
}
|
||||
|
||||
|
||||
//UUID生成17位随机字符串
|
||||
UUID uuid = UUID.randomUUID();
|
||||
String string = uuid.toString();
|
||||
String s = string.replaceAll("-", "");
|
||||
String vin = s.substring(0, 17);
|
||||
// System.out.println(vin+" "+vin.length());
|
||||
|
||||
/*
|
||||
//雪花算法生成随机数
|
||||
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||
long randomId = idGenerator.nextId();
|
||||
|
@ -196,6 +206,8 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
//切割,只留后17位
|
||||
vin = vin.substring(vin.length() - 17);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//创建入参对象
|
||||
Vehicle vehicle = new Vehicle();
|
||||
|
@ -243,4 +255,46 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
return logoIds;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param userId:
|
||||
* @return List<Vehicle>
|
||||
* @author 付凡芮
|
||||
* @description 根据登入人id查询管理车辆
|
||||
*
|
||||
*/
|
||||
@Override
|
||||
public List<Vehicle> UserUnderTheVehicleList(Long userId) {
|
||||
return vehicleMapper.UserUnderTheVehicleList(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer deleteVehicle(Long middleId) {
|
||||
return vehicleMapper.deleteVehicle(middleId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer addVehicle(VehicleMiddle vehicleMiddle) {
|
||||
|
||||
return vehicleMapper.addVehicle(vehicleMiddle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vehicle> vehicleAll() {
|
||||
return vehicleMapper.vehicleAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Vehicle> findByVIN(String vin) {
|
||||
|
||||
//创建查询条件包装器
|
||||
LambdaQueryWrapper<Vehicle> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
if (!StringUtils.isEmpty(vin)) {
|
||||
queryWrapper.eq(Vehicle::getVin, vin);
|
||||
}
|
||||
|
||||
//执行查询
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
com.couplet.vehicle.remote.factory.RemoteVehicleFallbackFactory
|
|
@ -29,4 +29,4 @@ spring:
|
|||
allow-bean-definition-overriding: true
|
||||
logging:
|
||||
level:
|
||||
com.couplet.system.mapper: DEBUG
|
||||
com.couplet.vehicle.mapper: DEBUG
|
||||
|
|
|
@ -5,4 +5,59 @@
|
|||
<mapper namespace="com.couplet.vehicle.mapper.VehicleMapper">
|
||||
|
||||
|
||||
<sql id="selectMiddleUserOrVehicle">
|
||||
SELECT
|
||||
m.middle_id,
|
||||
m.user_id,
|
||||
m.vehicle_id,
|
||||
m.del_flag,
|
||||
v.vehicle_type,
|
||||
v.motor_manufacturer,
|
||||
v.battery_manufacturer,
|
||||
v.motor_number,
|
||||
v.battery_number,
|
||||
v.vin,
|
||||
v.vehicle_state,
|
||||
t.vehicle_type_name
|
||||
FROM
|
||||
`couplet_middle` m
|
||||
LEFT JOIN couplet_vehicle v ON m.vehicle_id = v.vehicle_id
|
||||
LEFT JOIN couplet_vehicle_type t ON v.vehicle_id = t.vehicle_type_id
|
||||
WHERE m.del_flag = 0
|
||||
</sql>
|
||||
<sql id="selectVehicle">
|
||||
select
|
||||
v.vehicle_id,
|
||||
v.motor_manufacturer,
|
||||
v.battery_manufacturer,
|
||||
v.motor_number,
|
||||
v.battery_number,
|
||||
v.vin,
|
||||
v.vehicle_state,
|
||||
t.vehicle_type_name
|
||||
from couplet_vehicle v
|
||||
left join couplet_vehicle_type t on v.vehicle_type = t.vehicle_type_id
|
||||
where v.isdelete = 0
|
||||
</sql>
|
||||
<insert id="addVehicle">
|
||||
INSERT INTO `couplet-cloud`.`couplet_middle` (`user_id`, `vehicle_id`, `del_flag`) VALUES
|
||||
<foreach collection="vehicleId" item="vehicleId" separator=",">
|
||||
(#{userId}, #{vehicleId}, 0)
|
||||
</foreach>
|
||||
</insert>
|
||||
<delete id="deleteVehicle">
|
||||
update couplet_middle
|
||||
set del_flag = '2'
|
||||
where middle_id = #{middleId}
|
||||
</delete>
|
||||
|
||||
<select id="UserUnderTheVehicleList" resultType="com.couplet.vehicle.domain.Vehicle">
|
||||
<include refid="selectMiddleUserOrVehicle"/>
|
||||
<if test="userId!=null">
|
||||
AND m.user_id = #{userId}
|
||||
</if>
|
||||
</select>
|
||||
<select id="vehicleAll" resultType="com.couplet.vehicle.domain.Vehicle">
|
||||
<include refid="selectVehicle"/>
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import com.couplet.vehicle.utils.SnowflakeIdGenerator;
|
||||
import com.couplet.common.core.utils.uuid.UUID;
|
||||
|
||||
/**
|
||||
* @ProjectName: five-groups-couplet
|
||||
|
@ -11,23 +11,32 @@ public class IdTest {
|
|||
|
||||
|
||||
public static void main(String[] args) {
|
||||
SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||
|
||||
long l = idGenerator.nextId();
|
||||
String s = "VIN" + l;
|
||||
System.out.println(l);
|
||||
System.out.println(s);
|
||||
System.out.println("剪切前长度:" + s.length());
|
||||
// SnowflakeIdGenerator idGenerator = new SnowflakeIdGenerator(1, 1);
|
||||
//
|
||||
// long l = idGenerator.nextId();
|
||||
// String s = "VIN" + l;
|
||||
// System.out.println(l);
|
||||
// System.out.println(s);
|
||||
// System.out.println("剪切前长度:" + s.length());
|
||||
//
|
||||
//
|
||||
// String last17 = s.substring(s.length() - 17);
|
||||
// System.out.println("剪切后:"+last17+" 长度:"+last17.length());
|
||||
//
|
||||
//
|
||||
// System.out.println("----------------------");
|
||||
//
|
||||
// String s1 = "1224069209961664512";
|
||||
// String substring = s1.substring(s1.length() - 17);
|
||||
// System.out.println(substring);
|
||||
for (int i = 0; i < 22; i++) {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
String string = uuid.toString();
|
||||
String s = string.replaceAll("-", "");
|
||||
String substring = s.substring(0, 17);
|
||||
System.out.println(substring);
|
||||
}
|
||||
|
||||
|
||||
String last17 = s.substring(s.length() - 17);
|
||||
System.out.println("剪切后:"+last17+" 长度:"+last17.length());
|
||||
|
||||
|
||||
System.out.println("----------------------");
|
||||
|
||||
String s1 = "1224069209961664512";
|
||||
String substring = s1.substring(s1.length() - 17);
|
||||
System.out.println(substring);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ public class SysDeptController extends BaseController {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*根据deptId获取企业名称
|
||||
*/
|
||||
@GetMapping("/getSysDeptByDeptId/{deptId}")
|
||||
public Result<List<SysDept>> getSysDeptByDeptId(@PathVariable(value = "deptId") Long deptId){
|
||||
|
|
|
@ -16,9 +16,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
|||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 121.89.211.230:8848
|
||||
namespace: 172469
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
|
|
Loading…
Reference in New Issue