xuhy
2024-10-08 1e4e5e6eea1793f774f6ba8d710bb0b3e80aa039
Merge remote-tracking branch 'origin/master'
27个文件已修改
9个文件已添加
875 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/model/TChargingPile.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/factory/IotInterfaceFallbackFactory.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/factory/SecurityDetectionFallbackFactory.java 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/factory/SendMessageFallbackFactory.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/IotInterfaceClient.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/SecurityDetectionClient.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/SendMessageClient.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/model/PlatformStartChargingReply.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/model/SecurityDetection.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/vo/AddDevice.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/vo/AddDeviceResp.java 69 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/vo/DeleteDeviceResp.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-auth/src/main/resources/bootstrap.yml 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-gateway/src/main/resources/bootstrap.yml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/pom.xml 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WxLoginController.java 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/bootstrap.yml 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingGunServiceImpl.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/resources/bootstrap.yml 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/controller/SecurityDetectionController.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/controller/IotInterfaceController.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/api/IotInterfaceUtil.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/mongodb/service/SecurityDetectionService.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/mongodb/service/impl/SecurityDetectionServiceImpl.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/resources/bootstrap.yml 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/bootstrap.yml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/bootstrap.yml 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-payment/src/main/resources/bootstrap.yml 55 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/model/TChargingPile.java
@@ -96,4 +96,8 @@
    @ApiModelProperty(value = "设备状态(1=工作中,2=离线,3=故障)")
    @TableField("status")
    private Integer status;
    @ApiModelProperty(value = "iotd设备id")
    @TableField("iotd_device_id")
    private String iotdDeviceId;
}
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/factory/IotInterfaceFallbackFactory.java
New file
@@ -0,0 +1,40 @@
package com.ruoyi.integration.api.factory;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.integration.api.feignClient.IotInterfaceClient;
import com.ruoyi.integration.api.feignClient.SwitchwayGateClient;
import com.ruoyi.integration.api.vo.AddDevice;
import com.ruoyi.integration.api.vo.AddDeviceResp;
import com.ruoyi.integration.api.vo.DeleteDeviceResp;
import com.ruoyi.integration.api.vo.SwitchwayGateReq;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
 * 充电桩服务降级处理
 *
 * @author ruoyi
 */
@Component
public class IotInterfaceFallbackFactory implements org.springframework.cloud.openfeign.FallbackFactory<IotInterfaceClient> {
    private static final Logger log = LoggerFactory.getLogger(IotInterfaceFallbackFactory.class);
    @Override
    public IotInterfaceClient create(Throwable throwable) {
        log.error("调用失败:{}", throwable.getMessage());
        return new IotInterfaceClient() {
            @Override
            public R<AddDeviceResp> addDevice(AddDevice addDevice) {
                return R.fail("添加设备失败:" + throwable.getMessage());
            }
            @Override
            public R<DeleteDeviceResp> deleteDevice(String deviceId) {
                return R.fail("删除设备失败:" + throwable.getMessage());
            }
        };
    }
}
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/factory/SecurityDetectionFallbackFactory.java
New file
@@ -0,0 +1,35 @@
package com.ruoyi.integration.api.factory;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.integration.api.feignClient.SecurityDetectionClient;
import com.ruoyi.integration.api.feignClient.SendMessageClient;
import com.ruoyi.integration.api.model.PlatformStartCharging;
import com.ruoyi.integration.api.model.PlatformStopCharging;
import com.ruoyi.integration.api.model.QrCodeDelivery;
import com.ruoyi.integration.api.model.SecurityDetection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
/**
 * 充电桩服务降级处理
 *
 * @author ruoyi
 */
@Component
public class SecurityDetectionFallbackFactory implements org.springframework.cloud.openfeign.FallbackFactory<SecurityDetectionClient>
{
    private static final Logger log = LoggerFactory.getLogger(SecurityDetectionFallbackFactory.class);
    @Override
    public SecurityDetectionClient create(Throwable throwable) {
        log.error("调用失败:{}", throwable.getMessage());
        return new SecurityDetectionClient() {
            @Override
            public R<SecurityDetection> getSecurityDetection(String transactionSerialNumber) {
                return R.fail("获取安全检测数据失败:" + throwable.getMessage());
            }
        };
    }
}
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/factory/SendMessageFallbackFactory.java
@@ -6,6 +6,7 @@
import com.ruoyi.integration.api.model.ChargingHandshake;
import com.ruoyi.integration.api.model.PlatformStartCharging;
import com.ruoyi.integration.api.model.PlatformStopCharging;
import com.ruoyi.integration.api.model.QrCodeDelivery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
@@ -36,6 +37,11 @@
            public String platformStopCharging(PlatformStopCharging platformStopCharging) {
                return "远程停机失败";
            }
            @Override
            public String qrCodeDelivery(QrCodeDelivery qrCodeDelivery) {
                return "二维码下发失败";
            }
        };
    }
}
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/IotInterfaceClient.java
New file
@@ -0,0 +1,38 @@
package com.ruoyi.integration.api.feignClient;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.integration.api.factory.IotInterfaceFallbackFactory;
import com.ruoyi.integration.api.vo.AddDevice;
import com.ruoyi.integration.api.vo.AddDeviceResp;
import com.ruoyi.integration.api.vo.DeleteDeviceResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * @author zhibing.pu
 * @Date 2024/10/8 10:24
 */
