mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-21 03:25:12 +08:00
76 lines
3.2 KiB
Java
76 lines
3.2 KiB
Java
|
|
package com.jsowell.netty.handler;
|
|||
|
|
|
|||
|
|
import com.alibaba.fastjson2.JSONObject;
|
|||
|
|
import com.google.common.primitives.Bytes;
|
|||
|
|
import com.jsowell.common.constant.Constants;
|
|||
|
|
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.netty.service.yunkuaichong.impl.YKCPushCommandServiceImpl;
|
|||
|
|
import io.netty.channel.Channel;
|
|||
|
|
import lombok.extern.slf4j.Slf4j;
|
|||
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|||
|
|
import org.springframework.stereotype.Component;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* 后台远程下发二维码前缀指令
|
|||
|
|
*
|
|||
|
|
* 二维码下发时,只需下发前缀,同时选择是第 0 种格式,还是第 1 种格式即可,如果二维码格式为 0 种,桩自动补充桩编号。
|
|||
|
|
* 如果二维码格式为 1 种,桩自动补充桩编号+2位枪编号。
|
|||
|
|
* 注册通过后,后台即可立即下发二维码。推荐每次注册通过后,均下发一次二维码。每个桩下发一次前缀即可。无须按照枪个数下发。
|
|||
|
|
*
|
|||
|
|
* @deprecated 桩不会发送这个指令,由平台主动发送
|
|||
|
|
* @author JS-ZZA
|
|||
|
|
* @date 2022/9/29 14:05
|
|||
|
|
*/
|
|||
|
|
@Slf4j
|
|||
|
|
@Component
|
|||
|
|
public class RemoteIssuedQrCodeHandler extends AbstractHandler{
|
|||
|
|
private final String type = YKCUtils.frameType2Str(YKCFrameTypeCode.REMOTE_ISSUE_QRCODE_CODE.getBytes());
|
|||
|
|
|
|||
|
|
@Autowired
|
|||
|
|
private YKCPushCommandServiceImpl ykcPushBusinessService;
|
|||
|
|
|
|||
|
|
@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());
|
|||
|
|
// 下发
|
|||
|
|
// 桩编码
|
|||
|
|
String pileSn = "88000000000001";
|
|||
|
|
byte[] a = new byte[]{88};
|
|||
|
|
byte[] b = Constants.zeroByteArray;
|
|||
|
|
byte[] c = Constants.zeroByteArray;
|
|||
|
|
byte[] d = Constants.zeroByteArray;
|
|||
|
|
byte[] e = Constants.zeroByteArray;
|
|||
|
|
byte[] f = Constants.zeroByteArray;
|
|||
|
|
byte[] g = new byte[]{0x02};
|
|||
|
|
byte[] pileSnByteArr = Bytes.concat(a, b, c, d, e, f, g);
|
|||
|
|
|
|||
|
|
// 二维码格式 0x00:第一种 前缀+桩编号 0x01:第二种 前缀+桩编号+枪编号
|
|||
|
|
byte[] qrCodeTypeByteArr = Constants.zeroByteArray;
|
|||
|
|
// 二维码前缀 如:“www.baidu.com?No=”
|
|||
|
|
String qrCodePrefix = "https://wx.charging.shbochong.cn/prepare_charge?code=";
|
|||
|
|
byte[] qrCodePrefixByteArr = BytesUtil.str2Asc(qrCodePrefix);
|
|||
|
|
// 二维码前缀长度 二维码前缀长度长度最大不超过200 字节
|
|||
|
|
int length = qrCodePrefix.length();
|
|||
|
|
byte[] qrCodePrefixLengthByteArr = BytesUtil.intToBytes(length);
|
|||
|
|
|
|||
|
|
// 拼接消息体
|
|||
|
|
byte[] msg = Bytes.concat(pileSnByteArr, qrCodeTypeByteArr, qrCodePrefixLengthByteArr, qrCodePrefixByteArr);
|
|||
|
|
|
|||
|
|
// push消息
|
|||
|
|
// boolean result = ykcPushBusinessService.push(msg, pileSn, YKCFrameTypeCode.REMOTE_ISSUE_QRCODE_CODE);
|
|||
|
|
|
|||
|
|
// log.info(String.valueOf(result));
|
|||
|
|
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
}
|