+ * 版本号具有以下含意: + *
+ * 变体号具有以下含意: + *
+ * 60 位的时间戳值根据此 {@code UUID} 的 time_low、time_mid 和 time_hi 字段构造。
+ * 所得到的时间戳以 100 毫微秒为单位,从 UTC(通用协调时间) 1582 年 10 月 15 日零时开始。
+ *
+ *
+ * 时间戳值仅在在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 {@code UUID} 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
+ *
+ * @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。
+ */
+ public long timestamp () throws UnsupportedOperationException {
+ checkTimeBase();
+ return (mostSigBits & 0x0FFFL) << 48//
+ | ((mostSigBits >> 16) & 0x0FFFFL) << 32//
+ | mostSigBits >>> 32;
+ }
+
+ /**
+ * 与此 UUID 相关联的时钟序列值。
+ *
+ *
+ * 14 位的时钟序列值根据此 UUID 的 clock_seq 字段构造。clock_seq 字段用于保证在基于时间的 UUID 中的时间唯一性。 + *
+ * {@code clockSequence} 值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。 如果此 UUID 不是基于时间的 UUID,则此方法抛出 + * UnsupportedOperationException。 + * + * @return 此 {@code UUID} 的时钟序列 + * + * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1 + */ + public int clockSequence () throws UnsupportedOperationException { + checkTimeBase(); + return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48); + } + + /** + * 与此 UUID 相关的节点值。 + * + *
+ * 48 位的节点值根据此 UUID 的 node 字段构造。此字段旨在用于保存机器的 IEEE 802 地址,该地址用于生成此 UUID 以保证空间唯一性。 + *
+ * 节点值仅在基于时间的 UUID(其 version 类型为 1)中才有意义。
+ * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
+ *
+ * @return 此 {@code UUID} 的节点值
+ *
+ * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
+ */
+ public long node () throws UnsupportedOperationException {
+ checkTimeBase();
+ return leastSigBits & 0x0000FFFFFFFFFFFFL;
+ }
+
+ /**
+ * 返回此{@code UUID} 的字符串表现形式。
+ *
+ *
+ * UUID 的字符串表示形式由此 BNF 描述: + * + *
+ * {@code + * UUID =+ * + * + * + * @return 此{@code UUID} 的字符串表现形式 + * + * @see #toString(boolean) + */ + @Override + public String toString () { + return toString(false); + } + + /** + * 返回此{@code UUID} 的字符串表现形式。 + * + *- - - - + * time_low = 4* + * time_mid = 2* + * time_high_and_version = 2* + * variant_and_sequence = 2* + * node = 6* + * hexOctet = + * hexDigit = [0-9a-fA-F] + * } + *
+ * UUID 的字符串表示形式由此 BNF 描述: + * + *
+ * {@code + * UUID =+ * + * + * + * @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串 + * + * @return 此{@code UUID} 的字符串表现形式 + */ + public String toString (boolean isSimple) { + final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36); + // time_low + builder.append(digits(mostSigBits >> 32, 8)); + if (false == isSimple) { + builder.append('-'); + } + // time_mid + builder.append(digits(mostSigBits >> 16, 4)); + if (false == isSimple) { + builder.append('-'); + } + // time_high_and_version + builder.append(digits(mostSigBits, 4)); + if (false == isSimple) { + builder.append('-'); + } + // variant_and_sequence + builder.append(digits(leastSigBits >> 48, 4)); + if (false == isSimple) { + builder.append('-'); + } + // node + builder.append(digits(leastSigBits, 12)); + + return builder.toString(); + } + + // Comparison Operations + + /** + * 返回此 UUID 的哈希码。 + * + * @return UUID 的哈希码值。 + */ + @Override + public int hashCode () { + long hilo = mostSigBits ^ leastSigBits; + return ((int) (hilo >> 32)) ^ (int) hilo; + } + + // ------------------------------------------------------------------------------------------------------------------- + // Private method start + + /** + * 将此对象与指定对象比较。 + *- - - - + * time_low = 4* + * time_mid = 2* + * time_high_and_version = 2* + * variant_and_sequence = 2* + * node = 6* + * hexOctet = + * hexDigit = [0-9a-fA-F] + * } + *
+ * 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。 + * + * @param obj 要与之比较的对象 + * + * @return 如果对象相同,则返回 {@code true};否则返回 {@code false} + */ + @Override + public boolean equals (Object obj) { + if ((null == obj) || (obj.getClass() != UUID.class)) { + return false; + } + UUID id = (UUID) obj; + return (mostSigBits == id.mostSigBits && leastSigBits == id.leastSigBits); + } + + /** + * 将此 UUID 与指定的 UUID 比较。 + * + *
+ * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。
+ *
+ * @param val 与此 UUID 比较的 UUID
+ *
+ * @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。
+ */
+ @Override
+ public int compareTo (UUID val) {
+ // The ordering is intentionally set up so that the UUIDs
+ // can simply be numerically compared as two numbers
+ return (this.mostSigBits < val.mostSigBits ? -1 : //
+ (this.mostSigBits > val.mostSigBits ? 1 : //
+ (this.leastSigBits < val.leastSigBits ? -1 : //
+ (this.leastSigBits > val.leastSigBits ? 1 : //
+ 0))));
+ }
+
+ /**
+ * 检查是否为time-based版本UUID
+ */
+ private void checkTimeBase () {
+ if (version() != 1) {
+ throw new UnsupportedOperationException("Not a time-based UUID");
+ }
+ }
+
+ /**
+ * SecureRandom 的单例
+ */
+ private static class Holder {
+ static final SecureRandom numberGenerator = getSecureRandom();
+ }
+}
diff --git a/src/main/java/com/muyu/loadCenter/config/AliConfig.java b/src/main/java/com/muyu/loadCenter/config/AliConfig.java
new file mode 100644
index 0000000..a3a623b
--- /dev/null
+++ b/src/main/java/com/muyu/loadCenter/config/AliConfig.java
@@ -0,0 +1,54 @@
+package com.muyu.loadCenter.config;
+
+import com.aliyun.ecs20140526.Client;
+import com.aliyun.teaopenapi.models.Config;
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @ProjectName: LoadCenter
+ * @PackageName: com.muyu.loadCenter.aliyun.config
+ * @Description 阿里云配置类
+ * @Author HuangDaJu
+ * @Date 2024/4/16 14:48
+ * @Version 1.0
+ */
+
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "config.ali")
+public class AliConfig {
+
+
+ /**
+ * access-key-id
+ */
+ private String accessKeyId;
+ /**
+ * access-key-secret
+ */
+ private String accessKeySecret;
+ /**
+ * 地域id
+ */
+ private String regionId;
+
+
+
+ @Bean
+ public Client createEcsClient(AliConfig aliConfig) throws Exception {
+ Config config = new Config()
+ // 您的AccessKey ID
+ .setAccessKeyId(aliConfig.getAccessKeyId())
+ // 您的AccessKey Secret
+ .setAccessKeySecret(aliConfig.getAccessKeySecret())
+ // 您的可用区ID
+ .setRegionId(aliConfig.getRegionId());
+ return new Client(config);
+ }
+
+
+
+}
diff --git a/src/main/java/com/muyu/loadCenter/config/InstanceConfig.java b/src/main/java/com/muyu/loadCenter/config/InstanceConfig.java
new file mode 100644
index 0000000..b92276b
--- /dev/null
+++ b/src/main/java/com/muyu/loadCenter/config/InstanceConfig.java
@@ -0,0 +1,62 @@
+package com.muyu.loadCenter.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ *创建实例的参数映射yml
+ */
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "config.instance")
+public class InstanceConfig {
+
+ /**
+ * 地域Id
+ */
+ private String regionId;
+ /**
+ * 镜像 ID,启动实例时选择的镜像资源。
+ */
+ private String imageId;
+ /**
+ * 实例规格
+ */
+ private String instanceType;
+ /**
+ * 安全组id
+ */
+ private String securityGroupId;
+ /**
+ * 虚拟交换机
+ */
+ private String vSwitchId;
+ /**
+ * 公网出带宽最大值,单位为 Mbit/s。取值范围:0~100。 默认值:0。
+ */
+ private String internetMaxBandwidthOut;
+ /**
+ * 系统盘大小
+ */
+ private String size;
+ /**
+ * 系统盘的云盘种类
+ */
+ private String category;
+ /**
+ * ECS实例的计费方式
+ */
+ private String instanceChargeType;
+ /**
+ * 网络计费类型。取值范围:
+ */
+ private String internetChargeType;
+
+
+
+
+
+
+
+}
diff --git a/src/main/java/com/muyu/loadCenter/config/RestClientConfig.java b/src/main/java/com/muyu/loadCenter/config/RestClientConfig.java
new file mode 100644
index 0000000..338339a
--- /dev/null
+++ b/src/main/java/com/muyu/loadCenter/config/RestClientConfig.java
@@ -0,0 +1,23 @@
+package com.muyu.loadCenter.config;//package com.muyu.business.domain.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+/**
+ * @ProjectName: cloud-vehicles
+ * @PackageName: com.muyu.system.common.domain.config
+ * @Description TODO
+ * @Author XiaoFan
+ * @Date 2024/4/2 19:37
+ * @Version 1.0
+ */
+@Configuration
+public class RestClientConfig {
+ @Bean
+ public RestTemplate restTemplate(){
+ return new RestTemplate();
+ }
+
+
+}
diff --git a/src/main/java/com/muyu/loadCenter/controller/GatewayController.java b/src/main/java/com/muyu/loadCenter/controller/GatewayController.java
new file mode 100644
index 0000000..f076407
--- /dev/null
+++ b/src/main/java/com/muyu/loadCenter/controller/GatewayController.java
@@ -0,0 +1,49 @@
+package com.muyu.loadCenter.controller;
+
+import com.muyu.loadCenter.domain.Result;
+import com.muyu.loadCenter.service.GatewayLoadService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @ProjectName: load_center
+ * @PackageName: com.muyu.loadCenter.controller
+ * @Description 网关控制层->车辆控制
+ * @Author HuangDaJu
+ * @Date 2024/4/18 14:14
+ * @Version 1.0
+ */
+@RestController
+@RequestMapping("/gateway")
+public class GatewayController {
+
+ @Autowired
+ private GatewayLoadService gatewayLoadService;
+
+ /**
+ * 发送上线请求,返回一个节点id
+ */
+ @GetMapping("/load/node")
+ public Result