This commit is contained in:
Lemon
2024-09-09 21:08:21 +08:00
parent 4ce1837637
commit 97fab9cc2e
2 changed files with 25 additions and 5 deletions

View File

@@ -13,6 +13,7 @@ import com.jsowell.pile.dto.QueryStationDTO;
import com.jsowell.pile.dto.RemoteGroundLockDTO;
import com.jsowell.pile.service.*;
import com.jsowell.pile.vo.base.ConnectorInfoVO;
import com.jsowell.pile.vo.base.MerchantInfoVO;
import com.jsowell.pile.vo.uniapp.customer.BillingPriceVO;
import com.jsowell.pile.vo.web.ThirdPartySnRelationVO;
import com.jsowell.web.controller.pile.PileConnectorInfoController;
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
/**
* 充电桩相关接口
@@ -219,12 +221,28 @@ public class PileController extends BaseController {
@GetMapping("/selectConnectorInfoList/{pileSn}")
public RestApiResponse<?> selectConnectorInfoList(@PathVariable("pileSn") String pileSn) {
@PostMapping("/selectConnectorInfoList")
public RestApiResponse<?> selectConnectorInfoList(@RequestBody QueryConnectorListDTO dto) {
RestApiResponse<?> response = null;
try {
List<ConnectorInfoVO> connectorInfoVOS = pileConnectorInfoService.selectConnectorInfoList(pileSn);
response = new RestApiResponse<>(connectorInfoVOS);
// List<ConnectorInfoVO> connectorInfoVOS = pileConnectorInfoService.selectConnectorInfoList(pileSn);
CompletableFuture<List<ConnectorInfoVO>> connectorInfoListFuture = CompletableFuture.supplyAsync(() -> pileConnectorInfoService.selectConnectorInfoList(dto.getPileSn()));
logger.info("查询充电枪口详情-supplyAsync-selectConnectorInfoList:{}", connectorInfoListFuture);
// 查计费模板信息
CompletableFuture<List<BillingPriceVO>> billingPriceFuture = CompletableFuture.supplyAsync(() -> pileBillingTemplateService.queryBillingPrice(dto.getStationId()));
logger.info("查询充电枪口详情-supplyAsync-queryBillingPrice:{}", billingPriceFuture);
// 查询运营商信息
CompletableFuture<MerchantInfoVO> merchantInfoVOFuture = CompletableFuture.supplyAsync(() -> pileMerchantInfoService.getMerchantInfoVO(dto.getMerchantId()));
logger.info("查询充电枪口详情-supplyAsync-getMerchantInfoVO:{}", merchantInfoVOFuture);
CompletableFuture<Void> all = CompletableFuture.allOf(connectorInfoListFuture, merchantInfoVOFuture, billingPriceFuture);
// .join()和.get()都会阻塞并获取线程的执行情况
// .join()会抛出未经检查的异常,不会强制开发者处理异常 .get()会抛出检查异常,需要开发者处理
all.join();
all.get();
response = new RestApiResponse<>(connectorInfoListFuture.get());
}catch (Exception e) {
logger.error("查询充电枪口详情 error", e);
response = new RestApiResponse<>(e);