diff --git a/couplet-auth/src/main/resources/bootstrap.yml b/couplet-auth/src/main/resources/bootstrap.yml index 427f682..68c3c25 100644 --- a/couplet-auth/src/main/resources/bootstrap.yml +++ b/couplet-auth/src/main/resources/bootstrap.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 # 共享配置 diff --git a/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/constant/ServiceNameConstants.java b/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/constant/ServiceNameConstants.java index d8ed518..2cdf311 100644 --- a/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/constant/ServiceNameConstants.java +++ b/couplet-common/couplet-common-core/src/main/java/com/couplet/common/core/constant/ServiceNameConstants.java @@ -20,4 +20,9 @@ public class ServiceNameConstants { * 文件服务的serviceid */ public static final String FILE_SERVICE = "couplet-file"; + + /** + * 车辆服务的serviceid + */ + public static final String VEHICLE_SERVICE = "couplet-vehicle"; } diff --git a/couplet-gateway/src/main/resources/bootstrap.yml b/couplet-gateway/src/main/resources/bootstrap.yml index 091e68a..6dc39fe 100644 --- a/couplet-gateway/src/main/resources/bootstrap.yml +++ b/couplet-gateway/src/main/resources/bootstrap.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 # 共享配置 diff --git a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml b/couplet-modules/couplet-file/src/main/resources/bootstrap.yml index fa968e9..b0d1d24 100644 --- a/couplet-modules/couplet-file/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-file/src/main/resources/bootstrap.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 # 共享配置 diff --git a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml b/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml index fbabc20..b024662 100644 --- a/couplet-modules/couplet-gen/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-gen/src/main/resources/bootstrap.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 # 共享配置 diff --git a/couplet-modules/couplet-job/src/main/resources/bootstrap.yml b/couplet-modules/couplet-job/src/main/resources/bootstrap.yml index df563af..bb8e219 100644 --- a/couplet-modules/couplet-job/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-job/src/main/resources/bootstrap.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 # 共享配置 diff --git a/couplet-modules/couplet-modules-onLine/pom.xml b/couplet-modules/couplet-modules-onLine/pom.xml index 74327db..8f50175 100644 --- a/couplet-modules/couplet-modules-onLine/pom.xml +++ b/couplet-modules/couplet-modules-onLine/pom.xml @@ -91,6 +91,12 @@ 1.2.5 + + + com.couplet + couplet-modules-vehicle + + diff --git a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/OnlineApplication.java b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/OnlineApplication.java index d1b4a04..e68b054 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/OnlineApplication.java +++ b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/OnlineApplication.java @@ -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); diff --git a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java index cb2b57e..b50445b 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java +++ b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/MqttMonitor.java @@ -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 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 + "的车辆属于本系统,允许上线!"); + + } } diff --git a/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/ParseMessageUtil.java b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/ParseMessageUtil.java new file mode 100644 index 0000000..36a115e --- /dev/null +++ b/couplet-modules/couplet-modules-onLine/src/main/java/com/couplet/online/utils/ParseMessageUtil.java @@ -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; + } +} diff --git a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml index f690aa8..cd282a0 100644 --- a/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-onLine/src/main/resources/bootstrap.yml @@ -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 diff --git a/couplet-modules/couplet-modules-vehicle/pom.xml b/couplet-modules/couplet-modules-vehicle/pom.xml index 52301c1..37d941c 100644 --- a/couplet-modules/couplet-modules-vehicle/pom.xml +++ b/couplet-modules/couplet-modules-vehicle/pom.xml @@ -91,6 +91,11 @@ 1.4.1 + + com.couplet + couplet-common-core + + diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/controller/VehicleController.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/controller/VehicleController.java index 655dc34..0852945 100644 --- a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/controller/VehicleController.java +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/controller/VehicleController.java @@ -40,7 +40,7 @@ public class VehicleController extends BaseController { @RequiresPermissions("couplet:vehicle:list") @PostMapping("/list") @Log(title = "车辆列表") - public Result list(@RequestBody VehicleListParams listParams) { + public Result> list(@RequestBody VehicleListParams listParams) { PageHelper.startPage(listParams.getPageNum(), listParams.getPageSize()); List list = vehicleService.list(listParams); @@ -60,7 +60,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 deleteById(@PathVariable Long vehicleId) { String result = vehicleService.deleteById(vehicleId); return Result.success(result); @@ -77,7 +77,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 editById(@RequestBody VehicleEditParams editParams) { String result = vehicleService.editById(editParams); @@ -94,7 +94,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 insert(@RequestBody @Validated VehicleInsertParams insertParams) { System.out.println(insertParams); String result = vehicleService.insert(insertParams); @@ -111,11 +111,26 @@ public class VehicleController extends BaseController { **/ @RequiresPermissions("couplet:vehicle:list") @GetMapping("/getBindLogoById/{vehicleId}") - public Result getBindLogoById(@PathVariable("vehicleId") Long vehicleId) { + public Result> getBindLogoById(@PathVariable("vehicleId") Long vehicleId) { List 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> + **/ + @GetMapping("/findByVIN/{vin}") + public Result> findByVIN(@PathVariable("vin") String vin) { + List list = vehicleService.findByVIN(vin); + + return Result.success(list); + } } diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleInsertParams.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleInsertParams.java index 51c2279..afef401 100644 --- a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleInsertParams.java +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/domain/req/VehicleInsertParams.java @@ -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; /** diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/mapper/VehicleTypeMapper.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/mapper/VehicleTypeMapper.java index 4e406bc..f910181 100644 --- a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/mapper/VehicleTypeMapper.java +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/mapper/VehicleTypeMapper.java @@ -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; diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/remote/RemoteVehicleService.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/remote/RemoteVehicleService.java new file mode 100644 index 0000000..5d07889 --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/remote/RemoteVehicleService.java @@ -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> findByVIN(@PathVariable("vin") String vin); + + +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/remote/factory/RemoteVehicleFallbackFactory.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/remote/factory/RemoteVehicleFallbackFactory.java new file mode 100644 index 0000000..f7e14a5 --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/remote/factory/RemoteVehicleFallbackFactory.java @@ -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 { + 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> findByVIN(String vin) { + return Result.error("车辆服务调用失败:" + throwable.getMessage()); + } + }; + } +} diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/VehicleService.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/VehicleService.java index ee6b50f..60cb1c9 100644 --- a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/VehicleService.java +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/VehicleService.java @@ -25,4 +25,6 @@ public interface VehicleService extends IService { String insert(VehicleInsertParams insertParams); List getBindLogoById(Long vehicleId); + + List findByVIN(String vin); } diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleAndLogoServiceImpl.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleAndLogoServiceImpl.java index e5e5a5e..ec47bf4 100644 --- a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleAndLogoServiceImpl.java +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleAndLogoServiceImpl.java @@ -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; /** diff --git a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleServiceImpl.java b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleServiceImpl.java index 12e7591..8b37826 100644 --- a/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleServiceImpl.java +++ b/couplet-modules/couplet-modules-vehicle/src/main/java/com/couplet/vehicle/service/impl/VehicleServiceImpl.java @@ -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.vehicle.domain.Vehicle; import com.couplet.vehicle.domain.VehicleType; import com.couplet.vehicle.domain.req.VehicleEditParams; @@ -14,7 +15,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 +187,14 @@ public class VehicleServiceImpl extends ServiceImpl 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 +204,8 @@ public class VehicleServiceImpl extends ServiceImpl impl //切割,只留后17位 vin = vin.substring(vin.length() - 17); + */ + //创建入参对象 Vehicle vehicle = new Vehicle(); @@ -243,4 +253,18 @@ public class VehicleServiceImpl extends ServiceImpl impl return logoIds; } + @Override + public List findByVIN(String vin) { + + //创建查询条件包装器 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + + if (!StringUtils.isEmpty(vin)) { + queryWrapper.eq(Vehicle::getVin, vin); + } + + //执行查询 + return this.list(queryWrapper); + } + } diff --git a/couplet-modules/couplet-modules-vehicle/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/couplet-modules/couplet-modules-vehicle/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports new file mode 100644 index 0000000..872f2ce --- /dev/null +++ b/couplet-modules/couplet-modules-vehicle/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports @@ -0,0 +1 @@ +com.couplet.vehicle.remote.factory.RemoteVehicleFallbackFactory diff --git a/couplet-modules/couplet-modules-vehicle/src/main/resources/bootstrap.yml b/couplet-modules/couplet-modules-vehicle/src/main/resources/bootstrap.yml index f985e0c..0cb68b3 100644 --- a/couplet-modules/couplet-modules-vehicle/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-modules-vehicle/src/main/resources/bootstrap.yml @@ -29,4 +29,4 @@ spring: allow-bean-definition-overriding: true logging: level: - com.couplet.system.mapper: DEBUG + com.couplet.vehicle.mapper: DEBUG diff --git a/couplet-modules/couplet-modules-vehicle/src/test/java/IdTest.java b/couplet-modules/couplet-modules-vehicle/src/test/java/IdTest.java index 6cfd8e3..06b8ce7 100644 --- a/couplet-modules/couplet-modules-vehicle/src/test/java/IdTest.java +++ b/couplet-modules/couplet-modules-vehicle/src/test/java/IdTest.java @@ -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); } } diff --git a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml index aeddeaa..62d5318 100644 --- a/couplet-modules/couplet-system/src/main/resources/bootstrap.yml +++ b/couplet-modules/couplet-system/src/main/resources/bootstrap.yml @@ -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 # 共享配置 diff --git a/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml b/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml index d1064dc..d219500 100644 --- a/couplet-visual/couplet-monitor/src/main/resources/bootstrap.yml +++ b/couplet-visual/couplet-monitor/src/main/resources/bootstrap.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 # 共享配置 diff --git a/pom.xml b/pom.xml index 5f6d4c9..9d524f2 100644 --- a/pom.xml +++ b/pom.xml @@ -279,6 +279,13 @@ ${couplet.version} + + + com.couplet + couplet-modules-online + ${couplet.version} + +