@FeignClient(contextId = "IotInterfaceClient", value = ServiceNameConstants.INTEGRATION_SERVICE, fallbackFactory = IotInterfaceFallbackFactory.class)
public interface IotInterfaceClient {
    /**
     * 添加设备
     * @param addDevice
     * @return
     */
    @PostMapping("/iotInterface/addDevice")
    R<AddDeviceResp> addDevice(@RequestBody AddDevice addDevice);
    /**
     * 删除设备
     * @param deviceId
     * @return
     */
    @PostMapping("/iotInterface/deleteDevice")
    R<DeleteDeviceResp> deleteDevice(@RequestParam("deviceId") String deviceId);
}
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/SecurityDetectionClient.java
New file
@@ -0,0 +1,26 @@
package com.ruoyi.integration.api.feignClient;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.integration.api.factory.SecurityDetectionFallbackFactory;
import com.ruoyi.integration.api.model.SecurityDetection;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
/**
 * @author zhibing.pu
 * @Date 2024/10/8 14:23
 */
@FeignClient(contextId = "SecurityDetectionClient", value = ServiceNameConstants.INTEGRATION_SERVICE, fallbackFactory = SecurityDetectionFallbackFactory.class)
public interface SecurityDetectionClient {
    /**
     * 获取安全检测数据
     * @param transactionSerialNumber
     * @return
     */
    @PostMapping("/securityDetection/getSecurityDetection")
    R<SecurityDetection> getSecurityDetection(@RequestParam("transactionSerialNumber") String transactionSerialNumber);
}
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/SendMessageClient.java
@@ -4,6 +4,7 @@
import com.ruoyi.integration.api.factory.SendMessageFallbackFactory;
import com.ruoyi.integration.api.model.PlatformStartCharging;
import com.ruoyi.integration.api.model.PlatformStopCharging;
import com.ruoyi.integration.api.model.QrCodeDelivery;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -32,4 +33,13 @@
     */
    @PostMapping("/sendMessage/platformStopCharging")
    String platformStopCharging(@RequestBody PlatformStopCharging platformStopCharging);
    /**
     * 二维码下发
     * @param qrCodeDelivery
     * @return
     */
    @PostMapping("/sendMessage/qrCodeDelivery")
    String qrCodeDelivery(@RequestBody QrCodeDelivery qrCodeDelivery);
}
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/model/PlatformStartChargingReply.java
@@ -15,7 +15,6 @@
@Document(collection = "platform_start_charging_reply") //指定要对应的文档名(表名)
@Accessors(chain = true)
public class PlatformStartChargingReply extends BaseModel {
    @Id
    private String transaction_serial_number; // 交易流水号
    private String charging_pile_code; // 桩编码
    private String charging_gun_code; // 抢号
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/model/SecurityDetection.java
@@ -9,8 +9,7 @@
@Document(collection = "security_detection") //指定要对应的文档名(表名)
@Accessors(chain = true)
public class SecurityDetection {
    @Id
    private String transaction_serial_number; // 交易流水号
    private String charging_pile_code; // 桩编码
    private String charging_gun_code; // 抢号
    private Integer secure_connection; // 车枪连接(0=未连接,1=连接)
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/vo/AddDevice.java
New file
@@ -0,0 +1,27 @@
package com.ruoyi.integration.api.vo;
import lombok.Data;
/**
 * @author zhibing.pu
 * @Date 2024/10/8 10:26
 */
@Data
public class AddDevice {
    /**
     * 产品ID
     */
    private String productId;
    /**
     * 设备标识码  设备编号
     */
    private String nodeId;
    /**
     * 设备名称
     */
    private String deviceName;
    /**
     * 设备描述
     */
    private String description;
}
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/vo/AddDeviceResp.java
New file
@@ -0,0 +1,69 @@
package com.ruoyi.integration.api.vo;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
 * @author zhibing.pu
 * @Date 2024/10/8 10:37
 */
@Data
public class AddDeviceResp {
    private int httpStatusCode;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("app_id")
    private String appId;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("app_name")
    private String appName;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("device_id")
    private String deviceId;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("node_id")
    private String nodeId;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("gateway_id")
    private String gatewayId;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("device_name")
    private String deviceName;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("node_type")
    private String nodeType;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("description")
    private String description;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("fw_version")
    private String fwVersion;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("sw_version")
    private String swVersion;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("device_sdk_version")
    private String deviceSdkVersion;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("product_id")
    private String productId;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("product_name")
    private String productName;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("status")
    private String status;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("create_time")
    private String createTime;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("connection_status_update_time")
    private String connectionStatusUpdateTime;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("active_time")
    private String activeTime;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("extension_info")
    private Object extensionInfo;
}
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/vo/DeleteDeviceResp.java
New file
@@ -0,0 +1,19 @@
package com.ruoyi.integration.api.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
/**
 * @author zhibing.pu
 * @Date 2024/10/8 10:40
 */
@Data
public class DeleteDeviceResp {
    @JsonIgnore
    private int httpStatusCode;
    @JsonInclude(JsonInclude.Include.NON_NULL)
    @JsonProperty("body")
    private String body;
}
ruoyi-api/ruoyi-api-integration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -4,4 +4,6 @@
com.ruoyi.integration.api.factory.SendMessageFallbackFactory
com.ruoyi.integration.api.factory.PlatformStartChargingReplyFallbackFactory
com.ruoyi.integration.api.factory.PlatformStopChargingReplyFallbackFactory
com.ruoyi.integration.api.factory.SwitchwayGateFallbackFactory
com.ruoyi.integration.api.factory.SwitchwayGateFallbackFactory
com.ruoyi.integration.api.factory.IotInterfaceFallbackFactory
com.ruoyi.integration.api.factory.SecurityDetectionFallbackFactory
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java
@@ -16,6 +16,7 @@
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import java.util.List;
@@ -76,7 +77,7 @@
            }
            @Override
            public R<Long> getCar() {
            public R<Long> getCar(@PathVariable("id")String id) {
                return R.fail("获取用户最近使用车辆充电的车辆id:" + throwable.getMessage());
            }
    
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java
@@ -69,8 +69,8 @@
     * 获取用户最近使用车辆充电的车辆id
     * @return
     */
    @GetMapping(value = "/t-charging-order/getCar")
    public R<Long> getCar();
    @GetMapping(value = "/t-charging-order/getCar/{id}")
    public R<Long> getCar(@PathVariable("id")String id);
    
    
    /**
ruoyi-auth/src/main/resources/bootstrap.yml
@@ -6,7 +6,8 @@
spring:
  profiles:
    # 环境配置
    active: dev
#    active: dev
    active: prod
  application:
    # 应用名称
    name: ruoyi-auth
@@ -55,52 +56,52 @@
    type: nacos
    nacos:
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      data-id: seata-server.properties
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
  registry:
    type: nacos
    nacos:
      application: seata-server
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
  cloud:
    nacos:
      discovery:
        # 开发环境
        server-addr: 192.168.110.169:8848 # nacos注册中心地址
        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
        # 生产环境
#        server-addr: 192.168.0.137:8848,192.168.0.123:8848
#        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#        server-addr: 192.168.110.169:8848 # nacos注册中心地址
#        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
#        group: DEFAULT_GROUP
#        application: seata-server #Nacos 中 Seata 名称
#        username: nacos
#        password: nacos
        # 生产环境
        server-addr: 192.168.0.137:8848,192.168.0.123:8848
        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
    sentinel:
      transport:
        dashboard: 127.0.0.1:8080  #  Sentinel控制台地址
ruoyi-gateway/src/main/resources/bootstrap.yml
@@ -12,7 +12,8 @@
    allow-bean-definition-overriding: true
  profiles:
    # 环境配置
    active: dev
#    active: dev
    active: prod
---
spring:
  config:
ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
@@ -11,7 +11,8 @@
    allow-bean-definition-overriding: true
  profiles:
    # 环境配置
    active: dev
#    active: dev
    active: prod
---
spring:
  config:
@@ -54,52 +55,52 @@
    type: nacos
    nacos:
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      data-id: seata-server.properties
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
  registry:
    type: nacos
    nacos:
      application: seata-server
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
  cloud:
    nacos:
      discovery:
        # 开发环境
        server-addr: 192.168.110.169:8848 # nacos注册中心地址
        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
        # 生产环境
#        server-addr: 192.168.0.137:8848,192.168.0.123:8848
#        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#        server-addr: 192.168.110.169:8848 # nacos注册中心地址
#        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
#        group: DEFAULT_GROUP
#        application: seata-server #Nacos 中 Seata 名称
#        username: nacos
#        password: nacos
        # 生产环境
        server-addr: 192.168.0.137:8848,192.168.0.123:8848
        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
    sentinel:
      transport:
        dashboard: 127.0.0.1:8080  #  Sentinel控制台地址
ruoyi-service/ruoyi-account/pom.xml
@@ -16,11 +16,6 @@
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-mock</artifactId>
            <version>2.0.8</version>
        </dependency>
        <dependency>
            <groupId>com.ruoyi</groupId>
            <artifactId>ruoyi-api-order</artifactId>
        </dependency>
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java
@@ -113,7 +113,7 @@
        List<TAppUserCar> cars = appUserCarService.list(new QueryWrapper<TAppUserCar>()
                .eq("app_user_id",tokenService.getLoginUserApplet().getUserId())
                .orderByDesc("create_time"));
        Long data1 = chargingOrderClient.getCar().getData();
        Long data1 = chargingOrderClient.getCar(tokenService.getLoginUserApplet().getUserId().toString()).getData();
        Integer data2 = otherClient.getAddCarIntegral().getData();
        data.setIntegral(data2);
        if (!cars.isEmpty()){
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WxLoginController.java
@@ -30,7 +30,7 @@
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.mock.web.MockMultipartFile;
//import org.springframework.mock.web.MockMultipartFile;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;
@@ -63,11 +63,11 @@
    private WeixinProperties wxConfig;
    @Autowired
    private RestTemplate wxRestTemplate;
    /**
     * 上传文件存储在本地的根路径
     */
    @Value("${file.path}")
    private String localFilePath;
//    /**
//     * 上传文件存储在本地的根路径
//     */
//    @Value("${file.path}")
//    private String localFilePath;
    @ApiOperation(value = "通过code获得openid,获取用户信息",tags = {"微信小程序登录"})
    @PostMapping("/openIdByJsCode")
    public AjaxResult<Map<String, Object>> openIdByJsCode(@RequestBody AppletUserEncrypteData data) {
@@ -99,9 +99,9 @@
    public AjaxResult<Map<String, Object>> openIdByJsCode(@RequestBody AppletUserDecodeData appletUserDecodeData) {
        return AjaxResult.success(appUserService.wxLogin(appletUserDecodeData, null));
    }
    public static MultipartFile convertInputStreamToMultipartFile(InputStream inputStream, String fileName, String contentType) throws IOException {
        return new MockMultipartFile(fileName, fileName, contentType, inputStream);
    }
//    public static MultipartFile convertInputStreamToMultipartFile(InputStream inputStream, String fileName, String contentType) throws IOException {
//        return new MockMultipartFile(fileName, fileName, contentType, inputStream);
//    }
    @ApiOperation(value = "获取微信小程序二维码",tags = {"获取微信小程序二维码"})
    @PostMapping("/getQRCode")
    public AjaxResult getQRCode() {
@@ -132,10 +132,10 @@
            System.err.println(Base64.encodeBase64String(result));
            inputStream = new ByteArrayInputStream(result);
            String finalFileName = System.currentTimeMillis() + "" + new SecureRandom().nextInt(0x0400) + ".jpeg";
            MultipartFile multipartFile = convertInputStreamToMultipartFile(inputStream, finalFileName, "image/jpeg");
            String name = FileUploadUtils.upload(localFilePath, multipartFile);
            System.err.println(name);
            return AjaxResult.success(name);
//            MultipartFile multipartFile = convertInputStreamToMultipartFile(inputStream, finalFileName, "image/jpeg");
//            String name = FileUploadUtils.upload(localFilePath, multipartFile);
//            System.err.println(name);
            return AjaxResult.success(null);
        } catch (Exception e) {
            System.err.println("调用小程序生成微信永久小程序码URL接口异常" + e);
        } finally {
ruoyi-service/ruoyi-account/src/main/resources/bootstrap.yml
@@ -12,7 +12,8 @@
    allow-circular-references: true
  profiles:
    # 环境配置
    active: dev
#    active: dev
    active: prod
---
spring:
  config:
@@ -55,52 +56,52 @@
    type: nacos
    nacos:
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      data-id: seata-server.properties
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
  registry:
    type: nacos
    nacos:
      application: seata-server
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
  cloud:
    nacos:
      discovery:
        # 开发环境
        server-addr: 192.168.110.169:8848 # nacos注册中心地址
        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
        # 生产环境
#        server-addr: 192.168.0.137:8848,192.168.0.123:8848
#        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#        server-addr: 192.168.110.169:8848 # nacos注册中心地址
#        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
#        group: DEFAULT_GROUP
#        application: seata-server #Nacos 中 Seata 名称
#        username: nacos
#        password: nacos
        # 生产环境
        server-addr: 192.168.0.137:8848,192.168.0.123:8848
        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
    sentinel:
      transport:
        dashboard: 192.168.0.137:8080  #  Sentinel控制台地址
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingGunServiceImpl.java
@@ -19,6 +19,8 @@
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.integration.api.feignClient.SendMessageClient;
import com.ruoyi.integration.api.model.QrCodeDelivery;
import com.ruoyi.other.api.feignClient.RoleSiteClient;
import com.ruoyi.other.api.feignClient.UserSiteClient;
import com.ruoyi.system.api.domain.SysUser;
@@ -60,6 +62,9 @@
    @Resource
    private SysUserRoleClient sysUserRoleClient;
    @Resource
    private SendMessageClient sendMessageClient;
    
    
@@ -116,6 +121,17 @@
            return AjaxResult.error("接口编码已存在");
        }
        this.save(dto);
        TChargingPile chargingPile = chargingPileService.getById(dto.getChargingPileId());
        //下发硬件充电二维码
        String code_prefix = "https://mxcd.zhinenganguan.com?No=";
        QrCodeDelivery qrCodeDelivery = new QrCodeDelivery();
        qrCodeDelivery.setCharging_pile_code(chargingPile.getCode());
        qrCodeDelivery.setCode_format(1);
        qrCodeDelivery.setPrefix_length(code_prefix.length());
        qrCodeDelivery.setCode_prefix(code_prefix);
        qrCodeDelivery.setQr_code(code_prefix + chargingPile.getCode() + dto.getCode());
        sendMessageClient.qrCodeDelivery(qrCodeDelivery);
        return AjaxResult.success();
    }
    
@@ -141,6 +157,17 @@
            return AjaxResult.error("接口编码已存在");
        }
        this.updateById(dto);
        TChargingPile chargingPile = chargingPileService.getById(dto.getChargingPileId());
        //下发硬件充电二维码
        String code_prefix = "https://mxcd.zhinenganguan.com?No=";
        QrCodeDelivery qrCodeDelivery = new QrCodeDelivery();
        qrCodeDelivery.setCharging_pile_code(chargingPile.getCode());
        qrCodeDelivery.setCode_format(1);
        qrCodeDelivery.setPrefix_length(code_prefix.length());
        qrCodeDelivery.setCode_prefix(code_prefix);
        qrCodeDelivery.setQr_code(code_prefix + chargingPile.getCode() + dto.getCode());
        sendMessageClient.qrCodeDelivery(qrCodeDelivery);
        return AjaxResult.success();
    }
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java
@@ -23,12 +23,17 @@
import com.ruoyi.chargingPile.service.ISiteService;
import com.ruoyi.chargingPile.service.TChargingGunService;
import com.ruoyi.chargingPile.service.TChargingPileService;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.PageInfo;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.integration.api.feignClient.IotInterfaceClient;
import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient;
import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData;
import com.ruoyi.integration.api.vo.AddDevice;
import com.ruoyi.integration.api.vo.AddDeviceResp;
import com.ruoyi.integration.api.vo.DeleteDeviceResp;
import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient;
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
import com.ruoyi.order.api.model.TChargingOrder;
@@ -93,6 +98,9 @@
    @Resource
    private SysUserRoleClient sysUserRoleClient;
    
    @Resource
    private IotInterfaceClient iotInterfaceClient;
    
    
    
