luodangjia
2024-10-11 bd97f8c5cd9be78abfaaab295319bd7ceef98f11
Merge remote-tracking branch 'origin/master'
47个文件已修改
7个文件已添加
1762 ■■■■ 已修改文件
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppUserVipDetail.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/ChargingGunFallbackFactory.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/ChargingPileFallbackFactory.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingGunClient.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingPileClient.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/GetChargingGunByCode.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/SiteInfoVO.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/model/BmsDemandAndChargerExportation.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/model/BmsInformation.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/vo/GetPlatformStopChargingReply.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/PlatformStartChargingReplyMessageVO.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/PlatformStopChargingReplyVO.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/SecurityDetectionVO.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-auth/src/main/resources/bootstrap.yml 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-gateway/src/main/resources/bootstrap.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppCouponController.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WxLoginController.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-account/src/main/resources/bootstrap.yml 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingGunController.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TFaultMessageController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/util/TaskUtil.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-chargingPile/src/main/resources/bootstrap.yml 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/RuoYiIntegrationApplication.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/constant/SendTagConstant.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/mongodb/service/impl/PlatformStopChargingReplyServiceImpl.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/base/BaseMessage.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/EndChargeMessageListener.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/PlatformStartChargingReplyMessageListener.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/TimingSettingMessageListener.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/UploadRealTimeMonitoringDataMessageListener.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/model/BmsDemandAndChargerExportationMessage.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/model/BmsInformationMessage.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/model/ChargingMessage.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/model/GroundLockRealTimeDataMessage.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/ChargingMessageListener.java 501 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/EnhanceProduce.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-integration/src/main/resources/bootstrap.yml 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TChargingOrderController.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TOrderInvoiceController.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java 323 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderEvaluateServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TVipOrderServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-order/src/main/resources/bootstrap.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-other/src/main/resources/bootstrap.yml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-service/ruoyi-payment/src/main/resources/bootstrap.yml 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-api/ruoyi-api-account/src/main/java/com/ruoyi/account/api/model/TAppUserVipDetail.java
@@ -8,6 +8,7 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.math.BigDecimal;
@@ -63,15 +64,16 @@
    @ApiModelProperty(value = "会员开始时间")
    @TableField("start_time")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime startTime;
    @ApiModelProperty(value = "会员结束时间")
    @TableField("end_time")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime endTime;
    @TableField("create_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private LocalDateTime createTime;
    @ApiModelProperty(value = "已赠送的月份")
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/ChargingGunFallbackFactory.java
@@ -5,6 +5,7 @@
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.model.TChargingPile;
import com.ruoyi.chargingPile.api.model.TFaultMessage;
import com.ruoyi.chargingPile.api.vo.GetChargingGunByCode;
import com.ruoyi.chargingPile.api.vo.SiteNameVO;
import com.ruoyi.common.core.domain.R;
import org.slf4j.Logger;
@@ -45,7 +46,7 @@
            }
            @Override
            public R<TChargingGun> getChargingGunByCode(String code) {
            public R<TChargingGun> getChargingGunByCode(GetChargingGunByCode code) {
                return R.fail("根据枪编号获取充电枪失败:" + throwable.getMessage());
            }
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/factory/ChargingPileFallbackFactory.java
@@ -56,6 +56,12 @@
            public R<TChargingPile> getChargingPileById(Integer id) {
                return R.fail(throwable.getMessage());
            }
            @Override
            public void updateChargingPileStatus(String code, Integer status) {
                log.error("修改充电桩状态失败:" + throwable.getMessage());
            }
        };
    }
}
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingGunClient.java
@@ -3,6 +3,7 @@
import com.ruoyi.chargingPile.api.factory.ChargingGunFallbackFactory;
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.model.TFaultMessage;
import com.ruoyi.chargingPile.api.vo.GetChargingGunByCode;
import com.ruoyi.chargingPile.api.vo.SiteNameVO;
import com.ruoyi.common.core.constant.ServiceNameConstants;
import com.ruoyi.common.core.domain.R;
@@ -48,8 +49,8 @@
     * @param code
     * @return
     */
    @PostMapping("/t-charging-gun/getChargingGunByCode/{code}")
    R<TChargingGun> getChargingGunByCode(@PathVariable("code") String code);
    @PostMapping("/t-charging-gun/getChargingGunByCode")
    R<TChargingGun> getChargingGunByCode(@RequestBody GetChargingGunByCode code);
    /**
     * 编辑充电枪
     * @param chargingGun
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/feignClient/ChargingPileClient.java
@@ -49,4 +49,13 @@
    
    @PostMapping("/t-charging-pile/getChargingPileById/{id}")
    R<TChargingPile> getChargingPileById(@PathVariable("id") Integer id);
    /**
     * 修改充电桩状态
     * @param code
     * @param status
     */
    @PostMapping("/t-charging-pile/updateChargingPileStatus")
    void updateChargingPileStatus(@RequestParam("code") String code, @RequestParam("status") Integer status);
}
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/GetChargingGunByCode.java
New file
@@ -0,0 +1,13 @@
package com.ruoyi.chargingPile.api.vo;
import lombok.Data;
/**
 * @author zhibing.pu
 * @Date 2024/10/8 16:58
 */
@Data
public class GetChargingGunByCode {
    private String charging_pile_code; // 桩编码
    private String charging_gun_code; // 抢号
}
ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/vo/SiteInfoVO.java
@@ -14,6 +14,8 @@
    private String name;
    @ApiModelProperty(value = "桩id")
    private Integer chargingPileId;
    @ApiModelProperty(value = "站点id")
    private Integer siteId;
    @ApiModelProperty(value = "桩编号")
    private String number;
    @ApiModelProperty(value = "充电枪id")
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/model/BmsDemandAndChargerExportation.java
@@ -26,10 +26,10 @@
    private BigDecimal bms_current_measurement_value; // BMS 充电电流测量值
    private Integer bms_battery_voltage_and_group_number; // BMS 最高单体动力蓄电池电压及组号(1-12 位:最高单体动力蓄电池电压,数据分辨率:0.01 V/位,0 V 偏移量;数据范围:0~24 V;13-16 位:最高单体动力蓄电池电压所在组号,数据分辨率:1/位,0 偏移量;数据范围:0~15)
    private BigDecimal bms_charged_status; // BMS 当前荷电状态 SOC( %)
    private Integer bms_remaining_charging_time; // BMS 估算剩余充电时间
    private BigDecimal bms_remaining_charging_time; // BMS 估算剩余充电时间
    private BigDecimal voltage_output_value; // 电桩电压输出值
    private BigDecimal current_output_value; // 电桩电流输出值
    private Integer cumulative_charging_time; // 累计充电时间
    private BigDecimal cumulative_charging_time; // 累计充电时间
}
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/model/BmsInformation.java
@@ -21,9 +21,9 @@
    private String charging_gun_code; // 抢号
    private Integer bms_highest_voltage_number; // BMS 最高单体动力蓄电池电压所在编号
    private String bms_maximum_battery_temperature; // BMS 最高动力蓄电池温度
    private Integer maximum_temperature_detection_point_number; // 最高温度检测点编号
    private String maximum_temperature_detection_point_number; // 最高温度检测点编号
    private String minimum_cell_temperature; // 最低动力蓄电池温度
    private Integer lowest_temperature_detection_pointt_number; // 最低动力蓄电池温度检测点编号
    private String lowest_temperature_detection_pointt_number; // 最低动力蓄电池温度检测点编号
    private Integer bms_battery_voltage; // BMS 单体动力蓄电池电压过高 /过低(0:正常,1:过高,10:过低)
    private Integer bms_battery_charging_status; // BMS 整车动力蓄电池荷电状态SOC 过高/过低(0:正常,1:过高,10:过低)
    private Integer bms_charging_overcurrent; // BMS 动力蓄电池充电过电流(0:正常,1:过流,10:不可信状态)
ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/vo/GetPlatformStopChargingReply.java
@@ -16,4 +16,8 @@
     * 充电枪编号
     */
    private String charging_gun_code;
    /**
     * 充电结束时间
     */
    private String end_time;
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/factory/ChargingOrderFallbackFactory.java
@@ -9,9 +9,7 @@
import com.ruoyi.order.api.model.TSettlementConfirm;
import com.ruoyi.order.api.query.TChargingCountQuery;
import com.ruoyi.order.api.query.UploadRealTimeMonitoringDataQuery;
import com.ruoyi.order.api.vo.ChargingBillVO;
import com.ruoyi.order.api.vo.GetChargingOrderByLicensePlate;
import com.ruoyi.order.api.vo.SettlementTotalVO;
import com.ruoyi.order.api.vo.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
@@ -140,6 +138,21 @@
                log.error("购物订单退款回调通知失败:" + throwable.getMessage());
            }
            @Override
            public void securityDetection(SecurityDetectionVO securityDetection) {
                log.error("修改安全检测数据失败:" + throwable.getMessage());
            }
            @Override
            public void startChargeSuccessfully(PlatformStartChargingReplyMessageVO message) {
                log.error("远程启动充电应答失败:" + throwable.getMessage());
            }
            @Override
            public void terminateSuccessfulResponse(PlatformStopChargingReplyVO platformStopChargingReply) {
                log.error("停止充电应答处理失败:" + throwable.getMessage());
            }
        };
    }
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/feignClient/ChargingOrderClient.java
@@ -11,12 +11,10 @@
import com.ruoyi.order.api.model.TSettlementConfirm;
import com.ruoyi.order.api.query.TChargingCountQuery;
import com.ruoyi.order.api.query.UploadRealTimeMonitoringDataQuery;
import com.ruoyi.order.api.vo.ChargingBillVO;
import com.ruoyi.order.api.vo.SettlementTotalVO;
import com.ruoyi.order.api.vo.*;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.order.api.vo.GetChargingOrderByLicensePlate;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
@@ -162,10 +160,10 @@
     * @param success_time
     */
    @PostMapping("/t-charging-order/chargingOrderStartupFailureWxRefund")
    void chargingOrderStartupFailureWxRefund(@RequestParam("out_trade_no") String out_refund_no,
                                             @RequestParam("out_trade_no") String refund_id,
                                             @RequestParam("out_trade_no") String tradeState,
                                             @RequestParam("out_trade_no") String success_time);
    void chargingOrderStartupFailureWxRefund(@RequestParam("out_refund_no") String out_refund_no,
                                             @RequestParam("refund_id") String refund_id,
                                             @RequestParam("tradeState") String tradeState,
                                             @RequestParam("success_time") String success_time);
    /**
     * 管理后台取消购物订单后退款回调
     * @param out_refund_no
@@ -178,4 +176,27 @@
                                             @RequestParam("out_trade_no") String refund_id,
                                             @RequestParam("out_trade_no") String tradeState,
                                             @RequestParam("out_trade_no") String success_time);
    /**
     * 修改安全检测数据
     * @param securityDetection
     */
    @PostMapping("/t-charging-order/securityDetection")
    void securityDetection(@RequestBody SecurityDetectionVO securityDetection);
    /**
     * 远程启动充电应答
     * @param message
     */
    @PostMapping("/t-charging-order/startChargeSuccessfully")
    void startChargeSuccessfully(PlatformStartChargingReplyMessageVO message);
    /**
     * 停止充电应答处理
     * @param platformStopChargingReply
     */
    @PostMapping("/t-charging-order/terminateSuccessfulResponse")
    void terminateSuccessfulResponse(@RequestBody PlatformStopChargingReplyVO platformStopChargingReply);
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/PlatformStartChargingReplyMessageVO.java
New file
@@ -0,0 +1,16 @@
package com.ruoyi.order.api.vo;
import lombok.Data;
/**
 * @author zhibing.pu
 * @Date 2024/10/8 17:16
 */
