Files
jsowell-charger-web/jsowell-netty/src/main/java/com/jsowell/netty/handler/TimeCheckSettingResponseHandler.java

57 lines
1.9 KiB
Java
Raw Normal View History

2023-03-04 16:29:55 +08:00
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;
2023-11-20 12:02:31 +08:00
import com.jsowell.common.util.Cp56Time2a.Cp56Time2aUtil;
2023-11-28 13:25:07 +08:00
import com.jsowell.common.util.DateUtils;
2023-03-04 16:29:55 +08:00
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;
2023-11-28 13:25:07 +08:00
import java.util.Date;
2023-03-04 16:29:55 +08:00
/**
* 对时设置应答
*
* @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) {
2024-03-19 16:22:40 +08:00
// log.info("[===对时设置应答===] param:{}, channel:{}", JSON.toJSONString(ykcDataProtocol), channel.toString());
2023-03-04 16:29:55 +08:00
// 消息体
byte[] msgBody = ykcDataProtocol.getMsgBody();
int startIndex = 0;
int length = 7;
// 桩编号
byte[] pileSnByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
String pileSn = BytesUtil.bcd2Str(pileSnByteArr);
// 保存时间
2023-12-07 16:19:47 +08:00
saveLastTimeAndCheckChannel(pileSn, channel);
2023-03-04 16:29:55 +08:00
// 当前时间
startIndex += length;
length = 7;
byte[] currentTimeByteArr = BytesUtil.copyBytes(msgBody, startIndex, length);
2023-11-28 13:25:07 +08:00
Date date = Cp56Time2aUtil.byte2Hdate(currentTimeByteArr);
2023-12-15 15:51:01 +08:00
log.info("对时设置应答, pileSn:{}, channelId:{}, 充电桩当前时间:{}", pileSn, channel.id().asShortText(), DateUtils.formatDateTime(date));
2023-03-04 16:29:55 +08:00
return null;
}
}