上饶市公安局wvp平台
zhongrj
2023-03-07 9f8d7e3f8eb1e81e6eab411a415030085ff64da5
对讲设备读取数据修改
9 files modified
4 files added
1268 ■■■■■ changed files
.idea/workspace.xml 110 ●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/business/entity/TalkBackEquipment.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/business/entity/TalkBackEquipmentRecord.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/business/mapper/TalkBackEquipmentMapper.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/business/mapper/TalkBackEquipmentMapper.xml 8 ●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/business/service/impl/TalkBackEquipmentServiceImpl.java 12 ●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/config/MyDecoder.java 132 ●●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/handle/UdpServerHandler.java 102 ●●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/server/UdpServer.java 9 ●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/util/Hex.java 553 ●●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/util/HexStringTool.java 303 ●●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/netty/util/Utils.java 4 ●●●● patch | view | raw | blame | history
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java 21 ●●●●● patch | view | raw | blame | history
.idea/workspace.xml
@@ -17,8 +17,19 @@
  </component>
  <component name="ChangeListManager">
    <list default="true" id="208daac0-1abd-465d-abf2-6a0414be019b" name="默认的" comment="配置提交">
      <change afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/config/MyDecoder.java" afterDir="false" />
      <change afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/util/Hex.java" afterDir="false" />
      <change afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/util/HexStringTool.java" afterDir="false" />
      <change afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/util/Utils.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/business/entity/TalkBackEquipment.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/business/entity/TalkBackEquipment.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/business/entity/TalkBackEquipmentRecord.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/business/entity/TalkBackEquipmentRecord.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/business/mapper/TalkBackEquipmentMapper.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/business/mapper/TalkBackEquipmentMapper.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/business/mapper/TalkBackEquipmentMapper.xml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/business/mapper/TalkBackEquipmentMapper.xml" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/business/service/impl/TalkBackEquipmentServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/business/service/impl/TalkBackEquipmentServiceImpl.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/handle/UdpServerHandler.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/handle/UdpServerHandler.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/server/UdpServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/netty/server/UdpServer.java" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/main/resources/application.yml" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/application.yml" afterDir="false" />
      <change beforePath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java" afterDir="false" />
    </list>
    <option name="SHOW_DIALOG" value="false" />
    <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -43,6 +54,8 @@
    <option name="showLibraryContents" value="true" />
  </component>
  <component name="PropertiesComponent">
    <property name="ExpandSpringBootJavaOptionsPanel" value="true" />
    <property name="ExpandSpringBootSpringBootSettingsPanel" value="false" />
    <property name="RequestMappingsPanelOrder0" value="0" />
    <property name="RequestMappingsPanelOrder1" value="1" />
    <property name="RequestMappingsPanelWidth0" value="75" />
@@ -84,14 +97,38 @@
      <recent name="F:\code\server\shangraoshiju\wvp-GB281181-pro\src\main\java\com\genersoft\iot\vmp\netty" />
    </key>
  </component>
  <component name="RunManager">
    <configuration name="VManageBootstrap" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
  <component name="RunManager" selected="Spring Boot.VManageBootstrap">
    <configuration name="Hex" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
      <option name="MAIN_CLASS_NAME" value="com.genersoft.iot.vmp.netty.util.Hex" />
      <module name="wvp-pro" />
      <option name="SPRING_BOOT_MAIN_CLASS" value="com.genersoft.iot.vmp.VManageBootstrap" />
      <extension name="coverage">
        <pattern>
          <option name="PATTERN" value="com.genersoft.iot.vmp.netty.util.*" />
          <option name="ENABLED" value="true" />
        </pattern>
      </extension>
      <method v="2">
        <option name="Make" enabled="true" />
      </method>
    </configuration>
    <configuration name="VManageBootstrap" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
      <module name="wvp-pro" />
      <option name="SPRING_BOOT_MAIN_CLASS" value="com.genersoft.iot.vmp.VManageBootstrap" />
      <option name="VM_PARAMETERS" value="-Dspring.profiles.active=test" />
      <option name="ALTERNATIVE_JRE_PATH" />
      <method v="2">
        <option name="Make" enabled="true" />
      </method>
    </configuration>
    <list>
      <item itemvalue="Spring Boot.VManageBootstrap" />
      <item itemvalue="Application.Hex" />
    </list>
    <recent_temporary>
      <list>
        <item itemvalue="Application.Hex" />
      </list>
    </recent_temporary>
  </component>
  <component name="SpringBootOptions">
    <option name="showAdditionalConfigNotification" value="false" />
@@ -138,6 +175,7 @@
      <workItem from="1677651650908" duration="1778000" />
      <workItem from="1677660534432" duration="58000" />
      <workItem from="1677726051229" duration="38096000" />
      <workItem from="1678063078799" duration="34014000" />
    </task>
    <task id="LOCAL-00001" summary="默认的">
      <created>1676691639632</created>
@@ -229,10 +267,14 @@
    <option name="LAST_COMMIT_MESSAGE" value="执法记录仪移动位置插入新增" />
  </component>
  <component name="WindowStateProjectService">
    <state x="765" y="225" key="#com.intellij.ide.util.MemberChooser" timestamp="1677899698298">
    <state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1678100334007">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state x="765" y="225" key="#com.intellij.ide.util.MemberChooser/0.0.1920.1040@0.0.1920.1040" timestamp="1677899698298" />
    <state x="414" y="174" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1678100334007" />
    <state x="765" y="225" key="#com.intellij.ide.util.MemberChooser" timestamp="1678081258315">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state x="765" y="225" key="#com.intellij.ide.util.MemberChooser/0.0.1920.1040@0.0.1920.1040" timestamp="1678081258315" />
    <state x="511" y="442" key="#com.intellij.refactoring.move.MoveHandler.SelectRefactoringDialog" timestamp="1677736409554">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
