mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 11:35:12 +08:00
76 lines
2.9 KiB
Java
76 lines
2.9 KiB
Java
package com.jsowell.netty.handler;
|
||
|
||
import com.alibaba.fastjson2.JSONObject;
|
||
import com.jsowell.common.core.domain.ykc.YKCDataProtocol;
|
||
import com.jsowell.common.core.domain.ykc.YKCFrameTypeCode;
|
||
import com.jsowell.common.util.BytesUtil;
|
||
import com.jsowell.common.util.YKCUtils;
|
||
import com.jsowell.netty.factory.YKCOperateFactory;
|
||
import com.jsowell.pile.service.OrderPileOccupyService;
|
||
import io.netty.channel.Channel;
|
||
import lombok.extern.slf4j.Slf4j;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.stereotype.Component;
|
||
|
||
import java.util.Locale;
|
||
|
||
/**
|
||
* 充电桩返回遥控地锁升锁与降锁数据(上行)
|
||
*
|
||
* @author JS-ZZA
|
||
* @date 2022/9/27 13:21
|
||
*/
|
||
@Slf4j
|
||
@Component
|
||
public class RemoteControlGroundLockResponseHandler extends AbstractHandler{
|
||
|
||
@Autowired
|
||
private OrderPileOccupyService orderPileOccupyService;
|
||
|
||
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.CHARGING_PILE_RESPOND_GROUND_LOCK_LIFTING_CODE.getBytes());
|
||
|
||
@Override
|
||
public void afterPropertiesSet() throws Exception {
|
||
YKCOperateFactory.register(type, this);
|
||
}
|
||
|
||
@Override
|
||
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, Channel channel) {
|
||
log.info("[===充电桩返回遥控地锁升锁与降锁数据(上行)===] param:{}, channel:{}", JSONObject.toJSONString(ykcDataProtocol), channel.toString());
|
||
// 消息体
|
||
byte[] msgBody = ykcDataProtocol.getMsgBody();
|
||
|
||
int startIndex = 0;
|
||
int length = 7;
|
||
// 桩编号
|
||
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||
String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
|
||
|
||
// 枪号
|
||
startIndex += length;
|
||
length = 1;
|
||
byte[] connectorCodeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||
String connectorCode = BytesUtil.bcd2Str(connectorCodeByteArr);
|
||
|
||
// 升/降地锁标识 升锁 0X55,降锁 0XFF
|
||
startIndex += length;
|
||
byte[] raiseLowMarkingByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||
String raiseLowMarking = BytesUtil.bin2HexStr(raiseLowMarkingByteArr).toUpperCase(Locale.ROOT);
|
||
|
||
// 地锁控制返回标志 布尔型( 1, 鉴权成功; 0, 鉴权失败)
|
||
startIndex += length;
|
||
byte[] controlResultByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||
String controlResult = BytesUtil.bcd2Str(controlResultByteArr);
|
||
|
||
// 预留位
|
||
startIndex += length;
|
||
length = 4;
|
||
byte[] waitingUseByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
||
|
||
log.info("===充电桩返回遥控地锁升锁与降锁数据(上行)=== result: 桩编号:{}, 枪号:{}, 升/降地锁标识:{}, 地锁控制返回标志:( 1, 鉴权成功; 0, 鉴权失败){}",
|
||
pileSn, connectorCode,raiseLowMarking, controlResult);
|
||
|
||
return null;
|
||
}
|
||
}
|