feat:合并
parent
cd41265b79
commit
3bd6aeb39d
|
@ -1,6 +1,5 @@
|
||||||
# Tomcat
|
# Tomcat
|
||||||
server:
|
server:
|
||||||
<<<<<<<< HEAD:cloud-modules/cloud-modules-data-processing/src/main/resources/bootstrap.yml
|
|
||||||
port: 9711
|
port: 9711
|
||||||
|
|
||||||
# nacos线上地址
|
# nacos线上地址
|
||||||
|
@ -9,16 +8,6 @@ nacos:
|
||||||
user-name: nacos
|
user-name: nacos
|
||||||
password: nacos
|
password: nacos
|
||||||
namespace: one-saas
|
namespace: one-saas
|
||||||
========
|
|
||||||
port: 10010
|
|
||||||
|
|
||||||
# nacos线上地址
|
|
||||||
nacos:
|
|
||||||
addr: 110.42.213.184:8848
|
|
||||||
user-name: nacos
|
|
||||||
password: nacos
|
|
||||||
namespace: icecream
|
|
||||||
>>>>>>>> dev.saas.customer:cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/resources/bootstrap.yml
|
|
||||||
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||||
# Spring
|
# Spring
|
||||||
spring:
|
spring:
|
||||||
|
@ -37,11 +26,7 @@ spring:
|
||||||
allow-bean-definition-overriding: true
|
allow-bean-definition-overriding: true
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
<<<<<<<< HEAD:cloud-modules/cloud-modules-data-processing/src/main/resources/bootstrap.yml
|
|
||||||
name: cloud-data-processing
|
name: cloud-data-processing
|
||||||
========
|
|
||||||
name: cloud-car
|
|
||||||
>>>>>>>> dev.saas.customer:cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/resources/bootstrap.yml
|
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
active: dev
|
active: dev
|
||||||
|
@ -50,19 +35,19 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
# # nacos用户名
|
# nacos用户名
|
||||||
# username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# # nacos密码
|
# nacos密码
|
||||||
# password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
config:
|
config:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: ${nacos.addr}
|
server-addr: ${nacos.addr}
|
||||||
# # nacos用户名
|
# nacos用户名
|
||||||
# username: ${nacos.user-name}
|
username: ${nacos.user-name}
|
||||||
# # nacos密码
|
# nacos密码
|
||||||
# password: ${nacos.password}
|
password: ${nacos.password}
|
||||||
# 命名空间
|
# 命名空间
|
||||||
namespace: ${nacos.namespace}
|
namespace: ${nacos.namespace}
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
|
@ -84,7 +69,4 @@ logging:
|
||||||
level:
|
level:
|
||||||
com.muyu.system.mapper: DEBUG
|
com.muyu.system.mapper: DEBUG
|
||||||
|
|
||||||
<<<<<<<< HEAD:cloud-modules/cloud-modules-data-processing/src/main/resources/bootstrap.yml
|
|
||||||
cacheNames: fault,fence,warming
|
cacheNames: fault,fence,warming
|
||||||
========
|
|
||||||
>>>>>>>> dev.saas.customer:cloud-modules/cloud-modules-openbusiness/cloud-modules-openbusiness-server/src/main/resources/bootstrap.yml
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package com.muyu.openbusiness.mapper;
|
package com.muyu.openbusiness.mapper;
|
||||||
|
|
||||||
import com.github.yulichang.base.MPJBaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.openbusiness.domain.Messages;
|
import com.muyu.openbusiness.domain.Messages;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ spring:
|
||||||
allow-bean-definition-overriding: true
|
allow-bean-definition-overriding: true
|
||||||
application:
|
application:
|
||||||
# 应用名称
|
# 应用名称
|
||||||
name: cloud-parsing
|
name: cloud-car
|
||||||
profiles:
|
profiles:
|
||||||
# 环境配置
|
# 环境配置
|
||||||
active: dev
|
active: dev
|
||||||
|
|
|
@ -0,0 +1,121 @@
|
||||||
|
<?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.muyu</groupId>
|
||||||
|
<artifactId>cloud-modules</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>cloud-modules-parsing</artifactId>
|
||||||
|
<description>
|
||||||
|
cloud-modules-parsing 协议解析模块
|
||||||
|
</description>
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<!-- SpringCloud Alibaba Nacos -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Nacos Config -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringCloud Alibaba Sentinel -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- SpringBoot Actuator -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- Mysql Connector -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataSource -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-datasource</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common DataScope -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-datascope</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- MuYu Common Log -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-log</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 接口模块 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-api-doc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- XllJob定时任务 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-xxl</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-rabbit</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bouncycastle</groupId>
|
||||||
|
<artifactId>bcpkix-jdk15on</artifactId>
|
||||||
|
<version>1.70</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- kafka-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>cloud-common-kafka</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!-- mqtt-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>1.2.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>repackage</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.parsing;
|
||||||
|
|
||||||
|
import com.muyu.common.security.annotation.EnableCustomConfig;
|
||||||
|
import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统模块
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
*/
|
||||||
|
@EnableCustomConfig
|
||||||
|
//@EnableCustomSwagger2
|
||||||
|
@EnableMyFeignClients
|
||||||
|
@SpringBootApplication
|
||||||
|
public class CloudParsingApplication {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(CloudParsingApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,182 @@
|
||||||
|
package com.muyu.parsing.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
|
import com.muyu.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.muyu.common.core.web.controller.BaseController;
|
||||||
|
import com.muyu.common.kafka.constants.KafkaConstants;
|
||||||
|
import com.muyu.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.muyu.parsing.domain.KafKaData;
|
||||||
|
import com.muyu.parsing.domain.SysCarMessage;
|
||||||
|
import com.muyu.parsing.domain.resp.SysMessageResp;
|
||||||
|
import com.muyu.parsing.service.ISysCarMessageService;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
|
import org.apache.kafka.clients.producer.ProducerConfig;
|
||||||
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||||
|
import org.apache.kafka.common.serialization.StringSerializer;
|
||||||
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆报文记录Controller
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-18
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/messageInfo")
|
||||||
|
public class SysCarMessageController extends BaseController {
|
||||||
|
@Resource
|
||||||
|
private ISysCarMessageService sysCarMessageService;
|
||||||
|
@Resource
|
||||||
|
private KafkaProducer<String, String> kafkaProducer;
|
||||||
|
static String TEST = "56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56 56";
|
||||||
|
|
||||||
|
// @Autowired
|
||||||
|
// private KafkaTemplate<String, Object> kafkaTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆报文记录列表
|
||||||
|
*/
|
||||||
|
// @RequiresPermissions("message:message:list")
|
||||||
|
@Transactional
|
||||||
|
@GetMapping("/list")
|
||||||
|
public Result<List<SysCarMessage>> list(SysCarMessage sysCarMessage) throws ExecutionException, InterruptedException {
|
||||||
|
|
||||||
|
List<SysCarMessage> list = sysCarMessageService.selectSysCarMessageList(sysCarMessage);
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
return Result.error(); //为空返回错误信息
|
||||||
|
}
|
||||||
|
List<KafKaData> kafKaDataList = new ArrayList<>();
|
||||||
|
String[] test = TEST.split(" ");
|
||||||
|
String[] results = new String[list.size()];
|
||||||
|
// HashMap<String, CompletableFuture<String>> futures = new HashMap<>();
|
||||||
|
for (SysCarMessage carMessage : list) {
|
||||||
|
int start = Integer.parseInt(carMessage.getMessageStartIndex()) - 1;
|
||||||
|
int end = Integer.parseInt(carMessage.getMessageEndIndex());
|
||||||
|
StringBuilder hexBuilder = new StringBuilder();
|
||||||
|
for (int i = start; i < end; i++) {
|
||||||
|
hexBuilder.append(test[i]);
|
||||||
|
}
|
||||||
|
String hex = hexBuilder.toString();
|
||||||
|
char[] result = new char[hex.length() / 2];
|
||||||
|
for (int x = 0; x < hex.length(); x += 2) {
|
||||||
|
int high = Character.digit(hex.charAt(x), 16);
|
||||||
|
int low = Character.digit(hex.charAt(x + 1), 16);
|
||||||
|
result[x / 2] = (char) ((high << 4) + low);
|
||||||
|
}
|
||||||
|
String value = new String(result);
|
||||||
|
kafKaDataList.add(KafKaData.builder()
|
||||||
|
.key(carMessage.getMessageTypeCode())
|
||||||
|
.label(carMessage.getMessageTypeCode())
|
||||||
|
.value(value)
|
||||||
|
.type("String")
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
|
||||||
|
// String jsonString = """
|
||||||
|
// [{
|
||||||
|
// "key": "vin",
|
||||||
|
// "label": "VIN码",
|
||||||
|
// "type": "String",
|
||||||
|
// "value": "vin131413534474"
|
||||||
|
// },{
|
||||||
|
// "key": "timestamp",
|
||||||
|
// "label": "时间戳",
|
||||||
|
// "type": "String",
|
||||||
|
// "value": "1727525252127"
|
||||||
|
// },{
|
||||||
|
// "key": "latitude",
|
||||||
|
// "label": "纬度",
|
||||||
|
// "type": "String",
|
||||||
|
// "value": "66.898"
|
||||||
|
// },{
|
||||||
|
// "key": "longitude",
|
||||||
|
// "label": "经度",
|
||||||
|
// "type": "String",
|
||||||
|
// "value": "99.124"
|
||||||
|
// }]""";
|
||||||
|
String jsonString = JSONObject.toJSONString(kafKaDataList);
|
||||||
|
ProducerRecord<String, String> producerRecord = new ProducerRecord<>(KafkaConstants.KafkaTopic, jsonString);
|
||||||
|
kafkaProducer.send(producerRecord);
|
||||||
|
log.info("消息发送成功:{}", jsonString);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequiresPermissions("message:message:dobList")
|
||||||
|
@GetMapping("/dobList")
|
||||||
|
public Result<List<SysMessageResp>> dobList(SysMessageResp sysMessageResp) {
|
||||||
|
List<SysMessageResp> list = sysCarMessageService.dobList(sysMessageResp);
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出车辆报文记录列表
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("message:message:export")
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, SysCarMessage sysCarMessage) {
|
||||||
|
List<SysCarMessage> list = sysCarMessageService.selectSysCarMessageList(sysCarMessage);
|
||||||
|
ExcelUtil<SysCarMessage> util = new ExcelUtil<SysCarMessage>(SysCarMessage.class);
|
||||||
|
util.exportExcel(response, list, "车辆报文记录数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆报文记录详细信息
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("message:message:query")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public Result<List<SysCarMessage>> getInfo(@PathVariable("id") Long id) {
|
||||||
|
return success(sysCarMessageService.selectSysCarMessageById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增车辆报文记录
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("message:message:add")
|
||||||
|
@PostMapping
|
||||||
|
public Result<Integer> add(
|
||||||
|
@Validated @RequestBody SysCarMessage sysCarMessage) {
|
||||||
|
if (sysCarMessageService.checkIdUnique(sysCarMessage)) {
|
||||||
|
return error("新增 车辆报文记录 '" + sysCarMessage + "'失败,车辆报文记录已存在");
|
||||||
|
}
|
||||||
|
return toAjax(sysCarMessageService.save(sysCarMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改车辆报文记录
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("message:message:edit")
|
||||||
|
@PutMapping
|
||||||
|
public Result<Integer> edit(
|
||||||
|
@Validated @RequestBody SysCarMessage sysCarMessage) {
|
||||||
|
if (!sysCarMessageService.checkIdUnique(sysCarMessage)) {
|
||||||
|
return error("修改 车辆报文记录 '" + sysCarMessage + "'失败,车辆报文记录不存在");
|
||||||
|
}
|
||||||
|
return toAjax(sysCarMessageService.updateById(sysCarMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除车辆报文记录
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("message:message:remove")
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public Result<Integer> remove(@PathVariable("ids") Long[] ids) {
|
||||||
|
sysCarMessageService.removeBatchByIds(Arrays.asList(ids));
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.muyu.parsing.domain;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 报文消息 ktlv
|
||||||
|
*
|
||||||
|
* @ClassName KafKaData
|
||||||
|
* @Description 描述
|
||||||
|
* @Author Chen
|
||||||
|
* @Date 2024/9/28 20:41
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@ToString//
|
||||||
|
public class KafKaData implements Serializable {
|
||||||
|
private String key;
|
||||||
|
private String value;
|
||||||
|
private String type;
|
||||||
|
private String label;
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package com.muyu.parsing.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆报文记录对象 sys_car_message
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-18
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@TableName("sys_car_message")
|
||||||
|
public class SysCarMessage implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 自增主键 */
|
||||||
|
@TableId( type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 车辆型号编码 */
|
||||||
|
@Excel(name = "车辆型号编码")
|
||||||
|
private String modelCode;
|
||||||
|
|
||||||
|
/** 车辆报文类型编码 */
|
||||||
|
@Excel(name = "i")
|
||||||
|
private String messageTypeCode;
|
||||||
|
|
||||||
|
/** 开始位下标 */
|
||||||
|
@Excel(name = "开始位下标")
|
||||||
|
private String messageStartIndex;
|
||||||
|
|
||||||
|
/** 结束位下标 */
|
||||||
|
@Excel(name = "结束位下标")
|
||||||
|
private String messageEndIndex;
|
||||||
|
|
||||||
|
/** 报文分类 */
|
||||||
|
@Excel(name = "报文分类")
|
||||||
|
private String messageType;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("modelCode", getModelCode())
|
||||||
|
.append("messageTypeCode", getMessageTypeCode())
|
||||||
|
.append("messageStartIndex", getMessageStartIndex())
|
||||||
|
.append("messageEndIndex", getMessageEndIndex())
|
||||||
|
.append("messageType", getMessageType())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.muyu.parsing.domain.resp;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆报文类型对象 sys_message_type
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-18
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class SysMessageResp {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
private Long id;
|
||||||
|
private String modelCode;
|
||||||
|
private String messageTypeCode;
|
||||||
|
private String messageStartIndex;
|
||||||
|
private String messageEndIndex;
|
||||||
|
private String messageType;
|
||||||
|
private String messageName;
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.muyu.parsing.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
import com.muyu.parsing.domain.SysCarMessage;
|
||||||
|
import com.muyu.parsing.domain.resp.SysMessageResp;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆报文记录Mapper接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-18
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface SysCarMessageMapper extends BaseMapper<SysCarMessage>{
|
||||||
|
List<SysMessageResp>dobList(SysMessageResp sysMessageResp);
|
||||||
|
}
|
|
@ -0,0 +1,127 @@
|
||||||
|
package com.muyu.parsing.mqtt;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.muyu.common.kafka.constants.KafkaConstants;
|
||||||
|
import com.muyu.parsing.domain.KafKaData;
|
||||||
|
import com.muyu.parsing.domain.SysCarMessage;
|
||||||
|
import com.muyu.parsing.service.impl.SysCarMessageServiceImpl;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.kafka.clients.producer.KafkaProducer;
|
||||||
|
import org.apache.kafka.clients.producer.ProducerRecord;
|
||||||
|
import org.eclipse.paho.client.mqttv3.*;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mqtt
|
||||||
|
*
|
||||||
|
* @ClassName MqttTest
|
||||||
|
* @Description 描述
|
||||||
|
* @Author Chen
|
||||||
|
* @Date 2024/9/28 23:49
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class MqttTest {
|
||||||
|
private static final Integer ID = 1;
|
||||||
|
private static final Integer CODE = 1;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private KafkaProducer<String, String> kafkaProducer;
|
||||||
|
@Resource
|
||||||
|
private SysCarMessageServiceImpl sysCarMessageService;
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void Test() {
|
||||||
|
String topic = "vehicle";
|
||||||
|
String content = "Message from MqttPublishSample";
|
||||||
|
int qos = 2;
|
||||||
|
String broker = "tcp://106.15.136.7:1883";
|
||||||
|
String clientId = "JavaSample";
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 第三个参数为空,默认持久化策略
|
||||||
|
MqttClient sampleClient = new MqttClient(broker, clientId);
|
||||||
|
MqttConnectOptions connOpts = new MqttConnectOptions();
|
||||||
|
connOpts.setCleanSession(true);
|
||||||
|
System.out.println("Connecting to broker: " + broker);
|
||||||
|
sampleClient.connect(connOpts);
|
||||||
|
sampleClient.subscribe(topic, 0);
|
||||||
|
sampleClient.setCallback(new MqttCallback() {
|
||||||
|
// 连接丢失
|
||||||
|
@Override
|
||||||
|
public void connectionLost(Throwable throwable) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 连接成功
|
||||||
|
@Override
|
||||||
|
public void messageArrived(String s, MqttMessage mqttMessage) throws Exception {
|
||||||
|
List<SysCarMessage> list = sysCarMessageService.selectSysCarMessageLists(ID);
|
||||||
|
String string = new String(mqttMessage.getPayload());
|
||||||
|
log.info(new String(mqttMessage.getPayload()));
|
||||||
|
List<KafKaData> kafKaDataList = new ArrayList<>();
|
||||||
|
String[] test = string.split(" ");
|
||||||
|
// String[] results = new String[list.size()];
|
||||||
|
for (SysCarMessage carMessage : list) {
|
||||||
|
int start = Integer.parseInt(carMessage.getMessageStartIndex()) - 1;
|
||||||
|
int end = Integer.parseInt(carMessage.getMessageEndIndex());
|
||||||
|
StringBuilder hexBuilder = new StringBuilder();
|
||||||
|
for (int i = start; i < end; i++) {
|
||||||
|
hexBuilder.append(test[i]);
|
||||||
|
}
|
||||||
|
String hex = hexBuilder.toString();
|
||||||
|
char[] result = new char[hex.length() / 2];
|
||||||
|
for (int x = 0; x < hex.length(); x += 2) {
|
||||||
|
int high = Character.digit(hex.charAt(x), 16);
|
||||||
|
int low = Character.digit(hex.charAt(x + 1), 16);
|
||||||
|
result[x / 2] = (char) ((high << 4) + low);
|
||||||
|
}
|
||||||
|
String value = new String(result);
|
||||||
|
kafKaDataList.add(KafKaData.builder()
|
||||||
|
.key(carMessage.getMessageTypeCode())
|
||||||
|
.label(carMessage.getMessageTypeCode())
|
||||||
|
.value(value)
|
||||||
|
.type(carMessage.getMessageType())
|
||||||
|
.build());
|
||||||
|
}
|
||||||
|
kafKaDataList.add(KafKaData.builder()
|
||||||
|
.key("firmCode")
|
||||||
|
.label("企业编码")
|
||||||
|
.value("firm01")
|
||||||
|
.type("String")
|
||||||
|
.build());
|
||||||
|
String jsonString = JSONObject.toJSONString(kafKaDataList);
|
||||||
|
|
||||||
|
ProducerRecord<String, String> producerRecord = new ProducerRecord<>(KafkaConstants.KafkaTopic, jsonString);
|
||||||
|
kafkaProducer.send(producerRecord);
|
||||||
|
log.info("kafka投产:{}", jsonString);
|
||||||
|
// HashMap<String, String> stringStringHashMap = new HashMap<>();
|
||||||
|
// kafKaDataList.forEach(data -> stringStringHashMap.put(data.getKey(), data.getValue()));
|
||||||
|
// jsonString = JSONObject.toJSONString(stringStringHashMap);
|
||||||
|
// System.out.println(jsonString);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 接收信息
|
||||||
|
@Override
|
||||||
|
public void deliveryComplete(IMqttDeliveryToken iMqttDeliveryToken) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
} catch (MqttException me) {
|
||||||
|
System.out.println("reason " + me.getReasonCode());
|
||||||
|
System.out.println("msg " + me.getMessage());
|
||||||
|
System.out.println("loc " + me.getLocalizedMessage());
|
||||||
|
System.out.println("cause " + me.getCause());
|
||||||
|
System.out.println("excep " + me);
|
||||||
|
me.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.muyu.parsing.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.parsing.domain.SysCarMessage;
|
||||||
|
import com.muyu.parsing.domain.resp.SysMessageResp;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆报文记录Service接口
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-18
|
||||||
|
*/
|
||||||
|
public interface ISysCarMessageService extends IService<SysCarMessage> {
|
||||||
|
|
||||||
|
List<SysMessageResp>dobList(SysMessageResp sysMessageResp);
|
||||||
|
/**
|
||||||
|
* 精确查询车辆报文记录
|
||||||
|
*
|
||||||
|
* @param id 车辆报文记录主键
|
||||||
|
* @return 车辆报文记录
|
||||||
|
*/
|
||||||
|
public SysCarMessage selectSysCarMessageById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆报文记录列表
|
||||||
|
*
|
||||||
|
* @param sysCarMessage 车辆报文记录
|
||||||
|
* @return 车辆报文记录集合
|
||||||
|
*/
|
||||||
|
public List<SysCarMessage> selectSysCarMessageList(SysCarMessage sysCarMessage);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断 车辆报文记录 id是否唯一
|
||||||
|
* @param sysCarMessage 车辆报文记录
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
Boolean checkIdUnique(SysCarMessage sysCarMessage);
|
||||||
|
|
||||||
|
// Boolean checkById(SysCarMessage sysCarMessage);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
package com.muyu.parsing.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
||||||
|
import com.muyu.common.core.utils.StringUtils;
|
||||||
|
import com.muyu.parsing.domain.SysCarMessage;
|
||||||
|
import com.muyu.parsing.domain.resp.SysMessageResp;
|
||||||
|
import com.muyu.parsing.mapper.SysCarMessageMapper;
|
||||||
|
import com.muyu.parsing.service.ISysCarMessageService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆报文记录Service业务层处理
|
||||||
|
*
|
||||||
|
* @author muyu
|
||||||
|
* @date 2024-09-18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysCarMessageServiceImpl
|
||||||
|
extends ServiceImpl<SysCarMessageMapper, SysCarMessage>
|
||||||
|
implements ISysCarMessageService {
|
||||||
|
@Autowired
|
||||||
|
private SysCarMessageMapper mapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysMessageResp> dobList(SysMessageResp sysMessageResp) {
|
||||||
|
return mapper.dobList(sysMessageResp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 精确查询车辆报文记录
|
||||||
|
*
|
||||||
|
* @param id 车辆报文记录主键
|
||||||
|
* @return 车辆报文记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysCarMessage selectSysCarMessageById(Long id) {
|
||||||
|
LambdaQueryWrapper<SysCarMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
Assert.notNull(id, "id不可为空");
|
||||||
|
queryWrapper.eq(SysCarMessage::getId, id);
|
||||||
|
return this.getOne(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆报文记录列表
|
||||||
|
*
|
||||||
|
* @param sysCarMessage 车辆报文记录
|
||||||
|
* @return 车辆报文记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysCarMessage> selectSysCarMessageList(SysCarMessage sysCarMessage) {
|
||||||
|
LambdaQueryWrapper<SysCarMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (StringUtils.isNotEmpty(sysCarMessage.getModelCode())) {
|
||||||
|
queryWrapper.eq(SysCarMessage::getModelCode, sysCarMessage.getModelCode());
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotEmpty(sysCarMessage.getMessageType())) {
|
||||||
|
queryWrapper.eq(SysCarMessage::getMessageType, sysCarMessage.getMessageType());
|
||||||
|
}
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 唯一 判断
|
||||||
|
*
|
||||||
|
* @param sysCarMessage 车辆报文记录
|
||||||
|
* @return 车辆报文记录
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Boolean checkIdUnique(SysCarMessage sysCarMessage) {
|
||||||
|
LambdaQueryWrapper<SysCarMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysCarMessage::getId, sysCarMessage.getId());
|
||||||
|
return this.count(queryWrapper) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SysCarMessage> selectSysCarMessageLists(int id) {
|
||||||
|
LambdaQueryWrapper<SysCarMessage> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(SysCarMessage::getModelCode, id);
|
||||||
|
// queryWrapper.eq(SysCarMessage::getMessageType, modelCode);
|
||||||
|
return this.list(queryWrapper);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// @Override
|
||||||
|
// public Boolean checkById(SysMessageType sysMessageType) {
|
||||||
|
// LambdaQueryWrapper<SysCarMessage> sysCarMessageLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
// sysCarMessageLambdaQueryWrapper.eq(SysCarMessage::getMessageType, sysMessageType);
|
||||||
|
//// sysCarMessageLambdaQueryWrapper.eq(SysCarMessage::getMessageType, sysMessageType);
|
||||||
|
// sysCarMessageLambdaQueryWrapper.eq(SysCarMessage::get, sysMessageType);
|
||||||
|
//// return this.count(sysCarMessageLambdaQueryWrapper) > 0;
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
Spring Boot Version: ${spring-boot.version}
|
||||||
|
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,77 @@
|
||||||
|
# Tomcat
|
||||||
|
server:
|
||||||
|
port: 10010
|
||||||
|
|
||||||
|
# nacos线上地址
|
||||||
|
nacos:
|
||||||
|
addr: 49.235.136.60:8848
|
||||||
|
user-name: nacos
|
||||||
|
password: nacos
|
||||||
|
namespace: wyh
|
||||||
|
# SPRING_AMQP_DESERIALIZATION_TRUST_ALL=true spring.amqp.deserialization.trust.all
|
||||||
|
# Spring
|
||||||
|
spring:
|
||||||
|
amqp:
|
||||||
|
deserialization:
|
||||||
|
trust:
|
||||||
|
all: true
|
||||||
|
main:
|
||||||
|
allow-bean-definition-overriding: true
|
||||||
|
application:
|
||||||
|
# 应用名称
|
||||||
|
name: cloud-parsing
|
||||||
|
profiles:
|
||||||
|
# 环境配置
|
||||||
|
active: dev
|
||||||
|
cloud:
|
||||||
|
nacos:
|
||||||
|
discovery:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos.addr}
|
||||||
|
# # nacos用户名
|
||||||
|
# username: ${nacos.user-name}
|
||||||
|
# # nacos密码
|
||||||
|
# password: ${nacos.password}
|
||||||
|
# 命名空间
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
config:
|
||||||
|
# 服务注册地址
|
||||||
|
server-addr: ${nacos.addr}
|
||||||
|
# # nacos用户名
|
||||||
|
# username: ${nacos.user-name}
|
||||||
|
# # nacos密码
|
||||||
|
# password: ${nacos.password}
|
||||||
|
# 命名空间
|
||||||
|
namespace: ${nacos.namespace}
|
||||||
|
# 配置文件格式
|
||||||
|
file-extension: yml
|
||||||
|
# 共享配置
|
||||||
|
shared-configs:
|
||||||
|
# 系统共享配置
|
||||||
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# 系统环境Config共享配置
|
||||||
|
- application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# xxl-job 配置文件
|
||||||
|
- application-xxl-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
# rabbit 配置文件
|
||||||
|
- application-rabbit-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
logging:
|
||||||
|
level:
|
||||||
|
com.muyu.system.mapper: DEBUG
|
||||||
|
#mqtt:
|
||||||
|
# host:tcp://172.0.0.1:1883
|
||||||
|
# userName: root
|
||||||
|
# passWord: 11
|
||||||
|
### MQTT##
|
||||||
|
mqtt:
|
||||||
|
host: tcp://192.168.10.198:1883
|
||||||
|
userName: root
|
||||||
|
passWord: 123456
|
||||||
|
qos: 1
|
||||||
|
clientId: ClientId_local #ClientId_local必须唯一 比如你已经定了叫ABC 那你就一直叫ABC 其他地方就不要使用ABC了
|
||||||
|
timeout: 10
|
||||||
|
keepalive: 20
|
||||||
|
topic1: A/pick/warn/# #符号是代表整个warn下面的全部子主题 没有理解的话 可以百度仔细理解一下
|
||||||
|
topic2: A/cmd/resp
|
||||||
|
topic3: ABCF
|
||||||
|
topic4: ABCH
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="logs/cloud-system"/>
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="com.muyu" level="info"/>
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn"/>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info"/>
|
||||||
|
<appender-ref ref="file_error"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,81 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="logs/cloud-system"/>
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.sky.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 使用gRpc将日志发送到skywalking服务端 -->
|
||||||
|
<appender name="GRPC_LOG" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
|
||||||
|
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||||
|
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||||
|
<Pattern>${log.sky.pattern}</Pattern>
|
||||||
|
</layout>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="com.muyu" level="info"/>
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn"/>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="GRPC_LOG"/>
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info"/>
|
||||||
|
<appender-ref ref="file_error"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -0,0 +1,81 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
<!-- 日志存放路径 -->
|
||||||
|
<property name="log.path" value="logs/cloud-system"/>
|
||||||
|
<!-- 日志输出格式 -->
|
||||||
|
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
<property name="log.sky.pattern" value="%d{HH:mm:ss.SSS} %yellow([%tid]) [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
|
||||||
|
|
||||||
|
<!-- 控制台输出 -->
|
||||||
|
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>${log.sky.pattern}</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统日志输出 -->
|
||||||
|
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/info.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>INFO</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/error.log</file>
|
||||||
|
<!-- 循环政策:基于时间创建日志文件 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||||
|
<!-- 日志文件名格式 -->
|
||||||
|
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||||
|
<!-- 日志最大的历史 60天 -->
|
||||||
|
<maxHistory>60</maxHistory>
|
||||||
|
</rollingPolicy>
|
||||||
|
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 过滤的级别 -->
|
||||||
|
<level>ERROR</level>
|
||||||
|
<!-- 匹配时的操作:接收(记录) -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 使用gRpc将日志发送到skywalking服务端 -->
|
||||||
|
<appender name="GRPC_LOG" class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.log.GRPCLogClientAppender">
|
||||||
|
<encoder class="ch.qos.logback.core.encoder.LayoutWrappingEncoder">
|
||||||
|
<layout class="org.apache.skywalking.apm.toolkit.log.logback.v1.x.TraceIdPatternLogbackLayout">
|
||||||
|
<Pattern>${log.sky.pattern}</Pattern>
|
||||||
|
</layout>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- 系统模块日志级别控制 -->
|
||||||
|
<logger name="com.muyu" level="info"/>
|
||||||
|
<!-- Spring日志级别控制 -->
|
||||||
|
<logger name="org.springframework" level="warn"/>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="GRPC_LOG"/>
|
||||||
|
<appender-ref ref="console"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<!--系统操作日志-->
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="file_info"/>
|
||||||
|
<appender-ref ref="file_error"/>
|
||||||
|
</root>
|
||||||
|
</configuration>
|
|
@ -14,6 +14,7 @@
|
||||||
<module>cloud-modules-file</module>
|
<module>cloud-modules-file</module>
|
||||||
<module>cloud-modules-openbusiness</module>
|
<module>cloud-modules-openbusiness</module>
|
||||||
<module>cloud-modules-data-processing</module>
|
<module>cloud-modules-data-processing</module>
|
||||||
|
<module>cloud-modules-parsing</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>cloud-modules</artifactId>
|
<artifactId>cloud-modules</artifactId>
|
||||||
|
|
Loading…
Reference in New Issue