This commit is contained in:
2024-03-22 13:58:08 +08:00
4 changed files with 68 additions and 32 deletions

View File

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.jsowell.common.annotation.Anonymous; import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.controller.BaseController; import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.common.util.JWTUtils; import com.jsowell.common.util.JWTUtils;
import com.jsowell.pile.dto.huawei.*; import com.jsowell.pile.dto.huawei.*;
import com.jsowell.pile.vo.huawei.QueryChargeStatusVO; import com.jsowell.pile.vo.huawei.QueryChargeStatusVO;
@@ -26,7 +27,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
* TODO * 华为 Controller V2
* *
* @author Lemon * @author Lemon
* @Date 2024/2/2 14:34:56 * @Date 2024/2/2 14:34:56
@@ -223,16 +224,18 @@ public class HuaWeiControllerV2 extends BaseController {
* @return * @return
*/ */
@GetMapping("/v2/notification_operation_system_info/{stationId}") @GetMapping("/v2/notification_operation_system_info/{stationId}")
public String notificationOperationSystemInfo(@PathVariable("stationId") String stationId) { public RestApiResponse<?> notificationOperationSystemInfo(@PathVariable("stationId") String stationId) {
logger.info("华为平台充电设备编码同步 stationId:{}", stationId); // logger.info("华为平台充电设备编码同步 stationId:{}", stationId);
RestApiResponse<?> response = null;
String result = null; String result = null;
try { try {
result = huaweiServiceV2.notificationOperationSystemInfo(stationId); result = huaweiServiceV2.notificationOperationSystemInfo(stationId);
response = new RestApiResponse<>(result);
} catch (Exception e) { } catch (Exception e) {
logger.error("华为平台充电设备编码同步 error", e); logger.error("华为平台充电设备编码同步 error", e);
} }
logger.info("华为平台充电设备编码同步 result:{}", result); logger.info("华为平台充电设备编码同步 stationId:{}, result:{}", stationId, result);
return result; return response;
} }
/** /**
@@ -241,16 +244,18 @@ public class HuaWeiControllerV2 extends BaseController {
* @return * @return
*/ */
@PostMapping("/v2/query_station_status") @PostMapping("/v2/query_station_status")
public Map<String, String> queryStationStatus(@RequestBody List<String> stationIds) { public RestApiResponse<?> queryStationStatus(@RequestBody List<String> stationIds) {
logger.info("查询华为设备接口状态 stationIds:{}", stationIds); // logger.info("查询华为设备接口状态 stationIds:{}", stationIds);
RestApiResponse<?> response = null;
Map<String, String> map = new LinkedHashMap<>(); Map<String, String> map = new LinkedHashMap<>();
try { try {
map = huaweiServiceV2.queryStationStatus(stationIds); map = huaweiServiceV2.queryStationStatus(stationIds);
response = new RestApiResponse<>(map);
} catch (Exception e) { } catch (Exception e) {
logger.error("查询华为设备接口状态 error", e); logger.error("查询华为设备接口状态 error", e);
} }
logger.info("查询华为设备接口状态 result:{}", map); logger.info("查询华为设备接口状态 stationIds:{}, result:{}", stationIds, map);
return map; return response;
} }
/** /**
@@ -259,16 +264,18 @@ public class HuaWeiControllerV2 extends BaseController {
* @return * @return
*/ */
@PostMapping("/v2/query_equip_auth") @PostMapping("/v2/query_equip_auth")
public QueryEquipAuthVO queryEquipAuth(@RequestBody String connectorId) { public RestApiResponse<?> queryEquipAuth(@RequestBody String connectorId) {
logger.info("请求华为设备认证 connectorId:{}", connectorId); // logger.info("请求华为设备认证 connectorId:{}", connectorId);
RestApiResponse<?> response = null;
QueryEquipAuthVO vo = null; QueryEquipAuthVO vo = null;
try { try {
vo = huaweiServiceV2.queryEquipAuth(connectorId); vo = huaweiServiceV2.queryEquipAuth(connectorId);
response = new RestApiResponse<>(vo);
} catch (Exception e) { } catch (Exception e) {
logger.error("请求华为设备认证 error", e); logger.error("请求华为设备认证 error", e);
} }
logger.info("请求华为设备认证 result:{}", JSON.toJSONString(vo)); logger.info("请求华为设备认证 connectorId:{}, result:{}", connectorId, JSON.toJSONString(vo));
return vo; return response;
} }
/** /**
@@ -277,16 +284,18 @@ public class HuaWeiControllerV2 extends BaseController {
* @return * @return
*/ */
@PostMapping("/v2/query_start_charge") @PostMapping("/v2/query_start_charge")
public QueryStartChargeVO queryStartCharge(@RequestBody HWQueryStartChargeDTO dto) { public RestApiResponse<?> queryStartCharge(@RequestBody HWQueryStartChargeDTO dto) {
logger.info("请求华为启动充电 param:{}", JSON.toJSONString(dto)); // logger.info("请求华为启动充电 param:{}", JSON.toJSONString(dto));
RestApiResponse<?> response = null;
QueryStartChargeVO vo = null; QueryStartChargeVO vo = null;
try { try {
vo = huaweiServiceV2.queryStartCharge(dto); vo = huaweiServiceV2.queryStartCharge(dto);
response = new RestApiResponse<>(vo);
} catch (Exception e) { } catch (Exception e) {
logger.error("请求华为启动充电 error", e); logger.error("请求华为启动充电 error", e);
} }
logger.info("请求华为启动充电 result:{}", JSON.toJSONString(vo)); logger.info("请求华为启动充电 param:{}, result:{}", JSON.toJSONString(dto), JSON.toJSONString(vo));
return vo; return response;
} }
@@ -296,16 +305,18 @@ public class HuaWeiControllerV2 extends BaseController {
* @return * @return
*/ */
@PostMapping("/v2/query_equip_charge_status") @PostMapping("/v2/query_equip_charge_status")
public QueryChargeStatusVO queryChargeStatus(@RequestBody String startChargeSeq) { public RestApiResponse<?> queryChargeStatus(@RequestBody String startChargeSeq) {
logger.info("查询华为充电状态 startChargeSeq:{}", startChargeSeq); // logger.info("查询华为充电状态 startChargeSeq:{}", startChargeSeq);
RestApiResponse<?> response = null;
QueryChargeStatusVO vo = null; QueryChargeStatusVO vo = null;
try { try {
vo = huaweiServiceV2.queryChargeStatus(startChargeSeq); vo = huaweiServiceV2.queryChargeStatus(startChargeSeq);
response = new RestApiResponse<>(vo);
} catch (Exception e) { } catch (Exception e) {
logger.error("查询华为充电状态 error", e); logger.error("查询华为充电状态 error", e);
} }
logger.info("查询华为充电状态 result:{}", JSON.toJSONString(vo)); logger.info("查询华为充电状态 startChargeSeq:{}, result:{}", startChargeSeq, JSON.toJSONString(vo));
return vo; return response;
} }
@@ -315,16 +326,18 @@ public class HuaWeiControllerV2 extends BaseController {
* @return * @return
*/ */
@PostMapping("/v2/query_stop_charge") @PostMapping("/v2/query_stop_charge")
public QueryStartChargeVO queryStopCharge(@RequestBody String startChargeSeq) { public RestApiResponse<?> queryStopCharge(@RequestBody String startChargeSeq) {
logger.info("请求华为停止充电 startChargeSeq:{}", startChargeSeq); // logger.info("请求华为停止充电 startChargeSeq:{}", startChargeSeq);
RestApiResponse<?> response = null;
QueryStartChargeVO vo = null; QueryStartChargeVO vo = null;
try { try {
vo = huaweiServiceV2.queryStopCharge(startChargeSeq); vo = huaweiServiceV2.queryStopCharge(startChargeSeq);
response = new RestApiResponse<>(vo);
}catch (Exception e) { }catch (Exception e) {
logger.error("请求华为停止充电 error", e); logger.error("请求华为停止充电 error", e);
} }
logger.info("请求华为停止充电 result:{}", JSON.toJSONString(vo)); logger.info("请求华为停止充电 startChargeSeq:{}, result:{}", startChargeSeq, JSON.toJSONString(vo));
return vo; return response;
} }

View File

@@ -232,6 +232,21 @@ public class CacheConstants {
*/ */
public static final String JIANGSU_PUSH_PILE_STATUS = "JIANGSU_PUSH_PILE_STATUS:"; public static final String JIANGSU_PUSH_PILE_STATUS = "JIANGSU_PUSH_PILE_STATUS:";
/**
* 华为获取令牌
*/
public static final String HUAWEI_GET_TOKEN = "HUAWEI_GET_TOKEN:";
/**
* 华为保存实时设备充电状态信息
*/
public static final String HUA_WEI_REAL_TIME_INFO_BY_ORDER_CODE = "HUA_WEI_REAL_TIME_INFO_BY_ORDER_CODE:";
/**
* 华为订单信息
*/
public static final String HUA_WEI_ORDER_INFO_BY_ORDER_CODE = "HUA_WEI_ORDER_INFO_BY_ORDER_CODE:";
/** /**
* 桩硬件故障 * 桩硬件故障
*/ */

View File

@@ -436,6 +436,11 @@ public class DelayMerchantProgramLogic extends AbstractProgramLogic {
// 订单退款 // 订单退款
refundOrder(orderBasicInfo); refundOrder(orderBasicInfo);
// 如果是vin启动将启动锁定状态改为正常
if (StringUtils.equals(data.getTransactionIdentifier(), "05")) {
vinStatusUnlocked(data.getVinCode());
}
// 发送停止充电订阅消息 // 发送停止充电订阅消息
sendMsg(orderBasicInfo); sendMsg(orderBasicInfo);

View File

@@ -6,6 +6,7 @@ import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants; import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.domain.ykc.RealTimeMonitorData; import com.jsowell.common.core.domain.ykc.RealTimeMonitorData;
import com.jsowell.common.core.domain.ykc.TransactionRecordsData; import com.jsowell.common.core.domain.ykc.TransactionRecordsData;
@@ -102,9 +103,6 @@ public class HuaweiServiceV2 {
@Autowired @Autowired
private IThirdpartySnRelationService thirdpartySnRelationService; private IThirdpartySnRelationService thirdpartySnRelationService;
@Resource
private TransactionService transactionService;
@Autowired @Autowired
private RedisCache redisCache; private RedisCache redisCache;
@@ -114,7 +112,7 @@ public class HuaweiServiceV2 {
*/ */
public String getHuaWeiToken() { public String getHuaWeiToken() {
String operatorId = Constants.OPERATORID_JIANG_SU; String operatorId = Constants.OPERATORID_JIANG_SU;
String redisKey = "huawei_get_token:" + operatorId; String redisKey = CacheConstants.HUAWEI_GET_TOKEN + operatorId;
// 先查缓存 // 先查缓存
String cacheToken = redisCache.getCacheObject(redisKey); String cacheToken = redisCache.getCacheObject(redisKey);
if (StringUtils.isNotBlank(cacheToken)) { if (StringUtils.isNotBlank(cacheToken)) {
@@ -624,7 +622,7 @@ public class HuaweiServiceV2 {
return null; return null;
} }
// 将源数据存储至缓存 // 将源数据存储至缓存
String redisKey = "HUA_WEI_REAL_TIME_INFO_BY_ORDER_CODE:" + startChargeSeq; String redisKey = CacheConstants.HUA_WEI_REAL_TIME_INFO_BY_ORDER_CODE + startChargeSeq;
String jsonMsg = JSON.toJSONString(dto); String jsonMsg = JSON.toJSONString(dto);
// 在同一分钟内,只保留最后一条实时数据 // 在同一分钟内,只保留最后一条实时数据
redisCache.hset(redisKey, DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", new Date()), jsonMsg); redisCache.hset(redisKey, DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:00", new Date()), jsonMsg);
@@ -732,7 +730,7 @@ public class HuaweiServiceV2 {
String pileConnectorCode = dto.getConnectorID(); String pileConnectorCode = dto.getConnectorID();
// 将源数据存缓存 // 将源数据存缓存
String redisKey = "HUA_WEI_ORDER_INFO_BY_ORDER_CODE:" + startChargeSeq; String redisKey = CacheConstants.HUA_WEI_ORDER_INFO_BY_ORDER_CODE + startChargeSeq;
redisCache.setCacheObject(redisKey, dto); redisCache.setCacheObject(redisKey, dto);
// // 截取桩号 // // 截取桩号
@@ -751,7 +749,7 @@ public class HuaweiServiceV2 {
OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(startChargeSeq); OrderBasicInfo orderBasicInfo = orderBasicInfoService.getOrderInfoByOrderCode(startChargeSeq);
// OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(startChargeSeq); // OrderDetail orderDetail = orderBasicInfoService.getOrderDetailByOrderCode(startChargeSeq);
// TODO 结算订单 // 结算订单
TransactionRecordsData data = TransactionRecordsData.builder() TransactionRecordsData data = TransactionRecordsData.builder()
.consumptionAmount(String.valueOf(dto.getTotalMoney())) // 订单总金额 .consumptionAmount(String.valueOf(dto.getTotalMoney())) // 订单总金额
.stopReasonMsg(String.valueOf(dto.getStopReason())) // 停止原因 .stopReasonMsg(String.valueOf(dto.getStopReason())) // 停止原因
@@ -759,6 +757,11 @@ public class HuaweiServiceV2 {
.totalElectricityAmount(String.valueOf(dto.getTotalElecMoney())) // 总电费 .totalElectricityAmount(String.valueOf(dto.getTotalElecMoney())) // 总电费
.totalServiceAmount(String.valueOf(dto.getTotalSeviceMoney())) // 总服务费 .totalServiceAmount(String.valueOf(dto.getTotalSeviceMoney())) // 总服务费
.build(); .build();
if (StringUtils.equals(StartModeEnum.VIN_CODE.getValue(), orderBasicInfo.getStartMode())) {
// 将交易记录中的交易标识 05 传入实时数据对象,用于结算订单后解锁 vin 状态
data.setTransactionIdentifier("05");
}
String mode = pileMerchantInfoService.getDelayModeByMerchantId(orderBasicInfo.getMerchantId()); String mode = pileMerchantInfoService.getDelayModeByMerchantId(orderBasicInfo.getMerchantId());
AbstractProgramLogic orderLogic = ProgramLogicFactory.getProgramLogic(mode); AbstractProgramLogic orderLogic = ProgramLogicFactory.getProgramLogic(mode);
orderLogic.settleOrderForThirdParty(data, orderBasicInfo); orderLogic.settleOrderForThirdParty(data, orderBasicInfo);