@Data
public class PlatformStartChargingReplyMessageVO {
    private String transaction_serial_number; // 交易流水号
    private String charging_pile_code; // 桩编码
    private String charging_gun_code; // 抢号
    private Integer startup_result; // 启动结果(0:失败,1:成功)
    private Integer failure_cause; // "失败原因(0:无,1:设备编号不匹配,2:枪已在充电,3:设备故障,4:设备离线,5:未插枪桩在收到启充命令后,检测到未插枪则发送 0x33 报文回复充电失败。若在 60 秒(以收到 0x34 时间开始计算)内检测到枪重新连接,则补送 0x33 成功报文;超时或者离线等其他异常,桩不启充、不补发 0x33 报文)"
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/PlatformStopChargingReplyVO.java
New file
@@ -0,0 +1,19 @@
package com.ruoyi.order.api.vo;
import lombok.Data;
/**
 * 远程停机命令回复
 **/
@Data
public class PlatformStopChargingReplyVO {
    private String charging_pile_code; // 桩编码
    private String charging_gun_code; // 抢号
    private Integer stop_result; // 停止结果(0:失败,1:成功)
    private Integer failure_cause; // 失败原因(0:无,1:设备编号不匹配,2:枪未处于充电状态,3:其他)
}
ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/vo/SecurityDetectionVO.java
New file
@@ -0,0 +1,14 @@
package com.ruoyi.order.api.vo;
import lombok.Data;
@Data
public class SecurityDetectionVO {
    private String transaction_serial_number; // 交易流水号
    private String charging_pile_code; // 桩编码
    private String charging_gun_code; // 抢号
    private Integer secure_connection; // 车枪连接(0=未连接,1=连接)
    private Integer nsulation_detection; // 绝缘检测(0=安全,1=不安全)
    private Integer electronic_lock_lock; // 电磁锁状态(0=未锁,1=已锁)
}
ruoyi-auth/src/main/resources/bootstrap.yml
@@ -6,8 +6,8 @@
spring:
  profiles:
    # 环境配置
#    active: dev
    active: prod
    active: dev
#    active: prod
  application:
    # 应用名称
    name: ruoyi-auth
@@ -56,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,8 +12,8 @@
    allow-bean-definition-overriding: true
  profiles:
    # 环境配置
#    active: dev
    active: prod
    active: dev
#    active: prod
---
spring:
  config:
ruoyi-modules/ruoyi-system/src/main/resources/bootstrap.yml
@@ -11,8 +11,8 @@
    allow-bean-definition-overriding: true
  profiles:
    # 环境配置
#    active: dev
    active: prod
    active: dev
#    active: prod
---
spring:
  config:
@@ -55,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/src/main/java/com/ruoyi/account/controller/TAppCouponController.java
@@ -60,7 +60,7 @@
    @Autowired
    private TAppUserCarService appUserCarService;
    @Autowired
    @Resource
    private TokenService tokenService;
    @Resource
    private ChargingPileClient chargingPileClient;
@@ -109,6 +109,7 @@
        TChargingPile chargingPile = chargingPileClient.getChargingPileById(chargingGun.getChargingPileId()).getData();
        SiteInfoVO data = chargingPileClient.getSiteInfoByNumber1(chargingPile.getCode().toString()).getData();
        data.setChargingGunId(id);
        data.setSiteId(chargingGun.getId());
        data.setChargeMode(chargingGun.getChargeMode());
        List<TAppUserCar> cars = appUserCarService.list(new QueryWrapper<TAppUserCar>()
                .eq("app_user_id",tokenService.getLoginUserApplet().getUserId())
@@ -117,7 +118,7 @@
        Integer data2 = otherClient.getAddCarIntegral().getData();
        data.setIntegral(data2);
        if (!cars.isEmpty()){
            if (data1 == -1){
            if (null == data1 || data1 == -1){
                // 没有充电订单 展示最新添加的车辆
                data.setLicensePlate(cars.get(0).getLicensePlate());
                data.setVehicleBrand(cars.get(0).getVehicleBrand());
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
@@ -849,7 +849,7 @@
        boolean doubleVip = false;
        if (one!=null){
            TVip tVip = JSONObject.parseObject(one.getVipJson(), TVip.class);
            if (tVip.getDoubleIntegration()==1){
            if (tVip.getDoubleIntegration()!=null&&tVip.getDoubleIntegration()==1){
                doubleVip = true;
            }
        }
@@ -964,7 +964,7 @@
        boolean doubleVip = false;
        if (one!=null){
             TVip tVip = JSONObject.parseObject(one.getVipJson(), TVip.class);
             if (tVip.getDoubleIntegration()==1){
             if (tVip.getDoubleIntegration()!=null&&tVip.getDoubleIntegration()==1){
                 doubleVip = true;
             }
        }
ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/WxLoginController.java
@@ -63,11 +63,15 @@
    private WeixinProperties wxConfig;
    @Autowired
    private RestTemplate wxRestTemplate;
//    /**
//     * 上传文件存储在本地的根路径
//     */
//    @Value("${file.path}")
//    private String localFilePath;
    /**
     * 上传文件存储在本地的根路径
     */
    @Value("${file.upload.location}")
    private String localFilePath;
    @ApiOperation(value = "通过code获得openid,获取用户信息",tags = {"微信小程序登录"})
    @PostMapping("/openIdByJsCode")
    public AjaxResult<Map<String, Object>> openIdByJsCode(@RequestBody AppletUserEncrypteData data) {
@@ -99,9 +103,11 @@
    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);
//    }
    @ApiOperation(value = "获取微信小程序二维码",tags = {"获取微信小程序二维码"})
    @PostMapping("/getQRCode")
    public AjaxResult getQRCode() {
ruoyi-service/ruoyi-account/src/main/resources/bootstrap.yml
@@ -12,8 +12,8 @@
    allow-circular-references: true
  profiles:
    # 环境配置
#    active: dev
    active: prod
    active: dev
#    active: prod
---
spring:
  config:
@@ -56,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/controller/TChargingGunController.java
@@ -3,6 +3,7 @@
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.io.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.chargingPile.api.dto.GetSiteListDTO;
import com.ruoyi.chargingPile.api.dto.TChargingGunDTO;
@@ -11,6 +12,7 @@
import com.ruoyi.chargingPile.api.model.TChargingPile;
import com.ruoyi.chargingPile.api.model.TFaultMessage;
import com.ruoyi.chargingPile.api.query.TChargingGunQuery;
import com.ruoyi.chargingPile.api.vo.GetChargingGunByCode;
import com.ruoyi.chargingPile.api.vo.GunStatusStatisticsVO;
import com.ruoyi.chargingPile.api.vo.SiteNameVO;
import com.ruoyi.chargingPile.api.vo.TChargingGunVO;
@@ -155,7 +157,7 @@
    public void downloadQRCode(@PathVariable Integer id, HttpServletResponse response){
        try {
            TChargingGun chargingGun = chargingGunService.getById(id);
            TChargingPile chargingPile = chargingPileService.getById(chargingGun.getId());
            TChargingPile chargingPile = chargingPileService.getById(chargingGun.getChargingPileId());
            String code = chargingPile.getCode() + chargingGun.getCode();
            String fileName = URLEncoder.encode(code, "UTF-8") + ".jpg";
            response.setContentType("application/force-download");
@@ -175,15 +177,15 @@
            inputStream.close();
            
            //清楚服务器上的文件
            Process process = null;
            try {
                process = Runtime.getRuntime().exec("sudo rm -rf " + filePath);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            if (process != null) {
                process.destroy();
            }
//            Process process = null;
//            try {
//                process = Runtime.getRuntime().exec("sudo rm -rf " + filePath);
//            } catch (IOException e) {
//                throw new RuntimeException(e);
//            }
//            if (process != null) {
//                process.destroy();
//            }
        }catch (Exception e){
            e.printStackTrace();
        }
@@ -254,11 +256,14 @@
     * @param code
     * @return
     */
    @PostMapping("/getChargingGunByCode/{code}")
    public R<TChargingGun> getChargingGunByCode(@PathVariable("code") String code){
    @PostMapping("/getChargingGunByCode")
    public R<TChargingGun> getChargingGunByCode(@RequestBody GetChargingGunByCode code){
        TChargingPile chargingPile = chargingPileService.getOne(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getCode, code.getCharging_pile_code()).eq(TChargingPile::getDelFlag, 0));
        return R.ok(chargingGunService.getOne(Wrappers.lambdaQuery(TChargingGun.class)
                .eq(TChargingGun::getCode, code)
                .last("LIMIT 1")));
                        .eq(TChargingGun::getChargingPileId, chargingPile.getId())
                        .eq(TChargingGun::getCode, code.getCharging_gun_code())
                        .eq(TChargingGun::getDelFlag, 0)
                        .last("LIMIT 1")));
    }
    /**
     * 根据枪编号获取充电枪
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java
@@ -25,6 +25,7 @@
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.log.enums.OperatorType;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.other.api.domain.TVip;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -38,7 +39,9 @@
import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * <p>
@@ -55,12 +58,9 @@
    private final TChargingPileService chargingPileService;
    private final TChargingGunService chargingGunService;
    @Resource
    private TAccountingStrategyService accountingStrategyService;
    @Resource
    private TAccountingStrategyDetailService accountingStrategyDetailService;
    @Resource
    private RedisService redisService;
    @Autowired
@@ -205,6 +205,23 @@
        TChargingPile chargingPile = chargingPileService.getById(id);
        return R.ok(chargingPile);
    }
    /**
     * 更新充电桩状态
     * @param code
     * @param status
     */
    @ResponseBody
    @PostMapping("/updateChargingPileStatus")
    public void updateChargingPileStatus(@RequestParam("code") String code, @RequestParam("status") Integer status){
        TChargingPile chargingPile = chargingPileService.getOne(new LambdaQueryWrapper<TChargingPile>()
                .eq(TChargingPile::getCode, code).eq(TChargingPile::getDelFlag, 0));
        if(null != chargingPile){
            chargingPile.setStatus(0 == status ? 1 : 3);
            chargingPileService.updateById(chargingPile);
            redisService.getCacheMap("charging_pile_online").put(code, System.currentTimeMillis());
        }
    }
}
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TFaultMessageController.java
@@ -113,7 +113,7 @@
     * @param gunId
     * @return
     */
    @PostMapping("/t-fault-message/getFaultMessageByGunId/{gunId}")
    @PostMapping("/getFaultMessageByGunId/{gunId}")
    public R<TFaultMessage> getFaultMessageByGunId(@PathVariable("gunId") Integer gunId){
        return R.ok(faultMessageService.getOne(Wrappers.lambdaQuery(TFaultMessage.class)
                .eq(TFaultMessage::getChargingGunId,gunId)
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/TChargingPileService.java
@@ -106,5 +106,11 @@
     * @return
     */
    PageInfo<ChargingGunMonitoring> getChargingGunMonitoring(GetChargingGunMonitoring query);
    /**
     * 定时任务修改充电桩状态
     */
    void updateStatus();
}
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java
@@ -27,6 +27,7 @@
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.redis.service.RedisService;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.integration.api.feignClient.IotInterfaceClient;
import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient;
@@ -100,6 +101,9 @@
    
    @Resource
    private IotInterfaceClient iotInterfaceClient;
    @Resource
    private RedisService redisService;
    
    
    
@@ -544,4 +548,26 @@
        }
        return pageInfo.setRecords(chargingGunMonitoring);
    }
    /**
     * 定时任务修改充电桩状态
     */
    @Override
    public void updateStatus() {
        List<TChargingPile> list = this.list(new LambdaQueryWrapper<TChargingPile>().eq(TChargingPile::getDelFlag, 0));
        List<TChargingPile> datas = new ArrayList();
        Map<String, Object> charging_pile_online = redisService.getCacheMap("charging_pile_online");
        for (TChargingPile chargingPile : list) {
            Long time = (Long) charging_pile_online.get(chargingPile.getCode());
            if(null != time && System.currentTimeMillis() - time > 60000){
                chargingPile.setStatus(2);
                datas.add(chargingPile);
            }
        }
        if(datas.size() > 0){
            this.updateBatchById(datas);
        }
    }
}
ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/util/TaskUtil.java
New file
@@ -0,0 +1,30 @@
package com.ruoyi.chargingPile.util;
import com.ruoyi.chargingPile.service.TChargingPileService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
 * 定时任务工具类
 */
@Component
public class TaskUtil {
    @Resource
    private TChargingPileService chargingPileService;;
    /**
     * 每隔一分钟去处理的定时任务
     */
    @Scheduled(fixedRate = 1000 * 60)
    public void taskMinute(){
    }
}
ruoyi-service/ruoyi-chargingPile/src/main/resources/bootstrap.yml
@@ -12,8 +12,8 @@
    allow-circular-references: true
  profiles:
    # 环境配置
#    active: dev
    active: prod
    active: dev
#    active: prod
---
spring:
  config:
@@ -56,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/RuoYiIntegrationApplication.java
@@ -6,6 +6,10 @@
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@@ -20,6 +24,7 @@
@SpringBootApplication
@EnableScheduling//开启定时任务
@EnableTransactionManagement//开启事务
@EnableBinding({ Source.class, Sink.class })
public class RuoYiIntegrationApplication {
    public static void main(String[] args) {
        SpringApplication.run(RuoYiIntegrationApplication.class, args);
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/constant/SendTagConstant.java
@@ -126,4 +126,5 @@
     * 安全监测
     */
    public final static String SECURITY_DETECTION ="security_detection";
    public static final String CHARGING_MESSAGE ="charging_message";
}
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/iotda/utils/listener/IotMessageListener.java
@@ -68,12 +68,14 @@
        writer.write("服务id:"+service_id+"\n");
        writer.close();
        SendResult sendResult;
        ChargingMessage chargingMessage = new ChargingMessage();
        chargingMessage.setServiceId(service_id);
        // 设备消息下发
        String result;
        switch (service_id){
            case SendTagConstant.ONLINE:
                OnlineMessage onlineMessage = JSON.parseObject(content.toJSONString(),OnlineMessage.class);
                sendResult = enhanceProduce.onlineMessage(onlineMessage);
                chargingMessage.setOnlineMessage(onlineMessage);
                // 响应硬件
                // 业务处理 登录认证应答
                OnlineReply onlineReply = new OnlineReply();
@@ -86,10 +88,11 @@
                timingSettingReplyOnline.setCharging_pile_code(onlineMessage.getCharging_pile_code());
                timingSettingReplyOnline.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date()));
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReplyOnline));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.PING:
                PingMessage pingMessage = JSON.parseObject(content.toJSONString(),PingMessage.class);
                sendResult = enhanceProduce.pingMessage(pingMessage);
                chargingMessage.setPingMessage(pingMessage);
                // 响应硬件
                Pong pong = new Pong();
                pong.setCharging_pile_code(pingMessage.getCharging_pile_code());
@@ -97,20 +100,23 @@
                pong.setCharging_gun_status(0);
                result = iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.PONG.getKey(), messageUtil.pong(pong));
                log.info("充电桩心跳包-返回结果:{}",result);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.END_CHARGE:
                EndChargeMessage endChargeMessage = JSON.parseObject(content.toJSONString(),EndChargeMessage.class);
                sendResult = enhanceProduce.endChargeMessage(endChargeMessage);
                chargingMessage.setEndChargeMessage(endChargeMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.ERROR_MESSAGE:
                ErrorMessageMessage errorMessageMessage = JSON.parseObject(content.toJSONString(),ErrorMessageMessage.class);
                sendResult = enhanceProduce.errorMessageMessage(errorMessageMessage);
                chargingMessage.setErrorMessageMessage(errorMessageMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.BILLING_MODE_VERIFY:
                BillingModeVerifyMessage billingModeVerifyMessage = JSON.parseObject(content.toJSONString(),BillingModeVerifyMessage.class);
                sendResult = enhanceProduce.billingModeVerifyMessage(billingModeVerifyMessage);
                chargingMessage.setBillingModeVerifyMessage(billingModeVerifyMessage);
                // 响应硬件
                BillingModeVerifyReply billingModeVerifyReply = new BillingModeVerifyReply();
                if(billingModeVerifyMessage.getBilling_model_code().equals("0")){
@@ -134,10 +140,11 @@
                    }
                }
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.BILLING_MODE_VERIFY_REPLY.getKey(),messageUtil.billingModeVerifyReply(billingModeVerifyReply));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.ACQUISITION_BILLING_MODE:
                AcquisitionBillingModeMessage acquisitionBillingModeMessage = JSON.parseObject(content.toJSONString(),AcquisitionBillingModeMessage.class);
                sendResult = enhanceProduce.acquisitionBillingModeMessage(acquisitionBillingModeMessage);
                chargingMessage.setAcquisitionBillingModeMessage(acquisitionBillingModeMessage);
                // 响应硬件   计费模型请求应答  1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段
                List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailClient.getDetailListByCode(acquisitionBillingModeMessage.getCharging_pile_code().substring(0,14)).getData();
                Map<Integer, TAccountingStrategyDetail> strategyPrice = StrategyUtil.getStrategyPrice(accountingStrategyDetails);
@@ -151,43 +158,51 @@
                acquisitionBillingModeReply.setCharging_pile_code(acquisitionBillingModeMessage.getCharging_pile_code());
                acquisitionBillingModeReply.setLoss_ratio(BigDecimal.ZERO);
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.ACQUISITION_BILLING_MODE_REPLY.getKey(),messageUtil.acquisitionBillingModeReply(acquisitionBillingModeReply));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA:
                UploadRealTimeMonitoringDataMessage uploadRealTimeMonitoringDataMessage = JSON.parseObject(content.toJSONString(),UploadRealTimeMonitoringDataMessage.class);
                sendResult = enhanceProduce.uploadRealTimeMonitoringDataMessage(uploadRealTimeMonitoringDataMessage);
                chargingMessage.setUploadRealTimeMonitoringDataMessage(uploadRealTimeMonitoringDataMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.CHARGING_HANDSHAKE:
                ChargingHandshakeMessage chargingHandshakeMessage = JSON.parseObject(content.toJSONString(),ChargingHandshakeMessage.class);
                sendResult = enhanceProduce.chargingHandshakeMessage(chargingHandshakeMessage);
                chargingMessage.setChargingHandshakeMessage(chargingHandshakeMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.PARAMETER_SETTING:
                ParameterSettingMessage parameterSettingMessage = JSON.parseObject(content.toJSONString(),ParameterSettingMessage.class);
                sendResult = enhanceProduce.parameterSettingMessage(parameterSettingMessage);
                chargingMessage.setParameterSettingMessage(parameterSettingMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.BMS_ABORT:
                BmsAbortMessage bmsAbortMessage = JSON.parseObject(content.toJSONString(),BmsAbortMessage.class);
                sendResult = enhanceProduce.bmsAbortMessage(bmsAbortMessage);
                chargingMessage.setBmsAbortMessage(bmsAbortMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.MOTOR_ABORT:
                MotorAbortMessage motorAbortMessage = JSON.parseObject(content.toJSONString(),MotorAbortMessage.class);
                sendResult = enhanceProduce.motorAbortMessage(motorAbortMessage);
                chargingMessage.setMotorAbortMessage(motorAbortMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.BMS_DEMAND_AND_CHARGER_EXPORTATION:
                BmsDemandAndChargerExportationMessage bmsDemandAndChargerExportationMessage = JSON.parseObject(content.toJSONString(),BmsDemandAndChargerExportationMessage.class);
                sendResult = enhanceProduce.bmsDemandAndChargerExportationMessage(bmsDemandAndChargerExportationMessage);
                chargingMessage.setBmsDemandAndChargerExportationMessage(bmsDemandAndChargerExportationMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.BMS_INFORMATION:
                BmsInformationMessage bmsInformationMessage = JSON.parseObject(content.toJSONString(),BmsInformationMessage.class);
                sendResult = enhanceProduce.bmsInformationMessage(bmsInformationMessage);
                chargingMessage.setBmsInformationMessage(bmsInformationMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.CHARGING_PILE_STARTS_CHARGING:
                ChargingPileStartsChargingMessage chargingPileStartsChargingMessage = JSON.parseObject(content.toJSONString(),ChargingPileStartsChargingMessage.class);
                sendResult = enhanceProduce.chargingPileStartsChargingMessage(chargingPileStartsChargingMessage);
                chargingMessage.setChargingPileStartsChargingMessage(chargingPileStartsChargingMessage);
                // 响应硬件
                PlatformConfirmationCharging platformConfirmationCharging = new PlatformConfirmationCharging();
                platformConfirmationCharging.setCharging_pile_code(chargingPileStartsChargingMessage.getCharging_pile_code());
@@ -197,88 +212,104 @@
                platformConfirmationCharging.setAuthentication(1);
                // TODO 若是失败,给出失败原因
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.PLATFORM_CONFIRMATION_CHARGING.getKey(),messageUtil.platformConfirmationCharging(platformConfirmationCharging));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.PLATFORM_START_CHARGING_REPLY:
                PlatformStartChargingReplyMessage platformStartChargingReplyMessage = JSON.parseObject(content.toJSONString(),PlatformStartChargingReplyMessage.class);
                sendResult = enhanceProduce.platformStartChargingReplyMessage(platformStartChargingReplyMessage);
                chargingMessage.setPlatformStartChargingReplyMessage(platformStartChargingReplyMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.PLATFORM_STOP_CHARGING_REPLY:
                PlatformStopChargingReplyMessage platformStopChargingReplyMessage = JSON.parseObject(content.toJSONString(),PlatformStopChargingReplyMessage.class);
                sendResult = enhanceProduce.platformStopChargingReplyMessage(platformStopChargingReplyMessage);
                chargingMessage.setPlatformStopChargingReplyMessage(platformStopChargingReplyMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.TRANSACTION_RECORD:
                TransactionRecordMessage transactionRecordMessage = JSON.parseObject(content.toJSONString(),TransactionRecordMessage.class);
                sendResult = enhanceProduce.transactionRecordMessage(transactionRecordMessage);
                chargingMessage.setTransactionRecordMessage(transactionRecordMessage);
                // 响应硬件
                ConfirmTransactionRecord confirmTransactionRecord = new ConfirmTransactionRecord();
                confirmTransactionRecord.setTransaction_serial_number(transactionRecordMessage.getTransaction_serial_number());
                confirmTransactionRecord.setConfirm_result(0);
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.CONFIRM_TRANSACTION_RECORD.getKey(),messageUtil.confirmTransactionRecord(confirmTransactionRecord));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.UPDATE_BALANCE_REPLY:
                UpdateBalanceReplyMessage updateBalanceReplyMessage = JSON.parseObject(content.toJSONString(),UpdateBalanceReplyMessage.class);
                sendResult = enhanceProduce.updateBalanceReplyMessage(updateBalanceReplyMessage);
                chargingMessage.setUpdateBalanceReplyMessage(updateBalanceReplyMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.SYNCHRONIZE_OFFLINE_CARD_REPLY:
                SynchronizeOfflineCardReplyMessage synchronizeOfflineCardReplyMessage = JSON.parseObject(content.toJSONString(),SynchronizeOfflineCardReplyMessage.class);
                sendResult = enhanceProduce.synchronizeOfflineCardReplyMessage(synchronizeOfflineCardReplyMessage);
                chargingMessage.setSynchronizeOfflineCardReplyMessage(synchronizeOfflineCardReplyMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.CLEAR_OFFLINE_CARD_REPLY:
                ClearOfflineCardReplyMessage clearOfflineCardReplyMessage = JSON.parseObject(content.toJSONString(),ClearOfflineCardReplyMessage.class);
                sendResult = enhanceProduce.clearOfflineCardReplyMessage(clearOfflineCardReplyMessage);
                chargingMessage.setClearOfflineCardReplyMessage(clearOfflineCardReplyMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.WORKING_PARAMETER_SETTING_REPLY:
                WorkingParameterSettingReplyMessage workingParameterSettingReplyMessage = JSON.parseObject(content.toJSONString(),WorkingParameterSettingReplyMessage.class);
                sendResult = enhanceProduce.workingParameterSettingReplyMessage(workingParameterSettingReplyMessage);
                chargingMessage.setWorkingParameterSettingReplyMessage(workingParameterSettingReplyMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.TIMING_SETTING:
                TimingSettingMessage timingSettingMessage = JSON.parseObject(content.toJSONString(),TimingSettingMessage.class);
                sendResult = enhanceProduce.timingSettingMessage(timingSettingMessage);
                chargingMessage.setTimingSettingMessage(timingSettingMessage);
                // 响应硬件 对时设置应答
                TimingSettingReply timingSettingReply = new TimingSettingReply();
                timingSettingReply.setCharging_pile_code(timingSettingMessage.getCharging_pile_code());
                timingSettingReply.setCurrent_time(CP56Time2aConverter.convertToCP56Time2a(new Date()));
                iotMessageProduce.sendMessage(deviceId, ServiceIdMenu.TIMING_SETTING_REPLY.getKey(),messageUtil.timingSettingReply(timingSettingReply));
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                break;
            case SendTagConstant.SETUP_BILLING_MODEL_REPLY:
                SetupBillingModelReplyMessage setupBillingModelReplyMessage = JSON.parseObject(content.toJSONString(),SetupBillingModelReplyMessage.class);
                sendResult = enhanceProduce.setupBillingModelReplyMessage(setupBillingModelReplyMessage);
                chargingMessage.setSetupBillingModelReplyMessage(setupBillingModelReplyMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.GROUND_LOCK_REAL_TIME_DATA:
                GroundLockRealTimeDataMessage groundLockRealTimeDataMessage = JSON.parseObject(content.toJSONString(),GroundLockRealTimeDataMessage.class);
                sendResult = enhanceProduce.groundLockRealTimeDataMessage(groundLockRealTimeDataMessage);
                chargingMessage.setGroundLockRealTimeDataMessage(groundLockRealTimeDataMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.CHARGING_PILE_RETURNS_GROUND_LOCK_DATA:
                ChargingPileReturnsGroundLockDataMessage chargingPileReturnsGroundLockDataMessage = JSON.parseObject(content.toJSONString(),ChargingPileReturnsGroundLockDataMessage.class);
                sendResult = enhanceProduce.chargingPileReturnsGroundLockDataMessage(chargingPileReturnsGroundLockDataMessage);
                chargingMessage.setChargingPileReturnsGroundLockDataMessage(chargingPileReturnsGroundLockDataMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.PLATFORM_RESTART_REPLY:
                PlatformRestartReplyMessage platformRestartReplyMessage = JSON.parseObject(content.toJSONString(),PlatformRestartReplyMessage.class);
                sendResult = enhanceProduce.platformRestartReplyMessage(platformRestartReplyMessage);
                chargingMessage.setPlatformRestartReplyMessage(platformRestartReplyMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.QR_CODE_DELIVERY_REPLY:
                QrCodeDeliveryReplyMessage qrCodeDeliveryReplyMessage = JSON.parseObject(content.toJSONString(),QrCodeDeliveryReplyMessage.class);
                sendResult = enhanceProduce.qrCodeDeliveryReplyMessage(qrCodeDeliveryReplyMessage);
                chargingMessage.setQrCodeDeliveryReplyMessage(qrCodeDeliveryReplyMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            case SendTagConstant.SECURITY_DETECTION:
                SecurityDetectionMessage securityDetectionMessage = JSON.parseObject(content.toJSONString(),SecurityDetectionMessage.class);
                sendResult = enhanceProduce.securityDetectionMessage(securityDetectionMessage);
                chargingMessage.setSecurityDetectionMessage(securityDetectionMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
            default:
                PlatformRemoteUpdateReplyMessage platformRemoteUpdateReplyMessage = JSON.parseObject(content.toJSONString(),PlatformRemoteUpdateReplyMessage.class);
                sendResult = enhanceProduce.platformRemoteUpdateReplyMessage(platformRemoteUpdateReplyMessage);
                chargingMessage.setPlatformRemoteUpdateReplyMessage(platformRemoteUpdateReplyMessage);
                sendResult = enhanceProduce.chargingMessage(chargingMessage);
                // 响应硬件
                break;
        }
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/mongodb/service/impl/PlatformStopChargingReplyServiceImpl.java
@@ -10,6 +10,8 @@
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Service
@@ -39,8 +41,9 @@
     */
    @Override
    public PlatformStopChargingReply getPlatformStopChargingReply(GetPlatformStopChargingReply query) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        List<PlatformStopChargingReply> platformStopChargingReplies = mongoTemplate.find(new Query().addCriteria(Criteria.where("charging_pile_code").is(query.getCharging_pile_code())
                .and("charging_gun_code").is(query.getCharging_gun_code())), PlatformStopChargingReply.class);
                .and("charging_gun_code").is(query.getCharging_gun_code()).and("create_time").lte(sdf.format(new Date())).and("create_time").gte(query.getEnd_time())), PlatformStopChargingReply.class);
        return platformStopChargingReplies.size() > 0 ? platformStopChargingReplies.get(0) : null;
    }
}
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/base/BaseMessage.java
@@ -27,4 +27,9 @@
     * 重试次数,用于判断重试次数,超过重试次数发送异常警告
     */
    protected Integer retryTimes = 0;
    /**
     * 服务id
     */
    protected String serviceId;
}
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/EndChargeMessageListener.java
@@ -35,11 +35,6 @@
    @Autowired
    private EndChargeService endChargeService;
    @Autowired
    private MessageUtil messageUtil;
    @Autowired
    private IotMessageProduce iotMessageProduce;
    @Resource
    private ChargingOrderClient chargingOrderClient;
    
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/PlatformStartChargingReplyMessageListener.java
@@ -5,6 +5,8 @@
import com.ruoyi.integration.mongodb.service.PlatformStartChargingReplyService;
import com.ruoyi.integration.rocket.model.PlatformStartChargingReplyMessage;
import com.ruoyi.integration.rocket.util.EnhanceMessageHandler;
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
import com.ruoyi.order.api.vo.PlatformStartChargingReplyMessageVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
@@ -12,6 +14,8 @@
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Slf4j
@Component
@@ -26,6 +30,11 @@
    @Autowired
    private PlatformStartChargingReplyService platformStartChargingReplyService;
    @Resource
    private ChargingOrderClient chargingOrderClient;
    @Override
    protected void handleMessage(PlatformStartChargingReplyMessage message) throws Exception {
@@ -36,6 +45,9 @@
        BeanUtils.copyProperties(message,platformStartChargingReply);
        platformStartChargingReplyService.create(platformStartChargingReply);
        // 业务处理
        PlatformStartChargingReplyMessageVO message1 = new PlatformStartChargingReplyMessageVO();
        BeanUtils.copyProperties(message, message1);
        chargingOrderClient.startChargeSuccessfully(message1);
    }
    @Override
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/TimingSettingMessageListener.java
@@ -33,10 +33,6 @@
    @Autowired
    private TimingSettingService timingSettingService;
    @Autowired
    private IotMessageProduce iotMessageProduce;
    @Autowired
    private MessageUtil messageUtil;
    @Override
    protected void handleMessage(TimingSettingMessage message) throws Exception {
        // 此时这里才是最终的业务处理,代码只需要处理资源类关闭异常,其他的可以交给父类重试
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/UploadRealTimeMonitoringDataMessageListener.java
@@ -6,6 +6,7 @@
import com.ruoyi.chargingPile.api.model.TAccountingStrategyDetail;
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.model.TFaultMessage;
import com.ruoyi.chargingPile.api.vo.GetChargingGunByCode;
import com.ruoyi.integration.api.model.Online;
import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData;
import com.ruoyi.integration.mongodb.service.UploadRealTimeMonitoringDataService;
@@ -83,8 +84,10 @@
        UploadRealTimeMonitoringDataQuery query = new UploadRealTimeMonitoringDataQuery();
        BeanUtils.copyProperties(uploadRealTimeMonitoringData, query);
        chargingOrderClient.chargeMonitoring(query);
        TChargingGun chargingGun = chargingGunClient.getChargingGunByCode(message.getCharging_gun_code()).getData();
        GetChargingGunByCode code = new GetChargingGunByCode();
        code.setCharging_pile_code(message.getCharging_pile_code());
        code.setCharging_gun_code(message.getCharging_gun_code());
        TChargingGun chargingGun = chargingGunClient.getChargingGunByCode(code).getData();
        if(Objects.nonNull(chargingGun)){
            // 存储状态信息
            TFaultMessage faultMessage = new TFaultMessage();
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/model/BmsDemandAndChargerExportationMessage.java
@@ -25,10 +25,10 @@
    private BigDecimal bms_battery_voltage; //  最高电压 BMS 最高单体动力蓄电池电压及组号(1-12 位:最高单体动力蓄电池电压,数据分辨率:0.01 V/位,0 V 偏移量;数据范围:0~24 V;13-16 位:最高单体动力蓄电池电压所在组号,数据分辨率:1/位,0 偏移量;数据范围:0~15)
    private Integer bms_group_number; //  所在组号 BMS 最高单体动力蓄电池电压及组号(1-12 位:最高单体动力蓄电池电压,数据分辨率:0.01 V/位,0 V 偏移量;数据范围:0~24 V;13-16 位:最高单体动力蓄电池电压所在组号,数据分辨率:1/位,0 偏移量;数据范围:0~15)
    private BigDecimal bms_charged_status; // BMS 当前荷电状态 SOC( %)
    private Integer bms_remaining_charging_time; // BMS 估算剩余充电时间
    private BigDecimal bms_remaining_charging_time; // BMS 估算剩余充电时间
    private BigDecimal voltage_output_value; // 电桩电压输出值
    private BigDecimal current_output_value; // 电桩电流输出值
    private Integer cumulative_charging_time; // 累计充电时间
    private BigDecimal cumulative_charging_time; // 累计充电时间
}
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/model/BmsInformationMessage.java
@@ -17,9 +17,9 @@
    private String charging_gun_code; // 抢号
    private Integer bms_highest_voltage_number; // BMS 最高单体动力蓄电池电压所在编号
    private String bms_maximum_battery_temperature; // BMS 最高动力蓄电池温度
    private Integer maximum_temperature_detection_point_number; // 最高温度检测点编号
    private String maximum_temperature_detection_point_number; // 最高温度检测点编号
    private String minimum_cell_temperature; // 最低动力蓄电池温度
    private Integer lowest_temperature_detection_pointt_number; // 最低动力蓄电池温度检测点编号
    private String lowest_temperature_detection_pointt_number; // 最低动力蓄电池温度检测点编号
    private Integer bms_battery_voltage; // BMS 单体动力蓄电池电压过高 /过低(0:正常,1:过高,10:过低)
    private Integer bms_battery_charging_status; // BMS 整车动力蓄电池荷电状态SOC 过高/过低(0:正常,1:过高,10:过低)
    private Integer bms_charging_overcurrent; // BMS 动力蓄电池充电过电流(0:正常,1:过流,10:不可信状态)
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/model/ChargingMessage.java
New file
@@ -0,0 +1,44 @@
package com.ruoyi.integration.rocket.model;
import com.ruoyi.integration.rocket.base.BaseMessage;
import lombok.Data;
import org.apache.poi.ss.formula.functions.T;
@Data
public class ChargingMessage extends BaseMessage {
    private AcquisitionBillingModeMessage acquisitionBillingModeMessage;
    private BillingModeVerifyMessage billingModeVerifyMessage;
    private BmsAbortMessage bmsAbortMessage;
    private BmsDemandAndChargerExportationMessage bmsDemandAndChargerExportationMessage;
    private BmsInformationMessage bmsInformationMessage;
    private ChargingHandshakeMessage chargingHandshakeMessage;
    private ChargingMessage chargingMessage;
    private ChargingPileReturnsGroundLockDataMessage chargingPileReturnsGroundLockDataMessage;
    private ChargingPileStartsChargingMessage chargingPileStartsChargingMessage;
    private ClearOfflineCardReplyMessage clearOfflineCardReplyMessage;
    private EndChargeMessage endChargeMessage;
    private ErrorMessageMessage errorMessageMessage;
    private GroundLockRealTimeDataMessage groundLockRealTimeDataMessage;
    private MotorAbortMessage motorAbortMessage;
    private OnlineMessage onlineMessage;
    private ParameterSettingMessage parameterSettingMessage;
    private PingMessage pingMessage;
    private PlatformRemoteUpdateReplyMessage platformRemoteUpdateReplyMessage;
    private PlatformRestartReplyMessage platformRestartReplyMessage;
    private PlatformStartChargingReplyMessage platformStartChargingReplyMessage;
    private PlatformStopChargingReplyMessage platformStopChargingReplyMessage;
    private QrCodeDeliveryMessage qrCodeDeliveryMessage;
    private QrCodeDeliveryReplyMessage qrCodeDeliveryReplyMessage;
    private QueryOfflineCardReplyMessage queryOfflineCardReplyMessage;
    private SecurityDetectionMessage securityDetectionMessage;
    private SetupBillingModelReplyMessage setupBillingModelReplyMessage;
    private SynchronizeOfflineCardReplyMessage synchronizeOfflineCardReplyMessage;
    private TimingSettingMessage timingSettingMessage;
    private TimingSettingReplyMessage timingSettingReplyMessage;
    private TransactionRecordMessage transactionRecordMessage;
    private UpdateBalanceReplyMessage updateBalanceReplyMessage;
    private UploadRealTimeMonitoringDataMessage uploadRealTimeMonitoringDataMessage;
    private WorkingParameterSettingReplyMessage workingParameterSettingReplyMessage;
}
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/model/GroundLockRealTimeDataMessage.java
@@ -1,6 +1,7 @@
package com.ruoyi.integration.rocket.model;
import com.ruoyi.integration.rocket.base.BaseMessage;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.mongodb.core.mapping.Document;
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/ChargingMessageListener.java
New file
@@ -0,0 +1,501 @@
package com.ruoyi.integration.rocket.produce;
import com.alibaba.fastjson.JSON;
import com.ruoyi.chargingPile.api.feignClient.AccountingStrategyDetailClient;
import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient;
import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient;
import com.ruoyi.chargingPile.api.feignClient.FaultMessageClient;
import com.ruoyi.chargingPile.api.model.TAccountingStrategyDetail;
import com.ruoyi.chargingPile.api.model.TChargingGun;
import com.ruoyi.chargingPile.api.model.TFaultMessage;
import com.ruoyi.chargingPile.api.vo.GetChargingGunByCode;
import com.ruoyi.integration.api.model.*;
import com.ruoyi.integration.iotda.constant.SendTagConstant;
import com.ruoyi.integration.iotda.enums.ServiceIdMenu;
import com.ruoyi.integration.iotda.utils.tools.CP56Time2aConverter;
import com.ruoyi.integration.mongodb.service.*;
import com.ruoyi.integration.rocket.model.*;
import com.ruoyi.integration.rocket.util.EnhanceMessageHandler;
import com.ruoyi.order.api.feignClient.ChargingOrderClient;
import com.ruoyi.order.api.model.TChargingOrder;
import com.ruoyi.order.api.query.UploadRealTimeMonitoringDataQuery;
import com.ruoyi.order.api.vo.PlatformStartChargingReplyMessageVO;
import com.ruoyi.order.api.vo.PlatformStopChargingReplyVO;
import com.ruoyi.order.api.vo.SecurityDetectionVO;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.MessageModel;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Objects;
@Slf4j
@Component
@RocketMQMessageListener(
        messageModel = MessageModel.CLUSTERING,
        consumerGroup = "charge_charging_message",
        topic = "charge_charging_message",
        selectorExpression = "charging_message",
        consumeThreadMax = 5 //默认是64个线程并发消息,配置 consumeThreadMax 参数指定并发消费线程数,避免太大导致资源不够
)
public class ChargingMessageListener extends EnhanceMessageHandler<ChargingMessage> implements RocketMQListener<ChargingMessage> {
    @Autowired
    private AcquisitionBillingModeService acquisitionBillingModeService;
    @Autowired
    private BillingModeVerifyService billingModeVerifyService;
    @Autowired
    private BmsAbortService bmsAbortService;
    @Resource
    private ChargingOrderClient chargingOrderClient;
    @Autowired
    private BmsDemandAndChargerExportationService bmsDemandAndChargerExportationService;
    @Autowired
    private OnlineService onlineService;
    @Autowired
    private PingService pingService;
    @Autowired
    private EndChargeService endChargeService;
    @Autowired
    private ErrorMessageMessageService errorMessageMessageService;
    @Autowired
    private UploadRealTimeMonitoringDataService uploadRealTimeMonitoringDataService;
    @Resource
    private AccountingStrategyDetailClient accountingStrategyDetailClient;
    @Resource
    private ChargingGunClient chargingGunClient;
    @Resource
    private FaultMessageClient faultMessageClient;
    @Autowired
    private ChargingHandshakeService chargingHandshakeService;
    @Autowired
    private ParameterSettingService parameterSettingService;
    @Autowired
    private MotorAbortService motorAbortService;
    @Autowired
    private BmsInformationService bmsInformationService;
    @Autowired
    private ChargingPileStartsChargingService chargingPileStartsChargingService;
    @Autowired
    private PlatformStartChargingReplyService platformStartChargingReplyService;
    @Autowired
    private PlatformStopChargingReplyService platformStopChargingReplyService;
    @Autowired
    private TransactionRecordService transactionRecordService;
    @Autowired
    private UpdateBalanceReplyService updateBalanceReplyService;
    @Autowired
    private SynchronizeOfflineCardReplyService synchronizeOfflineCardReplyService;
    @Autowired
    private ClearOfflineCardReplyService clearOfflineCardReplyService;
    @Autowired
    private WorkingParameterSettingReplyService workingParameterSettingReplyService;
    @Autowired
    private TimingSettingService timingSettingService;
    @Autowired
    private SetupBillingModelReplyService setupBillingModelReplyService;
    @Autowired
    private GroundLockRealTimeDataService groundLockRealTimeDataService;
    @Autowired
    private ChargingPileReturnsGroundLockDataService chargingPileReturnsGroundLockDataService;
    @Autowired
    private PlatformRestartReplyService platformRestartReplyService;
    @Autowired
    private PlatformRemoteUpdateReplyService platformRemoteUpdateReplyService;
    @Autowired
    private QrCodeDeliveryReplyService qrCodeDeliveryReplyService;
    @Autowired
    private SecurityDetectionService securityDetectionService;
    @Resource
    private ChargingPileClient chargingPileClient;
    @StreamListener("input")
    @Override
    protected void handleMessage(ChargingMessage message) throws Exception {
        String serviceId = message.getServiceId();
        if(!StringUtils.hasLength(serviceId)){
            return;
        }
        switch (serviceId){
            case SendTagConstant.ONLINE:
                OnlineMessage onlineMessage = message.getOnlineMessage();
                log.info("充电桩登录认证业务消息处理:{}",onlineMessage);
                // 持久化消息
                Online online = new Online();
                BeanUtils.copyProperties(onlineMessage,online);
                onlineService.create(online);
                break;
            case SendTagConstant.PING:
                PingMessage pingMessage = message.getPingMessage();
                log.info("充电桩心跳包-业务消息处理:{}",pingMessage);
                // 持久化消息
                Ping ping = new Ping();
                BeanUtils.copyProperties(pingMessage,ping);
                pingService.create(ping);
                chargingPileClient.updateChargingPileStatus(pingMessage.getCharging_pile_code(), pingMessage.getCharging_gun_status());
                break;
            case SendTagConstant.END_CHARGE:
                EndChargeMessage endChargeMessage = message.getEndChargeMessage();
                log.info("充电结束-业务消息处理:{}",endChargeMessage);
                // 持久化消息
                EndCharge endCharge = new EndCharge();
                BeanUtils.copyProperties(endChargeMessage,endCharge);
                endChargeService.create(endCharge);
                // 业务处理
                chargingOrderClient.endCharge(endCharge.getTransaction_serial_number());
                break;
            case SendTagConstant.ERROR_MESSAGE:
                ErrorMessageMessage errorMessageMessage1 = message.getErrorMessageMessage();
                log.info("错误报文-业务消息处理:{}",errorMessageMessage1);
                // 持久化消息
                ErrorMessageMessage errorMessageMessage = new ErrorMessageMessage();
                BeanUtils.copyProperties(errorMessageMessage1,errorMessageMessage);
                errorMessageMessageService.create(errorMessageMessage);
                break;
            case SendTagConstant.BILLING_MODE_VERIFY:
                BillingModeVerifyMessage billingModeVerifyMessage = message.getBillingModeVerifyMessage();
                log.info("计费模型验证请求-业务消息处理:{}",billingModeVerifyMessage);
                // 持久化消息
                BillingModeVerify billingModeVerify = new BillingModeVerify();
                BeanUtils.copyProperties(billingModeVerifyMessage,billingModeVerify);
                billingModeVerifyService.create(billingModeVerify);
                break;
            case SendTagConstant.ACQUISITION_BILLING_MODE:
                AcquisitionBillingModeMessage acquisitionBillingModeMessage = message.getAcquisitionBillingModeMessage();
                log.info("充电桩计费模型请求-业务消息处理:{}",acquisitionBillingModeMessage);
                // 持久化消息
                AcquisitionBillingMode acquisitionBillingMode = new AcquisitionBillingMode();
                BeanUtils.copyProperties(acquisitionBillingModeMessage,acquisitionBillingMode);
                acquisitionBillingModeService.create(acquisitionBillingMode);
                break;
            case SendTagConstant.UPLOAD_REAL_TIME_MONITORING_DATA:
                UploadRealTimeMonitoringDataMessage uploadRealTimeMonitoringDataMessage = message.getUploadRealTimeMonitoringDataMessage();
                log.info("上传实时监测数据-业务消息处理:{}",uploadRealTimeMonitoringDataMessage);
                // 持久化消息
                UploadRealTimeMonitoringData uploadRealTimeMonitoringData = new UploadRealTimeMonitoringData();
                BeanUtils.copyProperties(uploadRealTimeMonitoringDataMessage,uploadRealTimeMonitoringData);
                // 查询mogondb上一条数据
                UploadRealTimeMonitoringData data = uploadRealTimeMonitoringDataService.getLastDataById(uploadRealTimeMonitoringDataMessage.getTransaction_serial_number());
                // 查询订单
                TChargingOrder chargingOrder = chargingOrderClient.getOrderByCode(uploadRealTimeMonitoringDataMessage.getTransaction_serial_number()).getData();
                // 查询当前时间段的计费策略
                TAccountingStrategyDetail accountingStrategyDetail = accountingStrategyDetailClient.getDetailBySiteId(chargingOrder.getSiteId()).getData();
                uploadRealTimeMonitoringData.setElectrovalence_all(accountingStrategyDetail.getElectrovalence());
                uploadRealTimeMonitoringData.setService_charge(accountingStrategyDetail.getServiceCharge());
                if (Objects.nonNull(data)) {
                    uploadRealTimeMonitoringData.setLast_time(data.getLast_time());
                    uploadRealTimeMonitoringData.setPeriod_electric_price(uploadRealTimeMonitoringDataMessage.getPaid_amount().subtract(data.getPaid_amount()));
                    uploadRealTimeMonitoringData.setPeriod_charging_degree(uploadRealTimeMonitoringDataMessage.getCharging_degree().subtract(data.getCharging_degree()));
                    uploadRealTimeMonitoringData.setPeriod_service_price(uploadRealTimeMonitoringDataMessage.getCharging_degree().multiply(accountingStrategyDetail.getServiceCharge()).setScale(4, RoundingMode.HALF_UP));
                }else {
                    log.info("首次上传实时监测数据");
                    uploadRealTimeMonitoringData.setPeriod_electric_price(uploadRealTimeMonitoringDataMessage.getPaid_amount());
                    uploadRealTimeMonitoringData.setPeriod_charging_degree(uploadRealTimeMonitoringDataMessage.getCharging_degree());
                    uploadRealTimeMonitoringData.setPeriod_service_price(uploadRealTimeMonitoringDataMessage.getCharging_degree().multiply(accountingStrategyDetail.getServiceCharge()).setScale(4, RoundingMode.HALF_UP));
                }
                uploadRealTimeMonitoringDataService.create(uploadRealTimeMonitoringData);
                // 业务处理
                UploadRealTimeMonitoringDataQuery query = new UploadRealTimeMonitoringDataQuery();
                BeanUtils.copyProperties(uploadRealTimeMonitoringData, query);
                chargingOrderClient.chargeMonitoring(query);
                GetChargingGunByCode code = new GetChargingGunByCode();
                code.setCharging_pile_code(uploadRealTimeMonitoringDataMessage.getCharging_pile_code());
                code.setCharging_gun_code(uploadRealTimeMonitoringDataMessage.getCharging_gun_code());
                TChargingGun chargingGun = chargingGunClient.getChargingGunByCode(code).getData();
                if(Objects.nonNull(chargingGun)){
                    // 存储状态信息
                    TFaultMessage faultMessage = new TFaultMessage();
                    if(uploadRealTimeMonitoringDataMessage.getCharging_gun_status().equals(0) || uploadRealTimeMonitoringDataMessage.getCharging_gun_status().equals(1)){
                        faultMessage.setSiteId(chargingGun.getSiteId());
                        faultMessage.setChargingPileId(chargingGun.getChargingPileId());
                        faultMessage.setChargingGunId(chargingGun.getId());
                        switch (uploadRealTimeMonitoringDataMessage.getCharging_gun_status()){
                            case 0:
                                faultMessage.setStatus(1);
                                chargingGun.setStatus(1);
                                break;
                            case 1:
                                faultMessage.setStatus(2);
                                chargingGun.setStatus(7);
                                break;
                        }
                        faultMessage.setDownTime(LocalDateTime.now());
                        faultMessageClient.createFaultMessage(faultMessage);
                    }else {
                        switch (uploadRealTimeMonitoringDataMessage.getCharging_gun_status()){
                            case 2:
                                chargingGun.setStatus(2);
                                break;
                            case 3:
                                chargingGun.setStatus(4);
                                break;
                        }
                        // 空闲 充电 查询是否该设备之前存在离线记录或者故障记录
                        faultMessage = faultMessageClient.getFaultMessageByGunId(chargingGun.getId()).getData();
                        if(Objects.nonNull(faultMessage)){
                            faultMessage.setEndTime(LocalDateTime.now());
                            faultMessageClient.updateFaultMessage(faultMessage);
                        }
                    }
                    chargingGunClient.updateChargingGunById(chargingGun);
                }
                break;
            case SendTagConstant.CHARGING_HANDSHAKE:
                ChargingHandshakeMessage chargingHandshakeMessage = message.getChargingHandshakeMessage();
                log.info("充电握手-业务消息处理:{}",chargingHandshakeMessage);
                // 持久化消息
                ChargingHandshake chargingHandshake = new ChargingHandshake();
                BeanUtils.copyProperties(chargingHandshakeMessage,chargingHandshake);
                chargingHandshakeService.create(chargingHandshake);
                break;
            case SendTagConstant.PARAMETER_SETTING:
                ParameterSettingMessage parameterSettingMessage = message.getParameterSettingMessage();
                log.info("业务消息处理:{}",parameterSettingMessage);
                // 持久化消息
                ParameterSetting parameterSetting = new ParameterSetting();
                BeanUtils.copyProperties(parameterSettingMessage,parameterSetting);
                parameterSettingService.create(parameterSetting);
                break;
            case SendTagConstant.BMS_ABORT:
                BmsAbortMessage bmsAbortMessage = message.getBmsAbortMessage();
                log.info("充电阶段BMS中止-业务消息处理:{}",bmsAbortMessage);
                // 持久化消息
                BmsAbort bmsAbort = new BmsAbort();
                BeanUtils.copyProperties(bmsAbortMessage,bmsAbort);
                bmsAbortService.create(bmsAbort);
                // 业务处理
                chargingOrderClient.excelEndCharge(bmsAbort.getTransaction_serial_number());
                break;
            case SendTagConstant.MOTOR_ABORT:
                MotorAbortMessage motorAbortMessage = message.getMotorAbortMessage();
                log.info("充电阶段充电机中止-业务消息处理:{}",motorAbortMessage);
                // 持久化消息
                MotorAbort motorAbort = new MotorAbort();
                BeanUtils.copyProperties(motorAbortMessage,motorAbort);
                motorAbortService.create(motorAbort);
                // 业务处理
                chargingOrderClient.excelEndCharge(motorAbort.getTransaction_serial_number());
                break;
            case SendTagConstant.BMS_DEMAND_AND_CHARGER_EXPORTATION:
                BmsDemandAndChargerExportationMessage bmsDemandAndChargerExportationMessage = message.getBmsDemandAndChargerExportationMessage();
                log.info("充电过程BMS需求、充电机输出-业务消息处理:{}",bmsDemandAndChargerExportationMessage);
                // 持久化消息
                BmsDemandAndChargerExportation bmsDemandAndChargerExportation = new BmsDemandAndChargerExportation();
                BeanUtils.copyProperties(bmsDemandAndChargerExportationMessage,bmsDemandAndChargerExportation);
                bmsDemandAndChargerExportationService.create(bmsDemandAndChargerExportation);
                // 业务处理
                TChargingOrder chargingOrderBms = chargingOrderClient.getOrderByCode(bmsDemandAndChargerExportationMessage.getTransaction_serial_number()).getData();
                if(Objects.nonNull(chargingOrderBms)){
                    chargingOrderBms.setNeedElec(bmsDemandAndChargerExportationMessage.getBms_current_requirements());
                    chargingOrderClient.updateChargingOrder(chargingOrderBms);
                }
                break;
            case SendTagConstant.BMS_INFORMATION:
                BmsInformationMessage bmsInformationMessage = message.getBmsInformationMessage();
                log.info("充电过程BMS信息-业务消息处理:{}",bmsInformationMessage);
                // 持久化消息
                BmsInformation bmsInformation = new BmsInformation();
                BeanUtils.copyProperties(bmsInformationMessage,bmsInformation);
                bmsInformationService.create(bmsInformation);
                break;
            case SendTagConstant.CHARGING_PILE_STARTS_CHARGING:
                ChargingPileStartsChargingMessage chargingPileStartsChargingMessage = message.getChargingPileStartsChargingMessage();
                log.info("充电桩主动申请启动充电-业务消息处理:{}",chargingPileStartsChargingMessage);
                // 持久化消息
                ChargingPileStartsCharging chargingPileStartsCharging = new ChargingPileStartsCharging();
                BeanUtils.copyProperties(chargingPileStartsChargingMessage,chargingPileStartsCharging);
                chargingPileStartsChargingService.create(chargingPileStartsCharging);
                break;
            case SendTagConstant.PLATFORM_START_CHARGING_REPLY:
                PlatformStartChargingReplyMessage platformStartChargingReplyMessage = message.getPlatformStartChargingReplyMessage();
                log.info("远程启机命令回复-业务消息处理:{}",platformStartChargingReplyMessage);
                // 持久化消息
                PlatformStartChargingReply platformStartChargingReply = new PlatformStartChargingReply();
                BeanUtils.copyProperties(platformStartChargingReplyMessage,platformStartChargingReply);
                platformStartChargingReplyService.create(platformStartChargingReply);
                // 业务处理
                PlatformStartChargingReplyMessageVO message1 = new com.ruoyi.order.api.vo.PlatformStartChargingReplyMessageVO();
                BeanUtils.copyProperties(platformStartChargingReplyMessage, message1);
                chargingOrderClient.startChargeSuccessfully(message1);
                break;
            case SendTagConstant.PLATFORM_STOP_CHARGING_REPLY:
                PlatformStopChargingReplyMessage platformStopChargingReplyMessage = message.getPlatformStopChargingReplyMessage();
                log.info("远程停机命令回复-业务消息处理:{}",platformStopChargingReplyMessage);
                // 持久化消息
                PlatformStopChargingReply platformStopChargingReply = new PlatformStopChargingReply();
                BeanUtils.copyProperties(platformStopChargingReplyMessage,platformStopChargingReply);
                platformStopChargingReplyService.create(platformStopChargingReply);
                PlatformStopChargingReplyVO platformStopChargingReply1 = new PlatformStopChargingReplyVO();
                BeanUtils.copyProperties(platformStopChargingReply, platformStopChargingReply1);
                chargingOrderClient.terminateSuccessfulResponse(platformStopChargingReply1);
                break;
            case SendTagConstant.TRANSACTION_RECORD:
                TransactionRecordMessage transactionRecordMessage = message.getTransactionRecordMessage();
                log.info("交易记录-业务消息处理:{}",transactionRecordMessage);
                // 持久化消息
                TransactionRecord transactionRecord = new TransactionRecord();
                BeanUtils.copyProperties(transactionRecordMessage,transactionRecord);
                transactionRecordService.create(transactionRecord);
                // 业务处理
                TChargingOrder chargingOrderRecord = chargingOrderClient.getOrderByCode(transactionRecordMessage.getTransaction_serial_number()).getData();
                if(Objects.nonNull(chargingOrderRecord)){
                    chargingOrderRecord.setTotalElectricity(transactionRecordMessage.getTotal_electricity());
                    chargingOrderClient.updateChargingOrder(chargingOrderRecord);
                }
                break;
            case SendTagConstant.UPDATE_BALANCE_REPLY:
                UpdateBalanceReplyMessage updateBalanceReplyMessage = message.getUpdateBalanceReplyMessage();
                log.info("余额更新应答-业务消息处理:{}",updateBalanceReplyMessage);
                // 持久化消息
                UpdateBalanceReply updateBalanceReply = new UpdateBalanceReply();
                BeanUtils.copyProperties(updateBalanceReplyMessage,updateBalanceReply);
                updateBalanceReplyService.create(updateBalanceReply);
                break;
            case SendTagConstant.SYNCHRONIZE_OFFLINE_CARD_REPLY:
                SynchronizeOfflineCardReplyMessage synchronizeOfflineCardReplyMessage = message.getSynchronizeOfflineCardReplyMessage();
                log.info("卡数据同步应答-业务消息处理:{}",synchronizeOfflineCardReplyMessage);
                // 持久化消息
                SynchronizeOfflineCardReply synchronizeOfflineCardReply = new SynchronizeOfflineCardReply();
                BeanUtils.copyProperties(synchronizeOfflineCardReplyMessage,synchronizeOfflineCardReply);
                synchronizeOfflineCardReplyService.create(synchronizeOfflineCardReply);
                break;
            case SendTagConstant.CLEAR_OFFLINE_CARD_REPLY:
                ClearOfflineCardReplyMessage clearOfflineCardReplyMessage = message.getClearOfflineCardReplyMessage();
                log.info("离线卡数据清除应答-业务消息处理:{}",clearOfflineCardReplyMessage);
                // 持久化消息
                ClearOfflineCardReply clearOfflineCardReply = new ClearOfflineCardReply();
                BeanUtils.copyProperties(clearOfflineCardReplyMessage,clearOfflineCardReply);
                clearOfflineCardReplyService.create(clearOfflineCardReply);
                break;
            case SendTagConstant.WORKING_PARAMETER_SETTING_REPLY:
                WorkingParameterSettingReplyMessage workingParameterSettingReplyMessage = message.getWorkingParameterSettingReplyMessage();
                log.info("充电桩工作参数设置应答-业务消息处理:{}",workingParameterSettingReplyMessage);
                // 持久化消息
                WorkingParameterSettingReply workingParameterSettingReply = new WorkingParameterSettingReply();
                BeanUtils.copyProperties(workingParameterSettingReplyMessage,workingParameterSettingReply);
                workingParameterSettingReplyService.create(workingParameterSettingReply);
                break;
            case SendTagConstant.TIMING_SETTING:
                TimingSettingMessage timingSettingMessage = message.getTimingSettingMessage();
                log.info("对时设置-业务消息处理:{}",timingSettingMessage);
                // 持久化消息
                TimingSetting timingSetting = new TimingSetting();
                BeanUtils.copyProperties(timingSettingMessage,timingSetting);
                timingSettingService.create(timingSetting);
                break;
            case SendTagConstant.SETUP_BILLING_MODEL_REPLY:
                SetupBillingModelReplyMessage setupBillingModelReplyMessage = message.getSetupBillingModelReplyMessage();
                log.info("计费模型应答-业务消息处理:{}",setupBillingModelReplyMessage);
                // 持久化消息
                SetupBillingModelReply setupBillingModelReply = new SetupBillingModelReply();
                BeanUtils.copyProperties(setupBillingModelReplyMessage,setupBillingModelReply);
                setupBillingModelReplyService.create(setupBillingModelReply);
                break;
            case SendTagConstant.GROUND_LOCK_REAL_TIME_DATA:
                GroundLockRealTimeDataMessage groundLockRealTimeDataMessage = message.getGroundLockRealTimeDataMessage();
                log.info("地锁数据上送(充电桩上送)-业务消息处理:{}",groundLockRealTimeDataMessage);
                // 持久化消息
                GroundLockRealTimeData groundLockRealTimeData = new GroundLockRealTimeData();
                BeanUtils.copyProperties(groundLockRealTimeDataMessage,groundLockRealTimeData);
                groundLockRealTimeDataService.create(groundLockRealTimeData);
                break;
            case SendTagConstant.CHARGING_PILE_RETURNS_GROUND_LOCK_DATA:
                ChargingPileReturnsGroundLockDataMessage chargingPileReturnsGroundLockDataMessage = message.getChargingPileReturnsGroundLockDataMessage();
                log.info("充电桩返回数据(上行)-业务消息处理:{}",chargingPileReturnsGroundLockDataMessage);
                // 持久化消息
                ChargingPileReturnsGroundLockData chargingPileReturnsGroundLockData = new ChargingPileReturnsGroundLockData();
                BeanUtils.copyProperties(chargingPileReturnsGroundLockDataMessage,chargingPileReturnsGroundLockData);
                chargingPileReturnsGroundLockDataService.create(chargingPileReturnsGroundLockData);
                break;
            case SendTagConstant.PLATFORM_RESTART_REPLY:
                PlatformRestartReplyMessage platformRestartReplyMessage = message.getPlatformRestartReplyMessage();
                log.info("远程重启应答-业务消息处理:{}",platformRestartReplyMessage);
                // 持久化消息
                PlatformRestartReply platformRestartReply = new PlatformRestartReply();
                BeanUtils.copyProperties(platformRestartReplyMessage,platformRestartReply);
                platformRestartReplyService.create(platformRestartReply);
                break;
            case SendTagConstant.QR_CODE_DELIVERY_REPLY:
                QrCodeDeliveryReplyMessage qrCodeDeliveryReplyMessage = message.getQrCodeDeliveryReplyMessage();
                log.info("二维码下发应答-业务消息处理:{}",qrCodeDeliveryReplyMessage);
                QrCodeDeliveryReply qrCodeDeliveryReply = new QrCodeDeliveryReply();
                BeanUtils.copyProperties(qrCodeDeliveryReplyMessage,qrCodeDeliveryReply);
                qrCodeDeliveryReplyService.create(qrCodeDeliveryReply);
                break;
            case SendTagConstant.SECURITY_DETECTION:
                SecurityDetectionMessage securityDetectionMessage = message.getSecurityDetectionMessage();
                log.info("安全监测-业务消息处理:{}",securityDetectionMessage);
                SecurityDetection securityDetection = new SecurityDetection();
                BeanUtils.copyProperties(securityDetectionMessage,securityDetection);
                securityDetectionService.create(securityDetection);
                SecurityDetectionVO securityDetection1 = new SecurityDetectionVO();
                BeanUtils.copyProperties(securityDetection, securityDetection1);
                chargingOrderClient.securityDetection(securityDetection1);
                break;
            default:
                PlatformRemoteUpdateReplyMessage platformRemoteUpdateReplyMessage = message.getPlatformRemoteUpdateReplyMessage();
                log.info("远程更新应答-业务消息处理:{}",platformRemoteUpdateReplyMessage);
                PlatformRemoteUpdateReply platformRemoteUpdateReply = new PlatformRemoteUpdateReply();
                BeanUtils.copyProperties(platformRemoteUpdateReplyMessage,platformRemoteUpdateReply);
                platformRemoteUpdateReplyService.create(platformRemoteUpdateReply);
                break;
        }
    }
    @Override
    protected void handleMaxRetriesExceeded(ChargingMessage message) {
        // 当超过指定重试次数消息时此处方法会被调用
        // 生产中可以进行回退或其他业务操作
        log.error("消息消费失败,请执行后续处理");
    }
    /**
     * 是否执行重试机制
     */
    @Override
    protected boolean isRetry() {
        return true;
    }
    @Override
    protected boolean throwException() {
        // 是否抛出异常,false搭配retry自行处理异常
        return false;
    }
    /**
     * 若需要处理消息过滤,在父级中进行统一处理,或者在此处实现之后,自行处理
     * @param message 待处理消息
     * @return true: 本次消息被过滤,false:不过滤
     */
    @Override
    protected boolean filter(ChargingMessage message) {
        // 此处可做消息过滤
        return false;
    }
    /**
     * 监听消费消息,不需要执行业务处理,委派给父类做基础操作,父类做完基础操作后会调用子类的实际处理类型
     */
    @Override
    public void onMessage(ChargingMessage message) {
        super.dispatchMessage(message);
    }
}
ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/produce/EnhanceProduce.java
@@ -343,4 +343,15 @@
        return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.SECURITY_DETECTION, SendTagConstant.SECURITY_DETECTION, message);
    }
    /**
     * 充电桩登录认证
     */
    public SendResult chargingMessage(ChargingMessage message) {
        // 设置业务key
        message.setKey(UUID.randomUUID().toString());
        // 设置消息来源,便于查询
        message.setSource(SendTagConstant.CHARGING_MESSAGE);
        return rocketMQEnhanceTemplate.send(TOPIC+SendTagConstant.CHARGING_MESSAGE, SendTagConstant.CHARGING_MESSAGE, message);
    }
}
ruoyi-service/ruoyi-integration/src/main/resources/bootstrap.yml
@@ -12,8 +12,8 @@
    allow-circular-references: true
  profiles:
    # 环境配置
#    active: dev
    active: prod
    active: dev
#    active: prod
    
---
spring:
@@ -64,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
@@ -53,6 +53,7 @@
import com.ruoyi.order.dto.OrderEvaluateVo;
import com.ruoyi.order.dto.*;
import com.ruoyi.order.service.*;
import com.ruoyi.order.service.impl.TChargingOrderServiceImpl;
import com.ruoyi.order.util.PreviousSixMonths;
import com.ruoyi.payment.api.feignClient.AliPaymentClient;
import com.ruoyi.payment.api.feignClient.WxPaymentClient;
@@ -63,6 +64,8 @@
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.models.auth.In;
import jdk.nashorn.internal.runtime.ListAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.ApiOperation;
@@ -94,6 +97,8 @@
@RestController
@RequestMapping("/t-charging-order")
public class TChargingOrderController {
    private Logger log = LoggerFactory.getLogger(TChargingOrderController.class);
    @Resource
    private TChargingOrderService chargingOrderService;
@@ -457,7 +462,30 @@
                                        @RequestParam("attach") String attach) {
        AjaxResult ajaxResult = chargingOrderService.chargingOrderCallback(1, out_trade_no, transaction_id, attach);
    }
    /**
     * 修改安全检测数据
     * @param securityDetection
     */
    @ResponseBody
    @PostMapping(value = "/securityDetection")
    public void securityDetection(@RequestBody SecurityDetectionVO securityDetection){
        chargingOrderService.securityDetection(securityDetection);
    }
    /**
     * 远程启动充电应答
     * @param message
     */
    @ResponseBody
    @PostMapping(value = "/startChargeSuccessfully")
    public void startChargeSuccessfully(@RequestBody PlatformStartChargingReplyMessageVO message){
        log.error("-------------------远程启动充电请求应答-------------------:" + message);
        chargingOrderService.startChargeSuccessfully(message);
    }
    /**
     * 支付宝支付成功后的回调
@@ -487,10 +515,10 @@
     */
    @ResponseBody
    @PostMapping(value = "/chargingOrderStartupFailureWxRefund")
    public void chargingOrderStartupFailureWxRefund(@RequestParam("out_trade_no") String out_refund_no,
                                                    @RequestParam("out_trade_no") String refund_id,
                                                    @RequestParam("out_trade_no") String tradeState,
                                                    @RequestParam("out_trade_no") String success_time){
    public void chargingOrderStartupFailureWxRefund(@RequestParam("out_refund_no") String out_refund_no,
                                                    @RequestParam("refund_id") String refund_id,
                                                    @RequestParam("tradeState") String tradeState,
                                                    @RequestParam("success_time") String success_time){
        chargingOrderService.chargingOrderStartupFailureWxRefund(out_refund_no, refund_id, tradeState, success_time);
    }
    
@@ -533,6 +561,20 @@
    public AjaxResult stopCharging(@PathVariable String id) {
        return chargingOrderService.stopCharging(id);
    }
    /**
     * 停止充电应答处理逻辑
     * @param platformStopChargingReply
     */
    @PostMapping("/terminateSuccessfulResponse")
    public void terminateSuccessfulResponse(@RequestBody PlatformStopChargingReplyVO platformStopChargingReply){
        log.error("-------------------远程停止充电请求应答-------------------:" + platformStopChargingReply);
        chargingOrderService.terminateSuccessfulResponse(platformStopChargingReply);
    }
    @ResponseBody
    @GetMapping(value = "/six/charge")
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/TOrderInvoiceController.java
@@ -142,7 +142,9 @@
                byte[] imageBytes = IOUtils.toByteArray(inputStream);
                // 创建临时文件
                File tempFile = File.createTempFile("tempImage", ".png");
                // 截取imageUrl后缀名
                String fileExtension = imageUrl.substring(imageUrl.lastIndexOf("."));
                File tempFile = File.createTempFile("tempImage", fileExtension);
                try (FileOutputStream fos = new FileOutputStream(tempFile)) {
                    fos.write(imageBytes);
                }
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/TChargingOrderService.java
@@ -17,10 +17,6 @@
import com.ruoyi.order.api.vo.*;
import com.ruoyi.order.dto.*;
import com.ruoyi.order.vo.ChargingOrderListInfoVO;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
@@ -80,6 +76,20 @@
    
    
    /**
     * 安全检测数据
     * @param securityDetection
     */
    void securityDetection(SecurityDetectionVO securityDetection);
    /**
     * 启动充电应发
     * @param message
     */
    void startChargeSuccessfully(PlatformStartChargingReplyMessageVO message);
    /**
     * 充电启动失败后的退款回调处理
     * @param out_refund_no
     * @param refund_id
@@ -105,6 +115,15 @@
     * @return
     */
    AjaxResult stopCharging(String id);
    /**
     * 停止充电应答结果处理
     * @param platformStopChargingReply
     */
    void terminateSuccessfulResponse(PlatformStopChargingReplyVO platformStopChargingReply);
    TCharingOrderVO chargingOrder(ChargingOrderQuery dto);
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -11,6 +11,7 @@
import com.ruoyi.account.api.vo.GetInviteUser;
import com.ruoyi.chargingPile.api.feignClient.*;
import com.ruoyi.chargingPile.api.model.*;
import com.ruoyi.chargingPile.api.vo.GetChargingGunByCode;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.dto.ChargingOrderGroup;
import com.ruoyi.common.core.dto.ChargingPercentProvinceDto;
@@ -37,6 +38,7 @@
import com.ruoyi.order.api.query.SettlementListQuery;
import com.ruoyi.order.api.query.UploadRealTimeMonitoringDataQuery;
import com.ruoyi.order.api.vo.*;
import com.ruoyi.order.api.vo.PlatformStopChargingReplyVO;
import com.ruoyi.order.dto.*;
import com.ruoyi.order.mapper.TChargingOrderMapper;
import com.ruoyi.order.mapper.TSettlementConfirmMapper;
@@ -189,6 +191,9 @@
    //计数器
    private Map<String, Integer> counter_map = new HashMap<>();
    //计数器
    private Map<String, Integer> boot_failed_map = new HashMap<>();
@@ -449,7 +454,7 @@
        
        //直营站点才可以享受会员折扣
        if(null != appUser.getVipId() && 1 == site.getBusinessCategory()){
            TVip vip = vipClient.getInfo(appUser.getVipId()).getData();
            TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
            BigDecimal discount = null;
            if(1 == vip.getType()){
                //普通会员折扣使用积分策略上的折扣,且有最高优惠金额
@@ -541,7 +546,7 @@
        preChargeCheck.setSecureConnectionDetection(false);
        preChargeCheck.setStartupSuccess(1);
        String key = "AQJC_" + chargingOrder.getChargingGunId();
        redisService.setCacheObject(key, preChargeCheck);
        redisService.setCacheObject(key, preChargeCheck, 24L, TimeUnit.HOURS);
        
        //根据当前充值的金额和计费模板算出充电的金额
        BigDecimal rechargeAmount = chargingOrder.getRechargeAmount();
@@ -602,7 +607,7 @@
        if(discountAmount.compareTo(BigDecimal.ZERO) >= 0){
            //计算会员最大优惠金额
            if(null != appUser.getVipId()){
                TVip vip = vipClient.getInfo(appUser.getVipId()).getData();
                TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
                BigDecimal maximumDeduction = vip.getMaximumDeduction();
                //普通会员有最高优惠限制
                if(vip.getType() == 1 && discountAmount.compareTo(maximumDeduction) > 0){
@@ -614,7 +619,7 @@
                getAppUserVipDetail.setAppUserId(chargingOrder.getAppUserId());
                getAppUserVipDetail.setVipId(appUser.getVipId());
                TAppUserVipDetail data = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData();
                if(data.getChargeNum() > 0){
                if(null != data && data.getChargeNum() > 0){
                    data.setChargeNum(data.getChargeNum() - 1);
                    appUserVipDetailClient.updateAppUserVipDetail(data);
                    //会员有充电优惠次数,直接将优惠金额加入到充电费用中增加充电时长
@@ -622,6 +627,9 @@
                }
            }
        }
        electrovalence = electrovalence.setScale(2, RoundingMode.HALF_EVEN);
        discountAmount = discountAmount.setScale(2, RoundingMode.HALF_EVEN);
        chargingOrder.setChargeAmount(electrovalence);
        chargingOrder.setVipDiscountAmount(discountAmount);
        this.updateById(chargingOrder);
@@ -636,72 +644,18 @@
        //使用订单id作为逻辑卡号
        platformStartCharging.setCard_number(chargingOrder.getId().toString());
        platformStartCharging.setAccount_balance(electrovalence);
        System.err.println("-------------------远程调起开始充电请求-------------------");
        System.err.println(platformStartCharging.toString());
        log.error(chargingOrder.getCode() + ":-------------------远程调起开始充电请求-------------------");
        log.error(platformStartCharging.toString());
        sendMessageClient.platformStartCharging(platformStartCharging);
        //异步线程检测远程启动的应答结果。如果失败,则需要全额退款
        String code = chargingOrder.getCode();
        Long id = chargingOrder.getId();
        //执行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());
            if(data.size() != 0){
                PlatformStartChargingReply platformStartChargingReply = data.get(1);
                Integer startup_result = platformStartChargingReply.getStartup_result();
                Integer failure_cause = platformStartChargingReply.getFailure_cause();
                Integer counter = counter_map.get(code);
                PreChargeCheck preChargeCheck1 = redisService.getCacheObject(key);
                //5分钟内还未插枪则取消充电,退回金额。
                if(failure_cause == 5 && (null == counter || counter < 300)){
                    counter = (null == counter ? 0 : counter) + 1;
                    counter_map.put(code, counter);
                    //启动失败
                    preChargeCheck1.setStartupSuccess(3);
                    preChargeCheck1.setFailureCause(failure_cause);
                    redisService.setCacheObject(key, preChargeCheck1);
                    return;
                }
                //清除计时器中的无效数据
                counter_map.remove(code);
                TChargingOrder order = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, code));
                if(0 == startup_result){
                    //启动失败
                    preChargeCheck1.setStartupSuccess(3);
                    preChargeCheck1.setFailureCause(failure_cause);
                    //启动失败后取消订单,退款操作
                    refund(code);
                    order.setStatus(-1);
                    order.setEndMode(0);
                }else{
                    //启动成功
                    preChargeCheck1.setStartupSuccess(2);
                    order.setStatus(3);
                    order.setStartTime(LocalDateTime.now());
                }
                this.updateById(order);
                redisService.setCacheObject(key, preChargeCheck1);
                //提前结束定时任务
            if(timingDetection(id)){
                scheduler.shutdown();
            }else{
                log.error("未上传开启充电结果........");
            }
        }, 5, 1, TimeUnit.SECONDS);
        return AjaxResult.success();
@@ -709,10 +663,167 @@
    
    
    /**
     * 定时检测mongodb数据库数据
     * @param id
     * @return
     */
    public boolean timingDetection(Long id){
        TChargingOrder chargingOrder = this.getById(id);
        if(chargingOrder.getStatus() != 2){
            return true;
        }
        String code = chargingOrder.getCode();
        String key = "AQJC_" + chargingOrder.getChargingGunId();
        //获取安全校验
        com.ruoyi.integration.api.model.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, 24L, TimeUnit.HOURS);
            }
        }
        List<PlatformStartChargingReply> data = platformStartChargingReplyClient.getPlatformStartChargingReply(code).getData();
        log.error(code + ":-------------------开始检查调起充电结果-------------------");
        log.error(data.toString());
        if(data.size() != 0){
            PlatformStartChargingReply platformStartChargingReply = data.get(1);
            Integer startup_result = platformStartChargingReply.getStartup_result();
            Integer failure_cause = platformStartChargingReply.getFailure_cause();
            Integer counter = counter_map.get(code);
            PreChargeCheck preChargeCheck1 = redisService.getCacheObject(key);
            //5分钟内还未插枪则取消充电,退回金额。
            if(failure_cause == 5 && (null == counter || counter < 300)){
                counter = (null == counter ? 0 : counter) + 1;
                counter_map.put(code, counter);
                //启动失败
                preChargeCheck1.setStartupSuccess(3);
                preChargeCheck1.setFailureCause(failure_cause);
                redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS);
                return false;
            }
            //清除计时器中的无效数据
            counter_map.remove(code);
            TChargingOrder order = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, code));
            if(0 == startup_result){
                //启动失败
                preChargeCheck1.setStartupSuccess(3);
                preChargeCheck1.setFailureCause(failure_cause);
                //启动失败后取消订单,退款操作
                refund(code);
                order.setStatus(-1);
                order.setEndMode(0);
            }else{
                //启动成功
                preChargeCheck1.setStartupSuccess(2);
                order.setStatus(3);
                order.setStartTime(LocalDateTime.now());
            }
            this.updateById(order);
            redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS);
            return true;
        }else{
            log.error(code + ":-------------------未上传开启充电结果-------------------");
            Integer counter = boot_failed_map.get(code);
            PreChargeCheck preChargeCheck1 = redisService.getCacheObject(key);
            //5分钟内未启动成功,退回金额。
            if(null == counter || counter < 300){
                counter = (null == counter ? 0 : counter) + 1;
                boot_failed_map.put(code, counter);
                //启动失败
                preChargeCheck1.setStartupSuccess(3);
                preChargeCheck1.setFailureCause(0);
                redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS);
                return false;
            }
            //清除计时器中的无效数据
            boot_failed_map.remove(code);
            TChargingOrder order = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, code));
            //启动失败
            preChargeCheck1.setStartupSuccess(3);
            preChargeCheck1.setFailureCause(0);
            //启动失败后取消订单,退款操作
            refund(code);
            order.setStatus(-1);
            order.setEndMode(0);
            this.updateById(order);
            redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS);
            return true;
        }
    }
    /**
     * 修改安全检测数据
     * @param securityDetection
     */
    @Override
    public void securityDetection(SecurityDetectionVO securityDetection){
        GetChargingGunByCode code = new GetChargingGunByCode();
        code.setCharging_pile_code(securityDetection.getCharging_pile_code());
        code.setCharging_gun_code(securityDetection.getCharging_gun_code());
        TChargingGun chargingGun = chargingGunClient.getChargingGunByCode(code).getData();
        PreChargeCheck preChargeCheck1 =  redisService.getCacheObject("AQJC_" + chargingGun.getId());
        if(null != preChargeCheck1){
            preChargeCheck1.setElectronicLockLock(preChargeCheck1.getElectronicLockLock());
            preChargeCheck1.setInsulationTesting(true);
            preChargeCheck1.setSecureConnectionDetection(preChargeCheck1.getSecureConnectionDetection());
            preChargeCheck1.setStartupSuccess(1);
            redisService.setCacheObject("AQJC_" + chargingGun.getId(), preChargeCheck1, 24L, TimeUnit.HOURS);
        }
    }
    /**
     * 启动充电应发
     * @param message
     */
    @Override
    public void startChargeSuccessfully(PlatformStartChargingReplyMessageVO message) {
        Integer startup_result = message.getStartup_result();
        Integer failure_cause = message.getFailure_cause();
        TChargingOrder order = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, message.getTransaction_serial_number()));
        if(order.getStatus() != 2){
            return;
        }
        String code = order.getCode();
        PreChargeCheck preChargeCheck1 =  redisService.getCacheObject("AQJC_" + order.getChargingGunId());
        if(null != preChargeCheck1){
            preChargeCheck1.setElectronicLockLock(preChargeCheck1.getElectronicLockLock());
            preChargeCheck1.setInsulationTesting(true);
            preChargeCheck1.setSecureConnectionDetection(preChargeCheck1.getSecureConnectionDetection());
            preChargeCheck1.setStartupSuccess(1);
        }
        if(0 == startup_result){
            //启动失败
            preChargeCheck1.setStartupSuccess(3);
            preChargeCheck1.setFailureCause(failure_cause);
            //启动失败后取消订单,退款操作
            refund(code);
            order.setStatus(-1);
            order.setEndMode(0);
        }else{
            //启动成功
            preChargeCheck1.setStartupSuccess(2);
            order.setStatus(3);
            order.setStartTime(LocalDateTime.now());
        }
        redisService.setCacheObject("AQJC_" + order.getChargingGunId(), preChargeCheck1, 24L, TimeUnit.HOURS);
        this.updateById(order);
    }
    /**
     * 启动失败后的退款,取消订单
     * @param code
     */
    public void refund(String code){
        log.error(code + ":-------------------充电启动失败,执行退款-------------------");
        TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, code));
        if(chargingOrder.getStatus() == 2){
            Integer rechargePaymentType = chargingOrder.getRechargePaymentType();
@@ -847,9 +958,13 @@
    public AjaxResult stopCharging(String id) {
        TChargingOrder chargingOrder = this.getById(id);
        Integer status = chargingOrder.getStatus();
        if(status != 3){
            return AjaxResult.error("还未开始充电");
        }
        if(status == 4 || status == 5){
            return AjaxResult.error("不能重复操作");
        }
        chargingOrder.setEndTime(LocalDateTime.now());
        chargingOrder.setStatus(4);
        chargingOrder.setEndMode(1);
        this.updateById(chargingOrder);
@@ -910,7 +1025,7 @@
                }
            }
        }
        String code1 = chargingOrder.getCode();
        
        //异步线程处理停机
        ExecutorService cachedThreadPool = Executors.newFixedThreadPool(1);
