ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/factory/TCECClientFallbackFactory.java
New file @@ -0,0 +1,45 @@ package com.ruoyi.integration.api.factory; import com.ruoyi.common.core.domain.R; import com.ruoyi.integration.api.feignClient.TCECClient; import com.ruoyi.integration.api.vo.StartChargeResult; import org.springframework.cloud.openfeign.FallbackFactory; /** * @author zhibing.pu * @Date 2025/1/24 10:33 */ public class TCECClientFallbackFactory implements FallbackFactory<TCECClient> { @Override public TCECClient create(Throwable cause) { return new TCECClient() { @Override public R pushChargingGunStatus(Integer id, Integer status) { return R.fail("接口状态变化后推送给第三方失败:" + cause.getMessage()); } @Override public R notificationStartChargeResult(StartChargeResult result) { return R.fail("启动充电结果推送失败:" + cause.getMessage()); } @Override public R notificationEquipChargeStatus(String startChargeSeq, Integer operatorId) { return R.fail("推送充电状态失败:" + cause.getMessage()); } @Override public R notificationStopChargeResult(String startChargeSeq, String connectorID, Integer operatorId) { return R.fail("推送停止充电结果失败:" + cause.getMessage()); } @Override public R notificationChargeOrderInfo(String startChargeSeq, Integer operatorId) { return R.fail("推送订单信息失败:" + cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/feignClient/TCECClient.java
New file @@ -0,0 +1,69 @@ 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.TCECClientFallbackFactory; import com.ruoyi.integration.api.vo.StartChargeResult; 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 2025/1/24 10:32 */ @FeignClient(contextId = "TCECClient", value = ServiceNameConstants.INTEGRATION_SERVICE, fallbackFactory = TCECClientFallbackFactory.class) public interface TCECClient { /** * 接口状态变化后推送给第三方 * @return */ @PostMapping("/evcs/v1.0/pushChargingGunStatus") R pushChargingGunStatus(@RequestParam("id") Integer id, @RequestParam("status") Integer status); /** * 启动充电结果推送 * @param result * @return */ @PostMapping("/evcs/v1.0/notificationStartChargeResult") R notificationStartChargeResult(@RequestBody StartChargeResult result); /** * 推送充电状态 * @param startChargeSeq * @return */ @PostMapping("/evcs/v1.0/notificationEquipChargeStatus") R notificationEquipChargeStatus(@RequestParam("startChargeSeq") String startChargeSeq, @RequestParam("operatorId") Integer operatorId); /** * 推送停止充电结果 * @param startChargeSeq 充电订单号 * @param connectorID 充电设备接口编码 * @return */ @PostMapping("/evcs/v1.0/notificationStopChargeResult") R notificationStopChargeResult(@RequestParam("startChargeSeq") String startChargeSeq, @RequestParam("connectorID") String connectorID, @RequestParam("operatorId") Integer operatorId); /** * 推送订单信息 * @param startChargeSeq * @return */ @PostMapping("/notificationChargeOrderInfo") R notificationChargeOrderInfo(@RequestParam("startChargeSeq") String startChargeSeq, @RequestParam("operatorId") Integer operatorId); } ruoyi-api/ruoyi-api-integration/src/main/java/com/ruoyi/integration/api/vo/StartChargeResult.java
File was renamed from ruoyi-api/ruoyi-api-order/src/main/java/com/ruoyi/order/api/model/StartChargeResult.java @@ -1,4 +1,4 @@ package com.ruoyi.order.api.model; package com.ruoyi.integration.api.vo; import lombok.Data; @@ -33,7 +33,12 @@ private String ConnectorID; /** * 充电启动时间 * yyyy-MM-dd HH:mm:ss */ @NotNull private String StartTime; /** * 合作商ID */ private String operatorID; } ruoyi-api/ruoyi-api-integration/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -7,4 +7,5 @@ com.ruoyi.integration.api.factory.SwitchwayGateFallbackFactory com.ruoyi.integration.api.factory.IotInterfaceFallbackFactory com.ruoyi.integration.api.factory.SecurityDetectionFallbackFactory com.ruoyi.integration.api.factory.BmsDemandAndChargerExportationFallbackFactory com.ruoyi.integration.api.factory.BmsDemandAndChargerExportationFallbackFactory com.ruoyi.integration.api.factory.TCECClientFallbackFactory ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/domain/Operator.java
@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.time.LocalDateTime; /** * 运营商信息 * @author zhibing.pu @@ -50,6 +52,31 @@ @TableField("sigSecret") private String sigSecret; /** * 测试接口地址 */ @TableField("test_url") private String testUrl; /** * 接口地址 */ @TableField("url") private String url; /** * 我方登录三方秘钥 */ @TableField("ourOperatorSecret") private String ourOperatorSecret; /** * 各平台登录token */ @TableField("accessToken") private String accessToken; /** * token过期时间(秒) */ @TableField("tokenAvailableTime") private LocalDateTime tokenAvailableTime; /** * token */ @TableField(exist = false) ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/factory/OperatorFallbackFactory.java
@@ -5,6 +5,8 @@ import com.ruoyi.other.api.feignClient.OperatorClient; import org.springframework.cloud.openfeign.FallbackFactory; import java.util.List; /** * @author zhibing.pu * @Date 2025/1/22 15:16 @@ -17,9 +19,24 @@ return new OperatorClient() { @Override public R<Operator> getOperatorById(Integer id) { return R.fail("获取运营商数据失败:" + cause.getMessage()); } @Override public R<Operator> getOperator(String operatorId) { return R.fail("获取运营商数据失败:" + cause.getMessage()); } @Override public R<List<Operator>> getAllOperator() { return R.fail("获取所有运营商失败:" + cause.getMessage()); } @Override public R editOperator(Operator operator) { return R.fail("更新运营商数据失败:" + cause.getMessage()); } }; } } ruoyi-api/ruoyi-api-other/src/main/java/com/ruoyi/other/api/feignClient/OperatorClient.java
@@ -6,7 +6,10 @@ import com.ruoyi.other.api.factory.OperatorFallbackFactory; 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; import java.util.List; /** * @author zhibing.pu @@ -16,6 +19,14 @@ public interface OperatorClient { /** * 获取运营商数据 * @param id * @return */ @PostMapping("/operator/getOperatorById") R<Operator> getOperatorById(@RequestParam("id") Integer id); /** * 获取运营商数据 @@ -24,6 +35,19 @@ */ @PostMapping("/operator/getOperator") R<Operator> getOperator(@RequestParam("operatorId") String operatorId); /** * 获取所有运营商 * @return */ @PostMapping("/operator/getAllOperator") R<List<Operator>> getAllOperator(); /** * 更新运营商数据 * @return */ @PostMapping("/operator/editOperator") R editOperator(@RequestBody Operator operator); } ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/ObsUploadUtil.java
File was deleted ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/utils/obs/OBSUtil.java
File was deleted ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/controller/TChargingPileController.java
@@ -30,6 +30,7 @@ import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.annotation.Logical; import com.ruoyi.common.security.annotation.RequiresPermissions; import com.ruoyi.integration.api.feignClient.TCECClient; import com.ruoyi.order.api.feignClient.ChargingOrderClient; import com.ruoyi.order.api.model.TChargingOrder; import com.ruoyi.order.api.vo.TChargingOrderVo; @@ -74,6 +75,9 @@ @Resource private ChargingOrderClient chargingOrderClient; @Resource private TCECClient tcecClient; @Autowired @@ -259,6 +263,9 @@ tChargingGun1.setId(tChargingGun.getId()); tChargingGun1.setStatus(2); chargingGunService.updateById(tChargingGun1); //推送状态给三方平台 tcecClient.pushChargingGunStatus(tChargingGun.getId(), tChargingGun1.getStatus()); if(chargingPile.getStatus() != 1){ TChargingPile chargingPile1 = new TChargingPile(); chargingPile1.setId(chargingPile.getId()); @@ -279,6 +286,8 @@ tChargingGun1.setId(tChargingGun.getId()); tChargingGun1.setStatus(7); chargingGunService.updateById(tChargingGun1); //推送状态给三方平台 tcecClient.pushChargingGunStatus(tChargingGun.getId(), tChargingGun1.getStatus()); //桩处于正常,桩所属的枪都处于非正常,修改桩状态为异常 List<TChargingGun> list = chargingGunService.list(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getChargingPileId, chargingPile.getId()).eq(TChargingGun::getDelFlag, 0)); @@ -321,11 +330,16 @@ } tChargingGun1.setId(tChargingGun.getId()); chargingGunService.updateById(tChargingGun1); //推送状态给三方平台 tcecClient.pushChargingGunStatus(tChargingGun.getId(), tChargingGun1.getStatus()); }else{ TChargingGun tChargingGun1 = new TChargingGun(); tChargingGun1.setId(tChargingGun.getId()); tChargingGun1.setStatus(3); chargingGunService.updateById(tChargingGun1); //推送状态给三方平台 tcecClient.pushChargingGunStatus(tChargingGun.getId(), tChargingGun1.getStatus()); } List<TFaultMessage> list = faultMessageService.list(new LambdaQueryWrapper<TFaultMessage>().eq(TFaultMessage::getChargingGunId, tChargingGun.getId()) ruoyi-service/ruoyi-chargingPile/src/main/java/com/ruoyi/chargingPile/service/impl/TChargingPileServiceImpl.java
@@ -26,10 +26,7 @@ import com.ruoyi.common.redis.service.RedisService; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.common.security.utils.SecurityUtils; import com.ruoyi.integration.api.feignClient.IntegrationClient; import com.ruoyi.integration.api.feignClient.IotInterfaceClient; import com.ruoyi.integration.api.feignClient.SendMessageClient; import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient; import com.ruoyi.integration.api.feignClient.*; import com.ruoyi.integration.api.model.QrCodeDelivery; import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData; import com.ruoyi.integration.api.vo.AddDevice; @@ -69,6 +66,9 @@ @Resource private TChargingGunService chargingGunService; @Resource private TCECClient tcecClient; @Resource private SysUserClient sysUserClient; @@ -689,6 +689,8 @@ chargingGun1.setId(chargingGun.getId()); chargingGun1.setStatus(1); chargingGunService.updateById(chargingGun1); //推送状态给三方平台 tcecClient.pushChargingGunStatus(chargingGun1.getId(), chargingGun1.getStatus()); //桩处于正常,桩所属的枪都处于非正常,修改桩状态为异常 TChargingPile chargingPile = this.getById(chargingGun.getChargingPileId()); ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/TCECController.java
@@ -13,13 +13,12 @@ import com.ruoyi.common.core.dto.ChargingPercentProvinceDto; import com.ruoyi.common.core.utils.StringUtils; import com.ruoyi.common.core.web.page.PageInfo; import com.ruoyi.common.security.service.TokenService; import com.ruoyi.integration.drainage.model.*; import com.ruoyi.integration.drainage.model.enu.*; import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; import com.ruoyi.order.api.feignClient.ChargingOrderClient; import com.ruoyi.order.api.model.AddTripartitePlatformOrder; import com.ruoyi.order.api.model.StartChargeResult; import com.ruoyi.integration.api.vo.StartChargeResult; import com.ruoyi.order.api.model.TChargingOrder; import com.ruoyi.order.api.model.TChargingOrderAccountingStrategy; import com.ruoyi.other.api.domain.Operator; @@ -36,6 +35,9 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** @@ -132,7 +134,7 @@ Operator operator = r.getData(); baseRequest.setOperator(operator); //校验签名 String sign = buildSign(baseRequest); String sign = TCECUtil.buildSign(baseRequest); if(!sign.equals(sig)){ baseResult.setRet(4001); baseResult.setMsg("签名校验失败"); @@ -140,32 +142,6 @@ } baseResult.setOperator(operator); return baseResult; } /** * 构建签名字符串 * @param model * @return */ public String buildSign(BaseModel model){ Operator operator = model.getOperator(); //签名秘钥SigSecret String key = operator.getSigSecret(); String sign = ""; switch (operator.getName()){ case "XinDianTu": //进行字符串拼接、计算 String m = new StringBuilder(model.getOperatorID()).append(model.getData()).append(model.getTimeStamp()).append(model.getSeq()).toString(); byte[] hmacMd5 = SignUtil.getHMacMD5Bytes(key.getBytes(), m.getBytes()); // 打印计算得到的签名Sig sign = SignUtil.bytesToHexString(hmacMd5); break; case "KuaiDian": sign = SignUtil.hmacSign(model.getData(), key); break; } return sign; } @@ -181,7 +157,7 @@ BaseResult baseResult = requestCheck(false, baseRequest, request); if(0 != baseResult.getRet()){ baseResult.setData(""); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } QueryTokenResult queryTokenResult = new QueryTokenResult(); @@ -189,6 +165,11 @@ if(null == operator){ queryTokenResult.setSuccStat(1); queryTokenResult.setFailReason(1); //参数加密 String jsonString = JSON.toJSONString(queryTokenResult); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } @@ -202,7 +183,7 @@ String jsonString = JSON.toJSONString(queryTokenResult); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } @@ -219,7 +200,7 @@ String jsonString = JSON.toJSONString(queryTokenResult); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } @@ -237,7 +218,7 @@ BaseResult baseResult = requestCheck(true, baseRequest, request); if(0 != baseResult.getRet()){ baseResult.setData(""); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } Operator operator = baseResult.getOperator(); @@ -262,7 +243,7 @@ String jsonString = JSON.toJSONString(queryStationsInfoResult); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } @@ -458,7 +439,10 @@ connectorStatusInfo.setStatus(255); break; } NotificationStationStatusResult result = TCECUtil.notificationStationStatus(connectorStatusInfo); List<Operator> operators = operatorClient.getAllOperator().getData(); for (Operator operator : operators) { TCECUtil.notificationStationStatus(operator, connectorStatusInfo); } return R.ok(); } @@ -473,7 +457,7 @@ BaseResult baseResult = requestCheck(true, baseRequest, request); if(0 != baseResult.getRet()){ baseResult.setData(""); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } Operator operator = baseResult.getOperator(); @@ -532,7 +516,7 @@ String jsonString = JSON.toJSONString(result); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } @@ -550,7 +534,7 @@ BaseResult baseResult = requestCheck(true, baseRequest, request); if(0 != baseResult.getRet()){ baseResult.setData(""); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } Operator operator = baseResult.getOperator(); @@ -602,7 +586,7 @@ String jsonString = JSON.toJSONString(result); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } @@ -617,7 +601,7 @@ BaseResult baseResult = requestCheck(true, baseRequest, request); if(0 != baseResult.getRet()){ baseResult.setData(""); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } Operator operator = baseResult.getOperator(); @@ -669,7 +653,7 @@ String jsonString = JSON.toJSONString(queryEquipAuthResult); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } @@ -685,7 +669,7 @@ BaseResult baseResult = requestCheck(true, baseRequest, request); if(0 != baseResult.getRet()){ baseResult.setData(""); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } Operator operator = baseResult.getOperator(); @@ -708,7 +692,7 @@ String jsonString = JSON.toJSONString(queryEquipBusinessPolicyResult); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } Integer accountingStrategyId = tChargingGun.getAccountingStrategyId(); @@ -725,7 +709,7 @@ String jsonString = JSON.toJSONString(queryEquipBusinessPolicyResult); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } List<PolicyInfo> PolicyInfos = new ArrayList<>(); @@ -742,7 +726,7 @@ String jsonString = JSON.toJSONString(queryEquipBusinessPolicyResult); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } @@ -757,7 +741,7 @@ BaseResult baseResult = requestCheck(true, baseRequest, request); if(0 != baseResult.getRet()){ baseResult.setData(""); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } Operator operator = baseResult.getOperator(); @@ -782,7 +766,7 @@ String jsonString = JSON.toJSONString(result); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } //设备离线 @@ -794,14 +778,14 @@ String jsonString = JSON.toJSONString(result); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } //调用充电接口 AddTripartitePlatformOrder addTripartitePlatformOrder = new AddTripartitePlatformOrder(); addTripartitePlatformOrder.setStartChargeSeq(queryStartCharge.getStartChargeSeq()); addTripartitePlatformOrder.setChargingGunId(tChargingGun.getId()); // addTripartitePlatformOrder.setOperatorId(query.get); addTripartitePlatformOrder.setOperatorId(operator.getOperatorId()); addTripartitePlatformOrder.setPaymentAmount(queryStartCharge.getPaymentAmount()); addTripartitePlatformOrder.setRechargePaymentType(queryStartCharge.getPaymentType()); R order = chargingOrderClient.addTripartitePlatformOrder(addTripartitePlatformOrder); @@ -814,7 +798,7 @@ String jsonString = JSON.toJSONString(result); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } result.setStartChargeSeqStat(1); @@ -824,7 +808,7 @@ String jsonString = JSON.toJSONString(result); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } @@ -838,10 +822,36 @@ public R notificationStartChargeResult(@RequestBody StartChargeResult result){ NotificationStartCharge notificationStartCharge = new NotificationStartCharge(); BeanUtils.copyProperties(result, notificationStartCharge); com.ruoyi.integration.drainage.model.NotificationStartChargeResult notificationStartChargeResult = TCECUtil.notificationStartChargeResult(notificationStartCharge); Operator operator = operatorClient.getOperator(result.getOperatorID()).getData(); com.ruoyi.integration.drainage.model.NotificationStartChargeResult notificationStartChargeResult = TCECUtil.notificationStartChargeResult(operator, notificationStartCharge); //启动重试推送机制 if(null == notificationStartChargeResult || 1 == notificationStartChargeResult.getSuccStat()){ ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); threadPoolExecutor.execute(new Runnable() { //计数器 Integer size = 0; @Override public void run() { NotificationStartChargeResult notificationStartChargeResult1 = TCECUtil.notificationStartChargeResult(operator, notificationStartCharge); //启动重试推送机制 if(null != notificationStartChargeResult1 && 0 == notificationStartChargeResult1.getSuccStat()){ threadPoolExecutor.shutdown(); return; } size++; if(size >= 5){ threadPoolExecutor.shutdown(); return; } //间隔一分钟重试一次 try { Thread.sleep(60000); } catch (InterruptedException e) { throw new RuntimeException(e); } } }); } return R.ok(); } @@ -858,7 +868,7 @@ BaseResult baseResult = requestCheck(true, baseRequest, request); if(0 != baseResult.getRet()){ baseResult.setData(""); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } Operator operator = baseResult.getOperator(); @@ -871,7 +881,7 @@ String jsonString = JSON.toJSONString(queryEquipChargeStatusResult); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } @@ -987,12 +997,37 @@ * @return */ @PostMapping("/notificationEquipChargeStatus") public R notificationEquipChargeStatus(@RequestParam("startChargeSeq") String startChargeSeq){ public R notificationEquipChargeStatus(@RequestParam("startChargeSeq") String startChargeSeq, @RequestParam("operatorId") Integer operatorId){ QueryEquipChargeStatusResult queryEquipChargeStatusResult = buildQueryEquipChargeStatusResult(startChargeSeq); NotificationEquipChargeStatusResult notificationEquipChargeStatusResult = TCECUtil.notificationEquipChargeStatus(queryEquipChargeStatusResult); Operator operator = operatorClient.getOperatorById(operatorId).getData(); NotificationEquipChargeStatusResult notificationEquipChargeStatusResult = TCECUtil.notificationEquipChargeStatus(operator, queryEquipChargeStatusResult); //启动重试推送机制 if(null == notificationEquipChargeStatusResult || 1 == notificationEquipChargeStatusResult.getSuccStat()){ ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); threadPoolExecutor.execute(new Runnable() { //计数器 Integer size = 0; @Override public void run() { NotificationEquipChargeStatusResult notificationEquipChargeStatusResult1 = TCECUtil.notificationEquipChargeStatus(operator, queryEquipChargeStatusResult); //启动重试推送机制 if(null != notificationEquipChargeStatusResult1 && 0 == notificationEquipChargeStatusResult1.getSuccStat()){ threadPoolExecutor.shutdown(); return; } size++; if(size >= 5){ threadPoolExecutor.shutdown(); return; } //间隔一分钟重试一次 try { Thread.sleep(60000); } catch (InterruptedException e) { throw new RuntimeException(e); } } }); } return R.ok(); } @@ -1008,7 +1043,7 @@ BaseResult baseResult = requestCheck(true, baseRequest, request); if(0 != baseResult.getRet()){ baseResult.setData(""); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } Operator operator = baseResult.getOperator(); @@ -1030,14 +1065,14 @@ String jsonString = JSON.toJSONString(queryStopChargeResult); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } //参数加密 String jsonString = JSON.toJSONString(queryStopChargeResult); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseResult.setData(encrypt); baseResult.setSig(buildSign(baseResult)); baseResult.setSig(TCECUtil.buildSign(baseResult)); return baseResult; } @@ -1050,17 +1085,43 @@ * @return */ @PostMapping("/notificationStopChargeResult") public R notificationStopChargeResult(@RequestParam("startChargeSeq") String startChargeSeq, @RequestParam("connectorID") String connectorID){ public R notificationStopChargeResult(@RequestParam("startChargeSeq") String startChargeSeq, @RequestParam("connectorID") String connectorID, @RequestParam("operatorId") Integer operatorId){ Operator operator = operatorClient.getOperatorById(operatorId).getData(); NotificationStopChargeResult info = new NotificationStopChargeResult(); info.setStartChargeSeq(startChargeSeq); info.setStartChargeSeqStat(4); info.setConnectorID(connectorID); info.setSuccStat(0); info.setFailReason(0); NotificationStopCharge notificationStopCharge = TCECUtil.notificationStopChargeResult(info); NotificationStopCharge notificationStopCharge = TCECUtil.notificationStopChargeResult(operator, info); //启动重试推送机制 if(null == notificationStopCharge || 1 == notificationStopCharge.getSuccStat()){ ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); threadPoolExecutor.execute(new Runnable() { //计数器 Integer size = 0; @Override public void run() { NotificationStopCharge notificationStopCharge1 = TCECUtil.notificationStopChargeResult(operator, info); //启动重试推送机制 if(null != notificationStopCharge1 && 0 == notificationStopCharge1.getSuccStat()){ threadPoolExecutor.shutdown(); return; } size++; if(size >= 5){ threadPoolExecutor.shutdown(); return; } //间隔一分钟重试一次 try { Thread.sleep(60000); } catch (InterruptedException e) { throw new RuntimeException(e); } } }); } return R.ok(); } @@ -1072,12 +1133,37 @@ * @return */ @PostMapping("/notificationChargeOrderInfo") public R notificationChargeOrderInfo(@RequestParam("startChargeSeq") String startChargeSeq){ public R notificationChargeOrderInfo(@RequestParam("startChargeSeq") String startChargeSeq, @RequestParam("operatorId") Integer operatorId){ NotificationChargeOrderInfo info = buildNotificationChargeOrderInfo(startChargeSeq); NotificationChargeOrderInfoResult notificationChargeOrderInfoResult = TCECUtil.notificationChargeOrderInfo(info); Operator operator = operatorClient.getOperatorById(operatorId).getData(); NotificationChargeOrderInfoResult notificationChargeOrderInfoResult = TCECUtil.notificationChargeOrderInfo(operator, info); //启动重试推送机制 if(null == notificationChargeOrderInfoResult || 1 == notificationChargeOrderInfoResult.getConfirmResult()){ ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>()); threadPoolExecutor.execute(new Runnable() { //计数器 Integer size = 0; @Override public void run() { NotificationChargeOrderInfoResult notificationChargeOrderInfoResult1 = TCECUtil.notificationChargeOrderInfo(operator, info); //启动重试推送机制 if(null != notificationChargeOrderInfoResult1 && 0 == notificationChargeOrderInfoResult1.getConfirmResult()){ threadPoolExecutor.shutdown(); return; } size++; if(size >= 5){ threadPoolExecutor.shutdown(); return; } //间隔一分钟重试一次 try { Thread.sleep(60000); } catch (InterruptedException e) { throw new RuntimeException(e); } } }); } return R.ok(); } ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/TCECUtil.java
@@ -3,9 +3,14 @@ import cn.hutool.http.*; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.core.utils.SpringUtils; import com.ruoyi.integration.drainage.model.*; import com.ruoyi.integration.drainage.model.enu.InterfaceUrlEnum; import com.ruoyi.other.api.domain.Operator; import com.ruoyi.other.api.feignClient.OperatorClient; import lombok.extern.slf4j.Slf4j; import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneOffset; import java.time.format.DateTimeFormatter; @@ -23,18 +28,8 @@ * 运营商标识 */ private static final String OperatorID = ""; /** * 运营商秘钥 */ private static final String OperatorSecret = ""; /** * tokne */ private static String token = ""; /** * token过期时间,秒 */ private static Long TokenAvailableTime = 0L; private static OperatorClient operatorClient = SpringUtils.getBean(OperatorClient.class); private static Map<Long, Integer> map = new HashMap<>(); @@ -42,26 +37,31 @@ /** * 获取token */ public static void queryToken(){ public static String queryToken(Operator operator){ HttpRequest post = HttpUtil.createPost(""); post.contentType("application/json;charset=utf-8"); JSONObject body = new JSONObject(); body.put("OperatorID", OperatorID); body.put("OperatorSecret", OperatorSecret); body.put("OperatorSecret", operator.getOurOperatorSecret()); post.body(body.toJSONString()); HttpResponse execute = post.execute(); if(200 != execute.getStatus()){ log.error("获取token失败:" + execute.body()); return; log.error("获取三方token失败:" + execute.body()); return null; } JSONObject jsonObject = JSON.parseObject(execute.body()); Integer succStat = jsonObject.getInteger("SuccStat"); if(0 != succStat){ log.error("获取token失败:" + jsonObject.getString("FailReason")); return; log.error("获取三方token失败:" + jsonObject.getString("FailReason")); return null; } token = jsonObject.getString("AccessToken"); TokenAvailableTime = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC) + jsonObject.getLong("TokenAvailableTime"); String token = jsonObject.getString("AccessToken"); Long tokenAvailableTime = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC) + jsonObject.getLong("TokenAvailableTime"); LocalDateTime localDateTime = Instant.ofEpochSecond(tokenAvailableTime).atOffset(ZoneOffset.UTC).toLocalDateTime(); operator.setAccessToken(token); operator.setTokenAvailableTime(localDateTime); operatorClient.editOperator(operator); return token; } @@ -69,12 +69,12 @@ * 获取token * @return */ public static String getToken(){ long second = LocalDateTime.now().toEpochSecond(ZoneOffset.UTC); if(second >= TokenAvailableTime){ queryToken(); public static String getToken(Operator operator){ if(null != operator.getTokenAvailableTime() && operator.getTokenAvailableTime().isBefore(LocalDateTime.now())){ return operator.getAccessToken(); }else{ return queryToken(operator); } return token; } @@ -83,12 +83,12 @@ * 设备状态变化推送 * @param info */ public static NotificationStationStatusResult notificationStationStatus(ConnectorStatusInfo info) { HttpRequest post = HttpUtil.createPost(""); buildBody(post, info); public static NotificationStationStatusResult notificationStationStatus(Operator operator, ConnectorStatusInfo info) { HttpRequest post = HttpUtil.createPost(operator.getTestUrl() + InterfaceUrlEnum.NOTIFICATION_STATION_STATUS.getUrl()); buildBody(post, info, operator); HttpResponse execute = post.execute(); if(200 != execute.getStatus()){ log.error("设备状态变化推送失败:" + execute.body()); log.error("推送三方设备状态变化失败:" + execute.body()); return null; } return JSON.parseObject(execute.body(), NotificationStationStatusResult.class); @@ -100,18 +100,18 @@ * @param info * @return */ public static NotificationStartChargeResult notificationStartChargeResult(NotificationStartCharge info){ HttpRequest post = HttpUtil.createPost(""); buildBody(post, info); public static NotificationStartChargeResult notificationStartChargeResult(Operator operator, NotificationStartCharge info){ HttpRequest post = HttpUtil.createPost(operator.getTestUrl() + InterfaceUrlEnum.NOTIFICATION_START_CHARGE_RESULT.getUrl()); buildBody(post, info, operator); HttpResponse execute = post.execute(); if(200 != execute.getStatus()){ log.error("启动充电结果推送失败:" + execute.body()); log.error("推送三方启动充电结果失败:" + execute.body()); return null; } JSONObject jsonObject = JSON.parseObject(execute.body()); Integer ret = jsonObject.getInteger("Ret"); if(0 != ret){ log.error("启动充电结果推送失败:" + execute.body()); log.error("推送三方启动充电结果失败:" + execute.body()); return null; } return jsonObject.getObject("Data", NotificationStartChargeResult.class); @@ -128,18 +128,18 @@ * @param info * @return */ public static NotificationEquipChargeStatusResult notificationEquipChargeStatus(QueryEquipChargeStatusResult info){ HttpRequest post = HttpUtil.createPost(""); buildBody(post, info); public static NotificationEquipChargeStatusResult notificationEquipChargeStatus(Operator operator, QueryEquipChargeStatusResult info){ HttpRequest post = HttpUtil.createPost(operator.getTestUrl() + InterfaceUrlEnum.NOTIFICATION_EQUIP_CHARGE_STATUS.getUrl()); buildBody(post, info, operator); HttpResponse execute = post.execute(); if(200 != execute.getStatus()){ log.error("推送充电状态失败:" + execute.body()); log.error("推送三方充电状态失败:" + execute.body()); return null; } JSONObject jsonObject = JSON.parseObject(execute.body()); Integer ret = jsonObject.getInteger("Ret"); if(0 != ret){ log.error("推送充电状态失败:" + execute.body()); log.error("推送三方充电状态失败:" + execute.body()); return null; } return jsonObject.getObject("Data", NotificationEquipChargeStatusResult.class); @@ -151,18 +151,18 @@ * @param info * @return */ public static NotificationStopCharge notificationStopChargeResult(NotificationStopChargeResult info){ HttpRequest post = HttpUtil.createPost(""); buildBody(post, info); public static NotificationStopCharge notificationStopChargeResult(Operator operator, NotificationStopChargeResult info){ HttpRequest post = HttpUtil.createPost(operator.getTestUrl() + InterfaceUrlEnum.NOTIFICATION_STOP_CHARGE_RESULT.getUrl()); buildBody(post, info, operator); HttpResponse execute = post.execute(); if(200 != execute.getStatus()){ log.error("推送停止充电结果失败:" + execute.body()); log.error("推送三方停止充电结果失败:" + execute.body()); return null; } JSONObject jsonObject = JSON.parseObject(execute.body()); Integer ret = jsonObject.getInteger("Ret"); if(0 != ret){ log.error("推送停止充电结果失败:" + execute.body()); log.error("推送三方停止充电结果失败:" + execute.body()); return null; } return jsonObject.getObject("Data", NotificationStopCharge.class); @@ -176,18 +176,18 @@ * @param info * @return */ public static NotificationChargeOrderInfoResult notificationChargeOrderInfo(NotificationChargeOrderInfo info){ HttpRequest post = HttpUtil.createPost(""); buildBody(post, info); public static NotificationChargeOrderInfoResult notificationChargeOrderInfo(Operator operator, NotificationChargeOrderInfo info){ HttpRequest post = HttpUtil.createPost(operator.getTestUrl() + InterfaceUrlEnum.NOTIFICATION_CHARGE_ORDER_INFO.getUrl()); buildBody(post, info, operator); HttpResponse execute = post.execute(); if(200 != execute.getStatus()){ log.error("推送充电订单信息失败:" + execute.body()); log.error("推送三方充电订单信息失败:" + execute.body()); return null; } JSONObject jsonObject = JSON.parseObject(execute.body()); Integer ret = jsonObject.getInteger("Ret"); if(0 != ret){ log.error("推送充电订单信息失败:" + execute.body()); log.error("推送三方充电订单信息失败:" + execute.body()); return null; } return jsonObject.getObject("Data", NotificationChargeOrderInfoResult.class); @@ -199,30 +199,59 @@ * @param post * @param o */ public static void buildBody(HttpRequest post, Object o){ Long key = Long.valueOf(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); Integer integer = map.get(key); public static void buildBody(HttpRequest post, Object o, Operator operator){ Long timeStamp = Long.valueOf(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))); Integer integer = map.get(timeStamp); if(null == integer){ integer = 1; }else{ integer++; } map.put(key, integer); map.put(timeStamp, integer); post.contentType("application/json;charset=utf-8"); post.header("Authorization", "Bearer " + getToken()); JSONObject body = new JSONObject(); body.put("OperatorID", OperatorID); body.put("Data", AESUtil.encrypt(JSON.toJSONString(o))); body.put("TimeStamp", key); body.put("Seq", String.format("%04d", integer)); body.put("Sig", ""); post.body(body.toJSONString()); post.header("Authorization", "Bearer " + getToken(operator)); BaseRequest baseRequest = new BaseRequest(); baseRequest.setOperatorID(OperatorID); baseRequest.setTimeStamp(timeStamp); baseRequest.setSeq(String.format("%04d", integer)); String jsonString = JSON.toJSONString(o); String encrypt = AESUtil.encrypt(jsonString, operator.getDataSecret(), operator.getDataSecretIv()); baseRequest.setData(encrypt); baseRequest.setOperator(operator); baseRequest.setSig(buildSign(baseRequest)); post.body(JSON.toJSONString(baseRequest)); //清空小于当前时间的map中的无效数据 for (Long k : map.keySet()) { if(k <= (key - 10)){ if(k <= (timeStamp - 10)){ map.remove(k); } } } /** * 构建签名字符串 * @param model * @return */ public static String buildSign(BaseModel model){ Operator operator = model.getOperator(); //签名秘钥SigSecret String key = operator.getSigSecret(); String sign = ""; switch (operator.getName()){ case "XinDianTu": //进行字符串拼接、计算 String m = new StringBuilder(model.getOperatorID()).append(model.getData()).append(model.getTimeStamp()).append(model.getSeq()).toString(); byte[] hmacMd5 = SignUtil.getHMacMD5Bytes(key.getBytes(), m.getBytes()); // 打印计算得到的签名Sig sign = SignUtil.bytesToHexString(hmacMd5); break; case "KuaiDian": sign = SignUtil.hmacSign(model.getData(), key); break; } return sign; } } ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/model/NotificationStopCharge.java
File was renamed from ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/NotificationStopCharge.java @@ -1,4 +1,4 @@ package com.ruoyi.integration.drainage; package com.ruoyi.integration.drainage.model; import lombok.Data; ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/model/QueryStationStats.java
@@ -12,11 +12,6 @@ @Data public class QueryStationStats { /** * 运营商ID */ @NotNull private String OperatorID; /** * 充电站ID */ @NotNull ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/model/QueryStopCharge.java
File was renamed from ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/QueryStopCharge.java @@ -1,4 +1,4 @@ package com.ruoyi.integration.drainage; package com.ruoyi.integration.drainage.model; import lombok.Data; ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/drainage/model/enu/InterfaceUrlEnum.java
@@ -6,10 +6,12 @@ * @Date 2025/1/21 14:38 */ public enum InterfaceUrlEnum { QUERY_STATIONS_INFO("query_stations_info", "查询充电站信息"), NOTIFICATION_STATION_STATUS("notification_stationStatus", "设备状态变化推送"), QUERY_STATION_STATUS("query_station_status", "设备接口状态查询"), NOTIFICATION_STATION_STATUS("/notification_station_status", "设备状态变化推送"), NOTIFICATION_START_CHARGE_RESULT("/notification_start_charge_result", "推送启动充电结果"), NOTIFICATION_EQUIP_CHARGE_STATUS("/notification_equip_charge_status", "推送充电状态"), NOTIFICATION_STOP_CHARGE_RESULT("/notification_stop_charge_result", "推送停止充电结果"), NOTIFICATION_CHARGE_ORDER_INFO("/notification_charge_order_info", "推送充电订单信息"), CHECK_CHARGE_ORDERS("/check_charge_orders", "推送订单对账结果信息"), ; private String url; ruoyi-service/ruoyi-integration/src/main/java/com/ruoyi/integration/rocket/listener/UploadRealTimeMonitoringDataMessageListener.java
@@ -7,6 +7,7 @@ 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.feignClient.TCECClient; import com.ruoyi.integration.api.model.Online; import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData; import com.ruoyi.integration.mongodb.service.UploadRealTimeMonitoringDataService; @@ -51,6 +52,9 @@ private ChargingGunClient chargingGunClient; @Resource private FaultMessageClient faultMessageClient; @Resource private TCECClient tcecClient; @Override @@ -124,6 +128,8 @@ } } chargingGunClient.updateChargingGunById(chargingGun); //推送状态给三方平台 tcecClient.pushChargingGunStatus(chargingGun.getId(), chargingGun.getStatus()); } } ruoyi-service/ruoyi-order/src/main/java/com/ruoyi/order/service/impl/TChargingOrderServiceImpl.java
@@ -32,6 +32,7 @@ import com.ruoyi.integration.api.feignClient.*; import com.ruoyi.integration.api.model.*; import com.ruoyi.integration.api.vo.GetPlatformStopChargingReply; import com.ruoyi.integration.api.vo.StartChargeResult; import com.ruoyi.order.api.dto.SettlementConfirmAdd; import com.ruoyi.order.api.feignClient.AccountingStrategyDetailOrderClient; import com.ruoyi.order.api.feignClient.AccountingStrategyOrderClient; @@ -141,7 +142,7 @@ private UploadRealTimeMonitoringDataClient uploadRealTimeMonitoringDataClient; @Resource private ChargingHandshakeClient chargingHandshakeClient; private TCECClient tcecClient; @Resource private SendMessageClient sendMessageClient; @@ -747,6 +748,10 @@ } this.updateById(order); redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS); //推送三方平台订单状态 if(2 == chargingOrder.getOrderSource()){ tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); } return true; }else{ Integer counter = boot_failed_map.get(code); @@ -777,6 +782,10 @@ order.setEndMode(0); this.updateById(order); redisService.setCacheObject(key, preChargeCheck1, 24L, TimeUnit.HOURS); //推送三方平台订单状态 if(2 == chargingOrder.getOrderSource()){ tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); } return true; } } @@ -836,9 +845,24 @@ TChargingGun chargingGun = chargingGunClient.getChargingGunById(order.getChargingGunId()).getData(); chargingGun.setStatus(4); chargingGunClient.updateChargingGunById(chargingGun); //推送状态给三方平台 tcecClient.pushChargingGunStatus(chargingGun.getId(), chargingGun.getStatus()); } redisService.setCacheObject("AQJC_" + order.getChargingGunId(), preChargeCheck1, 24L, TimeUnit.HOURS); this.updateById(order); //推送三方平台启动充电结果 if(2 == order.getOrderSource()){ StartChargeResult result = new StartChargeResult(); result.setStartChargeSeq(order.getStartChargeSeq()); result.setStartChargeSeqStat(3 == order.getStatus() ? 2 : 4); result.setConnectorID(order.getChargingGunId().toString()); result.setStartTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); Operator operator = operatorClient.getOperatorById(order.getOperatorId()).getData(); result.setOperatorID(operator.getOperatorId()); tcecClient.notificationStartChargeResult(result); tcecClient.notificationEquipChargeStatus(order.getStartChargeSeq(), order.getOperatorId()); } } /** @@ -1003,7 +1027,6 @@ chargingOrder.setStatus(4); chargingOrder.setEndMode(1); this.updateById(chargingOrder); String code1 = order.getCode(); TChargingGun chargingGun = chargingGunClient.getChargingGunById(order.getChargingGunId()).getData(); //异步线程处理停机 @@ -1018,6 +1041,11 @@ log.info(code1 + ":-------------------远程停止充电请求-------------------"); log.info(platformStopCharging.toString()); }); //推送三方平台 if(2 == order.getOrderSource()){ tcecClient.notificationEquipChargeStatus(order.getStartChargeSeq(), order.getOperatorId()); } return AjaxResult.success(); } @@ -2256,6 +2284,14 @@ this.updateById(order); chargingOrder = this.getById(order.getId()); //推送三方平台 if(2 == chargingOrder.getOrderSource()){ tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); tcecClient.notificationStopChargeResult(chargingOrder.getStartChargeSeq(), chargingOrder.getChargingGunId().toString(), chargingOrder.getOperatorId()); tcecClient.notificationChargeOrderInfo(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); } //开始将优惠券优惠的金额添加到明细中 BigDecimal couponDiscountAmount = order.getCouponDiscountAmount(); if(null != couponDiscountAmount && couponDiscountAmount.compareTo(BigDecimal.ZERO) > 0){ @@ -2277,6 +2313,8 @@ chargingGun.setStatus(2); chargingGun.setChargingPower(BigDecimal.ZERO); chargingGunClient.updateChargingGunById(chargingGun); //推送状态给三方平台 tcecClient.pushChargingGunStatus(chargingGun.getId(), chargingGun.getStatus()); //添加积分 TIntegralRule integralRule = integralRuleClient.getSet().getData(); @@ -4074,6 +4112,9 @@ scheduler.shutdown(); } }, 5, 1, TimeUnit.SECONDS); //推送三方平台订单状态 tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); return R.ok(); } @@ -4101,6 +4142,8 @@ chargingOrder.setEndMode(1); this.updateById(chargingOrder); tcecClient.notificationEquipChargeStatus(order.getStartChargeSeq(), order.getOperatorId()); String code1 = order.getCode(); TChargingGun chargingGun = chargingGunClient.getChargingGunById(order.getChargingGunId()).getData(); //异步线程处理停机 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/OperatorController.java
@@ -4,12 +4,10 @@ import com.ruoyi.common.core.domain.R; import com.ruoyi.other.api.domain.Operator; import com.ruoyi.other.service.OperatorService; 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 org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; /** * @author zhibing.pu @@ -23,6 +21,21 @@ private OperatorService operatorService; /** * 获取运营商数据 * @param id * @return */ @PostMapping("/getOperatorById") public R<Operator> getOperatorById(@RequestParam("id") Integer id){ Operator operator = operatorService.getById(id); return R.ok(operator); } /** * 获取运营商数据 * @param operatorId @@ -33,4 +46,28 @@ Operator operator = operatorService.getOne(new LambdaQueryWrapper<Operator>().eq(Operator::getOperatorId, operatorId)); return R.ok(operator); } /** * 获取所有运营商 * @return */ @PostMapping("/getAllOperator") public R<List<Operator>> getAllOperator(){ List<Operator> list = operatorService.list(); return R.ok(list); } /** * 更新运营商数据 * @return */ @PostMapping("/editOperator") public R editOperator(@RequestBody Operator operator){ operatorService.updateById(operator); return R.ok(); } }