打印日志

This commit is contained in:
Guoqs
2024-09-09 19:25:26 +08:00
parent 1d0d9cab1e
commit 484834dced
2 changed files with 15 additions and 21 deletions

View File

@@ -111,7 +111,7 @@ public class JumpController extends BaseController {
public RestApiResponse<?> getConnectorDetail(HttpServletRequest request, @PathVariable("pileConnectorCode") String pileConnectorCode) { public RestApiResponse<?> getConnectorDetail(HttpServletRequest request, @PathVariable("pileConnectorCode") String pileConnectorCode) {
// logger.info("app-xcx-h5查询充电枪口详情 param:{}", pileConnectorCode); // logger.info("app-xcx-h5查询充电枪口详情 param:{}", pileConnectorCode);
String requestSource = UserAgentUtils.determineRequestSource(request); String requestSource = UserAgentUtils.determineRequestSource(request);
logger.debug("查询充电枪口详情, pileConnectorCode:{}, User-Agent:{}, 请求来源:{}", pileConnectorCode, request.getHeader("user-agent"), requestSource); logger.info("查询充电枪口详情, pileConnectorCode:{}, User-Agent:{}, 请求来源:{}", pileConnectorCode, request.getHeader("user-agent"), requestSource);
RestApiResponse<?> response = null; RestApiResponse<?> response = null;
// 截取桩号 // 截取桩号
// String pileSn = StringUtils.substring(pileConnectorCode, 0, 14); // String pileSn = StringUtils.substring(pileConnectorCode, 0, 14);
@@ -138,7 +138,7 @@ public class JumpController extends BaseController {
} }
response = new RestApiResponse<>(vo); response = new RestApiResponse<>(vo);
} catch (BusinessException e) { } catch (BusinessException e) {
logger.warn("app-xcx-h5查询充电枪口详情 warn param:{}", pileConnectorCode, e); logger.error("app-xcx-h5查询充电枪口详情 warn param:{}", pileConnectorCode, e);
response = new RestApiResponse<>(e.getCode(), e.getMessage()); response = new RestApiResponse<>(e.getCode(), e.getMessage());
} catch (Exception e) { } catch (Exception e) {
logger.error("app-xcx-h5查询充电枪口详情 error param:{}", pileConnectorCode, e); logger.error("app-xcx-h5查询充电枪口详情 error param:{}", pileConnectorCode, e);

View File

@@ -1,5 +1,6 @@
package com.jsowell.service; package com.jsowell.service;
import com.alibaba.fastjson2.JSON;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
@@ -23,8 +24,11 @@ import com.jsowell.pile.vo.web.PileDetailVO;
import com.jsowell.pile.vo.web.PileStationVO; import com.jsowell.pile.vo.web.PileStationVO;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.RandomStringUtils; import org.apache.commons.lang3.RandomStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StopWatch;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -33,8 +37,10 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Service @Service
public class PileService { public class PileService {
private final Logger log = LoggerFactory.getLogger(PileService.class);
@Autowired @Autowired
private TransactionService pileTransactionService; private TransactionService pileTransactionService;
@@ -151,28 +157,13 @@ public class PileService {
/** /**
* 前端扫码跳转接口 * 前端扫码跳转接口
*/ */
public AppletPileDetailVO getPileDetailByPileSn(String param) throws ExecutionException, InterruptedException { public AppletPileDetailVO getPileDetailByPileSn(String param) throws Exception{
StopWatch stopWatch = new StopWatch("前端扫码跳转接口");
stopWatch.start("getPileDetailByPileSn: " + param);
if (StringUtils.isBlank(param)) { if (StringUtils.isBlank(param)) {
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR); throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
} }
String pileSn = YKCUtils.getPileSn(param); String pileSn = YKCUtils.getPileSn(param);
// param长度大于10是汽车桩, 否则是电单车桩
// if (param.length() > 10) {
// // 汽车桩, 桩编号14位, 枪口号2位
// if (param.length() == 16) {
// pileSn = StringUtils.substring(param, 0, param.length() - 2);
// } else {
// pileSn = param;
// }
// } else {
// // 电单车桩, 桩编号8位, 枪口号2位
// if (param.length() == 10) {
// pileSn = StringUtils.substring(param, 0, param.length() - 2);
// } else {
// pileSn = param;
// }
// }
// 查询充电桩信息 // 查询充电桩信息
PileInfoVO pileInfoVO = pileBasicInfoService.selectPileInfoBySn(pileSn); PileInfoVO pileInfoVO = pileBasicInfoService.selectPileInfoBySn(pileSn);
if (pileInfoVO == null) { if (pileInfoVO == null) {
@@ -218,6 +209,7 @@ public class PileService {
.stationInfo(stationInfo) .stationInfo(stationInfo)
.billingPriceList(billingPriceVOS) .billingPriceList(billingPriceVOS)
.build(); .build();
stopWatch.stop();
return vo; return vo;
} }
@@ -229,8 +221,9 @@ public class PileService {
* @throws ExecutionException * @throws ExecutionException
* @throws InterruptedException * @throws InterruptedException
*/ */
public AppletPileDetailVO getConnectorDetail(String pileConnectorCode) throws ExecutionException, InterruptedException { public AppletPileDetailVO getConnectorDetail(String pileConnectorCode) throws Exception {
PileConnectorDetailVO pileConnectorDetailVO = queryPileConnectorDetail(pileConnectorCode); PileConnectorDetailVO pileConnectorDetailVO = queryPileConnectorDetail(pileConnectorCode);
log.info("查询枪口信息, pileConnectorCode:{}, pileConnectorDetailVO:{}", pileConnectorCode, JSON.toJSONString(pileConnectorDetailVO));
if (pileConnectorDetailVO == null) { if (pileConnectorDetailVO == null) {
return null; return null;
} }
@@ -243,6 +236,7 @@ public class PileService {
} }
String pileSn = pileConnectorDetailVO.getPileSn(); String pileSn = pileConnectorDetailVO.getPileSn();
AppletPileDetailVO resultVO = getPileDetailByPileSn(pileSn); AppletPileDetailVO resultVO = getPileDetailByPileSn(pileSn);
log.info("getConnectorDetail, pileSn:{}, pileConnectorDetailVO:{}, resultVO:{}", pileSn, JSON.toJSONString(pileConnectorDetailVO), JSON.toJSONString(resultVO));
List<ConnectorInfoVO> connectorInfoList = resultVO.getConnectorInfoList(); List<ConnectorInfoVO> connectorInfoList = resultVO.getConnectorInfoList();
if (connectorInfoList.size() > 1 && !StringUtils.equals(pileConnectorDetailVO.getChargePortType(), "3")) { if (connectorInfoList.size() > 1 && !StringUtils.equals(pileConnectorDetailVO.getChargePortType(), "3")) {
List<ConnectorInfoVO> list = Lists.newArrayList(); List<ConnectorInfoVO> list = Lists.newArrayList();