@@ -151,7 +159,20 @@
        if(count > 0){
            return AjaxResult.error("设备编号已存在");
        }
        this.save(chargingPile);
        //调用华为Iot创建设备
        AddDevice addDevice = new AddDevice();
        addDevice.setProductId("66da68d21837002b28b34ec0");
        addDevice.setNodeId(chargingPile.getCode());
        addDevice.setDeviceName(chargingPile.getName());
        addDevice.setDescription(chargingPile.getNumber().toString());
        AddDeviceResp deviceResp = iotInterfaceClient.addDevice(addDevice).getData();
        if(null != deviceResp){
            int httpStatusCode = deviceResp.getHttpStatusCode();
            if(httpStatusCode == 201){
                chargingPile.setIotdDeviceId(deviceResp.getDeviceId());
                this.save(chargingPile);
            }
        }
        return AjaxResult.success();
    }
    
@@ -227,7 +248,6 @@
    @Override
    public AjaxResult delChargingPile(Integer[] ids) {
        //检查是否有关联数据
        //接口
        long count = chargingGunService.count(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getChargingPileId, Arrays.asList(ids))
                .eq(TChargingGun::getDelFlag, 0));
        if(count > 0){
@@ -235,7 +255,13 @@
        }
        for (Integer id : ids) {
            TChargingPile chargingPile = this.getById(id);
            this.removeById(chargingPile);
            //调用华为Iot删除设备
            if(StringUtils.isNotEmpty(chargingPile.getIotdDeviceId())){
                DeleteDeviceResp deviceResp = iotInterfaceClient.deleteDevice(chargingPile.getIotdDeviceId()).getData();
                if(null != deviceResp && deviceResp.getHttpStatusCode() == 201){
                    this.removeById(chargingPile);
                }
            }
        }
        return AjaxResult.success();
    }
