update 电单车

This commit is contained in:
Guoqs
2024-09-30 15:49:55 +08:00
parent ff459818ce
commit a8d7e76d25
3 changed files with 34 additions and 5 deletions

View File

@@ -2,6 +2,7 @@ package com.jsowell.api.uniapp.customer;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.jsowell.common.UserAgentUtils; import com.jsowell.common.UserAgentUtils;
import com.jsowell.common.YouDianUtils;
import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.core.domain.AjaxResult; import com.jsowell.common.core.domain.AjaxResult;
@@ -100,6 +101,11 @@ public class JumpController extends BaseController {
logger.error("修改第三方平台枪口状态 error", e); logger.error("修改第三方平台枪口状态 error", e);
} }
// 如果pileSN长度为8位需要解析一下
if (pileSn.length() == 8) {
pileSn = YouDianUtils.resolvePhysicalId(pileSn);
}
try { try {
// 进入充电桩详情做一下鉴权 // 进入充电桩详情做一下鉴权
String memberId = getMemberIdByAuthorization(request); String memberId = getMemberIdByAuthorization(request);
@@ -113,7 +119,7 @@ public class JumpController extends BaseController {
logger.error("app-xcx-h5查询充电桩详情 error", e); logger.error("app-xcx-h5查询充电桩详情 error", e);
response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR); response = new RestApiResponse<>(ReturnCodeEnum.CODE_GET_PILE_DETAIL_ERROR);
} }
logger.info("app-xcx-h5查询充电桩详情 param:{}, result:{}", pileSn, JSON.toJSONString(response)); logger.info("app-xcx-h5查询充电桩详情withConnectorCode param:{}, result:{}", pileSn, JSON.toJSONString(response));
return response; return response;
} }

View File

@@ -232,11 +232,14 @@ public class PileService {
// 判断桩是否在线 // 判断桩是否在线
boolean onLineStatus = pileConnectorInfoService.checkPileOffLine(pileInfoVO.getPileSn()); boolean onLineStatus = pileConnectorInfoService.checkPileOffLine(pileInfoVO.getPileSn());
log.info("查询充电枪口详情-判断桩是否在线:{}, onLineStatus:{}", pileInfoVO.getPileSn(), onLineStatus); String activeProfile = SpringUtils.getActiveProfile();
log.info("查询充电枪口详情-判断桩是否在线:{}, onLineStatus:{}, activeProfile:{}", pileInfoVO.getPileSn(), onLineStatus, activeProfile);
if ("prd".equals(activeProfile)) {
if (onLineStatus) { if (onLineStatus) {
// true为离线 // true为离线
throw new BusinessException(ReturnCodeEnum.CODE_PILE_CONNECTOR_STATUS_OFF_LINE); throw new BusinessException(ReturnCodeEnum.CODE_PILE_CONNECTOR_STATUS_OFF_LINE);
} }
}
// 查询站点信息 // 查询站点信息
PileStationVO stationInfo = pileStationInfoService.getStationInfo(pileInfoVO.getStationId()); PileStationVO stationInfo = pileStationInfoService.getStationInfo(pileInfoVO.getStationId());

View File

@@ -13,6 +13,26 @@ import java.util.Arrays;
@Slf4j @Slf4j
public class YouDianUtils { public class YouDianUtils {
public static void main(String[] args) {
String s = "1921ed07";
String s1 = resolvePhysicalId(s);
System.out.println(s1);
}
/**
* 解析物理id
* 电单车二维码地址:https://api.jsowellcloud.com/app-xcx-h5/pile/pileDetail/1921ed07/ff
* 1921ed07是前端解析出来的pileSn, 但不是实际的物理ID需要通过识别码和编号计算出物理ID, 解析后为15540505
* @param pileSN
* @return
*/
public static String resolvePhysicalId(String pileSN) {
byte[] bytes = BytesUtil.str2Bcd(pileSN);
int i = convertToPhysicalId(bytes);
return i + "";
}
/** /**
* 将byte数组转换为物理ID * 将byte数组转换为物理ID