Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile
| | |
| | | @TableField(exist = false) |
| | | private String orderNum; |
| | | |
| | | @TableField(exist = false) |
| | | private Integer goodType; |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | 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; |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @ApiModelProperty(value = "会员开始时间") |
| | | @TableField("start_time") |
| | | @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @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") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime endTime; |
| | | |
| | | @TableField("create_time") |
| | | @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") |
| | | private LocalDateTime createTime; |
| | | |
| | | @ApiModelProperty(value = "已赠送的月份") |
| | |
| | | private String vipName; |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | 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; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public R<TChargingGun> getChargingGunByCode(String code) { |
| | | public R<TChargingGun> getChargingGunByCode(GetChargingGunByCode code) { |
| | | return R.fail("根据枪编号获取充电枪失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | |
| | | 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; |
| | |
| | | * @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 |
| | |
| | | @ApiModelProperty(value = "设备状态(1=工作中,2=离线,3=故障)") |
| | | @TableField("status") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "iotd设备id") |
| | | @TableField("iotd_device_id") |
| | | private String iotdDeviceId; |
| | | } |
New file |
| | |
| | | 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; // 抢号 |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.api.factory; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.integration.api.feignClient.IotInterfaceClient; |
| | | import com.ruoyi.integration.api.feignClient.SwitchwayGateClient; |
| | | import com.ruoyi.integration.api.vo.AddDevice; |
| | | import com.ruoyi.integration.api.vo.AddDeviceResp; |
| | | import com.ruoyi.integration.api.vo.DeleteDeviceResp; |
| | | import com.ruoyi.integration.api.vo.SwitchwayGateReq; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 充电桩服务降级处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class IotInterfaceFallbackFactory implements org.springframework.cloud.openfeign.FallbackFactory<IotInterfaceClient> { |
| | | private static final Logger log = LoggerFactory.getLogger(IotInterfaceFallbackFactory.class); |
| | | |
| | | @Override |
| | | public IotInterfaceClient create(Throwable throwable) { |
| | | log.error("调用失败:{}", throwable.getMessage()); |
| | | return new IotInterfaceClient() { |
| | | |
| | | |
| | | @Override |
| | | public R<AddDeviceResp> addDevice(AddDevice addDevice) { |
| | | return R.fail("添加设备失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public R<DeleteDeviceResp> deleteDevice(String deviceId) { |
| | | return R.fail("删除设备失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.api.factory; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.integration.api.feignClient.SecurityDetectionClient; |
| | | import com.ruoyi.integration.api.feignClient.SendMessageClient; |
| | | import com.ruoyi.integration.api.model.PlatformStartCharging; |
| | | import com.ruoyi.integration.api.model.PlatformStopCharging; |
| | | import com.ruoyi.integration.api.model.QrCodeDelivery; |
| | | import com.ruoyi.integration.api.model.SecurityDetection; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * 充电桩服务降级处理 |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | @Component |
| | | public class SecurityDetectionFallbackFactory implements org.springframework.cloud.openfeign.FallbackFactory<SecurityDetectionClient> |
| | | { |
| | | private static final Logger log = LoggerFactory.getLogger(SecurityDetectionFallbackFactory.class); |
| | | |
| | | @Override |
| | | public SecurityDetectionClient create(Throwable throwable) { |
| | | log.error("调用失败:{}", throwable.getMessage()); |
| | | return new SecurityDetectionClient() { |
| | | |
| | | @Override |
| | | public R<SecurityDetection> getSecurityDetection(String transactionSerialNumber) { |
| | | return R.fail("获取安全检测数据失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | import com.ruoyi.integration.api.model.ChargingHandshake; |
| | | import com.ruoyi.integration.api.model.PlatformStartCharging; |
| | | import com.ruoyi.integration.api.model.PlatformStopCharging; |
| | | import com.ruoyi.integration.api.model.QrCodeDelivery; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.cloud.openfeign.FallbackFactory; |
| | |
| | | public String platformStopCharging(PlatformStopCharging platformStopCharging) { |
| | | return "远程停机失败"; |
| | | } |
| | | |
| | | @Override |
| | | public String qrCodeDelivery(QrCodeDelivery qrCodeDelivery) { |
| | | return "二维码下发失败"; |
| | | } |
| | | }; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.api.feignClient; |
| | | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.integration.api.factory.IotInterfaceFallbackFactory; |
| | | import com.ruoyi.integration.api.vo.AddDevice; |
| | | import com.ruoyi.integration.api.vo.AddDeviceResp; |
| | | import com.ruoyi.integration.api.vo.DeleteDeviceResp; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/10/8 10:24 |
| | | */ |
| | | @FeignClient(contextId = "IotInterfaceClient", value = ServiceNameConstants.INTEGRATION_SERVICE, fallbackFactory = IotInterfaceFallbackFactory.class) |
| | | public interface IotInterfaceClient { |
| | | |
| | | |
| | | /** |
| | | * 添加设备 |
| | | * @param addDevice |
| | | * @return |
| | | */ |
| | | @PostMapping("/iotInterface/addDevice") |
| | | R<AddDeviceResp> addDevice(@RequestBody AddDevice addDevice); |
| | | |
| | | |
| | | /** |
| | | * 删除设备 |
| | | * @param deviceId |
| | | * @return |
| | | */ |
| | | @PostMapping("/iotInterface/deleteDevice") |
| | | R<DeleteDeviceResp> deleteDevice(@RequestParam("deviceId") String deviceId); |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.api.feignClient; |
| | | |
| | | import com.ruoyi.common.core.constant.ServiceNameConstants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.integration.api.factory.SecurityDetectionFallbackFactory; |
| | | import com.ruoyi.integration.api.model.SecurityDetection; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/10/8 14:23 |
| | | */ |
| | | @FeignClient(contextId = "SecurityDetectionClient", value = ServiceNameConstants.INTEGRATION_SERVICE, fallbackFactory = SecurityDetectionFallbackFactory.class) |
| | | public interface SecurityDetectionClient { |
| | | |
| | | |
| | | /** |
| | | * 获取安全检测数据 |
| | | * @param transactionSerialNumber |
| | | * @return |
| | | */ |
| | | @PostMapping("/securityDetection/getSecurityDetection") |
| | | R<SecurityDetection> getSecurityDetection(@RequestParam("transactionSerialNumber") String transactionSerialNumber); |
| | | } |
| | |
| | | import com.ruoyi.integration.api.factory.SendMessageFallbackFactory; |
| | | import com.ruoyi.integration.api.model.PlatformStartCharging; |
| | | import com.ruoyi.integration.api.model.PlatformStopCharging; |
| | | import com.ruoyi.integration.api.model.QrCodeDelivery; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | */ |
| | | @PostMapping("/sendMessage/platformStopCharging") |
| | | String platformStopCharging(@RequestBody PlatformStopCharging platformStopCharging); |
| | | |
| | | |
| | | /** |
| | | * 二维码下发 |
| | | * @param qrCodeDelivery |
| | | * @return |
| | | */ |
| | | @PostMapping("/sendMessage/qrCodeDelivery") |
| | | String qrCodeDelivery(@RequestBody QrCodeDelivery qrCodeDelivery); |
| | | } |
| | |
| | | @Document(collection = "platform_start_charging_reply") //指定要对应的文档名(表名) |
| | | @Accessors(chain = true) |
| | | public class PlatformStartChargingReply extends BaseModel { |
| | | @Id |
| | | private String transaction_serial_number; // 交易流水号 |
| | | private String charging_pile_code; // 桩编码 |
| | | private String charging_gun_code; // 抢号 |
| | |
| | | @Document(collection = "security_detection") //指定要对应的文档名(表名) |
| | | @Accessors(chain = true) |
| | | public class SecurityDetection { |
| | | |
| | | @Id |
| | | private String transaction_serial_number; // 交易流水号 |
| | | private String charging_pile_code; // 桩编码 |
| | | private String charging_gun_code; // 抢号 |
| | | private Integer secure_connection; // 车枪连接(0=未连接,1=连接) |
New file |
| | |
| | | package com.ruoyi.integration.api.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/10/8 10:26 |
| | | */ |
| | | @Data |
| | | public class AddDevice { |
| | | /** |
| | | * 产品ID |
| | | */ |
| | | private String productId; |
| | | /** |
| | | * 设备标识码 设备编号 |
| | | */ |
| | | private String nodeId; |
| | | /** |
| | | * 设备名称 |
| | | */ |
| | | private String deviceName; |
| | | /** |
| | | * 设备描述 |
| | | */ |
| | | private String description; |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.api.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | import lombok.Data; |
| | | |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/10/8 10:37 |
| | | */ |
| | | @Data |
| | | public class AddDeviceResp { |
| | | private int httpStatusCode; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("app_id") |
| | | private String appId; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("app_name") |
| | | private String appName; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("device_id") |
| | | private String deviceId; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("node_id") |
| | | private String nodeId; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("gateway_id") |
| | | private String gatewayId; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("device_name") |
| | | private String deviceName; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("node_type") |
| | | private String nodeType; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("description") |
| | | private String description; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("fw_version") |
| | | private String fwVersion; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("sw_version") |
| | | private String swVersion; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("device_sdk_version") |
| | | private String deviceSdkVersion; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("product_id") |
| | | private String productId; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("product_name") |
| | | private String productName; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("status") |
| | | private String status; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("create_time") |
| | | private String createTime; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("connection_status_update_time") |
| | | private String connectionStatusUpdateTime; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("active_time") |
| | | private String activeTime; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("extension_info") |
| | | private Object extensionInfo; |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.api.vo; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonIgnore; |
| | | import com.fasterxml.jackson.annotation.JsonInclude; |
| | | import com.fasterxml.jackson.annotation.JsonProperty; |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/10/8 10:40 |
| | | */ |
| | | @Data |
| | | public class DeleteDeviceResp { |
| | | @JsonIgnore |
| | | private int httpStatusCode; |
| | | @JsonInclude(JsonInclude.Include.NON_NULL) |
| | | @JsonProperty("body") |
| | | private String body; |
| | | } |
| | |
| | | com.ruoyi.integration.api.factory.PlatformStartChargingReplyFallbackFactory |
| | | com.ruoyi.integration.api.factory.PlatformStopChargingReplyFallbackFactory |
| | | com.ruoyi.integration.api.factory.SwitchwayGateFallbackFactory |
| | | com.ruoyi.integration.api.factory.IotInterfaceFallbackFactory |
| | | com.ruoyi.integration.api.factory.SecurityDetectionFallbackFactory |
| | |
| | | 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; |
| | |
| | | log.error("购物订单退款回调通知失败:" + throwable.getMessage()); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void securityDetection(SecurityDetection securityDetection) { |
| | | log.error("修改安全检测数据失败:" + throwable.getMessage()); |
| | | } |
| | | |
| | | @Override |
| | | public void startChargeSuccessfully(PlatformStartChargingReplyMessage message) { |
| | | log.error("远程启动充电应答失败:" + throwable.getMessage()); |
| | | } |
| | | }; |
| | | } |
| | | } |
| | |
| | | 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.*; |
| | | |
| | |
| | | * @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 |
| | |
| | | @RequestParam("out_trade_no") String refund_id, |
| | | @RequestParam("out_trade_no") String tradeState, |
| | | @RequestParam("out_trade_no") String success_time); |
| | | |
| | | //todo 待监听完成后调用此方法 |
| | | /** |
| | | * 修改安全检测数据 |
| | | * @param securityDetection |
| | | */ |
| | | @PostMapping("/t-charging-order/securityDetection") |
| | | void securityDetection(@RequestBody SecurityDetection securityDetection); |
| | | |
| | | |
| | | /** |
| | | * 远程启动充电应答 |
| | | * @param message |
| | | */ |
| | | @PostMapping("/t-charging-order/startChargeSuccessfully") |
| | | void startChargeSuccessfully(PlatformStartChargingReplyMessage message); |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.api.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/10/8 17:16 |
| | | */ |
| | | @Data |
| | | public class PlatformStartChargingReplyMessage { |
| | | 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 报文)" |
| | | } |
New file |
| | |
| | | package com.ruoyi.order.api.vo; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class SecurityDetection { |
| | | 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=已锁) |
| | | |
| | | } |
| | |
| | | List<Map<String,Object>> equipmentMapOut1; |
| | | @ApiModelProperty("交流离网率") |
| | | List<Map<String,Object>> equipmentMapOut2; |
| | | @ApiModelProperty("需求电流满足率") |
| | | List<Map<String,Object>> needElec; |
| | | @ApiModelProperty("需求电流满足率直流") |
| | | List<Map<String,Object>> needElec1; |
| | | @ApiModelProperty("需求电流满足率交流") |
| | | List<Map<String,Object>> needElec2; |
| | | double average1; |
| | | double average2; |
| | | double average3; |
| | | double average4; |
| | | } |
| | |
| | | public class TCharingUserMapVO { |
| | | @ApiModelProperty("上分折线图") |
| | | private List<Map<String,Object>> map; |
| | | private List<Map<String,Object>> map1; |
| | | @ApiModelProperty("用户标签") |
| | | private List<Map<String,Object>> userMaps; |
| | | @ApiModelProperty("单位消费") |
| | |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | | # active: prod |
| | | application: |
| | | # 应用名称 |
| | | name: ruoyi-auth |
| | |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | | # active: prod |
| | | --- |
| | | spring: |
| | | config: |
| | |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | | # active: prod |
| | | --- |
| | | spring: |
| | | config: |
| | |
| | | |
| | | <dependencies> |
| | | <dependency> |
| | | <groupId>org.springframework</groupId> |
| | | <artifactId>spring-mock</artifactId> |
| | | <version>2.0.8</version> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-api-order</artifactId> |
| | | </dependency> |
| | |
| | | |
| | | @Autowired |
| | | private TAppUserCarService appUserCarService; |
| | | @Autowired |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private ChargingPileClient chargingPileClient; |
| | |
| | | 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()); |
| | |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TExchangeOrder; |
| | | import com.ruoyi.other.api.domain.*; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.dto.UnitListQueryDto; |
| | | import com.ruoyi.other.api.feignClient.IntegralRuleClient; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | |
| | | .eq(userListQueryDto.getStatus() != null, TAppUser::getStatus, userListQueryDto.getStatus()) |
| | | .eq(userListQueryDto.getVipTypeId() != null, TAppUser::getVipId, userListQueryDto.getVipTypeId()) |
| | | .in(!userIds.isEmpty(),TAppUser::getId,userIds) |
| | | .orderByDesc(BasePojo::getCreateTime) |
| | | .page(Page.of(userListQueryDto.getPageCurr(), userListQueryDto.getPageSize())); |
| | | if (page.getRecords().isEmpty()){ |
| | | return R.ok(page); |
| | |
| | | for (TAppUserIntegralChange record : page.getRecords()) { |
| | | record.setDateTime(record.getCreateTime()); |
| | | record.setUid(record.getId().toString()); |
| | | if (record.getChangeType()==2){ |
| | | if (record.getChangeType()==2||record.getChangeType()==3){ |
| | | R<TChargingOrder> tChargingOrderR = chargingOrderClient.orderDetail(Long.valueOf(record.getExtension())); |
| | | if (tChargingOrderR.getData()!=null) { |
| | | record.setOrderNum(tChargingOrderR.getData().getCode()); |
| | |
| | | @GetMapping(value = "/user/points/detail") |
| | | public R<TAppUserIntegralChange> pointsDetail(String id) { |
| | | TAppUserIntegralChange byId = integralChangeService.getById(id); |
| | | TExchangeOrder data = exchangeOrderClient.orderDetail(Long.valueOf(byId.getExtension())).getData(); |
| | | if (data!=null) { |
| | | byId.setGoodType(data.getOrderType()); |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | |
| | |
| | | }else { |
| | | appUserInfoDto.setIsVip(1); |
| | | appUserInfoDto.setVipExpireTime(byId.getVipEndTime()); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | //判断当天是否签到 |
| | | Long count = signService.lambdaQuery().eq(TAppUserSign::getAppUserId,userId).eq(TAppUserSign::getSignDay, LocalDate.now()).count(); |
| | |
| | | appUserInfoDto.setUserCars(list); |
| | | appUserInfoDto.setFirstAdd(byId.getFirstAdd()!=null?byId.getFirstAdd():0); |
| | | appUserInfoDto.setPoints(byId.getPoints()==null?0:byId.getPoints()); |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | return R.ok(appUserInfoDto); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "设置头像", tags = {"小程序-个人中心"}) |
| | | @GetMapping(value = "/user/set/avatar") |
| | | public R avatar(String url) { |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | TAppUser byId = appUserService.getById(userId); |
| | | byId.setAvatar(url); |
| | | appUserService.updateById(byId); |
| | | |
| | | return R.ok(); |
| | | |
| | | } |
| | | |
| | |
| | | String brand = CarBrandUtil.getBrand(); |
| | | JSONObject jsonObject = JSON.parseObject(brand); |
| | | JSONArray data = jsonObject.getJSONArray("data"); |
| | | JSONArray data1 = new JSONArray(); |
| | | if (name!=null) { |
| | | for (int i = 0; i < data.size(); i++) { |
| | | JSONObject brand1 = data.getJSONObject(i); |
| | | String o = (String) brand1.get("name"); |
| | | if (o.contains(name)) { |
| | | data1.add(brand1); |
| | | } |
| | | } |
| | | return R.ok(data1); |
| | | } |
| | | return R.ok(data); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.ruoyi.account.api.dto.SendCouponDto; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.api.vo.GetAppUserVipDetail; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import com.ruoyi.account.util.VipInfoDto; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.dto.VipCouponDto; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private VipClient vipClient; |
| | | @Resource |
| | | private OtherClient otherClient; |
| | | |
| | | @GetMapping("/getVipUseDetail") |
| | | @ApiOperation(value = "生效会员列表", tags = {"小程序-个人中心"}) |
| | | public R<List<TAppUserVipDetail>> getVipUseDetail(){ |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | List<TAppUserVipDetail> list = appUserVipDetailService.lambdaQuery().eq(TAppUserVipDetail::getAppUserId, userId).last(" and now() between start_time and end_time order by start_time asc").list(); |
| | | List<TAppUserVipDetail> list = appUserVipDetailService.lambdaQuery().eq(TAppUserVipDetail::getAppUserId, userId).last(" and now() <= end_time order by start_time asc").list(); |
| | | |
| | | for (TAppUserVipDetail tAppUserVipDetail : list) { |
| | | if(null != tAppUserVipDetail.getVipId()){ |
| | |
| | | tAppUserVipDetail.setVipName(data.getName()); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | return R.ok(list); |
| | | } |
| | | |
| | |
| | | import org.springframework.http.HttpEntity; |
| | | import org.springframework.http.HttpMethod; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.mock.web.MockMultipartFile; |
| | | //import org.springframework.mock.web.MockMultipartFile; |
| | | import org.springframework.util.LinkedMultiValueMap; |
| | | import org.springframework.util.MultiValueMap; |
| | | import org.springframework.web.bind.annotation.*; |
| | |
| | | /** |
| | | * 上传文件存储在本地的根路径 |
| | | */ |
| | | @Value("${file.path}") |
| | | @Value("${file.upload.location}") |
| | | private String localFilePath; |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "通过code获得openid,获取用户信息",tags = {"微信小程序登录"}) |
| | | @PostMapping("/openIdByJsCode") |
| | | public AjaxResult<Map<String, Object>> openIdByJsCode(@RequestBody AppletUserEncrypteData data) { |
| | |
| | | public AjaxResult<Map<String, Object>> openIdByJsCode(@RequestBody AppletUserDecodeData appletUserDecodeData) { |
| | | return AjaxResult.success(appUserService.wxLogin(appletUserDecodeData, null)); |
| | | } |
| | | public static MultipartFile convertInputStreamToMultipartFile(InputStream inputStream, String fileName, String contentType) throws IOException { |
| | | return new MockMultipartFile(fileName, fileName, contentType, inputStream); |
| | | } |
| | | |
| | | // public static MultipartFile convertInputStreamToMultipartFile(InputStream inputStream, String fileName, String contentType) throws IOException { |
| | | // return new MockMultipartFile(fileName, fileName, contentType, inputStream); |
| | | // } |
| | | |
| | | @ApiOperation(value = "获取微信小程序二维码",tags = {"获取微信小程序二维码"}) |
| | | @PostMapping("/getQRCode") |
| | | public AjaxResult getQRCode() { |
| | |
| | | System.err.println(Base64.encodeBase64String(result)); |
| | | inputStream = new ByteArrayInputStream(result); |
| | | String finalFileName = System.currentTimeMillis() + "" + new SecureRandom().nextInt(0x0400) + ".jpeg"; |
| | | MultipartFile multipartFile = convertInputStreamToMultipartFile(inputStream, finalFileName, "image/jpeg"); |
| | | String name = FileUploadUtils.upload(localFilePath, multipartFile); |
| | | System.err.println(name); |
| | | return AjaxResult.success(name); |
| | | // MultipartFile multipartFile = convertInputStreamToMultipartFile(inputStream, finalFileName, "image/jpeg"); |
| | | // String name = FileUploadUtils.upload(localFilePath, multipartFile); |
| | | // System.err.println(name); |
| | | return AjaxResult.success(null); |
| | | } catch (Exception e) { |
| | | System.err.println("调用小程序生成微信永久小程序码URL接口异常" + e); |
| | | } finally { |
| | |
| | | import com.ruoyi.account.service.TAppCouponService; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.order.api.query.TChargingCountQuery; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.poi.ss.formula.functions.T; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.dto.SendCouponDto; |
| | | import com.ruoyi.account.api.feignClient.AppCouponClient; |
| | | import com.ruoyi.account.api.model.TAppCoupon; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.mapper.TAppUserVipDetailMapper; |
| | |
| | | import com.ruoyi.account.service.TAppCouponService; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.feignClient.VipClient; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.service.TAppUserService; |
| | | import com.ruoyi.account.service.TAppUserVipDetailService; |
| | | import org.intellij.lang.annotations.RegExp; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | package com.ruoyi.account.util; |
| | | |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONArray; |
| | | import com.ruoyi.account.api.dto.SendCouponDto; |
| | | import com.ruoyi.account.api.model.TAppCoupon; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | |
| | | // 更新最后的连续天数 |
| | | maxContinuousDays = Math.max(maxContinuousDays, currentContinuousDays); |
| | | |
| | | return maxContinuousDays; |
| | | return currentContinuousDays; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.account.util; |
| | | |
| | | import com.ruoyi.other.api.dto.VipCouponDto; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | public class VipInfoDto { |
| | | private Integer id; |
| | | @ApiModelProperty("月卡价格") |
| | | private BigDecimal monthlyCard; |
| | | @ApiModelProperty(value = "月卡折扣") |
| | | private BigDecimal monthlyCardDiscount; |
| | | @ApiModelProperty("季卡价格") |
| | | private BigDecimal seasonCard; |
| | | @ApiModelProperty(value = "季卡折扣") |
| | | private BigDecimal seasonCardDiscount; |
| | | @ApiModelProperty("年卡价格") |
| | | private BigDecimal annualCard; |
| | | @ApiModelProperty(value = "年卡折扣") |
| | | private BigDecimal annualCardDiscount; |
| | | @ApiModelProperty("最高抵扣价格") |
| | | private BigDecimal maximumDeduction; |
| | | private BigDecimal timeAmount; |
| | | @ApiModelProperty("抵扣次数") |
| | | private Integer discountTimes; |
| | | |
| | | @ApiModelProperty(value = "双倍积分开关(0=否,1=是)") |
| | | private Integer doubleIntegration; |
| | | |
| | | @ApiModelProperty(value = "商城专享价开关(0=否,1=是)") |
| | | private Integer mallExclusivePrice; |
| | | @ApiModelProperty(value = "可赠送的优惠卷列表") |
| | | |
| | | private List<VipCouponDto> vipCouponDtos; |
| | | |
| | | @ApiModelProperty(value = "最高总折扣") |
| | | private BigDecimal totalDiscount; |
| | | |
| | | @ApiModelProperty(value = "会员名称") |
| | | private String name; |
| | | } |
| | |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | | # active: prod |
| | | --- |
| | | spring: |
| | | config: |
| | |
| | | @ApiOperation(value = "获取站点详细信息", tags = {"小程序-站点管理-站点详情"}) |
| | | @PostMapping("/getDetailById") |
| | | public AjaxResult<SiteDetailVO> getDetailById(@Validated @RequestBody SiteDetailQuery query){ |
| | | SiteDetailVO siteDetailVO = siteService.getDetailById(query.getSiteId()); |
| | | SiteDetailVO siteDetailVO = siteService.getDetailById(query); |
| | | // 查询合作商名称 |
| | | Partner partner = partnerService.getById(siteDetailVO.getPartnerId()); |
| | | if(Objects.nonNull(partner)){ |
| | |
| | | import com.ruoyi.chargingPile.api.model.Partner; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.common.core.utils.WebUtils; |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.order.api.model.ExportUidDto; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | |
| | | public AjaxResult<Page<TApplyChargingPile>> page(@RequestBody ApplyChargingQuery applyChargingQuery) { |
| | | Page<TApplyChargingPile> page = applyChargingPileService.lambdaQuery() |
| | | .like(applyChargingQuery.getLandlordPhone() != null && !applyChargingQuery.getLandlordPhone().equals(""), TApplyChargingPile::getLandlordPhone, applyChargingQuery.getLandlordPhone()) |
| | | .orderByDesc(BasePojo::getCreateTime ) |
| | | .page(Page.of(applyChargingQuery.getPageCurr(), applyChargingQuery.getPageSize())); |
| | | return AjaxResult.ok(page); |
| | | } |
| | |
| | | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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"); |
| | |
| | | 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(); |
| | | } |
| | |
| | | * @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) |
| | | .eq(TChargingGun::getChargingPileId, chargingPile.getId()) |
| | | .eq(TChargingGun::getCode, code.getCharging_gun_code()) |
| | | .eq(TChargingGun::getDelFlag, 0) |
| | | .last("LIMIT 1"))); |
| | | } |
| | | /** |
| | |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.net.URLEncoder; |
| | | import java.time.LocalDate; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | |
| | | |
| | | if (parkingRecordQueryDto.getDayType()==1) { |
| | | List<Map<String, Object>> maps = parkingRecordService.parkingData(parkingRecordQueryDto); |
| | | tParkLotRecordVO.setMaps(maps); |
| | | |
| | | |
| | | List<Map<String, Object>> charMap = new ArrayList<>(); |
| | | // 生成从 "00:00" 到 "23:00" 的时间数据 |
| | | for (int hour = 0; hour < 24; hour++) { |
| | | String time = String.format("%02d:00", hour); |
| | | Map<String, Object> mapWithTimeValue = findMapWithTimeValue(maps, time); |
| | | if (mapWithTimeValue!=null){ |
| | | charMap.add(mapWithTimeValue); |
| | | }else { |
| | | Map<String, Object> timeMap = new HashMap<>(); |
| | | timeMap.put("time", time); // 初始化值为 null |
| | | timeMap.put("orders", 0); |
| | | timeMap.put("timeoutAmount", 0); |
| | | |
| | | charMap.add(timeMap); |
| | | } |
| | | } |
| | | |
| | | tParkLotRecordVO.setMaps(charMap); |
| | | }else { |
| | | List<Map<String, Object>> maps = parkingRecordService.parkingDataByDate(parkingRecordQueryDto); |
| | | if(parkingRecordQueryDto.getDayType()==2||parkingRecordQueryDto.getDayType()==3){ |
| | | //按日 |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = parkingRecordQueryDto.getStartTime(); |
| | | LocalDate endDate = parkingRecordQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(maps, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("electrovalence", 0); |
| | | dateMap.put("orderCount", 0); |
| | | dateMap.put("servicecharge", 0); |
| | | dateMap.put("electricity", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusDays(1); |
| | | } |
| | | tParkLotRecordVO.setMaps(dateRangeStatistics); |
| | | |
| | | }else { |
| | | |
| | | } |
| | | |
| | | tParkLotRecordVO.setMaps(maps); |
| | | } |
| | | |
| | |
| | | return R.ok(tParkLotRecordVO); |
| | | |
| | | } |
| | | private static Map<String, Object> findMapWithTimeValue(List<Map<String, Object>> charMap1,String timeValue) { |
| | | for (Map<String, Object> map : charMap1) { |
| | | if (map.containsKey("time") && map.get("time").equals(timeValue)) { |
| | | return map; |
| | | } |
| | | } |
| | | return null; // 如果没有找到,返回 null |
| | | } |
| | | |
| | | |
| | | private Map<String, Object> findMapWithDateValue(List<Map<String, Object>> list, String date) { |
| | | for (Map<String, Object> map : list) { |
| | | if (date.equals(map.get("time"))) { |
| | | return map; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | @ResponseBody |
| | | @PostMapping(value = "/parking/work") |
| | | @ApiOperation(value = "停车订单统计", tags = {"管理后台-工作台"}) |
| | |
| | | import com.ruoyi.chargingPile.api.dto.GetSiteListDTO; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.chargingPile.api.query.GetSiteList; |
| | | import com.ruoyi.chargingPile.api.query.SiteDetailQuery; |
| | | import com.ruoyi.chargingPile.api.query.SiteQuery; |
| | | import com.ruoyi.chargingPile.api.vo.SiteDetailVO; |
| | | import com.ruoyi.chargingPile.api.vo.SiteVO; |
| | |
| | | * @param siteId |
| | | * @return |
| | | */ |
| | | SiteDetailVO getDetailById(@Param("siteId")Integer siteId); |
| | | SiteDetailVO getDetailById(@Param("query") SiteDetailQuery query); |
| | | |
| | | /** |
| | | * 获取站点列表不分页 管理后台-停车场绑定 |
| | |
| | | import com.ruoyi.chargingPile.api.dto.GetSiteListDTO; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.chargingPile.api.query.GetSiteList; |
| | | import com.ruoyi.chargingPile.api.query.SiteDetailQuery; |
| | | import com.ruoyi.chargingPile.api.query.SiteQuery; |
| | | import com.ruoyi.chargingPile.api.vo.SiteDetailVO; |
| | | import com.ruoyi.chargingPile.api.vo.SiteVO; |
| | |
| | | |
| | | /** |
| | | * 获取站点详情 |
| | | * @param siteId |
| | | * @param query |
| | | * @return |
| | | */ |
| | | SiteDetailVO getDetailById(Integer siteId); |
| | | SiteDetailVO getDetailById(SiteDetailQuery query); |
| | | |
| | | /** |
| | | * 获取站点列表不分页 管理后台-停车场绑定 |
| | |
| | | import com.ruoyi.chargingPile.api.model.TChargingPile; |
| | | import com.ruoyi.chargingPile.api.model.TParkingLot; |
| | | import com.ruoyi.chargingPile.api.query.GetSiteList; |
| | | import com.ruoyi.chargingPile.api.query.SiteDetailQuery; |
| | | import com.ruoyi.chargingPile.api.query.SiteQuery; |
| | | import com.ruoyi.chargingPile.api.vo.SiteDetailVO; |
| | | import com.ruoyi.chargingPile.api.vo.SiteVO; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public SiteDetailVO getDetailById(Integer siteId) { |
| | | return this.baseMapper.getDetailById(siteId); |
| | | public SiteDetailVO getDetailById(SiteDetailQuery query) { |
| | | return this.baseMapper.getDetailById(query); |
| | | } |
| | | |
| | | @Override |
| | |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.integration.api.feignClient.SendMessageClient; |
| | | import com.ruoyi.integration.api.model.QrCodeDelivery; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | |
| | | |
| | | @Resource |
| | | private SysUserRoleClient sysUserRoleClient; |
| | | |
| | | @Resource |
| | | private SendMessageClient sendMessageClient; |
| | | |
| | | |
| | | |
| | |
| | | return AjaxResult.error("接口编码已存在"); |
| | | } |
| | | this.save(dto); |
| | | TChargingPile chargingPile = chargingPileService.getById(dto.getChargingPileId()); |
| | | |
| | | //下发硬件充电二维码 |
| | | String code_prefix = "https://mxcd.zhinenganguan.com?No="; |
| | | QrCodeDelivery qrCodeDelivery = new QrCodeDelivery(); |
| | | qrCodeDelivery.setCharging_pile_code(chargingPile.getCode()); |
| | | qrCodeDelivery.setCode_format(1); |
| | | qrCodeDelivery.setPrefix_length(code_prefix.length()); |
| | | qrCodeDelivery.setCode_prefix(code_prefix); |
| | | qrCodeDelivery.setQr_code(code_prefix + chargingPile.getCode() + dto.getCode()); |
| | | sendMessageClient.qrCodeDelivery(qrCodeDelivery); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | return AjaxResult.error("接口编码已存在"); |
| | | } |
| | | this.updateById(dto); |
| | | TChargingPile chargingPile = chargingPileService.getById(dto.getChargingPileId()); |
| | | |
| | | //下发硬件充电二维码 |
| | | String code_prefix = "https://mxcd.zhinenganguan.com?No="; |
| | | QrCodeDelivery qrCodeDelivery = new QrCodeDelivery(); |
| | | qrCodeDelivery.setCharging_pile_code(chargingPile.getCode()); |
| | | qrCodeDelivery.setCode_format(1); |
| | | qrCodeDelivery.setPrefix_length(code_prefix.length()); |
| | | qrCodeDelivery.setCode_prefix(code_prefix); |
| | | qrCodeDelivery.setQr_code(code_prefix + chargingPile.getCode() + dto.getCode()); |
| | | sendMessageClient.qrCodeDelivery(qrCodeDelivery); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | Long count = this.baseMapper.selectCount(Wrappers.lambdaQuery(TChargingGun.class) |
| | | .eq(TChargingGun::getStatus, 1)); |
| | | HashMap<String, Integer> objectObjectHashMap1 = new HashMap<>(); |
| | | objectObjectHashMap1.put("1", count.intValue()); |
| | | objectObjectHashMap1.put("charge_mode",1); |
| | | objectObjectHashMap1.put("modeCount", count.intValue()); |
| | | statusStatistics.add(objectObjectHashMap1); |
| | | // statusStatistics.put(1, count.intValue()); |
| | | // 故障 |
| | | count = this.baseMapper.selectCount(Wrappers.lambdaQuery(TChargingGun.class) |
| | | .eq(TChargingGun::getStatus, 7)); |
| | | HashMap<String, Integer> objectObjectHashMap2 = new HashMap<>(); |
| | | objectObjectHashMap2.put("2", count.intValue()); |
| | | // objectObjectHashMap2.put("2", count.intValue()); |
| | | objectObjectHashMap2.put("charge_mode",2); |
| | | objectObjectHashMap2.put("modeCount", count.intValue()); |
| | | statusStatistics.add(objectObjectHashMap2); |
| | | |
| | | // statusStatistics.put(2, count.intValue()); |
| | |
| | | count = this.baseMapper.selectCount(Wrappers.lambdaQuery(TChargingGun.class) |
| | | .in(TChargingGun::getStatus, Arrays.asList(3,4,5,6))); |
| | | HashMap<String, Integer> objectObjectHashMap = new HashMap<>(); |
| | | objectObjectHashMap.put("3", count.intValue()); |
| | | objectObjectHashMap.put("charge_mode",3); |
| | | objectObjectHashMap.put("modeCount", count.intValue()); |
| | | statusStatistics.add(objectObjectHashMap); |
| | | |
| | | // statusStatistics.put(3, count.intValue()); |
| | |
| | | import com.ruoyi.chargingPile.service.ISiteService; |
| | | import com.ruoyi.chargingPile.service.TChargingGunService; |
| | | import com.ruoyi.chargingPile.service.TChargingPileService; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.StringUtils; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.integration.api.feignClient.IotInterfaceClient; |
| | | import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient; |
| | | import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData; |
| | | import com.ruoyi.integration.api.vo.AddDevice; |
| | | import com.ruoyi.integration.api.vo.AddDeviceResp; |
| | | import com.ruoyi.integration.api.vo.DeleteDeviceResp; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderClient; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | |
| | | @Resource |
| | | private SysUserRoleClient sysUserRoleClient; |
| | | |
| | | @Resource |
| | | private IotInterfaceClient iotInterfaceClient; |
| | | |
| | | |
| | | |
| | | |
| | |
| | | if(count > 0){ |
| | | return AjaxResult.error("设备编号已存在"); |
| | | } |
| | | //调用华为Iot创建设备 |
| | | AddDevice addDevice = new AddDevice(); |
| | | addDevice.setProductId("66da68d21837002b28b34ec0"); |
| | | addDevice.setNodeId(chargingPile.getCode()); |
| | | addDevice.setDeviceName(chargingPile.getName()); |
| | | addDevice.setDescription(chargingPile.getNumber().toString()); |
| | | AddDeviceResp deviceResp = iotInterfaceClient.addDevice(addDevice).getData(); |
| | | if(null != deviceResp){ |
| | | int httpStatusCode = deviceResp.getHttpStatusCode(); |
| | | if(httpStatusCode == 201){ |
| | | chargingPile.setIotdDeviceId(deviceResp.getDeviceId()); |
| | | this.save(chargingPile); |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public AjaxResult delChargingPile(Integer[] ids) { |
| | | //检查是否有关联数据 |
| | | //接口 |
| | | long count = chargingGunService.count(new LambdaQueryWrapper<TChargingGun>().in(TChargingGun::getChargingPileId, Arrays.asList(ids)) |
| | | .eq(TChargingGun::getDelFlag, 0)); |
| | | if(count > 0){ |
| | |
| | | } |
| | | for (Integer id : ids) { |
| | | TChargingPile chargingPile = this.getById(id); |
| | | //调用华为Iot删除设备 |
| | | if(StringUtils.isNotEmpty(chargingPile.getIotdDeviceId())){ |
| | | DeleteDeviceResp deviceResp = iotInterfaceClient.deleteDevice(chargingPile.getIotdDeviceId()).getData(); |
| | | if(null != deviceResp && deviceResp.getHttpStatusCode() == 201){ |
| | | this.removeById(chargingPile); |
| | | } |
| | | } |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | | # active: prod |
| | | --- |
| | | spring: |
| | | config: |
| | |
| | | ) |
| | | ) * 1000 |
| | | ) AS distance |
| | | FROM t_site WHERE id = #{siteId} AND del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} |
| | | FROM t_site WHERE id = #{query.siteId} AND del_flag = ${@com.ruoyi.common.core.enums.DelFlagEnum@NO.getCode()} |
| | | </select> |
| | | <select id="getSiteListParkLot" resultType="com.ruoyi.chargingPile.api.model.Site"> |
| | | select ts.id, ts.partner_id, ts.code, ts.`name`, ts.site_type, ts.business_category, ts.status |
| | |
| | | </select> |
| | | <select id="parkingData" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS TIME, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS time, |
| | | count( 1 ) AS orders, |
| | | SUM( timeout_amount ) AS timeoutAmount |
| | | FROM |
| | |
| | | AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId} |
| | | </if> |
| | | GROUP BY |
| | | TIME |
| | | time |
| | | ORDER BY |
| | | TIME |
| | | time |
| | | </select> |
| | | <select id="parkingDataByDate" resultType="java.util.Map"> |
| | | SELECT |
| | | DATE_FORMAT( create_time, '%Y-%m-%d' ) AS TIME, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d' ) AS time, |
| | | count( 1 ) AS orders, |
| | | SUM( timeout_amount ) AS timeoutAmount |
| | | FROM |
| | |
| | | AND parking_lot_id = #{parkingRecordQueryDto.parkingLotId} |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 2"> |
| | | AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 3"> |
| | | AND MONTH( co.create_time ) = MONTH(CURDATE()) |
| | | AND MONTH( create_time ) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 4"> |
| | | AND YEAR( co.create_time ) = YEAR(CURDATE() ) |
| | | AND YEAR( create_time ) = YEAR(CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 5"> |
| | | <if test="parkingRecordQueryDto.startTime != null"> |
| | | AND co.create_time >= #{parkingRecordQueryDto.startTime} |
| | | AND create_time >= #{parkingRecordQueryDto.startTime} |
| | | </if> |
| | | <if test="parkingRecordQueryDto.endTime != null"> |
| | | AND co.create_time <= #{parkingRecordQueryDto.endTime} |
| | | AND create_time <= #{parkingRecordQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | </where> |
| | | GROUP BY |
| | | TIME |
| | | time |
| | | ORDER BY |
| | | TIME |
| | | time |
| | | |
| | | |
| | | </select> |
| | |
| | | AND DATE( create_time ) = CURDATE() |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 2"> |
| | | AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 3"> |
| | | AND MONTH( co.create_time ) = MONTH(CURDATE()) |
| | | AND MONTH( create_time ) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 4"> |
| | | AND YEAR( co.create_time ) = YEAR(CURDATE() ) |
| | | AND YEAR( create_time ) = YEAR(CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 5"> |
| | | <if test="parkingRecordQueryDto.startTime != null"> |
| | | AND co.create_time >= #{parkingRecordQueryDto.startTime} |
| | | AND create_time >= #{parkingRecordQueryDto.startTime} |
| | | </if> |
| | | <if test="parkingRecordQueryDto.endTime != null"> |
| | | AND co.create_time <= #{parkingRecordQueryDto.endTime} |
| | | AND create_time <= #{parkingRecordQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | </where> |
| | |
| | | AND DATE( create_time ) = CURDATE() |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 2"> |
| | | AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 3"> |
| | | AND MONTH( co.create_time ) = MONTH(CURDATE()) |
| | | AND MONTH( create_time ) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 4"> |
| | | AND YEAR( co.create_time ) = YEAR(CURDATE() ) |
| | | AND YEAR( create_time ) = YEAR(CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 5"> |
| | | <if test="parkingRecordQueryDto.startTime != null"> |
| | | AND co.create_time >= #{parkingRecordQueryDto.startTime} |
| | | AND create_time >= #{parkingRecordQueryDto.startTime} |
| | | </if> |
| | | <if test="parkingRecordQueryDto.endTime != null"> |
| | | AND co.create_time <= #{parkingRecordQueryDto.endTime} |
| | | AND create_time <= #{parkingRecordQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | </where> |
| | |
| | | AND DATE( create_time ) = CURDATE() |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 2"> |
| | | AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | AND WEEKOFYEAR( create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 3"> |
| | | AND MONTH( co.create_time ) = MONTH(CURDATE()) |
| | | AND MONTH( create_time ) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 4"> |
| | | AND YEAR( co.create_time ) = YEAR(CURDATE() ) |
| | | AND YEAR( create_time ) = YEAR(CURDATE() ) |
| | | </if> |
| | | <if test="parkingRecordQueryDto.dayType == 5"> |
| | | <if test="parkingRecordQueryDto.startTime != null"> |
| | | AND co.create_time >= #{parkingRecordQueryDto.startTime} |
| | | AND create_time >= #{parkingRecordQueryDto.startTime} |
| | | </if> |
| | | <if test="parkingRecordQueryDto.endTime != null"> |
| | | AND co.create_time <= #{parkingRecordQueryDto.endTime} |
| | | AND create_time <= #{parkingRecordQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | </where> |
| | |
| | | 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; |
| | | |
| | |
| | | @SpringBootApplication |
| | | @EnableScheduling//开启定时任务 |
| | | @EnableTransactionManagement//开启事务 |
| | | @EnableBinding({ Source.class, Sink.class }) |
| | | public class RuoYiIntegrationApplication { |
| | | public static void main(String[] args) { |
| | | SpringApplication.run(RuoYiIntegrationApplication.class, args); |
New file |
| | |
| | | package com.ruoyi.integration.controller; |
| | | |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.integration.api.model.SecurityDetection; |
| | | import com.ruoyi.integration.mongodb.service.SecurityDetectionService; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/10/8 14:25 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/securityDetection") |
| | | public class SecurityDetectionController { |
| | | |
| | | @Resource |
| | | private SecurityDetectionService securityDetectionService; |
| | | |
| | | /** |
| | | * 获取安全检测数据 |
| | | * @param transactionSerialNumber |
| | | * @return |
| | | */ |
| | | @PostMapping("/getSecurityDetection") |
| | | public R<SecurityDetection> getSecurityDetection(@RequestParam("transactionSerialNumber") String transactionSerialNumber){ |
| | | SecurityDetection securityDetection = securityDetectionService.getSecurityDetection(transactionSerialNumber); |
| | | return R.ok(securityDetection); |
| | | } |
| | | } |
| | |
| | | * 安全监测 |
| | | */ |
| | | public final static String SECURITY_DETECTION ="security_detection"; |
| | | public static final String CHARGING_MESSAGE ="charging_message"; |
| | | } |
New file |
| | |
| | | package com.ruoyi.integration.iotda.controller; |
| | | |
| | | import com.huaweicloud.sdk.iotda.v5.model.AddDeviceResponse; |
| | | import com.huaweicloud.sdk.iotda.v5.model.DeleteDeviceResponse; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.integration.api.vo.AddDevice; |
| | | import com.ruoyi.integration.api.vo.AddDeviceResp; |
| | | import com.ruoyi.integration.api.vo.DeleteDeviceResp; |
| | | import com.ruoyi.integration.iotda.utils.api.IotInterfaceUtil; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | | * @Date 2024/10/8 10:29 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/iotInterface") |
| | | public class IotInterfaceController { |
| | | |
| | | @Resource |
| | | private IotInterfaceUtil iotInterfaceUtil; |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 添加设备 |
| | | * @return |
| | | */ |
| | | @PostMapping("/addDevice") |
| | | public R<AddDeviceResp> addDevice(@RequestBody AddDevice addDevice){ |
| | | return iotInterfaceUtil.addDeviceRequest(addDevice.getProductId(), addDevice.getNodeId(), addDevice.getDeviceName(), addDevice.getDescription()); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除设备 |
| | | * @param deviceId |
| | | * @return |
| | | */ |
| | | @PostMapping("/deleteDevice") |
| | | public R<DeleteDeviceResp> deleteDevice(@RequestParam("deviceId") String deviceId){ |
| | | return iotInterfaceUtil.deleteDeviceRequest(deviceId); |
| | | } |
| | | } |
| | |
| | | package com.ruoyi.integration.iotda.utils.api; |
| | | |
| | | import com.huaweicloud.sdk.core.auth.AbstractCredentials; |
| | | import com.huaweicloud.sdk.core.auth.ICredential; |
| | | import com.huaweicloud.sdk.core.exception.ConnectionException; |
| | | import com.huaweicloud.sdk.core.exception.RequestTimeoutException; |
| | | import com.huaweicloud.sdk.core.exception.ServiceResponseException; |
| | | import com.huaweicloud.sdk.iotda.v5.IoTDAClient; |
| | | import com.huaweicloud.sdk.iotda.v5.model.*; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.CodeGenerateUtils; |
| | | import com.ruoyi.common.core.utils.uuid.UUID; |
| | | import com.ruoyi.integration.api.vo.AddDeviceResp; |
| | | import com.ruoyi.integration.api.vo.DeleteDeviceResp; |
| | | import com.ruoyi.integration.iotda.builder.IotBuilder; |
| | | import com.ruoyi.integration.iotda.config.IotAccountConfig; |
| | | import com.ruoyi.integration.iotda.config.IotDAConfig; |
| | | import com.ruoyi.integration.iotda.constant.IotConstant; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | |
| | | * iot接口调用工具类 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @Component |
| | | public class IotInterfaceUtil { |
| | | |
| | | private static final String dataFormat = "json"; |
| | |
| | | * @param description 设备描述 |
| | | * @return AddDeviceResponse |
| | | */ |
| | | public AddDeviceResponse addDeviceRequest(String productId,String nodeId,String deviceName,String description) { |
| | | public R<AddDeviceResp> addDeviceRequest(String productId,String nodeId,String deviceName,String description) { |
| | | AddDeviceRequest request = new AddDeviceRequest(); |
| | | AddDevice body = new AddDevice(); |
| | | body.withDeviceId(nodeId); |
| | |
| | | try { |
| | | AddDeviceResponse response = iotBuilder.buildIot().addDevice(request); |
| | | log.info("创建设备:{}",response.toString()); |
| | | return response; |
| | | |
| | | AddDeviceResp addDeviceResp = new AddDeviceResp(); |
| | | BeanUtils.copyProperties(response, addDeviceResp); |
| | | return R.ok(addDeviceResp); |
| | | } catch (ConnectionException e) { |
| | | e.printStackTrace(); |
| | | } catch (RequestTimeoutException e) { |
| | |
| | | System.out.println(e.getErrorCode()); |
| | | System.out.println(e.getErrorMsg()); |
| | | } |
| | | return null; |
| | | return R.fail(); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param deviceId 设备ID 使用已有设备编号 |
| | | * @return DeleteDeviceResponse |
| | | */ |
| | | public DeleteDeviceResponse deleteDeviceRequest(String deviceId) { |
| | | public R<DeleteDeviceResp> deleteDeviceRequest(String deviceId) { |
| | | DeleteDeviceRequest request = new DeleteDeviceRequest(); |
| | | request.withDeviceId(deviceId); |
| | | try { |
| | | DeleteDeviceResponse response = iotBuilder.buildIot().deleteDevice(request); |
| | | log.info("删除设备:{}",response.toString()); |
| | | return response; |
| | | DeleteDeviceResp deleteDeviceResp = new DeleteDeviceResp(); |
| | | BeanUtils.copyProperties(response, deleteDeviceResp); |
| | | return R.ok(deleteDeviceResp); |
| | | } catch (ConnectionException e) { |
| | | e.printStackTrace(); |
| | | } catch (RequestTimeoutException e) { |
| | |
| | | System.out.println(e.getErrorCode()); |
| | | System.out.println(e.getErrorMsg()); |
| | | } |
| | | return null; |
| | | return R.fail(); |
| | | } |
| | | } |
| | |
| | | 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); |
| | | sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | // 响应硬件 |
| | | // 业务处理 登录认证应答 |
| | | OnlineReply onlineReply = new OnlineReply(); |
| | |
| | | break; |
| | | case SendTagConstant.PING: |
| | | PingMessage pingMessage = JSON.parseObject(content.toJSONString(),PingMessage.class); |
| | | sendResult = enhanceProduce.pingMessage(pingMessage); |
| | | chargingMessage.setPingMessage(pingMessage); |
| | | sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | // 响应硬件 |
| | | Pong pong = new Pong(); |
| | | pong.setCharging_pile_code(pingMessage.getCharging_pile_code()); |
| | |
| | | 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); |
| | | sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | // 响应硬件 |
| | | BillingModeVerifyReply billingModeVerifyReply = new BillingModeVerifyReply(); |
| | | if(billingModeVerifyMessage.getBilling_model_code().equals("0")){ |
| | |
| | | break; |
| | | case SendTagConstant.ACQUISITION_BILLING_MODE: |
| | | AcquisitionBillingModeMessage acquisitionBillingModeMessage = JSON.parseObject(content.toJSONString(),AcquisitionBillingModeMessage.class); |
| | | sendResult = enhanceProduce.acquisitionBillingModeMessage(acquisitionBillingModeMessage); |
| | | chargingMessage.setAcquisitionBillingModeMessage(acquisitionBillingModeMessage); |
| | | sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | // 响应硬件 计费模型请求应答 1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段 |
| | | List<TAccountingStrategyDetail> accountingStrategyDetails = accountingStrategyDetailClient.getDetailListByCode(acquisitionBillingModeMessage.getCharging_pile_code().substring(0,14)).getData(); |
| | | Map<Integer, TAccountingStrategyDetail> strategyPrice = StrategyUtil.getStrategyPrice(accountingStrategyDetails); |
| | |
| | | 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); |
| | | sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | // 响应硬件 |
| | | PlatformConfirmationCharging platformConfirmationCharging = new PlatformConfirmationCharging(); |
| | | platformConfirmationCharging.setCharging_pile_code(chargingPileStartsChargingMessage.getCharging_pile_code()); |
| | |
| | | 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); |
| | | sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | // 响应硬件 |
| | | ConfirmTransactionRecord confirmTransactionRecord = new ConfirmTransactionRecord(); |
| | | confirmTransactionRecord.setTransaction_serial_number(transactionRecordMessage.getTransaction_serial_number()); |
| | |
| | | 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); |
| | | sendResult = enhanceProduce.chargingMessage(chargingMessage); |
| | | // 响应硬件 对时设置应答 |
| | | TimingSettingReply timingSettingReply = new TimingSettingReply(); |
| | | timingSettingReply.setCharging_pile_code(timingSettingMessage.getCharging_pile_code()); |
| | |
| | | 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; |
| | | } |
| | |
| | | */ |
| | | public interface SecurityDetectionService extends BaseService<SecurityDetection> { |
| | | |
| | | |
| | | /** |
| | | * 根据业务流水号查询数据 |
| | | * @param transactionSerialNumber |
| | | * @return |
| | | */ |
| | | SecurityDetection getSecurityDetection(String transactionSerialNumber); |
| | | } |
| | |
| | | import com.ruoyi.integration.mongodb.service.SecurityDetectionService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | |
| | | public List<SecurityDetection> findAll() { |
| | | return mongoTemplate.findAll(SecurityDetection.class); |
| | | } |
| | | |
| | | /** |
| | | * 根据业务流水号查询数据 |
| | | * @param transactionSerialNumber |
| | | * @return |
| | | */ |
| | | @Override |
| | | public SecurityDetection getSecurityDetection(String transactionSerialNumber) { |
| | | List<SecurityDetection> securityDetectionList = mongoTemplate.find(new Query().addCriteria(Criteria.where("transaction_serial_number") |
| | | .is(transactionSerialNumber)), SecurityDetection.class); |
| | | return securityDetectionList.size() > 0 ? securityDetectionList.get(0) : null; |
| | | } |
| | | } |
| | |
| | | * 重试次数,用于判断重试次数,超过重试次数发送异常警告 |
| | | */ |
| | | protected Integer retryTimes = 0; |
| | | |
| | | /** |
| | | * 服务id |
| | | */ |
| | | protected String serviceId; |
| | | } |
| | |
| | | |
| | | @Autowired |
| | | private EndChargeService endChargeService; |
| | | @Autowired |
| | | private MessageUtil messageUtil; |
| | | @Autowired |
| | | private IotMessageProduce iotMessageProduce; |
| | | |
| | | @Resource |
| | | private ChargingOrderClient chargingOrderClient; |
| | | |
| | |
| | | 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 lombok.extern.slf4j.Slf4j; |
| | | import org.apache.rocketmq.spring.annotation.MessageModel; |
| | | import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
| | |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | @Slf4j |
| | | @Component |
| | |
| | | @Autowired |
| | | private PlatformStartChargingReplyService platformStartChargingReplyService; |
| | | |
| | | @Resource |
| | | private ChargingOrderClient chargingOrderClient; |
| | | |
| | | |
| | | |
| | | @Override |
| | | protected void handleMessage(PlatformStartChargingReplyMessage message) throws Exception { |
| | | // 此时这里才是最终的业务处理,代码只需要处理资源类关闭异常,其他的可以交给父类重试 |
| | |
| | | BeanUtils.copyProperties(message,platformStartChargingReply); |
| | | platformStartChargingReplyService.create(platformStartChargingReply); |
| | | // 业务处理 |
| | | com.ruoyi.order.api.vo.PlatformStartChargingReplyMessage message1 = new com.ruoyi.order.api.vo.PlatformStartChargingReplyMessage(); |
| | | BeanUtils.copyProperties(message, message1); |
| | | chargingOrderClient.startChargeSuccessfully(message1); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Autowired |
| | | private TimingSettingService timingSettingService; |
| | | @Autowired |
| | | private IotMessageProduce iotMessageProduce; |
| | | @Autowired |
| | | private MessageUtil messageUtil; |
| | | @Override |
| | | protected void handleMessage(TimingSettingMessage message) throws Exception { |
| | | // 此时这里才是最终的业务处理,代码只需要处理资源类关闭异常,其他的可以交给父类重试 |
| | |
| | | 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; |
| | |
| | | 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(); |
New file |
| | |
| | | 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; |
| | | |
| | | } |
| | |
| | | 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; |
New file |
| | |
| | | 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.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 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; |
| | | @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); |
| | | 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().divide(data.getPaid_amount())); |
| | | uploadRealTimeMonitoringData.setPeriod_charging_degree(uploadRealTimeMonitoringDataMessage.getCharging_degree().divide(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); |
| | | // 业务处理 |
| | | com.ruoyi.order.api.vo.PlatformStartChargingReplyMessage message1 = new com.ruoyi.order.api.vo.PlatformStartChargingReplyMessage(); |
| | | 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); |
| | | 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); |
| | | com.ruoyi.order.api.vo.SecurityDetection securityDetection1 = new com.ruoyi.order.api.vo.SecurityDetection(); |
| | | 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); |
| | | } |
| | | } |
| | |
| | | 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); |
| | | } |
| | | |
| | | } |
| | |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | | # active: prod |
| | | |
| | | --- |
| | | spring: |
| | |
| | | |
| | | |
| | | /** |
| | | * 修改安全检测数据 |
| | | * @param securityDetection |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping(value = "/securityDetection") |
| | | public void securityDetection(@RequestBody SecurityDetection securityDetection){ |
| | | chargingOrderService.securityDetection(securityDetection); |
| | | } |
| | | |
| | | /** |
| | | * 远程启动充电应答 |
| | | * @param message |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping(value = "/startChargeSuccessfully") |
| | | public void startChargeSuccessfully(@RequestBody PlatformStartChargingReplyMessage message){ |
| | | System.err.println("远程启动应答:" + message); |
| | | chargingOrderService.startChargeSuccessfully(message); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 支付宝支付成功后的回调 |
| | | */ |
| | | @ResponseBody |
| | |
| | | */ |
| | | @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); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @GetMapping(value = "/work/shop") |
| | | @PostMapping(value = "/work/shop") |
| | | @ApiOperation(value = "购物收入", tags = {"后台-工作台"}) |
| | | public R workShop(@RequestBody ChargingStatisticsQueryDto statisticsQueryDto) { |
| | | //count近6个月的数据 |
| | |
| | | //上方折现 |
| | | if (statisticsQueryDto.getDayType()==1){ |
| | | List<Map<String,Object>> map = chargingOrderService.usersDay(); |
| | | tCharingUserMapVO.setMap(map); |
| | | |
| | | List<Map<String, Object>> charMap = new ArrayList<>(); |
| | | // 生成从 "00:00" 到 "23:00" 的时间数据 |
| | | for (int hour = 0; hour < 24; hour++) { |
| | | String time = String.format("%02d:00", hour); |
| | | Map<String, Object> mapWithTimeValue = findMapWithTimeValue(map, time); |
| | | if (mapWithTimeValue!=null){ |
| | | charMap.add(mapWithTimeValue); |
| | | }else { |
| | | Map<String, Object> timeMap = new HashMap<>(); |
| | | timeMap.put("time", time); // 初始化值为 null |
| | | timeMap.put("counts", 0); |
| | | |
| | | charMap.add(timeMap); |
| | | } |
| | | } |
| | | |
| | | List<Map<String,Object>> map1 = chargingOrderService.usersDay1(); |
| | | |
| | | List<Map<String, Object>> charMap1 = new ArrayList<>(); |
| | | // 生成从 "00:00" 到 "23:00" 的时间数据 |
| | | for (int hour = 0; hour < 24; hour++) { |
| | | String time = String.format("%02d:00", hour); |
| | | Map<String, Object> mapWithTimeValue = findMapWithTimeValue(map1, time); |
| | | if (mapWithTimeValue!=null){ |
| | | charMap1.add(mapWithTimeValue); |
| | | }else { |
| | | Map<String, Object> timeMap = new HashMap<>(); |
| | | timeMap.put("time", time); // 初始化值为 null |
| | | timeMap.put("counts", 0); |
| | | |
| | | charMap1.add(timeMap); |
| | | } |
| | | } |
| | | |
| | | |
| | | tCharingUserMapVO.setMap(charMap); |
| | | tCharingUserMapVO.setMap1(charMap1); |
| | | }else { |
| | | List<Map<String,Object>> map = chargingOrderService.usersByQuery(statisticsQueryDto); |
| | | |
| | | |
| | | //按日 |
| | | // 解析 startTime 和 endTime 为 LocalDate |
| | | LocalDate startDate = statisticsQueryDto.getStartTime(); |
| | | LocalDate endDate = statisticsQueryDto.getEndTime(); |
| | | |
| | | List<Map<String, Object>> dateRangeStatistics = new ArrayList<>(); |
| | | |
| | | // 遍历日期范围 |
| | | while (!startDate.isAfter(endDate)) { |
| | | String formattedDate = startDate.format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); |
| | | Map<String, Object> dailyStats = findMapWithDateValue(map, formattedDate); |
| | | |
| | | if (dailyStats != null) { |
| | | dateRangeStatistics.add(dailyStats); |
| | | } else { |
| | | Map<String, Object> dateMap = new HashMap<>(); |
| | | dateMap.put("time", formattedDate); |
| | | dateMap.put("counts", 0); |
| | | dateRangeStatistics.add(dateMap); |
| | | } |
| | | |
| | | // 移动到下一天 |
| | | startDate = startDate.plusDays(1); |
| | | } |
| | | |
| | | tCharingUserMapVO.setMap(map); |
| | | } |
| | | |
| | |
| | | List<Map<String,Object>> equipmentMap1 = chargingOrderService.equipmentUserType1(siteIds,statisticsQueryDto); |
| | | //交流可用率 |
| | | List<Map<String,Object>> equipmentMap2= chargingOrderService.equipmentUserType2(siteIds,statisticsQueryDto); |
| | | |
| | | //取出直流可用率和交流可用率的percent的平均值保留两位小数 |
| | | |
| | | double average1 = calculateAveragePercent(equipmentMap1, equipmentMap2); |
| | | System.out.printf("The average percent is: %.2f\n", average1); |
| | | |
| | | |
| | | //直流故障率 |
| | | List<Map<String,Object>> equipmentMapbroke1 = chargingOrderService.equipmentMapbroke1(siteIds,statisticsQueryDto); |
| | | //交流故障率 |
| | | List<Map<String,Object>> equipmentMapbroke2 = chargingOrderService.equipmentMapbroke2(siteIds,statisticsQueryDto); |
| | | |
| | | |
| | | double average2 = calculateAveragePercent(equipmentMapbroke1, equipmentMapbroke2); |
| | | System.out.printf("The average percent is: %.2f\n", average2); |
| | | //直流离网率 |
| | | List<Map<String,Object>> equipmentMapOut1 = chargingOrderService.equipmentMapOut1(siteIds,statisticsQueryDto); |
| | | //交流离网率 |
| | | List<Map<String,Object>> equipmentMapOut2 = chargingOrderService.equipmentMapOut2(siteIds,statisticsQueryDto); |
| | | |
| | | double average3 = calculateAveragePercent(equipmentMapOut1, equipmentMapOut2); |
| | | System.out.printf("The average percent is: %.2f\n", average3); |
| | | |
| | | //需求电流满足率 |
| | | List<Map<String,Object>> needElec = chargingOrderService.needElec(siteIds,statisticsQueryDto); |
| | | List<Map<String,Object>> needElec1 = chargingOrderService.needElec(siteIds,statisticsQueryDto); |
| | | List<Map<String,Object>> needElec2 = chargingOrderService.needElec1(siteIds,statisticsQueryDto); |
| | | |
| | | double average4 = calculateAveragePercent(needElec1, needElec2); |
| | | System.out.printf("The average percent is: %.2f\n", average4); |
| | | |
| | | |
| | | |
| | | TCharingUserEquimentVO tCharingUserEquimentVO = new TCharingUserEquimentVO(); |
| | | tCharingUserEquimentVO.setEquipmentMap1(equipmentMap1); |
| | |
| | | tCharingUserEquimentVO.setEquipmentMapbroke2(equipmentMapbroke2); |
| | | tCharingUserEquimentVO.setEquipmentMapOut1(equipmentMapOut1); |
| | | tCharingUserEquimentVO.setEquipmentMapOut2(equipmentMapOut2); |
| | | tCharingUserEquimentVO.setNeedElec(needElec); |
| | | tCharingUserEquimentVO.setNeedElec1(needElec1); |
| | | tCharingUserEquimentVO.setNeedElec2(needElec2); |
| | | tCharingUserEquimentVO.setAverage1(average1); |
| | | tCharingUserEquimentVO.setAverage2(average2); |
| | | tCharingUserEquimentVO.setAverage3(average3); |
| | | tCharingUserEquimentVO.setAverage4(average4); |
| | | return R.ok(tCharingUserEquimentVO); |
| | | } |
| | | |
| | | |
| | | private static double calculateAveragePercent(List<Map<String, Object>> mapList1, List<Map<String, Object>> mapList2) { |
| | | int totalElements = mapList1.size() + mapList2.size(); |
| | | double sum = 0.0; |
| | | |
| | | // 累加两个列表中所有元素的 "percent" 值 |
| | | for (Map<String, Object> map : mapList1) { |
| | | if (map.containsKey("percent")) { |
| | | sum += Double.parseDouble((String) map.get("percent")); |
| | | } |
| | | } |
| | | for (Map<String, Object> map : mapList2) { |
| | | if (map.containsKey("percent")) { |
| | | sum += Double.parseDouble((String) map.get("percent")); |
| | | } |
| | | } |
| | | |
| | | // 防止除以零错误 |
| | | if (totalElements == 0) { |
| | | return 0.0; |
| | | } |
| | | |
| | | // 计算平均值 |
| | | return sum / totalElements; |
| | | } |
| | | |
| | | @ResponseBody |
| | | @PostMapping(value = "/work/charge") |
| | | @ApiOperation(value = "上方充电数据统计", tags = {"管理后台-工作台"}) |
| | |
| | | tExchangeOrder.setPurchaseQuantity(1); |
| | | tExchangeOrder.setAppUserAddressId(exchangeDto.getAddressId()==null?null:Long.valueOf(exchangeDto.getAddressId())); |
| | | tExchangeOrder.setPoints(exchangeDto.getPoint()); |
| | | tExchangeOrder.setRemark(""); |
| | | tExchangeOrder.setRemark(exchangeDto.getRemark()); |
| | | if (exchangeDto.getGoodType()==1){ |
| | | tExchangeOrder.setStatus(1); |
| | | }else { |
| | |
| | | @ApiOperation(value = "获取兑换订单详情", tags = {"小程序-兑换记录"}) |
| | | public AjaxResult<ExchangeOrderGoodsInfo> getGoodsExchangeOrder(@PathVariable String id){ |
| | | ExchangeOrderGoodsInfo goodsExchangeOrder = exchangeOrderService.getGoodsExchangeOrder(id); |
| | | |
| | | return AjaxResult.success(goodsExchangeOrder); |
| | | } |
| | | |
| | |
| | | shoppingOrder.setOrderType(exchangeDto.getGoodType()); |
| | | if (exchangeDto.getGoodType() == 1) { |
| | | shoppingOrder.setGoodsId(exchangeDto.getGoodId()); |
| | | shoppingOrder.setStatus(1); |
| | | |
| | | } else { |
| | | shoppingOrder.setCouponId(exchangeDto.getGoodId()); |
| | | shoppingOrder.setStatus(3); |
| | | |
| | | } |
| | | shoppingOrder.setPurchaseQuantity(exchangeDto.getNum()); |
| | | shoppingOrder.setAppUserAddressId(exchangeDto.getAddressId()); |
| | |
| | | shoppingOrder.setPaymentStatus(1); |
| | | shoppingOrder.setPaymentType(exchangeDto.getPayMethod()); |
| | | shoppingOrder.setRemark(exchangeDto.getRemark()); |
| | | shoppingOrder.setStatus(1); |
| | | shoppingOrder.setPhone(exchangeDto.getPhone()); |
| | | shoppingOrder.setCreateTime(LocalDateTime.now()); |
| | | shoppingOrder.setDelFlag(false); |
| | |
| | | package com.ruoyi.order.dto; |
| | | |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | |
| | |
| | | @ApiModelProperty("支付金额") |
| | | private BigDecimal payAmount; |
| | | @ApiModelProperty("支付时间") |
| | | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
| | | private LocalDateTime payTime; |
| | | @ApiModelProperty("退款金额") |
| | | private BigDecimal refundAmount; |
| | |
| | | |
| | | Map<String, Object> queryPowerLevel(@Param("siteIds") List<Integer> siteIds,@Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto); |
| | | |
| | | List<Map<String, Object>> queryOrderCountAndMoneyBySiteIdDate(List<Integer> siteIds); |
| | | List<Map<String, Object>> queryOrderCountAndMoneyBySiteIdDate(@Param("siteIds")List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> usersDay(); |
| | | List<Map<String, Object>> usersDay1(); |
| | | |
| | | List<Map<String, Object>> usersByQuery(ChargingStatisticsQueryDto statisticsQueryDto); |
| | | List<Map<String, Object>> usersByQuery(@Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto); |
| | | |
| | | List<Map<String, Object>> getUserTagCount(); |
| | | |
| | | List<Map<String, Object>> getVipCount(); |
| | | |
| | | List<Map<String, Object>> unitConsumption(ChargingStatisticsQueryDto statisticsQueryDto); |
| | | List<Map<String, Object>> unitConsumption(@Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto); |
| | | |
| | | List<Map<String, Object>> carUserMethod(); |
| | | |
| | |
| | | |
| | | Map<String, Object> countLocalCar(); |
| | | |
| | | Long getAver(List<Integer> siteIds); |
| | | Long getAver(@Param("siteIds") List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> getLevelEvaluate(List<Integer> siteIds); |
| | | List<Map<String, Object>> getLevelEvaluate(@Param("siteIds")List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> countBySource(List<Integer> siteIds); |
| | | List<Map<String, Object>> countBySource(@Param("siteIds")List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> equipmentUserType1(@Param("siteIds") List<Integer> siteIds, @Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto); |
| | | |
| | |
| | | List<Map<String, Object>> getchargingCapacity(@Param("siteIds")List<Integer> siteIds,@Param("statisticsQueryDto") ChargingDetailQueryDto statisticsQueryDto); |
| | | |
| | | List<Map<String, Object>> countAllUserData(); |
| | | |
| | | List<Map<String, Object>> needElec1(@Param("siteIds")List<Integer> siteIds,@Param("statisticsQueryDto") ChargingStatisticsQueryDto statisticsQueryDto); |
| | | } |
| | |
| | | */ |
| | | List<TOrderEvaluateVO> getOrderEvaluateBySiteId(@Param("siteId")Integer siteId); |
| | | |
| | | List<Map<String, Object>> goodTop(List<Integer> siteIds); |
| | | List<Map<String, Object>> goodTop(@Param("siteIds")List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> badTop(List<Integer> siteIds); |
| | | List<Map<String, Object>> badTop(@Param("siteIds")List<Integer> siteIds); |
| | | } |
| | |
| | | |
| | | |
| | | /** |
| | | * 安全检测数据 |
| | | * @param securityDetection |
| | | */ |
| | | void securityDetection(SecurityDetection securityDetection); |
| | | |
| | | |
| | | /** |
| | | * 启动充电应发 |
| | | * @param message |
| | | */ |
| | | void startChargeSuccessfully(PlatformStartChargingReplyMessage message); |
| | | |
| | | |
| | | /** |
| | | * 充电启动失败后的退款回调处理 |
| | | * @param out_refund_no |
| | | * @param refund_id |
| | |
| | | List<Map<String, Object>> queryOrderCountAndMoneyBySiteIdDate(List<Integer> siteIds); |
| | | |
| | | List<Map<String, Object>> usersDay(); |
| | | List<Map<String, Object>> usersDay1(); |
| | | |
| | | List<Map<String, Object>> usersByQuery(ChargingStatisticsQueryDto statisticsQueryDto); |
| | | |
| | |
| | | List<Map<String, Object>> getchargingCapacity(List<Integer> siteIds, ChargingDetailQueryDto statisticsQueryDto); |
| | | |
| | | List<Map<String, Object>> countAllUserData(); |
| | | |
| | | List<Map<String, Object>> needElec1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto); |
| | | } |
| | |
| | | package com.ruoyi.order.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | 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; |
| | |
| | | import com.ruoyi.order.api.dto.SettlementConfirmAdd; |
| | | import com.ruoyi.order.api.feignClient.AccountingStrategyDetailOrderClient; |
| | | import com.ruoyi.order.api.feignClient.AccountingStrategyOrderClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; |
| | | import com.ruoyi.order.api.model.*; |
| | | import com.ruoyi.order.api.query.ChargingOrderQuery; |
| | | 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.SecurityDetection; |
| | | import com.ruoyi.order.dto.*; |
| | | import com.ruoyi.order.mapper.TChargingOrderMapper; |
| | | import com.ruoyi.order.mapper.TSettlementConfirmMapper; |
| | |
| | | import com.ruoyi.payment.api.model.WxPaymentRefundModel; |
| | | import com.ruoyi.payment.api.vo.*; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | @Resource |
| | | private AppUserTagClient appUserTagClient; |
| | | |
| | | @Resource |
| | | private SecurityDetectionClient securityDetectionClient; |
| | | |
| | | //计数器 |
| | | private Map<String, Integer> counter_map = new HashMap<>(); |
| | | |
| | | //计数器 |
| | | private Map<String, Integer> boot_failed_map = new HashMap<>(); |
| | | |
| | | |
| | | |
| | |
| | | |
| | | //直营站点才可以享受会员折扣 |
| | | 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()){ |
| | | //普通会员折扣使用积分策略上的折扣,且有最高优惠金额 |
| | |
| | | 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(); |
| | |
| | | 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){ |
| | |
| | | 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); |
| | | //会员有充电优惠次数,直接将优惠金额加入到充电费用中增加充电时长 |
| | |
| | | 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(()->{ |
| | | if(timingDetection(id)){ |
| | | scheduler.shutdown(); |
| | | } |
| | | }, 5, 1, TimeUnit.SECONDS); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 定时检测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(); |
| | | System.err.println("-------------------开始检查调起充电结果-------------------"); |
| | | System.err.println(data.toString()); |
| | | log.error(code + ":-------------------开始检查调起充电结果-------------------"); |
| | | log.error(data.toString()); |
| | | if(data.size() != 0){ |
| | | PlatformStartChargingReply platformStartChargingReply = data.get(1); |
| | | Integer startup_result = platformStartChargingReply.getStartup_result(); |
| | |
| | | //启动失败 |
| | | preChargeCheck1.setStartupSuccess(3); |
| | | preChargeCheck1.setFailureCause(failure_cause); |
| | | redisService.setCacheObject(key, preChargeCheck1); |
| | | return; |
| | | redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS); |
| | | return false; |
| | | } |
| | | |
| | | //清除计时器中的无效数据 |
| | |
| | | order.setStartTime(LocalDateTime.now()); |
| | | } |
| | | this.updateById(order); |
| | | redisService.setCacheObject(key, preChargeCheck1); |
| | | //提前结束定时任务 |
| | | scheduler.shutdown(); |
| | | redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS); |
| | | return true; |
| | | }else{ |
| | | log.error("未上传开启充电结果........"); |
| | | } |
| | | }, 5, 1, TimeUnit.SECONDS); |
| | | return AjaxResult.success(); |
| | | 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(SecurityDetection 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(PlatformStartChargingReplyMessage 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(); |
| | |
| | | |
| | | 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){ |
| | |
| | | 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){ |
| | |
| | | |
| | | 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){ |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> usersDay1() { |
| | | return this.baseMapper.usersDay1(); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> usersByQuery(ChargingStatisticsQueryDto statisticsQueryDto) { |
| | | return this.baseMapper.usersByQuery(statisticsQueryDto); |
| | | } |
| | |
| | | |
| | | @Resource |
| | | private TShoppingOrderService shoppingOrderService; |
| | | @Resource |
| | | private TShoppingOrderRefundService shoppingOrderRefundService; |
| | | @Override |
| | | public R payRefund(PayOrderRefundDto payOrderQueryDto) { |
| | | if (payOrderQueryDto.getType()==1){ |
| | |
| | | model.setAmount(amount); |
| | | R<String> orderR = wxPaymentClient.refundOrderR(model); |
| | | if(200 == orderR.getCode()){ |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | this.baseMapper.updateById(tChargingOrder); |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | } |
| | | } |
| | |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE"); |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | this.baseMapper.updateById(tChargingOrder); |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | |
| | | } |
| | |
| | | } |
| | | if (payOrderQueryDto.getType()==2){ |
| | | TShoppingOrder tChargingOrder = shoppingOrderService.getById(payOrderQueryDto.getOrderId()); |
| | | TChargingOrderRefund chargingOrderRefund = new TChargingOrderRefund(); |
| | | chargingOrderRefund.setChargingOrderId(tChargingOrder.getId()); |
| | | TShoppingOrderRefund chargingOrderRefund = new TShoppingOrderRefund(); |
| | | chargingOrderRefund.setShoppingOrderId(tChargingOrder.getId()); |
| | | chargingOrderRefund.setRefundAmount(payOrderQueryDto.getRefundAmount()); |
| | | chargingOrderRefund.setRefundStatus(1); |
| | | chargingOrderRefund.setPayType(tChargingOrder.getPaymentType()); |
| | |
| | | model.setAmount(amount); |
| | | R<String> orderR = wxPaymentClient.refundOrderR(model); |
| | | if(200 == orderR.getCode()){ |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | shoppingOrderService.updateById(tChargingOrder); |
| | | shoppingOrderRefundService.save(chargingOrderRefund); |
| | | } |
| | | } |
| | | |
| | |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE"); |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | shoppingOrderService.updateById(tChargingOrder); |
| | | |
| | | shoppingOrderRefundService.save(chargingOrderRefund); |
| | | |
| | | } |
| | | } |
| | |
| | | return this.baseMapper.countAllUserData(); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> needElec1(List<Integer> siteIds, ChargingStatisticsQueryDto statisticsQueryDto) { |
| | | return this.baseMapper.needElec1(siteIds,statisticsQueryDto); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); |
| | | // String format1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); |
| | |
| | | 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){ |
| | |
| | | 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()); |
| | | } |
| | |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | | # active: prod |
| | | --- |
| | | spring: |
| | | config: |
| | |
| | | AND o.code LIKE CONCAT('%',#{data.code},'%') |
| | | </if> |
| | | <if test="data.phone != null and data.phone != ''"> |
| | | AND o.phone LIKE CONCAT('%',#{data.phone},'%') |
| | | AND i.phone LIKE CONCAT('%',#{data.phone},'%') |
| | | </if> |
| | | <if test="data.type != null"> |
| | | AND o.type = #{data.type} |
| | |
| | | <if test="data.isRefund == 1"> |
| | | AND o.refund_status is not null |
| | | </if> |
| | | <if test="data.isRefund == 1"> |
| | | <if test="data.isRefund == 2"> |
| | | AND o.refund_status is null |
| | | </if> |
| | | |
| | |
| | | |
| | | </select> |
| | | <select id="usersDay" resultType="java.util.Map"> |
| | | |
| | | SELECT |
| | | |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS time, |
| | | count(1) AS counts |
| | | FROM |
| | | charging_pile_account.t_app_user |
| | | WHERE |
| | | del_flag = 0 |
| | | AND DATE ( create_time ) = CURDATE() |
| | | GROUP BY |
| | | time |
| | | </select> |
| | | |
| | | |
| | | <select id="usersDay1" resultType="java.util.Map"> |
| | | SELECT |
| | | 'today' AS data_type, |
| | | '1' as type, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS TIME, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS time, |
| | | count(DISTINCT app_user_id) AS counts |
| | | FROM |
| | | t_charging_order |
| | |
| | | AND ISNULL( refund_status ) |
| | | AND DATE ( create_time ) = CURDATE() |
| | | GROUP BY |
| | | TIME |
| | | UNION all |
| | | SELECT |
| | | 'today' AS data_type, |
| | | '2' as type, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d %H' ) AS TIME, |
| | | count(1) AS counts |
| | | FROM |
| | | charging_pile_account.t_app_user |
| | | WHERE |
| | | del_flag = 0 |
| | | AND DATE ( create_time ) = CURDATE() |
| | | GROUP BY |
| | | TIME |
| | | time |
| | | </select> |
| | | <select id="usersByQuery" resultType="java.util.Map"> |
| | | |
| | | SELECT |
| | | 'today' AS data_type, |
| | | '1' as type, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d' ) AS TIME, |
| | | count(DISTINCT app_user_id) AS counts |
| | | FROM |
| | | t_charging_order |
| | | WHERE |
| | | del_flag = 0 |
| | | AND recharge_payment_status = 2 |
| | | AND ISNULL( refund_status ) |
| | | <if test="statisticsQueryDto.dayType =1 "> |
| | | AND DATE(create_time) = CURDATE() |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType =2 "> |
| | | AND WEEKOFYEAR(create_time) = WEEKOFYEAR(CURDATE()) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType =3 "> |
| | | AND MONTH(create_time) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType =4"> |
| | | AND YEAR(create_time) = YEAR(CURDATE()) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType =5"> |
| | | <if test="statisticsQueryDto.startTime != null"> |
| | | AND create_time >= #{statisticsQueryDto.startTime} |
| | | </if> |
| | | <if test="statisticsQueryDto.endTime != null"> |
| | | AND create_time <= #{statisticsQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | GROUP BY |
| | | TIME |
| | | UNION all |
| | | SELECT |
| | | 'today' AS data_type, |
| | | '2' as type, |
| | | DATE_FORMAT( create_time, '%Y-%m-%d' ) AS TIME, |
| | | |
| | | DATE_FORMAT( create_time, '%Y-%m-%d' ) AS time, |
| | | count(1) AS counts |
| | | FROM |
| | | charging_pile_account.t_app_user |
| | |
| | | </if> |
| | | </if> |
| | | GROUP BY |
| | | TIME |
| | | time |
| | | |
| | | |
| | | </select> |
| | | <select id="getUserTagCount" resultType="java.util.Map"> |
| | | SELECT user_tag_id,COUNT(1) as count from ( |
| | | SELECT |
| | | tt.`name`, |
| | | COUNT( 1 ) AS count |
| | | FROM |
| | | ( |
| | | SELECT |
| | | a.app_user_id, |
| | | a.user_tag_id, |
| | | a.create_time |
| | | FROM |
| | | charging_pile_account.t_app_user_tag a |
| | | JOIN ( |
| | | SELECT |
| | | app_user_id, |
| | | MAX(create_time) AS max_create_time |
| | | FROM |
| | | charging_pile_account.t_app_user_tag |
| | | GROUP BY |
| | | app_user_id |
| | | ) b ON a.app_user_id = b.app_user_id AND a.create_time = b.max_create_time |
| | | JOIN ( SELECT app_user_id, MAX( create_time ) AS max_create_time FROM charging_pile_account.t_app_user_tag GROUP BY app_user_id ) b ON a.app_user_id = b.app_user_id |
| | | AND a.create_time = b.max_create_time |
| | | ) o |
| | | GROUP BY o.user_tag_id |
| | | LEFT JOIN `charging_pile_other`.`t_user_tag` tt on o.user_tag_id = tt.id |
| | | GROUP BY |
| | | tt.name |
| | | </select> |
| | | <select id="getVipCount" resultType="java.util.Map"> |
| | | SELECT vip_id,count(1) as Counts |
| | | FROM charging_pile_account.t_app_user |
| | | WHERE del_flag = 0 |
| | | GROUP BY vip_id |
| | | SELECT |
| | | tv.`name`, |
| | | count(1) AS Counts |
| | | FROM |
| | | charging_pile_account.t_app_user ta |
| | | LEFT JOIN `charging_pile_other`.`t_vip` tv on ta.vip_id = tv.id |
| | | WHERE |
| | | ta.del_flag = 0 |
| | | GROUP BY |
| | | tv.`name` |
| | | </select> |
| | | <select id="unitConsumption" resultType="java.util.Map"> |
| | | SELECT |
| | | tc.`name`, |
| | | au.company_id as companyId, |
| | | SUM( co.charging_capacity ) as chargingCapacity |
| | | FROM |
| | | charging_pile_order.t_charging_order co |
| | | LEFT JOIN charging_pile_account.t_app_user au ON co.app_user_id = au.id |
| | | LEFT JOIN `charging_pile_other`.`t_company` tc on au.company_id = tc.id |
| | | |
| | | <where> |
| | | co.del_flag = 0 |
| | | <if test="statisticsQueryDto.dayType == 1"> |
| | |
| | | </if> |
| | | </where> |
| | | GROUP BY |
| | | au.company_id |
| | | tc.`name`, au.company_id |
| | | </select> |
| | | <select id="carUserMethod" resultType="java.util.Map"> |
| | | SELECT |
| | |
| | | `t_order_evaluate` te |
| | | LEFT JOIN t_charging_order co on te.order_id = co.id |
| | | WHERE |
| | | 1 = 1 |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | AND co.site_id IN |
| | | <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> |
| | | #{siteId} |
| | | </foreach> |
| | | </if> |
| | | te.del_flag = 0 |
| | | AND te.del_flag = 0 |
| | | |
| | | </select> |
| | | <select id="getLevelEvaluate" resultType="java.util.Map"> |
| | |
| | | source_name as source |
| | | from t_charging_order |
| | | where 1=1 |
| | | del_flag = 0 |
| | | AND del_flag = 0 |
| | | AND recharge_payment_status = 2 |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | and site_id IN |
| | |
| | | </if> |
| | | |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as siteName |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as siteName |
| | | FROM |
| | | `charging_pile_order`.`t_charging_order` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | </if> |
| | | |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as siteName |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as siteName |
| | | FROM |
| | | `charging_pile_order`.`t_charging_order` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | )) |
| | | </if> |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1 |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1 |
| | | FROM |
| | | `charging_pile_service`.`t_fault_message` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | )) |
| | | </if> |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1 |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1 |
| | | FROM |
| | | `charging_pile_service`.`t_fault_message` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | )) |
| | | </if> |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1 |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1 |
| | | FROM |
| | | `charging_pile_service`.`t_fault_message` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | )) |
| | | </if> |
| | | |
| | | ), 2) AS total_days,co.charging_gun_id,tc.name,cp.name as name1 |
| | | ), 2) AS percent,co.charging_gun_id,tc.name,cp.name as name1 |
| | | FROM |
| | | `charging_pile_service`.`t_fault_message` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc on co.charging_gun_id = tc.id |
| | |
| | | SELECT |
| | | FORMAT((SUM(co.current) / SUM(co.need_elec)), 2) AS percent, |
| | | co.charging_gun_id, |
| | | tc.name, |
| | | cp.name AS gun_name |
| | | tc.name as name, |
| | | cp.name AS siteName |
| | | FROM |
| | | `charging_pile_order`.`t_charging_order` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc ON co.charging_gun_id = tc.id |
| | | LEFT JOIN `charging_pile_service`.`t_charging_pile` cp ON tc.charging_pile_id = cp.id |
| | | <where> |
| | | cp.type = 1 |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | and co.site_id IN |
| | | <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> |
| | |
| | | |
| | | |
| | | </select> |
| | | <select id="needElec1" resultType="java.util.Map"> |
| | | SELECT |
| | | FORMAT((SUM(co.current) / SUM(co.need_elec)), 2) AS percent, |
| | | co.charging_gun_id, |
| | | tc.name as name, |
| | | cp.name AS siteName |
| | | FROM |
| | | `charging_pile_order`.`t_charging_order` co |
| | | LEFT JOIN `charging_pile_service`.`t_charging_gun` tc ON co.charging_gun_id = tc.id |
| | | LEFT JOIN `charging_pile_service`.`t_charging_pile` cp ON tc.charging_pile_id = cp.id |
| | | <where> |
| | | cp.type = 2 |
| | | <if test="siteIds != null and siteIds.size() > 0"> |
| | | and co.site_id IN |
| | | <foreach collection="siteIds" item="siteId" open="(" separator="," close=")"> |
| | | #{siteId} |
| | | </foreach> |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType == 1"> |
| | | AND DATE( co.create_time ) = CURDATE() |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType == 2"> |
| | | AND WEEKOFYEAR( co.create_time ) = WEEKOFYEAR( CURDATE() ) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType == 3"> |
| | | AND MONTH( co.create_time ) = MONTH(CURDATE()) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType == 4"> |
| | | AND YEAR( co.create_time ) = YEAR(CURDATE() ) |
| | | </if> |
| | | <if test="statisticsQueryDto.dayType == 5"> |
| | | <if test="statisticsQueryDto.startTime != null"> |
| | | AND co.create_time >= #{statisticsQueryDto.startTime} |
| | | </if> |
| | | <if test="statisticsQueryDto.endTime != null"> |
| | | AND co.create_time <= #{statisticsQueryDto.endTime} |
| | | </if> |
| | | </if> |
| | | </where> |
| | | GROUP BY |
| | | tc.name, |
| | | cp.name, |
| | | co.charging_gun_id; |
| | | </select> |
| | | </mapper> |
| | |
| | | order by a.create_time desc |
| | | </select> |
| | | <select id="goodTop" resultType="java.util.Map"> |
| | | SELECT count(1) as counts ,ot.evaluation_tag_id |
| | | from t_order_evaluate_tag ot |
| | | left join t_order_evaluate te on ot.order_evaluate_id = te.id |
| | | left join t_charging_order co on te.order_id = co.id |
| | | SELECT |
| | | count( 1 ) AS counts, |
| | | |
| | | tt.`name` |
| | | FROM |
| | | t_order_evaluate_tag ot |
| | | LEFT JOIN t_order_evaluate te ON ot.order_evaluate_id = te.id |
| | | LEFT JOIN t_charging_order co ON te.order_id = co.id |
| | | LEFT JOIN `charging_pile_other`.`t_evaluation_tag` tt on ot.evaluation_tag_id = tt.id |
| | | WHERE ot.evaluation_tag_id in ( |
| | | SELECT id from `charging_pile_other`.`t_evaluation_tag` WHERE type = 1 |
| | | ) <if test="null != siteIds"> |
| | |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY ot.evaluation_tag_id |
| | | ORDER BY counts desc |
| | | limit 5 |
| | | GROUP BY |
| | | tt.`name` |
| | | ORDER BY |
| | | counts DESC |
| | | LIMIT 5 |
| | | |
| | | |
| | | |
| | | </select> |
| | | <select id="badTop" resultType="java.util.Map"> |
| | | SELECT count(1) as counts ,ot.evaluation_tag_id |
| | | from t_order_evaluate_tag ot |
| | | left join t_order_evaluate te on ot.order_evaluate_id = te.id |
| | | left join t_charging_order co on te.order_id = co.id |
| | | SELECT |
| | | count( 1 ) AS counts, |
| | | |
| | | tt.`name` |
| | | FROM |
| | | t_order_evaluate_tag ot |
| | | LEFT JOIN t_order_evaluate te ON ot.order_evaluate_id = te.id |
| | | LEFT JOIN t_charging_order co ON te.order_id = co.id |
| | | LEFT JOIN `charging_pile_other`.`t_evaluation_tag` tt on ot.evaluation_tag_id = tt.id |
| | | WHERE ot.evaluation_tag_id in ( |
| | | SELECT id from `charging_pile_other`.`t_evaluation_tag` WHERE type = 3 |
| | | ) <if test="null != siteIds"> |
| | |
| | | #{item} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY ot.evaluation_tag_id |
| | | ORDER BY counts desc |
| | | limit 5 |
| | | GROUP BY |
| | | tt.`name` |
| | | ORDER BY |
| | | counts DESC |
| | | LIMIT 5 |
| | | </select> |
| | | </mapper> |
| | |
| | | payment_amount |
| | | FROM |
| | | t_shopping_order |
| | | <where> |
| | | |
| | | WHERE del_flag = 0 and payment_status = 2 and ISNULL(refund_status) and status!=4 |
| | | <if test="null != sixBefore"> |
| | | and DATE_FORMAT(create_time, '%Y-%m-%d') >= DATE_FORMAT(#{sixBefore}, '%Y-%m-%d') |
| | | and create_time >= #{sixBefore} |
| | | </if> |
| | | <if test="null != status"> |
| | | and status = #{status} |
| | | </if> |
| | | </where> |
| | | |
| | | |
| | | ) AS subquery |
| | | GROUP BY |
| | | DATE_FORMAT( subquery.create_time, '%m' ); |
| | | DATE_FORMAT( subquery.create_time, '%m' ) |
| | | |
| | | |
| | | </select> |
| | |
| | | <select id="sixBefore" resultType="com.ruoyi.order.dto.SixVipDto"> |
| | | SELECT |
| | | DATE_FORMAT(subquery.create_time, '%Y-%m') AS MONTH, |
| | | subquery.vip_id, |
| | | COUNT(1) AS orderNum, |
| | | SUM(subquery.payment_amount) AS paymentAmount |
| | | SUM(subquery.payment_amount) AS paymentAmount, |
| | | tp.`name` |
| | | FROM ( |
| | | SELECT |
| | | vip_id, |
| | |
| | | <where> |
| | | del_flag = 0 AND |
| | | payment_status = 2 AND |
| | | refund_amount IS NULL |
| | | <if test="sixBefore != null"> |
| | | AND create_time > #{sixBefore} |
| | | </if> |
| | | </where> |
| | | ) AS subquery |
| | | LEFT JOIN `charging_pile_other`.`t_vip` tp on subquery.vip_id = tp.id |
| | | GROUP BY |
| | | DATE_FORMAT(subquery.create_time, '%Y-%m'), |
| | | subquery.vip_id; |
| | | tp.`name`; |
| | | |
| | | |
| | | </select> |
| | |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import com.ruoyi.common.log.annotation.Log; |
| | | import com.ruoyi.common.log.enums.BusinessType; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | |
| | | // Page<TEnterpriseUserApplication> page = enterpriseUserApplicationService.lambdaQuery().in(TEnterpriseUserApplication::getAppUserId, userIds).page(Page.of(enterpriseQuery.getPageCurr(), enterpriseQuery.getPageSize())); |
| | | // return R.ok(page); |
| | | // }else { |
| | | Page<TEnterpriseUserApplication> page = enterpriseUserApplicationService.lambdaQuery().eq(enterpriseQuery.getPhone()!=null&&enterpriseQuery.getPhone()!="",TEnterpriseUserApplication::getPhone,enterpriseQuery.getPhone()).page(Page.of(enterpriseQuery.getPageCurr(), enterpriseQuery.getPageSize())); |
| | | Page<TEnterpriseUserApplication> page = enterpriseUserApplicationService.lambdaQuery().eq(enterpriseQuery.getPhone()!=null&&enterpriseQuery.getPhone()!="",TEnterpriseUserApplication::getPhone,enterpriseQuery.getPhone()).orderByDesc(BasePojo::getCreateTime).page(Page.of(enterpriseQuery.getPageCurr(), enterpriseQuery.getPageSize())); |
| | | return R.ok(page); |
| | | // } |
| | | } |
| | |
| | | |
| | | @GetMapping("/getInfoByType") |
| | | @ApiOperation(tags = {"小程序-兑换商城"},value = "商品查看详情") |
| | | public AjaxResult getInfoByType(Integer goodType,Integer id) { |
| | | public R getInfoByType(Integer goodType,Integer id) { |
| | | if (goodType==1){ |
| | | TGoods byId = goodsService.getById(id); |
| | | return AjaxResult.ok(byId);} |
| | | if (byId==null||byId.getStatus()==2){ |
| | | return R.fail(2,"内容不存在"); |
| | | } |
| | | return R.ok(byId);} |
| | | else { |
| | | TCoupon byId = couponService.getById(id); |
| | | return AjaxResult.ok(byId); |
| | | if (byId==null||byId.getStatus()==2){ |
| | | return R.fail(2,"内容不存在"); |
| | | } |
| | | return R.ok(byId); |
| | | } |
| | | } |
| | | |
| | |
| | | }else { |
| | | //减少库存 |
| | | good.setInventory(good.getInventory()-exchangeDto.getNum()); |
| | | goodsService.updateById(good); |
| | | } |
| | | if (user.getPoints()<good.getRedeemPoints()){ |
| | | return AjaxResult.error("当前用户积分不足"); |
| | |
| | | if (coupon.getInventoryQuantity() != -1 && count >= coupon.getInventoryQuantity()) { |
| | | return AjaxResult.error("当前用户已到达兑换"+coupon+"次"); |
| | | }else { |
| | | coupon.setInventoryQuantity(coupon.getInventoryQuantity()-exchangeDto.getNum()); |
| | | coupon.setInventoryQuantity(coupon.getInventoryQuantity()-1); |
| | | couponService.updateById(coupon); |
| | | } |
| | | |
| | | |
| | |
| | | PointChangeDto pointChangeDto = new PointChangeDto(); |
| | | pointChangeDto.setUserId(userId); |
| | | pointChangeDto.setPoints(point); |
| | | pointChangeDto.setRemark(longR.getData().toString()); |
| | | pointChangeDto.setRemark(String.valueOf(longR.getData().getId())); |
| | | pointChangeDto.setType(6); |
| | | pointChangeDto.setCode(longR.getData().getCode()); |
| | | appUserClient.changeDown(pointChangeDto); |
| | | return AjaxResult.success(); |
| | | return AjaxResult.success(longR.getData().getId()); |
| | | |
| | | |
| | | } |
| | |
| | | BigDecimal vipDiscount = new BigDecimal(0); |
| | | if (exchangeDto.getGoodType()==1){ |
| | | TGoods good = goodsService.getById(exchangeDto.getGoodId()); |
| | | if (good.getStatus()==2){ |
| | | return R.fail("当前商品已下架"); |
| | | } |
| | | BigDecimal originalPrice = good.getPreferentialPrice(); |
| | | exchangeDto.setTitle("【商品购买】"+good.getName()); |
| | | if (isVip){ |
| | |
| | | }else { |
| | | |
| | | TCoupon coupon = couponService.getById(exchangeDto.getGoodId()); |
| | | if (coupon.getStatus()==2){ |
| | | return R.fail("当前商品已下架"); |
| | | } |
| | | exchangeDto.setTitle("【优惠卷购买】"+coupon.getName()); |
| | | BigDecimal originalPrice = coupon.getPaymentAmount(); |
| | | if (isVip){ |
| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.account.api.dto.SendCouponDto; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @ApiOperation(value = "当前生效会员信息", tags = {"小程序-个人中心"}) |
| | | @GetMapping("/recent/vipInfo") |
| | | public R<List<VipInfoDto>> recentVipInfo() { |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | TAppUser data = appUserClient.getUserById(userId).getData(); |
| | | if (data.getVipEndTime()!=null&&data.getVipEndTime().isAfter(LocalDateTime.now())) { |
| | | |
| | | List<VipInfoDto> vipInfoDtos = new ArrayList<>(); |
| | | List<TVip> vips = vipService.lambdaQuery().eq(TVip::getId, data.getVipId()).list(); |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | for (TVip vip : vips) { |
| | | VipInfoDto vipInfoDto = new VipInfoDto(); |
| | | vipInfoDto.setMonthlyCard(vip.getMonthlyCardReveal() == 1 ? vip.getMonthlyCard() : null); |
| | | vipInfoDto.setSeasonCard(vip.getSeasonCardReveal() == 1 ? vip.getSeasonCard() : null); |
| | | vipInfoDto.setAnnualCard(vip.getAnnualCardReveal() == 1 ? vip.getAnnualCard() : null); |
| | | //判断是否在折扣时间内,然后设置折扣价格 |
| | | if (vip.getMonthlyCardDiscountStart() != null && (now.isAfter(vip.getMonthlyCardDiscountStart()) && now.isBefore(vip.getMonthlyCardDiscountEnd()))) { |
| | | vipInfoDto.setMonthlyCardDiscount(vip.getMonthlyCardDiscount()); |
| | | } |
| | | if (vip.getSeasonCardDiscountStart() != null && (now.isAfter(vip.getSeasonCardDiscountStart()) && now.isBefore(vip.getSeasonCardDiscountEnd()))) { |
| | | vipInfoDto.setSeasonCardDiscount(vip.getSeasonCardDiscount()); |
| | | } |
| | | if (vip.getAnnualCardDiscountStart() != null && (now.isAfter(vip.getAnnualCardDiscountStart()) && now.isBefore(vip.getAnnualCardDiscountEnd()))) { |
| | | vipInfoDto.setAnnualCardDiscount(vip.getAnnualCardDiscount()); |
| | | } |
| | | |
| | | |
| | | vipInfoDto.setMaximumDeduction(vip.getMaximumDeduction()); |
| | | vipInfoDto.setDiscountTimes(vip.getDiscountTimes()); |
| | | vipInfoDto.setDoubleIntegration(vip.getDoubleIntegration()); |
| | | vipInfoDto.setMallExclusivePrice(vip.getMallExclusivePrice()); |
| | | vipInfoDto.setName(vip.getName()); |
| | | vipInfoDto.setId(vip.getId()); |
| | | List<SendCouponDto> javaList = JSON.parseArray(vip.getCoupon()).toJavaList(SendCouponDto.class); |
| | | List<VipCouponDto> vipCouponDtos = new ArrayList<>(); |
| | | if (!javaList.isEmpty()) { |
| | | for (SendCouponDto sendCouponDto : javaList) { |
| | | VipCouponDto vipCouponDto = new VipCouponDto(); |
| | | TCoupon byId = couponService.getById(sendCouponDto.getId()); |
| | | vipCouponDto.setNum(sendCouponDto.getNumber()); |
| | | vipCouponDto.setTCoupon(byId); |
| | | vipCouponDtos.add(vipCouponDto); |
| | | } |
| | | } |
| | | |
| | | vipInfoDto.setVipCouponDtos(vipCouponDtos); |
| | | |
| | | //计算总折扣 |
| | | BigDecimal total = BigDecimal.ZERO; |
| | | total = total.add(vip.getMaximumDeduction().multiply(BigDecimal.valueOf(vip.getDiscountTimes()))); |
| | | for (VipCouponDto vipCouponDto : vipCouponDtos) { |
| | | TCoupon tCoupon = vipCouponDto.getTCoupon(); |
| | | if (tCoupon.getPreferentialMode() == 2) { |
| | | total.add(tCoupon.getMaximumDiscountAmount()); |
| | | } else { |
| | | total.add(tCoupon.getDiscountAmount()); |
| | | } |
| | | } |
| | | vipInfoDto.setTotalDiscount(total); |
| | | vipInfoDto.setTimeAmount(vip.getMaximumDeduction().multiply(BigDecimal.valueOf(vip.getDiscountTimes()))); |
| | | vipInfoDtos.add(vipInfoDto); |
| | | } |
| | | return R.ok(vipInfoDtos); |
| | | |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "购买会员", tags = {"小程序-个人中心"}) |
| | |
| | | ) { |
| | | |
| | | TVip byId = vipService.getById(vipId); |
| | | if (byId==null){ |
| | | return R.ok("当前会员不存在,请刷新后重试。"); |
| | | } |
| | | BigDecimal payMoney = BigDecimal.ZERO; |
| | | BigDecimal discountMoney = BigDecimal.ZERO; |
| | | BigDecimal discount = BigDecimal.ZERO; |
| | |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | | # active: prod |
| | | --- |
| | | spring: |
| | | config: |
| | |
| | | profiles: |
| | | # 环境配置 |
| | | active: dev |
| | | # active: prod |
| | | --- |
| | | spring: |
| | | config: |