ruoyi-service/ruoyi-chargingPile/src/main/resources/bootstrap.yml
@@ -12,7 +12,8 @@
    allow-circular-references: true
  profiles:
    # 环境配置
    active: dev
#    active: dev
    active: prod
---
spring:
  config:
@@ -55,52 +56,52 @@
    type: nacos
    nacos:
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      data-id: seata-server.properties
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
  registry:
    type: nacos
    nacos:
      application: seata-server
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
  cloud:
    nacos:
      discovery:
        # 开发环境
        server-addr: 192.168.110.169:8848 # nacos注册中心地址
        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
        # 生产环境
#        server-addr: 192.168.0.137:8848,192.168.0.123:8848
#        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#        server-addr: 192.168.110.169:8848 # nacos注册中心地址
#        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
#        group: DEFAULT_GROUP
#        application: seata-server #Nacos 中 Seata 名称
#        username: nacos
#        password: nacos
        # 生产环境
        server-addr: 192.168.0.137:8848,192.168.0.123:8848
        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
    sentinel:
      transport:
        dashboard: 127.0.0.1:8080  #  Sentinel控制台地址
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/controller/SecurityDetectionController.java
New file
@@ -0,0 +1,34 @@
package com.ruoyi.integration.controller;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.integration.api.model.SecurityDetection;
import com.ruoyi.integration.mongodb.service.SecurityDetectionService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
 * @author zhibing.pu
 * @Date 2024/10/8 14:25
 */
