作者 王勇

搭建仓库管理服务后台,初步搭建

正在显示 34 个修改的文件 包含 3309 行增加0 行删除
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
*.log
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
... ...
server:
port: 9111
# spring 配置
spring:
security:
user:
name: admin
password: 123456
application:
name: station-manage
# 数据源配置
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://118.31.66.166:3306/station?characterEncoding=utf8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
username: 110
password: QAHqCJf2kFYCLirM
# 多环境配置
profiles:
active: dev
# Jackson配置
jackson:
default-property-inclusion: ALWAYS
time-zone: GMT+8
date-format: yyyy-MM-dd HH:mm:ss
# zipkin 链路追踪配置
zipkin:
base-url: http://192.168.1.63:9411
sleuth:
sampler:
probability: 1
# mybatis 配置
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.sunyo.wlpt.station.manage.domain
# 日志配置
logging:
config: config/logback-dev.xml
level:
com.sunyo.wlpt.station.manage: debug
logback:
appname: station_manage
logdir: ./log
#eureka 配置
eureka:
instance:
status-page-url: http://${eureka.instance.hostname}:${server.port}/index
prefer-ip-address: true
instance-id: ${spring.cloud.client.ip-address}:${server.port}
hostname: ${spring.cloud.client.ip-address}
metadata-map:
user:
name: "admin"
password: "123456"
client:
healthcheck:
enabled: true
service-url:
defaultZone: http://192.168.1.53:12345/eureka/
# boot admin
management:
endpoints:
enabled-by-default: true
web:
exposure:
include: "*"
endpoint:
health:
show-details: always
shutdown:
enabled: true
# 基础信息配置
info:
version: 1.0.0
description: "场站管理:包括场站管理、卡口管理、仓库管理"
... ...
# 解决eureka的多网卡配置问题,指定网卡的IP地址的前缀
spring:
cloud:
inetutils:
preferred-networks: 192.168.1.
eureka:
instance:
prefer-ip-address: true
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!--参考文档链接:https://blog.csdn.net/qq_34912478/article/details/80877132-->
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="10 seconds">
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
<contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<property name="log.path" value="./logs" />
<!-- 彩色日志 -->
<!-- 彩色日志依赖的渲染类 -->
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<!-- 彩色日志格式 -->
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
<!--输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>debug</level>
</filter>
<encoder>
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
<!-- 设置字符集 windows系统这里设置成GBK-->
<charset>UTF-8</charset>
</encoder>
</appender>
<!--输出到文件-->
<!-- 时间滚动输出 level为 DEBUG 日志 -->
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_debug.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志归档 -->
<fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 INFO 日志 -->
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_info.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 WARN 日志 -->
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_warn.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录warn级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 ERROR 日志 -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_error.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 trace 日志 -->
<appender name="TRACE_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_trace.log</file>
<!--日志文件输出格式-->
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/trace/log-trace-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录trace级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>TRACE</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!--
<logger>用来设置某一个包或者具体的某一个类的日志打印级别、
以及指定<appender>。<logger>仅有一个name属性,
一个可选的level和一个可选的addtivity属性。
name:用来指定受此logger约束的某一个包或者具体的某一个类。
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。
如果未设置此属性,那么当前logger将会继承上级的级别。
addtivity:是否向上级logger传递打印信息。默认是true。
-->
<!--<logger name="org.springframework.web" level="info"/>-->
<!--<logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>-->
<!--
使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作:
第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息
第二种就是单独给dao下目录配置debug模式,代码如下,这样配置sql语句会打印,其他还是正常info级别:
-->
<!--
root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
不能设置为INHERITED或者同义词NULL。默认是DEBUG
可以包含零个或多个元素,标识这个appender将会添加到这个logger。
-->
<!--<logger name="com.tianbo.analysis" level="trace">-->
<!--<appender-ref ref="CONSOLE" />-->
<!--<appender-ref ref="TRACE_FILE" />-->
<!--<appender-ref ref="DEBUG_FILE" />-->
<!--<appender-ref ref="INFO_FILE" />-->
<!--<appender-ref ref="WARN_FILE" />-->
<!--<appender-ref ref="ERROR_FILE" />-->
<!--</logger>-->
<!--开发环境:打印控制台-->
<springProfile name="dev">
<logger name="org.springframework" level="info"/>
<logger name="com.sunyo.wlpt.nmms.mapper" level="debug">
<appender-ref ref="CONSOLE" />
<appender-ref ref="DEBUG_FILE" />
</logger>
<logger name="org.apache.tomcat" level="info" />
<root level="info">
<appender-ref ref="CONSOLE" />
<appender-ref ref="TRACE_FILE" />
<appender-ref ref="DEBUG_FILE" />
<appender-ref ref="INFO_FILE" />
<appender-ref ref="WARN_FILE" />
<appender-ref ref="ERROR_FILE" />
</root>
</springProfile>
<!--生产环境:输出到文件-->
<springProfile name="pro">
<logger name="org.springframework" level="INFO"/>
<root level="info">
<appender-ref ref="CONSOLE" />
<appender-ref ref="DEBUG_FILE" />
<appender-ref ref="INFO_FILE" />
<appender-ref ref="ERROR_FILE" />
<appender-ref ref="WARN_FILE" />
<appender-ref ref="TRACE_FILE" />
</root>
</springProfile>
</configuration>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="ture" scanPeriod="60 seconds" debug="false">
<springProperty scope="context" name="appname" source="logback.appname"/>
<springProperty scope="context" name="logdir" source="logback.logdir"/>
<!--文件名-->
<contextName>${appname}</contextName>
<!--输出到控制面板-->
<appender name="consoleLog1" class="ch.qos.logback.core.ConsoleAppender">
<!-- layout输出方式输出-->
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>%d [%thread] %-5level %logger{36} - %msg%n</pattern>
</layout>
</appender>
<!--输出到控制面板-->
<appender name="consoleLog" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<!--输出info级别日志-->
<appender name="fileInfoLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!--过滤 Error-->
<level>ERROR</level>
<!--匹配到就禁止-->
<onMatch>DENY</onMatch>
<!--没有匹配到就允许-->
<onMismatch>ACCEPT</onMismatch>
</filter>
<!--<File>../logs</File>-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${logdir}/info.${appname}.%d{yyyy-MM-dd}.log</FileNamePattern>
<maxHistory>100</maxHistory>
<totalSizeCap>100MB</totalSizeCap>
</rollingPolicy>
<encoder>
<charset>UTF-8</charset>
<pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</pattern>
</encoder>
</appender>
<!--输出Error级别日志-->
<!--<appender name="fileErrorLog" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!--<filter class="ch.qos.logback.classic.filter.LevelFilter">-->
<!--&lt;!&ndash;过滤 Error &ndash;&gt;-->
<!--<level>ERROR</level>-->
<!--</filter>-->
<!--&lt;!&ndash;<File>../logs</File>&ndash;&gt;-->
<!--<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">-->
<!--<FileNamePattern>${logdir}/error.${appname}.%d{yyyy-MM-dd}.log</FileNamePattern>-->
<!--<maxHistory>100</maxHistory>-->
<!--<totalSizeCap>100MB</totalSizeCap>-->
<!--</rollingPolicy>-->
<!--<encoder>-->
<!--<charset>UTF-8</charset>-->
<!--<pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</pattern>-->
<!--</encoder>-->
<!--</appender>-->
<!--监控下列类的所有日志,定义输出级别-->
<logger name="java.sql.PreparedStatement" level="DEBUG" additivity="false">
<appender-ref ref="consoleLog"/>
</logger>    
<logger name="java.sql.Connection" level="DEBUG" additivity="false"> 
<appender-ref ref="consoleLog"/>
</logger>  
<logger name="java.sql.Statement" level="DEBUG" additivity="false">
<appender-ref ref="consoleLog"/>
</logger>    
<logger name="com.ibatis" level="DEBUG" additivity="false">
<appender-ref ref="consoleLog"/>
</logger>    
<logger name="com.ibatis.common.jdbc.SimpleDataSource" level="DEBUG" additivity="false">
<appender-ref ref="consoleLog"/>
</logger>    
<logger name="com.ibatis.common.jdbc.ScriptRunner" level="DEBUG" additivity="false">
<appender-ref ref="consoleLog"/>
</logger>    
<logger name="com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate" level="DEBUG" additivity="false">
<appender-ref ref="consoleLog"/>
</logger> 
<!--输出-->
<root level="INFO">
<appender-ref ref="consoleLog"/>
<!--<appender-ref ref="consoleLog"/>-->
<appender-ref ref="fileInfoLog"/>
<!--<appender-ref ref="fileErrorLog"/>-->
</root>
</configuration>
... ...
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.5.RELEASE</version>
<relativePath/>
</parent>
<groupId>com.sunyo.wlpt.station.manage</groupId>
<artifactId>station-manage</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>station-manage</name>
<description>场站管理</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<!-- SpringBoot start -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<!-- SpringBoot end -->
<!-- SpringCloud start -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- SpringCloud end -->
<!-- database start -->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-data-redis</artifactId>-->
<!-- </dependency>-->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.12</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.1.9</version>
</dependency>
<!-- database end -->
<!-- tools start -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>29.0-jre</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.9.6</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-milestone</id>
<name>Spring Milestone</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-snapshot</id>
<name>Spring Snapshot</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-milestone</id>
<name>Spring Milestone</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-snapshot</id>
<name>Spring Snapshot</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
... ...
package com.sunyo.wlpt.station.manage;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* @author 子诚
*/
@EnableCaching
@SpringBootApplication
@MapperScan("com.sunyo.wlpt.station.manage.mapper")
@EnableFeignClients
@EnableEurekaClient
@EnableTransactionManagement
public class StationManageApplication {
public static void main(String[] args)
{
SpringApplication.run(StationManageApplication.class, args);
}
}
... ...
package com.sunyo.wlpt.station.manage.common;
/**
* @author 子诚
* Description:常量公共类
* 时间:2020/7/17 9:49
*/
public class Common {
public static final String RESULT_SUCCESS = "200";
}
... ...
package com.sunyo.wlpt.station.manage.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
/**
* @author 子诚
* Description:SpringSecurity 权限配置框架
* 时间:2020/7/5 13:38
*/
@EnableWebSecurity
@Configuration
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.csrf().disable();
}
}
... ...
package com.sunyo.wlpt.station.manage.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
/**
* @author 子诚
* Description:swagger-knife4j 的配置文件
* 时间:2020/7/10 11:48
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi()
{
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.sunyo.wlpt.station.manage.controller"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo()
{
return new ApiInfoBuilder()
.title("场站管理服务")
.description("场站管理服务")
.termsOfServiceUrl("http://localhost:9111/")
.contact("子诚")
.version("1.0.0")
.build();
}
}
... ...
package com.sunyo.wlpt.station.manage.controller;
import com.sunyo.wlpt.station.manage.domain.Bayonet;
import com.sunyo.wlpt.station.manage.domain.Yard;
import com.sunyo.wlpt.station.manage.response.ResultJson;
import com.sunyo.wlpt.station.manage.service.BayonetService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author 子诚
* Description:卡口信息,控制器
* 时间:2020/10/12 14:23
*/
@Api(tags = "卡口信息,控制器")
@CrossOrigin
@RequestMapping("bayonet")
@RestController
public class BayonetController {
@Resource
private BayonetService bayonetService;
/**
* 分页查询
* @param stationName 场站名称
* @param name 卡口名称
* @param channel 通道编号
* @param pageNum 当前页数
* @param pageSize 每页数量
* @return
*/
@ApiOperation(value = "卡口信息,分页查询")
@GetMapping("/page")
public ResultJson selectListByPage(@RequestParam(value = "stationName", required = false) String stationName,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "channel", required = false) String channel,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize)
{
Bayonet bayonet = Bayonet.builder()
.stationName(stationName)
.name(name).channel(channel)
.build();
return bayonetService.selectListByPage(bayonet, pageNum, pageSize);
}
/**
* 删除
* 条件:id
*
* @param bayonet 卡口信息 {@link Bayonet}
* @return
*/
@ApiOperation(value = "卡口信息,删除")
@DeleteMapping("/delete")
public ResultJson deleteBayonet(@RequestBody Bayonet bayonet)
{
return bayonetService.deleteByPrimaryKey(bayonet.getId());
}
/**
* 新增
*
* @param bayonet 卡口信息 {@link Bayonet}
* @return 成功 or 失败
*/
@ApiOperation(value = "卡口信息,增加")
@PostMapping("/insert")
public ResultJson insertBayonet(@RequestBody Bayonet bayonet)
{
return bayonetService.insertSelective(bayonet);
}
/**
* 修改 or 编辑
*
* @param bayonet 卡口信息 {@link Bayonet}
* @return 成功 or 失败
*/
@ApiOperation(value = "卡口信息,编辑")
@PutMapping("/update")
public ResultJson updateBayonet(@RequestBody Bayonet bayonet)
{
return bayonetService.updateByPrimaryKeySelective(bayonet);
}
}
... ...
package com.sunyo.wlpt.station.manage.controller;
import com.sunyo.wlpt.station.manage.domain.Bayonet;
import com.sunyo.wlpt.station.manage.domain.Warehouse;
import com.sunyo.wlpt.station.manage.response.ResultJson;
import com.sunyo.wlpt.station.manage.service.WarehouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author 子诚
* Description:仓库信息,控制器
* 时间:2020/10/12 15:32
*/
@Api(tags = "仓库信息,控制器")
@CrossOrigin
@RequestMapping("warehouse")
@RestController
public class WarehouseController {
@Resource
private WarehouseService warehouseService;
/**
* 分页查询
*
* @param stationName 场站名称
* @param name 仓库名称
* @param pageNum 当前页数
* @param pageSize 每页数量
* @return
*/
@ApiOperation(value = "仓库信息,分页查询")
@GetMapping("/page")
public ResultJson selectListByPage(@RequestParam(value = "stationName", required = false) String stationName,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize)
{
Warehouse warehouse = Warehouse.builder().name(name).stationName(stationName).build();
return warehouseService.selectListByPage(warehouse, pageNum, pageSize);
}
/**
* 删除
* 条件:id
*
* @param warehouse 仓库信息 {@link Warehouse}
* @return
*/
@ApiOperation(value = "仓库信息,删除")
@DeleteMapping("/delete")
public ResultJson deleteWarehouse(@RequestBody Warehouse warehouse)
{
return warehouseService.deleteByPrimaryKey(warehouse.getId());
}
/**
* 新增
*
* @param warehouse 仓库信息 {@link Warehouse}
* @return 成功 or 失败
*/
@ApiOperation(value = "仓库信息,增加")
@PostMapping("/insert")
public ResultJson insertWarehouse(@RequestBody Warehouse warehouse)
{
return warehouseService.insertSelective(warehouse);
}
/**
* 修改 or 编辑
*
* @param warehouse 仓库信息 {@link Warehouse}
* @return 成功 or 失败
*/
@ApiOperation(value = "仓库信息,编辑")
@PutMapping("/update")
public ResultJson updateWarehouse(@RequestBody Warehouse warehouse)
{
return warehouseService.updateByPrimaryKeySelective(warehouse);
}
}
... ...
package com.sunyo.wlpt.station.manage.controller;
import com.sunyo.wlpt.station.manage.domain.Yard;
import com.sunyo.wlpt.station.manage.response.ResultJson;
import com.sunyo.wlpt.station.manage.service.YardService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
/**
* @author 子诚
* Description:
* 时间:2020/10/12 12:06
*/
@Api(tags = "场站信息,控制器")
@CrossOrigin
@RequestMapping("yard")
@RestController
public class YardController {
@Resource
private YardService yardService;
/**
* 分页查询
*
* @param name 场站名称
* @param customsCode 关区代码
* @param pageNum 当前页数
* @param pageSize 每页大小
* @return
*/
@ApiOperation(value = "场站信息,分页查询")
@GetMapping("/page")
public ResultJson selectListByPage(@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "customsCode", required = false) Integer customsCode,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize)
{
Yard yard = Yard.builder().name(name).customsCode(customsCode).build();
return yardService.selectListByPage(yard, pageNum, pageSize);
}
/**
* 删除
* 条件:id
*
* @param yard 场站信息 {@link Yard}
* @return
*/
@ApiOperation(value = "场站信息,删除")
@DeleteMapping("/delete")
public ResultJson deleteYard(@RequestBody Yard yard)
{
return yardService.deleteByPrimaryKey(yard.getId());
}
/**
* 新增
*
* @param yard 场站信息 {@link Yard}
* @return 成功 or 失败
*/
@ApiOperation(value = "场站信息,增加")
@PostMapping("/insert")
public ResultJson insertYard(@RequestBody Yard yard)
{
return yardService.insertSelective(yard);
}
/**
* 修改 or 编辑
*
* @param yard 场站信息 {@link Yard}
* @return 成功 or 失败
*/
@ApiOperation(value = "场站信息,编辑")
@PutMapping("/update")
public ResultJson updateYard(@RequestBody Yard yard)
{
return yardService.updateByPrimaryKeySelective(yard);
}
}
... ...
package com.sunyo.wlpt.station.manage.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author 子诚
* Description:卡口静态资源表
* 时间:2020/10/12 11:56
*/
@ApiModel(value = "卡口静态资源表")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Bayonet implements Serializable {
private static final long serialVersionUID = -4051552282588726036L;
/**
* ID
*/
@ApiModelProperty(value = "ID")
private String id;
/**
* 场站ID_父ID
*/
@ApiModelProperty(value = "场站ID_父ID")
private String yardId;
/**
* 卡口名称
*/
@ApiModelProperty(value = "卡口名称")
private String name;
/**
* 通道编号
*/
@ApiModelProperty(value = "通道编号")
private String channel;
/**
* 卡口类型:1是进、2是出、3是进出共用
*/
@ApiModelProperty(value = "卡口类型:1是进、2是出、3是进出共用")
private String type;
/**
* 创建者
*/
@ApiModelProperty(value = "创建者")
private String createBy;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private Date createDate;
/**
* 更新者
*/
@ApiModelProperty(value = "更新者")
private String updateBy;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private Date updateDate;
/**
* 备注信息
*/
@ApiModelProperty(value = "备注信息")
private String remarks;
/**
* 删除标记
*/
@ApiModelProperty(value = "删除标记")
private String delFlag;
/**
* 场站名称(表中没有该字段,为查询方便,特意添加)
*/
@ApiModelProperty(value = "场站名称")
private String stationName;
/**
* 场站与卡口的关系 1:n
* <p>
* 一个卡口,对应一个场站
*/
private Yard yard;
}
\ No newline at end of file
... ...
package com.sunyo.wlpt.station.manage.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author 子诚
* Description:仓库静态资源表
* 时间:2020/10/12 12:00
*/
@ApiModel(value = "仓库静态资源表")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Warehouse implements Serializable {
private static final long serialVersionUID = 7237627901812899555L;
/**
* ID
*/
@ApiModelProperty(value = "ID")
private String id;
/**
* 场站ID_父ID
*/
@ApiModelProperty(value = "场站ID_父ID")
private String yardId;
/**
* 仓库编码
*/
@ApiModelProperty(value = "仓库编码")
private String copCode;
/**
* 仓库名称
*/
@ApiModelProperty(value = "仓库名称")
private String name;
/**
* 仓库长度
*/
@ApiModelProperty(value = "仓库长度")
private BigDecimal length;
/**
* 仓库宽度
*/
@ApiModelProperty(value = "仓库宽度")
private BigDecimal width;
/**
* 仓库面积
*/
@ApiModelProperty(value = "仓库面积")
private BigDecimal area;
/**
* 创建者
*/
@ApiModelProperty(value = "创建者")
private String createBy;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private Date createDate;
/**
* 更新者
*/
@ApiModelProperty(value = "更新者")
private String updateBy;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private Date updateDate;
/**
* 备注信息
*/
@ApiModelProperty(value = "备注信息")
private String remarks;
/**
* 删除标记
*/
@ApiModelProperty(value = "删除标记")
private String delFlag;
/**
* 场站名称(表中没有该字段,为查询方便,特意添加)
*/
@ApiModelProperty(value = "场站名称")
private String stationName;
/**
* 场站与仓库的关系 1:n
* <p>
* 一个仓库,对应一个场站
*/
private Yard yard;
}
\ No newline at end of file
... ...
package com.sunyo.wlpt.station.manage.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author 子诚
* Description:场站静态资源表
* 时间:2020/10/12 11:52
*/
@ApiModel(value = "场站静态资源表")
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Yard implements Serializable {
private static final long serialVersionUID = -5446527862823094064L;
/**
* ID
*/
@ApiModelProperty(value = "ID")
private String id;
/**
* 区域代码
*/
@ApiModelProperty(value = "区域代码")
private String areaCode;
/**
* 场站ID
*/
@ApiModelProperty(value = "场站ID")
private String stationId;
/**
* 场站名称
*/
@ApiModelProperty(value = "场站名称")
private String name;
/**
* 关区代码
*/
@ApiModelProperty(value = "关区代码")
private Integer customsCode;
/**
* 所属组织机构
*/
@ApiModelProperty(value = "所属组织机构")
private String orgId;
/**
* 创建者
*/
@ApiModelProperty(value = "创建者")
private String createBy;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private Date createDate;
/**
* 更新者
*/
@ApiModelProperty(value = "更新者")
private String updateBy;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private Date updateDate;
/**
* 备注信息
*/
@ApiModelProperty(value = "备注信息")
private String remarks;
/**
* 删除标记
*/
@ApiModelProperty(value = "删除标记")
private String delFlag;
/**
* 场站与卡口的关系 1:n
* 一个场站对应多个卡口
*/
private List<Bayonet> Bayonets;
/**
* 场站与仓库的关系 1:n
* 一个场站对应多个仓库
*/
private List<Warehouse> warehouses;
}
\ No newline at end of file
... ...
package com.sunyo.wlpt.station.manage.exception;
/**
* @author 子诚
* Description:
* 时间:2020/7/17 16:43
*/
public class CustomException extends RuntimeException {
private static final long serialVersionUID = 6098063244016154220L;
/**
* 异常错误编码
*/
private String code;
/**
* 异常信息
*/
private String message;
public CustomException(CustomExceptionType exceptionTypeEnum, String message)
{
this.code = exceptionTypeEnum.getCode();
this.message = message;
}
public CustomException(String code, String message)
{
this.code = code;
this.message = message;
}
public CustomException(CustomExceptionType exceptionTypeEnum)
{
this.code = exceptionTypeEnum.getCode();
this.message = exceptionTypeEnum.getMsg();
}
public String getCode()
{
return code;
}
@Override
public String getMessage()
{
return message;
}
}
... ...
package com.sunyo.wlpt.station.manage.exception;
/**
* @author 子诚
* Description:枚举,定制异常类型
* 时间:2020/7/17 16:27
*/
public enum CustomExceptionType {
CLIENT_ERROR("400", "客户端异常"),
SYSTEM_ERROR("500", "系统服务异常"),
OTHER_ERROR("999", "其他未知异常");
/**
* 响应业务状态
*/
private String code;
/**
* 响应消息
*/
private String msg;
CustomExceptionType(String code, String msg)
{
this.code = code;
this.msg = msg;
}
public String getCode()
{
return code;
}
public String getMsg()
{
return msg;
}
}
... ...
package com.sunyo.wlpt.station.manage.exception;
import com.sunyo.wlpt.station.manage.response.ResultJson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* @author 子诚
* Description:自定义全局异常处理类
* 时间:2020/7/17 17:44
*/
@ControllerAdvice
public class GlobalExceptionHandler {
private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
@ExceptionHandler(CustomException.class)
@ResponseBody
public ResultJson customerException(CustomException e)
{
if (e.getCode() == CustomExceptionType.SYSTEM_ERROR.getCode()) {
//TODO 将异常信息持久化,or 打印日志
logger.error("");
}
return ResultJson.error(e);
}
}
... ...
package com.sunyo.wlpt.station.manage.mapper;
import com.sunyo.wlpt.station.manage.domain.Bayonet;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/10/12 11:56
*/
@Mapper
public interface BayonetMapper {
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(String id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(Bayonet record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
int insertSelective(Bayonet record);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
Bayonet selectByPrimaryKey(String id);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(Bayonet record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(Bayonet record);
/**
* 分页查询,卡口信息
* 条件:场站名称
*
* @param bayonet 卡口信息 {@link Bayonet}
* @return
*/
List<Bayonet> selectListByPage(Bayonet bayonet);
}
\ No newline at end of file
... ...
package com.sunyo.wlpt.station.manage.mapper;
import com.sunyo.wlpt.station.manage.domain.Warehouse;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/10/12 12:00
*/
@Mapper
public interface WarehouseMapper {
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(String id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(Warehouse record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
int insertSelective(Warehouse record);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
Warehouse selectByPrimaryKey(String id);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(Warehouse record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(Warehouse record);
/**
* 分页查询,仓库信息
* 条件:场站名称,仓库名称
*
* @param warehouse {@link Warehouse}
* @return
*/
List<Warehouse> selectListByPage(Warehouse warehouse);
}
\ No newline at end of file
... ...
package com.sunyo.wlpt.station.manage.mapper;
import com.sunyo.wlpt.station.manage.domain.Yard;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/10/12 11:52
*/
@Mapper
public interface YardMapper {
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(String id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(Yard record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
int insertSelective(Yard record);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
Yard selectByPrimaryKey(String id);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(Yard record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(Yard record);
/**
* 场站信息,分页查询
* 条件:name(场站名称);customsCode(关区代码)
*
* @param yard 场站信息
* @return
*/
List<Yard> selectListByPage(Yard yard);
}
\ No newline at end of file
... ...
package com.sunyo.wlpt.station.manage.response;
import com.sunyo.wlpt.station.manage.exception.CustomException;
import com.sunyo.wlpt.station.manage.exception.CustomExceptionType;
import lombok.Data;
import java.io.Serializable;
/**
* @author 子诚
* Description:返回结果封装类
* 时间:2020/7/01 10:06
*/
@Data
public class ResultJson<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 响应业务状态,默认为200
*/
private String code;
/**
* 响应消息
*/
private String msg;
/**
* 错误消息内容
*/
private String error;
/**
* 数据总条数
*/
private Integer total;
/**
* 响应数据
*/
private T data;
/**
* JWT令牌
*/
private String jwtToken;
/**
* 无参,构造方法
*/
public ResultJson()
{
}
/**
* 定义有参构造器
*
* @param code 响应状态
* @param msg 响应消息
*/
public ResultJson(String code, String msg)
{
this.code = code;
this.msg = msg;
}
/**
* 定义有参构造器
*
* @param code 响应状态
* @param msg 响应消息
* @param data 响应数据
*/
public ResultJson(String code, String msg, T data)
{
this.code = code;
this.msg = msg;
this.data = data;
}
public ResultJson(String code, String msg, T data, Integer total)
{
this.code = code;
this.msg = msg;
this.data = data;
this.total = total;
}
/**
* 定义静态、成功方法(重载)
*
* @return 成功(没有响应数据)
*/
public static ResultJson success()
{
return new ResultJson<>("200", "success");
}
public static ResultJson success(String message)
{
return new ResultJson<>("200", message);
}
/**
* 定义静态、成功方法(重载)
*
* @return 成功(响应数据)
*/
public static ResultJson success(Object data)
{
return new ResultJson<>("200", "success", data);
}
/**
* 定义静态、成功方法(重载)
*
* @return 成功(响应数据)
*/
public static ResultJson success(String message, Object data)
{
return new ResultJson<>("200", message, data);
}
public static ResultJson success(String code, String message)
{
return new ResultJson<>(code, message);
}
public static ResultJson success(String code, String message, Object data)
{
return new ResultJson<>(code, message, data);
}
public static ResultJson success(CustomExceptionType customExceptionType)
{
return new ResultJson<>(customExceptionType.getCode(), customExceptionType.getMsg());
}
public static ResultJson success(CustomExceptionType customExceptionType, Object data)
{
return new ResultJson<>(customExceptionType.getCode(), customExceptionType.getMsg(), data);
}
/**
* 请求出现异常时的响应数据封装
*
* @param e 自定义异常类
* @return 返回异常信息
*/
public static ResultJson error(CustomException e)
{
ResultJson result = new ResultJson<>();
result.setCode(e.getCode());
if (e.getCode() == CustomExceptionType.CLIENT_ERROR.getCode()) {
result.setMsg(e.getMessage());
} else if (e.getCode() == CustomExceptionType.SYSTEM_ERROR.getCode()) {
result.setMsg(e.getMessage() + ";请将该异常发送给管理员");
} else {
result.setMsg("系统出现未知异常,请联系管理员!");
}
// 可以尝试着做异常信息持久化
return result;
}
public static ResultJson error(CustomExceptionType customExceptionType, String errorMessage)
{
return new ResultJson<>(customExceptionType.getCode(), errorMessage);
}
public static ResultJson error(CustomExceptionType customExceptionType)
{
return new ResultJson<>(customExceptionType.getCode(), customExceptionType.getMsg());
}
public static ResultJson error(String code, String message)
{
return new ResultJson<>(code, message);
}
}
... ...
package com.sunyo.wlpt.station.manage.service;
import com.sunyo.wlpt.station.manage.domain.Bayonet;
import com.sunyo.wlpt.station.manage.response.ResultJson;
/**
* @author 子诚
* Description:
* 时间:2020/10/12 11:56
*/
public interface BayonetService {
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
ResultJson deleteByPrimaryKey(String id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(Bayonet record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
ResultJson insertSelective(Bayonet record);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
Bayonet selectByPrimaryKey(String id);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
ResultJson updateByPrimaryKeySelective(Bayonet record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(Bayonet record);
/**
* 卡口信息,分页查询
*
* @param bayonet 卡口信息{@link Bayonet}
* @param pageNum 当前页数
* @param pageSize 每页数量
* @return
*/
ResultJson selectListByPage(Bayonet bayonet, Integer pageNum, Integer pageSize);
}
... ...
package com.sunyo.wlpt.station.manage.service;
import com.sunyo.wlpt.station.manage.domain.Warehouse;
import com.sunyo.wlpt.station.manage.response.ResultJson;
/**
* @author 子诚
* Description:
* 时间:2020/10/12 12:00
*/
public interface WarehouseService {
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
ResultJson deleteByPrimaryKey(String id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(Warehouse record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
ResultJson insertSelective(Warehouse record);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
Warehouse selectByPrimaryKey(String id);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
ResultJson updateByPrimaryKeySelective(Warehouse record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(Warehouse record);
/**
* 分页查询
*
* @param warehouse 仓库
* @param pageNum 当前页数
* @param pageSize 每页大小
* @return
*/
ResultJson selectListByPage(Warehouse warehouse, Integer pageNum, Integer pageSize);
}
... ...
package com.sunyo.wlpt.station.manage.service;
import com.sunyo.wlpt.station.manage.domain.Yard;
import com.sunyo.wlpt.station.manage.response.ResultJson;
/**
* @author 子诚
* Description:
* 时间:2020/10/12 11:52
*/
public interface YardService {
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
ResultJson deleteByPrimaryKey(String id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(Yard record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
ResultJson insertSelective(Yard record);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
Yard selectByPrimaryKey(String id);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
ResultJson updateByPrimaryKeySelective(Yard record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(Yard record);
/**
* 场站信息,分页查询
*
* @param yard 场站信息 {@link Yard}
* @param pageNum 当前页数
* @param pageSize 每页大小
* @return
*/
ResultJson selectListByPage(Yard yard, Integer pageNum, Integer pageSize);
}
... ...
package com.sunyo.wlpt.station.manage.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sunyo.wlpt.station.manage.domain.Yard;
import com.sunyo.wlpt.station.manage.response.ResultJson;
import com.sunyo.wlpt.station.manage.utils.IdUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.sunyo.wlpt.station.manage.mapper.BayonetMapper;
import com.sunyo.wlpt.station.manage.domain.Bayonet;
import com.sunyo.wlpt.station.manage.service.BayonetService;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/10/12 11:56
*/
@Service
public class BayonetServiceImpl implements BayonetService {
@Resource
private BayonetMapper bayonetMapper;
/**
* 删除卡口信息
*
* @param id primaryKey
* @return
*/
@Override
public ResultJson deleteByPrimaryKey(String id)
{
return bayonetMapper.deleteByPrimaryKey(id) > 0
? ResultJson.success("200", "删除卡口信息,成功")
: ResultJson.error("500", "删除卡口信息,失败");
}
@Override
public int insert(Bayonet record)
{
return bayonetMapper.insert(record);
}
/**
* 选择性新增,卡口信息
*
* @param bayonet 卡口信息 {@link Bayonet}
* @return
*/
@Override
public ResultJson insertSelective(Bayonet bayonet)
{
bayonet.setId(IdUtils.generateId());
return bayonetMapper.insertSelective(bayonet) > 0
? ResultJson.success("200", "新增卡口信息,成功")
: ResultJson.error("500", "新增卡口信息,失败");
}
@Override
public Bayonet selectByPrimaryKey(String id)
{
return bayonetMapper.selectByPrimaryKey(id);
}
/**
* 编辑卡口信息
*
* @param bayonet the updated record 卡口信息 {@link Bayonet}
* @return
*/
@Override
public ResultJson updateByPrimaryKeySelective(Bayonet bayonet)
{
return bayonetMapper.updateByPrimaryKeySelective(bayonet) > 0
? ResultJson.success("200", "编辑卡口信息,成功")
: ResultJson.error("500", "编辑卡口信息,失败");
}
@Override
public int updateByPrimaryKey(Bayonet record)
{
return bayonetMapper.updateByPrimaryKey(record);
}
/**
* 分页查询
*
* @param bayonet 卡口信息 {@link Bayonet}
* @param pageNum 当前页数
* @param pageSize 每页大小
* @return
*/
@Override
public ResultJson selectListByPage(Bayonet bayonet, Integer pageNum, Integer pageSize)
{
PageHelper.startPage(pageNum, pageSize);
List<Bayonet> bayonetList = bayonetMapper.selectListByPage(bayonet);
PageInfo<Bayonet> pageInfo = new PageInfo<>(bayonetList);
return pageInfo.getTotal() >= 0
? ResultJson.success("200", "查询卡口信息列表,成功!", pageInfo)
: ResultJson.error("500", "查询卡口信息列表,失败!");
}
}
... ...
package com.sunyo.wlpt.station.manage.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sunyo.wlpt.station.manage.domain.Bayonet;
import com.sunyo.wlpt.station.manage.response.ResultJson;
import com.sunyo.wlpt.station.manage.utils.IdUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.sunyo.wlpt.station.manage.domain.Warehouse;
import com.sunyo.wlpt.station.manage.mapper.WarehouseMapper;
import com.sunyo.wlpt.station.manage.service.WarehouseService;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/10/12 12:00
*/
@Service
public class WarehouseServiceImpl implements WarehouseService {
@Resource
private WarehouseMapper warehouseMapper;
/**
* 删除,仓库信息
*
* @param id primaryKey
* @return
*/
@Override
public ResultJson deleteByPrimaryKey(String id)
{
return warehouseMapper.deleteByPrimaryKey(id) > 0
? ResultJson.success("200", "删除仓库信息,成功")
: ResultJson.error("500", "删除仓库信息,失败");
}
@Override
public int insert(Warehouse record)
{
return warehouseMapper.insert(record);
}
/**
* 新增仓库信息
*
* @param warehouse {@link Warehouse}
* @return
*/
@Override
public ResultJson insertSelective(Warehouse warehouse)
{
warehouse.setId(IdUtils.generateId());
return warehouseMapper.insertSelective(warehouse) > 0
? ResultJson.success("200", "增加仓库信息,成功")
: ResultJson.error("500", "增加仓库信息,失败");
}
@Override
public Warehouse selectByPrimaryKey(String id)
{
return warehouseMapper.selectByPrimaryKey(id);
}
/**
* 编辑仓库信息
*
* @param warehouse the updated record
* @return
*/
@Override
public ResultJson updateByPrimaryKeySelective(Warehouse warehouse)
{
return warehouseMapper.updateByPrimaryKeySelective(warehouse) > 0
? ResultJson.success("200", "编辑仓库信息,成功")
: ResultJson.error("500", "编辑仓库信息,失败");
}
@Override
public int updateByPrimaryKey(Warehouse record)
{
return warehouseMapper.updateByPrimaryKey(record);
}
/**
* 分页查询,仓库信息
*
* @param warehouse 仓库信息{@link Warehouse}
* @param pageNum 当前页数
* @param pageSize 每页大小
* @return
*/
@Override
public ResultJson selectListByPage(Warehouse warehouse, Integer pageNum, Integer pageSize)
{
PageHelper.startPage(pageNum, pageSize);
List<Warehouse> warehouseList = warehouseMapper.selectListByPage(warehouse);
PageInfo<Warehouse> pageInfo = new PageInfo<>(warehouseList);
return pageInfo.getTotal() >= 0
? ResultJson.success("200", "查询仓库信息列表,成功!", pageInfo)
: ResultJson.error("500", "查询仓库信息列表,失败!");
}
}
... ...
package com.sunyo.wlpt.station.manage.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sunyo.wlpt.station.manage.response.ResultJson;
import com.sunyo.wlpt.station.manage.utils.IdUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import com.sunyo.wlpt.station.manage.domain.Yard;
import com.sunyo.wlpt.station.manage.mapper.YardMapper;
import com.sunyo.wlpt.station.manage.service.YardService;
import java.util.List;
/**
* @author 子诚
* Description:
* 时间:2020/10/12 11:52
*/
@Service
public class YardServiceImpl implements YardService {
@Resource
private YardMapper yardMapper;
/**
* 删除场站信息
*
* @param id primaryKey
* @return
*/
@Override
public ResultJson deleteByPrimaryKey(String id)
{
return yardMapper.deleteByPrimaryKey(id) > 0
? ResultJson.success("200", "删除场站信息,成功")
: ResultJson.error("500", "删除场站信息,失败");
}
@Override
public int insert(Yard record)
{
return yardMapper.insert(record);
}
/**
* 场站信息,选择性增加
*
* @param yard 场站信息 {@link Yard}
* @return
*/
@Override
public ResultJson insertSelective(Yard yard)
{
yard.setId(IdUtils.generateId());
return yardMapper.insertSelective(yard) > 0
? ResultJson.success("200", "增加场站信息,成功")
: ResultJson.error("500", "增加场站信息,失败");
}
@Override
public Yard selectByPrimaryKey(String id)
{
return yardMapper.selectByPrimaryKey(id);
}
@Override
public ResultJson updateByPrimaryKeySelective(Yard record)
{
return yardMapper.updateByPrimaryKeySelective(record) > 0
? ResultJson.success("200", "编辑场站信息,成功")
: ResultJson.error("500", "编辑场站信息,失败");
}
@Override
public int updateByPrimaryKey(Yard record)
{
return yardMapper.updateByPrimaryKey(record);
}
/**
* 分页查询,场站信息
*
* @param yard 场站信息 {@link Yard}
* @param pageNum 当前页数
* @param pageSize 每页大小
* @return
*/
@Override
public ResultJson selectListByPage(Yard yard, Integer pageNum, Integer pageSize)
{
PageHelper.startPage(pageNum, pageSize);
List<Yard> yardList = yardMapper.selectListByPage(yard);
PageInfo<Yard> pageInfo = new PageInfo<>(yardList);
return pageInfo.getTotal() >= 0
? ResultJson.success("200", "查询场站信息列表,成功!", pageInfo)
: ResultJson.error("500", "查询场站信息列表,失败!");
}
}
... ...
package com.sunyo.wlpt.station.manage.utils;
/**
* @author 子诚
* Description:生成雪花算法唯一id
* 时间:2020/7/1 9:26
*/
public class IdUtils {
/**
* 静态工具类
*
* @return id
*/
public static synchronized String generateId() {
IdWorker idWorker = new IdWorker();
long nextId = idWorker.nextId();
String id = String.valueOf(nextId);
return id;
}
}
... ...
package com.sunyo.wlpt.station.manage.utils;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.NetworkInterface;
/**
* @author 子诚
* Description:雪花算法生成唯一ID
* 时间:2020/6/30 19:19
*/
public final class IdWorker {
/**
* 时间起始标记点,作为基准,一般取系统的最近时间(一旦确定不能变动)
*/
private final static long TWEPOCH = 1288834974657L;
/**
* 机器标识位数
*/
private final static long WORKER_ID_BITS = 5L;
/**
* 数据中心标识位数
*/
private final static long DATA_CENTER_ID_BITS = 5L;
/**
* 机器ID最大值
*/
private final static long MAX_WORKER_ID = ~(-1L << WORKER_ID_BITS);
/**
* 数据中心ID最大值
*/
private final static long MAX_DATA_CENTER_ID = ~(-1L << DATA_CENTER_ID_BITS);
/**
* 毫秒内自增位
*/
private final static long SEQUENCE_BITS = 12L;
/**
* 机器ID偏左移12位
*/
private final static long WORKER_ID_SHIFT = SEQUENCE_BITS;
/**
* 数据中心ID左移17位
*/
private final static long DATA_CENTER_ID_SHIFT = SEQUENCE_BITS + WORKER_ID_BITS;
/**
* 时间毫秒左移22位
*/
private final static long TIME_STAMP_LEFT_SHIFT = SEQUENCE_BITS + WORKER_ID_BITS + DATA_CENTER_ID_BITS;
private final static long SEQUENCE_MASK = ~(-1L << SEQUENCE_BITS);
/**
* 上次生产id时间戳
*/
private static long LAST_TIME_STAMP = -1L;
/**
* 0,并发控制
*/
private long sequence = 0L;
private final long workerId;
/**
* 数据标识id部分
*/
private final long DATA_CENTER_ID;
public IdWorker() {
this.DATA_CENTER_ID = getDatacenterId(MAX_DATA_CENTER_ID);
this.workerId = getMaxWorkerId(DATA_CENTER_ID, MAX_WORKER_ID);
}
public IdWorker(long workerId, long datacenterId) {
if (workerId > MAX_WORKER_ID || workerId < 0) {
throw new IllegalArgumentException(String.format("id不能大于最大值 %d 或者小于 0", MAX_WORKER_ID));
}
if (datacenterId > MAX_DATA_CENTER_ID || datacenterId < 0) {
throw new IllegalArgumentException(String.format("数据中心id不能大于最大值 %d 或者小于 0", MAX_DATA_CENTER_ID));
}
this.workerId = workerId;
this.DATA_CENTER_ID = datacenterId;
}
/**
* 获取下一个ID
*
* @return id
*/
public synchronized long nextId() {
long timestamp = timeGen();
if (timestamp < LAST_TIME_STAMP) {
throw new RuntimeException(String.format("时间生成异常 %d", LAST_TIME_STAMP - timestamp));
}
if (LAST_TIME_STAMP == timestamp) {
// 当前毫秒内,则+1
sequence = (sequence + 1) & SEQUENCE_MASK;
if (sequence == 0) {
// 当前毫秒内计数满了,则等待下一秒
timestamp = tilNextMillis(LAST_TIME_STAMP);
}
} else {
sequence = 0L;
}
LAST_TIME_STAMP = timestamp;
// ID偏移组合生成最终的ID,并返回ID
return ((timestamp - TWEPOCH) << TIME_STAMP_LEFT_SHIFT)
| (DATA_CENTER_ID << DATA_CENTER_ID_SHIFT)
| (workerId << WORKER_ID_SHIFT) | sequence;
}
private long tilNextMillis(final long lastTimestamp) {
long timestamp = this.timeGen();
while (timestamp <= lastTimestamp) {
timestamp = this.timeGen();
}
return timestamp;
}
private long timeGen() {
return System.currentTimeMillis();
}
/**
* <p>
* 获取 maxWorkerId
* </p>
*/
private static long getMaxWorkerId(long dataCenterId, long maxWorkerId) {
StringBuilder mpid = new StringBuilder();
mpid.append(dataCenterId);
String name = ManagementFactory.getRuntimeMXBean().getName();
if (!name.isEmpty()) {
/*
* GET jvmPid
*/
mpid.append(name.split("@")[0]);
}
/*
* MAC + PID 的 hashcode 获取16个低位
*/
return (mpid.toString().hashCode() & 0xffff) % (maxWorkerId + 1);
}
/**
* <p>
* 数据标识id部分
* </p>
*/
private static long getDatacenterId(long maxDatacenterId) {
long id = 0L;
try {
InetAddress ip = InetAddress.getLocalHost();
NetworkInterface network = NetworkInterface.getByInetAddress(ip);
if (network == null) {
id = 1L;
} else {
byte[] mac = network.getHardwareAddress();
id = ((0x000000FF & (long) mac[mac.length - 1])
| (0x0000FF00 & (((long) mac[mac.length - 2]) << 8))) >> 6;
id = id % (maxDatacenterId + 1);
}
} catch (Exception e) {
System.out.println(" getDatacenterId: " + e.getMessage());
}
return id;
}
/**
* 静态工具类
*
* @return id
public static synchronized String generateId() {
String id = String.valueOf(new IdWorker().nextId());
return id;
}
*/
/**
* 测试
public static void main(String[] args) {
System.out.println("当前时间戳:" + System.currentTimeMillis());
for (int i = 0; i < 10; i++) {
//生成唯一雪花id
String id = IdWorker.generateId();
System.out.println("第" + i + "个:" + id + ";长度为:" + id.length());
}
}
*/
}
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sunyo.wlpt.station.manage.mapper.BayonetMapper">
<resultMap id="BaseResultMap" type="com.sunyo.wlpt.station.manage.domain.Bayonet">
<!--@mbg.generated-->
<!--@Table bayonet-->
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="yard_id" jdbcType="VARCHAR" property="yardId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="channel" jdbcType="VARCHAR" property="channel"/>
<result column="type" jdbcType="VARCHAR" property="type"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="del_flag" jdbcType="CHAR" property="delFlag"/>
</resultMap>
<!-- 该Mapper映射关系的作用,是卡口与场站的1:1的关系映射 -->
<resultMap id="BayonetAndYardMap" extends="BaseResultMap"
type="com.sunyo.wlpt.station.manage.domain.Bayonet">
<association property="yard" javaType="com.sunyo.wlpt.station.manage.domain.Yard">
<id column="id" property="id"/>
<result column="yard_name" property="name"/>
</association>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, yard_id, `name`, channel, `type`, create_by, create_date, update_by, update_date,
remarks, del_flag
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from bayonet
where id = #{id,jdbcType=VARCHAR}
</select>
<select id="selectListByPage" parameterType="com.sunyo.wlpt.station.manage.domain.Bayonet" resultMap="BayonetAndYardMap">
select b.id,
b.yard_id,
b.name,
b.channel,
b.type,
b.create_by,
b.create_date,
b.update_by,
b.update_date,
b.remarks,
b.del_flag,
y.name as yard_name
from bayonet b,
yard y
<where>
<!-- name,卡口名称 -->
<if test="name != null and name != ''">
and b.name = #{name,jdbcType=VARCHAR}
</if>
<!-- channel,通道编号 -->
<if test="channel != null and channel != ''">
and b.channel = #{channel,jdbcType=VARCHAR}
</if>
<!-- stationName,货站名称 -->
<if test="stationName != null and stationName != ''">
and y.name = #{stationName,jdbcType=VARCHAR}
</if>
and b.yard_id = y.stationId
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--@mbg.generated-->
delete
from bayonet
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.sunyo.wlpt.station.manage.domain.Bayonet">
<!--@mbg.generated-->
insert into bayonet (id, yard_id, `name`,
channel, `type`, create_by,
create_date, update_by, update_date,
remarks, del_flag)
values (#{id,jdbcType=VARCHAR}, #{yardId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{channel,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{createBy,jdbcType=VARCHAR},
#{createDate,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR}, #{updateDate,jdbcType=TIMESTAMP},
#{remarks,jdbcType=VARCHAR}, #{delFlag,jdbcType=CHAR})
</insert>
<insert id="insertSelective" parameterType="com.sunyo.wlpt.station.manage.domain.Bayonet">
<!--@mbg.generated-->
insert into bayonet
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="yardId != null">
yard_id,
</if>
<if test="name != null">
`name`,
</if>
<if test="channel != null">
channel,
</if>
<if test="type != null">
`type`,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createDate != null">
create_date,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateDate != null">
update_date,
</if>
<if test="remarks != null">
remarks,
</if>
<if test="delFlag != null">
del_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="yardId != null">
#{yardId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="channel != null">
#{channel,jdbcType=VARCHAR},
</if>
<if test="type != null">
#{type,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
#{createDate,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateDate != null">
#{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null">
#{remarks,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=CHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sunyo.wlpt.station.manage.domain.Bayonet">
<!--@mbg.generated-->
update bayonet
<set>
<if test="yardId != null">
yard_id = #{yardId,jdbcType=VARCHAR},
</if>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="channel != null">
channel = #{channel,jdbcType=VARCHAR},
</if>
<if test="type != null">
`type` = #{type,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
create_date = #{createDate,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateDate != null">
update_date = #{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null">
remarks = #{remarks,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=CHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sunyo.wlpt.station.manage.domain.Bayonet">
<!--@mbg.generated-->
update bayonet
set yard_id = #{yardId,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
channel = #{channel,jdbcType=VARCHAR},
`type` = #{type,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_date = #{createDate,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_date = #{updateDate,jdbcType=TIMESTAMP},
remarks = #{remarks,jdbcType=VARCHAR},
del_flag = #{delFlag,jdbcType=CHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sunyo.wlpt.station.manage.mapper.WarehouseMapper">
<resultMap id="BaseResultMap" type="com.sunyo.wlpt.station.manage.domain.Warehouse">
<!--@mbg.generated-->
<!--@Table warehouse-->
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="yard_id" jdbcType="VARCHAR" property="yardId"/>
<result column="cop_code" jdbcType="VARCHAR" property="copCode"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="length" jdbcType="DECIMAL" property="length"/>
<result column="width" jdbcType="DECIMAL" property="width"/>
<result column="area" jdbcType="DECIMAL" property="area"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="del_flag" jdbcType="CHAR" property="delFlag"/>
</resultMap>
<!-- 该Mapper映射关系的作用,是仓库与场站的1:1的关系映射 -->
<resultMap id="WarehouseAndYardMap" extends="BaseResultMap"
type="com.sunyo.wlpt.station.manage.domain.Warehouse">
<association property="yard" javaType="com.sunyo.wlpt.station.manage.domain.Yard">
<id column="id" property="id"/>
<result column="yard_name" property="name"/>
</association>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, yard_id, cop_code, `name`, `length`, width, area, create_by, create_date, update_by,
update_date, remarks, del_flag
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from warehouse
where id = #{id,jdbcType=VARCHAR}
</select>
<!-- 分页查询 -->
<select id="selectListByPage" parameterType="com.sunyo.wlpt.station.manage.domain.Warehouse" resultMap="WarehouseAndYardMap">
select w.id,
w.yard_id,
w.cop_code,
w.name,
w.length,
w.width,
w.area,
w.create_by,
w.create_date,
w.update_by,
w.update_date,
w.remarks,
w.del_flag,
y.name as yard_name
from warehouse w,
yard y
<where>
<!-- name,仓库名称 -->
<if test="name != null and name != ''">
and w.name = #{name,jdbcType=VARCHAR}
</if>
<!-- stationName,货站名称 -->
<if test="stationName != null and stationName != ''">
and y.name = #{stationName,jdbcType=VARCHAR}
</if>
and w.yard_id = y.id
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--@mbg.generated-->
delete
from warehouse
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.sunyo.wlpt.station.manage.domain.Warehouse">
<!--@mbg.generated-->
insert into warehouse (id, yard_id, cop_code,
`name`, `length`, width,
area, create_by, create_date,
update_by, update_date, remarks,
del_flag)
values (#{id,jdbcType=VARCHAR}, #{yardId,jdbcType=VARCHAR}, #{copCode,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{length,jdbcType=DECIMAL}, #{width,jdbcType=DECIMAL},
#{area,jdbcType=DECIMAL}, #{createBy,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP},
#{updateBy,jdbcType=VARCHAR}, #{updateDate,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR},
#{delFlag,jdbcType=CHAR})
</insert>
<insert id="insertSelective" parameterType="com.sunyo.wlpt.station.manage.domain.Warehouse">
<!--@mbg.generated-->
insert into warehouse
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="yardId != null">
yard_id,
</if>
<if test="copCode != null">
cop_code,
</if>
<if test="name != null">
`name`,
</if>
<if test="length != null">
`length`,
</if>
<if test="width != null">
width,
</if>
<if test="area != null">
area,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createDate != null">
create_date,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateDate != null">
update_date,
</if>
<if test="remarks != null">
remarks,
</if>
<if test="delFlag != null">
del_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="yardId != null">
#{yardId,jdbcType=VARCHAR},
</if>
<if test="copCode != null">
#{copCode,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="length != null">
#{length,jdbcType=DECIMAL},
</if>
<if test="width != null">
#{width,jdbcType=DECIMAL},
</if>
<if test="area != null">
#{area,jdbcType=DECIMAL},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
#{createDate,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateDate != null">
#{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null">
#{remarks,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=CHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sunyo.wlpt.station.manage.domain.Warehouse">
<!--@mbg.generated-->
update warehouse
<set>
<if test="yardId != null">
yard_id = #{yardId,jdbcType=VARCHAR},
</if>
<if test="copCode != null">
cop_code = #{copCode,jdbcType=VARCHAR},
</if>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="length != null">
`length` = #{length,jdbcType=DECIMAL},
</if>
<if test="width != null">
width = #{width,jdbcType=DECIMAL},
</if>
<if test="area != null">
area = #{area,jdbcType=DECIMAL},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
create_date = #{createDate,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateDate != null">
update_date = #{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null">
remarks = #{remarks,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=CHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sunyo.wlpt.station.manage.domain.Warehouse">
<!--@mbg.generated-->
update warehouse
set yard_id = #{yardId,jdbcType=VARCHAR},
cop_code = #{copCode,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
`length` = #{length,jdbcType=DECIMAL},
width = #{width,jdbcType=DECIMAL},
area = #{area,jdbcType=DECIMAL},
create_by = #{createBy,jdbcType=VARCHAR},
create_date = #{createDate,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_date = #{updateDate,jdbcType=TIMESTAMP},
remarks = #{remarks,jdbcType=VARCHAR},
del_flag = #{delFlag,jdbcType=CHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.sunyo.wlpt.station.manage.mapper.YardMapper">
<resultMap id="BaseResultMap" type="com.sunyo.wlpt.station.manage.domain.Yard">
<!--@mbg.generated-->
<!--@Table yard-->
<id column="id" jdbcType="VARCHAR" property="id"/>
<result column="area_code" jdbcType="VARCHAR" property="areaCode"/>
<result column="stationId" jdbcType="VARCHAR" property="stationId"/>
<result column="name" jdbcType="VARCHAR" property="name"/>
<result column="customs_code" jdbcType="INTEGER" property="customsCode"/>
<result column="org_id" jdbcType="VARCHAR" property="orgId"/>
<result column="create_by" jdbcType="VARCHAR" property="createBy"/>
<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_by" jdbcType="VARCHAR" property="updateBy"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>
<result column="remarks" jdbcType="VARCHAR" property="remarks"/>
<result column="del_flag" jdbcType="CHAR" property="delFlag"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, area_code, stationId, `name`, customs_code, org_id, create_by, create_date, update_by,
update_date, remarks, del_flag
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List"/>
from yard
where id = #{id,jdbcType=VARCHAR}
</select>
<select id="selectListByPage" parameterType="com.sunyo.wlpt.station.manage.domain.Yard" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from yard
<where>
<!-- name,场站名称 -->
<if test="name != null and name != ''">
name = #{name,jdbcType=VARCHAR}
</if>
<!-- customsCode,关区代码 -->
<if test="customsCode != null">
and customs_code = #{customsCode,jdbcType=INTEGER}
</if>
</where>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
<!--@mbg.generated-->
delete
from yard
where id = #{id,jdbcType=VARCHAR}
</delete>
<insert id="insert" parameterType="com.sunyo.wlpt.station.manage.domain.Yard">
<!--@mbg.generated-->
insert into yard (id, area_code, stationId,
`name`, customs_code, org_id,
create_by, create_date, update_by,
update_date, remarks, del_flag)
values (#{id,jdbcType=VARCHAR}, #{areaCode,jdbcType=VARCHAR}, #{stationId,jdbcType=VARCHAR},
#{name,jdbcType=VARCHAR}, #{customsCode,jdbcType=INTEGER}, #{orgId,jdbcType=VARCHAR},
#{createBy,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{updateBy,jdbcType=VARCHAR},
#{updateDate,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR}, #{delFlag,jdbcType=CHAR})
</insert>
<insert id="insertSelective" parameterType="com.sunyo.wlpt.station.manage.domain.Yard">
<!--@mbg.generated-->
insert into yard
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="areaCode != null">
area_code,
</if>
<if test="stationId != null">
stationId,
</if>
<if test="name != null">
`name`,
</if>
<if test="customsCode != null">
customs_code,
</if>
<if test="orgId != null">
org_id,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createDate != null">
create_date,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateDate != null">
update_date,
</if>
<if test="remarks != null">
remarks,
</if>
<if test="delFlag != null">
del_flag,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=VARCHAR},
</if>
<if test="areaCode != null">
#{areaCode,jdbcType=VARCHAR},
</if>
<if test="stationId != null">
#{stationId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="customsCode != null">
#{customsCode,jdbcType=INTEGER},
</if>
<if test="orgId != null">
#{orgId,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
#{createBy,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
#{createDate,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
#{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateDate != null">
#{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null">
#{remarks,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
#{delFlag,jdbcType=CHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.sunyo.wlpt.station.manage.domain.Yard">
<!--@mbg.generated-->
update yard
<set>
<if test="areaCode != null">
area_code = #{areaCode,jdbcType=VARCHAR},
</if>
<if test="stationId != null">
stationId = #{stationId,jdbcType=VARCHAR},
</if>
<if test="name != null">
`name` = #{name,jdbcType=VARCHAR},
</if>
<if test="customsCode != null">
customs_code = #{customsCode,jdbcType=INTEGER},
</if>
<if test="orgId != null">
org_id = #{orgId,jdbcType=VARCHAR},
</if>
<if test="createBy != null">
create_by = #{createBy,jdbcType=VARCHAR},
</if>
<if test="createDate != null">
create_date = #{createDate,jdbcType=TIMESTAMP},
</if>
<if test="updateBy != null">
update_by = #{updateBy,jdbcType=VARCHAR},
</if>
<if test="updateDate != null">
update_date = #{updateDate,jdbcType=TIMESTAMP},
</if>
<if test="remarks != null">
remarks = #{remarks,jdbcType=VARCHAR},
</if>
<if test="delFlag != null">
del_flag = #{delFlag,jdbcType=CHAR},
</if>
</set>
where id = #{id,jdbcType=VARCHAR}
</update>
<update id="updateByPrimaryKey" parameterType="com.sunyo.wlpt.station.manage.domain.Yard">
<!--@mbg.generated-->
update yard
set area_code = #{areaCode,jdbcType=VARCHAR},
stationId = #{stationId,jdbcType=VARCHAR},
`name` = #{name,jdbcType=VARCHAR},
customs_code = #{customsCode,jdbcType=INTEGER},
org_id = #{orgId,jdbcType=VARCHAR},
create_by = #{createBy,jdbcType=VARCHAR},
create_date = #{createDate,jdbcType=TIMESTAMP},
update_by = #{updateBy,jdbcType=VARCHAR},
update_date = #{updateDate,jdbcType=TIMESTAMP},
remarks = #{remarks,jdbcType=VARCHAR},
del_flag = #{delFlag,jdbcType=CHAR}
where id = #{id,jdbcType=VARCHAR}
</update>
</mapper>
\ No newline at end of file
... ...