commit 1a39a51aaa0427355e96cbd3b1ab7a13704bd0a8 Author: wu Date: Fri Sep 13 10:57:12 2024 +0800 第一次提交 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ff6309 --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### IntelliJ IDEA ### +.idea/modules.xml +.idea/jarRepositories.xml +.idea/compiler.xml +.idea/libraries/ +*.iws +*.iml +*.ipr + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..720421d --- /dev/null +++ b/pom.xml @@ -0,0 +1,147 @@ + + + 4.0.0 + + com.ykMap + ykMap + 1.0-SNAPSHOT + + + 8 + 8 + UTF-8 + 2.7.6 + 1.2.23 + + + + + + + org.springframework.boot + spring-boot-starter-aop + + + + + org.postgresql + postgresql + 42.6.0 + + + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.springframework.boot + spring-boot-starter-web + + + com.mysql + mysql-connector-j + 8.2.0 + runtime + + + org.projectlombok + lombok + true + + + + com.baomidou + mybatis-plus-boot-starter + 3.5.5 + + + + com.github.xiaoymin + knife4j-openapi2-spring-boot-starter + 4.4.0 + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + cn.hutool + hutool-all + 5.8.25 + + + com.alibaba.fastjson2 + fastjson2 + 2.0.41 + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + public + aliyun nexus + https://maven.aliyun.com/repository/public + + true + + + + + + + ykMap + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 1.8 + 1.8 + UTF-8 + + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + com.ykMap.YkMapApplication + + + + repackage + + repackage + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/ykMap/YkMapApplication.java b/src/main/java/com/ykMap/YkMapApplication.java new file mode 100644 index 0000000..5115446 --- /dev/null +++ b/src/main/java/com/ykMap/YkMapApplication.java @@ -0,0 +1,23 @@ +package com.ykMap; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.scheduling.annotation.EnableAsync; +import org.springframework.scheduling.annotation.EnableScheduling; + +/** + * @author wu + * @since 2024/2/26 10:24 + */ + +@SpringBootApplication +@MapperScan("com.ykMap.mapper") +@EnableAsync +@EnableScheduling +public class YkMapApplication { + public static void main(String[] args) { + SpringApplication.run(YkMapApplication.class, args); + + } +} \ No newline at end of file diff --git a/src/main/java/com/ykMap/base/annotation/DataSource.java b/src/main/java/com/ykMap/base/annotation/DataSource.java new file mode 100644 index 0000000..058e4bf --- /dev/null +++ b/src/main/java/com/ykMap/base/annotation/DataSource.java @@ -0,0 +1,29 @@ +package com.ykMap.base.annotation; + + +import com.ykMap.base.enums.DataSourceType; + +import java.lang.annotation.Documented; +import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 自定义多数据源切换注解 + *

