feat():增加添加报文模版功能
parent
dfacea67f6
commit
6545fc79ef
|
@ -0,0 +1,85 @@
|
|||
<?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-template</artifactId>
|
||||
|
||||
<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>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,27 @@
|
|||
package com.muyu.template;
|
||||
|
||||
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 liuxinyue
|
||||
* @Package:com.muyu.template
|
||||
* @name:CloudTemplateApplication
|
||||
* @Date:2024/9/30 10:36
|
||||
*/
|
||||
|
||||
@EnableCustomConfig
|
||||
//@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
public class CloudTemplateApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
SpringApplication.run(CloudTemplateApplication.class, args);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.muyu.template.service;
|
||||
|
||||
/**
|
||||
* @author liuxinyue
|
||||
* @Package:com.muyu.template.service
|
||||
* @name:TemplateService
|
||||
* @Date:2024/9/30 10:57
|
||||
*/
|
||||
public interface TemplateService {
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.muyu.template.service.impl;
|
||||
|
||||
import com.muyu.template.service.TemplateService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author liuxinyue
|
||||
* @Package:com.muyu.template.service.impl
|
||||
* @name:TemplateServiceImpl
|
||||
* @Date:2024/9/30 10:57
|
||||
*/
|
||||
@Service
|
||||
public class TemplateServiceImpl implements TemplateService {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -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-saas"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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-saas"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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-saas"/>
|
||||
<!-- 日志输出格式 -->
|
||||
<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,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.server.mapper.CarTypeMapper">
|
||||
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<!--
|
||||
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||
-->
|
||||
<mapper namespace="com.muyu.server.mapper.EnterpriseDao">
|
||||
|
||||
<!--查询企业信息-->
|
||||
<select id="selectEnterprise" resultType="HashMap" parameterType="Map">
|
||||
select *
|
||||
from tb_enterprise
|
||||
<where>
|
||||
<if test="enterpriseName != null">
|
||||
and enterprise_name like concat('%',#{enterpriseName},'%')
|
||||
</if>
|
||||
</where>
|
||||
limit #{start},#{length}
|
||||
</select>
|
||||
|
||||
<!--查询企业记录总数-->
|
||||
<select id="selectEnterpriseCount" resultType="Long">
|
||||
select count(enterprise_id)
|
||||
from tb_enterprise
|
||||
</select>
|
||||
|
||||
<!--新增企业信息-->
|
||||
<insert id="insert" parameterType="com.muyu.server.mapper.EnterpriseDao">
|
||||
insert into tb_enterprise
|
||||
set enterprise_name = #{enterpriseName},
|
||||
enterprise_car_count = #{enterpriseCarCount},
|
||||
enterprise_fence_count = #{enterpriseFenceCount}
|
||||
</insert>
|
||||
|
||||
|
||||
|
||||
<!--根据编号查询企业信息-->
|
||||
<select id="searchById" resultType="java.util.HashMap">
|
||||
select enterprise_id,enterprise_name,enterprise_car_count,enterprise_fence_count
|
||||
from tb_enterprise
|
||||
where enterprise_id = #{enterpriseId}
|
||||
</select>
|
||||
<!--修改企业信息-->
|
||||
<update id="updateEnterprise" parameterType="com.muyu.common.domain.Enterprise">
|
||||
update tb_enterprise
|
||||
set enterprise_name = #{enterpriseName},
|
||||
enterprise_car_count = #{enterpriseCarCount},
|
||||
enterprise_fence_count = #{enterpriseFenceCount}
|
||||
where enterprise_id = #{enterpriseId} and enterprise_id != 0
|
||||
</update>
|
||||
|
||||
|
||||
|
||||
<!--删除企业信息-->
|
||||
<delete id="deleteByIds">
|
||||
delete from tb_enterprise
|
||||
where enterprise_id in
|
||||
<foreach collection="ids" open="(" separator="," close=")" item="one">
|
||||
#{one}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.server.mapper.SysCarMapper">
|
||||
<insert id="addSysCar">
|
||||
INSERT INTO `four`.`sys_car`
|
||||
( `car_vin`, `car_type_id`, `state`, `car_motor_manufacturer`, `car_motor_model`,
|
||||
`car_battery_manufacturer`, `car_battery_model`, `strategy_id`,`group_id`, `create_by`, `create_time`, `update_by`, `update_time`, `remark`,)
|
||||
VALUES (#{carVin}, #{carTypeId}, '1', #{carMotorManufacturer}, #{carMotorModel},
|
||||
#{carBatteryManufacturer}, #{carBatteryModel}, #{strategyId},#{groupId},#{createBy}, #{createTime}, #{updateBy}, #{updateTime}, #{remark})
|
||||
</insert>
|
||||
<update id="updSysCarById">
|
||||
UPDATE `four`.`sys_car`
|
||||
SET `car_vin` = #{carVin},
|
||||
`car_type_id` = #{carTypeId},
|
||||
`state` = #{state},
|
||||
`car_motor_manufacturer` = #{carMotorManufacturer},
|
||||
`car_motor_model` = #{carMotorModel},
|
||||
`car_battery_manufacturer` = #{carBatteryManufacturer},
|
||||
`car_battery_model` = #{carBatteryModel},
|
||||
`strategy_id` = #{strategyId},
|
||||
`group_id`=#{groupId}
|
||||
`create_by` = #{createBy},
|
||||
`create_time` = #{createTime},
|
||||
`update_by` = #{updateBy},
|
||||
`update_time` = #{updateTime},
|
||||
`remark` = #{remark} WHERE `id` = #{id}
|
||||
</update>
|
||||
<select id="selectSysCarVoList" resultType="com.muyu.common.domain.resp.SysCarVo">
|
||||
SELECT * ,car_type.type_name,warn_strategy.strategy_name,electronic_fence_group.group_name
|
||||
FROM `sys_car`
|
||||
LEFT JOIN car_type ON sys_car.car_type_id=car_type.id
|
||||
LEFT JOIN warn_strategy ON sys_car.strategy_id=warn_strategy.id
|
||||
LEFT JOIN electronic_fence_group ON sys_car.group_id=electronic_fence_group.id
|
||||
<where>
|
||||
<if test="carVin!=null and carVin!=''">
|
||||
sys_car.car_vin=#{carVin}
|
||||
</if>
|
||||
<if test="state!=null and state!=''">
|
||||
and sys_car.state=#{state}
|
||||
</if>
|
||||
<if test="carMotorManufacturer!=null and carMotorManufacturer!=''">
|
||||
and sys_car.car_motor_manufacturer=#{carMotorManufacturer}
|
||||
</if>
|
||||
<if test="carBatteryManufacturer!=null and carBatteryManufacturer!=''">
|
||||
and sys_car.car_battery_manufacturer=#{carBatteryManufacturer}
|
||||
</if>
|
||||
<if test="carMotorModel!=null and carMotorModel!=''">
|
||||
and sys_car.car_motor_model=#{carMotorModel}
|
||||
</if>
|
||||
<if test="carBatteryModel!=null and carBatteryModel!=''">
|
||||
and sys_car.car_battery_model=#{carBatteryModel}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectSysCarVoById" resultType="com.muyu.common.domain.resp.SysCarVo">
|
||||
SELECT * ,car_type.type_name,warn_strategy.strategy_name,electronic_fence_group.group_name
|
||||
FROM `sys_car`
|
||||
LEFT JOIN car_type ON sys_car.car_type_id=car_type.id
|
||||
LEFT JOIN warn_strategy ON sys_car.strategy_id=warn_strategy.id
|
||||
LEFT JOIN electronic_fence_group ON sys_car.group_id=electronic_fence_group.id
|
||||
where sys_car.id=#{id}
|
||||
</select>
|
||||
<select id="findFenceByCarVin" resultType="com.muyu.common.domain.resp.SysCarFaultLogVo">
|
||||
SELECT
|
||||
sys_car_fault_log.*,
|
||||
sys_car_fault.*
|
||||
FROM
|
||||
sys_car_fault_log
|
||||
LEFT JOIN sys_car_fault ON sys_car_fault_log.sys_car_fault_id = sys_car_fault.id
|
||||
WHERE
|
||||
sys_car_fault_log.vin = #{carVin};
|
||||
</select>
|
||||
<select id="findCarByVin" resultType="com.muyu.common.domain.SysCar">
|
||||
select * from sys_car where car_vin=#{carVin}
|
||||
</select>
|
||||
<select id="selectByCarVin" resultType="com.muyu.common.domain.SysCar">
|
||||
select * from sys_car where car_cin=#{carVin}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.server.mapper.TemplateNeedMapper">
|
||||
|
||||
<select id="selectByTemplateId" resultType="com.muyu.common.domain.MessageTemplateType">
|
||||
SELECT * FROM `message_template_type` WHERE template_id=#{templateId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.muyu.server.mapper.WarnLogsMapper">
|
||||
<insert id="addWarnLog">
|
||||
INSERT INTO warn_logs VALUES
|
||||
<foreach collection="list" item="warnLogs" index="index" separator=",">
|
||||
(#{warnLogs.id})
|
||||
</foreach>
|
||||
</insert>
|
||||
<select id="selectWarnLogsList" resultType="com.muyu.common.domain.resp.WarnLogsResp">
|
||||
SELECT
|
||||
*,
|
||||
warn_rule.rule_name
|
||||
FROM
|
||||
warn_logs
|
||||
LEFT JOIN warn_rule
|
||||
ON warn_logs.warn_rule_id = warn_rule.id
|
||||
</select>
|
||||
<select id="selectWarnLogs" resultType="com.muyu.common.domain.resp.WarnLogsResp">
|
||||
SELECT
|
||||
*,
|
||||
warn_rule.rule_name
|
||||
FROM
|
||||
warn_logs
|
||||
LEFT JOIN warn_rule
|
||||
ON warn_logs.warn_rule_id = warn_rule.id
|
||||
where warn_rule.id=#{id}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.muyu.server.mapper.WarnRuleMapper">
|
||||
|
||||
<select id="selectListByStrategyId" resultType="com.muyu.common.domain.resp.WarnRuleResp">
|
||||
SELECT * ,warn_strategy.strategy_name,
|
||||
message_template_type.message_field
|
||||
FROM `warn_rule`
|
||||
LEFT JOIN warn_strategy ON warn_rule.strategy_id=warn_strategy.id
|
||||
LEFT JOIN message_template_type ON warn_rule.msg_type_id=message_template_type.message_template_type_id
|
||||
WHERE warn_rule.strategy_id=#{strategyId}
|
||||
</select>
|
||||
<select id="selectWarnRuleRespList" resultType="com.muyu.common.domain.resp.WarnRuleResp">
|
||||
SELECT * ,warn_strategy.strategy_name,
|
||||
message_template_type.message_field
|
||||
FROM `warn_rule`
|
||||
LEFT JOIN warn_strategy ON warn_rule.strategy_id=warn_strategy.id
|
||||
LEFT JOIN message_template_type ON warn_rule.msg_type_id=message_template_type.message_template_type_id
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.muyu.server.mapper.WarnStrategyMapper">
|
||||
<select id="selectWarnStrategyList" resultType="com.muyu.common.domain.resp.WarnStrategyResp">
|
||||
SELECT *,
|
||||
car_type.type_name,
|
||||
t_template.template_name
|
||||
FROM `warn_strategy`
|
||||
LEFT JOIN car_type ON warn_strategy.car_type_id=car_type.id
|
||||
LEFT JOIN t_template ON warn_strategy.template_id=t_template.template_id
|
||||
<where>
|
||||
<if test="carTypeId!=null and carTypeId!=''">
|
||||
car_type.id=#{carTypeId}
|
||||
</if>
|
||||
<if test="strategyName!=null and strategyName!=''">
|
||||
and warn_strategy.strategy_name=#{strategyName}
|
||||
</if>
|
||||
<if test="templateId!=null and templateId!=''">
|
||||
and t_template.template_id=#{templateId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectListByCarType" resultType="com.muyu.common.domain.resp.WarnStrategyResp">
|
||||
SELECT *,
|
||||
car_type.type_name,
|
||||
t_template.template_name
|
||||
FROM `warn_strategy`
|
||||
LEFT JOIN car_type ON warn_strategy.car_type_id=car_type.id
|
||||
LEFT JOIN t_template ON warn_strategy.template_id=t_template.template_id
|
||||
where warn_strategy.car_type_id=#{carTypeId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -24,6 +24,7 @@
|
|||
<module>saas</module>
|
||||
<module>cloud-modules-vehiclegateway</module>
|
||||
<module>cloud-event</module>
|
||||
<module>cloud-modules-template</module>
|
||||
</modules>
|
||||
|
||||
<artifactId>cloud-modules</artifactId>
|
||||
|
|
|
@ -3,11 +3,13 @@ package com.muyu.common.domain;
|
|||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
@ -47,5 +49,7 @@ public class Template {
|
|||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ public class MqttConfigure {
|
|||
@Autowired
|
||||
private TemplateService templateService;
|
||||
|
||||
|
||||
@PostConstruct
|
||||
public void MQTTMonitoring(){
|
||||
String topic = "vehicle";
|
||||
|
|
|
@ -6,13 +6,11 @@ import com.muyu.server.service.TemplateService;
|
|||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.apache.iotdb.rpc.IoTDBConnectionException;
|
||||
import org.apache.iotdb.rpc.StatementExecutionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
@ -25,6 +23,7 @@ import java.util.concurrent.ExecutionException;
|
|||
* @name:TemplateController
|
||||
* @Date:2024/9/20 12:12
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/template")
|
||||
@AllArgsConstructor
|
||||
|
@ -58,6 +57,18 @@ public class TemplateController {
|
|||
return Result.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 报文模版添加
|
||||
* @param template
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/addTemplate")
|
||||
@Operation(summary = "报文模版添加",description = "报文模版添加")
|
||||
public Result addTemplate(@RequestBody Template template) {
|
||||
boolean save = templateService.save(template);
|
||||
log.info("添加的结果为:"+save);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ public class MessageTemplateTypeServiceImpl extends ServiceImpl<MessageTemplate
|
|||
public List<MessageTemplateType> findTemplateById(Integer templateId) {
|
||||
QueryWrapper<MessageTemplateType> messageTemplateTypeQueryWrapper = new QueryWrapper<>();
|
||||
messageTemplateTypeQueryWrapper.eq("template_id",templateId);
|
||||
return List.of();
|
||||
List<MessageTemplateType> messageTemplateTypes = messageTemplateTypeMapper.selectList(messageTemplateTypeQueryWrapper);
|
||||
return messageTemplateTypes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.server.service.impl;
|
|||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.domain.MessageTemplateType;
|
||||
import com.muyu.common.domain.SysCar;
|
||||
import com.muyu.common.domain.Template;
|
||||
|
@ -46,69 +47,65 @@ public class TemplateServiceImpl extends ServiceImpl<TemplateMapper, Template> i
|
|||
|
||||
|
||||
@Override
|
||||
public void messageParsing(String templateMessage) throws SQLException, IoTDBConnectionException, ClassNotFoundException, StatementExecutionException, ExecutionException, InterruptedException {
|
||||
public void messageParsing(String messageStr) throws SQLException, IoTDBConnectionException, ClassNotFoundException, StatementExecutionException, ExecutionException, InterruptedException {
|
||||
|
||||
//给一个JSON对象
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
//先截取出VIN码 然后根据VIN码查询这个车属于什么类型
|
||||
if (templateMessage.length() < 18) {
|
||||
throw new RuntimeException("The vehicle message is incorrect");
|
||||
}
|
||||
//将报文进行切割
|
||||
String[] hexArray = templateMessage.split(" ");
|
||||
//根据空格切割数据
|
||||
String[] hexArray = messageStr.split(" ");
|
||||
StringBuilder result = new StringBuilder();
|
||||
//遍历十六进制数据转换为字符
|
||||
for (String hex : hexArray) {
|
||||
int decimal = Integer.parseInt(hex, 16);
|
||||
result.append((char) decimal);
|
||||
}
|
||||
//取出VIN码
|
||||
String carVin = result.substring(0, 18 - 1);
|
||||
log.info("carVin码为:" + carVin);
|
||||
//取出车辆VIN码
|
||||
String vehicleVin = result.substring(1, 18);
|
||||
log.info("车辆VIN码: " + vehicleVin);
|
||||
//根据VIN码获取车辆信息
|
||||
SysCar carByVin = sysCarService.findCarByVin(carVin);
|
||||
log.info("车辆信息为:" + carByVin);
|
||||
//对应车辆所对应的报文模版
|
||||
SysCar carByVin = sysCarService.findCarByVin(vehicleVin);
|
||||
Integer templateId = carByVin.getTemplateId();
|
||||
|
||||
List<MessageTemplateType> templateTypeList;
|
||||
|
||||
//key
|
||||
String redisKey = "messageTemplateType" + templateId;
|
||||
|
||||
//key存在
|
||||
if (redisTemplate.hasKey(redisKey)) {
|
||||
|
||||
List list = redisTemplate.opsForList().range(redisKey, 0, -1);
|
||||
|
||||
templateTypeList = list.stream().map(o -> JSON.parseObject(o.toString(), MessageTemplateType.class))
|
||||
.toList();
|
||||
|
||||
} else {
|
||||
List<MessageTemplateType> templateTypeList1 = messageTemplateTypeService.findTemplateById(templateId);
|
||||
templateTypeList = templateTypeList1;
|
||||
templateTypeList.forEach(
|
||||
templateType ->
|
||||
redisTemplate.opsForList().rightPush(
|
||||
redisKey, com.alibaba.fastjson.JSON.toJSONString(templateType)
|
||||
)
|
||||
);
|
||||
List<MessageTemplateType> templateList;
|
||||
//从redis缓存中获取报文模板数据
|
||||
try {
|
||||
String redisKey = "messageTemplate" + templateId;
|
||||
if (redisTemplate.hasKey(redisKey)) {
|
||||
List<Object> list = redisTemplate.opsForList().range(redisKey, 0, -1);
|
||||
templateList = list.stream()
|
||||
.map(obj -> JSON.parseObject(obj.toString(), MessageTemplateType.class))
|
||||
.toList();
|
||||
log.info("Redis缓存查询成功");
|
||||
} else {
|
||||
List<MessageTemplateType> byTemplateId = messageTemplateTypeService.findTemplateById(templateId);
|
||||
log.info(byTemplateId);
|
||||
templateList = byTemplateId;
|
||||
templateList.forEach(
|
||||
listResp ->
|
||||
redisTemplate.opsForList().rightPush(
|
||||
redisKey, JSON.toJSONString(listResp)
|
||||
)
|
||||
);
|
||||
log.info("数据库查询成功");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("获取报文模板失败");
|
||||
}
|
||||
//将模版里面有的配置进行循环
|
||||
for (MessageTemplateType messageTemplateType : templateTypeList) {
|
||||
//开始位置
|
||||
Integer startIndex = messageTemplateType.getStartIndex() - 1;
|
||||
//结束位置
|
||||
Integer endIndex = messageTemplateType.getEndIndex();
|
||||
//将每个解析后的字段都存入到JSON对象中
|
||||
jsonObject.put(messageTemplateType.getMessageField(), result.substring(startIndex, endIndex));
|
||||
//判断报文模板列表不为空
|
||||
if (templateList.isEmpty()) {
|
||||
throw new RuntimeException("报文模版为空");
|
||||
}
|
||||
//存储报文模版解析后的数据
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
for (MessageTemplateType messageValue : templateList) {
|
||||
//起始位下标
|
||||
Integer startIndex = messageValue.getStartIndex() - 1;
|
||||
//结束位下标
|
||||
Integer endIndex = messageValue.getEndIndex();
|
||||
//根据报文模版截取数据
|
||||
|
||||
System.out.println("哈哈哈红红火火恍恍惚惚");
|
||||
log.info("解析后的报文是:" + jsonObject);
|
||||
|
||||
|
||||
String value = result.substring(startIndex, endIndex);
|
||||
//存入数据
|
||||
jsonObject.put(messageValue.getMessageField(), value);
|
||||
}
|
||||
System.out.println(jsonObject);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue