mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 11:05:18 +08:00
update 查询枪口状态之前先查询该站点有没有推送第三方平台(华为)
This commit is contained in:
@@ -21,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -143,10 +144,15 @@ public class PileController extends BaseController {
|
||||
public RestApiResponse<?> selectStationConnectorList(HttpServletRequest request, @RequestBody QueryConnectorListDTO dto) {
|
||||
logger.info("查询充电枪口列表 params:{}", JSON.toJSONString(dto));
|
||||
RestApiResponse<?> response = null;
|
||||
try {
|
||||
// 修改对接第三方平台的枪口状态
|
||||
updateThirdPartyConnectorStatus(dto);
|
||||
} catch (Exception e) {
|
||||
logger.error("修改对接第三方平台的枪口状态 error");
|
||||
}
|
||||
|
||||
try {
|
||||
PageResponse pageResponse = pileConnectorInfoService.selectStationConnectorList(dto);
|
||||
List<PileConnectorInfoVO> list = (List<PileConnectorInfoVO>) pageResponse.getList();
|
||||
updateThirdPartyConnectorStatus(list);
|
||||
response = new RestApiResponse<>(pageResponse);
|
||||
} catch (Exception e) {
|
||||
logger.error("查询充电枪口列表异常", e);
|
||||
@@ -186,26 +192,35 @@ public class PileController extends BaseController {
|
||||
|
||||
/**
|
||||
* 修改第三方平台枪口状态
|
||||
* @see com.jsowell.web.controller.pile.PileConnectorInfoController#updateThirdPartyConnectorStatus(com.jsowell.pile.dto.QueryConnectorListDTO)
|
||||
* 两个方法完全相同,如有修改需同步修改
|
||||
*/
|
||||
public void updateThirdPartyConnectorStatus(List<PileConnectorInfoVO> connectorList) {
|
||||
if (CollectionUtils.isEmpty(connectorList)) {
|
||||
private void updateThirdPartyConnectorStatus(QueryConnectorListDTO dto) {
|
||||
if (dto == null) {
|
||||
return;
|
||||
}
|
||||
List<String> stationIdList = connectorList.stream()
|
||||
.map(PileConnectorInfoVO::getStationId)
|
||||
.collect(Collectors.toList());
|
||||
List<Long> pileIds = dto.getPileIds();
|
||||
List<Long> stationIdList = dto.getStationIdList();
|
||||
|
||||
for (String stationId : stationIdList) {
|
||||
String stationIdStr = String.valueOf(stationId);
|
||||
List<ThirdPartySnRelationVO> list = snRelationService.selectSnRelationListByParams(stationIdStr, null);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
for (ThirdPartySnRelationVO vo : list) {
|
||||
String thirdPartyType = vo.getThirdPartyType();
|
||||
// 调用通用查询实时数据接口(需在接口中修改枪口状态)
|
||||
commonService.commonQueryStationStatus(stationIdStr, thirdPartyType);
|
||||
List<ThirdPartySnRelationVO> list = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(pileIds)) {
|
||||
list = snRelationService.selectSnRelationListByParams(null, null, pileIds);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(stationIdList)) {
|
||||
for (Long stationId : stationIdList) {
|
||||
String stationIdStr = String.valueOf(stationId);
|
||||
list = snRelationService.selectSnRelationListByParams(stationIdStr, null, null);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ThirdPartySnRelationVO vo : list) {
|
||||
String thirdPartyType = vo.getThirdPartyType();
|
||||
String stationId = vo.getStationId();
|
||||
// 调用通用查询实时数据接口(需在接口中修改枪口状态)
|
||||
commonService.commonQueryStationStatus(stationId, thirdPartyType);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1336,7 +1336,7 @@ public class OrderService {
|
||||
String pileSn = orderInfo.getPileSn();
|
||||
|
||||
// 根据 stationId 查询 pile_sn_relation 表
|
||||
List<ThirdPartySnRelationVO> snRelations = snRelationService.selectSnRelationListByParams(stationId, pileSn);
|
||||
List<ThirdPartySnRelationVO> snRelations = snRelationService.selectSnRelationListByParams(stationId, pileSn, null);
|
||||
if (CollectionUtils.isEmpty(snRelations)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsowell.web.controller.pile;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.jsowell.api.uniapp.PileController;
|
||||
import com.jsowell.common.annotation.Log;
|
||||
import com.jsowell.common.core.controller.BaseController;
|
||||
import com.jsowell.common.core.page.TableDataInfo;
|
||||
@@ -12,7 +13,9 @@ import com.jsowell.pile.dto.QueryConnectorDTO;
|
||||
import com.jsowell.pile.dto.QueryConnectorListDTO;
|
||||
import com.jsowell.pile.dto.UpdateConnectorParkNoDTO;
|
||||
import com.jsowell.pile.service.IThirdpartySnRelationService;
|
||||
import com.jsowell.pile.service.PileBasicInfoService;
|
||||
import com.jsowell.pile.service.PileConnectorInfoService;
|
||||
import com.jsowell.pile.service.PileStationInfoService;
|
||||
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.web.ThirdPartySnRelationVO;
|
||||
import com.jsowell.thirdparty.common.CommonService;
|
||||
@@ -22,6 +25,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -40,6 +44,12 @@ public class PileConnectorInfoController extends BaseController {
|
||||
@Autowired
|
||||
private IThirdpartySnRelationService snRelationService;
|
||||
|
||||
@Autowired
|
||||
private PileStationInfoService pileStationInfoService;
|
||||
|
||||
@Autowired
|
||||
private PileBasicInfoService pileBasicInfoService;
|
||||
|
||||
@Autowired
|
||||
private CommonService commonService;
|
||||
|
||||
@@ -74,9 +84,13 @@ public class PileConnectorInfoController extends BaseController {
|
||||
@PostMapping("/getConnectorInfoListByParams")
|
||||
public TableDataInfo getConnectorInfoListByParams(@RequestBody QueryConnectorListDTO dto) {
|
||||
logger.info("查询接口列表 param:{}", JSON.toJSONString(dto));
|
||||
try {
|
||||
// 修改对接第三方平台的枪口状态
|
||||
updateThirdPartyConnectorStatus(dto);
|
||||
} catch (Exception e) {
|
||||
logger.error("修改对接第三方平台的枪口状态 error");
|
||||
}
|
||||
List<PileConnectorInfoVO> list = pileConnectorInfoService.getConnectorInfoListByParams(dto);
|
||||
// 修改对接第三方平台的枪口状态
|
||||
updateThirdPartyConnectorStatus(list);
|
||||
logger.info("查询接口列表 result:{}", JSON.toJSONString(list));
|
||||
return getDataTable(list);
|
||||
}
|
||||
@@ -144,26 +158,35 @@ public class PileConnectorInfoController extends BaseController {
|
||||
|
||||
/**
|
||||
* 修改第三方平台枪口状态
|
||||
* @see PileController#updateThirdPartyConnectorStatus(com.jsowell.pile.dto.QueryConnectorListDTO)
|
||||
* 两个方法完全相同,如有修改需同步修改
|
||||
*/
|
||||
public void updateThirdPartyConnectorStatus(List<PileConnectorInfoVO> connectorList) {
|
||||
if (CollectionUtils.isEmpty(connectorList)) {
|
||||
private void updateThirdPartyConnectorStatus(QueryConnectorListDTO dto) {
|
||||
if (dto == null) {
|
||||
return;
|
||||
}
|
||||
List<String> stationIdList = connectorList.stream()
|
||||
.map(PileConnectorInfoVO::getStationId)
|
||||
.collect(Collectors.toList());
|
||||
List<Long> pileIds = dto.getPileIds();
|
||||
List<Long> stationIdList = dto.getStationIdList();
|
||||
|
||||
for (String stationId : stationIdList) {
|
||||
String stationIdStr = String.valueOf(stationId);
|
||||
List<ThirdPartySnRelationVO> list = snRelationService.selectSnRelationListByParams(stationIdStr, null);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
for (ThirdPartySnRelationVO vo : list) {
|
||||
String thirdPartyType = vo.getThirdPartyType();
|
||||
// 调用通用查询实时数据接口(需在接口中修改枪口状态)
|
||||
commonService.commonQueryStationStatus(stationIdStr, thirdPartyType);
|
||||
}
|
||||
List<ThirdPartySnRelationVO> list = new ArrayList<>();
|
||||
if (CollectionUtils.isNotEmpty(pileIds)) {
|
||||
list = snRelationService.selectSnRelationListByParams(null, null, pileIds);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(stationIdList)) {
|
||||
for (Long stationId : stationIdList) {
|
||||
String stationIdStr = String.valueOf(stationId);
|
||||
list = snRelationService.selectSnRelationListByParams(stationIdStr, null, null);
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (ThirdPartySnRelationVO vo : list) {
|
||||
String thirdPartyType = vo.getThirdPartyType();
|
||||
String stationId = vo.getStationId();
|
||||
// 调用通用查询实时数据接口(需在接口中修改枪口状态)
|
||||
commonService.commonQueryStationStatus(stationId, thirdPartyType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user