Commit 27f727e0f7b05f77c6a0a66accbeab4e4f13f3bf

Authored by 王通
0 parents

Init

Showing 50 changed files with 4846 additions and 0 deletions

Too many changes to show.

To preserve performance only 50 of 87 files are displayed.

.idea/artifacts/gb32960_server_war.xml 0 → 100644
  1 +++ a/.idea/artifacts/gb32960_server_war.xml
  1 +<component name="ArtifactManager">
  2 + <artifact type="war" name="gb32960_server:war">
  3 + <output-path>$PROJECT_DIR$/target</output-path>
  4 + <properties id="maven-jee-properties">
  5 + <options>
  6 + <module>gb32960_server</module>
  7 + <packaging>war</packaging>
  8 + </options>
  9 + </properties>
  10 + <root id="archive" name="transport_server-0.0.1-SNAPSHOT.war">
  11 + <element id="artifact" artifact-name="gb32960_server:war exploded" />
  12 + </root>
  13 + </artifact>
  14 +</component>
0 15 \ No newline at end of file
... ...
.idea/artifacts/gb32960_server_war_exploded.xml 0 → 100644
  1 +++ a/.idea/artifacts/gb32960_server_war_exploded.xml
  1 +<component name="ArtifactManager">
  2 + <artifact type="exploded-war" name="gb32960_server:war exploded">
  3 + <output-path>$PROJECT_DIR$/target/transport_server-0.0.1-SNAPSHOT</output-path>
  4 + <properties id="maven-jee-properties">
  5 + <options>
  6 + <exploded>true</exploded>
  7 + <module>gb32960_server</module>
  8 + <packaging>war</packaging>
  9 + </options>
  10 + </properties>
  11 + <root id="root">
  12 + <element id="directory" name="WEB-INF">
  13 + <element id="directory" name="classes">
  14 + <element id="module-output" name="gb32960_server" />
  15 + </element>
  16 + <element id="directory" name="lib">
  17 + <element id="library" level="project" name="Maven: javax.servlet:servlet-api:2.5" />
  18 + <element id="library" level="project" name="Maven: javax.servlet.jsp:jsp-api:2.1" />
  19 + <element id="library" level="project" name="Maven: javax.servlet:jstl:1.2" />
  20 + <element id="library" level="project" name="Maven: taglibs:standard:1.1.2" />
  21 + <element id="library" level="project" name="Maven: org.apache.mina:mina-core:2.0.13" />
  22 + <element id="library" level="project" name="Maven: org.springframework:spring-core:3.0.6.RELEASE" />
  23 + <element id="library" level="project" name="Maven: org.springframework:spring-asm:3.0.6.RELEASE" />
  24 + <element id="library" level="project" name="Maven: commons-logging:commons-logging:1.1.1" />
  25 + <element id="library" level="project" name="Maven: org.springframework:spring-beans:3.0.6.RELEASE" />
  26 + <element id="library" level="project" name="Maven: org.springframework:spring-context:3.0.6.RELEASE" />
  27 + <element id="library" level="project" name="Maven: org.springframework:spring-expression:3.0.6.RELEASE" />
  28 + <element id="library" level="project" name="Maven: org.springframework:spring-aop:3.0.6.RELEASE" />
  29 + <element id="library" level="project" name="Maven: aopalliance:aopalliance:1.0" />
  30 + <element id="library" level="project" name="Maven: org.springframework:spring-orm:3.0.6.RELEASE" />
  31 + <element id="library" level="project" name="Maven: org.springframework:spring-tx:3.0.6.RELEASE" />
  32 + <element id="library" level="project" name="Maven: org.springframework:spring-jdbc:3.0.6.RELEASE" />
  33 + <element id="library" level="project" name="Maven: org.springframework:spring-web:3.0.6.RELEASE" />
  34 + <element id="library" level="project" name="Maven: org.springframework:spring-webmvc:3.0.6.RELEASE" />
  35 + <element id="library" level="project" name="Maven: org.springframework:spring-context-support:3.0.6.RELEASE" />
  36 + <element id="library" level="project" name="Maven: org.aspectj:aspectjweaver:1.6.8" />
  37 + <element id="library" level="project" name="Maven: cglib:cglib-nodep:2.2" />
  38 + <element id="library" level="project" name="Maven: commons-dbcp:commons-dbcp:1.3" />
  39 + <element id="library" level="project" name="Maven: commons-pool:commons-pool:1.5.4" />
  40 + <element id="library" level="project" name="Maven: commons-codec:commons-codec:1.3" />
  41 + <element id="library" level="project" name="Maven: commons-io:commons-io:1.3.2" />
  42 + <element id="library" level="project" name="Maven: commons-beanutils:commons-beanutils:1.8.3" />
  43 + <element id="library" level="project" name="Maven: commons-fileupload:commons-fileupload:1.2.1" />
  44 + <element id="library" level="project" name="Maven: mysql:mysql-connector-java:5.1.38" />
  45 + <element id="library" level="project" name="Maven: org.slf4j:slf4j-api:1.7.21" />
  46 + <element id="library" level="project" name="Maven: org.apache.logging.log4j:log4j-api:2.7" />
  47 + <element id="library" level="project" name="Maven: org.apache.logging.log4j:log4j-core:2.7" />
  48 + <element id="library" level="project" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.7" />
  49 + <element id="library" level="project" name="Maven: com.lmax:disruptor:3.0.1" />
  50 + <element id="library" level="project" name="Maven: org.codehaus.jackson:jackson-core-asl:1.9.11" />
  51 + <element id="library" level="project" name="Maven: org.codehaus.jackson:jackson-mapper-asl:1.9.11" />
  52 + <element id="library" level="project" name="Maven: org.quartz-scheduler:quartz:1.8.5" />
  53 + <element id="library" level="project" name="Maven: javax.transaction:jta:1.1" />
  54 + <element id="library" level="project" name="Maven: joda-time:joda-time:2.8.2" />
  55 + </element>
  56 + </element>
  57 + <element id="directory" name="META-INF">
  58 + <element id="file-copy" path="$PROJECT_DIR$/target/transport_server-0.0.1-SNAPSHOT/META-INF/MANIFEST.MF" />
  59 + </element>
  60 + <element id="javaee-facet-resources" facet="gb32960_server/web/Web" />
  61 + </root>
  62 + </artifact>
  63 +</component>
0 64 \ No newline at end of file
... ...
.idea/jarRepositories.xml 0 → 100644
  1 +++ a/.idea/jarRepositories.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="RemoteRepositoriesConfiguration">
  4 + <remote-repository>
  5 + <option name="id" value="public-snapshots" />
  6 + <option name="name" value="public-snapshots" />
  7 + <option name="url" value="http://104.224.181.229:8081/repository/maven-snapshots/" />
  8 + </remote-repository>
  9 + <remote-repository>
  10 + <option name="id" value="central" />
  11 + <option name="name" value="Central Repository" />
  12 + <option name="url" value="http://104.224.181.229:8081/repository/maven-public" />
  13 + </remote-repository>
  14 + <remote-repository>
  15 + <option name="id" value="central" />
  16 + <option name="name" value="Maven Central repository" />
  17 + <option name="url" value="https://repo1.maven.org/maven2" />
  18 + </remote-repository>
  19 + <remote-repository>
  20 + <option name="id" value="jboss.community" />
  21 + <option name="name" value="JBoss Community repository" />
  22 + <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
  23 + </remote-repository>
  24 + <remote-repository>
  25 + <option name="id" value="central" />
  26 + <option name="name" value="Central Repository" />
  27 + <option name="url" value="https://maven.aliyun.com/repository/central" />
  28 + </remote-repository>
  29 + <remote-repository>
  30 + <option name="id" value="public-snapshots" />
  31 + <option name="name" value="public-snapshots" />
  32 + <option name="url" value="http://public-snapshots" />
  33 + </remote-repository>
  34 + </component>
  35 +</project>
0 36 \ No newline at end of file
... ...
.idea/uiDesigner.xml 0 → 100644
  1 +++ a/.idea/uiDesigner.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="Palette2">
  4 + <group name="Swing">
  5 + <item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
  6 + <default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
  7 + </item>
  8 + <item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
  9 + <default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
  10 + </item>
  11 + <item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
  12 + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
  13 + </item>
  14 + <item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
  15 + <default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
  16 + </item>
  17 + <item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
  18 + <default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
  19 + <initial-values>
  20 + <property name="text" value="Button" />
  21 + </initial-values>
  22 + </item>
  23 + <item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
  24 + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
  25 + <initial-values>
  26 + <property name="text" value="RadioButton" />
  27 + </initial-values>
  28 + </item>
  29 + <item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
  30 + <default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
  31 + <initial-values>
  32 + <property name="text" value="CheckBox" />
  33 + </initial-values>
  34 + </item>
  35 + <item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
  36 + <default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
  37 + <initial-values>
  38 + <property name="text" value="Label" />
  39 + </initial-values>
  40 + </item>
  41 + <item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
  42 + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
  43 + <preferred-size width="150" height="-1" />
  44 + </default-constraints>
  45 + </item>
  46 + <item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
  47 + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
  48 + <preferred-size width="150" height="-1" />
  49 + </default-constraints>
  50 + </item>
  51 + <item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
  52 + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
  53 + <preferred-size width="150" height="-1" />
  54 + </default-constraints>
  55 + </item>
  56 + <item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
  57 + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
  58 + <preferred-size width="150" height="50" />
  59 + </default-constraints>
  60 + </item>
  61 + <item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
  62 + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
  63 + <preferred-size width="150" height="50" />
  64 + </default-constraints>
  65 + </item>
  66 + <item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
  67 + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
  68 + <preferred-size width="150" height="50" />
  69 + </default-constraints>
  70 + </item>
  71 + <item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
  72 + <default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
  73 + </item>
  74 + <item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
  75 + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
  76 + <preferred-size width="150" height="50" />
  77 + </default-constraints>
  78 + </item>
  79 + <item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
  80 + <default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
  81 + <preferred-size width="150" height="50" />
  82 + </default-constraints>
  83 + </item>
  84 + <item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
  85 + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
  86 + <preferred-size width="150" height="50" />
  87 + </default-constraints>
  88 + </item>
  89 + <item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
  90 + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
  91 + <preferred-size width="200" height="200" />
  92 + </default-constraints>
  93 + </item>
  94 + <item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
  95 + <default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
  96 + <preferred-size width="200" height="200" />
  97 + </default-constraints>
  98 + </item>
  99 + <item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
  100 + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
  101 + </item>
  102 + <item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
  103 + <default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
  104 + </item>
  105 + <item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
  106 + <default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
  107 + </item>
  108 + <item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
  109 + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
  110 + </item>
  111 + <item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
  112 + <default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
  113 + <preferred-size width="-1" height="20" />
  114 + </default-constraints>
  115 + </item>
  116 + <item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
  117 + <default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
  118 + </item>
  119 + <item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
  120 + <default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
  121 + </item>
  122 + </group>
  123 + </component>
  124 +</project>
0 125 \ No newline at end of file
... ...
README.md 0 → 100644
  1 +++ a/README.md
  1 +11
0 2 \ No newline at end of file
... ...
gb32960_server.iml 0 → 100644
  1 +++ a/gb32960_server.iml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<module version="4">
  3 + <component name="FacetManager">
  4 + <facet type="jpa" name="JPA">
  5 + <configuration>
  6 + <setting name="validation-enabled" value="true" />
  7 + <datasource-mapping>
  8 + <factory-entry name="gb32960_server" />
  9 + <factory-entry name="transport_server" />
  10 + </datasource-mapping>
  11 + <naming-strategy-map />
  12 + </configuration>
  13 + </facet>
  14 + <facet type="Spring" name="Spring">
  15 + <configuration />
  16 + </facet>
  17 + </component>
  18 +</module>
0 19 \ No newline at end of file
... ...
pom.xml 0 → 100644
  1 +++ a/pom.xml
  1 +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  2 + <modelVersion>4.0.0</modelVersion>
  3 + <groupId>gb32960_server</groupId>
  4 + <artifactId>gb32960_server</artifactId>
  5 + <version>0.0.1-SNAPSHOT</version>
  6 + <packaging>jar</packaging>
  7 + <parent>
  8 + <groupId>org.springframework.boot</groupId>
  9 + <artifactId>spring-boot-starter-parent</artifactId>
  10 + <version>2.5.14</version>
  11 + </parent>
  12 +
  13 + <properties>
  14 + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  15 + <mina.version>2.0.13</mina.version>
  16 + <spring.version>3.0.6.RELEASE</spring.version>
  17 + </properties>
  18 + <dependencies>
  19 + <dependency>
  20 + <groupId>org.springframework.boot</groupId>
  21 + <artifactId>spring-boot-starter-web</artifactId>
  22 + </dependency>
  23 + <dependency>
  24 + <groupId>org.springframework.kafka</groupId>
  25 + <artifactId>spring-kafka</artifactId>
  26 + </dependency>
  27 + <dependency>
  28 + <groupId>org.springframework.boot</groupId>
  29 + <artifactId>spring-boot-starter-jdbc</artifactId>
  30 + </dependency>
  31 +
  32 + <dependency>
  33 + <groupId>org.apache.mina</groupId>
  34 + <artifactId>mina-core</artifactId>
  35 + <version>${mina.version}</version>
  36 + </dependency>
  37 +
  38 + <dependency>
  39 + <groupId>joda-time</groupId>
  40 + <artifactId>joda-time</artifactId>
  41 + <version>2.10.2</version>
  42 + </dependency>
  43 +
  44 + <dependency>
  45 + <groupId>commons-codec</groupId>
  46 + <artifactId>commons-codec</artifactId>
  47 + <version>1.3</version>
  48 + </dependency>
  49 +
  50 + <dependency>
  51 + <groupId>commons-io</groupId>
  52 + <artifactId>commons-io</artifactId>
  53 + <version>1.3.2</version>
  54 + </dependency>
  55 +
  56 + <dependency>
  57 + <groupId>commons-beanutils</groupId>
  58 + <artifactId>commons-beanutils</artifactId>
  59 + <version>1.8.3</version>
  60 + </dependency>
  61 +
  62 + <dependency>
  63 + <groupId>commons-fileupload</groupId>
  64 + <artifactId>commons-fileupload</artifactId>
  65 + <version>1.2.1</version>
  66 + </dependency>
  67 +
  68 + <dependency>
  69 + <groupId>mysql</groupId>
  70 + <artifactId>mysql-connector-java</artifactId>
  71 + </dependency>
  72 + </dependencies>
  73 + <build>
  74 + <plugins>
  75 + <plugin>
  76 + <artifactId>maven-war-plugin</artifactId>
  77 + </plugin>
  78 + <plugin>
  79 + <artifactId>maven-compiler-plugin</artifactId>
  80 + <configuration>
  81 + <source>1.8</source>
  82 + <target>1.8</target>
  83 + </configuration>
  84 + </plugin>
  85 + <plugin>
  86 + <groupId>org.springframework.boot</groupId>
  87 + <artifactId>spring-boot-maven-plugin</artifactId>
  88 + <configuration>
  89 + <mainClass>com.bsth.Application</mainClass>
  90 + </configuration>
  91 + <executions>
  92 + <execution>
  93 + <goals>
  94 + <goal>repackage</goal>
  95 + </goals>
  96 + </execution>
  97 + </executions>
  98 + </plugin>
  99 + </plugins>
  100 + </build>
  101 +</project>
0 102 \ No newline at end of file
... ...
src/main/java/com/bsth/Application.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/Application.java
  1 +package com.bsth;
  2 +
  3 +import com.bsth.util.AppProperties;
  4 +import org.springframework.beans.factory.annotation.Autowired;
  5 +import org.springframework.boot.SpringApplication;
  6 +import org.springframework.boot.autoconfigure.SpringBootApplication;
  7 +
  8 +/**
  9 + * @author Hill
  10 + */
  11 +@SpringBootApplication
  12 +public class Application {
  13 +
  14 + @Autowired
  15 + private AppProperties appProperties;
  16 +
  17 + public static void main(String[] args) throws Exception {
  18 + SpringApplication.run(Application.class, args);
  19 + }
  20 +}
... ...
src/main/java/com/bsth/DataSourceConfig.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/DataSourceConfig.java
  1 +package com.bsth;
  2 +
  3 +import org.springframework.beans.factory.annotation.Qualifier;
  4 +import org.springframework.boot.context.properties.ConfigurationProperties;
  5 +import org.springframework.boot.jdbc.DataSourceBuilder;
  6 +import org.springframework.context.annotation.Bean;
  7 +import org.springframework.context.annotation.Configuration;
  8 +import org.springframework.context.annotation.Primary;
  9 +import org.springframework.jdbc.core.JdbcTemplate;
  10 +
  11 +import javax.sql.DataSource;
  12 +
  13 +/**
  14 + * @author Hill
  15 + */
  16 +@Configuration
  17 +public class DataSourceConfig {
  18 + @Bean(name = "controlDataSource")
  19 + @Qualifier("controlDataSource")
  20 + @ConfigurationProperties(prefix = "spring.datasource.control")
  21 + public DataSource controlDataSource(){
  22 + return DataSourceBuilder.create().build();
  23 + }
  24 +
  25 + @Bean(name = "msDataSource")
  26 + @Qualifier("msDataSource")
  27 + @Primary
  28 + @ConfigurationProperties(prefix = "spring.datasource.ms")
  29 +
  30 + public DataSource msDataSource(){
  31 + return DataSourceBuilder.create().build();
  32 + }
  33 +
  34 + @Bean(name = "controlJdbcTemplate")
  35 + public JdbcTemplate controlJdbcTemplate(@Qualifier("controlDataSource")DataSource dataSource){
  36 + return new JdbcTemplate(dataSource);
  37 + }
  38 +
  39 + @Bean(name = "msJdbcTemplate")
  40 + public JdbcTemplate msJdbcTemplate(@Qualifier("msDataSource")DataSource dataSource){
  41 + return new JdbcTemplate(dataSource);
  42 + }
  43 +}
... ...
src/main/java/com/bsth/constant/Constant.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/constant/Constant.java
  1 +package com.bsth.constant;
  2 +
  3 +/**
  4 + * @author Hill
  5 + */
  6 +public class Constant {
  7 +
  8 + public final static int BYTE_INT = 0xFF;
  9 +
  10 + public final static int SHORT_INT = 0xFFFF;
  11 +
  12 + public final static long INT_LONG = 0xFFFFFFFF;
  13 +
  14 + public final static byte ACK_FLAG_SUCCESS = (byte)0x01;
  15 +
  16 + public final static byte ACK_FLAG_FAILURE = (byte)0x02;
  17 +
  18 + public final static byte ACK_FLAG_DUPLICATE_VIN = (byte)0x03;
  19 +
  20 + public final static byte ACK_FLAG_COMMAND = (byte)0xFE;
  21 +}
