Commit e2764e635c27be3c2963fd0a3a85f006a55a98ae
0 parents
init
Showing
60 changed files
with
4670 additions
and
0 deletions
Too many changes to show.
To preserve performance only 60 of 244 files are displayed.
.gitignore
0 → 100644
README.md
0 → 100644
git
0 → 100644
| 1 | +++ a/git |
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" | ||
| 2 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 3 | + | ||
| 4 | + <modelVersion>4.0.0</modelVersion> | ||
| 5 | + <groupId>com.bsth</groupId> | ||
| 6 | + <artifactId>bus_park_dispatch</artifactId> | ||
| 7 | + <version>0.0.1-SNAPSHOT</version> | ||
| 8 | + <packaging>jar</packaging> | ||
| 9 | + | ||
| 10 | + <parent> | ||
| 11 | + <groupId>org.springframework.boot</groupId> | ||
| 12 | + <artifactId>spring-boot-starter-parent</artifactId> | ||
| 13 | + <version>1.5.6.RELEASE</version> | ||
| 14 | + </parent> | ||
| 15 | + | ||
| 16 | + <dependencies> | ||
| 17 | + <dependency> | ||
| 18 | + <groupId>org.springframework.boot</groupId> | ||
| 19 | + <artifactId>spring-boot-starter-web</artifactId> | ||
| 20 | + </dependency> | ||
| 21 | + | ||
| 22 | + <dependency> | ||
| 23 | + <groupId>org.springframework.boot</groupId> | ||
| 24 | + <artifactId>spring-boot-starter-tomcat</artifactId> | ||
| 25 | + <scope>provided</scope> | ||
| 26 | + </dependency> | ||
| 27 | + <dependency> | ||
| 28 | + <groupId>javax.servlet</groupId> | ||
| 29 | + <artifactId>javax.servlet-api</artifactId> | ||
| 30 | + <version>3.1.0</version> | ||
| 31 | + <scope>provided</scope> | ||
| 32 | + </dependency> | ||
| 33 | + <dependency> | ||
| 34 | + <groupId>org.springframework.boot</groupId> | ||
| 35 | + <artifactId>spring-boot-starter-security</artifactId> | ||
| 36 | + </dependency> | ||
| 37 | + <!-- <dependency> <groupId>org.springframework.security</groupId> <artifactId>spring-security-config</artifactId> | ||
| 38 | + </dependency> --> | ||
| 39 | + <dependency> | ||
| 40 | + <groupId>org.springframework.boot</groupId> | ||
| 41 | + <artifactId>spring-boot-starter-data-jpa</artifactId> | ||
| 42 | + </dependency> | ||
| 43 | + <dependency> | ||
| 44 | + <groupId>org.springframework.boot</groupId> | ||
| 45 | + <artifactId>spring-boot-starter-aop</artifactId> | ||
| 46 | + </dependency> | ||
| 47 | + | ||
| 48 | + <dependency> | ||
| 49 | + <groupId>org.springframework</groupId> | ||
| 50 | + <artifactId>spring-context-support</artifactId> | ||
| 51 | + </dependency> | ||
| 52 | + <dependency> | ||
| 53 | + <groupId>org.springframework.boot</groupId> | ||
| 54 | + <artifactId>spring-boot-starter-websocket</artifactId> | ||
| 55 | + </dependency> | ||
| 56 | + <dependency> | ||
| 57 | + <groupId>mysql</groupId> | ||
| 58 | + <artifactId>mysql-connector-java</artifactId> | ||
| 59 | + </dependency> | ||
| 60 | + | ||
| 61 | + <dependency> | ||
| 62 | + <groupId>joda-time</groupId> | ||
| 63 | + <artifactId>joda-time</artifactId> | ||
| 64 | + </dependency> | ||
| 65 | + <dependency> | ||
| 66 | + <groupId>com.alibaba</groupId> | ||
| 67 | + <artifactId>fastjson</artifactId> | ||
| 68 | + <version>1.2.4</version> | ||
| 69 | + </dependency> | ||
| 70 | + | ||
| 71 | + <dependency> | ||
| 72 | + <groupId>org.apache.httpcomponents</groupId> | ||
| 73 | + <artifactId>httpclient</artifactId> | ||
| 74 | + </dependency> | ||
| 75 | + | ||
| 76 | + <dependency> | ||
| 77 | + <groupId>commons-dbcp</groupId> | ||
| 78 | + <artifactId>commons-dbcp</artifactId> | ||
| 79 | + </dependency> | ||
| 80 | + <dependency> | ||
| 81 | + <groupId>commons-lang</groupId> | ||
| 82 | + <artifactId>commons-lang</artifactId> | ||
| 83 | + <version>2.6</version> | ||
| 84 | + </dependency> | ||
| 85 | + <dependency> | ||
| 86 | + <groupId>org.apache.commons</groupId> | ||
| 87 | + <artifactId>commons-lang3</artifactId> | ||
| 88 | + <version>3.4</version> | ||
| 89 | + </dependency> | ||
| 90 | + <dependency> | ||
| 91 | + <groupId>commons-fileupload</groupId> | ||
| 92 | + <artifactId>commons-fileupload</artifactId> | ||
| 93 | + <version>1.2.2</version> | ||
| 94 | + </dependency> | ||
| 95 | + <dependency> | ||
| 96 | + <groupId>commons-io</groupId> | ||
| 97 | + <artifactId>commons-io</artifactId> | ||
| 98 | + <version>2.4</version> | ||
| 99 | + </dependency> | ||
| 100 | + <dependency> | ||
| 101 | + <groupId>org.codehaus.janino</groupId> | ||
| 102 | + <artifactId>janino</artifactId> | ||
| 103 | + </dependency> | ||
| 104 | + | ||
| 105 | + <dependency> | ||
| 106 | + <groupId>org.apache.poi</groupId> | ||
| 107 | + <artifactId>poi-ooxml</artifactId> | ||
| 108 | + <version>3.13</version> | ||
| 109 | + </dependency> | ||
| 110 | + | ||
| 111 | + <dependency> | ||
| 112 | + <groupId>com.google.guava</groupId> | ||
| 113 | + <artifactId>guava</artifactId> | ||
| 114 | + <version>19.0</version> | ||
| 115 | + </dependency> | ||
| 116 | + <!-- ftp文件上传包 --> | ||
| 117 | + <dependency> | ||
| 118 | + <groupId>commons-net</groupId> | ||
| 119 | + <artifactId>commons-net</artifactId> | ||
| 120 | + <version>3.5</version> | ||
| 121 | + </dependency> | ||
| 122 | + <dependency> | ||
| 123 | + <groupId>org.apache.commons</groupId> | ||
| 124 | + <artifactId>commons-compress</artifactId> | ||
| 125 | + <version>1.3</version> | ||
| 126 | + </dependency> | ||
| 127 | + <dependency> | ||
| 128 | + <groupId>c3p0</groupId> | ||
| 129 | + <artifactId>c3p0</artifactId> | ||
| 130 | + <version>0.9.1.2</version> | ||
| 131 | + </dependency> | ||
| 132 | + | ||
| 133 | + <!-- 图表 --> | ||
| 134 | + <dependency> | ||
| 135 | + <groupId>com.google.code.gson</groupId> | ||
| 136 | + <artifactId>gson</artifactId> | ||
| 137 | + <version>2.2.4</version> | ||
| 138 | + </dependency> | ||
| 139 | + <dependency> | ||
| 140 | + <groupId>com.github.abel533</groupId> | ||
| 141 | + <artifactId>ECharts</artifactId> | ||
| 142 | + <version>2.1.8</version> | ||
| 143 | + </dependency> | ||
| 144 | + <dependency> | ||
| 145 | + <groupId>net.sourceforge.jexcelapi</groupId> | ||
| 146 | + <artifactId>jxl</artifactId> | ||
| 147 | + <version>2.6.12</version> | ||
| 148 | + </dependency> | ||
| 149 | + <dependency> | ||
| 150 | + <groupId>rhino</groupId> | ||
| 151 | + <artifactId>js</artifactId> | ||
| 152 | + <version>1.7R2</version> | ||
| 153 | + </dependency> | ||
| 154 | + <dependency> | ||
| 155 | + <groupId>javax.mail</groupId> | ||
| 156 | + <artifactId>mail</artifactId> | ||
| 157 | + <version>1.4.7</version> | ||
| 158 | + </dependency> | ||
| 159 | + | ||
| 160 | + <dependency> | ||
| 161 | + <groupId>com.github.axet</groupId> | ||
| 162 | + <artifactId>kaptcha</artifactId> | ||
| 163 | + <version>0.0.9</version> | ||
| 164 | + </dependency> | ||
| 165 | + | ||
| 166 | + <dependency> | ||
| 167 | + <groupId>commons-codec</groupId> | ||
| 168 | + <artifactId>commons-codec</artifactId> | ||
| 169 | + <version>1.4</version> | ||
| 170 | + <scope>compile</scope> | ||
| 171 | + </dependency> | ||
| 172 | + <dependency> | ||
| 173 | + <groupId>org.bouncycastle</groupId> | ||
| 174 | + <artifactId>bcprov-jdk15on</artifactId> | ||
| 175 | + <version>1.52</version> | ||
| 176 | + </dependency> | ||
| 177 | + <dependency> | ||
| 178 | + <groupId>axis</groupId> | ||
| 179 | + <artifactId>axis</artifactId> | ||
| 180 | + <version>1.4</version> | ||
| 181 | + </dependency> | ||
| 182 | + <dependency> | ||
| 183 | + <groupId>javax.xml</groupId> | ||
| 184 | + <artifactId>jaxrpc-api</artifactId> | ||
| 185 | + <version>1.1</version> | ||
| 186 | + </dependency> | ||
| 187 | + | ||
| 188 | + <dependency> | ||
| 189 | + <groupId>org.apache.axis2</groupId> | ||
| 190 | + <artifactId>axis2-adb</artifactId> | ||
| 191 | + <version>1.7.4</version> | ||
| 192 | + </dependency> | ||
| 193 | + <dependency> | ||
| 194 | + <groupId>org.apache.axis2</groupId> | ||
| 195 | + <artifactId>axis2-transport-local</artifactId> | ||
| 196 | + <version>1.7.4</version> | ||
| 197 | + </dependency> | ||
| 198 | + <dependency> | ||
| 199 | + <groupId>org.apache.axis2</groupId> | ||
| 200 | + <artifactId>axis2-transport-http</artifactId> | ||
| 201 | + <version>1.7.4</version> | ||
| 202 | + </dependency> | ||
| 203 | + | ||
| 204 | + | ||
| 205 | + <!-- <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> | ||
| 206 | + <optional>true</optional> </dependency> --> | ||
| 207 | + <dependency> | ||
| 208 | + <groupId>com.vividsolutions</groupId> | ||
| 209 | + <artifactId>jts</artifactId> | ||
| 210 | + <version>1.13</version> | ||
| 211 | + </dependency> | ||
| 212 | + | ||
| 213 | + <dependency> | ||
| 214 | + <groupId>org.dbunit</groupId> | ||
| 215 | + <artifactId>dbunit</artifactId> | ||
| 216 | + <version>2.4.9</version> | ||
| 217 | + <scope>test</scope> | ||
| 218 | + | ||
| 219 | + <exclusions> | ||
| 220 | + <exclusion> | ||
| 221 | + <groupId>org.slf4j</groupId> | ||
| 222 | + <artifactId>slf4j-api</artifactId> | ||
| 223 | + </exclusion> | ||
| 224 | + </exclusions> | ||
| 225 | + </dependency> | ||
| 226 | + | ||
| 227 | + <dependency> | ||
| 228 | + <groupId>com.h2database</groupId> | ||
| 229 | + <artifactId>h2</artifactId> | ||
| 230 | + <version>1.2.132</version> | ||
| 231 | + <scope>test</scope> | ||
| 232 | + </dependency> | ||
| 233 | + | ||
| 234 | + | ||
| 235 | + <dependency> | ||
| 236 | + <groupId>ojdbc</groupId> | ||
| 237 | + <artifactId>ojdbc</artifactId> | ||
| 238 | + <version>14</version> | ||
| 239 | + </dependency> | ||
| 240 | + | ||
| 241 | + <dependency> | ||
| 242 | + <groupId>org.apache.mina</groupId> | ||
| 243 | + <artifactId>mina-core</artifactId> | ||
| 244 | + <version>2.0.13</version> | ||
| 245 | + </dependency> | ||
| 246 | + | ||
| 247 | + <dependency> | ||
| 248 | + <groupId>com.google.protobuf</groupId> | ||
| 249 | + <artifactId>protobuf-java</artifactId> | ||
| 250 | + <version>3.3.0</version> | ||
| 251 | + </dependency> | ||
| 252 | + | ||
| 253 | + <dependency> | ||
| 254 | + <groupId>com.github.stuxuhai</groupId> | ||
| 255 | + <artifactId>jpinyin</artifactId> | ||
| 256 | + <version>1.1.8</version> | ||
| 257 | + </dependency> | ||
| 258 | + | ||
| 259 | + <!-- CXF的rs客户端 --> | ||
| 260 | + <dependency> | ||
| 261 | + <groupId>org.apache.cxf</groupId> | ||
| 262 | + <artifactId>cxf-rt-rs-client</artifactId> | ||
| 263 | + <version>3.0.0-milestone1</version> | ||
| 264 | + </dependency> | ||
| 265 | + | ||
| 266 | + <dependency> | ||
| 267 | + <groupId>com.fasterxml.jackson.jaxrs</groupId> | ||
| 268 | + <artifactId>jackson-jaxrs-json-provider</artifactId> | ||
| 269 | + <version>2.9.0</version> | ||
| 270 | + </dependency> | ||
| 271 | + | ||
| 272 | + <dependency> | ||
| 273 | + <groupId>org.apache.poi</groupId> | ||
| 274 | + <artifactId>poi</artifactId> | ||
| 275 | + <version>3.15</version> | ||
| 276 | + </dependency> | ||
| 277 | + </dependencies> | ||
| 278 | + | ||
| 279 | + <build> | ||
| 280 | + <plugins> | ||
| 281 | + <plugin> | ||
| 282 | + <artifactId>maven-compiler-plugin</artifactId> | ||
| 283 | + <version>2.3.2</version><!--$NO-MVN-MAN-VER$ --> | ||
| 284 | + <configuration> | ||
| 285 | + <source>1.7</source> | ||
| 286 | + <target>1.7</target> | ||
| 287 | + </configuration> | ||
| 288 | + </plugin> | ||
| 289 | + <plugin> | ||
| 290 | + <artifactId>maven-war-plugin</artifactId> | ||
| 291 | + <version>2.2</version><!--$NO-MVN-MAN-VER$ --> | ||
| 292 | + <configuration> | ||
| 293 | + <failOnMissingWebXml>false</failOnMissingWebXml> | ||
| 294 | + </configuration> | ||
| 295 | + </plugin> | ||
| 296 | + <plugin> | ||
| 297 | + <groupId>org.springframework.boot</groupId> | ||
| 298 | + <artifactId>spring-boot-maven-plugin</artifactId> | ||
| 299 | + </plugin> | ||
| 300 | + </plugins> | ||
| 301 | + <resources> | ||
| 302 | + <resource> | ||
| 303 | + <directory>src/main/resources</directory> | ||
| 304 | + <filtering>false</filtering> | ||
| 305 | + </resource> | ||
| 306 | + </resources> | ||
| 307 | + </build> | ||
| 308 | + <repositories> | ||
| 309 | + <repository> | ||
| 310 | + <id>spring-snapshots</id> | ||
| 311 | + <url>http://repo.spring.io/snapshot</url> | ||
| 312 | + <snapshots> | ||
| 313 | + <enabled>true</enabled> | ||
| 314 | + </snapshots> | ||
| 315 | + </repository> | ||
| 316 | + <repository> | ||
| 317 | + <id>spring-milestones</id> | ||
| 318 | + <url>http://repo.spring.io/milestone</url> | ||
| 319 | + </repository> | ||
| 320 | + </repositories> | ||
| 321 | + <pluginRepositories> | ||
| 322 | + <pluginRepository> | ||
| 323 | + <id>spring-snapshots</id> | ||
| 324 | + <url>http://repo.spring.io/snapshot</url> | ||
| 325 | + </pluginRepository> | ||
| 326 | + <pluginRepository> | ||
| 327 | + <id>spring-milestones</id> | ||
| 328 | + <url>http://repo.spring.io/milestone</url> | ||
| 329 | + </pluginRepository> | ||
| 330 | + </pluginRepositories> | ||
| 331 | + | ||
| 332 | + <properties> | ||
| 333 | + <start-class>com.bsth.Application</start-class> | ||
| 334 | + </properties> | ||
| 335 | +</project> |
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 org.springframework.boot.SpringApplication; | ||
| 4 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| 5 | +import org.springframework.boot.web.support.SpringBootServletInitializer; | ||
| 6 | + | ||
| 7 | +import java.util.concurrent.Executors; | ||
| 8 | +import java.util.concurrent.ScheduledExecutorService; | ||
| 9 | + | ||
| 10 | +@SpringBootApplication | ||
| 11 | +public class Application extends SpringBootServletInitializer { | ||
| 12 | + | ||
| 13 | + public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(4); | ||
| 14 | + | ||
| 15 | + public static void main(String[] args) throws Exception { | ||
| 16 | + SpringApplication.run(Application.class, args); | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | +} | ||
| 0 | \ No newline at end of file | 20 | \ No newline at end of file |
src/main/java/com/bsth/StartCommand.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/StartCommand.java | ||
| 1 | +package com.bsth; | ||
| 2 | + | ||
| 3 | + | ||
| 4 | +import com.bsth.data.msg_queue.SignalAndAttConsumeQueue; | ||
| 5 | +import com.bsth.data.real_park.BerthDataBuffer; | ||
| 6 | +import com.bsth.data.real_park.CarParkRealHandler; | ||
| 7 | +import com.bsth.data.real_park.thread.RealParkDataPersistenceThread; | ||
| 8 | +import com.bsth.data.signal.thread.SignalPstThread; | ||
| 9 | +import com.bsth.security.SecurityMetadataSourceService; | ||
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 11 | +import org.springframework.boot.CommandLineRunner; | ||
| 12 | +import org.springframework.stereotype.Component; | ||
| 13 | + | ||
| 14 | +import java.util.concurrent.ScheduledExecutorService; | ||
| 15 | +import java.util.concurrent.TimeUnit; | ||
| 16 | + | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * 随应用启动运行 | ||
| 20 | + * @author PanZhao | ||
| 21 | + * | ||
| 22 | + */ | ||
| 23 | +@Component | ||
| 24 | +public class StartCommand implements CommandLineRunner{ | ||
| 25 | + | ||
| 26 | + @Autowired | ||
| 27 | + SecurityMetadataSourceService invocationSecurityMetadataSourceService; | ||
| 28 | + @Autowired | ||
| 29 | + SignalPstThread signalPstThread; | ||
| 30 | + @Autowired | ||
| 31 | + BerthDataBuffer.BerthCacheRefreshThread berthCacheRefreshThread; | ||
| 32 | + @Autowired | ||
| 33 | + RealParkDataPersistenceThread realParkDataPersistenceThread; | ||
| 34 | + | ||
| 35 | + @Autowired | ||
| 36 | + CarParkRealHandler carParkRealHandler; | ||
| 37 | + | ||
| 38 | + @Override | ||
| 39 | + public void run(String... arg0){ | ||
| 40 | + | ||
| 41 | + try { | ||
| 42 | + //启动时加载所有资源 | ||
| 43 | + invocationSecurityMetadataSourceService.loadResourceDefine(); | ||
| 44 | + | ||
| 45 | + //signal、牌照识别、查询一体机数据消费队列 | ||
| 46 | + SignalAndAttConsumeQueue.start(); | ||
| 47 | + | ||
| 48 | + ScheduledExecutorService sexec = Application.mainServices; | ||
| 49 | + //进出场数据入库线程 | ||
| 50 | + sexec.scheduleWithFixedDelay(signalPstThread, 30, 10, TimeUnit.SECONDS); | ||
| 51 | + | ||
| 52 | + //泊位缓存刷新 | ||
| 53 | + sexec.scheduleWithFixedDelay(berthCacheRefreshThread, 0, 60 * 2, TimeUnit.SECONDS); | ||
| 54 | + | ||
| 55 | + //从数据库恢复场内实时停放数据 | ||
| 56 | + carParkRealHandler.recovery(); | ||
| 57 | + //实时场内停放数据入库 | ||
| 58 | + sexec.scheduleWithFixedDelay(realParkDataPersistenceThread, 40, 30, TimeUnit.SECONDS); | ||
| 59 | + } catch (Exception e) { | ||
| 60 | + e.printStackTrace(); | ||
| 61 | + } | ||
| 62 | + } | ||
| 63 | +} |
src/main/java/com/bsth/WebAppConfiguration.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/WebAppConfiguration.java | ||
| 1 | +package com.bsth; | ||
| 2 | + | ||
| 3 | +import org.slf4j.Logger; | ||
| 4 | +import org.slf4j.LoggerFactory; | ||
| 5 | +import org.springframework.context.annotation.Bean; | ||
| 6 | +import org.springframework.context.annotation.ComponentScan; | ||
| 7 | +import org.springframework.context.annotation.Configuration; | ||
| 8 | +import org.springframework.web.filter.CharacterEncodingFilter; | ||
| 9 | +import org.springframework.web.filter.HttpPutFormContentFilter; | ||
| 10 | +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
| 11 | +import org.springframework.web.socket.config.annotation.EnableWebSocket; | ||
| 12 | +import org.springframework.web.socket.config.annotation.WebSocketConfigurer; | ||
| 13 | +import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; | ||
| 14 | +import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean; | ||
| 15 | + | ||
| 16 | +import javax.servlet.Filter; | ||
| 17 | + | ||
| 18 | +@Configuration | ||
| 19 | +@EnableWebSocket | ||
| 20 | +@ComponentScan | ||
| 21 | +public class WebAppConfiguration extends WebMvcConfigurerAdapter implements WebSocketConfigurer{ | ||
| 22 | + | ||
| 23 | +// @Autowired | ||
| 24 | +// HttpOpLogInterceptor httpOpLogInterceptor; | ||
| 25 | + | ||
| 26 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * @Title: httpPutFormContentFilter | ||
| 30 | + * @Description: TODO(弥补浏览器不支持PUT/DELETE,对携带 _method 参数的请求进行转换) | ||
| 31 | + */ | ||
| 32 | + @Bean | ||
| 33 | + public Filter httpPutFormContentFilter() { | ||
| 34 | + return new HttpPutFormContentFilter(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * @Title: characterEncodingFilter | ||
| 39 | + * @Description: TODO(编码过滤器) | ||
| 40 | + */ | ||
| 41 | + @Bean | ||
| 42 | + public Filter characterEncodingFilter(){ | ||
| 43 | + return new CharacterEncodingFilter("UTF-8"); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + | ||
| 47 | + @Override | ||
| 48 | + public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { | ||
| 49 | + //线调webSocket | ||
| 50 | + //registry.addHandler(new RealControlSocketHandler(), "/sockjs/").addInterceptors(new WebSocketHandshakeInterceptor()) | ||
| 51 | + // .withSockJS(); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 增加websocket的输出缓冲区 | ||
| 56 | + * @return | ||
| 57 | + */ | ||
| 58 | + @Bean | ||
| 59 | + public ServletServerContainerFactoryBean createServletServerContainerFactoryBean() { | ||
| 60 | + ServletServerContainerFactoryBean container = new ServletServerContainerFactoryBean(); | ||
| 61 | + container.setMaxTextMessageBufferSize(52768); | ||
| 62 | + container.setMaxBinaryMessageBufferSize(52768); | ||
| 63 | + logger.info("Websocket factory returned"); | ||
| 64 | + return container; | ||
| 65 | + } | ||
| 66 | +} |
src/main/java/com/bsth/common/Constants.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/common/Constants.java | ||
| 1 | +package com.bsth.common; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * | ||
| 5 | + * @ClassName: Constants | ||
| 6 | + * @Description: TODO(常量类) | ||
| 7 | + * @author PanZhao | ||
| 8 | + * @date 2016年3月18日 下午11:06:53 | ||
| 9 | + * | ||
| 10 | + */ | ||
| 11 | +public class Constants { | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 不需要拦截的资源 | ||
| 15 | + */ | ||
| 16 | + public static final String LOGIN = "/user/login/**"; | ||
| 17 | + public static final String LOGIN_PAGE = "/login.html"; | ||
| 18 | + public static final String ASSETS_URL = "/assets/**"; | ||
| 19 | + public static final String FAVICON_URL = "/favicon.ico"; | ||
| 20 | + public static final String LOGIN_FAILURE = "/user/loginFailure"; | ||
| 21 | + public static final String CAPTCHA = "/captcha.jpg"; | ||
| 22 | + | ||
| 23 | + public static final String SESSION_USERNAME = "sessionUserName"; | ||
| 24 | + public static final String COMPANY_AUTHORITYS = "cmyAuths"; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 对外的上行输入接口 | ||
| 28 | + */ | ||
| 29 | + public static final String UPSTREAM_URL = "/bus_park_dispatch/**"; | ||
| 30 | +} |
src/main/java/com/bsth/common/RemotePostDataException.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/common/RemotePostDataException.java | ||
| 1 | +package com.bsth.common; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by panzhao on 2017/8/18. | ||
| 5 | + */ | ||
| 6 | +public class RemotePostDataException extends Exception{ | ||
| 7 | + | ||
| 8 | + private static final long serialVersionUID = 1L; | ||
| 9 | + | ||
| 10 | + public RemotePostDataException(String url) { | ||
| 11 | + super("向远端接口:" + url + " 提交数据出现异常!!"); | ||
| 12 | + } | ||
| 13 | +} |
src/main/java/com/bsth/common/ResponseCode.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/common/ResponseCode.java | ||
| 1 | +package com.bsth.common; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * | ||
| 5 | + * @ClassName: ResponseCode | ||
| 6 | + * @Description: TODO(响应状态码) | ||
| 7 | + * @author PanZhao | ||
| 8 | + * @date 2016年3月18日 下午11:12:08 | ||
| 9 | + * | ||
| 10 | + */ | ||
| 11 | +public enum ResponseCode { | ||
| 12 | + | ||
| 13 | + SUCCESS("操作成功", 200), | ||
| 14 | + NO_PERMISSION("无资源访问权限", 403), | ||
| 15 | + NO_AUTHENTICATION("客户端未授权", 407), | ||
| 16 | + ERROR("服务器异常", 500); | ||
| 17 | + | ||
| 18 | + private String text; | ||
| 19 | + private int code; | ||
| 20 | + | ||
| 21 | + ResponseCode(String text, int code) { | ||
| 22 | + this.text = text; | ||
| 23 | + this.code = code; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @Override | ||
| 27 | + public String toString() { | ||
| 28 | + return this.code + ""; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public String getText() { | ||
| 32 | + return this.text; | ||
| 33 | + } | ||
| 34 | +} |
src/main/java/com/bsth/controller/BaseController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/BaseController.java | ||
| 1 | +package com.bsth.controller; | ||
| 2 | + | ||
| 3 | +import com.bsth.service.BaseService; | ||
| 4 | +import com.google.common.base.Splitter; | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.data.domain.Page; | ||
| 7 | +import org.springframework.data.domain.PageRequest; | ||
| 8 | +import org.springframework.data.domain.Sort; | ||
| 9 | +import org.springframework.data.domain.Sort.Direction; | ||
| 10 | +import org.springframework.web.bind.annotation.PathVariable; | ||
| 11 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 12 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 13 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 14 | + | ||
| 15 | +import java.io.Serializable; | ||
| 16 | +import java.util.ArrayList; | ||
| 17 | +import java.util.List; | ||
| 18 | +import java.util.Map; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * @param <T> | ||
| 22 | + * @param <ID> 主键类型 | ||
| 23 | + * @author PanZhao | ||
| 24 | + * @ClassName: BaseController | ||
| 25 | + * @Description: TODO(基础的Controller实现) | ||
| 26 | + * @date 2016年3月17日 下午12:44:06 | ||
| 27 | + */ | ||
| 28 | +public class BaseController<T, ID extends Serializable> { | ||
| 29 | + | ||
| 30 | + @Autowired | ||
| 31 | + protected BaseService<T, ID> baseService; | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * @param @param map 查询条件 | ||
| 35 | + * @param @param page 页码 | ||
| 36 | + * @param @param size 每页显示数量 | ||
| 37 | + * @throws | ||
| 38 | + * @Title: list | ||
| 39 | + * @Description: TODO(多条件分页查询) | ||
| 40 | + */ | ||
| 41 | + @RequestMapping(method = RequestMethod.GET) | ||
| 42 | + public Page<T> list(@RequestParam Map<String, Object> map, | ||
| 43 | + @RequestParam(defaultValue = "0") int page, | ||
| 44 | + @RequestParam(defaultValue = "10") int size, | ||
| 45 | + @RequestParam(defaultValue = "id") String order, | ||
| 46 | + @RequestParam(defaultValue = "DESC") String direction) { | ||
| 47 | + | ||
| 48 | + // 允许多个字段排序,order可以写单个字段,也可以写多个字段 | ||
| 49 | + // 多个字段格式:{col1},{col2},{col3},....,{coln} | ||
| 50 | + List<String> order_columns = Splitter.on(",").trimResults().splitToList(order); | ||
| 51 | + // 多字段排序:DESC,ASC... | ||
| 52 | + List<String> order_dirs = Splitter.on(",").trimResults().splitToList(direction); | ||
| 53 | + | ||
| 54 | + if (order_dirs.size() == 1) { // 所有字段采用一种排序 | ||
| 55 | + if (null != order_dirs.get(0) && order_dirs.get(0).equals("ASC")) { | ||
| 56 | + return baseService.list(map, new PageRequest(page, size, new Sort(Direction.ASC, order_columns))); | ||
| 57 | + } else { | ||
| 58 | + return baseService.list(map, new PageRequest(page, size, new Sort(Direction.DESC, order_columns))); | ||
| 59 | + } | ||
| 60 | + } else if (order_columns.size() == order_dirs.size()) { | ||
| 61 | + List<Sort.Order> orderList = new ArrayList<>(); | ||
| 62 | + for (int i = 0; i < order_columns.size(); i++) { | ||
| 63 | + if (null != order_dirs.get(i) && order_dirs.get(i).equals("ASC")) { | ||
| 64 | + orderList.add(new Sort.Order(Direction.ASC, order_columns.get(i))); | ||
| 65 | + } else { | ||
| 66 | + orderList.add(new Sort.Order(Direction.DESC, order_columns.get(i))); | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + return baseService.list(map, new PageRequest(page, size, new Sort(orderList))); | ||
| 70 | + } else { | ||
| 71 | + throw new RuntimeException("多字段排序参数格式问题,排序顺序和字段数不一致"); | ||
| 72 | + } | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * @param @param map | ||
| 77 | + * @throws | ||
| 78 | + * @Title: list | ||
| 79 | + * @Description: TODO(多条件查询) | ||
| 80 | + */ | ||
| 81 | + @RequestMapping(value = "/all", method = RequestMethod.GET) | ||
| 82 | + public Iterable<T> list(@RequestParam Map<String, Object> map) { | ||
| 83 | + return baseService.list(map); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + /** | ||
| 87 | + * @param @param t | ||
| 88 | + * @param @return 设定文件 | ||
| 89 | + * @return Map<String,Object> {status: 1(成功),-1(失败)} | ||
| 90 | + * @throws | ||
| 91 | + * @Title: save | ||
| 92 | + * @Description: TODO(持久化对象) | ||
| 93 | + */ | ||
| 94 | + @RequestMapping(method = RequestMethod.POST) | ||
| 95 | + public Map<String, Object> save(T t) { | ||
| 96 | + return baseService.save(t); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + /** | ||
| 100 | + * @param @param id | ||
| 101 | + * @throws | ||
| 102 | + * @Title: findById | ||
| 103 | + * @Description: TODO(根据主键获取单个对象) | ||
| 104 | + */ | ||
| 105 | + @RequestMapping(value = "/{id}", method = RequestMethod.GET) | ||
| 106 | + public T findById(@PathVariable("id") ID id) { | ||
| 107 | + return baseService.findById(id); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + /** | ||
| 111 | + * @param @param id | ||
| 112 | + * @throws | ||
| 113 | + * @Title: delete | ||
| 114 | + * @Description: TODO(根据主键删除对象) | ||
| 115 | + */ | ||
| 116 | + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) | ||
| 117 | + public Map<String, Object> delete(@PathVariable("id") ID id) { | ||
| 118 | + return baseService.delete(id); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | +} |
src/main/java/com/bsth/controller/UpstreamEntrance.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/UpstreamEntrance.java | ||
| 1 | +package com.bsth.controller; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.attendance.AttendaceDataBuffer; | ||
| 4 | +import com.bsth.data.attendance.dto.RemoteAttendaceDTO; | ||
| 5 | +import com.bsth.data.electric.CarElectricBuffer; | ||
| 6 | +import com.bsth.data.signal.RFIDInParkDataBuffer; | ||
| 7 | +import com.bsth.data.signal.dto.RfidInOutDto; | ||
| 8 | +import com.bsth.entity.electric.BusElectric; | ||
| 9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 10 | +import org.springframework.web.bind.annotation.*; | ||
| 11 | + | ||
| 12 | +import java.util.List; | ||
| 13 | + | ||
| 14 | +/** | ||
| 15 | + * 对外的输入接口 | ||
| 16 | + * Created by panzhao on 2017/9/4. | ||
| 17 | + */ | ||
| 18 | +@RestController | ||
| 19 | +@RequestMapping("bus_park_dispatch") | ||
| 20 | +public class UpstreamEntrance { | ||
| 21 | + | ||
| 22 | + @Autowired | ||
| 23 | + CarElectricBuffer carElectricBuffer; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 查询一体机实时签到 | ||
| 27 | + * @param attendace | ||
| 28 | + */ | ||
| 29 | + @RequestMapping("attendace") | ||
| 30 | + public void attendace(RemoteAttendaceDTO attendace){ | ||
| 31 | + AttendaceDataBuffer.put(attendace); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * RFID 进出场 | ||
| 36 | + * @param rfidInOut | ||
| 37 | + */ | ||
| 38 | + @RequestMapping("inout_rfid") | ||
| 39 | + public void inOut_rfid(RfidInOutDto rfidInOut){ | ||
| 40 | + RFIDInParkDataBuffer.put(rfidInOut); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 雷博电量数据接入 | ||
| 45 | + * @param list | ||
| 46 | + */ | ||
| 47 | + @RequestMapping(value = "electric", method = RequestMethod.POST) | ||
| 48 | + @ResponseBody | ||
| 49 | + public void electric(@RequestBody List<BusElectric> list){ | ||
| 50 | + carElectricBuffer.putAll(list); | ||
| 51 | + } | ||
| 52 | +} |
src/main/java/com/bsth/controller/ac/CarInOutController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/ac/CarInOutController.java | ||
| 1 | +package com.bsth.controller.ac; | ||
| 2 | + | ||
| 3 | +import com.bsth.controller.BaseController; | ||
| 4 | +import com.bsth.entity.ac.CarInOutEntity; | ||
| 5 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 6 | +import org.springframework.web.bind.annotation.RestController; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Created by panzhao on 2017/9/13. | ||
| 10 | + */ | ||
| 11 | +@RestController | ||
| 12 | +@RequestMapping("car_in_out") | ||
| 13 | +public class CarInOutController extends BaseController<CarInOutEntity, Long> { | ||
| 14 | + | ||
| 15 | + | ||
| 16 | +} |
src/main/java/com/bsth/controller/attendace/AttendaceController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/attendace/AttendaceController.java | ||
| 1 | +package com.bsth.controller.attendace; | ||
| 2 | + | ||
| 3 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 4 | +import org.springframework.web.bind.annotation.RestController; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * Created by panzhao on 2017/9/4. | ||
| 8 | + */ | ||
| 9 | +@RestController | ||
| 10 | +@RequestMapping("attendace") | ||
| 11 | +public class AttendaceController { | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +} |
src/main/java/com/bsth/controller/basic/BusCardController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/basic/BusCardController.java | ||
| 1 | +package com.bsth.controller.basic; | ||
| 2 | + | ||
| 3 | +import com.bsth.controller.BaseController; | ||
| 4 | +import com.bsth.entity.BusCard; | ||
| 5 | +import com.bsth.service.basic.BusCardService; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 8 | +import org.springframework.web.bind.annotation.RestController; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Created by panzhao on 2017/8/21. | ||
| 12 | + */ | ||
| 13 | +@RestController | ||
| 14 | +@RequestMapping("bus_card") | ||
| 15 | +public class BusCardController extends BaseController<BusCard, String>{ | ||
| 16 | + | ||
| 17 | + @Autowired | ||
| 18 | + BusCardService busCardService; | ||
| 19 | + | ||
| 20 | + @RequestMapping("refresh") | ||
| 21 | + public void refresh(){ | ||
| 22 | + busCardService.refresh(); | ||
| 23 | + } | ||
| 24 | +} |
src/main/java/com/bsth/controller/basic/BusController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/basic/BusController.java | ||
| 1 | +package com.bsth.controller.basic; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.electric.CarElectricBuffer; | ||
| 4 | +import com.bsth.entity.Bus; | ||
| 5 | +import com.bsth.entity.electric.BusElectric; | ||
| 6 | +import com.bsth.service.basic.BusService; | ||
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | +import org.springframework.web.bind.annotation.*; | ||
| 9 | + | ||
| 10 | +import java.util.Collection; | ||
| 11 | +import java.util.Map; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Created by panzhao on 2017/8/15. | ||
| 15 | + */ | ||
| 16 | +@RestController | ||
| 17 | +@RequestMapping("bus") | ||
| 18 | +public class BusController { | ||
| 19 | + | ||
| 20 | + @Autowired | ||
| 21 | + BusService busService; | ||
| 22 | + | ||
| 23 | + @RequestMapping("list") | ||
| 24 | + public Map<String, Object> list(@RequestParam Map<String, Object> map, | ||
| 25 | + @RequestParam(defaultValue = "0") int page, | ||
| 26 | + @RequestParam(defaultValue = "10") int size){ | ||
| 27 | + | ||
| 28 | + return busService.list(map, page, size); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + @RequestMapping("{nbbm}") | ||
| 32 | + public Map<String, Object> findOne(@PathVariable("nbbm") String nbbm){ | ||
| 33 | + return busService.findOne(nbbm); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + @RequestMapping("parseFile") | ||
| 37 | + public Map<String, Object> parseFile(@RequestParam String base64,@RequestParam String fileName){ | ||
| 38 | + return busService.parseFile(base64, fileName); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + /** | ||
| 42 | + * 人卡数据批量save | ||
| 43 | + * @param jsonStr | ||
| 44 | + * @return | ||
| 45 | + */ | ||
| 46 | + @RequestMapping(value = "multiSave" ,method = RequestMethod.POST) | ||
| 47 | + public Map<String, Object> multiSave(@RequestParam String jsonStr){ | ||
| 48 | + return busService.multiSave(jsonStr); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 刷新车卡数据 | ||
| 53 | + */ | ||
| 54 | + @RequestMapping(value = "refresh", method = RequestMethod.POST) | ||
| 55 | + public void refresh(){ | ||
| 56 | + busService.refresh(); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + @RequestMapping(value = "save" ,method = RequestMethod.POST) | ||
| 60 | + public Map<String, Object> save(Bus b){ | ||
| 61 | + return busService.save(b); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + @RequestMapping("real_elec_info") | ||
| 65 | + public Collection<BusElectric> realElecInfo(){ | ||
| 66 | + return CarElectricBuffer.all(); | ||
| 67 | + } | ||
| 68 | +} |
src/main/java/com/bsth/controller/basic/CarController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/basic/CarController.java | ||
| 1 | +package com.bsth.controller.basic; | ||
| 2 | + | ||
| 3 | +import com.bsth.controller.BaseController; | ||
| 4 | +import com.bsth.entity.Car; | ||
| 5 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 6 | +import org.springframework.web.bind.annotation.RestController; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Created by panzhao on 2017/8/21. | ||
| 10 | + */ | ||
| 11 | +@RestController | ||
| 12 | +@RequestMapping("car") | ||
| 13 | +public class CarController extends BaseController<Car, Integer>{ | ||
| 14 | +} |
src/main/java/com/bsth/controller/basic/CompanyController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/basic/CompanyController.java | ||
| 1 | +package com.bsth.controller.basic; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSONObject; | ||
| 4 | +import com.bsth.util.ConfigUtil; | ||
| 5 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 6 | +import org.springframework.web.bind.annotation.RestController; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Created by panzhao on 2017/8/2. | ||
| 10 | + */ | ||
| 11 | +@RestController | ||
| 12 | +@RequestMapping("company_json") | ||
| 13 | +public class CompanyController { | ||
| 14 | + | ||
| 15 | + static String jsonStr; | ||
| 16 | + | ||
| 17 | + static{ | ||
| 18 | + JSONObject json = JSONObject.parseObject(ConfigUtil.get("data.company.json")); | ||
| 19 | + JSONObject authJson = new JSONObject(); | ||
| 20 | + String[] codes = ConfigUtil.get("tcc.company.id").split(","); | ||
| 21 | + for(int i = 0; i < codes.length; i ++){ | ||
| 22 | + authJson.put(codes[i], json.get(codes[i])); | ||
| 23 | + } | ||
| 24 | + jsonStr = authJson.toJSONString(); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + @RequestMapping | ||
| 28 | + public String get(){ | ||
| 29 | + return jsonStr; | ||
| 30 | + } | ||
| 31 | +} |
src/main/java/com/bsth/controller/basic/LineController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/basic/LineController.java | ||
| 1 | +package com.bsth.controller.basic; | ||
| 2 | + | ||
| 3 | +import com.bsth.service.basic.LineService; | ||
| 4 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 5 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 6 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 7 | +import org.springframework.web.bind.annotation.RestController; | ||
| 8 | + | ||
| 9 | +import java.util.Map; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * Created by panzhao on 2017/8/1. | ||
| 13 | + */ | ||
| 14 | +@RestController | ||
| 15 | +@RequestMapping("line") | ||
| 16 | +public class LineController { | ||
| 17 | + | ||
| 18 | + @Autowired | ||
| 19 | + LineService lineService; | ||
| 20 | + | ||
| 21 | + @RequestMapping("list") | ||
| 22 | + public Map<String, Object> list(@RequestParam Map<String, Object> map, | ||
| 23 | + @RequestParam(defaultValue = "0") int page, | ||
| 24 | + @RequestParam(defaultValue = "10") int size){ | ||
| 25 | + | ||
| 26 | + return lineService.list(map, page, size); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + @RequestMapping("all") | ||
| 30 | + public Map<String, Object> all(){ | ||
| 31 | + return lineService.all(); | ||
| 32 | + } | ||
| 33 | +} |
src/main/java/com/bsth/controller/basic/PersonController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/basic/PersonController.java | ||
| 1 | +package com.bsth.controller.basic; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.Person; | ||
| 4 | +import com.bsth.service.basic.PersonService; | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.web.bind.annotation.*; | ||
| 7 | + | ||
| 8 | +import java.util.Map; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Created by panzhao on 2017/8/1. | ||
| 12 | + */ | ||
| 13 | +@RestController | ||
| 14 | +@RequestMapping("person") | ||
| 15 | +public class PersonController { | ||
| 16 | + | ||
| 17 | + @Autowired | ||
| 18 | + PersonService personService; | ||
| 19 | + | ||
| 20 | + @RequestMapping("list") | ||
| 21 | + public Map<String, Object> list(@RequestParam Map<String, Object> map, | ||
| 22 | + @RequestParam(defaultValue = "0") int page, | ||
| 23 | + @RequestParam(defaultValue = "10") int size){ | ||
| 24 | + | ||
| 25 | + return personService.list(map, page, size); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + @RequestMapping("{jobCode}") | ||
| 29 | + public Map<String, Object> findOne(@PathVariable("jobCode") String jobCode){ | ||
| 30 | + return personService.findOne(jobCode); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @RequestMapping("parseFile") | ||
| 34 | + public Map<String, Object> parseFile(@RequestParam String base64,@RequestParam String fileName){ | ||
| 35 | + return personService.parseFile(base64, fileName); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 人卡数据批量save | ||
| 40 | + * @param jsonStr | ||
| 41 | + * @return | ||
| 42 | + */ | ||
| 43 | + @RequestMapping(value = "multiSave" ,method = RequestMethod.POST) | ||
| 44 | + public Map<String, Object> multiSave(@RequestParam String jsonStr){ | ||
| 45 | + return personService.multiSave(jsonStr); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @RequestMapping(value = "save" ,method = RequestMethod.POST) | ||
| 49 | + public Map<String, Object> save(Person p){ | ||
| 50 | + return personService.save(p); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * 刷新人员数据 | ||
| 55 | + */ | ||
| 56 | + @RequestMapping(value = "refresh", method = RequestMethod.POST) | ||
| 57 | + public void refresh(){ | ||
| 58 | + personService.refresh(); | ||
| 59 | + } | ||
| 60 | +} |
src/main/java/com/bsth/controller/berth/BerthController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/berth/BerthController.java | ||
| 1 | +package com.bsth.controller.berth; | ||
| 2 | + | ||
| 3 | +import com.bsth.controller.BaseController; | ||
| 4 | +import com.bsth.entity.berth.RegionBerth; | ||
| 5 | +import com.bsth.service.berth.BerthService; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 8 | +import org.springframework.web.bind.annotation.RestController; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * Created by panzhao on 2017/8/22. | ||
| 12 | + */ | ||
| 13 | +@RestController | ||
| 14 | +@RequestMapping("/berth") | ||
| 15 | +public class BerthController extends BaseController<RegionBerth, Integer> { | ||
| 16 | + | ||
| 17 | + @Autowired | ||
| 18 | + BerthService berthService; | ||
| 19 | + | ||
| 20 | +/* @RequestMapping(value = "real_change", method = RequestMethod.POST) | ||
| 21 | + public Map<String, Object> realChange(@RequestParam String s,@RequestParam String d){ | ||
| 22 | + return null;//berthService.realChange(s, d); | ||
| 23 | + }*/ | ||
| 24 | + | ||
| 25 | + @RequestMapping("max_order_no") | ||
| 26 | + public String maxOrderNo() { | ||
| 27 | + String rs = berthService.maxOrderNo(); | ||
| 28 | + return rs==null?"0":rs; | ||
| 29 | + } | ||
| 30 | +} |
src/main/java/com/bsth/controller/berth/RegionController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/berth/RegionController.java | ||
| 1 | +package com.bsth.controller.berth; | ||
| 2 | + | ||
| 3 | +import com.bsth.controller.BaseController; | ||
| 4 | +import com.bsth.entity.berth.Region; | ||
| 5 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 6 | +import org.springframework.web.bind.annotation.RestController; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Created by panzhao on 2017/8/22. | ||
| 10 | + */ | ||
| 11 | +@RestController | ||
| 12 | +@RequestMapping("/region") | ||
| 13 | +public class RegionController extends BaseController<Region, Integer>{ | ||
| 14 | +} |
src/main/java/com/bsth/controller/real/CarParkRealController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/real/CarParkRealController.java | ||
| 1 | +package com.bsth.controller.real; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.real_park.CarParkRealHandler; | ||
| 4 | +import com.bsth.entity.real.RealCarPark; | ||
| 5 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 6 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 8 | +import org.springframework.web.bind.annotation.RestController; | ||
| 9 | + | ||
| 10 | +import java.util.Collection; | ||
| 11 | +import java.util.Map; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Created by panzhao on 2017/9/14. | ||
| 15 | + */ | ||
| 16 | +@RestController | ||
| 17 | +@RequestMapping("car_park_real") | ||
| 18 | +public class CarParkRealController { | ||
| 19 | + | ||
| 20 | + | ||
| 21 | + @RequestMapping("bus") | ||
| 22 | + public Collection<RealCarPark> busAll(){ | ||
| 23 | + return CarParkRealHandler.allBus(); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + @RequestMapping(value = "real_change", method = RequestMethod.POST) | ||
| 27 | + public Map<String, Object> realChange(@RequestParam String s, @RequestParam String d){ | ||
| 28 | + return CarParkRealHandler.realChange(s, d); | ||
| 29 | + } | ||
| 30 | +} |
src/main/java/com/bsth/controller/schedule/InOutScheduleController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/schedule/InOutScheduleController.java | ||
| 1 | +package com.bsth.controller.schedule; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.schedule.dto.ScheduleInOut; | ||
| 4 | +import com.bsth.service.schedule.InOutScheduleService; | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 7 | +import org.springframework.web.bind.annotation.RestController; | ||
| 8 | + | ||
| 9 | +import java.util.Collection; | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * Created by panzhao on 2017/9/4. | ||
| 14 | + */ | ||
| 15 | +@RestController | ||
| 16 | +@RequestMapping("in_out") | ||
| 17 | +public class InOutScheduleController { | ||
| 18 | + | ||
| 19 | + @Autowired | ||
| 20 | + InOutScheduleService inOutScheduleService; | ||
| 21 | + | ||
| 22 | + @RequestMapping("all") | ||
| 23 | + public Collection<ScheduleInOut> all(){ | ||
| 24 | + return inOutScheduleService.findAll(); | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + @RequestMapping("all_out") | ||
| 28 | + public List<ScheduleInOut> all_out(){ | ||
| 29 | + return inOutScheduleService.all_out(); | ||
| 30 | + } | ||
| 31 | +} |
src/main/java/com/bsth/controller/sys/CompanyAuthorityController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/sys/CompanyAuthorityController.java | ||
| 1 | +package com.bsth.controller.sys; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSONArray; | ||
| 4 | +import com.bsth.controller.BaseController; | ||
| 5 | +import com.bsth.entity.sys.CompanyAuthority; | ||
| 6 | +import com.bsth.service.sys.CompanyAuthorityService; | ||
| 7 | +import org.apache.commons.lang3.StringEscapeUtils; | ||
| 8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 9 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 10 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 11 | +import org.springframework.web.bind.annotation.RestController; | ||
| 12 | + | ||
| 13 | +import java.util.List; | ||
| 14 | +import java.util.Map; | ||
| 15 | + | ||
| 16 | +/** | ||
| 17 | + * Created by panzhao on 2016/11/22. | ||
| 18 | + */ | ||
| 19 | +@RestController | ||
| 20 | +@RequestMapping("companyAuthority") | ||
| 21 | +public class CompanyAuthorityController extends BaseController<CompanyAuthority, Integer>{ | ||
| 22 | + | ||
| 23 | + @Autowired | ||
| 24 | + CompanyAuthorityService companyAuthorityService; | ||
| 25 | + | ||
| 26 | + @RequestMapping(value = "save") | ||
| 27 | + public Map<String, Object> save(@RequestParam Integer roleId, @RequestParam String authJsonStr){ | ||
| 28 | + authJsonStr = StringEscapeUtils.unescapeHtml4(authJsonStr); | ||
| 29 | + System.out.println(authJsonStr); | ||
| 30 | + List<CompanyAuthority> list = JSONArray.parseArray(authJsonStr, CompanyAuthority.class); | ||
| 31 | + return companyAuthorityService.save(roleId, list); | ||
| 32 | + } | ||
| 33 | +} |
src/main/java/com/bsth/controller/sys/DictionaryController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/sys/DictionaryController.java | ||
| 1 | +package com.bsth.controller.sys; | ||
| 2 | + | ||
| 3 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 4 | +import org.springframework.web.bind.annotation.RestController; | ||
| 5 | + | ||
| 6 | +import com.bsth.controller.BaseController; | ||
| 7 | +import com.bsth.entity.sys.Dictionary; | ||
| 8 | + | ||
| 9 | +@RestController | ||
| 10 | +@RequestMapping("dictionary") | ||
| 11 | +public class DictionaryController extends BaseController<Dictionary, Integer>{ | ||
| 12 | + | ||
| 13 | +} |
src/main/java/com/bsth/controller/sys/KaptchaController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/sys/KaptchaController.java | ||
| 1 | +package com.bsth.controller.sys; | ||
| 2 | + | ||
| 3 | +import java.io.IOException; | ||
| 4 | + | ||
| 5 | +import javax.servlet.ServletException; | ||
| 6 | +import javax.servlet.http.HttpServletRequest; | ||
| 7 | +import javax.servlet.http.HttpServletResponse; | ||
| 8 | + | ||
| 9 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 10 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 11 | +import org.springframework.web.bind.annotation.RestController; | ||
| 12 | + | ||
| 13 | +import com.google.code.kaptcha.servlet.KaptchaExtend; | ||
| 14 | + | ||
| 15 | +@RestController | ||
| 16 | +public class KaptchaController extends KaptchaExtend{ | ||
| 17 | + | ||
| 18 | + @RequestMapping(value = "/captcha.jpg", method = RequestMethod.GET) | ||
| 19 | + public void captcha(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { | ||
| 20 | + super.captcha(req, resp); | ||
| 21 | + } | ||
| 22 | +} |
src/main/java/com/bsth/controller/sys/ModuleController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/sys/ModuleController.java | ||
| 1 | +package com.bsth.controller.sys; | ||
| 2 | + | ||
| 3 | +import com.bsth.controller.BaseController; | ||
| 4 | +import com.bsth.entity.sys.Module; | ||
| 5 | +import com.bsth.service.sys.ModuleService; | ||
| 6 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 8 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 9 | +import org.springframework.web.bind.annotation.RestController; | ||
| 10 | + | ||
| 11 | +import java.util.List; | ||
| 12 | + | ||
| 13 | +@RestController | ||
| 14 | +@RequestMapping("module") | ||
| 15 | +public class ModuleController extends BaseController<Module, Integer>{ | ||
| 16 | + | ||
| 17 | + @Autowired | ||
| 18 | + ModuleService moduleService; | ||
| 19 | + | ||
| 20 | + @RequestMapping(value = "/findByGroupType") | ||
| 21 | + public List<Module> findByGroupType(@RequestParam String group){ | ||
| 22 | + return moduleService.findByGroupType(group); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * | ||
| 27 | + * @Title: findByRoleId | ||
| 28 | + * @Description: TODO(根据角色获取功能模块) | ||
| 29 | + * @param @param roleId | ||
| 30 | + * @throws | ||
| 31 | + */ | ||
| 32 | + @RequestMapping(value = "/findByCurrentUser") | ||
| 33 | + public List<Module> findByCurrentUser(){ | ||
| 34 | + return moduleService.findByCurrentUser(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @RequestMapping(value = "/all_distinct") | ||
| 38 | + public List<Module> findAll_distinct(){ | ||
| 39 | + return moduleService.findAll_distinct(); | ||
| 40 | + } | ||
| 41 | +} |
src/main/java/com/bsth/controller/sys/ResourceController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/sys/ResourceController.java | ||
| 1 | +package com.bsth.controller.sys; | ||
| 2 | + | ||
| 3 | +import java.util.Map; | ||
| 4 | + | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 8 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 9 | +import org.springframework.web.bind.annotation.RestController; | ||
| 10 | + | ||
| 11 | +import com.alibaba.fastjson.JSON; | ||
| 12 | +import com.bsth.controller.BaseController; | ||
| 13 | +import com.bsth.entity.sys.Resource; | ||
| 14 | +import com.bsth.service.sys.ResourceService; | ||
| 15 | + | ||
| 16 | +@RestController | ||
| 17 | +@RequestMapping("resource") | ||
| 18 | +public class ResourceController extends BaseController<Resource, Integer>{ | ||
| 19 | + | ||
| 20 | + @Autowired | ||
| 21 | + ResourceService resourceService; | ||
| 22 | + | ||
| 23 | + @RequestMapping(value = "/batch", method = RequestMethod.POST) | ||
| 24 | + public Map<String, Object> save(@RequestParam String array){ | ||
| 25 | + return resourceService.saveList(JSON.parseArray(array, Resource.class)); | ||
| 26 | + } | ||
| 27 | +} |
src/main/java/com/bsth/controller/sys/RoleController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/sys/RoleController.java | ||
| 1 | +package com.bsth.controller.sys; | ||
| 2 | + | ||
| 3 | +import java.util.Map; | ||
| 4 | + | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 7 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 8 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 9 | +import org.springframework.web.bind.annotation.RestController; | ||
| 10 | + | ||
| 11 | +import com.bsth.controller.BaseController; | ||
| 12 | +import com.bsth.entity.sys.Role; | ||
| 13 | +import com.bsth.service.sys.RoleService; | ||
| 14 | + | ||
| 15 | +@RestController | ||
| 16 | +@RequestMapping("role") | ||
| 17 | +public class RoleController extends BaseController<Role, Integer>{ | ||
| 18 | + | ||
| 19 | + | ||
| 20 | + @Autowired | ||
| 21 | + RoleService roleService; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * | ||
| 25 | + * @Title: settRoleModules | ||
| 26 | + * @Description: TODO(为角色设置模块,全量覆盖) | ||
| 27 | + * @param @param roleId 角色ID | ||
| 28 | + * @param @param mIds 模块ID字符串(1,2,3,4) | ||
| 29 | + * @throws | ||
| 30 | + */ | ||
| 31 | + @RequestMapping(value = "/settModules", method = RequestMethod.POST) | ||
| 32 | + public Map<String, Object> settRoleModules(@RequestParam Integer roleId,@RequestParam String mIds){ | ||
| 33 | + return roleService.settRoleModules(roleId, mIds); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * | ||
| 38 | + * @Title: roleInfo | ||
| 39 | + * @Description: TODO(角色信息) | ||
| 40 | + * @param @param id 角色ID | ||
| 41 | + * @throws | ||
| 42 | + */ | ||
| 43 | + @RequestMapping(value = "/roleInfo") | ||
| 44 | + public Map<String, Object> roleInfo(@RequestParam Integer id){ | ||
| 45 | + return roleService.roleInfo(id); | ||
| 46 | + } | ||
| 47 | +} |
src/main/java/com/bsth/controller/sys/UserController.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/sys/UserController.java | ||
| 1 | +package com.bsth.controller.sys; | ||
| 2 | + | ||
| 3 | +import com.bsth.common.Constants; | ||
| 4 | +import com.bsth.common.ResponseCode; | ||
| 5 | +import com.bsth.controller.BaseController; | ||
| 6 | +import com.bsth.controller.sys.dto.CompanyData; | ||
| 7 | +import com.bsth.controller.sys.util.RSAUtils; | ||
| 8 | +import com.bsth.entity.sys.CompanyAuthority; | ||
| 9 | +import com.bsth.entity.sys.SysUser; | ||
| 10 | +import com.bsth.security.util.SecurityUtils; | ||
| 11 | +import com.bsth.service.sys.CompanyAuthorityService; | ||
| 12 | +import com.bsth.service.sys.SysUserService; | ||
| 13 | +import com.google.common.collect.ArrayListMultimap; | ||
| 14 | +import org.slf4j.Logger; | ||
| 15 | +import org.slf4j.LoggerFactory; | ||
| 16 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 17 | +import org.springframework.security.authentication.BadCredentialsException; | ||
| 18 | +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||
| 19 | +import org.springframework.security.web.authentication.session.SessionAuthenticationException; | ||
| 20 | +import org.springframework.web.bind.annotation.RequestMapping; | ||
| 21 | +import org.springframework.web.bind.annotation.RequestMethod; | ||
| 22 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 23 | +import org.springframework.web.bind.annotation.RestController; | ||
| 24 | + | ||
| 25 | +import javax.servlet.http.HttpServletRequest; | ||
| 26 | +import javax.servlet.http.HttpSession; | ||
| 27 | +import java.util.*; | ||
| 28 | + | ||
| 29 | +@RestController | ||
| 30 | +@RequestMapping("user") | ||
| 31 | +public class UserController extends BaseController<SysUser, Integer> { | ||
| 32 | + | ||
| 33 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 34 | + | ||
| 35 | + @Autowired | ||
| 36 | + SysUserService sysUserService; | ||
| 37 | + | ||
| 38 | + @Autowired | ||
| 39 | + CompanyAuthorityService companyAuthorityService; | ||
| 40 | + | ||
| 41 | + @RequestMapping(value = "/login/jCryptionKey") | ||
| 42 | + public Map<String, Object> jCryptionKey(HttpServletRequest request){ | ||
| 43 | + //公匙返回页面 | ||
| 44 | + Map<String, Object> rs = new HashMap<>(); | ||
| 45 | + rs.put("publickey", RSAUtils.generateBase64PublicKey()); | ||
| 46 | + return rs; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + //需要验证码的账号 | ||
| 50 | + //public static Map<String, Integer> captchaMap = new HashMap<>(); | ||
| 51 | + | ||
| 52 | + @RequestMapping(value = "/login", method = RequestMethod.POST) | ||
| 53 | + public Map<String, Object> login(HttpServletRequest request, @RequestParam String userName, | ||
| 54 | + @RequestParam String password, String captcha) { | ||
| 55 | + | ||
| 56 | + Map<String, Object> rs = new HashMap<>(); | ||
| 57 | + rs.put("status", ResponseCode.ERROR); | ||
| 58 | + try { | ||
| 59 | + HttpSession session = request.getSession(); | ||
| 60 | + rs.put("captcha", session.getAttribute("captcha")); | ||
| 61 | + | ||
| 62 | + //解密RSA | ||
| 63 | + try { | ||
| 64 | + userName = RSAUtils.decryptBase64(userName); | ||
| 65 | + password = RSAUtils.decryptBase64(password); | ||
| 66 | + } catch (RuntimeException e) { | ||
| 67 | + logger.error("", e); | ||
| 68 | + return put(rs, "msg", "decrypt RSA fail!可能页面已过期,尝试刷新页面"); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + SysUser user = sysUserService.findByUserName(userName); | ||
| 72 | + if (null == user) | ||
| 73 | + return put(rs, "msg", "不存在的用户"); | ||
| 74 | + | ||
| 75 | + if (!user.isEnabled()) | ||
| 76 | + return put(rs, "msg", "该用户已被锁定,请联系管理员"); | ||
| 77 | + | ||
| 78 | + // 校验密码 | ||
| 79 | + boolean matchStatus = new BCryptPasswordEncoder(4).matches(password, user.getPassword()); | ||
| 80 | + if (!matchStatus) { | ||
| 81 | + rs.put("msg", "密码有误"); | ||
| 82 | + return rs; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + // 登录 | ||
| 86 | + SecurityUtils.login(user, request); | ||
| 87 | + //session里写入用户名,webSocket连接时标识身份用 | ||
| 88 | + session.setAttribute(Constants.SESSION_USERNAME, user.getUserName()); | ||
| 89 | + | ||
| 90 | + //获取公司权限数据 | ||
| 91 | + List<CompanyAuthority> cmyAuths=companyAuthorityService.findByUser(user); | ||
| 92 | + session.setAttribute(Constants.COMPANY_AUTHORITYS, cmyAuths); | ||
| 93 | + | ||
| 94 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 95 | + } catch (Exception e) { | ||
| 96 | + logger.error("", e); | ||
| 97 | + rs.put("msg", "服务器出现异常,请联系管理员"); | ||
| 98 | + } | ||
| 99 | + return rs; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + /** | ||
| 103 | + * 返回当前用户的公司权限数据,用于构建页面级联下拉框 | ||
| 104 | + * @return | ||
| 105 | + */ | ||
| 106 | + @RequestMapping("companyData") | ||
| 107 | + public List<CompanyData> companyData(HttpServletRequest request){ | ||
| 108 | + List<CompanyData> rs = new ArrayList<>(); | ||
| 109 | + CompanyData companyData; | ||
| 110 | + | ||
| 111 | + ArrayListMultimap<String, CompanyAuthority> map = ArrayListMultimap.create(); | ||
| 112 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) request.getSession().getAttribute(Constants.COMPANY_AUTHORITYS); | ||
| 113 | + | ||
| 114 | + for(CompanyAuthority cAuth : cmyAuths){ | ||
| 115 | + map.put(cAuth.getCompanyCode()+"_"+cAuth.getCompanyName(), cAuth); | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + Set<String> keys = map.keySet(); | ||
| 119 | + String[] temps; | ||
| 120 | + for(String k : keys){ | ||
| 121 | + temps = k.split("_"); | ||
| 122 | + | ||
| 123 | + companyData = new CompanyData(); | ||
| 124 | + companyData.setCompanyCode(temps[0]); | ||
| 125 | + companyData.setCompanyName(temps[1]); | ||
| 126 | + companyData.setChildren(new ArrayList<CompanyData.ChildrenCompany>()); | ||
| 127 | + | ||
| 128 | + cmyAuths = map.get(k); | ||
| 129 | + for(CompanyAuthority c : cmyAuths){ | ||
| 130 | + companyData.getChildren().add(new CompanyData.ChildrenCompany(c.getSubCompanyCode(), c.getSubCompanyName())); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + rs.add(companyData); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + return rs; | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + public Map<String, Object> put(Map<String, Object> rs, String key, Object val){ | ||
| 140 | + rs.put(key, val); | ||
| 141 | + return rs; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + /** | ||
| 145 | + * | ||
| 146 | + * @Title: loginFailure @Description: TODO(查询登录失败的详细信息) @param @param | ||
| 147 | + * request @return String 返回类型 @throws | ||
| 148 | + */ | ||
| 149 | + @RequestMapping("/loginFailure") | ||
| 150 | + public String loginFailure(HttpServletRequest request) { | ||
| 151 | + String msg = ""; | ||
| 152 | + HttpSession session = request.getSession(); | ||
| 153 | + | ||
| 154 | + Object obj = session.getAttribute("SPRING_SECURITY_LAST_EXCEPTION"); | ||
| 155 | + | ||
| 156 | + if (obj instanceof BadCredentialsException) | ||
| 157 | + msg = "登录失败,用户名或密码错误."; | ||
| 158 | + else if (obj instanceof SessionAuthenticationException) | ||
| 159 | + msg = "登录失败,当前策略不允许重复登录."; | ||
| 160 | + session.removeAttribute("SPRING_SECURITY_LAST_EXCEPTION"); | ||
| 161 | + return msg; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + @RequestMapping("/currentUser") | ||
| 165 | + public SysUser currentUser() { | ||
| 166 | + return SecurityUtils.getCurrentUser(); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + /** | ||
| 170 | + * @Title changeEnabled | ||
| 171 | + * @Description: TODO(改变用户状态) | ||
| 172 | + * @param id | ||
| 173 | + * 用户ID | ||
| 174 | + * @param enabled | ||
| 175 | + * 状态 | ||
| 176 | + * @return | ||
| 177 | + */ | ||
| 178 | + @RequestMapping("/changeEnabled") | ||
| 179 | + public int changeEnabled(@RequestParam int id, @RequestParam int enabled) { | ||
| 180 | + return sysUserService.changeEnabled(id, enabled); | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + /** | ||
| 184 | + * @Title changePWD | ||
| 185 | + * @Description: TODO(修改密码) | ||
| 186 | + * @param oldPWD | ||
| 187 | + * 原始密码 | ||
| 188 | + * @param newPWD | ||
| 189 | + * 新密码 | ||
| 190 | + * @param cnewPWD | ||
| 191 | + * 确认新密码 | ||
| 192 | + * @return | ||
| 193 | + */ | ||
| 194 | + @RequestMapping(value = "/changePWD", method = RequestMethod.POST) | ||
| 195 | + public String changePWD(@RequestParam String oldPWD, @RequestParam String newPWD, @RequestParam String cnewPWD) { | ||
| 196 | + SysUser sysUser = SecurityUtils.getCurrentUser(); | ||
| 197 | + String msg = ""; | ||
| 198 | + if (new BCryptPasswordEncoder(4).matches(oldPWD, sysUser.getPassword())) { | ||
| 199 | + if (oldPWD.equals(newPWD)) { | ||
| 200 | + msg = "新密码不能跟原始密码一样!"; | ||
| 201 | + } else { | ||
| 202 | + if (newPWD.equals(cnewPWD)) { | ||
| 203 | + sysUserService.changePWD(sysUser.getId(), newPWD); | ||
| 204 | + msg = "修改成功!"; | ||
| 205 | + } else { | ||
| 206 | + msg = "新密码两次输入不一致!"; | ||
| 207 | + } | ||
| 208 | + } | ||
| 209 | + } else { | ||
| 210 | + msg = "原始密码错误!"; | ||
| 211 | + } | ||
| 212 | + return msg; | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + @RequestMapping(value = "/register" ,method = RequestMethod.POST) | ||
| 216 | + public Map<String, Object> register(SysUser u){ | ||
| 217 | + return sysUserService.register(u); | ||
| 218 | + } | ||
| 219 | + | ||
| 220 | + @RequestMapping(value = "/all_distinct") | ||
| 221 | + public List<SysUser> findAll_distinct(){ | ||
| 222 | + return sysUserService.findAll_distinct(); | ||
| 223 | + } | ||
| 224 | +} |
src/main/java/com/bsth/controller/sys/dto/CompanyData.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/sys/dto/CompanyData.java | ||
| 1 | +package com.bsth.controller.sys.dto; | ||
| 2 | + | ||
| 3 | +import java.util.List; | ||
| 4 | + | ||
| 5 | +/** | ||
| 6 | + * Created by panzhao on 2016/11/22. | ||
| 7 | + */ | ||
| 8 | +public class CompanyData { | ||
| 9 | + | ||
| 10 | + private String companyCode; | ||
| 11 | + | ||
| 12 | + private String companyName; | ||
| 13 | + | ||
| 14 | + private List<ChildrenCompany> children; | ||
| 15 | + | ||
| 16 | + public String getCompanyCode() { | ||
| 17 | + return companyCode; | ||
| 18 | + } | ||
| 19 | + | ||
| 20 | + public void setCompanyCode(String companyCode) { | ||
| 21 | + this.companyCode = companyCode; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + public String getCompanyName() { | ||
| 25 | + return companyName; | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public void setCompanyName(String companyName) { | ||
| 29 | + this.companyName = companyName; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public List<ChildrenCompany> getChildren() { | ||
| 33 | + return children; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public void setChildren(List<ChildrenCompany> children) { | ||
| 37 | + this.children = children; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public static class ChildrenCompany { | ||
| 41 | + private String code; | ||
| 42 | + | ||
| 43 | + private String name; | ||
| 44 | + | ||
| 45 | + public ChildrenCompany(String code, String name){ | ||
| 46 | + this.code = code; | ||
| 47 | + this.name = name; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public String getName() { | ||
| 51 | + return name; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public void setName(String name) { | ||
| 55 | + this.name = name; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public String getCode() { | ||
| 59 | + return code; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public void setCode(String code) { | ||
| 63 | + this.code = code; | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | +} |
src/main/java/com/bsth/controller/sys/util/RSAUtils.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/controller/sys/util/RSAUtils.java | ||
| 1 | +package com.bsth.controller.sys.util; | ||
| 2 | + | ||
| 3 | +import java.security.KeyPair; | ||
| 4 | +import java.security.KeyPairGenerator; | ||
| 5 | +import java.security.SecureRandom; | ||
| 6 | +import java.security.Security; | ||
| 7 | +import java.security.interfaces.RSAPrivateKey; | ||
| 8 | +import java.security.interfaces.RSAPublicKey; | ||
| 9 | + | ||
| 10 | +import javax.crypto.Cipher; | ||
| 11 | + | ||
| 12 | +import org.apache.commons.net.util.Base64; | ||
| 13 | +import org.slf4j.Logger; | ||
| 14 | +import org.slf4j.LoggerFactory; | ||
| 15 | + | ||
| 16 | +public class RSAUtils { | ||
| 17 | + private static final KeyPair keyPair = initKey(); | ||
| 18 | + | ||
| 19 | + static Logger logger = LoggerFactory.getLogger(RSAUtils.class); | ||
| 20 | + | ||
| 21 | + private static KeyPair initKey(){ | ||
| 22 | + try { | ||
| 23 | + Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); | ||
| 24 | + SecureRandom random = new SecureRandom(); | ||
| 25 | + KeyPairGenerator generator = KeyPairGenerator.getInstance("RSA", "BC"); | ||
| 26 | + generator.initialize(1024, random); | ||
| 27 | + return generator.generateKeyPair(); | ||
| 28 | + }catch (Exception e) { | ||
| 29 | + throw new RuntimeException(e); | ||
| 30 | + } | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 生成public key | ||
| 35 | + * @return | ||
| 36 | + */ | ||
| 37 | + public static String generateBase64PublicKey(){ | ||
| 38 | + RSAPublicKey key = (RSAPublicKey)keyPair.getPublic(); | ||
| 39 | + return new String(Base64.encodeBase64(key.getEncoded())); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * 解密 | ||
| 44 | + * @param string | ||
| 45 | + * @return | ||
| 46 | + */ | ||
| 47 | + public static String decryptBase64(String string) { | ||
| 48 | + logger.info("decryptBase64 -[" + string + "]"); | ||
| 49 | + return new String(decrypt(Base64.decodeBase64(string))); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + private static byte[] decrypt(byte[] string) { | ||
| 53 | + try { | ||
| 54 | + Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider()); | ||
| 55 | + Cipher cipher = Cipher.getInstance("RSA/None/PKCS1Padding", "BC"); | ||
| 56 | + RSAPrivateKey pbk = (RSAPrivateKey)keyPair.getPrivate(); | ||
| 57 | + cipher.init(Cipher.DECRYPT_MODE, pbk); | ||
| 58 | + byte[] plainText = cipher.doFinal(string); | ||
| 59 | + return plainText; | ||
| 60 | + }catch (Exception e) { | ||
| 61 | + throw new RuntimeException(e); | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | +} |
src/main/java/com/bsth/data/attendance/AttendaceDataBuffer.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/attendance/AttendaceDataBuffer.java | ||
| 1 | +package com.bsth.data.attendance; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.attendance.dto.RemoteAttendaceDTO; | ||
| 4 | +import com.bsth.data.attendance.entity.JsyAttendance; | ||
| 5 | +import com.bsth.data.msg_queue.SignalAndAttConsumeQueue; | ||
| 6 | + | ||
| 7 | +import java.util.LinkedList; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 查询一体机实时考勤数据缓存 | ||
| 11 | + * Created by panzhao on 2017/9/4. | ||
| 12 | + */ | ||
| 13 | +public class AttendaceDataBuffer { | ||
| 14 | + | ||
| 15 | + | ||
| 16 | + private static LinkedList<JsyAttendance> list; | ||
| 17 | + | ||
| 18 | + static{ | ||
| 19 | + list = new LinkedList<>(); | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + public static void put(RemoteAttendaceDTO dto){ | ||
| 23 | + JsyAttendance att = JsyAttendance.getInstance(dto); | ||
| 24 | + if(null != att) | ||
| 25 | + list.add(att); | ||
| 26 | + | ||
| 27 | + SignalAndAttConsumeQueue.put(att); | ||
| 28 | + } | ||
| 29 | +} |
src/main/java/com/bsth/data/attendance/dto/RemoteAttendaceDTO.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/attendance/dto/RemoteAttendaceDTO.java | ||
| 1 | +package com.bsth.data.attendance.dto; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 从查询一体机http发送来的实时考勤数据 | ||
| 5 | + * Created by panzhao on 2017/9/4. | ||
| 6 | + */ | ||
| 7 | +public class RemoteAttendaceDTO { | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * 带公司前缀的工号 55-S012345 | ||
| 11 | + */ | ||
| 12 | + private String workNo; | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 0: 签到 | ||
| 16 | + * 1:签退 | ||
| 17 | + */ | ||
| 18 | + private int type; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 时间 | ||
| 22 | + */ | ||
| 23 | + private long date; | ||
| 24 | + | ||
| 25 | + public String getWorkNo() { | ||
| 26 | + return workNo; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public void setWorkNo(String workNo) { | ||
| 30 | + this.workNo = workNo; | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + public int getType() { | ||
| 34 | + return type; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public void setType(int type) { | ||
| 38 | + this.type = type; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public long getDate() { | ||
| 42 | + return date; | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public void setDate(long date) { | ||
| 46 | + this.date = date; | ||
| 47 | + } | ||
| 48 | +} |
src/main/java/com/bsth/data/attendance/entity/JsyAttendance.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/attendance/entity/JsyAttendance.java | ||
| 1 | +package com.bsth.data.attendance.entity; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.attendance.dto.RemoteAttendaceDTO; | ||
| 4 | +import org.slf4j.Logger; | ||
| 5 | +import org.slf4j.LoggerFactory; | ||
| 6 | + | ||
| 7 | +import java.util.Date; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 驾驶员考勤 | ||
| 11 | + * Created by panzhao on 2017/9/4. | ||
| 12 | + */ | ||
| 13 | +public class JsyAttendance { | ||
| 14 | + | ||
| 15 | + private Long id; | ||
| 16 | + | ||
| 17 | + private String company; | ||
| 18 | + | ||
| 19 | + private String userId; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 0: 签到 | ||
| 23 | + * 1:签退 | ||
| 24 | + */ | ||
| 25 | + private int type; | ||
| 26 | + | ||
| 27 | + private Date attTime; | ||
| 28 | + | ||
| 29 | + private Long at; | ||
| 30 | + | ||
| 31 | + private String outCard; | ||
| 32 | + | ||
| 33 | + private String ip; | ||
| 34 | + | ||
| 35 | + private Date serverTime; | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + static Logger logger = LoggerFactory.getLogger(JsyAttendance.class); | ||
| 39 | + | ||
| 40 | + public static JsyAttendance getInstance(RemoteAttendaceDTO dto){ | ||
| 41 | + try{ | ||
| 42 | + if(dto.getWorkNo().indexOf("-") == -1) | ||
| 43 | + return null; | ||
| 44 | + | ||
| 45 | + JsyAttendance att = new JsyAttendance(); | ||
| 46 | + String[] array = dto.getWorkNo().split("-"); | ||
| 47 | + att.company = array[0]; | ||
| 48 | + att.userId = array[1]; | ||
| 49 | + att.type = dto.getType(); | ||
| 50 | + att.at = dto.getDate(); | ||
| 51 | + att.attTime = new Date(att.at); | ||
| 52 | + att.serverTime = new Date(); | ||
| 53 | + | ||
| 54 | + return att; | ||
| 55 | + }catch (Exception e){ | ||
| 56 | + logger.error("", e); | ||
| 57 | + return null; | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public Long getId() { | ||
| 62 | + return id; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void setId(Long id) { | ||
| 66 | + this.id = id; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public String getCompany() { | ||
| 70 | + return company; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public void setCompany(String company) { | ||
| 74 | + this.company = company; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public String getUserId() { | ||
| 78 | + return userId; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public void setUserId(String userId) { | ||
| 82 | + this.userId = userId; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public int getType() { | ||
| 86 | + return type; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public void setType(int type) { | ||
| 90 | + this.type = type; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public Date getAttTime() { | ||
| 94 | + return attTime; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public void setAttTime(Date attTime) { | ||
| 98 | + this.attTime = attTime; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public Long getAt() { | ||
| 102 | + return at; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public void setAt(Long at) { | ||
| 106 | + this.at = at; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public String getOutCard() { | ||
| 110 | + return outCard; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public void setOutCard(String outCard) { | ||
| 114 | + this.outCard = outCard; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + public String getIp() { | ||
| 118 | + return ip; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public void setIp(String ip) { | ||
| 122 | + this.ip = ip; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public Date getServerTime() { | ||
| 126 | + return serverTime; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public void setServerTime(Date serverTime) { | ||
| 130 | + this.serverTime = serverTime; | ||
| 131 | + } | ||
| 132 | +} |
src/main/java/com/bsth/data/basic/bus/BusCardDto.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/basic/bus/BusCardDto.java | ||
| 1 | +package com.bsth.data.basic.bus; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by panzhao on 2017/8/11. | ||
| 5 | + */ | ||
| 6 | +public class BusCardDto { | ||
| 7 | + | ||
| 8 | + /** | ||
| 9 | + * 16进制ID卡号 | ||
| 10 | + */ | ||
| 11 | + private String idCard; | ||
| 12 | + | ||
| 13 | + /** | ||
| 14 | + * 车辆自编号 | ||
| 15 | + */ | ||
| 16 | + private String nbbm; | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 标签号 | ||
| 20 | + */ | ||
| 21 | + private String tagCard; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 备注 | ||
| 25 | + */ | ||
| 26 | + private String remark; | ||
| 27 | + | ||
| 28 | + public String getIdCard() { | ||
| 29 | + return idCard; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public void setIdCard(String idCard) { | ||
| 33 | + this.idCard = idCard; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public String getTagCard() { | ||
| 37 | + return tagCard; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public void setTagCard(String tagCard) { | ||
| 41 | + this.tagCard = tagCard; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + public String getRemark() { | ||
| 45 | + return remark; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public void setRemark(String remark) { | ||
| 49 | + this.remark = remark; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public String getNbbm() { | ||
| 53 | + return nbbm; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public void setNbbm(String nbbm) { | ||
| 57 | + this.nbbm = nbbm; | ||
| 58 | + } | ||
| 59 | +} |
src/main/java/com/bsth/data/basic/bus/BusDataBuffer.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/basic/bus/BusDataBuffer.java | ||
| 1 | +package com.bsth.data.basic.bus; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.alibaba.fastjson.JSONArray; | ||
| 5 | +import com.alibaba.fastjson.JSONObject; | ||
| 6 | +import com.bsth.Application; | ||
| 7 | +import com.bsth.common.RemotePostDataException; | ||
| 8 | +import com.bsth.common.ResponseCode; | ||
| 9 | +import com.bsth.data.basic.person.PersonDataBuffer; | ||
| 10 | +import com.bsth.data.utils.HttpClientUtils; | ||
| 11 | +import com.bsth.data.utils.RsRequestUtils; | ||
| 12 | +import com.bsth.entity.Bus; | ||
| 13 | +import com.bsth.service.basic.BusCardService; | ||
| 14 | +import com.bsth.util.ConfigUtil; | ||
| 15 | +import com.google.common.base.Splitter; | ||
| 16 | +import org.apache.commons.lang3.StringUtils; | ||
| 17 | +import org.slf4j.Logger; | ||
| 18 | +import org.slf4j.LoggerFactory; | ||
| 19 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 20 | +import org.springframework.boot.CommandLineRunner; | ||
| 21 | +import org.springframework.stereotype.Component; | ||
| 22 | + | ||
| 23 | +import java.util.*; | ||
| 24 | +import java.util.concurrent.TimeUnit; | ||
| 25 | + | ||
| 26 | +/** | ||
| 27 | + * 公交车数据 --定时和远端接口同步 | ||
| 28 | + * Created by panzhao on 2017/8/15. | ||
| 29 | + */ | ||
| 30 | +@Component | ||
| 31 | +public class BusDataBuffer implements CommandLineRunner { | ||
| 32 | + | ||
| 33 | + private static List<Bus> list; | ||
| 34 | + private static Map<String, Bus> idMaps; | ||
| 35 | + private static String dataUrl; | ||
| 36 | + public static List<String> companys;//有权限的公司编码list | ||
| 37 | + | ||
| 38 | + @Autowired | ||
| 39 | + BusFixedRefreshThread busFixedRefreshThread; | ||
| 40 | + | ||
| 41 | + @Autowired | ||
| 42 | + BusCardService busCardService; | ||
| 43 | + | ||
| 44 | + static Logger logger = LoggerFactory.getLogger(PersonDataBuffer.class); | ||
| 45 | + | ||
| 46 | + static { | ||
| 47 | + list = new ArrayList<>(); | ||
| 48 | + idMaps = new HashMap<>(); | ||
| 49 | + dataUrl = ConfigUtil.get("data.bus.url"); | ||
| 50 | + companys = Splitter.on(",").splitToList(ConfigUtil.get("tcc.company.id")); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public void run(String... strings) throws Exception { | ||
| 56 | + Application.mainServices.scheduleWithFixedDelay(busFixedRefreshThread, 20, 60 * 20, TimeUnit.SECONDS); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * 直接向远端接口提交车卡数据 | ||
| 61 | + * @param jsonStr | ||
| 62 | + * @return | ||
| 63 | + */ | ||
| 64 | + public static Map<String, Object> sendCardsData(String jsonStr) { | ||
| 65 | + Map<String, Object> rs = new HashMap<>(); | ||
| 66 | + try{ | ||
| 67 | + StringBuilder sb = HttpClientUtils.post(dataUrl + "/setCards" + RsRequestUtils.getParams(), jsonStr); | ||
| 68 | + if(sb.length() > 0){ | ||
| 69 | + rs = JSONObject.parseObject(sb.toString()); | ||
| 70 | + | ||
| 71 | + //将远端成功的卡信息更新到本地 | ||
| 72 | + JSONArray successArray = (JSONArray) rs.get("successList"); | ||
| 73 | + Bus b; | ||
| 74 | + BusCardDto bcd; | ||
| 75 | + for(int i = 0; i < successArray.size(); i++){ | ||
| 76 | + bcd = successArray.getObject(i, BusCardDto.class); | ||
| 77 | + b = findOne(bcd.getNbbm()); | ||
| 78 | + if(null == b) | ||
| 79 | + continue; | ||
| 80 | + b.setIdRfid(bcd.getIdCard()); | ||
| 81 | + b.setTagRfid(bcd.getTagCard()); | ||
| 82 | + b.setRemark(bcd.getRemark()); | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + else{ | ||
| 86 | + rs.put("status", ResponseCode.ERROR); | ||
| 87 | + } | ||
| 88 | + }catch (Exception e){ | ||
| 89 | + logger.error("", e); | ||
| 90 | + rs.put("status", ResponseCode.ERROR); | ||
| 91 | + } | ||
| 92 | + return rs; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + public void refresh() { | ||
| 96 | + busFixedRefreshThread.run(); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + public static Bus updateCardInfo(Bus nb) throws Exception { | ||
| 100 | + Bus b =findOne(nb.getNbbm()); | ||
| 101 | + if(null != b){ | ||
| 102 | + try{ | ||
| 103 | + Map<String, String> bodyMap = new HashMap<>(); | ||
| 104 | + bodyMap.put("nbbm", nb.getNbbm()); | ||
| 105 | + bodyMap.put("idCard", nb.getIdRfid()); | ||
| 106 | + bodyMap.put("tagCard", nb.getTagRfid()); | ||
| 107 | + bodyMap.put("remark", nb.getRemark()); | ||
| 108 | + | ||
| 109 | + String bodyStr = "[" + JSON.toJSONString(bodyMap) + "]"; | ||
| 110 | + StringBuilder sb = HttpClientUtils.post(dataUrl + "/setCards" + RsRequestUtils.getParams(), bodyStr); | ||
| 111 | + Map<String, Object> rs = JSONObject.parseObject(sb.toString()); | ||
| 112 | + | ||
| 113 | + if(((int)rs.get("success")) != 1){ | ||
| 114 | + throw new RemotePostDataException("setCards"); | ||
| 115 | + } | ||
| 116 | + }catch (Exception e){ | ||
| 117 | + logger.error("", e); | ||
| 118 | + throw e; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + b.setIdRfid(nb.getIdRfid()); | ||
| 122 | + b.setTagRfid(nb.getTagRfid()); | ||
| 123 | + b.setRemark(nb.getRemark()); | ||
| 124 | + | ||
| 125 | + } | ||
| 126 | + return b; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + @Component | ||
| 130 | + public class BusFixedRefreshThread extends Thread { | ||
| 131 | + | ||
| 132 | + @Override | ||
| 133 | + public void run() { | ||
| 134 | + try{ | ||
| 135 | + logger.info("同步车辆信息..."); | ||
| 136 | + StringBuilder sb = HttpClientUtils.get(dataUrl + "/all" + RsRequestUtils.getParams()); | ||
| 137 | + List<Bus> tempList = new ArrayList<>(); | ||
| 138 | + | ||
| 139 | + if(null != sb){ | ||
| 140 | + tempList = JSON.parseArray(sb.toString(), Bus.class); | ||
| 141 | + } | ||
| 142 | + logger.info("同步车辆信息完成," + tempList.size()); | ||
| 143 | + | ||
| 144 | + //按公司编码过滤数据 | ||
| 145 | + Set<Bus> subList = new HashSet<>(); | ||
| 146 | + for(Bus b : tempList){ | ||
| 147 | + if(companys.contains(b.getCompanyCode())) | ||
| 148 | + subList.add(b); | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + tempList = new ArrayList<>(subList); | ||
| 152 | + //排序 | ||
| 153 | + Collections.sort(tempList, new Comparator<Bus>() { | ||
| 154 | + @Override | ||
| 155 | + public int compare(Bus o1, Bus o2) { | ||
| 156 | + return o1.getNbbm().compareTo(o2.getNbbm()); | ||
| 157 | + } | ||
| 158 | + }); | ||
| 159 | + | ||
| 160 | + //id对照 | ||
| 161 | + Map<String, Bus> idMapsCopy = new HashMap<>(); | ||
| 162 | + for(Bus b : tempList) | ||
| 163 | + idMapsCopy.put(b.getNbbm(), b); | ||
| 164 | + | ||
| 165 | + list = tempList; | ||
| 166 | + idMaps = idMapsCopy; | ||
| 167 | + logger.info("车辆信息过滤," + list.size()); | ||
| 168 | + | ||
| 169 | + /*if(list.size() > 0){ | ||
| 170 | + //更新本地卡信息 | ||
| 171 | + busCardService.update(list); | ||
| 172 | + }*/ | ||
| 173 | + //更新本地卡信息 | ||
| 174 | + busCardService.refresh(); | ||
| 175 | + }catch (Exception e){ | ||
| 176 | + logger.error("", e); | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + public static List<Bus> findAll(){ | ||
| 182 | + return list; | ||
| 183 | + } | ||
| 184 | + | ||
| 185 | + /** | ||
| 186 | + * 获取有卡的车辆信息 | ||
| 187 | + * @return | ||
| 188 | + */ | ||
| 189 | + public static List<Bus> findHaveCard(){ | ||
| 190 | + List<Bus> rs = new ArrayList<>(); | ||
| 191 | + for(Bus b : list){ | ||
| 192 | + if(StringUtils.isNotEmpty(b.getIdRfid())) | ||
| 193 | + rs.add(b); | ||
| 194 | + } | ||
| 195 | + return rs; | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + public static Bus findOne(String nbbm){ | ||
| 199 | + return idMaps.get(nbbm); | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + public static Bus findByCard(String idCard){ | ||
| 203 | + for(Bus b : list){ | ||
| 204 | + if(idCard.equals(b.getIdRfid())) | ||
| 205 | + return b; | ||
| 206 | + } | ||
| 207 | + return null; | ||
| 208 | + } | ||
| 209 | +} |
src/main/java/com/bsth/data/basic/line/LineDataBuffer.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/basic/line/LineDataBuffer.java | ||
| 1 | +package com.bsth.data.basic.line; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.bsth.Application; | ||
| 5 | +import com.bsth.data.basic.person.PersonDataBuffer; | ||
| 6 | +import com.bsth.data.utils.HttpClientUtils; | ||
| 7 | +import com.bsth.data.utils.RsRequestUtils; | ||
| 8 | +import com.bsth.entity.Line; | ||
| 9 | +import com.bsth.util.ConfigUtil; | ||
| 10 | +import com.google.common.base.Splitter; | ||
| 11 | +import org.slf4j.Logger; | ||
| 12 | +import org.slf4j.LoggerFactory; | ||
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | +import org.springframework.boot.CommandLineRunner; | ||
| 15 | +import org.springframework.stereotype.Component; | ||
| 16 | + | ||
| 17 | +import java.util.*; | ||
| 18 | +import java.util.concurrent.TimeUnit; | ||
| 19 | + | ||
| 20 | +/** | ||
| 21 | + * 线路数据 --定时从集调刷新 | ||
| 22 | + * Created by panzhao on 2017/8/4. | ||
| 23 | + */ | ||
| 24 | +@Component | ||
| 25 | +public class LineDataBuffer implements CommandLineRunner { | ||
| 26 | + | ||
| 27 | + private static List<Line> list; | ||
| 28 | + private static Map<String, Line> idMap; | ||
| 29 | + private static String dataUrl; | ||
| 30 | + private static List<String> companys;//有权限的公司编码list | ||
| 31 | + | ||
| 32 | + @Autowired | ||
| 33 | + LineFixedRefreshThread lineFixedRefreshThread; | ||
| 34 | + | ||
| 35 | + static Logger logger = LoggerFactory.getLogger(PersonDataBuffer.class); | ||
| 36 | + | ||
| 37 | + static { | ||
| 38 | + dataUrl = ConfigUtil.get("data.line.url"); | ||
| 39 | + companys = Splitter.on(",").splitToList(ConfigUtil.get("tcc.company.id")); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + | ||
| 43 | + @Override | ||
| 44 | + public void run(String... strings) throws Exception { | ||
| 45 | + Application.mainServices.scheduleWithFixedDelay(lineFixedRefreshThread, 10, 60 * 20, TimeUnit.SECONDS); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @Component | ||
| 49 | + public class LineFixedRefreshThread extends Thread { | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public void run() { | ||
| 53 | + try{ | ||
| 54 | + logger.info("同步线路信息..."); | ||
| 55 | + StringBuilder sb = HttpClientUtils.get(dataUrl + "/all" + RsRequestUtils.getParams()); | ||
| 56 | + | ||
| 57 | + if(null != sb){ | ||
| 58 | + list = JSON.parseArray(sb.toString(), Line.class); | ||
| 59 | + } | ||
| 60 | + logger.info("同步线路信息完成," + list.size()); | ||
| 61 | + | ||
| 62 | + //按公司编码过滤 | ||
| 63 | + List<Line> subList = new ArrayList<>(); | ||
| 64 | + Map<String, Line> idMapCopy = new HashMap<>(); | ||
| 65 | + for(Line line : list){ | ||
| 66 | + if(companys.contains(line.getCompany())){ | ||
| 67 | + subList.add(line); | ||
| 68 | + idMapCopy.put(line.getLineCode(), line); | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + list = subList; | ||
| 72 | + idMap = idMapCopy; | ||
| 73 | + logger.info("过滤线路信息," + list.size()); | ||
| 74 | + | ||
| 75 | + //排序 | ||
| 76 | + Collections.sort(list, new Comparator<Line>() { | ||
| 77 | + @Override | ||
| 78 | + public int compare(Line o1, Line o2) { | ||
| 79 | + return o1.getName().compareTo(o2.getName()); | ||
| 80 | + } | ||
| 81 | + }); | ||
| 82 | + }catch (Exception e){ | ||
| 83 | + logger.error("", e); | ||
| 84 | + } | ||
| 85 | + } | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public static List<Line> findAll(){ | ||
| 89 | + return list; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public static Line get(String lineCode){ | ||
| 93 | + return idMap.get(lineCode); | ||
| 94 | + } | ||
| 95 | +} |
src/main/java/com/bsth/data/basic/person/PersonDataBuffer.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/basic/person/PersonDataBuffer.java | ||
| 1 | +package com.bsth.data.basic.person; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.alibaba.fastjson.JSONObject; | ||
| 5 | +import com.bsth.Application; | ||
| 6 | +import com.bsth.common.RemotePostDataException; | ||
| 7 | +import com.bsth.common.ResponseCode; | ||
| 8 | +import com.bsth.data.utils.HttpClientUtils; | ||
| 9 | +import com.bsth.data.utils.RsRequestUtils; | ||
| 10 | +import com.bsth.entity.Person; | ||
| 11 | +import com.bsth.util.ConfigUtil; | ||
| 12 | +import com.google.common.base.Splitter; | ||
| 13 | +import org.apache.commons.lang3.StringUtils; | ||
| 14 | +import org.slf4j.Logger; | ||
| 15 | +import org.slf4j.LoggerFactory; | ||
| 16 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 17 | +import org.springframework.boot.CommandLineRunner; | ||
| 18 | +import org.springframework.stereotype.Component; | ||
| 19 | + | ||
| 20 | +import java.util.*; | ||
| 21 | +import java.util.concurrent.TimeUnit; | ||
| 22 | + | ||
| 23 | +/** | ||
| 24 | + * 人员数据 --定时和远端接口同步 | ||
| 25 | + * Created by panzhao on 2017/8/2. | ||
| 26 | + */ | ||
| 27 | +@Component | ||
| 28 | +public class PersonDataBuffer implements CommandLineRunner { | ||
| 29 | + | ||
| 30 | + private static List<Person> list; | ||
| 31 | + private static Map<String, Person> idMaps; | ||
| 32 | + private static String dataUrl; | ||
| 33 | + public static List<String> companys;//有权限的公司编码list | ||
| 34 | + //private static String companyId; | ||
| 35 | + | ||
| 36 | + @Autowired | ||
| 37 | + PersonFixedRefreshThread personFixedRefreshThread; | ||
| 38 | + | ||
| 39 | + static Logger logger = LoggerFactory.getLogger(PersonDataBuffer.class); | ||
| 40 | + | ||
| 41 | + static { | ||
| 42 | + list = new ArrayList<>(); | ||
| 43 | + idMaps = new HashMap<>(); | ||
| 44 | + dataUrl = ConfigUtil.get("data.person.url"); | ||
| 45 | + companys = Splitter.on(",").splitToList(ConfigUtil.get("tcc.company.id")); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public void refresh(){ | ||
| 49 | + //personFixedRefreshThread.start(); | ||
| 50 | + personFixedRefreshThread.run(); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @Override | ||
| 54 | + public void run(String... strings) throws Exception { | ||
| 55 | + Application.mainServices.scheduleWithFixedDelay(personFixedRefreshThread, 20, 60 * 20, TimeUnit.SECONDS); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * 直接向远端接口提交人卡数据 | ||
| 60 | + * @param jsonStr | ||
| 61 | + * @return | ||
| 62 | + */ | ||
| 63 | + public static Map<String, Object> sendCardsData(String jsonStr) { | ||
| 64 | + Map<String, Object> rs = new HashMap<>(); | ||
| 65 | + try{ | ||
| 66 | + StringBuilder sb = HttpClientUtils.post(dataUrl + "/setCards" + RsRequestUtils.getParams(), jsonStr); | ||
| 67 | + if(sb.length() > 0) | ||
| 68 | + rs = JSONObject.parseObject(sb.toString()); | ||
| 69 | + else{ | ||
| 70 | + rs.put("status", ResponseCode.ERROR); | ||
| 71 | + } | ||
| 72 | + }catch (Exception e){ | ||
| 73 | + logger.error("", e); | ||
| 74 | + rs.put("status", ResponseCode.ERROR); | ||
| 75 | + } | ||
| 76 | + return rs; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + @Component | ||
| 80 | + public class PersonFixedRefreshThread extends Thread { | ||
| 81 | + | ||
| 82 | + @Override | ||
| 83 | + public void run() { | ||
| 84 | + try{ | ||
| 85 | + logger.info("同步人员信息..."); | ||
| 86 | + StringBuilder sb = HttpClientUtils.get(dataUrl + "/all" + RsRequestUtils.getParams()); | ||
| 87 | + List<Person> tempList = new ArrayList<>(); | ||
| 88 | + | ||
| 89 | + if(null != sb){ | ||
| 90 | + tempList = JSON.parseArray(sb.toString(), Person.class); | ||
| 91 | + } | ||
| 92 | + logger.info("同步人员信息完成," + tempList.size()); | ||
| 93 | + | ||
| 94 | + //按公司编码过滤数据 | ||
| 95 | + Set<Person> subList = new HashSet<>(); | ||
| 96 | + for(Person p : tempList){ | ||
| 97 | + if(companys.contains(p.getCompanyCode())) | ||
| 98 | + subList.add(p); | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + tempList = new ArrayList<>(subList); | ||
| 102 | + //排序 | ||
| 103 | + Collections.sort(tempList, new Comparator<Person>() { | ||
| 104 | + @Override | ||
| 105 | + public int compare(Person o1, Person o2) { | ||
| 106 | + return o1.getPersonnelName().compareTo(o2.getPersonnelName()); | ||
| 107 | + } | ||
| 108 | + }); | ||
| 109 | + | ||
| 110 | + //id对照 | ||
| 111 | + Map<String, Person> idMapsCopy = new HashMap<>(); | ||
| 112 | + for(Person p : tempList) | ||
| 113 | + idMapsCopy.put(p.getJobCode(), p); | ||
| 114 | + | ||
| 115 | + list = tempList; | ||
| 116 | + idMaps = idMapsCopy; | ||
| 117 | + logger.info("人员信息过滤," + list.size()); | ||
| 118 | + }catch (Exception e){ | ||
| 119 | + logger.error("", e); | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + public static List<Person> findAll(){ | ||
| 125 | + return list; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public static Person findOne(String jobCode){ | ||
| 129 | + return idMaps.get(jobCode); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + public static Person findByCard(String pCard){ | ||
| 133 | + if(StringUtils.isEmpty(pCard)) | ||
| 134 | + return null; | ||
| 135 | + | ||
| 136 | + for(Person p : list){ | ||
| 137 | + if(pCard.equals(p.getIdRfid())) | ||
| 138 | + return p; | ||
| 139 | + } | ||
| 140 | + return null; | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + public static Person updateCardInfo(Person np) throws Exception { | ||
| 144 | + Person p =findOne(np.getJobCode()); | ||
| 145 | + if(null != p){ | ||
| 146 | + try{ | ||
| 147 | + Map<String, String> bodyMap = new HashMap<>(); | ||
| 148 | + bodyMap.put("company", p.getCompanyCode()); | ||
| 149 | + bodyMap.put("jobCode", np.getJobCode().split("-")[1]); | ||
| 150 | + bodyMap.put("idCard", np.getIdRfid()); | ||
| 151 | + bodyMap.put("tagCard", np.getTagRfid()); | ||
| 152 | + bodyMap.put("remark", np.getRemark()); | ||
| 153 | + | ||
| 154 | + String bodyStr = "[" + JSON.toJSONString(bodyMap) + "]"; | ||
| 155 | + StringBuilder sb = HttpClientUtils.post(dataUrl + "/setCards" + RsRequestUtils.getParams(), bodyStr); | ||
| 156 | + Map<String, Object> rs = JSONObject.parseObject(sb.toString()); | ||
| 157 | + | ||
| 158 | + if(((int)rs.get("success")) != 1){ | ||
| 159 | + throw new RemotePostDataException("setCards"); | ||
| 160 | + } | ||
| 161 | + }catch (Exception e){ | ||
| 162 | + logger.error("", e); | ||
| 163 | + throw e; | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + p.setIdRfid(np.getIdRfid()); | ||
| 167 | + p.setTagRfid(np.getTagRfid()); | ||
| 168 | + p.setRemark(np.getRemark()); | ||
| 169 | + | ||
| 170 | + } | ||
| 171 | + return p; | ||
| 172 | + } | ||
| 173 | +} |
src/main/java/com/bsth/data/electric/CarElectricBuffer.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/electric/CarElectricBuffer.java | ||
| 1 | +package com.bsth.data.electric; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.real_park.CarParkRealHandler; | ||
| 4 | +import com.bsth.entity.electric.BusElectric; | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.stereotype.Component; | ||
| 7 | + | ||
| 8 | +import java.util.Collection; | ||
| 9 | +import java.util.HashMap; | ||
| 10 | +import java.util.List; | ||
| 11 | +import java.util.Map; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 车辆电量信息 | ||
| 15 | + * Created by panzhao on 2017/9/11. | ||
| 16 | + */ | ||
| 17 | +@Component | ||
| 18 | +public class CarElectricBuffer { | ||
| 19 | + | ||
| 20 | + public static Map<String, BusElectric> carElecMap = new HashMap<>(); | ||
| 21 | + | ||
| 22 | + @Autowired | ||
| 23 | + CarParkRealHandler carParkRealHandler; | ||
| 24 | + | ||
| 25 | + public void putAll(List<BusElectric> list){ | ||
| 26 | + for(BusElectric be : list){ | ||
| 27 | + carElecMap.put(be.getNbbm(), be); | ||
| 28 | + carParkRealHandler.putElec(be); | ||
| 29 | + } | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public static Collection<BusElectric> all(){ | ||
| 33 | + return carElecMap.values(); | ||
| 34 | + } | ||
| 35 | +} |
src/main/java/com/bsth/data/msg_queue/SignalAndAttConsumeQueue.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/msg_queue/SignalAndAttConsumeQueue.java | ||
| 1 | +package com.bsth.data.msg_queue; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.attendance.entity.JsyAttendance; | ||
| 4 | +import com.bsth.entity.ac.CarInOutEntity; | ||
| 5 | +import com.bsth.service.schedule.InOutScheduleService; | ||
| 6 | +import org.slf4j.Logger; | ||
| 7 | +import org.slf4j.LoggerFactory; | ||
| 8 | +import org.springframework.beans.BeansException; | ||
| 9 | +import org.springframework.context.ApplicationContext; | ||
| 10 | +import org.springframework.context.ApplicationContextAware; | ||
| 11 | +import org.springframework.stereotype.Component; | ||
| 12 | + | ||
| 13 | +import java.util.ArrayList; | ||
| 14 | +import java.util.LinkedList; | ||
| 15 | +import java.util.List; | ||
| 16 | + | ||
| 17 | +/** | ||
| 18 | + * rfid 、牌照识别 、 考勤数据消费队列 | ||
| 19 | + * Created by panzhao on 2017/9/5. | ||
| 20 | + */ | ||
| 21 | +@Component | ||
| 22 | +public class SignalAndAttConsumeQueue implements ApplicationContextAware { | ||
| 23 | + | ||
| 24 | + private static List<Class> clazzs; | ||
| 25 | + private static LinkedList<Object> linkedList; | ||
| 26 | + static InOutScheduleService outScheduleService; | ||
| 27 | + static ConsumeThread thread; | ||
| 28 | + static long t; | ||
| 29 | + static final int IDLE_TIME = 1000 * 30; | ||
| 30 | + | ||
| 31 | + static { | ||
| 32 | + linkedList = new LinkedList<>(); | ||
| 33 | + clazzs = new ArrayList<>(); | ||
| 34 | + clazzs.add(JsyAttendance.class); | ||
| 35 | + clazzs.add(CarInOutEntity.class); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public static void put(Object obj) { | ||
| 39 | + if (!clazzs.contains(obj.getClass())) | ||
| 40 | + return; | ||
| 41 | + | ||
| 42 | + linkedList.add(obj); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public static boolean isIdle(){ | ||
| 46 | + return System.currentTimeMillis() - t > IDLE_TIME; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public static void start(){ | ||
| 50 | + if(thread != null){ | ||
| 51 | + thread.interrupt(); | ||
| 52 | + } | ||
| 53 | + linkedList.clear(); | ||
| 54 | + thread = new ConsumeThread(); | ||
| 55 | + thread.start(); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + @Override | ||
| 59 | + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | ||
| 60 | + outScheduleService = applicationContext.getBean(InOutScheduleService.class); | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + @Component | ||
| 64 | + public static class ConsumeThread extends Thread { | ||
| 65 | + | ||
| 66 | + Logger log = LoggerFactory.getLogger(this.getClass()); | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public void run() { | ||
| 70 | + Object obj; | ||
| 71 | + | ||
| 72 | + boolean sleepFlag = false; | ||
| 73 | + while (true) { | ||
| 74 | + try { | ||
| 75 | + obj = linkedList.poll(); | ||
| 76 | + if (null != obj) { | ||
| 77 | + //驾驶员签到 | ||
| 78 | + if(obj instanceof JsyAttendance) | ||
| 79 | + outScheduleService.jsyReport((JsyAttendance) obj); | ||
| 80 | + //车辆进出场 | ||
| 81 | + else if(obj instanceof CarInOutEntity) | ||
| 82 | + outScheduleService.inOut((CarInOutEntity)obj); | ||
| 83 | + } else { | ||
| 84 | + Thread.sleep(500); | ||
| 85 | + if (!sleepFlag) { | ||
| 86 | + log.info("sleep..."); | ||
| 87 | + sleepFlag = true; | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + t = System.currentTimeMillis(); | ||
| 92 | + } catch (InterruptedException e) { | ||
| 93 | + log.error("", e); | ||
| 94 | + break; | ||
| 95 | + } catch (Exception e) { | ||
| 96 | + log.error("", e); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + log.warn("RfidAndAttConsumeQueue is break..."); | ||
| 102 | + } | ||
| 103 | + } | ||
| 104 | +} |
src/main/java/com/bsth/data/real_park/BerthDataBuffer.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/real_park/BerthDataBuffer.java | ||
| 1 | +package com.bsth.data.real_park; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.berth.RegionBerth; | ||
| 4 | +import com.bsth.repository.berth.BerthRepository; | ||
| 5 | +import org.slf4j.Logger; | ||
| 6 | +import org.slf4j.LoggerFactory; | ||
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | +import org.springframework.stereotype.Component; | ||
| 9 | + | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 预设泊位数据缓存 | ||
| 14 | + * Created by panzhao on 2017/9/14. | ||
| 15 | + */ | ||
| 16 | +public class BerthDataBuffer { | ||
| 17 | + | ||
| 18 | + private static List<RegionBerth> allList; | ||
| 19 | + | ||
| 20 | + static Logger logger = LoggerFactory.getLogger(BerthDataBuffer.class); | ||
| 21 | + | ||
| 22 | + private static void update(RegionBerth b){ | ||
| 23 | + RegionBerth cacheB = getById(b.getId()); | ||
| 24 | + if(null == cacheB) | ||
| 25 | + allList.add(cacheB); | ||
| 26 | + else{ | ||
| 27 | + //cacheB.setNbbm(b.getNbbm()); | ||
| 28 | + cacheB.setOrderNo(b.getOrderNo()); | ||
| 29 | + cacheB.setName(b.getName()); | ||
| 30 | + cacheB.setRegion(b.getRegion()); | ||
| 31 | + cacheB.setUpdateDate(b.getUpdateDate()); | ||
| 32 | + cacheB.setRemark(b.getRemark()); | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + private static RegionBerth getById(Integer id) { | ||
| 37 | + for(RegionBerth b : allList){ | ||
| 38 | + if(id.equals(b.getId())) | ||
| 39 | + return b; | ||
| 40 | + } | ||
| 41 | + return null; | ||
| 42 | + } | ||
| 43 | +/* | ||
| 44 | + public static RegionBerth get(String nbbm) { | ||
| 45 | + for(RegionBerth b : allList){ | ||
| 46 | + if(nbbm.equals(b.getNbbm())) | ||
| 47 | + return b; | ||
| 48 | + } | ||
| 49 | + return null; | ||
| 50 | + }*/ | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * 泊位缓存刷新线程 | ||
| 54 | + */ | ||
| 55 | + @Component | ||
| 56 | + public static class BerthCacheRefreshThread extends Thread { | ||
| 57 | + | ||
| 58 | + @Autowired | ||
| 59 | + BerthRepository berthRepository; | ||
| 60 | + | ||
| 61 | + @Override | ||
| 62 | + public void run() { | ||
| 63 | + /*try{ | ||
| 64 | + List<RegionBerth> list = (List<RegionBerth>) berthRepository.findAll(); | ||
| 65 | + Map<String, RegionBerth> nbbm2BerthMapCopy = new HashMap<>(); | ||
| 66 | + for (RegionBerth b : list) { | ||
| 67 | + if (StringUtils.isNotEmpty(b.getName())) { | ||
| 68 | + //nbbm2BerthMapCopy.put(b.getNbbm(), b); | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + list = new ArrayList(nbbm2BerthMapCopy.values()); | ||
| 73 | + | ||
| 74 | + if (null == allList) | ||
| 75 | + allList = list; | ||
| 76 | + else { | ||
| 77 | + //增量更新 | ||
| 78 | + for (RegionBerth b : list) { | ||
| 79 | + update(b); | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + //排序 | ||
| 84 | + Collections.sort(allList, new Comparator<RegionBerth>() { | ||
| 85 | + @Override | ||
| 86 | + public int compare(RegionBerth o1, RegionBerth o2) { | ||
| 87 | + return Integer.parseInt(o1.getOrderNo()) - Integer.parseInt(o2.getOrderNo()); | ||
| 88 | + } | ||
| 89 | + }); | ||
| 90 | + }catch (Exception e){ | ||
| 91 | + logger.error("泊位数据刷新失败!!", e); | ||
| 92 | + }*/ | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | +} |
src/main/java/com/bsth/data/real_park/CarParkRealHandler.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/real_park/CarParkRealHandler.java | ||
| 1 | +package com.bsth.data.real_park; | ||
| 2 | + | ||
| 3 | +import com.bsth.common.ResponseCode; | ||
| 4 | +import com.bsth.data.basic.bus.BusDataBuffer; | ||
| 5 | +import com.bsth.data.electric.CarElectricBuffer; | ||
| 6 | +import com.bsth.entity.Bus; | ||
| 7 | +import com.bsth.entity.ac.CarInOutEntity; | ||
| 8 | +import com.bsth.entity.electric.BusElectric; | ||
| 9 | +import com.bsth.entity.real.RealCarPark; | ||
| 10 | +import org.apache.commons.lang3.StringUtils; | ||
| 11 | +import org.slf4j.Logger; | ||
| 12 | +import org.slf4j.LoggerFactory; | ||
| 13 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 14 | +import org.springframework.jdbc.core.BeanPropertyRowMapper; | ||
| 15 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 16 | +import org.springframework.stereotype.Component; | ||
| 17 | + | ||
| 18 | +import java.util.*; | ||
| 19 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 20 | +import java.util.concurrent.ConcurrentMap; | ||
| 21 | + | ||
| 22 | +/** | ||
| 23 | + * 实时场内车辆停放数据 | ||
| 24 | + * Created by panzhao on 2017/9/14. | ||
| 25 | + */ | ||
| 26 | +@Component | ||
| 27 | +public class CarParkRealHandler { | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 公交车 | ||
| 31 | + * K: 自编号 | ||
| 32 | + */ | ||
| 33 | + private static ConcurrentMap<String, RealCarPark> busRcps; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 非公交车 | ||
| 37 | + * K: 车牌号 | ||
| 38 | + */ | ||
| 39 | + private static ConcurrentMap<String, RealCarPark> carRcps; | ||
| 40 | + | ||
| 41 | + static Logger logger = LoggerFactory.getLogger(CarParkRealHandler.class); | ||
| 42 | + | ||
| 43 | + static { | ||
| 44 | + busRcps = new ConcurrentHashMap<>(); | ||
| 45 | + carRcps = new ConcurrentHashMap<>(); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 公交车电量信息 | ||
| 50 | + * | ||
| 51 | + * @param be | ||
| 52 | + */ | ||
| 53 | + public void putElec(BusElectric be) { | ||
| 54 | + RealCarPark rcp = busRcps.get(be.getNbbm()); | ||
| 55 | + if (null != rcp) { | ||
| 56 | + rcp.setSoc(be.getSoc()); | ||
| 57 | + } | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public static Collection<RealCarPark> allBus() { | ||
| 61 | + return busRcps.values(); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public static List<RealCarPark> allData(){ | ||
| 65 | + List<RealCarPark> all = new ArrayList<>(); | ||
| 66 | + all.addAll(busRcps.values()); | ||
| 67 | + all.addAll(carRcps.values()); | ||
| 68 | + return all; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public void carInOut(CarInOutEntity cio) { | ||
| 72 | + if (cio.getType() == 2) | ||
| 73 | + carIn(cio); | ||
| 74 | + else if (cio.getType() == 4) | ||
| 75 | + carOut(cio); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * 车辆进场 | ||
| 80 | + * | ||
| 81 | + * @param cio | ||
| 82 | + */ | ||
| 83 | + private void carIn(CarInOutEntity cio) { | ||
| 84 | + if (cio.getCarType() == 0) | ||
| 85 | + busIn(cio); | ||
| 86 | + else { | ||
| 87 | + | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * 公交车进场 | ||
| 93 | + * | ||
| 94 | + * @param cio | ||
| 95 | + */ | ||
| 96 | + private void busIn(CarInOutEntity cio) { | ||
| 97 | + String nbbm = cio.getNbbm(); | ||
| 98 | + if (StringUtils.isEmpty(nbbm)) | ||
| 99 | + return; | ||
| 100 | + | ||
| 101 | + RealCarPark rcp = new RealCarPark(); | ||
| 102 | + //泊位信息 | ||
| 103 | + /*RegionBerth b = BerthDataBuffer.get(nbbm); | ||
| 104 | + if (null != b) | ||
| 105 | + rcp.setBerthName(b.getName());*/ | ||
| 106 | + | ||
| 107 | + rcp.setNbbm(nbbm); | ||
| 108 | + rcp.setInTime(System.currentTimeMillis()); | ||
| 109 | + rcp.setType(0); | ||
| 110 | + | ||
| 111 | + //车牌号 | ||
| 112 | + Bus bus = BusDataBuffer.findOne(nbbm); | ||
| 113 | + if(null != bus) | ||
| 114 | + rcp.setPlateNo(bus.getCarPlate()); | ||
| 115 | + //电量信息 | ||
| 116 | + BusElectric be = CarElectricBuffer.carElecMap.get(nbbm); | ||
| 117 | + if(null != be) | ||
| 118 | + rcp.setSoc(be.getSoc()); | ||
| 119 | + | ||
| 120 | + busRcps.put(nbbm, rcp); | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + /** | ||
| 124 | + * 公交车出场 | ||
| 125 | + * | ||
| 126 | + * @param cio | ||
| 127 | + */ | ||
| 128 | + private void carOut(CarInOutEntity cio) { | ||
| 129 | + String nbbm = cio.getNbbm(); | ||
| 130 | + if (StringUtils.isEmpty(nbbm)) | ||
| 131 | + return; | ||
| 132 | + | ||
| 133 | + busRcps.remove(nbbm); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + /** | ||
| 137 | + * 泊位交换 | ||
| 138 | + * | ||
| 139 | + * @param sName 泊位名称 源 | ||
| 140 | + * @param dName 泊位名称 目标 | ||
| 141 | + * @return | ||
| 142 | + */ | ||
| 143 | + public static Map<String, Object> realChange(String sName, String dName) { | ||
| 144 | + Map<String, Object> rs = new HashMap(); | ||
| 145 | + try { | ||
| 146 | + RealCarPark rcp1 = getByBerthName(sName); | ||
| 147 | + RealCarPark rcp2 = getByBerthName(dName); | ||
| 148 | + | ||
| 149 | + if (null != rcp1) | ||
| 150 | + rcp1.setBerthName(dName); | ||
| 151 | + | ||
| 152 | + if (null != rcp2) | ||
| 153 | + rcp2.setBerthName(sName); | ||
| 154 | + | ||
| 155 | + rs.put("status", ResponseCode.SUCCESS); | ||
| 156 | + rs.put("list", allBus()); | ||
| 157 | + } catch (Exception e) { | ||
| 158 | + logger.error("", e); | ||
| 159 | + rs.put("status", ResponseCode.ERROR); | ||
| 160 | + } | ||
| 161 | + return rs; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + private static RealCarPark getByBerthName(String sName) { | ||
| 165 | + for (RealCarPark rcp : busRcps.values()) { | ||
| 166 | + if (sName.equals(rcp.getBerthName())) | ||
| 167 | + return rcp; | ||
| 168 | + } | ||
| 169 | + return null; | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + @Autowired | ||
| 173 | + JdbcTemplate jdbcTemplate; | ||
| 174 | + | ||
| 175 | + /** | ||
| 176 | + * 从数据库恢复 | ||
| 177 | + */ | ||
| 178 | + public void recovery() { | ||
| 179 | + String sql = "select type, nbbm, plate_no,in_time,berth_name,soc from bsth_real_carpark"; | ||
| 180 | + List<RealCarPark> list = jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(RealCarPark.class)); | ||
| 181 | + | ||
| 182 | + for(RealCarPark rcp : list){ | ||
| 183 | + if(rcp.getType() == 0) | ||
| 184 | + busRcps.put(rcp.getNbbm(), rcp); | ||
| 185 | + else | ||
| 186 | + carRcps.put(rcp.getPlateNo(), rcp); | ||
| 187 | + } | ||
| 188 | + } | ||
| 189 | +} |
src/main/java/com/bsth/data/real_park/thread/RealParkDataPersistenceThread.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/real_park/thread/RealParkDataPersistenceThread.java | ||
| 1 | +package com.bsth.data.real_park.thread; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.real_park.CarParkRealHandler; | ||
| 4 | +import com.bsth.entity.real.RealCarPark; | ||
| 5 | +import org.slf4j.Logger; | ||
| 6 | +import org.slf4j.LoggerFactory; | ||
| 7 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 8 | +import org.springframework.jdbc.core.BatchPreparedStatementSetter; | ||
| 9 | +import org.springframework.jdbc.core.JdbcTemplate; | ||
| 10 | +import org.springframework.jdbc.datasource.DataSourceTransactionManager; | ||
| 11 | +import org.springframework.stereotype.Component; | ||
| 12 | +import org.springframework.transaction.TransactionDefinition; | ||
| 13 | +import org.springframework.transaction.TransactionStatus; | ||
| 14 | +import org.springframework.transaction.support.DefaultTransactionDefinition; | ||
| 15 | + | ||
| 16 | +import java.sql.PreparedStatement; | ||
| 17 | +import java.sql.SQLException; | ||
| 18 | +import java.util.Date; | ||
| 19 | +import java.util.List; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * 实时停放信息入库线程 | ||
| 23 | + * Created by panzhao on 2017/9/14. | ||
| 24 | + */ | ||
| 25 | +@Component | ||
| 26 | +public class RealParkDataPersistenceThread extends Thread { | ||
| 27 | + | ||
| 28 | + @Autowired | ||
| 29 | + JdbcTemplate jdbcTemplate; | ||
| 30 | + | ||
| 31 | + Logger logger = LoggerFactory.getLogger(this.getClass()); | ||
| 32 | + | ||
| 33 | + @Override | ||
| 34 | + public void run() { | ||
| 35 | + try { | ||
| 36 | + final List<RealCarPark> list = CarParkRealHandler.allData(); | ||
| 37 | + | ||
| 38 | + //编程式事务 | ||
| 39 | + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource()); | ||
| 40 | + DefaultTransactionDefinition def = new DefaultTransactionDefinition(); | ||
| 41 | + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); | ||
| 42 | + TransactionStatus status = tran.getTransaction(def); | ||
| 43 | + | ||
| 44 | + try { | ||
| 45 | + final java.sql.Date d = new java.sql.Date(new Date().getTime()); | ||
| 46 | + //删除 | ||
| 47 | + jdbcTemplate.update("delete from bsth_real_carpark"); | ||
| 48 | + //重新写入 | ||
| 49 | + jdbcTemplate.batchUpdate("insert into bsth_real_carpark(type, nbbm, plate_no, in_time, berth_name, soc, create_time)" + | ||
| 50 | + " VALUES (?, ?, ?, ?, ?, ?, SYSDATE())", new BatchPreparedStatementSetter() { | ||
| 51 | + @Override | ||
| 52 | + public void setValues(PreparedStatement ps, int i) throws SQLException { | ||
| 53 | + RealCarPark rcp = list.get(i); | ||
| 54 | + ps.setInt(1, rcp.getType()); | ||
| 55 | + ps.setString(2, rcp.getNbbm()); | ||
| 56 | + ps.setString(3, rcp.getPlateNo()); | ||
| 57 | + ps.setLong(4, rcp.getInTime()); | ||
| 58 | + ps.setString(5, rcp.getBerthName()); | ||
| 59 | + ps.setString(6, rcp.getSoc()); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public int getBatchSize() { | ||
| 64 | + return list.size(); | ||
| 65 | + } | ||
| 66 | + }); | ||
| 67 | + | ||
| 68 | + tran.commit(status); | ||
| 69 | + } catch (Exception e) { | ||
| 70 | + tran.rollback(status); | ||
| 71 | + logger.error("", e); | ||
| 72 | + } | ||
| 73 | + } catch (Exception e) { | ||
| 74 | + logger.error("", e); | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | +} |
src/main/java/com/bsth/data/schedule/dto/ScheduleInOut.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/schedule/dto/ScheduleInOut.java | ||
| 1 | +package com.bsth.data.schedule.dto; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 进出场班次数据 ---给停车场用的 | ||
| 5 | + * Created by panzhao on 2017/8/24. | ||
| 6 | + */ | ||
| 7 | +public class ScheduleInOut { | ||
| 8 | + private Long id; | ||
| 9 | + private String scheduleDateStr; | ||
| 10 | + private String lineCode; | ||
| 11 | + private String lineName; | ||
| 12 | + private String lpName; | ||
| 13 | + private String nbbm; | ||
| 14 | + private String jsy; | ||
| 15 | + private String spy; | ||
| 16 | + private int upDown; | ||
| 17 | + private String qdzCode; | ||
| 18 | + private String qdzName; | ||
| 19 | + private String zdzCode; | ||
| 20 | + private String zdzName; | ||
| 21 | + private Long dfsjT; | ||
| 22 | + private Long zdsjT; | ||
| 23 | + private Long fcsjActualTime;//实际发车时间,集调gps | ||
| 24 | + private Long zdsjActualTime; | ||
| 25 | + private boolean sflj; | ||
| 26 | + private String remarks; | ||
| 27 | + private String bcType; | ||
| 28 | + /**班次状态 0 未执行 1 正在执行 2 已执行 -1 已烂班 */ | ||
| 29 | + private int status; | ||
| 30 | + | ||
| 31 | + private String gsbm;//公司编码 | ||
| 32 | + private String fgsbm;//分公司编码 | ||
| 33 | + private Long attJhTime;//计划报到 | ||
| 34 | + private Long attSjTime;//实际报到 | ||
| 35 | + | ||
| 36 | + private Long ut;// 同步时间 | ||
| 37 | + | ||
| 38 | + private String jGh;//驾驶员工号 | ||
| 39 | + | ||
| 40 | + private Long outTimeRfid;//出场时间 -rfid | ||
| 41 | + private Long outTimePzsb;//出场时间 -牌照识别 | ||
| 42 | + | ||
| 43 | + public Long getId() { | ||
| 44 | + return id; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public void setId(Long id) { | ||
| 48 | + this.id = id; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public String getScheduleDateStr() { | ||
| 52 | + return scheduleDateStr; | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public void setScheduleDateStr(String scheduleDateStr) { | ||
| 56 | + this.scheduleDateStr = scheduleDateStr; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public String getLineCode() { | ||
| 60 | + return lineCode; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public void setLineCode(String lineCode) { | ||
| 64 | + this.lineCode = lineCode; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public String getLineName() { | ||
| 68 | + return lineName; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public void setLineName(String lineName) { | ||
| 72 | + this.lineName = lineName; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public String getLpName() { | ||
| 76 | + return lpName; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public void setLpName(String lpName) { | ||
| 80 | + this.lpName = lpName; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public String getNbbm() { | ||
| 84 | + return nbbm; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public void setNbbm(String nbbm) { | ||
| 88 | + this.nbbm = nbbm; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + public String getJsy() { | ||
| 92 | + return jsy; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + public void setJsy(String jsy) { | ||
| 96 | + this.jsy = jsy; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + public String getSpy() { | ||
| 100 | + return spy; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + public void setSpy(String spy) { | ||
| 104 | + this.spy = spy; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + public int getUpDown() { | ||
| 108 | + return upDown; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + public void setUpDown(int upDown) { | ||
| 112 | + this.upDown = upDown; | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + public String getQdzCode() { | ||
| 116 | + return qdzCode; | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + public void setQdzCode(String qdzCode) { | ||
| 120 | + this.qdzCode = qdzCode; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + public String getQdzName() { | ||
| 124 | + return qdzName; | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + public void setQdzName(String qdzName) { | ||
| 128 | + this.qdzName = qdzName; | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + public String getZdzCode() { | ||
| 132 | + return zdzCode; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + public void setZdzCode(String zdzCode) { | ||
| 136 | + this.zdzCode = zdzCode; | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + public String getZdzName() { | ||
| 140 | + return zdzName; | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + public void setZdzName(String zdzName) { | ||
| 144 | + this.zdzName = zdzName; | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + public Long getDfsjT() { | ||
| 148 | + return dfsjT; | ||
| 149 | + } | ||
| 150 | + | ||
| 151 | + public void setDfsjT(Long dfsjT) { | ||
| 152 | + this.dfsjT = dfsjT; | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + public Long getZdsjT() { | ||
| 156 | + return zdsjT; | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + public void setZdsjT(Long zdsjT) { | ||
| 160 | + this.zdsjT = zdsjT; | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + public Long getFcsjActualTime() { | ||
| 164 | + return fcsjActualTime; | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + public void setFcsjActualTime(Long fcsjActualTime) { | ||
| 168 | + this.fcsjActualTime = fcsjActualTime; | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + public Long getZdsjActualTime() { | ||
| 172 | + return zdsjActualTime; | ||
| 173 | + } | ||
| 174 | + | ||
| 175 | + public void setZdsjActualTime(Long zdsjActualTime) { | ||
| 176 | + this.zdsjActualTime = zdsjActualTime; | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + public boolean isSflj() { | ||
| 180 | + return sflj; | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + public void setSflj(boolean sflj) { | ||
| 184 | + this.sflj = sflj; | ||
| 185 | + } | ||
| 186 | + | ||
| 187 | + public String getRemarks() { | ||
| 188 | + return remarks; | ||
| 189 | + } | ||
| 190 | + | ||
| 191 | + public void setRemarks(String remarks) { | ||
| 192 | + this.remarks = remarks; | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + public String getBcType() { | ||
| 196 | + return bcType; | ||
| 197 | + } | ||
| 198 | + | ||
| 199 | + public void setBcType(String bcType) { | ||
| 200 | + this.bcType = bcType; | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + public String getGsbm() { | ||
| 204 | + return gsbm; | ||
| 205 | + } | ||
| 206 | + | ||
| 207 | + public void setGsbm(String gsbm) { | ||
| 208 | + this.gsbm = gsbm; | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + public String getFgsbm() { | ||
| 212 | + return fgsbm; | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + public void setFgsbm(String fgsbm) { | ||
| 216 | + this.fgsbm = fgsbm; | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + public Long getAttJhTime() { | ||
| 220 | + return attJhTime; | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + public void setAttJhTime(Long attJhTime) { | ||
| 224 | + this.attJhTime = attJhTime; | ||
| 225 | + } | ||
| 226 | + | ||
| 227 | + public Long getAttSjTime() { | ||
| 228 | + return attSjTime; | ||
| 229 | + } | ||
| 230 | + | ||
| 231 | + public void setAttSjTime(Long attSjTime) { | ||
| 232 | + this.attSjTime = attSjTime; | ||
| 233 | + } | ||
| 234 | + | ||
| 235 | + public int getStatus() { | ||
| 236 | + return status; | ||
| 237 | + } | ||
| 238 | + | ||
| 239 | + public void setStatus(int status) { | ||
| 240 | + this.status = status; | ||
| 241 | + } | ||
| 242 | + | ||
| 243 | + public Long getUt() { | ||
| 244 | + return ut; | ||
| 245 | + } | ||
| 246 | + | ||
| 247 | + public void setUt(Long ut) { | ||
| 248 | + this.ut = ut; | ||
| 249 | + } | ||
| 250 | + | ||
| 251 | + public String getjGh() { | ||
| 252 | + return jGh; | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + public void setjGh(String jGh) { | ||
| 256 | + this.jGh = jGh; | ||
| 257 | + } | ||
| 258 | + | ||
| 259 | + public Long getOutTimeRfid() { | ||
| 260 | + return outTimeRfid; | ||
| 261 | + } | ||
| 262 | + | ||
| 263 | + public void setOutTimeRfid(Long outTimeRfid) { | ||
| 264 | + this.outTimeRfid = outTimeRfid; | ||
| 265 | + } | ||
| 266 | + | ||
| 267 | + public Long getOutTimePzsb() { | ||
| 268 | + return outTimePzsb; | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + public void setOutTimePzsb(Long outTimePzsb) { | ||
| 272 | + this.outTimePzsb = outTimePzsb; | ||
| 273 | + } | ||
| 274 | +} |
src/main/java/com/bsth/data/schedule/real/InOutScheduleDataBuffer.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/schedule/real/InOutScheduleDataBuffer.java | ||
| 1 | +package com.bsth.data.schedule.real; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.bsth.Application; | ||
| 5 | +import com.bsth.data.basic.line.LineDataBuffer; | ||
| 6 | +import com.bsth.data.schedule.dto.ScheduleInOut; | ||
| 7 | +import com.bsth.data.utils.HttpClientUtils; | ||
| 8 | +import com.bsth.data.utils.RsRequestUtils; | ||
| 9 | +import com.bsth.entity.Line; | ||
| 10 | +import com.bsth.util.ConfigUtil; | ||
| 11 | +import com.google.common.collect.ArrayListMultimap; | ||
| 12 | +import org.slf4j.Logger; | ||
| 13 | +import org.slf4j.LoggerFactory; | ||
| 14 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 15 | +import org.springframework.boot.CommandLineRunner; | ||
| 16 | +import org.springframework.stereotype.Component; | ||
| 17 | + | ||
| 18 | +import java.util.ArrayList; | ||
| 19 | +import java.util.Collection; | ||
| 20 | +import java.util.Collections; | ||
| 21 | +import java.util.List; | ||
| 22 | +import java.util.concurrent.ConcurrentHashMap; | ||
| 23 | +import java.util.concurrent.TimeUnit; | ||
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * 进出场班次数据缓存 | ||
| 27 | + * Created by panzhao on 2017/8/24. | ||
| 28 | + */ | ||
| 29 | +@Component | ||
| 30 | +public class InOutScheduleDataBuffer implements CommandLineRunner { | ||
| 31 | + | ||
| 32 | + private static String tccCode; | ||
| 33 | + private static String dataUrl; | ||
| 34 | + private static ConcurrentHashMap<Long, ScheduleInOut> allMaps; | ||
| 35 | + private static List<ScheduleInOut> outList; | ||
| 36 | + private static List<ScheduleInOut> inList; | ||
| 37 | + //人员映射 k: 公司编码_工号 | ||
| 38 | + private static ArrayListMultimap pMultimap; | ||
| 39 | + //车辆映射 K: 车辆自编号 | ||
| 40 | + private static ArrayListMultimap cMultimap; | ||
| 41 | + //排序器 | ||
| 42 | + static ScheduleComparator schComparator = new ScheduleComparator(); | ||
| 43 | + | ||
| 44 | + static final int SPACE_THRESHOLD = 1000 * 60 * 60 * 2; | ||
| 45 | + | ||
| 46 | + static Logger logger = LoggerFactory.getLogger(InOutScheduleDataBuffer.class); | ||
| 47 | + @Autowired | ||
| 48 | + InoutSchFixedRefreshThread fixedRefreshThread; | ||
| 49 | + | ||
| 50 | + static { | ||
| 51 | + allMaps = new ConcurrentHashMap<>(); | ||
| 52 | + tccCode = ConfigUtil.get("tcc.code"); | ||
| 53 | + dataUrl = ConfigUtil.get("data.schedule.inout.url"); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public static Collection<ScheduleInOut> all() { | ||
| 57 | + return allMaps.values(); | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + public static List<ScheduleInOut> all_out() { | ||
| 61 | + return outList; | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public static List<ScheduleInOut> getOutsByUserId(String company, String jGh){ | ||
| 65 | + return filterOuts(pMultimap.get(company + "-" + jGh)); | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + public static List<ScheduleInOut> getOutsByNbbm(String nbbm){ | ||
| 69 | + return filterOuts(cMultimap.get(nbbm)); | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + private static List<ScheduleInOut> filterOuts(List<ScheduleInOut> list){ | ||
| 73 | + List<ScheduleInOut> rs = new ArrayList<>(); | ||
| 74 | + for(ScheduleInOut sio : list){ | ||
| 75 | + if(sio.getBcType().equals("out")) | ||
| 76 | + rs.add(sio); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + Collections.sort(rs, schComparator); | ||
| 80 | + return rs; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public static List<ScheduleInOut> getByNbbm(String nbbm){ | ||
| 84 | + return cMultimap.get(nbbm); | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + private static void putAll(List<ScheduleInOut> list) { | ||
| 88 | + Long t = System.currentTimeMillis(); | ||
| 89 | + for (ScheduleInOut sio : list) { | ||
| 90 | + sio.setUt(t); | ||
| 91 | + put(sio); | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + //要删除的计划 | ||
| 95 | + removeScheduleInout(t); | ||
| 96 | + //分离进出场 | ||
| 97 | + splitInOutList(); | ||
| 98 | + //人员和车辆映射 | ||
| 99 | + p_c_mapps(); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + private static void put(ScheduleInOut sio) { | ||
| 103 | + if (allMaps.containsKey(sio.getId())) | ||
| 104 | + update(allMaps.get(sio.getId()), sio); | ||
| 105 | + else | ||
| 106 | + allMaps.put(sio.getId(), sio); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + /** | ||
| 110 | + * 分离进出场计划 | ||
| 111 | + */ | ||
| 112 | + private static void splitInOutList() { | ||
| 113 | + List<ScheduleInOut> outListCopy = new ArrayList<>(), | ||
| 114 | + inListCopy = new ArrayList<>(); | ||
| 115 | + | ||
| 116 | + Collection<ScheduleInOut> vs = allMaps.values(); | ||
| 117 | + for (ScheduleInOut sio : vs) { | ||
| 118 | + if (sio.getBcType().equals("out")) | ||
| 119 | + outListCopy.add(sio); | ||
| 120 | + else if (sio.getBcType().equals("in")) | ||
| 121 | + inListCopy.add(sio); | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + outList = outListCopy; | ||
| 125 | + inList = inListCopy; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + /** | ||
| 129 | + * 远端被删除的计划 | ||
| 130 | + * @param ut | ||
| 131 | + */ | ||
| 132 | + private static void removeScheduleInout(long ut) { | ||
| 133 | + Collection<ScheduleInOut> vs = allMaps.values(); | ||
| 134 | + List<ScheduleInOut> rems = new ArrayList<>(); | ||
| 135 | + | ||
| 136 | + for (ScheduleInOut sio : vs) { | ||
| 137 | + if (sio.getUt() < ut) | ||
| 138 | + rems.add(sio); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + for (ScheduleInOut sio : rems) { | ||
| 142 | + allMaps.remove(sio.getId()); | ||
| 143 | + logger.info("删除计划:" + sio.getId()); | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + /** | ||
| 148 | + * 人员,车辆分组的计划 | ||
| 149 | + */ | ||
| 150 | + private static void p_c_mapps() { | ||
| 151 | + //人员和车辆映射 | ||
| 152 | + ArrayListMultimap pMultimapCopy = ArrayListMultimap.create(), | ||
| 153 | + cMultimapCopy = ArrayListMultimap.create(); | ||
| 154 | + | ||
| 155 | + Collection<ScheduleInOut> vs = allMaps.values(); | ||
| 156 | + for (ScheduleInOut sio : vs) { | ||
| 157 | + pMultimapCopy.put(sio.getGsbm() + "-" + sio.getjGh(), sio); | ||
| 158 | + cMultimapCopy.put(sio.getNbbm(), sio); | ||
| 159 | + } | ||
| 160 | + | ||
| 161 | + pMultimap = pMultimapCopy; | ||
| 162 | + cMultimap = cMultimapCopy; | ||
| 163 | + } | ||
| 164 | + | ||
| 165 | + private static void update(ScheduleInOut old, ScheduleInOut now) { | ||
| 166 | + old.setDfsjT(now.getDfsjT()); | ||
| 167 | + old.setZdsjT(now.getZdsjT()); | ||
| 168 | + old.setAttJhTime(now.getAttJhTime()); | ||
| 169 | + old.setUt(now.getUt()); | ||
| 170 | + | ||
| 171 | + boolean isCPerson = !old.getJsy().equals(now.getJsy());//换人 | ||
| 172 | + boolean isCCar = !old.getNbbm().equals(now.getNbbm());//换车 | ||
| 173 | + | ||
| 174 | + if (isCPerson) { | ||
| 175 | + //重新匹配人员计划和实际报到 | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + if (isCCar) { | ||
| 179 | + //重新匹配车辆计划和实际出场 | ||
| 180 | + } | ||
| 181 | + } | ||
| 182 | + | ||
| 183 | + @Override | ||
| 184 | + public void run(String... strings) throws Exception { | ||
| 185 | + Application.mainServices.scheduleWithFixedDelay(fixedRefreshThread, 10, 60 * 5, TimeUnit.SECONDS); | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + /** | ||
| 189 | + * 驾驶员当前要执行的出场计划 | ||
| 190 | + * @param company | ||
| 191 | + * @param userId | ||
| 192 | + * @return | ||
| 193 | + */ | ||
| 194 | + public static ScheduleInOut getCurrExecOut(String company, String userId, Long t) { | ||
| 195 | + return getNearSch(getOutsByUserId(company, userId), t); | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + /** | ||
| 199 | + * 车辆当前要执行的出场计划 | ||
| 200 | + * @param nbbm | ||
| 201 | + * @param t | ||
| 202 | + * @return | ||
| 203 | + */ | ||
| 204 | + public static ScheduleInOut getCurrExecOut(String nbbm, Long t){ | ||
| 205 | + return getNearSch(getOutsByNbbm(nbbm), t); | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + private static ScheduleInOut getNearSch(List<ScheduleInOut> list, Long t){ | ||
| 209 | + List<ScheduleInOut> execs = new ArrayList<>(); | ||
| 210 | + | ||
| 211 | + for(ScheduleInOut sio : list){ | ||
| 212 | + if(Math.abs(t - sio.getDfsjT()) < SPACE_THRESHOLD){ | ||
| 213 | + execs.add(sio); | ||
| 214 | + } | ||
| 215 | + } | ||
| 216 | + | ||
| 217 | + //2小时内多个计划,取当前时间之后最近的一个 | ||
| 218 | + ScheduleInOut rs = null; | ||
| 219 | + for(ScheduleInOut sio : execs){ | ||
| 220 | + rs = sio; | ||
| 221 | + if(sio.getDfsjT() > t) | ||
| 222 | + break; | ||
| 223 | + } | ||
| 224 | + | ||
| 225 | + return rs; | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + @Component | ||
| 229 | + public class InoutSchFixedRefreshThread extends Thread { | ||
| 230 | + | ||
| 231 | + @Override | ||
| 232 | + public void run() { | ||
| 233 | + try { | ||
| 234 | + StringBuilder sb = HttpClientUtils.get(dataUrl + "/in_out/" + tccCode + RsRequestUtils.getParams()); | ||
| 235 | + List<ScheduleInOut> listCopy = JSON.parseArray(sb.toString(), ScheduleInOut.class); | ||
| 236 | + | ||
| 237 | + //排序 | ||
| 238 | + Collections.sort(listCopy, schComparator); | ||
| 239 | + Line line; | ||
| 240 | + for (ScheduleInOut sio : listCopy) { | ||
| 241 | + //进场还是出场 | ||
| 242 | + if (sio.getQdzCode().equals(tccCode)) { | ||
| 243 | + sio.setBcType("out"); | ||
| 244 | + } else if (sio.getZdzCode().equals(tccCode)) | ||
| 245 | + sio.setBcType("in"); | ||
| 246 | + else | ||
| 247 | + sio.setBcType(""); | ||
| 248 | + | ||
| 249 | + //公司编码 | ||
| 250 | + line = LineDataBuffer.get(sio.getLineCode()); | ||
| 251 | + sio.setGsbm(line.getCompany()); | ||
| 252 | + sio.setFgsbm(line.getBrancheCompany()); | ||
| 253 | + try { | ||
| 254 | + //分离驾驶员工号 | ||
| 255 | + String[] jsyArray = sio.getJsy().split("/"); | ||
| 256 | + sio.setjGh(jsyArray[0]); | ||
| 257 | + } catch (Exception e) { | ||
| 258 | + logger.info("计划异常 ID (jsy error...)" + sio.getId()); | ||
| 259 | + } | ||
| 260 | + | ||
| 261 | + //计划报到时间 | ||
| 262 | + sio.setAttJhTime(sio.getDfsjT() - 1000 * 60 * 15); | ||
| 263 | + } | ||
| 264 | + | ||
| 265 | + logger.info("同步进出场班数量 " + listCopy.size()); | ||
| 266 | + InOutScheduleDataBuffer.putAll(listCopy); | ||
| 267 | + | ||
| 268 | + } catch (Exception e) { | ||
| 269 | + e.printStackTrace(); | ||
| 270 | + } | ||
| 271 | + } | ||
| 272 | + } | ||
| 273 | +} |
src/main/java/com/bsth/data/schedule/real/ScheduleComparator.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/schedule/real/ScheduleComparator.java | ||
| 1 | +package com.bsth.data.schedule.real; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.schedule.dto.ScheduleInOut; | ||
| 4 | + | ||
| 5 | +import java.util.Comparator; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * Created by panzhao on 2017/9/4. | ||
| 9 | + */ | ||
| 10 | +public class ScheduleComparator implements Comparator<ScheduleInOut>{ | ||
| 11 | + | ||
| 12 | + @Override | ||
| 13 | + public int compare(ScheduleInOut o1, ScheduleInOut o2) { | ||
| 14 | + return (int) (o1.getDfsjT() - o2.getDfsjT()); | ||
| 15 | + } | ||
| 16 | +} |
src/main/java/com/bsth/data/signal/RFIDInParkDataBuffer.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/signal/RFIDInParkDataBuffer.java | ||
| 1 | +package com.bsth.data.signal; | ||
| 2 | + | ||
| 3 | +import com.bsth.data.signal.dto.RfidInOutDto; | ||
| 4 | +import com.bsth.data.msg_queue.SignalAndAttConsumeQueue; | ||
| 5 | +import com.bsth.entity.ac.CarInOutEntity; | ||
| 6 | +import org.apache.commons.lang3.StringUtils; | ||
| 7 | +import org.slf4j.Logger; | ||
| 8 | +import org.slf4j.LoggerFactory; | ||
| 9 | + | ||
| 10 | +import java.util.LinkedList; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 场内 RFID 数据缓存 | ||
| 14 | + * Created by panzhao on 2017/9/5. | ||
| 15 | + */ | ||
| 16 | +public class RFIDInParkDataBuffer { | ||
| 17 | + | ||
| 18 | + static Logger logger = LoggerFactory.getLogger(RFIDInParkDataBuffer.class); | ||
| 19 | + | ||
| 20 | + private static LinkedList<RfidInOutDto> list; | ||
| 21 | + | ||
| 22 | + static{ | ||
| 23 | + list = new LinkedList<>(); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public static void put(RfidInOutDto rfidInOut){ | ||
| 27 | + if(null == rfidInOut) | ||
| 28 | + return; | ||
| 29 | + if(StringUtils.isEmpty(rfidInOut.getCarCard())) | ||
| 30 | + return; | ||
| 31 | + | ||
| 32 | + if(null == rfidInOut.getReportTime()) | ||
| 33 | + return; | ||
| 34 | + | ||
| 35 | + list.add(rfidInOut); | ||
| 36 | + CarInOutEntity cio = CarInOutEntity.getInstance(rfidInOut); | ||
| 37 | + SignalAndAttConsumeQueue.put(cio); | ||
| 38 | + } | ||
| 39 | +} |
src/main/java/com/bsth/data/signal/dto/RfidInOutDto.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/signal/dto/RfidInOutDto.java | ||
| 1 | +package com.bsth.data.signal.dto; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * rfid 进出场 | ||
| 5 | + * Created by panzhao on 2017/9/6. | ||
| 6 | + */ | ||
| 7 | +public class RfidInOutDto { | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * 人卡号 | ||
| 11 | + */ | ||
| 12 | + private String driverCard; | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 车卡号 | ||
| 16 | + */ | ||
| 17 | + private String carCard; | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 4:出场 2: 进场 | ||
| 21 | + */ | ||
| 22 | + private Integer type; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 进出时间戳 | ||
| 26 | + */ | ||
| 27 | + private Long reportTime; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 出入区域ID | ||
| 31 | + */ | ||
| 32 | + private String areaId; | ||
| 33 | + | ||
| 34 | + public String getDriverCard() { | ||
| 35 | + return driverCard; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public void setDriverCard(String driverCard) { | ||
| 39 | + this.driverCard = driverCard; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public String getCarCard() { | ||
| 43 | + return carCard; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public void setCarCard(String carCard) { | ||
| 47 | + this.carCard = carCard; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public Integer getType() { | ||
| 51 | + return type; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public void setType(Integer type) { | ||
| 55 | + this.type = type; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public Long getReportTime() { | ||
| 59 | + return reportTime; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public void setReportTime(Long reportTime) { | ||
| 63 | + this.reportTime = reportTime; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public String getAreaId() { | ||
| 67 | + return areaId; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public void setAreaId(String areaId) { | ||
| 71 | + this.areaId = areaId; | ||
| 72 | + } | ||
| 73 | +} |
src/main/java/com/bsth/data/signal/thread/SignalPstThread.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/signal/thread/SignalPstThread.java | ||
| 1 | +package com.bsth.data.signal.thread; | ||
| 2 | + | ||
| 3 | +import com.bsth.entity.ac.CarInOutEntity; | ||
| 4 | +import com.bsth.repository.ac.CarInOutRepository; | ||
| 5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 6 | +import org.springframework.stereotype.Component; | ||
| 7 | + | ||
| 8 | +import java.util.ArrayList; | ||
| 9 | +import java.util.LinkedList; | ||
| 10 | +import java.util.List; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * rfid 和 牌照识别进出场数据入库线程 | ||
| 14 | + * Created by panzhao on 2017/9/6. | ||
| 15 | + */ | ||
| 16 | +@Component | ||
| 17 | +public class SignalPstThread extends Thread{ | ||
| 18 | + | ||
| 19 | + @Autowired | ||
| 20 | + CarInOutRepository carInOutRepository; | ||
| 21 | + | ||
| 22 | + public static LinkedList<CarInOutEntity> psts; | ||
| 23 | + | ||
| 24 | + static { | ||
| 25 | + psts = new LinkedList<>(); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + public void run() { | ||
| 30 | + | ||
| 31 | + List<CarInOutEntity> list = new ArrayList<>(); | ||
| 32 | + CarInOutEntity cio; | ||
| 33 | + for(int i = 0; i < 1000; i ++){ | ||
| 34 | + cio = psts.poll(); | ||
| 35 | + if(null == cio) | ||
| 36 | + break; | ||
| 37 | + | ||
| 38 | + list.add(cio); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + carInOutRepository.save(list); | ||
| 42 | + } | ||
| 43 | +} |
src/main/java/com/bsth/data/utils/HttpClientUtils.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/utils/HttpClientUtils.java | ||
| 1 | +package com.bsth.data.utils; | ||
| 2 | + | ||
| 3 | +import org.apache.http.HttpEntity; | ||
| 4 | +import org.apache.http.client.config.RequestConfig; | ||
| 5 | +import org.apache.http.client.methods.CloseableHttpResponse; | ||
| 6 | +import org.apache.http.client.methods.HttpGet; | ||
| 7 | +import org.apache.http.client.methods.HttpPost; | ||
| 8 | +import org.apache.http.entity.StringEntity; | ||
| 9 | +import org.apache.http.impl.client.CloseableHttpClient; | ||
| 10 | +import org.apache.http.impl.client.HttpClients; | ||
| 11 | +import org.slf4j.Logger; | ||
| 12 | +import org.slf4j.LoggerFactory; | ||
| 13 | + | ||
| 14 | +import java.io.BufferedReader; | ||
| 15 | +import java.io.IOException; | ||
| 16 | +import java.io.InputStreamReader; | ||
| 17 | + | ||
| 18 | +/** | ||
| 19 | + * Created by panzhao on 2017/8/2. | ||
| 20 | + */ | ||
| 21 | +public class HttpClientUtils { | ||
| 22 | + | ||
| 23 | + static Logger logger = LoggerFactory.getLogger(HttpClientUtils.class); | ||
| 24 | + | ||
| 25 | + public static StringBuilder get(String url) throws Exception { | ||
| 26 | + CloseableHttpClient httpClient = null; | ||
| 27 | + CloseableHttpResponse response = null; | ||
| 28 | + StringBuilder stringBuffer = null; | ||
| 29 | + try { | ||
| 30 | + httpClient = HttpClients.createDefault(); | ||
| 31 | + HttpGet get = new HttpGet(url); | ||
| 32 | + //超时时间 | ||
| 33 | + RequestConfig requestConfig = RequestConfig.custom() | ||
| 34 | + .setConnectTimeout(4500).setConnectionRequestTimeout(4000) | ||
| 35 | + .setSocketTimeout(4500).build(); | ||
| 36 | + get.setConfig(requestConfig); | ||
| 37 | + get.addHeader("Content-Encoding", "gzip"); | ||
| 38 | + | ||
| 39 | + response = httpClient.execute(get); | ||
| 40 | + stringBuffer = getResult(response.getEntity()); | ||
| 41 | + } catch (Exception e) { | ||
| 42 | + logger.error("", e); | ||
| 43 | + } finally { | ||
| 44 | + if (null != httpClient) | ||
| 45 | + httpClient.close(); | ||
| 46 | + if (null != response) | ||
| 47 | + response.close(); | ||
| 48 | + } | ||
| 49 | + return stringBuffer; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + /** | ||
| 53 | + * raw post data | ||
| 54 | + * @param url | ||
| 55 | + * @param data | ||
| 56 | + * @return | ||
| 57 | + */ | ||
| 58 | + public static StringBuilder post(String url, String data) throws Exception { | ||
| 59 | + CloseableHttpClient httpClient = null; | ||
| 60 | + CloseableHttpResponse response = null; | ||
| 61 | + StringBuilder stringBuffer = null; | ||
| 62 | + try { | ||
| 63 | + httpClient = HttpClients.createDefault(); | ||
| 64 | + HttpPost post = new HttpPost(url); | ||
| 65 | + | ||
| 66 | + post.setHeader("Accept", "application/json"); | ||
| 67 | + post.setHeader("Content-Type", "application/json"); | ||
| 68 | + //超时时间 | ||
| 69 | + RequestConfig requestConfig = RequestConfig.custom() | ||
| 70 | + .setConnectTimeout(2500).setConnectionRequestTimeout(2000) | ||
| 71 | + .setSocketTimeout(3500).build(); | ||
| 72 | + post.setConfig(requestConfig); | ||
| 73 | + post.setEntity((new StringEntity(data, "UTF-8"))); | ||
| 74 | + | ||
| 75 | + response = httpClient.execute(post); | ||
| 76 | + stringBuffer = getResult(response.getEntity()); | ||
| 77 | + } catch (Exception e) { | ||
| 78 | + logger.error("", e); | ||
| 79 | + } finally { | ||
| 80 | + if (null != httpClient) | ||
| 81 | + httpClient.close(); | ||
| 82 | + if (null != response) | ||
| 83 | + response.close(); | ||
| 84 | + } | ||
| 85 | + return stringBuffer; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + private static StringBuilder getResult(HttpEntity entity) throws IOException { | ||
| 89 | + StringBuilder stringBuffer = null; | ||
| 90 | + if (null != entity) { | ||
| 91 | + BufferedReader br = new BufferedReader(new InputStreamReader(entity.getContent())); | ||
| 92 | + stringBuffer = new StringBuilder(); | ||
| 93 | + String str = ""; | ||
| 94 | + while ((str = br.readLine()) != null) | ||
| 95 | + stringBuffer.append(str); | ||
| 96 | + } | ||
| 97 | + return stringBuffer; | ||
| 98 | + } | ||
| 99 | +} |
src/main/java/com/bsth/data/utils/ListFilterUtils.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/utils/ListFilterUtils.java | ||
| 1 | +package com.bsth.data.utils; | ||
| 2 | + | ||
| 3 | +import org.apache.commons.lang3.StringUtils; | ||
| 4 | +import org.slf4j.Logger; | ||
| 5 | +import org.slf4j.LoggerFactory; | ||
| 6 | + | ||
| 7 | +import java.lang.reflect.Field; | ||
| 8 | +import java.util.ArrayList; | ||
| 9 | +import java.util.List; | ||
| 10 | +import java.util.Map; | ||
| 11 | + | ||
| 12 | +/** | ||
| 13 | + * 集合搜索过滤 | ||
| 14 | + * Created by panzhao on 2017/8/2. | ||
| 15 | + */ | ||
| 16 | +public class ListFilterUtils { | ||
| 17 | + | ||
| 18 | + static Logger logger = LoggerFactory.getLogger(ListFilterUtils.class); | ||
| 19 | + | ||
| 20 | + public static List filter(List all, Map<String, Object> map, Class clazz) { | ||
| 21 | + List rs = new ArrayList(); | ||
| 22 | + Field[] fields = clazz.getDeclaredFields(); | ||
| 23 | + | ||
| 24 | + //参与过滤的字段 | ||
| 25 | + List<Field> fs = new ArrayList<>(); | ||
| 26 | + for (Field f : fields) { | ||
| 27 | + f.setAccessible(true); | ||
| 28 | + if (map.containsKey(f.getName())) | ||
| 29 | + fs.add(f); | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + //过滤数据 | ||
| 33 | + for (Object obj : all) { | ||
| 34 | + if (fieldEquals(fs, obj, map)) | ||
| 35 | + rs.add(obj); | ||
| 36 | + } | ||
| 37 | + return rs; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public static boolean fieldEquals(List<Field> fs, Object obj, Map<String, Object> map) { | ||
| 41 | + try { | ||
| 42 | + for (Field f : fs) { | ||
| 43 | + if (StringUtils.isEmpty(map.get(f.getName()).toString())) | ||
| 44 | + continue; | ||
| 45 | + | ||
| 46 | + if (f.get(obj) == null || f.get(obj).toString().indexOf(map.get(f.getName()).toString()) == -1) | ||
| 47 | + return false; | ||
| 48 | + } | ||
| 49 | + } catch (Exception e) { | ||
| 50 | + logger.error("", e); | ||
| 51 | + return false; | ||
| 52 | + } | ||
| 53 | + return true; | ||
| 54 | + } | ||
| 55 | +} |
src/main/java/com/bsth/data/utils/ListPageQueryUtils.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/utils/ListPageQueryUtils.java | ||
| 1 | +package com.bsth.data.utils; | ||
| 2 | + | ||
| 3 | +import java.util.ArrayList; | ||
| 4 | +import java.util.List; | ||
| 5 | + | ||
| 6 | +/** | ||
| 7 | + * 集合分页工具 | ||
| 8 | + * Created by panzhao on 2017/8/2. | ||
| 9 | + */ | ||
| 10 | +public class ListPageQueryUtils { | ||
| 11 | + | ||
| 12 | + public static List paging(List all, int page, int pageSize) { | ||
| 13 | + List rs = new ArrayList(pageSize); | ||
| 14 | + | ||
| 15 | + int s = page * pageSize; | ||
| 16 | + int e = (page + 1) * pageSize; | ||
| 17 | + | ||
| 18 | + int size = all.size(); | ||
| 19 | + | ||
| 20 | + if (e > size) | ||
| 21 | + e = size; | ||
| 22 | + | ||
| 23 | + if (s > size) | ||
| 24 | + return rs; | ||
| 25 | + | ||
| 26 | + for (; s < e; s++) { | ||
| 27 | + rs.add(all.get(s)); | ||
| 28 | + } | ||
| 29 | + return rs; | ||
| 30 | + } | ||
| 31 | +} |
src/main/java/com/bsth/data/utils/RsRequestUtils.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/data/utils/RsRequestUtils.java | ||
| 1 | +package com.bsth.data.utils; | ||
| 2 | + | ||
| 3 | +import com.bsth.util.ConfigUtil; | ||
| 4 | +import org.slf4j.Logger; | ||
| 5 | +import org.slf4j.LoggerFactory; | ||
| 6 | + | ||
| 7 | +import javax.ws.rs.client.WebTarget; | ||
| 8 | +import java.security.MessageDigest; | ||
| 9 | +import java.util.*; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * RS 接口调用工具类 | ||
| 13 | + * Created by panzhao on 2017/8/2. | ||
| 14 | + */ | ||
| 15 | +public class RsRequestUtils { | ||
| 16 | + | ||
| 17 | + private static String password; | ||
| 18 | + | ||
| 19 | + static { | ||
| 20 | + password = ConfigUtil.get("data.password"); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + static Logger logger = LoggerFactory.getLogger(RsRequestUtils.class); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 生成参数字符串 | ||
| 27 | + * @return | ||
| 28 | + */ | ||
| 29 | + public static String getParams(){ | ||
| 30 | + String rs=""; | ||
| 31 | + try { | ||
| 32 | + String nonce = getNonce(6); | ||
| 33 | + long t = System.currentTimeMillis(); | ||
| 34 | + | ||
| 35 | + Map<String, String> map = new HashMap<>(); | ||
| 36 | + map.put("password", password); | ||
| 37 | + map.put("timestamp", t + ""); | ||
| 38 | + map.put("nonce", nonce); | ||
| 39 | + | ||
| 40 | + String sign = getSHA1(map); | ||
| 41 | + | ||
| 42 | + rs = "?password="+password+"×tamp="+t+"&nonce="+nonce+"&sign="+sign; | ||
| 43 | + }catch (Exception e){ | ||
| 44 | + logger.error("", e); | ||
| 45 | + } | ||
| 46 | + return rs; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * 生成参数字符串 | ||
| 51 | + * @return | ||
| 52 | + */ | ||
| 53 | + public static String getParams(Map<String, String> paramMap){ | ||
| 54 | + StringBuilder rs=new StringBuilder("?"); | ||
| 55 | + try { | ||
| 56 | + String nonce = getNonce(6); | ||
| 57 | + long t = System.currentTimeMillis(); | ||
| 58 | + | ||
| 59 | + paramMap.put("password", password); | ||
| 60 | + paramMap.put("timestamp", t + ""); | ||
| 61 | + paramMap.put("nonce", nonce); | ||
| 62 | + | ||
| 63 | + String sign = getSHA1(paramMap); | ||
| 64 | + paramMap.put("sign", sign); | ||
| 65 | + | ||
| 66 | + //rs = "?password="+password+"×tamp="+t+"&nonce="+nonce+"&sign="+sign; | ||
| 67 | + Set<String> ks = paramMap.keySet(); | ||
| 68 | + for(String k : ks){ | ||
| 69 | + rs.append(k + "=" + paramMap.get(k) + "&"); | ||
| 70 | + } | ||
| 71 | + rs.deleteCharAt(rs.length() - 1); | ||
| 72 | + }catch (Exception e){ | ||
| 73 | + logger.error("", e); | ||
| 74 | + } | ||
| 75 | + return rs.toString(); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + /** | ||
| 79 | + * 生成随机字符串 | ||
| 80 | + * @return | ||
| 81 | + */ | ||
| 82 | + public static String getNonce(int length) { | ||
| 83 | + String base = "abcdefghijklmnopqrstuvwxyz0123456789"; | ||
| 84 | + Random random = new Random(); | ||
| 85 | + StringBuffer sb = new StringBuffer(); | ||
| 86 | + for (int i = 0; i < length; i++) { | ||
| 87 | + int number = random.nextInt(base.length()); | ||
| 88 | + sb.append(base.charAt(number)); | ||
| 89 | + } | ||
| 90 | + return sb.toString(); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + private static String getSHA1(Map<String, String> map) throws Exception { | ||
| 94 | + try { | ||
| 95 | + String[] array = new String[map.size()]; | ||
| 96 | + map.values().toArray(array); | ||
| 97 | + StringBuffer sb = new StringBuffer(); | ||
| 98 | + // 字符串排序 | ||
| 99 | + Arrays.sort(array); | ||
| 100 | + for (int i = 0; i < array.length; i++) { | ||
| 101 | + sb.append(array[i]); | ||
| 102 | + } | ||
| 103 | + String str = sb.toString(); | ||
| 104 | + // SHA1签名生成 | ||
| 105 | + MessageDigest md = MessageDigest.getInstance("SHA-1"); | ||
| 106 | + md.update(str.getBytes()); | ||
| 107 | + byte[] digest = md.digest(); | ||
| 108 | + StringBuffer hexstr = new StringBuffer(); | ||
| 109 | + String shaHex = ""; | ||
| 110 | + for (int i = 0; i < digest.length; i++) { | ||
| 111 | + shaHex = Integer.toHexString(digest[i] & 0xFF); | ||
| 112 | + if (shaHex.length() < 2) { | ||
| 113 | + hexstr.append(0); | ||
| 114 | + } | ||
| 115 | + hexstr.append(shaHex); | ||
| 116 | + } | ||
| 117 | + return hexstr.toString(); | ||
| 118 | + } catch (Exception e) { | ||
| 119 | + throw e; | ||
| 120 | + } | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + public static WebTarget addParams(WebTarget wt) { | ||
| 124 | + String rs=""; | ||
| 125 | + try { | ||
| 126 | + String nonce = getNonce(6); | ||
| 127 | + long t = System.currentTimeMillis(); | ||
| 128 | + | ||
| 129 | + Map<String, String> map = new HashMap<>(); | ||
| 130 | + map.put("password", password); | ||
| 131 | + map.put("timestamp", t + ""); | ||
| 132 | + map.put("nonce", nonce); | ||
| 133 | + | ||
| 134 | + String sign = getSHA1(map); | ||
| 135 | + | ||
| 136 | + | ||
| 137 | + wt.queryParam("password", password).queryParam("timestamp", t).queryParam("nonce", nonce).queryParam("sign", sign); | ||
| 138 | + }catch (Exception e){ | ||
| 139 | + logger.error("", e); | ||
| 140 | + } | ||
| 141 | + return wt; | ||
| 142 | + } | ||
| 143 | +} |
src/main/java/com/bsth/entity/Bus.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/entity/Bus.java | ||
| 1 | +package com.bsth.entity; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 公交车 | ||
| 5 | + * Created by panzhao on 2017/8/15. | ||
| 6 | + */ | ||
| 7 | +public class Bus { | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * 公司编码 | ||
| 11 | + */ | ||
| 12 | + private String companyCode; | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 分公司编码 | ||
| 16 | + */ | ||
| 17 | + private String brancheCompanyCode; | ||
| 18 | + | ||
| 19 | + private String lineCode; | ||
| 20 | + | ||
| 21 | + private String lineName; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 内部编码 | ||
| 25 | + */ | ||
| 26 | + private String nbbm; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 车牌号 | ||
| 30 | + */ | ||
| 31 | + private String carPlate; | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 是否电车 | ||
| 35 | + */ | ||
| 36 | + private boolean sfdc; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 是否报废 | ||
| 40 | + */ | ||
| 41 | + private boolean scrapState; | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 车卡ID号(16进制) | ||
| 45 | + */ | ||
| 46 | + private String idRfid; | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 车卡标签号 | ||
| 50 | + */ | ||
| 51 | + private String tagRfid; | ||
| 52 | + | ||
| 53 | + private String remark; | ||
| 54 | + | ||
| 55 | + public String getCompanyCode() { | ||
| 56 | + return companyCode; | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + public void setCompanyCode(String companyCode) { | ||
| 60 | + this.companyCode = companyCode; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + public String getBrancheCompanyCode() { | ||
| 64 | + return brancheCompanyCode; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + public void setBrancheCompanyCode(String brancheCompanyCode) { | ||
| 68 | + this.brancheCompanyCode = brancheCompanyCode; | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + public String getNbbm() { | ||
| 72 | + return nbbm; | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public void setNbbm(String nbbm) { | ||
| 76 | + this.nbbm = nbbm; | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + public String getCarPlate() { | ||
| 80 | + return carPlate; | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + public void setCarPlate(String carPlate) { | ||
| 84 | + this.carPlate = carPlate; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public boolean isSfdc() { | ||
| 88 | + return sfdc; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + public void setSfdc(boolean sfdc) { | ||
| 92 | + this.sfdc = sfdc; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + public boolean isScrapState() { | ||
| 96 | + return scrapState; | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + public void setScrapState(boolean scrapState) { | ||
| 100 | + this.scrapState = scrapState; | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + public String getIdRfid() { | ||
| 104 | + return idRfid; | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + public void setIdRfid(String idRfid) { | ||
| 108 | + this.idRfid = idRfid; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + public String getTagRfid() { | ||
| 112 | + return tagRfid; | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + public void setTagRfid(String tagRfid) { | ||
| 116 | + this.tagRfid = tagRfid; | ||
| 117 | + } | ||
| 118 | + | ||
| 119 | + public String getLineCode() { | ||
| 120 | + return lineCode; | ||
| 121 | + } | ||
| 122 | + | ||
| 123 | + public void setLineCode(String lineCode) { | ||
| 124 | + this.lineCode = lineCode; | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + public String getLineName() { | ||
| 128 | + return lineName; | ||
| 129 | + } | ||
| 130 | + | ||
| 131 | + public void setLineName(String lineName) { | ||
| 132 | + this.lineName = lineName; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + public String getRemark() { | ||
| 136 | + return remark; | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | + public void setRemark(String remark) { | ||
| 140 | + this.remark = remark; | ||
| 141 | + } | ||
| 142 | +} |
src/main/java/com/bsth/entity/BusCard.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/entity/BusCard.java | ||
| 1 | +package com.bsth.entity; | ||
| 2 | + | ||
| 3 | +import javax.persistence.Entity; | ||
| 4 | +import javax.persistence.Id; | ||
| 5 | +import javax.persistence.Table; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 车卡 | ||
| 9 | + * Created by panzhao on 2017/8/21. | ||
| 10 | + */ | ||
| 11 | +@Entity | ||
| 12 | +@Table(name = "bsth_ac_bus_card") | ||
| 13 | +public class BusCard { | ||
| 14 | + | ||
| 15 | + @Id | ||
| 16 | + private String id; | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * 公司编码 | ||
| 20 | + */ | ||
| 21 | + private String companyId; | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 分公司编码 | ||
| 25 | + */ | ||
| 26 | + private String fgsCompanyId; | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 卡标签号 | ||
| 30 | + */ | ||
| 31 | + private String tagRfid; | ||
| 32 | + | ||
| 33 | + /** | ||
| 34 | + * 卡ID号 (16进制) | ||
| 35 | + */ | ||
| 36 | + private String idRfid; | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 录入日期 | ||
| 40 | + */ | ||
| 41 | + private String rq; | ||
| 42 | + | ||
| 43 | + /** | ||
| 44 | + * 绑定的车辆自编号 | ||
| 45 | + */ | ||
| 46 | + private String nbbm; | ||
| 47 | + | ||
| 48 | + /** | ||
| 49 | + * 状态 | ||
| 50 | + * 0:空闲卡 | ||
| 51 | + * 1:已绑定车 | ||
| 52 | + * -1:屏蔽卡 | ||
| 53 | + */ | ||
| 54 | + private int status; | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 备注 | ||
| 58 | + */ | ||
| 59 | + private String remark; | ||
| 60 | + | ||
| 61 | + public String getTagRfid() { | ||
| 62 | + return tagRfid; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void setTagRfid(String tagRfid) { | ||
| 66 | + this.tagRfid = tagRfid; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public String getIdRfid() { | ||
| 70 | + return idRfid; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public void setIdRfid(String idRfid) { | ||
| 74 | + this.idRfid = idRfid; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public String getRemark() { | ||
| 78 | + return remark; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public void setRemark(String remark) { | ||
| 82 | + this.remark = remark; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public String getRq() { | ||
| 86 | + return rq; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public void setRq(String rq) { | ||
| 90 | + this.rq = rq; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + public String getNbbm() { | ||
| 94 | + return nbbm; | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + public void setNbbm(String nbbm) { | ||
| 98 | + this.nbbm = nbbm; | ||
| 99 | + } | ||
| 100 | + | ||
| 101 | + public int getStatus() { | ||
| 102 | + return status; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public void setStatus(int status) { | ||
| 106 | + this.status = status; | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public String getCompanyId() { | ||
| 110 | + return companyId; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public void setCompanyId(String companyId) { | ||
| 114 | + this.companyId = companyId; | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + public String getFgsCompanyId() { | ||
| 118 | + return fgsCompanyId; | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public void setFgsCompanyId(String fgsCompanyId) { | ||
| 122 | + this.fgsCompanyId = fgsCompanyId; | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + public String getId() { | ||
| 126 | + return id; | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + public void setId(String id) { | ||
| 130 | + this.id = id; | ||
| 131 | + } | ||
| 132 | +} |
src/main/java/com/bsth/entity/Car.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/entity/Car.java | ||
| 1 | +package com.bsth.entity; | ||
| 2 | + | ||
| 3 | +import javax.persistence.Entity; | ||
| 4 | +import javax.persistence.GeneratedValue; | ||
| 5 | +import javax.persistence.Id; | ||
| 6 | +import javax.persistence.Table; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 小车, 私家车 | ||
| 10 | + * Created by panzhao on 2017/8/19. | ||
| 11 | + */ | ||
| 12 | +@Entity | ||
| 13 | +@Table(name = "bsth_ac_car") | ||
| 14 | +public class Car { | ||
| 15 | + | ||
| 16 | + @Id | ||
| 17 | + @GeneratedValue | ||
| 18 | + private Integer id; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * 车牌号 | ||
| 22 | + */ | ||
| 23 | + private String plateNo; | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 车主姓名 | ||
| 27 | + */ | ||
| 28 | + private String carOwnerName; | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 部门,所属机构 | ||
| 32 | + */ | ||
| 33 | + private String department; | ||
| 34 | + | ||
| 35 | + /** | ||
| 36 | + * 联系电话 | ||
| 37 | + */ | ||
| 38 | + private String phone; | ||
| 39 | + | ||
| 40 | + /** | ||
| 41 | + * 备注 | ||
| 42 | + */ | ||
| 43 | + private String remark; | ||
| 44 | + | ||
| 45 | + public Integer getId() { | ||
| 46 | + return id; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void setId(Integer id) { | ||
| 50 | + this.id = id; | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + public String getPlateNo() { | ||
| 54 | + return plateNo; | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + public void setPlateNo(String plateNo) { | ||
| 58 | + this.plateNo = plateNo; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + public String getCarOwnerName() { | ||
| 62 | + return carOwnerName; | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + public void setCarOwnerName(String carOwnerName) { | ||
| 66 | + this.carOwnerName = carOwnerName; | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + public String getDepartment() { | ||
| 70 | + return department; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + public void setDepartment(String department) { | ||
| 74 | + this.department = department; | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + public String getPhone() { | ||
| 78 | + return phone; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public void setPhone(String phone) { | ||
| 82 | + this.phone = phone; | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public String getRemark() { | ||
| 86 | + return remark; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + public void setRemark(String remark) { | ||
| 90 | + this.remark = remark; | ||
| 91 | + } | ||
| 92 | +} |
src/main/java/com/bsth/entity/Line.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/entity/Line.java | ||
| 1 | +package com.bsth.entity; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * Created by panzhao on 2017/8/4. | ||
| 5 | + */ | ||
| 6 | +public class Line { | ||
| 7 | + | ||
| 8 | + /** 线路编码 */ | ||
| 9 | + private String lineCode; | ||
| 10 | + | ||
| 11 | + /** 线路名称 */ | ||
| 12 | + private String name; | ||
| 13 | + | ||
| 14 | + /** 起始站名称 */ | ||
| 15 | + private String startStationName; | ||
| 16 | + | ||
| 17 | + /** 终点站名称 */ | ||
| 18 | + private String endStationName; | ||
| 19 | + | ||
| 20 | + /** 公司编码 */ | ||
| 21 | + private String company; | ||
| 22 | + | ||
| 23 | + /** 分公司编码 */ | ||
| 24 | + private String brancheCompany; | ||
| 25 | + | ||
| 26 | + public String getLineCode() { | ||
| 27 | + return lineCode; | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public void setLineCode(String lineCode) { | ||
| 31 | + this.lineCode = lineCode; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public String getName() { | ||
| 35 | + return name; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public void setName(String name) { | ||
| 39 | + this.name = name; | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public String getStartStationName() { | ||
| 43 | + return startStationName; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public void setStartStationName(String startStationName) { | ||
| 47 | + this.startStationName = startStationName; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public String getEndStationName() { | ||
| 51 | + return endStationName; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public void setEndStationName(String endStationName) { | ||
| 55 | + this.endStationName = endStationName; | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public String getCompany() { | ||
| 59 | + return company; | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public void setCompany(String company) { | ||
| 63 | + this.company = company; | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public String getBrancheCompany() { | ||
| 67 | + return brancheCompany; | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public void setBrancheCompany(String brancheCompany) { | ||
| 71 | + this.brancheCompany = brancheCompany; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | +} |
src/main/java/com/bsth/entity/Person.java
0 → 100644
| 1 | +++ a/src/main/java/com/bsth/entity/Person.java | ||
| 1 | +package com.bsth.entity; | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * 人员信息 | ||
| 5 | + * Created by panzhao on 2017/8/1. | ||
| 6 | + */ | ||
| 7 | +public class Person { | ||
| 8 | + | ||
| 9 | + /** | ||
| 10 | + * 工号 | ||
| 11 | + */ | ||
| 12 | + private String jobCode; | ||
| 13 | + | ||
| 14 | + /** | ||
| 15 | + * 公司编码 | ||
| 16 | + */ | ||
| 17 | + private String companyCode; | ||
| 18 | + | ||
| 19 | + /** | ||
| 20 | + * 分公司编码 | ||
| 21 | + */ | ||
| 22 | + private String brancheCompanyCode; | ||
| 23 | + | ||
| 24 | + /** | ||
| 25 | + * 姓名 | ||
| 26 | + */ | ||
| 27 | + private String personnelName; | ||
| 28 | + | ||
| 29 | + /** | ||
| 30 | + * 运营服务证书号 | ||
| 31 | + */ | ||
| 32 | + private String papersCode; | ||
| 33 | + | ||
| 34 | + /** | ||
| 35 | + * 一卡通工作卡号 | ||
| 36 | + */ | ||
| 37 | + private String icCardCode; | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 性别 | ||
| 41 | + */ | ||
| 42 | + private String personnelType; | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * 所属岗位/工种 | ||
| 46 | + */ | ||
| 47 | + private String posts; | ||
| 48 | + | ||
| 49 | + /** | ||
| 50 | + * 身份证 | ||
| 51 | + */ | ||
| 52 | + private String card; | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 联系电话 | ||
| 56 | + */ | ||
| 57 | + private String telphone; | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * signal 人卡IC号 | ||
| 61 | + */ | ||
| 62 | + private String icRfid; | ||
| 63 | + | ||
| 64 | + /** | ||
| 65 | + * signal 人卡ID号 | ||
| 66 | + */ | ||
| 67 | + private String idRfid; | ||
| 68 | + | ||
| 69 | + /** | ||
| 70 | + * signal 标签号 | ||
| 71 | + */ | ||
| 72 | + private String tagRfid; | ||
| 73 | + | ||
| 74 | + private String lineCode; | ||
| 75 | + | ||
| 76 | + private String lineName; | ||
| 77 | + | ||
| 78 | + private String remark; | ||
| 79 | + | ||
| 80 | + public String getJobCode() { | ||
| 81 | + return jobCode; | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + public String getUserId() { | ||
| 85 | + return jobCode.split("-")[1]; | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + public void setJobCode(String jobCode) { | ||
| 89 | + this.jobCode = jobCode; | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + public String getCompanyCode() { | ||
| 93 | + return companyCode; | ||
| 94 | + } | ||
| 95 | + | ||
| 96 | + public void setCompanyCode(String companyCode) { | ||
| 97 | + this.companyCode = companyCode; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + public String getBrancheCompanyCode() { | ||
| 101 | + return brancheCompanyCode; | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public void setBrancheCompanyCode(String brancheCompanyCode) { | ||
| 105 | + this.brancheCompanyCode = brancheCompanyCode; | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public String getPersonnelName() { | ||
| 109 | + return personnelName; | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + public void setPersonnelName(String personnelName) { | ||
| 113 | + this.personnelName = personnelName; | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + public String getPapersCode() { | ||
| 117 | + return papersCode; | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public void setPapersCode(String papersCode) { | ||
| 121 | + this.papersCode = papersCode; | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + public String getIcCardCode() { | ||
| 125 | + return icCardCode; | ||
| 126 | + } | ||
| 127 | + | ||
| 128 | + public void setIcCardCode(String icCardCode) { | ||
| 129 | + this.icCardCode = icCardCode; | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + public String getPersonnelType() { | ||
| 133 | + return personnelType; | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + public void setPersonnelType(String personnelType) { | ||
| 137 | + this.personnelType = personnelType; | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + public String getPosts() { | ||
| 141 | + return posts; | ||
| 142 | + } | ||
| 143 | + | ||
| 144 | + public void setPosts(String posts) { | ||
| 145 | + this.posts = posts; | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + public String getCard() { | ||
| 149 | + return card; | ||
| 150 | + } | ||
| 151 | + | ||
| 152 | + public void setCard(String card) { | ||
| 153 | + this.card = card; | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + public String getTelphone() { | ||
| 157 | + return telphone; | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + public void setTelphone(String telphone) { | ||
| 161 | + this.telphone = telphone; | ||
| 162 | + } | ||
| 163 | + | ||
| 164 | + public String getIcRfid() { | ||
| 165 | + return icRfid; | ||
| 166 | + } | ||
| 167 | + | ||
| 168 | + public void setIcRfid(String icRfid) { | ||
| 169 | + this.icRfid = icRfid; | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + public String getIdRfid() { | ||
| 173 | + return idRfid; | ||
| 174 | + } | ||
| 175 | + | ||
| 176 | + public void setIdRfid(String idRfid) { | ||
| 177 | + this.idRfid = idRfid; | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + public String getTagRfid() { | ||
| 181 | + return tagRfid; | ||
| 182 | + } | ||
| 183 | + | ||
| 184 | + public void setTagRfid(String tagRfid) { | ||
| 185 | + this.tagRfid = tagRfid; | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + public String getLineName() { | ||
| 189 | + return lineName; | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + public void setLineName(String lineName) { | ||
| 193 | + this.lineName = lineName; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + public String getLineCode() { | ||
| 197 | + return lineCode; | ||
| 198 | + } | ||
| 199 | + | ||
| 200 | + public void setLineCode(String lineCode) { | ||
| 201 | + this.lineCode = lineCode; | ||
| 202 | + } | ||
| 203 | + | ||
| 204 | + @Override | ||
| 205 | + public int hashCode() { | ||
| 206 | + return this.toString().hashCode(); | ||
| 207 | + } | ||
| 208 | + | ||
| 209 | + @Override | ||
| 210 | + public boolean equals(Object obj) { | ||
| 211 | + return this.toString().equals(((Person)obj).toString()); | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + @Override | ||
| 215 | + public String toString() { | ||
| 216 | + return this.companyCode+"_"+this.brancheCompanyCode+"_"+this.jobCode; | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + public String getRemark() { | ||
| 220 | + return remark; | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + public void setRemark(String remark) { | ||
| 224 | + this.remark = remark; | ||
| 225 | + } | ||
| 226 | +} |