提交 306c8fde 作者: chenshiqiang

init

上级
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.zzsn</groupId>
<artifactId>event-analysis</artifactId>
<version>0.0.1-RELEASE</version>
<name>event-analysis</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<!--mybatis plus-->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.21</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<!-- json-->
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.25</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.83</version>
</dependency>
<!-- hutool工具类-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.3.8</version>
</dependency>
<!-- jsoup html解析 -->
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.13.1</version>
</dependency>
<!-- AutoPoi Excel工具类-->
<dependency>
<groupId>org.jeecgframework</groupId>
<artifactId>autopoi-web</artifactId>
<version>1.2.5</version>
<exclusions>
<exclusion>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- httpclient-->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.2</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
</dependency>
<!-- redis-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<!-- 华为obs-->
<!-- https://mvnrepository.com/artifact/com.huaweicloud/esdk-obs-java-bundle -->
<dependency>
<groupId>com.huaweicloud</groupId>
<artifactId>esdk-obs-java-bundle</artifactId>
<version>3.22.12</version>
</dependency>
<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>1.26.1-RELEASE</version>
</dependency>
<!-- es-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
<version>2.2.6.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>4.0.5.RELEASE</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-common</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.zwobble.mammoth</groupId>
<artifactId>mammoth</artifactId>
<version>1.5.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>${project.basedir}/lib</directory>
<targetPath>BOOT-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<repositories>
<repository>
<id>zzsn</id>
<name>zzsn Repository</name>
<url>http://114.115.159.144:8065/repository/maven-public</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</repository>
</repositories>
</project>
package com.zzsn.event;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class EventAnalysisApplication {
public static void main(String[] args) {
SpringApplication.run(EventAnalysisApplication.class, args);
}
}
package com.zzsn.event.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;
/**
* Description: 解决跨域问题
* Author: EDY
* Date: 2024/1/10
*/
@Configuration
public class CorsConfig {
@Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
config.addAllowedOrigin("*");
config.addAllowedHeader("*");
config.addAllowedMethod("*");
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}
package com.zzsn.event.config;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Description:
* Author: obcy
* Date: 2024/1/4
*/
@Configuration
public class MybatisPlusConfig {
/**
* mybatis-plus分页插件
* */
@Bean
public PaginationInterceptor paginationInterceptor() {
PaginationInterceptor paginationInterceptor = new PaginationInterceptor().setLimit(-1);
return paginationInterceptor;
}
}
package com.zzsn.event.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* redisConfig
*
* @author ShiQiangChen
* @date 2024/1/8
*/
@Configuration
public class RedisConfig {
@Bean
public RedisTemplate<String, ?> getRedisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, ?> template = new RedisTemplate<>();
template.setKeySerializer(new StringRedisSerializer());
template.setHashKeySerializer(new StringRedisSerializer());
template.setHashValueSerializer(new GenericJackson2JsonRedisSerializer());
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
template.setEnableTransactionSupport(true);
template.setConnectionFactory(factory);
return template;
}
}
\ No newline at end of file
package com.zzsn.event.config.interceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
* @Description:
* @Author: obcy
* @Date: 2024/4/5
*/
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 添加自定义拦截器,拦截所有路径
}
}
package com.zzsn.event.constant;
import java.util.Arrays;
import java.util.List;
/**
* Description:
* Author: EDY
* Date: 2023/10/9
*/
public enum DirEnum {
QYYearReport("QYYearReport/","企业年报","1"),
QYQuarterReport("QYQuarterReport/","企业季报","2"),
QYMonthReport("QYMonthReport/","企业月报","3"),
QYResearchReport("QYResearchReport/","企业研报","4"),
HYResearchReport("HYResearchReport/","行业研报","5"),
SubjectAtt("SubjectAtt/","专题上的附件","6"),
PolicyDocuments("PolicyDocuments/","政策文件附件","7"),
QYNotice("QYNotice/","企业公告","8"),
GZNotice3("GZNotice-3/","股转公告 新三版","9"),
GPSH3("GPSH-3/","挂牌审核 新三版","10"),
ZLJGCS3("ZLJGCS-3/","自律监管措施 新三版","11"),
WXH3("WXH-3/","问询函 新三版","12"),
JLCF3("JLCF-3/","纪律处分 新三版","13"),
MXYL("MXYL/","模型语料","14"),
SubjectUp("SubjectUp/","专题上传","15"),
KLBImage("KLBImage/","克虏宝企业log图片","16"),
REPORT("report/","生成的报告","17"),
REPORT_TEMPLATE("report/template/","生成的报告模板","18"),
SCIENCE_FILE("report/reportScience/","智能写作_期刊/论文/图书/研报","19"),
;
public static List<DirEnum> getAll(){
DirEnum[] values = DirEnum.values();
return Arrays.asList(values);
}
public static DirEnum getByPath(String path) {
for (DirEnum enumValue : DirEnum.values()) {
if (enumValue.getPath().equals(path)) {
return enumValue;
}
}
throw new IllegalArgumentException("No enum constant with value: " + path);
}
public static DirEnum getByDes(String des) {
for (DirEnum enumValue : DirEnum.values()) {
if (enumValue.getDes().equals(des)) {
return enumValue;
}
}
throw new IllegalArgumentException("No enum constant with value: " + des);
}
public static DirEnum getByType(String type) {
for (DirEnum enumValue : DirEnum.values()) {
if (enumValue.getType().equals(type)) {
return enumValue;
}
}
throw new IllegalArgumentException("No enum constant with value: " + type);
}
/**路径名称*/
private final String path;
/**路径描述*/
private final String des;
/**路径描述*/
private final String type;
public String getType() {
return type;
}
public String getPath() {
return path;
}
public String getDes() {
return des;
}
DirEnum(String path, String des , String type) {
this.path = path;
this.des = des;
this.type = type;
}
}
package com.zzsn.event.constant;
import java.time.Duration;
/**
* @author: zhangcx
* @date: 2019/8/7 17:23
*/
public class DocumentConstants {
public static final String HTTP_SCHEME = "http";
/**
* 支持的文档类型
*/
public static final String[] FILE_TYPE_SUPPORT_VIEW = {"doc", "docx", "xls", "xlsx", "ppt", "pptx", "txt", "pdf"};
/**
* 不支持编辑的类型
*/
public static final String[] FILE_TYPE_UNSUPPORT_EDIT = {"pdf"};
/**
* 文档文件下载接口地址
*/
public static final String OFFICE_API_DOC_FILE = "%s/api/file/download%s";
/**
* 文档信息获取地址
*/
public static final String OFFICE_API_DOC = "%s/api/doc/%s";
/**
* 编辑回调地址
*/
public static final String OFFICE_API_CALLBACK = "%s/api/file/callback";
/**
* 预览地址
*/
public static final String OFFICE_VIEWER = "%s/viewer/%s";
/**
* 编辑地址
*/
public static final String OFFICE_EDITOR = "%s/editor/%s";
/**
* 文档redis缓存前缀 格式化
*/
public static final String DOCUMENT_REDIS_KEY_PREFIX_FORMAT = "onlyoffice:document:%s";
/**
* 缓存过期时间: 1天
*/
public static final Duration CACHE_DURATION = Duration.ofDays(1);
public static final String HASH_KEY = "lezhixing";
}
/**
*
* (c) Copyright Ascensio System SIA 2023
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.zzsn.event.constant;
public enum DocumentType {
word,
cell,
slide
}
package com.zzsn.event.constant;
import org.apache.commons.lang3.StringUtils;
import java.util.Arrays;
/**
* 错误码枚举
* 约定 code 为 0 表示操作成功,
* 1 或 2 等正数表示软件错误,
* -1, -2 等负数表示系统错误.
* @author: zhangcx
* @date: 2019/8/12 13:18
*/
public enum ErrorCodeEnum {
SUCCESS("0", "success"),
DOC_FILE_NOT_EXISTS("1001", "目标文档不存在"),
DOC_FILE_EMPTY("1002", "目标文档是目录或空文件"),
DOC_FILE_UNREADABLE("1003", "目标文档不可读"),
DOC_FILE_OVERSIZE("1004", "目标文档大小超过限制"),
DOC_FILE_TYPE_UNSUPPORTED("1005", "目标文档格式不正确"),
DOC_FILE_MD5_ERROR("1006", "目标文档md5校验失败"),
DOC_FILE_MIME_ERROR("1007", "目标文档MIME检查失败"),
DOC_FILE_NO_EXTENSION("1008", "文件路径不包含扩展名"),
DOC_FILE_EXTENSION_NOT_MATCH("1009", "文件路径和名称后缀不匹配"),
DOC_FILE_KEY_ERROR("1010", "目标文档key计算失败"),
DOC_CACHE_ERROR("1101", "文档信息缓存失败"),
DOC_CACHE_NOT_EXISTS("1102", "从缓存中获取文档信息失败"),
UNSUPPORTED_REQUEST_METHOD("1201", "不支持的请求类型"),
SYSTEM_UNKNOWN_ERROR("-1", "系统繁忙,请稍后再试...");
private String code;
private String msg;
ErrorCodeEnum(String code, String msg) {
this.code = code;
this.msg = msg;
}
public String getCode() {
return code;
}
public String getMsg() {
return msg;
}
@Override
public String toString() {
return "ErrorCodeEnum{" +
"code='" + code + '\'' +
", msg='" + msg + '\'' +
'}';
}
public boolean isSuccessful() {
return this.code == ErrorCodeEnum.SUCCESS.getCode();
}
public boolean isFailed() {
return !isSuccessful();
}
public static void main(String[] args) {
System.out.println("| 代码 | 描述 |");
System.out.println("| ---- | ---- |");
Arrays.stream(ErrorCodeEnum.values()).forEach((ce) -> {
System.out.println("| " + StringUtils.rightPad(ce.getCode(), 4) + " | " + ce.getMsg() + " |");
});
}
}
package com.zzsn.event.enums;
/**
* Description:
*
* @author: EDY
* @since: 2024/1/9
*/
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Description:
* Author: EDY
* Date: 2023/10/9
*/
public enum KnowTypeEnum {
Notice("公告","1"),
LeadershipSpeech("领导讲话","2"),
YearReport("年报","3"),
JournalArticle("期刊论文","3"),
Book("图书","4"),
ResearchReport("研报","5"),
Policies("政策法规","6"),
Message("资讯","7"),
;
public static List<KnowTypeEnum> getAll(){
KnowTypeEnum[] values = KnowTypeEnum.values();
return Arrays.asList(values);
}
public static Map<String,String> getAllAsMap(){
Map<String , String> res = new HashMap<>();
KnowTypeEnum[] values = KnowTypeEnum.values();
for (KnowTypeEnum value : values) {
res.put(value.des,value.type);
}
return res;
}
public static KnowTypeEnum getByDes(String des) {
for (KnowTypeEnum enumValue : KnowTypeEnum.values()) {
if (enumValue.getDes().equals(des)) {
return enumValue;
}
}
throw new IllegalArgumentException("No enum constant with value: " + des);
}
public static KnowTypeEnum getByType(String type) {
for (KnowTypeEnum enumValue : KnowTypeEnum.values()) {
if (enumValue.getType().equals(type)) {
return enumValue;
}
}
throw new IllegalArgumentException("No enum constant with value: " + type);
}
/**路径描述*/
private final String des;
/**路径描述*/
private final String type;
public String getType() {
return type;
}
public String getDes() {
return des;
}
KnowTypeEnum( String des ,String type) {
this.des = des;
this.type = type;
}
}
package com.zzsn.event.util;
import lombok.SneakyThrows;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.support.atomic.RedisAtomicLong;
import org.springframework.stereotype.Component;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* @author lkg
* @description: 按规则生成唯一值
* @date 2021/6/3 18:29
*/
@Component
public class CodeGenerateUtil {
@Autowired
private StringRedisTemplate stringRedisTemplate;
/**
* 生成编码
* @param prefix 前缀
* @return java.lang.String
*/
public String geneCodeNo(String prefix){
return getCode(prefix);
}
/**
* 生成id
* @param prefix 前缀
* @return java.lang.String
*/
public String geneIdNo(String prefix, int num){
return getId(prefix, num);
}
/**
* 生成统一社会信用代码
* @param prefix 前缀
* @return java.lang.String
*/
public String geneSocialCreditCode(String prefix){
return getCreditCode(prefix);
}
//根据规则生成code(规则:前缀+格式化日期(截取后六位)+递增值(8位数))
private String getCreditCode(String prefix) {
String redisKey = getRedisKey(prefix);
Date expireDate = getExpireDate();
//返回当前redis中的key的最大值
long seq = generate(stringRedisTemplate, redisKey, expireDate);
//获取当天的日期,格式为yyyyMMdd
String date = new SimpleDateFormat("yyyyMMdd").format(expireDate);
//生成八位的序列号,如果seq不够四位,seq前面补0,
//如果seq位数超过了八位,那么无需补0直接返回当前的seq
String sequence = StringUtils.leftPad(Long.toString(seq), 8, "0");
return prefix + date.substring(2) + sequence;
}
//生成老企业库id
public long getEnterpriseId(String prefix) {
String redisKey = getRedisKey(prefix);
Date expireDate = getExpireDate();
//返回当前redis中的key的最大值
long seq = generate(stringRedisTemplate, redisKey, expireDate);
//获取当天的日期,格式为yyyyMMdd
String date = new SimpleDateFormat("yyyyMMdd").format(expireDate);
//生成八位的序列号,如果seq不够四位,seq前面补0,
//如果seq位数超过了八位,那么无需补0直接返回当前的seq
String sequence = StringUtils.leftPad(Long.toString(seq), 5, "0");
return Long.parseLong(date.substring(2) + sequence);
}
//根据规则生成编码(规则:前缀+格式化日期+递增值(4位数))
private String getCode(String prefix){
String redisKey = getRedisKey(prefix);
Date expireDate = getExpireDate();
//返回当前redis中的key的最大值
long seq = generate(stringRedisTemplate, redisKey, expireDate);
//获取当天的日期,格式为yyyyMMdd
String date = new SimpleDateFormat("yyyyMMdd").format(expireDate);
//生成四位的序列号,如果seq不够四位,seq前面补0,
//如果seq位数超过了四位,那么无需补0直接返回当前的seq
String sequence = StringUtils.leftPad(Long.toString(seq), 4, "0");
//返回编码
return prefix + "-" + date + "-" + sequence;
}
//根据规则生成id(规则:格式化日期(截取后六位)+递增值(8位数))
private String getId(String prefix, int num){
String redisKey = getRedisKey(prefix);
Date expireDate = getExpireDate();
//返回当前redis中的key的最大值
long seq = generate(stringRedisTemplate, redisKey, expireDate);
//获取当天的日期,格式为yyyyMMdd
String date = new SimpleDateFormat("yyyyMMdd").format(expireDate);
//生成八位的序列号,如果seq不够四位,seq前面补0,
//如果seq位数超过了八位,那么无需补0直接返回当前的seq
String sequence = StringUtils.leftPad(Long.toString(seq), num, "0");
return date.substring(2)+sequence;
}
//获取redis--key
@SneakyThrows
private String getRedisKey(String prefix){
if (StringUtils.isEmpty(prefix)){
throw new Exception("前缀不能为空!");
}
//用作存放redis中的key前缀
String PREFIX_KEY = "CodeGenerateUtil::";
return PREFIX_KEY + prefix;
}
//获取缓存过期时间点
private Date getExpireDate(){
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
//设置过期时间,这里设置为当天的23:59:59
return calendar.getTime();
}
//获取redis缓存
private long generate(StringRedisTemplate stringRedisTemplate,String key,Date expireTime) {
//RedisAtomicLong为原子类,根据传入的key和redis链接工厂创建原子类
RedisAtomicLong counter = new RedisAtomicLong(key,stringRedisTemplate.getConnectionFactory());
//设置过期时间
counter.expireAt(expireTime);
//返回redis中key的值
return counter.incrementAndGet();
}
}
package com.zzsn.event.util;
import java.text.SimpleDateFormat;
import java.util.*;
public class DateUtil {
static SimpleDateFormat format;
public static String dateToString(Date date) {
format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return format.format(date);
}
public static String getStringDate(Date date){
String format = "yyyy-MM-dd";
return DateUtil.format(date, format);
}
public static String format(Date d, String format)
{
if (d == null)
return "";
SimpleDateFormat myFormatter = new SimpleDateFormat(format);
myFormatter.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
return myFormatter.format(d);
}
/**
* 获取每天的开始时间 00:00:00:00
*
* @param date
* @return
*/
public static Date getStartTime(Date date) {
Calendar dateStart = Calendar.getInstance();
dateStart.setTime(date);
dateStart.set(Calendar.HOUR_OF_DAY, 0);
dateStart.set(Calendar.MINUTE, 0);
dateStart.set(Calendar.SECOND, 0);
return dateStart.getTime();
}
/**
* 获取每天的结束时间 23:59:59:999
*
* @param date
* @return
*/
public static Date getEndTime(Date date) {
Calendar dateEnd = Calendar.getInstance();
dateEnd.setTime(date);
dateEnd.set(Calendar.HOUR_OF_DAY, 23);
dateEnd.set(Calendar.MINUTE, 59);
dateEnd.set(Calendar.SECOND, 59);
return dateEnd.getTime();
}
/**
* 获取当前年份
* @return
*/
public static String getSysYear() {
Calendar date = Calendar.getInstance();
return String.valueOf(date.get(Calendar.YEAR));
}
/**
* 获取当前时间所在日
*/
public static Integer getDay(String dateStr) {
Calendar instance = Calendar.getInstance();
Date date = stringToDate(dateStr, "yyyy-MM-dd");
instance.setTime(date);
return instance.get(Calendar.DAY_OF_MONTH);
}
/**
* 获取前一小时的时间
* @param date 时间
*/
public static Date beforeOneHour(Date date){
Calendar instance = Calendar.getInstance();
instance.setTime(date);
instance.add(Calendar.HOUR_OF_DAY,-1);
return instance.getTime();
}
public static Date stringToDate(String date,String formatStr) {
Date parse = null;
format = new SimpleDateFormat(formatStr);
try {
parse = format.parse(date);
} catch (Exception e) {
e.printStackTrace();
}
return parse;
}
public static List<String> betweenDate(String startDate,String endDate) {
List<String> dateList = new ArrayList<>();
String formatStr = "yyyy-MM-dd";
try {
Date dayOne = stringToDate(startDate, formatStr);
Date dayTwo = stringToDate(endDate, formatStr);
Calendar calendar = Calendar.getInstance();
calendar.setTime(dayOne);
dateList.add(startDate);
while (dayTwo.after(calendar.getTime())) {
calendar.add(Calendar.DAY_OF_MONTH,1);
dateList.add(format(calendar.getTime(),formatStr));
}
} catch (Exception e) {
e.printStackTrace();
}
return dateList;
}
/**
* 获取天前凌晨时间
* @param number 几天前
*/
public static Date getSomeDayBegin(int number) {
// 获取当前的日期和时间
Calendar calendar = Calendar.getInstance();
// 将当前的日期和时间减去一天
calendar.add(Calendar.DAY_OF_MONTH, -number);
// 将时间部分设置为凌晨时间
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
// 获取昨天凌晨时间
return new Date(String.valueOf(calendar.getTime()));
}
}
package com.zzsn.event.util;
import com.zzsn.event.constant.ErrorCodeEnum;
/**
* 文档异常封装类
* @author zhangcx
*/
public final class DocumentException extends RuntimeException {
private ErrorCodeEnum errorCode;
public DocumentException(ErrorCodeEnum errorCode) {
super(errorCode.getMsg());
this.errorCode = errorCode;
}
public DocumentException(ErrorCodeEnum errorCode, Throwable t) {
super(errorCode.getMsg(), t);
this.errorCode = errorCode;
}
public ErrorCodeEnum getErrorCode() {
return errorCode;
}
}
package com.zzsn.event.util;
/**
* Es对日期类型处理
* @author kongliufeng
* @create 2020-08-07 14:05
*/
public class EsDateUtil {
/**
* yyyy-MM-dd HH:mm:ss ->yyyy-MM-ddTHH:mm:ss
* @param data
* @return
*/
public static String esFieldDateFormat(String data) {
if (data == null)
return data;
if (data.length() == 19) {//标准yyyy-MM-dd HH:mm:ss
return data.replace(" ", "T");
} else if (data.length() == 10) {//yyyy-MM-dd
return data;
}
return null;
}
/**
* yyyy-MM-dd HH:mm:ss ->yyyy-MM-ddTHH:mm:ss
* @param data
* @return
*/
public static String esFieldDateMapping(String data) {
if (data == null)
return data;
if (data.length() == 19) {//标准yyyy-MM-dd HH:mm:ss
return data.replace("T", " ");
} else if (data.length() == 10) {//yyyy-MM-dd
return data;
}
return null;
}
}
package com.zzsn.event.util;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
/**
* 在线程的run方法中使用注解@autoware注入的bean,会报空指针异常,原因是因为线程中为了线程安全,防注入。
* 获取bean实例的工具类组件
*/
@Component
public class GetBeanUtil implements ApplicationContextAware {
//Spring应用上下文环境
private static ApplicationContext applicationContext;
/**
* 实现ApplicationContextAware接口的回调方法,设置上下文环境
*/
public void setApplicationContext(ApplicationContext context) {
GetBeanUtil.applicationContext = context;
}
/**
* 获取对象 这里重写了bean方法,起主要作用
*/
public static Object getBean(String name) {
return applicationContext.getBean(name);
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
}
package com.zzsn.event.util;
import java.security.MessageDigest;
public class MD5Util {
private static String byteArrayToHexString(byte[] b) {
StringBuilder resultSb = new StringBuilder();
for (byte value : b) {
resultSb.append(byteToHexString(value));
}
return resultSb.toString();
}
private static String byteToHexString(byte b) {
int n = b;
if (n < 0) {
n += 256;
}
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
}
public static String MD5Encode(String origin, String charsetName) {
String resultString = null;
try {
resultString = origin;
MessageDigest md = MessageDigest.getInstance("MD5");
if (charsetName == null || "".equals(charsetName)) {
resultString = byteArrayToHexString(md.digest(resultString.getBytes()));
} else {
resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetName)));
}
} catch (Exception e) {
e.printStackTrace();
}
return resultString;
}
private static final String[] hexDigits = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
}
//package com.zzsn.knowbase.util;
//
//
//import com.github.tobato.fastdfs.proto.storage.DownloadByteArray;
//import com.obs.services.ObsClient;
//import com.obs.services.model.*;
////import org.apache.commons.lang.StringUtils;
//import org.apache.commons.lang3.StringUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Component;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.*;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * Description: obs桶文件操作
// * Author: EDY
// * Date: 2023/10/9
// */
//@Component
//public class ObsUtil {
//
// @Autowired
// ObsClient obsClient;
// /**桶名称*/
// private String bucketName = "zzsn";
//
// /**判断桶是否存在*/
// public Boolean existsBucket(String bucket){
// return obsClient.headBucket(bucket);
// }
// public Boolean existsBucket(){
// return obsClient.headBucket(bucketName);
// }
//
// /**
// * 创建文件夹本质上来说是创建了一个大小为0且对象名以“/”结尾的对象。
// * 多级文件夹创建最后一级即可,比如src1/src2/src3/,创建src1/src2/src3/即可,无需创建src1/、src1/src2/。
// * keySuffixWithSlash为文件夹名称,以 / 结尾
// * */
// public boolean mkdir(String keySuffixWithSlash){
// PutObjectResult putObjectResult = obsClient.putObject(bucketName, keySuffixWithSlash, new ByteArrayInputStream(new byte[0]));
// if (putObjectResult.getStatusCode()==200) {
// return true;
// }else {
// return false;
// }
// }
//
// /**查询桶内文件夹下所有文件
// * folderPrefix 为文件夹名称,以 / 结尾
// * */
// public List<ObsObject> getPathFileList(String folderPrefix){
// List<ObsObject> res = new ArrayList<>();
// ListObjectsRequest request = new ListObjectsRequest(bucketName);
// request.setPrefix(folderPrefix);
// ObjectListing result = obsClient.listObjects(request);
// for (ObsObject obsObject : result.getObjects()) {
// res.add(obsObject);
// }
// return res;
// }
// /**
// * 获取文件夹下的文件数量
// * */
// public Integer getCount (String folderPrefix){
// ListObjectsRequest listObjectsRequest = new ListObjectsRequest(bucketName);
// listObjectsRequest.setPrefix(folderPrefix);
// listObjectsRequest.setMaxKeys(1000);
// int fileCount = 0;
//
// ObjectListing objectListing;
//
// do {
// objectListing = obsClient.listObjects(listObjectsRequest);
//
// List<S3Object> objectSummaries = objectListing.getObjectSummaries();
// fileCount += objectSummaries.size();
//
// String nextMarker = objectListing.getNextMarker();
// listObjectsRequest.setMarker(nextMarker);
// } while (objectListing.isTruncated());
//
// return fileCount;
// }
//
// /**删除桶内文件
// * objectKey为文件路径,起始为桶内某文件夹,或者直接为桶内文件
// * */
// public boolean delFile (String objectKey){
// DeleteObjectResult deleteObjectResult = obsClient.deleteObject(bucketName, objectKey);
// if (deleteObjectResult.getStatusCode()==200) {
// return true;
// }else {
// return false;
// }
// }
//
// /**文件上传
// * objectKey为文件路径
// * */
// public PutObjectResult uploadFile(String objectKey,byte[] bytes){
// PutObjectResult putObjectResult = obsClient.putObject(bucketName, objectKey, new ByteArrayInputStream(bytes));
// return putObjectResult;
// }
// /**文件上传
// * objectKey为文件路径
// * */
// public PutObjectResult uploadFile(String objectKey ,InputStream inputStream){
// PutObjectResult putObjectResult = obsClient.putObject(bucketName, objectKey, inputStream);
// return putObjectResult;
// }
// /**
// * 获取文件流
// *
// * */
// public InputStream getObjectStream(String objectKey){
// ObsObject obsObject = obsClient.getObject(bucketName, objectKey);
// return obsObject.getObjectContent();
// }
// /**
// * 获取文件流
// *
// * */
// public byte[] getObjectByte(String objectKey){
// ObsObject obsObject = obsClient.getObject(bucketName, objectKey);
// // 获取文件的输入流
// InputStream objectContent = obsObject.getObjectContent();
//
// // 将输入流转换为byte[]
// ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
// byte[] buffer = new byte[4096];
// int bytesRead;
// while (true) {
// try {
// if (!((bytesRead = objectContent.read(buffer)) != -1)) {
// break;
// }
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
// byteArrayOutputStream.write(buffer, 0, bytesRead);
// }
// byte[] fileBytes = byteArrayOutputStream.toByteArray();
// return fileBytes;
// }
//
// /*
// * 文件预览
// * @param fileName
// */
// public boolean previewImg(HttpServletRequest request, HttpServletResponse response) throws IOException {
// String filePath = request.getParameter("attachmentPath");
// String group = request.getParameter("group");
// if (StringUtils.isBlank(filePath)) {
// return false;
// }
// DownloadByteArray downloadByteArray = new DownloadByteArray();
// byte[] content = getObjectByte(filePath);
// if (content == null || content.length == 0) {
// return false;
// }
//
// response.addHeader("Pragma", "No-cache");
// response.addHeader("Cache-Control", "no-store,No-cache");
// response.setCharacterEncoding("UTF-8");
//// response.setContentType("application/json;charset=utf-8");
// String s = filePath.split("/")[filePath.split("/").length - 1];
// String mimeType = request.getServletContext().getMimeType(s);
// System.out.println("文件类型为" + mimeType);
// response.setContentType(request.getServletContext().getMimeType(s) + ";charset=utf-8");
// OutputStream out = response.getOutputStream();
// BufferedOutputStream bos = new BufferedOutputStream(out);
// try {
// bos.write(content, 0, content.length);
// bos.flush();
// } catch (Exception e) {
// e.printStackTrace();
// } finally {
// if (bos != null) {
// bos.close();
// }
// if (out != null) {
// out.close();
// }
// }
// return true;
// }
//
//}
/**
*
* (c) Copyright Ascensio System SIA 2023
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.zzsn.event.util.file;
import com.zzsn.event.constant.Constants;
import com.zzsn.event.constant.DocumentType;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Component
@Qualifier("default")
public class DefaultFileUtility implements FileUtility {
@Value("${filesize-max}")
private String filesizeMax;
@Value("${files.docservice.viewed-docs}")
private String docserviceViewedDocs;
@Value("${files.docservice.edited-docs}")
private String docserviceEditedDocs;
@Value("${files.docservice.convert-docs}")
private String docserviceConvertDocs;
@Value("${files.docservice.fillforms-docs}")
private String docserviceFillDocs;
// document extensions
private List<String> extsDocument = Arrays.asList(
".doc", ".docx", ".docm",
".dot", ".dotx", ".dotm",
".odt", ".fodt", ".ott", ".rtf", ".txt",
".html", ".htm", ".mht", ".xml",
".pdf", ".djvu", ".fb2", ".epub", ".xps", ".oform");
// spreadsheet extensions
private List<String> extsSpreadsheet = Arrays.asList(
".xls", ".xlsx", ".xlsm", ".xlsb",
".xlt", ".xltx", ".xltm",
".ods", ".fods", ".ots", ".csv");
// presentation extensions
private List<String> extsPresentation = Arrays.asList(
".pps", ".ppsx", ".ppsm",
".ppt", ".pptx", ".pptm",
".pot", ".potx", ".potm",
".odp", ".fodp", ".otp");
// get the document type
public DocumentType getDocumentType(final String fileName) {
String ext = getFileExtension(fileName).toLowerCase(); // get file extension from its name
// word type for document extensions
if (extsDocument.contains(ext)) {
return DocumentType.word;
}
// cell type for spreadsheet extensions
if (extsSpreadsheet.contains(ext)) {
return DocumentType.cell;
}
// slide type for presentation extensions
if (extsPresentation.contains(ext)) {
return DocumentType.slide;
}
// default file type is word
return DocumentType.word;
}
// get file name from its URL
public String getFileName(final String url) {
if (url == null) {
return "";
}
// get file name from the last part of URL
String fileName = url.substring(url.lastIndexOf('/') + 1);
fileName = fileName.split("\\?")[0];
return fileName;
}
// get file name without extension
public String getFileNameWithoutExtension(final String url) {
String fileName = getFileName(url);
if (fileName == null) {
return null;
}
String fileNameWithoutExt = fileName.substring(0, fileName.lastIndexOf('.'));
return fileNameWithoutExt;
}
// get file extension from URL
public String getFileExtension(final String url) {
String fileName = getFileName(url);
if (fileName == null) {
return null;
}
String fileExt = fileName.substring(fileName.lastIndexOf("."));
return fileExt.toLowerCase();
}
//get file type from URL
public String getFileType(final String url) {
String fileName = getFileName(url);
if (fileName == null) {
return null;
}
String fileExt = fileName.substring(fileName.lastIndexOf("."));
return fileExt.toLowerCase();
}
// get an editor internal extension
public String getInternalExtension(final DocumentType type) {
// .docx for word file type
if (type.equals(DocumentType.word)) {
return ".docx";
}
// .xlsx for cell file type
if (type.equals(DocumentType.cell)) {
return ".xlsx";
}
// .pptx for slide file type
if (type.equals(DocumentType.slide)) {
return ".pptx";
}
// the default file type is .docx
return ".docx";
}
public List<String> getFillExts() {
return Arrays.asList(docserviceFillDocs.split("\\|"));
}
// get file extensions that can be viewed
public List<String> getViewedExts() {
return Arrays.asList(docserviceViewedDocs.split("\\|"));
}
// get file extensions that can be edited
public List<String> getEditedExts() {
return Arrays.asList(docserviceEditedDocs.split("\\|"));
}
// get file extensions that can be converted
public List<String> getConvertExts() {
return Arrays.asList(docserviceConvertDocs.split("\\|"));
}
// get all the supported file extensions
public List<String> getFileExts() {
List<String> res = new ArrayList<>();
res.addAll(getViewedExts());
res.addAll(getEditedExts());
res.addAll(getConvertExts());
res.addAll(getFillExts());
return res;
}
// generate the file path from file directory and name
public Path generateFilepath(final String directory, final String fullFileName) {
String fileName = getFileNameWithoutExtension(fullFileName); // get file name without extension
String fileExtension = getFileExtension(fullFileName); // get file extension
Path path = Paths.get(directory + fullFileName); // get the path to the files with the specified name
for (int i = 1; Files.exists(path); i++) { // run through all the files with the specified name
// get a name of each file without extension and add an index to it
fileName = getFileNameWithoutExtension(fullFileName) + "(" + i + ")";
// create a new path for this file with the correct name and extension
path = Paths.get(directory + fileName + fileExtension);
}
path = Paths.get(directory + fileName + fileExtension);
return path;
}
// get maximum file size
public long getMaxFileSize() {
long size = Long.parseLong(filesizeMax);
return size > 0 ? size : Constants.MAX_FILE_SIZE;
}
}
/**
*
* (c) Copyright Ascensio System SIA 2023
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.zzsn.event.util.file;
import com.zzsn.event.constant.DocumentType;
import java.nio.file.Path;
import java.util.List;
// specify the file utility functions
public interface FileUtility {
DocumentType getDocumentType(String fileName); // get the document type
String getFileName(String url); // get file name from its URL
String getFileNameWithoutExtension(String url); // get file name without extension
String getFileExtension(String url); // get file extension from URL
String getFileType(String url); // get file type from URL
String getInternalExtension(DocumentType type); // get an editor internal extension
List<String> getFileExts(); // get all the supported file extensions
List<String> getFillExts(); // get file extensions that can be filled
List<String> getViewedExts(); // get file extensions that can be viewed
List<String> getEditedExts(); // get file extensions that can be edited
List<String> getConvertExts(); // get file extensions that can be converted
Path generateFilepath(String directory, String fullFileName); /* generate the file path
from file directory and name */
long getMaxFileSize(); // get maximum file size
}
package com.zzsn.event.util.file;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* Md5 工具类
* need commons-codec-1.6.jar +
* @author zhangcx
* @date 2019-7-23
*/
@Slf4j
public class Md5Utils {
private static MessageDigest MD5 = null;
static {
try {
MD5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException ne) {
ne.printStackTrace();
}
}
public static String getFileMd5(String filePath) {
if (StringUtils.isBlank(filePath)) {
return null;
}
return getFileMd5(new File(filePath));
}
/**
* 对一个文件获取md5值
*/
public static String getFileMd5(File file) {
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(file);
byte[] buffer = new byte[8192];
int length;
while ((length = fileInputStream.read(buffer)) != -1) {
MD5.update(buffer, 0, length);
}
return new String(Hex.encodeHex(MD5.digest()));
} catch (IOException e) {
log.error("$$$ 获取文件md5失败!", e);
return null;
} finally {
try {
if (fileInputStream != null) {
fileInputStream.close();
}
} catch (IOException e) {
log.error("关闭文件流出错!", e);
}
}
}
/**
* 计算字符串的md5值
* @param target 字符串
* @return md5 value
*/
public static String md5(final String target) {
return DigestUtils.md5Hex(target);
}
}
server:
port: 9088
spring:
servlet:
multipart:
max-request-size: 1024MB
max-file-size: 100MB
datasource:
url: jdbc:mysql://114.116.44.11:3306/knowledge?useUnicode=true&characterEncoding=utf-8&AllowPublicKeyRetrieval=True&serverTimezone=Asia/Shanghai&autoReconnect=true&rewriteBatchedStatements=true
username: ciglobal
password: qwer@9988&zzsn
elasticsearch:
rest:
uris: ["114.116.90.53:9200"]
username: elastic
password: elastic
cloud:
stream:
kafka:
binder:
brokers: 114.115.159.144:9092
zkNodes: 114.115.159.144:2181
requiredAcks: 1
redis:
database: 0
host: 114.116.90.53
lettuce:
pool:
max-active: 8 #最大连接数据库连接数,设 0 为没有限制
max-idle: 8 #最大等待连接中的数量,设 0 为没有限制
max-wait: -1ms #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
min-idle: 0 #最小等待连接中的数量,设 0 为没有限制
shutdown-timeout: 100ms
port: 6380
password: clbzzsn
thymeleaf:
prefix: classpath:/templates
mybatis-plus:
mapper-locations: classpath*:com/zzsn/knowbase/mapper/xml/*Mapper.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
map-underscore-to-camel-case: true
python:
intelligentQaUrl: http://116.63.179.212:7862/platform/chat
searchUrl: http://116.63.179.212:7862/platform/searchInfo
deleteUrl: http://114.115.172.99:10013/platform/delete
know:
thirdpartyurl:
# checkuserurl: https://clb.ciglobal.cn/clb-api/sys/checkToken
# getusersurl: https://clb.ciglobal.cn/clb-api/sys/user/thirdparty
checkuserurl: http://192.168.0.124:9988/sys/checkToken
getusersurl: http://192.168.0.124:9988/sys/user/thirdparty
document:
server:
host: http://114.116.116.241:9088
# host: http://192.168.1.71:9088
files:
storage: /storage/know/
# storage: C:/know/
docservice:
url:
site: http://114.116.116.241:80/
# site: http://192.168.1.216:80/
converter: ConvertService.ashx
command: coauthoring/CommandService.ashx
api: web-apps/apps/api/documents/api.js
preloader: web-apps/apps/api/documents/cache-scripts.html
fillforms-docs: .docx|.oform
viewed-docs: .djvu|.oxps|.pdf|.xps
edited-docs: .csv|.docm|.docx|.docxf|.dotm|.dotx|.epub|.fb2|.html|.odp|.ods|.odt|.otp|.ots|.ott|.potm|.potx|.ppsm|.ppsx|.pptm|.pptx|.rtf|.txt|.xlsm|.xlsx|.xltm|.xltx
convert-docs: .doc|.dot|.dps|.dpt|.epub|.et|.ett|.fb2|.fodp|.fods|.fodt|.htm|.html|.mht|.mhtml|.odp|.ods|.odt|.otp|.ots|.ott|.pot|.pps|.ppt|.rtf|.stw|.sxc|.sxi|.sxw|.wps|.wpt|.xls|.xlsb|.xlt|.xml
timeout: 120000
history:
postfix: -hist
filesize-max: 52428800
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false">
<!--定义日志文件的存储地址 -->
<property name="LOG_HOME" value="../clbLogs/eventAnalysis" />
<!--<property name="COLOR_PATTERN" value="%black(%contextName-) %red(%d{yyyy-MM-dd HH:mm:ss}) %green([%thread]) %highlight(%-5level) %boldMagenta( %replace(%caller{1}){'\t|Caller.{1}0|\r\n', ''})- %gray(%msg%xEx%n)" />-->
<!-- 控制台输出 -->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %highlight(%-5level) %cyan(%logger{50}:%L) - %msg%n</pattern>
</encoder>
</appender>
<!-- 按照每天生成日志文件 -->
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_HOME}/knowBase.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名 -->
<FileNamePattern>${LOG_HOME}/knowBase-%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数 -->
<MaxHistory>10</MaxHistory>
<maxFileSize>10MB</maxFileSize>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符 -->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n</pattern>
</encoder>
</appender>
<!--myibatis log configure -->
<logger name="com.apache.ibatis" level="TRACE" />
<logger name="java.sql.Connection" level="DEBUG" />
<logger name="java.sql.Statement" level="DEBUG" />
<logger name="java.sql.PreparedStatement" level="DEBUG" />
<!-- 日志输出级别 -->
<root level="INFO">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论