... ...
src/main/java/com/bsth/entity/AlarmData.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/AlarmData.java
  1 +package com.bsth.entity;
  2 +
  3 +import com.bsth.socket.protocol.Message0207;
  4 +import org.springframework.beans.BeanUtils;
  5 +
  6 +import java.util.ArrayList;
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * @author Hill
  11 + * 报警数据
  12 + */
  13 +public class AlarmData extends Data {
  14 +
  15 + /**
  16 + * 最高警报等级 0-3(亦可自定义)
  17 + * 0 无故障
  18 + * 1 级故障,不影响车辆行驶的故障
  19 + * 2 级故障,影响车辆性能,需驾驶员限制行驶的故障
  20 + * 3 级故障,停车待援
  21 + * 0xfe 异常
  22 + * 0xff 无效
  23 + */
  24 + private short maxAlarmLevel;
  25 +
  26 + /**
  27 + * 通用报警标志
  28 + * 0位 0正常 1温度差异 1位 电池高温 2位 车载储能装置类型过压 3位 车载储能装置类型欠压
  29 + * 4位 SOC低 5位 单体电池过压 6位 单体电池欠压 7位 SOC过高
  30 + * 8位 SOC跳变 9位 可充电储能系统不匹配 10位 电池单体一致性差 11位 绝缘
  31 + * 12位 DC-DC温度 13位 制动系统 14位 DC-DC状态 15位 驱动电机控制器温度
  32 + * 16位 高压互锁状态 17位 驱动电机温度 18位 车载储能装置类型过充
  33 + * 19-31位 保留
  34 + */
  35 + private int commonAlarmFlag;
  36 +
  37 + /**
  38 + * 储能装置数量 0-252
  39 + * N1
  40 + * 0xfe 异常
  41 + * 0xff 无效
  42 + */
  43 + private short energyStorageDeviceQuantity;
  44 +
  45 + /**
  46 + * 储能装置报警情况(自定义)
  47 + * N1 * 4
  48 + */
  49 + private int[] esdAlarms;
  50 +
  51 + /**
  52 + * 驱动电机数量 0-252
  53 + * N2
  54 + * 0xfe 异常
  55 + * 0xff 无效
  56 + */
  57 + private short electricMotorQuantity;
  58 +
  59 + /**
  60 + * 驱动电机报警情况(自定义)
  61 + * N2 * 4
  62 + */
  63 + private int[] emAlarms;
  64 +
  65 + /**
  66 + * 发动机数量 0-252
  67 + * N3
  68 + * 0xfe 异常
  69 + * 0xff 无效
  70 + */
  71 + private short engineQuantity;
  72 +
  73 + /**
  74 + * 发动机报警情况(自定义)
  75 + * N3 * 4
  76 + */
  77 + private int[] engineAlarms;
  78 +
  79 + /**
  80 + * 其它故障 0-252
  81 + * N4
  82 + * 0xfe 异常
  83 + * 0xff 无效
  84 + */
  85 + private short otherQuantity;
  86 +
  87 + /**
  88 + * 扩展故障详细
  89 + */
  90 + private List<String> troubles = new ArrayList<>();
  91 +
  92 + public AlarmData() {
  93 +
  94 + }
  95 +
  96 + public AlarmData(Message0207 message0207) {
  97 + BeanUtils.copyProperties(message0207, this);
  98 + this.maxAlarmLevel &= (short) 0xFF;
  99 + this.energyStorageDeviceQuantity &= (short) 0xFF;
  100 + this.electricMotorQuantity &= (short) 0xFF;
  101 + this.engineQuantity &= (short) 0xFF;
  102 + this.otherQuantity &= (short) 0xFF;
  103 + for (Message0207.Trouble trouble : message0207.getTroubleList()) {
  104 + troubles.add(trouble.toString());
  105 + }
  106 + }
  107 +
  108 + public short getMaxAlarmLevel() {
  109 + return maxAlarmLevel;
  110 + }
  111 +
  112 + public void setMaxAlarmLevel(short maxAlarmLevel) {
  113 + this.maxAlarmLevel = maxAlarmLevel;
  114 + }
  115 +
  116 + public int getCommonAlarmFlag() {
  117 + return commonAlarmFlag;
  118 + }
  119 +
  120 + public void setCommonAlarmFlag(int commonAlarmFlag) {
  121 + this.commonAlarmFlag = commonAlarmFlag;
  122 + }
  123 +
  124 + public short getEnergyStorageDeviceQuantity() {
  125 + return energyStorageDeviceQuantity;
  126 + }
  127 +
  128 + public void setEnergyStorageDeviceQuantity(short energyStorageDeviceQuantity) {
  129 + this.energyStorageDeviceQuantity = energyStorageDeviceQuantity;
  130 + }
  131 +
  132 + public int[] getEsdAlarms() {
  133 + return esdAlarms;
  134 + }
  135 +
  136 + public void setEsdAlarms(int[] esdAlarms) {
  137 + this.esdAlarms = esdAlarms;
  138 + }
  139 +
  140 + public short getElectricMotorQuantity() {
  141 + return electricMotorQuantity;
  142 + }
  143 +
  144 + public void setElectricMotorQuantity(short electricMotorQuantity) {
  145 + this.electricMotorQuantity = electricMotorQuantity;
  146 + }
  147 +
  148 + public int[] getEmAlarms() {
  149 + return emAlarms;
  150 + }
  151 +
  152 + public void setEmAlarms(int[] emAlarms) {
  153 + this.emAlarms = emAlarms;
  154 + }
  155 +
  156 + public short getEngineQuantity() {
  157 + return engineQuantity;
  158 + }
  159 +
  160 + public void setEngineQuantity(short engineQuantity) {
  161 + this.engineQuantity = engineQuantity;
  162 + }
  163 +
  164 + public int[] getEngineAlarms() {
  165 + return engineAlarms;
  166 + }
  167 +
  168 + public void setEngineAlarms(int[] engineAlarms) {
  169 + this.engineAlarms = engineAlarms;
  170 + }
  171 +
  172 + public short getOtherQuantity() {
  173 + return otherQuantity;
  174 + }
  175 +
  176 + public void setOtherQuantity(short otherQuantity) {
  177 + this.otherQuantity = otherQuantity;
  178 + }
  179 +
  180 + public List<String> getTroubles() {
  181 + return troubles;
  182 + }
  183 +
  184 + public void setTroubles(List<String> troubles) {
  185 + this.troubles = troubles;
  186 + }
  187 +
  188 + @Override
  189 + public String toString() {
  190 + StringBuilder sb = new StringBuilder();
  191 + sb.append(" 最大报警级别: ").append(maxAlarmLevel)
  192 + .append(" 通用报警标志: ").append(commonAlarmFlag)
  193 + .append(" 储能设备报警数: ").append(energyStorageDeviceQuantity)
  194 + .append(" 电机报警数: ").append(electricMotorQuantity)
  195 + .append(" 发动机报警数: ").append(engineQuantity)
  196 + .append(" 其它报警数: ").append(otherQuantity)
  197 + .append(" 自定义报警详情: ");
  198 +
  199 + for (String trouble : troubles) {
  200 + sb.append(trouble);
  201 + }
  202 +
  203 + return sb.toString();
  204 + }
  205 +
  206 + @Override
  207 + public String getType() {
  208 + return "alarm_data";
  209 + }
  210 +}
... ...
src/main/java/com/bsth/entity/CarParkInfo.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/CarParkInfo.java
  1 +package com.bsth.entity;
  2 +
  3 +import java.util.List;
  4 +
  5 +import com.bsth.geo.Point;
  6 +
  7 +public class CarParkInfo {
  8 +
  9 + private int id;
  10 + private String parkCode;
  11 + private String parkName;
  12 + private Point point;
  13 + private String shapesType;
  14 + private int radius;
  15 + private List<Point> points;
  16 +
  17 + public int getId() {
  18 + return id;
  19 + }
  20 +
  21 + public void setId(int id) {
  22 + this.id = id;
  23 + }
  24 +
  25 + public String getParkCode() {
  26 + return parkCode;
  27 + }
  28 +
  29 + public void setParkCode(String parkCode) {
  30 + this.parkCode = parkCode;
  31 + }
  32 +
  33 + public String getParkName() {
  34 + return parkName;
  35 + }
  36 +
  37 + public void setParkName(String parkName) {
  38 + this.parkName = parkName;
  39 + }
  40 +
  41 + public Point getPoint() {
  42 + return point;
  43 + }
  44 +
  45 + public void setPoint(Point point) {
  46 + this.point = point;
  47 + }
  48 +
  49 + public String getShapesType() {
  50 + return shapesType;
  51 + }
  52 +
  53 + public void setShapesType(String shapesType) {
  54 + this.shapesType = shapesType;
  55 + }
  56 +
  57 + public int getRadius() {
  58 + return radius;
  59 + }
  60 +
  61 + public void setRadius(int radius) {
  62 + this.radius = radius;
  63 + }
  64 +
  65 + public List<Point> getPoints() {
  66 + return points;
  67 + }
  68 +
  69 + public void setPoints(List<Point> points) {
  70 + this.points = points;
  71 + }
  72 +}
... ...
src/main/java/com/bsth/entity/Data.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/Data.java
  1 +package com.bsth.entity;
  2 +
  3 +/**
  4 + * @author Hill
  5 + */
  6 +public abstract class Data {
  7 +
  8 + /**
  9 + * 获取数据类型
  10 + * @return
  11 + */
  12 + public abstract String getType();
  13 +}
... ...
src/main/java/com/bsth/entity/DeviceAbnormal.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/DeviceAbnormal.java
  1 +package com.bsth.entity;
  2 +
  3 +public class DeviceAbnormal {
  4 +
  5 + private int id;
  6 +
  7 + private String deviceId;
  8 +
  9 + // 掉线次数
  10 + private int offline;
  11 +
  12 + // 漂移次数
  13 + private int drift;
  14 +
  15 + // 协议错误次数
  16 + private int protocol;
  17 +
  18 + // 数据是否存在于数据库
  19 + private boolean exists = true;
  20 +
  21 + public int getId() {
  22 + return id;
  23 + }
  24 +
  25 + public void setId(int id) {
  26 + this.id = id;
  27 + }
  28 +
  29 + public String getDeviceId() {
  30 + return deviceId;
  31 + }
  32 +
  33 + public void setDeviceId(String deviceId) {
  34 + this.deviceId = deviceId;
  35 + }
  36 +
  37 + public int getOffline() {
  38 + return offline;
  39 + }
  40 +
  41 + public void setOffline(int offline) {
  42 + this.offline = offline;
  43 + }
  44 +
  45 + public int getDrift() {
  46 + return drift;
  47 + }
  48 +
  49 + public void setDrift(int drift) {
  50 + this.drift = drift;
  51 + }
  52 +
  53 + public int getProtocol() {
  54 + return protocol;
  55 + }
  56 +
  57 + public void setProtocol(int protocol) {
  58 + this.protocol = protocol;
  59 + }
  60 +
  61 + public boolean isExists() {
  62 + return exists;
  63 + }
  64 +
  65 + public void setExists(boolean exists) {
  66 + this.exists = exists;
  67 + }
  68 +}
... ...
src/main/java/com/bsth/entity/DeviceSimMapping.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/DeviceSimMapping.java
  1 +package com.bsth.entity;
  2 +
  3 +public class DeviceSimMapping {
  4 +
  5 + private String deviceId;
  6 +
  7 + private String sim;
  8 +
  9 + // 0 A模块为主 1 B模块为主
  10 + private int extEnabled;
  11 +
  12 + public String getDeviceId() {
  13 + return deviceId;
  14 + }
  15 +
  16 + public void setDeviceId(String deviceId) {
  17 + this.deviceId = deviceId;
  18 + }
  19 +
  20 + public String getSim() {
  21 + return sim;
  22 + }
  23 +
  24 + public void setSim(String sim) {
  25 + this.sim = sim;
  26 + }
  27 +
  28 + public int getExtEnabled() {
  29 + return extEnabled;
  30 + }
  31 +
  32 + public void setExtEnabled(int extEnabled) {
  33 + this.extEnabled = extEnabled;
  34 + }
  35 +}
... ...
src/main/java/com/bsth/entity/GridInfo.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/GridInfo.java
  1 +package com.bsth.entity;
  2 +
  3 +public class GridInfo {
  4 +
  5 + private double minLon;
  6 +
  7 + private double maxLon;
  8 +
  9 + private double minLat;
  10 +
  11 + private double maxLat;
  12 +
  13 + private int row;
  14 +
  15 + private int column;
  16 +
  17 + private SectionGrid[][] grid;
  18 +
  19 + public double getMinLon() {
  20 + return minLon;
  21 + }
  22 +
  23 + public void setMinLon(double minLon) {
  24 + this.minLon = minLon;
  25 + }
  26 +
  27 + public double getMaxLon() {
  28 + return maxLon;
  29 + }
  30 +
  31 + public void setMaxLon(double maxLon) {
  32 + this.maxLon = maxLon;
  33 + }
  34 +
  35 + public double getMinLat() {
  36 + return minLat;
  37 + }
  38 +
  39 + public void setMinLat(double minLat) {
  40 + this.minLat = minLat;
  41 + }
  42 +
  43 + public double getMaxLat() {
  44 + return maxLat;
  45 + }
  46 +
  47 + public void setMaxLat(double maxLat) {
  48 + this.maxLat = maxLat;
  49 + }
  50 +
  51 + public int getRow() {
  52 + return row;
  53 + }
  54 +
  55 + public void setRow(int row) {
  56 + this.row = row;
  57 + }
  58 +
  59 + public int getColumn() {
  60 + return column;
  61 + }
  62 +
  63 + public void setColumn(int column) {
  64 + this.column = column;
  65 + }
  66 +
  67 + public SectionGrid[][] getGrid() {
  68 + return grid;
  69 + }
  70 +
  71 + public void setGrid(SectionGrid[][] grid) {
  72 + this.grid = grid;
  73 + }
  74 +}
... ...
src/main/java/com/bsth/entity/HistoryArrival.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/HistoryArrival.java
  1 +package com.bsth.entity;
  2 +
  3 +import java.util.Date;
  4 +
  5 +public class HistoryArrival {
  6 +
  7 + private int id;
  8 + private String deviceId;
  9 + private int lineId;
  10 + private String stopNo;
  11 + private long timestamp;
  12 + private int upDown;
  13 + private int upDown1;
  14 + // 0进站 1出站
  15 + private int inOut = -1;
  16 + private Date createDate;
  17 + private float totalMiles;
  18 + private float lon;
  19 + private float lat;
  20 +
  21 + // true场内 false场外
  22 + private boolean state;
  23 +
  24 + // 特殊情况下进站也是出站
  25 + private String lastStopNo;
  26 + private int lastUpDown;
  27 +
  28 + public boolean getState() {
  29 + return state;
  30 + }
  31 +
  32 + public void setState(boolean state) {
  33 + this.state = state;
  34 + }
  35 +
  36 + public int getInOut() {
  37 + return inOut;
  38 + }
  39 +
  40 + public void setInOut(int inOut) {
  41 + this.inOut = inOut;
  42 + }
  43 +
  44 + public float getLon() {
  45 + return lon;
  46 + }
  47 +
  48 + public void setLon(float lon) {
  49 + this.lon = lon;
  50 + }
  51 +
  52 + public float getLat() {
  53 + return lat;
  54 + }
  55 +
  56 + public void setLat(float lat) {
  57 + this.lat = lat;
  58 + }
  59 +
  60 + public float getTotalMiles() {
  61 + return totalMiles;
  62 + }
  63 +
  64 + public void setTotalMiles(float totalMiles) {
  65 + this.totalMiles = totalMiles;
  66 + }
  67 +
  68 + public int getId() {
  69 + return id;
  70 + }
  71 +
  72 + public void setId(int id) {
  73 + this.id = id;
  74 + }
  75 +
  76 + public String getDeviceId() {
  77 + return deviceId;
  78 + }
  79 +
  80 + public void setDeviceId(String deviceId) {
  81 + this.deviceId = deviceId;
  82 + }
  83 +
  84 + public int getLineId() {
  85 + return lineId;
  86 + }
  87 +
  88 + public void setLineId(int lineId) {
  89 + this.lineId = lineId;
  90 + }
  91 +
  92 + public String getStopNo() {
  93 + return stopNo;
  94 + }
  95 +
  96 + public void setStopNo(String stopNo) {
  97 + this.stopNo = stopNo;
  98 + }
  99 +
  100 + public long getTimestamp() {
  101 + return timestamp;
  102 + }
  103 +
  104 + public void setTimestamp(long timestamp) {
  105 + this.timestamp = timestamp;
  106 + }
  107 +
  108 + public int getUpDown() {
  109 + return upDown;
  110 + }
  111 +
  112 + public void setUpDown(int upDown) {
  113 + this.upDown = upDown;
  114 + }
  115 +
  116 + public int getUpDown1() {
  117 + return upDown1;
  118 + }
  119 +
  120 + public void setUpDown1(int upDown1) {
  121 + this.upDown1 = upDown1;
  122 + }
  123 +
  124 + public Date getCreateDate() {
  125 + return createDate;
  126 + }
  127 +
  128 + public void setCreateDate(Date createDate) {
  129 + this.createDate = createDate;
  130 + }
  131 +
  132 + public String getLastStopNo() {
  133 + return lastStopNo;
  134 + }
  135 +
  136 + public void setLastStopNo(String lastStopNo) {
  137 + this.lastStopNo = lastStopNo;
  138 + }
  139 +
  140 + public int getLastUpDown() {
  141 + return lastUpDown;
  142 + }
  143 +
  144 + public void setLastUpDown(int lastUpDown) {
  145 + this.lastUpDown = lastUpDown;
  146 + }
  147 +
  148 + public String toString() {
  149 + return "deviceID" + deviceId + "stopNo" + stopNo + "timestamp" + new Date(timestamp) + "inout" + inOut;
  150 + }
  151 +
  152 + @Override
  153 + public boolean equals(Object obj) {
  154 + HistoryArrival temp = (HistoryArrival)obj;
  155 + return temp.getTimestamp() == this.getTimestamp() && temp.getLon() == this.getLon() && temp.getLat() == this.getLat();
  156 + }
  157 +}
... ...
src/main/java/com/bsth/entity/HistoryGps.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/HistoryGps.java
  1 +package com.bsth.entity;
  2 +
  3 +public class HistoryGps {
  4 +
  5 + private int cityCode;
  6 + private int industryCode;
  7 + private int companyCode;
  8 + private int lineId;
  9 + private String deviceId;
  10 + private int driverNo;
  11 + private short carparkSerialNo;
  12 + private String carparkNo;
  13 + private short stopSerialNo;
  14 + private String stopNo;
  15 + private float lon;
  16 + private float lat;
  17 + private long timestamp;
  18 + private float speedSensor;
  19 + private float speedGps;
  20 + private float direction;
  21 + private byte inTemp;
  22 + private long serviceState;
  23 + private long controlState;
  24 + private float totalMiles;
  25 + private byte waterTemp;
  26 + private float oilConsumption;
  27 + private int engineSpeed;
  28 + private byte inOutStop;
  29 +
  30 + private long serverTimestamp;
  31 + private String sectionCode;
  32 +
  33 + public String getSectionCode() {
  34 + return sectionCode;
  35 + }
  36 +
  37 + public void setSectionCode(String sectionCode) {
  38 + this.sectionCode = sectionCode;
  39 + }
  40 +
  41 + public long getServerTimestamp() {
  42 + return serverTimestamp;
  43 + }
  44 +
  45 + public void setServerTimestamp(long serverTimestamp) {
  46 + this.serverTimestamp = serverTimestamp;
  47 + }
  48 +
  49 + public int getCityCode() {
  50 + return cityCode;
  51 + }
  52 +
  53 + public void setCityCode(int cityCode) {
  54 + this.cityCode = cityCode;
  55 + }
  56 +
  57 + public int getIndustryCode() {
  58 + return industryCode;
  59 + }
  60 +
  61 + public void setIndustryCode(int industryCode) {
  62 + this.industryCode = industryCode;
  63 + }
  64 +
  65 + public int getCompanyCode() {
  66 + return companyCode;
  67 + }
  68 +
  69 + public void setCompanyCode(int companyCode) {
  70 + this.companyCode = companyCode;
  71 + }
  72 +
  73 + public int getLineId() {
  74 + return lineId;
  75 + }
  76 +
  77 + public void setLineId(int lineId) {
  78 + this.lineId = lineId;
  79 + }
  80 +
  81 + public String getDeviceId() {
  82 + return deviceId;
  83 + }
  84 +
  85 + public void setDeviceId(String deviceId) {
  86 + this.deviceId = deviceId;
  87 + }
  88 +
  89 + public int getDriverNo() {
  90 + return driverNo;
  91 + }
  92 +
  93 + public void setDriverNo(int driverNo) {
  94 + this.driverNo = driverNo;
  95 + }
  96 +
  97 + public short getCarparkSerialNo() {
  98 + return carparkSerialNo;
  99 + }
  100 +
  101 + public void setCarparkSerialNo(short carparkSerialNo) {
  102 + this.carparkSerialNo = carparkSerialNo;
  103 + }
  104 +
  105 + public String getCarparkNo() {
  106 + return carparkNo;
  107 + }
  108 +
  109 + public void setCarparkNo(String carparkNo) {
  110 + this.carparkNo = carparkNo;
  111 + }
  112 +
  113 + public short getStopSerialNo() {
  114 + return stopSerialNo;
  115 + }
  116 +
  117 + public void setStopSerialNo(short stopSerialNo) {
  118 + this.stopSerialNo = stopSerialNo;
  119 + }
  120 +
  121 + public String getStopNo() {
  122 + return stopNo;
  123 + }
  124 +
  125 + public void setStopNo(String stopNo) {
  126 + this.stopNo = stopNo;
  127 + }
  128 +
  129 + public float getLon() {
  130 + return lon;
  131 + }
  132 +
  133 + public void setLon(float lon) {
  134 + this.lon = lon;
  135 + }
  136 +
  137 + public float getLat() {
  138 + return lat;
  139 + }
  140 +
  141 + public void setLat(float lat) {
  142 + this.lat = lat;
  143 + }
  144 +
  145 + public long getTimestamp() {
  146 + return timestamp;
  147 + }
  148 +
  149 + public void setTimestamp(long timestamp) {
  150 + this.timestamp = timestamp;
  151 + }
  152 +
  153 + public float getSpeedSensor() {
  154 + return speedSensor;
  155 + }
  156 +
  157 + public void setSpeedSensor(float speedSensor) {
  158 + this.speedSensor = speedSensor;
  159 + }
  160 +
  161 + public float getSpeedGps() {
  162 + return speedGps;
  163 + }
  164 +
  165 + public void setSpeedGps(float speedGps) {
  166 + this.speedGps = speedGps;
  167 + }
  168 +
  169 + public float getDirection() {
  170 + return direction;
  171 + }
  172 +
  173 + public void setDirection(float direction) {
  174 + this.direction = direction;
  175 + }
  176 +
  177 + public byte getInTemp() {
  178 + return inTemp;
  179 + }
  180 +
  181 + public void setInTemp(byte inTemp) {
  182 + this.inTemp = inTemp;
  183 + }
  184 +
  185 + public long getServiceState() {
  186 + return serviceState;
  187 + }
  188 +
  189 + public void setServiceState(long serviceState) {
  190 + this.serviceState = serviceState;
  191 + }
  192 +
  193 + public long getControlState() {
  194 + return controlState;
  195 + }
  196 +
  197 + public void setControlState(long controlState) {
  198 + this.controlState = controlState;
  199 + }
  200 +
  201 + public float getTotalMiles() {
  202 + return totalMiles;
  203 + }
  204 +
  205 + public void setTotalMiles(float totalMiles) {
  206 + this.totalMiles = totalMiles;
  207 + }
  208 +
  209 + public byte getWaterTemp() {
  210 + return waterTemp;
  211 + }
  212 +
  213 + public void setWaterTemp(byte waterTemp) {
  214 + this.waterTemp = waterTemp;
  215 + }
  216 +
  217 + public float getOilConsumption() {
  218 + return oilConsumption;
  219 + }
  220 +
  221 + public void setOilConsumption(float oilConsumption) {
  222 + this.oilConsumption = oilConsumption;
  223 + }
  224 +
  225 + public int getEngineSpeed() {
  226 + return engineSpeed;
  227 + }
  228 +
  229 + public void setEngineSpeed(int engineSpeed) {
  230 + this.engineSpeed = engineSpeed;
  231 + }
  232 +
  233 + public byte getInOutStop() {
  234 + return inOutStop;
  235 + }
  236 +
  237 + public void setInOutStop(byte inOutStop) {
  238 + this.inOutStop = inOutStop;
  239 + }
  240 +}
