mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 19:45:09 +08:00
57 lines
1.9 KiB
Java
57 lines
1.9 KiB
Java
package com.jsowell.netty.handler;
|
|
|
|
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.Cp56Time2a.Cp56Time2aUtil;
|
|
import com.jsowell.common.util.DateUtils;
|
|
import com.jsowell.common.util.YKCUtils;
|
|
import com.jsowell.netty.factory.YKCOperateFactory;
|
|
import io.netty.channel.Channel;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
import java.util.Date;
|
|
|
|
/**
|
|
* 对时设置应答
|
|
*
|
|
* @author JS-ZZA
|
|
* @date 2022/9/27 11:09
|
|
*/
|
|
@Slf4j
|
|
@Component
|
|
public class TimeCheckSettingResponseHandler extends AbstractHandler{
|
|
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.TIME_CHECK_SETTING_ANSWER_CODE.getBytes());
|
|
|
|
@Override
|
|
public void afterPropertiesSet() throws Exception {
|
|
YKCOperateFactory.register(type, this);
|
|
}
|
|
|
|
@Override
|
|
public byte[] supplyProcess(YKCDataProtocol ykcDataProtocol, Channel channel) {
|
|
// log.info("[===对时设置应答===] param:{}, channel:{}", JSON.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);
|
|
|
|
// 保存时间
|
|
saveLastTimeAndCheckChannel(pileSn, channel);
|
|
|
|
// 当前时间
|
|
startIndex += length;
|
|
length = 7;
|
|
byte[] currentTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
|
|
Date date = Cp56Time2aUtil.byte2Hdate(currentTimeByteArr);
|
|
log.info("对时设置应答, pileSn:{}, channelId:{}, 充电桩当前时间:{}", pileSn, channel.id().asShortText(), DateUtils.formatDateTime(date));
|
|
return null;
|
|
}
|
|
}
|