第一次提交
commit
3ed2417133
@ -0,0 +1,37 @@
|
||||
# 三一沈阳实时驱动
|
||||
|
||||
#### 介绍
|
||||
三一华睿实时驱动数据,如机械臂数据等。
|
||||
|
||||
#### 软件架构
|
||||
软件架构说明
|
||||
|
||||
|
||||
#### 安装教程
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 使用说明
|
||||
|
||||
1. xxxx
|
||||
2. xxxx
|
||||
3. xxxx
|
||||
|
||||
#### 参与贡献
|
||||
|
||||
1. Fork 本仓库
|
||||
2. 新建 Feat_xxx 分支
|
||||
3. 提交代码
|
||||
4. 新建 Pull Request
|
||||
|
||||
|
||||
#### 特技
|
||||
|
||||
1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md
|
||||
2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com)
|
||||
3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目
|
||||
4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
|
||||
5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help)
|
||||
6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/)
|
@ -0,0 +1,77 @@
|
||||
<?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.6.7</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<groupId>com.ipsplm</groupId>
|
||||
<artifactId>sany-shenyang-realtime-drive</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>sany-shenyang-realtime-drive</name>
|
||||
<description>三一沈阳实时驱动</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.76</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
</dependency>
|
||||
<!--自定义通用模块-->
|
||||
<dependency>
|
||||
<groupId>com.ipsplm</groupId>
|
||||
<artifactId>common-api</artifactId>
|
||||
<version>1.0</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!--数据库多数据源-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||
<version>2.5.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
<version>3.0.6</version>
|
||||
</dependency>
|
||||
<!--spring整合kafka-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.kafka</groupId>
|
||||
<artifactId>spring-kafka</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,16 @@
|
||||
package com.ipsplm;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SanyShenYangRealtimeDriveApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
|
||||
SpringApplication.run(SanyShenYangRealtimeDriveApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.ipsplm.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
* @Description 跨域配置
|
||||
* @Author FanDongqiang
|
||||
* @Date 2023/1/12 9:37
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class CrossConfig implements WebMvcConfigurer {
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/**") // 允许跨域访问的路径
|
||||
.allowedOriginPatterns("*") // 允许跨域访问的源
|
||||
.allowedMethods("GET", "POST","PUT", "DELETE", "OPTIONS") // 允许请求方法
|
||||
.allowCredentials(true) // 是否发送cookie
|
||||
.maxAge(3600); // 预检间隔时间
|
||||
}
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package com.ipsplm.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
|
||||
import org.springframework.kafka.config.KafkaListenerContainerFactory;
|
||||
import org.springframework.kafka.core.ConsumerFactory;
|
||||
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
|
||||
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
|
||||
|
||||
@Configuration
|
||||
public class FirstKafkaConfig {
|
||||
/**
|
||||
* 读取第一个kafka配置
|
||||
* Primary注解表示默认以这个为准
|
||||
*
|
||||
* @return 第一个kafka配置
|
||||
*/
|
||||
@Primary
|
||||
@ConfigurationProperties(prefix = "spring.kafka.first")
|
||||
@Bean
|
||||
public KafkaProperties firstKafkaProperties() {
|
||||
return new KafkaProperties();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 构建第一个kafka的生产者发送template
|
||||
// *
|
||||
// * @param firstKafkaProperties 第一个kafka配置
|
||||
// * @return 第一个kafka的生产者发送template
|
||||
// */
|
||||
// @Primary
|
||||
// @Bean
|
||||
// public KafkaTemplate<String, String> firstKafkaTemplate(
|
||||
// @Autowired @Qualifier("firstKafkaProperties") KafkaProperties firstKafkaProperties) {
|
||||
// return new KafkaTemplate<>(firstProducerFactory(firstKafkaProperties));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 构建第一个kafka的消费者监听容器工厂
|
||||
*
|
||||
* @param firstKafkaProperties 第一个kafka配置
|
||||
* @return 第一个kafka的消费者监听容器工厂
|
||||
*/
|
||||
@Bean("firstKafkaListenerContainerFactory")
|
||||
public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<Integer, String>>
|
||||
firstKafkaListenerContainerFactory(@Autowired @Qualifier("firstKafkaProperties") KafkaProperties firstKafkaProperties) {
|
||||
ConcurrentKafkaListenerContainerFactory<Integer, String> factory =
|
||||
new ConcurrentKafkaListenerContainerFactory<>();
|
||||
factory.setConsumerFactory(firstConsumerFactory(firstKafkaProperties));
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建第一个kafka的消费者工厂
|
||||
*
|
||||
* @param firstKafkaProperties 第一个kafka配置
|
||||
* @return 第一个kafka的消费者工厂
|
||||
*/
|
||||
private ConsumerFactory<? super Integer, ? super String> firstConsumerFactory(KafkaProperties firstKafkaProperties) {
|
||||
return new DefaultKafkaConsumerFactory<>(firstKafkaProperties.buildConsumerProperties());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 新建第一个kafka的生产者工厂
|
||||
// *
|
||||
// * @param firstKafkaProperties 第一个kafka配置
|
||||
// * @return 第一个kafka的生产者工厂
|
||||
// */
|
||||
// private DefaultKafkaProducerFactory<String, String> firstProducerFactory(KafkaProperties firstKafkaProperties) {
|
||||
// return new DefaultKafkaProducerFactory<>(firstKafkaProperties.buildProducerProperties());
|
||||
// }
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.ipsplm.config;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@MapperScan(basePackages = "com.ipsplm.dao")
|
||||
public class MybatisPlusConfig {
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
|
||||
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
|
||||
return interceptor;
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.ipsplm.config;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.ipsplm.listener.RedisListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CachingConfigurerSupport;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
/**
|
||||
* @Description redis配置
|
||||
* @Author FanDongqiang
|
||||
* @Date 2023/2/3 13:36
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfig extends CachingConfigurerSupport {
|
||||
@Autowired
|
||||
private RedisListener redisListener;
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
objectMapper.registerModule(new JavaTimeModule());
|
||||
objectMapper.registerModule((new SimpleModule()));
|
||||
//有属性不能映射的时候不报错
|
||||
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
|
||||
//对象为空时不抛异常
|
||||
objectMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL,
|
||||
JsonTypeInfo.As.PROPERTY);
|
||||
|
||||
GenericJackson2JsonRedisSerializer serializer = new GenericJackson2JsonRedisSerializer(objectMapper);
|
||||
|
||||
// key采用String的序列化方式
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
// value序列化方式采用jackson
|
||||
template.setValueSerializer(serializer);
|
||||
|
||||
// Hash的key也采用StringRedisSerializer的序列化方式
|
||||
template.setHashKeySerializer(new StringRedisSerializer());
|
||||
// Hash的value序列化方式采用jackson
|
||||
template.setHashValueSerializer(serializer);
|
||||
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
|
||||
@Bean
|
||||
RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
|
||||
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
|
||||
container.setConnectionFactory(connectionFactory);
|
||||
container.addMessageListener(redisListener, redisListener.getTopic());
|
||||
return container;
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.ipsplm.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.kafka.KafkaProperties;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
|
||||
import org.springframework.kafka.config.KafkaListenerContainerFactory;
|
||||
import org.springframework.kafka.core.ConsumerFactory;
|
||||
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
|
||||
import org.springframework.kafka.core.DefaultKafkaProducerFactory;
|
||||
import org.springframework.kafka.core.KafkaTemplate;
|
||||
import org.springframework.kafka.listener.ConcurrentMessageListenerContainer;
|
||||
|
||||
@Configuration
|
||||
public class SecondKafkaConfig {
|
||||
/**
|
||||
* 读取第二个kafka配置
|
||||
*
|
||||
* @return 第二个kafka配置
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.kafka.second")
|
||||
@Bean
|
||||
public KafkaProperties secondKafkaProperties() {
|
||||
return new KafkaProperties();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 构建第二个kafka的生产者发送template
|
||||
// *
|
||||
// * @param secondKafkaProperties 第二个kafka配置
|
||||
// * @return 第二个kafka的生产者发送template
|
||||
// */
|
||||
// @Bean
|
||||
// public KafkaTemplate<String, String> secondKafkaTemplate(
|
||||
// @Autowired @Qualifier("secondKafkaProperties") KafkaProperties secondKafkaProperties) {
|
||||
// return new KafkaTemplate<>(secondProducerFactory(secondKafkaProperties));
|
||||
// }
|
||||
|
||||
/**
|
||||
* 构建第二个kafka的消费者监听容器工厂
|
||||
*
|
||||
* @param secondKafkaProperties 第二个kafka配置
|
||||
* @return 第二个kafka的消费者监听容器工厂
|
||||
*/
|
||||
@Bean("secondKafkaListenerContainerFactory")
|
||||
public KafkaListenerContainerFactory<ConcurrentMessageListenerContainer<Integer, String>>
|
||||
secondKafkaListenerContainerFactory(@Autowired @Qualifier("secondKafkaProperties") KafkaProperties secondKafkaProperties) {
|
||||
ConcurrentKafkaListenerContainerFactory<Integer, String> factory =
|
||||
new ConcurrentKafkaListenerContainerFactory<>();
|
||||
factory.setConsumerFactory(secondConsumerFactory(secondKafkaProperties));
|
||||
return factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建第二个kafka的消费者工厂
|
||||
*
|
||||
* @param secondKafkaProperties 第二个kafka配置
|
||||
* @return 第二个kafka的消费者工厂
|
||||
*/
|
||||
private ConsumerFactory<? super Integer, ? super String> secondConsumerFactory(KafkaProperties secondKafkaProperties) {
|
||||
return new DefaultKafkaConsumerFactory<>(secondKafkaProperties.buildConsumerProperties());
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 新建第二个kafka的生产者工厂
|
||||
// *
|
||||
// * @param secondKafkaProperties 第二个kafka配置
|
||||
// * @return 第二个kafka的生产者工厂
|
||||
// */
|
||||
// private DefaultKafkaProducerFactory<String, String> secondProducerFactory(KafkaProperties secondKafkaProperties) {
|
||||
// return new DefaultKafkaProducerFactory<>(secondKafkaProperties.buildProducerProperties());
|
||||
// }
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.ipsplm.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ipsplm.entity.iot.IotDeviceList;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Description IOT设备清单表Mapper
|
||||
* @Author FanDongqiang
|
||||
* @Date 2023/2/16 10:19
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Mapper
|
||||
public interface IotDeviceListMapper extends BaseMapper<IotDeviceList> {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.ipsplm.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ipsplm.entity.iot.XaIotDeviceList;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface XaIotDeviceListMapper extends BaseMapper<XaIotDeviceList> {
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.ipsplm.dao;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ipsplm.entity.iot.XaIotDeviceListSync;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface XaIotDeviceListSyncMapper extends BaseMapper<XaIotDeviceListSync> {
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package com.ipsplm.entity.common;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description 基础实体类
|
||||
* @Author FanDongqiang
|
||||
* @Date 2023/2/20 10:38
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
public class BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField("creator")
|
||||
private Long creator;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("gmt_created")
|
||||
private Date gmtCreated;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField("editor")
|
||||
private Long editor;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("gmt_modified")
|
||||
private Date gmtModified;
|
||||
}
|
@ -0,0 +1,161 @@
|
||||
package com.ipsplm.entity.iot;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description IOT设备清单表
|
||||
* @Author FanDongqiang
|
||||
* @Date 2023/2/16 10:15
|
||||
* @Version 1.0
|
||||
*/
|
||||
@TableName("iot_device_list")
|
||||
@Data
|
||||
public class IotDeviceList implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键ID
|
||||
* iot_device_list.id
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 工厂
|
||||
* iot_device_list.factory
|
||||
*/
|
||||
@TableField("factory")
|
||||
private String factory;
|
||||
|
||||
/**
|
||||
* 厂房代码
|
||||
* iot_device_list.workshop
|
||||
*/
|
||||
@TableField("workshop")
|
||||
private String workshop;
|
||||
|
||||
/**
|
||||
* 设备编号
|
||||
* iot_device_list.device_num
|
||||
*/
|
||||
@TableField("device_num")
|
||||
private String deviceNum;
|
||||
|
||||
/**
|
||||
* 厂房描述
|
||||
* iot_device_list.workshop_desc
|
||||
*/
|
||||
@TableField("workshop_desc")
|
||||
private String workshopDesc;
|
||||
|
||||
/**
|
||||
* 设备型号
|
||||
* iot_device_list.device_model
|
||||
*/
|
||||
@TableField("device_model")
|
||||
private String deviceModel;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
* iot_device_list.device_name
|
||||
*/
|
||||
@TableField("device_name")
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 设备位置
|
||||
* iot_device_list.device_position
|
||||
*/
|
||||
@TableField("device_position")
|
||||
private String devicePosition;
|
||||
|
||||
/**
|
||||
* 设备等级
|
||||
* iot_device_list.device_grade
|
||||
*/
|
||||
@TableField("device_grade")
|
||||
private String deviceGrade;
|
||||
|
||||
/**
|
||||
* 使用状态
|
||||
* iot_device_list.use_state
|
||||
*/
|
||||
@TableField("use_state")
|
||||
private String useState;
|
||||
|
||||
/**
|
||||
* 工作中心
|
||||
* iot_device_list.work_center
|
||||
*/
|
||||
@TableField("work_center")
|
||||
private String workCenter;
|
||||
|
||||
/**
|
||||
* 管理工作中心
|
||||
* iot_device_list.manage_work_center
|
||||
*/
|
||||
@TableField("manage_work_center")
|
||||
private String manageWorkCenter;
|
||||
|
||||
/**
|
||||
* 设备操作员名称
|
||||
* iot_device_list.operator
|
||||
*/
|
||||
@TableField("operator")
|
||||
private String operator;
|
||||
|
||||
/**
|
||||
* 班组
|
||||
* iot_device_list.team_group
|
||||
*/
|
||||
@TableField("team_group")
|
||||
private String teamGroup;
|
||||
|
||||
/**
|
||||
* 制造厂商
|
||||
* iot_device_list.manufacturer
|
||||
*/
|
||||
@TableField("manufacturer")
|
||||
private String manufacturer;
|
||||
|
||||
/**
|
||||
* 工位编号
|
||||
* iot_device_list.station
|
||||
*/
|
||||
@TableField("station")
|
||||
private String station;
|
||||
|
||||
/**
|
||||
* 备件包编号
|
||||
* iot_device_list.spares_kit_num
|
||||
*/
|
||||
@TableField("spares_kit_num")
|
||||
private String sparesKitNum;
|
||||
|
||||
/**
|
||||
* 备件包描述
|
||||
* iot_device_list.spares_kit_desc
|
||||
*/
|
||||
@TableField("spares_kit_desc")
|
||||
private String sparesKitDesc;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
* iot_device_list.device_type
|
||||
*/
|
||||
@TableField("device_type")
|
||||
private String deviceType;
|
||||
|
||||
/**
|
||||
* websocket分组ID
|
||||
* iot_device_list.websocket_group_id
|
||||
*/
|
||||
@TableField("websocket_group_id")
|
||||
private Integer websocketGroupId;
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.ipsplm.entity.iot;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@TableName("xazz_iot_device_list")
|
||||
public class XaIotDeviceList implements Serializable {
|
||||
//主键id
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
//设备编号
|
||||
@TableField("device_num")
|
||||
private String deviceNum;
|
||||
//设备名称
|
||||
@TableField("device_name")
|
||||
private String deviceName;
|
||||
//设备型号
|
||||
@TableField("device_model")
|
||||
private String deviceModel;
|
||||
//公司名称
|
||||
@TableField("company_name")
|
||||
private String companyName;
|
||||
//工作中心名称
|
||||
@TableField("work_center_name")
|
||||
private String workCenterName;
|
||||
//班组名称
|
||||
@TableField("product_line")
|
||||
private String teamGroupName;
|
||||
//一级工艺
|
||||
@TableField("first_process")
|
||||
private String firstProcess;
|
||||
//二级工艺
|
||||
@TableField("sec_process")
|
||||
private String secProcess;
|
||||
//websocket分组
|
||||
@TableField("websocket_group_id")
|
||||
private Integer websocketGroupId;
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package com.ipsplm.entity.iot;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
@Data
|
||||
@TableName("xazz_iot_device_list_sync")
|
||||
public class XaIotDeviceListSync implements Serializable {
|
||||
//主键id
|
||||
@TableId(value = "id",type = IdType.AUTO)
|
||||
private Long id;
|
||||
//设备编号
|
||||
@TableField("device_num")
|
||||
private String deviceNum;
|
||||
//设备名称
|
||||
@TableField("device_name")
|
||||
private String deviceName;
|
||||
//设备型号
|
||||
@TableField("device_model")
|
||||
private String deviceModel;
|
||||
//公司名称
|
||||
@TableField("company_name")
|
||||
private String companyName;
|
||||
//工作中心名称
|
||||
@TableField("work_center_name")
|
||||
private String workCenterName;
|
||||
//班组名称
|
||||
@TableField("product_line")
|
||||
private String teamGroupName;
|
||||
//一级工艺
|
||||
@TableField("first_process")
|
||||
private String firstProcess;
|
||||
//二级工艺
|
||||
@TableField("sec_process")
|
||||
private String secProcess;
|
||||
//websocket分组
|
||||
@TableField("websocket_group_id")
|
||||
private Integer websocketGroupId;
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package com.ipsplm.listener;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.ipsplm.entity.iot.IotDeviceRealInfo;
|
||||
import com.ipsplm.utils.RedisUtils;
|
||||
import com.ipsplm.websocket.*;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.data.redis.connection.Message;
|
||||
import org.springframework.data.redis.connection.MessageListener;
|
||||
import org.springframework.data.redis.listener.PatternTopic;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Description Redis监听器
|
||||
* @Author FanDongqiang
|
||||
* @Date 2023/5/4 11:32
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@Getter
|
||||
public class RedisListener implements MessageListener {
|
||||
private final PatternTopic topic = new PatternTopic("__keyevent@0__:set");
|
||||
|
||||
@Autowired
|
||||
@Lazy
|
||||
private RedisUtils redisUtils;
|
||||
@Override
|
||||
public void onMessage(Message message, byte[] pattern) {
|
||||
String msg = redisUtils.get(new String(message.getBody())).toString();
|
||||
int websocketGroupId = JSON.parseObject(msg).getInteger("websocketGroupId");
|
||||
if (websocketGroupId != 0) {
|
||||
sendInfoToWebSocketHandler(websocketGroupId, msg);
|
||||
}
|
||||
}
|
||||
private void sendInfoToWebSocketHandler(int websocketGroupId, String message) {
|
||||
switch (websocketGroupId) {
|
||||
case 1:
|
||||
WebSocketHandler1.sendInfo(message);
|
||||
break;
|
||||
case 2:
|
||||
WebSocketHandler2.sendInfo(message);
|
||||
break;
|
||||
case 3:
|
||||
WebSocketHandler3.sendInfo(message);
|
||||
break;
|
||||
case 4:
|
||||
WebSocketHandler4.sendInfo(message);
|
||||
break;
|
||||
case 5:
|
||||
WebSocketHandler5.sendInfo(message);
|
||||
break;
|
||||
case 6:
|
||||
WebSocketHandler6.sendInfo(message);
|
||||
break;
|
||||
case 7:
|
||||
WebSocketHandler7.sendInfo(message);
|
||||
break;
|
||||
case 8:
|
||||
WebSocketHandler8.sendInfo(message);
|
||||
break;
|
||||
default:
|
||||
log.warn("Invalid websocketGroupId: {}", websocketGroupId);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.ipsplm.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ipsplm.entity.iot.IotDeviceList;
|
||||
|
||||
/**
|
||||
* @Description IOT设备清单表Service
|
||||
* @Author FanDongqiang
|
||||
* @Date 2023/2/16 10:21
|
||||
* @Version 1.0
|
||||
*/
|
||||
public interface IIotDeviceListService extends IService<IotDeviceList> {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.ipsplm.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ipsplm.entity.iot.XaIotDeviceList;
|
||||
|
||||
public interface IXaIotDeviceListService extends IService<XaIotDeviceList> {
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.ipsplm.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.ipsplm.entity.iot.XaIotDeviceListSync;
|
||||
|
||||
public interface IXaIotDeviceListSyncService extends IService<XaIotDeviceListSync> {
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.ipsplm.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ipsplm.dao.IotDeviceListMapper;
|
||||
import com.ipsplm.entity.iot.IotDeviceList;
|
||||
import com.ipsplm.service.IIotDeviceListService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description IOT设备清单表Service实现类
|
||||
* @Author FanDongqiang
|
||||
* @Date 2023/2/16 10:21
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Service
|
||||
public class IotDeviceListServiceImpl extends ServiceImpl<IotDeviceListMapper, IotDeviceList> implements IIotDeviceListService {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.ipsplm.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ipsplm.dao.XaIotDeviceListMapper;
|
||||
import com.ipsplm.entity.iot.XaIotDeviceList;
|
||||
import com.ipsplm.service.IXaIotDeviceListService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class XaIotDeviceListServiceImpl extends ServiceImpl<XaIotDeviceListMapper, XaIotDeviceList> implements IXaIotDeviceListService {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.ipsplm.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.ipsplm.dao.XaIotDeviceListSyncMapper;
|
||||
import com.ipsplm.entity.iot.XaIotDeviceListSync;
|
||||
import com.ipsplm.service.IXaIotDeviceListSyncService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class XaIotDeviceListSyncServiceImpl extends ServiceImpl<XaIotDeviceListSyncMapper, XaIotDeviceListSync> implements IXaIotDeviceListSyncService {
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.ipsplm.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONException;
|
||||
|
||||
/**
|
||||
* @Description JSON工具类
|
||||
* @Author FanDongqiang
|
||||
* @Date 2023/2/17 10:42
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class JSONUtils {
|
||||
/**
|
||||
* 是否合法Json
|
||||
*
|
||||
* @param jsonStr 待解析字符串
|
||||
* @return
|
||||
*/
|
||||
public static boolean isJSONValidate(String jsonStr){
|
||||
try {
|
||||
JSON.parse(jsonStr);
|
||||
return true;
|
||||
} catch (JSONException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<property name="log.path" value="logs/" />
|
||||
<appender name="logbackAll" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<encoder>
|
||||
<pattern>%date [%level] [%thread] %logger{80} [%file : %line] %msg%n</pattern>
|
||||
</encoder>
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern>%date{yyyy-MM-dd HH:mm:ss.Asia/Shanghai} %-5level [%thread] %logger{56}.%method:%L -%msg%n</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
<appender name="Console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>
|
||||
<pattern>%date{yyyy-MM-dd HH:mm:ss.Asia/Shanghai} [%highlight(%level)] [%boldMagenta(%thread)] [%cyan(%file) : %line] %msg%n</pattern>
|
||||
</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- kafka 日志关闭 -->
|
||||
<logger name="org.apache.kafka" level="OFF"/>
|
||||
<logger name="io.netty" level="OFF" />
|
||||
<logger name="org.springframework" level="INFO" additivity="false">
|
||||
<appender-ref ref="Console"/>
|
||||
<appender-ref ref="logbackAll"/>
|
||||
</logger>
|
||||
<logger name="com.ipsplm.dao" level="info" />
|
||||
<root level="INFO">
|
||||
<appender-ref ref="Console"/>
|
||||
<appender-ref ref="logbackAll"/>
|
||||
</root>
|
||||
</configuration>
|
Loading…
Reference in New Issue