@RestController
@RequestMapping("/securityDetection")
public class SecurityDetectionController {
    @Resource
    private SecurityDetectionService securityDetectionService;
    /**
     * 获取安全检测数据
     * @param transactionSerialNumber
     * @return
     */
    @PostMapping("/getSecurityDetection")
    public R<SecurityDetection> getSecurityDetection(@RequestParam("transactionSerialNumber") String transactionSerialNumber){
        SecurityDetection securityDetection = securityDetectionService.getSecurityDetection(transactionSerialNumber);
        return R.ok(securityDetection);
    }
}
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/controller/IotInterfaceController.java
New file
@@ -0,0 +1,48 @@
package com.ruoyi.integration.iotda.controller;
import com.huaweicloud.sdk.iotda.v5.model.AddDeviceResponse;
import com.huaweicloud.sdk.iotda.v5.model.DeleteDeviceResponse;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.integration.api.vo.AddDevice;
import com.ruoyi.integration.api.vo.AddDeviceResp;
import com.ruoyi.integration.api.vo.DeleteDeviceResp;
import com.ruoyi.integration.iotda.utils.api.IotInterfaceUtil;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
 * @author zhibing.pu
 * @Date 2024/10/8 10:29
 */
@RestController
@RequestMapping("/iotInterface")
public class IotInterfaceController {
    @Resource
    private IotInterfaceUtil iotInterfaceUtil;
    /**
     * 添加设备
     * @return
     */
    @PostMapping("/addDevice")
    public R<AddDeviceResp> addDevice(@RequestBody AddDevice addDevice){
        return iotInterfaceUtil.addDeviceRequest(addDevice.getProductId(), addDevice.getNodeId(), addDevice.getDeviceName(), addDevice.getDescription());
    }
    /**
     * 删除设备
     * @param deviceId
     * @return
     */
    @PostMapping("/deleteDevice")
    public R<DeleteDeviceResp> deleteDevice(@RequestParam("deviceId") String deviceId){
        return iotInterfaceUtil.deleteDeviceRequest(deviceId);
    }
}
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/api/IotInterfaceUtil.java
@@ -1,22 +1,19 @@
package com.ruoyi.integration.iotda.utils.api;
import com.huaweicloud.sdk.core.auth.AbstractCredentials;
import com.huaweicloud.sdk.core.auth.ICredential;
import com.huaweicloud.sdk.core.exception.ConnectionException;
import com.huaweicloud.sdk.core.exception.RequestTimeoutException;
import com.huaweicloud.sdk.core.exception.ServiceResponseException;
import com.huaweicloud.sdk.iotda.v5.IoTDAClient;
import com.huaweicloud.sdk.iotda.v5.model.*;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.CodeGenerateUtils;
import com.ruoyi.common.core.utils.uuid.UUID;
import com.ruoyi.integration.api.vo.AddDeviceResp;
import com.ruoyi.integration.api.vo.DeleteDeviceResp;
import com.ruoyi.integration.iotda.builder.IotBuilder;
import com.ruoyi.integration.iotda.config.IotAccountConfig;
import com.ruoyi.integration.iotda.config.IotDAConfig;
import com.ruoyi.integration.iotda.constant.IotConstant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RestController;
import java.text.MessageFormat;
import java.util.ArrayList;
@@ -26,7 +23,7 @@
 * iot接口调用工具类
 */
