打印日志

This commit is contained in:
Guoqs
2024-09-09 21:45:49 +08:00
parent 4500fd649d
commit d77aeaec35
2 changed files with 77 additions and 3 deletions

View File

@@ -21,6 +21,7 @@ import com.jsowell.web.controller.pile.PileConnectorInfoController;
import com.jsowell.thirdparty.common.CommonService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
@@ -259,7 +260,36 @@ public class PileController extends BaseController {
return response;
}
/**
* 预约充电接口
*/
@PostMapping("/selectConnectorInfoListNo")
public RestApiResponse<?> selectConnectorInfoListNo(@RequestBody QueryConnectorListDTO dto) {
RestApiResponse<?> response = null;
try {
Map<String, Object> map = Maps.newHashMap();
StopWatch stopWatch = new StopWatch("selectConnectorInfoListNo");
stopWatch.start("查询枪口列表");
List<ConnectorInfoVO> connectorInfoVOS = pileConnectorInfoService.selectConnectorInfoList(dto.getPileSn());
stopWatch.stop();
stopWatch.start("查询计费模板");
List<BillingPriceVO> billingPriceVOS = pileBillingTemplateService.queryBillingPrice(dto.getStationId());
stopWatch.stop();
stopWatch.start("查询运营商信息");
MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(dto.getMerchantId());
stopWatch.stop();
map.put("connectorInfoList", connectorInfoVOS);
map.put("billingPriceList", billingPriceVOS);
map.put("merchantInfoVO", merchantInfoVO);
response = new RestApiResponse<>(map);
logger.info("查询充电枪口详情耗时:{}", stopWatch);
}catch (Exception e) {
logger.error("查询充电枪口详情 error", e);
response = new RestApiResponse<>(e);
}
logger.info("查询充电枪口详情 response:{}", response);
return response;
}
}

View File

@@ -186,6 +186,50 @@ public class PileService {
throw new BusinessException(ReturnCodeEnum.CODE_STATION_IS_NOT_OPEN);
}
List<ConnectorInfoVO> connectorInfoList = pileConnectorInfoService.selectConnectorInfoList(pileSn);
List<BillingPriceVO> billingPriceVOS = pileBillingTemplateService.queryBillingPrice(pileInfoVO.getStationId());
MerchantInfoVO merchantInfoVO = pileMerchantInfoService.getMerchantInfoVO(pileInfoVO.getMerchantId());
vo = AppletPileDetailVO.builder()
.pileInfo(pileInfoVO)
.connectorInfoList(connectorInfoList)
.merchantInfo(merchantInfoVO)
.stationInfo(stationInfo)
.billingPriceList(billingPriceVOS)
.build();
return vo;
}
public AppletPileDetailVO getPileDetailByPileSnOld(String param) throws Exception {
AppletPileDetailVO vo = null;
log.info("查询充电枪口详情-getPileDetailByPileSn, param:{}", param);
if (StringUtils.isBlank(param)) {
throw new BusinessException(ReturnCodeEnum.CODE_PARAM_NOT_NULL_ERROR);
}
String pileSn = YKCUtils.getPileSn(param);
log.info("查询充电枪口详情-getPileDetailByPileSn, pileSn:{}", pileSn);
// 查询充电桩信息
PileInfoVO pileInfoVO = pileBasicInfoService.selectPileInfoBySn(pileSn);
log.info("查询充电枪口详情-pileInfoVO:{}", JSON.toJSONString(pileInfoVO));
if (pileInfoVO == null) {
return null;
}
// 判断桩是否在线
boolean onLineStatus = pileConnectorInfoService.checkPileOffLine(pileInfoVO.getPileSn());
log.info("查询充电枪口详情-判断桩是否在线:{}, onLineStatus:{}", pileInfoVO.getPileSn(), onLineStatus);
if (onLineStatus) {
// true为离线
throw new BusinessException(ReturnCodeEnum.CODE_PILE_CONNECTOR_STATUS_OFF_LINE);
}
// 查询站点信息
PileStationVO stationInfo = pileStationInfoService.getStationInfo(pileInfoVO.getStationId());
log.info("查询充电枪口详情-getStationInfo:{}, onLineStatus:{}", pileInfoVO.getStationId(), JSON.toJSONString(stationInfo));
if (stationInfo == null || StringUtils.equals(stationInfo.getOpenFlag(), Constants.ZERO)) {
throw new BusinessException(ReturnCodeEnum.CODE_STATION_IS_NOT_OPEN);
}
// 查询充电桩下枪口信息
CompletableFuture<List<ConnectorInfoVO>> connectorInfoListFuture = CompletableFuture.supplyAsync(() -> pileConnectorInfoService.selectConnectorInfoList(pileSn));
log.info("查询充电枪口详情-supplyAsync-selectConnectorInfoList:{}", connectorInfoListFuture);