... ...
src/main/java/com/bsth/entity/LineInfo.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/LineInfo.java
  1 +package com.bsth.entity;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +
  6 +/**
  7 + * @author Hill
  8 + */
  9 +public class LineInfo {
  10 +
  11 + private final static double SPEEDING_LIMIT = 60;
  12 +
  13 + private int id;
  14 + private int lineId;
  15 + private String lineName;
  16 + private int startStation;
  17 + private String startStationName;
  18 + private String startStationFirstTime;
  19 + private String startStationEndTime;
  20 + private int endStation;
  21 + private String endStationName;
  22 + private String endStationFirstTime;
  23 + private String endStationEndTime;
  24 + private String company;
  25 + private String brancheCompany;
  26 + private double length;
  27 + private String telephone;
  28 + private double speedLimit;
  29 + private int linePlayType;
  30 + private int inUse;
  31 + // 上行分段路段
  32 + private List<SectionInfo> sectionsUp = new ArrayList<SectionInfo>();
  33 + // 下行分段路段
  34 + private List<SectionInfo> sectionsDown = new ArrayList<SectionInfo>();
  35 + // 上行站点
  36 + private List<StopInfo> stopsUp = new ArrayList<StopInfo>();
  37 + // 下行站点
  38 + private List<StopInfo> stopsDown = new ArrayList<StopInfo>();
  39 + // 回环站点
  40 + private List<SpecialStation> specailStation = new ArrayList<SpecialStation>();
  41 +
  42 + public double getSpeedLimit() {
  43 + if (speedLimit > 0) return speedLimit;
  44 + else return SPEEDING_LIMIT;
  45 + }
  46 +
  47 + public void setSpeedLimit(double speedLimit) {
  48 + this.speedLimit = speedLimit;
  49 + }
  50 +
  51 + public List<SectionInfo> getSectionsUp() {
  52 + return sectionsUp;
  53 + }
  54 +
  55 + public void setSectionsUp(List<SectionInfo> sectionsUp) {
  56 + this.sectionsUp = sectionsUp;
  57 + }
  58 +
  59 + public List<SectionInfo> getSectionsDown() {
  60 + return sectionsDown;
  61 + }
  62 +
  63 + public void setSectionsDown(List<SectionInfo> sectionsDown) {
  64 + this.sectionsDown = sectionsDown;
  65 + }
  66 +
  67 + public List<StopInfo> getStopsUp() {
  68 + return stopsUp;
  69 + }
  70 +
  71 + public void setStopsUp(List<StopInfo> stopsUp) {
  72 + this.stopsUp = stopsUp;
  73 + }
  74 +
  75 + public List<StopInfo> getStopsDown() {
  76 + return stopsDown;
  77 + }
  78 +
  79 + public void setStopsDown(List<StopInfo> stopsDown) {
  80 + this.stopsDown = stopsDown;
  81 + }
  82 +
  83 + public List<SpecialStation> getSpecailStation() {
  84 + return specailStation;
  85 + }
  86 +
  87 + public void setSpecailStation(List<SpecialStation> specailStation) {
  88 + this.specailStation = specailStation;
  89 + }
  90 +
  91 + public int getId() {
  92 + return id;
  93 + }
  94 +
  95 + public void setId(int id) {
  96 + this.id = id;
  97 + }
  98 +
  99 + public int getLineId() {
  100 + return lineId;
  101 + }
  102 +
  103 + public void setLineId(int lineId) {
  104 + this.lineId = lineId;
  105 + }
  106 +
  107 + public String getLineName() {
  108 + return lineName;
  109 + }
  110 +
  111 + public void setLineName(String lineName) {
  112 + this.lineName = lineName;
  113 + }
  114 +
  115 + public int getStartStation() {
  116 + return startStation;
  117 + }
  118 +
  119 + public void setStartStation(int startStation) {
  120 + this.startStation = startStation;
  121 + }
  122 +
  123 + public String getStartStationName() {
  124 + return startStationName;
  125 + }
  126 +
  127 + public void setStartStationName(String startStationName) {
  128 + this.startStationName = startStationName;
  129 + }
  130 +
  131 + public String getStartStationFirstTime() {
  132 + return startStationFirstTime;
  133 + }
  134 +
  135 + public void setStartStationFirstTime(String startStationFirstTime) {
  136 + this.startStationFirstTime = startStationFirstTime;
  137 + }
  138 +
  139 + public String getStartStationEndTime() {
  140 + return startStationEndTime;
  141 + }
  142 +
  143 + public void setStartStationEndTime(String startStationEndTime) {
  144 + this.startStationEndTime = startStationEndTime;
  145 + }
  146 +
  147 + public int getEndStation() {
  148 + return endStation;
  149 + }
  150 +
  151 + public void setEndStation(int endStation) {
  152 + this.endStation = endStation;
  153 + }
  154 +
  155 + public String getEndStationName() {
  156 + return endStationName;
  157 + }
  158 +
  159 + public void setEndStationName(String endStationName) {
  160 + this.endStationName = endStationName;
  161 + }
  162 +
  163 + public String getEndStationFirstTime() {
  164 + return endStationFirstTime;
  165 + }
  166 +
  167 + public void setEndStationFirstTime(String endStationFirstTime) {
  168 + this.endStationFirstTime = endStationFirstTime;
  169 + }
  170 +
  171 + public String getEndStationEndTime() {
  172 + return endStationEndTime;
  173 + }
  174 +
  175 + public void setEndStationEndTime(String endStationEndTime) {
  176 + this.endStationEndTime = endStationEndTime;
  177 + }
  178 +
  179 + public String getCompany() {
  180 + return company;
  181 + }
  182 +
  183 + public void setCompany(String company) {
  184 + this.company = company;
  185 + }
  186 +
  187 + public String getBrancheCompany() {
  188 + return brancheCompany;
  189 + }
  190 +
  191 + public void setBrancheCompany(String brancheCompany) {
  192 + this.brancheCompany = brancheCompany;
  193 + }
  194 +
  195 + public double getLength() {
  196 + return length;
  197 + }
  198 +
  199 + public void setLength(double length) {
  200 + this.length = length;
  201 + }
  202 +
  203 + public String getTelephone() {
  204 + return telephone;
  205 + }
  206 +
  207 + public void setTelephone(String telephone) {
  208 + this.telephone = telephone;
  209 + }
  210 +
  211 + public int getLinePlayType() {
  212 + return linePlayType;
  213 + }
  214 +
  215 + public void setLinePlayType(int linePlayType) {
  216 + this.linePlayType = linePlayType;
  217 + }
  218 +
  219 + public int getInUse() {
  220 + return inUse;
  221 + }
  222 +
  223 + public void setInUse(int inUse) {
  224 + this.inUse = inUse;
  225 + }
  226 +}
... ...
src/main/java/com/bsth/entity/LineStandInfo.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/LineStandInfo.java
  1 +package com.bsth.entity;
  2 +
  3 +public class LineStandInfo {
  4 +
  5 + private int id;
  6 + private String type;
  7 + private String earlyStartTime;
  8 + private String earlyEndTime;
  9 + private String lateStartTime;
  10 + private String lateEndTime;
  11 + /* 大间隔start */
  12 + private double earlyInterval;
  13 + private double lateInterval;
  14 + private double interval;
  15 + /* 大间隔end */
  16 + /* 限速start */
  17 + private double speedLimit;
  18 + private double rainSpeedLimit;
  19 + private double fogSpeedLimit;
  20 + private double snowSpeedLimit;
  21 + private double festivalSpeedLimit;
  22 + /* 限速end */
  23 +
  24 + public int getId() {
  25 + return id;
  26 + }
  27 +
  28 + public void setId(int id) {
  29 + this.id = id;
  30 + }
  31 +
  32 + public String getType() {
  33 + return type;
  34 + }
  35 +
  36 + public void setType(String type) {
  37 + this.type = type;
  38 + }
  39 +
  40 + public String getEarlyStartTime() {
  41 + return earlyStartTime;
  42 + }
  43 +
  44 + public void setEarlyStartTime(String earlyStartTime) {
  45 + this.earlyStartTime = earlyStartTime;
  46 + }
  47 +
  48 + public String getEarlyEndTime() {
  49 + return earlyEndTime;
  50 + }
  51 +
  52 + public void setEarlyEndTime(String earlyEndTime) {
  53 + this.earlyEndTime = earlyEndTime;
  54 + }
  55 +
  56 + public String getLateStartTime() {
  57 + return lateStartTime;
  58 + }
  59 +
  60 + public void setLateStartTime(String lateStartTime) {
  61 + this.lateStartTime = lateStartTime;
  62 + }
  63 +
  64 + public String getLateEndTime() {
  65 + return lateEndTime;
  66 + }
  67 +
  68 + public void setLateEndTime(String lateEndTime) {
  69 + this.lateEndTime = lateEndTime;
  70 + }
  71 +
  72 + public double getEarlyInterval() {
  73 + return earlyInterval;
  74 + }
  75 +
  76 + public void setEarlyInterval(double earlyInterval) {
  77 + this.earlyInterval = earlyInterval;
  78 + }
  79 +
  80 + public double getLateInterval() {
  81 + return lateInterval;
  82 + }
  83 +
  84 + public void setLateInterval(double lateInterval) {
  85 + this.lateInterval = lateInterval;
  86 + }
  87 +
  88 + public double getInterval() {
  89 + return interval;
  90 + }
  91 +
  92 + public void setInterval(double interval) {
  93 + this.interval = interval;
  94 + }
  95 +
  96 + public double getSpeedLimit() {
  97 + return speedLimit;
  98 + }
  99 +
  100 + public void setSpeedLimit(double speedLimit) {
  101 + this.speedLimit = speedLimit;
  102 + }
  103 +
  104 + public double getRainSpeedLimit() {
  105 + return rainSpeedLimit;
  106 + }
  107 +
  108 + public void setRainSpeedLimit(double rainSpeedLimit) {
  109 + this.rainSpeedLimit = rainSpeedLimit;
  110 + }
  111 +
  112 + public double getFogSpeedLimit() {
  113 + return fogSpeedLimit;
  114 + }
  115 +
  116 + public void setFogSpeedLimit(double fogSpeedLimit) {
  117 + this.fogSpeedLimit = fogSpeedLimit;
  118 + }
  119 +
  120 + public double getSnowSpeedLimit() {
  121 + return snowSpeedLimit;
  122 + }
  123 +
  124 + public void setSnowSpeedLimit(double snowSpeedLimit) {
  125 + this.snowSpeedLimit = snowSpeedLimit;
  126 + }
  127 +
  128 + public double getFestivalSpeedLimit() {
  129 + return festivalSpeedLimit;
  130 + }
  131 +
  132 + public void setFestivalSpeedLimit(double festivalSpeedLimit) {
  133 + this.festivalSpeedLimit = festivalSpeedLimit;
  134 + }
  135 +}
... ...
src/main/java/com/bsth/entity/OfflineData.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/OfflineData.java
  1 +package com.bsth.entity;
  2 +
  3 +import java.util.Date;
  4 +
  5 +public class OfflineData {
  6 +
  7 + private int id;
  8 + private String vehicle;
  9 + private int line;
  10 + private int upDown;
  11 + private float lon;
  12 + private float lat;
  13 + private long timestamp;
  14 + private Date createDate;
  15 +
  16 + public OfflineData() {
  17 +
  18 + }
  19 +
  20 + public OfflineData(RealTimeGps gps) {
  21 + vehicle = gps.getVehicle();
  22 + line = gps.getLineId();
  23 + upDown = gps.getUpDown();
  24 + lon = gps.getLon();
  25 + lat = gps.getLat();
  26 + timestamp = gps.getTimestamp();
  27 + }
  28 +
  29 + public int getId() {
  30 + return id;
  31 + }
  32 +
  33 + public void setId(int id) {
  34 + this.id = id;
  35 + }
  36 +
  37 + public String getVehicle() {
  38 + return vehicle;
  39 + }
  40 +
  41 + public void setVehicle(String vehicle) {
  42 + this.vehicle = vehicle;
  43 + }
  44 +
  45 + public int getLine() {
  46 + return line;
  47 + }
  48 +
  49 + public void setLine(int line) {
  50 + this.line = line;
  51 + }
  52 +
  53 + public int getUpDown() {
  54 + return upDown;
  55 + }
  56 +
  57 + public void setUpDown(int upDown) {
  58 + this.upDown = upDown;
  59 + }
  60 +
  61 + public float getLon() {
  62 + return lon;
  63 + }
  64 +
  65 + public void setLon(float lon) {
  66 + this.lon = lon;
  67 + }
  68 +
  69 + public float getLat() {
  70 + return lat;
  71 + }
  72 +
  73 + public void setLat(float lat) {
  74 + this.lat = lat;
  75 + }
  76 +
  77 + public long getTimestamp() {
  78 + return timestamp;
  79 + }
  80 +
  81 + public void setTimestamp(long timestamp) {
  82 + this.timestamp = timestamp;
  83 + }
  84 +
  85 + public Date getCreateDate() {
  86 + return createDate;
  87 + }
  88 +
  89 + public void setCreateDate(Date createDate) {
  90 + this.createDate = createDate;
  91 + }
  92 +}
... ...
src/main/java/com/bsth/entity/OutboundData.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/OutboundData.java
  1 +package com.bsth.entity;
  2 +
  3 +import java.util.Date;
  4 +
  5 +public class OutboundData {
  6 +
  7 + private int id;
  8 + private String vehicle;
  9 + private int line;
  10 + private int upDown;
  11 + private float lon;
  12 + private float lat;
  13 + private String location;
  14 + private long timestamp;
  15 + private Date createDate;
  16 +
  17 + public OutboundData() {
  18 +
  19 + }
  20 +
  21 + public OutboundData(RealTimeGps gps) {
  22 + vehicle = gps.getVehicle();
  23 + line = gps.getLineId();
  24 + upDown = gps.getUpDown();
  25 + lon = gps.getLon();
  26 + lat = gps.getLat();
  27 + timestamp = gps.getTimestamp();
  28 + }
  29 +
  30 + public int getId() {
  31 + return id;
  32 + }
  33 +
  34 + public void setId(int id) {
  35 + this.id = id;
  36 + }
  37 +
  38 + public String getVehicle() {
  39 + return vehicle;
  40 + }
  41 +
  42 + public void setVehicle(String vehicle) {
  43 + this.vehicle = vehicle;
  44 + }
  45 +
  46 + public int getLine() {
  47 + return line;
  48 + }
  49 +
  50 + public void setLine(int line) {
  51 + this.line = line;
  52 + }
  53 +
  54 + public int getUpDown() {
  55 + return upDown;
  56 + }
  57 +
  58 + public void setUpDown(int upDown) {
  59 + this.upDown = upDown;
  60 + }
  61 +
  62 + public float getLon() {
  63 + return lon;
  64 + }
  65 +
  66 + public void setLon(float lon) {
  67 + this.lon = lon;
  68 + }
  69 +
  70 + public float getLat() {
  71 + return lat;
  72 + }
  73 +
  74 + public void setLat(float lat) {
  75 + this.lat = lat;
  76 + }
  77 +
  78 + public String getLocation() {
  79 + return location;
  80 + }
  81 +
  82 + public void setLocation(String location) {
  83 + this.location = location;
  84 + }
  85 +
  86 + public long getTimestamp() {
  87 + return timestamp;
  88 + }
  89 +
  90 + public void setTimestamp(long timestamp) {
  91 + this.timestamp = timestamp;
  92 + }
  93 +
  94 + public Date getCreateDate() {
  95 + return createDate;
  96 + }
  97 +
  98 + public void setCreateDate(Date createDate) {
  99 + this.createDate = createDate;
  100 + }
  101 +}
... ...
src/main/java/com/bsth/entity/PeakData.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/PeakData.java
  1 +package com.bsth.entity;
  2 +
  3 +import com.bsth.socket.protocol.Message0206;
  4 +import org.springframework.beans.BeanUtils;
  5 +
  6 +/**
  7 + * @author Hill
  8 + * 极值数据
  9 + */
  10 +public class PeakData extends Data {
  11 +
  12 + /**
  13 + * 最高电压电池子系统代码 1-250
  14 + * 0xfe 异常
  15 + * 0xff 无效
  16 + */
  17 + private short maxVoltageSubSysCode;
  18 +
  19 + /**
  20 + * 最高电压电池单体代码 1-250
  21 + * 0xfe 异常
  22 + * 0xff 无效
  23 + */
  24 + private short maxVoltageSubCode;
  25 +
  26 + /**
  27 + * 电池单体电压最高值 0-15000
  28 + * 分辨率0.001v
  29 + * 0xff 0xfe 异常
  30 + * 0xff 0xff 无效
  31 + */
  32 + private short maxVoltage;
  33 +
  34 + /**
  35 + * 最低电压电池子系统代码 1-250
  36 + * 0xfe 异常
  37 + * 0xff 无效
  38 + */
  39 + private short minVoltageSubSysCode;
  40 +
  41 + /**
  42 + * 最低电压电池单体代码 1-250
  43 + * 0xfe 异常
  44 + * 0xff 无效
  45 + */
  46 + private short minVoltageSubCode;
  47 +
  48 + /**
  49 + * 电池单体电压最低值 0-15000
  50 + * 分辨率0.001v
  51 + * 0xff 0xfe 异常
  52 + * 0xff 0xff 无效
  53 + */
  54 + private short minVoltage;
  55 +
  56 + /**
  57 + * 最高温度子系统代码 1-250
  58 + * 0xfe 异常
  59 + * 0xff 无效
  60 + */
  61 + private short maxTempSubSysCode;
  62 +
  63 + /**
  64 + * 最高温度探针代码 1-250
  65 + * 0xfe 异常
  66 + * 0xff 无效
  67 + */
  68 + private short maxTempSensorCode;
  69 +
  70 + /**
  71 + * 最高温度值 0-250
  72 + * 分辨率1℃ 偏移量-40
  73 + * 0xfe 异常
  74 + * 0xff 无效
  75 + */
  76 + private short maxTemp;
  77 +
  78 + /**
  79 + * 最低温度子系统代码 1-250
  80 + * 0xfe 异常
  81 + * 0xff 无效
  82 + */
  83 + private short minTempSubSysCode;
  84 +
  85 + /**
  86 + * 最低温度探针代码 1-250
  87 + * 0xfe 异常
  88 + * 0xff 无效
  89 + */
  90 + private short minTempSensorCode;
  91 +
  92 + /**
  93 + * 最低温度值 0-250
  94 + * 分辨率1℃ 偏移量-40
  95 + * 0xfe 异常
  96 + * 0xff 无效
  97 + */
  98 + private short minTemp;
  99 +
  100 + public PeakData() {
  101 +
  102 + }
  103 +
  104 + public PeakData(Message0206 message0206) {
  105 + BeanUtils.copyProperties(message0206, this);
  106 + this.maxVoltageSubSysCode &= (short) 0xFF;
  107 + this.maxVoltageSubCode &= (short) 0xFF;
  108 + this.minVoltageSubSysCode &= (short) 0xFF;
  109 + this.minVoltageSubCode &= (short) 0xFF;
  110 + this.maxTempSubSysCode &= (short) 0xFF;
  111 + this.maxTempSensorCode &= (short) 0xFF;
  112 + this.maxTemp -= 40;
  113 + this.minTempSubSysCode &= (short) 0xFF;
  114 + this.minTempSensorCode &= (short) 0xFF;
  115 + this.minTemp -= 40;
  116 + }
  117 +
  118 + public short getMaxVoltageSubSysCode() {
  119 + return maxVoltageSubSysCode;
  120 + }
  121 +
  122 + public void setMaxVoltageSubSysCode(short maxVoltageSubSysCode) {
  123 + this.maxVoltageSubSysCode = maxVoltageSubSysCode;
  124 + }
  125 +
  126 + public short getMaxVoltageSubCode() {
  127 + return maxVoltageSubCode;
  128 + }
  129 +
  130 + public void setMaxVoltageSubCode(short maxVoltageSubCode) {
  131 + this.maxVoltageSubCode = maxVoltageSubCode;
  132 + }
  133 +
  134 + public short getMaxVoltage() {
  135 + return maxVoltage;
  136 + }
  137 +
  138 + public void setMaxVoltage(short maxVoltage) {
  139 + this.maxVoltage = maxVoltage;
  140 + }
  141 +
  142 + public short getMinVoltageSubSysCode() {
  143 + return minVoltageSubSysCode;
  144 + }
  145 +
  146 + public void setMinVoltageSubSysCode(short minVoltageSubSysCode) {
  147 + this.minVoltageSubSysCode = minVoltageSubSysCode;
  148 + }
  149 +
  150 + public short getMinVoltageSubCode() {
  151 + return minVoltageSubCode;
  152 + }
  153 +
  154 + public void setMinVoltageSubCode(short minVoltageSubCode) {
  155 + this.minVoltageSubCode = minVoltageSubCode;
  156 + }
  157 +
  158 + public short getMinVoltage() {
  159 + return minVoltage;
  160 + }
  161 +
  162 + public void setMinVoltage(short minVoltage) {
  163 + this.minVoltage = minVoltage;
  164 + }
  165 +
  166 + public short getMaxTempSubSysCode() {
  167 + return maxTempSubSysCode;
  168 + }
  169 +
  170 + public void setMaxTempSubSysCode(short maxTempSubSysCode) {
  171 + this.maxTempSubSysCode = maxTempSubSysCode;
  172 + }
  173 +
  174 + public short getMaxTempSensorCode() {
  175 + return maxTempSensorCode;
  176 + }
  177 +
  178 + public void setMaxTempSensorCode(short maxTempSensorCode) {
  179 + this.maxTempSensorCode = maxTempSensorCode;
  180 + }
  181 +
  182 + public short getMaxTemp() {
  183 + return maxTemp;
  184 + }
  185 +
  186 + public void setMaxTemp(short maxTemp) {
  187 + this.maxTemp = maxTemp;
  188 + }
  189 +
  190 + public short getMinTempSubSysCode() {
  191 + return minTempSubSysCode;
  192 + }
  193 +
  194 + public void setMinTempSubSysCode(short minTempSubSysCode) {
  195 + this.minTempSubSysCode = minTempSubSysCode;
  196 + }
  197 +
  198 + public short getMinTempSensorCode() {
  199 + return minTempSensorCode;
  200 + }
  201 +
  202 + public void setMinTempSensorCode(short minTempSensorCode) {
  203 + this.minTempSensorCode = minTempSensorCode;
  204 + }
  205 +
  206 + public short getMinTemp() {
  207 + return minTemp;
  208 + }
  209 +
  210 + public void setMinTemp(short minTemp) {
  211 + this.minTemp = minTemp;
  212 + }
  213 +
  214 + @Override
  215 + public String toString() {
  216 + StringBuilder sb = new StringBuilder();
  217 + sb.append(" 最大电压子系统编码: ").append(maxVoltageSubSysCode)
  218 + .append(" 最大电压子单体代号: ").append(maxVoltageSubCode)
  219 + .append(" 电池单体电压最高值: ").append(maxVoltage)
  220 + .append(" 最低电压子系统编码: ").append(minVoltageSubSysCode)
  221 + .append(" 最低电压子单体代号: ").append(minVoltageSubCode)
  222 + .append(" 电池单体电压最低值: ").append(minVoltage)
  223 + .append(" 最高温度子系统代码: ").append(maxTempSubSysCode)
  224 + .append(" 最高温度探针代码: ").append(maxTempSensorCode)
  225 + .append(" 最高温度值: ").append(maxTemp)
  226 + .append(" 最低温度子系统代码: ").append(maxTempSubSysCode)
  227 + .append(" 最低温度探针代码: ").append(maxTempSensorCode)
  228 + .append(" 最低温度值: ").append(maxTemp);
  229 +
  230 + return sb.toString();
  231 + }
  232 +
  233 + @Override
  234 + public String getType() {
  235 + return "peak_data";
  236 + }
  237 +}
