Merge remote-tracking branch 'origin/server_five_liuyunhu' into server_five_xiaoyao
# Conflicts: # couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/constant/ServiceNameConstants.java # couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/controller/VehicleController.java # couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/VehicleService.java # couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleServiceImpl.javaserver_five_liuyunhu
commit
6ab26976d6
|
@ -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
|
||||
# 共享配置
|
||||
|
|
|
@ -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
|
||||
# 共享配置
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -61,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);
|
||||
|
@ -78,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);
|
||||
|
||||
|
@ -95,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);
|
||||
|
||||
|
@ -112,7 +112,7 @@ 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);
|
||||
|
||||
|
@ -121,61 +121,17 @@ public class VehicleController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description 根据员工id查询员工下有哪些车
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("UserUnderTheVehicle/{userId}")
|
||||
public Result<List<Vehicle>> UserUnderTheVehicleList(@PathVariable Long userId){
|
||||
List<Vehicle> userVehicleList = vehicleService.UserUnderTheVehicleList(userId);
|
||||
Result<List<Vehicle>> success = Result.success(userVehicleList);
|
||||
return success;
|
||||
}
|
||||
* @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);
|
||||
|
||||
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description 删除员工所管理的车辆
|
||||
* @date
|
||||
*/
|
||||
@DeleteMapping("/{middleId}")
|
||||
public Result<Integer> deleteVehicle(@PathVariable Long middleId){
|
||||
Integer remove = vehicleService.deleteVehicle(middleId);
|
||||
return Result.success(remove);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description 添加员工车辆
|
||||
* @date
|
||||
*/
|
||||
@PostMapping
|
||||
public Result<Integer> addVehicle(@RequestBody VehicleMiddle vehicleMiddle){
|
||||
Integer i = vehicleService.addVehicle(vehicleMiddle);
|
||||
return Result.success(i);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @param null:
|
||||
* @return null
|
||||
* @author 付凡芮
|
||||
* @description 车辆列表查询
|
||||
* @date
|
||||
*/
|
||||
@PostMapping("vehicleAll")
|
||||
public Result<List<Vehicle>> VehicleManageList(){
|
||||
List<Vehicle> vehicleAll = vehicleService.vehicleAll();
|
||||
return Result.success(vehicleAll);
|
||||
return Result.success(list);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
/**
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -27,6 +27,8 @@ public interface VehicleService extends IService<Vehicle> {
|
|||
|
||||
List<Long> getBindLogoById(Long vehicleId);
|
||||
|
||||
List<Vehicle> findByVIN(String vin);
|
||||
|
||||
List<Vehicle> UserUnderTheVehicleList(Long userId);
|
||||
|
||||
Integer deleteVehicle(Long middleId);
|
||||
|
|
|
@ -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,6 +5,7 @@ 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;
|
||||
|
@ -16,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;
|
||||
|
@ -189,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();
|
||||
|
@ -198,6 +206,8 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
//切割,只留后17位
|
||||
vin = vin.substring(vin.length() - 17);
|
||||
|
||||
*/
|
||||
|
||||
|
||||
//创建入参对象
|
||||
Vehicle vehicle = new Vehicle();
|
||||
|
@ -273,4 +283,18 @@ public class VehicleServiceImpl extends ServiceImpl<VehicleMapper, Vehicle> impl
|
|||
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
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
||||
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);
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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