+ * 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准 + * + * @author ruoyi + */ +@Target({ElementType.METHOD, ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +@Inherited +public @interface DataSource { + /** + * 切换数据源名称 + */ + public DataSourceType value() default DataSourceType.MASTER; +} diff --git a/src/main/java/com/ykMap/base/aspectj/DataSourceAspect.java b/src/main/java/com/ykMap/base/aspectj/DataSourceAspect.java new file mode 100644 index 0000000..9e84c84 --- /dev/null +++ b/src/main/java/com/ykMap/base/aspectj/DataSourceAspect.java @@ -0,0 +1,63 @@ +package com.ykMap.base.aspectj; + +import cn.hutool.core.bean.BeanUtil; +import com.ykMap.base.annotation.DataSource; +import com.ykMap.base.datasource.DynamicDataSourceContextHolder; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.aspectj.lang.annotation.Pointcut; +import org.aspectj.lang.reflect.MethodSignature; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.core.annotation.AnnotationUtils; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +import java.util.Objects; + +/** + * 多数据源处理 + * + * @author ruoyi + */ +@Aspect +@Order(1) +@Component +public class DataSourceAspect { + protected Logger logger = LoggerFactory.getLogger(getClass()); + + @Pointcut("@annotation(com.ykMap.base.annotation.DataSource)" + "|| @within(com.ykMap.base.annotation.DataSource)") + public void dsPointCut() { + + } + + @Around("dsPointCut()") + public Object around(ProceedingJoinPoint point) throws Throwable { + DataSource dataSource = getDataSource(point); + + if (BeanUtil.isNotEmpty(dataSource)) { + DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name()); + } + + try { + return point.proceed(); + } finally { + // 销毁数据源 在执行方法之后 + DynamicDataSourceContextHolder.clearDataSourceType(); + } + } + + /** + * 获取需要切换的数据源 + */ + public DataSource getDataSource(ProceedingJoinPoint point) { + MethodSignature signature = (MethodSignature) point.getSignature(); + DataSource dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), DataSource.class); + if (Objects.nonNull(dataSource)) { + return dataSource; + } + + return AnnotationUtils.findAnnotation(signature.getDeclaringType(), DataSource.class); + } +} diff --git a/src/main/java/com/ykMap/base/config/ApplicationConfig.java b/src/main/java/com/ykMap/base/config/ApplicationConfig.java new file mode 100644 index 0000000..3aadb00 --- /dev/null +++ b/src/main/java/com/ykMap/base/config/ApplicationConfig.java @@ -0,0 +1,31 @@ +package com.ykMap.base.config; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableAspectJAutoProxy; + +import java.util.TimeZone; + +/** + * 程序注解配置 + * + * @author ruoyi + */ +@Configuration +// 表示通过aop框架暴露该代理对象,AopContext能够访问 +@EnableAspectJAutoProxy(exposeProxy = true) +// 指定要扫描的Mapper类的包的路径 +@MapperScan("com.ykMap.**.mapper") +public class ApplicationConfig +{ + /** + * 时区配置 + */ + @Bean + public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() + { + return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault()); + } +} diff --git a/src/main/java/com/ykMap/base/config/DruidConfig.java b/src/main/java/com/ykMap/base/config/DruidConfig.java new file mode 100644 index 0000000..1b77b40 --- /dev/null +++ b/src/main/java/com/ykMap/base/config/DruidConfig.java @@ -0,0 +1,116 @@ +package com.ykMap.base.config; + +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; +import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties; +import com.alibaba.druid.util.Utils; +import com.ykMap.base.config.properties.DruidProperties; +import com.ykMap.base.datasource.DynamicDataSource; +import com.ykMap.base.enums.DataSourceType; +import com.ykMap.utils.spring.SpringUtils; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; + +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.sql.DataSource; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +/** + * druid 配置多数据源 + * + * @author ruoyi + */ +@Configuration +public class DruidConfig { + @Bean + @ConfigurationProperties("spring.datasource.druid.master") + public DataSource masterDataSource(DruidProperties druidProperties) { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + return druidProperties.dataSource(dataSource); + } + + @Bean + @ConfigurationProperties("spring.datasource.druid.slave") + @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true") + public DataSource slaveDataSource(DruidProperties druidProperties) { + DruidDataSource dataSource = DruidDataSourceBuilder.create().build(); + return druidProperties.dataSource(dataSource); + } + + @Bean(name = "dynamicDataSource") + @Primary + public DynamicDataSource dataSource(DataSource masterDataSource) { + Map targetDataSources = new HashMap<>(); + targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource); + setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource"); + return new DynamicDataSource(masterDataSource, targetDataSources); + } + + /** + * 设置数据源 + * + * @param targetDataSources 备选数据源集合 + * @param sourceName 数据源名称 + * @param beanName bean名称 + */ + public void setDataSource(Map targetDataSources, String sourceName, String beanName) { + try { + DataSource dataSource = SpringUtils.getBean(beanName); + targetDataSources.put(sourceName, dataSource); + } catch (Exception e) { + } + } + + /** + * 去除监控页面底部的广告 + */ + @SuppressWarnings({"rawtypes", "unchecked"}) + @Bean + @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true") + public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) { + // 获取web监控页面的参数 + DruidStatProperties.StatViewServlet config = properties.getStatViewServlet(); + // 提取common.js的配置路径 + String pattern = config.getUrlPattern() != null ? config.getUrlPattern() : "/druid/*"; + String commonJsPattern = pattern.replaceAll("\\*", "js/common.js"); + final String filePath = "support/http/resources/js/common.js"; + // 创建filter进行过滤 + Filter filter = new Filter() { + @Override + public void init(javax.servlet.FilterConfig filterConfig) throws ServletException { + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException { + chain.doFilter(request, response); + // 重置缓冲区,响应头不会被重置 + response.resetBuffer(); + // 获取common.js + String text = Utils.readFromResource(filePath); + // 正则替换banner, 除去底部的广告信息 + text = text.replaceAll("
", ""); + text = text.replaceAll("powered.*?shrek.wang", ""); + response.getWriter().write(text); + } + + @Override + public void destroy() { + } + }; + FilterRegistrationBean registrationBean = new FilterRegistrationBean(); + registrationBean.setFilter(filter); + registrationBean.addUrlPatterns(commonJsPattern); + return registrationBean; + } +} diff --git a/src/main/java/com/ykMap/base/config/properties/DruidProperties.java b/src/main/java/com/ykMap/base/config/properties/DruidProperties.java new file mode 100644 index 0000000..b64c80e --- /dev/null +++ b/src/main/java/com/ykMap/base/config/properties/DruidProperties.java @@ -0,0 +1,89 @@ +package com.ykMap.base.config.properties; + +import com.alibaba.druid.pool.DruidDataSource; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +/** + * druid 配置属性 + * + * @author ruoyi + */ +@Configuration +public class DruidProperties +{ + @Value("${spring.datasource.druid.initialSize}") + private int initialSize; + + @Value("${spring.datasource.druid.minIdle}") + private int minIdle; + + @Value("${spring.datasource.druid.maxActive}") + private int maxActive; + + @Value("${spring.datasource.druid.maxWait}") + private int maxWait; + + @Value("${spring.datasource.druid.connectTimeout}") + private int connectTimeout; + + @Value("${spring.datasource.druid.socketTimeout}") + private int socketTimeout; + + @Value("${spring.datasource.druid.timeBetweenEvictionRunsMillis}") + private int timeBetweenEvictionRunsMillis; + + @Value("${spring.datasource.druid.minEvictableIdleTimeMillis}") + private int minEvictableIdleTimeMillis; + + @Value("${spring.datasource.druid.maxEvictableIdleTimeMillis}") + private int maxEvictableIdleTimeMillis; + + @Value("${spring.datasource.druid.validationQuery}") + private String validationQuery; + + @Value("${spring.datasource.druid.testWhileIdle}") + private boolean testWhileIdle; + + @Value("${spring.datasource.druid.testOnBorrow}") + private boolean testOnBorrow; + + @Value("${spring.datasource.druid.testOnReturn}") + private boolean testOnReturn; + + public DruidDataSource dataSource(DruidDataSource datasource) + { + /** 配置初始化大小、最小、最大 */ + datasource.setInitialSize(initialSize); + datasource.setMaxActive(maxActive); + datasource.setMinIdle(minIdle); + + /** 配置获取连接等待超时的时间 */ + datasource.setMaxWait(maxWait); + + /** 配置驱动连接超时时间,检测数据库建立连接的超时时间,单位是毫秒 */ + datasource.setConnectTimeout(connectTimeout); + + /** 配置网络超时时间,等待数据库操作完成的网络超时时间,单位是毫秒 */ + datasource.setSocketTimeout(socketTimeout); + + /** 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 */ + datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); + + /** 配置一个连接在池中最小、最大生存的时间,单位是毫秒 */ + datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); + datasource.setMaxEvictableIdleTimeMillis(maxEvictableIdleTimeMillis); + + /** + * 用来检测连接是否有效的sql,要求是一个查询语句,常用select 'x'。如果validationQuery为null,testOnBorrow、testOnReturn、testWhileIdle都不会起作用。 + */ + datasource.setValidationQuery(validationQuery); + /** 建议配置为true,不影响性能,并且保证安全性。申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 */ + datasource.setTestWhileIdle(testWhileIdle); + /** 申请连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */ + datasource.setTestOnBorrow(testOnBorrow); + /** 归还连接时执行validationQuery检测连接是否有效,做了这个配置会降低性能。 */ + datasource.setTestOnReturn(testOnReturn); + return datasource; + } +} diff --git a/src/main/java/com/ykMap/base/constant/HttpStatus.java b/src/main/java/com/ykMap/base/constant/HttpStatus.java new file mode 100644 index 0000000..f1e5106 --- /dev/null +++ b/src/main/java/com/ykMap/base/constant/HttpStatus.java @@ -0,0 +1,93 @@ +package com.ykMap.base.constant; + +/** + * 返回状态码 + * + * @author ruoyi + */ +public class HttpStatus { + /** + * 操作成功 + */ + public static final int SUCCESS = 200; + + /** + * 对象创建成功 + */ + public static final int CREATED = 201; + + /** + * 请求已经被接受 + */ + public static final int ACCEPTED = 202; + + /** + * 操作已经执行成功,但是没有返回数据 + */ + public static final int NO_CONTENT = 204; + + /** + * 资源已被移除 + */ + public static final int MOVED_PERM = 301; + + /** + * 重定向 + */ + public static final int SEE_OTHER = 303; + + /** + * 资源没有被修改 + */ + public static final int NOT_MODIFIED = 304; + + /** + * 参数列表错误(缺少,格式不匹配) + */ + public static final int BAD_REQUEST = 400; + + /** + * 未授权 + */ + public static final int UNAUTHORIZED = 401; + + /** + * 访问受限,授权过期 + */ + public static final int FORBIDDEN = 403; + + /** + * 资源,服务未找到 + */ + public static final int NOT_FOUND = 404; + + /** + * 不允许的http方法 + */ + public static final int BAD_METHOD = 405; + + /** + * 资源冲突,或者资源被锁 + */ + public static final int CONFLICT = 409; + + /** + * 不支持的数据,媒体类型 + */ + public static final int UNSUPPORTED_TYPE = 415; + + /** + * 系统内部错误 + */ + public static final int ERROR = 500; + + /** + * 接口未实现 + */ + public static final int NOT_IMPLEMENTED = 501; + + /** + * 系统警告消息 + */ + public static final int WARN = 601; +} diff --git a/src/main/java/com/ykMap/base/controller/BaseController.java b/src/main/java/com/ykMap/base/controller/BaseController.java new file mode 100644 index 0000000..44735a4 --- /dev/null +++ b/src/main/java/com/ykMap/base/controller/BaseController.java @@ -0,0 +1,78 @@ +package com.ykMap.base.controller; + +import com.ykMap.base.domain.AjaxResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * web层通用数据处理 + * + * @author ruoyi + */ +public class BaseController { + protected final Logger logger = LoggerFactory.getLogger(this.getClass()); + + + /** + * 返回成功 + */ + public AjaxResult success() { + return AjaxResult.success(); + } + + /** + * 返回失败消息 + */ + public AjaxResult error() { + return AjaxResult.error(); + } + + /** + * 返回成功消息 + */ + public AjaxResult success(String message) { + return AjaxResult.success(message); + } + + /** + * 返回成功消息 + */ + public AjaxResult success(Object data) { + return AjaxResult.success(data); + } + + /** + * 返回失败消息 + */ + public AjaxResult error(String message) { + return AjaxResult.error(message); + } + + /** + * 返回警告消息 + */ + public AjaxResult warn(String message) { + return AjaxResult.warn(message); + } + + /** + * 响应返回结果 + * + * @param rows 影响行数 + * @return 操作结果 + */ + protected AjaxResult toAjax(int rows) { + return rows > 0 ? AjaxResult.success() : AjaxResult.error(); + } + + /** + * 响应返回结果 + * + * @param result 结果 + * @return 操作结果 + */ + protected AjaxResult toAjax(boolean result) { + return result ? success() : error(); + } + +} diff --git a/src/main/java/com/ykMap/base/datasource/DynamicDataSource.java b/src/main/java/com/ykMap/base/datasource/DynamicDataSource.java new file mode 100644 index 0000000..4289c4e --- /dev/null +++ b/src/main/java/com/ykMap/base/datasource/DynamicDataSource.java @@ -0,0 +1,24 @@ +package com.ykMap.base.datasource; + +import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; + +import javax.sql.DataSource; +import java.util.Map; + +/** + * 动态数据源 + * + * @author ruoyi + */ +public class DynamicDataSource extends AbstractRoutingDataSource { + public DynamicDataSource(DataSource defaultTargetDataSource, Map targetDataSources) { + super.setDefaultTargetDataSource(defaultTargetDataSource); + super.setTargetDataSources(targetDataSources); + super.afterPropertiesSet(); + } + + @Override + protected Object determineCurrentLookupKey() { + return DynamicDataSourceContextHolder.getDataSourceType(); + } +} \ No newline at end of file diff --git a/src/main/java/com/ykMap/base/datasource/DynamicDataSourceContextHolder.java b/src/main/java/com/ykMap/base/datasource/DynamicDataSourceContextHolder.java new file mode 100644 index 0000000..917d140 --- /dev/null +++ b/src/main/java/com/ykMap/base/datasource/DynamicDataSourceContextHolder.java @@ -0,0 +1,41 @@ +package com.ykMap.base.datasource; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 数据源切换处理 + * + * @author ruoyi + */ +public class DynamicDataSourceContextHolder { + public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class); + + /** + * 使用ThreadLocal维护变量,ThreadLocal为每个使用该变量的线程提供独立的变量副本, + * 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。 + */ + private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); + + /** + * 获得数据源的变量 + */ + public static String getDataSourceType() { + return CONTEXT_HOLDER.get(); + } + + /** + * 设置数据源的变量 + */ + public static void setDataSourceType(String dsType) { + log.info("切换到{}数据源", dsType); + CONTEXT_HOLDER.set(dsType); + } + + /** + * 清空数据源变量 + */ + public static void clearDataSourceType() { + CONTEXT_HOLDER.remove(); + } +} diff --git a/src/main/java/com/ykMap/base/domain/AjaxResult.java b/src/main/java/com/ykMap/base/domain/AjaxResult.java new file mode 100644 index 0000000..b075543 --- /dev/null +++ b/src/main/java/com/ykMap/base/domain/AjaxResult.java @@ -0,0 +1,202 @@ +package com.ykMap.base.domain; + + +import cn.hutool.core.bean.BeanUtil; +import com.ykMap.base.constant.HttpStatus; + +import java.util.HashMap; +import java.util.Objects; + +/** + * 操作消息提醒 + * + * @author ruoyi + */ +public class AjaxResult extends HashMap { + /** + * 状态码 + */ + public static final String CODE_TAG = "code"; + /** + * 返回内容 + */ + public static final String MSG_TAG = "msg"; + /** + * 数据对象 + */ + public static final String DATA_TAG = "data"; + private static final long serialVersionUID = 1L; + + /** + * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 + */ + public AjaxResult() { + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param code 状态码 + * @param msg 返回内容 + */ + public AjaxResult(int code, String msg) { + super.put(CODE_TAG, code); + super.put(MSG_TAG, msg); + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param code 状态码 + * @param msg 返回内容 + * @param data 数据对象 + */ + public AjaxResult(int code, String msg, Object data) { + super.put(CODE_TAG, code); + super.put(MSG_TAG, msg); + if (BeanUtil.isNotEmpty(data)) { + super.put(DATA_TAG, data); + } + } + + /** + * 返回成功消息 + * + * @return 成功消息 + */ + public static AjaxResult success() { + return AjaxResult.success("操作成功"); + } + + /** + * 返回成功数据 + * + * @return 成功消息 + */ + public static AjaxResult success(Object data) { + return AjaxResult.success("操作成功", data); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @return 成功消息 + */ + public static AjaxResult success(String msg) { + return AjaxResult.success(msg, null); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 成功消息 + */ + public static AjaxResult success(String msg, Object data) { + return new AjaxResult(HttpStatus.SUCCESS, msg, data); + } + + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResult warn(String msg) { + return AjaxResult.warn(msg, null); + } + + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static AjaxResult warn(String msg, Object data) { + return new AjaxResult(HttpStatus.WARN, msg, data); + } + + /** + * 返回错误消息 + * + * @return 错误消息 + */ + public static AjaxResult error() { + return AjaxResult.error("操作失败"); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @return 错误消息 + */ + public static AjaxResult error(String msg) { + return AjaxResult.error(msg, null); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 错误消息 + */ + public static AjaxResult error(String msg, Object data) { + return new AjaxResult(HttpStatus.ERROR, msg, data); + } + + /** + * 返回错误消息 + * + * @param code 状态码 + * @param msg 返回内容 + * @return 错误消息 + */ + public static AjaxResult error(int code, String msg) { + return new AjaxResult(code, msg, null); + } + + /** + * 是否为成功消息 + * + * @return 结果 + */ + public boolean isSuccess() { + return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG)); + } + + /** + * 是否为警告消息 + * + * @return 结果 + */ + public boolean isWarn() { + return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG)); + } + + /** + * 是否为错误消息 + * + * @return 结果 + */ + public boolean isError() { + return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG)); + } + + /** + * 方便链式调用 + * + * @param key 键 + * @param value 值 + * @return 数据对象 + */ + @Override + public AjaxResult put(String key, Object value) { + super.put(key, value); + return this; + } +} diff --git a/src/main/java/com/ykMap/base/enums/DataSourceType.java b/src/main/java/com/ykMap/base/enums/DataSourceType.java new file mode 100644 index 0000000..d7cb1a7 --- /dev/null +++ b/src/main/java/com/ykMap/base/enums/DataSourceType.java @@ -0,0 +1,19 @@ +package com.ykMap.base.enums; + +/** + * 数据源 + * + * @author ruoyi + */ +public enum DataSourceType +{ + /** + * 主库 + */ + MASTER, + + /** + * 从库 + */ + SLAVE +} diff --git a/src/main/java/com/ykMap/controller/LineController.java b/src/main/java/com/ykMap/controller/LineController.java new file mode 100644 index 0000000..7505cdc --- /dev/null +++ b/src/main/java/com/ykMap/controller/LineController.java @@ -0,0 +1,90 @@ +package com.ykMap.controller; + +import com.ykMap.base.annotation.DataSource; +import com.ykMap.base.controller.BaseController; +import com.ykMap.base.domain.AjaxResult; +import com.ykMap.base.enums.DataSourceType; +import com.ykMap.entity.response.EquipResponse; +import com.ykMap.entity.response.GetCarIdInfoResponse; +import com.ykMap.entity.response.ItemsResponse; +import com.ykMap.entity.response.LineTemplateResponse; +import com.ykMap.entity.response.SearchCityCountResponse; +import com.ykMap.entity.response.SearchCityResponse; +import com.ykMap.entity.response.SelectLineInfoResponse; +import com.ykMap.entity.response.UserInfoResponse; +import com.ykMap.service.LineService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; + +/** + * 大屏线路接口 + * + * @author du + * @since 2024/8/14 10:40 + */ +@RestController +@RequestMapping("/ykmap/line") +@Api(tags = "大屏线路接口") +public class LineController extends BaseController { + + @Resource + private LineService lineService; + + @ApiOperation(value = "根据车辆id查询线路,装备,人员,标的物", response = GetCarIdInfoResponse.class) + @GetMapping("/getCarIdInfo/{id}") + public AjaxResult getCarIdInfo(@PathVariable String id) { + return success(lineService.getCarIdInfo(id)); + } + + + @ApiOperation(value = "任务明细弹窗线路信息", response = SelectLineInfoResponse.class) + @GetMapping("/selectLineInfo/{id}") + public AjaxResult selectLineInfo(@PathVariable String id) { + return success(lineService.selectLineInfo(id)); + } + + @ApiOperation(value = "任务明细弹窗装备信息", response = EquipResponse.class) + @GetMapping("/equip/{id}") + public AjaxResult equip(@PathVariable String id) { + return success(lineService.equip(id)); + } + + @ApiOperation(value = "任务明细弹窗人员信息", response = UserInfoResponse.class) + @GetMapping("/userInfo/{id}") + public AjaxResult userInfo(@PathVariable String id) { + return success(lineService.userInfo(id)); + } + + @ApiOperation(value = "任务明细弹窗标的物信息", response = ItemsResponse.class) + @GetMapping("/items/{id}") + public AjaxResult items(@PathVariable String id) { + return success(lineService.items(id)); + } + + @ApiOperation(value = "线路模板具体信息", response = LineTemplateResponse.class) + @GetMapping("/lineTemplate") + @DataSource(value = DataSourceType.SLAVE) + public AjaxResult lineTemplate(String area) { + return success(lineService.lineTemplate(area)); + } + + @ApiOperation(value = "业务已覆盖省份清单", response = SearchCityResponse.class) + @GetMapping("/searchCity") + @DataSource(value = DataSourceType.SLAVE) + public AjaxResult searchCity() { + return success(lineService.searchCity()); + } + + @ApiOperation(value = "业务已覆盖省份个数", response = SearchCityCountResponse.class) + @GetMapping("/searchCityCount") + @DataSource(value = DataSourceType.SLAVE) + public AjaxResult searchCityCount() { + return success(lineService.searchCityCount()); + } +} diff --git a/src/main/java/com/ykMap/controller/YxlglController.java b/src/main/java/com/ykMap/controller/YxlglController.java new file mode 100644 index 0000000..b029b30 --- /dev/null +++ b/src/main/java/com/ykMap/controller/YxlglController.java @@ -0,0 +1,103 @@ +package com.ykMap.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ykMap.base.annotation.DataSource; +import com.ykMap.base.controller.BaseController; +import com.ykMap.base.domain.AjaxResult; +import com.ykMap.base.enums.DataSourceType; +import com.ykMap.entity.Yxlgl; +import com.ykMap.entity.request.YxlglRequest; +import com.ykMap.service.YxlglService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.io.Serializable; + +/** + * 【营运管理部门】:线路管理数据(exl_operation_line_data)表控制层 + * + * @author du + * @since 2024/8/13 9:56 + */ +@RestController +@RequestMapping("/ykmap/xlgl") +@Api(tags = "【营运管理部门】:线路管理数据") +@DataSource(value = DataSourceType.SLAVE) +public class YxlglController extends BaseController { + + /** + * 服务对象 + */ + @Resource + private YxlglService yxlglService; + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @param yxlglRequest 查询实体 + * @return 所有数据 + */ + @ApiOperation(value = "分页查询所有数据", response = Yxlgl.class) + @GetMapping + public AjaxResult selectAll(Page page, YxlglRequest yxlglRequest) { + return success(yxlglService.page(page, yxlglRequest)); + } + + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @ApiOperation(value = "通过主键查询单条数据", response = Yxlgl.class) + @GetMapping("{id}") + public AjaxResult selectOne(@PathVariable Serializable id) { + return success(yxlglService.getById(id)); + } + + /** + * 新增数据 + * + * @param xlgl 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping + public AjaxResult insert(@RequestBody Yxlgl xlgl) { + return success(yxlglService.save(xlgl)); + } + + /** + * 修改数据 + * + * @param xlgl 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "修改数据") + @PostMapping("/edit") + public AjaxResult update(@RequestBody Yxlgl xlgl) { + return success(yxlglService.updateById(xlgl)); + } + + /** + * 删除数据 + * + * @param id 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "删除数据") + @GetMapping("/delete/{id}") + public AjaxResult delete(@PathVariable Long id) { + return success(yxlglService.removeById(id)); + } + +} diff --git a/src/main/java/com/ykMap/controller/YywtzController.java b/src/main/java/com/ykMap/controller/YywtzController.java new file mode 100644 index 0000000..f873c19 --- /dev/null +++ b/src/main/java/com/ykMap/controller/YywtzController.java @@ -0,0 +1,101 @@ +package com.ykMap.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ykMap.base.annotation.DataSource; +import com.ykMap.base.controller.BaseController; +import com.ykMap.base.domain.AjaxResult; +import com.ykMap.base.enums.DataSourceType; +import com.ykMap.entity.Yywtz; +import com.ykMap.service.YywtzService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.io.Serializable; + +/** + * 【营运管理部门】:业务拓展数据(exl_operation_expansion_data)表控制层 + * + * @author du + * @since 2024/8/13 9:56 + */ +@RestController +@RequestMapping("/ykmap/ywtz") +@Api(tags = "【营运管理部门】:业务拓展数据") +@DataSource(value = DataSourceType.SLAVE) +public class YywtzController extends BaseController { + + /** + * 服务对象 + */ + @Resource + private YywtzService yywtzService; + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @return 所有数据 + */ + @ApiOperation(value = "分页查询所有数据", response = Yywtz.class) + @GetMapping + public AjaxResult selectAll(Page page) { + return success(yywtzService.page(page)); + } + + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @ApiOperation(value = "通过主键查询单条数据", response = Yywtz.class) + @GetMapping("{id}") + public AjaxResult selectOne(@PathVariable Serializable id) { + return success(yywtzService.getById(id)); + } + + /** + * 新增数据 + * + * @param xlgl 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping + public AjaxResult insert(@RequestBody Yywtz xlgl) { + return success(yywtzService.save(xlgl)); + } + + /** + * 修改数据 + * + * @param xlgl 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "修改数据") + @PostMapping("/edit") + public AjaxResult update(@RequestBody Yywtz xlgl) { + return success(yywtzService.updateById(xlgl)); + } + + /** + * 删除数据 + * + * @param id 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "删除数据") + @GetMapping("/delete/{id}") + public AjaxResult delete(@PathVariable Long id) { + return success(yywtzService.removeById(id)); + } + +} diff --git a/src/main/java/com/ykMap/controller/YywzlController.java b/src/main/java/com/ykMap/controller/YywzlController.java new file mode 100644 index 0000000..81c5445 --- /dev/null +++ b/src/main/java/com/ykMap/controller/YywzlController.java @@ -0,0 +1,101 @@ +package com.ykMap.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ykMap.base.annotation.DataSource; +import com.ykMap.base.controller.BaseController; +import com.ykMap.base.domain.AjaxResult; +import com.ykMap.base.enums.DataSourceType; +import com.ykMap.entity.Yywzl; +import com.ykMap.service.YywzlService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.io.Serializable; + +/** + * 【营运管理部门】:业务总览数据(exl_operation_overview_data_route)表控制层 + * + * @author du + * @since 2024/8/13 9:56 + */ +@RestController +@RequestMapping("/ykmap/ywzl") +@Api(tags = "【营运管理部门】:业务总览数据") +@DataSource(value = DataSourceType.SLAVE) +public class YywzlController extends BaseController { + + /** + * 服务对象 + */ + @Resource + private YywzlService yywzlService; + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @return 所有数据 + */ + @ApiOperation(value = "分页查询所有数据", response = Yywzl.class) + @GetMapping + public AjaxResult selectAll(Page page) { + return success(yywzlService.page(page)); + } + + + /** + * 通过主键查询单条数据 + * + * @param id 主键 + * @return 单条数据 + */ + @ApiOperation(value = "通过主键查询单条数据", response = Yywzl.class) + @GetMapping("{id}") + public AjaxResult selectOne(@PathVariable Serializable id) { + return success(yywzlService.getById(id)); + } + + /** + * 新增数据 + * + * @param xlgl 实体对象 + * @return 新增结果 + */ + @ApiOperation(value = "新增数据") + @PostMapping + public AjaxResult insert(@RequestBody Yywzl xlgl) { + return success(yywzlService.save(xlgl)); + } + + /** + * 修改数据 + * + * @param xlgl 实体对象 + * @return 修改结果 + */ + @ApiOperation(value = "修改数据") + @PostMapping("/edit") + public AjaxResult update(@RequestBody Yywzl xlgl) { + return success(yywzlService.updateById(xlgl)); + } + + /** + * 删除数据 + * + * @param id 主键结合 + * @return 删除结果 + */ + @ApiOperation(value = "删除数据") + @GetMapping("/delete/{id}") + public AjaxResult delete(@PathVariable Long id) { + return success(yywzlService.removeById(id)); + } + +} diff --git a/src/main/java/com/ykMap/entity/Yxlgl.java b/src/main/java/com/ykMap/entity/Yxlgl.java new file mode 100644 index 0000000..46074f5 --- /dev/null +++ b/src/main/java/com/ykMap/entity/Yxlgl.java @@ -0,0 +1,92 @@ +package com.ykMap.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** + * 【营运管理部门】:线路管理数据(exl_operation_line_data)表实体类 + * + * @author du + * @since 2024/8/13 9:49 + */ +@Data +@ApiModel("线路管理数据") +@TableName(value = "exl_operation_line_data") +public class Yxlgl { + + /** + * id + */ + @TableId + @ApiModelProperty("id") + private String id; + + /** + * 创建id + */ + @ApiModelProperty("创建id") + private Integer creatorId; + + /** + * 更新id + */ + @ApiModelProperty("更新id") + private Integer updaterId; + + /** + * 更新时间 + */ + @ApiModelProperty("更新时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updateTime; + + /** + * 创建时间 + */ + @ApiModelProperty("创建时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; + + /** + * 线路类型:工作日、周六、周日 + */ + @ApiModelProperty("线路类型:工作日、周六、周日") + private String lineType; + + /** + * 营运网点线路条数(条) + */ + @ApiModelProperty("营运网点线路条数(条)") + private Integer networkLineNum; + + /** + * 营运无网点线路条数(条) + */ + @ApiModelProperty("营运无网点线路条数(条)") + private Integer noNetworkLineNum; + + /** + * 维护线路条数(条) + */ + @ApiModelProperty("维护线路条数(条)") + private Integer maintenanceLineNum; + + /** + * 数据时间(月份),时间戳 + */ + @ApiModelProperty("数据时间(月份),时间戳") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate dataTime; + +} diff --git a/src/main/java/com/ykMap/entity/Yywtz.java b/src/main/java/com/ykMap/entity/Yywtz.java new file mode 100644 index 0000000..04ba043 --- /dev/null +++ b/src/main/java/com/ykMap/entity/Yywtz.java @@ -0,0 +1,72 @@ +package com.ykMap.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** + * 【营运管理部门】:业务拓展数据(exl_operation_expansion_data)表实体类 + * @author du + * @since 2024/8/14 10:33 + */ +@Data +@ApiModel("业务总览数据") +@TableName(value = "exl_operation_expansion_data") +public class Yywtz { + /** + * id + */ + @TableId + @ApiModelProperty("id") + private String id; + + /** + * 创建id + */ + @ApiModelProperty("创建id") + private Integer creatorId; + + /** + * 更新id + */ + @ApiModelProperty("更新id") + private Integer updaterId; + + /** + * 更新时间 + */ + @ApiModelProperty("更新时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updateTime; + + /** + * 创建时间 + */ + @ApiModelProperty("创建时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; + + /** + * 业务已覆盖省份名称 + */ + @ApiModelProperty("业务已覆盖省份名称") + private String provinceName; + + + /** + * 数据时间(月份),时间戳 + */ + @ApiModelProperty("数据时间(月份),时间戳") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate dataTime; +} diff --git a/src/main/java/com/ykMap/entity/Yywzl.java b/src/main/java/com/ykMap/entity/Yywzl.java new file mode 100644 index 0000000..b496121 --- /dev/null +++ b/src/main/java/com/ykMap/entity/Yywzl.java @@ -0,0 +1,82 @@ +package com.ykMap.entity; + +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** + * 【营运管理部门】:业务总览数据(exl_operation_overview_data_route)表实体类 + * @author du + * @since 2024/8/14 10:17 + */ +@Data +@ApiModel("业务总览数据") +@TableName(value = "exl_operation_overview_data_route") +public class Yywzl { + + /** + * id + */ + @TableId + @ApiModelProperty("id") + private String id; + + /** + * 创建id + */ + @ApiModelProperty("创建id") + private Integer creatorId; + + /** + * 更新id + */ + @ApiModelProperty("更新id") + private Integer updaterId; + + /** + * 更新时间 + */ + @ApiModelProperty("更新时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime updateTime; + + /** + * 创建时间 + */ + @ApiModelProperty("创建时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; + + + /** + * 区镇:吴中区、吴江区、虎丘区、姑苏区、工业园区、相城区 + */ + @ApiModelProperty("区镇:吴中区、吴江区、虎丘区、姑苏区、工业园区、相城区") + private String area; + + + /** + * 线路总条数(条) + */ + @ApiModelProperty("线路总条数(条)") + private Integer lineTotalNum; + + + /** + * 数据时间(月份),时间戳 + */ + @ApiModelProperty("数据时间(月份),时间戳") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate dataTime; + +} diff --git a/src/main/java/com/ykMap/entity/request/YxlglRequest.java b/src/main/java/com/ykMap/entity/request/YxlglRequest.java new file mode 100644 index 0000000..5c6425d --- /dev/null +++ b/src/main/java/com/ykMap/entity/request/YxlglRequest.java @@ -0,0 +1,21 @@ +package com.ykMap.entity.request; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 【营运管理部门】:线路管理数据(exl_operation_line_data)请求体 + * @author du + * @since 2024/8/14 9:01 + */ +@Data +@ApiModel("线路管理数据") +public class YxlglRequest { + + /** + * 线路类型:工作日、周六、周日 + */ + @ApiModelProperty("线路类型:工作日、周六、周日") + private String lineType; +} diff --git a/src/main/java/com/ykMap/entity/response/EquipResponse.java b/src/main/java/com/ykMap/entity/response/EquipResponse.java new file mode 100644 index 0000000..ec91893 --- /dev/null +++ b/src/main/java/com/ykMap/entity/response/EquipResponse.java @@ -0,0 +1,27 @@ +package com.ykMap.entity.response; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 任务装备返回体 + * @author du + * @since 2024/8/14 11:06 + */ +@Data +@ApiModel("任务装备返回体") +public class EquipResponse { + + /** + * 装备名称 + */ + @ApiModelProperty("装备名称") + private String thingType; + + /** + * 装备类型 + */ + @ApiModelProperty("装备类型") + private String type; +} diff --git a/src/main/java/com/ykMap/entity/response/GetCarIdInfoResponse.java b/src/main/java/com/ykMap/entity/response/GetCarIdInfoResponse.java new file mode 100644 index 0000000..76da1fc --- /dev/null +++ b/src/main/java/com/ykMap/entity/response/GetCarIdInfoResponse.java @@ -0,0 +1,40 @@ +package com.ykMap.entity.response; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * 根据车辆id查询线路,装备,人员,标的物 + * @author du + * @since 2024/8/15 9:29 + */ +@Data +public class GetCarIdInfoResponse { + + /** + * 线路类型 + */ + @ApiModelProperty("线路类型") + private String lineType; + + + /** + * 装备信息 + */ + @ApiModelProperty("装备信息") + private List zbList; + + /** + * 人员信息 + */ + @ApiModelProperty("人员信息") + private List userList; + + /** + * 标的物 + */ + @ApiModelProperty("标的物") + private ItemsResponse bdwInfo; +} diff --git a/src/main/java/com/ykMap/entity/response/ItemsResponse.java b/src/main/java/com/ykMap/entity/response/ItemsResponse.java new file mode 100644 index 0000000..1e1a4b8 --- /dev/null +++ b/src/main/java/com/ykMap/entity/response/ItemsResponse.java @@ -0,0 +1,18 @@ +package com.ykMap.entity.response; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 标的物信息返回体 + * @author du + * @since 2024/8/14 11:18 + */ +@Data +@ApiModel("标的物信息返回体") +public class ItemsResponse { + + @ApiModelProperty("数量") + private Integer count; +} diff --git a/src/main/java/com/ykMap/entity/response/LineTemplateResponse.java b/src/main/java/com/ykMap/entity/response/LineTemplateResponse.java new file mode 100644 index 0000000..672b572 --- /dev/null +++ b/src/main/java/com/ykMap/entity/response/LineTemplateResponse.java @@ -0,0 +1,58 @@ +package com.ykMap.entity.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +/** + * 线路模板具体信息返回体 + * + * @author du + * @since 2024/8/14 15:09 + */ +@Data +@ApiModel("线路模板具体信息返回体") +public class LineTemplateResponse { + + /** + * 区域 + */ + @ApiModelProperty("区域") + private String area; + + /** + * 线路总数 + */ + @ApiModelProperty("线路总数") + private Integer LineTotalNum; + + /** + * 营业网点总数 + */ + @ApiModelProperty("营业网点总数") + private Integer outletsTotalNum; + + /** + * 上门收款点总数 + */ + @ApiModelProperty("上门收款点总数") + private Integer paymentPointNum; + + /** + * ATM机总数 + */ + @ApiModelProperty("ATM机总数") + private Integer atmTotalNum; + + /** + * 创建时间 + */ + @ApiModelProperty("创建时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime dataTime; +} diff --git a/src/main/java/com/ykMap/entity/response/SearchCityCountResponse.java b/src/main/java/com/ykMap/entity/response/SearchCityCountResponse.java new file mode 100644 index 0000000..021eacd --- /dev/null +++ b/src/main/java/com/ykMap/entity/response/SearchCityCountResponse.java @@ -0,0 +1,21 @@ +package com.ykMap.entity.response; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 业务已覆盖省份清单数量 + * @author du + * @since 2024/8/14 17:08 + */ +@Data +@ApiModel("业务已覆盖省份清单数量") +public class SearchCityCountResponse { + + /** + * 个数 + */ + @ApiModelProperty("个数") + private Integer count; +} diff --git a/src/main/java/com/ykMap/entity/response/SearchCityResponse.java b/src/main/java/com/ykMap/entity/response/SearchCityResponse.java new file mode 100644 index 0000000..7db1e0c --- /dev/null +++ b/src/main/java/com/ykMap/entity/response/SearchCityResponse.java @@ -0,0 +1,33 @@ +package com.ykMap.entity.response; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +/** + * 业务已覆盖省份清单 + * @author du + * @since 2024/8/14 16:04 + */ +@Data +@ApiModel("业务已覆盖省份清单") +public class SearchCityResponse { + + /** + * 省份 + */ + @ApiModelProperty("省份") + private String city; + + /** + * 创建时间 + */ + @ApiModelProperty("创建时间") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime dataTime; +} diff --git a/src/main/java/com/ykMap/entity/response/SelectLineInfoResponse.java b/src/main/java/com/ykMap/entity/response/SelectLineInfoResponse.java new file mode 100644 index 0000000..c8a8a5a --- /dev/null +++ b/src/main/java/com/ykMap/entity/response/SelectLineInfoResponse.java @@ -0,0 +1,28 @@ +package com.ykMap.entity.response; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 线路信息返回体 + * @author du + * @since 2024/8/14 10:51 + */ +@Data +@ApiModel("线路信息返回体") +public class SelectLineInfoResponse { + /** + * 任务名称 + */ + @ApiModelProperty("任务名称") + private String name; + + /** + * 任务类型 + */ + @ApiModelProperty("任务类型") + private String type; + + +} diff --git a/src/main/java/com/ykMap/entity/response/UserInfoResponse.java b/src/main/java/com/ykMap/entity/response/UserInfoResponse.java new file mode 100644 index 0000000..ecc7173 --- /dev/null +++ b/src/main/java/com/ykMap/entity/response/UserInfoResponse.java @@ -0,0 +1,33 @@ +package com.ykMap.entity.response; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 人员信息返回体 + * @author du + * @since 2024/8/14 11:10 + */ +@Data +@ApiModel("人员信息返回体") +public class UserInfoResponse { + + /** + * 人员信息 + */ + @ApiModelProperty("人员信息") + private String ename; + + /** + * 职位名称 + */ + @ApiModelProperty("职位名称") + private String name; + + /** + * 排序 + */ + @ApiModelProperty("排序") + private Integer orderNum; +} diff --git a/src/main/java/com/ykMap/mapper/LineMapper.java b/src/main/java/com/ykMap/mapper/LineMapper.java new file mode 100644 index 0000000..df71994 --- /dev/null +++ b/src/main/java/com/ykMap/mapper/LineMapper.java @@ -0,0 +1,61 @@ +package com.ykMap.mapper; + +import com.ykMap.entity.response.EquipResponse; +import com.ykMap.entity.response.ItemsResponse; +import com.ykMap.entity.response.LineTemplateResponse; +import com.ykMap.entity.response.SearchCityCountResponse; +import com.ykMap.entity.response.SearchCityResponse; +import com.ykMap.entity.response.SelectLineInfoResponse; +import com.ykMap.entity.response.UserInfoResponse; +import org.apache.ibatis.annotations.Param; + +import java.time.LocalDate; +import java.util.List; + +/** + * 大屏线路数据层 + * + * @author du + * @since 2024/8/13 9:49 + */ +public interface LineMapper{ + + + /** + * 任务明细弹窗线路信息 + */ + SelectLineInfoResponse selectLineInfo(String id); + + /** + * 任务明细弹窗装备信息 + */ + List equip(String id); + + /** + * 任务明细弹窗人员信息 + */ + List userInfo(String id); + + /** + * 任务明细弹窗标的物信息 + */ + ItemsResponse items(String id); + + /** + * 线路模板具体信息 + */ + List lineTemplate(@Param("area") String area,@Param("a1") LocalDate a1, @Param("a2")LocalDate a2); + + + /** + * 业务已覆盖省份清单 + */ + List searchCity(@Param("a1") LocalDate a1, @Param("a2")LocalDate a2); + + /** + * 业务已覆盖省份个数 + */ + SearchCityCountResponse searchCityCount(@Param("a1") LocalDate a1, @Param("a2")LocalDate a2); + + String getByCarId(String id); +} diff --git a/src/main/java/com/ykMap/mapper/YxlglMapper.java b/src/main/java/com/ykMap/mapper/YxlglMapper.java new file mode 100644 index 0000000..a7cff95 --- /dev/null +++ b/src/main/java/com/ykMap/mapper/YxlglMapper.java @@ -0,0 +1,25 @@ +package com.ykMap.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ykMap.entity.Yxlgl; +import com.ykMap.entity.request.YxlglRequest; +import org.apache.ibatis.annotations.Param; + +/** + * 【营运管理部门】:线路管理数据(exl_operation_line_data)表数据层 + * + * @author du + * @since 2024/8/13 9:49 + */ +public interface YxlglMapper extends BaseMapper { + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @param yxlglRequest 查询实体 + * @return 所有数据 + */ + Page page(Page page,@Param("req") YxlglRequest yxlglRequest); +} diff --git a/src/main/java/com/ykMap/mapper/YywtzMapper.java b/src/main/java/com/ykMap/mapper/YywtzMapper.java new file mode 100644 index 0000000..787640d --- /dev/null +++ b/src/main/java/com/ykMap/mapper/YywtzMapper.java @@ -0,0 +1,22 @@ +package com.ykMap.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ykMap.entity.Yywtz; + +/** + * 【营运管理部门】:业务拓展数据(exl_operation_expansion_data)表数据层 + * + * @author du + * @since 2024/8/13 9:49 + */ +public interface YywtzMapper extends BaseMapper { + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @return 所有数据 + */ + Page page(Page page); +} diff --git a/src/main/java/com/ykMap/mapper/YywzlMapper.java b/src/main/java/com/ykMap/mapper/YywzlMapper.java new file mode 100644 index 0000000..469fd23 --- /dev/null +++ b/src/main/java/com/ykMap/mapper/YywzlMapper.java @@ -0,0 +1,22 @@ +package com.ykMap.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ykMap.entity.Yywzl; + +/** + * 【营运管理部门】:业务总览数据(exl_operation_overview_data_route)表数据层 + * + * @author du + * @since 2024/8/13 9:49 + */ +public interface YywzlMapper extends BaseMapper { + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @return 所有数据 + */ + Page page(Page page); +} diff --git a/src/main/java/com/ykMap/service/LineService.java b/src/main/java/com/ykMap/service/LineService.java new file mode 100644 index 0000000..14bef60 --- /dev/null +++ b/src/main/java/com/ykMap/service/LineService.java @@ -0,0 +1,62 @@ +package com.ykMap.service; + +import com.ykMap.entity.response.EquipResponse; +import com.ykMap.entity.response.GetCarIdInfoResponse; +import com.ykMap.entity.response.ItemsResponse; +import com.ykMap.entity.response.LineTemplateResponse; +import com.ykMap.entity.response.SearchCityCountResponse; +import com.ykMap.entity.response.SearchCityResponse; +import com.ykMap.entity.response.SelectLineInfoResponse; +import com.ykMap.entity.response.UserInfoResponse; + +import java.util.List; + +/** + * 大屏线路业务层 + * @author du + * @since 2024/8/14 10:43 + */ +public interface LineService { + + /** + * 任务明细弹窗线路信息 + */ + SelectLineInfoResponse selectLineInfo(String id); + + + /** + * 任务明细弹窗装备信息 + */ + List equip(String id); + + /** + * 任务明细弹窗人员信息 + */ + List userInfo(String id); + + /** + * 任务明细弹窗标的物信息 + */ + ItemsResponse items(String id); + + /** + * 线路模板具体信息 + */ + List lineTemplate(String area); + + /** + * 业务已覆盖省份清单 + */ + List searchCity(); + + /** + * 业务已覆盖省份个数 + */ + SearchCityCountResponse searchCityCount(); + + + /** + * 根据车辆id查询线路,装备,人员,标的 + */ + GetCarIdInfoResponse getCarIdInfo(String id); +} diff --git a/src/main/java/com/ykMap/service/YxlglService.java b/src/main/java/com/ykMap/service/YxlglService.java new file mode 100644 index 0000000..0af3111 --- /dev/null +++ b/src/main/java/com/ykMap/service/YxlglService.java @@ -0,0 +1,25 @@ +package com.ykMap.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ykMap.entity.Yxlgl; +import com.ykMap.entity.request.YxlglRequest; + +/** + * 【营运管理部门】:线路管理数据(exl_operation_line_data)表业务层 + * + * @author du + * @since 2024/8/13 9:49 + */ +public interface YxlglService extends IService { + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @param yxlglRequest 查询实体 + * @return 所有数据 + */ + Page page(Page page, YxlglRequest yxlglRequest); + +} diff --git a/src/main/java/com/ykMap/service/YywtzService.java b/src/main/java/com/ykMap/service/YywtzService.java new file mode 100644 index 0000000..3a715e1 --- /dev/null +++ b/src/main/java/com/ykMap/service/YywtzService.java @@ -0,0 +1,23 @@ +package com.ykMap.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ykMap.entity.Yywtz; + +/** + * 【营运管理部门】:业务拓展数据(exl_operation_expansion_data)表业务层 + * + * @author du + * @since 2024/8/13 9:49 + */ +public interface YywtzService extends IService { + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @return 所有数据 + */ + Page page(Page page); + +} diff --git a/src/main/java/com/ykMap/service/YywzlService.java b/src/main/java/com/ykMap/service/YywzlService.java new file mode 100644 index 0000000..b43287a --- /dev/null +++ b/src/main/java/com/ykMap/service/YywzlService.java @@ -0,0 +1,23 @@ +package com.ykMap.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.ykMap.entity.Yywzl; + +/** + * 【营运管理部门】:业务总览数据(exl_operation_overview_data_route)表业务层 + * + * @author du + * @since 2024/8/13 9:49 + */ +public interface YywzlService extends IService { + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @return 所有数据 + */ + Page page(Page page); + +} diff --git a/src/main/java/com/ykMap/service/impl/LineServiceImpl.java b/src/main/java/com/ykMap/service/impl/LineServiceImpl.java new file mode 100644 index 0000000..a894cb8 --- /dev/null +++ b/src/main/java/com/ykMap/service/impl/LineServiceImpl.java @@ -0,0 +1,132 @@ +package com.ykMap.service.impl; + +import cn.hutool.core.bean.BeanUtil; +import com.ykMap.entity.response.EquipResponse; +import com.ykMap.entity.response.GetCarIdInfoResponse; +import com.ykMap.entity.response.ItemsResponse; +import com.ykMap.entity.response.LineTemplateResponse; +import com.ykMap.entity.response.SearchCityCountResponse; +import com.ykMap.entity.response.SearchCityResponse; +import com.ykMap.entity.response.SelectLineInfoResponse; +import com.ykMap.entity.response.UserInfoResponse; +import com.ykMap.mapper.LineMapper; +import com.ykMap.service.LineService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.time.LocalDate; +import java.util.List; + +/** + * 大屏线路业务处理层 + * + * @author du + * @since 2024/8/14 10:44 + */ +@Service +public class LineServiceImpl implements LineService { + + @Resource + private LineMapper lineMapper; + + /** + * 任务明细弹窗线路信息 + */ + @Override + public SelectLineInfoResponse selectLineInfo(String id) { + return lineMapper.selectLineInfo(id); + } + + /** + * 任务明细弹窗装备信息 + */ + @Override + public List equip(String id) { + return lineMapper.equip(id); + } + + /** + * 任务明细弹窗人员信息 + */ + @Override + public List userInfo(String id) { + return lineMapper.userInfo(id); + } + + /** + * 任务明细弹窗标的物信息 + */ + @Override + public ItemsResponse items(String id) { + return lineMapper.items(id); + } + + /** + * 线路模板具体信息 + */ + @Override + public List lineTemplate(String area) { + LocalDate now = LocalDate.now(); + if (now.getDayOfMonth() < 26) { + LocalDate a1 = now.minusMonths(2).withDayOfMonth(26); + LocalDate a2 = now.minusMonths(1).withDayOfMonth(25); + return lineMapper.lineTemplate(area, a1, a2); + } else { + LocalDate a1 = now.minusMonths(1).withDayOfMonth(26); + LocalDate a2 = now.withDayOfMonth(25); + return lineMapper.lineTemplate(area, a1, a2); + } + } + + /** + * 业务已覆盖省份清单 + */ + @Override + public List searchCity() { + LocalDate now = LocalDate.now(); + if (now.getDayOfMonth() < 26) { + LocalDate a1 = now.minusMonths(2).withDayOfMonth(26); + LocalDate a2 = now.minusMonths(1).withDayOfMonth(25); + return lineMapper.searchCity(a1, a2); + } else { + LocalDate a1 = now.minusMonths(1).withDayOfMonth(26); + LocalDate a2 = now.withDayOfMonth(25); + return lineMapper.searchCity(a1, a2); + } + } + + /** + * 业务已覆盖省份个数 + */ + @Override + public SearchCityCountResponse searchCityCount() { + LocalDate now = LocalDate.now(); + if (now.getDayOfMonth() < 26) { + LocalDate a1 = now.minusMonths(2).withDayOfMonth(26); + LocalDate a2 = now.minusMonths(1).withDayOfMonth(25); + return lineMapper.searchCityCount(a1, a2); + } else { + LocalDate a1 = now.minusMonths(1).withDayOfMonth(26); + LocalDate a2 = now.withDayOfMonth(25); + return lineMapper.searchCityCount(a1, a2); + } + } + + /** + * 根据车辆id查询线路,装备,人员,标的 + */ + @Override + public GetCarIdInfoResponse getCarIdInfo(String id) { + //获取该车辆的任务id + String bcs = lineMapper.getByCarId(id); + GetCarIdInfoResponse res = new GetCarIdInfoResponse(); + res.setZbList(lineMapper.equip(bcs)); + res.setUserList(lineMapper.userInfo(bcs)); + res.setBdwInfo(lineMapper.items(bcs)); + SelectLineInfoResponse se = lineMapper.selectLineInfo(bcs); + if (BeanUtil.isNotEmpty(se)) { + res.setLineType(se.getType()); + } + return res; + } +} diff --git a/src/main/java/com/ykMap/service/impl/YxlglServiceImpl.java b/src/main/java/com/ykMap/service/impl/YxlglServiceImpl.java new file mode 100644 index 0000000..ef85e49 --- /dev/null +++ b/src/main/java/com/ykMap/service/impl/YxlglServiceImpl.java @@ -0,0 +1,31 @@ +package com.ykMap.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ykMap.entity.Yxlgl; +import com.ykMap.entity.request.YxlglRequest; +import com.ykMap.mapper.YxlglMapper; +import com.ykMap.service.YxlglService; +import org.springframework.stereotype.Service; + +/** + * 【营运管理部门】:线路管理数据(exl_operation_line_data)表业务处理层 + * + * @author du + * @since 2024/5/13 9:58 + */ +@Service +public class YxlglServiceImpl extends ServiceImpl implements YxlglService { + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @param yxlglRequest 查询实体 + * @return 所有数据 + */ + @Override + public Page page(Page page, YxlglRequest yxlglRequest) { + return baseMapper.page(page,yxlglRequest); + } +} diff --git a/src/main/java/com/ykMap/service/impl/YywtzServiceImpl.java b/src/main/java/com/ykMap/service/impl/YywtzServiceImpl.java new file mode 100644 index 0000000..d025186 --- /dev/null +++ b/src/main/java/com/ykMap/service/impl/YywtzServiceImpl.java @@ -0,0 +1,29 @@ +package com.ykMap.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ykMap.entity.Yywtz; +import com.ykMap.mapper.YywtzMapper; +import com.ykMap.service.YywtzService; +import org.springframework.stereotype.Service; + +/** + * 【营运管理部门】:业务拓展数据(exl_operation_expansion_data)表业务处理层 + * + * @author du + * @since 2024/5/13 9:58 + */ +@Service +public class YywtzServiceImpl extends ServiceImpl implements YywtzService { + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @return 所有数据 + */ + @Override + public Page page(Page page) { + return baseMapper.page(page); + } +} diff --git a/src/main/java/com/ykMap/service/impl/YywzlServiceImpl.java b/src/main/java/com/ykMap/service/impl/YywzlServiceImpl.java new file mode 100644 index 0000000..d0d8b50 --- /dev/null +++ b/src/main/java/com/ykMap/service/impl/YywzlServiceImpl.java @@ -0,0 +1,29 @@ +package com.ykMap.service.impl; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.ykMap.entity.Yywzl; +import com.ykMap.mapper.YywzlMapper; +import com.ykMap.service.YywzlService; +import org.springframework.stereotype.Service; + +/** + * 【营运管理部门】:业务总览数据(exl_operation_overview_data_route)表业务处理层 + * + * @author du + * @since 2024/5/13 9:58 + */ +@Service +public class YywzlServiceImpl extends ServiceImpl implements YywzlService { + + /** + * 分页查询所有数据 + * + * @param page 分页对象 + * @return 所有数据 + */ + @Override + public Page page(Page page) { + return baseMapper.page(page); + } +} diff --git a/src/main/java/com/ykMap/utils/spring/SpringUtils.java b/src/main/java/com/ykMap/utils/spring/SpringUtils.java new file mode 100644 index 0000000..c56fe77 --- /dev/null +++ b/src/main/java/com/ykMap/utils/spring/SpringUtils.java @@ -0,0 +1,140 @@ +package com.ykMap.utils.spring; + +import org.springframework.aop.framework.AopContext; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.NoSuchBeanDefinitionException; +import org.springframework.beans.factory.config.BeanFactoryPostProcessor; +import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +/** + * spring工具类 方便在非spring管理环境中获取bean + * + * @author ruoyi + */ +@Component +public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware { + /** + * Spring应用上下文环境 + */ + private static ConfigurableListableBeanFactory beanFactory; + + private static ApplicationContext applicationContext; + + /** + * 获取对象 + * + * @param name + * @return Object 一个以所给名字注册的bean的实例 + * @throws BeansException + */ + @SuppressWarnings("unchecked") + public static T getBean(String name) throws BeansException { + return (T) beanFactory.getBean(name); + } + + /** + * 获取类型为requiredType的对象 + * + * @param clz + * @return + * @throws BeansException + */ + public static T getBean(Class clz) throws BeansException { + T result = (T) beanFactory.getBean(clz); + return result; + } + + /** + * 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true + * + * @param name + * @return boolean + */ + public static boolean containsBean(String name) { + return beanFactory.containsBean(name); + } + + /** + * 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException) + * + * @param name + * @return boolean + * @throws NoSuchBeanDefinitionException + */ + public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException { + return beanFactory.isSingleton(name); + } + + /** + * @param name + * @return Class 注册对象的类型 + * @throws NoSuchBeanDefinitionException + */ + public static Class getType(String name) throws NoSuchBeanDefinitionException { + return beanFactory.getType(name); + } + + /** + * 如果给定的bean名字在bean定义中有别名,则返回这些别名 + * + * @param name + * @return + * @throws NoSuchBeanDefinitionException + */ + public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { + return beanFactory.getAliases(name); + } + + /** + * 获取aop代理对象 + * + * @param invoker + * @return + */ + @SuppressWarnings("unchecked") + public static T getAopProxy(T invoker) { + return (T) AopContext.currentProxy(); + } + + /** + * 获取当前的环境配置,无配置返回null + * + * @return 当前的环境配置 + */ + public static String[] getActiveProfiles() { + return applicationContext.getEnvironment().getActiveProfiles(); + } + + /** + * 获取当前的环境配置,当有多个环境配置时,只获取第一个 + * + * @return 当前的环境配置 + */ + public static String getActiveProfile() { + final String[] activeProfiles = getActiveProfiles(); + return activeProfiles.length > 0 ? activeProfiles[0] : null; + } + + /** + * 获取配置文件中的值 + * + * @param key 配置文件的key + * @return 当前的配置文件的值 + */ + public static String getRequiredProperty(String key) { + return applicationContext.getEnvironment().getRequiredProperty(key); + } + + @Override + public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { + SpringUtils.beanFactory = beanFactory; + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + SpringUtils.applicationContext = applicationContext; + } +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..1e8bec8 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,64 @@ +# 数据源配置 +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + # 主库数据源 + master: + driverClassName: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://39.101.188.84:3307/yk_map?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: root + password: Admin123@ + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + driverClassName: org.postgresql.Driver + enabled: true + url: jdbc:postgresql://39.101.188.84:5432/yk_map + username: postgres + password: adminadmin + # 配置检测连接是否有效 + validationQuery: SELECT 1 + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置连接超时时间 + connectTimeout: 30000 + # 配置网络超时时间 + socketTimeout: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true \ No newline at end of file diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml new file mode 100644 index 0000000..4996af6 --- /dev/null +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,64 @@ +# 数据源配置 +spring: + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + # 主库数据源 + master: + driverClassName: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://192.168.0.177:3306/finance_security?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + username: readuser + password: Ctsy@1234 + # 从库数据源 + slave: + # 从数据源开关/默认关闭 + driverClassName: org.postgresql.Driver + enabled: true + url: jdbc:postgresql://192.168.0.84:5432/ctsy_data + username: szctsy + password: 1hblsqt@!Wingconn# + # 配置检测连接是否有效 + validationQuery: SELECT 1 + # 初始连接数 + initialSize: 5 + # 最小连接池数量 + minIdle: 10 + # 最大连接池数量 + maxActive: 20 + # 配置获取连接等待超时的时间 + maxWait: 60000 + # 配置连接超时时间 + connectTimeout: 30000 + # 配置网络超时时间 + socketTimeout: 60000 + # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 + timeBetweenEvictionRunsMillis: 60000 + # 配置一个连接在池中最小生存的时间,单位是毫秒 + minEvictableIdleTimeMillis: 300000 + # 配置一个连接在池中最大生存的时间,单位是毫秒 + maxEvictableIdleTimeMillis: 900000 + # 配置检测连接是否有效 + validationQuery: SELECT 1 FROM DUAL + testWhileIdle: true + testOnBorrow: false + testOnReturn: false + webStatFilter: + enabled: true + statViewServlet: + enabled: true + # 设置白名单,不填则允许所有访问 + allow: + url-pattern: /druid/* + # 控制台管理用户名和密码 + login-username: ruoyi + login-password: 123456 + filter: + stat: + enabled: true + # 慢SQL记录 + log-slow-sql: true + slow-sql-millis: 1000 + merge-sql: true + wall: + config: + multi-statement-allow: true \ No newline at end of file diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..1ab14a2 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,90 @@ +# 开发环境配置 +server: + # 服务器的HTTP端口,默认为8080 + port: 9066 + servlet: + # 应用的访问路径 + context-path: / + tomcat: + # tomcat的URI编码 + uri-encoding: UTF-8 + # 连接数满后的排队数,默认为100 + accept-count: 1000 + threads: + # tomcat最大线程数,默认为200 + max: 800 + # Tomcat启动初始化的线程数,默认值10 + min-spare: 100 + +# 日志配置 +logging: + level: + com.ykMap: debug + org.springframework: warn + +# Spring配置 +spring: + profiles: + active: prod + # 文件上传 + servlet: + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB + # 服务模块 + devtools: + restart: + # 热部署开关 + enabled: false + # redis 配置 + redis: + # 地址 + host: localhost + # 端口,默认为6379 + port: 6379 + # 数据库索引 + database: 0 + # 密码 + password: + # 连接超时时间 + timeout: 10s + lettuce: + pool: + # 连接池中的最小空闲连接 + min-idle: 0 + # 连接池中的最大空闲连接 + max-idle: 8 + # 连接池的最大数据库连接数 + max-active: 8 + # #连接池最大阻塞等待时间(使用负值表示没有限制) + max-wait: -1ms + +# mybatis-plus配置 +mybatis-plus: + # 搜索指定包别名 + typeAliasesPackage: com.ykMap.**.domain,com.ykMap.**.entity, + # 配置mapper的扫描,找到所有的mapper.xml映射文件 + mapperLocations: classpath*:mapper/**/*Mapper.xml + # 加载全局的配置文件 + configLocation: classpath:mybatis/mybatis-config.xml + +# PageHelper分页插件 +pagehelper: + helperDialect: mysql + supportMethodsArguments: true + params: count=countSql + +knife4j: + # production: true + enable: true + +# 防止XSS攻击 +xss: + # 过滤开关 + enabled: true + # 排除链接(多个用逗号分隔) + excludes: /system/notice + # 匹配链接 + urlPatterns: /system/*,/monitor/*,/tool/* diff --git a/src/main/resources/com/ykMap/mapper/LineMapper.xml b/src/main/resources/com/ykMap/mapper/LineMapper.xml new file mode 100644 index 0000000..4f06e7b --- /dev/null +++ b/src/main/resources/com/ykMap/mapper/LineMapper.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + diff --git a/src/main/resources/com/ykMap/mapper/YxlglMapper.xml b/src/main/resources/com/ykMap/mapper/YxlglMapper.xml new file mode 100644 index 0000000..d3718b7 --- /dev/null +++ b/src/main/resources/com/ykMap/mapper/YxlglMapper.xml @@ -0,0 +1,15 @@ + + + + + diff --git a/src/main/resources/com/ykMap/mapper/YywtzMapper.xml b/src/main/resources/com/ykMap/mapper/YywtzMapper.xml new file mode 100644 index 0000000..b75bde9 --- /dev/null +++ b/src/main/resources/com/ykMap/mapper/YywtzMapper.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/src/main/resources/com/ykMap/mapper/YywzlMapper.xml b/src/main/resources/com/ykMap/mapper/YywzlMapper.xml new file mode 100644 index 0000000..7fb53a6 --- /dev/null +++ b/src/main/resources/com/ykMap/mapper/YywzlMapper.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..f1bcbc8 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + ${log.pattern} + + + + + + ${log.path}/sys-info.log + + + + ${log.path}/sys-info.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + INFO + + ACCEPT + + DENY + + + + + ${log.path}/sys-error.log + + + + ${log.path}/sys-error.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + ERROR + + ACCEPT + + DENY + + + + + + ${log.path}/sys-user.log + + + ${log.path}/sys-user.%d{yyyy-MM-dd}.log + + 60 + + + ${log.pattern} + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mybatis/mybatis-config.xml b/src/main/resources/mybatis/mybatis-config.xml new file mode 100644 index 0000000..ac47c03 --- /dev/null +++ b/src/main/resources/mybatis/mybatis-config.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + +