小程序扫码跳转判断是否对接第三方平台并更新枪口状态

This commit is contained in:
Lemon
2024-04-07 09:08:26 +08:00
parent bcc287b50c
commit 81f15e3dc0

View File

@@ -10,12 +10,18 @@ import com.jsowell.common.response.RestApiResponse;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.file.AliyunOssUploadUtils;
import com.jsowell.common.util.file.FileUtils;
import com.jsowell.pile.domain.PileBasicInfo;
import com.jsowell.pile.dto.QueryConnectorListDTO;
import com.jsowell.pile.service.IThirdpartySnRelationService;
import com.jsowell.pile.service.MemberGroupService;
import com.jsowell.pile.service.PileBasicInfoService;
import com.jsowell.pile.vo.base.PileInfoVO;
import com.jsowell.pile.vo.uniapp.GroundLockInfoVO;
import com.jsowell.pile.vo.uniapp.PileConnectorVO;
import com.jsowell.pile.vo.web.ThirdPartySnRelationVO;
import com.jsowell.service.PileService;
import com.jsowell.thirdparty.common.CommonService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -38,6 +44,12 @@ public class JumpController extends BaseController {
@Autowired
private MemberGroupService memberGroupService;
@Autowired
private IThirdpartySnRelationService snRelationService;
@Autowired
private CommonService commonService;
/**
* 查询充电桩详情
* http://localhost:8080/app-xcx-h5/pile/pileDetail/{pileSn}
@@ -47,6 +59,13 @@ public class JumpController extends BaseController {
// logger.info("app-xcx-h5查询充电桩详情 param:{}", pileSn);
logger.info("User-Agent:{}", request.getHeader("user-agent"));
RestApiResponse<?> response = null;
try {
// 如果对接了类似华为平台的第三方平台,先修改一下枪口状态
updateThirdPartyConnectorStatus(pileSn);
}catch (Exception e) {
logger.error("修改第三方平台枪口状态 error", e);
}
try {
// 进入充电桩详情做一下鉴权
String memberId = getMemberIdByAuthorization(request);
@@ -92,6 +111,8 @@ public class JumpController extends BaseController {
// logger.info("app-xcx-h5查询充电枪口详情 param:{}", pileConnectorCode);
logger.info("User-Agent:{}", request.getHeader("user-agent"));
RestApiResponse<?> response = null;
// 截取桩号
String pileSn = StringUtils.substring(pileConnectorCode, 0, 14);
String memberId = null;
try {
@@ -100,6 +121,13 @@ public class JumpController extends BaseController {
logger.error("进入充电桩详情做一下鉴权", e);
}
try {
// 如果对接了类似华为平台的第三方平台,先修改一下枪口状态
updateThirdPartyConnectorStatus(pileSn);
}catch (Exception e) {
logger.error("修改第三方平台枪口状态 error", e);
}
try {
// 进入充电桩详情做一下鉴权
// String memberId = getMemberIdByAuthorization(request);
@@ -170,4 +198,26 @@ public class JumpController extends BaseController {
logger.info("获取地锁列表信息 result:{}", response);
return response;
}
private void updateThirdPartyConnectorStatus(String pileSn) {
// 根据桩号查询站点id
PileBasicInfo pileBasicInfo = pileBasicInfoService.selectPileBasicInfoBySN(pileSn);
if (pileBasicInfo == null) {
return;
}
Long stationId = pileBasicInfo.getStationId();
String stationIdStr = String.valueOf(stationId);
List<ThirdPartySnRelationVO> list = snRelationService.selectSnRelationListByParams(stationIdStr, null, null);
if (CollectionUtils.isEmpty(list)) {
return;
}
for (ThirdPartySnRelationVO vo : list) {
String thirdPartyType = vo.getThirdPartyType();
// 调用通用查询实时数据接口(需在接口中修改枪口状态)
commonService.commonQueryStationStatus(String.valueOf(stationId), thirdPartyType);
}
}
}