From 9eda593dd43df0067b5a09c51667fbbe23468281 Mon Sep 17 00:00:00 2001 From: leiguohui Date: Fri, 11 Oct 2024 14:34:23 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E7=AB=AF=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 ++ .idea/compiler.xml | 18 +++ .idea/encodings.xml | 8 ++ .idea/jarRepositories.xml | 25 ++++ .idea/misc.xml | 14 ++ .idea/uiDesigner.xml | 124 ++++++++++++++++++ .idea/vcs.xml | 6 + LOG_HOME_IS_UNDEFINED/error-log.html | 33 +++++ LOG_HOME_IS_UNDEFINED/hive-2024-10-11.0.log | 36 +++++ README.en.md | 36 +++++ README.md | 39 ++++++ pom.xml | 81 ++++++++++++ .../java/com/hive/SharpCoreApplication.java | 17 +++ src/main/java/com/hive/common/AjaxResult.java | 36 +++++ src/main/java/com/hive/config/CorsConfig.java | 26 ++++ .../com/hive/config/MinioConfiguration.java | 19 +++ .../java/com/hive/config/MinioProperties.java | 26 ++++ .../com/hive/controller/ExcelController.java | 33 +++++ src/main/java/com/hive/entity/XieZhuan.java | 34 +++++ .../java/com/hive/mapper/XieZhuanMapper.java | 9 ++ .../com/hive/service/XieZhuanService.java | 16 +++ .../com/hive/service/impl/XieZhuanImpl.java | 90 +++++++++++++ src/main/resources/application.yml | 46 +++++++ src/main/resources/logback-spring.xml | 77 +++++++++++ src/main/resources/mapper/XieZhuanMapper.xml | 12 ++ 25 files changed, 869 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 LOG_HOME_IS_UNDEFINED/error-log.html create mode 100644 LOG_HOME_IS_UNDEFINED/hive-2024-10-11.0.log create mode 100644 README.en.md create mode 100644 README.md create mode 100644 pom.xml create mode 100644 src/main/java/com/hive/SharpCoreApplication.java create mode 100644 src/main/java/com/hive/common/AjaxResult.java create mode 100644 src/main/java/com/hive/config/CorsConfig.java create mode 100644 src/main/java/com/hive/config/MinioConfiguration.java create mode 100644 src/main/java/com/hive/config/MinioProperties.java create mode 100644 src/main/java/com/hive/controller/ExcelController.java create mode 100644 src/main/java/com/hive/entity/XieZhuan.java create mode 100644 src/main/java/com/hive/mapper/XieZhuanMapper.java create mode 100644 src/main/java/com/hive/service/XieZhuanService.java create mode 100644 src/main/java/com/hive/service/impl/XieZhuanImpl.java create mode 100644 src/main/resources/application.yml create mode 100644 src/main/resources/logback-spring.xml create mode 100644 src/main/resources/mapper/XieZhuanMapper.xml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..dde952b --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..34d7d10 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..c7ea920 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..132404b --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LOG_HOME_IS_UNDEFINED/error-log.html b/LOG_HOME_IS_UNDEFINED/error-log.html new file mode 100644 index 0000000..43cf062 --- /dev/null +++ b/LOG_HOME_IS_UNDEFINED/error-log.html @@ -0,0 +1,33 @@ + + + + Logback Log Messages + + + + +
+

Log session start time Fri Oct 11 13:43:12 CST 2024

