update 华为Service

This commit is contained in:
Lemon
2024-04-01 16:17:00 +08:00
parent 7064f4e4b2
commit 60d54f8fea
12 changed files with 338 additions and 163 deletions

View File

@@ -13,6 +13,9 @@ import com.jsowell.pile.dto.QueryStationDTO;
import com.jsowell.pile.dto.RemoteGroundLockDTO;
import com.jsowell.pile.service.*;
import com.jsowell.pile.vo.uniapp.BillingPriceVO;
import com.jsowell.pile.vo.web.ThirdPartySnRelationVO;
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.*;
@@ -44,6 +47,12 @@ public class PileController extends BaseController {
@Autowired
private OrderPileOccupyService orderPileOccupyService;
@Autowired
private IThirdpartySnRelationService snRelationService;
@Autowired
private CommonService commonService;
/**
* 查询充电站信息列表(主页)
@@ -112,6 +121,9 @@ public class PileController extends BaseController {
RestApiResponse<?> response = null;
try {
PageResponse pageResponse = pileConnectorInfoService.getUniAppConnectorInfoListByParams(dto);
if (CollectionUtils.isNotEmpty(dto.getStationIdList())) {
updateThirdPartyConnectorStatus(dto.getStationIdList());
}
response = new RestApiResponse<>(pageResponse);
} catch (Exception e) {
logger.error("查询充电枪口列表异常", e);
@@ -171,4 +183,25 @@ public class PileController extends BaseController {
return response;
}
/**
* 修改第三方平台枪口状态
*/
private void updateThirdPartyConnectorStatus(List<Long> stationIdList) {
if (CollectionUtils.isEmpty(stationIdList)) {
return;
}
for (Long 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);
}
}
}
}

View File