@@ -922,12 +1037,17 @@
            platformStopCharging.setCharging_pile_code(chargingPile.getCode());
            platformStopCharging.setCharging_gun_code(chargingGun.getCode());
            sendMessageClient.platformStopCharging(platformStopCharging);
            log.error(code1 + ":-------------------远程停止充电请求-------------------");
            log.error(platformStopCharging.toString());
            //开始查询停机应答,成功后开始计费费用
            for (int i = 0; i < 60; i++) {
                GetPlatformStopChargingReply query = new GetPlatformStopChargingReply();
                query.setCharging_gun_code(chargingGun.getCode());
                query.setCharging_pile_code(chargingPile.getCode());
                query.setEnd_time(chargingOrder.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
                PlatformStopChargingReply reply = platformStopChargingReplyClient.getPlatformStopChargingReply(query).getData();
                log.error(code1 + ":-------------------查询远程停止充电应答-------------------");
                log.error(reply.toString());
                if(null == reply){
                    try {
                        Thread.sleep(1000);
@@ -936,7 +1056,12 @@
                    }
                    continue;
                }
                TChargingOrder chargingOrder1 = this.getById(id);
                if(chargingOrder1.getStatus() != 3){
                    break;
                }
                if(0 == reply.getStop_result()){
                    String failure_cause = "";
                    switch (reply.getFailure_cause()){
@@ -953,8 +1078,13 @@
                            failure_cause = "其他";
                            break;
                    }
                    log.error("停机失败:订单号:{},失败原因:{}", chargingOrder.getCode(), failure_cause);
                    throw new RuntimeException(failure_cause);
                    log.error(code1 + ":停机失败:订单号:{},失败原因:{}", chargingOrder.getCode(), failure_cause);
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    continue;
                }
                // 将枪状态重置为空闲
@@ -962,6 +1092,7 @@
                chargingGunClient.updateChargingGunById(chargingGun);
                //计算费用,处理退款
                endCharge(chargingOrder);
                log.error(code1 + ":-------------------远程停止充电请求成功-------------------");
                break;
            }
        });
