Commit 298f6764 by xmh

初次提交

0 parents
Showing 34 changed files with 1115 additions and 0 deletions
| 模块名称 | 模块描述 |
|---------------------------------|-----------|
| fanxing-integration-jiaoguansuo | 与无锡交管所的对接 |
\ No newline at end of file
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.viontech</groupId>
<artifactId>fanxing3-integration</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>fanxing-integration-jiaoguansuo</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.viontech</groupId>
<artifactId>fanxing-commons</artifactId>
<version>3.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</exclusion>
<exclusion>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data-23</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-config</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package com.viontech.integration.jiaoguansuo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.scheduling.annotation.EnableScheduling;
/**
* .
*
* @author 谢明辉
* @date 2022/2/21
*/
@SpringBootApplication
@ComponentScan(basePackages = {"com.viontech.fanxing", "com.viontech.integration.jiaoguansuo"}, excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = com.viontech.fanxing.commons.config.RedissonConfig.class), @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = com.viontech.fanxing.commons.service.RedisService.class)})
@EnableFeignClients(basePackages = "com.viontech.integration.jiaoguansuo")
@EnableDiscoveryClient
@EnableScheduling
@Slf4j
public class App {
public static void main(String[] args) {
try {
SpringApplication.run(App.class, args);
} catch (Exception e) {
log.error("ops app start error", e);
}
}
}
package com.viontech.integration.jiaoguansuo.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.viontech.fanxing.commons.constant.TaskStatus;
import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.integration.jiaoguansuo.entity.Code;
import com.viontech.integration.jiaoguansuo.entity.Message;
import com.viontech.integration.jiaoguansuo.entity.VideoEntity;
import com.viontech.integration.jiaoguansuo.service.MainService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
* .
*
* @author 谢明辉
* @date 2022/2/21
*/
@RestController
public class MainController {
@Resource
private MainService mainService;
/**
* 1. 添加对应视频信息
* 2. 创建任务
* 3. 启动任务
*/
@PostMapping("/rmevent/addvideo")
public Message addVideoAndTask(@RequestBody VideoEntity videoEntity) {
Code code;
try {
code = Code.valueOf("C_" + videoEntity.getJclx());
} catch (Exception e) {
return Message.error("不支持的检测类型:" + videoEntity.getJclx());
}
Channel channel = mainService.addChannel(videoEntity);
Task task = null;
try {
task = mainService.addTask(videoEntity, channel,code);
// 修改scene
JSONArray scenes = JSON.parseArray(task.getScene());
JSONObject config = scenes.getJSONObject(0).getJSONObject("config");
String xml = config.getString("xml");
xml = code.modifyConfig(xml);
config.put("xml", xml);
Task temp = new Task();
temp.setScene(scenes.toString());
mainService.updateTask(task.getId(), temp);
mainService.startTask(task.getId());
} catch (Exception e) {
if (task != null) {
mainService.removeTask(task.getId());
}
mainService.removeChannel(channel.getId());
throw e;
}
return Message.success();
}
/**
* 查询运行中的任务
*
* @return
*/
@PostMapping("/rmevent/queryvideo")
public Message queryVideoAndTask() {
Task task = new Task();
task.setStatus(TaskStatus.RUNNING.val);
List<Task> tasks = mainService.getTask(task);
List<VideoEntity> videos = tasks.stream().map(x -> new VideoEntity().setDwxh(x.getDeviceUnid()).setSxjbh(x.getChannelUnid())).collect(Collectors.toList());
Message success = Message.success();
success.setVideos(videos);
return success;
}
@PostMapping("/rmevent/removevideo")
public Message removeVideoAndTask(@RequestBody VideoEntity videoEntity) {
Channel channel = new Channel();
channel.setChannelUnid(videoEntity.getSxjbh());
channel.setDeviceUnid(videoEntity.getDwxh());
List<Channel> channels = mainService.getChannels(channel);
if (channels.size() > 0) {
channel = channels.get(0);
Task task = new Task();
task.setChannelUnid(videoEntity.getSxjbh());
List<Task> tasks = mainService.getTask(task);
if (tasks.size() > 0) {
task = tasks.get(0);
mainService.removeTask(task.getId());
}
mainService.removeChannel(channel.getId());
}
return Message.success();
}
}
package com.viontech.integration.jiaoguansuo.entity;
import cn.hutool.core.util.XmlUtil;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* .
*
* @author 谢明辉
* @date 2022/2/23
*/
@SuppressWarnings("ALL")
public enum Code {
C_1003("大货车禁行","开启"),
C_1005("逆行","启用"),
C_1006("压导流带","启用算法"),
C_1007("跨线变道","启用"),
C_1009("异常停车","启用"),
C_1012("超速","启用"),
C_1013("隧道车灯","启用"),
C_1016("车辆超限","启用"),
C_1017("货车载人","启用"),
C_0001("行人上高速事件","启用"),
C_0005("拥堵检测","启用"),
C_0006("事故","启用"),
C_0007("隧道烟雾","启用"),
C_0009("路面湿滑","启用"),
C_0011("道路破损","启用"){
@Override
public String modifyConfig(String xml) {
Document document = XmlUtil.parseXml(xml);
Element element = XmlUtil.getElementByXPath("//root//功能配置//抓拍参数配置//路口电警", document);
Element zongzhi = XmlUtil.appendChild(element, "综治");
Element paramNode = XmlUtil.appendChild(zongzhi, paramName);
Element open = XmlUtil.appendChild(paramNode, openName);
XmlUtil.appendText(open, "1");
return XmlUtil.toStr(document);
}
},
C_0013("抛洒物检测","启用"),
C_0015("施工占道","启用"){
@Override
public String modifyConfig(String xml) {
Document document = XmlUtil.parseXml(xml);
Element element = XmlUtil.getElementByXPath("//root//功能配置//抓拍参数配置//路口电警", document);
Element zongzhi = XmlUtil.appendChild(element, "综治");
Element paramNode = XmlUtil.appendChild(zongzhi, paramName);
Element open = XmlUtil.appendChild(paramNode, openName);
XmlUtil.appendText(open, "1");
return XmlUtil.toStr(document);
}
};
public String paramName;
public String openName;
Code(String paramName, String openName) {
this.paramName = paramName;
this.openName = openName;
}
public String modifyConfig(String xml) {
Document document = XmlUtil.parseXml(xml);
Element element = XmlUtil.getElementByXPath("//root//功能配置//抓拍参数配置//路口电警", document);
Element paramNode = XmlUtil.appendChild(element, paramName);
Element open = XmlUtil.appendChild(paramNode, openName);
XmlUtil.appendText(open, "1");
return XmlUtil.toStr(document);
}
}
package com.viontech.integration.jiaoguansuo.entity;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2022/2/21
*/
@Getter
@Setter
public class Message {
private String message;
private Integer code;
private List<VideoEntity> videos;
public Message(String message, Integer code) {
this.message = message;
this.code = code;
}
public Message() {
}
public static Message error(String msg) {
return new Message(msg, 0);
}
public static Message success(String msg) {
return new Message(msg, 1);
}
public static Message success() {
return success("success");
}
public static Message error() {
return error("error");
}
}
package com.viontech.integration.jiaoguansuo.entity;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
/**
* .
*
* @author 谢明辉
* @date 2022/2/21
*/
@Getter
@Setter
@Accessors(chain = true)
public class VideoEntity {
private String dwxh;
private String sxjbh;
private String jkdz;
private Integer jcfx;
private Integer jcsj;
private String jcsd;
private Integer cjlx;
private String jclx;
}
package com.viontech.integration.jiaoguansuo.feign;
import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.vo.ChannelVo;
import com.viontech.keliu.util.JsonMessageUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2022/2/21
*/
@FeignClient(value = "fanxing-ops")
@Service
public interface OpsClient {
@GetMapping("/channels")
JsonMessageUtil.JsonMessage<List<Channel>> getChannels(@SpringQueryMap Channel channel);
@PostMapping("/channels")
JsonMessageUtil.JsonMessage<Channel> add(@RequestBody Channel channel);
@DeleteMapping("/channels/{id}")
JsonMessageUtil.JsonMessage remove(@PathVariable("id") Long id);
}
package com.viontech.integration.jiaoguansuo.feign;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.vo.TaskVo;
import com.viontech.keliu.util.JsonMessageUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2022/2/21
*/
@FeignClient(value = "fanxing-task")
@Service
public interface TaskClient {
@PostMapping("/tasks")
JsonMessageUtil.JsonMessage<TaskVo> addTask(@RequestBody TaskVo taskVo);
@GetMapping("/tasks")
JsonMessageUtil.JsonMessage<List<Task>> getTask(@SpringQueryMap Task task);
@DeleteMapping("/tasks/{id}")
JsonMessageUtil.JsonMessage removeTask(@PathVariable("id") Long id);
@PostMapping("/tasks/{id}")
JsonMessageUtil.JsonMessage<TaskVo> update(@PathVariable("id") Long id, @RequestBody Task task);
@GetMapping("/tasks/{id}/start")
JsonMessageUtil.JsonMessage<TaskVo> startTask(@PathVariable("id") Long id);
}
package com.viontech.integration.jiaoguansuo.service;
import cn.hutool.core.date.DateUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.viontech.fanxing.commons.constant.ChannelType;
import com.viontech.fanxing.commons.model.Channel;
import com.viontech.fanxing.commons.model.Task;
import com.viontech.fanxing.commons.vo.TaskVo;
import com.viontech.integration.jiaoguansuo.entity.Code;
import com.viontech.integration.jiaoguansuo.entity.VideoEntity;
import com.viontech.integration.jiaoguansuo.feign.OpsClient;
import com.viontech.integration.jiaoguansuo.feign.TaskClient;
import com.viontech.keliu.util.JsonMessageUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.Duration;
import java.util.Date;
import java.util.List;
/**
* .
*
* @author 谢明辉
* @date 2022/2/21
*/
@Service
@Slf4j
public class MainService {
@Resource
private TaskClient taskClient;
@Resource
private OpsClient opsClient;
@Value("${vion.storage-config-id}")
private Long storageConfigId;
public List<Channel> getChannels(Channel channel) {
JsonMessageUtil.JsonMessage<List<Channel>> channels = opsClient.getChannels(channel);
if (channels.isSuccess()) {
return channels.getData();
} else {
throw new RuntimeException(channels.getMsg());
}
}
public Channel addChannel(VideoEntity addVideo) {
Channel channel = new Channel();
channel.setChannelUnid(addVideo.getSxjbh());
channel.setDeviceUnid(addVideo.getDwxh());
JsonMessageUtil.JsonMessage<List<Channel>> channels = opsClient.getChannels(channel);
if (channels.isSuccess() && channels.getData().size() > 0) {
return channels.getData().get(0);
}
channel.setName(addVideo.getSxjbh());
channel.setStreamType(ChannelType.STREAM_RTSP.value);
channel.setStreamPath(addVideo.getJkdz());
channel.setIp("0.0.0.0");
channel.setPort(0);
channel.setUsername("username");
channel.setPassword("password");
channel.setType(ChannelType.MANUALLY.value);
JsonMessageUtil.JsonMessage<Channel> add = opsClient.add(channel);
if (add.isSuccess()) {
return add.getData();
} else {
throw new RuntimeException(add.getMsg());
}
}
public Task addTask(VideoEntity videoEntity, Channel channel, Code code) {
TaskVo taskVo = new TaskVo();
taskVo.setResourceNeed(1F);
taskVo.setStoreConfigId(storageConfigId);
taskVo.setName(videoEntity.getSxjbh());
taskVo.setAlgType(String.valueOf(0));
taskVo.setDeviceUnid(channel.getDeviceUnid());
taskVo.setChannelUnid(channel.getChannelUnid());
taskVo.setStreamPath(channel.getStreamPath());
taskVo.setStreamType(channel.getStreamType());
taskVo.setAlgEnabled("[\"" + code.paramName + "\"]");
// 视频检测运行配置
Integer jcfx = videoEntity.getJcfx();
if (jcfx == 1) {
long l = Duration.ofMinutes(videoEntity.getJcsj()).toMillis();
if (l == 0) {
taskVo.setRuntimeType(4);
taskVo.setRuntimeConf("{\"type\":4}");
} else {
taskVo.setRuntimeType(1);
JSONObject config = new JSONObject();
config.set("start", DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"));
config.set("end", DateUtil.format(new Date(System.currentTimeMillis() + l + 1000), "yyyy-MM-dd HH:mm:ss"));
JSONObject jsonObject = new JSONObject();
jsonObject.set("type", 1);
jsonObject.set("config", config);
taskVo.setRuntimeConf(jsonObject.toString());
}
} else {
String[] split = videoEntity.getJcsd().split("#");
if (split.length == 0) {
taskVo.setRuntimeType(4);
taskVo.setRuntimeConf("{\"type\":4}");
} else {
taskVo.setRuntimeType(0);
JSONArray configs = new JSONArray();
for (String dd : split) {
String[] ddd = dd.split("-");
JSONObject config = new JSONObject();
config.set("start", ddd[0] + ":00");
config.set("end", ddd[1] + ":00");
configs.add(config);
}
JSONObject jsonObject = new JSONObject();
jsonObject.set("type", 0);
jsonObject.set("config", configs);
taskVo.setRuntimeConf(jsonObject.toString());
}
}
JsonMessageUtil.JsonMessage<TaskVo> res = taskClient.addTask(taskVo);
if (res.isSuccess()) {
return res.getData();
} else {
throw new RuntimeException(res.getMsg());
}
}
public void removeChannel(Long id) {
JsonMessageUtil.JsonMessage remove = opsClient.remove(id);
log.info("删除视频资源结果:{}", remove.getMsg());
}
public void startTask(Long id) {
JsonMessageUtil.JsonMessage<TaskVo> task = taskClient.startTask(id);
}
public void removeTask(Long id) {
JsonMessageUtil.JsonMessage jsonMessage = taskClient.removeTask(id);
log.info("删除任务结果:{}", jsonMessage.getMsg());
}
public List<Task> getTask(Task task) {
JsonMessageUtil.JsonMessage<List<Task>> res = taskClient.getTask(task);
if (res.isSuccess()) {
return res.getData();
}
throw new RuntimeException(res.getMsg());
}
public void updateTask(Long id, Task task) {
JsonMessageUtil.JsonMessage<TaskVo> update = taskClient.update(id, task);
if (!update.isSuccess()) {
throw new RuntimeException(update.getMsg());
}
}
}
spring.cloud.consul.discovery.metadata.version=1.0-SNAPSHOT
spring.main.allow-bean-definition-overriding=true
\ No newline at end of file
spring:
servlet:
multipart:
max-file-size: 500MB
max-request-size: 512MB
cloud:
loadbalancer:
ribbon:
enabled: false
consul:
# 服务发现配置
discovery:
# 启用服务发现
enabled: true
# 启用服务注册
register: true
# 服务停止时取消注册
deregister: true
# 表示注册时使用IP而不是hostname
prefer-ip-address: true
# 执行监控检查的频率
health-check-interval: 10s
# 设置健康检查失败多长时间后,取消注册
health-check-critical-timeout: 30s
# 健康检查的路径
health-check-path: /actuator/info
# 服务注册标识,格式为:应用名称:服务器IP:端口
instance-id: ${spring.application.name}:${spring.cloud.consul.discovery.ip-address}:${server.port}
ip-address: 192.168.9.146
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
default-property-inclusion: non_null
task:
scheduling:
pool:
size: 10
logging:
config: classpath:logback-${spring.profiles.active}.xml
vion:
storage-config-id: 17
\ No newline at end of file
server:
port: 30100
spring:
profiles:
active:
${PROFILE}
application:
name: fanxing-integration-jiaoguansuo
cloud:
consul:
host: 192.168.9.233
port: 8500
discovery:
service-name: ${spring.application.name}
# config 在 consul > key/value 中命名规则: prefix/default-context,profiles.active/data-key
config:
enabled: true
format: YAML
prefix: fanxing
default-context: ${spring.application.name}
data-key: config
watch:
enabled: true
delay: 10000
wait-time: 30
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds">
<contextName>logback</contextName>
<property name="log.path" value="logs"/>
<property name="pattern" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%thread] %logger{50} - %msg%n"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<encoder>
<Pattern>${pattern}</Pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="10 seconds">
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
<contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<property name="log.path" value="logs"/>
<property name="pattern" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%thread] %logger{50} - %msg%n"/>
<!--输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<encoder>
<Pattern>${pattern}</Pattern>
<!-- 设置字符集 -->
</encoder>
</appender>
<!--输出到文件-->
<!-- 时间滚动输出 level为 DEBUG 日志 -->
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_debug.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志归档 -->
<fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 INFO 日志 -->
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_info.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>NEUTRAL</onMismatch>
</filter>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 WARN 日志 -->
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_warn.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>5</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录warn级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 ERROR 日志 -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_error.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<logger name="com.viontech" level="debug">
<appender-ref ref="DEBUG_FILE"/>
</logger>
<root level="info">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="WARN_FILE"/>
<appender-ref ref="ERROR_FILE"/>
</root>
</configuration>
\ No newline at end of file
spring.cloud.consul.discovery.metadata.version=1.0-SNAPSHOT
spring.main.allow-bean-definition-overriding=true
\ No newline at end of file
spring:
servlet:
multipart:
max-file-size: 500MB
max-request-size: 512MB
cloud:
loadbalancer:
ribbon:
enabled: false
consul:
# 服务发现配置
discovery:
# 启用服务发现
enabled: true
# 启用服务注册
register: true
# 服务停止时取消注册
deregister: true
# 表示注册时使用IP而不是hostname
prefer-ip-address: true
# 执行监控检查的频率
health-check-interval: 10s
# 设置健康检查失败多长时间后,取消注册
health-check-critical-timeout: 30s
# 健康检查的路径
health-check-path: /actuator/info
# 服务注册标识,格式为:应用名称:服务器IP:端口
instance-id: ${spring.application.name}:${spring.cloud.consul.discovery.ip-address}:${server.port}
ip-address: 192.168.9.146
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
default-property-inclusion: non_null
task:
scheduling:
pool:
size: 10
logging:
config: classpath:logback-${spring.profiles.active}.xml
vion:
storage-config-id: 17
\ No newline at end of file
server:
port: 30100
spring:
profiles:
active:
${PROFILE}
application:
name: fanxing-integration-jiaoguansuo
cloud:
consul:
host: 192.168.9.233
port: 8500
discovery:
service-name: ${spring.application.name}
# config 在 consul > key/value 中命名规则: prefix/default-context,profiles.active/data-key
config:
enabled: true
format: YAML
prefix: fanxing
default-context: ${spring.application.name}
data-key: config
watch:
enabled: true
delay: 10000
wait-time: 30
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds">
<contextName>logback</contextName>
<property name="log.path" value="logs"/>
<property name="pattern" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%thread] %logger{50} - %msg%n"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<encoder>
<Pattern>${pattern}</Pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="CONSOLE"/>
</root>
</configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
<configuration scan="true" scanPeriod="10 seconds">
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
<contextName>logback</contextName>
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
<property name="log.path" value="logs"/>
<property name="pattern" value="[%d{yyyy-MM-dd HH:mm:ss.SSS}] [%-5level] [%thread] %logger{50} - %msg%n"/>
<!--输出到控制台-->
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>info</level>
</filter>
<encoder>
<Pattern>${pattern}</Pattern>
<!-- 设置字符集 -->
</encoder>
</appender>
<!--输出到文件-->
<!-- 时间滚动输出 level为 DEBUG 日志 -->
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_debug.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志归档 -->
<fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录debug级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>debug</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 INFO 日志 -->
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_info.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset>
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 每天日志归档路径以及格式 -->
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录info级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>info</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>NEUTRAL</onMismatch>
</filter>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 WARN 日志 -->
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_warn.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>5</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录warn级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>warn</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 时间滚动输出 level为 ERROR 日志 -->
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- 正在记录的日志文件的路径及文件名 -->
<file>${log.path}/log_error.log</file>
<!--日志文件输出格式-->
<encoder>
<Pattern>${pattern}</Pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>100MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
</rollingPolicy>
<!-- 此日志文件只记录ERROR级别的 -->
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>ACCEPT</onMatch>
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<logger name="com.viontech" level="debug">
<appender-ref ref="DEBUG_FILE"/>
</logger>
<root level="info">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="INFO_FILE"/>
<appender-ref ref="WARN_FILE"/>
<appender-ref ref="ERROR_FILE"/>
</root>
</configuration>
\ No newline at end of file
<?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 http://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.3.RELEASE</version>
</parent>
<packaging>pom</packaging>
<groupId>com.viontech</groupId>
<artifactId>fanxing3-integration</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<skipTests>true</skipTests>
<maven.javadoc.failOnError>false</maven.javadoc.failOnError>
</properties>
<modules>
<module>fanxing-integration-jiaoguansuo</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Hoxton.SR7</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<generateBackupPoms>false</generateBackupPoms>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!