@@ -132,6 +132,9 @@ public class OrderService {
@Autowired
private ThirdPartyStationRelationService thirdPartyStationRelationService;
@Autowired
private IThirdpartySnRelationService snRelationService;
@Autowired
private CommonService commonService;
@@ -1323,31 +1326,55 @@ public class OrderService {
}
/**
* 异步判断是否对接了类似华为平台的第三方平台,并启动充电
* 判断是否对接了类似华为平台的第三方平台,并启动充电
* @param orderCode
*/
private void checkThirdPartyQueryStartCharge(String orderCode) {
private boolean checkThirdPartyQueryStartCharge(String orderCode) {
// 根据订单号查询订单信息
OrderBasicInfo orderInfoByOrderCode = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
String stationId = orderInfoByOrderCode.getStationId();
// 判断是否对接了类似华为平台
List<ThirdPartyStationRelationVO> relationInfoList = thirdPartyStationRelationService.getRelationInfoList(stationId);
if (CollectionUtils.isEmpty(relationInfoList)) {
return;
}
for (ThirdPartyStationRelationVO vo : relationInfoList) {
String startMode = vo.getStartMode();
if (StringUtils.equals(Constants.TWO, startMode)) {
continue;
}
ThirdPartyCommonStartChargeDTO dto = new ThirdPartyCommonStartChargeDTO();
dto.setPayMode(orderInfoByOrderCode.getPayMode());
dto.setStationIds(Lists.newArrayList(stationId));
dto.setPileConnectorCode(orderInfoByOrderCode.getPileConnectorCode());
dto.setThirdPartyType(vo.getThirdPartyType());
OrderBasicInfo orderInfo = orderBasicInfoService.getOrderInfoByOrderCode(orderCode);
String stationId = orderInfo.getStationId();
String pileSn = orderInfo.getPileSn();
String result = commonService.commonQueryStartCharge(dto);
log.info("异步判断是否对接第三方平台 result:{}", result);
// 根据 stationId 查询 pile_sn_relation 表
List<ThirdPartySnRelationVO> snRelations = snRelationService.selectSnRelationListByParams(stationId, pileSn);
if (CollectionUtils.isEmpty(snRelations)) {
return false;
}
for (ThirdPartySnRelationVO snRelation : snRelations) {
String startMode = snRelation.getStartMode();
String thirdPartyType = snRelation.getThirdPartyType();
if (StringUtils.equals(Constants.ONE, startMode)) {
// 如果 startMode 为 1则调用第三方平台启动充电接口
ThirdPartyCommonStartChargeDTO dto = new ThirdPartyCommonStartChargeDTO();
dto.setPayMode(orderInfo.getPayMode());
dto.setStationIds(Lists.newArrayList(stationId));
dto.setPileConnectorCode(orderInfo.getPileConnectorCode());
dto.setThirdPartyType(thirdPartyType);
String result = commonService.commonQueryStartCharge(dto);
log.info("异步判断是否对接第三方平台 stationId:{}, thirdPartyType:{}, result:{}", stationId, thirdPartyType, result);
}
}
// 判断是否对接了类似华为平台
// List<ThirdPartyStationRelationVO> relationInfoList = thirdPartyStationRelationService.getRelationInfoList(stationId);
// if (CollectionUtils.isEmpty(relationInfoList)) {
// return false;
// }
// for (ThirdPartyStationRelationVO vo : relationInfoList) {
// String startMode = vo.getStartMode();
// if (StringUtils.equals(Constants.TWO, startMode)) {
// continue;
// }
// ThirdPartyCommonStartChargeDTO dto = new ThirdPartyCommonStartChargeDTO();
// dto.setPayMode(orderInfo.getPayMode());
// dto.setStationIds(Lists.newArrayList(stationId));
// dto.setPileConnectorCode(orderInfo.getPileConnectorCode());
// dto.setThirdPartyType(vo.getThirdPartyType());
//
// String result = commonService.commonQueryStartCharge(dto);
// log.info("异步判断是否对接第三方平台 result:{}", result);
// }
return true;
}
}

View File

@@ -11,8 +11,12 @@ import com.jsowell.pile.domain.PileConnectorInfo;
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.PileConnectorInfoService;
import com.jsowell.pile.vo.web.PileConnectorInfoVO;
import com.jsowell.pile.vo.web.ThirdPartySnRelationVO;
import com.jsowell.thirdparty.common.CommonService;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -29,104 +33,136 @@ import java.util.List;
@RestController
@RequestMapping("/pile/connector")
public class PileConnectorInfoController extends BaseController {
@Autowired
private PileConnectorInfoService pileConnectorInfoService;
@Autowired
private PileConnectorInfoService pileConnectorInfoService;
/**
* 查询充电桩枪口信息列表
*/
@PreAuthorize("@ss.hasPermi('pile:connector:list')")
@GetMapping("/list")
public TableDataInfo list(QueryConnectorDTO queryConnectorDTO) {
startPage();
List<PileConnectorInfoVO> list = pileConnectorInfoService.getConnectorInfoListByParams(queryConnectorDTO);
return getDataTable(list);
}
@Autowired
private IThirdpartySnRelationService snRelationService;
/**
* 导出充电桩枪口信息列表
*/
@PreAuthorize("@ss.hasPermi('pile:connector:export')")
@Log(title = "充电桩枪口信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, PileConnectorInfo pileConnectorInfo) {
List<PileConnectorInfo> list = pileConnectorInfoService.selectPileConnectorInfoList(pileConnectorInfo);
ExcelUtil<PileConnectorInfo> util = new ExcelUtil<PileConnectorInfo>(PileConnectorInfo.class);
util.exportExcel(response, list, "充电桩枪口信息数据");
}
@Autowired
private CommonService commonService;
/**
* 通过入参 查询接口列表
* http://localhost:8080/pile/connector/getConnectorInfoListByParams?pileIds=1,2
* 多id使用逗号拼接
*/
@PostMapping("/getConnectorInfoListByParams")
public TableDataInfo getConnectorInfoListByParams(@RequestBody QueryConnectorListDTO dto) {
logger.info("查询接口列表 param:{}", JSON.toJSONString(dto));
List<PileConnectorInfoVO> list = pileConnectorInfoService.getConnectorInfoListByParams(dto);
logger.info("查询接口列表 result:{}", JSON.toJSONString(list));
return getDataTable(list);
}
/**
* 查询充电桩枪口信息列表
*/
@PreAuthorize("@ss.hasPermi('pile:connector:list')")
@GetMapping("/list")
public TableDataInfo list(QueryConnectorDTO queryConnectorDTO) {
startPage();
List<PileConnectorInfoVO> list = pileConnectorInfoService.getConnectorInfoListByParams(queryConnectorDTO);
return getDataTable(list);
}
/**
* 修改车位号
* @param dto
* @return
*/
@PreAuthorize("@ss.hasPermi('pile:connector:edit')")
@Log(title = "充电桩枪口信息", businessType = BusinessType.UPDATE)
@PostMapping("/updateParkNo")
public RestApiResponse<?> updateParkNo(@RequestBody UpdateConnectorParkNoDTO dto) {
logger.info("修改车位号 param:{}", JSON.toJSONString(dto));
RestApiResponse<?> response = null;
try {
int i = pileConnectorInfoService.updateConnectorParkNo(dto);
response = new RestApiResponse<>(i);
} catch (Exception e) {
logger.error("修改车位号 error,", e);
response = new RestApiResponse<>(e);
}
return response;
}
/**
* 导出充电桩枪口信息列表
*/
@PreAuthorize("@ss.hasPermi('pile:connector:export')")
@Log(title = "充电桩枪口信息", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, PileConnectorInfo pileConnectorInfo) {
List<PileConnectorInfo> list = pileConnectorInfoService.selectPileConnectorInfoList(pileConnectorInfo);
ExcelUtil<PileConnectorInfo> util = new ExcelUtil<PileConnectorInfo>(PileConnectorInfo.class);
util.exportExcel(response, list, "充电桩枪口信息数据");
}
/**
* 获取充电桩枪口信息详细信息
*/
// @PreAuthorize("@ss.hasPermi('pile:connector:query')")
// @GetMapping(value = "/{id}")
// public AjaxResult getInfo(@PathVariable("id") Integer id) {
// return AjaxResult.success(pileConnectorInfoService.selectPileConnectorInfoById(id));
// }
/**
* 通过入参 查询接口列表
* http://localhost:8080/pile/connector/getConnectorInfoListByParams?pileIds=1,2
* 多id使用逗号拼接
*/
@PostMapping("/getConnectorInfoListByParams")
public TableDataInfo getConnectorInfoListByParams(@RequestBody QueryConnectorListDTO dto) {
logger.info("查询接口列表 param:{}", JSON.toJSONString(dto));
List<PileConnectorInfoVO> list = pileConnectorInfoService.getConnectorInfoListByParams(dto);
if (CollectionUtils.isNotEmpty(dto.getStationIdList())) {
// 修改对接第三方平台的枪口状态
updateThirdPartyConnectorStatus(dto.getStationIdList());
}
logger.info("查询接口列表 result:{}", JSON.toJSONString(list));
return getDataTable(list);
}
/**
* 新增充电桩枪口信息
*/
// @PreAuthorize("@ss.hasPermi('pile:connector:add')")
// @Log(title = "充电桩枪口信息", businessType = BusinessType.INSERT)
// @PostMapping
// public AjaxResult add(@RequestBody PileConnectorInfo pileConnectorInfo) {
// return toAjax(pileConnectorInfoService.insertPileConnectorInfo(pileConnectorInfo));
// }
/**
* 修改车位号
*
* @param dto
* @return
*/
@PreAuthorize("@ss.hasPermi('pile:connector:edit')")
@Log(title = "充电桩枪口信息", businessType = BusinessType.UPDATE)
@PostMapping("/updateParkNo")
public RestApiResponse<?> updateParkNo(@RequestBody UpdateConnectorParkNoDTO dto) {
logger.info("修改车位号 param:{}", JSON.toJSONString(dto));
RestApiResponse<?> response = null;
try {
int i = pileConnectorInfoService.updateConnectorParkNo(dto);
response = new RestApiResponse<>(i);
} catch (Exception e) {
logger.error("修改车位号 error,", e);
response = new RestApiResponse<>(e);
}
return response;
}
/**
* 修改充电桩枪口信息
*/
// @PreAuthorize("@ss.hasPermi('pile:connector:edit')")
// @Log(title = "充电桩枪口信息", businessType = BusinessType.UPDATE)
// @PutMapping
// public AjaxResult edit(@RequestBody PileConnectorInfo pileConnectorInfo) {
// return toAjax(pileConnectorInfoService.updatePileConnectorInfo(pileConnectorInfo));
// }
/**
* 获取充电桩枪口信息详细信息
*/
// @PreAuthorize("@ss.hasPermi('pile:connector:query')")
// @GetMapping(value = "/{id}")
// public AjaxResult getInfo(@PathVariable("id") Integer id) {
// return AjaxResult.success(pileConnectorInfoService.selectPileConnectorInfoById(id));
// }
/**
* 删除充电桩枪口信息
*/
// @PreAuthorize("@ss.hasPermi('pile:connector:remove')")
// @Log(title = "充电桩枪口信息", businessType = BusinessType.DELETE)
// @DeleteMapping("/{ids}")
// public AjaxResult remove(@PathVariable Integer[] ids) {
// return toAjax(pileConnectorInfoService.deletePileConnectorInfoByIds(ids));
// }
/**
* 新增充电桩枪口信息
*/
// @PreAuthorize("@ss.hasPermi('pile:connector:add')")
// @Log(title = "充电桩枪口信息", businessType = BusinessType.INSERT)
// @PostMapping
// public AjaxResult add(@RequestBody PileConnectorInfo pileConnectorInfo) {
// return toAjax(pileConnectorInfoService.insertPileConnectorInfo(pileConnectorInfo));
// }
/**
* 修改充电桩枪口信息
*/
// @PreAuthorize("@ss.hasPermi('pile:connector:edit')")
// @Log(title = "充电桩枪口信息", businessType = BusinessType.UPDATE)
// @PutMapping
// public AjaxResult edit(@RequestBody PileConnectorInfo pileConnectorInfo) {
// return toAjax(pileConnectorInfoService.updatePileConnectorInfo(pileConnectorInfo));
// }
/**
* 删除充电桩枪口信息
*/
// @PreAuthorize("@ss.hasPermi('pile:connector:remove')")
// @Log(title = "充电桩枪口信息", businessType = BusinessType.DELETE)
// @DeleteMapping("/{ids}")
// public AjaxResult remove(@PathVariable Integer[] ids) {
// return toAjax(pileConnectorInfoService.deletePileConnectorInfoByIds(ids));
// }
/**
* 修改第三方平台枪口状态
*/
public void updateThirdPartyConnectorStatus(List<Long> stationIdList) {
if (CollectionUtils.isEmpty(stationIdList)) {
return;
}
for (Long 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);
}
}
}
}

View File

@@ -84,5 +84,5 @@ public interface ThirdpartySnRelationMapper {
* @param stationId
* @return
*/
List<ThirdpartySnRelation> selectSnRelationListByStationId(String stationId);
List<ThirdPartySnRelationVO> selectSnRelationListByParams(@Param("stationId") String stationId, @Param("pileSn") String pileSn);
}

View File

@@ -30,7 +30,7 @@ public interface IThirdpartySnRelationService {
*/
public List<ThirdpartySnRelation> selectThirdpartySnRelationList(ThirdpartySnRelation thirdpartySnRelation);
public List<ThirdpartySnRelation> selectSnRelationListByStationId(String stationId);
public List<ThirdPartySnRelationVO> selectSnRelationListByParams(String stationId, String pileSn);
/**
* 新增万车充--第三方平台桩编号对应关系

View File

@@ -3055,10 +3055,10 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
sendStartCharging = false;
}
// 判断该桩所在的站点是否推送了第三方站点(需要我方平台发送启动指令的,如:华为平台)
List<ThirdPartyStationRelationVO> relationInfoList = thirdPartyStationRelationService.getRelationInfoList(orderInfo.getStationId());
if (CollectionUtils.isNotEmpty(relationInfoList)) {
for (ThirdPartyStationRelationVO vo : relationInfoList) {
// 判断该桩是否对接了类似华为平台的第三方站点
List<ThirdPartySnRelationVO> list = snRelationService.selectSnRelationListByParams(null, orderInfo.getPileSn());
if (CollectionUtils.isNotEmpty(list)) {
for (ThirdPartySnRelationVO vo : list) {
String startMode = vo.getStartMode();
if (StringUtils.equals(Constants.ONE, startMode)) {
// 无需发送启机指令,在汇付回调中发送
@@ -3066,7 +3066,17 @@ public class OrderBasicInfoServiceImpl implements OrderBasicInfoService {
}
}
}
// 判断该桩所在的站点是否推送了第三方站点(需要我方平台发送启动指令的,如:华为平台)
// List<ThirdPartyStationRelationVO> relationInfoList = thirdPartyStationRelationService.getRelationInfoList(orderInfo.getStationId());
// if (CollectionUtils.isNotEmpty(relationInfoList)) {
// for (ThirdPartyStationRelationVO vo : relationInfoList) {
// String startMode = vo.getStartMode();
// if (StringUtils.equals(Constants.ONE, startMode)) {
// // 无需发送启机指令,在汇付回调中发送
// sendStartCharging = false;
// }
// }
// }
// 修改订单
orderInfo.setPayMode(dto.getPayMode());

View File

@@ -45,8 +45,9 @@ public class ThirdpartySnRelationServiceImpl implements IThirdpartySnRelationSer
return thirdpartySnRelationMapper.selectThirdpartySnRelationList(thirdpartySnRelation);
}
public List<ThirdpartySnRelation> selectSnRelationListByStationId(String stationId) {
return thirdpartySnRelationMapper.selectSnRelationListByStationId(stationId);
public List<ThirdPartySnRelationVO> selectSnRelationListByParams(String stationId, String pileSn) {
return thirdpartySnRelationMapper.selectSnRelationListByParams(stationId, pileSn);
}
/**

View File

@@ -15,6 +15,10 @@ public class ThirdPartySnRelationVO {
*/
private String pileSn;
private String stationId;
private String startMode;
// 第三方平台类型
private String thirdPartyType;

View File

@@ -89,6 +89,26 @@
</foreach>
</delete>
<select id="selectSnRelationListByParams" resultType="com.jsowell.pile.vo.web.ThirdPartySnRelationVO">
SELECT
t1.station_id AS stationId,
t1.pile_sn AS pileSn,
t1.thirdparty_type AS thirdPartyType,
t1.thirdparty_pile_sn AS thirdPartyPileSn,
t2.start_mode AS startMode
FROM
thirdparty_sn_relation t1
JOIN thirdparty_station_relation t2 ON t1.thirdparty_type = t2.third_party_type
WHERE
t1.del_flag = '0'
<if test="stationId != null and stationId != ''">
AND t1.station_id = #{stationId,jdbcType=VARCHAR}
</if>
<if test="pileSn != null and pileSn != ''">
AND t1.pile_sn = #{pileSn,jdbcType=VARCHAR}
</if>
</select>
<select id="getRelationVOList" resultType="com.jsowell.pile.vo.web.ThirdPartySnRelationVO">
SELECT
pile_sn AS pileSn,
@@ -109,7 +129,4 @@
pile_sn = #{dto.pileSn,jdbcType=VARCHAR}
AND thirdparty_type = #{dto.thirdPartyType,jdbcType=VARCHAR}
</update>
<select id="selectSnRelationListByStationId" resultMap="ThirdpartySnRelationResult">
</select>
</mapper>

View File

@@ -2,6 +2,7 @@ package com.jsowell.thirdparty.common;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.collect.Lists;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
@@ -508,47 +509,16 @@ public class CommonService {
*/
public String commonQueryStartCharge(ThirdPartyCommonStartChargeDTO dto) {
String thirdPartyType = dto.getThirdPartyType();
List<String> stationIds = dto.getStationIds();
String pileConnectorCode = dto.getPileConnectorCode();
BigDecimal chargeAmount = dto.getChargeAmount();
String payMode = dto.getPayMode();
// List<String> stationIds = dto.getStationIds();
// String pileConnectorCode = dto.getPileConnectorCode();
// BigDecimal chargeAmount = dto.getChargeAmount();
// String payMode = dto.getPayMode();
// 判断平台类型
if (StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getTypeCode(), thirdPartyType)) {
// 华为平台
String label = ThirdPlatformTypeEnum.getTypeLabelByTypeCode(thirdPartyType);
// query_station_status 查询站点枪口详情
Map<String, String> map = huaweiServiceV2.queryStationStatus(stationIds);
String status = map.get(pileConnectorCode);
// 判断枪口状态
if (!StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) {
log.error(label + "判断枪口状态 error, 枪口状态为:{}", status);
}
// query_equip_auth 请求设备认证
QueryEquipAuthVO vo = huaweiServiceV2.queryEquipAuth(pileConnectorCode);
Integer succStat = vo.getSuccStat();
if (succStat != Constants.zero) {
log.error(label + "请求设备认证 error, {}", vo.getFailReason());
}
// query_start_charge 请求启动充电
HWQueryStartChargeDTO chargeDTO = new HWQueryStartChargeDTO();
chargeDTO.setConnectorID(pileConnectorCode);
chargeDTO.setMoneyLimit(chargeAmount);
chargeDTO.setPayMode(payMode);
QueryStartChargeVO startChargeVO = huaweiServiceV2.queryStartCharge(chargeDTO);
if (startChargeVO.getSuccStat() != Constants.zero) {
log.error(label + "请求启动充电 error, {}", startChargeVO.getFailReason());
}
String startChargeSeq = startChargeVO.getStartChargeSeq(); // 充电订单号
// 延时2s查询充电状态
Threads.sleep(2000);
// query_equip_charge_status 查询设备充电状态
QueryChargeStatusVO chargeStatusVO = huaweiServiceV2.queryChargeStatus(startChargeSeq);
if (chargeStatusVO.getConnectorStatus() == 3) {
// 充电中, 返回充电订单号
return chargeStatusVO.getStartChargeSeq();
}
String result = huaweiServiceV2.startChargeFlow(dto);
log.info("华为统一请求启动充电 result:{}", result);
}
return null;
@@ -595,4 +565,13 @@ public class CommonService {
return connectorStatus;
}
}
public void commonQueryStationStatus(String stationId, String thirdPartyType) {
if (StringUtils.equals(ThirdPlatformTypeEnum.HUA_WEI.getTypeCode(), thirdPartyType)) {
// 华为平台
Map<String, String> map = huaweiServiceV2.queryStationStatus(Lists.newArrayList(stationId));
// key: pileConnectorCode,
// value: status
}
}
}

View File

@@ -16,17 +16,20 @@ import com.jsowell.common.enums.thirdparty.ThirdPlatformTypeEnum;
import com.jsowell.common.enums.thirdparty.huawei.StartFailedReasonEnum;
import com.jsowell.common.enums.thirdparty.huawei.StopFailedReasonEnum;
import com.jsowell.common.enums.ykc.OrderStatusEnum;
import com.jsowell.common.enums.ykc.PileConnectorDataBaseStatusEnum;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.enums.ykc.StartModeEnum;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.util.DateUtils;
import com.jsowell.common.util.StringUtils;
import com.jsowell.common.util.Threads;
import com.jsowell.common.util.id.IdUtils;
import com.jsowell.pile.domain.*;
import com.jsowell.pile.domain.huawei.HWStationInfo;
import com.jsowell.pile.domain.huawei.HWStationStatusInfo;
import com.jsowell.pile.dto.GenerateOrderDTO;
import com.jsowell.pile.dto.QueryStartChargeDTO;
import com.jsowell.pile.dto.ThirdPartyCommonStartChargeDTO;
import com.jsowell.pile.dto.huawei.*;
import com.jsowell.pile.service.*;
import com.jsowell.pile.service.programlogic.AbstractProgramLogic;
@@ -654,6 +657,12 @@ public class HuaweiServiceV2 {
if (orderBasicInfo == null) {
return null;
}
String orderStatus = orderBasicInfo.getOrderStatus();
if (!StringUtils.equals(OrderStatusEnum.IN_THE_CHARGING.getValue(), orderStatus)) {
// 如果查出订单状态不为充电中,将订单改状态改为充电中
orderBasicInfo.setOrderStatus(OrderStatusEnum.IN_THE_CHARGING.getValue());
orderBasicInfoService.updateOrderBasicInfo(orderBasicInfo);
}
// 将源数据存储至缓存
String redisKey = CacheConstants.HUA_WEI_REAL_TIME_INFO_BY_ORDER_CODE + startChargeSeq;
String jsonMsg = JSON.toJSONString(dto);
@@ -928,6 +937,65 @@ public class HuaweiServiceV2 {
}
/**
* 华为启动充电流程(用于 CommonService
* @param dto
* @return
*/
public String startChargeFlow(ThirdPartyCommonStartChargeDTO dto) {
String thirdPartyType = dto.getThirdPartyType();
List<String> stationIds = dto.getStationIds();
String pileConnectorCode = dto.getPileConnectorCode();
BigDecimal chargeAmount = dto.getChargeAmount();
String payMode = dto.getPayMode();
String label = ThirdPlatformTypeEnum.getTypeLabelByTypeCode(thirdPartyType);
// query_station_status 查询站点枪口详情
Map<String, String> map = queryStationStatus(stationIds);
String status = map.get(pileConnectorCode);
// 判断枪口状态
if (!StringUtils.equals(PileConnectorDataBaseStatusEnum.OCCUPIED_NOT_CHARGED.getValue(), status)) {
log.error(label + "判断枪口状态 error, 枪口状态为:{}", status);
}
// query_equip_auth 请求设备认证
QueryEquipAuthVO vo = queryEquipAuth(pileConnectorCode);
Integer succStat = vo.getSuccStat();
if (succStat != Constants.zero) {
log.error(label + "请求设备认证 error, {}", vo.getFailReason());
}
// query_start_charge 请求启动充电
HWQueryStartChargeDTO chargeDTO = new HWQueryStartChargeDTO();
chargeDTO.setConnectorID(pileConnectorCode);
chargeDTO.setMoneyLimit(chargeAmount);
chargeDTO.setPayMode(payMode);
QueryStartChargeVO startChargeVO = queryStartCharge(chargeDTO);
if (startChargeVO.getSuccStat() != Constants.zero) {
log.error(label + "请求启动充电 error, {}", startChargeVO.getFailReason());
}
String startChargeSeq = startChargeVO.getStartChargeSeq(); // 充电订单号
// Threads.sleep(5000);
// query_equip_charge_status 查询设备充电状态
QueryChargeStatusVO chargeStatusVO = new QueryChargeStatusVO();
for (int i = 1; i <= 3; i ++) {
// 循环 3 次每次延时5s查询充电状态
Threads.sleep(5000);
chargeStatusVO = queryChargeStatus(startChargeSeq);
if (chargeStatusVO != null) {
break;
}
}
if (chargeStatusVO == null) {
return null;
}
if (chargeStatusVO.getConnectorStatus() == 3) {
// 充电中, 返回充电订单号
return chargeStatusVO.getStartChargeSeq();
}
return null;
}
/**
* 获取华为配置信息
* @return

View File

@@ -379,10 +379,10 @@ public class LianLianServiceImpl implements LianLianService {
public static void main(String[] args) throws UnsupportedEncodingException {
String dataSecret = "pJahbxk8wG79CMDB"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR 正式NHsBDtTanA60vTIu pJahbxk8wG79CMDB
String dataSecretIV = "y259VRq7h8RyFXmT"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm 正式2uyE2Cgu4nVf6egc y259VRq7h8RyFXmT
String dataSecret = "E6gnWuz0QzBW75CR"; // SPBNJ1Z5EQNmpK08 VTAEKDPVN9CUS7WO huawei: zd4NrLWJ38XCTaqP E6gnWuz0QzBW75CR 正式NHsBDtTanA60vTIu pJahbxk8wG79CMDB
String dataSecretIV = "SXejaSUx5yud8UHm"; // peRoTcb2C7zqKeII 83UZFFRRZDYNF5CR huawei: RJJecvNTJ48SGMG7 SXejaSUx5yud8UHm 正式2uyE2Cgu4nVf6egc y259VRq7h8RyFXmT
String signSecret = "sRjCDeokckFGpYpA"; // sRjCDeokckFGpYpA
String dataString = "ESOi5BHD3GIr3bEN8VTQsvSyj6P8nICQF0+sk8pqaGJ/z9Y4bJK+UPLBYNZze7De5GKDsVcM/V8rfx3DG+yDqLkpq4vSNm6LFzpk/U6WQF1Z7n+8NrqTDCEtFTYmiF7qhZPng550UpLg3rU6G9CXQw==";
String dataString = "iW1cm5Ktq70YeNayo1+R3UVzsqFK2AN9C7xDbKmdhrLQivIVtbR30Ct6VxpBrXSkDbgtyX7jxPxsnhrE+X2uxw==";
// 解密data
byte[] plainText = Cryptos.aesDecrypt(Encodes.decodeBase64(dataString), dataSecret.getBytes(), dataSecretIV.getBytes());