@@ -979,7 +1110,7 @@
            
            TAppUser appUser1 = appUserClient.getUserById(appUser.getInviteUserId()).getData();
            if(null != appUser1.getVipId()){
                TVip vip = vipClient.getInfo(appUser1.getVipId()).getData();
                TVip vip = vipClient.getInfo1(appUser1.getVipId()).getData();
                Integer doubleIntegration = vip.getDoubleIntegration();
                //双倍积分
                if(1 == doubleIntegration){
@@ -1018,8 +1149,56 @@
        return AjaxResult.success();
    }
    /**
     * 停止充电应答结果处理
     * @param platformStopChargingReply
     */
    @Override
    public void terminateSuccessfulResponse(PlatformStopChargingReplyVO platformStopChargingReply){
        GetChargingGunByCode code = new GetChargingGunByCode();
        code.setCharging_gun_code(platformStopChargingReply.getCharging_gun_code());
        code.setCharging_pile_code(platformStopChargingReply.getCharging_pile_code());
        TChargingGun chargingGun = chargingGunClient.getChargingGunByCode(code).getData();
        TChargingOrder order = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getChargingGunId, chargingGun.getId())
                .orderByDesc(TChargingOrder::getEndTime).eq(TChargingOrder::getRechargePaymentStatus, 2).last(" limit 0, 1"));
        if(null != order && order.getStatus() != 3){
            return;
        }
        String code1 = order.getCode();
        if(0 == platformStopChargingReply.getStop_result()){
            String failure_cause = "";
            switch (platformStopChargingReply.getFailure_cause()){
                case 0:
                    failure_cause = "无";
                    break;
                case 1:
                    failure_cause = "设备编号不匹配";
                    break;
                case 2:
                    failure_cause = "枪未处于充电状态";
                    break;
                case 3:
                    failure_cause = "其他";
                    break;
            }
            log.error(code1 + ":停机失败:订单号:{},失败原因:{}", order.getCode(), failure_cause);
            return;
        }
        // 将枪状态重置为空闲
        chargingGun.setStatus(2);
        chargingGunClient.updateChargingGunById(chargingGun);
        //计算费用,处理退款
        endCharge(order);
    }
    /**
     * 手动结束后的费用计算和退款逻辑
     */