@@ -249,54 +291,54 @@
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state x="740" y="275" key="FileChooserDialogImpl/0.0.1920.1040@0.0.1920.1040" timestamp="1677835225799" />
    <state width="1877" height="529" key="GridCell.Tab.0.bottom" timestamp="1677917445519">
    <state width="1877" height="437" key="GridCell.Tab.0.bottom" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445519" />
    <state width="1877" height="529" key="GridCell.Tab.0.center" timestamp="1677917445519">
    <state width="1877" height="437" key="GridCell.Tab.0.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state width="1877" height="437" key="GridCell.Tab.0.center" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445519" />
    <state width="1877" height="529" key="GridCell.Tab.0.left" timestamp="1677917445519">
    <state width="1877" height="437" key="GridCell.Tab.0.center/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state width="1877" height="437" key="GridCell.Tab.0.left" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445519" />
    <state width="1877" height="529" key="GridCell.Tab.0.right" timestamp="1677917445519">
    <state width="1877" height="437" key="GridCell.Tab.0.left/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state width="1877" height="437" key="GridCell.Tab.0.right" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445519" />
    <state width="1877" height="529" key="GridCell.Tab.1.bottom" timestamp="1677917445157">
    <state width="1877" height="437" key="GridCell.Tab.0.right/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state width="1877" height="437" key="GridCell.Tab.1.bottom" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.1.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445157" />
    <state width="1877" height="529" key="GridCell.Tab.1.center" timestamp="1677917445157">
    <state width="1877" height="437" key="GridCell.Tab.1.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state width="1877" height="437" key="GridCell.Tab.1.center" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.1.center/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445157" />
    <state width="1877" height="529" key="GridCell.Tab.1.left" timestamp="1677917445157">
    <state width="1877" height="437" key="GridCell.Tab.1.center/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state width="1877" height="437" key="GridCell.Tab.1.left" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.1.left/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445157" />
    <state width="1877" height="529" key="GridCell.Tab.1.right" timestamp="1677917445157">
    <state width="1877" height="437" key="GridCell.Tab.1.left/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state width="1877" height="437" key="GridCell.Tab.1.right" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.1.right/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445157" />
    <state width="1877" height="529" key="GridCell.Tab.2.bottom" timestamp="1677917445157">
    <state width="1877" height="437" key="GridCell.Tab.1.right/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state width="1877" height="437" key="GridCell.Tab.2.bottom" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.2.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445157" />
    <state width="1877" height="529" key="GridCell.Tab.2.center" timestamp="1677917445157">
    <state width="1877" height="437" key="GridCell.Tab.2.bottom/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state width="1877" height="437" key="GridCell.Tab.2.center" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.2.center/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445157" />
    <state width="1877" height="529" key="GridCell.Tab.2.left" timestamp="1677917445157">
    <state width="1877" height="437" key="GridCell.Tab.2.center/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state width="1877" height="437" key="GridCell.Tab.2.left" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.2.left/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445157" />
    <state width="1877" height="529" key="GridCell.Tab.2.right" timestamp="1677917445157">
    <state width="1877" height="437" key="GridCell.Tab.2.left/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state width="1877" height="437" key="GridCell.Tab.2.right" timestamp="1678169159490">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state width="1877" height="529" key="GridCell.Tab.2.right/0.0.1920.1040@0.0.1920.1040" timestamp="1677917445157" />
    <state width="1877" height="437" key="GridCell.Tab.2.right/0.0.1920.1040@0.0.1920.1040" timestamp="1678169159490" />
    <state x="698" y="221" key="RollbackChangesDialog" timestamp="1671415751049">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
@@ -313,10 +355,14 @@
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state x="92" y="92" width="1736" height="856" key="com.intellij.history.integration.ui.views.FileHistoryDialog/0.0.1920.1040@0.0.1920.1040" timestamp="1673925442539" />
    <state x="661" y="252" width="866" height="536" key="find.popup" timestamp="1677922543352">
    <state x="122" y="0" width="1402" height="698" maximized="true" key="dock-window-1" timestamp="1678073150799">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state x="661" y="252" width="866" height="536" key="find.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1677922543352" />
    <state x="122" y="0" width="1402" height="698" maximized="true" key="dock-window-1/0.0.1920.1040@0.0.1920.1040" timestamp="1678073150799" />
    <state x="661" y="252" width="866" height="536" key="find.popup" timestamp="1678152440240">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
    <state x="661" y="252" width="866" height="536" key="find.popup/0.0.1920.1040@0.0.1920.1040" timestamp="1678152440240" />
    <state x="643" y="306" key="git4idea.merge.GitPullDialog" timestamp="1676946006482">
      <screen x="0" y="0" width="1920" height="1040" />
    </state>
src/main/java/com/genersoft/iot/vmp/netty/business/entity/TalkBackEquipment.java
@@ -87,12 +87,6 @@
    private String latitude;
    /**
     * 类型 1:手台  2:执法记录仪
     */
    @ApiModelProperty(value = "类型 1:手台  2:执法记录仪")
    private Integer type;
    /**
     * 速度,单位 米/秒
     */
    @ApiModelProperty(value = "速度,单位 米/秒")
src/main/java/com/genersoft/iot/vmp/netty/business/entity/TalkBackEquipmentRecord.java
@@ -83,12 +83,6 @@
    private String latitude;
    /**
     * 类型 1:手台  2:执法记录仪
     */
    @ApiModelProperty(value = "类型 1:手台  2:执法记录仪")
    private Integer type;
    /**
     * 速度,单位 米/秒
     */
    @ApiModelProperty(value = "速度,单位 米/秒")
