| | |
| | | import com.zy.acs.framework.common.RadixTools; |
| | | import com.zy.acs.common.constant.CommonConstant; |
| | | import com.zy.acs.common.enums.AgvCompleteType; |
| | | import com.zy.acs.common.utils.QrCodeCodecSupport; |
| | | import com.zy.acs.common.utils.Utils; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | |
| | | @Override |
| | | public void readFromBytes(byte[] bytes) { |
| | | int qrCodeBytes = QrCodeCodecSupport.qrCodeBytes(); |
| | | int qrCodePos = 17; |
| | | int directionPos = qrCodePos + qrCodeBytes; |
| | | int locCodePos = directionPos + 2; |
| | | int boxCodePos = locCodePos + 16; |
| | | // try { |
| | | this.serialNo = new String(Utils.sliceWithReverse(bytes, 0, 16)); |
| | | // } catch (UnsupportedEncodingException e) { |
| | |
| | | // } |
| | | this.completeCode = Utils.slice(bytes, 16, 1)[0]; |
| | | this.completeType = AgvCompleteType.query(this.completeCode); |
| | | this.qrCode = Utils.zeroFill(String.valueOf(RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 17, 4))), CommonConstant.QR_CODE_LEN); |
| | | this.direction = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, 21,2)); |
| | | this.qrCode = QrCodeCodecSupport.decode(bytes, qrCodePos); |
| | | this.direction = RadixTools.byteToShort(Utils.sliceWithReverse(bytes, directionPos, 2)); |
| | | // this.locCode = new String(Utils.sliceWithReverse(bytes, 23, 16)).replaceAll("\\u0000", ""); |
| | | // this.boxCode = new String(Utils.sliceWithReverse(bytes, 39, 16)).replaceAll("\\u0000", ""); |
| | | this.locCode = Utils.zeroFill(String.valueOf(RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 23, 4))), CommonConstant.QR_CODE_LEN); |
| | | this.boxCode = Utils.zeroFill(String.valueOf(RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, 39, 4))), CommonConstant.QR_CODE_LEN); |
| | | this.locCode = Utils.zeroFill(String.valueOf(RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, locCodePos, 4))), CommonConstant.QR_CODE_LEN); |
| | | this.boxCode = Utils.zeroFill(String.valueOf(RadixTools.bytesToInt(Utils.sliceWithReverse(bytes, boxCodePos, 4))), CommonConstant.QR_CODE_LEN); |
| | | } |
| | | |
| | | private String serialNo; |