@@ -1061,7 +1240,7 @@
            Integer num1 = JSON.parseObject(integralRule.getChargeCredit()).getInteger("num1");
            Integer integral = payAmount.multiply(new BigDecimal(num1)).intValue();
            if(null != appUser.getVipId()){
                TVip vip = vipClient.getInfo(appUser.getVipId()).getData();
                TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
                Integer doubleIntegration = vip.getDoubleIntegration();
                //双倍积分
                if(1 == doubleIntegration){
@@ -1791,7 +1970,7 @@
            
            TAppUser appUser1 = appUserClient.getUserById(appUser.getInviteUserId()).getData();
            if(null != appUser1.getVipId()){
                TVip vip = vipClient.getInfo(appUser1.getVipId()).getData();
                TVip vip = vipClient.getInfo1(appUser1.getVipId()).getData();
                Integer doubleIntegration = vip.getDoubleIntegration();
                //双倍积分
                if(1 == doubleIntegration){
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TOrderEvaluateServiceImpl.java
@@ -278,7 +278,7 @@
            if(null != num1 && 0 < num1){
                TAppUser appUser = appUserClient.getUserById(userid).getData();
                if(null != appUser.getVipId()){
                    TVip vip = vipClient.getInfo(appUser.getVipId()).getData();
                    TVip vip = vipClient.getInfo1(appUser.getVipId()).getData();
                    Integer doubleIntegration = vip.getDoubleIntegration();
                    //双倍积分
                    if(1 == doubleIntegration){
ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TVipOrderServiceImpl.java
@@ -53,7 +53,7 @@
        for (TVipOrder tVipOrder : list) {
            tVipOrder.setUid(tVipOrder.getId().toString());
            tVipOrder.setUserUid(tVipOrder.getAppUserId().toString());
            TVip data = vipClient.getInfo(tVipOrder.getVipId()).getData();
            TVip data = vipClient.getInfo1(tVipOrder.getVipId()).getData();
            if (data!=null){
                tVipOrder.setName(data.getName());
            }
ruoyi-service/ruoyi-order/src/main/resources/bootstrap.yml
@@ -29,7 +29,6 @@
        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
@@ -29,7 +29,6 @@
        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,8 +12,8 @@
    allow-circular-references: true
  profiles:
    # 环境配置
#    active: dev
    active: prod
    active: dev
#    active: prod
---
spring:
  config:
@@ -56,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控制台地址