src/main/java/com/genersoft/iot/vmp/netty/business/mapper/TalkBackEquipmentMapper.java
@@ -32,7 +32,7 @@
     * @param code
     * @return
     */
    @Select("select * from sys_talk_back_equipment where code = #{code}")
    @Select("select * from sys_talk_back_equipment where terminal_number = #{code}")
    TalkBackEquipment getTalkBackEquipment(String code);
    /**
src/main/java/com/genersoft/iot/vmp/netty/business/mapper/TalkBackEquipmentMapper.xml
@@ -7,12 +7,12 @@
        insert into sys_talk_back_equipment
        (
        name,code,status,unit_name,unit_code,police_name,police_code,terminal_number,longitude,latitude,
        type,speed,direction,elevation,precisions,receive_time,create_time,update_time
        speed,direction,elevation,precisions,receive_time,create_time,update_time
        )
        values
        (
        #{name},#{code},#{status},#{unitName},#{unitCode},#{policeName},#{policeCode},#{terminalNumber},#{longitude},#{latitude},
        #{type},#{speed},#{direction},#{elevation},#{precisions},#{receiveTime},#{createTime},#{updateTime}
        #{speed},#{direction},#{elevation},#{precisions},#{receiveTime},#{createTime},#{updateTime}
        )
    </insert>
@@ -21,12 +21,12 @@
        insert into sys_talk_back_equipment_record
        (
        talk_back_equipment_id,status,unit_name,unit_code,police_name,police_code,terminal_number,
        longitude,latitude,type,speed,direction,elevation,precisions,receive_time,create_time
        longitude,latitude,speed,direction,elevation,precisions,receive_time,create_time
        )
        values
        (
        #{talkBackEquipmentId},#{status},#{unitName},#{unitCode},#{policeName},#{policeCode},#{terminalNumber},
        #{longitude},#{latitude}, #{type},#{speed},#{direction},#{elevation},#{precisions},#{receiveTime},#{createTime}
        #{longitude},#{latitude}, #{speed},#{direction},#{elevation},#{precisions},#{receiveTime},#{createTime}
        )
    </insert>
src/main/java/com/genersoft/iot/vmp/netty/business/service/impl/TalkBackEquipmentServiceImpl.java
@@ -29,8 +29,9 @@
    @Transactional(rollbackFor = Exception.class)
    public void save(TalkBackEquipment talkBackEquipment) {
        //判断设备是否已存在,如果存在则更新,不存在则新增
        TalkBackEquipment backEquipment = talkBackEquipmentMapper.getTalkBackEquipment(talkBackEquipment.getCode());
        TalkBackEquipment backEquipment = talkBackEquipmentMapper.getTalkBackEquipment(talkBackEquipment.getTerminalNumber());
        if (null==backEquipment) {
            talkBackEquipment.setCreateTime(new Date());
            //新增对接设备数据
            talkBackEquipmentMapper.saveTalkBackEquipment(talkBackEquipment);
        }else {
@@ -43,12 +44,11 @@
            TalkBackEquipmentRecord equipmentRecord = new TalkBackEquipmentRecord();
            equipmentRecord.setTalkBackEquipmentId(talkBackEquipment.getId());
            equipmentRecord.setStatus(talkBackEquipment.getStatus());
            equipmentRecord.setUnitName(talkBackEquipment.getUnitName());
            equipmentRecord.setUnitCode(talkBackEquipment.getUnitCode());
            equipmentRecord.setPoliceName(talkBackEquipment.getPoliceName());
            equipmentRecord.setPoliceCode(talkBackEquipment.getPoliceCode());
//            equipmentRecord.setUnitName(talkBackEquipment.getUnitName());
//            equipmentRecord.setUnitCode(talkBackEquipment.getUnitCode());
//            equipmentRecord.setPoliceName(talkBackEquipment.getPoliceName());
//            equipmentRecord.setPoliceCode(talkBackEquipment.getPoliceCode());
            equipmentRecord.setTerminalNumber(talkBackEquipment.getTerminalNumber());
            equipmentRecord.setType(talkBackEquipment.getType());
            equipmentRecord.setLongitude(talkBackEquipment.getLongitude());
            equipmentRecord.setLatitude(talkBackEquipment.getLatitude());
            equipmentRecord.setSpeed(talkBackEquipment.getSpeed());
src/main/java/com/genersoft/iot/vmp/netty/config/MyDecoder.java
New file
@@ -0,0 +1,132 @@
package com.genersoft.iot.vmp.netty.config;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * 自定义解析
 */