@Slf4j
@RestController
@Component
public class IotInterfaceUtil {
    private static final String dataFormat = "json";
@@ -118,7 +115,7 @@
     * @param description 设备描述
     * @return AddDeviceResponse
     */
    public AddDeviceResponse addDeviceRequest(String productId,String nodeId,String deviceName,String description) {
    public R<AddDeviceResp> addDeviceRequest(String productId,String nodeId,String deviceName,String description) {
        AddDeviceRequest request = new AddDeviceRequest();
        AddDevice body = new AddDevice();
        body.withDeviceId(nodeId);
@@ -130,7 +127,10 @@
        try {
            AddDeviceResponse response = iotBuilder.buildIot().addDevice(request);
            log.info("创建设备:{}",response.toString());
            return response;
            AddDeviceResp addDeviceResp = new AddDeviceResp();
            BeanUtils.copyProperties(response, addDeviceResp);
            return R.ok(addDeviceResp);
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
@@ -142,7 +142,7 @@
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
        return null;
        return R.fail();
    }
    /**
@@ -234,13 +234,15 @@
     * @param deviceId 设备ID 使用已有设备编号
     * @return DeleteDeviceResponse
     */
    public DeleteDeviceResponse deleteDeviceRequest(String deviceId) {
    public R<DeleteDeviceResp> deleteDeviceRequest(String deviceId) {
        DeleteDeviceRequest request = new DeleteDeviceRequest();
        request.withDeviceId(deviceId);
        try {
            DeleteDeviceResponse response = iotBuilder.buildIot().deleteDevice(request);
            log.info("删除设备:{}",response.toString());
            return response;
            DeleteDeviceResp deleteDeviceResp = new DeleteDeviceResp();
            BeanUtils.copyProperties(response, deleteDeviceResp);
            return R.ok(deleteDeviceResp);
        } catch (ConnectionException e) {
            e.printStackTrace();
        } catch (RequestTimeoutException e) {
@@ -252,6 +254,6 @@
            System.out.println(e.getErrorCode());
            System.out.println(e.getErrorMsg());
        }
        return null;
        return R.fail();
    }
}
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/mongodb/service/SecurityDetectionService.java
@@ -7,5 +7,12 @@
/**
 */
public interface SecurityDetectionService extends BaseService<SecurityDetection> {
    /**
     * 根据业务流水号查询数据
     * @param transactionSerialNumber
     * @return
     */
    SecurityDetection getSecurityDetection(String transactionSerialNumber);
}
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/mongodb/service/impl/SecurityDetectionServiceImpl.java
@@ -5,6 +5,8 @@
import com.ruoyi.integration.mongodb.service.SecurityDetectionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -33,4 +35,16 @@
    public List<SecurityDetection> findAll() {
        return mongoTemplate.findAll(SecurityDetection.class);
    }
    /**
     * 根据业务流水号查询数据
     * @param transactionSerialNumber
     * @return
     */
    @Override
    public SecurityDetection getSecurityDetection(String transactionSerialNumber) {
        List<SecurityDetection> securityDetectionList = mongoTemplate.find(new Query().addCriteria(Criteria.where("transaction_serial_number")
                .is(transactionSerialNumber)), SecurityDetection.class);
        return securityDetectionList.size() > 0 ? securityDetectionList.get(0) : null;
    }
}
ruoyi-service/ruoyi-integration/src/main/resources/bootstrap.yml
@@ -12,7 +12,8 @@
    allow-circular-references: true
  profiles:
    # 环境配置
    active: dev
#    active: dev
    active: prod
    
---
spring:
@@ -63,52 +64,52 @@
    type: nacos
    nacos:
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      data-id: seata-server.properties
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
  registry:
    type: nacos
    nacos:
      application: seata-server
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
  cloud:
    nacos:
      discovery:
        # 开发环境
        server-addr: 192.168.110.169:8848 # nacos注册中心地址
        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
        # 生产环境
#        server-addr: 192.168.0.137:8848,192.168.0.123:8848
#        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#        server-addr: 192.168.110.169:8848 # nacos注册中心地址
#        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
#        group: DEFAULT_GROUP
#        application: seata-server #Nacos 中 Seata 名称
#        username: nacos
#        password: nacos
        # 生产环境
        server-addr: 192.168.0.137:8848,192.168.0.123:8848
        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
    sentinel:
      transport:
        dashboard: 127.0.0.1:8080  #  Sentinel控制台地址
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java
@@ -342,10 +342,10 @@
     * @param
     * @return
     */
    @GetMapping(value = "/getCar")
    public R<Long> getCar() {
    @GetMapping(value = "/getCar/{id}")
    public R<Long> getCar(@PathVariable("id")String id) {
        List<TChargingOrder> list = chargingOrderService.list(new LambdaQueryWrapper<TChargingOrder>()
                .eq(TChargingOrder::getAppUserId, tokenService.getLoginUserApplet().getUserId())
                .eq(TChargingOrder::getAppUserId, id)
                .isNotNull(TChargingOrder::getAppUserCarId));
        if (!list.isEmpty()){
            // 最近使用的车辆id
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -190,6 +190,9 @@
    
    @Resource
    private AppUserTagClient appUserTagClient;
    @Resource
    private SecurityDetectionClient securityDetectionClient;
    //计数器
    private Map<String, Integer> counter_map = new HashMap<>();
@@ -650,6 +653,19 @@
        //执行5分钟的定时任务检测
        ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
        scheduler.scheduleAtFixedRate(()->{
            //获取安全校验
            SecurityDetection securityDetection = securityDetectionClient.getSecurityDetection(chargingOrder.getCode()).getData();
            if(null != securityDetection){
                PreChargeCheck preChargeCheck1 =  redisService.getCacheObject("AQJC_" + chargingOrder.getChargingGunId());
                if(null != preChargeCheck1){
                    preChargeCheck1.setElectronicLockLock(preChargeCheck1.getElectronicLockLock());
                    preChargeCheck1.setInsulationTesting(true);
                    preChargeCheck1.setSecureConnectionDetection(preChargeCheck1.getSecureConnectionDetection());
                    preChargeCheck1.setStartupSuccess(1);
                    redisService.setCacheObject("AQJC_" + chargingOrder.getChargingGunId(), preChargeCheck1);
                }
            }
            List<PlatformStartChargingReply> data = platformStartChargingReplyClient.getPlatformStartChargingReply(code).getData();
            System.err.println("-------------------开始检查调起充电结果-------------------");
            System.err.println(data.toString());
ruoyi-service/ruoyi-order/src/main/resources/bootstrap.yml
@@ -13,6 +13,7 @@
  profiles:
    # 环境配置
    active: dev
#    active: prod
---
spring:
  config:
@@ -28,6 +29,7 @@
        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
        username: nacos
        password: nacos
        ip: 192.168.110.85
      config:
        # 配置中心地址
        server-addr: 192.168.110.169:8848
ruoyi-service/ruoyi-other/src/main/resources/bootstrap.yml
@@ -13,6 +13,7 @@
  profiles:
    # 环境配置
    active: dev
#    active: prod
---
spring:
  config:
@@ -28,6 +29,7 @@
        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
        username: nacos
        password: nacos
        ip: 192.168.110.85
      config:
        # 配置中心地址
        server-addr: 192.168.110.169:8848
ruoyi-service/ruoyi-payment/src/main/resources/bootstrap.yml
@@ -12,7 +12,8 @@
    allow-circular-references: true
  profiles:
    # 环境配置
    active: dev
#    active: dev
    active: prod
---
spring:
  config:
@@ -55,52 +56,52 @@
    type: nacos
    nacos:
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      data-id: seata-server.properties
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      data-id: seata-server.properties
      username: nacos
      password: nacos
  registry:
    type: nacos
    nacos:
      application: seata-server
      # 开发环境
      server-addr: 192.168.110.169:8848
      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
      # 生产环境
#      server-addr: 192.168.0.137:8848,192.168.0.123:8848
#      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#      server-addr: 192.168.110.169:8848
#      namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb
#      group: DEFAULT_GROUP
#      username: nacos
#      password: nacos
      # 生产环境
      server-addr: 192.168.0.137:8848,192.168.0.123:8848
      namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
      group: DEFAULT_GROUP
      username: nacos
      password: nacos
  cloud:
    nacos:
      discovery:
        # 开发环境
        server-addr: 192.168.110.169:8848 # nacos注册中心地址
        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
        # 生产环境
#        server-addr: 192.168.0.137:8848,192.168.0.123:8848
#        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
#        server-addr: 192.168.110.169:8848 # nacos注册中心地址
#        namespace: b5290bc2-e3aa-4988-8a7d-9c07e4e073cb # 命名空间
#        group: DEFAULT_GROUP
#        application: seata-server #Nacos 中 Seata 名称
#        username: nacos
#        password: nacos
        # 生产环境
        server-addr: 192.168.0.137:8848,192.168.0.123:8848
        namespace: c6cf40b5-44e8-43f9-be61-8d10fa830e2a
        group: DEFAULT_GROUP
        application: seata-server #Nacos 中 Seata 名称
        username: nacos
        password: nacos
    sentinel:
      transport:
        dashboard: 127.0.0.1:8080  #  Sentinel控制台地址