1.excel台账导入
2.pom文件添加 3.添加knife4j 4.添加日志
This commit is contained in:
15
pom.xml
15
pom.xml
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.1.4</version>
|
||||
<version>2.2.2.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.njcn</groupId>
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<name>冀北数据同步项目</name>
|
||||
|
||||
<description>jb_syncdata</description>
|
||||
|
||||
|
||||
@@ -156,6 +155,18 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>3.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>2.0.7</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.njcn.jbsyncdata.controller;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.njcn.jbsyncdata.pojo.DisPhotovoltaic10Excel;
|
||||
import com.njcn.jbsyncdata.pojo.DisPhotovoltaic380Excel;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2023/9/26 15:28
|
||||
*/
|
||||
@RestController
|
||||
@Slf4j
|
||||
@Api(tags = "冀北数据管理")
|
||||
@RequestMapping("/dataImport")
|
||||
@RequiredArgsConstructor
|
||||
public class DisPhotovoltaicController {
|
||||
|
||||
@ApiOperation(value = "获取10kv分布式光伏接入情况")
|
||||
@PostMapping("/import10")
|
||||
public void importTakeOrder(MultipartFile file) throws Exception {
|
||||
List<DisPhotovoltaic10Excel> list = EasyExcel.read(file.getInputStream())
|
||||
.head(DisPhotovoltaic10Excel.class)
|
||||
.headRowNumber(2)
|
||||
.sheet(2).doReadSync();
|
||||
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取380kv分布式光伏接入情况")
|
||||
@PostMapping("/import380")
|
||||
public void import380(MultipartFile file) throws Exception {
|
||||
List<DisPhotovoltaic380Excel> list = EasyExcel.read(file.getInputStream())
|
||||
.head(DisPhotovoltaic380Excel.class)
|
||||
.headRowNumber(2)
|
||||
.sheet(3).doReadSync();
|
||||
|
||||
System.out.println();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.jbsyncdata.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Api(tags = "首页模块")
|
||||
@RestController
|
||||
public class IndexController {
|
||||
|
||||
@ApiImplicitParam(name = "name",value = "姓名",required = true)
|
||||
@ApiOperation(value = "向客人问好")
|
||||
@GetMapping("/sayHi")
|
||||
public ResponseEntity<String> sayHi(@RequestParam(value = "name")String name){
|
||||
return ResponseEntity.ok("Hi:"+name);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.njcn.jbsyncdata.pojo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2023/9/26 15:28
|
||||
*/
|
||||
@Data
|
||||
public class DisPhotovoltaic10Excel implements Serializable {
|
||||
|
||||
@ExcelProperty(value = "市单位")
|
||||
private String orgName;
|
||||
|
||||
@ExcelProperty(value = "区县")
|
||||
private String county;
|
||||
|
||||
@ExcelProperty(value = "供电所")
|
||||
private String powerSupply;
|
||||
|
||||
@ExcelProperty(value = "发电客户编号")
|
||||
private String generationUserID;
|
||||
|
||||
@ExcelProperty(value = "发电客户名称")
|
||||
private String generationUserName;
|
||||
|
||||
@ExcelProperty(value = "并网时间")
|
||||
private String connectionDate;
|
||||
|
||||
@ExcelProperty(value = "电压等级")
|
||||
private String Voltage_Level;
|
||||
|
||||
@ExcelProperty(value = "发电客户地址")
|
||||
private String address;
|
||||
|
||||
@ExcelProperty(value = "发电客户类型")
|
||||
private String generationUserType;
|
||||
|
||||
@ExcelProperty(value = "消纳方式")
|
||||
private String wayConsumption;
|
||||
|
||||
@ExcelProperty(value = "合同容量")
|
||||
private BigDecimal contractCapacity;
|
||||
|
||||
@ExcelProperty(value = "行业类别")
|
||||
private String industryType;
|
||||
|
||||
@ExcelProperty(value = "台区编号")
|
||||
private String stageID;
|
||||
|
||||
@ExcelProperty(value = "台区名称")
|
||||
private String stageName;
|
||||
|
||||
@ExcelProperty(value = "PMS系统线路编号")
|
||||
private String lineID;
|
||||
|
||||
@ExcelProperty(value = "线路名称")
|
||||
private String lineName;
|
||||
|
||||
@ExcelProperty(value = "公线/专线")
|
||||
private String lineType;
|
||||
|
||||
@ExcelProperty(value = "运行状态")
|
||||
private String comFlag;
|
||||
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.njcn.jbsyncdata.pojo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2023/9/26 15:28
|
||||
*/
|
||||
@Data
|
||||
public class DisPhotovoltaic380Excel implements Serializable {
|
||||
|
||||
@ExcelProperty(value = "市单位")
|
||||
private String orgName;
|
||||
|
||||
@ExcelProperty(value = "区县")
|
||||
private String county;
|
||||
|
||||
@ExcelProperty(value = "供电所")
|
||||
private String powerSupply;
|
||||
|
||||
@ExcelProperty(value = "发电客户编号")
|
||||
private String generationUserID;
|
||||
|
||||
@ExcelProperty(value = "发电客户名称")
|
||||
private String generationUserName;
|
||||
|
||||
@ExcelProperty(value = "并网时间")
|
||||
private String connectionDate;
|
||||
|
||||
|
||||
|
||||
@ExcelProperty(value = "发电客户地址")
|
||||
private String address;
|
||||
|
||||
@ExcelProperty(value = "发电客户类型")
|
||||
private String generationUserType;
|
||||
|
||||
@ExcelProperty(value = "消纳方式")
|
||||
private String wayConsumption;
|
||||
|
||||
@ExcelProperty(value = "合同容量")
|
||||
private BigDecimal contractCapacity;
|
||||
|
||||
@ExcelProperty(value = "电压等级")
|
||||
private String Voltage_Level;
|
||||
|
||||
@ExcelProperty(value = "行业类别")
|
||||
private String industryType;
|
||||
|
||||
@ExcelProperty(value = "台区编号")
|
||||
private String stageID;
|
||||
|
||||
@ExcelProperty(value = "台区名称")
|
||||
private String stageName;
|
||||
|
||||
@ExcelProperty(value = "变压器PMSID")
|
||||
private String transformerPMSID;
|
||||
|
||||
@ExcelProperty(value = "是否已配置配变融合终端")
|
||||
private String isFusionTerminal;
|
||||
|
||||
@ExcelProperty(value = "是否安装反孤岛保护")
|
||||
private String isAntiarc;
|
||||
|
||||
@ExcelProperty(value = "所属线路PMS编号")
|
||||
private String lineID;
|
||||
|
||||
@ExcelProperty(value = "所属线路PMS名称")
|
||||
private String lineName;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.njcn.jbsyncdata.service;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2023/9/26 16:09
|
||||
*/
|
||||
public class DisPhotovoltaicService {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.njcn.jbsyncdata.service.impl;
|
||||
|
||||
import com.njcn.jbsyncdata.service.DisPhotovoltaicService;
|
||||
|
||||
/**
|
||||
* @author wr
|
||||
* @description
|
||||
* @date 2023/9/26 16:10
|
||||
*/
|
||||
public class DisPhotovoltaicServiceImpl extends DisPhotovoltaicService {
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.jbsyncdata.util;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2WebMvc
|
||||
public class Knife4jConfiguration {
|
||||
|
||||
@Bean(value = "defaultApi2")
|
||||
public Docket defaultApi2() {
|
||||
Docket docket=new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(new ApiInfoBuilder()
|
||||
.title("冀北数据同步API接口文档")
|
||||
.description("冀北数据同步API")
|
||||
.termsOfServiceUrl("http://www.xx.com/")
|
||||
.version("1.0")
|
||||
.build())
|
||||
//分组名称
|
||||
.groupName("2.X版本")
|
||||
.select()
|
||||
//这里指定Controller扫描包路径
|
||||
.apis(RequestHandlerSelectors.basePackage("com.njcn.jbsyncdata.controller"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
return docket;
|
||||
}
|
||||
}
|
||||
@@ -1 +1,64 @@
|
||||
server:
|
||||
port: 10288
|
||||
spring:
|
||||
application:
|
||||
name: jbsyncdata
|
||||
#???????
|
||||
datasource:
|
||||
druid:
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://101.132.25.239:13306/pqsinfo?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=CTT&rewriteBatchedStatements=true
|
||||
url: jdbc:mysql://192.168.1.18:13306/pqsinfo_pmscs?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||
username: root
|
||||
password: njcnpqs
|
||||
# url: jdbc:mysql://localhost:3306/info?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=CTT
|
||||
# username: root
|
||||
# password: root
|
||||
|
||||
#?????????????????????
|
||||
initial-size: 5
|
||||
min-idle: 5
|
||||
max-active: 50
|
||||
#???????????????
|
||||
max-wait: 60000
|
||||
#?????????????????????
|
||||
min-evictable-idle-time-millis: 300000
|
||||
validation-query: select 1
|
||||
test-while-idle: true
|
||||
test-on-borrow: false
|
||||
test-on-return: false
|
||||
pool-prepared-statements: true
|
||||
max-pool-prepared-statement-per-connection-size: 20
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
locale: zh_CN
|
||||
serialization:
|
||||
# ?????
|
||||
indent_output: false
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 100MB
|
||||
max-request-size: 500MB
|
||||
|
||||
|
||||
#mybatis????
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:com/njcn/**/mapping/*.xml
|
||||
configuration:
|
||||
#????
|
||||
map-underscore-to-camel-case: true
|
||||
#??sql????
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
#??????
|
||||
#log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
|
||||
global-config:
|
||||
db-config:
|
||||
#????????
|
||||
id-type: assign_uuid
|
||||
log:
|
||||
commonLevel: info
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
140
src/main/resources/logback.xml
Normal file
140
src/main/resources/logback.xml
Normal file
@@ -0,0 +1,140 @@
|
||||
<configuration scan="true" scanPeriod="20 seconds" debug="false">
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
||||
|
||||
<springProperty scope="context" name="log.projectName" source="spring.application.name" defaultValue="pqs"/>
|
||||
|
||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
||||
<conversionRule conversionWord="wex"
|
||||
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
||||
<conversionRule conversionWord="ec"
|
||||
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
||||
|
||||
|
||||
<!--日志输出格式-->
|
||||
<property name="log.homeDir" value="d:\logs"/>
|
||||
<property name="log.pattern"
|
||||
value="|-%d{yyyy-MM-dd HH:mm:ss.SSS} ${LOG_LEVEL_PATTERN:-%level} ${log.projectName} -- %t %logger{100}.%M ==> %m%n${Log_EXCEPTION_CONVERSION_WORD:-%ec}}}"/>
|
||||
<property name="log.maxHistory" value="30"/>
|
||||
|
||||
<!--客户端输出日志-->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>
|
||||
<!-- 设置日志输出格式 -->
|
||||
${log.pattern}
|
||||
</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--系统中常规的debug日志-->
|
||||
<!-- 滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 RollingFileAppender -->
|
||||
<appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>
|
||||
${log.homeDir}/${log.projectName}/debug/debug.log
|
||||
</file>
|
||||
<!-- 如果日志级别等于配置级别,过滤器会根据onMath 和 onMismatch接收或拒绝日志。 -->
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 设置过滤级别 -->
|
||||
<level>DEBUG</level>
|
||||
<!-- 用于配置符合过滤条件的操作 -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 用于配置不符合过滤条件的操作 -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责触发滚动 SizeAndTimeBasedRollingPolicy-->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!--日志输出位置 可相对、和绝对路径 -->
|
||||
<fileNamePattern>
|
||||
${log.homeDir}/${log.projectName}/debug/debug.log.%d{yyyy-MM-dd}.%i.log
|
||||
</fileNamePattern>
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
<!-- 可选节点,控制保留的归档文件的最大数量,超出数量就删除旧文件,假设设置每个月滚动,且<maxHistory>是6,
|
||||
则只保存最近6个月的文件,删除之前的旧文件。注意,删除旧文件是,那些为了归档而创建的目录也会被删除 -->
|
||||
<maxHistory>${log.maxHistory:-30}</maxHistory>
|
||||
<!--重启清理日志文件-->
|
||||
<!-- <cleanHistoryOnStart>true</cleanHistoryOnStart>-->
|
||||
<!--每个文件最多100MB,保留N天的历史记录,但最多20GB-->
|
||||
<!--<totalSizeCap>20GB</totalSizeCap>-->
|
||||
<!--日志文件最大的大小-->
|
||||
<!--<MaxFileSize>${log.maxSize}</MaxFileSize>-->
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>
|
||||
${log.pattern}
|
||||
</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!--系统中常规的info日志-->
|
||||
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>INFO</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<file>
|
||||
${log.homeDir}/${log.projectName}/info/info.log
|
||||
</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>
|
||||
${log.homeDir}/${log.projectName}/info/info.log.%d{yyyy-MM-dd}.%i.log
|
||||
</fileNamePattern>
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
<maxHistory>${log.maxHistory:-30}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>
|
||||
${log.pattern}
|
||||
</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<!--系统中常规的error日志-->
|
||||
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>
|
||||
${log.homeDir}/${log.projectName}/error/error.log
|
||||
</file>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<level>ERROR</level>
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<fileNamePattern>
|
||||
${log.homeDir}/${log.projectName}/error/error.log.%d{yyyy-MM-dd}.%i.log
|
||||
</fileNamePattern>
|
||||
<maxFileSize>10MB</maxFileSize>
|
||||
<maxHistory>${log.maxHistory:-30}</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>
|
||||
${log.pattern}
|
||||
</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="org.apache.catalina.startup.DigesterFactory" level="ERROR"/>
|
||||
<logger name="org.apache.catalina.util.LifecycleBase" level="ERROR"/>
|
||||
<logger name="org.apache.coyote.http11.Http11NioProtocol" level="WARN"/>
|
||||
|
||||
|
||||
|
||||
<logger name="com.njcn" level="INFO" additivity="false">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="DEBUG"/>
|
||||
<appender-ref ref="INFO"/>
|
||||
<appender-ref ref="ERROR"/>
|
||||
</logger>
|
||||
|
||||
<root level="INFO">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="DEBUG"/>
|
||||
<appender-ref ref="INFO"/>
|
||||
<appender-ref ref="ERROR"/>
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user