Commit 5126dc57a94004e4e36ab626811a65b7c8e8b97f
1 parent
8c31d70a
1.JDK升级,springboot升级到2
Showing
12 changed files
with
2379 additions
and
2383 deletions
Too many changes to show.
To preserve performance only 12 of 72 files are displayed.
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>bsth_control</artifactId> | |
| 7 | - <version>0.0.1-SNAPSHOT</version> | |
| 8 | - <packaging>war</packaging> | |
| 9 | - | |
| 10 | - <parent> | |
| 11 | - <groupId>org.springframework.boot</groupId> | |
| 12 | - <artifactId>spring-boot-starter-parent</artifactId> | |
| 13 | - <version>1.3.3.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-redis</artifactId> | |
| 55 | - </dependency> | |
| 56 | - <dependency> | |
| 57 | - <groupId>org.springframework.boot</groupId> | |
| 58 | - <artifactId>spring-boot-starter-websocket</artifactId> | |
| 59 | - </dependency> | |
| 60 | - <dependency> | |
| 61 | - <groupId>mysql</groupId> | |
| 62 | - <artifactId>mysql-connector-java</artifactId> | |
| 63 | - </dependency> | |
| 64 | - | |
| 65 | - <dependency> | |
| 66 | - <groupId>joda-time</groupId> | |
| 67 | - <artifactId>joda-time</artifactId> | |
| 68 | - </dependency> | |
| 69 | - <dependency> | |
| 70 | - <groupId>com.alibaba</groupId> | |
| 71 | - <artifactId>fastjson</artifactId> | |
| 72 | - <version>1.2.4</version> | |
| 73 | - </dependency> | |
| 74 | - | |
| 75 | - <dependency> | |
| 76 | - <groupId>org.apache.httpcomponents</groupId> | |
| 77 | - <artifactId>httpclient</artifactId> | |
| 78 | - </dependency> | |
| 79 | - | |
| 80 | - <dependency> | |
| 81 | - <groupId>commons-dbcp</groupId> | |
| 82 | - <artifactId>commons-dbcp</artifactId> | |
| 83 | - </dependency> | |
| 84 | - <dependency> | |
| 85 | - <groupId>commons-lang</groupId> | |
| 86 | - <artifactId>commons-lang</artifactId> | |
| 87 | - <version>2.6</version> | |
| 88 | - </dependency> | |
| 89 | - <dependency> | |
| 90 | - <groupId>org.apache.commons</groupId> | |
| 91 | - <artifactId>commons-lang3</artifactId> | |
| 92 | - <version>3.4</version> | |
| 93 | - </dependency> | |
| 94 | - <dependency> | |
| 95 | - <groupId>commons-fileupload</groupId> | |
| 96 | - <artifactId>commons-fileupload</artifactId> | |
| 97 | - <version>1.2.2</version> | |
| 98 | - </dependency> | |
| 99 | - <dependency> | |
| 100 | - <groupId>commons-io</groupId> | |
| 101 | - <artifactId>commons-io</artifactId> | |
| 102 | - <version>2.4</version> | |
| 103 | - </dependency> | |
| 104 | - <dependency> | |
| 105 | - <groupId>org.codehaus.janino</groupId> | |
| 106 | - <artifactId>janino</artifactId> | |
| 107 | - </dependency> | |
| 108 | - | |
| 109 | - <dependency> | |
| 110 | - <groupId>org.apache.poi</groupId> | |
| 111 | - <artifactId>poi-ooxml</artifactId> | |
| 112 | - <version>3.13</version> | |
| 113 | - </dependency> | |
| 114 | - | |
| 115 | - <dependency> | |
| 116 | - <groupId>com.google.guava</groupId> | |
| 117 | - <artifactId>guava</artifactId> | |
| 118 | - <version>19.0</version> | |
| 119 | - </dependency> | |
| 120 | - <!-- ftp文件上传包 --> | |
| 121 | - <dependency> | |
| 122 | - <groupId>commons-net</groupId> | |
| 123 | - <artifactId>commons-net</artifactId> | |
| 124 | - <version>3.5</version> | |
| 125 | - </dependency> | |
| 126 | - <dependency> | |
| 127 | - <groupId>org.apache.commons</groupId> | |
| 128 | - <artifactId>commons-compress</artifactId> | |
| 129 | - <version>1.3</version> | |
| 130 | - </dependency> | |
| 131 | - <!-- drools 6依赖 --> | |
| 132 | - <dependency> | |
| 133 | - <groupId>org.kie</groupId> | |
| 134 | - <artifactId>kie-api</artifactId> | |
| 135 | - </dependency> | |
| 136 | - <dependency> | |
| 137 | - <groupId>org.drools</groupId> | |
| 138 | - <artifactId>drools-compiler</artifactId> | |
| 139 | - </dependency> | |
| 140 | - | |
| 141 | - <!-- springboot测试 --> | |
| 142 | - <dependency> | |
| 143 | - <groupId>org.springframework.boot</groupId> | |
| 144 | - <artifactId>spring-boot-starter-test</artifactId> | |
| 145 | - <scope>test</scope> | |
| 146 | - </dependency> | |
| 147 | - | |
| 148 | - <dependency> | |
| 149 | - <groupId>c3p0</groupId> | |
| 150 | - <artifactId>c3p0</artifactId> | |
| 151 | - <version>0.9.1.2</version> | |
| 152 | - </dependency> | |
| 153 | - | |
| 154 | - <!-- 图表 --> | |
| 155 | - <dependency> | |
| 156 | - <groupId>com.google.code.gson</groupId> | |
| 157 | - <artifactId>gson</artifactId> | |
| 158 | - <version>2.2.4</version> | |
| 159 | - </dependency> | |
| 160 | - <dependency> | |
| 161 | - <groupId>com.github.abel533</groupId> | |
| 162 | - <artifactId>ECharts</artifactId> | |
| 163 | - <version>2.1.8</version> | |
| 164 | - </dependency> | |
| 165 | - | |
| 166 | - <dependency> | |
| 167 | - <groupId>org.apache.tika</groupId> | |
| 168 | - <artifactId>tika-core</artifactId> | |
| 169 | - <version>1.7</version> | |
| 170 | - </dependency> | |
| 171 | - | |
| 172 | - <!-- pentaho kettle 依赖 --> | |
| 173 | - <dependency> | |
| 174 | - <groupId>com.pentaho.kettle</groupId> | |
| 175 | - <artifactId>kettle-core</artifactId> | |
| 176 | - <version>6.0.1.0-386</version> | |
| 177 | - </dependency> | |
| 178 | - <dependency> | |
| 179 | - <groupId>com.pentaho.kettle</groupId> | |
| 180 | - <artifactId>kettle-engine</artifactId> | |
| 181 | - <version>6.0.1.0-386</version> | |
| 182 | - </dependency> | |
| 183 | - <dependency> | |
| 184 | - <groupId>com.pentaho.kettle</groupId> | |
| 185 | - <artifactId>metastore</artifactId> | |
| 186 | - <version>6.0.1.0-386</version> | |
| 187 | - </dependency> | |
| 188 | - <dependency> | |
| 189 | - <groupId>com.pentaho.kettle</groupId> | |
| 190 | - <artifactId>vfs2</artifactId> | |
| 191 | - <version>2.1-20150824</version> | |
| 192 | - </dependency> | |
| 193 | - <dependency> | |
| 194 | - <groupId>net.sourceforge.jexcelapi</groupId> | |
| 195 | - <artifactId>jxl</artifactId> | |
| 196 | - <version>2.6.12</version> | |
| 197 | - <exclusions> | |
| 198 | - <exclusion> | |
| 199 | - <groupId>log4j</groupId> | |
| 200 | - <artifactId>log4j</artifactId> | |
| 201 | - </exclusion> | |
| 202 | - </exclusions> | |
| 203 | - </dependency> | |
| 204 | - <dependency> | |
| 205 | - <groupId>rhino</groupId> | |
| 206 | - <artifactId>js</artifactId> | |
| 207 | - <version>1.7R2</version> | |
| 208 | - </dependency> | |
| 209 | - <dependency> | |
| 210 | - <groupId>javax.mail</groupId> | |
| 211 | - <artifactId>mail</artifactId> | |
| 212 | - <version>1.4.7</version> | |
| 213 | - </dependency> | |
| 214 | - | |
| 215 | - <dependency> | |
| 216 | - <groupId>com.github.axet</groupId> | |
| 217 | - <artifactId>kaptcha</artifactId> | |
| 218 | - <version>0.0.9</version> | |
| 219 | - </dependency> | |
| 220 | - | |
| 221 | - <dependency> | |
| 222 | - <groupId>commons-codec</groupId> | |
| 223 | - <artifactId>commons-codec</artifactId> | |
| 224 | - <version>1.4</version> | |
| 225 | - <scope>compile</scope> | |
| 226 | - </dependency> | |
| 227 | - <dependency> | |
| 228 | - <groupId>org.bouncycastle</groupId> | |
| 229 | - <artifactId>bcprov-jdk15on</artifactId> | |
| 230 | - <version>1.52</version> | |
| 231 | - </dependency> | |
| 232 | - <dependency> | |
| 233 | - <groupId>axis</groupId> | |
| 234 | - <artifactId>axis</artifactId> | |
| 235 | - <version>1.4</version> | |
| 236 | - </dependency> | |
| 237 | - <dependency> | |
| 238 | - <groupId>javax.xml</groupId> | |
| 239 | - <artifactId>jaxrpc-api</artifactId> | |
| 240 | - <version>1.1</version> | |
| 241 | - </dependency> | |
| 242 | - | |
| 243 | - <dependency> | |
| 244 | - <groupId>org.apache.axis2</groupId> | |
| 245 | - <artifactId>axis2-adb</artifactId> | |
| 246 | - <version>1.7.4</version> | |
| 247 | - </dependency> | |
| 248 | - <dependency> | |
| 249 | - <groupId>org.apache.axis2</groupId> | |
| 250 | - <artifactId>axis2-transport-local</artifactId> | |
| 251 | - <version>1.7.4</version> | |
| 252 | - </dependency> | |
| 253 | - <dependency> | |
| 254 | - <groupId>org.apache.axis2</groupId> | |
| 255 | - <artifactId>axis2-transport-http</artifactId> | |
| 256 | - <version>1.7.4</version> | |
| 257 | - </dependency> | |
| 258 | - | |
| 259 | - <dependency> | |
| 260 | - <groupId>org.dbunit</groupId> | |
| 261 | - <artifactId>dbunit</artifactId> | |
| 262 | - <version>2.4.9</version> | |
| 263 | - <scope>test</scope> | |
| 264 | - | |
| 265 | - <exclusions> | |
| 266 | - <exclusion> | |
| 267 | - <groupId>org.slf4j</groupId> | |
| 268 | - <artifactId>slf4j-api</artifactId> | |
| 269 | - </exclusion> | |
| 270 | - </exclusions> | |
| 271 | - </dependency> | |
| 272 | - | |
| 273 | - <dependency> | |
| 274 | - <groupId>com.h2database</groupId> | |
| 275 | - <artifactId>h2</artifactId> | |
| 276 | - <version>1.2.132</version> | |
| 277 | - <scope>test</scope> | |
| 278 | - </dependency> | |
| 279 | - | |
| 280 | - | |
| 281 | - <dependency> | |
| 282 | - <groupId>ojdbc</groupId> | |
| 283 | - <artifactId>ojdbc</artifactId> | |
| 284 | - <version>14</version> | |
| 285 | - </dependency> | |
| 286 | - | |
| 287 | - <dependency> | |
| 288 | - <groupId>org.apache.mina</groupId> | |
| 289 | - <artifactId>mina-core</artifactId> | |
| 290 | - <version>2.0.13</version> | |
| 291 | - </dependency> | |
| 292 | - | |
| 293 | - <dependency> | |
| 294 | - <groupId>com.google.protobuf</groupId> | |
| 295 | - <artifactId>protobuf-java</artifactId> | |
| 296 | - <version>3.3.0</version> | |
| 297 | - </dependency> | |
| 298 | - | |
| 299 | - <dependency> | |
| 300 | - <groupId>com.github.stuxuhai</groupId> | |
| 301 | - <artifactId>jpinyin</artifactId> | |
| 302 | - <version>1.1.8</version> | |
| 303 | - </dependency> | |
| 304 | - | |
| 305 | - <!-- dubbo 需要的jar start --> | |
| 306 | - <dependency> | |
| 307 | - <groupId>com.alibaba</groupId> | |
| 308 | - <artifactId>dubbo</artifactId> | |
| 309 | - <!--<version>2.6.3</version>--> | |
| 310 | - <version>2.5.3</version> | |
| 311 | - <exclusions> | |
| 312 | - <exclusion> | |
| 313 | - <groupId>org.springframework</groupId> | |
| 314 | - <artifactId>spring</artifactId> | |
| 315 | - </exclusion> | |
| 316 | - <exclusion> | |
| 317 | - <groupId>log4j</groupId> | |
| 318 | - <artifactId>log4j</artifactId> | |
| 319 | - </exclusion> | |
| 320 | - </exclusions> | |
| 321 | - </dependency> | |
| 322 | - | |
| 323 | - <dependency> | |
| 324 | - <groupId>org.apache.zookeeper</groupId> | |
| 325 | - <artifactId>zookeeper</artifactId> | |
| 326 | - <version>3.4.5</version> | |
| 327 | - <exclusions> | |
| 328 | - <exclusion> | |
| 329 | - <groupId>log4j</groupId> | |
| 330 | - <artifactId>log4j</artifactId> | |
| 331 | - </exclusion> | |
| 332 | - <exclusion> | |
| 333 | - <groupId>org.slf4j</groupId> | |
| 334 | - <artifactId>slf4j-log4j12</artifactId> | |
| 335 | - </exclusion> | |
| 336 | - </exclusions> | |
| 337 | - </dependency> | |
| 338 | - | |
| 339 | - <dependency> | |
| 340 | - <groupId>com.101tec</groupId> | |
| 341 | - <artifactId>zkclient</artifactId> | |
| 342 | - <version>0.3</version> | |
| 343 | - <exclusions> | |
| 344 | - <exclusion> | |
| 345 | - <groupId>log4j</groupId> | |
| 346 | - <artifactId>log4j</artifactId> | |
| 347 | - </exclusion> | |
| 348 | - </exclusions> | |
| 349 | - </dependency> | |
| 350 | - | |
| 351 | - <!-- plan common工程依赖 --> | |
| 352 | - <dependency> | |
| 353 | - <groupId>com.bsth.control_v2</groupId> | |
| 354 | - <artifactId>plan_module-common</artifactId> | |
| 355 | - <version>1.0-SNAPSHOT</version> | |
| 356 | - </dependency> | |
| 357 | - <!-- plan common config 工程依赖 --> | |
| 358 | - <dependency> | |
| 359 | - <groupId>com.bsth.control_v2</groupId> | |
| 360 | - <artifactId>plan_module-common-config</artifactId> | |
| 361 | - <version>1.0-SNAPSHOT</version> | |
| 362 | - </dependency> | |
| 363 | - <dependency> | |
| 364 | - <groupId>org.slf4j</groupId> | |
| 365 | - <artifactId>slf4j-api</artifactId> | |
| 366 | - <version>1.7.7</version> | |
| 367 | - </dependency> | |
| 368 | - <dependency> | |
| 369 | - <groupId>ch.qos.logback</groupId> | |
| 370 | - <artifactId>logback-classic</artifactId> | |
| 371 | - <version>1.1.3</version> | |
| 372 | - </dependency> | |
| 373 | - <dependency> | |
| 374 | - <groupId>org.slf4j</groupId> | |
| 375 | - <artifactId>log4j-over-slf4j</artifactId> | |
| 376 | - <version>1.7.7</version> | |
| 377 | - </dependency> | |
| 378 | - | |
| 379 | - <!-- web服务依赖 --> | |
| 380 | - <dependency> | |
| 381 | - <groupId>org.springframework.boot</groupId> | |
| 382 | - <artifactId>spring-boot-starter-ws</artifactId> | |
| 383 | - </dependency> | |
| 384 | - <dependency> | |
| 385 | - <groupId>wsdl4j</groupId> | |
| 386 | - <artifactId>wsdl4j</artifactId> | |
| 387 | - </dependency> | |
| 388 | - | |
| 389 | - </dependencies> | |
| 390 | - | |
| 391 | - <dependencyManagement> | |
| 392 | - <dependencies> | |
| 393 | - <!-- drools 6依赖 --> | |
| 394 | - <dependency> | |
| 395 | - <groupId>org.drools</groupId> | |
| 396 | - <artifactId>drools-bom</artifactId> | |
| 397 | - <type>pom</type> | |
| 398 | - <version>6.3.0.Final</version> | |
| 399 | - <scope>import</scope> | |
| 400 | - </dependency> | |
| 401 | - </dependencies> | |
| 402 | - </dependencyManagement> | |
| 403 | - | |
| 404 | - <build> | |
| 405 | - <plugins> | |
| 406 | - <plugin> | |
| 407 | - <artifactId>maven-compiler-plugin</artifactId> | |
| 408 | - <version>2.3.2</version><!--$NO-MVN-MAN-VER$ --> | |
| 409 | - <configuration> | |
| 410 | - <source>1.7</source> | |
| 411 | - <target>1.7</target> | |
| 412 | - </configuration> | |
| 413 | - </plugin> | |
| 414 | - <plugin> | |
| 415 | - <artifactId>maven-war-plugin</artifactId> | |
| 416 | - <version>2.2</version><!--$NO-MVN-MAN-VER$ --> | |
| 417 | - <configuration> | |
| 418 | - <failOnMissingWebXml>false</failOnMissingWebXml> | |
| 419 | - </configuration> | |
| 420 | - </plugin> | |
| 421 | - <plugin> | |
| 422 | - <groupId>org.springframework.boot</groupId> | |
| 423 | - <artifactId>spring-boot-maven-plugin</artifactId> | |
| 424 | - </plugin> | |
| 425 | - <plugin> | |
| 426 | - <groupId>org.codehaus.mojo</groupId> | |
| 427 | - <artifactId>jaxb2-maven-plugin</artifactId> | |
| 428 | - <version>1.6</version> | |
| 429 | - <executions> | |
| 430 | - <execution> | |
| 431 | - <id>xjc</id> | |
| 432 | - <phase>none</phase> | |
| 433 | - <goals> | |
| 434 | - <goal>xjc</goal> | |
| 435 | - </goals> | |
| 436 | - </execution> | |
| 437 | - </executions> | |
| 438 | - <configuration> | |
| 439 | - <schemaDirectory>${project.basedir}/src/main/resources/xsd/</schemaDirectory> | |
| 440 | - <outputDirectory>${project.basedir}/src/main/java</outputDirectory> | |
| 441 | - <clearOutputDir>false</clearOutputDir> | |
| 442 | - <encoding>utf-8</encoding> | |
| 443 | - </configuration> | |
| 444 | - </plugin> | |
| 445 | - </plugins> | |
| 446 | - <resources> | |
| 447 | - <resource> | |
| 448 | - <directory>src/main/resources</directory> | |
| 449 | - <filtering>false</filtering> | |
| 450 | - </resource> | |
| 451 | - </resources> | |
| 452 | - </build> | |
| 453 | - <repositories> | |
| 454 | - <repository> | |
| 455 | - <id>spring-snapshots</id> | |
| 456 | - <url>http://repo.spring.io/snapshot</url> | |
| 457 | - <snapshots> | |
| 458 | - <enabled>true</enabled> | |
| 459 | - </snapshots> | |
| 460 | - </repository> | |
| 461 | - <repository> | |
| 462 | - <id>spring-milestones</id> | |
| 463 | - <url>http://repo.spring.io/milestone</url> | |
| 464 | - </repository> | |
| 465 | - </repositories> | |
| 466 | - <pluginRepositories> | |
| 467 | - <pluginRepository> | |
| 468 | - <id>spring-snapshots</id> | |
| 469 | - <url>http://repo.spring.io/snapshot</url> | |
| 470 | - </pluginRepository> | |
| 471 | - <pluginRepository> | |
| 472 | - <id>spring-milestones</id> | |
| 473 | - <url>http://repo.spring.io/milestone</url> | |
| 474 | - </pluginRepository> | |
| 475 | - </pluginRepositories> | |
| 476 | - | |
| 477 | - <properties> | |
| 478 | - <start-class>com.bsth.Application</start-class> | |
| 479 | - </properties> | |
| 480 | -</project> | |
| 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>bsth_control</artifactId> | |
| 7 | + <version>0.0.1-SNAPSHOT</version> | |
| 8 | + <packaging>war</packaging> | |
| 9 | + | |
| 10 | + <parent> | |
| 11 | + <groupId>org.springframework.boot</groupId> | |
| 12 | + <artifactId>spring-boot-starter-parent</artifactId> | |
| 13 | + <version>2.1.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>org.springframework.boot</groupId> | |
| 58 | + <artifactId>spring-boot-configuration-processor</artifactId> | |
| 59 | + <optional>true</optional> | |
| 60 | + </dependency> | |
| 61 | + <dependency> | |
| 62 | + <groupId>mysql</groupId> | |
| 63 | + <artifactId>mysql-connector-java</artifactId> | |
| 64 | + </dependency> | |
| 65 | + | |
| 66 | + <dependency> | |
| 67 | + <groupId>joda-time</groupId> | |
| 68 | + <artifactId>joda-time</artifactId> | |
| 69 | + </dependency> | |
| 70 | + <dependency> | |
| 71 | + <groupId>com.alibaba</groupId> | |
| 72 | + <artifactId>fastjson</artifactId> | |
| 73 | + <version>1.2.4</version> | |
| 74 | + </dependency> | |
| 75 | + | |
| 76 | + <dependency> | |
| 77 | + <groupId>org.apache.httpcomponents</groupId> | |
| 78 | + <artifactId>httpclient</artifactId> | |
| 79 | + </dependency> | |
| 80 | + | |
| 81 | + <!-- dbcp2数据库连接池 --> | |
| 82 | + <dependency> | |
| 83 | + <groupId>org.apache.commons</groupId> | |
| 84 | + <artifactId>commons-dbcp2</artifactId> | |
| 85 | + </dependency> | |
| 86 | + | |
| 87 | + <dependency> | |
| 88 | + <groupId>org.hibernate</groupId> | |
| 89 | + <artifactId>hibernate-search-orm</artifactId> | |
| 90 | + <version>5.11.2.Final</version> | |
| 91 | + </dependency> | |
| 92 | + | |
| 93 | + <dependency> | |
| 94 | + <groupId>commons-lang</groupId> | |
| 95 | + <artifactId>commons-lang</artifactId> | |
| 96 | + <version>2.6</version> | |
| 97 | + </dependency> | |
| 98 | + <dependency> | |
| 99 | + <groupId>org.apache.commons</groupId> | |
| 100 | + <artifactId>commons-lang3</artifactId> | |
| 101 | + <version>3.4</version> | |
| 102 | + </dependency> | |
| 103 | + <dependency> | |
| 104 | + <groupId>commons-fileupload</groupId> | |
| 105 | + <artifactId>commons-fileupload</artifactId> | |
| 106 | + <version>1.2.2</version> | |
| 107 | + </dependency> | |
| 108 | + <dependency> | |
| 109 | + <groupId>commons-io</groupId> | |
| 110 | + <artifactId>commons-io</artifactId> | |
| 111 | + <version>2.4</version> | |
| 112 | + </dependency> | |
| 113 | + <dependency> | |
| 114 | + <groupId>org.codehaus.janino</groupId> | |
| 115 | + <artifactId>janino</artifactId> | |
| 116 | + </dependency> | |
| 117 | + | |
| 118 | + <dependency> | |
| 119 | + <groupId>org.apache.poi</groupId> | |
| 120 | + <artifactId>poi-ooxml</artifactId> | |
| 121 | + <version>3.13</version> | |
| 122 | + </dependency> | |
| 123 | + | |
| 124 | + <dependency> | |
| 125 | + <groupId>com.google.guava</groupId> | |
| 126 | + <artifactId>guava</artifactId> | |
| 127 | + <version>19.0</version> | |
| 128 | + </dependency> | |
| 129 | + <!-- ftp文件上传包 --> | |
| 130 | + <dependency> | |
| 131 | + <groupId>commons-net</groupId> | |
| 132 | + <artifactId>commons-net</artifactId> | |
| 133 | + <version>3.5</version> | |
| 134 | + </dependency> | |
| 135 | + <dependency> | |
| 136 | + <groupId>org.apache.commons</groupId> | |
| 137 | + <artifactId>commons-compress</artifactId> | |
| 138 | + <version>1.3</version> | |
| 139 | + </dependency> | |
| 140 | + <!-- drools 6依赖 --> | |
| 141 | + <dependency> | |
| 142 | + <groupId>org.kie</groupId> | |
| 143 | + <artifactId>kie-api</artifactId> | |
| 144 | + </dependency> | |
| 145 | + <dependency> | |
| 146 | + <groupId>org.drools</groupId> | |
| 147 | + <artifactId>drools-compiler</artifactId> | |
| 148 | + </dependency> | |
| 149 | + | |
| 150 | + <!-- springboot测试 --> | |
| 151 | + <dependency> | |
| 152 | + <groupId>org.springframework.boot</groupId> | |
| 153 | + <artifactId>spring-boot-starter-test</artifactId> | |
| 154 | + <scope>test</scope> | |
| 155 | + </dependency> | |
| 156 | + | |
| 157 | + <dependency> | |
| 158 | + <groupId>c3p0</groupId> | |
| 159 | + <artifactId>c3p0</artifactId> | |
| 160 | + <version>0.9.1.2</version> | |
| 161 | + </dependency> | |
| 162 | + | |
| 163 | + <!-- 图表 --> | |
| 164 | + <dependency> | |
| 165 | + <groupId>com.google.code.gson</groupId> | |
| 166 | + <artifactId>gson</artifactId> | |
| 167 | + <version>2.8.5</version> | |
| 168 | + </dependency> | |
| 169 | + <dependency> | |
| 170 | + <groupId>com.github.abel533</groupId> | |
| 171 | + <artifactId>ECharts</artifactId> | |
| 172 | + <version>2.1.8</version> | |
| 173 | + </dependency> | |
| 174 | + | |
| 175 | + <dependency> | |
| 176 | + <groupId>org.apache.tika</groupId> | |
| 177 | + <artifactId>tika-core</artifactId> | |
| 178 | + <version>1.7</version> | |
| 179 | + </dependency> | |
| 180 | + | |
| 181 | + <!-- pentaho kettle 依赖 --> | |
| 182 | + <dependency> | |
| 183 | + <groupId>com.pentaho.kettle</groupId> | |
| 184 | + <artifactId>kettle-core</artifactId> | |
| 185 | + <version>6.0.1.0-386</version> | |
| 186 | + </dependency> | |
| 187 | + <dependency> | |
| 188 | + <groupId>com.pentaho.kettle</groupId> | |
| 189 | + <artifactId>kettle-engine</artifactId> | |
| 190 | + <version>6.0.1.0-386</version> | |
| 191 | + </dependency> | |
| 192 | + <dependency> | |
| 193 | + <groupId>com.pentaho.kettle</groupId> | |
| 194 | + <artifactId>metastore</artifactId> | |
| 195 | + <version>6.0.1.0-386</version> | |
| 196 | + </dependency> | |
| 197 | + <dependency> | |
| 198 | + <groupId>com.pentaho.kettle</groupId> | |
| 199 | + <artifactId>vfs2</artifactId> | |
| 200 | + <version>2.1-20150824</version> | |
| 201 | + </dependency> | |
| 202 | + <dependency> | |
| 203 | + <groupId>net.sourceforge.jexcelapi</groupId> | |
| 204 | + <artifactId>jxl</artifactId> | |
| 205 | + <version>2.6.12</version> | |
| 206 | + <exclusions> | |
| 207 | + <exclusion> | |
| 208 | + <groupId>log4j</groupId> | |
| 209 | + <artifactId>log4j</artifactId> | |
| 210 | + </exclusion> | |
| 211 | + </exclusions> | |
| 212 | + </dependency> | |
| 213 | + <dependency> | |
| 214 | + <groupId>rhino</groupId> | |
| 215 | + <artifactId>js</artifactId> | |
| 216 | + <version>1.7R2</version> | |
| 217 | + </dependency> | |
| 218 | + <dependency> | |
| 219 | + <groupId>javax.mail</groupId> | |
| 220 | + <artifactId>mail</artifactId> | |
| 221 | + <version>1.4.7</version> | |
| 222 | + </dependency> | |
| 223 | + | |
| 224 | + <dependency> | |
| 225 | + <groupId>com.github.axet</groupId> | |
| 226 | + <artifactId>kaptcha</artifactId> | |
| 227 | + <version>0.0.9</version> | |
| 228 | + </dependency> | |
| 229 | + | |
| 230 | + <dependency> | |
| 231 | + <groupId>commons-codec</groupId> | |
| 232 | + <artifactId>commons-codec</artifactId> | |
| 233 | + <version>1.4</version> | |
| 234 | + <scope>compile</scope> | |
| 235 | + </dependency> | |
| 236 | + <dependency> | |
| 237 | + <groupId>org.bouncycastle</groupId> | |
| 238 | + <artifactId>bcprov-jdk15on</artifactId> | |
| 239 | + <version>1.52</version> | |
| 240 | + </dependency> | |
| 241 | + <dependency> | |
| 242 | + <groupId>axis</groupId> | |
| 243 | + <artifactId>axis</artifactId> | |
| 244 | + <version>1.4</version> | |
| 245 | + </dependency> | |
| 246 | + <dependency> | |
| 247 | + <groupId>javax.xml</groupId> | |
| 248 | + <artifactId>jaxrpc-api</artifactId> | |
| 249 | + <version>1.1</version> | |
| 250 | + </dependency> | |
| 251 | + | |
| 252 | + <dependency> | |
| 253 | + <groupId>org.apache.axis2</groupId> | |
| 254 | + <artifactId>axis2-adb</artifactId> | |
| 255 | + <version>1.7.4</version> | |
| 256 | + </dependency> | |
| 257 | + <dependency> | |
| 258 | + <groupId>org.apache.axis2</groupId> | |
| 259 | + <artifactId>axis2-transport-local</artifactId> | |
| 260 | + <version>1.7.4</version> | |
| 261 | + </dependency> | |
| 262 | + <dependency> | |
| 263 | + <groupId>org.apache.axis2</groupId> | |
| 264 | + <artifactId>axis2-transport-http</artifactId> | |
| 265 | + <version>1.7.4</version> | |
| 266 | + </dependency> | |
| 267 | + | |
| 268 | + <dependency> | |
| 269 | + <groupId>org.dbunit</groupId> | |
| 270 | + <artifactId>dbunit</artifactId> | |
| 271 | + <version>2.4.9</version> | |
| 272 | + <scope>test</scope> | |
| 273 | + | |
| 274 | + <exclusions> | |
| 275 | + <exclusion> | |
| 276 | + <groupId>org.slf4j</groupId> | |
| 277 | + <artifactId>slf4j-api</artifactId> | |
| 278 | + </exclusion> | |
| 279 | + </exclusions> | |
| 280 | + </dependency> | |
| 281 | + | |
| 282 | + <dependency> | |
| 283 | + <groupId>com.h2database</groupId> | |
| 284 | + <artifactId>h2</artifactId> | |
| 285 | + <version>1.2.132</version> | |
| 286 | + <scope>test</scope> | |
| 287 | + </dependency> | |
| 288 | + | |
| 289 | + | |
| 290 | + <dependency> | |
| 291 | + <groupId>ojdbc</groupId> | |
| 292 | + <artifactId>ojdbc</artifactId> | |
| 293 | + <version>14</version> | |
| 294 | + </dependency> | |
| 295 | + | |
| 296 | + <dependency> | |
| 297 | + <groupId>org.apache.mina</groupId> | |
| 298 | + <artifactId>mina-core</artifactId> | |
| 299 | + <version>2.0.13</version> | |
| 300 | + </dependency> | |
| 301 | + | |
| 302 | + <dependency> | |
| 303 | + <groupId>com.google.protobuf</groupId> | |
| 304 | + <artifactId>protobuf-java</artifactId> | |
| 305 | + <version>3.3.0</version> | |
| 306 | + </dependency> | |
| 307 | + | |
| 308 | + <dependency> | |
| 309 | + <groupId>com.github.stuxuhai</groupId> | |
| 310 | + <artifactId>jpinyin</artifactId> | |
| 311 | + <version>1.1.8</version> | |
| 312 | + </dependency> | |
| 313 | + | |
| 314 | + <!-- dubbo 需要的jar start --> | |
| 315 | + <dependency> | |
| 316 | + <groupId>com.alibaba</groupId> | |
| 317 | + <artifactId>dubbo</artifactId> | |
| 318 | + <!--<version>2.6.3</version>--> | |
| 319 | + <version>2.5.3</version> | |
| 320 | + <exclusions> | |
| 321 | + <exclusion> | |
| 322 | + <groupId>org.springframework</groupId> | |
| 323 | + <artifactId>spring</artifactId> | |
| 324 | + </exclusion> | |
| 325 | + <exclusion> | |
| 326 | + <groupId>log4j</groupId> | |
| 327 | + <artifactId>log4j</artifactId> | |
| 328 | + </exclusion> | |
| 329 | + </exclusions> | |
| 330 | + </dependency> | |
| 331 | + | |
| 332 | + <dependency> | |
| 333 | + <groupId>org.apache.zookeeper</groupId> | |
| 334 | + <artifactId>zookeeper</artifactId> | |
| 335 | + <version>3.4.5</version> | |
| 336 | + <exclusions> | |
| 337 | + <exclusion> | |
| 338 | + <groupId>log4j</groupId> | |
| 339 | + <artifactId>log4j</artifactId> | |
| 340 | + </exclusion> | |
| 341 | + <exclusion> | |
| 342 | + <groupId>org.slf4j</groupId> | |
| 343 | + <artifactId>slf4j-log4j12</artifactId> | |
| 344 | + </exclusion> | |
| 345 | + </exclusions> | |
| 346 | + </dependency> | |
| 347 | + | |
| 348 | + <dependency> | |
| 349 | + <groupId>com.101tec</groupId> | |
| 350 | + <artifactId>zkclient</artifactId> | |
| 351 | + <version>0.3</version> | |
| 352 | + <exclusions> | |
| 353 | + <exclusion> | |
| 354 | + <groupId>log4j</groupId> | |
| 355 | + <artifactId>log4j</artifactId> | |
| 356 | + </exclusion> | |
| 357 | + </exclusions> | |
| 358 | + </dependency> | |
| 359 | + | |
| 360 | + <!-- plan common工程依赖 --> | |
| 361 | + <dependency> | |
| 362 | + <groupId>com.bsth.control_v2</groupId> | |
| 363 | + <artifactId>plan_module-common</artifactId> | |
| 364 | + <version>1.0-SNAPSHOT</version> | |
| 365 | + </dependency> | |
| 366 | + <!-- plan common config 工程依赖 --> | |
| 367 | + <dependency> | |
| 368 | + <groupId>com.bsth.control_v2</groupId> | |
| 369 | + <artifactId>plan_module-common-config</artifactId> | |
| 370 | + <version>1.0-SNAPSHOT</version> | |
| 371 | + </dependency> | |
| 372 | + <dependency> | |
| 373 | + <groupId>org.slf4j</groupId> | |
| 374 | + <artifactId>slf4j-api</artifactId> | |
| 375 | + <version>1.7.7</version> | |
| 376 | + </dependency> | |
| 377 | + <dependency> | |
| 378 | + <groupId>ch.qos.logback</groupId> | |
| 379 | + <artifactId>logback-classic</artifactId> | |
| 380 | + <version>1.1.11</version> | |
| 381 | + </dependency> | |
| 382 | + <dependency> | |
| 383 | + <groupId>org.slf4j</groupId> | |
| 384 | + <artifactId>log4j-over-slf4j</artifactId> | |
| 385 | + <version>1.7.7</version> | |
| 386 | + </dependency> | |
| 387 | + | |
| 388 | + <!-- web服务依赖 --> | |
| 389 | + <dependency> | |
| 390 | + <groupId>org.springframework.boot</groupId> | |
| 391 | + <artifactId>spring-boot-starter-web-services</artifactId> | |
| 392 | + </dependency> | |
| 393 | + <dependency> | |
| 394 | + <groupId>wsdl4j</groupId> | |
| 395 | + <artifactId>wsdl4j</artifactId> | |
| 396 | + </dependency> | |
| 397 | + | |
| 398 | + </dependencies> | |
| 399 | + | |
| 400 | + <dependencyManagement> | |
| 401 | + <dependencies> | |
| 402 | + <!-- drools 6依赖 --> | |
| 403 | + <dependency> | |
| 404 | + <groupId>org.drools</groupId> | |
| 405 | + <artifactId>drools-bom</artifactId> | |
| 406 | + <type>pom</type> | |
| 407 | + <version>6.3.0.Final</version> | |
| 408 | + <scope>import</scope> | |
| 409 | + </dependency> | |
| 410 | + </dependencies> | |
| 411 | + </dependencyManagement> | |
| 412 | + | |
| 413 | + <build> | |
| 414 | + <plugins> | |
| 415 | + <plugin> | |
| 416 | + <artifactId>maven-compiler-plugin</artifactId> | |
| 417 | + <version>2.3.2</version><!--$NO-MVN-MAN-VER$ --> | |
| 418 | + <configuration> | |
| 419 | + <source>1.8</source> | |
| 420 | + <target>1.8</target> | |
| 421 | + </configuration> | |
| 422 | + </plugin> | |
| 423 | + <plugin> | |
| 424 | + <artifactId>maven-war-plugin</artifactId> | |
| 425 | + <version>2.2</version><!--$NO-MVN-MAN-VER$ --> | |
| 426 | + <configuration> | |
| 427 | + <failOnMissingWebXml>false</failOnMissingWebXml> | |
| 428 | + </configuration> | |
| 429 | + </plugin> | |
| 430 | + <plugin> | |
| 431 | + <groupId>org.springframework.boot</groupId> | |
| 432 | + <artifactId>spring-boot-maven-plugin</artifactId> | |
| 433 | + </plugin> | |
| 434 | + <plugin> | |
| 435 | + <groupId>org.codehaus.mojo</groupId> | |
| 436 | + <artifactId>jaxb2-maven-plugin</artifactId> | |
| 437 | + <version>1.6</version> | |
| 438 | + <executions> | |
| 439 | + <execution> | |
| 440 | + <id>xjc</id> | |
| 441 | + <phase>none</phase> | |
| 442 | + <goals> | |
| 443 | + <goal>xjc</goal> | |
| 444 | + </goals> | |
| 445 | + </execution> | |
| 446 | + </executions> | |
| 447 | + <configuration> | |
| 448 | + <schemaDirectory>${project.basedir}/src/main/resources/xsd/</schemaDirectory> | |
| 449 | + <outputDirectory>${project.basedir}/src/main/java</outputDirectory> | |
| 450 | + <clearOutputDir>false</clearOutputDir> | |
| 451 | + <encoding>utf-8</encoding> | |
| 452 | + </configuration> | |
| 453 | + </plugin> | |
| 454 | + </plugins> | |
| 455 | + <resources> | |
| 456 | + <resource> | |
| 457 | + <directory>src/main/resources</directory> | |
| 458 | + <filtering>false</filtering> | |
| 459 | + </resource> | |
| 460 | + </resources> | |
| 461 | + </build> | |
| 462 | + <repositories> | |
| 463 | + <repository> | |
| 464 | + <id>spring-snapshots</id> | |
| 465 | + <url>http://repo.spring.io/snapshot</url> | |
| 466 | + <snapshots> | |
| 467 | + <enabled>true</enabled> | |
| 468 | + </snapshots> | |
| 469 | + </repository> | |
| 470 | + <repository> | |
| 471 | + <id>spring-milestones</id> | |
| 472 | + <url>http://repo.spring.io/milestone</url> | |
| 473 | + </repository> | |
| 474 | + </repositories> | |
| 475 | + <pluginRepositories> | |
| 476 | + <pluginRepository> | |
| 477 | + <id>spring-snapshots</id> | |
| 478 | + <url>http://repo.spring.io/snapshot</url> | |
| 479 | + </pluginRepository> | |
| 480 | + <pluginRepository> | |
| 481 | + <id>spring-milestones</id> | |
| 482 | + <url>http://repo.spring.io/milestone</url> | |
| 483 | + </pluginRepository> | |
| 484 | + </pluginRepositories> | |
| 485 | + | |
| 486 | + <properties> | |
| 487 | + <start-class>com.bsth.Application</start-class> | |
| 488 | + </properties> | |
| 489 | +</project> | ... | ... |
src/main/java/com/bsth/Application.java
| 1 | -package com.bsth; | |
| 2 | - | |
| 3 | -import com.fasterxml.jackson.databind.ObjectMapper; | |
| 4 | -import com.fasterxml.jackson.databind.SerializationFeature; | |
| 5 | -import org.springframework.boot.SpringApplication; | |
| 6 | -import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| 7 | -import org.springframework.boot.builder.SpringApplicationBuilder; | |
| 8 | -import org.springframework.boot.context.web.SpringBootServletInitializer; | |
| 9 | -import org.springframework.context.annotation.Bean; | |
| 10 | -import org.springframework.context.annotation.Primary; | |
| 11 | -import org.springframework.transaction.annotation.EnableTransactionManagement; | |
| 12 | - | |
| 13 | -import java.util.concurrent.Executors; | |
| 14 | -import java.util.concurrent.ScheduledExecutorService; | |
| 15 | - | |
| 16 | -@EnableTransactionManagement | |
| 17 | -@SpringBootApplication | |
| 18 | -public class Application extends SpringBootServletInitializer { | |
| 19 | - | |
| 20 | - public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(18); | |
| 21 | - | |
| 22 | - @Override | |
| 23 | - protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { | |
| 24 | - return application.sources(Application.class); | |
| 25 | - } | |
| 26 | - | |
| 27 | - @Bean | |
| 28 | - @Primary | |
| 29 | - public ObjectMapper objectMapper() { | |
| 30 | - ObjectMapper objectMapper = new ObjectMapper(); | |
| 31 | - objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); | |
| 32 | - | |
| 33 | - return objectMapper; | |
| 34 | - } | |
| 35 | - | |
| 36 | - public static void main(String[] args) throws Exception { | |
| 37 | - SpringApplication.run(Application.class, args); | |
| 38 | - } | |
| 1 | +package com.bsth; | |
| 2 | + | |
| 3 | +import com.fasterxml.jackson.databind.ObjectMapper; | |
| 4 | +import com.fasterxml.jackson.databind.SerializationFeature; | |
| 5 | +import org.springframework.boot.SpringApplication; | |
| 6 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | |
| 7 | +import org.springframework.boot.builder.SpringApplicationBuilder; | |
| 8 | +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | |
| 9 | +import org.springframework.context.annotation.Bean; | |
| 10 | +import org.springframework.context.annotation.Primary; | |
| 11 | +import org.springframework.transaction.annotation.EnableTransactionManagement; | |
| 12 | + | |
| 13 | +import java.util.concurrent.Executors; | |
| 14 | +import java.util.concurrent.ScheduledExecutorService; | |
| 15 | + | |
| 16 | +@EnableTransactionManagement | |
| 17 | +@SpringBootApplication | |
| 18 | +public class Application extends SpringBootServletInitializer { | |
| 19 | + | |
| 20 | + public static ScheduledExecutorService mainServices = Executors.newScheduledThreadPool(18); | |
| 21 | + | |
| 22 | + @Override | |
| 23 | + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { | |
| 24 | + return application.sources(Application.class); | |
| 25 | + } | |
| 26 | + | |
| 27 | + @Bean | |
| 28 | + @Primary | |
| 29 | + public ObjectMapper objectMapper() { | |
| 30 | + ObjectMapper objectMapper = new ObjectMapper(); | |
| 31 | + objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS); | |
| 32 | + | |
| 33 | + return objectMapper; | |
| 34 | + } | |
| 35 | + | |
| 36 | + public static void main(String[] args) throws Exception { | |
| 37 | + SpringApplication.run(Application.class, args); | |
| 38 | + } | |
| 39 | 39 | } |
| 40 | 40 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/WebAppConfiguration.java
| 1 | -package com.bsth; | |
| 2 | - | |
| 3 | -import com.bsth.filter.ResourceFilter; | |
| 4 | -import com.bsth.websocket.WebSocketHandshakeInterceptor; | |
| 5 | -import com.bsth.websocket.handler.RealControlSocketHandler; | |
| 6 | -import org.slf4j.Logger; | |
| 7 | -import org.slf4j.LoggerFactory; | |
| 8 | -import org.springframework.boot.context.embedded.FilterRegistrationBean; | |
| 9 | -import org.springframework.context.annotation.Bean; | |
| 10 | -import org.springframework.context.annotation.ComponentScan; | |
| 11 | -import org.springframework.context.annotation.Configuration; | |
| 12 | -import org.springframework.web.filter.CharacterEncodingFilter; | |
| 13 | -import org.springframework.web.filter.HttpPutFormContentFilter; | |
| 14 | -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | |
| 15 | -import org.springframework.web.socket.config.annotation.EnableWebSocket; | |
| 16 | -import org.springframework.web.socket.config.annotation.WebSocketConfigurer; | |
| 17 | -import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; | |
| 18 | -import org.springframework.web.socket.server.standard.ServletServerContainerFactoryBean; | |
| 19 | - | |
| 20 | -import javax.servlet.Filter; | |
| 21 | - | |
| 22 | -@Configuration | |
| 23 | -@EnableWebSocket | |
| 24 | -@ComponentScan | |
| 25 | -public class WebAppConfiguration extends WebMvcConfigurerAdapter implements WebSocketConfigurer{ | |
| 26 | - | |
| 27 | -// @Autowired | |
| 28 | -// HttpOpLogInterceptor httpOpLogInterceptor; | |
| 29 | - | |
| 30 | - Logger logger = LoggerFactory.getLogger(this.getClass()); | |
| 31 | - | |
| 32 | - /** | |
| 33 | - * @Title: httpPutFormContentFilter | |
| 34 | - * @Description: TODO(弥补浏览器不支持PUT/DELETE,对携带 _method 参数的请求进行转换) | |
| 35 | - */ | |
| 36 | - @Bean | |
| 37 | - public Filter httpPutFormContentFilter() { | |
| 38 | - return new HttpPutFormContentFilter(); | |
| 39 | - } | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * @Title: characterEncodingFilter | |
| 43 | - * @Description: TODO(编码过滤器) | |
| 44 | - */ | |
| 45 | - @Bean | |
| 46 | - public Filter characterEncodingFilter(){ | |
| 47 | - return new CharacterEncodingFilter("UTF-8"); | |
| 48 | - } | |
| 49 | - | |
| 50 | - /** | |
| 51 | - * | |
| 52 | - * @Title: resourceFilterRegistration | |
| 53 | - * @Description: TODO(静态资源过滤器, 只处理 /pages 目录下的片段请求 ) | |
| 54 | - */ | |
| 55 | - @Bean | |
| 56 | - public FilterRegistrationBean resourceFilterRegistration(){ | |
| 57 | - FilterRegistrationBean registration = new FilterRegistrationBean(); | |
| 58 | - registration.setFilter(new ResourceFilter()); | |
| 59 | - registration.addUrlPatterns("/pages/*"); | |
| 60 | - return registration; | |
| 61 | - } | |
| 62 | - | |
| 63 | - /** | |
| 64 | - * | |
| 65 | - * @Title: addInterceptors | |
| 66 | - * @Description: TODO(HTTP结构化访问日志记录 ) | |
| 67 | - | |
| 68 | - @Override | |
| 69 | - public void addInterceptors(InterceptorRegistry registry) { | |
| 70 | - registry.addInterceptor(httpOpLogInterceptor); | |
| 71 | - }*/ | |
| 72 | - | |
| 73 | - @Override | |
| 74 | - public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { | |
| 75 | - //线调webSocket | |
| 76 | - registry.addHandler(new RealControlSocketHandler(), "/sockjs/realcontrol").addInterceptors(new WebSocketHandshakeInterceptor()) | |
| 77 | - .withSockJS(); | |
| 78 | - } | |
| 79 | -} | |
| 1 | +package com.bsth; | |
| 2 | + | |
| 3 | +import com.bsth.filter.ResourceFilter; | |
| 4 | +import com.bsth.websocket.WebSocketHandshakeInterceptor; | |
| 5 | +import com.bsth.websocket.handler.RealControlSocketHandler; | |
| 6 | +import org.slf4j.Logger; | |
| 7 | +import org.slf4j.LoggerFactory; | |
| 8 | +import org.springframework.boot.web.servlet.FilterRegistrationBean; | |
| 9 | +import org.springframework.context.annotation.Bean; | |
| 10 | +import org.springframework.context.annotation.ComponentScan; | |
| 11 | +import org.springframework.context.annotation.Configuration; | |
| 12 | +import org.springframework.web.filter.CharacterEncodingFilter; | |
| 13 | +import org.springframework.web.filter.FormContentFilter; | |
| 14 | +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | |
| 15 | +import org.springframework.web.socket.config.annotation.EnableWebSocket; | |
| 16 | +import org.springframework.web.socket.config.annotation.WebSocketConfigurer; | |
| 17 | +import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry; | |
| 18 | + | |
| 19 | +import javax.servlet.Filter; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * @author Hill | |
| 23 | + */ | |
| 24 | +@Configuration | |
| 25 | +@EnableWebSocket | |
| 26 | +@ComponentScan | |
| 27 | +public class WebAppConfiguration implements WebSocketConfigurer, WebMvcConfigurer { | |
| 28 | + | |
| 29 | + /** | |
| 30 | + * @Title: httpPutFormContentFilter | |
| 31 | + * @Description: TODO(弥补浏览器不支持PUT/DELETE,对携带 _method 参数的请求进行转换) | |
| 32 | + */ | |
| 33 | + @Bean | |
| 34 | + public Filter httpPutFormContentFilter() { | |
| 35 | + return new FormContentFilter(); | |
| 36 | + } | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * @Title: characterEncodingFilter | |
| 40 | + * @Description: TODO(编码过滤器) | |
| 41 | + */ | |
| 42 | + /*@Bean | |
| 43 | + public Filter characterEncodingFilter(){ | |
| 44 | + return new CharacterEncodingFilter("UTF-8"); | |
| 45 | + }*/ | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * | |
| 49 | + * @Title: resourceFilterRegistration | |
| 50 | + * @Description: TODO(静态资源过滤器, 只处理 /pages 目录下的片段请求 ) | |
| 51 | + */ | |
| 52 | + @Bean | |
| 53 | + public FilterRegistrationBean resourceFilterRegistration(){ | |
| 54 | + FilterRegistrationBean registration = new FilterRegistrationBean(); | |
| 55 | + registration.setFilter(new ResourceFilter()); | |
| 56 | + registration.addUrlPatterns("/pages/*"); | |
| 57 | + return registration; | |
| 58 | + } | |
| 59 | + | |
| 60 | + @Override | |
| 61 | + public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { | |
| 62 | + //线调webSocket | |
| 63 | + registry.addHandler(new RealControlSocketHandler(), "/sockjs/realcontrol").addInterceptors(new WebSocketHandshakeInterceptor()) | |
| 64 | + .withSockJS(); | |
| 65 | + } | |
| 66 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/BController_facade.java
| 1 | -package com.bsth.controller.schedule; | |
| 2 | - | |
| 3 | -import com.bsth.common.Constants; | |
| 4 | -import com.bsth.common.ResponseCode; | |
| 5 | -import com.bsth.control_v2.plan_module.common.dto.PageRequestDto; | |
| 6 | -import com.bsth.control_v2.plan_module.common.exception.PlanModuleException; | |
| 7 | -import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 8 | -import com.bsth.entity.sys.SysUser; | |
| 9 | -import com.bsth.service.sys.SysUserService; | |
| 10 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | -import org.springframework.web.bind.annotation.*; | |
| 12 | - | |
| 13 | -import javax.servlet.http.HttpSession; | |
| 14 | -import java.io.Serializable; | |
| 15 | -import java.util.Date; | |
| 16 | -import java.util.HashMap; | |
| 17 | -import java.util.List; | |
| 18 | -import java.util.Map; | |
| 19 | - | |
| 20 | -public abstract class BController_facade<Id extends Serializable, DTO> { | |
| 21 | - protected abstract BServiceFacade<Id, DTO> getBServiceFacade(); | |
| 22 | - | |
| 23 | - @Autowired | |
| 24 | - private SysUserService sysUserService; | |
| 25 | - | |
| 26 | - //---------------- 设置操作用户 ----------------// | |
| 27 | - public void setCreateUserInfo(DTO dto, Integer userId, Date createDate) { | |
| 28 | - throw new PlanModuleException("子类必须override setCUserInfo方法!"); | |
| 29 | - } | |
| 30 | - public void setUpdateUserInfo(DTO dto, Integer userId, Date updateDate) { | |
| 31 | - throw new PlanModuleException("子类必须override setUpdateUserInfo方法!"); | |
| 32 | - } | |
| 33 | - | |
| 34 | - //---------------- 扩展的save,update,delete操作 --------------------// | |
| 35 | - protected boolean isSaveExtend() { | |
| 36 | - return false; | |
| 37 | - } | |
| 38 | - protected DTO saveExtend(DTO dto) { | |
| 39 | - throw new PlanModuleException("子类如果isSaveExtend()==true,必须覆写saveExtend!"); | |
| 40 | - } | |
| 41 | - protected boolean isUpdateExtend() { | |
| 42 | - return false; | |
| 43 | - } | |
| 44 | - protected DTO updateExtend(DTO dto) { | |
| 45 | - throw new PlanModuleException("子类如果isUpdateExtend()==true,必须覆写updateExtend!"); | |
| 46 | - } | |
| 47 | - protected boolean isDeleteExtend() { | |
| 48 | - return false; | |
| 49 | - } | |
| 50 | - protected void deleteExtend(Id id) { | |
| 51 | - throw new PlanModuleException("子类如果isDeleteExtend()==true,必须覆写deleteExtend!"); | |
| 52 | - } | |
| 53 | - | |
| 54 | - //---------------- CRUD 操作 ----------------// | |
| 55 | - // Create操作 | |
| 56 | - @RequestMapping(method = RequestMethod.POST) | |
| 57 | - public Map<String, Object> save(@RequestBody DTO dto, HttpSession httpSession) { | |
| 58 | - String userName = String.valueOf(httpSession.getAttribute(Constants.SESSION_USERNAME)); | |
| 59 | - SysUser sysUser = sysUserService.findByUserName(userName); | |
| 60 | - setCreateUserInfo(dto, sysUser.getId(), new Date()); | |
| 61 | - setUpdateUserInfo(dto, sysUser.getId(), new Date()); | |
| 62 | - | |
| 63 | - Map<String, Object> rtn = new HashMap<>(); | |
| 64 | - try { | |
| 65 | - DTO dto_saved; | |
| 66 | - if (isSaveExtend()) { | |
| 67 | - dto_saved = saveExtend(dto); | |
| 68 | - } else { | |
| 69 | - dto_saved = getBServiceFacade().save(dto); | |
| 70 | - } | |
| 71 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 72 | - rtn.put("data", dto_saved); | |
| 73 | - } catch (Exception exp) { | |
| 74 | - rtn.put("status", ResponseCode.ERROR); | |
| 75 | - rtn.put("msg", exp.getMessage()); | |
| 76 | - } | |
| 77 | - | |
| 78 | - return rtn; | |
| 79 | - } | |
| 80 | - | |
| 81 | - // Update操作 | |
| 82 | - @RequestMapping(value="/{id}", method = RequestMethod.POST) | |
| 83 | - public Map<String, Object> update(@RequestBody DTO dto, HttpSession httpSession) { | |
| 84 | - String userName = String.valueOf(httpSession.getAttribute(Constants.SESSION_USERNAME)); | |
| 85 | - SysUser sysUser = sysUserService.findByUserName(userName); | |
| 86 | - setUpdateUserInfo(dto, sysUser.getId(), new Date()); | |
| 87 | - | |
| 88 | - Map<String, Object> rtn = new HashMap<>(); | |
| 89 | - try { | |
| 90 | - DTO dto_updated; | |
| 91 | - if (isUpdateExtend()) { | |
| 92 | - dto_updated = updateExtend(dto); | |
| 93 | - } else { | |
| 94 | - dto_updated = getBServiceFacade().save(dto); | |
| 95 | - } | |
| 96 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 97 | - rtn.put("data", dto_updated); | |
| 98 | - } catch (Exception exp) { | |
| 99 | - rtn.put("status", ResponseCode.ERROR); | |
| 100 | - rtn.put("msg", exp.getMessage()); | |
| 101 | - } | |
| 102 | - | |
| 103 | - return rtn; | |
| 104 | - } | |
| 105 | - | |
| 106 | - // Research操作 | |
| 107 | - @RequestMapping(value = "/{id}", method = RequestMethod.GET) | |
| 108 | - public Map<String, Object> findById(@PathVariable("id") Id id) { | |
| 109 | - Map<String, Object> rtn = new HashMap<>(); | |
| 110 | - try { | |
| 111 | - DTO dto = getBServiceFacade().findById(id); | |
| 112 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 113 | - rtn.put("data", dto); | |
| 114 | - } catch (Exception exp) { | |
| 115 | - rtn.put("status", ResponseCode.ERROR); | |
| 116 | - rtn.put("msg", exp.getMessage()); | |
| 117 | - } | |
| 118 | - | |
| 119 | - return rtn; | |
| 120 | - } | |
| 121 | - | |
| 122 | - // 查询所有操作 | |
| 123 | - @RequestMapping(value = "/all", method = RequestMethod.GET) | |
| 124 | - public Map<String, Object> list(@RequestParam Map<String, Object> param) { | |
| 125 | - Map<String, Object> rtn = new HashMap<>(); | |
| 126 | - try { | |
| 127 | - List<DTO> tList = getBServiceFacade().list(param); | |
| 128 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 129 | - rtn.put("data", tList); | |
| 130 | - } catch (Exception exp) { | |
| 131 | - rtn.put("status", ResponseCode.ERROR); | |
| 132 | - rtn.put("msg", exp.getMessage()); | |
| 133 | - } | |
| 134 | - return rtn; | |
| 135 | - } | |
| 136 | - | |
| 137 | - // 分页查询操作 | |
| 138 | - @RequestMapping(method = RequestMethod.GET) | |
| 139 | - public Map<String, Object> list( | |
| 140 | - @RequestParam Map<String, Object> map, | |
| 141 | - @RequestParam(defaultValue = "0") int page, | |
| 142 | - @RequestParam(defaultValue = "10") int size, | |
| 143 | - @RequestParam(defaultValue = "id") String order, | |
| 144 | - @RequestParam(defaultValue = "DESC") String direction) { | |
| 145 | - PageRequestDto pageRequestDto = PageRequestDto.getBuilder() | |
| 146 | - .setPage(page) | |
| 147 | - .setSize(size) | |
| 148 | - .setOrder(order) | |
| 149 | - .setDirection(direction) | |
| 150 | - .build(); | |
| 151 | - Map<String, Object> rtn = new HashMap<>(); | |
| 152 | - try { | |
| 153 | - rtn.put("data", getBServiceFacade().list(map, pageRequestDto)); | |
| 154 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 155 | - } catch (Exception exp) { | |
| 156 | - rtn.put("status", ResponseCode.ERROR); | |
| 157 | - rtn.put("msg", exp.getMessage()); | |
| 158 | - } | |
| 159 | - return rtn; | |
| 160 | - } | |
| 161 | - | |
| 162 | - // Delete操作 | |
| 163 | - @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) | |
| 164 | - public Map<String, Object> delete(@PathVariable("id") Id id, HttpSession httpSession) { | |
| 165 | - Map<String, Object> rtn = new HashMap<>(); | |
| 166 | - try { | |
| 167 | - // 由于种种原因,这里不保存用户和操作时间了 | |
| 168 | - if (isDeleteExtend()) { | |
| 169 | - deleteExtend(id); | |
| 170 | - } else { | |
| 171 | - getBServiceFacade().delete(id); | |
| 172 | - } | |
| 173 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 174 | - } catch (Exception exp) { | |
| 175 | - rtn.put("status", ResponseCode.ERROR); | |
| 176 | - rtn.put("msg", exp.getMessage()); | |
| 177 | - } | |
| 178 | - return rtn; | |
| 179 | - } | |
| 180 | -} | |
| 1 | +package com.bsth.controller.schedule; | |
| 2 | + | |
| 3 | +import com.bsth.common.Constants; | |
| 4 | +import com.bsth.common.ResponseCode; | |
| 5 | +import com.bsth.control_v2.plan_module.common.dto.PageRequestDto; | |
| 6 | +import com.bsth.control_v2.plan_module.common.exception.PlanModuleException; | |
| 7 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 8 | +import com.bsth.entity.sys.SysUser; | |
| 9 | +import com.bsth.service.sys.SysUserService; | |
| 10 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 11 | +import org.springframework.web.bind.annotation.*; | |
| 12 | + | |
| 13 | +import javax.servlet.http.HttpSession; | |
| 14 | +import java.io.Serializable; | |
| 15 | +import java.util.Date; | |
| 16 | +import java.util.HashMap; | |
| 17 | +import java.util.List; | |
| 18 | +import java.util.Map; | |
| 19 | + | |
| 20 | +public abstract class BController_facade<Id extends Serializable, DTO> { | |
| 21 | + protected abstract BServiceFacade<Id, DTO> getBServiceFacade(); | |
| 22 | + | |
| 23 | + @Autowired | |
| 24 | + private SysUserService sysUserService; | |
| 25 | + | |
| 26 | + //---------------- 设置操作用户 ----------------// | |
| 27 | + public void setCreateUserInfo(DTO dto, Integer userId, Date createDate) { | |
| 28 | + throw new PlanModuleException("子类必须override setCUserInfo方法!"); | |
| 29 | + } | |
| 30 | + public void setUpdateUserInfo(DTO dto, Integer userId, Date updateDate) { | |
| 31 | + throw new PlanModuleException("子类必须override setUpdateUserInfo方法!"); | |
| 32 | + } | |
| 33 | + | |
| 34 | + //---------------- 扩展的save,update,delete操作 --------------------// | |
| 35 | + protected boolean isSaveExtend() { | |
| 36 | + return false; | |
| 37 | + } | |
| 38 | + protected DTO saveExtend(DTO dto) { | |
| 39 | + throw new PlanModuleException("子类如果isSaveExtend()==true,必须覆写saveExtend!"); | |
| 40 | + } | |
| 41 | + protected boolean isUpdateExtend() { | |
| 42 | + return false; | |
| 43 | + } | |
| 44 | + protected DTO updateExtend(DTO dto) { | |
| 45 | + throw new PlanModuleException("子类如果isUpdateExtend()==true,必须覆写updateExtend!"); | |
| 46 | + } | |
| 47 | + protected boolean isDeleteExtend() { | |
| 48 | + return false; | |
| 49 | + } | |
| 50 | + protected void deleteExtend(Id id) { | |
| 51 | + throw new PlanModuleException("子类如果isDeleteExtend()==true,必须覆写deleteExtend!"); | |
| 52 | + } | |
| 53 | + | |
| 54 | + //---------------- CRUD 操作 ----------------// | |
| 55 | + // Create操作 | |
| 56 | + @RequestMapping(method = RequestMethod.POST) | |
| 57 | + public Map<String, Object> save(@RequestBody DTO dto, HttpSession httpSession) { | |
| 58 | + String userName = String.valueOf(httpSession.getAttribute(Constants.SESSION_USERNAME)); | |
| 59 | + SysUser sysUser = sysUserService.findByUserName(userName); | |
| 60 | + setCreateUserInfo(dto, sysUser.getId(), new Date()); | |
| 61 | + setUpdateUserInfo(dto, sysUser.getId(), new Date()); | |
| 62 | + | |
| 63 | + Map<String, Object> rtn = new HashMap<>(); | |
| 64 | + try { | |
| 65 | + DTO dto_saved; | |
| 66 | + if (isSaveExtend()) { | |
| 67 | + dto_saved = saveExtend(dto); | |
| 68 | + } else { | |
| 69 | + dto_saved = getBServiceFacade().save(dto); | |
| 70 | + } | |
| 71 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 72 | + rtn.put("data", dto_saved); | |
| 73 | + } catch (Exception exp) { | |
| 74 | + rtn.put("status", ResponseCode.ERROR); | |
| 75 | + rtn.put("msg", exp.getMessage()); | |
| 76 | + } | |
| 77 | + | |
| 78 | + return rtn; | |
| 79 | + } | |
| 80 | + | |
| 81 | + // Update操作 | |
| 82 | + @RequestMapping(value="/{id}", method = RequestMethod.POST) | |
| 83 | + public Map<String, Object> update(@RequestBody DTO dto, HttpSession httpSession) { | |
| 84 | + String userName = String.valueOf(httpSession.getAttribute(Constants.SESSION_USERNAME)); | |
| 85 | + SysUser sysUser = sysUserService.findByUserName(userName); | |
| 86 | + setUpdateUserInfo(dto, sysUser.getId(), new Date()); | |
| 87 | + | |
| 88 | + Map<String, Object> rtn = new HashMap<>(); | |
| 89 | + try { | |
| 90 | + DTO dto_updated; | |
| 91 | + if (isUpdateExtend()) { | |
| 92 | + dto_updated = updateExtend(dto); | |
| 93 | + } else { | |
| 94 | + dto_updated = getBServiceFacade().save(dto); | |
| 95 | + } | |
| 96 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 97 | + rtn.put("data", dto_updated); | |
| 98 | + } catch (Exception exp) { | |
| 99 | + rtn.put("status", ResponseCode.ERROR); | |
| 100 | + rtn.put("msg", exp.getMessage()); | |
| 101 | + } | |
| 102 | + | |
| 103 | + return rtn; | |
| 104 | + } | |
| 105 | + | |
| 106 | + // Research操作 | |
| 107 | + @RequestMapping(value = "/{id}", method = RequestMethod.GET) | |
| 108 | + public Map<String, Object> findById(@PathVariable("id") Id id) { | |
| 109 | + Map<String, Object> rtn = new HashMap<>(); | |
| 110 | + try { | |
| 111 | + DTO dto = getBServiceFacade().findById(id); | |
| 112 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 113 | + rtn.put("data", dto); | |
| 114 | + } catch (Exception exp) { | |
| 115 | + rtn.put("status", ResponseCode.ERROR); | |
| 116 | + rtn.put("msg", exp.getMessage()); | |
| 117 | + } | |
| 118 | + | |
| 119 | + return rtn; | |
| 120 | + } | |
| 121 | + | |
| 122 | + // 查询所有操作 | |
| 123 | + @RequestMapping(value = "/all", method = RequestMethod.GET) | |
| 124 | + public Map<String, Object> list(@RequestParam Map<String, Object> param) { | |
| 125 | + Map<String, Object> rtn = new HashMap<>(); | |
| 126 | + try { | |
| 127 | + List<DTO> tList = getBServiceFacade().list(param); | |
| 128 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 129 | + rtn.put("data", tList); | |
| 130 | + } catch (Exception exp) { | |
| 131 | + rtn.put("status", ResponseCode.ERROR); | |
| 132 | + rtn.put("msg", exp.getMessage()); | |
| 133 | + } | |
| 134 | + return rtn; | |
| 135 | + } | |
| 136 | + | |
| 137 | + // 分页查询操作 | |
| 138 | + @RequestMapping(method = RequestMethod.GET) | |
| 139 | + public Map<String, Object> list( | |
| 140 | + @RequestParam Map<String, Object> map, | |
| 141 | + @RequestParam(defaultValue = "0") int page, | |
| 142 | + @RequestParam(defaultValue = "10") int size, | |
| 143 | + @RequestParam(defaultValue = "id") String order, | |
| 144 | + @RequestParam(defaultValue = "DESC") String direction) { | |
| 145 | + PageRequestDto pageRequestDto = PageRequestDto.getBuilder() | |
| 146 | + .setPage(page) | |
| 147 | + .setSize(size) | |
| 148 | + .setOrder(order) | |
| 149 | + .setDirection(direction) | |
| 150 | + .build(); | |
| 151 | + Map<String, Object> rtn = new HashMap<>(); | |
| 152 | + try { | |
| 153 | + rtn.put("data", getBServiceFacade().list(map, pageRequestDto)); | |
| 154 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 155 | + } catch (Exception exp) { | |
| 156 | + rtn.put("status", ResponseCode.ERROR); | |
| 157 | + rtn.put("msg", exp.getMessage()); | |
| 158 | + } | |
| 159 | + return rtn; | |
| 160 | + } | |
| 161 | + | |
| 162 | + // Delete操作 | |
| 163 | + @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) | |
| 164 | + public Map<String, Object> delete(@PathVariable("id") Id id, HttpSession httpSession) { | |
| 165 | + Map<String, Object> rtn = new HashMap<>(); | |
| 166 | + try { | |
| 167 | + // 由于种种原因,这里不保存用户和操作时间了 | |
| 168 | + if (isDeleteExtend()) { | |
| 169 | + deleteExtend(id); | |
| 170 | + } else { | |
| 171 | + getBServiceFacade().delete(id); | |
| 172 | + } | |
| 173 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 174 | + } catch (Exception exp) { | |
| 175 | + rtn.put("status", ResponseCode.ERROR); | |
| 176 | + rtn.put("msg", exp.getMessage()); | |
| 177 | + } | |
| 178 | + return rtn; | |
| 179 | + } | |
| 180 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/basicinfo/CarController_facade.java
| 1 | -package com.bsth.controller.schedule.basicinfo; | |
| 2 | - | |
| 3 | -import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | -import com.bsth.common.ResponseCode; | |
| 5 | -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 6 | -import com.bsth.control_v2.plan_module.common.dto.baseinfo.CarDto; | |
| 7 | -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 8 | -import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 9 | -import com.bsth.control_v2.plan_module.common.service.baseinfo.CarServiceFacade; | |
| 10 | -import com.bsth.controller.schedule.BController_facade; | |
| 11 | -import com.bsth.service.schedule.CarsService; | |
| 12 | -import com.bsth.service.schedule.utils.DataToolsFile; | |
| 13 | -import org.apache.commons.lang3.StringUtils; | |
| 14 | -import org.apache.poi.ss.usermodel.Workbook; | |
| 15 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | -import org.springframework.context.annotation.Conditional; | |
| 17 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 18 | -import org.springframework.web.bind.annotation.RequestMethod; | |
| 19 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 20 | -import org.springframework.web.bind.annotation.RestController; | |
| 21 | -import org.springframework.web.multipart.MultipartFile; | |
| 22 | - | |
| 23 | -import javax.servlet.http.HttpServletResponse; | |
| 24 | -import java.io.*; | |
| 25 | -import java.util.*; | |
| 26 | - | |
| 27 | -/** | |
| 28 | - * 车辆基础信息controller_facade | |
| 29 | - */ | |
| 30 | -@RestController | |
| 31 | -@Conditional(DubboConfigCondition.class) | |
| 32 | -@RequestMapping("cars_sc") | |
| 33 | -public class CarController_facade extends BController_facade<Integer, CarDto> { | |
| 34 | - | |
| 35 | - @Override | |
| 36 | - public void setCreateUserInfo(CarDto carDto, Integer userId, Date createDate) { | |
| 37 | - UserDto userDto = UserDto.getBuilder() | |
| 38 | - .setId(userId) | |
| 39 | - .build(); | |
| 40 | - carDto.setCreateBy(userDto); | |
| 41 | - carDto.setCreateDate(createDate); | |
| 42 | - } | |
| 43 | - @Override | |
| 44 | - public void setUpdateUserInfo(CarDto carDto, Integer userId, Date updateDate) { | |
| 45 | - UserDto userDto = UserDto.getBuilder() | |
| 46 | - .setId(userId) | |
| 47 | - .build(); | |
| 48 | - carDto.setUpdateBy(userDto); | |
| 49 | - carDto.setUpdateDate(updateDate); | |
| 50 | - } | |
| 51 | - | |
| 52 | - @Reference | |
| 53 | - private CarServiceFacade carServiceFacade; | |
| 54 | - @Override | |
| 55 | - protected BServiceFacade<Integer, CarDto> getBServiceFacade() { | |
| 56 | - return carServiceFacade; | |
| 57 | - } | |
| 58 | - | |
| 59 | - @RequestMapping(value = "/validate_zbh", method = RequestMethod.GET) | |
| 60 | - public Map<String, Object> validate_zbh(@RequestParam Map<String, Object> param) { | |
| 61 | - Map<String, Object> rtn = new HashMap<>(); | |
| 62 | - try { | |
| 63 | - // 自编号验证 | |
| 64 | - CarDto carDto = CarDto.getBuilder() | |
| 65 | - .setId(param.get("id_eq") == null ? | |
| 66 | - null : Integer.valueOf(param.get("id_eq").toString())) | |
| 67 | - .setInsideCode(param.get("insideCode_eq") == null ? | |
| 68 | - null : param.get("insideCode_eq").toString()) | |
| 69 | - .build(); | |
| 70 | - this.carServiceFacade.validate_repeat_nbbh(carDto); | |
| 71 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 72 | - } catch (Exception exp) { | |
| 73 | - rtn.put("status", ResponseCode.ERROR); | |
| 74 | - rtn.put("msg", exp.getMessage()); | |
| 75 | - } | |
| 76 | - return rtn; | |
| 77 | - } | |
| 78 | - | |
| 79 | - @RequestMapping(value = "/validate_clbh", method = RequestMethod.GET) | |
| 80 | - public Map<String, Object> validate_clbh(@RequestParam Map<String, Object> param) { | |
| 81 | - Map<String, Object> rtn = new HashMap<>(); | |
| 82 | - try { | |
| 83 | - // 车辆编号验证 | |
| 84 | - CarDto carDto = CarDto.getBuilder() | |
| 85 | - .setId(param.get("id_eq") == null ? | |
| 86 | - null : Integer.valueOf(param.get("id_eq").toString())) | |
| 87 | - .setCarCode(param.get("carCode_eq") == null ? | |
| 88 | - null : param.get("carCode_eq").toString()) | |
| 89 | - .build(); | |
| 90 | - this.carServiceFacade.validate_repeat_clbh(carDto); | |
| 91 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 92 | - } catch (Exception exp) { | |
| 93 | - rtn.put("status", ResponseCode.ERROR); | |
| 94 | - rtn.put("msg", exp.getMessage()); | |
| 95 | - } | |
| 96 | - return rtn; | |
| 97 | - } | |
| 98 | - | |
| 99 | - @RequestMapping(value = "/validate_cph", method = RequestMethod.GET) | |
| 100 | - public Map<String, Object> validate_cph(@RequestParam Map<String, Object> param) { | |
| 101 | - Map<String, Object> rtn = new HashMap<>(); | |
| 102 | - try { | |
| 103 | - // 车牌号验证 | |
| 104 | - CarDto carDto = CarDto.getBuilder() | |
| 105 | - .setId(param.get("id_eq") == null ? | |
| 106 | - null : Integer.valueOf(param.get("id_eq").toString())) | |
| 107 | - .setCarPlate(param.get("carPlate_eq") == null ? | |
| 108 | - null : param.get("carPlate_eq").toString()) | |
| 109 | - .build(); | |
| 110 | - this.carServiceFacade.validate_repeat_cph(carDto); | |
| 111 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 112 | - } catch (Exception exp) { | |
| 113 | - rtn.put("status", ResponseCode.ERROR); | |
| 114 | - rtn.put("msg", exp.getMessage()); | |
| 115 | - } | |
| 116 | - return rtn; | |
| 117 | - } | |
| 118 | - | |
| 119 | - @RequestMapping(value = "/validate_sbbh", method = RequestMethod.GET) | |
| 120 | - public Map<String, Object> validate_sbbh(@RequestParam Map<String, Object> param) { | |
| 121 | - Map<String, Object> rtn = new HashMap<>(); | |
| 122 | - try { | |
| 123 | - // 设备编号验证 | |
| 124 | - CarDto carDto = CarDto.getBuilder() | |
| 125 | - .setId(param.get("id_eq") == null ? | |
| 126 | - null : Integer.valueOf(param.get("id_eq").toString())) | |
| 127 | - .setEquipmentCode(param.get("equipmentCode_eq") == null ? | |
| 128 | - null : param.get("equipmentCode_eq").toString()) | |
| 129 | - .build(); | |
| 130 | - this.carServiceFacade.validate_repeat_sbbh(carDto); | |
| 131 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 132 | - } catch (Exception exp) { | |
| 133 | - rtn.put("status", ResponseCode.ERROR); | |
| 134 | - rtn.put("msg", exp.getMessage()); | |
| 135 | - } | |
| 136 | - return rtn; | |
| 137 | - } | |
| 138 | - | |
| 139 | - //------------------ TODO:导入导出逻辑,之后会服务化 -----------------// | |
| 140 | - @Autowired | |
| 141 | - private CarsService carsService; | |
| 142 | - // 上传excel文件 | |
| 143 | - @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 144 | - public Map<String, Object> uploadFile(MultipartFile file) { | |
| 145 | - Map<String, Object> rtn = new HashMap<>(); | |
| 146 | - try { | |
| 147 | - DataToolsFile dataToolsFile = carsService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 148 | - // excel文件名 | |
| 149 | - String fileName = dataToolsFile.getFile().getAbsolutePath(); | |
| 150 | - Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile()); | |
| 151 | - | |
| 152 | - // excel文件sheet | |
| 153 | - List<String> sheetnames = new ArrayList<>(); | |
| 154 | - for (int i = 0; i < wb.getNumberOfSheets(); i ++) { | |
| 155 | - sheetnames.add(wb.getSheetAt(i).getSheetName()); | |
| 156 | - } | |
| 157 | - | |
| 158 | - wb.close(); | |
| 159 | - | |
| 160 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 161 | - rtn.put("filename", fileName); | |
| 162 | - rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | |
| 163 | - } catch (Exception exp) { | |
| 164 | - exp.printStackTrace(); | |
| 165 | - rtn.put("status", ResponseCode.ERROR); | |
| 166 | - rtn.put("msg", exp.getMessage()); | |
| 167 | - } | |
| 168 | - return rtn; | |
| 169 | - } | |
| 170 | - // 导入excel文件 | |
| 171 | - @RequestMapping(value = "/importFile", method = RequestMethod.POST) | |
| 172 | - public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | |
| 173 | - Map<String, Object> rtn = new HashMap<>(); | |
| 174 | - | |
| 175 | - try { | |
| 176 | - File file = new File(String.valueOf(params.get("filename"))); | |
| 177 | - if (!file.exists()) { | |
| 178 | - throw new Exception("导入文件不存在!"); | |
| 179 | - } | |
| 180 | - carsService.importData(file, params); | |
| 181 | - | |
| 182 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 183 | - rtn.put("msg", "导入文件成功"); | |
| 184 | - } catch (Exception exp) { | |
| 185 | - rtn.put("status", ResponseCode.ERROR); | |
| 186 | - rtn.put("msg", exp.getMessage()); | |
| 187 | - } | |
| 188 | - | |
| 189 | - return rtn; | |
| 190 | - } | |
| 191 | - // 上传并导入excel文件 | |
| 192 | - @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | |
| 193 | - public Map<String, Object> uploadAndImportFile(MultipartFile file) { | |
| 194 | - Map<String, Object> rtn = new HashMap<>(); | |
| 195 | - | |
| 196 | - try { | |
| 197 | - DataToolsFile dataToolsFile = carsService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 198 | - Map<String, Object> params = new HashMap<>(); | |
| 199 | - carsService.importData(dataToolsFile.getFile(), params); | |
| 200 | - | |
| 201 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 202 | - rtn.put("msg", "上传&导入文件成功"); | |
| 203 | - } catch (Exception exp) { | |
| 204 | - exp.printStackTrace(); | |
| 205 | - rtn.put("status", ResponseCode.ERROR); | |
| 206 | - rtn.put("msg", exp.getMessage()); | |
| 207 | - } | |
| 208 | - | |
| 209 | - return rtn; | |
| 210 | - } | |
| 211 | - | |
| 212 | - // 导出数据到xls文件 | |
| 213 | - @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | |
| 214 | - public void exportFile(HttpServletResponse response, | |
| 215 | - @RequestParam Map<String, Object> params) throws Exception { | |
| 216 | - DataToolsFile dataToolsFile = carsService.exportData(params); | |
| 217 | - // 流输出导出文件 | |
| 218 | - response.setHeader("content-type", "application/octet-stream"); | |
| 219 | - response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName()); | |
| 220 | - response.setContentType("application/octet-stream"); | |
| 221 | - | |
| 222 | - OutputStream os = response.getOutputStream(); | |
| 223 | - BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 224 | - | |
| 225 | - InputStream is = new FileInputStream(dataToolsFile.getFile()); | |
| 226 | - BufferedInputStream bis = new BufferedInputStream(is); | |
| 227 | - | |
| 228 | - int length = 0; | |
| 229 | - byte[] temp = new byte[1 * 1024 * 10]; | |
| 230 | - while ((length = bis.read(temp)) != -1) { | |
| 231 | - bos.write(temp, 0, length); | |
| 232 | - } | |
| 233 | - bos.flush(); | |
| 234 | - bis.close(); | |
| 235 | - bos.close(); | |
| 236 | - is.close(); | |
| 237 | - } | |
| 238 | - | |
| 239 | - | |
| 240 | - | |
| 241 | - | |
| 242 | -} | |
| 1 | +package com.bsth.controller.schedule.basicinfo; | |
| 2 | + | |
| 3 | +import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | +import com.bsth.common.ResponseCode; | |
| 5 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 6 | +import com.bsth.control_v2.plan_module.common.dto.baseinfo.CarDto; | |
| 7 | +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 8 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 9 | +import com.bsth.control_v2.plan_module.common.service.baseinfo.CarServiceFacade; | |
| 10 | +import com.bsth.controller.schedule.BController_facade; | |
| 11 | +import com.bsth.service.schedule.CarsService; | |
| 12 | +import com.bsth.service.schedule.utils.DataToolsFile; | |
| 13 | +import org.apache.commons.lang3.StringUtils; | |
| 14 | +import org.apache.poi.ss.usermodel.Workbook; | |
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | +import org.springframework.context.annotation.Conditional; | |
| 17 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 18 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 19 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 20 | +import org.springframework.web.bind.annotation.RestController; | |
| 21 | +import org.springframework.web.multipart.MultipartFile; | |
| 22 | + | |
| 23 | +import javax.servlet.http.HttpServletResponse; | |
| 24 | +import java.io.*; | |
| 25 | +import java.util.*; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * 车辆基础信息controller_facade | |
| 29 | + */ | |
| 30 | +@RestController | |
| 31 | +@Conditional(DubboConfigCondition.class) | |
| 32 | +@RequestMapping("cars_sc") | |
| 33 | +public class CarController_facade extends BController_facade<Integer, CarDto> { | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public void setCreateUserInfo(CarDto carDto, Integer userId, Date createDate) { | |
| 37 | + UserDto userDto = UserDto.getBuilder() | |
| 38 | + .setId(userId) | |
| 39 | + .build(); | |
| 40 | + carDto.setCreateBy(userDto); | |
| 41 | + carDto.setCreateDate(createDate); | |
| 42 | + } | |
| 43 | + @Override | |
| 44 | + public void setUpdateUserInfo(CarDto carDto, Integer userId, Date updateDate) { | |
| 45 | + UserDto userDto = UserDto.getBuilder() | |
| 46 | + .setId(userId) | |
| 47 | + .build(); | |
| 48 | + carDto.setUpdateBy(userDto); | |
| 49 | + carDto.setUpdateDate(updateDate); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Reference | |
| 53 | + private CarServiceFacade carServiceFacade; | |
| 54 | + @Override | |
| 55 | + protected BServiceFacade<Integer, CarDto> getBServiceFacade() { | |
| 56 | + return carServiceFacade; | |
| 57 | + } | |
| 58 | + | |
| 59 | + @RequestMapping(value = "/validate_zbh", method = RequestMethod.GET) | |
| 60 | + public Map<String, Object> validate_zbh(@RequestParam Map<String, Object> param) { | |
| 61 | + Map<String, Object> rtn = new HashMap<>(); | |
| 62 | + try { | |
| 63 | + // 自编号验证 | |
| 64 | + CarDto carDto = CarDto.getBuilder() | |
| 65 | + .setId(param.get("id_eq") == null ? | |
| 66 | + null : Integer.valueOf(param.get("id_eq").toString())) | |
| 67 | + .setInsideCode(param.get("insideCode_eq") == null ? | |
| 68 | + null : param.get("insideCode_eq").toString()) | |
| 69 | + .build(); | |
| 70 | + this.carServiceFacade.validate_repeat_nbbh(carDto); | |
| 71 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 72 | + } catch (Exception exp) { | |
| 73 | + rtn.put("status", ResponseCode.ERROR); | |
| 74 | + rtn.put("msg", exp.getMessage()); | |
| 75 | + } | |
| 76 | + return rtn; | |
| 77 | + } | |
| 78 | + | |
| 79 | + @RequestMapping(value = "/validate_clbh", method = RequestMethod.GET) | |
| 80 | + public Map<String, Object> validate_clbh(@RequestParam Map<String, Object> param) { | |
| 81 | + Map<String, Object> rtn = new HashMap<>(); | |
| 82 | + try { | |
| 83 | + // 车辆编号验证 | |
| 84 | + CarDto carDto = CarDto.getBuilder() | |
| 85 | + .setId(param.get("id_eq") == null ? | |
| 86 | + null : Integer.valueOf(param.get("id_eq").toString())) | |
| 87 | + .setCarCode(param.get("carCode_eq") == null ? | |
| 88 | + null : param.get("carCode_eq").toString()) | |
| 89 | + .build(); | |
| 90 | + this.carServiceFacade.validate_repeat_clbh(carDto); | |
| 91 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 92 | + } catch (Exception exp) { | |
| 93 | + rtn.put("status", ResponseCode.ERROR); | |
| 94 | + rtn.put("msg", exp.getMessage()); | |
| 95 | + } | |
| 96 | + return rtn; | |
| 97 | + } | |
| 98 | + | |
| 99 | + @RequestMapping(value = "/validate_cph", method = RequestMethod.GET) | |
| 100 | + public Map<String, Object> validate_cph(@RequestParam Map<String, Object> param) { | |
| 101 | + Map<String, Object> rtn = new HashMap<>(); | |
| 102 | + try { | |
| 103 | + // 车牌号验证 | |
| 104 | + CarDto carDto = CarDto.getBuilder() | |
| 105 | + .setId(param.get("id_eq") == null ? | |
| 106 | + null : Integer.valueOf(param.get("id_eq").toString())) | |
| 107 | + .setCarPlate(param.get("carPlate_eq") == null ? | |
| 108 | + null : param.get("carPlate_eq").toString()) | |
| 109 | + .build(); | |
| 110 | + this.carServiceFacade.validate_repeat_cph(carDto); | |
| 111 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 112 | + } catch (Exception exp) { | |
| 113 | + rtn.put("status", ResponseCode.ERROR); | |
| 114 | + rtn.put("msg", exp.getMessage()); | |
| 115 | + } | |
| 116 | + return rtn; | |
| 117 | + } | |
| 118 | + | |
| 119 | + @RequestMapping(value = "/validate_sbbh", method = RequestMethod.GET) | |
| 120 | + public Map<String, Object> validate_sbbh(@RequestParam Map<String, Object> param) { | |
| 121 | + Map<String, Object> rtn = new HashMap<>(); | |
| 122 | + try { | |
| 123 | + // 设备编号验证 | |
| 124 | + CarDto carDto = CarDto.getBuilder() | |
| 125 | + .setId(param.get("id_eq") == null ? | |
| 126 | + null : Integer.valueOf(param.get("id_eq").toString())) | |
| 127 | + .setEquipmentCode(param.get("equipmentCode_eq") == null ? | |
| 128 | + null : param.get("equipmentCode_eq").toString()) | |
| 129 | + .build(); | |
| 130 | + this.carServiceFacade.validate_repeat_sbbh(carDto); | |
| 131 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 132 | + } catch (Exception exp) { | |
| 133 | + rtn.put("status", ResponseCode.ERROR); | |
| 134 | + rtn.put("msg", exp.getMessage()); | |
| 135 | + } | |
| 136 | + return rtn; | |
| 137 | + } | |
| 138 | + | |
| 139 | + //------------------ TODO:导入导出逻辑,之后会服务化 -----------------// | |
| 140 | + @Autowired | |
| 141 | + private CarsService carsService; | |
| 142 | + // 上传excel文件 | |
| 143 | + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 144 | + public Map<String, Object> uploadFile(MultipartFile file) { | |
| 145 | + Map<String, Object> rtn = new HashMap<>(); | |
| 146 | + try { | |
| 147 | + DataToolsFile dataToolsFile = carsService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 148 | + // excel文件名 | |
| 149 | + String fileName = dataToolsFile.getFile().getAbsolutePath(); | |
| 150 | + Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile()); | |
| 151 | + | |
| 152 | + // excel文件sheet | |
| 153 | + List<String> sheetnames = new ArrayList<>(); | |
| 154 | + for (int i = 0; i < wb.getNumberOfSheets(); i ++) { | |
| 155 | + sheetnames.add(wb.getSheetAt(i).getSheetName()); | |
| 156 | + } | |
| 157 | + | |
| 158 | + wb.close(); | |
| 159 | + | |
| 160 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 161 | + rtn.put("filename", fileName); | |
| 162 | + rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | |
| 163 | + } catch (Exception exp) { | |
| 164 | + exp.printStackTrace(); | |
| 165 | + rtn.put("status", ResponseCode.ERROR); | |
| 166 | + rtn.put("msg", exp.getMessage()); | |
| 167 | + } | |
| 168 | + return rtn; | |
| 169 | + } | |
| 170 | + // 导入excel文件 | |
| 171 | + @RequestMapping(value = "/importFile", method = RequestMethod.POST) | |
| 172 | + public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | |
| 173 | + Map<String, Object> rtn = new HashMap<>(); | |
| 174 | + | |
| 175 | + try { | |
| 176 | + File file = new File(String.valueOf(params.get("filename"))); | |
| 177 | + if (!file.exists()) { | |
| 178 | + throw new Exception("导入文件不存在!"); | |
| 179 | + } | |
| 180 | + carsService.importData(file, params); | |
| 181 | + | |
| 182 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 183 | + rtn.put("msg", "导入文件成功"); | |
| 184 | + } catch (Exception exp) { | |
| 185 | + rtn.put("status", ResponseCode.ERROR); | |
| 186 | + rtn.put("msg", exp.getMessage()); | |
| 187 | + } | |
| 188 | + | |
| 189 | + return rtn; | |
| 190 | + } | |
| 191 | + // 上传并导入excel文件 | |
| 192 | + @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | |
| 193 | + public Map<String, Object> uploadAndImportFile(MultipartFile file) { | |
| 194 | + Map<String, Object> rtn = new HashMap<>(); | |
| 195 | + | |
| 196 | + try { | |
| 197 | + DataToolsFile dataToolsFile = carsService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 198 | + Map<String, Object> params = new HashMap<>(); | |
| 199 | + carsService.importData(dataToolsFile.getFile(), params); | |
| 200 | + | |
| 201 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 202 | + rtn.put("msg", "上传&导入文件成功"); | |
| 203 | + } catch (Exception exp) { | |
| 204 | + exp.printStackTrace(); | |
| 205 | + rtn.put("status", ResponseCode.ERROR); | |
| 206 | + rtn.put("msg", exp.getMessage()); | |
| 207 | + } | |
| 208 | + | |
| 209 | + return rtn; | |
| 210 | + } | |
| 211 | + | |
| 212 | + // 导出数据到xls文件 | |
| 213 | + @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | |
| 214 | + public void exportFile(HttpServletResponse response, | |
| 215 | + @RequestParam Map<String, Object> params) throws Exception { | |
| 216 | + DataToolsFile dataToolsFile = carsService.exportData(params); | |
| 217 | + // 流输出导出文件 | |
| 218 | + response.setHeader("content-type", "application/octet-stream"); | |
| 219 | + response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName()); | |
| 220 | + response.setContentType("application/octet-stream"); | |
| 221 | + | |
| 222 | + OutputStream os = response.getOutputStream(); | |
| 223 | + BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 224 | + | |
| 225 | + InputStream is = new FileInputStream(dataToolsFile.getFile()); | |
| 226 | + BufferedInputStream bis = new BufferedInputStream(is); | |
| 227 | + | |
| 228 | + int length = 0; | |
| 229 | + byte[] temp = new byte[1 * 1024 * 10]; | |
| 230 | + while ((length = bis.read(temp)) != -1) { | |
| 231 | + bos.write(temp, 0, length); | |
| 232 | + } | |
| 233 | + bos.flush(); | |
| 234 | + bis.close(); | |
| 235 | + bos.close(); | |
| 236 | + is.close(); | |
| 237 | + } | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/basicinfo/CarDeviceController_facade.java
| 1 | -package com.bsth.controller.schedule.basicinfo; | |
| 2 | - | |
| 3 | -import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | -import com.bsth.common.ResponseCode; | |
| 5 | -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 6 | -import com.bsth.control_v2.plan_module.common.dto.baseinfo.CarDeviceDto; | |
| 7 | -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 8 | -import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 9 | -import com.bsth.control_v2.plan_module.common.service.baseinfo.CarDeviceServiceFacade; | |
| 10 | -import com.bsth.controller.schedule.BController_facade; | |
| 11 | -import org.joda.time.DateTime; | |
| 12 | -import org.springframework.context.annotation.Conditional; | |
| 13 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 14 | -import org.springframework.web.bind.annotation.RequestMethod; | |
| 15 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 16 | -import org.springframework.web.bind.annotation.RestController; | |
| 17 | - | |
| 18 | -import java.util.Date; | |
| 19 | -import java.util.HashMap; | |
| 20 | -import java.util.Map; | |
| 21 | - | |
| 22 | -@RestController | |
| 23 | -@Conditional(DubboConfigCondition.class) | |
| 24 | -@RequestMapping("cde_sc") | |
| 25 | -public class CarDeviceController_facade extends BController_facade<Long, CarDeviceDto> { | |
| 26 | - @Override | |
| 27 | - public void setCreateUserInfo(CarDeviceDto carDeviceDto, Integer userId, Date createDate) { | |
| 28 | - UserDto userDto = UserDto.getBuilder() | |
| 29 | - .setId(userId) | |
| 30 | - .build(); | |
| 31 | - carDeviceDto.setCreateBy(userDto); | |
| 32 | - carDeviceDto.setCreateDate(createDate); | |
| 33 | - } | |
| 34 | - | |
| 35 | - @Override | |
| 36 | - public void setUpdateUserInfo(CarDeviceDto carDeviceDto, Integer userId, Date updateDate) { | |
| 37 | - UserDto userDto = UserDto.getBuilder() | |
| 38 | - .setId(userId) | |
| 39 | - .build(); | |
| 40 | - carDeviceDto.setUpdateBy(userDto); | |
| 41 | - carDeviceDto.setUpdateDate(updateDate); | |
| 42 | - } | |
| 43 | - | |
| 44 | - @Reference | |
| 45 | - private CarDeviceServiceFacade carDeviceServiceFacade; | |
| 46 | - | |
| 47 | - @Override | |
| 48 | - protected BServiceFacade<Long, CarDeviceDto> getBServiceFacade() { | |
| 49 | - return carDeviceServiceFacade; | |
| 50 | - } | |
| 51 | - @RequestMapping(value = "/validate_qyrq", method = RequestMethod.GET) | |
| 52 | - public Map<String, Object> validate_qyrq(@RequestParam Map<String, Object> param) { | |
| 53 | - Map<String, Object> rtn = new HashMap<>(); | |
| 54 | - | |
| 55 | - try { | |
| 56 | - // 启用日期验证 | |
| 57 | - // 计算日期 | |
| 58 | - Date qyrq_c = null; | |
| 59 | - if (param.get("qyrq_eq") != null) { | |
| 60 | - try { | |
| 61 | - qyrq_c = new Date(); | |
| 62 | - qyrq_c.setTime(Long.parseLong(param.get("qyrq_eq").toString())); | |
| 63 | - } catch (Exception exp) { | |
| 64 | - qyrq_c = new DateTime(param.get("qyrq_eq").toString()).toDate(); | |
| 65 | - } | |
| 66 | - } | |
| 67 | - | |
| 68 | - CarDeviceDto carDeviceDto = CarDeviceDto.getBuilder() | |
| 69 | - .setId(param.get("id_eq") == null ? | |
| 70 | - null : Long.valueOf(param.get("id_eq").toString())) | |
| 71 | - .setXl(param.get("xl_eq") == null ? | |
| 72 | - null : Integer.valueOf(param.get("xl_eq").toString())) | |
| 73 | - .setCl(param.get("cl_eq") == null ? | |
| 74 | - null : Integer.valueOf(param.get("cl_eq").toString())) | |
| 75 | - .setQyrq(qyrq_c) | |
| 76 | - .build(); | |
| 77 | - | |
| 78 | - this.carDeviceServiceFacade.validate_qyrq(carDeviceDto); | |
| 79 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 80 | - } catch (Exception exp) { | |
| 81 | - rtn.put("status", ResponseCode.ERROR); | |
| 82 | - rtn.put("msg", exp.getMessage()); | |
| 83 | - } | |
| 84 | - | |
| 85 | - return rtn; | |
| 86 | - } | |
| 87 | -} | |
| 1 | +package com.bsth.controller.schedule.basicinfo; | |
| 2 | + | |
| 3 | +import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | +import com.bsth.common.ResponseCode; | |
| 5 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 6 | +import com.bsth.control_v2.plan_module.common.dto.baseinfo.CarDeviceDto; | |
| 7 | +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 8 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 9 | +import com.bsth.control_v2.plan_module.common.service.baseinfo.CarDeviceServiceFacade; | |
| 10 | +import com.bsth.controller.schedule.BController_facade; | |
| 11 | +import org.joda.time.DateTime; | |
| 12 | +import org.springframework.context.annotation.Conditional; | |
| 13 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 14 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 15 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 16 | +import org.springframework.web.bind.annotation.RestController; | |
| 17 | + | |
| 18 | +import java.util.Date; | |
| 19 | +import java.util.HashMap; | |
| 20 | +import java.util.Map; | |
| 21 | + | |
| 22 | +@RestController | |
| 23 | +@Conditional(DubboConfigCondition.class) | |
| 24 | +@RequestMapping("cde_sc") | |
| 25 | +public class CarDeviceController_facade extends BController_facade<Long, CarDeviceDto> { | |
| 26 | + @Override | |
| 27 | + public void setCreateUserInfo(CarDeviceDto carDeviceDto, Integer userId, Date createDate) { | |
| 28 | + UserDto userDto = UserDto.getBuilder() | |
| 29 | + .setId(userId) | |
| 30 | + .build(); | |
| 31 | + carDeviceDto.setCreateBy(userDto); | |
| 32 | + carDeviceDto.setCreateDate(createDate); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public void setUpdateUserInfo(CarDeviceDto carDeviceDto, Integer userId, Date updateDate) { | |
| 37 | + UserDto userDto = UserDto.getBuilder() | |
| 38 | + .setId(userId) | |
| 39 | + .build(); | |
| 40 | + carDeviceDto.setUpdateBy(userDto); | |
| 41 | + carDeviceDto.setUpdateDate(updateDate); | |
| 42 | + } | |
| 43 | + | |
| 44 | + @Reference | |
| 45 | + private CarDeviceServiceFacade carDeviceServiceFacade; | |
| 46 | + | |
| 47 | + @Override | |
| 48 | + protected BServiceFacade<Long, CarDeviceDto> getBServiceFacade() { | |
| 49 | + return carDeviceServiceFacade; | |
| 50 | + } | |
| 51 | + @RequestMapping(value = "/validate_qyrq", method = RequestMethod.GET) | |
| 52 | + public Map<String, Object> validate_qyrq(@RequestParam Map<String, Object> param) { | |
| 53 | + Map<String, Object> rtn = new HashMap<>(); | |
| 54 | + | |
| 55 | + try { | |
| 56 | + // 启用日期验证 | |
| 57 | + // 计算日期 | |
| 58 | + Date qyrq_c = null; | |
| 59 | + if (param.get("qyrq_eq") != null) { | |
| 60 | + try { | |
| 61 | + qyrq_c = new Date(); | |
| 62 | + qyrq_c.setTime(Long.parseLong(param.get("qyrq_eq").toString())); | |
| 63 | + } catch (Exception exp) { | |
| 64 | + qyrq_c = new DateTime(param.get("qyrq_eq").toString()).toDate(); | |
| 65 | + } | |
| 66 | + } | |
| 67 | + | |
| 68 | + CarDeviceDto carDeviceDto = CarDeviceDto.getBuilder() | |
| 69 | + .setId(param.get("id_eq") == null ? | |
| 70 | + null : Long.valueOf(param.get("id_eq").toString())) | |
| 71 | + .setXl(param.get("xl_eq") == null ? | |
| 72 | + null : Integer.valueOf(param.get("xl_eq").toString())) | |
| 73 | + .setCl(param.get("cl_eq") == null ? | |
| 74 | + null : Integer.valueOf(param.get("cl_eq").toString())) | |
| 75 | + .setQyrq(qyrq_c) | |
| 76 | + .build(); | |
| 77 | + | |
| 78 | + this.carDeviceServiceFacade.validate_qyrq(carDeviceDto); | |
| 79 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 80 | + } catch (Exception exp) { | |
| 81 | + rtn.put("status", ResponseCode.ERROR); | |
| 82 | + rtn.put("msg", exp.getMessage()); | |
| 83 | + } | |
| 84 | + | |
| 85 | + return rtn; | |
| 86 | + } | |
| 87 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/basicinfo/EmployeeController_facade.java
| 1 | -package com.bsth.controller.schedule.basicinfo; | |
| 2 | - | |
| 3 | -import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | -import com.bsth.common.ResponseCode; | |
| 5 | -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 6 | -import com.bsth.control_v2.plan_module.common.dto.baseinfo.PersonnelDto; | |
| 7 | -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 8 | -import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 9 | -import com.bsth.control_v2.plan_module.common.service.baseinfo.PersonnelServiceFacade; | |
| 10 | -import com.bsth.controller.schedule.BController_facade; | |
| 11 | -import com.bsth.service.schedule.EmployeeService; | |
| 12 | -import com.bsth.service.schedule.utils.DataToolsFile; | |
| 13 | -import org.apache.commons.lang3.StringUtils; | |
| 14 | -import org.apache.poi.ss.usermodel.Workbook; | |
| 15 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | -import org.springframework.context.annotation.Conditional; | |
| 17 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 18 | -import org.springframework.web.bind.annotation.RequestMethod; | |
| 19 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 20 | -import org.springframework.web.bind.annotation.RestController; | |
| 21 | -import org.springframework.web.multipart.MultipartFile; | |
| 22 | - | |
| 23 | -import javax.servlet.http.HttpServletResponse; | |
| 24 | -import java.io.*; | |
| 25 | -import java.util.*; | |
| 26 | - | |
| 27 | -/** | |
| 28 | - * 人员基础信息Controller_facade | |
| 29 | - */ | |
| 30 | -@RestController | |
| 31 | -@Conditional(DubboConfigCondition.class) | |
| 32 | -@RequestMapping("ee") | |
| 33 | -public class EmployeeController_facade extends BController_facade<Integer, PersonnelDto> { | |
| 34 | - @Override | |
| 35 | - public void setCreateUserInfo(PersonnelDto personnelDto, Integer userId, Date createDate) { | |
| 36 | - UserDto userDto = UserDto.getBuilder() | |
| 37 | - .setId(userId) | |
| 38 | - .build(); | |
| 39 | - personnelDto.setCreateBy(userDto); | |
| 40 | - personnelDto.setCreateDate(createDate); | |
| 41 | - } | |
| 42 | - | |
| 43 | - @Override | |
| 44 | - public void setUpdateUserInfo(PersonnelDto personnelDto, Integer userId, Date updateDate) { | |
| 45 | - UserDto userDto = UserDto.getBuilder() | |
| 46 | - .setId(userId) | |
| 47 | - .build(); | |
| 48 | - personnelDto.setUpdateBy(userDto); | |
| 49 | - personnelDto.setUpdateDate(updateDate); | |
| 50 | - } | |
| 51 | - | |
| 52 | - @Reference | |
| 53 | - private PersonnelServiceFacade personnelServiceFacade; | |
| 54 | - @Override | |
| 55 | - protected BServiceFacade<Integer, PersonnelDto> getBServiceFacade() { | |
| 56 | - return personnelServiceFacade; | |
| 57 | - } | |
| 58 | - @RequestMapping(value = "/validate_gh", method = RequestMethod.GET) | |
| 59 | - public Map<String, Object> validate_gh(@RequestParam Map<String, Object> param) { | |
| 60 | - Map<String, Object> rtn = new HashMap<>(); | |
| 61 | - try { | |
| 62 | - // 工号验证 | |
| 63 | - PersonnelDto personnelDto = PersonnelDto.getBuilder() | |
| 64 | - .setId(param.get("id_eq") == null ? | |
| 65 | - null : Integer.valueOf(param.get("id_eq").toString())) | |
| 66 | - .setCompanyCode(param.get("companyCode_eq") == null ? | |
| 67 | - null : param.get("companyCode_eq").toString()) | |
| 68 | - .setJobCode(param.get("jobCode_eq") == null ? | |
| 69 | - null : param.get("jobCode_eq").toString()) | |
| 70 | - .build(); | |
| 71 | - this.personnelServiceFacade.validate_gh(personnelDto); | |
| 72 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 73 | - } catch (Exception exp) { | |
| 74 | - rtn.put("status", ResponseCode.ERROR); | |
| 75 | - rtn.put("msg", exp.getMessage()); | |
| 76 | - } | |
| 77 | - | |
| 78 | - return rtn; | |
| 79 | - } | |
| 80 | - | |
| 81 | - //------------------ TODO:导入导出逻辑,之后会服务化 -----------------// | |
| 82 | - @Autowired | |
| 83 | - private EmployeeService employeeService; | |
| 84 | - // 上传excel文件 | |
| 85 | - @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 86 | - public Map<String, Object> uploadFile(MultipartFile file) { | |
| 87 | - Map<String, Object> rtn = new HashMap<>(); | |
| 88 | - try { | |
| 89 | - DataToolsFile dataToolsFile = employeeService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 90 | - // excel文件名 | |
| 91 | - String fileName = dataToolsFile.getFile().getAbsolutePath(); | |
| 92 | - Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile()); | |
| 93 | - | |
| 94 | - // excel文件sheet | |
| 95 | - List<String> sheetnames = new ArrayList<>(); | |
| 96 | - for (int i = 0; i < wb.getNumberOfSheets(); i ++) { | |
| 97 | - sheetnames.add(wb.getSheetAt(i).getSheetName()); | |
| 98 | - } | |
| 99 | - | |
| 100 | - wb.close(); | |
| 101 | - | |
| 102 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 103 | - rtn.put("filename", fileName); | |
| 104 | - rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | |
| 105 | - } catch (Exception exp) { | |
| 106 | - exp.printStackTrace(); | |
| 107 | - rtn.put("status", ResponseCode.ERROR); | |
| 108 | - rtn.put("msg", exp.getMessage()); | |
| 109 | - } | |
| 110 | - return rtn; | |
| 111 | - } | |
| 112 | - // 导入excel文件 | |
| 113 | - @RequestMapping(value = "/importFile", method = RequestMethod.POST) | |
| 114 | - public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | |
| 115 | - Map<String, Object> rtn = new HashMap<>(); | |
| 116 | - | |
| 117 | - try { | |
| 118 | - File file = new File(String.valueOf(params.get("filename"))); | |
| 119 | - if (!file.exists()) { | |
| 120 | - throw new Exception("导入文件不存在!"); | |
| 121 | - } | |
| 122 | - employeeService.importData(file, params); | |
| 123 | - | |
| 124 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 125 | - rtn.put("msg", "导入文件成功"); | |
| 126 | - } catch (Exception exp) { | |
| 127 | - rtn.put("status", ResponseCode.ERROR); | |
| 128 | - rtn.put("msg", exp.getMessage()); | |
| 129 | - } | |
| 130 | - | |
| 131 | - return rtn; | |
| 132 | - } | |
| 133 | - // 上传并导入excel文件 | |
| 134 | - @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | |
| 135 | - public Map<String, Object> uploadAndImportFile(MultipartFile file) { | |
| 136 | - Map<String, Object> rtn = new HashMap<>(); | |
| 137 | - | |
| 138 | - try { | |
| 139 | - DataToolsFile dataToolsFile = employeeService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 140 | - Map<String, Object> params = new HashMap<>(); | |
| 141 | - employeeService.importData(dataToolsFile.getFile(), params); | |
| 142 | - | |
| 143 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 144 | - rtn.put("msg", "上传&导入文件成功"); | |
| 145 | - } catch (Exception exp) { | |
| 146 | - exp.printStackTrace(); | |
| 147 | - rtn.put("status", ResponseCode.ERROR); | |
| 148 | - rtn.put("msg", exp.getMessage()); | |
| 149 | - } | |
| 150 | - | |
| 151 | - return rtn; | |
| 152 | - } | |
| 153 | - | |
| 154 | - // 导出数据到xls文件 | |
| 155 | - @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | |
| 156 | - public void exportFile(HttpServletResponse response, | |
| 157 | - @RequestParam Map<String, Object> params) throws Exception { | |
| 158 | - DataToolsFile dataToolsFile = employeeService.exportData(params); | |
| 159 | - // 流输出导出文件 | |
| 160 | - response.setHeader("content-type", "application/octet-stream"); | |
| 161 | - response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName()); | |
| 162 | - response.setContentType("application/octet-stream"); | |
| 163 | - | |
| 164 | - OutputStream os = response.getOutputStream(); | |
| 165 | - BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 166 | - | |
| 167 | - InputStream is = new FileInputStream(dataToolsFile.getFile()); | |
| 168 | - BufferedInputStream bis = new BufferedInputStream(is); | |
| 169 | - | |
| 170 | - int length = 0; | |
| 171 | - byte[] temp = new byte[1 * 1024 * 10]; | |
| 172 | - while ((length = bis.read(temp)) != -1) { | |
| 173 | - bos.write(temp, 0, length); | |
| 174 | - } | |
| 175 | - bos.flush(); | |
| 176 | - bis.close(); | |
| 177 | - bos.close(); | |
| 178 | - is.close(); | |
| 179 | - } | |
| 180 | - | |
| 181 | -} | |
| 1 | +package com.bsth.controller.schedule.basicinfo; | |
| 2 | + | |
| 3 | +import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | +import com.bsth.common.ResponseCode; | |
| 5 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 6 | +import com.bsth.control_v2.plan_module.common.dto.baseinfo.PersonnelDto; | |
| 7 | +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 8 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 9 | +import com.bsth.control_v2.plan_module.common.service.baseinfo.PersonnelServiceFacade; | |
| 10 | +import com.bsth.controller.schedule.BController_facade; | |
| 11 | +import com.bsth.service.schedule.EmployeeService; | |
| 12 | +import com.bsth.service.schedule.utils.DataToolsFile; | |
| 13 | +import org.apache.commons.lang3.StringUtils; | |
| 14 | +import org.apache.poi.ss.usermodel.Workbook; | |
| 15 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 16 | +import org.springframework.context.annotation.Conditional; | |
| 17 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 18 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 19 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 20 | +import org.springframework.web.bind.annotation.RestController; | |
| 21 | +import org.springframework.web.multipart.MultipartFile; | |
| 22 | + | |
| 23 | +import javax.servlet.http.HttpServletResponse; | |
| 24 | +import java.io.*; | |
| 25 | +import java.util.*; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * 人员基础信息Controller_facade | |
| 29 | + */ | |
| 30 | +@RestController | |
| 31 | +@Conditional(DubboConfigCondition.class) | |
| 32 | +@RequestMapping("ee") | |
| 33 | +public class EmployeeController_facade extends BController_facade<Integer, PersonnelDto> { | |
| 34 | + @Override | |
| 35 | + public void setCreateUserInfo(PersonnelDto personnelDto, Integer userId, Date createDate) { | |
| 36 | + UserDto userDto = UserDto.getBuilder() | |
| 37 | + .setId(userId) | |
| 38 | + .build(); | |
| 39 | + personnelDto.setCreateBy(userDto); | |
| 40 | + personnelDto.setCreateDate(createDate); | |
| 41 | + } | |
| 42 | + | |
| 43 | + @Override | |
| 44 | + public void setUpdateUserInfo(PersonnelDto personnelDto, Integer userId, Date updateDate) { | |
| 45 | + UserDto userDto = UserDto.getBuilder() | |
| 46 | + .setId(userId) | |
| 47 | + .build(); | |
| 48 | + personnelDto.setUpdateBy(userDto); | |
| 49 | + personnelDto.setUpdateDate(updateDate); | |
| 50 | + } | |
| 51 | + | |
| 52 | + @Reference | |
| 53 | + private PersonnelServiceFacade personnelServiceFacade; | |
| 54 | + @Override | |
| 55 | + protected BServiceFacade<Integer, PersonnelDto> getBServiceFacade() { | |
| 56 | + return personnelServiceFacade; | |
| 57 | + } | |
| 58 | + @RequestMapping(value = "/validate_gh", method = RequestMethod.GET) | |
| 59 | + public Map<String, Object> validate_gh(@RequestParam Map<String, Object> param) { | |
| 60 | + Map<String, Object> rtn = new HashMap<>(); | |
| 61 | + try { | |
| 62 | + // 工号验证 | |
| 63 | + PersonnelDto personnelDto = PersonnelDto.getBuilder() | |
| 64 | + .setId(param.get("id_eq") == null ? | |
| 65 | + null : Integer.valueOf(param.get("id_eq").toString())) | |
| 66 | + .setCompanyCode(param.get("companyCode_eq") == null ? | |
| 67 | + null : param.get("companyCode_eq").toString()) | |
| 68 | + .setJobCode(param.get("jobCode_eq") == null ? | |
| 69 | + null : param.get("jobCode_eq").toString()) | |
| 70 | + .build(); | |
| 71 | + this.personnelServiceFacade.validate_gh(personnelDto); | |
| 72 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 73 | + } catch (Exception exp) { | |
| 74 | + rtn.put("status", ResponseCode.ERROR); | |
| 75 | + rtn.put("msg", exp.getMessage()); | |
| 76 | + } | |
| 77 | + | |
| 78 | + return rtn; | |
| 79 | + } | |
| 80 | + | |
| 81 | + //------------------ TODO:导入导出逻辑,之后会服务化 -----------------// | |
| 82 | + @Autowired | |
| 83 | + private EmployeeService employeeService; | |
| 84 | + // 上传excel文件 | |
| 85 | + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 86 | + public Map<String, Object> uploadFile(MultipartFile file) { | |
| 87 | + Map<String, Object> rtn = new HashMap<>(); | |
| 88 | + try { | |
| 89 | + DataToolsFile dataToolsFile = employeeService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 90 | + // excel文件名 | |
| 91 | + String fileName = dataToolsFile.getFile().getAbsolutePath(); | |
| 92 | + Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile()); | |
| 93 | + | |
| 94 | + // excel文件sheet | |
| 95 | + List<String> sheetnames = new ArrayList<>(); | |
| 96 | + for (int i = 0; i < wb.getNumberOfSheets(); i ++) { | |
| 97 | + sheetnames.add(wb.getSheetAt(i).getSheetName()); | |
| 98 | + } | |
| 99 | + | |
| 100 | + wb.close(); | |
| 101 | + | |
| 102 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 103 | + rtn.put("filename", fileName); | |
| 104 | + rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | |
| 105 | + } catch (Exception exp) { | |
| 106 | + exp.printStackTrace(); | |
| 107 | + rtn.put("status", ResponseCode.ERROR); | |
| 108 | + rtn.put("msg", exp.getMessage()); | |
| 109 | + } | |
| 110 | + return rtn; | |
| 111 | + } | |
| 112 | + // 导入excel文件 | |
| 113 | + @RequestMapping(value = "/importFile", method = RequestMethod.POST) | |
| 114 | + public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | |
| 115 | + Map<String, Object> rtn = new HashMap<>(); | |
| 116 | + | |
| 117 | + try { | |
| 118 | + File file = new File(String.valueOf(params.get("filename"))); | |
| 119 | + if (!file.exists()) { | |
| 120 | + throw new Exception("导入文件不存在!"); | |
| 121 | + } | |
| 122 | + employeeService.importData(file, params); | |
| 123 | + | |
| 124 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 125 | + rtn.put("msg", "导入文件成功"); | |
| 126 | + } catch (Exception exp) { | |
| 127 | + rtn.put("status", ResponseCode.ERROR); | |
| 128 | + rtn.put("msg", exp.getMessage()); | |
| 129 | + } | |
| 130 | + | |
| 131 | + return rtn; | |
| 132 | + } | |
| 133 | + // 上传并导入excel文件 | |
| 134 | + @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | |
| 135 | + public Map<String, Object> uploadAndImportFile(MultipartFile file) { | |
| 136 | + Map<String, Object> rtn = new HashMap<>(); | |
| 137 | + | |
| 138 | + try { | |
| 139 | + DataToolsFile dataToolsFile = employeeService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 140 | + Map<String, Object> params = new HashMap<>(); | |
| 141 | + employeeService.importData(dataToolsFile.getFile(), params); | |
| 142 | + | |
| 143 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 144 | + rtn.put("msg", "上传&导入文件成功"); | |
| 145 | + } catch (Exception exp) { | |
| 146 | + exp.printStackTrace(); | |
| 147 | + rtn.put("status", ResponseCode.ERROR); | |
| 148 | + rtn.put("msg", exp.getMessage()); | |
| 149 | + } | |
| 150 | + | |
| 151 | + return rtn; | |
| 152 | + } | |
| 153 | + | |
| 154 | + // 导出数据到xls文件 | |
| 155 | + @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | |
| 156 | + public void exportFile(HttpServletResponse response, | |
| 157 | + @RequestParam Map<String, Object> params) throws Exception { | |
| 158 | + DataToolsFile dataToolsFile = employeeService.exportData(params); | |
| 159 | + // 流输出导出文件 | |
| 160 | + response.setHeader("content-type", "application/octet-stream"); | |
| 161 | + response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName()); | |
| 162 | + response.setContentType("application/octet-stream"); | |
| 163 | + | |
| 164 | + OutputStream os = response.getOutputStream(); | |
| 165 | + BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 166 | + | |
| 167 | + InputStream is = new FileInputStream(dataToolsFile.getFile()); | |
| 168 | + BufferedInputStream bis = new BufferedInputStream(is); | |
| 169 | + | |
| 170 | + int length = 0; | |
| 171 | + byte[] temp = new byte[1 * 1024 * 10]; | |
| 172 | + while ((length = bis.read(temp)) != -1) { | |
| 173 | + bos.write(temp, 0, length); | |
| 174 | + } | |
| 175 | + bos.flush(); | |
| 176 | + bis.close(); | |
| 177 | + bos.close(); | |
| 178 | + is.close(); | |
| 179 | + } | |
| 180 | + | |
| 181 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/core/CarConfigInfoController_facade.java
| 1 | -package com.bsth.controller.schedule.core; | |
| 2 | - | |
| 3 | -import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | -import com.bsth.common.Constants; | |
| 5 | -import com.bsth.common.ResponseCode; | |
| 6 | -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 7 | -import com.bsth.control_v2.plan_module.common.dto.baseinfo.CarDto; | |
| 8 | -import com.bsth.control_v2.plan_module.common.dto.baseinfo.LineDto; | |
| 9 | -import com.bsth.control_v2.plan_module.common.dto.schedule.config.VehicleConfigDto; | |
| 10 | -import com.bsth.control_v2.plan_module.common.dto.sys.CompanyAuthorityDto; | |
| 11 | -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 12 | -import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 13 | -import com.bsth.control_v2.plan_module.common.service.schedule.config.VehicleConfigServiceFacade; | |
| 14 | -import com.bsth.controller.schedule.BController_facade; | |
| 15 | -import com.bsth.entity.sys.CompanyAuthority; | |
| 16 | -import com.bsth.service.schedule.CarConfigInfoService; | |
| 17 | -import com.bsth.service.schedule.utils.DataToolsFile; | |
| 18 | -import org.apache.commons.lang3.StringUtils; | |
| 19 | -import org.apache.poi.ss.usermodel.Workbook; | |
| 20 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 21 | -import org.springframework.context.annotation.Conditional; | |
| 22 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 23 | -import org.springframework.web.bind.annotation.RequestMethod; | |
| 24 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 25 | -import org.springframework.web.bind.annotation.RestController; | |
| 26 | -import org.springframework.web.multipart.MultipartFile; | |
| 27 | - | |
| 28 | -import javax.servlet.http.HttpServletRequest; | |
| 29 | -import javax.servlet.http.HttpServletResponse; | |
| 30 | -import javax.servlet.http.HttpSession; | |
| 31 | -import java.io.*; | |
| 32 | -import java.util.*; | |
| 33 | - | |
| 34 | -/** | |
| 35 | - * Created by xu on 16/5/9. | |
| 36 | - */ | |
| 37 | -@RestController | |
| 38 | -@Conditional(DubboConfigCondition.class) | |
| 39 | -@RequestMapping("cci") | |
| 40 | -public class CarConfigInfoController_facade extends BController_facade<Long, VehicleConfigDto> { | |
| 41 | - | |
| 42 | - @Override | |
| 43 | - public void setCreateUserInfo(VehicleConfigDto vehicleConfigDto, Integer userId, Date createDate) { | |
| 44 | - UserDto userDto = UserDto.getBuilder() | |
| 45 | - .setId(userId) | |
| 46 | - .build(); | |
| 47 | - vehicleConfigDto.setCreateBy(userDto); | |
| 48 | - vehicleConfigDto.setCreateDate(createDate); | |
| 49 | - } | |
| 50 | - | |
| 51 | - @Override | |
| 52 | - public void setUpdateUserInfo(VehicleConfigDto vehicleConfigDto, Integer userId, Date updateDate) { | |
| 53 | - UserDto userDto = UserDto.getBuilder() | |
| 54 | - .setId(userId) | |
| 55 | - .build(); | |
| 56 | - vehicleConfigDto.setUpdateBy(userDto); | |
| 57 | - vehicleConfigDto.setUpdateDate(updateDate); | |
| 58 | - } | |
| 59 | - | |
| 60 | - @Reference | |
| 61 | - private VehicleConfigServiceFacade vehicleConfigServiceFacade; | |
| 62 | - | |
| 63 | - @Override | |
| 64 | - protected BServiceFacade<Long, VehicleConfigDto> getBServiceFacade() { | |
| 65 | - return vehicleConfigServiceFacade; | |
| 66 | - } | |
| 67 | - | |
| 68 | - @RequestMapping(value = "/cars", method = RequestMethod.GET) | |
| 69 | - public List<Map<String, Object>> findCarConfigCars() { | |
| 70 | - return vehicleConfigServiceFacade.findCarsFromConfig_nbbm(); | |
| 71 | - } | |
| 72 | - | |
| 73 | - @RequestMapping(value = "/cars2", method = RequestMethod.GET) | |
| 74 | - public List<Map<String, Object>> findCarsFromConfig() { | |
| 75 | - return vehicleConfigServiceFacade.findCarsFromConfig_insideCode(); | |
| 76 | - } | |
| 77 | - | |
| 78 | - @RequestMapping(value = "/validate_cars", method = RequestMethod.GET) | |
| 79 | - public Map<String, Object> validate_cars(@RequestParam Map<String, Object> param) { | |
| 80 | - Map<String, Object> rtn = new HashMap<>(); | |
| 81 | - try { | |
| 82 | - VehicleConfigDto vehicleConfigDto = VehicleConfigDto.getBuilder() | |
| 83 | - .setId(param.get("id_eq") == null ? null : Long.parseLong(param.get("id_eq").toString())) | |
| 84 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 85 | - LineDto.getBuilder() | |
| 86 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 87 | - .setName(param.get("xl.name_eq").toString()) | |
| 88 | - .build() | |
| 89 | - )) | |
| 90 | - .setCl(param.get("cl.id_eq") == null ? null : ( | |
| 91 | - CarDto.getBuilder() | |
| 92 | - .setId(Integer.valueOf(param.get("cl.id_eq").toString())) | |
| 93 | - .build() | |
| 94 | - )) | |
| 95 | - .build(); | |
| 96 | - | |
| 97 | - vehicleConfigServiceFacade.validate_already_config(vehicleConfigDto); | |
| 98 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 99 | - } catch (Exception exp) { | |
| 100 | - rtn.put("status", ResponseCode.ERROR); | |
| 101 | - rtn.put("msg", exp.getMessage()); | |
| 102 | - } | |
| 103 | - | |
| 104 | - return rtn; | |
| 105 | - } | |
| 106 | - | |
| 107 | - @RequestMapping(value = "/validate_cars_2", method = RequestMethod.GET) | |
| 108 | - public Map<String, Object> validate_cars(@RequestParam Integer xlId, @RequestParam Integer clId) { | |
| 109 | - Map<String, Object> rtn = new HashMap<>(); | |
| 110 | - try { | |
| 111 | - VehicleConfigDto vehicleConfigDto = VehicleConfigDto.getBuilder() | |
| 112 | - .setXl(xlId == null ? null : (LineDto.getBuilder() | |
| 113 | - .setId(xlId) | |
| 114 | - .build())) | |
| 115 | - .setCl(clId == null ? null : (CarDto.getBuilder() | |
| 116 | - .setId(clId) | |
| 117 | - .build())) | |
| 118 | - .build(); | |
| 119 | - | |
| 120 | - vehicleConfigServiceFacade.validate_already_config(vehicleConfigDto); | |
| 121 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 122 | - } catch (Exception exp) { | |
| 123 | - rtn.put("status", ResponseCode.ERROR); | |
| 124 | - rtn.put("msg", exp.getMessage()); | |
| 125 | - } | |
| 126 | - | |
| 127 | - return rtn; | |
| 128 | - } | |
| 129 | - | |
| 130 | - @RequestMapping(value = "/validate_cars_gs", method = RequestMethod.GET) | |
| 131 | - public Map<String, Object> validate_cars_gs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 132 | - HttpSession session = request.getSession(); | |
| 133 | - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 134 | - List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 135 | - for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 136 | - CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 137 | - .setId(companyAuthority.getId()) | |
| 138 | - .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 139 | - .setCompanyName(companyAuthority.getCompanyName()) | |
| 140 | - .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 141 | - .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 142 | - .build(); | |
| 143 | - companyAuthorityDtoList.add(companyAuthorityDto); | |
| 144 | - } | |
| 145 | - | |
| 146 | - Map<String, Object> rtn = new HashMap<>(); | |
| 147 | - try { | |
| 148 | - VehicleConfigDto vehicleConfigDto = VehicleConfigDto.getBuilder() | |
| 149 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 150 | - LineDto.getBuilder() | |
| 151 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 152 | - .setName(param.get("xl.name_eq").toString()) | |
| 153 | - .build() | |
| 154 | - )) | |
| 155 | - .setCl(param.get("cl.id_eq") == null ? null : ( | |
| 156 | - CarDto.getBuilder() | |
| 157 | - .setId(Integer.valueOf(param.get("cl.id_eq").toString())) | |
| 158 | - .build() | |
| 159 | - )) | |
| 160 | - .build(); | |
| 161 | - | |
| 162 | - vehicleConfigServiceFacade.validate_cars_gs(vehicleConfigDto, companyAuthorityDtoList); | |
| 163 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 164 | - } catch (Exception exp) { | |
| 165 | - rtn.put("status", ResponseCode.ERROR); | |
| 166 | - rtn.put("msg", exp.getMessage()); | |
| 167 | - } | |
| 168 | - | |
| 169 | - return rtn; | |
| 170 | - } | |
| 171 | - | |
| 172 | - @RequestMapping(value = "/validate_cars_fgs", method = RequestMethod.GET) | |
| 173 | - public Map<String, Object> validate_cars_fgs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 174 | - HttpSession session = request.getSession(); | |
| 175 | - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 176 | - List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 177 | - for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 178 | - CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 179 | - .setId(companyAuthority.getId()) | |
| 180 | - .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 181 | - .setCompanyName(companyAuthority.getCompanyName()) | |
| 182 | - .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 183 | - .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 184 | - .build(); | |
| 185 | - companyAuthorityDtoList.add(companyAuthorityDto); | |
| 186 | - } | |
| 187 | - | |
| 188 | - Map<String, Object> rtn = new HashMap<>(); | |
| 189 | - try { | |
| 190 | - VehicleConfigDto vehicleConfigDto = VehicleConfigDto.getBuilder() | |
| 191 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 192 | - LineDto.getBuilder() | |
| 193 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 194 | - .setName(param.get("xl.name_eq").toString()) | |
| 195 | - .build() | |
| 196 | - )) | |
| 197 | - .setCl(param.get("cl.id_eq") == null ? null : ( | |
| 198 | - CarDto.getBuilder() | |
| 199 | - .setId(Integer.valueOf(param.get("cl.id_eq").toString())) | |
| 200 | - .build() | |
| 201 | - )) | |
| 202 | - .build(); | |
| 203 | - | |
| 204 | - vehicleConfigServiceFacade.validate_cars_fgs(vehicleConfigDto, companyAuthorityDtoList); | |
| 205 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 206 | - } catch (Exception exp) { | |
| 207 | - rtn.put("status", ResponseCode.ERROR); | |
| 208 | - rtn.put("msg", exp.getMessage()); | |
| 209 | - } | |
| 210 | - | |
| 211 | - return rtn; | |
| 212 | - } | |
| 213 | - | |
| 214 | - @RequestMapping(value = "/validate_cars_config", method = RequestMethod.GET) | |
| 215 | - public Map<String, Object> validate_cars_config(@RequestParam Map<String, Object> param) { | |
| 216 | - Map<String, Object> rtn = new HashMap<>(); | |
| 217 | - try { | |
| 218 | - VehicleConfigDto vehicleConfigDto = VehicleConfigDto.getBuilder() | |
| 219 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 220 | - LineDto.getBuilder() | |
| 221 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 222 | - .setName(param.get("xl.name_eq").toString()) | |
| 223 | - .build() | |
| 224 | - )) | |
| 225 | - .setCl(param.get("cl.id_eq") == null ? null : ( | |
| 226 | - CarDto.getBuilder() | |
| 227 | - .setId(Integer.valueOf(param.get("cl.id_eq").toString())) | |
| 228 | - .build() | |
| 229 | - )) | |
| 230 | - .build(); | |
| 231 | - vehicleConfigServiceFacade.validate_config_exist(vehicleConfigDto); | |
| 232 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 233 | - } catch (Exception exp) { | |
| 234 | - rtn.put("status", ResponseCode.ERROR); | |
| 235 | - rtn.put("msg", exp.getMessage()); | |
| 236 | - } | |
| 237 | - | |
| 238 | - return rtn; | |
| 239 | - } | |
| 240 | - | |
| 241 | - //------------------ TODO:导入导出逻辑,之后会服务化 -----------------// | |
| 242 | - @Autowired | |
| 243 | - private CarConfigInfoService carConfigInfoService; | |
| 244 | - // 上传excel文件 | |
| 245 | - @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 246 | - public Map<String, Object> uploadFile(MultipartFile file) { | |
| 247 | - Map<String, Object> rtn = new HashMap<>(); | |
| 248 | - try { | |
| 249 | - DataToolsFile dataToolsFile = carConfigInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 250 | - // excel文件名 | |
| 251 | - String fileName = dataToolsFile.getFile().getAbsolutePath(); | |
| 252 | - Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile()); | |
| 253 | - | |
| 254 | - // excel文件sheet | |
| 255 | - List<String> sheetnames = new ArrayList<>(); | |
| 256 | - for (int i = 0; i < wb.getNumberOfSheets(); i ++) { | |
| 257 | - sheetnames.add(wb.getSheetAt(i).getSheetName()); | |
| 258 | - } | |
| 259 | - | |
| 260 | - wb.close(); | |
| 261 | - | |
| 262 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 263 | - rtn.put("filename", fileName); | |
| 264 | - rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | |
| 265 | - } catch (Exception exp) { | |
| 266 | - exp.printStackTrace(); | |
| 267 | - rtn.put("status", ResponseCode.ERROR); | |
| 268 | - rtn.put("msg", exp.getMessage()); | |
| 269 | - } | |
| 270 | - return rtn; | |
| 271 | - } | |
| 272 | - // 导入excel文件 | |
| 273 | - @RequestMapping(value = "/importFile", method = RequestMethod.POST) | |
| 274 | - public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | |
| 275 | - Map<String, Object> rtn = new HashMap<>(); | |
| 276 | - | |
| 277 | - try { | |
| 278 | - File file = new File(String.valueOf(params.get("filename"))); | |
| 279 | - if (!file.exists()) { | |
| 280 | - throw new Exception("导入文件不存在!"); | |
| 281 | - } | |
| 282 | - carConfigInfoService.importData(file, params); | |
| 283 | - | |
| 284 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 285 | - rtn.put("msg", "导入文件成功"); | |
| 286 | - } catch (Exception exp) { | |
| 287 | - rtn.put("status", ResponseCode.ERROR); | |
| 288 | - rtn.put("msg", exp.getMessage()); | |
| 289 | - } | |
| 290 | - | |
| 291 | - return rtn; | |
| 292 | - } | |
| 293 | - // 上传并导入excel文件 | |
| 294 | - @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | |
| 295 | - public Map<String, Object> uploadAndImportFile(MultipartFile file) { | |
| 296 | - Map<String, Object> rtn = new HashMap<>(); | |
| 297 | - | |
| 298 | - try { | |
| 299 | - DataToolsFile dataToolsFile = carConfigInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 300 | - Map<String, Object> params = new HashMap<>(); | |
| 301 | - carConfigInfoService.importData(dataToolsFile.getFile(), params); | |
| 302 | - | |
| 303 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 304 | - rtn.put("msg", "上传&导入文件成功"); | |
| 305 | - } catch (Exception exp) { | |
| 306 | - exp.printStackTrace(); | |
| 307 | - rtn.put("status", ResponseCode.ERROR); | |
| 308 | - rtn.put("msg", exp.getMessage()); | |
| 309 | - } | |
| 310 | - | |
| 311 | - return rtn; | |
| 312 | - } | |
| 313 | - | |
| 314 | - // 导出数据到xls文件 | |
| 315 | - @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | |
| 316 | - public void exportFile(HttpServletResponse response, | |
| 317 | - @RequestParam Map<String, Object> params) throws Exception { | |
| 318 | - DataToolsFile dataToolsFile = carConfigInfoService.exportData(params); | |
| 319 | - // 流输出导出文件 | |
| 320 | - response.setHeader("content-type", "application/octet-stream"); | |
| 321 | - response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName()); | |
| 322 | - response.setContentType("application/octet-stream"); | |
| 323 | - | |
| 324 | - OutputStream os = response.getOutputStream(); | |
| 325 | - BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 326 | - | |
| 327 | - InputStream is = new FileInputStream(dataToolsFile.getFile()); | |
| 328 | - BufferedInputStream bis = new BufferedInputStream(is); | |
| 329 | - | |
| 330 | - int length = 0; | |
| 331 | - byte[] temp = new byte[1 * 1024 * 10]; | |
| 332 | - while ((length = bis.read(temp)) != -1) { | |
| 333 | - bos.write(temp, 0, length); | |
| 334 | - } | |
| 335 | - bos.flush(); | |
| 336 | - bis.close(); | |
| 337 | - bos.close(); | |
| 338 | - is.close(); | |
| 339 | - } | |
| 340 | - | |
| 341 | - | |
| 342 | -} | |
| 1 | +package com.bsth.controller.schedule.core; | |
| 2 | + | |
| 3 | +import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | +import com.bsth.common.Constants; | |
| 5 | +import com.bsth.common.ResponseCode; | |
| 6 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 7 | +import com.bsth.control_v2.plan_module.common.dto.baseinfo.CarDto; | |
| 8 | +import com.bsth.control_v2.plan_module.common.dto.baseinfo.LineDto; | |
| 9 | +import com.bsth.control_v2.plan_module.common.dto.schedule.config.VehicleConfigDto; | |
| 10 | +import com.bsth.control_v2.plan_module.common.dto.sys.CompanyAuthorityDto; | |
| 11 | +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 12 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 13 | +import com.bsth.control_v2.plan_module.common.service.schedule.config.VehicleConfigServiceFacade; | |
| 14 | +import com.bsth.controller.schedule.BController_facade; | |
| 15 | +import com.bsth.entity.sys.CompanyAuthority; | |
| 16 | +import com.bsth.service.schedule.CarConfigInfoService; | |
| 17 | +import com.bsth.service.schedule.utils.DataToolsFile; | |
| 18 | +import org.apache.commons.lang3.StringUtils; | |
| 19 | +import org.apache.poi.ss.usermodel.Workbook; | |
| 20 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 21 | +import org.springframework.context.annotation.Conditional; | |
| 22 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 23 | +import org.springframework.web.bind.annotation.RequestMethod; | |
| 24 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 25 | +import org.springframework.web.bind.annotation.RestController; | |
| 26 | +import org.springframework.web.multipart.MultipartFile; | |
| 27 | + | |
| 28 | +import javax.servlet.http.HttpServletRequest; | |
| 29 | +import javax.servlet.http.HttpServletResponse; | |
| 30 | +import javax.servlet.http.HttpSession; | |
| 31 | +import java.io.*; | |
| 32 | +import java.util.*; | |
| 33 | + | |
| 34 | +/** | |
| 35 | + * Created by xu on 16/5/9. | |
| 36 | + */ | |
| 37 | +@RestController | |
| 38 | +@Conditional(DubboConfigCondition.class) | |
| 39 | +@RequestMapping("cci") | |
| 40 | +public class CarConfigInfoController_facade extends BController_facade<Long, VehicleConfigDto> { | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public void setCreateUserInfo(VehicleConfigDto vehicleConfigDto, Integer userId, Date createDate) { | |
| 44 | + UserDto userDto = UserDto.getBuilder() | |
| 45 | + .setId(userId) | |
| 46 | + .build(); | |
| 47 | + vehicleConfigDto.setCreateBy(userDto); | |
| 48 | + vehicleConfigDto.setCreateDate(createDate); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + public void setUpdateUserInfo(VehicleConfigDto vehicleConfigDto, Integer userId, Date updateDate) { | |
| 53 | + UserDto userDto = UserDto.getBuilder() | |
| 54 | + .setId(userId) | |
| 55 | + .build(); | |
| 56 | + vehicleConfigDto.setUpdateBy(userDto); | |
| 57 | + vehicleConfigDto.setUpdateDate(updateDate); | |
| 58 | + } | |
| 59 | + | |
| 60 | + @Reference | |
| 61 | + private VehicleConfigServiceFacade vehicleConfigServiceFacade; | |
| 62 | + | |
| 63 | + @Override | |
| 64 | + protected BServiceFacade<Long, VehicleConfigDto> getBServiceFacade() { | |
| 65 | + return vehicleConfigServiceFacade; | |
| 66 | + } | |
| 67 | + | |
| 68 | + @RequestMapping(value = "/cars", method = RequestMethod.GET) | |
| 69 | + public List<Map<String, Object>> findCarConfigCars() { | |
| 70 | + return vehicleConfigServiceFacade.findCarsFromConfig_nbbm(); | |
| 71 | + } | |
| 72 | + | |
| 73 | + @RequestMapping(value = "/cars2", method = RequestMethod.GET) | |
| 74 | + public List<Map<String, Object>> findCarsFromConfig() { | |
| 75 | + return vehicleConfigServiceFacade.findCarsFromConfig_insideCode(); | |
| 76 | + } | |
| 77 | + | |
| 78 | + @RequestMapping(value = "/validate_cars", method = RequestMethod.GET) | |
| 79 | + public Map<String, Object> validate_cars(@RequestParam Map<String, Object> param) { | |
| 80 | + Map<String, Object> rtn = new HashMap<>(); | |
| 81 | + try { | |
| 82 | + VehicleConfigDto vehicleConfigDto = VehicleConfigDto.getBuilder() | |
| 83 | + .setId(param.get("id_eq") == null ? null : Long.parseLong(param.get("id_eq").toString())) | |
| 84 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 85 | + LineDto.getBuilder() | |
| 86 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 87 | + .setName(param.get("xl.name_eq").toString()) | |
| 88 | + .build() | |
| 89 | + )) | |
| 90 | + .setCl(param.get("cl.id_eq") == null ? null : ( | |
| 91 | + CarDto.getBuilder() | |
| 92 | + .setId(Integer.valueOf(param.get("cl.id_eq").toString())) | |
| 93 | + .build() | |
| 94 | + )) | |
| 95 | + .build(); | |
| 96 | + | |
| 97 | + vehicleConfigServiceFacade.validate_already_config(vehicleConfigDto); | |
| 98 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 99 | + } catch (Exception exp) { | |
| 100 | + rtn.put("status", ResponseCode.ERROR); | |
| 101 | + rtn.put("msg", exp.getMessage()); | |
| 102 | + } | |
| 103 | + | |
| 104 | + return rtn; | |
| 105 | + } | |
| 106 | + | |
| 107 | + @RequestMapping(value = "/validate_cars_2", method = RequestMethod.GET) | |
| 108 | + public Map<String, Object> validate_cars(@RequestParam Integer xlId, @RequestParam Integer clId) { | |
| 109 | + Map<String, Object> rtn = new HashMap<>(); | |
| 110 | + try { | |
| 111 | + VehicleConfigDto vehicleConfigDto = VehicleConfigDto.getBuilder() | |
| 112 | + .setXl(xlId == null ? null : (LineDto.getBuilder() | |
| 113 | + .setId(xlId) | |
| 114 | + .build())) | |
| 115 | + .setCl(clId == null ? null : (CarDto.getBuilder() | |
| 116 | + .setId(clId) | |
| 117 | + .build())) | |
| 118 | + .build(); | |
| 119 | + | |
| 120 | + vehicleConfigServiceFacade.validate_already_config(vehicleConfigDto); | |
| 121 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 122 | + } catch (Exception exp) { | |
| 123 | + rtn.put("status", ResponseCode.ERROR); | |
| 124 | + rtn.put("msg", exp.getMessage()); | |
| 125 | + } | |
| 126 | + | |
| 127 | + return rtn; | |
| 128 | + } | |
| 129 | + | |
| 130 | + @RequestMapping(value = "/validate_cars_gs", method = RequestMethod.GET) | |
| 131 | + public Map<String, Object> validate_cars_gs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 132 | + HttpSession session = request.getSession(); | |
| 133 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 134 | + List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 135 | + for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 136 | + CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 137 | + .setId(companyAuthority.getId()) | |
| 138 | + .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 139 | + .setCompanyName(companyAuthority.getCompanyName()) | |
| 140 | + .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 141 | + .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 142 | + .build(); | |
| 143 | + companyAuthorityDtoList.add(companyAuthorityDto); | |
| 144 | + } | |
| 145 | + | |
| 146 | + Map<String, Object> rtn = new HashMap<>(); | |
| 147 | + try { | |
| 148 | + VehicleConfigDto vehicleConfigDto = VehicleConfigDto.getBuilder() | |
| 149 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 150 | + LineDto.getBuilder() | |
| 151 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 152 | + .setName(param.get("xl.name_eq").toString()) | |
| 153 | + .build() | |
| 154 | + )) | |
| 155 | + .setCl(param.get("cl.id_eq") == null ? null : ( | |
| 156 | + CarDto.getBuilder() | |
| 157 | + .setId(Integer.valueOf(param.get("cl.id_eq").toString())) | |
| 158 | + .build() | |
| 159 | + )) | |
| 160 | + .build(); | |
| 161 | + | |
| 162 | + vehicleConfigServiceFacade.validate_cars_gs(vehicleConfigDto, companyAuthorityDtoList); | |
| 163 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 164 | + } catch (Exception exp) { | |
| 165 | + rtn.put("status", ResponseCode.ERROR); | |
| 166 | + rtn.put("msg", exp.getMessage()); | |
| 167 | + } | |
| 168 | + | |
| 169 | + return rtn; | |
| 170 | + } | |
| 171 | + | |
| 172 | + @RequestMapping(value = "/validate_cars_fgs", method = RequestMethod.GET) | |
| 173 | + public Map<String, Object> validate_cars_fgs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 174 | + HttpSession session = request.getSession(); | |
| 175 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 176 | + List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 177 | + for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 178 | + CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 179 | + .setId(companyAuthority.getId()) | |
| 180 | + .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 181 | + .setCompanyName(companyAuthority.getCompanyName()) | |
| 182 | + .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 183 | + .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 184 | + .build(); | |
| 185 | + companyAuthorityDtoList.add(companyAuthorityDto); | |
| 186 | + } | |
| 187 | + | |
| 188 | + Map<String, Object> rtn = new HashMap<>(); | |
| 189 | + try { | |
| 190 | + VehicleConfigDto vehicleConfigDto = VehicleConfigDto.getBuilder() | |
| 191 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 192 | + LineDto.getBuilder() | |
| 193 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 194 | + .setName(param.get("xl.name_eq").toString()) | |
| 195 | + .build() | |
| 196 | + )) | |
| 197 | + .setCl(param.get("cl.id_eq") == null ? null : ( | |
| 198 | + CarDto.getBuilder() | |
| 199 | + .setId(Integer.valueOf(param.get("cl.id_eq").toString())) | |
| 200 | + .build() | |
| 201 | + )) | |
| 202 | + .build(); | |
| 203 | + | |
| 204 | + vehicleConfigServiceFacade.validate_cars_fgs(vehicleConfigDto, companyAuthorityDtoList); | |
| 205 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 206 | + } catch (Exception exp) { | |
| 207 | + rtn.put("status", ResponseCode.ERROR); | |
| 208 | + rtn.put("msg", exp.getMessage()); | |
| 209 | + } | |
| 210 | + | |
| 211 | + return rtn; | |
| 212 | + } | |
| 213 | + | |
| 214 | + @RequestMapping(value = "/validate_cars_config", method = RequestMethod.GET) | |
| 215 | + public Map<String, Object> validate_cars_config(@RequestParam Map<String, Object> param) { | |
| 216 | + Map<String, Object> rtn = new HashMap<>(); | |
| 217 | + try { | |
| 218 | + VehicleConfigDto vehicleConfigDto = VehicleConfigDto.getBuilder() | |
| 219 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 220 | + LineDto.getBuilder() | |
| 221 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 222 | + .setName(param.get("xl.name_eq").toString()) | |
| 223 | + .build() | |
| 224 | + )) | |
| 225 | + .setCl(param.get("cl.id_eq") == null ? null : ( | |
| 226 | + CarDto.getBuilder() | |
| 227 | + .setId(Integer.valueOf(param.get("cl.id_eq").toString())) | |
| 228 | + .build() | |
| 229 | + )) | |
| 230 | + .build(); | |
| 231 | + vehicleConfigServiceFacade.validate_config_exist(vehicleConfigDto); | |
| 232 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 233 | + } catch (Exception exp) { | |
| 234 | + rtn.put("status", ResponseCode.ERROR); | |
| 235 | + rtn.put("msg", exp.getMessage()); | |
| 236 | + } | |
| 237 | + | |
| 238 | + return rtn; | |
| 239 | + } | |
| 240 | + | |
| 241 | + //------------------ TODO:导入导出逻辑,之后会服务化 -----------------// | |
| 242 | + @Autowired | |
| 243 | + private CarConfigInfoService carConfigInfoService; | |
| 244 | + // 上传excel文件 | |
| 245 | + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 246 | + public Map<String, Object> uploadFile(MultipartFile file) { | |
| 247 | + Map<String, Object> rtn = new HashMap<>(); | |
| 248 | + try { | |
| 249 | + DataToolsFile dataToolsFile = carConfigInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 250 | + // excel文件名 | |
| 251 | + String fileName = dataToolsFile.getFile().getAbsolutePath(); | |
| 252 | + Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile()); | |
| 253 | + | |
| 254 | + // excel文件sheet | |
| 255 | + List<String> sheetnames = new ArrayList<>(); | |
| 256 | + for (int i = 0; i < wb.getNumberOfSheets(); i ++) { | |
| 257 | + sheetnames.add(wb.getSheetAt(i).getSheetName()); | |
| 258 | + } | |
| 259 | + | |
| 260 | + wb.close(); | |
| 261 | + | |
| 262 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 263 | + rtn.put("filename", fileName); | |
| 264 | + rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | |
| 265 | + } catch (Exception exp) { | |
| 266 | + exp.printStackTrace(); | |
| 267 | + rtn.put("status", ResponseCode.ERROR); | |
| 268 | + rtn.put("msg", exp.getMessage()); | |
| 269 | + } | |
| 270 | + return rtn; | |
| 271 | + } | |
| 272 | + // 导入excel文件 | |
| 273 | + @RequestMapping(value = "/importFile", method = RequestMethod.POST) | |
| 274 | + public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | |
| 275 | + Map<String, Object> rtn = new HashMap<>(); | |
| 276 | + | |
| 277 | + try { | |
| 278 | + File file = new File(String.valueOf(params.get("filename"))); | |
| 279 | + if (!file.exists()) { | |
| 280 | + throw new Exception("导入文件不存在!"); | |
| 281 | + } | |
| 282 | + carConfigInfoService.importData(file, params); | |
| 283 | + | |
| 284 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 285 | + rtn.put("msg", "导入文件成功"); | |
| 286 | + } catch (Exception exp) { | |
| 287 | + rtn.put("status", ResponseCode.ERROR); | |
| 288 | + rtn.put("msg", exp.getMessage()); | |
| 289 | + } | |
| 290 | + | |
| 291 | + return rtn; | |
| 292 | + } | |
| 293 | + // 上传并导入excel文件 | |
| 294 | + @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | |
| 295 | + public Map<String, Object> uploadAndImportFile(MultipartFile file) { | |
| 296 | + Map<String, Object> rtn = new HashMap<>(); | |
| 297 | + | |
| 298 | + try { | |
| 299 | + DataToolsFile dataToolsFile = carConfigInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 300 | + Map<String, Object> params = new HashMap<>(); | |
| 301 | + carConfigInfoService.importData(dataToolsFile.getFile(), params); | |
| 302 | + | |
| 303 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 304 | + rtn.put("msg", "上传&导入文件成功"); | |
| 305 | + } catch (Exception exp) { | |
| 306 | + exp.printStackTrace(); | |
| 307 | + rtn.put("status", ResponseCode.ERROR); | |
| 308 | + rtn.put("msg", exp.getMessage()); | |
| 309 | + } | |
| 310 | + | |
| 311 | + return rtn; | |
| 312 | + } | |
| 313 | + | |
| 314 | + // 导出数据到xls文件 | |
| 315 | + @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | |
| 316 | + public void exportFile(HttpServletResponse response, | |
| 317 | + @RequestParam Map<String, Object> params) throws Exception { | |
| 318 | + DataToolsFile dataToolsFile = carConfigInfoService.exportData(params); | |
| 319 | + // 流输出导出文件 | |
| 320 | + response.setHeader("content-type", "application/octet-stream"); | |
| 321 | + response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName()); | |
| 322 | + response.setContentType("application/octet-stream"); | |
| 323 | + | |
| 324 | + OutputStream os = response.getOutputStream(); | |
| 325 | + BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 326 | + | |
| 327 | + InputStream is = new FileInputStream(dataToolsFile.getFile()); | |
| 328 | + BufferedInputStream bis = new BufferedInputStream(is); | |
| 329 | + | |
| 330 | + int length = 0; | |
| 331 | + byte[] temp = new byte[1 * 1024 * 10]; | |
| 332 | + while ((length = bis.read(temp)) != -1) { | |
| 333 | + bos.write(temp, 0, length); | |
| 334 | + } | |
| 335 | + bos.flush(); | |
| 336 | + bis.close(); | |
| 337 | + bos.close(); | |
| 338 | + is.close(); | |
| 339 | + } | |
| 340 | + | |
| 341 | + | |
| 342 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/core/EmployeeConfigInfoController_facade.java
| 1 | -package com.bsth.controller.schedule.core; | |
| 2 | - | |
| 3 | -import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | -import com.bsth.common.Constants; | |
| 5 | -import com.bsth.common.ResponseCode; | |
| 6 | -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 7 | -import com.bsth.control_v2.plan_module.common.dto.baseinfo.LineDto; | |
| 8 | -import com.bsth.control_v2.plan_module.common.dto.baseinfo.PersonnelDto; | |
| 9 | -import com.bsth.control_v2.plan_module.common.dto.schedule.config.EmployeeConfigDto; | |
| 10 | -import com.bsth.control_v2.plan_module.common.dto.sys.CompanyAuthorityDto; | |
| 11 | -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 12 | -import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 13 | -import com.bsth.control_v2.plan_module.common.service.schedule.config.EmployeeConfigServiceFacade; | |
| 14 | -import com.bsth.controller.schedule.BController_facade; | |
| 15 | -import com.bsth.entity.sys.CompanyAuthority; | |
| 16 | -import com.bsth.service.schedule.EmployeeConfigInfoService; | |
| 17 | -import com.bsth.service.schedule.utils.DataToolsFile; | |
| 18 | -import org.apache.commons.lang3.StringUtils; | |
| 19 | -import org.apache.poi.ss.usermodel.Workbook; | |
| 20 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 21 | -import org.springframework.context.annotation.Conditional; | |
| 22 | -import org.springframework.web.bind.annotation.*; | |
| 23 | -import org.springframework.web.multipart.MultipartFile; | |
| 24 | - | |
| 25 | -import javax.servlet.http.HttpServletRequest; | |
| 26 | -import javax.servlet.http.HttpServletResponse; | |
| 27 | -import javax.servlet.http.HttpSession; | |
| 28 | -import java.io.*; | |
| 29 | -import java.util.*; | |
| 30 | - | |
| 31 | -/** | |
| 32 | - * Created by xu on 16/5/10. | |
| 33 | - */ | |
| 34 | -@RestController | |
| 35 | -@Conditional(DubboConfigCondition.class) | |
| 36 | -@RequestMapping("eci") | |
| 37 | -public class EmployeeConfigInfoController_facade extends BController_facade<Long, EmployeeConfigDto> { | |
| 38 | - | |
| 39 | - @Override | |
| 40 | - public void setCreateUserInfo(EmployeeConfigDto employeeConfigDto, Integer userId, Date createDate) { | |
| 41 | - UserDto userDto = UserDto.getBuilder() | |
| 42 | - .setId(userId) | |
| 43 | - .build(); | |
| 44 | - employeeConfigDto.setCreateBy(userDto); | |
| 45 | - employeeConfigDto.setCreateDate(createDate); | |
| 46 | - } | |
| 47 | - | |
| 48 | - @Override | |
| 49 | - public void setUpdateUserInfo(EmployeeConfigDto employeeConfigDto, Integer userId, Date updateDate) { | |
| 50 | - UserDto userDto = UserDto.getBuilder() | |
| 51 | - .setId(userId) | |
| 52 | - .build(); | |
| 53 | - employeeConfigDto.setUpdateBy(userDto); | |
| 54 | - employeeConfigDto.setUpdateDate(updateDate); | |
| 55 | - } | |
| 56 | - | |
| 57 | - @Reference | |
| 58 | - private EmployeeConfigServiceFacade employeeConfigServiceFacade; | |
| 59 | - | |
| 60 | - @Override | |
| 61 | - protected BServiceFacade<Long, EmployeeConfigDto> getBServiceFacade() { | |
| 62 | - return employeeConfigServiceFacade; | |
| 63 | - } | |
| 64 | - | |
| 65 | - @RequestMapping(value = "/jsy", method = RequestMethod.GET) | |
| 66 | - public List<Map<String, Object>> findJsyFromConfig() { | |
| 67 | - return employeeConfigServiceFacade.findJsyFromConfig(); | |
| 68 | - } | |
| 69 | - | |
| 70 | - @RequestMapping(value = "/spy", method = RequestMethod.GET) | |
| 71 | - public List<Map<String, Object>> findSpyFromConfig() { | |
| 72 | - return employeeConfigServiceFacade.findSpyFromConfig(); | |
| 73 | - } | |
| 74 | - | |
| 75 | - | |
| 76 | - @RequestMapping(value = "/dbbm/{xlid}", method = RequestMethod.GET) | |
| 77 | - public Map<String, Object> getDbbm(@PathVariable("xlid") Integer xl) { | |
| 78 | - Map<String, Object> rtn = new HashMap<>(); | |
| 79 | - try { | |
| 80 | - rtn.put("data", employeeConfigServiceFacade.getMaxDbbm(xl)); | |
| 81 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 82 | - } catch (Exception exp) { | |
| 83 | - exp.printStackTrace(); | |
| 84 | - rtn.put("status", ResponseCode.ERROR); | |
| 85 | - rtn.put("msg", exp.getMessage()); | |
| 86 | - } | |
| 87 | - return rtn; | |
| 88 | - } | |
| 89 | - | |
| 90 | - @RequestMapping(value = "/validate_jsy", method = RequestMethod.GET) | |
| 91 | - public Map<String, Object> validate_jsy(@RequestParam Map<String, Object> param) { | |
| 92 | - Map<String, Object> rtn = new HashMap<>(); | |
| 93 | - try { | |
| 94 | - EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 95 | - .setId(param.get("id_eq") == null ? null : Long.parseLong(param.get("id_eq").toString())) | |
| 96 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 97 | - LineDto.getBuilder() | |
| 98 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 99 | - .setName(param.get("xl.name_eq").toString()) | |
| 100 | - .build() | |
| 101 | - )) | |
| 102 | - .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 103 | - PersonnelDto.getBuilder() | |
| 104 | - .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 105 | - .build() | |
| 106 | - )) | |
| 107 | - .build(); | |
| 108 | - employeeConfigServiceFacade.validate_jsy_duplicate_without_current(employeeConfigDto); | |
| 109 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 110 | - } catch (Exception exp) { | |
| 111 | - rtn.put("status", ResponseCode.ERROR); | |
| 112 | - rtn.put("msg", exp.getMessage()); | |
| 113 | - } | |
| 114 | - | |
| 115 | - return rtn; | |
| 116 | - } | |
| 117 | - | |
| 118 | - @RequestMapping(value = "/validate_jsy_config", method = RequestMethod.GET) | |
| 119 | - public Map<String, Object> validate_jsy_config(@RequestParam Map<String, Object> param) { | |
| 120 | - Map<String, Object> rtn = new HashMap<>(); | |
| 121 | - try { | |
| 122 | - EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 123 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 124 | - LineDto.getBuilder() | |
| 125 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 126 | - .setName(param.get("xl.name_eq").toString()) | |
| 127 | - .build() | |
| 128 | - )) | |
| 129 | - .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 130 | - PersonnelDto.getBuilder() | |
| 131 | - .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 132 | - .build() | |
| 133 | - )) | |
| 134 | - .build(); | |
| 135 | - employeeConfigServiceFacade.validate_jsy_exist(employeeConfigDto); | |
| 136 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 137 | - } catch (Exception exp) { | |
| 138 | - rtn.put("status", ResponseCode.ERROR); | |
| 139 | - rtn.put("msg", exp.getMessage()); | |
| 140 | - } | |
| 141 | - | |
| 142 | - return rtn; | |
| 143 | - } | |
| 144 | - | |
| 145 | - @RequestMapping(value = "/validate_jsy_gs", method = RequestMethod.GET) | |
| 146 | - public Map<String, Object> validate_jsy_gs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 147 | - HttpSession session = request.getSession(); | |
| 148 | - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 149 | - List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 150 | - for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 151 | - CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 152 | - .setId(companyAuthority.getId()) | |
| 153 | - .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 154 | - .setCompanyName(companyAuthority.getCompanyName()) | |
| 155 | - .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 156 | - .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 157 | - .build(); | |
| 158 | - companyAuthorityDtoList.add(companyAuthorityDto); | |
| 159 | - } | |
| 160 | - | |
| 161 | - Map<String, Object> rtn = new HashMap<>(); | |
| 162 | - try { | |
| 163 | - EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 164 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 165 | - LineDto.getBuilder() | |
| 166 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 167 | - .setName(param.get("xl.name_eq").toString()) | |
| 168 | - .build() | |
| 169 | - )) | |
| 170 | - .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 171 | - PersonnelDto.getBuilder() | |
| 172 | - .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 173 | - .build() | |
| 174 | - )) | |
| 175 | - .build(); | |
| 176 | - employeeConfigServiceFacade.validate_jsy_gs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 177 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 178 | - } catch (Exception exp) { | |
| 179 | - rtn.put("status", ResponseCode.ERROR); | |
| 180 | - rtn.put("msg", exp.getMessage()); | |
| 181 | - } | |
| 182 | - | |
| 183 | - return rtn; | |
| 184 | - } | |
| 185 | - | |
| 186 | - @RequestMapping(value = "/validate_jsy_fgs", method = RequestMethod.GET) | |
| 187 | - public Map<String, Object> validate_jsy_fgs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 188 | - HttpSession session = request.getSession(); | |
| 189 | - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 190 | - List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 191 | - for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 192 | - CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 193 | - .setId(companyAuthority.getId()) | |
| 194 | - .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 195 | - .setCompanyName(companyAuthority.getCompanyName()) | |
| 196 | - .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 197 | - .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 198 | - .build(); | |
| 199 | - companyAuthorityDtoList.add(companyAuthorityDto); | |
| 200 | - } | |
| 201 | - | |
| 202 | - Map<String, Object> rtn = new HashMap<>(); | |
| 203 | - try { | |
| 204 | - EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 205 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 206 | - LineDto.getBuilder() | |
| 207 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 208 | - .setName(param.get("xl.name_eq").toString()) | |
| 209 | - .build() | |
| 210 | - )) | |
| 211 | - .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 212 | - PersonnelDto.getBuilder() | |
| 213 | - .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 214 | - .build() | |
| 215 | - )) | |
| 216 | - .build(); | |
| 217 | - employeeConfigServiceFacade.validate_jsy_fgs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 218 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 219 | - } catch (Exception exp) { | |
| 220 | - rtn.put("status", ResponseCode.ERROR); | |
| 221 | - rtn.put("msg", exp.getMessage()); | |
| 222 | - } | |
| 223 | - | |
| 224 | - return rtn; | |
| 225 | - } | |
| 226 | - | |
| 227 | - @RequestMapping(value = "/validate_spy", method = RequestMethod.GET) | |
| 228 | - public Map<String, Object> validate_spy(@RequestParam Map<String, Object> param) { | |
| 229 | - Map<String, Object> rtn = new HashMap<>(); | |
| 230 | - try { | |
| 231 | - EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 232 | - .setId(param.get("id_eq") == null ? null : Long.parseLong(param.get("id_eq").toString())) | |
| 233 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 234 | - LineDto.getBuilder() | |
| 235 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 236 | - .setName(param.get("xl.name_eq").toString()) | |
| 237 | - .build() | |
| 238 | - )) | |
| 239 | - .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 240 | - PersonnelDto.getBuilder() | |
| 241 | - .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 242 | - .build() | |
| 243 | - )) | |
| 244 | - .build(); | |
| 245 | - employeeConfigServiceFacade.validate_spy_duplicate_without_current(employeeConfigDto); | |
| 246 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 247 | - } catch (Exception exp) { | |
| 248 | - rtn.put("status", ResponseCode.ERROR); | |
| 249 | - rtn.put("msg", exp.getMessage()); | |
| 250 | - } | |
| 251 | - return rtn; | |
| 252 | - } | |
| 253 | - | |
| 254 | - @RequestMapping(value = "/validate_spy_config", method = RequestMethod.GET) | |
| 255 | - public Map<String, Object> validate_spy_config(@RequestParam Map<String, Object> param) { | |
| 256 | - Map<String, Object> rtn = new HashMap<>(); | |
| 257 | - try { | |
| 258 | - EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 259 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 260 | - LineDto.getBuilder() | |
| 261 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 262 | - .setName(param.get("xl.name_eq").toString()) | |
| 263 | - .build() | |
| 264 | - )) | |
| 265 | - .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 266 | - PersonnelDto.getBuilder() | |
| 267 | - .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 268 | - .build() | |
| 269 | - )) | |
| 270 | - .build(); | |
| 271 | - employeeConfigServiceFacade.validate_spy_exist(employeeConfigDto); | |
| 272 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 273 | - } catch (Exception exp) { | |
| 274 | - rtn.put("status", ResponseCode.ERROR); | |
| 275 | - rtn.put("msg", exp.getMessage()); | |
| 276 | - } | |
| 277 | - return rtn; | |
| 278 | - } | |
| 279 | - | |
| 280 | - @RequestMapping(value = "/validate_spy_gs", method = RequestMethod.GET) | |
| 281 | - public Map<String, Object> validate_spy_gs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 282 | - HttpSession session = request.getSession(); | |
| 283 | - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 284 | - List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 285 | - for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 286 | - CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 287 | - .setId(companyAuthority.getId()) | |
| 288 | - .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 289 | - .setCompanyName(companyAuthority.getCompanyName()) | |
| 290 | - .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 291 | - .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 292 | - .build(); | |
| 293 | - companyAuthorityDtoList.add(companyAuthorityDto); | |
| 294 | - } | |
| 295 | - | |
| 296 | - Map<String, Object> rtn = new HashMap<>(); | |
| 297 | - try { | |
| 298 | - EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 299 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 300 | - LineDto.getBuilder() | |
| 301 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 302 | - .setName(param.get("xl.name_eq").toString()) | |
| 303 | - .build() | |
| 304 | - )) | |
| 305 | - .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 306 | - PersonnelDto.getBuilder() | |
| 307 | - .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 308 | - .build() | |
| 309 | - )) | |
| 310 | - .build(); | |
| 311 | - employeeConfigServiceFacade.validate_spy_gs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 312 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 313 | - } catch (Exception exp) { | |
| 314 | - rtn.put("status", ResponseCode.ERROR); | |
| 315 | - rtn.put("msg", exp.getMessage()); | |
| 316 | - } | |
| 317 | - return rtn; | |
| 318 | - } | |
| 319 | - | |
| 320 | - @RequestMapping(value = "/validate_spy_fgs", method = RequestMethod.GET) | |
| 321 | - public Map<String, Object> validate_spy_fgs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 322 | - HttpSession session = request.getSession(); | |
| 323 | - List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 324 | - List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 325 | - for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 326 | - CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 327 | - .setId(companyAuthority.getId()) | |
| 328 | - .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 329 | - .setCompanyName(companyAuthority.getCompanyName()) | |
| 330 | - .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 331 | - .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 332 | - .build(); | |
| 333 | - companyAuthorityDtoList.add(companyAuthorityDto); | |
| 334 | - } | |
| 335 | - | |
| 336 | - Map<String, Object> rtn = new HashMap<>(); | |
| 337 | - try { | |
| 338 | - EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 339 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 340 | - LineDto.getBuilder() | |
| 341 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 342 | - .setName(param.get("xl.name_eq").toString()) | |
| 343 | - .build() | |
| 344 | - )) | |
| 345 | - .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 346 | - PersonnelDto.getBuilder() | |
| 347 | - .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 348 | - .build() | |
| 349 | - )) | |
| 350 | - .build(); | |
| 351 | - employeeConfigServiceFacade.validate_spy_fgs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 352 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 353 | - } catch (Exception exp) { | |
| 354 | - rtn.put("status", ResponseCode.ERROR); | |
| 355 | - rtn.put("msg", exp.getMessage()); | |
| 356 | - } | |
| 357 | - return rtn; | |
| 358 | - } | |
| 359 | - | |
| 360 | - //------------------ TODO:导入导出逻辑,之后会服务化 -----------------// | |
| 361 | - @Autowired | |
| 362 | - private EmployeeConfigInfoService employeeConfigInfoService; | |
| 363 | - // 上传excel文件 | |
| 364 | - @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 365 | - public Map<String, Object> uploadFile(MultipartFile file) { | |
| 366 | - Map<String, Object> rtn = new HashMap<>(); | |
| 367 | - try { | |
| 368 | - DataToolsFile dataToolsFile = employeeConfigInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 369 | - // excel文件名 | |
| 370 | - String fileName = dataToolsFile.getFile().getAbsolutePath(); | |
| 371 | - Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile()); | |
| 372 | - | |
| 373 | - // excel文件sheet | |
| 374 | - List<String> sheetnames = new ArrayList<>(); | |
| 375 | - for (int i = 0; i < wb.getNumberOfSheets(); i ++) { | |
| 376 | - sheetnames.add(wb.getSheetAt(i).getSheetName()); | |
| 377 | - } | |
| 378 | - | |
| 379 | - wb.close(); | |
| 380 | - | |
| 381 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 382 | - rtn.put("filename", fileName); | |
| 383 | - rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | |
| 384 | - } catch (Exception exp) { | |
| 385 | - exp.printStackTrace(); | |
| 386 | - rtn.put("status", ResponseCode.ERROR); | |
| 387 | - rtn.put("msg", exp.getMessage()); | |
| 388 | - } | |
| 389 | - return rtn; | |
| 390 | - } | |
| 391 | - // 导入excel文件 | |
| 392 | - @RequestMapping(value = "/importFile", method = RequestMethod.POST) | |
| 393 | - public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | |
| 394 | - Map<String, Object> rtn = new HashMap<>(); | |
| 395 | - | |
| 396 | - try { | |
| 397 | - File file = new File(String.valueOf(params.get("filename"))); | |
| 398 | - if (!file.exists()) { | |
| 399 | - throw new Exception("导入文件不存在!"); | |
| 400 | - } | |
| 401 | - employeeConfigInfoService.importData(file, params); | |
| 402 | - | |
| 403 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 404 | - rtn.put("msg", "导入文件成功"); | |
| 405 | - } catch (Exception exp) { | |
| 406 | - rtn.put("status", ResponseCode.ERROR); | |
| 407 | - rtn.put("msg", exp.getMessage()); | |
| 408 | - } | |
| 409 | - | |
| 410 | - return rtn; | |
| 411 | - } | |
| 412 | - // 上传并导入excel文件 | |
| 413 | - @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | |
| 414 | - public Map<String, Object> uploadAndImportFile(MultipartFile file) { | |
| 415 | - Map<String, Object> rtn = new HashMap<>(); | |
| 416 | - | |
| 417 | - try { | |
| 418 | - DataToolsFile dataToolsFile = employeeConfigInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 419 | - Map<String, Object> params = new HashMap<>(); | |
| 420 | - employeeConfigInfoService.importData(dataToolsFile.getFile(), params); | |
| 421 | - | |
| 422 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 423 | - rtn.put("msg", "上传&导入文件成功"); | |
| 424 | - } catch (Exception exp) { | |
| 425 | - exp.printStackTrace(); | |
| 426 | - rtn.put("status", ResponseCode.ERROR); | |
| 427 | - rtn.put("msg", exp.getMessage()); | |
| 428 | - } | |
| 429 | - | |
| 430 | - return rtn; | |
| 431 | - } | |
| 432 | - | |
| 433 | - // 导出数据到xls文件 | |
| 434 | - @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | |
| 435 | - public void exportFile(HttpServletResponse response, | |
| 436 | - @RequestParam Map<String, Object> params) throws Exception { | |
| 437 | - DataToolsFile dataToolsFile = employeeConfigInfoService.exportData(params); | |
| 438 | - // 流输出导出文件 | |
| 439 | - response.setHeader("content-type", "application/octet-stream"); | |
| 440 | - response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName()); | |
| 441 | - response.setContentType("application/octet-stream"); | |
| 442 | - | |
| 443 | - OutputStream os = response.getOutputStream(); | |
| 444 | - BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 445 | - | |
| 446 | - InputStream is = new FileInputStream(dataToolsFile.getFile()); | |
| 447 | - BufferedInputStream bis = new BufferedInputStream(is); | |
| 448 | - | |
| 449 | - int length = 0; | |
| 450 | - byte[] temp = new byte[1 * 1024 * 10]; | |
| 451 | - while ((length = bis.read(temp)) != -1) { | |
| 452 | - bos.write(temp, 0, length); | |
| 453 | - } | |
| 454 | - bos.flush(); | |
| 455 | - bis.close(); | |
| 456 | - bos.close(); | |
| 457 | - is.close(); | |
| 458 | - } | |
| 459 | - | |
| 460 | - | |
| 461 | -} | |
| 1 | +package com.bsth.controller.schedule.core; | |
| 2 | + | |
| 3 | +import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | +import com.bsth.common.Constants; | |
| 5 | +import com.bsth.common.ResponseCode; | |
| 6 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 7 | +import com.bsth.control_v2.plan_module.common.dto.baseinfo.LineDto; | |
| 8 | +import com.bsth.control_v2.plan_module.common.dto.baseinfo.PersonnelDto; | |
| 9 | +import com.bsth.control_v2.plan_module.common.dto.schedule.config.EmployeeConfigDto; | |
| 10 | +import com.bsth.control_v2.plan_module.common.dto.sys.CompanyAuthorityDto; | |
| 11 | +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 12 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 13 | +import com.bsth.control_v2.plan_module.common.service.schedule.config.EmployeeConfigServiceFacade; | |
| 14 | +import com.bsth.controller.schedule.BController_facade; | |
| 15 | +import com.bsth.entity.sys.CompanyAuthority; | |
| 16 | +import com.bsth.service.schedule.EmployeeConfigInfoService; | |
| 17 | +import com.bsth.service.schedule.utils.DataToolsFile; | |
| 18 | +import org.apache.commons.lang3.StringUtils; | |
| 19 | +import org.apache.poi.ss.usermodel.Workbook; | |
| 20 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 21 | +import org.springframework.context.annotation.Conditional; | |
| 22 | +import org.springframework.web.bind.annotation.*; | |
| 23 | +import org.springframework.web.multipart.MultipartFile; | |
| 24 | + | |
| 25 | +import javax.servlet.http.HttpServletRequest; | |
| 26 | +import javax.servlet.http.HttpServletResponse; | |
| 27 | +import javax.servlet.http.HttpSession; | |
| 28 | +import java.io.*; | |
| 29 | +import java.util.*; | |
| 30 | + | |
| 31 | +/** | |
| 32 | + * Created by xu on 16/5/10. | |
| 33 | + */ | |
| 34 | +@RestController | |
| 35 | +@Conditional(DubboConfigCondition.class) | |
| 36 | +@RequestMapping("eci") | |
| 37 | +public class EmployeeConfigInfoController_facade extends BController_facade<Long, EmployeeConfigDto> { | |
| 38 | + | |
| 39 | + @Override | |
| 40 | + public void setCreateUserInfo(EmployeeConfigDto employeeConfigDto, Integer userId, Date createDate) { | |
| 41 | + UserDto userDto = UserDto.getBuilder() | |
| 42 | + .setId(userId) | |
| 43 | + .build(); | |
| 44 | + employeeConfigDto.setCreateBy(userDto); | |
| 45 | + employeeConfigDto.setCreateDate(createDate); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public void setUpdateUserInfo(EmployeeConfigDto employeeConfigDto, Integer userId, Date updateDate) { | |
| 50 | + UserDto userDto = UserDto.getBuilder() | |
| 51 | + .setId(userId) | |
| 52 | + .build(); | |
| 53 | + employeeConfigDto.setUpdateBy(userDto); | |
| 54 | + employeeConfigDto.setUpdateDate(updateDate); | |
| 55 | + } | |
| 56 | + | |
| 57 | + @Reference | |
| 58 | + private EmployeeConfigServiceFacade employeeConfigServiceFacade; | |
| 59 | + | |
| 60 | + @Override | |
| 61 | + protected BServiceFacade<Long, EmployeeConfigDto> getBServiceFacade() { | |
| 62 | + return employeeConfigServiceFacade; | |
| 63 | + } | |
| 64 | + | |
| 65 | + @RequestMapping(value = "/jsy", method = RequestMethod.GET) | |
| 66 | + public List<Map<String, Object>> findJsyFromConfig() { | |
| 67 | + return employeeConfigServiceFacade.findJsyFromConfig(); | |
| 68 | + } | |
| 69 | + | |
| 70 | + @RequestMapping(value = "/spy", method = RequestMethod.GET) | |
| 71 | + public List<Map<String, Object>> findSpyFromConfig() { | |
| 72 | + return employeeConfigServiceFacade.findSpyFromConfig(); | |
| 73 | + } | |
| 74 | + | |
| 75 | + | |
| 76 | + @RequestMapping(value = "/dbbm/{xlid}", method = RequestMethod.GET) | |
| 77 | + public Map<String, Object> getDbbm(@PathVariable("xlid") Integer xl) { | |
| 78 | + Map<String, Object> rtn = new HashMap<>(); | |
| 79 | + try { | |
| 80 | + rtn.put("data", employeeConfigServiceFacade.getMaxDbbm(xl)); | |
| 81 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 82 | + } catch (Exception exp) { | |
| 83 | + exp.printStackTrace(); | |
| 84 | + rtn.put("status", ResponseCode.ERROR); | |
| 85 | + rtn.put("msg", exp.getMessage()); | |
| 86 | + } | |
| 87 | + return rtn; | |
| 88 | + } | |
| 89 | + | |
| 90 | + @RequestMapping(value = "/validate_jsy", method = RequestMethod.GET) | |
| 91 | + public Map<String, Object> validate_jsy(@RequestParam Map<String, Object> param) { | |
| 92 | + Map<String, Object> rtn = new HashMap<>(); | |
| 93 | + try { | |
| 94 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 95 | + .setId(param.get("id_eq") == null ? null : Long.parseLong(param.get("id_eq").toString())) | |
| 96 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 97 | + LineDto.getBuilder() | |
| 98 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 99 | + .setName(param.get("xl.name_eq").toString()) | |
| 100 | + .build() | |
| 101 | + )) | |
| 102 | + .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 103 | + PersonnelDto.getBuilder() | |
| 104 | + .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 105 | + .build() | |
| 106 | + )) | |
| 107 | + .build(); | |
| 108 | + employeeConfigServiceFacade.validate_jsy_duplicate_without_current(employeeConfigDto); | |
| 109 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 110 | + } catch (Exception exp) { | |
| 111 | + rtn.put("status", ResponseCode.ERROR); | |
| 112 | + rtn.put("msg", exp.getMessage()); | |
| 113 | + } | |
| 114 | + | |
| 115 | + return rtn; | |
| 116 | + } | |
| 117 | + | |
| 118 | + @RequestMapping(value = "/validate_jsy_config", method = RequestMethod.GET) | |
| 119 | + public Map<String, Object> validate_jsy_config(@RequestParam Map<String, Object> param) { | |
| 120 | + Map<String, Object> rtn = new HashMap<>(); | |
| 121 | + try { | |
| 122 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 123 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 124 | + LineDto.getBuilder() | |
| 125 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 126 | + .setName(param.get("xl.name_eq").toString()) | |
| 127 | + .build() | |
| 128 | + )) | |
| 129 | + .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 130 | + PersonnelDto.getBuilder() | |
| 131 | + .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 132 | + .build() | |
| 133 | + )) | |
| 134 | + .build(); | |
| 135 | + employeeConfigServiceFacade.validate_jsy_exist(employeeConfigDto); | |
| 136 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 137 | + } catch (Exception exp) { | |
| 138 | + rtn.put("status", ResponseCode.ERROR); | |
| 139 | + rtn.put("msg", exp.getMessage()); | |
| 140 | + } | |
| 141 | + | |
| 142 | + return rtn; | |
| 143 | + } | |
| 144 | + | |
| 145 | + @RequestMapping(value = "/validate_jsy_gs", method = RequestMethod.GET) | |
| 146 | + public Map<String, Object> validate_jsy_gs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 147 | + HttpSession session = request.getSession(); | |
| 148 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 149 | + List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 150 | + for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 151 | + CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 152 | + .setId(companyAuthority.getId()) | |
| 153 | + .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 154 | + .setCompanyName(companyAuthority.getCompanyName()) | |
| 155 | + .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 156 | + .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 157 | + .build(); | |
| 158 | + companyAuthorityDtoList.add(companyAuthorityDto); | |
| 159 | + } | |
| 160 | + | |
| 161 | + Map<String, Object> rtn = new HashMap<>(); | |
| 162 | + try { | |
| 163 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 164 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 165 | + LineDto.getBuilder() | |
| 166 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 167 | + .setName(param.get("xl.name_eq").toString()) | |
| 168 | + .build() | |
| 169 | + )) | |
| 170 | + .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 171 | + PersonnelDto.getBuilder() | |
| 172 | + .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 173 | + .build() | |
| 174 | + )) | |
| 175 | + .build(); | |
| 176 | + employeeConfigServiceFacade.validate_jsy_gs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 177 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 178 | + } catch (Exception exp) { | |
| 179 | + rtn.put("status", ResponseCode.ERROR); | |
| 180 | + rtn.put("msg", exp.getMessage()); | |
| 181 | + } | |
| 182 | + | |
| 183 | + return rtn; | |
| 184 | + } | |
| 185 | + | |
| 186 | + @RequestMapping(value = "/validate_jsy_fgs", method = RequestMethod.GET) | |
| 187 | + public Map<String, Object> validate_jsy_fgs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 188 | + HttpSession session = request.getSession(); | |
| 189 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 190 | + List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 191 | + for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 192 | + CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 193 | + .setId(companyAuthority.getId()) | |
| 194 | + .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 195 | + .setCompanyName(companyAuthority.getCompanyName()) | |
| 196 | + .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 197 | + .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 198 | + .build(); | |
| 199 | + companyAuthorityDtoList.add(companyAuthorityDto); | |
| 200 | + } | |
| 201 | + | |
| 202 | + Map<String, Object> rtn = new HashMap<>(); | |
| 203 | + try { | |
| 204 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 205 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 206 | + LineDto.getBuilder() | |
| 207 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 208 | + .setName(param.get("xl.name_eq").toString()) | |
| 209 | + .build() | |
| 210 | + )) | |
| 211 | + .setJsy(param.get("jsy.id_eq") == null ? null : ( | |
| 212 | + PersonnelDto.getBuilder() | |
| 213 | + .setId(Integer.valueOf(param.get("jsy.id_eq").toString())) | |
| 214 | + .build() | |
| 215 | + )) | |
| 216 | + .build(); | |
| 217 | + employeeConfigServiceFacade.validate_jsy_fgs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 218 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 219 | + } catch (Exception exp) { | |
| 220 | + rtn.put("status", ResponseCode.ERROR); | |
| 221 | + rtn.put("msg", exp.getMessage()); | |
| 222 | + } | |
| 223 | + | |
| 224 | + return rtn; | |
| 225 | + } | |
| 226 | + | |
| 227 | + @RequestMapping(value = "/validate_spy", method = RequestMethod.GET) | |
| 228 | + public Map<String, Object> validate_spy(@RequestParam Map<String, Object> param) { | |
| 229 | + Map<String, Object> rtn = new HashMap<>(); | |
| 230 | + try { | |
| 231 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 232 | + .setId(param.get("id_eq") == null ? null : Long.parseLong(param.get("id_eq").toString())) | |
| 233 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 234 | + LineDto.getBuilder() | |
| 235 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 236 | + .setName(param.get("xl.name_eq").toString()) | |
| 237 | + .build() | |
| 238 | + )) | |
| 239 | + .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 240 | + PersonnelDto.getBuilder() | |
| 241 | + .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 242 | + .build() | |
| 243 | + )) | |
| 244 | + .build(); | |
| 245 | + employeeConfigServiceFacade.validate_spy_duplicate_without_current(employeeConfigDto); | |
| 246 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 247 | + } catch (Exception exp) { | |
| 248 | + rtn.put("status", ResponseCode.ERROR); | |
| 249 | + rtn.put("msg", exp.getMessage()); | |
| 250 | + } | |
| 251 | + return rtn; | |
| 252 | + } | |
| 253 | + | |
| 254 | + @RequestMapping(value = "/validate_spy_config", method = RequestMethod.GET) | |
| 255 | + public Map<String, Object> validate_spy_config(@RequestParam Map<String, Object> param) { | |
| 256 | + Map<String, Object> rtn = new HashMap<>(); | |
| 257 | + try { | |
| 258 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 259 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 260 | + LineDto.getBuilder() | |
| 261 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 262 | + .setName(param.get("xl.name_eq").toString()) | |
| 263 | + .build() | |
| 264 | + )) | |
| 265 | + .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 266 | + PersonnelDto.getBuilder() | |
| 267 | + .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 268 | + .build() | |
| 269 | + )) | |
| 270 | + .build(); | |
| 271 | + employeeConfigServiceFacade.validate_spy_exist(employeeConfigDto); | |
| 272 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 273 | + } catch (Exception exp) { | |
| 274 | + rtn.put("status", ResponseCode.ERROR); | |
| 275 | + rtn.put("msg", exp.getMessage()); | |
| 276 | + } | |
| 277 | + return rtn; | |
| 278 | + } | |
| 279 | + | |
| 280 | + @RequestMapping(value = "/validate_spy_gs", method = RequestMethod.GET) | |
| 281 | + public Map<String, Object> validate_spy_gs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 282 | + HttpSession session = request.getSession(); | |
| 283 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 284 | + List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 285 | + for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 286 | + CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 287 | + .setId(companyAuthority.getId()) | |
| 288 | + .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 289 | + .setCompanyName(companyAuthority.getCompanyName()) | |
| 290 | + .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 291 | + .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 292 | + .build(); | |
| 293 | + companyAuthorityDtoList.add(companyAuthorityDto); | |
| 294 | + } | |
| 295 | + | |
| 296 | + Map<String, Object> rtn = new HashMap<>(); | |
| 297 | + try { | |
| 298 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 299 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 300 | + LineDto.getBuilder() | |
| 301 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 302 | + .setName(param.get("xl.name_eq").toString()) | |
| 303 | + .build() | |
| 304 | + )) | |
| 305 | + .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 306 | + PersonnelDto.getBuilder() | |
| 307 | + .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 308 | + .build() | |
| 309 | + )) | |
| 310 | + .build(); | |
| 311 | + employeeConfigServiceFacade.validate_spy_gs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 312 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 313 | + } catch (Exception exp) { | |
| 314 | + rtn.put("status", ResponseCode.ERROR); | |
| 315 | + rtn.put("msg", exp.getMessage()); | |
| 316 | + } | |
| 317 | + return rtn; | |
| 318 | + } | |
| 319 | + | |
| 320 | + @RequestMapping(value = "/validate_spy_fgs", method = RequestMethod.GET) | |
| 321 | + public Map<String, Object> validate_spy_fgs(HttpServletRequest request, @RequestParam Map<String, Object> param) { | |
| 322 | + HttpSession session = request.getSession(); | |
| 323 | + List<CompanyAuthority> cmyAuths = (List<CompanyAuthority>) session.getAttribute(Constants.COMPANY_AUTHORITYS); | |
| 324 | + List<CompanyAuthorityDto> companyAuthorityDtoList = new ArrayList<>(); | |
| 325 | + for (CompanyAuthority companyAuthority : cmyAuths) { | |
| 326 | + CompanyAuthorityDto companyAuthorityDto = CompanyAuthorityDto.getBuilder() | |
| 327 | + .setId(companyAuthority.getId()) | |
| 328 | + .setCompanyCode(companyAuthority.getCompanyCode()) | |
| 329 | + .setCompanyName(companyAuthority.getCompanyName()) | |
| 330 | + .setSubCompanyCode(companyAuthority.getSubCompanyCode()) | |
| 331 | + .setSubCompanyName(companyAuthority.getSubCompanyName()) | |
| 332 | + .build(); | |
| 333 | + companyAuthorityDtoList.add(companyAuthorityDto); | |
| 334 | + } | |
| 335 | + | |
| 336 | + Map<String, Object> rtn = new HashMap<>(); | |
| 337 | + try { | |
| 338 | + EmployeeConfigDto employeeConfigDto = EmployeeConfigDto.getBuilder() | |
| 339 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 340 | + LineDto.getBuilder() | |
| 341 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 342 | + .setName(param.get("xl.name_eq").toString()) | |
| 343 | + .build() | |
| 344 | + )) | |
| 345 | + .setSpy(param.get("spy.id_eq") == null ? null : ( | |
| 346 | + PersonnelDto.getBuilder() | |
| 347 | + .setId(Integer.valueOf(param.get("spy.id_eq").toString())) | |
| 348 | + .build() | |
| 349 | + )) | |
| 350 | + .build(); | |
| 351 | + employeeConfigServiceFacade.validate_spy_fgs_authority(employeeConfigDto, companyAuthorityDtoList); | |
| 352 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 353 | + } catch (Exception exp) { | |
| 354 | + rtn.put("status", ResponseCode.ERROR); | |
| 355 | + rtn.put("msg", exp.getMessage()); | |
| 356 | + } | |
| 357 | + return rtn; | |
| 358 | + } | |
| 359 | + | |
| 360 | + //------------------ TODO:导入导出逻辑,之后会服务化 -----------------// | |
| 361 | + @Autowired | |
| 362 | + private EmployeeConfigInfoService employeeConfigInfoService; | |
| 363 | + // 上传excel文件 | |
| 364 | + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 365 | + public Map<String, Object> uploadFile(MultipartFile file) { | |
| 366 | + Map<String, Object> rtn = new HashMap<>(); | |
| 367 | + try { | |
| 368 | + DataToolsFile dataToolsFile = employeeConfigInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 369 | + // excel文件名 | |
| 370 | + String fileName = dataToolsFile.getFile().getAbsolutePath(); | |
| 371 | + Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile()); | |
| 372 | + | |
| 373 | + // excel文件sheet | |
| 374 | + List<String> sheetnames = new ArrayList<>(); | |
| 375 | + for (int i = 0; i < wb.getNumberOfSheets(); i ++) { | |
| 376 | + sheetnames.add(wb.getSheetAt(i).getSheetName()); | |
| 377 | + } | |
| 378 | + | |
| 379 | + wb.close(); | |
| 380 | + | |
| 381 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 382 | + rtn.put("filename", fileName); | |
| 383 | + rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | |
| 384 | + } catch (Exception exp) { | |
| 385 | + exp.printStackTrace(); | |
| 386 | + rtn.put("status", ResponseCode.ERROR); | |
| 387 | + rtn.put("msg", exp.getMessage()); | |
| 388 | + } | |
| 389 | + return rtn; | |
| 390 | + } | |
| 391 | + // 导入excel文件 | |
| 392 | + @RequestMapping(value = "/importFile", method = RequestMethod.POST) | |
| 393 | + public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | |
| 394 | + Map<String, Object> rtn = new HashMap<>(); | |
| 395 | + | |
| 396 | + try { | |
| 397 | + File file = new File(String.valueOf(params.get("filename"))); | |
| 398 | + if (!file.exists()) { | |
| 399 | + throw new Exception("导入文件不存在!"); | |
| 400 | + } | |
| 401 | + employeeConfigInfoService.importData(file, params); | |
| 402 | + | |
| 403 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 404 | + rtn.put("msg", "导入文件成功"); | |
| 405 | + } catch (Exception exp) { | |
| 406 | + rtn.put("status", ResponseCode.ERROR); | |
| 407 | + rtn.put("msg", exp.getMessage()); | |
| 408 | + } | |
| 409 | + | |
| 410 | + return rtn; | |
| 411 | + } | |
| 412 | + // 上传并导入excel文件 | |
| 413 | + @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | |
| 414 | + public Map<String, Object> uploadAndImportFile(MultipartFile file) { | |
| 415 | + Map<String, Object> rtn = new HashMap<>(); | |
| 416 | + | |
| 417 | + try { | |
| 418 | + DataToolsFile dataToolsFile = employeeConfigInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 419 | + Map<String, Object> params = new HashMap<>(); | |
| 420 | + employeeConfigInfoService.importData(dataToolsFile.getFile(), params); | |
| 421 | + | |
| 422 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 423 | + rtn.put("msg", "上传&导入文件成功"); | |
| 424 | + } catch (Exception exp) { | |
| 425 | + exp.printStackTrace(); | |
| 426 | + rtn.put("status", ResponseCode.ERROR); | |
| 427 | + rtn.put("msg", exp.getMessage()); | |
| 428 | + } | |
| 429 | + | |
| 430 | + return rtn; | |
| 431 | + } | |
| 432 | + | |
| 433 | + // 导出数据到xls文件 | |
| 434 | + @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | |
| 435 | + public void exportFile(HttpServletResponse response, | |
| 436 | + @RequestParam Map<String, Object> params) throws Exception { | |
| 437 | + DataToolsFile dataToolsFile = employeeConfigInfoService.exportData(params); | |
| 438 | + // 流输出导出文件 | |
| 439 | + response.setHeader("content-type", "application/octet-stream"); | |
| 440 | + response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName()); | |
| 441 | + response.setContentType("application/octet-stream"); | |
| 442 | + | |
| 443 | + OutputStream os = response.getOutputStream(); | |
| 444 | + BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 445 | + | |
| 446 | + InputStream is = new FileInputStream(dataToolsFile.getFile()); | |
| 447 | + BufferedInputStream bis = new BufferedInputStream(is); | |
| 448 | + | |
| 449 | + int length = 0; | |
| 450 | + byte[] temp = new byte[1 * 1024 * 10]; | |
| 451 | + while ((length = bis.read(temp)) != -1) { | |
| 452 | + bos.write(temp, 0, length); | |
| 453 | + } | |
| 454 | + bos.flush(); | |
| 455 | + bis.close(); | |
| 456 | + bos.close(); | |
| 457 | + is.close(); | |
| 458 | + } | |
| 459 | + | |
| 460 | + | |
| 461 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/core/GuideboardInfoController_facade.java
| 1 | -package com.bsth.controller.schedule.core; | |
| 2 | - | |
| 3 | -import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | -import com.bsth.common.ResponseCode; | |
| 5 | -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 6 | -import com.bsth.control_v2.plan_module.common.dto.baseinfo.LineDto; | |
| 7 | -import com.bsth.control_v2.plan_module.common.dto.schedule.config.LpConfigDto; | |
| 8 | -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 9 | -import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 10 | -import com.bsth.control_v2.plan_module.common.service.schedule.config.LpConfigServiceFacade; | |
| 11 | -import com.bsth.controller.schedule.BController_facade; | |
| 12 | -import com.bsth.service.schedule.GuideboardInfoService; | |
| 13 | -import com.bsth.service.schedule.utils.DataToolsFile; | |
| 14 | -import org.apache.commons.lang3.StringUtils; | |
| 15 | -import org.apache.poi.ss.usermodel.Workbook; | |
| 16 | -import org.springframework.beans.factory.annotation.Autowired; | |
| 17 | -import org.springframework.context.annotation.Conditional; | |
| 18 | -import org.springframework.web.bind.annotation.*; | |
| 19 | -import org.springframework.web.multipart.MultipartFile; | |
| 20 | - | |
| 21 | -import javax.servlet.http.HttpServletResponse; | |
| 22 | -import java.io.*; | |
| 23 | -import java.util.*; | |
| 24 | - | |
| 25 | -/** | |
| 26 | - * 路牌管理控制器。 | |
| 27 | - */ | |
| 28 | -@RestController | |
| 29 | -@Conditional(DubboConfigCondition.class) | |
| 30 | -@RequestMapping("gic") | |
| 31 | -public class GuideboardInfoController_facade extends BController_facade<Long, LpConfigDto> { | |
| 32 | - @Override | |
| 33 | - public void setCreateUserInfo(LpConfigDto lpConfigDto, Integer userId, Date createDate) { | |
| 34 | - UserDto userDto = UserDto.getBuilder() | |
| 35 | - .setId(userId) | |
| 36 | - .build(); | |
| 37 | - lpConfigDto.setCreateBy(userDto); | |
| 38 | - lpConfigDto.setCreateDate(createDate); | |
| 39 | - } | |
| 40 | - | |
| 41 | - @Override | |
| 42 | - public void setUpdateUserInfo(LpConfigDto lpConfigDto, Integer userId, Date updateDate) { | |
| 43 | - UserDto userDto = UserDto.getBuilder() | |
| 44 | - .setId(userId) | |
| 45 | - .build(); | |
| 46 | - lpConfigDto.setUpdateBy(userDto); | |
| 47 | - lpConfigDto.setUpdateDate(updateDate); | |
| 48 | - } | |
| 49 | - | |
| 50 | - @Reference | |
| 51 | - private LpConfigServiceFacade lpConfigServiceFacade; | |
| 52 | - | |
| 53 | - @Override | |
| 54 | - protected BServiceFacade<Long, LpConfigDto> getBServiceFacade() { | |
| 55 | - return lpConfigServiceFacade; | |
| 56 | - } | |
| 57 | - | |
| 58 | - @RequestMapping(value = "/ttlpnames", method = RequestMethod.GET) | |
| 59 | - public List<Map<String, Object>> findLpName(Long ttid) { | |
| 60 | - return lpConfigServiceFacade.findLpName_from_ttinfo(ttid); | |
| 61 | - } | |
| 62 | - | |
| 63 | - @RequestMapping(value = "lpno/{xlid}", method = RequestMethod.GET) | |
| 64 | - public Map<String, Object> getLpNo(@PathVariable("xlid") Integer xl) { | |
| 65 | - Map<String, Object> rtn = new HashMap<>(); | |
| 66 | - try { | |
| 67 | - rtn.put("data", lpConfigServiceFacade.getMaxLpno(xl)); | |
| 68 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 69 | - } catch (Exception exp) { | |
| 70 | - exp.printStackTrace(); | |
| 71 | - rtn.put("status", ResponseCode.ERROR); | |
| 72 | - rtn.put("msg", exp.getMessage()); | |
| 73 | - } | |
| 74 | - | |
| 75 | - return rtn; | |
| 76 | - } | |
| 77 | - | |
| 78 | - @RequestMapping(value = "/validate_lpno", method = RequestMethod.GET) | |
| 79 | - public Map<String, Object> validate_lpno(@RequestParam Map<String, Object> param) { | |
| 80 | - Map<String, Object> rtn = new HashMap<>(); | |
| 81 | - try { | |
| 82 | - LpConfigDto lpConfigDto = LpConfigDto.getBuilder() | |
| 83 | - .setId(param.get("id_eq") == null ? null : Long.valueOf(param.get("id_eq").toString())) | |
| 84 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 85 | - LineDto.getBuilder() | |
| 86 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 87 | - .build() | |
| 88 | - )) | |
| 89 | - .setLpNo(param.get("lpNo_eq") == null ? null : Integer.valueOf(param.get("lpNo_eq").toString())) | |
| 90 | - .build(); | |
| 91 | - lpConfigServiceFacade.validate_lpno_duplicate(lpConfigDto); | |
| 92 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 93 | - } catch (Exception exp) { | |
| 94 | - rtn.put("status", ResponseCode.ERROR); | |
| 95 | - rtn.put("msg", exp.getMessage()); | |
| 96 | - } | |
| 97 | - return rtn; | |
| 98 | - } | |
| 99 | - | |
| 100 | - @RequestMapping(value = "/validate_lpname", method = RequestMethod.GET) | |
| 101 | - public Map<String, Object> validate_lpname(@RequestParam Map<String, Object> param) { | |
| 102 | - Map<String, Object> rtn = new HashMap<>(); | |
| 103 | - try { | |
| 104 | - LpConfigDto lpConfigDto = LpConfigDto.getBuilder() | |
| 105 | - .setId(param.get("id_eq") == null ? null : Long.valueOf(param.get("id_eq").toString())) | |
| 106 | - .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 107 | - LineDto.getBuilder() | |
| 108 | - .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 109 | - .build() | |
| 110 | - )) | |
| 111 | - .setLpName(param.get("lpName_eq") == null ? null : param.get("lpName_eq").toString()) | |
| 112 | - .build(); | |
| 113 | - lpConfigServiceFacade.validate_lpname_duplicate(lpConfigDto); | |
| 114 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 115 | - } catch (Exception exp) { | |
| 116 | - rtn.put("status", ResponseCode.ERROR); | |
| 117 | - rtn.put("msg", exp.getMessage()); | |
| 118 | - } | |
| 119 | - return rtn; | |
| 120 | - } | |
| 121 | - | |
| 122 | - //------------------ TODO:导入导出逻辑,之后会服务化 -----------------// | |
| 123 | - @Autowired | |
| 124 | - private GuideboardInfoService guideboardInfoService; | |
| 125 | - // 上传excel文件 | |
| 126 | - @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 127 | - public Map<String, Object> uploadFile(MultipartFile file) { | |
| 128 | - Map<String, Object> rtn = new HashMap<>(); | |
| 129 | - try { | |
| 130 | - DataToolsFile dataToolsFile = guideboardInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 131 | - // excel文件名 | |
| 132 | - String fileName = dataToolsFile.getFile().getAbsolutePath(); | |
| 133 | - Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile()); | |
| 134 | - | |
| 135 | - // excel文件sheet | |
| 136 | - List<String> sheetnames = new ArrayList<>(); | |
| 137 | - for (int i = 0; i < wb.getNumberOfSheets(); i ++) { | |
| 138 | - sheetnames.add(wb.getSheetAt(i).getSheetName()); | |
| 139 | - } | |
| 140 | - | |
| 141 | - wb.close(); | |
| 142 | - | |
| 143 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 144 | - rtn.put("filename", fileName); | |
| 145 | - rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | |
| 146 | - } catch (Exception exp) { | |
| 147 | - exp.printStackTrace(); | |
| 148 | - rtn.put("status", ResponseCode.ERROR); | |
| 149 | - rtn.put("msg", exp.getMessage()); | |
| 150 | - } | |
| 151 | - return rtn; | |
| 152 | - } | |
| 153 | - // 导入excel文件 | |
| 154 | - @RequestMapping(value = "/importFile", method = RequestMethod.POST) | |
| 155 | - public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | |
| 156 | - Map<String, Object> rtn = new HashMap<>(); | |
| 157 | - | |
| 158 | - try { | |
| 159 | - File file = new File(String.valueOf(params.get("filename"))); | |
| 160 | - if (!file.exists()) { | |
| 161 | - throw new Exception("导入文件不存在!"); | |
| 162 | - } | |
| 163 | - guideboardInfoService.importData(file, params); | |
| 164 | - | |
| 165 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 166 | - rtn.put("msg", "导入文件成功"); | |
| 167 | - } catch (Exception exp) { | |
| 168 | - rtn.put("status", ResponseCode.ERROR); | |
| 169 | - rtn.put("msg", exp.getMessage()); | |
| 170 | - } | |
| 171 | - | |
| 172 | - return rtn; | |
| 173 | - } | |
| 174 | - // 上传并导入excel文件 | |
| 175 | - @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | |
| 176 | - public Map<String, Object> uploadAndImportFile(MultipartFile file) { | |
| 177 | - Map<String, Object> rtn = new HashMap<>(); | |
| 178 | - | |
| 179 | - try { | |
| 180 | - DataToolsFile dataToolsFile = guideboardInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 181 | - Map<String, Object> params = new HashMap<>(); | |
| 182 | - guideboardInfoService.importData(dataToolsFile.getFile(), params); | |
| 183 | - | |
| 184 | - rtn.put("status", ResponseCode.SUCCESS); | |
| 185 | - rtn.put("msg", "上传&导入文件成功"); | |
| 186 | - } catch (Exception exp) { | |
| 187 | - exp.printStackTrace(); | |
| 188 | - rtn.put("status", ResponseCode.ERROR); | |
| 189 | - rtn.put("msg", exp.getMessage()); | |
| 190 | - } | |
| 191 | - | |
| 192 | - return rtn; | |
| 193 | - } | |
| 194 | - | |
| 195 | - // 导出数据到xls文件 | |
| 196 | - @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | |
| 197 | - public void exportFile(HttpServletResponse response, | |
| 198 | - @RequestParam Map<String, Object> params) throws Exception { | |
| 199 | - DataToolsFile dataToolsFile = guideboardInfoService.exportData(params); | |
| 200 | - // 流输出导出文件 | |
| 201 | - response.setHeader("content-type", "application/octet-stream"); | |
| 202 | - response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName()); | |
| 203 | - response.setContentType("application/octet-stream"); | |
| 204 | - | |
| 205 | - OutputStream os = response.getOutputStream(); | |
| 206 | - BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 207 | - | |
| 208 | - InputStream is = new FileInputStream(dataToolsFile.getFile()); | |
| 209 | - BufferedInputStream bis = new BufferedInputStream(is); | |
| 210 | - | |
| 211 | - int length = 0; | |
| 212 | - byte[] temp = new byte[1 * 1024 * 10]; | |
| 213 | - while ((length = bis.read(temp)) != -1) { | |
| 214 | - bos.write(temp, 0, length); | |
| 215 | - } | |
| 216 | - bos.flush(); | |
| 217 | - bis.close(); | |
| 218 | - bos.close(); | |
| 219 | - is.close(); | |
| 220 | - } | |
| 221 | -} | |
| 1 | +package com.bsth.controller.schedule.core; | |
| 2 | + | |
| 3 | +import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | +import com.bsth.common.ResponseCode; | |
| 5 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 6 | +import com.bsth.control_v2.plan_module.common.dto.baseinfo.LineDto; | |
| 7 | +import com.bsth.control_v2.plan_module.common.dto.schedule.config.LpConfigDto; | |
| 8 | +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 9 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 10 | +import com.bsth.control_v2.plan_module.common.service.schedule.config.LpConfigServiceFacade; | |
| 11 | +import com.bsth.controller.schedule.BController_facade; | |
| 12 | +import com.bsth.service.schedule.GuideboardInfoService; | |
| 13 | +import com.bsth.service.schedule.utils.DataToolsFile; | |
| 14 | +import org.apache.commons.lang3.StringUtils; | |
| 15 | +import org.apache.poi.ss.usermodel.Workbook; | |
| 16 | +import org.springframework.beans.factory.annotation.Autowired; | |
| 17 | +import org.springframework.context.annotation.Conditional; | |
| 18 | +import org.springframework.web.bind.annotation.*; | |
| 19 | +import org.springframework.web.multipart.MultipartFile; | |
| 20 | + | |
| 21 | +import javax.servlet.http.HttpServletResponse; | |
| 22 | +import java.io.*; | |
| 23 | +import java.util.*; | |
| 24 | + | |
| 25 | +/** | |
| 26 | + * 路牌管理控制器。 | |
| 27 | + */ | |
| 28 | +@RestController | |
| 29 | +@Conditional(DubboConfigCondition.class) | |
| 30 | +@RequestMapping("gic") | |
| 31 | +public class GuideboardInfoController_facade extends BController_facade<Long, LpConfigDto> { | |
| 32 | + @Override | |
| 33 | + public void setCreateUserInfo(LpConfigDto lpConfigDto, Integer userId, Date createDate) { | |
| 34 | + UserDto userDto = UserDto.getBuilder() | |
| 35 | + .setId(userId) | |
| 36 | + .build(); | |
| 37 | + lpConfigDto.setCreateBy(userDto); | |
| 38 | + lpConfigDto.setCreateDate(createDate); | |
| 39 | + } | |
| 40 | + | |
| 41 | + @Override | |
| 42 | + public void setUpdateUserInfo(LpConfigDto lpConfigDto, Integer userId, Date updateDate) { | |
| 43 | + UserDto userDto = UserDto.getBuilder() | |
| 44 | + .setId(userId) | |
| 45 | + .build(); | |
| 46 | + lpConfigDto.setUpdateBy(userDto); | |
| 47 | + lpConfigDto.setUpdateDate(updateDate); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @Reference | |
| 51 | + private LpConfigServiceFacade lpConfigServiceFacade; | |
| 52 | + | |
| 53 | + @Override | |
| 54 | + protected BServiceFacade<Long, LpConfigDto> getBServiceFacade() { | |
| 55 | + return lpConfigServiceFacade; | |
| 56 | + } | |
| 57 | + | |
| 58 | + @RequestMapping(value = "/ttlpnames", method = RequestMethod.GET) | |
| 59 | + public List<Map<String, Object>> findLpName(Long ttid) { | |
| 60 | + return lpConfigServiceFacade.findLpName_from_ttinfo(ttid); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @RequestMapping(value = "lpno/{xlid}", method = RequestMethod.GET) | |
| 64 | + public Map<String, Object> getLpNo(@PathVariable("xlid") Integer xl) { | |
| 65 | + Map<String, Object> rtn = new HashMap<>(); | |
| 66 | + try { | |
| 67 | + rtn.put("data", lpConfigServiceFacade.getMaxLpno(xl)); | |
| 68 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 69 | + } catch (Exception exp) { | |
| 70 | + exp.printStackTrace(); | |
| 71 | + rtn.put("status", ResponseCode.ERROR); | |
| 72 | + rtn.put("msg", exp.getMessage()); | |
| 73 | + } | |
| 74 | + | |
| 75 | + return rtn; | |
| 76 | + } | |
| 77 | + | |
| 78 | + @RequestMapping(value = "/validate_lpno", method = RequestMethod.GET) | |
| 79 | + public Map<String, Object> validate_lpno(@RequestParam Map<String, Object> param) { | |
| 80 | + Map<String, Object> rtn = new HashMap<>(); | |
| 81 | + try { | |
| 82 | + LpConfigDto lpConfigDto = LpConfigDto.getBuilder() | |
| 83 | + .setId(param.get("id_eq") == null ? null : Long.valueOf(param.get("id_eq").toString())) | |
| 84 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 85 | + LineDto.getBuilder() | |
| 86 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 87 | + .build() | |
| 88 | + )) | |
| 89 | + .setLpNo(param.get("lpNo_eq") == null ? null : Integer.valueOf(param.get("lpNo_eq").toString())) | |
| 90 | + .build(); | |
| 91 | + lpConfigServiceFacade.validate_lpno_duplicate(lpConfigDto); | |
| 92 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 93 | + } catch (Exception exp) { | |
| 94 | + rtn.put("status", ResponseCode.ERROR); | |
| 95 | + rtn.put("msg", exp.getMessage()); | |
| 96 | + } | |
| 97 | + return rtn; | |
| 98 | + } | |
| 99 | + | |
| 100 | + @RequestMapping(value = "/validate_lpname", method = RequestMethod.GET) | |
| 101 | + public Map<String, Object> validate_lpname(@RequestParam Map<String, Object> param) { | |
| 102 | + Map<String, Object> rtn = new HashMap<>(); | |
| 103 | + try { | |
| 104 | + LpConfigDto lpConfigDto = LpConfigDto.getBuilder() | |
| 105 | + .setId(param.get("id_eq") == null ? null : Long.valueOf(param.get("id_eq").toString())) | |
| 106 | + .setXl(param.get("xl.id_eq") == null ? null : ( | |
| 107 | + LineDto.getBuilder() | |
| 108 | + .setId(Integer.valueOf(param.get("xl.id_eq").toString())) | |
| 109 | + .build() | |
| 110 | + )) | |
| 111 | + .setLpName(param.get("lpName_eq") == null ? null : param.get("lpName_eq").toString()) | |
| 112 | + .build(); | |
| 113 | + lpConfigServiceFacade.validate_lpname_duplicate(lpConfigDto); | |
| 114 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 115 | + } catch (Exception exp) { | |
| 116 | + rtn.put("status", ResponseCode.ERROR); | |
| 117 | + rtn.put("msg", exp.getMessage()); | |
| 118 | + } | |
| 119 | + return rtn; | |
| 120 | + } | |
| 121 | + | |
| 122 | + //------------------ TODO:导入导出逻辑,之后会服务化 -----------------// | |
| 123 | + @Autowired | |
| 124 | + private GuideboardInfoService guideboardInfoService; | |
| 125 | + // 上传excel文件 | |
| 126 | + @RequestMapping(value = "/uploadFile", method = RequestMethod.POST) | |
| 127 | + public Map<String, Object> uploadFile(MultipartFile file) { | |
| 128 | + Map<String, Object> rtn = new HashMap<>(); | |
| 129 | + try { | |
| 130 | + DataToolsFile dataToolsFile = guideboardInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 131 | + // excel文件名 | |
| 132 | + String fileName = dataToolsFile.getFile().getAbsolutePath(); | |
| 133 | + Workbook wb = dataToolsFile.getFileType().getWorkBook(dataToolsFile.getFile()); | |
| 134 | + | |
| 135 | + // excel文件sheet | |
| 136 | + List<String> sheetnames = new ArrayList<>(); | |
| 137 | + for (int i = 0; i < wb.getNumberOfSheets(); i ++) { | |
| 138 | + sheetnames.add(wb.getSheetAt(i).getSheetName()); | |
| 139 | + } | |
| 140 | + | |
| 141 | + wb.close(); | |
| 142 | + | |
| 143 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 144 | + rtn.put("filename", fileName); | |
| 145 | + rtn.put("sheetnames", StringUtils.join(sheetnames, ",")); | |
| 146 | + } catch (Exception exp) { | |
| 147 | + exp.printStackTrace(); | |
| 148 | + rtn.put("status", ResponseCode.ERROR); | |
| 149 | + rtn.put("msg", exp.getMessage()); | |
| 150 | + } | |
| 151 | + return rtn; | |
| 152 | + } | |
| 153 | + // 导入excel文件 | |
| 154 | + @RequestMapping(value = "/importFile", method = RequestMethod.POST) | |
| 155 | + public Map<String, Object> importFile(@RequestParam Map<String, Object> params) { | |
| 156 | + Map<String, Object> rtn = new HashMap<>(); | |
| 157 | + | |
| 158 | + try { | |
| 159 | + File file = new File(String.valueOf(params.get("filename"))); | |
| 160 | + if (!file.exists()) { | |
| 161 | + throw new Exception("导入文件不存在!"); | |
| 162 | + } | |
| 163 | + guideboardInfoService.importData(file, params); | |
| 164 | + | |
| 165 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 166 | + rtn.put("msg", "导入文件成功"); | |
| 167 | + } catch (Exception exp) { | |
| 168 | + rtn.put("status", ResponseCode.ERROR); | |
| 169 | + rtn.put("msg", exp.getMessage()); | |
| 170 | + } | |
| 171 | + | |
| 172 | + return rtn; | |
| 173 | + } | |
| 174 | + // 上传并导入excel文件 | |
| 175 | + @RequestMapping(value = "/uploadAndImportFile", method = RequestMethod.POST) | |
| 176 | + public Map<String, Object> uploadAndImportFile(MultipartFile file) { | |
| 177 | + Map<String, Object> rtn = new HashMap<>(); | |
| 178 | + | |
| 179 | + try { | |
| 180 | + DataToolsFile dataToolsFile = guideboardInfoService.uploadFile(file.getOriginalFilename(), file.getBytes()); | |
| 181 | + Map<String, Object> params = new HashMap<>(); | |
| 182 | + guideboardInfoService.importData(dataToolsFile.getFile(), params); | |
| 183 | + | |
| 184 | + rtn.put("status", ResponseCode.SUCCESS); | |
| 185 | + rtn.put("msg", "上传&导入文件成功"); | |
| 186 | + } catch (Exception exp) { | |
| 187 | + exp.printStackTrace(); | |
| 188 | + rtn.put("status", ResponseCode.ERROR); | |
| 189 | + rtn.put("msg", exp.getMessage()); | |
| 190 | + } | |
| 191 | + | |
| 192 | + return rtn; | |
| 193 | + } | |
| 194 | + | |
| 195 | + // 导出数据到xls文件 | |
| 196 | + @RequestMapping(value = "/exportFile", method = RequestMethod.GET) | |
| 197 | + public void exportFile(HttpServletResponse response, | |
| 198 | + @RequestParam Map<String, Object> params) throws Exception { | |
| 199 | + DataToolsFile dataToolsFile = guideboardInfoService.exportData(params); | |
| 200 | + // 流输出导出文件 | |
| 201 | + response.setHeader("content-type", "application/octet-stream"); | |
| 202 | + response.setHeader("Content-Disposition", "attachment; filename=" + dataToolsFile.getFile().getName()); | |
| 203 | + response.setContentType("application/octet-stream"); | |
| 204 | + | |
| 205 | + OutputStream os = response.getOutputStream(); | |
| 206 | + BufferedOutputStream bos = new BufferedOutputStream(os); | |
| 207 | + | |
| 208 | + InputStream is = new FileInputStream(dataToolsFile.getFile()); | |
| 209 | + BufferedInputStream bis = new BufferedInputStream(is); | |
| 210 | + | |
| 211 | + int length = 0; | |
| 212 | + byte[] temp = new byte[1 * 1024 * 10]; | |
| 213 | + while ((length = bis.read(temp)) != -1) { | |
| 214 | + bos.write(temp, 0, length); | |
| 215 | + } | |
| 216 | + bos.flush(); | |
| 217 | + bis.close(); | |
| 218 | + bos.close(); | |
| 219 | + is.close(); | |
| 220 | + } | |
| 221 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/core/LogController_facade.java
| 1 | -package com.bsth.controller.schedule.core; | |
| 2 | - | |
| 3 | -import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 5 | -import com.bsth.control_v2.plan_module.common.dto.schedule.log.ModuleOperatorLogDto; | |
| 6 | -import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 7 | -import com.bsth.control_v2.plan_module.common.service.log.LogServiceFacade; | |
| 8 | -import com.bsth.controller.schedule.BController_facade; | |
| 9 | -import org.springframework.context.annotation.Conditional; | |
| 10 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 11 | -import org.springframework.web.bind.annotation.RestController; | |
| 12 | - | |
| 13 | -@RestController | |
| 14 | -@Conditional(DubboConfigCondition.class) | |
| 15 | -@RequestMapping("s_log") | |
| 16 | -public class LogController_facade extends BController_facade<Long, ModuleOperatorLogDto> { | |
| 17 | - @Reference | |
| 18 | - private LogServiceFacade logServiceFacade; | |
| 19 | - | |
| 20 | - @Override | |
| 21 | - protected BServiceFacade<Long, ModuleOperatorLogDto> getBServiceFacade() { | |
| 22 | - return logServiceFacade; | |
| 23 | - } | |
| 24 | -} | |
| 1 | +package com.bsth.controller.schedule.core; | |
| 2 | + | |
| 3 | +import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 5 | +import com.bsth.control_v2.plan_module.common.dto.schedule.log.ModuleOperatorLogDto; | |
| 6 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 7 | +import com.bsth.control_v2.plan_module.common.service.log.LogServiceFacade; | |
| 8 | +import com.bsth.controller.schedule.BController_facade; | |
| 9 | +import org.springframework.context.annotation.Conditional; | |
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 11 | +import org.springframework.web.bind.annotation.RestController; | |
| 12 | + | |
| 13 | +@RestController | |
| 14 | +@Conditional(DubboConfigCondition.class) | |
| 15 | +@RequestMapping("s_log") | |
| 16 | +public class LogController_facade extends BController_facade<Long, ModuleOperatorLogDto> { | |
| 17 | + @Reference | |
| 18 | + private LogServiceFacade logServiceFacade; | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + protected BServiceFacade<Long, ModuleOperatorLogDto> getBServiceFacade() { | |
| 22 | + return logServiceFacade; | |
| 23 | + } | |
| 24 | +} | ... | ... |
src/main/java/com/bsth/controller/schedule/core/RerunController_facade.java
| 1 | -package com.bsth.controller.schedule.core; | |
| 2 | - | |
| 3 | -import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | -import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 5 | -import com.bsth.control_v2.plan_module.common.dto.schedule.rule.RerunRuleDto; | |
| 6 | -import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 7 | -import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 8 | -import com.bsth.control_v2.plan_module.common.service.schedule.rule.RerunRuleConfigServiceFacade; | |
| 9 | -import com.bsth.controller.schedule.BController_facade; | |
| 10 | -import org.springframework.context.annotation.Conditional; | |
| 11 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 12 | -import org.springframework.web.bind.annotation.RestController; | |
| 13 | - | |
| 14 | -import java.util.Date; | |
| 15 | - | |
| 16 | -/** | |
| 17 | - * Created by xu on 16/10/20. | |
| 18 | - */ | |
| 19 | -@RestController | |
| 20 | -@Conditional(DubboConfigCondition.class) | |
| 21 | -@RequestMapping("rms") | |
| 22 | -public class RerunController_facade extends BController_facade<Long, RerunRuleDto> { | |
| 23 | - @Override | |
| 24 | - public void setCreateUserInfo(RerunRuleDto rerunRuleDto, Integer userId, Date createDate) { | |
| 25 | - UserDto userDto = UserDto.getBuilder() | |
| 26 | - .setId(userId) | |
| 27 | - .build(); | |
| 28 | - rerunRuleDto.setCreateBy(userDto); | |
| 29 | - rerunRuleDto.setCreateDate(createDate); | |
| 30 | - } | |
| 31 | - | |
| 32 | - @Override | |
| 33 | - public void setUpdateUserInfo(RerunRuleDto rerunRuleDto, Integer userId, Date updateDate) { | |
| 34 | - UserDto userDto = UserDto.getBuilder() | |
| 35 | - .setId(userId) | |
| 36 | - .build(); | |
| 37 | - rerunRuleDto.setUpdateBy(userDto); | |
| 38 | - rerunRuleDto.setUpdateDate(updateDate); | |
| 39 | - } | |
| 40 | - | |
| 41 | - @Reference | |
| 42 | - private RerunRuleConfigServiceFacade rerunRuleConfigServiceFacade; | |
| 43 | - | |
| 44 | - @Override | |
| 45 | - protected BServiceFacade<Long, RerunRuleDto> getBServiceFacade() { | |
| 46 | - return rerunRuleConfigServiceFacade; | |
| 47 | - } | |
| 48 | -} | |
| 1 | +package com.bsth.controller.schedule.core; | |
| 2 | + | |
| 3 | +import com.alibaba.dubbo.config.annotation.Reference; | |
| 4 | +import com.bsth.control_v2.plan_module.common.config.springboot.dubbo.DubboConfigCondition; | |
| 5 | +import com.bsth.control_v2.plan_module.common.dto.schedule.rule.RerunRuleDto; | |
| 6 | +import com.bsth.control_v2.plan_module.common.dto.sys.UserDto; | |
| 7 | +import com.bsth.control_v2.plan_module.common.service.BServiceFacade; | |
| 8 | +import com.bsth.control_v2.plan_module.common.service.schedule.rule.RerunRuleConfigServiceFacade; | |
| 9 | +import com.bsth.controller.schedule.BController_facade; | |
| 10 | +import org.springframework.context.annotation.Conditional; | |
| 11 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 12 | +import org.springframework.web.bind.annotation.RestController; | |
| 13 | + | |
| 14 | +import java.util.Date; | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * Created by xu on 16/10/20. | |
| 18 | + */ | |
| 19 | +@RestController | |
| 20 | +@Conditional(DubboConfigCondition.class) | |
| 21 | +@RequestMapping("rms") | |
| 22 | +public class RerunController_facade extends BController_facade<Long, RerunRuleDto> { | |
| 23 | + @Override | |
| 24 | + public void setCreateUserInfo(RerunRuleDto rerunRuleDto, Integer userId, Date createDate) { | |
| 25 | + UserDto userDto = UserDto.getBuilder() | |
| 26 | + .setId(userId) | |
| 27 | + .build(); | |
| 28 | + rerunRuleDto.setCreateBy(userDto); | |
| 29 | + rerunRuleDto.setCreateDate(createDate); | |
| 30 | + } | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public void setUpdateUserInfo(RerunRuleDto rerunRuleDto, Integer userId, Date updateDate) { | |
| 34 | + UserDto userDto = UserDto.getBuilder() | |
| 35 | + .setId(userId) | |
| 36 | + .build(); | |
| 37 | + rerunRuleDto.setUpdateBy(userDto); | |
| 38 | + rerunRuleDto.setUpdateDate(updateDate); | |
| 39 | + } | |
| 40 | + | |
| 41 | + @Reference | |
| 42 | + private RerunRuleConfigServiceFacade rerunRuleConfigServiceFacade; | |
| 43 | + | |
| 44 | + @Override | |
| 45 | + protected BServiceFacade<Long, RerunRuleDto> getBServiceFacade() { | |
| 46 | + return rerunRuleConfigServiceFacade; | |
| 47 | + } | |
| 48 | +} | ... | ... |