ruoyi-api/ruoyi-api-chargingPile/src/main/java/com/ruoyi/chargingPile/api/model/TVehicleRamp.java
@@ -53,5 +53,7 @@ @TableField("direction") private Integer direction; @ApiModelProperty(value = "开关动作(open:开、close:关)") @TableField(exist = false) private String action; } ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/factory/SwitchwayGateFallbackFactory.java
New file @@ -0,0 +1,34 @@ package com.ruoyi.integration.api.factory; import com.ruoyi.common.core.domain.R; import com.ruoyi.integration.api.feignClient.SendMessageClient; import com.ruoyi.integration.api.feignClient.SwitchwayGateClient; import com.ruoyi.integration.api.model.PlatformStartCharging; import com.ruoyi.integration.api.model.PlatformStopCharging; 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 SwitchwayGateFallbackFactory implements org.springframework.cloud.openfeign.FallbackFactory<SwitchwayGateClient> { private static final Logger log = LoggerFactory.getLogger(SwitchwayGateFallbackFactory.class); @Override public SwitchwayGateClient create(Throwable throwable) { log.error("调用道闸开关失败:{}", throwable.getMessage()); return new SwitchwayGateClient() { @Override public R<Boolean> gateService(SwitchwayGateReq req) { return R.fail("道闸开关失败:" + throwable.getMessage()); } }; } } ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/SwitchwayGateClient.java
New file @@ -0,0 +1,25 @@ 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.SwitchwayGateFallbackFactory; import com.ruoyi.integration.api.vo.SwitchwayGateReq; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; /** * @author zhibing.pu * @Date 2024/9/10 11:08 */ @FeignClient(contextId = "SwitchwayGateClient", value = ServiceNameConstants.INTEGRATION_SERVICE, fallbackFactory = SwitchwayGateFallbackFactory.class) public interface SwitchwayGateClient { /** * 道闸开关 * @param req * @return */ @PostMapping("/switchwayGate/gateService") R<Boolean> gateService(@RequestBody SwitchwayGateReq req); } ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/vo/SwitchwayGateReq.java
New file @@ -0,0 +1,19 @@ package com.ruoyi.integration.api.vo; import lombok.Data; /** * @author zhibing.pu * @Date 2024/9/10 10:48 */ @Data public class SwitchwayGateReq { /** * 开关动作(open:开、close:关) */ private String action; /** * 通道编号 */ private String channel; } ruoyi-api/ruoyi-api-integration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -4,3 +4,4 @@ com.ruoyi.integration.api.factory.SendMessageFallbackFactory com.ruoyi.integration.api.factory.PlatformStartChargingReplyFallbackFactory com.ruoyi.integration.api.factory.PlatformStopChargingReplyFallbackFactory com.ruoyi.integration.api.factory.SwitchwayGateFallbackFactory ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/ChargingListQuery.java
@@ -22,6 +22,8 @@ private Integer type; @ApiModelProperty("状态(1未出账 2已出账)") private Integer state; @ApiModelProperty("状态(1日结 2月结)") private Integer orderState; @ApiModelProperty("uid 前端忽略") private String uid; ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TApplyChargingPileController.java
@@ -290,7 +290,8 @@ @ApiOperation(value = "下载", tags = {"管理后台-账户结算账单"}) @PutMapping("/downloadAccount") public R downloadAccount(@RequestBody ChargingListQuery dto,HttpServletResponse response) { { dto.setPageCurr(1); dto.setPageSize(99999999); AccountListVO data = orderClient.accountBillList(dto).getData(); try { response.setCharacterEncoding(Constants.UTF8); ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TVehicleRampController.java
@@ -9,11 +9,14 @@ import com.ruoyi.common.log.annotation.Log; import com.ruoyi.common.log.enums.BusinessType; import com.ruoyi.common.log.enums.OperatorType; import com.ruoyi.integration.api.feignClient.SwitchwayGateClient; import com.ruoyi.integration.api.vo.SwitchwayGateReq; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.Arrays; import java.util.List; @@ -31,6 +34,13 @@ public class TVehicleRampController { private final TVehicleRampService vehicleRampService; @Resource private SwitchwayGateClient switchwayGateClient; @Autowired public TVehicleRampController(TVehicleRampService vehicleRampService) { @@ -95,8 +105,11 @@ @ApiOperation(tags = {"后台-车道"},value = "开关闸车道") @PostMapping(value = "/openOrDown") public AjaxResult<String> openOrDown(@RequestBody TVehicleRamp dto) { // TODO 硬件 开关闸车道 return AjaxResult.success(); SwitchwayGateReq req = new SwitchwayGateReq(); req.setAction(dto.getAction()); req.setChannel(dto.getCarportNum()); Boolean data = switchwayGateClient.gateService(req).getData(); return data ? AjaxResult.success() : AjaxResult.error("操作失败"); } } ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/barrierGate/controller/CouponController.java
@@ -1,10 +1,12 @@ package com.ruoyi.integration.barrierGate.controller; import com.alibaba.fastjson.JSON; import com.ruoyi.integration.barrierGate.model.BaseResponse; import com.ruoyi.integration.barrierGate.model.GetCouponReq; import com.ruoyi.integration.barrierGate.model.GetCouponResp; import com.ruoyi.integration.barrierGate.model.UsedCoupon; import com.ruoyi.integration.barrierGate.server.CouponService; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -14,6 +16,7 @@ * @author zhibing.pu * @Date 2024/9/5 11:10 */ @Slf4j @RestController @RequestMapping("/coupon") public class CouponController { @@ -31,6 +34,7 @@ @ResponseBody @PostMapping("/getCoupon") public BaseResponse<GetCouponResp> getCoupon(@RequestBody GetCouponReq req){ log.info("停车获取优惠券请求参数:{}" + JSON.toJSONString(req)); GetCouponResp coupon = couponService.getCoupon(req); return BaseResponse.ok(coupon); } @@ -44,6 +48,7 @@ @ResponseBody @PostMapping("/usedCoupon") public BaseResponse usedCoupon(@RequestBody UsedCoupon req){ log.info("停车使用优惠券请求参数:{}" + JSON.toJSONString(req)); couponService.usedCoupon(req); return BaseResponse.ok(); } ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/barrierGate/controller/ParkingOrderController.java
@@ -1,7 +1,9 @@ package com.ruoyi.integration.barrierGate.controller; import com.alibaba.fastjson.JSON; import com.ruoyi.integration.barrierGate.model.*; import com.ruoyi.integration.barrierGate.server.ParkingOrderService; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -10,6 +12,7 @@ * @author zhibing.pu * @Date 2024/9/5 16:14 */ @Slf4j @RestController @RequestMapping("/parkingOrder") public class ParkingOrderController { @@ -25,6 +28,7 @@ @ResponseBody @PostMapping("/cloudParkingInOrder") public BaseResponse cloudParkingInOrder(@RequestBody CloudParkingOrder order){ log.info("云停车入场请求参数:{}" + JSON.toJSONString(order)); parkingOrderService.cloudParkingInOrder(order); return BaseResponse.ok(); } @@ -37,6 +41,7 @@ @ResponseBody @PostMapping("/cloudParkingOutOrder") public BaseResponse cloudParkingOutOrder(@RequestBody CloudParkingOrder order){ log.info("云停车出场请求参数:{}" + JSON.toJSONString(order)); parkingOrderService.cloudParkingOutOrder(order); return BaseResponse.ok(); } @@ -49,6 +54,7 @@ @ResponseBody @PostMapping("/cloudParkingSpace") public BaseResponse cloudParkingSpace(@RequestBody CloudParkingSpace parkingSpace){ log.info("云停车实时车位请求参数:{}" + JSON.toJSONString(parkingSpace)); parkingOrderService.cloudParkingSpace(parkingSpace); return BaseResponse.ok(); } @@ -62,6 +68,7 @@ @ResponseBody @PostMapping("/offlineParkingInOrder") public BaseResponse offlineParkingInOrder(@RequestBody OfflineParkingOrder order){ log.info("线下停车场入场请求参数:{}" + JSON.toJSONString(order)); parkingOrderService.offlineParkingInOrder(order); OfflineParkingResponse offlineParkingResponse = new OfflineParkingResponse(); offlineParkingResponse.setCode(0); @@ -78,6 +85,7 @@ @ResponseBody @PostMapping("/offlineParkingOutOrder") public BaseResponse offlineParkingOutOrder(@RequestBody OfflineParkingOrder order){ log.info("线下停车场出场请求参数:{}" + JSON.toJSONString(order)); parkingOrderService.offlineParkingOutOrder(order); OfflineParkingResponse offlineParkingResponse = new OfflineParkingResponse(); offlineParkingResponse.setCode(0); @@ -94,6 +102,7 @@ @ResponseBody @PostMapping("/offlineParkingSpace") public BaseResponse offlineParkingSpace(@RequestBody OfflineParkingSpace parkingSpace){ log.info("线下停车场实时车位请求参数:{}" + JSON.toJSONString(parkingSpace)); parkingOrderService.offlineParkingSpace(parkingSpace); return BaseResponse.ok(); } ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/barrierGate/controller/SwitchwayGateController.java
New file @@ -0,0 +1,36 @@ package com.ruoyi.integration.barrierGate.controller; import com.ruoyi.common.core.domain.R; import com.ruoyi.integration.api.vo.SwitchwayGateReq; import com.ruoyi.integration.barrierGate.server.SwitchwayGateService; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; /** * 开关道闸 * @author zhibing.pu * @Date 2024/9/10 9:43 */ @RestController @RequestMapping("/switchwayGate") public class SwitchwayGateController { @Resource private SwitchwayGateService switchwayGateService; /** * 开关道闸 * @param req * @return */ @PostMapping("/gateService") public R<Boolean> gateService(@RequestBody SwitchwayGateReq req){ Boolean aBoolean = switchwayGateService.gateService(req); return R.ok(aBoolean); } } ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/barrierGate/model/SwitchwayGate.java
New file @@ -0,0 +1,50 @@ package com.ruoyi.integration.barrierGate.model; import com.ruoyi.common.core.utils.MD5Util; import lombok.Data; import lombok.experimental.Accessors; import lombok.extern.slf4j.Slf4j; /** * @author zhibing.pu * @Date 2024/9/10 9:45 */ @Slf4j @Data @Accessors(chain = true) public class SwitchwayGate { /** * 停车场appkey */ private String appkey; /** * 开关动作(open:开、close:关) */ private String action; /** * 通道编号 */ private String channel; /** * 当前时间戳 */ private String timestamp; /** * 签名信息:参数升序排序,&拼接所有参数,MD5(参数+&+参数值...+签名密钥)转大写 */ private String sign; public SwitchwayGate build(String secretkey){ String str = String.format("action=%s&appkey=%s&channel=%s×tamp=%s&key=%s", this.getAction(), this.getAppkey(), this.getChannel(), this.getTimestamp(), secretkey); log.info("待签名串:{}", str); //MD5加密 String encoder = MD5Util.getMD5(str); //将签名结果转大写 encoder = encoder.toUpperCase(); log.info("签名结果:{}", encoder); this.setSign(encoder); return this; } } ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/barrierGate/server/SwitchwayGateService.java
New file @@ -0,0 +1,61 @@ package com.ruoyi.integration.barrierGate.server; import cn.hutool.http.HttpUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.ruoyi.integration.api.vo.SwitchwayGateReq; import com.ruoyi.integration.barrierGate.model.SwitchwayGate; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; /** * @author zhibing.pu * @Date 2024/9/10 9:44 */ @Slf4j @Service public class SwitchwayGateService { private final String url = "http://8.137.103.127/universal"; private final String appkey = "886621e841fc44c1ad63a823d"; private final String secretkey = "7d87c2c36bea4749b30f38f4d"; /** * 开关道闸 * @param req * @return */ public Boolean gateService(SwitchwayGateReq req){ SwitchwayGate switchwayGate = new SwitchwayGate() .setAppkey(appkey) .setAction(req.getAction()) .setChannel(req.getChannel()) .setTimestamp(System.currentTimeMillis() + "") .build(secretkey); String body = JSON.toJSONString(switchwayGate); String result = HttpUtil.post(url + "/gateService", body); JSONObject jsonObject = JSON.parseObject(result); Boolean success = jsonObject.getBoolean("success"); if(!success){ log.error("调用开关道闸失败:\n请求参数:{}\n返回结果:{}", body, result); } return success; } // public static void main(String[] args) { // SwitchwayGateService switchwayGateService = new SwitchwayGateService(); // SwitchwayGateReq req = new SwitchwayGateReq(); // req.setAction("close"); // req.setChannel("001"); // Boolean success = switchwayGateService.gateService(req); // if(success){ // log.info("调用成功"); // }else{ // log.info("调用失败"); // } // } } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/controller/ChargingBillController.java
@@ -73,8 +73,7 @@ public R<AccountListVO> accountBillList(@RequestBody ChargingListQuery dto) { AccountListVO accountListVO = new AccountListVO(); ChargingBillVO res = chargingBillService.chargingBillList(dto); dto.setPageCurr(1); dto.setPageSize(99999999); ChargingBillVO res1 = chargingBillService.chargingBillList(dto); List<ChargingBillListVO> records = res1.getList().getRecords(); accountListVO.setBillCount(records.size()); ruoyi-service/ruoyi-order/src/main/resources/mapper/order/TChargingOrderMapper.xml
@@ -852,4 +852,5 @@ and (t1.end_time between #{endTime1} and #{endTime2}) </if> </select> </mapper> ruoyi-service/ruoyi-payment/src/main/java/com/ruoyi/payment/wx/utils/WxAbstractPay.java
@@ -69,7 +69,7 @@ */ protected String buildBaseParam(WxPaymentInfoModel requestBody, String notifyUrl) { // 封装基础数据 requestBody.setNotify_url(notifyUrl); // requestBody.setNotify_url(notifyUrl); String reqBody = WxJsonUtils.toJsonString(requestBody); return reqBody; }