@Component
public class MyDecoder extends ByteToMessageDecoder {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception {
        //创建字节数组,buffer.readableBytes可读字节长度
        byte[] b = new byte[buffer.readableBytes()];
        //复制内容到字节数组b
        buffer.readBytes(b);
        //字节数组转字符串
        String str = new String(b);
        System.out.println(str);
        out.add(bytesToHexString(b));
    }
    public String bytesToHexString(byte[] bArray) {
        StringBuffer sb = new StringBuffer(bArray.length);
        String sTemp;
        for (int i = 0; i < bArray.length; i++) {
            sTemp = Integer.toHexString(0xFF & bArray[i]);
            if (sTemp.length() < 2)
                sb.append(0);
            sb.append(sTemp.toUpperCase());
        }
        return sb.toString();
    }
    public static String toHexString1(byte[] b) {
        StringBuffer buffer = new StringBuffer();
        for (int i = 0; i < b.length; ++i) {
            buffer.append(toHexString1(b[i]));
        }
        return buffer.toString();
    }
    public static String toHexString1(byte b) {
        String s = Integer.toHexString(b & 0xFF);
        if (s.length() == 1) {
            return "0" + s;
        } else {
            return s;
        }
    }
    /**
     * 16进制字符串转换为字符串
     *
     * @param s
     * @return
     */
    public static String hexStringToString(String s) {
        if (s == null || s.equals("")) {
            return null;
        }
        s = s.replace(" ", "");
        byte[] baKeyword = new byte[s.length() / 2];
        for (int i = 0; i < baKeyword.length; i++) {
            try {
                baKeyword[i] = (byte) (0xff & Integer.parseInt(
                        s.substring(i * 2, i * 2 + 2), 16));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        try {
            s = new String(baKeyword, "gbk");
            new String();
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        return s;
    }
    /**
     * Hex字符串转byte
     * @param inHex 待转换的Hex字符串
     * @return  转换后的byte
     */
    public static byte hexToByte(String inHex){
        return (byte)Integer.parseInt(inHex,16);
    }
    /**
     * Hex字符串转byte
     * @param inHex 待转换的Hex字符串
     * @return  转换后的byte
     */
    public static short hexTohort(String inHex){
        return (short)Integer.parseInt(inHex,16);
    }
    /**
     * hex字符串转byte数组
     * @param inHex 待转换的Hex字符串
     * @return  转换后的byte数组结果
     */
    public static byte[] hexToByteArray(String inHex){
        int hexlen = inHex.length();
        byte[] result;
        if (hexlen % 2 == 1){
            //奇数
            hexlen++;
            result = new byte[(hexlen/2)];
            inHex="0"+inHex;
        }else {
            //偶数
            result = new byte[(hexlen/2)];
        }
        int j=0;
        for (int i = 0; i < hexlen; i+=2){
            result[j]=hexToByte(inHex.substring(i,i+2));
            j++;
        }
        return result;
    }
}
src/main/java/com/genersoft/iot/vmp/netty/handle/UdpServerHandler.java
@@ -2,11 +2,13 @@
import com.genersoft.iot.vmp.netty.business.entity.TalkBackEquipment;
import com.genersoft.iot.vmp.netty.business.service.TalkBackEquipmentService;
import com.genersoft.iot.vmp.netty.config.MyDecoder;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.DatagramPacket;
import io.netty.util.CharsetUtil;
import okio.Utf8;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -14,7 +16,15 @@
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import static com.genersoft.iot.vmp.netty.config.MyDecoder.hexToByte;
import static com.genersoft.iot.vmp.netty.config.MyDecoder.hexTohort;
import static com.genersoft.iot.vmp.netty.util.Hex.getDouble;
import static com.genersoft.iot.vmp.netty.util.Hex.hexStr2Str;
/**
 * updHandler udp 服务端数据接收处理
@@ -43,14 +53,92 @@
        ByteBuf buf = (ByteBuf) datagramPacket.copy().content();
        byte[] req = new byte[buf.readableBytes()];
        buf.readBytes(req);
        String body = new String(req, CharsetUtil.UTF_8);
        System.out.println("【UDP】>>>>>> 收到客户端的数据:"+body);
        String s = bytesToHexString(req);
        System.out.println("s111111 = " + s);
        //获取字符串的长度
        int length = body.length();
        int length = s.length();
        System.out.println("数据长度>>>>>> = " + length);
        //保存数据
        saveTalkBackEquipmentInfo(body);
        //数据解析
        dataHandler(s);
    }
    /**
     * 数据解析
     * @param s 16位字符串
     */
    private void dataHandler(String s) {
//        s = "AAAACCCC220000000033373933343732393100000000000000000000000052D50451F77D5D406C04E275FD723C400000015F0000000507E70306103B0A";
        //创建设备对象
        TalkBackEquipment backEquipment = new TalkBackEquipment();
        if (s.substring(4,8).equals("CCCC")) {
            backEquipment.setStatus(1);
        }
        //断开连接
        if (s.substring(4,8).equals("FFFF")) {
            backEquipment.setStatus(0);
        }
        //截取字符串
        backEquipment.setTerminalNumber(hexStr2Str(s.substring(20, 60)));
        backEquipment.setLongitude(Double.toString(getDouble(s.substring(60, 76))));
        backEquipment.setLatitude(Double.toString(getDouble(s.substring(76, 92))));
        backEquipment.setSpeed(Short.toString(hexTohort(s.substring(92, 96))));
        backEquipment.setDirection(Short.toString(hexTohort(s.substring(96, 100))));
        backEquipment.setElevation(Short.toString(hexTohort(s.substring(100, 104))));
        backEquipment.setPrecisions(Short.toString(hexTohort(s.substring(104, 108))));
        String year = Short.toString(hexTohort(s.substring(108, 112)));
        String month = Short.toString(hexToByte(s.substring(112, 114)));
        if (Integer.parseInt(month)<10){
            month = "0" + month;
        }
        String day = Short.toString(hexToByte(s.substring(114, 116)));
        if (Integer.parseInt(day)<10){
            day = "0" + day;
        }
        String hour = Short.toString(hexToByte(s.substring(116, 118)));
        if (Integer.parseInt(hour)<10){
            hour = "0" + hour;
        }
        String minute = Short.toString(hexToByte(s.substring(118, 120)));
        if (Integer.parseInt(minute)<10){
            minute = "0" + minute;
        }
        String second = Short.toString(hexToByte(s.substring(120, 122)));
        if (Integer.parseInt(second)<10){
            second = "0" + second;
        }
        String time = year + "-" + month + "-" + day +" " + hour+ ":"+minute + ":" + second;
        System.out.println("接收时间: time = " + time);
        //时间拼接
        try {
            backEquipment.setReceiveTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(time));
        } catch (ParseException e) {
            e.printStackTrace();
        }
        backEquipment.setUpdateTime(new Date());
        // 新增
        udpServerHandler.talkBackEquipmentService.save(backEquipment);
    }
    /**
     * 转换
     * @param bArray
     * @return
     */
    public String bytesToHexString(byte[] bArray) {
        StringBuffer sb = new StringBuffer(bArray.length);
        String sTemp;
        for (int i = 0; i < bArray.length; i++) {
            sTemp = Integer.toHexString(0xFF & bArray[i]);
            if (sTemp.length() < 2)
                sb.append(0);
            sb.append(sTemp.toUpperCase());
        }
        return sb.toString();
    }
    /**
@@ -68,7 +156,6 @@
        equipmentRecord.setPoliceName("JINGYUAN");
        equipmentRecord.setPoliceCode("JINGYUAN123456");
        equipmentRecord.setTerminalNumber("788888888888");
        equipmentRecord.setType(1);
        equipmentRecord.setLongitude("128.124124412");
        equipmentRecord.setLatitude("27.1224521421");
        equipmentRecord.setSpeed("10");
@@ -78,8 +165,7 @@
        equipmentRecord.setReceiveTime(new Date());
        equipmentRecord.setCreateTime(new Date());
        equipmentRecord.setUpdateTime(new Date());
        //保存数据
        udpServerHandler.talkBackEquipmentService.save(equipmentRecord);
    }
    /**
src/main/java/com/genersoft/iot/vmp/netty/server/UdpServer.java
@@ -1,10 +1,12 @@
package com.genersoft.iot.vmp.netty.server;
import com.genersoft.iot.vmp.netty.config.MyDecoder;
import com.genersoft.iot.vmp.netty.handle.UdpServerHandler;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.*;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioDatagramChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.string.StringDecoder;
import io.netty.handler.codec.string.StringEncoder;
import io.netty.util.concurrent.DefaultEventExecutorGroup;
@@ -53,13 +55,16 @@
                            // TODO Auto-generated method stub
                            //创建一个执行Handler的容器
                            ChannelPipeline pipeline = ch.pipeline();
                            pipeline.addLast(new StringDecoder());
                            pipeline.addLast(new StringEncoder());
//                            pipeline.addLast(new StringDecoder());
                            pipeline.addLast("decoder",new MyDecoder());
//                            pipeline.addLast(new StringEncoder());
                            pipeline.addLast(new LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 4, 4, -8, 0));
                            //执行具体的自定义处理器
                            pipeline.addLast(group, "handler", new UdpServerHandler());
                        }
                    })//初始化处理器
                    //true / false 多播模式(UDP适用),可以向多个主机发送消息
                    .option(ChannelOption.SO_BROADCAST, true)
                    // 设置UDP读缓冲区为2M
src/main/java/com/genersoft/iot/vmp/netty/util/Hex.java
New file
@@ -0,0 +1,553 @@
package com.genersoft.iot.vmp.netty.util;
import com.genersoft.iot.vmp.netty.config.MyDecoder;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import static com.genersoft.iot.vmp.netty.config.MyDecoder.*;
public class Hex {
    /**
     * 用于建立十六进制字符的输出的小写字符数组
     */
    private static final char[] DIGITS_LOWER = {'0', '1', '2', '3', '4', '5',
            '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
    /**
     * 用于建立十六进制字符的输出的大写字符数组
     */
    private static final char[] DIGITS_UPPER = {'0', '1', '2', '3', '4', '5',
            '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
    private static ByteBuffer buffer = ByteBuffer.allocate(8);
    /**
     * 字符串转换成十六进制字符串
     *
     * @param str 待转换的ASCII字符串
     * @return String 每个Byte之间空格分隔,如: [61 6C 6B]
     */
    public static String str2HexStr(String str) {
        char[] chars = "0123456789ABCDEF".toCharArray();
        StringBuilder sb = new StringBuilder("");
        byte[] bs = str.getBytes();
        int bit;
        for (int i = 0; i < bs.length; i++) {
            bit = (bs[i] & 0x0f0) >> 4;
            sb.append(chars[bit]);
            bit = bs[i] & 0x0f;
            sb.append(chars[bit]);
            sb.append(' ');
        }
        return sb.toString().trim();
    }
    /**
     * 十六进制转换字符串
     *
     * @param hexStr Byte字符串(Byte之间无分隔符 如:[616C6B])
     * @return String 对应的字符串
     */
    public static String hexStr2Str(String hexStr) {
        String str = "0123456789ABCDEF";
        char[] hexs = hexStr.toCharArray();
        byte[] bytes = new byte[hexStr.length() / 2];
        int n;
        for (int i = 0; i < bytes.length; i++) {
            n = str.indexOf(hexs[2 * i]) * 16;
            n += str.indexOf(hexs[2 * i + 1]);
            bytes[i] = (byte) (n & 0xff);
        }
        return new String(bytes);
    }
    /**
     * bytes转换成十六进制字符串
     *
     * @param b byte数组
     * @return String 每个Byte值之间空格分隔
     */
    public static String byte2HexStr(byte[] b) {
        String stmp = "";
        StringBuilder sb = new StringBuilder("");
        for (int n = 0; n < b.length; n++) {
            stmp = Integer.toHexString(b[n] & 0xFF);
            sb.append((stmp.length() == 1) ? "0" + stmp : stmp);
//            sb.append(" ");
        }
        return sb.toString().toUpperCase().trim();
    }
    /**
     * bytes字符串转换为Byte值
     *
     * @param src Byte字符串,每个Byte之间没有分隔符
     * @return byte[]
     */
    public static byte[] hexStr2Bytes(String src) {
        int m = 0, n = 0;
        int l = src.length() / 2;
        System.out.println(l);
        byte[] ret = new byte[l];
        for (int i = 0; i < l; i++) {
            m = i * 2 + 1;
            n = m + 1;
            String tmp = "0x" + src.substring(i * 2, m) + src.substring(m, n);
            ret[i] = Byte.decode(tmp);
        }
        return ret;
    }
    /**
     * bytes字符串转换为Byte值
     *
     * @param hexString
     * @return
     */
    public static byte[] hexToBytes(String hexString) {
        if (hexString == null || hexString.equals("")) {
            return null;
        }
        int length = hexString.length() / 2;
        char[] hexChars = hexString.toCharArray();
        byte[] bytes = new byte[length];
//        String hexDigits = "0123456789abcdefABCDEF";
        String hexDigits = "0123456789abcdef";
        for (int i = 0; i < length; i++) {
            int pos = i * 2; // 两个字符对应一个byte
            int h = hexDigits.indexOf(hexChars[pos]) << 4; // 注1
            int l = hexDigits.indexOf(hexChars[pos + 1]); // 注2
            if (h == -1 || l == -1) { // 非16进制字符
                return null;
            }
            bytes[i] = (byte) (h | l);
        }
        return bytes;
    }
    /**
     * String的字符串转换成unicode的String
     *
     * @param strText 全角字符串
     * @return String 每个unicode之间无分隔符
     * @throws Exception
     */
    public static String strToUnicode(String strText) throws Exception {
        char c;
        StringBuilder str = new StringBuilder();
        int intAsc;
        String strHex;
        for (int i = 0; i < strText.length(); i++) {
            c = strText.charAt(i);
            intAsc = (int) c;
            strHex = Integer.toHexString(intAsc);
            if (intAsc > 128)
                str.append("\\u" + strHex);
            else
                // 低位在前面补00
                str.append("\\u00" + strHex);
        }
        return str.toString();
    }
    /**
     * unicode的String转换成String的字符串
     *
     * @param hex 16进制值字符串 (一个unicode为2byte)
     * @return String 全角字符串
     */
    public static String unicodeToString(String hex) {
        int t = hex.length() / 6;
        StringBuilder str = new StringBuilder();
        for (int i = 0; i < t; i++) {
            String s = hex.substring(i * 6, (i + 1) * 6);
            // 高位需要补上00再转
            String s1 = s.substring(2, 4) + "00";
            // 低位直接转
            String s2 = s.substring(4);
            // 将16进制的string转为int
            int n = Integer.valueOf(s1, 16) + Integer.valueOf(s2, 16);
            // 将int转换为字符
            char[] chars = Character.toChars(n);
            str.append(new String(chars));
        }
        return str.toString();
    }
    /**
     * 将字节数组转换为十六进制字符数组
     *
     * @param data byte[]
     * @return 十六进制char[]
     */
    public static char[] encodeHex(byte[] data) {
        return encodeHex(data, true);
    }
    /**
     * 将字节数组转换为十六进制字符数组
     *
     * @param data        byte[]
     * @param toLowerCase <code>true</code> 传换成小写格式 , <code>false</code> 传换成大写格式
     * @return 十六进制char[]
     */
    public static char[] encodeHex(byte[] data, boolean toLowerCase) {
        return encodeHex(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER);
    }
    /**
     * 将字节数组转换为十六进制字符数组
     *
     * @param data     byte[]
     * @param toDigits 用于控制输出的char[]
     * @return 十六进制char[]
     */
    protected static char[] encodeHex(byte[] data, char[] toDigits) {
        int l = data.length;
        char[] out = new char[l << 1];
        // two characters form the hex value.
        for (int i = 0, j = 0; i < l; i++) {
            out[j++] = toDigits[(0xF0 & data[i]) >>> 4];
            out[j++] = toDigits[0x0F & data[i]];
        }
        return out;
    }
    /**
     * 将字节数组转换为十六进制字符串
     *
     * @param data byte[]
     * @return 十六进制String
     */
    public static String encodeHexStr(byte[] data) {
        return encodeHexStr(data, true);
    }
    /**
     * 将字节数组转换为十六进制字符串
     *
     * @param data        byte[]
     * @param toLowerCase <code>true</code> 传换成小写格式 , <code>false</code> 传换成大写格式
     * @return 十六进制String
     */
    public static String encodeHexStr(byte[] data, boolean toLowerCase) {
        return encodeHexStr(data, toLowerCase ? DIGITS_LOWER : DIGITS_UPPER);
    }
    /**
     * 将字节数组转换为十六进制字符串
     *
     * @param data     byte[]
     * @param toDigits 用于控制输出的char[]
     * @return 十六进制String
     */
    protected static String encodeHexStr(byte[] data, char[] toDigits) {
        return new String(encodeHex(data, toDigits));
    }
    /**
     * 将十六进制字符数组转换为字节数组
     *
     * @param data 十六进制char[]
     * @return byte[]
     * @throws RuntimeException 如果源十六进制字符数组是一个奇怪的长度,将抛出运行时异常
     */
    public static byte[] decodeHex(char[] data) {
        int len = data.length;
        if ((len & 0x01) != 0) {
            throw new RuntimeException("Odd number of characters.");
        }
        byte[] out = new byte[len >> 1];
        // two characters form the hex value.
        for (int i = 0, j = 0; j < len; i++) {
            int f = toDigit(data[j], j) << 4;
            j++;
            f = f | toDigit(data[j], j);
            j++;
            out[i] = (byte) (f & 0xFF);
        }
        return out;
    }
    /**
     * 将十六进制字符转换成一个整数
     *
     * @param ch    十六进制char
     * @param index 十六进制字符在字符数组中的位置
     * @return 一个整数
     * @throws RuntimeException 当ch不是一个合法的十六进制字符时,抛出运行时异常
     */
    protected static int toDigit(char ch, int index) {
        int digit = Character.digit(ch, 16);
        if (digit == -1) {
            throw new RuntimeException("Illegal hexadecimal character " + ch
                    + " at index " + index);
        }
        return digit;
    }
    /**
     * float -> byte[]
     *
     * @param data
     * @return
     */
    public static byte[] getBytes(float data) {
        int intBits = Float.floatToIntBits(data);
        return intToByteArray(intBits);
    }
    /**
     * double -> byte[]
     *
     * @param data
     * @return
     */
    public static byte[] getBytes(double data) {
        long longBits = Double.doubleToLongBits(data);
        return longToBytes(longBits);
    }
    /**
     * byte[] -> float
     *
     * @param bytes
     * @return
     */
    public static float getFloat(byte[] bytes) {
        return Float.intBitsToFloat(getInt(bytes));
    }
    public static int getInt(byte[] bytes) {
        return (0xff & bytes[0]) | (0xff00 & (bytes[1] << 8)) | (0xff0000 & (bytes[2] << 16)) | (0xff000000 & (bytes[3] << 24));
    }
    /**
     * byte[] -> double
     *
     * @return
     */
    public static double getDouble(byte[] b) {
        long l;
        l = b[0];
        l &= 0xff;
        l |= ((long) b[1] << 8);
        l &= 0xffff;
        l |= ((long) b[2] << 16);
        l &= 0xffffff;
        l |= ((long) b[3] << 24);
        l &= 0xffffffffL;
        l |= ((long) b[4] << 32);
        l &= 0xffffffffffL;
        l |= ((long) b[5] << 40);
        l &= 0xffffffffffffL;
        l |= ((long) b[6] << 48);
        l &= 0xffffffffffffffL;
        l |= ((long) b[7] << 56);
        return Double.longBitsToDouble(l);
    }
    /**
     * 字节数组字符串 -> double
     *
     * @param bytesStr
     * @return
     */
    public static double getDouble(String bytesStr) {
        byte[] aa = hexToBytes(bytesStr.toLowerCase());
        return getDouble(aa);
    }
    /**
     * 字节数组字符串 -> float
     *
     * @param bytesStr
     * @return
     */
    public static float getFloat(String bytesStr) {
        byte[] aa = hexToBytes(bytesStr.toLowerCase());
        return getFloat(aa);
    }
    /**
     * 16进制字符串 -> byte数组
     */
    public static byte[] str16ToByte(String str16) {
        int len = str16.length();
        if (len % 2 > 0) {
            return null;
        }
        byte res[] = new byte[len / 2];
        for (int i = 0; i < len / 2; i++) {
            String tmp = str16.substring(i*2, (i + 1) * 2);
            byte t[] = hexToBytes(tmp);
            res[i] = t[0];
        }
        return res;
    }
    public static void main(String args[]) throws Exception {
        String aa = "AAAACCCC220000000033373933343732393100000000000000000000000052D50451F77D5D406C04E275FD723C400000015F0000000507E70306103B0A";
        String substring = aa.substring(20, 60);
        String substring1 = aa.substring(60, 76);
        String substring2 = aa.substring(76, 92);
        // 编号
        String a1 = "AAAACCCC2200000000333739333437323931000000000000000000000000";
        // 编号
        String a2 = "3739333437323931000000000000000000000000";
        System.out.println("a2 = " + hexStr2Str(a2));
        //经
        String lng = "52D50451F77D5D40";
        System.out.println("lng = " + getDouble(lng));
        String lat = "6C04E275FD723C40";
        System.out.println("lat = " + getDouble(lat));
        //日
        String str = "0000";
        System.out.println("a = " + hexTohort(str));
        String str1 = "015F";
        System.out.println("b = " + hexTohort(str1));
        //日
        String str2 = "0000";
        System.out.println("c = " + hexTohort(str2));
        String str3 = "0005";
        System.out.println("tr3 = " + hexTohort(str3));
        String nian = "07E7";
        System.out.println("nian = " + hexTohort(nian));
        String yue = "03";
        System.out.println("yue = " + hexToByte(yue));
        String ri = "06";
        System.out.println("ri = " + hexToByte(ri));
        String h = "10";
        System.out.println("h = " + hexToByte(h));
        String f = "3B";
        System.out.println("f = " + hexToByte(f));
        String m = "0A";
        System.out.println("m = " + hexToByte(m));
    }
    public static int toshort(String str) {
        char[] in = str.toCharArray();
        /*
         * for(int i=0;i<in.length;i+=2) { int value= tohx16(in[i]); int value2=
         * tohx16(in[i+1]); int value3=value<<4|value2;
         *
         * System.out.print(value3); }//这里可设计照规则进行转换
         */
        int j = 0;
        for(int i=0;i<in.length;i+=2) {
            int value= tohx16(in[i]);
            int value2=tohx16(in[i+1]);
            j=value<<4|value2;
        }
        return j;
    }
    public static int tohx16(char str) {
        switch (str) {
            case '0':
                return 0;
            case '1':
                return '1';
            case '2':
                return 2;
            case '3':
                return 3;
            case '4':
                return 4;
            case '5':
                return 5;
            case '6':
                return 6;
            case '7':
                return 7;
            case '8':
                return 8;
            case '9':
                return 9;
            case 'a':
            case 'A':
                return 10;
            case 'b':
            case 'B':
                return 11;
            case 'c':
            case 'C':
                return 12;
            case 'd':
            case 'D':
                return 13;
            case 'e':
            case 'E':
                return 14;
            case 'f':
            case 'F':
                return 15;
        }
        return 0;
    }
    public static byte[] intToByteArray(int a) {
        return new byte[]{
                (byte) ((a >> 24) & 0xFF),
                (byte) ((a >> 16) & 0xFF),
                (byte) ((a >> 8) & 0xFF),
                (byte) (a & 0xFF)
        };
    }
    public static byte intToByte(int a) {
        return (byte) (a & 0xFF);
    }
    public static byte[] longToBytes(long x) {
        buffer.putLong(0, x);
        return buffer.array();
    }
}
src/main/java/com/genersoft/iot/vmp/netty/util/HexStringTool.java
New file
@@ -0,0 +1,303 @@
package com.genersoft.iot.vmp.netty.util;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
public class HexStringTool {
    private static final char[] HEX_CHAR_ARR = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};
    private static final String HEX_STR = "0123456789abcdef";
    //对字符串,进行分组,转化为List
    public static List<String> getStrList(String str16, int frontLen, int size, int length) {
        List<String> list = new ArrayList<String>();
        String content = str16.substring(frontLen);
        String tem = "";
        for (int index = 0; index < size; index++) {
            tem = content.substring(0, length);
            content = content.substring(length);
            list.add(tem);
        }
        return list;
    }
    //对字符串,进行分组,转化为List(字符串数据类型转化专用)
    public static List<String> getStrList(String str16, int frontLen, int size, int totalLen, int lenLen) {
        List<String> list = new ArrayList<>();
        String content = str16.substring(frontLen);
        String tem = "";
        for (int index = 0; index < size; index++) {
            String len16 = content.substring(totalLen * 2, (totalLen + lenLen) * 2);
            int len = Integer.parseInt(len16, 16);
            int length = (totalLen + lenLen + len) * 2;
            tem = content.substring(0, length);
            content = content.substring(length);
            list.add(tem);
        }
        return list;
    }
    //字符串转换unicode
    public static String string2Unicode(String string) {
        StringBuffer unicode = new StringBuffer();
        for (int i = 0; i < string.length(); i++) {
            // 取出每一个字符
            char c = string.charAt(i);
            // 转换为unicode
            unicode.append("\\u" + Integer.toHexString(c));
        }
        return unicode.toString();
    }
    //字符串转化成为16进制字符串
    public static String strTo16(String s) {
        String str = "";
        for (int i = 0; i < s.length(); i++) {
            int ch = (int) s.charAt(i);
            String s4 = Integer.toHexString(ch);
            str = str + s4;
        }
        return str;
    }
    //16进制转换成为string类型字符串
    public static String hexStringToString(String s) {
        if (s == null || s.equals("")) {
            return null;
        }
        s = s.replace(" ", "");
        byte[] baKeyword = new byte[s.length() / 2];
        for (int i = 0; i < baKeyword.length; i++) {
            try {
                baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, i * 2 + 2), 16));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        try {
            s = new String(baKeyword, "UTF-8");
            new String();
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        return s;
    }
    //unicode 转字符串
    public static String unicode2String(String unicode) {
        StringBuffer string = new StringBuffer();
        String[] hex = unicode.split("\\\\u");
        for (int i = 1; i < hex.length; i++) {
            // 转换出每一个代码点
            int data = Integer.parseInt(hex[i], 16);
            // 追加成string
            string.append((char) data);
        }
        return string.toString();
    }
    //字符串转换成为16进制(无需Unicode编码)
    public static String str2HexStr(String str) {
        char[] chars = "0123456789ABCDEF".toCharArray();
        StringBuilder sb = new StringBuilder("");
        byte[] bs = str.getBytes();
        int bit;
        for (int i = 0; i < bs.length; i++) {
            bit = (bs[i] & 0x0f0) >> 4;
            sb.append(chars[bit]);
            bit = bs[i] & 0x0f;
            sb.append(chars[bit]);
            // sb.append(' ');
        }
        return sb.toString().trim();
    }
    //16进制直接转换成为字符串(无需Unicode解码)
    public static String hexStr2Str(String hexStr) {
        String str = "0123456789ABCDEF";
        char[] hexs = hexStr.toCharArray();
        byte[] bytes = new byte[hexStr.length() / 2];
        int n;
        for (int i = 0; i < bytes.length; i++) {
            n = str.indexOf(hexs[2 * i]) * 16;
            n += str.indexOf(hexs[2 * i + 1]);
            bytes[i] = (byte) (n & 0xff);
        }
        return new String(bytes);
    }
    /**
     * int/long转16字节字符串(按所占字节数用0补齐)
     *
     * @param byteLen 所占字节长度
     * @param b       需要转换的数字
     * @return str16
     */
    public static String numToStr16(int byteLen, long b) {
        return String.format("%0" + byteLen * 2 + "x", b);
    }
    /**
     * float/double转16字节字符串(按所占字节数用0补齐)
     *
     * @param byteLen 所占字节长度
     * @param b       需要转换的数字
     * @return str16
     */
    public static String numToStr16(int byteLen, double b) {
        byte[] bytes = Hex.getBytes(b);
        int anInt = Hex.getInt(bytes);
        return String.format("%0" + byteLen * 2 + "x", anInt);
    }
    /**
     * 16进制字符串转字符串(ASCII)
     *
     * @param x16 十六进制字符串
     * @return string
     */
    public static String x16toString(String x16) {
        if (x16 == null || "".equals(x16.trim())) {
            return "";
        }
        String tempStr = "";
        byte[] b = new byte[x16.length() / 2];
        for (int i = 0; i < x16.length() / 2; i++) {
            tempStr = x16.substring(i * 2, i * 2 + 2);
            int temp = Integer.parseInt(tempStr, 16);
            b[i] = (byte) temp;
        }
        return new String(b, StandardCharsets.US_ASCII);
    }
    /**
     * 16进制字符串转字符串(GBK)
     *
     * @param x16 十六进制字符串
     * @return string
     */
    public static String x16toGbk(String x16) {
        byte[] bytes = new byte[x16.length() / 2];
        byte tempByte = 0;
        byte tempHigh = 0;
        byte tempLow = 0;
        for (int i = 0, j = 0; i < x16.length(); i += 2, j++) {
            tempByte = (byte) (((int) x16.charAt(i)) & 0xff);
            if (tempByte >= 48 && tempByte <= 57) {
                tempHigh = (byte) ((tempByte - 48) << 4);
            } else if (tempByte >= 97 && tempByte <= 101) {
                tempHigh = (byte) ((tempByte - 97 + 10) << 4);
            }
            tempByte = (byte) (((int) x16.charAt(i + 1)) & 0xff);
            if (tempByte >= 48 && tempByte <= 57) {
                tempLow = (byte) (tempByte - 48);
            } else if (tempByte >= 97 && tempByte <= 101) {
                tempLow = (byte) (tempByte - 97 + 10);
            }
            bytes[j] = (byte) (tempHigh | tempLow);
        }
        String result = null;
        try {
            result = new String(bytes, "GBK");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return result;
    }
    public static boolean isChinese(String s) {
        boolean result = false;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
            if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
                    || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
                    || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
                    || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
                    || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
                    || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
                result = true;
            }
        }
        return result;
    }
    private static String byteArrToHex(byte[] btArr) {
        char[] strArr = new char[btArr.length * 2];
        int i = 0;
        for (byte bt : btArr) {
            strArr[i++] = HEX_CHAR_ARR[bt >>> 4 & 0xf];
            strArr[i++] = HEX_CHAR_ARR[bt & 0xf];
        }
        return new String(strArr);
    }
    private static byte[] hexToByteArr(String hexStr) {
        char[] charArr = hexStr.toCharArray();
        byte[] btArr = new byte[charArr.length / 2];
        int index = 0;
        for (int i = 0; i < charArr.length; i++) {
            int highBit = HEX_STR.indexOf(charArr[i]);
            int lowBit = HEX_STR.indexOf(charArr[++i]);
            btArr[index] = (byte) (highBit << 4 | lowBit);
            index++;
        }
        return btArr;
    }
    /**
     * 字符串转16进制字符串(无汉字utf-8,有汉字gbk)
     *
     * @param str
     * @return
     */
    public static String str2StrHex(String str) {
        boolean chinese = isChinese(str);
        if (chinese) {
            try {
                byte[] bytes1 = str.getBytes(StandardCharsets.UTF_8);
                byte[] bytes2 = new String(bytes1, StandardCharsets.UTF_8).getBytes("gbk");
                String gbk = new String(bytes2, "gbk");
                byte[] gbkArr = gbk.getBytes();
                return byteArrToHex(gbkArr);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
                return null;
            }
        } else {
            return strTo16(str);
        }
    }
    /**
     * 16进制字符串转字符串(无汉字utf-8,有汉字gbk)
     *
     * @param strHex
     * @return
     */
    public static String strHex2Str(String strHex) {
        byte[] bytes = hexToByteArr(strHex);
        String s1 = new String(bytes, StandardCharsets.UTF_8);
        boolean chinese = isChinese(s1);
        if (!chinese) {
            try {
                return new String(bytes, "gbk");
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
                return null;
            }
        } else {
            return s1;
        }
    }
}
src/main/java/com/genersoft/iot/vmp/netty/util/Utils.java
New file
@@ -0,0 +1,4 @@
package com.genersoft.iot.vmp.netty.util;
public class Utils {
}
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
@@ -10,6 +10,7 @@
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.policeBodyCamera.entity.DeviceChannelPoliceCamera;
import com.genersoft.iot.vmp.policeBodyCamera.mapper.DeviceChannelPoliceCameraMapper;
import com.genersoft.iot.vmp.policeBodyCamera.service.DeviceChannelPoliceCameraService;
import com.genersoft.iot.vmp.service.IGbStreamService;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
@@ -107,6 +108,9 @@
    @Autowired
    private DeviceChannelPoliceCameraService deviceChannelPoliceCameraService;
    @Autowired
    private DeviceChannelPoliceCameraMapper deviceChannelPoliceCameraMapper;
    private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -179,11 +183,12 @@
            deviceChannelMapper.update(channel);
        }
        deviceChannelMapper.updateChannelSubCount(deviceId,channel.getParentId());
        System.out.println("设备名称 = " + channel.getName());
        //如果是是执法记录仪
        if (null!=channel.getName() && channel.getName().contains("执法记录仪")){
//        if (null!=channel.getName() && channel.getName().contains("执法记录仪")){
            //更新执法记录仪信息
            deviceChannelPoliceCameraService.updateChannelPoliceCamera(channel);
        }
//        }
    }
    @Override
@@ -234,9 +239,15 @@
                            toIndex = addChannels.size();
                        }
                        deviceChannelMapper.batchAdd(addChannels.subList(i, toIndex));
                        //执法记录仪数据新增
                        System.out.println("执法记录仪批量新增 ================= ");
                        deviceChannelPoliceCameraMapper.batchAdd(addChannels.subList(i, toIndex));
                    }
                }else {
                    deviceChannelMapper.batchAdd(addChannels);
                    //执法记录仪数据新增
                    System.out.println("执法记录仪批量新增 ================= ");
                    deviceChannelPoliceCameraMapper.batchAdd(addChannels);
                }
            }
            if (updateChannels.size() > 0) {
@@ -247,9 +258,15 @@
                            toIndex = updateChannels.size();
                        }
                        deviceChannelMapper.batchUpdate(updateChannels.subList(i, toIndex));
                        //执法记录仪数据修改
                        System.out.println("执法记录仪批量修改 ================= ");
                        deviceChannelPoliceCameraMapper.batchUpdate(updateChannels.subList(i, toIndex));
                    }
                }else {
                    deviceChannelMapper.batchUpdate(updateChannels);
                    //执法记录仪数据修改
                    System.out.println("执法记录仪批量修改 ================= ");
                    deviceChannelPoliceCameraMapper.batchUpdate(updateChannels);
                }
            }
        }