... ...
src/main/java/com/bsth/entity/RealTimeGps.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/RealTimeGps.java
  1 +package com.bsth.entity;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +public class RealTimeGps implements Serializable {
  6 +
  7 + private static final long serialVersionUID = -8996943161741177815L;
  8 + private int companyCode;
  9 + private int lineId;
  10 + private String deviceId;
  11 + private String carparkNo;
  12 + private String stopNo;
  13 + private float lon;
  14 + private float lat;
  15 + private long timestamp;
  16 + private float speed;
  17 + private float direction;
  18 + // 营运状态
  19 + private byte state = (byte)-1;
  20 + // 上下行 -1无效 0上行 1下行
  21 + private byte upDown;
  22 + // 站内外 -1无效 0站外 1站内
  23 + private byte inOrOutStation;
  24 + // 场内外 -1无效 0场外 1场内
  25 + private byte inOrOutCarpark;
  26 + // 车辆内部编码
  27 + private String vehicle;
  28 +
  29 + private byte valid = (byte)0;
  30 + // 版本号
  31 + private short version;
  32 +
  33 + private String insideCode;
  34 +
  35 + private long serverTimestamp;
  36 + private String sectionCode;
  37 +
  38 + public String getSectionCode() {
  39 + return sectionCode;
  40 + }
  41 +
  42 + public void setSectionCode(String sectionCode) {
  43 + this.sectionCode = sectionCode;
  44 + }
  45 +
  46 + public short getVersion() {
  47 + return version;
  48 + }
  49 +
  50 + public void setVersion(short version) {
  51 + this.version = version;
  52 + }
  53 +
  54 + public long getServerTimestamp() {
  55 + return serverTimestamp;
  56 + }
  57 +
  58 + public void setServerTimestamp(long serverTimestamp) {
  59 + this.serverTimestamp = serverTimestamp;
  60 + }
  61 +
  62 + public byte getValid() {
  63 + return valid;
  64 + }
  65 +
  66 + public void setValid(byte valid) {
  67 + this.valid = valid;
  68 + }
  69 +
  70 + public String getVehicle() {
  71 + return vehicle;
  72 + }
  73 +
  74 + public void setVehicle(String vehicle) {
  75 + this.vehicle = vehicle;
  76 + }
  77 +
  78 + public byte getInOrOutStation() {
  79 + return inOrOutStation;
  80 + }
  81 +
  82 + public void setInOrOutStation(byte inOrOutStation) {
  83 + this.inOrOutStation = inOrOutStation;
  84 + }
  85 +
  86 + public byte getInOrOutCarpark() {
  87 + return inOrOutCarpark;
  88 + }
  89 +
  90 + public void setInOrOutCarpark(byte inOrOutCarpark) {
  91 + this.inOrOutCarpark = inOrOutCarpark;
  92 + }
  93 +
  94 + public int getCompanyCode() {
  95 + return companyCode;
  96 + }
  97 +
  98 + public void setCompanyCode(int companyCode) {
  99 + this.companyCode = companyCode;
  100 + }
  101 +
  102 + public int getLineId() {
  103 + return lineId;
  104 + }
  105 +
  106 + public void setLineId(int lineId) {
  107 + this.lineId = lineId;
  108 + }
  109 +
  110 + public String getDeviceId() {
  111 + return deviceId;
  112 + }
  113 +
  114 + public void setDeviceId(String deviceId) {
  115 + this.deviceId = deviceId;
  116 + }
  117 +
  118 + public String getCarparkNo() {
  119 + return carparkNo;
  120 + }
  121 +
  122 + public void setCarparkNo(String carparkNo) {
  123 + this.carparkNo = carparkNo;
  124 + }
  125 +
  126 + public String getStopNo() {
  127 + return stopNo;
  128 + }
  129 +
  130 + public void setStopNo(String stopNo) {
  131 + this.stopNo = stopNo;
  132 + }
  133 +
  134 + public float getLon() {
  135 + return lon;
  136 + }
  137 +
  138 + public void setLon(float lon) {
  139 + this.lon = lon;
  140 + }
  141 +
  142 + public float getLat() {
  143 + return lat;
  144 + }
  145 +
  146 + public void setLat(float lat) {
  147 + this.lat = lat;
  148 + }
  149 +
  150 + public long getTimestamp() {
  151 + return timestamp;
  152 + }
  153 +
  154 + public void setTimestamp(long timestamp) {
  155 + this.timestamp = timestamp;
  156 + }
  157 +
  158 + public float getSpeed() {
  159 + return speed;
  160 + }
  161 +
  162 + public void setSpeed(float speed) {
  163 + this.speed = speed;
  164 + }
  165 +
  166 + public float getDirection() {
  167 + return direction;
  168 + }
  169 +
  170 + public void setDirection(float direction) {
  171 + this.direction = direction;
  172 + }
  173 +
  174 + public byte getState() {
  175 + return state;
  176 + }
  177 +
  178 + public void setState(byte state) {
  179 + this.state = state;
  180 + }
  181 +
  182 + public byte getUpDown() {
  183 + return upDown;
  184 + }
  185 +
  186 + public void setUpDown(byte upDown) {
  187 + this.upDown = upDown;
  188 + }
  189 +
  190 + public String getInsideCode() {
  191 + return insideCode;
  192 + }
  193 +
  194 + public void setInsideCode(String insideCode) {
  195 + this.insideCode = insideCode;
  196 + }
  197 +}
... ...
src/main/java/com/bsth/entity/SectionGrid.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/SectionGrid.java
  1 +package com.bsth.entity;
  2 +
  3 +import java.util.HashSet;
  4 +import java.util.Set;
  5 +
  6 +public class SectionGrid {
  7 +
  8 + private Set<SectionInfo> secs = new HashSet<SectionInfo>();
  9 +
  10 + public Set<SectionInfo> getSecs() {
  11 + return secs;
  12 + }
  13 +}
... ...
src/main/java/com/bsth/entity/SectionInfo.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/SectionInfo.java
  1 +package com.bsth.entity;
  2 +
  3 +import java.util.List;
  4 +
  5 +import com.bsth.geo.Point;
  6 +
  7 +/**
  8 + * @author Hill
  9 + */
  10 +public class SectionInfo {
  11 +
  12 + private final static double SPEEDING_LIMIT = 60;
  13 +
  14 + private int id;
  15 + private String sectionCode;
  16 + private String roadCoding;
  17 + private String sectionName;
  18 + private double sectionDistance;
  19 + private double speedLimit;
  20 + private List<Point> points;
  21 +
  22 + private int lineId;
  23 + private int lineCode;
  24 + private int directions;
  25 +
  26 + private int isRoadeSpeed;
  27 +
  28 + public int getIsRoadeSpeed() {
  29 + return isRoadeSpeed;
  30 + }
  31 +
  32 + public void setIsRoadeSpeed(int isRoadeSpeed) {
  33 + this.isRoadeSpeed = isRoadeSpeed;
  34 + }
  35 +
  36 + public int getDirections() {
  37 + return directions;
  38 + }
  39 +
  40 + public void setDirections(int directions) {
  41 + this.directions = directions;
  42 + }
  43 +
  44 + public int getLineId() {
  45 + return lineId;
  46 + }
  47 +
  48 + public void setLineId(int lineId) {
  49 + this.lineId = lineId;
  50 + }
  51 +
  52 + public List<Point> getPoints() {
  53 + return points;
  54 + }
  55 +
  56 + public void setPoints(List<Point> points) {
  57 + this.points = points;
  58 + }
  59 +
  60 + public int getId() {
  61 + return id;
  62 + }
  63 +
  64 + public void setId(int id) {
  65 + this.id = id;
  66 + }
  67 +
  68 + public String getSectionCode() {
  69 + return sectionCode;
  70 + }
  71 +
  72 + public void setSectionCode(String sectionCode) {
  73 + this.sectionCode = sectionCode;
  74 + }
  75 +
  76 + public String getRoadCoding() {
  77 + return roadCoding;
  78 + }
  79 +
  80 + public void setRoadCoding(String roadCoding) {
  81 + this.roadCoding = roadCoding;
  82 + }
  83 +
  84 + public String getSectionName() {
  85 + return sectionName;
  86 + }
  87 +
  88 + public void setSectionName(String sectionName) {
  89 + this.sectionName = sectionName;
  90 + }
  91 +
  92 + public double getSectionDistance() {
  93 + return sectionDistance;
  94 + }
  95 +
  96 + public void setSectionDistance(double sectionDistance) {
  97 + this.sectionDistance = sectionDistance;
  98 + }
  99 +
  100 + public double getSpeedLimit() {
  101 + if (speedLimit > 0) return speedLimit;
  102 + else return SPEEDING_LIMIT;
  103 + }
  104 +
  105 + public void setSpeedLimit(double speedLimit) {
  106 + this.speedLimit = speedLimit;
  107 + }
  108 +
  109 + public int getLineCode() {
  110 + return lineCode;
  111 + }
  112 +
  113 + public void setLineCode(int lineCode) {
  114 + this.lineCode = lineCode;
  115 + }
  116 +}
... ...
src/main/java/com/bsth/entity/SpecialStation.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/SpecialStation.java
  1 +package com.bsth.entity;
  2 +
  3 +/**
  4 + * 对付线路回环的情况(如起点站->第四站->起点站)
  5 + * @author Hill
  6 + *
  7 + */
  8 +public class SpecialStation {
  9 +
  10 + private int lineId;
  11 +
  12 + private String stopNo;
  13 +
  14 + private String lastStopNo;
  15 +
  16 + public int getLineId() {
  17 + return lineId;
  18 + }
  19 +
  20 + public void setLineId(int lineId) {
  21 + this.lineId = lineId;
  22 + }
  23 +
  24 + public String getStopNo() {
  25 + return stopNo;
  26 + }
  27 +
  28 + public void setStopNo(String stopNo) {
  29 + this.stopNo = stopNo;
  30 + }
  31 +
  32 + public String getLastStopNo() {
  33 + return lastStopNo;
  34 + }
  35 +
  36 + public void setLastStopNo(String lastStopNo) {
  37 + this.lastStopNo = lastStopNo;
  38 + }
  39 +}
... ...
src/main/java/com/bsth/entity/SpeedingData.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/SpeedingData.java
  1 +package com.bsth.entity;
  2 +
  3 +import java.util.Date;
  4 +
  5 +public class SpeedingData {
  6 +
  7 + private int id;
  8 + private String vehicle;
  9 + private int line;
  10 + private int upDown;
  11 + private float lon;
  12 + private float lat;
  13 + private float speed;
  14 + private long timestamp;
  15 + private Date createDate;
  16 +
  17 + public SpeedingData() {
  18 +
  19 + }
  20 +
  21 + public SpeedingData(RealTimeGps gps) {
  22 + vehicle = gps.getVehicle();
  23 + line = gps.getLineId();
  24 + upDown = gps.getUpDown();
  25 + lon = gps.getLon();
  26 + lat = gps.getLat();
  27 + speed = gps.getSpeed();
  28 + timestamp = gps.getTimestamp();
  29 + }
  30 +
  31 + public int getId() {
  32 + return id;
  33 + }
  34 +
  35 + public void setId(int id) {
  36 + this.id = id;
  37 + }
  38 +
  39 + public String getVehicle() {
  40 + return vehicle;
  41 + }
  42 +
  43 + public void setVehicle(String vehicle) {
  44 + this.vehicle = vehicle;
  45 + }
  46 +
  47 + public int getLine() {
  48 + return line;
  49 + }
  50 +
  51 + public void setLine(int line) {
  52 + this.line = line;
  53 + }
  54 +
  55 + public int getUpDown() {
  56 + return upDown;
  57 + }
  58 +
  59 + public void setUpDown(int upDown) {
  60 + this.upDown = upDown;
  61 + }
  62 +
  63 + public float getLon() {
  64 + return lon;
  65 + }
  66 +
  67 + public void setLon(float lon) {
  68 + this.lon = lon;
  69 + }
  70 +
  71 + public float getLat() {
  72 + return lat;
  73 + }
  74 +
  75 + public void setLat(float lat) {
  76 + this.lat = lat;
  77 + }
  78 +
  79 + public float getSpeed() {
  80 + return speed;
  81 + }
  82 +
  83 + public void setSpeed(float speed) {
  84 + this.speed = speed;
  85 + }
  86 +
  87 + public long getTimestamp() {
  88 + return timestamp;
  89 + }
  90 +
  91 + public void setTimestamp(long timestamp) {
  92 + this.timestamp = timestamp;
  93 + }
  94 +
  95 + public Date getCreateDate() {
  96 + return createDate;
  97 + }
  98 +
  99 + public void setCreateDate(Date createDate) {
  100 + this.createDate = createDate;
  101 + }
  102 +}
... ...
src/main/java/com/bsth/entity/StopInfo.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/StopInfo.java
  1 +package com.bsth.entity;
  2 +
  3 +import java.util.List;
  4 +
  5 +import com.bsth.geo.Point;
  6 +
  7 +public class StopInfo {
  8 +
  9 + private int id;
  10 + private String stationCod;
  11 + private String stationName;
  12 + private String stationType;
  13 + private String roadCoding;
  14 + private Point point;
  15 + private String shapesType;
  16 + private int radius;
  17 + private List<Point> points;
  18 + private double distances;
  19 +
  20 + private int lineId;
  21 + private int lineCode;
  22 + private int directions;
  23 +
  24 + public double getDistances() {
  25 + return distances;
  26 + }
  27 +
  28 + public void setDistances(double distances) {
  29 + this.distances = distances;
  30 + }
  31 +
  32 + public int getRadius() {
  33 + return radius;
  34 + }
  35 +
  36 + public void setRadius(int radius) {
  37 + this.radius = radius;
  38 + }
  39 +
  40 + public List<Point> getPoints() {
  41 + return points;
  42 + }
  43 +
  44 + public void setPoints(List<Point> points) {
  45 + this.points = points;
  46 + }
  47 +
  48 + public String getShapesType() {
  49 + return shapesType;
  50 + }
  51 +
  52 + public void setShapesType(String shapesType) {
  53 + this.shapesType = shapesType;
  54 + }
  55 +
  56 + public int getDirections() {
  57 + return directions;
  58 + }
  59 +
  60 + public void setDirections(int directions) {
  61 + this.directions = directions;
  62 + }
  63 +
  64 + public int getLineId() {
  65 + return lineId;
  66 + }
  67 +
  68 + public void setLineId(int lineId) {
  69 + this.lineId = lineId;
  70 + }
  71 +
  72 + public Point getPoint() {
  73 + return point;
  74 + }
  75 +
  76 + public void setPoint(Point point) {
  77 + this.point = point;
  78 + }
  79 +
  80 + public int getId() {
  81 + return id;
  82 + }
  83 +
  84 + public void setId(int id) {
  85 + this.id = id;
  86 + }
  87 +
  88 + public String getStationCod() {
  89 + return stationCod;
  90 + }
  91 +
  92 + public void setStationCod(String stationCod) {
  93 + this.stationCod = stationCod;
  94 + }
  95 +
  96 + public String getStationName() {
  97 + return stationName;
  98 + }
  99 +
  100 + public void setStationName(String stationName) {
  101 + this.stationName = stationName;
  102 + }
  103 +
  104 + public String getStationType() {
  105 + return stationType;
  106 + }
  107 +
  108 + public void setStationType(String stationType) {
  109 + this.stationType = stationType;
  110 + }
  111 +
  112 + public String getRoadCoding() {
  113 + return roadCoding;
  114 + }
  115 +
  116 + public void setRoadCoding(String roadCoding) {
  117 + this.roadCoding = roadCoding;
  118 + }
  119 +
  120 + public int getLineCode() {
  121 + return lineCode;
  122 + }
  123 +
  124 + public void setLineCode(int lineCode) {
  125 + this.lineCode = lineCode;
  126 + }
  127 +}
... ...
src/main/java/com/bsth/entity/VehicleData.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/entity/VehicleData.java
  1 +package com.bsth.entity;
  2 +
  3 +import com.bsth.socket.protocol.Message0201;
  4 +import com.fasterxml.jackson.annotation.JsonIgnore;
  5 +import com.fasterxml.jackson.annotation.JsonProperty;
  6 +import org.springframework.beans.BeanUtils;
  7 +
  8 +/**
  9 + * @author Hill
  10 + * 整车数据
  11 + */
  12 +public class VehicleData extends Data {
  13 +
  14 + /**
  15 + * 车辆状态
  16 + * 0x01 车辆启动
  17 + * 0x02 车辆熄火
  18 + * 0x03 其它
  19 + * 0xFE 异常
  20 + * 0xFF 无效
  21 + */
  22 + private byte vehicleState;
  23 +
  24 + /**
  25 + * 充电状态
  26 + * 0x01 停车充电
  27 + * 0x02 行驶充电
  28 + * 0x03 未充电
  29 + * 0x04 充电完成
  30 + * 0xFE 异常
  31 + * 0xFF 无效
  32 + */
  33 + private byte chargeState;
  34 +
  35 + /**
  36 + * 运行模式
  37 + * 0x01 纯电
  38 + * 0x02 混动
  39 + * 0x03 燃油
  40 + * 0xFE 异常
  41 + * 0xFF 无效
  42 + */
  43 + private byte runMode;
  44 +
  45 + /**
  46 + * 车速 0-2200
  47 + * 分辨率0.1km/h
  48 + * 0xff 0xfe 异常
  49 + * 0xff 0xff 无效
  50 + */
  51 + private short speed;
  52 +
  53 + /**
  54 + * 累计里程 0-9999999
  55 + * 分辨率0.1km/h
  56 + * 0xff 0xff 0xff 0xfe 异常
  57 + * 0xff 0xff 0xff 0xff 无效
  58 + */
  59 + private int totalMiles;
  60 +
  61 + /**
  62 + * 总电压 0-10000
  63 + * 分辨率0.1v
  64 + * 0xff 0xfe 异常
  65 + * 0xff 0xff 无效
  66 + */
  67 + private short totalVoltage;
  68 +
  69 + /**
  70 + * 总电流 0-20000
  71 + * 分辨率0.1a
  72 + * 0xff 0xfe 异常
  73 + * 0xff 0xff 无效
  74 + */
  75 + private short totalCurrent;
  76 +
  77 + /**
  78 + * soc 0-100%
  79 + * 分辨率1%
  80 + * 0xFE 异常
  81 + * 0xFF 无效
  82 + */
  83 + private byte soc;
  84 +
  85 + /**
  86 + * dc-dc状态
  87 + * 0x01 工作
  88 + * 0x02 断开
  89 + * 0xFE 异常
  90 + * 0xFF 无效
  91 + */
  92 + private byte dcState;
  93 +
  94 + /**
  95 + * 挡位
  96 + */
  97 + @JsonIgnore
  98 + private byte gear;
  99 +
  100 + /**
  101 + * 驱动力
  102 + */
  103 + private boolean drivingForce;
  104 +
  105 + /**
  106 + * 制动力
  107 + */
  108 + private boolean brakingForce;
  109 +
  110 + /**
  111 + * 挡位(json)
  112 + */
  113 + @JsonProperty("gear")
  114 + private byte gear1;
  115 +
  116 + /**
  117 + * 绝缘电阻 0-60000
  118 + * 分辨率 1k欧
  119 + */
  120 + private int insulationResistance;
  121 +
  122 + /**
  123 + * 加速踏板行程值 0-100%
  124 + * 分辨率1%
  125 + * 0xFE 异常
  126 + * 0xFF 无效
  127 + */
  128 + private byte acceleratorState;
  129 +
  130 + /**
  131 + * 制动踏板状态 0-100%
  132 + * 分辨率1% 在无具体行程值情况下,用“101”表示制动有效状态
  133 + * 0xFE 异常
  134 + * 0xFF 无效
  135 + */
  136 + private byte brakePedalState;
  137 +
  138 + public VehicleData() {
  139 +
  140 + }
  141 +
  142 + public VehicleData(Message0201 message0201) {
  143 + BeanUtils.copyProperties(message0201, this);
  144 + this.drivingForce = (gear & 32) == 32 ? true : false;
  145 + this.drivingForce = (gear & 16) == 16 ? true : false;
  146 + this.gear1 = (byte) (gear & 15);
  147 + }
  148 +
  149 + public byte getVehicleState() {
  150 + return vehicleState;
  151 + }
  152 +
  153 + public void setVehicleState(byte vehicleState) {
  154 + this.vehicleState = vehicleState;
  155 + }
  156 +
  157 + public byte getChargeState() {
  158 + return chargeState;
  159 + }
  160 +
  161 + public void setChargeState(byte chargeState) {
  162 + this.chargeState = chargeState;
  163 + }
  164 +
  165 + public byte getRunMode() {
  166 + return runMode;
  167 + }
  168 +
  169 + public void setRunMode(byte runMode) {
  170 + this.runMode = runMode;
  171 + }
  172 +
  173 + public short getSpeed() {
  174 + return speed;
  175 + }
  176 +
  177 + public void setSpeed(short speed) {
  178 + this.speed = speed;
  179 + }
  180 +
  181 + public int getTotalMiles() {
  182 + return totalMiles;
  183 + }
  184 +
  185 + public void setTotalMiles(int totalMiles) {
  186 + this.totalMiles = totalMiles;
  187 + }
  188 +
  189 + public short getTotalVoltage() {
  190 + return totalVoltage;
  191 + }
  192 +
  193 + public void setTotalVoltage(short totalVoltage) {
  194 + this.totalVoltage = totalVoltage;
  195 + }
  196 +
  197 + public short getTotalCurrent() {
  198 + return totalCurrent;
  199 + }
  200 +
  201 + public void setTotalCurrent(short totalCurrent) {
  202 + this.totalCurrent = totalCurrent;
  203 + }
  204 +
  205 + public byte getSoc() {
  206 + return soc;
  207 + }
  208 +
  209 + public void setSoc(byte soc) {
  210 + this.soc = soc;
  211 + }
  212 +
  213 + public byte getDcState() {
  214 + return dcState;
  215 + }
  216 +
  217 + public void setDcState(byte dcState) {
  218 + this.dcState = dcState;
  219 + }
  220 +
  221 + public byte getGear() {
  222 + return gear;
  223 + }
  224 +
  225 + public void setGear(byte gear) {
  226 + this.gear = gear;
  227 + }
  228 +
  229 + public boolean isDrivingForce() {
  230 + return drivingForce;
  231 + }
  232 +
  233 + public void setDrivingForce(boolean drivingForce) {
  234 + this.drivingForce = drivingForce;
  235 + }
  236 +
  237 + public boolean isBrakingForce() {
  238 + return brakingForce;
  239 + }
  240 +
  241 + public void setBrakingForce(boolean brakingForce) {
  242 + this.brakingForce = brakingForce;
  243 + }
  244 +
  245 + public byte getGear1() {
  246 + return gear1;
  247 + }
  248 +
  249 + public void setGear1(byte gear1) {
  250 + this.gear1 = gear1;
  251 + }
  252 +
  253 + public int getInsulationResistance() {
  254 + return insulationResistance;
  255 + }
  256 +
  257 + public void setInsulationResistance(int insulationResistance) {
  258 + this.insulationResistance = insulationResistance;
  259 + }
  260 +
  261 + public byte getAcceleratorState() {
  262 + return acceleratorState;
  263 + }
  264 +
  265 + public void setAcceleratorState(byte acceleratorState) {
  266 + this.acceleratorState = acceleratorState;
  267 + }
  268 +
  269 + public byte getBrakePedalState() {
  270 + return brakePedalState;
  271 + }
  272 +
  273 + public void setBrakePedalState(byte brakePedalState) {
  274 + this.brakePedalState = brakePedalState;
  275 + }
  276 +
  277 + @Override
  278 + public String toString() {
  279 + StringBuilder sb = new StringBuilder();
  280 + sb.append("车辆状态: ").append(vehicleState)
  281 + .append(" 充电状态: ").append(chargeState)
  282 + .append(" 运行模式: ").append(runMode)
  283 + .append(" 车速: ").append(speed)
  284 + .append(" 累计里程: ").append(totalMiles)
  285 + .append(" 总电压: ").append(totalVoltage)
  286 + .append(" 总电流: ").append(totalCurrent)
  287 + .append(" soc: ").append(soc)
  288 + .append(" dc-dc状态: ").append(dcState)
  289 + .append(" 挡位: ").append(gear)
  290 + .append(" 绝缘电阻: ").append(insulationResistance)
  291 + .append(" 加速踏板行程值: ").append(acceleratorState)
  292 + .append(" 制动踏板状态: ").append(brakePedalState);
  293 +
  294 + return sb.toString();
  295 + }
  296 +
  297 + @Override
  298 + public String getType() {
  299 + return "vehicle_data";
  300 + }
  301 +}
... ...
src/main/java/com/bsth/geo/Bounds.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/geo/Bounds.java
  1 +package com.bsth.geo;
  2 +
  3 +public final class Bounds {
  4 +
  5 + private Point northEast;
  6 + private Point southWest;
  7 +
  8 + public Bounds(Point min, Point max) {
  9 + this.southWest = min;
  10 + this.northEast = max;
  11 + }
  12 +
  13 + public Point getNorthEast() {
  14 + return northEast;
  15 + }
  16 +
  17 + public Point getSouthWest() {
  18 + return southWest;
  19 + }
  20 +}
... ...
src/main/java/com/bsth/geo/Circle.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/geo/Circle.java
  1 +package com.bsth.geo;
  2 +
  3 +public final class Circle {
  4 +
  5 + private Point center;
  6 + private double radius;
  7 +
  8 + public Circle(Point c, double r) {
  9 + this.center = c;
  10 + this.radius = r;
  11 + }
  12 +
  13 + public Point getCenter() {
  14 + return center;
  15 + }
  16 +
  17 + public double getRadius() {
  18 + return radius;
  19 + }
  20 +}
... ...
src/main/java/com/bsth/geo/Point.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/geo/Point.java
  1 +package com.bsth.geo;
  2 +
  3 +public class Point {
  4 +
  5 + private double lon;
  6 + private double lat;
  7 +
  8 + public Point(double lon, double lat) {
  9 + this.lon = lon;
  10 + this.lat = lat;
  11 + }
  12 +
  13 + public double getLon() {
  14 + return lon;
  15 + }
  16 +
  17 + public double getLat() {
  18 + return lat;
  19 + }
  20 +}
... ...
src/main/java/com/bsth/geo/Polygon.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/geo/Polygon.java
  1 +package com.bsth.geo;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +
  6 +public final class Polygon {
  7 +
  8 + private List<Point> points;
  9 + private Bounds bounds;
  10 +
  11 + public Polygon(List<Point> ps) {
  12 + this.points = new ArrayList<Point>(ps);
  13 + double minlon = 200, minlat = 200, maxlon = -1, maxlat = -1;
  14 + for (Point p : ps) {
  15 + minlon = p.getLon() < minlon ? p.getLon() : minlon;
  16 + minlat = p.getLat() < minlat ? p.getLat() : minlat;
  17 + maxlon = p.getLon() > maxlon ? p.getLon() : maxlon;
  18 + maxlat = p.getLat() > maxlat ? p.getLat() : maxlat;
  19 + }
  20 + bounds = new Bounds(new Point(minlon, minlat), new Point(maxlon, maxlat));
  21 + }
  22 +
  23 + public List<Point> getPoints() {
  24 + return new ArrayList<Point>(points);
  25 + }
  26 +
  27 + public Bounds getBounds() {
  28 + return bounds;
  29 + }
  30 +}