+ + + + + + + + + + + diff --git a/LOG_HOME_IS_UNDEFINED/hive-2024-10-11.0.log b/LOG_HOME_IS_UNDEFINED/hive-2024-10-11.0.log new file mode 100644 index 0000000..a2cfc91 --- /dev/null +++ b/LOG_HOME_IS_UNDEFINED/hive-2024-10-11.0.log @@ -0,0 +1,36 @@ +2024-10-11 13:43:12.215 [main] ERROR org.springframework.boot.SpringApplication:871 - Application run failed +java.lang.IllegalStateException: java.lang.IllegalStateException: Logback configuration error detected: +ERROR in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Could not create component [layout] of type [org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout] java.lang.ClassNotFoundException: org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout +ERROR in ch.qos.logback.core.joran.spi.Interpreter@23:26 - no applicable action for [pattern], current ElementPath is [[configuration][appender][encoder][layout][pattern]] +ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [GRPC]. Did you define it below instead of above in the configuration file? +ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details. + at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:327) + at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:281) + at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:239) + at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:216) + at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176) + at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169) + at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143) + at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131) + at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82) + at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63) + at java.util.ArrayList.forEach(ArrayList.java:1257) + at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117) + at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111) + at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62) + at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:375) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:333) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1340) + at org.springframework.boot.SpringApplication.run(SpringApplication.java:1329) + at com.coffee.SharpCoreApplication.main(SharpCoreApplication.java:15) +Caused by: java.lang.IllegalStateException: Logback configuration error detected: +ERROR in ch.qos.logback.core.joran.action.NestedComplexPropertyIA - Could not create component [layout] of type [org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout] java.lang.ClassNotFoundException: org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout +ERROR in ch.qos.logback.core.joran.spi.Interpreter@23:26 - no applicable action for [pattern], current ElementPath is [[configuration][appender][encoder][layout][pattern]] +ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - Could not find an appender named [GRPC]. Did you define it below instead of above in the configuration file? +ERROR in ch.qos.logback.core.joran.action.AppenderRefAction - See http://logback.qos.ch/codes.html#appender_order for more details. + at org.springframework.boot.logging.logback.LogbackLoggingSystem.loadConfiguration(LogbackLoggingSystem.java:179) + at org.springframework.boot.logging.AbstractLoggingSystem.initializeWithConventions(AbstractLoggingSystem.java:80) + at org.springframework.boot.logging.AbstractLoggingSystem.initialize(AbstractLoggingSystem.java:60) + at org.springframework.boot.logging.logback.LogbackLoggingSystem.initialize(LogbackLoggingSystem.java:132) + at org.springframework.boot.context.logging.LoggingApplicationListener.initializeSystem(LoggingApplicationListener.java:312) + ... 18 common frames omitted diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000..6d04143 --- /dev/null +++ b/README.en.md @@ -0,0 +1,36 @@ +# 前后端脚手架 + +#### Description +{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} + +#### Software Architecture +Software architecture description + +#### Installation + +1. xxxx +2. xxxx +3. xxxx + +#### Instructions + +1. xxxx +2. xxxx +3. xxxx + +#### Contribution + +1. Fork the repository +2. Create Feat_xxx branch +3. Commit your code +4. Create Pull Request + + +#### Gitee Feature + +1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md +2. Gitee blog [blog.gitee.com](https://blog.gitee.com) +3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) +4. The most valuable open source project [GVP](https://gitee.com/gvp) +5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) +6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md new file mode 100644 index 0000000..cf91c0e --- /dev/null +++ b/README.md @@ -0,0 +1,39 @@ +# 前后端脚手架 + +#### 介绍 +{**以下是 Gitee 平台说明,您可以替换此简介** +Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 +无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} + +#### 软件架构 +软件架构说明 + + +#### 安装教程 + +1. xxxx +2. xxxx +3. xxxx + +#### 使用说明 + +1. xxxx +2. xxxx +3. xxxx + +#### 参与贡献 + +1. Fork 本仓库 +2. 新建 Feat_xxx 分支 +3. 提交代码 +4. 新建 Pull Request + + +#### 特技 + +1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md +2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) +3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 +4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 +5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) +6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..347b725 --- /dev/null +++ b/pom.xml @@ -0,0 +1,81 @@ + + + 4.0.0 + + org.coffee + iot_hive + 1.0-SNAPSHOT + + + org.springframework.boot + spring-boot-starter-parent + 2.4.5 + + + + + 8 + 8 + UTF-8 + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-logging + + + + org.apache.logging.log4j + log4j-core + 2.17.0 + + + org.apache.logging.log4j + log4j-api + 2.17.0 + + + + com.baomidou + mybatis-plus-boot-starter + 3.1.0 + + + + io.minio + minio + 8.2.0 + + + + + com.alibaba + easyexcel + 3.1.0 + + + + + org.projectlombok + lombok + 1.18.30 + + + + mysql + mysql-connector-java + 8.0.31 + + + + diff --git a/src/main/java/com/hive/SharpCoreApplication.java b/src/main/java/com/hive/SharpCoreApplication.java new file mode 100644 index 0000000..6783490 --- /dev/null +++ b/src/main/java/com/hive/SharpCoreApplication.java @@ -0,0 +1,17 @@ +package com.hive; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; + + +@SpringBootApplication +@MapperScan("com.hive.mapper") +public class SharpCoreApplication { + + public static void main(String[] args) { + SpringApplication.run(SharpCoreApplication.class,args); + } +} diff --git a/src/main/java/com/hive/common/AjaxResult.java b/src/main/java/com/hive/common/AjaxResult.java new file mode 100644 index 0000000..af2b279 --- /dev/null +++ b/src/main/java/com/hive/common/AjaxResult.java @@ -0,0 +1,36 @@ +package com.hive.common; + +import lombok.Data; + +@Data +public class AjaxResult { + + private int code; + + private String msg; + + private T data; + + public static AjaxResult success(String msg,T data){ + AjaxResult result = new AjaxResult(); + result.setCode(200); + result.setMsg(msg); + result.setData(data); + return result; + } + + public static AjaxResult success(String msg){ + AjaxResult result = new AjaxResult(); + result.setCode(200); + result.setMsg(msg); + result.setData(null); + return result; + } + public static AjaxResult faile(String msg){ + AjaxResult result = new AjaxResult(); + result.setCode(500); + result.setMsg(msg); + result.setData(null); + return result; + } +} diff --git a/src/main/java/com/hive/config/CorsConfig.java b/src/main/java/com/hive/config/CorsConfig.java new file mode 100644 index 0000000..6a79efd --- /dev/null +++ b/src/main/java/com/hive/config/CorsConfig.java @@ -0,0 +1,26 @@ +package com.hive.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.UrlBasedCorsConfigurationSource; +import org.springframework.web.filter.CorsFilter; + +@Configuration +public class CorsConfig { + // 当前跨域请求最大有效时长。这里默认1天 + private static final long MAX_AGE = 24 * 60 * 60; + + @Bean + public CorsFilter corsFilter() { + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(); + CorsConfiguration corsConfiguration = new CorsConfiguration(); + corsConfiguration.addAllowedOrigin("*"); // 1 设置访问源地址,或者http://localhost:7060 + corsConfiguration.addAllowedHeader("*"); // 2 设置访问源请求头 + corsConfiguration.addAllowedMethod("*"); // 3 设置访问源请求方法,或设置为"GET", "POST", "DELETE", "PUT" + corsConfiguration.setMaxAge(MAX_AGE); + source.registerCorsConfiguration("/**", corsConfiguration); // 4 对接口配置跨域设置 + return new CorsFilter(source); + } +} + diff --git a/src/main/java/com/hive/config/MinioConfiguration.java b/src/main/java/com/hive/config/MinioConfiguration.java new file mode 100644 index 0000000..c56defb --- /dev/null +++ b/src/main/java/com/hive/config/MinioConfiguration.java @@ -0,0 +1,19 @@ +package com.hive.config; + +import io.minio.MinioClient; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +public class MinioConfiguration { + + @Autowired + private com.coffee.config.MinioProperties properties; + + @Bean + public MinioClient minioClient() { + return MinioClient.builder().endpoint(properties.getEndpoint()).credentials(properties.getAccessKey(), properties.getSecretKey()).build(); + } + +} diff --git a/src/main/java/com/hive/config/MinioProperties.java b/src/main/java/com/hive/config/MinioProperties.java new file mode 100644 index 0000000..e72e1c2 --- /dev/null +++ b/src/main/java/com/hive/config/MinioProperties.java @@ -0,0 +1,26 @@ +package com.hive.config; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +@Data +@Configuration +public class MinioProperties { + + @Value("${minio.endpoint}") + private String endpoint; + + @Value("${minio.access-key}") + private String accessKey; + + @Value("${minio.secret-key}") + private String secretKey; + + @Value("${minio.bucket-name}") + private String bucketName; + + @Value("${minio.secure}") + private String secure; +} diff --git a/src/main/java/com/hive/controller/ExcelController.java b/src/main/java/com/hive/controller/ExcelController.java new file mode 100644 index 0000000..57a6b51 --- /dev/null +++ b/src/main/java/com/hive/controller/ExcelController.java @@ -0,0 +1,33 @@ +package com.hive.controller; + +import com.hive.common.AjaxResult; +import com.hive.entity.XieZhuan; +import com.hive.service.XieZhuanService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.List; + +@RestController +public class ExcelController { + + @Autowired + private XieZhuanService xieZhuanService; + + @PostMapping("/importFile") + private AjaxResult importFile(@RequestParam("file") MultipartFile file) throws IOException { + + xieZhuanService.importFile(file); + return AjaxResult.success("导入成功"); + } + + @GetMapping("/getXZList") + private AjaxResult getXZList(){ + List list = xieZhuanService.getXZList(); + return AjaxResult.success("查询成功",list); + } + + +} diff --git a/src/main/java/com/hive/entity/XieZhuan.java b/src/main/java/com/hive/entity/XieZhuan.java new file mode 100644 index 0000000..5933b45 --- /dev/null +++ b/src/main/java/com/hive/entity/XieZhuan.java @@ -0,0 +1,34 @@ +package com.hive.entity; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +@Data +@TableName("xiezhuan") +public class XieZhuan { + + @TableId(type= IdType.AUTO) + private Long id; + + @ExcelProperty("省代码") + private String provinceCode; + + @ExcelProperty("省公司") + private String provinceCompanny; + + @ExcelProperty("数据日期") + private String dataDate; + + @ExcelProperty("省侧系统原因导致携转业务失败量") + private String failCount; + + @ExcelProperty("携转业务总量") + private String businessCount; + + @ExcelProperty("携转业务接口成功率") + private String successRate; + +} diff --git a/src/main/java/com/hive/mapper/XieZhuanMapper.java b/src/main/java/com/hive/mapper/XieZhuanMapper.java new file mode 100644 index 0000000..80d2542 --- /dev/null +++ b/src/main/java/com/hive/mapper/XieZhuanMapper.java @@ -0,0 +1,9 @@ +package com.hive.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.coffee.entity.XieZhuan; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface XieZhuanMapper extends BaseMapper { +} diff --git a/src/main/java/com/hive/service/XieZhuanService.java b/src/main/java/com/hive/service/XieZhuanService.java new file mode 100644 index 0000000..364d69c --- /dev/null +++ b/src/main/java/com/hive/service/XieZhuanService.java @@ -0,0 +1,16 @@ +package com.hive.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.hive.entity.XieZhuan; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.List; + +public interface XieZhuanService extends IService { + + + void importFile(MultipartFile file) throws IOException; + + List getXZList(); +} diff --git a/src/main/java/com/hive/service/impl/XieZhuanImpl.java b/src/main/java/com/hive/service/impl/XieZhuanImpl.java new file mode 100644 index 0000000..4d94bb6 --- /dev/null +++ b/src/main/java/com/hive/service/impl/XieZhuanImpl.java @@ -0,0 +1,90 @@ +package com.hive.service.impl; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.context.AnalysisContext; +import com.alibaba.excel.event.AnalysisEventListener; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.coffee.entity.XieZhuan; +import com.coffee.mapper.XieZhuanMapper; +import com.hive.service.XieZhuanService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.UUID; + +@Service +public class XieZhuanImpl extends ServiceImpl implements XieZhuanService { + + @Autowired + XieZhuanMapper xieZhuanMapper; + + private static final String UPLOAD_DIR = "C:\\Users\\Lenovo\\Desktop\\"; + + @Override + public void importFile(MultipartFile file) throws IOException { + + byte[] bytes = file.getBytes(); + Path path = Paths.get(UPLOAD_DIR); + + // 创建目录(如果不存在) + Files.createDirectories(path); + + String fileName = file.getOriginalFilename(); + + // 存储文件 + Files.write(path.resolve(fileName), bytes); + + String filePath = UPLOAD_DIR + fileName; + readExcel(filePath, XieZhuan.class, new CustomExcelListener(fileName)); + } + + @Override + public List getXZList() { + return xieZhuanMapper.selectList(null); + } + + class CustomExcelListener extends AnalysisEventListener { + + private String filename; + + public CustomExcelListener() { + } + + public CustomExcelListener(String filename) { + this.filename = filename; + } + + + @Override + public void invoke(T object, AnalysisContext context) { + + switch (filename) { + case "携转业务成功率日指标.xlsx": + xieZhuanMapper.insert((XieZhuan) object); + break; + } + System.out.println("解析数据:" + object); + } + + @Override + public void doAfterAllAnalysed(AnalysisContext context) { + System.out.println("读取" + filename + "文件并存入数据库结束======"); + } + + } + + + + + public static void readExcel(String path, Class clazz, AnalysisEventListener listener) { + EasyExcel.read(path, clazz, listener).sheet().doRead(); + } + +} diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..e47626b --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,46 @@ +spring: + datasource: + driverClassName: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/wd_jsh?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false + username: root + password: 123456 + # 文件上传 + servlet: + multipart: + # 单个文件大小 + max-file-size: 10MB + # 设置总上传的文件大小 + max-request-size: 20MB +server: + port: 8085 +# 配置MyBatis日志 +#mybatis-plus: + # configuration: + # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + # mapUnderscoreToCamelCase: true #自动转驼峰 true开启 + #type-aliases-package: com.coffee.entity + #mapper-locations: classpath*:mapper/*.xml,classpath*:mapper/**/*.xml +#mybatis plus 设置 + +mybatis-plus: + mapper-locations: classpath*:mapper/*.xml,classpath*:mapper/**/*.xml + global-config: + # 关闭MP3.0自带的banner + banner: false + db-config: + # 默认数据库表下划线命名 + table-underline: true + configuration: + # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 + #log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + # 返回类型为Map,显示null对应的字段 + call-setters-on-nulls: true + # 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl +minio: + endpoint: http://localhost:9000 # MinIO服务器的URL + access-key: minioadmin # 访问密钥 + secret-key: minioadmin # 密钥密码 + bucket-name: works # 默认的Bucket名称 + secure: false # 是否使用HTTPS(如果使用HTTPS,请设置为true) + diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..1c4a7f2 --- /dev/null +++ b/src/main/resources/logback-spring.xml @@ -0,0 +1,77 @@ + + + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}:%L) - %msg%n + + + + + + + + ${LOG_HOME}/hive-%d{yyyy-MM-dd}.%i.log + + 30 + 10MB + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n + + + + + + + + ERROR + + + + %p%d%msg%M%F{32}%L + + + ${LOG_HOME}/error-log.html + + + + + + + + ${LOG_HOME}/hive-%d{yyyy-MM-dd}.%i.html + + 30 + 10MB + + + + %p%d%msg%M%F{32}%L + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/XieZhuanMapper.xml b/src/main/resources/mapper/XieZhuanMapper.xml new file mode 100644 index 0000000..27f3800 --- /dev/null +++ b/src/main/resources/mapper/XieZhuanMapper.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + +
LevelDateMessageMethodOfCallerFileOfCallerLineOfCaller