| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.yzh; |
| | | |
| | | import io.github.yezhihao.protostar.util.Explain; |
| | | import io.netty.buffer.ByteBuf; |
| | | import io.netty.buffer.ByteBufUtil; |
| | | import io.netty.buffer.Unpooled; |
| | | import org.apache.poi.ss.usermodel.*; |
| | | import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
| | | import org.junit.platform.commons.util.StringUtils; |
| | | import org.yzh.protocol.JT808Beans; |
| | | import org.yzh.protocol.basics.JTMessage; |
| | | import org.yzh.protocol.codec.JTMessageAdapter; |
| | | import org.yzh.protocol.codec.JTMessageDecoder; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.nio.ByteBuffer; |
| | | import java.nio.ByteOrder; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * è§£ç åæ |
| | | * @author yezhihao |
| | | * https://gitee.com/yezhihao/jt808-server |
| | | */ |
| | | public class Elucidator extends JT808Beans { |
| | | |
| | | public static final JTMessageAdapter coder = new JTMessageAdapter("org.yzh.protocol"); |
| | | |
| | | public static void main(String[] args) { |
| | | String hex = "0200004c06724440021104ad00000000000c000301e4c49606fcbc04003c00000000250213220412010400001a4e02020000030200002504000000002a0200002b0400000000300115310112e306000012990000f2020000ac7e"; |
| | | // String hex = "0201004e0672444002110097019100000000000c0001015b197c06c8362e00000000000025020616592601040000083f02020000030200002504000000002a0200002b0400000000300117310100e306000012990000f2020000187e"; |
| | | // String hex = "020000d40123456789017fff000004000000080006eeb6ad02633df7013800030063200707192359642f000000400101020a0a02010a1e00640001b2070003640e200707192359000100000061646173200827111111010101652f000000410202020a0000000a1e00c8000516150006c81c20070719235900020000000064736d200827111111020202662900000042031e012c00087a23000a2c2a200707192359000300000074706d732008271111110303030067290000004304041e0190000bde31000d90382007071923590004000000006273642008271111110404049d"; |
| | | // JTMessage msg = H2019(T0200JSATL12()); |
| | | |
| | | // msg = decode(hex); |
| | | // hex = encode(msg); |
| | | // System.out.println(decode(hex)); |
| | | |
| | | try (FileInputStream fis = new FileInputStream(new File("C:\\Users\\T14\\Desktop\\member.xlsx")); |
| | | Workbook workbook = new XSSFWorkbook(fis)) { |
| | | Sheet sheet = workbook.getSheetAt(0); // è·å第ä¸ä¸ªå·¥ä½è¡¨ |
| | | List<String> phoneNumbers = new ArrayList<>(); |
| | | for (Row row : sheet) { |
| | | Cell cell = row.getCell(1); // åè®¾ææºå·å¨ç¬¬ä¸å |
| | | if (cell != null) { |
| | | if (cell.getCellType() == CellType.NUMERIC){ |
| | | System.out.println(cell.getCellType()); |
| | | phoneNumbers.add( cell.getNumericCellValue()+""); // æ·»å å°åè¡¨ä¸ |
| | | } |
| | | cell.setCellType(CellType.STRING); // ç¡®ä¿åå
æ ¼ç±»å为å符串 |
| | | String phoneNumber = cell.getStringCellValue(); // è·ååå
æ ¼å¼ä½ä¸ºå符串 |
| | | phoneNumbers.add( phoneNumber); // æ·»å å°åè¡¨ä¸ |
| | | } |
| | | } |
| | | // è¾åºææºå·å表 |
| | | phoneNumbers.forEach(System.out::println); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | private static String encode(JTMessage message) { |
| | | System.out.println("====================================================================================\n"); |
| | | Explain explain = new Explain(); |
| | | ByteBuf buf = null; |
| | | try { |
| | | buf = coder.encode(message, explain); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | String hex = ByteBufUtil.hexDump(buf); |
| | | System.out.println(message); |
| | | System.out.println(hex); |
| | | explain.println(); |
| | | return hex; |
| | | } |
| | | |
| | | private static JTMessage decode(String hex) { |
| | | System.out.println("====================================================================================\n"); |
| | | Explain explain = new Explain(); |
| | | JTMessage message = null; |
| | | try { |
| | | message = coder.decode(Unpooled.wrappedBuffer(ByteBufUtil.decodeHexDump(hex)), explain); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | System.out.println(message); |
| | | System.out.println(hex); |
| | | explain.println(); |
| | | return message; |
| | | } |
| | | } |