... ...
src/main/java/com/bsth/service/BasicDataService.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/service/BasicDataService.java
  1 +package com.bsth.service;
  2 +
  3 +import java.sql.ResultSet;
  4 +import java.sql.SQLException;
  5 +import java.util.ArrayList;
  6 +import java.util.Calendar;
  7 +import java.util.HashMap;
  8 +import java.util.List;
  9 +import java.util.Map;
  10 +import java.util.concurrent.Executors;
  11 +import java.util.concurrent.ScheduledExecutorService;
  12 +import java.util.concurrent.ThreadFactory;
  13 +import java.util.concurrent.TimeUnit;
  14 +import java.util.regex.Matcher;
  15 +import java.util.regex.Pattern;
  16 +
  17 +import org.slf4j.Logger;
  18 +import org.slf4j.LoggerFactory;
  19 +import org.springframework.beans.factory.DisposableBean;
  20 +import org.springframework.beans.factory.InitializingBean;
  21 +import org.springframework.beans.factory.annotation.Autowired;
  22 +import org.springframework.jdbc.core.JdbcTemplate;
  23 +import org.springframework.jdbc.core.RowMapper;
  24 +import org.springframework.stereotype.Service;
  25 +
  26 +import com.bsth.entity.CarParkInfo;
  27 +import com.bsth.entity.DeviceSimMapping;
  28 +import com.bsth.entity.GridInfo;
  29 +import com.bsth.entity.HistoryArrival;
  30 +import com.bsth.entity.LineInfo;
  31 +import com.bsth.entity.SectionGrid;
  32 +import com.bsth.entity.SectionInfo;
  33 +import com.bsth.entity.SpecialStation;
  34 +import com.bsth.entity.StopInfo;
  35 +import com.bsth.geo.Point;
  36 +
  37 +@Service
  38 +public class BasicDataService implements InitializingBean, DisposableBean {
  39 +
  40 + private final static Logger log = LoggerFactory.getLogger(BasicDataService.class);
  41 +
  42 + @Autowired
  43 + private JdbcTemplate msJdbcTemplate;
  44 + @Autowired
  45 + private JdbcTemplate controlJdbcTemplate;
  46 + private static Map<Integer, LineInfo> id_info = new HashMap<Integer, LineInfo>();
  47 + private static List<CarParkInfo> parks = new ArrayList<CarParkInfo>();
  48 + private static List<Integer> sline = new ArrayList<Integer>();
  49 + private static Map<String, DeviceSimMapping> mapping = new HashMap<String, DeviceSimMapping>();
  50 + private static Map<String, String> sim_device = new HashMap<String, String>();
  51 + private static Map<String, String> device_sim = new HashMap<String, String>();
  52 + private static GridInfo ginfo = new GridInfo();
  53 + private static int year = 0;
  54 + private ScheduledExecutorService sexec = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
  55 +
  56 + @Override
  57 + public Thread newThread(Runnable r) {
  58 + // TODO Auto-generated method stub
  59 + Thread t = new Thread(r);
  60 + t.setName("BasicDataServiceScheduled");
  61 + return t;
  62 + }
  63 + });
  64 +
  65 + public synchronized void loadBasicData() {
  66 + Map<Integer, LineInfo> id_info = new HashMap<Integer, LineInfo>();
  67 + List<CarParkInfo> parks = new ArrayList<CarParkInfo>();
  68 + List<Integer> sline = new ArrayList<Integer>();
  69 + Map<String, DeviceSimMapping> mapping = new HashMap<String, DeviceSimMapping>();
  70 + Map<String, String> sim_device = new HashMap<String, String>();
  71 + Map<String, String> device_sim = new HashMap<String, String>();
  72 +
  73 + String qline = "select a.id,in_use,line_code,name,start_station_name,start_station_first_time,start_station_end_time,end_station_name,end_station_first_time,end_station_end_time,company,branche_company,length,telephone,speed_limit,line_play_type from bsth_c_line a left join bsth_c_line_information b on a.id = b.line where a.destroy = 0";
  74 + // 查询完整路段
  75 + // 改 查询路段 只有分段路段了
  76 + String qsection = "select b.id,b.section_code,b.section_name,b.section_distance,b.speed_limit,AsText(b.gsection_vector) as gsection_vector,a.line,a.line_code,a.directions,a.is_roade_speed from bsth_c_sectionroute a join bsth_c_section b on a.section = b.id where line is not null and a.destroy = 0 order by a.line,a.directions,a.sectionroute_code";
  77 + // 查询分段路段
  78 + //String qsection = "select b.id,b.road_code as section_code,b.road_name as section_name,0 as section_distance,b.speed as speed_limit,AsText(b.groad_vector) as gsection_vector,a.line,a.line_code,a.directions,-1 as is_roade_speed from bsth_c_sectionspeed a join bsth_c_road b on a.road = b.id order by a.line,a.directions,a.code";
  79 + String qstop = "select b.id,b.station_cod,b.station_name,b.road_coding,b.g_lonx,b.g_laty,b.shapes_type,b.radius,AsText(b.g_polygon_grid) as g_polygon_grid,a.line,a.line_code,a.directions,a.distances from bsth_c_stationroute a join bsth_c_station b on a.station = b.id where a.destroy = 0 order by a.line,a.directions,a.station_route_code";
  80 + String qcarpark = "select b.id,b.park_code,b.park_name,b.shapes_type,b.radius,b.g_center_point,AsText(b.g_park_point) as g_polygon_grid from bsth_c_car_park b where b.destroy = 0";
  81 + // 查询特定线路ID
  82 + String qsline = "select line_id from bsth_c_special_line";
  83 + // 查询设备号和小模块映射信息
  84 + String qmapping = "select device_id, sim, ext_enabled from bsth_c_device_sim_mapping";
  85 + // 查询最后的到离站信息
  86 + String qlastarr = "select device_id, line_id, stop_no, ts, up_down, up_down1, in_out, state, last_stop_no, last_up_down from bsth_c_last_arrival";
  87 + // 查询特殊站点(回环二次进站)
  88 + String qsstation = "select line_id, stop_no, last_stop_no from bsth_c_special_station order by line_id";
  89 + List<LineInfo> lines = controlJdbcTemplate.query(qline, new RowMapperLineInfo());
  90 + List<SectionInfo> secs = controlJdbcTemplate.query(qsection, new RowMapperSectionInfo());
  91 + List<StopInfo> stops = controlJdbcTemplate.query(qstop, new RowMapperStopInfo());
  92 + parks = controlJdbcTemplate.query(qcarpark, new RowMapperCarParkInfo());
  93 + sline = msJdbcTemplate.queryForList(qsline, Integer.class);
  94 + List<DeviceSimMapping> dsms = msJdbcTemplate.query(qmapping, new RowMapperDeviceSimMapping());
  95 + List<HistoryArrival> lastarrs = msJdbcTemplate.query(qlastarr, new RowMapperHistoryArrival());
  96 + List<SpecialStation> sstations = msJdbcTemplate.query(qsstation, new RowMapperSpecialStation());
  97 + // 缓存设备和小模块映射信息
  98 + for (DeviceSimMapping dsm : dsms) {
  99 + mapping.put(dsm.getDeviceId(), dsm);
  100 + sim_device.put(dsm.getSim(), dsm.getDeviceId());
  101 + device_sim.put(dsm.getDeviceId(), dsm.getSim());
  102 + }
  103 + // 缓存线路基本信息
  104 + for (LineInfo line : lines) {
  105 + id_info.put(line.getLineId(), line);
  106 + }
  107 + int oldId = -1;
  108 + LineInfo line = null;
  109 + // 线路信息中添加回环站点信息
  110 + for (SpecialStation ss : sstations) {
  111 + if (ss.getLineId() != oldId) {
  112 + oldId = ss.getLineId();
  113 + line = id_info.get(oldId);
  114 + }
  115 + if (line != null) {
  116 + line.getSpecailStation().add(ss);
  117 + }
  118 + }
  119 + // 线路信息中添加分段的上下行路段信息
  120 + oldId = -1;
  121 + line = null;
  122 + double minLon = 180, maxLon = 0, minLat = 180, maxLat = 0;
  123 + for (SectionInfo sec : secs) {
  124 + if (sec.getLineCode() != oldId) {
  125 + oldId = sec.getLineCode();
  126 + line = id_info.get(oldId);
  127 + }
  128 + if (line != null) {
  129 + if (sec.getDirections() == 0) line.getSectionsUp().add(sec);
  130 + else line.getSectionsDown().add(sec);
  131 + }
  132 + for (Point p : sec.getPoints()) {
  133 + minLon = Math.min(p.getLon(), minLon);
  134 + maxLon = Math.max(p.getLon(), maxLon);
  135 + minLat = Math.min(p.getLat(), minLat);
  136 + maxLat = Math.max(p.getLat(), maxLat);
  137 + }
  138 + }
  139 + log.info("minLon:" + minLon + " maxLon:" + maxLon + " minLat:" + minLat + " maxLat:" + maxLat);
  140 + int row = (int)Math.ceil((maxLon - minLon)/.001), column = (int)Math.ceil((maxLat - minLat)/.001);
  141 + ginfo.setMinLon(minLon);
  142 + ginfo.setMaxLon(maxLon);
  143 + ginfo.setMinLat(minLat);
  144 + ginfo.setMaxLat(maxLat);
  145 + ginfo.setRow(row + 1);
  146 + ginfo.setColumn(column + 1);
  147 + ginfo.setGrid(new SectionGrid[row + 1][column + 1]);
  148 + for (SectionInfo sec : secs) {
  149 + for (Point p : sec.getPoints()) {
  150 + int r = (int)Math.ceil((p.getLon() - minLon)/.001), c = (int)Math.ceil((p.getLat() - minLat)/.001);
  151 + SectionGrid sg = ginfo.getGrid()[r][c];
  152 + if (sg == null) {
  153 + sg = new SectionGrid();
  154 + ginfo.getGrid()[r][c] = sg;
  155 + }
  156 + sg.getSecs().add(sec);
  157 + }
  158 + }
  159 + // 线路信息中添加上下行站点信息
  160 + oldId = -1;
  161 + line = null;
  162 + for (StopInfo stop : stops) {
  163 + if (stop.getLineCode() != oldId) {
  164 + oldId = stop.getLineCode();
  165 + line = id_info.get(oldId);
  166 + }
  167 + if (line != null) {
  168 + if (stop.getDirections() == 0) line.getStopsUp().add(stop);
  169 + else line.getStopsDown().add(stop);
  170 + }
  171 + }
  172 +
  173 + if (id_info.size() > 0) BasicDataService.id_info = id_info;
  174 + if (parks.size() > 0) BasicDataService.parks = parks;
  175 + if (sline.size() > 0) BasicDataService.sline = sline;
  176 + if (mapping.size() > 0) BasicDataService.mapping = mapping;
  177 + if (sim_device.size() > 0) BasicDataService.sim_device = sim_device;
  178 + if (device_sim.size() > 0) BasicDataService.device_sim = device_sim;
  179 + }
  180 +
  181 + @Override
  182 + public void afterPropertiesSet() throws Exception {
  183 + // TODO Auto-generated method stub
  184 + /*try {
  185 + jdbcTemplate.execute("create table if not exists `bsth_c_gps_info` (`city_code` int(6) NOT NULL,`industry_code` int(5) NOT NULL,`company_code` int(5) NOT NULL,`line_id` int(6) NOT NULL,`device_id` varchar(8) NOT NULL,`driver_no` int(8) NOT NULL,`carpark_serial_no` smallint(5) unsigned NOT NULL,`carpark_no` varchar(255) NOT NULL,`stop_serial_no` smallint(5) unsigned NOT NULL,`stop_no` varchar(255) NOT NULL,`lon` float(10,6) NOT NULL,`lat` float(10,6) NOT NULL,`ts` bigint(20) NOT NULL,`speed_sensor` float(7,1) NOT NULL,`speed_gps` float(7,1) NOT NULL,`direction` float(7,1) NOT NULL,`in_temp` tinyint(4) NOT NULL,`service_state` bigint(20) NOT NULL,`control_state` bigint(20) NOT NULL,`total_miles` float(8,2) NOT NULL,`water_temp` tinyint(4) NOT NULL,`oil_consumption` float(4,1) NOT NULL,`engine_speed` int(11) NOT NULL,`inout_stop` tinyint(4) NOT NULL,`days_year` smallint(4) NOT NULL,`hours_day` tinyint(4) NOT NULL,`server_ts` bigint(20),`create_date` timestamp default CURRENT_TIMESTAMP,`section_code` varchar(255) NOT NULL,KEY `idx_test` (`days_year`,`device_id`,`ts`,`line_id`,`lon`,`lat`,`inout_stop`,`server_ts`,`section_code`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 PARTITION by hash(days_year) PARTITIONS 366");
  186 + log.info("历史gps服务初始化完成。。。");
  187 + } catch(Exception e) {
  188 + //e.printStackTrace();
  189 + log.warn("历史gps服务初始化异常。。。", e);
  190 + }
  191 + try {
  192 + jdbcTemplate.execute("create table if not exists `bsth_c_arrival_info` (`device_id` varchar(8) NOT NULL,`line_id` int(11) NOT NULL,`stop_no` varchar(32) NOT NULL,`ts` bigint(20) NOT NULL,`up_down` int(11) NOT NULL,`in_out` int(11) NOT NULL,`create_date` bigint(20) NOT NULL,`weeks_year` tinyint(4) NOT NULL,`create_timestamp` bigint(20),KEY `idx_test` (`weeks_year`,`device_id`,`ts`,`create_date`,`create_timestamp`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 PARTITION by hash(weeks_year) PARTITIONS 53");
  193 + log.info("历史到离站服务初始化完成。。。");
  194 + } catch (Exception e) {
  195 + log.warn("历史到离站服务初始化异常。。。", e);
  196 + }*/
  197 + try {
  198 + loadBasicData();
  199 + } catch (Exception e) {
  200 + log.error("BasicDataService初始化时加载基础数据异常", e);
  201 + }
  202 +
  203 + // 开启调度
  204 + sexec.scheduleAtFixedRate(new Runnable() {
  205 +
  206 + @Override
  207 + public void run() {
  208 + // TODO Auto-generated method stub
  209 + try {
  210 + loadBasicData();
  211 + } catch (Exception e) {
  212 + log.error("BasicDataService加载基础数据异常", e);
  213 + }
  214 + }
  215 + }, 1, 1, TimeUnit.HOURS);
  216 + sexec.scheduleAtFixedRate(new SplitTableChecker(), 0, 10, TimeUnit.SECONDS);
  217 + }
  218 +
  219 + final class RowMapperSectionInfo implements RowMapper<SectionInfo> {
  220 +
  221 + private final Pattern p = Pattern.compile("(\\d+(\\.\\d+)?) (\\d+(\\.\\d+)?)");
  222 +
  223 + @Override
  224 + public SectionInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  225 + // TODO Auto-generated method stub
  226 + SectionInfo section = new SectionInfo();
  227 + section.setId(rs.getInt("id"));
  228 + section.setSectionCode(rs.getString("section_code"));
  229 + section.setSectionName(rs.getString("section_name"));
  230 + section.setSectionDistance(rs.getDouble("section_distance"));
  231 + section.setSpeedLimit(rs.getDouble("speed_limit"));
  232 + List<Point> points = new ArrayList<Point>();
  233 + String gstr = rs.getString("gsection_vector");
  234 + if (gstr != null) {
  235 + Matcher m = p.matcher(gstr);
  236 + while (m.find()) {
  237 + points.add(new Point(Float.parseFloat(m.group(1)), Float.parseFloat(m.group(3))));
  238 + }
  239 + }
  240 + section.setPoints(points);
  241 + section.setLineId(rs.getInt("line"));
  242 + section.setLineCode(rs.getInt("line_code"));
  243 + section.setDirections(rs.getInt("directions"));
  244 + section.setIsRoadeSpeed(rs.getInt("is_roade_speed"));
  245 + return section;
  246 + }
  247 +
  248 + }
  249 +
  250 + final class RowMapperLineInfo implements RowMapper<LineInfo> {
  251 +
  252 + @Override
  253 + public LineInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  254 + // TODO Auto-generated method stub
  255 + LineInfo line = new LineInfo();
  256 + line.setId(rs.getInt("id"));
  257 + line.setInUse(rs.getInt("in_use"));
  258 + line.setLineId(rs.getInt("line_code"));
  259 + line.setLineName(rs.getString("name"));
  260 + //line.setStartStation(rs.getInt("start_station"));
  261 + line.setStartStationName(rs.getString("start_station_name"));
  262 + line.setStartStationFirstTime(rs.getString("start_station_first_time"));
  263 + line.setStartStationEndTime(rs.getString("start_station_end_time"));
  264 + //line.setEndStation(rs.getInt("end_station"));
  265 + line.setEndStationName(rs.getString("end_station_name"));
  266 + line.setEndStationFirstTime(rs.getString("end_station_first_time"));
  267 + line.setEndStationEndTime(rs.getString("end_station_end_time"));
  268 + line.setCompany(rs.getString("company"));
  269 + line.setBrancheCompany(rs.getString("branche_company"));
  270 + line.setTelephone(rs.getString("telephone"));
  271 + line.setSpeedLimit(rs.getDouble("speed_limit"));
  272 + line.setLinePlayType(rs.getInt("line_play_type"));
  273 + return line;
  274 + }
  275 +
  276 + }
  277 +
  278 + final class RowMapperStopInfo implements RowMapper<StopInfo> {
  279 +
  280 + private final Pattern p = Pattern.compile("(\\d+(\\.\\d+)?) (\\d+(\\.\\d+)?)");
  281 + @Override
  282 + public StopInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  283 + // TODO Auto-generated method stub
  284 + StopInfo stop = new StopInfo();
  285 + stop.setId(rs.getInt("id"));
  286 + stop.setStationCod(rs.getString("station_cod"));
  287 + stop.setStationName(rs.getString("station_name"));
  288 + //stop.setStationType(rs.getString("station_type"));
  289 + stop.setRoadCoding(rs.getString("road_coding"));
  290 + float lon = rs.getFloat("g_lonx");
  291 + float lat = rs.getFloat("g_laty");
  292 + stop.setPoint(new Point(lon, lat));
  293 + stop.setLineId(rs.getInt("line"));
  294 + stop.setLineCode(rs.getInt("line_code"));
  295 + stop.setDirections(rs.getInt("directions"));
  296 + stop.setShapesType(rs.getString("shapes_type"));
  297 + stop.setRadius(rs.getInt("radius"));
  298 + List<Point> points = new ArrayList<Point>();
  299 + String gstr = rs.getString("g_polygon_grid");
  300 + if (gstr != null) {
  301 + Matcher m = p.matcher(gstr);
  302 + while (m.find()) {
  303 + points.add(new Point(Float.parseFloat(m.group(1)), Float.parseFloat(m.group(3))));
  304 + }
  305 + }
  306 + stop.setPoints(points);
  307 + stop.setDistances(rs.getDouble("distances")*1000);
  308 + return stop;
  309 + }
  310 +
  311 + }
  312 +
  313 + final class RowMapperCarParkInfo implements RowMapper<CarParkInfo> {
  314 +
  315 + private final Pattern p = Pattern.compile("(\\d+(\\.\\d+)?) (\\d+(\\.\\d+)?)");
  316 + @Override
  317 + public CarParkInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  318 + // TODO Auto-generated method stub
  319 + CarParkInfo park = new CarParkInfo();
  320 + park.setId(rs.getInt("id"));
  321 + park.setParkCode(rs.getString("park_code"));
  322 + park.setParkName(rs.getString("park_name"));
  323 + String gstr = rs.getString("g_center_point");
  324 + if (gstr != null) {
  325 + Matcher m = p.matcher(gstr);
  326 + while (m.find()) {
  327 + park.setPoint(new Point(Float.parseFloat(m.group(1)), Float.parseFloat(m.group(3))));
  328 + }
  329 + }
  330 + park.setShapesType(rs.getString("shapes_type"));
  331 + park.setRadius(rs.getInt("radius"));
  332 + List<Point> points = new ArrayList<Point>();
  333 + gstr = rs.getString("g_polygon_grid");
  334 + if (gstr != null) {
  335 + Matcher m = p.matcher(gstr);
  336 + while (m.find()) {
  337 + points.add(new Point(Float.parseFloat(m.group(1)), Float.parseFloat(m.group(3))));
  338 + }
  339 + }
  340 + park.setPoints(points);
  341 + return park;
  342 + }
  343 +
  344 + }
  345 +
  346 + final class RowMapperDeviceSimMapping implements RowMapper<DeviceSimMapping> {
  347 +
  348 + @Override
  349 + public DeviceSimMapping mapRow(ResultSet rs, int rowNum) throws SQLException {
  350 + // TODO Auto-generated method stub
  351 + DeviceSimMapping dsm = new DeviceSimMapping();
  352 + dsm.setDeviceId(rs.getString("device_id"));
  353 + dsm.setSim(rs.getString("sim"));
  354 + dsm.setExtEnabled(rs.getInt("ext_enabled"));
  355 +
  356 + return dsm;
  357 + }
  358 +
  359 + }
  360 +
  361 + final class RowMapperHistoryArrival implements RowMapper<HistoryArrival> {
  362 +
  363 + @Override
  364 + public HistoryArrival mapRow(ResultSet rs, int rowNum) throws SQLException {
  365 + // TODO Auto-generated method stub
  366 + HistoryArrival ha = new HistoryArrival();
  367 + ha.setDeviceId(rs.getString("device_id"));
  368 + ha.setLineId(rs.getInt("line_id"));
  369 + ha.setStopNo(rs.getString("stop_no"));
  370 + ha.setTimestamp(rs.getLong("ts"));
  371 + ha.setUpDown(rs.getInt("up_down"));
  372 + ha.setUpDown1(rs.getInt("up_down1"));
  373 + ha.setInOut(rs.getInt("in_out"));
  374 + ha.setState(rs.getInt("state") == 1 ? true : false);
  375 + ha.setLastStopNo(rs.getString("last_stop_no"));
  376 + ha.setLastUpDown(rs.getInt("last_up_down"));
  377 +
  378 + return ha;
  379 + }
  380 +
  381 + }
  382 +
  383 + final class RowMapperSpecialStation implements RowMapper<SpecialStation> {
  384 +
  385 + @Override
  386 + public SpecialStation mapRow(ResultSet rs, int rowNum) throws SQLException {
  387 + // TODO Auto-generated method stub
  388 + SpecialStation ss = new SpecialStation();
  389 + ss.setLineId(rs.getInt("line_id"));
  390 + ss.setStopNo(rs.getString("stop_no"));
  391 + ss.setLastStopNo(rs.getString("last_stop_no"));
  392 +
  393 + return ss;
  394 + }
  395 +
  396 + }
  397 +
  398 + final class SplitTableChecker implements Runnable {
  399 +
  400 + private long nextTime = 0;
  401 +
  402 + @Override
  403 + public void run() {
  404 + // TODO Auto-generated method stub
  405 + try {
  406 + long now = System.currentTimeMillis();
  407 + Calendar c = Calendar.getInstance();
  408 + c.setTimeInMillis(now);
  409 + if (nextTime < now) {
  410 + nextTime = getNextTime(now);
  411 + year = c.get(Calendar.YEAR);
  412 + }
  413 + } catch (Exception e) {
  414 + log.error("SplitTableChecker schedule exception", e);
  415 + }
  416 + }
  417 +
  418 + }
  419 +
  420 + private long getNextTime(long now) {
  421 + Calendar c = Calendar.getInstance();
  422 + c.setTimeInMillis(now);
  423 + c.add(Calendar.YEAR, 1);
  424 + c.set(Calendar.MONTH, 0);
  425 + c.set(Calendar.DAY_OF_MONTH, 1);
  426 + c.set(Calendar.HOUR_OF_DAY, 0);
  427 + c.set(Calendar.MINUTE, 0);
  428 + c.set(Calendar.SECOND, 0);
  429 + c.set(Calendar.MILLISECOND, 0);
  430 +
  431 + return c.getTimeInMillis();
  432 + }
  433 +
  434 + public static LineInfo getLineById(int id) {
  435 + return id_info.get(id);
  436 + }
  437 +
  438 + public static List<CarParkInfo> getCarParks() {
  439 + return parks;
  440 + }
  441 +
  442 + public static GridInfo getGinfo() {
  443 + return ginfo;
  444 + }
  445 +
  446 + public static List<Integer> getSpecialLine() {
  447 + return sline;
  448 + }
  449 +
  450 + public static DeviceSimMapping getMappingByDeviceId(String deviceId) {
  451 + return mapping.get(deviceId);
  452 + }
  453 +
  454 + public static String getDeviceIdBySim(String sim) {
  455 + return sim_device.get(sim);
  456 + }
  457 +
  458 + public static String getSimByDeviceId(String deviceId) {
  459 + return device_sim.get(deviceId);
  460 + }
  461 +
  462 + public static int getYear() {
  463 + return year;
  464 + }
  465 +
  466 + @Override
  467 + public void destroy() throws Exception {
  468 + // TODO Auto-generated method stub
  469 + sexec.shutdown();
  470 + }
  471 +}
... ...
src/main/java/com/bsth/service/DownProtocolDataService.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/service/DownProtocolDataService.java
  1 +package com.bsth.service;
  2 +
  3 +import java.io.BufferedOutputStream;
  4 +import java.io.File;
  5 +import java.io.FileNotFoundException;
  6 +import java.io.FileOutputStream;
  7 +import java.io.IOException;
  8 +import java.text.SimpleDateFormat;
  9 +import java.util.Date;
  10 +
  11 +import com.bsth.util.AppProperties;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
  14 +
  15 +/**
  16 + * @author Hill
  17 + */
  18 +public class DownProtocolDataService {
  19 +
  20 + private final static Logger log = LoggerFactory.getLogger(DownProtocolDataService.class);
  21 +
  22 + private static DownProtocolDataService service = new DownProtocolDataService();
  23 +
  24 + private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHH");
  25 +
  26 + private String dir = AppProperties.getDowndir();
  27 +
  28 + private Date cur = new Date();
  29 + /**
  30 + * 下次切换写文件时间节点
  31 + */
  32 + private long nextTime;
  33 +
  34 + private BufferedOutputStream out;
  35 +
  36 + private String fileName;
  37 +
  38 + private DownProtocolDataService() {
  39 + File file = new File(dir);
  40 + Date now = new Date();
  41 + if (!file.exists()) { file.mkdirs(); }
  42 + fileName = sdf.format(now);
  43 + nextTime = now.getTime() + 3600000 - now.getTime() % 3600000;
  44 + try {
  45 + out = new BufferedOutputStream(new FileOutputStream(dir + fileName, true));
  46 + } catch (FileNotFoundException e) {
  47 + // TODO Auto-generated catch block
  48 + log.error(dir + fileName + "文件未找到");
  49 + }
  50 + }
  51 +
  52 + public static DownProtocolDataService getInstance() {
  53 + return service;
  54 + }
  55 +
  56 + public void write(byte[] bytes) throws IOException {
  57 + long now = System.currentTimeMillis();
  58 + if (nextTime < now) {
  59 + cur.setTime(now);
  60 + rollOver(now);
  61 + }
  62 + out.write(bytes);
  63 + out.flush();
  64 + }
  65 +
  66 + private synchronized void rollOver(long now) throws IOException {
  67 + if (now < nextTime) {
  68 + return;
  69 + }
  70 + BufferedOutputStream os = out;
  71 + try {
  72 + fileName = sdf.format(cur);
  73 + File file = new File(dir + fileName);
  74 + out = new BufferedOutputStream(new FileOutputStream(file, true));
  75 + nextTime = getNextTime(now);
  76 + } catch (FileNotFoundException e) {
  77 + // TODO Auto-generated catch block
  78 + log.error(dir + fileName + "文件未找到");
  79 + } finally {
  80 + os.flush();
  81 + os.close();
  82 + }
  83 + }
  84 +
  85 + private long getNextTime(long now) {
  86 + return now + 3600000 - now % 3600000;
  87 + }
  88 +}
