| | |
| | | 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; |
| | |
| | | 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; |
| | | |
| | | /** |
| | |
| | | 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("签名校验失败"); |
| | |
| | | } |
| | | 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; |
| | | } |
| | | |
| | | |
| | |
| | | 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(); |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | 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(); |
| | |
| | | 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<>(); |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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(); |
| | |
| | | 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; |
| | | } |
| | | //设备离线 |
| | |
| | | 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); |
| | |
| | | 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); |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | 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(); |
| | | } |
| | |
| | | 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(); |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | * @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(); |
| | | } |
| | |
| | | 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(); |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | * @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(); |
| | | } |
| | |
| | | * @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(); |
| | | } |