Commit 7a3ba34f by xmh

初次提交

0 parents
Showing 48 changed files with 2810 additions and 0 deletions
**/logs/
**/target/
*.iml
**/.idea/
# 繁星3.0文档
## 繁星3.0架构图
![](./images/繁星3.0架构图.png)
## 繁星3.0流程图
### 系统流程图
![](./images/流程图.jpg)
### 任务流程图
![](./images/繁星3.0任务流程图.jpg)
## 繁星3.0 模块划分
1. 服务网关(Gateway)
服务网关作为应用层统一对外接口,负责接口路由、安全验证、流量控制等工作。
2. consul
服务治理及配置中心
3. 任务管理
任务管理模块负责任务的建立、查询、管理等工作
4. 任务调度
任务调度模块负责对任务的调度,与 VAServer 间对于任务的交互
5. 转发服务
转发服务模块负责收集任务分析结果,并将结果转发给需要的服务
6. 查询服务
查询服务负责查询任务分析结果
7. 运维服务
运维服务负责服务器、应用、集群状态的监控,负责对接地址管理,系统校时,升级等功能,负责对接普罗米修斯监控平台
8. 日志服务
日志服务以 ELK 为基础,负责收集和分析各个应用的运行日志
9. 认证服务
认证服务负责用户管理及安全认证
10. 编码服务
编码服务负责整个系统的字典码存储和管理
## 数据库设计
### 任务管理模块
#### s_task(任务信息表)
| 字段名称 | 类型 | 可否为空 | 默认值 | 注释 |
| --------------- | ------------ | -------- | ------ | -------------------------- |
| id | BIGINT | 否 | | 自增主键ID |
| unid | VARCHAR(32) | 否 | uuid() | 唯一ID |
| name | VARCHAR(128) | 否 | | 任务名称 |
| alg_type | VARCHAR(32) | 否 | | 算法类型 |
| resource_need | FLOAT | 否 | | 任务所需资源数量 |
| priority | INT | 否 | 0 | 优先级 |
| store_config_id | BIGINT | 否 | | 存储配置(VAServer使用) |
| va_type | VARCHAR(64) | | | 算法分析设备类型(plate_tupe) |
| runtime_type | SMALLINT | 否 | 0 | 任务运行类型(全天,分时段等) |
| runtime_conf | VARCHAR(1024) | | | 分时段运行的配置 |
| device_unid | varchar(32) | | | 设备unid |
| channel_unid | varchar(32) | | | 通道unid |
| stream_path | VARCHAR(1024) | 否 | | 视频流地址 |
| stream_type | INT | 否 | | 视频流类型 |
| scene | TEXT | | | 场景配置 |
| create_time | TIMESTAMP | 否 | now() | 创建时间 |
| status | SMALLINT | 否 | 0 | 任务状态 |
#### s_store_config(存储配置表)
| 字段名称 | 类型 | 可否为空 | 默认值 | 注释 |
| -------------- | ------------ | -------- | ------ | ----------------------- |
| id | BIGINT | 否 | | 自增主键ID |
| unid | VARCHAR(32) | 否 | uuid() | 唯一ID |
| name | VARCHAR(256) | 否 | | 存储配置名称 |
| content_format | SMALLINT | 否 | 0 | 配置内容格式,默认0(XML) |
| content | TEXT | | | 配置内容 |
| status | SMALLINT | 否 | 0 | 状态 |
| create_time | TIMESTAMP | 否 | now() | 创建时间 |
### 查询服务模块
#### d_traffic(交通数据表)
| 字段名称 | 类型 | 可否为空 | 默认值 | 注释 |
| ---------------------- | ------------ | -------- | ------ | ----------------- |
| id | BIGINT | 否 | | 自增主键ID |
| unid | VARCHAR(32) | 否 | uuid() | 唯一ID |
| event_cate | BIGINT | | | |
| event_type | INT | 否 | | |
| event_time | TIMESTAMP | 否 | | |
| vchan_ref_id | INT | | | |
| plate_color | VARCHAR(32) | | | 车牌颜色 |
| plate_number | VARCHAR(32) | | | 车牌号码 |
| location_code | VARCHAR(32) | | | 位置编码 |
| lane_code | VARCHAR(32) | | | 车道号 |
| direction_code | VARCHAR(32) | | | 卡口方向 |
| vehicle_type | VARCHAR(32) | | | 车辆类型 |
| illegal_code | VARCHAR(32) | | | 违法行为 |
| illegal_state | SMALLINT | | | 违法行为是否可用 |
| vehicle_color | VARCHAR(32) | | | 车身颜色 |
| logo | VARCHAR(32) | | | 车标编码 |
| annual_inspection_mark | SMALLINT | | | 年检标 |
| pendant | SMALLINT | | | 吊坠 |
| decoration | SMALLINT | | | 摆件 |
| sun_shield | SMALLINT | | | 遮阳板 |
| xcycle_type | VARCHAR(32) | | | 非机动车类型 |
| event_id | BIGINT | | | |
| shoot_time | TIMESTAMP | | | |
| special_type | VARCHAR(32) | | | |
| with_helmet | SMALLINT | | 0 | 是否戴头盔(0不带) |
| json_data | TEXT | | | |
| pic_name | VARCHAR(256) | | | |
| video_name | VARCHAR(256) | | | |
| status | SMALLINT | | | |
#### d_flow_data(交通流量数据表)
| 字段名称 | 类型 | 可否为空 | 默认值 | 注释 |
| ---------------- | ----------- | -------- | ------ | ---------- |
| id | BIGINT | 否 | | 自增主键ID |
| unid | VARCHAR(32) | 否 | uuid() | 唯一ID |
| event_id | BIGINT | 否 | | |
| task_id | BIGINT | | | |
| detection_type | VARCHAR(32) | | | |
| road_code | VARCHAR(32) | | | |
| direction_code | VARCHAE(32) | | | |
| sample_dura | INT | | | |
| sample_num | FLOAT | | | |
| velocity | FLOAT | | | |
| velocity_unit | VARCHAR(16) | | | |
| occupy | FLOAT | | | 车道占有率 |
| distance | FLOAT | | | 车头间距 |
| queue_length | FLOAT | | | |
| region_id | VARCHAR(32) | | | |
| region_name | VARCHAR(64) | | | |
| position_content | TEXT | | | |
| head_content | TEXT | | | |
| area | FLOAT | | | |
| density | FLOAT | | | |
| sample_num_in | FLOAT | | | |
| sample_num_out | FLOAT | | | |
| event_time | TIMESTAMP | | | |
| dist_time | FLOAT | | | |
| time_occupy | FLOAT | | | |
| status | INT | | | |
#### d_flow_event(交通流量数据表)
| 字段名称 | 类型 | 可否为空 | 默认值 | 注释 |
| ------------- | ------------ | -------- | ------ | ---------- |
| id | BIGINT | 否 | | 自增主键ID |
| unid | VARCHAR(32) | 否 | uuid() | 唯一ID |
| task_id | BIGINT | | | |
| type | VARCHAR(32) | | | |
| time | TIMESTAMP | | | |
| device_name | VARCHAR(64) | | | |
| location_name | VARCHAR(64) | | | |
| location_code | VARCHAR(32) | | | |
| event_id | VARCHAR(255) | | | |
| device_code | VARCHAR(32) | | | |
| json_data | TEXT | | | |
| pic_name | VARCHAR(256) | | | |
| video_name | VARCHAR(256) | | | |
#### d_behavior(行为数据表)
| 字段名称 | 类型 | 可否为空 | 默认值 | 注释 |
| -------------- | ------------ | -------- | ------ | ---------- |
| id | BIGINT | 否 | | 自增主键ID |
| unid | VARCHAR(32) | 否 | uuid() | 唯一ID |
| task_id | BIGINT | | | |
| event_type | VARCHAR(32) | | | |
| event_ref_id | VARCHAR(32) | | | |
| event_time | TIMESTAMP | | | |
| aux_dev_info | TEXT | | | |
| event_data | TEXT | | | |
| pics | TEXT | | | |
| video | TEXT | | | |
| event_cate | VARCHAR(32) | | | |
| vchan_ref_id | VARCHAR(32) | | | |
| test_pic_file | VARCHAR(256) | | | |
| test_frame_no | VARCHAR(256) | | | |
| task_name | VARCHAR(64) | | | |
| event_data_num | VARCHAR(32) | | | |
### 转发服务模块
#### s_forward(转发信息表)
| 字段名称 | 类型 | 可否为空 | 默认值 | 注释 |
| -------------- | ------------- | -------- | ------ | ---------------- |
| id | BIGINT | 否 | | 自增主键ID |
| unid | VARCHAR(32) | 否 | uuid() | 唯一ID |
| name | VARCHAR(128) | 否 | | 转发名称 |
| url | VARCHAR(1024) | 否 | | 转发地址 |
| total | BIGINT | 否 | 0 | 转发数据总数 |
| failed | BIGINT | 否 | 0 | 转发数据失败数量 |
| last_send_time | TIMESTAMP | 是 | | 最后发送数据时间 |
| status | SMALLINT | 否 | 0 | 状态 |
| create_time | TIMESTAMP | 否 | now() | 创建时间 |
#### s_forward_config(转发配置表)
> 此处存储需要被转发的数据类型
| 字段名称 | 类型 | 可否为空 | 默认值 | 注释 |
| ---------- | ----------- | -------- | ------ | ---------- |
| id | BIGINT | 否 | | 自增主键ID |
| unid | VARCHAR(32) | 否 | uuid() | 唯一ID |
| forward_id | BIGINT | 否 | | 转发信息id |
| event_cate | VARCHAR(32) | 否 | | |
| event_type | VARCHAR(32) | 否 | | |
## 接口
### 任务管理模块
#### 新建任务
- **path**
- `/fanxing-task-manager/tasks`
- **verb**
- `POST`
- **body**
```json
{
"name": "xxxxx",
"algType": 1,
"resourceNeed": 2,
"storeConfigId": 1,
"vaType": "xxx",
"runtimeType":0,
"runtimeConf":"json",
"streamPath":"rtsp://xxxxx",
"streamType":0,
"scene":[
{
"algo_type": 0,
"analyse_play_url": {},
"calibration": {},
"calibrationalgo": {},
"config": {
"xml": "<?xml version=\"1.0\" encoding=\"GBK\"?>\n<root><功能配置><抓拍参数配置><路口电警><综治><施工占道><启用>0</启用></施工占道><堆积><启用>0</启用></堆积><横幅><启用>1</启用></横幅><交通场景>0</交通场景><黄土裸露><启用>1</启用><灵敏度>99</灵敏度></黄土裸露><停留时间>5</停留时间><报警周期>10</报警周期></综治></路口电警></抓拍参数配置></功能配置></root>\n"
},
"is_active": 0,
"is_record": 0,
"is_running": 1,
"play_urls": {
"rtsp": "rtsp://192.168.9.233:8554//opt/data/vedio/1604050247355.264"
},
"position_name": "1",
"position_num": "1",
"rois": [
{
"roi": "<?xml version=\"1.0\" encoding=\"GBK\"?>\n<roi><flow_roi><flow_type/><flow_region><polygon_point_count>0</polygon_point_count></flow_region></flow_roi><plate_detect_region><detect_polygon><polygon_point_count>0</polygon_point_count></detect_polygon></plate_detect_region><lane_line><line_count>0</line_count></lane_line><lanes><lane_count>0</lane_count></lanes><lights><light_count>0</light_count></lights><no_stop_region><region_count>0</region_count></no_stop_region><pedestrian_detection_region><region_count>0</region_count></pedestrian_detection_region><median_lines><lane_count>0</lane_count></median_lines><pedestrian_density_region><region_count>0</region_count></pedestrian_density_region><foreign_detection_region><region_count>1</region_count><polygon><polygon_id>79897898</polygon_id><polygon_name>9789898</polygon_name><polygon_point_count>4</polygon_point_count><point><point_seq>1</point_seq><x>0.470000</x><y>0.238000</y></point><point><point_seq>2</point_seq><x>0.427500</x><y>0.880000</y></point><point><point_seq>3</point_seq><x>0.990000</x><y>0.856000</y></point><point><point_seq>4</point_seq><x>0.990000</x><y>0.310000</y></point></polygon></foreign_detection_region><test_result_region><region_count>1</region_count></test_result_region></roi>\n"
}
],
"runtime": -1,
"scene_unid": "dfa211e285884764aba286f743609c5f",
"vchan_refid": "5d4e4e86-fc78-4781-a4a0-8ede9bb9de14",
"basicConfig": {
"xml": "<?xml version=\"1.0\" encoding=\"GBK\"?><root><短时录像设置><启用><AttribType>4</AttribType><AttribInfo>是否开启录像</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><是否画框><AttribType>4</AttribType><AttribInfo>是否画框</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否画框><向前录像时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>5</AttribDefault><AttribRange>0-1000</AttribRange></向前录像时间><向后录像时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>5</AttribDefault><AttribRange>0-1000</AttribRange></向后录像时间><录像最大缓存时间><AttribType>0</AttribType><AttribInfo>秒</AttribInfo><AttribDefault>60</AttribDefault><AttribRange>0-1000</AttribRange></录像最大缓存时间></短时录像设置><软件参数设置><球机3D拉框倍数><AttribType>0</AttribType><AttribInfo>球机3D拉框倍数</AttribInfo><AttribDefault>1</AttribDefault><AttribRange>1-5</AttribRange></球机3D拉框倍数><显示视频参数><AttribType>4</AttribType><AttribInfo>显示视频参数</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></显示视频参数><显示Buffer状态><AttribType>4</AttribType><AttribInfo>显示Bufffer状态</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></显示Buffer状态></软件参数设置><测试抓拍><车牌><AttribType>2</AttribType><AttribInfo>手动抓拍车牌</AttribInfo><AttribDefault>manual</AttribDefault><AttribRange>128</AttribRange></车牌><类型><AttribType>0</AttribType><AttribInfo>type</AttribInfo><AttribDefault>59</AttribDefault><AttribRange>0-1000</AttribRange></类型></测试抓拍><BUFFER_SIZE><PROCESSING><AttribType>0</AttribType><AttribInfo>帧</AttribInfo><AttribDefault>10</AttribDefault><AttribRange>3-10</AttribRange></PROCESSING><REFERENCE><AttribType>0</AttribType><AttribInfo>帧</AttribInfo><AttribDefault>40</AttribDefault><AttribRange>10-100</AttribRange></REFERENCE></BUFFER_SIZE><结果处理><未系安全带违法检测><是否启用><AttribType>4</AttribType><AttribInfo>是否未系安全带违法检测</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否启用><只在卡口数据中检测><AttribType>4</AttribType><AttribInfo>已违法数据不再进行未系安全带违法检测</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></只在卡口数据中检测><违法置信度阈值><AttribType>0</AttribType><AttribInfo>当高于此值时才认为是违法</AttribInfo><AttribDefault>30</AttribDefault><AttribRange>0-100</AttribRange></违法置信度阈值><过滤无牌数据><AttribType>4</AttribType><AttribInfo>过滤无牌的违法数据</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></过滤无牌数据><检测副驾驶><AttribType>4</AttribType><AttribInfo>副驾驶是否未系安全带违法检测</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></检测副驾驶></未系安全带违法检测><前排抱小孩违法检测><是否启用><AttribType>4</AttribType><AttribInfo>是否前排抱小孩违法检测</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否启用><只在卡口数据中检测><AttribType>4</AttribType><AttribInfo>已违法数据不再进行前排抱小孩违法检测</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></只在卡口数据中检测><违法置信度阈值><AttribType>0</AttribType><AttribInfo>当高于此值时才认为是违法</AttribInfo><AttribDefault>30</AttribDefault><AttribRange>0-100</AttribRange></违法置信度阈值><过滤无牌数据><AttribType>4</AttribType><AttribInfo>过滤无牌的违法数据</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></过滤无牌数据></前排抱小孩违法检测><使用手机违法检测><是否启用><AttribType>4</AttribType><AttribInfo>是否使用手机违法检测</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否启用><只在卡口数据中检测><AttribType>4</AttribType><AttribInfo>已违法数据不再进行使用手机违法检测</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></只在卡口数据中检测><违法置信度阈值><AttribType>0</AttribType><AttribInfo>当高于此值时才认为是违法</AttribInfo><AttribDefault>30</AttribDefault><AttribRange>0-100</AttribRange></违法置信度阈值><过滤无牌数据><AttribType>4</AttribType><AttribInfo>过滤无牌的违法数据</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></过滤无牌数据></使用手机违法检测><危险品车辆检测><是否启用><AttribType>4</AttribType><AttribInfo>是否危化品车辆违法检测</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否启用><启用时间段><AttribType>2</AttribType><AttribInfo>如7:1-8:1;17:1:18:1</AttribInfo><AttribDefault></AttribDefault><AttribRange>256</AttribRange></启用时间段><只在卡口数据中检测><AttribType>4</AttribType><AttribInfo>已违法数据不再进行危化品车辆违法检测</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></只在卡口数据中检测><违法置信度阈值><AttribType>0</AttribType><AttribInfo>当高于此值时才认为是违法</AttribInfo><AttribDefault>30</AttribDefault><AttribRange>0-100</AttribRange></违法置信度阈值><过滤无牌数据><AttribType>4</AttribType><AttribInfo>过滤无牌的违法数据</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></过滤无牌数据></危险品车辆检测><属性违法><启用危险品运输车无押运员><AttribType>4</AttribType><AttribInfo>启用危险品运输车无押运员</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用危险品运输车无押运员><启用号牌污损><AttribType>4</AttribType><AttribInfo>启用号牌污损</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用号牌污损><启用夜间开车放下遮阳板><AttribType>4</AttribType><AttribInfo>启用夜间开车放下遮阳板</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用夜间开车放下遮阳板><启用夜间行车不开灯><AttribType>4</AttribType><AttribInfo>启用夜间行车不开灯</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用夜间行车不开灯><启用车载货物超长超宽><AttribType>4</AttribType><AttribInfo>启用车载货物超长超宽</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用车载货物超长超宽><启用渣土车冒尖><AttribType>4</AttribType><AttribInfo>启用渣土车冒尖</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用渣土车冒尖><启用泥头车禁行><AttribType>4</AttribType><AttribInfo>启用泥头车禁行</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用泥头车禁行><启用小金刚禁行><AttribType>4</AttribType><AttribInfo>启用小金刚禁行</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用小金刚禁行></属性违法></结果处理><车辆属性识别><识别车辆类型><AttribType>4</AttribType><AttribInfo>识别车辆类型</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车辆类型><识别车标><AttribType>4</AttribType><AttribInfo>识别车标</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车标><识别车身颜色><AttribType>4</AttribType><AttribInfo>识别车身颜色</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别车身颜色><识别驾驶员><AttribType>4</AttribType><AttribInfo>识别驾驶员</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别驾驶员><识别危险品标识><AttribType>4</AttribType><AttribInfo>识别危险品标识</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></识别危险品标识></车辆属性识别><设备配置><设备名称><AttribType>2</AttribType><AttribInfo>设备名称</AttribInfo><AttribDefault></AttribDefault><AttribRange>256</AttribRange></设备名称><设备编号><AttribType>2</AttribType><AttribInfo>设备编号</AttribInfo><AttribDefault></AttribDefault><AttribRange>256</AttribRange></设备编号><地点名称><AttribType>2</AttribType><AttribInfo>地点名称</AttribInfo><AttribDefault></AttribDefault><AttribRange>256</AttribRange></地点名称><地点编号><AttribType>2</AttribType><AttribInfo>地点编号</AttribInfo><AttribDefault></AttribDefault><AttribRange>256</AttribRange></地点编号><方向名称><AttribType>2</AttribType><AttribInfo>方向名称</AttribInfo><AttribDefault></AttribDefault><AttribRange>256</AttribRange></方向名称><方向编号><AttribType>0</AttribType><AttribInfo>方向编号</AttribInfo><AttribDefault>1</AttribDefault><AttribRange>0-15</AttribRange></方向编号></设备配置><红灯设置><模拟红灯><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></模拟红灯><红灯校正><开启算法><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></开启算法><校正不成功的不抓闯红灯违法><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></校正不成功的不抓闯红灯违法><校正灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>50</AttribDefault><AttribRange>1-100</AttribRange></校正灵敏度><开始时间1><AttribType>5</AttribType><AttribInfo></AttribInfo><AttribDefault>Time:00_00_00</AttribDefault><AttribRange>MaxTime:23_59_59-MinTime:00_00_00</AttribRange></开始时间1><结束时间1><AttribType>5</AttribType><AttribInfo></AttribInfo><AttribDefault>Time:00_00_00</AttribDefault><AttribRange>MaxTime:23_59_59-MinTime:00_00_00</AttribRange></结束时间1><开始时间2><AttribType>5</AttribType><AttribInfo></AttribInfo><AttribDefault>Time:00_00_00</AttribDefault><AttribRange>MaxTime:23_59_59-MinTime:00_00_00</AttribRange></开始时间2><结束时间2><AttribType>5</AttribType><AttribInfo></AttribInfo><AttribDefault>Time:00_00_00</AttribDefault><AttribRange>MaxTime:23_59_59-MinTime:00_00_00</AttribRange></结束时间2></红灯校正><红灯最短时长><AttribType>0</AttribType><AttribInfo>秒,小于此时长的红灯周期作废</AttribInfo><AttribDefault>10</AttribDefault><AttribRange>0-100</AttribRange></红灯最短时长><持续状态多长时间报警><AttribType>0</AttribType><AttribInfo>秒,大于此时长的红灯周期作废,且输出警告日志</AttribInfo><AttribDefault>120</AttribDefault><AttribRange>30-86400</AttribRange></持续状态多长时间报警><红灯开始后的无效时间><AttribType>0</AttribType><AttribInfo>秒,红灯开始前多少秒不抓闯红灯</AttribInfo><AttribDefault>0</AttribDefault><AttribRange>0-10</AttribRange></红灯开始后的无效时间><红灯结束前的无效时间><AttribType>0</AttribType><AttribInfo>秒,红灯结束前多少秒不抓闯红灯</AttribInfo><AttribDefault>0</AttribDefault><AttribRange>0-10</AttribRange></红灯结束前的无效时间><是否做红灯周期波动检测><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否做红灯周期波动检测><红灯周期最大波动><AttribType>0</AttribType><AttribInfo>当前红灯时间大于或小于前一周期多少秒,则当前红灯无效</AttribInfo><AttribDefault>10</AttribDefault><AttribRange>1-100</AttribRange></红灯周期最大波动><灯色最小饱和度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>30</AttribDefault><AttribRange>1-100</AttribRange></灯色最小饱和度></红灯设置><系统性能测试><显示违法状态调试信息><AttribType>3</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange>27:0-未设置违法类型&amp;2-占用公交车道&amp;3-异常停车&amp;4-非法停车&amp;5-压线&amp;6-逆行&amp;7-掉头&amp;8-闯红灯&amp;11-不按导向行驶&amp;12-占用非机动车道&amp;15-行人非机动车上高速&amp;16-按车牌限行&amp;20-未礼让行人&amp;22-占道禁道行驶类&amp;23-车辆禁行类&amp;29-路口滞留&amp;30-越线停车&amp;1-流量&amp;31-左转大弯转小弯&amp;32-左转不让直行&amp;36-右转不让非机动车&amp;37-渣土车&amp;59-追尾事故&amp;60-骑摩托未戴头盔&amp;62-倒车&amp;72-卡口&amp;74-场景分析</AttribRange></显示违法状态调试信息><相同车牌过滤><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></相同车牌过滤><串口过车信号><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></串口过车信号><离开停止线跟踪帧数><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>1000</AttribDefault><AttribRange>1-10000</AttribRange></离开停止线跟踪帧数><视频触发跟踪帧数><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>10000</AttribDefault><AttribRange>1-20000</AttribRange></视频触发跟踪帧数><打印车辆信息><AttribType>0</AttribType><AttribInfo>为0时不打印,1对应车筐高度最大</AttribInfo><AttribDefault>0</AttribDefault><AttribRange>0-20</AttribRange></打印车辆信息><捕获率优先><AttribType>4</AttribType><AttribInfo>PK模式</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></捕获率优先><复杂路况去除误报><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></复杂路况去除误报><模拟红灯时全部判断为闯红灯><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></模拟红灯时全部判断为闯红灯><显示红绿灯定位框><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示红绿灯定位框><显示车辆跟踪框><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示车辆跟踪框><显示ROI信息><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示ROI信息><显示密度图><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></显示密度图><显示距离><AttribType>4</AttribType><AttribInfo>车道纵向距离</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></显示距离><显示版本时间><AttribType>4</AttribType><AttribInfo>算法版本编译时间</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></显示版本时间><是否显示检测框等><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否显示检测框等><红绿灯翻转><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></红绿灯翻转><图像偏移过大报警开启><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></图像偏移过大报警开启><保存灯切换时的图片文件><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></保存灯切换时的图片文件></系统性能测试><功能配置><抓拍参数配置><路口电警><路面异物><停留时间><AttribType>0</AttribType><AttribInfo>单位:秒</AttribInfo><AttribDefault>10</AttribDefault><AttribRange>0-600</AttribRange></停留时间><个数阈值><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>3</AttribDefault><AttribRange>0-600</AttribRange></个数阈值><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><检测灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>50</AttribDefault><AttribRange>0-100</AttribRange></检测灵敏度></路面异物><跌倒行人><停留时间><AttribType>0</AttribType><AttribInfo>单位:秒</AttribInfo><AttribDefault>3</AttribDefault><AttribRange>0-600</AttribRange></停留时间><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><检测灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>50</AttribDefault><AttribRange>0-100</AttribRange></检测灵敏度></跌倒行人><倒地自行车><停留时间><AttribType>0</AttribType><AttribInfo>单位:秒</AttribInfo><AttribDefault>30</AttribDefault><AttribRange>0-600</AttribRange></停留时间><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><检测灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>50</AttribDefault><AttribRange>0-100</AttribRange></检测灵敏度></倒地自行车><综治><道板停车><停留时间><AttribType>0</AttribType><AttribInfo>单位:秒</AttribInfo><AttribDefault>30</AttribDefault><AttribRange>0-600</AttribRange></停留时间><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用></道板停车><停留时间><AttribType>0</AttribType><AttribInfo>单位:秒</AttribInfo><AttribDefault>30</AttribDefault><AttribRange>5-600</AttribRange></停留时间><报警周期><AttribType>0</AttribType><AttribInfo>单位:秒(定义综治事件报警的周期)</AttribInfo><AttribDefault>900</AttribDefault><AttribRange>10-86400</AttribRange></报警周期><开启时间><AttribType>2</AttribType><AttribInfo>时间段内生效:hh:mm-hh:mm;hh:mm-hh:mm,最多支持3个时间段</AttribInfo><AttribDefault></AttribDefault><AttribRange>256</AttribRange></开启时间><对象最小像素大小><AttribType>0</AttribType><AttribInfo>过滤w*h&lt;n*n&amp;的对象,n:对象最小像素,[w,h]:对象实际宽高</AttribInfo><AttribDefault>32</AttribDefault><AttribRange>10-1440</AttribRange></对象最小像素大小><交通场景><AttribType>4</AttribType><AttribInfo>只适用于前6个交通场景功能和遗撒</AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></交通场景><城市综治是否启用二次识别><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></城市综治是否启用二次识别><施工占道><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></施工占道><路障><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></路障><积水><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></积水><堆积><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></堆积><广告牌><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></广告牌><护栏倒地><启用><AttribType>4</AttribType><AttribInfo>只交通场景</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></护栏倒地><道路破损><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></道路破损><店外经营><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></店外经营><井盖><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></井盖><垃圾溢出><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></垃圾溢出><自行车乱放><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></自行车乱放><黄土裸露><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></黄土裸露><横幅><启用><AttribType>4</AttribType><AttribInfo>T4版本不支持</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></横幅><电动车入户><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用></电动车入户><综治检测灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></综治检测灵敏度><摆摊><灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>0-100</AttribRange></灵敏度></摆摊><手动设定缩放比><AttribType>1</AttribType><AttribInfo>使用范围大于0.2</AttribInfo><AttribDefault>0.000000</AttribDefault><AttribRange>0.000000-10.000000</AttribRange></手动设定缩放比></综治><违规><停留时间><AttribType>0</AttribType><AttribInfo>单位:秒</AttribInfo><AttribDefault>5</AttribDefault><AttribRange>0-600</AttribRange></停留时间><自行车><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用></自行车><电动车><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用></电动车><手推车><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用></手推车></违规><区域行人密度><密度阈值><AttribType>1</AttribType><AttribInfo>密度报警</AttribInfo><AttribDefault>0.500000</AttribDefault><AttribRange>0.000000-20.000000</AttribRange></密度阈值><人数阈值><AttribType>0</AttribType><AttribInfo>人数报警</AttribInfo><AttribDefault>10</AttribDefault><AttribRange>0-600</AttribRange></人数阈值><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用></区域行人密度><行人非机动车最小像素大小><AttribType>0</AttribType><AttribInfo>过滤w*h&lt;n*n&amp;的对象,n:对象最小像素,[w,h]:对象实际宽高</AttribInfo><AttribDefault>32</AttribDefault><AttribRange>10-1440</AttribRange></行人非机动车最小像素大小><抛洒物检测><启用><AttribType>4</AttribType><AttribInfo>只综治下交通场景</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用></抛洒物检测><摆摊检测><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用></摆摊检测><物品遗留检测><启用><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></启用></物品遗留检测></路口电警></抓拍参数配置></功能配置><结构化信息><显示性别信息><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示性别信息><显示是否带帽><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示是否带帽><显示上身颜色><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示上身颜色><显示下身颜色><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示下身颜色><显示身高><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示身高><显示速度><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示速度><显示外卖品牌><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示外卖品牌><显示快递品牌><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示快递品牌><显示单车品牌><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></显示单车品牌></结构化信息><算法参数设置><是否启用车头模式><AttribType>4</AttribType><AttribInfo>默认车尾模式</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否启用车头模式><是否启用高速模式><AttribType>4</AttribType><AttribInfo>应用于车辆通常速度较高且视频卡顿场景</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否启用高速模式><车牌识别置信度阈值><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>10</AttribDefault><AttribRange>0-101</AttribRange></车牌识别置信度阈值><是否检测无牌车><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否检测无牌车><是否检测行人非机动车><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否检测行人非机动车><是否检测人头><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否检测人头><是否检测交通标志><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否检测交通标志><是否对无牌车补充车牌识别><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否对无牌车补充车牌识别><是否摩托车车牌识别><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否摩托车车牌识别><无牌虚拟车牌大于最小车牌宽度才输出><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></无牌虚拟车牌大于最小车牌宽度才输出><是否保存综治样本><AttribType>4</AttribType><AttribInfo>保存样本</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否保存综治样本><综治样本保存间隔><AttribType>0</AttribType><AttribInfo>最小时间间隔</AttribInfo><AttribDefault>1200</AttribDefault><AttribRange>30-3600</AttribRange></综治样本保存间隔><是否保存行人车辆样本><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否保存行人车辆样本><行人非机动车样本保存间隔><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>3600</AttribDefault><AttribRange>30-3600</AttribRange></行人非机动车样本保存间隔><是否保存电梯样本><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否保存电梯样本><电梯样本保存间隔><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>60</AttribDefault><AttribRange>30-3600</AttribRange></电梯样本保存间隔><是否保存摩托车牌样本><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否保存摩托车牌样本><摩托车牌存图间隔><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>30</AttribDefault><AttribRange>30-3600</AttribRange></摩托车牌存图间隔><摩托车牌存图分数阈值><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>80</AttribDefault><AttribRange>1-99</AttribRange></摩托车牌存图分数阈值><无牌车确认距离阈值><AttribType>0</AttribType><AttribInfo>米</AttribInfo><AttribDefault>0</AttribDefault><AttribRange>0-100</AttribRange></无牌车确认距离阈值><无牌车检测灵敏度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>50</AttribDefault><AttribRange>0-100</AttribRange></无牌车检测灵敏度><行人非机动车检测灵敏度><AttribType>0</AttribType><AttribInfo>街道、电梯间非机动车,行人、头部检测器通用</AttribInfo><AttribDefault>40</AttribDefault><AttribRange>0-100</AttribRange></行人非机动车检测灵敏度><是否保存跟踪图><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否保存跟踪图><是否保存大车检测图><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否保存大车检测图><是否发送Debugger><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否发送Debugger><车辆跟踪最远纵向距离><AttribType>1</AttribType><AttribInfo></AttribInfo><AttribDefault>100.000000</AttribDefault><AttribRange>0.000000-300.000000</AttribRange></车辆跟踪最远纵向距离><车辆跟踪最远横向距离><AttribType>1</AttribType><AttribInfo></AttribInfo><AttribDefault>3.000000</AttribDefault><AttribRange>0.000000-20.000000</AttribRange></车辆跟踪最远横向距离><车牌宽度范围设定方法><AttribType>3</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange>2:0-手动设置&amp;1-自动计算</AttribRange></车牌宽度范围设定方法><车牌识别><本地车牌首字母><AttribType>3</AttribType><AttribInfo>只摩托车</AttribInfo><AttribDefault>0</AttribDefault><AttribRange>26:0-A&amp;1-B&amp;2-C&amp;3-D&amp;4-E&amp;5-F&amp;6-G&amp;7-H&amp;8-I&amp;9-J&amp;10-K&amp;11-L&amp;12-M&amp;13-N&amp;14-O&amp;15-P&amp;16-Q&amp;17-R&amp;18-S&amp;19-T&amp;20-U&amp;21-V&amp;22-W&amp;23-X&amp;24-Y&amp;25-Z</AttribRange></本地车牌首字母><车牌最小宽度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>90</AttribDefault><AttribRange>60-230</AttribRange></车牌最小宽度><车牌最大宽度><AttribType>0</AttribType><AttribInfo></AttribInfo><AttribDefault>130</AttribDefault><AttribRange>60-230</AttribRange></车牌最大宽度><本地汉字><AttribType>3</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange>31:0-京&amp;1-沪&amp;2-津&amp;3-渝&amp;4-冀&amp;5-晋&amp;6-蒙&amp;7-辽&amp;8-吉&amp;9-黑&amp;10-苏&amp;11-浙&amp;12-皖&amp;13-闽&amp;14-赣&amp;15-鲁&amp;16-豫&amp;17-鄂&amp;18-湘&amp;19-粤&amp;20-桂&amp;21-琼&amp;22-川&amp;23-贵&amp;24-云&amp;25-藏&amp;26-陕&amp;27-甘&amp;28-青&amp;29-宁&amp;30-新</AttribRange></本地汉字><是否识别新能源车牌><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>1</AttribDefault><AttribRange /></是否识别新能源车牌></车牌识别><样本存储路径><AttribType>2</AttribType><AttribInfo>训练样本存储路径,所在运行环境</AttribInfo><AttribDefault>/opt/snapshot</AttribDefault><AttribRange>180</AttribRange></样本存储路径><是否存储样本><AttribType>4</AttribType><AttribInfo>在“样本存储路径”修改存储路径</AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否存储样本><调试信息><字体大小><AttribType>0</AttribType><AttribInfo>root\\算法参数设置\\调试信息\\字体大小</AttribInfo><AttribDefault>20</AttribDefault><AttribRange>10-100</AttribRange></字体大小><是否显示Scale><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否显示Scale><是否显示耗时><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否显示耗时><是否显示版本><AttribType>4</AttribType><AttribInfo></AttribInfo><AttribDefault>0</AttribDefault><AttribRange /></是否显示版本></调试信息></算法参数设置></root>\n"
}
}
],
"channelUnid":"xxxxxx",
"deviceUnid":"xxxxxx"
}
```
#### 修改任务
- **path**
- `/fanxing-task-manager/tasks/{taskId}`
- **verb**
- `POST`
- **body**
```json
{
"name": "xxxxx",
"algType": 1,
"resourceNeed": 2,
"storeConfigId": 1,
"vaType": "xxx",
"runType":0,
"runConf":"json",
"rtspPath":"rtsp://xxxxx",
"scene":"xxxx",
"channelUnid":"xxxxxx",
"deviceUnid":"xxxxxx"
}
```
#### 删除任务
- **path**
- `/fanxing-task-manager/tasks/{taskId}`
- **verb**
- `DELETE`
#### 查询任务
- **path**
- `/fanxing-task-manager/tasks`
- `/fanxing-task-manager/tasks/{id}`
- **verb**
- `GET`
- **param**
- `pageSize`
- `page`
#### 获取视频流播放地址
- **path**
- `/fanxing-task-manager/tasks/{taskId}/streamPath`
- **verb**
- `GET`
- **response**
```json
{
"code": 200,
"msg": "OK",
"streamPath": "rtsp://192.168.9.159:10087/task1111111"
}
```
#### 添加存储配置
- **path**
- `/fanxing-task-manager/storeConfig`
- **verb**
- `POST`
- **body**
```json
{
"name": "xxxxx",
"contentFormat": "xml",
"content": "xxxxxxx"
}
```
#### 删除存储配置
- **path**
- `/fanxing-task-manager/storeConfig/{storeConfigId}`
- **verb**
- `DELETE`
#### 查询存储配置
- **path**
- `/fanxing-task-manager/storeConfig`
- `/fanxing-task-manager/storeConfig/{id}`
- **verb**
- `GET`
- **param**
- `pageSize`
- `page`
#### 修改存储配置
- **path**
- `/fanxing-task-manager/storeConfig/{storeConfigId}`
- **verb**
- `POST`
- **body**
```json
{
"name": "xxxxx",
"contentFormat": "xml",
"content": "xxxxxxx"
}
```
### 任务调度模块
#### VAServer注册接口
- **path**
- `/fanxing-task-scheduling/register`
- **verb**
- `POST`
- **body**
```json
{
"devID": "xxx-xx-xx", //设备id
"serviceName": "vaserver",
"videoResource": 10, //资源数
"serviceBaseUrl": "http://192.168.9.159:20083", //服务地址,平台主动调用VAServer时使用
"proxy": "192.168.9.233" //非必要
}
```
- **response**
```json
{
"code": 200,
"msg": "OK",
"resultRecvUrl": "http://192.168.9.159:20080/recv_data/event", //平台接受结果的地址
"videoUploadUrl": "http://192.168.9.159:20080/upload" //录像上传地址
}
```
#### VAServer心跳接口
- **path**
- `/fanxing-task-scheduling/keepalive`
- **verb**
- `POST`
- **body**
```json
{
keepalive: "i am good"
}
```
#### VAServer运行状态推送
- **path**
- `/fanxing-task-scheduling/status`
- **verb**
- `POST`
- **body**
```json
{
tasks:
[
{
"progress": 0, //进度百分比
"status": "Running", //状态,Running Finished
"task_id": "0821fdac47b04b0d9f85ec4a2f9657eb" //任务id
},
{
"task_id": "0a263320bd274b529e5185e3b05aa157",
"status": "Running",
"progress": 0
}
],
resource:
{
"brief":
{
"video_total":10, //视频资源总数
"video_busy":10, //视频资源占用数
"video_free":0 //视频资源剩余数
}
}
}
```
### 转发服务
#### 任务分析结果接收接口
- **path**
- `/fanxing-forward/result`
- **verb**
- `POST`
- **body**
- `沿用之前`
#### 添加转发地址
- **path**
- `/fanxing-forward/forward`
- **verb**
- `POST`
- **body**
```json
{
"name": "xxxx",
"url": "xxxxx",
"config":
[
{
"eventCate":"xxxx",
"eventType":"xxxx"
},
{
"eventCate":"all",
"eventType":"all"
}
]
}
```
#### 查询转发地址
- **path**
- `/fanxing-forward/forward`
- `/fanxing-forward/forward/{id}`
- **verb**
- `GET`
- **param**
- `pageSize`
- `page`
#### 修改转发地址
- **path**
- `/fanxing-forward/forward/{forwardId}`
- **verb**
- `POST`
- **body**
```json
{
"name": "xxxx",
"url": "xxxxx",
"config":
[
{
"eventCate":"xxxx",
"eventType":"xxxx"
},
{
"eventCate":"all",
"eventType":"all"
}
]
}
```
#### 删除转发地址
- **path**
- `/fanxing-forward/forward/{forwardId}`
- **verb**
- `DELETE`
#### 查询转发配置
- **path**
- `/fanxing-forward/forward/{forwardId}/config`
- **verb**
- `GET`
#### 添加转发配置
- **path**
- `/fanxing-forward/forward/{forwardId}/config`
- **verb**
- `POST`
- **body**
```json
[
{
"eventCate":"xxxx",
"eventType":"xxxx"
},
{
"eventCate":"all",
"eventType":"all"
}
]
```
#### 删除转发配置
- **path**
- `/fanxing-forward/forward/{forwardId}/config/{configId}`
- **verb**
- `DELETE`
### 查询服务
#### 交通数据查询
#### 综治数据查询
#### 行人非机动车查询
#### 违法查询
#### 流量查询
### 运维服务
#### 系统校时
#### 服务器、节点、集群状态查询
#### 数据备份导出
#### 数据备份导入
#### 网络配置
#### 地址配置
### VAServer
#### 添加任务
#### 编辑任务
#### 删除任务
#### 获取算法/运行参数
#### 分析结果推送
#### 截图
#### 获取点播地址
- **path**
- `/api/vaserver/v1/get_analyze_stream`
- **verb**
- `POST`
- **body**
```json
{
"taskID": "task1111111" //任务id
}
```
- **response**
```json
{
"code": 200,
"msg": "OK",
"stream_url": "rtsp://192.168.9.159:10087/task1111111"
}
```
#### 开始输出分析流
- **path**
- `/api/vaserver/v1/get_analyze_stream`
- **verb**
- `POST`
- **body**
```json
//开始推送rtmp流
//此接口在点播期间30秒钟调用一次,如果超时,分析会关闭编码通道
{
"taskID": "task1111111", //任务id
"isDrawRect": 1, //是否画框
"mediaServerPushUrl": "rtmp://192.168.9.159:1200/task1111111" //流推送地址
}
```
- **response**
```json
{
"code": 400,
"msg": "task not found"
}
```
#### 录像上传
\ No newline at end of file \ 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</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<!-- 公共服务 -->
<artifactId>fanxing-commons</artifactId>
<version>${parent.version}</version>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.20</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.8.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-data-23</artifactId>
<version>3.13.6</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.25</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
</dependencies>
</project>
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.commons.config;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.spring.data.connection.RedissonConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import java.io.IOException;
/**
* .
*
* @author 谢明辉
* @date 2021/7/5
*/
@Configuration
public class RedissonConfig {
@Bean
public RedissonConnectionFactory redissonConnectionFactory(RedissonClient redisson) {
return new RedissonConnectionFactory(redisson);
}
@Bean(destroyMethod = "shutdown")
public RedissonClient redisson(@Value("classpath:/redisson.yml") Resource configFile) throws IOException {
Config config = Config.fromYAML(configFile.getInputStream());
return Redisson.create(config);
}
}
codec: !<org.redisson.codec.JsonJacksonCodec> { }
"transportMode": "NIO"
# 单机配置
singleServerConfig:
idleConnectionTimeout: 10000
connectTimeout: 10000
timeout: 3000
retryAttempts: 3
retryInterval: 1500
password: vionredis
subscriptionsPerConnection: 5
clientName: null
address: "redis://127.0.0.1:6379"
subscriptionConnectionMinimumIdleSize: 1
subscriptionConnectionPoolSize: 50
connectionMinimumIdleSize: 32
connectionPoolSize: 64
database: 0
dnsMonitoringInterval: 5000
# 集群配置
#clusterServersConfig:
# idleConnectionTimeout: 10000
# connectTimeout: 10000
# timeout: 3000
# retryAttempts: 3
# retryInterval: 1500
# password: null
# subscriptionsPerConnection: 5
# clientName: null
# loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
# slaveSubscriptionConnectionMinimumIdleSize: 1
# slaveSubscriptionConnectionPoolSize: 50
# slaveConnectionMinimumIdleSize: 32
# slaveConnectionPoolSize: 64
# masterConnectionMinimumIdleSize: 32
# masterConnectionPoolSize: 64
# readMode: "SLAVE"
# nodeAddresses:
# - "redis://127.0.0.1:7004"
# - "redis://127.0.0.1:7001"
# - "redis://127.0.0.1:7000"
# scanInterval: 1000
# 哨兵
#sentinelServersConfig:
# idleConnectionTimeout: 10000
# connectTimeout: 10000
# timeout: 3000
# retryAttempts: 3
# retryInterval: 1500
# password: null
# subscriptionsPerConnection: 5
# clientName: null
# loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
# slaveSubscriptionConnectionMinimumIdleSize: 1
# slaveSubscriptionConnectionPoolSize: 50
# slaveConnectionMinimumIdleSize: 32
# slaveConnectionPoolSize: 64
# masterConnectionMinimumIdleSize: 32
# masterConnectionPoolSize: 64
# readMode: "SLAVE"
# sentinelAddresses:
# - "redis://127.0.0.1:26379"
# - "redis://127.0.0.1:26389"
# masterName: "mymaster"
# database: 0
# 主从
#masterSlaveServersConfig:
# idleConnectionTimeout: 10000
# connectTimeout: 10000
# timeout: 3000
# retryAttempts: 3
# retryInterval: 1500
# failedAttempts: 3
# password: null
# subscriptionsPerConnection: 5
# clientName: null
# loadBalancer: !<org.redisson.connection.balancer.RoundRobinLoadBalancer> {}
# slaveSubscriptionConnectionMinimumIdleSize: 1
# slaveSubscriptionConnectionPoolSize: 50
# slaveConnectionMinimumIdleSize: 32
# slaveConnectionPoolSize: 64
# masterConnectionMinimumIdleSize: 32
# masterConnectionPoolSize: 64
# readMode: "SLAVE"
# slaveAddresses:
# - "redis://127.0.0.1:6381"
# - "redis://127.0.0.1:6380"
# masterAddress: "redis://127.0.0.1:6379"
# database: 0
\ No newline at end of file \ 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</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<!-- 转发服务 -->
<artifactId>fanxing-forward</artifactId>
<version>${parent.version}</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>${parent.version}</version>
</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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.forward;
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.scheduling.annotation.EnableScheduling;
/**
* .
*
* @author 谢明辉
* @date 2021/6/11
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableScheduling
@EnableFeignClients
@Slf4j
public class ForwardApp {
public static void main(String[] args) {
try {
SpringApplication.run(ForwardApp.class, args);
} catch (Exception e) {
log.error("forward app start error", e);
}
}
}
package com.viontech.fanxing.forward.controller;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* .
*
* @author 谢明辉
* @date 2021/6/11
*/
@RestController
@RefreshScope
public class MainController {
@Value("${name:default}")
private String name;
@GetMapping("test")
public String test() {
return name;
}
}
spring:
cloud:
consul:
# 服务发现配置
discovery:
# 启用服务发现
enabled: true
# 启用服务注册
register: true
# 服务停止时取消注册
deregister: true
# 表示注册时使用IP而不是hostname
prefer-ip-address: true
# 执行监控检查的频率
health-check-interval: 30s
# 设置健康检查失败多长时间后,取消注册
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
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.9.233:3306/fanxing3
username: root
password: 123456
redis:
host: localhost
port: 6379
password: vionredis
database: 2
logging:
config: classpath:logback-${spring.profiles.active}.xml
\ No newline at end of file \ No newline at end of file
server:
port: 30005
spring:
profiles:
active:
${PROFILE}
application:
name: fanxing-forward
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
\ No newline at end of file \ No newline at end of file
<?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 \ 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 \ 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</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>fanxing-gateway</artifactId>
<version>3.0.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>com.viontech</groupId>
<artifactId>fanxing-commons</artifactId>
<version>${parent.version}</version>
</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>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.forward;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import java.nio.charset.StandardCharsets;
/**
* .
*
* @author 谢明辉
* @date 2021/7/5
*/
@Slf4j
@Component
@RefreshScope
public class AuthorizationFilter implements GlobalFilter {
@Value("${vion.authorization.enable}")
private Boolean enable;
@Override
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
if (enable) {
// todo authorize
return unAuthorized(exchange.getResponse(), "authorization failed");
}
return chain.filter(exchange);
}
private Mono<Void> unAuthorized(ServerHttpResponse response, String msg) {
response.getHeaders().setContentType(MediaType.APPLICATION_JSON);
response.setStatusCode(HttpStatus.UNAUTHORIZED);
return response.writeWith(Flux.just(msg).map(x -> {
byte[] bytes = x.getBytes(StandardCharsets.UTF_8);
return response.bufferFactory().wrap(bytes);
}));
}
}
package com.viontech.fanxing.forward;
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.scheduling.annotation.EnableScheduling;
/**
* .
*
* @author 谢明辉
* @date 2021/6/11
*/
@SpringBootApplication
@EnableDiscoveryClient
@EnableScheduling
@EnableFeignClients
@Slf4j
public class GatewayApp {
public static void main(String[] args) {
try {
SpringApplication.run(GatewayApp.class, args);
} catch (Exception e) {
log.error("gateway app start error", e);
}
}
}
spring:
cloud:
gateway:
globalcors:
cors-configurations:
'[/**]':
allowedOrigins: "*"
allowedMethods:
- ALL
discovery:
locator:
enabled: true
lower-case-service-id: true
consul:
# 服务发现配置
discovery:
# 启用服务发现
enabled: true
# 启用服务注册
register: true
# 服务停止时取消注册
deregister: true
# 表示注册时使用IP而不是hostname
prefer-ip-address: true
# 执行监控检查的频率
health-check-interval: 30s
# 设置健康检查失败多长时间后,取消注册
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
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.9.233:3306/fanxing3
username: root
password: 123456
redis:
host: localhost
port: 6379
password: vionredis
database: 2
logging:
config: classpath:logback-${spring.profiles.active}.xml
\ No newline at end of file \ No newline at end of file
server:
port: 30000
spring:
profiles:
active:
${PROFILE}
application:
name: fanxing-gateway
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 \ 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 \ 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</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<!-- 运维服务 -->
<artifactId>fanxing-ops</artifactId>
<version>${parent.version}</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>${parent.version}</version>
</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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.ops;
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.scheduling.annotation.EnableScheduling;
/**
* .
*
* @author 谢明辉
* @date 2021/6/11
*/
@EnableDiscoveryClient
@EnableScheduling
@SpringBootApplication
@EnableFeignClients
@Slf4j
public class OpsApp {
public static void main(String[] args) {
try {
SpringApplication.run(OpsApp.class, args);
} catch (Exception e) {
log.error("ops app start error", e);
}
}
}
spring:
cloud:
consul:
# 服务发现配置
discovery:
# 启用服务发现
enabled: true
# 启用服务注册
register: true
# 服务停止时取消注册
deregister: true
# 表示注册时使用IP而不是hostname
prefer-ip-address: true
# 执行监控检查的频率
health-check-interval: 30s
# 设置健康检查失败多长时间后,取消注册
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
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.9.233:3306/fanxing3
username: root
password: 123456
redis:
host: localhost
port: 6379
password: vionredis
database: 2
logging:
config: classpath:logback-${spring.profiles.active}.xml
server:
port: 30004
spring:
profiles:
active:
${PROFILE}
application:
name: fanxing-ops
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 \ 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 \ 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</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<!-- 查询服务 -->
<artifactId>fanxing-query</artifactId>
<version>${parent.version}</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>${parent.version}</version>
</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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.query;
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.scheduling.annotation.EnableScheduling;
/**
* .
*
* @author 谢明辉
* @date 2021/6/11
*/
@EnableDiscoveryClient
@EnableScheduling
@SpringBootApplication
@EnableFeignClients
@Slf4j
public class QueryApp {
public static void main(String[] args) {
try{
SpringApplication.run(QueryApp.class, args);
}catch(Exception e){
log.error("query app start error", e);
}
}
}
spring:
cloud:
consul:
# 服务发现配置
discovery:
# 启用服务发现
enabled: true
# 启用服务注册
register: true
# 服务停止时取消注册
deregister: true
# 表示注册时使用IP而不是hostname
prefer-ip-address: true
# 执行监控检查的频率
health-check-interval: 30s
# 设置健康检查失败多长时间后,取消注册
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
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.9.233:3306/fanxing3
username: root
password: 123456
redis:
host: localhost
port: 6379
password: vionredis
database: 2
logging:
config: classpath:logback-${spring.profiles.active}.xml
server:
port: 30003
spring:
profiles:
active:
${PROFILE}
application:
name: fanxing-query
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 \ 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 \ 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</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<!-- 任务管理服务 -->
<artifactId>fanxing-task-manager</artifactId>
<version>${parent.version}</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>${parent.version}</version>
</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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.task.manager;
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.scheduling.annotation.EnableScheduling;
/**
* .
*
* @author 谢明辉
* @date 2021/6/11
*/
@EnableDiscoveryClient
@EnableScheduling
@SpringBootApplication
@EnableFeignClients
@Slf4j
public class TaskManagerApp {
public static void main(String[] args) {
try {
SpringApplication.run(TaskManagerApp.class, args);
} catch (Exception e) {
log.error("taskManager app start error", e);
}
}
}
spring:
cloud:
consul:
# 服务发现配置
discovery:
# 启用服务发现
enabled: true
# 启用服务注册
register: true
# 服务停止时取消注册
deregister: true
# 表示注册时使用IP而不是hostname
prefer-ip-address: true
# 执行监控检查的频率
health-check-interval: 30s
# 设置健康检查失败多长时间后,取消注册
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
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://192.168.9.233:3306/fanxing3
username: root
password: 123456
redis:
host: localhost
port: 6379
password: vionredis
database: 2
logging:
config: classpath:logback-${spring.profiles.active}.xml
server:
port: 30002
spring:
profiles:
active:
${PROFILE}
application:
name: fanxing-task-manager
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 \ 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 \ 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</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<!-- 任务调度服务 -->
<artifactId>fanxing-task-scheduling</artifactId>
<version>${parent.version}</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>${parent.version}</version>
</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>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file \ No newline at end of file
package com.viontech.fanxing.task.scheduling;
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.scheduling.annotation.EnableScheduling;
/**
* .
*
* @author 谢明辉
* @date 2021/6/11
*/
@EnableDiscoveryClient
@EnableScheduling
@SpringBootApplication
@EnableFeignClients
@Slf4j
public class TaskSchedulingApp {
public static void main(String[] args) {
try {
SpringApplication.run(TaskSchedulingApp.class, args);
} catch (Exception e) {
log.error("taskScheduling app start error", e);
}
}
}
package com.viontech.fanxing.task.scheduling.config;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.spring.data.connection.RedissonConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
import java.io.IOException;
/**
* .
*
* @author 谢明辉
* @date 2021/7/5
*/
@Configuration
public class RedissonConfig {
@Bean
public RedissonConnectionFactory redissonConnectionFactory(RedissonClient redisson) {
return new RedissonConnectionFactory(redisson);
}
@Bean(destroyMethod = "shutdown")
public RedissonClient redisson(@Value("classpath:/redisson.yml") Resource configFile) throws IOException {
Config config = Config.fromYAML(configFile.getInputStream());
return Redisson.create(config);
}
}
spring:
cloud:
consul:
# 服务发现配置
discovery:
# 启用服务发现
enabled: true
# 启用服务注册
register: true
# 服务停止时取消注册
deregister: true
# 表示注册时使用IP而不是hostname
prefer-ip-address: true
# 执行监控检查的频率
health-check-interval: 30s
# 设置健康检查失败多长时间后,取消注册
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
redis:
host: localhost
port: 6379
password: vionredis
database: 2
autoconfigure:
exclude: org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
logging:
config: classpath:logback-${spring.profiles.active}.xml
server:
port: 30001
spring:
profiles:
active:
${PROFILE}
application:
name: fanxing-task-scheduling
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 \ 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 \ 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>
<groupId>com.viontech</groupId>
<artifactId>fanxing3</artifactId>
<version>3.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>fanxing-commons</module>
<module>fanxing-gateway</module>
<module>fanxing-task-manager</module>
<module>fanxing-task-scheduling</module>
<module>fanxing-forward</module>
<module>fanxing-ops</module>
<module>fanxing-query</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>
</project>
\ No newline at end of file \ 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!