... ...
src/main/java/com/bsth/service/MessageService.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/service/MessageService.java
  1 +package com.bsth.service;
  2 +
  3 +import java.io.ByteArrayOutputStream;
  4 +import java.io.IOException;
  5 +import java.io.InputStream;
  6 +import java.io.OutputStream;
  7 +import java.net.HttpURLConnection;
  8 +import java.net.URL;
  9 +import java.util.Map;
  10 +import java.util.Queue;
  11 +import java.util.concurrent.ConcurrentHashMap;
  12 +import java.util.concurrent.ConcurrentLinkedQueue;
  13 +import java.util.concurrent.ExecutorService;
  14 +import java.util.concurrent.Executors;
  15 +import java.util.concurrent.ScheduledExecutorService;
  16 +import java.util.concurrent.ThreadFactory;
  17 +import java.util.concurrent.TimeUnit;
  18 +
  19 +import com.fasterxml.jackson.databind.ObjectMapper;
  20 +import org.apache.commons.io.IOUtils;
  21 +import org.slf4j.Logger;
  22 +import org.slf4j.LoggerFactory;
  23 +import org.springframework.beans.factory.DisposableBean;
  24 +import org.springframework.beans.factory.InitializingBean;
  25 +import org.springframework.stereotype.Service;
  26 +
  27 +import com.bsth.socket.protocol.Message;
  28 +
  29 +/**
  30 + * @author Hill
  31 + */
  32 +@Service
  33 +public class MessageService implements InitializingBean, DisposableBean {
  34 +
  35 + private final static Logger log = LoggerFactory.getLogger(MessageService.class);
  36 +
  37 + private Map<String, Queue<Message>> device_msgs = new ConcurrentHashMap<String, Queue<Message>>();
  38 + private ScheduledExecutorService sexec = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
  39 +
  40 + @Override
  41 + public Thread newThread(Runnable r) {
  42 + // TODO Auto-generated method stub
  43 + Thread t = new Thread(r);
  44 + t.setName("MessageServiceExecutor");
  45 + return t;
  46 + }
  47 + });
  48 + private ConcurrentLinkedQueue<Message> queue = new ConcurrentLinkedQueue<>();
  49 + private ExecutorService exec = Executors.newFixedThreadPool(5, new ThreadFactory() {
  50 +
  51 + @Override
  52 + public Thread newThread(Runnable r) {
  53 + // TODO Auto-generated method stub
  54 + Thread t = new Thread(r);
  55 + t.setName("MessageUpPool");
  56 + return t;
  57 + }
  58 + });
  59 +
  60 + /**
  61 + * 消息下发
  62 + * @param msg
  63 + */
  64 + public void down(Message msg) {
  65 + // 0x64协议在下发时缓存此消息 以便确认时对应
  66 + /*if (msg.getCommandType() == 0x64) {
  67 + String deviceId = msg.getMessageBody().getDeviceId();
  68 + Queue<Message> msgs = device_msgs.get(deviceId);
  69 + if (msgs == null) {
  70 + msgs = new ConcurrentLinkedQueue<>();
  71 + device_msgs.put(deviceId, msgs);
  72 + }
  73 + msgs.add(msg);
  74 + }
  75 + MessageSender.getInstance().send(msg);*/
  76 + }
  77 +
  78 + public void up(Message msg) {
  79 + if (msg != null) queue.add(msg);
  80 + }
  81 +
  82 + /**
  83 + * 消息上传(包括应答)
  84 + * @param msg
  85 + */
  86 + private void upHandle(Message msg) {
  87 +
  88 + }
  89 +
  90 + @SuppressWarnings("unchecked")
  91 + public Map<String, Object> request(Map<String, Object> map, String url) {
  92 + InputStream in = null;
  93 + OutputStream out = null;
  94 + HttpURLConnection con = null;
  95 + try {
  96 + con = (HttpURLConnection)new URL(url).openConnection();
  97 + con.setRequestMethod("POST");
  98 + con.setRequestProperty("keep-alive", "true");
  99 + con.setRequestProperty("Connection", "Close");
  100 + con.setRequestProperty("accept", "*/*");
  101 + con.setDoInput(true);
  102 + con.setDoOutput(true);
  103 + con.setReadTimeout(2500);
  104 + con.setConnectTimeout(2500);
  105 + out = con.getOutputStream();
  106 + out.write("json=".getBytes());
  107 + out.write(new ObjectMapper().writeValueAsBytes(map));
  108 + out.flush();
  109 + if (con.getResponseCode() == 200) {
  110 + in = con.getInputStream();
  111 + ByteArrayOutputStream bout = new ByteArrayOutputStream();
  112 + IOUtils.copy(in, bout); bout.close();
  113 + log.info("Message:" + new String(bout.toByteArray()));
  114 + return new ObjectMapper().readValue(bout.toByteArray(), Map.class);
  115 + }
  116 + } catch (IOException e) {
  117 + // TODO Auto-generated catch block
  118 + log.error("调用消息上传接口时发生异常|" + map, e);
  119 + } finally {
  120 + try {
  121 + if (in != null) in.close();
  122 + if (out != null) out.close();
  123 + } catch (IOException e) {
  124 + // TODO Auto-generated catch block
  125 + log.error("", e);
  126 + }
  127 + con.disconnect();
  128 + }
  129 + return null;
  130 + }
  131 +
  132 + @SuppressWarnings("unchecked")
  133 + public Map<String, Object> requestJson(Map<String, Object> map, String url) {
  134 + InputStream in = null;
  135 + OutputStream out = null;
  136 + HttpURLConnection con = null;
  137 + try {
  138 + con = (HttpURLConnection)new URL(url).openConnection();
  139 + con.setRequestMethod("POST");
  140 + con.setRequestProperty("keep-alive", "true");
  141 + con.setRequestProperty("Connection", "Close");
  142 + con.setRequestProperty("accept", "application/json");
  143 + con.setRequestProperty("content-type", "application/json");
  144 + con.setDoInput(true);
  145 + con.setDoOutput(true);
  146 + con.setReadTimeout(2500);
  147 + con.setConnectTimeout(2500);
  148 + out = con.getOutputStream();
  149 + out.write(new ObjectMapper().writeValueAsBytes(map));
  150 + out.flush();
  151 + if (con.getResponseCode() == 200) {
  152 + in = con.getInputStream();
  153 + ByteArrayOutputStream bout = new ByteArrayOutputStream();
  154 + IOUtils.copy(in, bout); bout.close();
  155 + log.info("Message:" + new String(bout.toByteArray()));
  156 + return new ObjectMapper().readValue(bout.toByteArray(), Map.class);
  157 + }
  158 + } catch (IOException e) {
  159 + // TODO Auto-generated catch block
  160 + log.error("调用消息上传接口时发生异常|" + map, e);
  161 + } finally {
  162 + try {
  163 + if (in != null) in.close();
  164 + if (out != null) out.close();
  165 + } catch (IOException e) {
  166 + // TODO Auto-generated catch block
  167 + log.error("", e);
  168 + }
  169 + con.disconnect();
  170 + }
  171 + return null;
  172 + }
  173 +
  174 + public Queue<Message> getMessageByDevice(String deviceId) {
  175 + return device_msgs.get(deviceId);
  176 + }
  177 +
  178 + @Override
  179 + public void afterPropertiesSet() throws Exception {
  180 + // TODO Auto-generated method stub
  181 + //ShareExecutors.count.set(5);
  182 + sexec.scheduleAtFixedRate(new MessageWorker(), 30, 30, TimeUnit.SECONDS);
  183 + exec.submit(new MessageUpWorker());
  184 + }
  185 +
  186 + final class MessageWorker implements Runnable {
  187 +
  188 + @Override
  189 + public void run() {
  190 + // TODO Auto-generated method stub
  191 +
  192 + }
  193 + }
  194 +
  195 + final class MessageUpWorker implements Runnable {
  196 +
  197 + @Override
  198 + public void run() {
  199 + // TODO Auto-generated method stub
  200 + while (true) {
  201 + try {
  202 + final Message msg = queue.poll();
  203 + if (msg == null) {
  204 + try {
  205 + Thread.sleep(50);
  206 + } catch (InterruptedException e) {
  207 + log.error("sleep", e);
  208 + }
  209 + continue;
  210 + }
  211 + exec.submit(new Runnable() {
  212 +
  213 + @Override
  214 + public void run() {
  215 + // TODO Auto-generated method stub
  216 + try {
  217 + upHandle(msg);
  218 + } catch(Exception e) {
  219 + log.error("MessageUpWorker handle exception|" + msg, e);
  220 + }
  221 + }
  222 + });
  223 + } catch (Exception e) {
  224 + log.error("MessageUpPool handle exception", e);
  225 + }
  226 + }
  227 + }
  228 + }
  229 +
  230 + @Override
  231 + public void destroy() throws Exception {
  232 + // TODO Auto-generated method stub
  233 + exec.shutdown();
  234 + sexec.shutdown();
  235 + }
  236 +}
... ...
src/main/java/com/bsth/service/ServerService.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/service/ServerService.java
  1 +package com.bsth.service;
  2 +
  3 +import java.lang.reflect.Field;
  4 +import java.net.InetSocketAddress;
  5 +import java.nio.channels.SelectionKey;
  6 +import java.util.Collection;
  7 +import java.util.concurrent.Executors;
  8 +import java.util.concurrent.ScheduledExecutorService;
  9 +import java.util.concurrent.ThreadFactory;
  10 +import java.util.concurrent.TimeUnit;
  11 +
  12 +import com.bsth.socket.handler.ServerHandler;
  13 +import com.bsth.util.AppProperties;
  14 +import org.apache.mina.core.session.IdleStatus;
  15 +import org.apache.mina.core.session.IoSession;
  16 +import org.apache.mina.core.session.IoSessionConfig;
  17 +import org.apache.mina.filter.codec.ProtocolCodecFilter;
  18 +import org.apache.mina.filter.executor.ExecutorFilter;
  19 +import org.apache.mina.filter.logging.LogLevel;
  20 +import org.apache.mina.filter.logging.LoggingFilter;
  21 +import org.apache.mina.transport.socket.nio.NioSocketAcceptor;
  22 +import org.slf4j.Logger;
  23 +import org.slf4j.LoggerFactory;
  24 +import org.springframework.beans.factory.DisposableBean;
  25 +import org.springframework.beans.factory.InitializingBean;
  26 +import org.springframework.beans.factory.annotation.Autowired;
  27 +import org.springframework.stereotype.Service;
  28 +
  29 +import com.bsth.socket.codec.MessageCodecFactory;
  30 +import com.bsth.socket.manager.MessageSessionManager;
  31 +
  32 +/**
  33 + * @author Hill
  34 + */
  35 +@Service
  36 +public class ServerService implements InitializingBean, DisposableBean {
  37 +
  38 + private final static Logger log = LoggerFactory.getLogger(ServerService.class);
  39 +
  40 + @Autowired
  41 + private ServerHandler serverHandler;
  42 +
  43 + private NioSocketAcceptor dataAccepter;
  44 +
  45 + private ScheduledExecutorService sexec = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
  46 +
  47 + @Override
  48 + public Thread newThread(Runnable r) {
  49 + // TODO Auto-generated method stub
  50 + Thread t = new Thread(r);
  51 + t.setName("DeadSessionCheckExecutor");
  52 + return t;
  53 + }
  54 + });
  55 +
  56 + @Override
  57 + public void afterPropertiesSet() throws Exception {
  58 + // TODO Auto-generated method stub
  59 + sexec.scheduleAtFixedRate(new DeadSessionChecker(), 5, 5, TimeUnit.MINUTES);
  60 + int port = AppProperties.getPort();
  61 + try {
  62 + dataAccepter = new NioSocketAcceptor();
  63 +
  64 + LoggingFilter logger = new LoggingFilter();
  65 + logger.setMessageReceivedLogLevel(LogLevel.DEBUG);
  66 + logger.setSessionClosedLogLevel(LogLevel.WARN);
  67 + dataAccepter.getFilterChain().addLast("logger", logger);
  68 +
  69 + dataAccepter.getFilterChain().addLast("codec",
  70 + new ProtocolCodecFilter(new MessageCodecFactory()));
  71 +
  72 + dataAccepter.getFilterChain().addLast("threadPool", new ExecutorFilter());
  73 +
  74 + IoSessionConfig config = dataAccepter.getSessionConfig();
  75 +
  76 + config.setReadBufferSize(4096);
  77 + config.setWriteTimeout(10);
  78 + config.setIdleTime(IdleStatus.BOTH_IDLE, 50);
  79 +
  80 + dataAccepter.setHandler(serverHandler);
  81 +
  82 + dataAccepter.setReuseAddress(true);
  83 + // 8899
  84 + dataAccepter.bind(new InetSocketAddress(port));
  85 + log.info("数据服务器启动成功!端口号:" + port);
  86 + } catch (Exception e) {
  87 + log.error("服务器启动失败:" + e.getMessage(), e);
  88 + }
  89 + }
  90 +
  91 + @Override
  92 + public void destroy() throws Exception {
  93 + // TODO Auto-generated method stub
  94 + if (dataAccepter != null) {
  95 + dataAccepter.unbind();
  96 + dataAccepter.getFilterChain().clear();
  97 + dataAccepter.dispose();
  98 + dataAccepter = null;
  99 + }
  100 + sexec.shutdown();
  101 + }
  102 +
  103 + final class DeadSessionChecker implements Runnable {
  104 +
  105 + @Override
  106 + public void run() {
  107 + // TODO Auto-generated method stub
  108 + try {
  109 + long now = System.currentTimeMillis();
  110 + MessageSessionManager manager = MessageSessionManager.getInstance();
  111 + log.warn("转发设备号:" + manager.getAllForwardDevice() + " cost:" + (System.currentTimeMillis() - now));
  112 +
  113 + Collection<IoSession> sessions = dataAccepter.getManagedSessions().values();
  114 + for (IoSession session : sessions) {
  115 + if (!session.isActive() && session.getLastIoTime() < System.currentTimeMillis() - 300000 || session.getWriteRequestQueue().size() > 6000) {
  116 + session.getWriteRequestQueue().clear(session);
  117 + dataAccepter.getListeners().fireSessionDestroyed(session);
  118 +
  119 + Class<?> clazzS = session.getClass();
  120 + Field key = clazzS.getDeclaredField("key");
  121 + key.setAccessible(true);
  122 + SelectionKey sk = (SelectionKey)key.get(session);
  123 + sk.cancel();
  124 + }
  125 + }
  126 + } catch (Exception e) {
  127 + log.error("DeadSessionChecker异常", e);
  128 + }
  129 + }
  130 + }
  131 +}
... ...
src/main/java/com/bsth/service/UpProtocolDataService.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/service/UpProtocolDataService.java
  1 +package com.bsth.service;
  2 +
  3 +import java.io.BufferedOutputStream;
  4 +import java.io.File;
  5 +import java.io.FileNotFoundException;
  6 +import java.io.FileOutputStream;
  7 +import java.io.IOException;
  8 +import java.text.SimpleDateFormat;
  9 +import java.util.Date;
  10 +
  11 +import com.bsth.util.AppProperties;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
  14 +
  15 +/**
  16 + * @author Hill
  17 + */
  18 +public class UpProtocolDataService {
  19 +
  20 + private final static Logger log = LoggerFactory.getLogger(UpProtocolDataService.class);
  21 +
  22 + private static UpProtocolDataService service = new UpProtocolDataService();
  23 +
  24 + private SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHH");
  25 +
  26 + private String dir = AppProperties.getUpdir();
  27 +
  28 + private Date cur = new Date();
  29 +
  30 + /**
  31 + * 下次切换写文件时间节点
  32 + */
  33 + private long nextTime;
  34 +
  35 + private BufferedOutputStream out;
  36 +
  37 + private String fileName;
  38 +
  39 + private UpProtocolDataService() {
  40 + File file = new File(dir);
  41 + Date now = new Date();
  42 + if (!file.exists()) {
  43 + file.mkdirs();
  44 + }
  45 + fileName = sdf.format(now);
  46 + nextTime = now.getTime() + 3600000 - now.getTime() % 3600000;
  47 + try {
  48 + out = new BufferedOutputStream(new FileOutputStream(dir + fileName, true));
  49 + } catch (FileNotFoundException e) {
  50 + // TODO Auto-generated catch block
  51 + log.error(dir + fileName + "文件未找到");
  52 + }
  53 + }
  54 +
  55 + public static UpProtocolDataService getInstance() {
  56 + return service;
  57 + }
  58 +
  59 + public void write(byte[] bytes) throws IOException {
  60 + long now = System.currentTimeMillis();
  61 + if (now >= nextTime) {
  62 + cur.setTime(now);
  63 + rollOver(now);
  64 + }
  65 + out.write(bytes);
  66 + }
  67 +
  68 + private synchronized void rollOver(long now) throws IOException {
  69 + if (now < nextTime) {
  70 + return;
  71 + }
  72 + BufferedOutputStream os = out;
  73 + try {
  74 + fileName = sdf.format(cur);
  75 + File file = new File(dir + fileName);
  76 + out = new BufferedOutputStream(new FileOutputStream(file, true));
  77 + nextTime = getNextTime(now);
  78 + } catch (FileNotFoundException e) {
  79 + // TODO Auto-generated catch block
  80 + log.error(dir + fileName + "文件未找到");
  81 + } finally {
  82 + os.flush();
  83 + os.close();
  84 + }
  85 + }
  86 +
  87 + private long getNextTime(long now) {
  88 + return now + 3600000 - now % 3600000;
  89 + }
  90 +}
... ...
src/main/java/com/bsth/socket/codec/MessageCodecFactory.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/socket/codec/MessageCodecFactory.java
  1 +package com.bsth.socket.codec;
  2 +
  3 +import org.apache.mina.core.session.IoSession;
  4 +import org.apache.mina.filter.codec.ProtocolCodecFactory;
  5 +import org.apache.mina.filter.codec.ProtocolDecoder;
  6 +import org.apache.mina.filter.codec.ProtocolEncoder;
  7 +
  8 +/**
  9 + * @author Hill
  10 + */
  11 +public class MessageCodecFactory implements ProtocolCodecFactory {
  12 +
  13 + private ProtocolEncoder encoder;
  14 + private ProtocolDecoder decoder;
  15 +
  16 + public MessageCodecFactory() {
  17 + encoder = new MessageEncoder();
  18 + decoder = new MessageDecoder();
  19 + }
  20 +
  21 + @Override
  22 + public ProtocolEncoder getEncoder(IoSession session) throws Exception {
  23 + // TODO Auto-generated method stub
  24 + return encoder;
  25 + }
  26 +
  27 + @Override
  28 + public ProtocolDecoder getDecoder(IoSession session) throws Exception {
  29 + // TODO Auto-generated method stub
  30 + return decoder;
  31 + }
  32 +
  33 +}
... ...
src/main/java/com/bsth/socket/codec/MessageDecoder.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/socket/codec/MessageDecoder.java
  1 +package com.bsth.socket.codec;
  2 +
  3 +import com.bsth.socket.protocol.Message;
  4 +import com.bsth.service.UpProtocolDataService;
  5 +import com.bsth.util.AppProperties;
  6 +import org.apache.mina.core.buffer.IoBuffer;
  7 +import org.apache.mina.core.session.IoSession;
  8 +import org.apache.mina.filter.codec.CumulativeProtocolDecoder;
  9 +import org.apache.mina.filter.codec.ProtocolDecoderOutput;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +
  13 +import java.nio.ByteBuffer;
  14 +
  15 +/**
  16 + * @author Hill
  17 + */
  18 +public class MessageDecoder extends CumulativeProtocolDecoder {
  19 +
  20 + private final static Logger log = LoggerFactory.getLogger(MessageDecoder.class);
  21 +
  22 + @Override
  23 + protected boolean doDecode(IoSession session, IoBuffer in,
  24 + ProtocolDecoderOutput out) throws Exception {
  25 + // TODO Auto-generated method stub
  26 + while (in.remaining() > 1) {
  27 + in.mark();
  28 + byte start1 = in.get();
  29 + if (start1 == 0x23) {
  30 + byte start2 = in.get();
  31 + if (start2 == 0x23) {
  32 + if (in.remaining() > 21) {
  33 + byte[] bytes1 = new byte[22];
  34 + in.get(bytes1);
  35 + byte lenHigh = bytes1[20], lenLow = bytes1[21];
  36 + int len = ((lenHigh & 0xff) << 8) + (lenLow & 0xff);
  37 + if (in.remaining() > len) {
  38 + ByteBuffer buffer = ByteBuffer.allocate(len + 25);
  39 + byte[] bytes2 = new byte[len + 1];
  40 + in.get(bytes2);
  41 + buffer.put(start1).put(start2).put(bytes1).put(bytes2);
  42 + try {
  43 + Message msg = new Message();
  44 + msg.read(buffer.array());
  45 + out.write(msg);
  46 + } catch (Exception e) {
  47 + StringBuilder sb = new StringBuilder();
  48 + sb.append(" 协议解析异常:").append(buffer.array());
  49 +
  50 + log.error(sb.toString(), e);
  51 + } finally {
  52 + if (AppProperties.isUprecord()) {
  53 + UpProtocolDataService.getInstance().write(buffer.array());
  54 + }
  55 + }
  56 + } else {
  57 + in.reset();
  58 + return false;
  59 + }
  60 + } else {
  61 + in.reset();
  62 + return false;
  63 + }
  64 + } else {
  65 + in.reset();
  66 + in.get();
  67 + }
  68 + } else {
  69 + if (AppProperties.isUprecord()) {
  70 + UpProtocolDataService.getInstance().write(new byte[]{ start1 });
  71 + }
  72 + }
  73 + }
  74 + return false;
  75 + }
  76 +}
... ...
src/main/java/com/bsth/socket/codec/MessageEncoder.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/socket/codec/MessageEncoder.java
  1 +package com.bsth.socket.codec;
  2 +
  3 +import com.bsth.util.AppProperties;
  4 +import org.apache.mina.core.buffer.IoBuffer;
  5 +import org.apache.mina.core.session.IoSession;
  6 +import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
  7 +import org.apache.mina.filter.codec.ProtocolEncoderOutput;
  8 +
  9 +import com.bsth.service.DownProtocolDataService;
  10 +
  11 +/**
  12 + * @author Hill
  13 + */
  14 +public class MessageEncoder extends ProtocolEncoderAdapter {
  15 +
  16 + @Override
  17 + public void encode(IoSession session, Object message,
  18 + ProtocolEncoderOutput out) throws Exception {
  19 + // TODO Auto-generated method stub
  20 + IoBuffer buf = IoBuffer.allocate(1024).setAutoExpand(true);
  21 + buf.put((byte[])message);
  22 + buf.flip();
  23 + out.write(buf);
  24 + if (AppProperties.isDownrecord()) {
  25 + DownProtocolDataService.getInstance().write((byte[])message);
  26 + }
  27 + }
  28 +
  29 +}
... ...
src/main/java/com/bsth/socket/handler/ServerHandler.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/socket/handler/ServerHandler.java
  1 +package com.bsth.socket.handler;
  2 +
  3 +import java.io.IOException;
  4 +import java.util.Date;
  5 +
  6 +import com.bsth.socket.protocol.Message01;
  7 +import org.apache.mina.core.service.IoHandlerAdapter;
  8 +import org.apache.mina.core.session.IdleStatus;
  9 +import org.apache.mina.core.session.IoSession;
  10 +import org.apache.mina.transport.socket.SocketSessionConfig;
  11 +import org.slf4j.Logger;
  12 +import org.slf4j.LoggerFactory;
  13 +import org.springframework.beans.factory.annotation.Autowired;
  14 +import org.springframework.stereotype.Service;
  15 +
  16 +import com.bsth.socket.manager.MessageProcessor;
  17 +import com.bsth.socket.manager.MessageSessionManager;
  18 +import com.bsth.socket.protocol.IMessageBody;
  19 +import com.bsth.socket.protocol.Message;
  20 +
  21 +/**
  22 + * @author Hill
  23 + */
  24 +@Service
  25 +public class ServerHandler extends IoHandlerAdapter{
  26 +
  27 + private final static Logger log = LoggerFactory.getLogger(ServerHandler.class);
  28 + @Autowired
  29 + private MessageProcessor processor;
  30 +
  31 + public MessageProcessor getProcessor() {
  32 + return this.processor;
  33 + }
  34 +
  35 + @Override
  36 + public void sessionCreated(IoSession session) throws Exception {
  37 + SocketSessionConfig cfg = (SocketSessionConfig) session.getConfig();
  38 + cfg.setTcpNoDelay(true);
  39 + cfg.setSoLinger(0);
  40 + }
  41 +
  42 + @Override
  43 + public void sessionOpened(IoSession session) throws Exception {
  44 +
  45 + }
  46 +
  47 + @Override
  48 + public void sessionClosed(IoSession session) throws Exception {
  49 + String deviceId = (String)session.getAttribute("deviceId");
  50 + if (deviceId != null && session == MessageSessionManager.getInstance().getSession(deviceId)) {
  51 + MessageSessionManager.getInstance().unregister(deviceId);
  52 + log.warn("vin:" + deviceId + "断开连接");
  53 + }
  54 + }
  55 +
  56 + @Override
  57 + public void sessionIdle(IoSession session, IdleStatus status) throws Exception {
  58 + log.warn("idle 关闭连接, vin " + session.getAttribute("deviceId") + " status " + status + ",lastIo:" + new Date(session.getLastIoTime()) + ",now:" + new Date(System.currentTimeMillis()));
  59 + session.closeNow();
  60 + }
  61 +
  62 + @Override
  63 + public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
  64 + if (cause instanceof IOException) {
  65 + log.warn("handler exceptionCaught 关闭连接,vin " + session.getAttribute("deviceId"));
  66 + }
  67 + log.error("MessageServerHandler捕获异常", cause);
  68 + }
  69 +
  70 + @Override
  71 + public void messageReceived(IoSession session, Object message) throws Exception {
  72 + Message msg = (Message)message;
  73 + IMessageBody body = msg.getMessageBody();
  74 + String sDeviceId = (String)session.getAttribute("deviceId");
  75 + if (body != null) {
  76 + String vin = msg.getVin();
  77 + log.warn("msg.getVin():" + vin);
  78 + if (Message01.COMMAND == msg.getCommand()) {
  79 + if (sDeviceId == null) {
  80 + MessageSessionManager.getInstance().register(vin, session);
  81 + log.warn("vin:" + vin + "建立连接");
  82 + }
  83 + }
  84 + processor.process(msg);
  85 + } else {
  86 + log.warn("异常协议命令字:" + msg.getCommand());
  87 + if (sDeviceId == null) {
  88 + log.warn("未登入");
  89 + }
  90 + }
  91 + }
  92 +
  93 + @Override
  94 + public void messageSent(IoSession session, Object message) throws Exception {
  95 +
  96 + }
  97 +}
... ...
src/main/java/com/bsth/socket/manager/MessageProcessor.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/socket/manager/MessageProcessor.java
  1 +package com.bsth.socket.manager;
  2 +
  3 +
  4 +import com.bsth.socket.protocol.Message;
  5 +import com.bsth.socket.protocol.Message02;
  6 +import com.bsth.util.ProtocolConverter;
  7 +import com.fasterxml.jackson.databind.ObjectMapper;
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +import org.springframework.beans.factory.InitializingBean;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.kafka.core.KafkaTemplate;
  13 +import org.springframework.kafka.support.SendResult;
  14 +import org.springframework.stereotype.Service;
  15 +import org.springframework.util.concurrent.ListenableFuture;
  16 +import org.springframework.util.concurrent.ListenableFutureCallback;
  17 +
  18 +import java.util.Map;
  19 +
  20 +/**
  21 + * @author Hill
  22 + */
  23 +@Service
  24 +public class MessageProcessor {
  25 +
  26 + @Autowired
  27 + private KafkaTemplate kafkaTemplate;
  28 +
  29 + private final static Logger log = LoggerFactory.getLogger(MessageProcessor.class);
  30 +
  31 + private ObjectMapper mapper = new ObjectMapper();
  32 +
  33 + private KafkaCallback callback = new KafkaCallback();
  34 +
  35 + public void process(Message msg) {
  36 + try {
  37 + if (msg.getCommand() == 0x02 || msg.getCommand() == 0x03) {
  38 + Map<String, Object> data = ProtocolConverter.convert(msg);
  39 + String json = mapper.writeValueAsString(data);
  40 + ListenableFuture<SendResult<String, String>> future = kafkaTemplate.send("LGGJ_ELEC_VEHICLE", json);
  41 + future.addCallback(callback);
  42 + }
  43 + MessageSender.getInstance().ack(msg);
  44 + } catch (Exception e) {
  45 + log.error("Processor msg:" + msg, e);
  46 + }
  47 + }
  48 +
  49 + private final static class KafkaCallback implements ListenableFutureCallback<SendResult<String, String>> {
  50 +
  51 + @Override
  52 + public void onSuccess(SendResult<String, String> result) {
  53 + log.info(result.getProducerRecord().value());
  54 + }
  55 +
  56 + @Override
  57 + public void onFailure(Throwable ex) {
  58 + log.error("kafka发送电车数据异常", ex);
  59 + }
  60 + }
  61 +}
... ...
src/main/java/com/bsth/socket/manager/MessageSender.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/socket/manager/MessageSender.java
  1 +package com.bsth.socket.manager;
  2 +
  3 +import java.util.concurrent.ConcurrentLinkedQueue;
  4 +import java.util.concurrent.ExecutorService;
  5 +import java.util.concurrent.Executors;
  6 +import java.util.concurrent.ThreadFactory;
  7 +
  8 +import org.slf4j.Logger;
  9 +import org.slf4j.LoggerFactory;
  10 +
  11 +import com.bsth.socket.protocol.Message;
  12 +import com.bsth.util.AckUtil;
  13 +
  14 +/**
  15 + * @author Hill
  16 + */
  17 +public class MessageSender {
  18 +
  19 + private final static Logger log = LoggerFactory.getLogger(MessageSender.class);
  20 +
  21 + private static MessageSender sender = new MessageSender();
  22 + private ConcurrentLinkedQueue<Message> queue = new ConcurrentLinkedQueue<Message>();
  23 + private ExecutorService exec = Executors.newFixedThreadPool(5, new ThreadFactory() {
  24 +
  25 + @Override
  26 + public Thread newThread(Runnable r) {
  27 + // TODO Auto-generated method stub
  28 + Thread t = new Thread(r);
  29 + t.setName("MessageSendPool");
  30 + return t;
  31 + }
  32 + });
  33 +
  34 + private MessageSender() {
  35 + exec.submit(new MessageSendWorker());
  36 + }
  37 +
  38 + public static MessageSender getInstance() {
  39 + return sender;
  40 + }
  41 +
  42 + public void ack(Message msg) {
  43 + Message ack = AckUtil.generateAckMessage(msg);
  44 + if (ack.getMessageBody() != null) {
  45 + queue.add(ack);
  46 + }
  47 + }
  48 +
  49 + public void send(Message msg) {
  50 + queue.add(msg);
  51 + }
  52 +
  53 + final class MessageSendWorker implements Runnable {
  54 +
  55 + @Override
  56 + public void run() {
  57 + // TODO Auto-generated method stub
  58 + while (true) {
  59 + try {
  60 + final Message msg = queue.poll();
  61 + if (msg == null) {
  62 + try {
  63 + Thread.sleep(50);
  64 + } catch (InterruptedException e) {
  65 + log.error("sender sleep", e);
  66 + }
  67 + continue;
  68 + }
  69 + exec.submit(new Runnable() {
  70 +
  71 + @Override
  72 + public void run() {
  73 + // TODO Auto-generated method stub
  74 + try {
  75 + if (MessageSessionManager.getInstance().getSession(msg.getVin()) != null)
  76 + MessageSessionManager.getInstance().getSession(msg.getVin()).write(msg.write());
  77 + else {
  78 + StringBuilder sb = new StringBuilder();
  79 + sb.append(" vin:")
  80 + .append(msg.getVin())
  81 + .append(" 无会话信息,不发送消息.消息:")
  82 + .append(msg.toString());
  83 +
  84 + log.warn(sb.toString());
  85 + }
  86 + } catch (Exception e) {
  87 + log.error("MessageSendWorker handle exception|" + msg , e);
  88 + }
  89 + }
  90 + });
  91 + } catch (Exception e) {
  92 + log.error("MessageSendPool handle exception");
  93 + }
  94 + }
  95 + }
  96 + }
  97 +}
... ...
src/main/java/com/bsth/socket/manager/MessageSessionManager.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/socket/manager/MessageSessionManager.java
  1 +package com.bsth.socket.manager;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.List;
  5 +import java.util.Map;
  6 +import java.util.concurrent.ConcurrentHashMap;
  7 +
  8 +import com.bsth.util.AppProperties;
  9 +import org.apache.mina.core.session.IoSession;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +
  13 +/**
  14 + * @author Hill
  15 + */
  16 +public class MessageSessionManager {
  17 +
  18 + private final static Logger log = LoggerFactory.getLogger(MessageSessionManager.class);
  19 +
  20 + private static MessageSessionManager sessionManager = new MessageSessionManager();
  21 + private Map<String, IoSession> deviceSession = new ConcurrentHashMap<String, IoSession>();
  22 + private Map<String, IoSession> forwardDevice = new ConcurrentHashMap<String, IoSession>();
  23 +
  24 + private MessageSessionManager() {
  25 +
  26 + }
  27 +
  28 + public static MessageSessionManager getInstance() {
  29 + return sessionManager;
  30 + }
  31 +
  32 + public void register(String deviceId, IoSession session) {
  33 + session.setAttribute("deviceId", deviceId);
  34 + if (deviceId.startsWith(AppProperties.getForwarddevice())) {
  35 + forwardDevice.put(deviceId, session);
  36 + return;
  37 + }
  38 + deviceSession.put(deviceId, session);
  39 + }
  40 +
  41 + public void unregister(String deviceId) {
  42 + IoSession session = null;
  43 + if (deviceId.startsWith(AppProperties.getForwarddevice())) {
  44 + session = forwardDevice.remove(deviceId);
  45 + if (session != null) session.removeAttribute("deviceId");
  46 + return;
  47 + }
  48 + session = deviceSession.remove(deviceId);
  49 + if (session != null) session.removeAttribute("deviceId");
  50 + }
  51 +
  52 + public IoSession getSession(String deviceId) {
  53 + if (deviceId.startsWith(AppProperties.getForwarddevice())) {
  54 + return forwardDevice.get(deviceId);
  55 + }
  56 + return deviceSession.get(deviceId);
  57 + }
  58 +
  59 + public List<String> getAllDevice() {
  60 + return new ArrayList<>(deviceSession.keySet());
  61 + }
  62 +
  63 + public List<IoSession> getAllSession() {
  64 + return new ArrayList<>(deviceSession.values());
  65 + }
  66 +
  67 + public IoSession getForwardSession(String deviceId) {
  68 + return forwardDevice.get(deviceId);
  69 + }
  70 +
  71 + public List<String> getAllForwardDevice() {
  72 + return new ArrayList<>(forwardDevice.keySet());
  73 + }
  74 +
  75 + public List<IoSession> getAllForwardSession() {
  76 + return new ArrayList<>(forwardDevice.values());
  77 + }
  78 +}
... ...
src/main/java/com/bsth/socket/protocol/IMessage82Param.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/socket/protocol/IMessage82Param.java
  1 +package com.bsth.socket.protocol;
  2 +
  3 +/**
  4 + * @author Hill
  5 + */
  6 +public interface IMessage82Param {
  7 +
  8 + public byte[] write();
  9 +}
... ...
src/main/java/com/bsth/socket/protocol/IMessageBody.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/socket/protocol/IMessageBody.java
  1 +package com.bsth.socket.protocol;
  2 +
  3 +/**
  4 + * @author Hill
  5 + */
  6 +public interface IMessageBody {
  7 +
  8 + public void read(byte[] bytes);
  9 +
  10 + public byte[] write();
  11 +
  12 + public void setTimestamp(long timestamp);
  13 +}
... ...
src/main/java/com/bsth/socket/protocol/IMessageBody02.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/socket/protocol/IMessageBody02.java
  1 +package com.bsth.socket.protocol;
  2 +
  3 +/**
  4 + * @author Hill
  5 + */
  6 +public interface IMessageBody02 {
  7 +
  8 + /**
  9 + * 根据字节数组组装实时信息体数据
  10 + * @param bytes 字节数组
  11 + */
  12 + public void read(byte[] bytes, int idx);
  13 +
  14 + /**
  15 + * 获取实时信息体内容字节长度
  16 + * @return 实时信息体内容字节长度
  17 + */
  18 + public int getByteLen();
  19 +}
... ...
src/main/java/com/bsth/socket/protocol/Message.java 0 → 100644
  1 +++ a/src/main/java/com/bsth/socket/protocol/Message.java
  1 +package com.bsth.socket.protocol;
  2 +
  3 +import com.bsth.util.ConvertUtil;
  4 +import com.bsth.util.CrcUtil;
  5 +
  6 +import java.nio.ByteBuffer;
  7 +import java.util.Arrays;
  8 +
  9 +/**
  10 + * @author Hill
  11 + */
  12 +public class Message {
  13 +
  14 + /**
  15 + * 协议起始符
  16 + */
  17 + private String start = "##";
  18 +
  19 + /**
  20 + * 命令标识
  21 + */
  22 + private byte command;
  23 +
  24 + /**
  25 + * 应答标志
  26 + * 0x01 成功
  27 + * 0x02 设置识别
  28 + * 0x03 vin重复
  29 + * 0xFE 命令
  30 + */
  31 + private byte ackFlag;
  32 +
  33 + /**
  34 + * 车辆识别码(常规vin,可自定义唯一码)
  35 + */
  36 + private String vin = "\0";
  37 +
  38 + /**
  39 + * 加密方式
  40 + */
  41 + private byte encryption;
  42 +
  43 + /**
  44 + * 数据长度
  45 + */
  46 + private short dataLength;
  47 +
  48 + /**
  49 + * 数据体
  50 + */
  51 + private IMessageBody messageBody;
  52 +
  53 + /**
  54 + * 校验码(BBC)
  55 + */
  56 + private byte crc;
  57 +
  58 + public void read(byte[] data) {
  59 + int idx = 2, len = data.length;
  60 + command = data[idx]; idx++;
  61 + ackFlag = data[idx]; idx++;
  62 + vin = ConvertUtil.ascii2string(data, idx, 17); idx += 17;
  63 + encryption = data[idx]; idx += 3;
  64 + byte[] temp = Arrays.copyOfRange(data, idx, len - 1);
  65 + crc = data[len - 1];
  66 + byte sum = CrcUtil.bbc(data, 2, len - 2);
  67 + if (sum == crc) {
  68 + System.out.println(ConvertUtil.toHexString(data));
  69 + messageBody = MessageFactory.create(command, temp);
  70 + } else {
  71 + throw new ProtocolException("校验未通过" + ConvertUtil.toHexString(data));
  72 + }
  73 + }
  74 +
  75 + public byte[] write() {
  76 + byte[] bytes = messageBody.write();
  77 + ByteBuffer buf = ByteBuffer.allocate(bytes.length + 25);
  78 + buf.put(start.getBytes());
  79 + buf.put(command);
  80 + buf.put(ackFlag);
  81 + buf.put(vin.getBytes());
  82 + buf.put(encryption);
  83 + buf.putShort((short)bytes.length);
  84 + buf.put(bytes);
  85 + byte[] data = buf.array();
  86 + crc = CrcUtil.bbc(data, 2, data.length - 2);
  87 + buf.put(crc);
  88 +
  89 + return buf.array();
  90 + }
  91 +
  92 + public String getStart() {
  93 + return start;
  94 + }
  95 +
  96 + public void setStart(String start) {
  97 + this.start = start;
  98 + }
  99 +
  100 + public byte getCommand() {
  101 + return command;
  102 + }
  103 +
  104 + public void setCommand(byte command) {
  105 + this.command = command;
  106 + }
  107 +
  108 + public byte getAckFlag() {
  109 + return ackFlag;
  110 + }
  111 +
  112 + public void setAckFlag(byte ackFlag) {
  113 + this.ackFlag = ackFlag;
  114 + }
  115 +
  116 + public String getVin() {
  117 + return vin;
  118 + }
  119 +
  120 + public void setVin(String vin) {
  121 + this.vin = vin;
  122 + }
  123 +
  124 + public byte getEncryption() {
  125 + return encryption;
  126 + }
  127 +
  128 + public void setEncryption(byte encryption) {
  129 + this.encryption = encryption;
  130 + }
  131 +
  132 + public short getDataLength() {
  133 + return dataLength;
  134 + }
  135 +
  136 + public void setDataLength(short dataLength) {
  137 + this.dataLength = dataLength;
  138 + }
  139 +
  140 + public IMessageBody getMessageBody() {
  141 + return messageBody;
  142 + }
  143 +
  144 + public void setMessageBody(IMessageBody messageBody) {
  145 + this.messageBody = messageBody;
  146 + }
  147 +
  148 + public byte getCrc() {
  149 + return crc;
  150 + }
  151 +
  152 + public void setCrc(byte crc) {
  153 + this.crc = crc;
  154 + }
  155 +
  156 + @Override
  157 + public String toString() {
  158 + StringBuilder sb = new StringBuilder();
  159 + sb.append(" 起始符号:").append(start)
  160 + .append(" 命令标识:").append(command)
  161 + .append(" 应答标志:").append(ackFlag)
  162 + .append(" vin:").append(vin)
  163 + .append(" 加密方式:").append(encryption)
  164 + .append(" 报文主体:(").append(messageBody).append(" )")
  165 + .append(" 报文校验和:").append(crc);
  166 +
  167 + return sb.toString();
  168 + }
  169 +
  170 + public static void main(String args[]) {
  171 + // (byte)0x11,(byte)0x64,(byte)0x47,(byte)0x00,(byte)0x33,(byte)0x31,(byte)0x44,(byte)0x51,(byte)0x33,(byte)0x38,(byte)0x33,(byte)0x31,(byte)0x17,(byte)0x07,(byte)0x26,(byte)0x16,(byte)0x54,(byte)0x24,(byte)0x00,(byte)0x00,(byte)0x45,(byte)0x4e,(byte)0x07,(byte)0x1a,(byte)0x10,(byte)0x37,(byte)0x51
  172 + // (byte)0x11,(byte)0x5e,(byte)0x46,(byte)0x00,(byte)0x33,(byte)0x31,(byte)0x44,(byte)0x51,(byte)0x33,(byte)0x38,(byte)0x33,(byte)0x31,(byte)0x17,(byte)0x07,(byte)0x26,(byte)0x16,(byte)0x53,(byte)0x33,(byte)0x60,(byte)0x00,(byte)0x00,(byte)0x45,(byte)0x4e,(byte)0x07,(byte)0x1a,(byte)0x10,(byte)0x37,(byte)0xb8
  173 + byte[] bytes = new byte[]{(byte)0x23,(byte)0x23,(byte)0x02,(byte)0xFE,(byte)0x4C,(byte)0x53,(byte)0x46,(byte)0x44,(byte)0x31,(byte)0x33,(byte)0x32,(byte)0x30,(byte)0x30,(byte)0x50,(byte)0x43,(byte)0x30,(byte)0x30,(byte)0x30,(byte)0x32,(byte)0x35,(byte)0x35,(byte)0x01,(byte)0x00,(byte)0x7F,(byte)0x17,(byte)0x07,(byte)0x04,(byte)0x09,(byte)0x39,(byte)0x26,(byte)0x01,(byte)0x01,(byte)0x03,(byte)0x01,(byte)0x01,(byte)0x7B,(byte)0x00,(byte)0x00,(byte)0x27,(byte)0xEC,(byte)0x17,(byte)0x39,(byte)0x2A,(byte)0x04,(byte)0x54,(byte)0xFF,(byte)0x0E,(byte)0x19,(byte)0x64,(byte)0x14,(byte)0x00,(byte)0x02,(byte)0x01,(byte)0x01,(byte)0x01,(byte)0x56,(byte)0x53,(byte)0x43,(byte)0x57,(byte)0x26,(byte)0x65,(byte)0x17,(byte)0x28,(byte)0x29,(byte)0x54,(byte)0x05,(byte)0x01,(byte)0x07,(byte)0x44,(byte)0x28,(byte)0x25,(byte)0x01,(byte)0xD7,(byte)0x30,(byte)0x37,(byte)0x06,(byte)0x01,(byte)0x02,(byte)0x0C,(byte)0xED,(byte)0x01,(byte)0x45,(byte)0x0C,(byte)0xE6,(byte)0x01,(byte)0x01,(byte)0x4C,(byte)0x01,(byte)0x37,(byte)0x4A,(byte)0x07,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x80,(byte)0x00,(byte)0x30,(byte)0xDC,(byte)0xDC,(byte)0x36,(byte)0x04,(byte)0xFA,(byte)0x04,(byte)0xEC,(byte)0x57,(byte)0x57,(byte)0xF6,(byte)0x53,(byte)0xF4,(byte)0x54,(byte)0xF4,(byte)0x54,(byte)0xF6,(byte)0x55,(byte)0xF7,(byte)0x56,(byte)0xF8,(byte)0x56,(byte)0x17,(byte)0x3A,(byte)0x2A,(byte)0x04,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x00,(byte)0x30,(byte)0x69,(byte)0x00,(byte)0x00,(byte)0x27,(byte)0x2A,(byte)0x01,(byte)0xA0,(byte)0x19,(byte)0x64,(byte)0x19,(byte)0x64,(byte)0x57,(byte)0xFF,(byte)0x00,(byte)0xFF,(byte)0x80,(byte)0x4B,(byte)0x02,(byte)0xC7};
  174 + Message msg= new Message();
  175 + msg.read(bytes);
  176 + System.out.println(msg);
  177 + //System.out.println(bytes[bytes.length - 1]);
  178 + //System.out.println(CrcUtil.bbc(bytes, 2, bytes.length - 2));
  179 +
  180 + //byte[] bytes1 = new byte[]{(byte)0x17,(byte)0x03,(byte)0x10,(byte)0x09,(byte)0x0a,(byte)0x12};
  181 + //System.out.println(new DateTime(ConvertUtil.bytes2timestamp(bytes1, 0)).toString("yyyy-MM-dd HH:mm:ss"));
  182 + }
  183 +}
... ...