@@ -0,0 +1,3 @@ | |||
# tuoheng_nxdp | |||
贵州机场大屏后端 |
@@ -0,0 +1,118 @@ | |||
<?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 https://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.4.3</version> | |||
<relativePath/> <!-- lookup parent from repository --> | |||
</parent> | |||
<groupId>com.tuoheng</groupId> | |||
<artifactId>springboot-airport-nxdp</artifactId> | |||
<version>0.0.1-SNAPSHOT</version> | |||
<packaging>jar</packaging> | |||
<name>springboot-airport-nxdp</name> | |||
<description>Demo project for Spring Boot</description> | |||
<properties> | |||
<java.version>8</java.version> | |||
</properties> | |||
<dependencies> | |||
<!-- 这是mysql的依赖 --> | |||
<dependency> | |||
<groupId>mysql</groupId> | |||
<artifactId>mysql-connector-java</artifactId> | |||
<scope>runtime</scope> | |||
</dependency> | |||
<!-- 这是lombok的依赖 --> | |||
<dependency> | |||
<groupId>org.projectlombok</groupId> | |||
<artifactId>lombok</artifactId> | |||
<optional>true</optional> | |||
</dependency> | |||
<!-- 这是mybatis-plus依赖 --> | |||
<dependency> | |||
<groupId>com.baomidou</groupId> | |||
<artifactId>mybatis-plus-boot-starter</artifactId> | |||
<version>3.1.1</version> | |||
</dependency> | |||
<!-- 这是mybatis-plus的代码自动生成器 --> | |||
<dependency> | |||
<groupId>com.baomidou</groupId> | |||
<artifactId>mybatis-plus-generator</artifactId> | |||
<version>3.1.1</version> | |||
</dependency> | |||
<!-- 这是模板引擎依赖 --> | |||
<dependency> | |||
<groupId>org.freemarker</groupId> | |||
<artifactId>freemarker</artifactId> | |||
<version>2.3.28</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-web</artifactId> | |||
</dependency> | |||
<!-- https://gitee.com/loolly/hutool --> | |||
<dependency> | |||
<groupId>cn.hutool</groupId> | |||
<artifactId>hutool-core</artifactId> | |||
<version>5.4.4</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>cn.hutool</groupId> | |||
<artifactId>hutool-log</artifactId> | |||
<version>5.4.4</version> | |||
</dependency> | |||
<!-- Redis 起始依赖 --> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-data-redis-reactive</artifactId> | |||
</dependency> | |||
<dependency> | |||
<groupId>com.alibaba</groupId> | |||
<artifactId>fastjson</artifactId> | |||
<version>1.2.83</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.eclipse.paho</groupId> | |||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId> | |||
<version>1.2.5</version> | |||
</dependency> | |||
<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-websocket</artifactId> | |||
</dependency> | |||
<!--去除内嵌tomcat--> | |||
<!--<dependency> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-starter-tomcat</artifactId> | |||
<scope>provided</scope> | |||
</dependency> | |||
<!– https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-websocket –> | |||
<!–websocket依赖包–> | |||
<dependency> | |||
<groupId>org.apache.tomcat.embed</groupId> | |||
<artifactId>tomcat-embed-websocket</artifactId> | |||
<version>8.5.23</version> | |||
</dependency>--> | |||
<!--websocket作为客户端--> | |||
<!--<dependency> | |||
<groupId>org.java-websocket</groupId> | |||
<artifactId>Java-WebSocket</artifactId> | |||
<version>1.5.2</version> | |||
</dependency>--> | |||
</dependencies> | |||
<build> | |||
<plugins> | |||
<plugin> | |||
<groupId>org.springframework.boot</groupId> | |||
<artifactId>spring-boot-maven-plugin</artifactId> | |||
</plugin> | |||
</plugins> | |||
</build> | |||
</project> |
@@ -0,0 +1,26 @@ | |||
package com.tuoheng.airportGzdp; | |||
import org.mybatis.spring.annotation.MapperScan; | |||
import org.springframework.boot.SpringApplication; | |||
import org.springframework.boot.autoconfigure.SpringBootApplication; | |||
import org.springframework.boot.builder.SpringApplicationBuilder; | |||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | |||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | |||
import org.springframework.context.annotation.Profile; | |||
import org.springframework.scheduling.annotation.EnableAsync; | |||
@MapperScan(basePackages = {"com.tuoheng.airportGzdp.mapper"}) //扫描DAO | |||
@SpringBootApplication | |||
@EnableConfigurationProperties | |||
@EnableAsync | |||
public class Application extends SpringBootServletInitializer { | |||
public static void main(String[] args) { | |||
SpringApplication.run(Application.class, args); | |||
} | |||
@Profile(value = {"war"}) | |||
@Override | |||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { | |||
return application.sources(Application.class); | |||
} | |||
} |
@@ -0,0 +1,98 @@ | |||
package com.tuoheng.airportGzdp.common; | |||
import java.io.Serializable; | |||
/** | |||
* JSON回应类 | |||
* | |||
* @author 牧羊人 | |||
* @date 2019/11/28 | |||
*/ | |||
public class JsonResult<T> implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 成功 | |||
*/ | |||
public static final int SUCCESS = 0;//CommonConstants.SUCCESS; | |||
/** | |||
* 专用 | |||
*/ | |||
public static final int OIDC_ERROR = -2; | |||
/** | |||
* 失败 | |||
*/ | |||
public static final int error = 500; | |||
private int code; | |||
private String msg; | |||
private T data; | |||
public static <T> JsonResult<T> success() { | |||
return jsonResult(null, SUCCESS, "操作成功"); | |||
} | |||
public static <T> JsonResult<T> success(T data) { | |||
return jsonResult(data, SUCCESS, "操作成功"); | |||
} | |||
public static <T> JsonResult<T> success(T data, String msg) { | |||
return jsonResult(data, SUCCESS, msg); | |||
} | |||
public static <T> JsonResult<T> error() { | |||
return jsonResult(null, error, "操作失败"); | |||
} | |||
public static <T> JsonResult<T> error(String msg) { | |||
return jsonResult(null, error, msg); | |||
} | |||
public static <T> JsonResult<T> error(T data) { | |||
return jsonResult(data, error, "操作失败"); | |||
} | |||
public static <T> JsonResult<T> error(T data, String msg) { | |||
return jsonResult(data, error, msg); | |||
} | |||
public static <T> JsonResult<T> error(int code, String msg) { | |||
return jsonResult(null, code, msg); | |||
} | |||
private static <T> JsonResult<T> jsonResult(T data, int code, String msg) { | |||
JsonResult<T> result = new JsonResult<>(); | |||
result.setCode(code); | |||
result.setData(data); | |||
result.setMsg(msg); | |||
return result; | |||
} | |||
public int getCode() { | |||
return code; | |||
} | |||
public void setCode(int code) { | |||
this.code = code; | |||
} | |||
public String getMsg() { | |||
return msg; | |||
} | |||
public void setMsg(String msg) { | |||
this.msg = msg; | |||
} | |||
public T getData() { | |||
return data; | |||
} | |||
public void setData(T data) { | |||
this.data = data; | |||
} | |||
} |
@@ -0,0 +1,135 @@ | |||
package com.tuoheng.airportGzdp.config; | |||
import com.baomidou.mybatisplus.core.exceptions.MybatisPlusException; | |||
import com.baomidou.mybatisplus.core.toolkit.StringPool; | |||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
import com.baomidou.mybatisplus.generator.AutoGenerator; | |||
import com.baomidou.mybatisplus.generator.InjectionConfig; | |||
import com.baomidou.mybatisplus.generator.config.*; | |||
import com.baomidou.mybatisplus.generator.config.po.TableInfo; | |||
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy; | |||
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Scanner; | |||
public class CodeGenerator { | |||
public static String scanner(String tip) { | |||
Scanner scanner = new Scanner(System.in); | |||
StringBuilder help = new StringBuilder(); | |||
help.append("请输入" + tip + ":"); | |||
System.out.println(help.toString()); | |||
if (scanner.hasNext()) { | |||
String ipt = scanner.next(); | |||
if (StringUtils.isNotEmpty(ipt)) { | |||
return ipt; | |||
} | |||
} | |||
throw new MybatisPlusException("请输入正确的" + tip + "!"); | |||
} | |||
public static void main(String[] args) { | |||
// 代码生成器 | |||
AutoGenerator mpg = new AutoGenerator(); | |||
// 全局配置 | |||
GlobalConfig gc = new GlobalConfig(); | |||
String projectPath = System.getProperty("user.dir"); | |||
gc.setOutputDir(projectPath + "/src/main/java"); | |||
gc.setAuthor("tzs"); | |||
gc.setOpen(false); | |||
// gc.setSwagger2(true); 实体属性 Swagger2 注解 | |||
mpg.setGlobalConfig(gc); | |||
// 数据源配置 | |||
DataSourceConfig dsc = new DataSourceConfig(); | |||
dsc.setUrl("jdbc:mysql://localhost:3306/test?useUnicode=true&useSSL=false&characterEncoding=utf8"); | |||
// dsc.setSchemaName("public"); | |||
dsc.setDriverName("com.mysql.cj.jdbc.Driver"); | |||
dsc.setUsername("root"); | |||
dsc.setPassword("accp"); | |||
mpg.setDataSource(dsc); | |||
// 包配置 | |||
PackageConfig pc = new PackageConfig(); | |||
//这里有个模块名的配置,可以注释掉不用。 | |||
// pc.setModuleName(scanner("模块名")); | |||
pc.setParent("com.example.mybatisplus"); | |||
mpg.setPackageInfo(pc); | |||
// 自定义配置 | |||
InjectionConfig cfg = new InjectionConfig() { | |||
@Override | |||
public void initMap() { | |||
// to do nothing | |||
} | |||
}; | |||
// 如果模板引擎是 freemarker | |||
String templatePath = "/templates/mapper.xml.ftl"; | |||
// 如果模板引擎是 velocity | |||
// String templatePath = "/templates/mapper.xml.vm"; | |||
// 自定义输出配置 | |||
List<FileOutConfig> focList = new ArrayList<>(); | |||
// 自定义配置会被优先输出 | |||
focList.add(new FileOutConfig(templatePath) { | |||
@Override | |||
public String outputFile(TableInfo tableInfo) { | |||
// 自定义输出文件名 , 如果你 Entity 设置了前后缀、此处注意 xml 的名称会跟着发生变化!! | |||
return projectPath + "/src/main/resources/mapper/" | |||
// + + pc.getModuleName() + 如果放开上面的模块名,这里就有一个模块名了 | |||
+ "/" + tableInfo.getEntityName() + "Mapper" + StringPool.DOT_XML; | |||
} | |||
}); | |||
/* | |||
cfg.setFileCreate(new IFileCreate() { | |||
@Override | |||
public boolean isCreate(ConfigBuilder configBuilder, FileType fileType, String filePath) { | |||
// 判断自定义文件夹是否需要创建 | |||
checkDir("调用默认方法创建的目录"); | |||
return false; | |||
} | |||
}); | |||
*/ | |||
cfg.setFileOutConfigList(focList); | |||
mpg.setCfg(cfg); | |||
// 配置模板 | |||
TemplateConfig templateConfig = new TemplateConfig(); | |||
// 配置自定义输出模板 | |||
//指定自定义模板路径,注意不要带上.ftl/.vm, 会根据使用的模板引擎自动识别 | |||
// templateConfig.setEntity("templates/entity2.java"); | |||
// templateConfig.setService(); | |||
// templateConfig.setController(); | |||
templateConfig.setXml(null); | |||
mpg.setTemplate(templateConfig); | |||
// 策略配置 | |||
StrategyConfig strategy = new StrategyConfig(); | |||
//数据库表映射到实体的明明策略 | |||
strategy.setNaming(NamingStrategy.underline_to_camel); | |||
//数据库表字段映射到实体的命名策略, 未指定按照 naming 执行 | |||
strategy.setColumnNaming(NamingStrategy.underline_to_camel); | |||
//自定义继承的Entity类全称,带包名 | |||
// strategy.setSuperEntityClass("***"); | |||
strategy.setEntityLombokModel(true); | |||
strategy.setRestControllerStyle(true); | |||
//自定义继承的Controller类全称,带包名 | |||
// strategy.setSuperControllerClass("***"); | |||
strategy.setInclude(scanner("表名,多个英文逗号分割").split(",")); | |||
//自定义基础的Entity类,公共字段(可添加更多) | |||
// strategy.setSuperEntityColumns("id"); | |||
//驼峰转连字符 | |||
strategy.setControllerMappingHyphenStyle(true); | |||
//表前缀 | |||
// strategy.setTablePrefix(pc.getModuleName() + "_"); | |||
mpg.setStrategy(strategy); | |||
mpg.setTemplateEngine(new FreemarkerTemplateEngine()); | |||
mpg.execute(); | |||
} | |||
} |
@@ -0,0 +1,187 @@ | |||
package com.tuoheng.airportGzdp.config; | |||
import com.tuoheng.airportGzdp.until.RedisUtils; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.context.annotation.Bean; | |||
import org.springframework.context.annotation.Configuration; | |||
import org.springframework.data.redis.connection.RedisConnectionFactory; | |||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | |||
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.Jackson2JsonRedisSerializer; | |||
import org.springframework.data.redis.serializer.RedisSerializer; | |||
import org.springframework.data.redis.serializer.StringRedisSerializer; | |||
@Configuration | |||
//@PropertySource("classpath:redis.properties") | |||
public class RedisConfig { | |||
@Value("${spring.redis.host}") | |||
private String hostName; | |||
@Value("${spring.redis.port}") | |||
private Integer port; | |||
@Value("${spring.redis.password}") | |||
private String password; | |||
@Value("${spring.redis.timeout}") | |||
private Integer timeout; | |||
/* | |||
@Value("${redis.maxIdle}") | |||
private Integer maxIdle; | |||
@Value("${redis.maxTotal}") | |||
private Integer maxTotal; | |||
@Value("${redis.maxWaitMillis}") | |||
private Integer maxWaitMillis; | |||
@Value("${redis.minEvictableIdleTimeMillis}") | |||
private Integer minEvictableIdleTimeMillis; | |||
@Value("${redis.numTestsPerEvictionRun}") | |||
private Integer numTestsPerEvictionRun; | |||
@Value("${redis.timeBetweenEvictionRunsMillis}") | |||
private long timeBetweenEvictionRunsMillis; | |||
@Value("${redis.testOnBorrow}") | |||
private boolean testOnBorrow; | |||
@Value("${redis.testWhileIdle}") | |||
private boolean testWhileIdle; | |||
*/ | |||
/** | |||
* JedisPoolConfig 连接池 | |||
* @return | |||
@Bean public JedisPoolConfig jedisPoolConfig() { | |||
JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); | |||
// 最大空闲数 | |||
jedisPoolConfig.setMaxIdle(maxIdle); | |||
// 连接池的最大数据库连接数 | |||
jedisPoolConfig.setMaxTotal(maxTotal); | |||
// 最大建立连接等待时间 | |||
jedisPoolConfig.setMaxWaitMillis(maxWaitMillis); | |||
// 逐出连接的最小空闲时间 默认1800000毫秒(30分钟) | |||
jedisPoolConfig.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis); | |||
// 每次逐出检查时 逐出的最大数目 如果为负数就是 : 1/abs(n), 默认3 | |||
jedisPoolConfig.setNumTestsPerEvictionRun(numTestsPerEvictionRun); | |||
// 逐出扫描的时间间隔(毫秒) 如果为负数,则不运行逐出线程, 默认-1 | |||
jedisPoolConfig.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis); | |||
// 是否在从池中取出连接前进行检验,如果检验失败,则从池中去除连接并尝试取出另一个 | |||
jedisPoolConfig.setTestOnBorrow(testOnBorrow); | |||
// 在空闲时检查有效性, 默认false | |||
jedisPoolConfig.setTestWhileIdle(testWhileIdle); | |||
return jedisPoolConfig; | |||
} | |||
/** | |||
* 单机版配置 | |||
* @Title: JedisConnectionFactory | |||
* @param @param jedisPoolConfig | |||
* @param @return | |||
* @return JedisConnectionFactory | |||
* @autor lpl | |||
* @date 2018年2月24日 | |||
* @throws | |||
@Bean public JedisConnectionFactory jedisConnectionFactory(){ | |||
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(); | |||
redisStandaloneConfiguration.setHostName(hostName); | |||
redisStandaloneConfiguration.setPort(port); | |||
redisStandaloneConfiguration.setPassword(password); | |||
JedisClientConfiguration.JedisClientConfigurationBuilder jedisClientConfigurationBuilder = JedisClientConfiguration.builder(); | |||
jedisClientConfigurationBuilder.connectTimeout(Duration.ofMillis(timeout)); | |||
JedisConnectionFactory factory = new JedisConnectionFactory(redisStandaloneConfiguration,jedisClientConfigurationBuilder.build()); | |||
return factory; | |||
} | |||
*/ | |||
/** | |||
* 实例化 RedisTemplate 对象 jredis实现方式,springboot2.x以后使用下面的方法 | |||
* | |||
* @return | |||
@Bean public RedisTemplate<String, Object> functionDomainRedisTemplate(RedisConnectionFactory redisConnectionFactory) { | |||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); | |||
initDomainRedisTemplate(redisTemplate, redisConnectionFactory); | |||
return redisTemplate; | |||
} | |||
*/ | |||
/** | |||
* lettuce实现redis方式 | |||
* | |||
* @param redisConnectionFactory | |||
* @return | |||
*/ | |||
@Bean | |||
public RedisTemplate<String, Object> redisCacheTemplate(LettuceConnectionFactory redisConnectionFactory) { | |||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); | |||
initDomainRedisTemplate(redisTemplate, redisConnectionFactory); | |||
return redisTemplate; | |||
} | |||
/** | |||
* 设置数据存入 redis 的序列化方式,并开启事务 | |||
* | |||
* @param redisTemplate | |||
* @param factory | |||
*/ | |||
private void initDomainRedisTemplate(RedisTemplate<String, Object> redisTemplate, RedisConnectionFactory factory) { | |||
//如果不配置Serializer,那么存储的时候缺省使用String,如果用User类型存储,那么会提示错误User can't cast to String! | |||
redisTemplate.setKeySerializer(new StringRedisSerializer()); | |||
redisTemplate.setHashKeySerializer(new StringRedisSerializer()); | |||
redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); | |||
redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); | |||
// 开启事务 | |||
redisTemplate.setEnableTransactionSupport(true); | |||
redisTemplate.setConnectionFactory(factory); | |||
} | |||
/** | |||
* 注入封装RedisTemplate | |||
* | |||
* @return RedisUtil | |||
* @throws | |||
* @Title: redisUtil | |||
* @autor lpl | |||
* @date 2017年12月21日 | |||
*/ | |||
@Bean(name = "redisUtils") | |||
public RedisUtils redisUtils(RedisTemplate<String, Object> redisTemplate) { | |||
RedisUtils redisUtil = new RedisUtils(); | |||
redisUtil.setRedisTemplate(redisTemplate); | |||
return redisUtil; | |||
} | |||
/** | |||
* 使CacheComponent的redisTemplate组件的key使用StringRedisSerializer而非默认的JdkSerializationRedisSerializer | |||
* 避免key出现字节码的情况 | |||
* @param factory redis链接 | |||
* @return RedisTemplate | |||
*/ | |||
/*@Bean | |||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) { | |||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); | |||
redisTemplate.setConnectionFactory(factory); | |||
RedisSerializer redisSerializer = new StringRedisSerializer(); | |||
Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); | |||
//key使用StringRedisSerializer序列化 | |||
redisTemplate.setKeySerializer(redisSerializer); | |||
//value使用jackson2JsonRedisSerializer序列化 | |||
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); | |||
return redisTemplate; | |||
}*/ | |||
/** | |||
* 创建Redis消息监听者容器 | |||
* @param factory | |||
* @return | |||
*/ | |||
@Bean("redisMessageListenerContainer") | |||
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory factory){ | |||
RedisMessageListenerContainer container = new RedisMessageListenerContainer(); | |||
container.setConnectionFactory(factory); | |||
return container; | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
package com.tuoheng.airportGzdp.config; | |||
import org.springframework.beans.BeansException; | |||
import org.springframework.context.ApplicationContext; | |||
import org.springframework.context.ApplicationContextAware; | |||
import org.springframework.stereotype.Component; | |||
@Component | |||
public class SpringUtil implements ApplicationContextAware { | |||
private static ApplicationContext applicationContext; | |||
@Override | |||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | |||
SpringUtil.applicationContext = applicationContext; | |||
} | |||
public static Object getBean(String beanName) { | |||
return applicationContext.getBean(beanName); | |||
} | |||
public static <T> T getBean(Class<T> beanClass) { | |||
return applicationContext.getBean(beanClass); | |||
} | |||
public static String getProperty(String key) { | |||
return applicationContext.getEnvironment().getProperty(key); | |||
} | |||
} |
@@ -0,0 +1,134 @@ | |||
package com.tuoheng.airportGzdp.config; | |||
import lombok.SneakyThrows; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Component; | |||
import javax.websocket.OnClose; | |||
import javax.websocket.OnMessage; | |||
import javax.websocket.OnOpen; | |||
import javax.websocket.Session; | |||
import javax.websocket.server.PathParam; | |||
import javax.websocket.server.ServerEndpoint; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import java.util.concurrent.CopyOnWriteArraySet; | |||
@Component | |||
@Slf4j | |||
@ServerEndpoint("/websocket/{code}") | |||
public class WebSocket { | |||
@Autowired | |||
WebSocketClient webSocketClient; | |||
/** | |||
* 线程安全的无序的集合 | |||
*/ | |||
private static final CopyOnWriteArraySet<Session> SESSIONS = new CopyOnWriteArraySet<>(); | |||
/** | |||
* 存储在线连接数 | |||
*/ | |||
private static final Map<String, Session> SESSION_POOL = new HashMap<>(); | |||
@OnOpen | |||
public void onOpen(Session session, @PathParam(value = "code") String code) { | |||
try { | |||
log.info("线程名称{}",Thread.currentThread().getName()); | |||
SESSIONS.add(session); | |||
SESSION_POOL.put(code, session); | |||
log.info("【WebSocket消息】有新的连接,总数为:" + SESSIONS.size()); | |||
Thread thread = new Thread(new Runnable() { | |||
@SneakyThrows | |||
@Override | |||
public void run() { | |||
handleData(code); | |||
} | |||
}); | |||
thread.start(); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
public void handleData(String code){ | |||
WebSocketClient webSocketClient = new WebSocketClient(); | |||
webSocketClient.connectWebsocket(code); | |||
} | |||
@OnClose | |||
public void onClose(Session session) { | |||
try { | |||
SESSIONS.remove(session); | |||
log.info("【WebSocket消息】连接断开,总数为:" + SESSIONS.size()); | |||
WebSocketClient webSocketClient = new WebSocketClient(); | |||
webSocketClient.closeWebsocket(); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
@OnMessage | |||
public void onMessage(String message) { | |||
log.info("【WebSocket消息】收到客户端消息:" + message); | |||
} | |||
/** | |||
* 此为广播消息 | |||
* | |||
* @param message 消息 | |||
*/ | |||
public void sendAllMessage(String message) { | |||
log.info("【WebSocket消息】广播消息:" + message); | |||
for (Session session : SESSIONS) { | |||
try { | |||
if (session.isOpen()) { | |||
session.getAsyncRemote().sendText(message); | |||
} | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
} | |||
/** | |||
* 此为单点消息 | |||
* | |||
* @param userId 用户编号 | |||
* @param message 消息 | |||
*/ | |||
public void sendOneMessage(String userId, String message) { | |||
Session session = SESSION_POOL.get(userId); | |||
if (session != null && session.isOpen()) { | |||
try { | |||
synchronized (session) { | |||
log.info("【WebSocket消息】单点消息:" + message); | |||
session.getAsyncRemote().sendText(message); | |||
} | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
} | |||
/** | |||
* 此为单点消息(多人) | |||
* | |||
* @param userIds 用户编号列表 | |||
* @param message 消息 | |||
*/ | |||
public void sendMoreMessage(String[] userIds, String message) { | |||
for (String userId : userIds) { | |||
Session session = SESSION_POOL.get(userId); | |||
if (session != null && session.isOpen()) { | |||
try { | |||
log.info("【WebSocket消息】单点消息:" + message); | |||
session.getAsyncRemote().sendText(message); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
} | |||
} | |||
} |
@@ -0,0 +1,75 @@ | |||
package com.tuoheng.airportGzdp.config; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.airportGzdp.service.impl.TaskServiceImpl; | |||
import com.tuoheng.airportGzdp.until.SpringUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.scheduling.annotation.Async; | |||
import org.springframework.stereotype.Component; | |||
import javax.websocket.*; | |||
import java.net.URI; | |||
@Component | |||
@ClientEndpoint | |||
@Slf4j | |||
public class WebSocketClient { | |||
@Autowired | |||
WebSocket webSocket; | |||
public static Session session; | |||
@OnOpen | |||
public void onOpen(Session session) { | |||
this.session=session; | |||
System.out.println("Connected: " + session.getId()); | |||
} | |||
@OnMessage | |||
public void onMessage(String message) { | |||
/*log.info("线程名称fa{}",Thread.currentThread().getName()); | |||
System.out.println("Received message: " + message);*/ | |||
if (ObjectUtil.isEmpty(webSocket)){ | |||
webSocket = SpringUtil.getBean(WebSocket.class); | |||
} | |||
webSocket.sendAllMessage(message); | |||
} | |||
@OnError | |||
public void onError(Throwable throwable) { | |||
throwable.printStackTrace(); | |||
} | |||
@Async | |||
public void connectWebsocket(String code) { | |||
WebSocketContainer container = ContainerProvider.getWebSocketContainer(); | |||
try { | |||
if (session!=null&&session.isOpen()){ | |||
return; | |||
} | |||
String url = SpringUtil.getProperty("websocketurl")+"/0:0:"+code; | |||
session = container.connectToServer(WebSocketClient.class, URI.create(url)); | |||
//session.getBasicRemote().sendText("Hello, server!"); // 发送消息给服务器 | |||
log.info("websocket请求地址{}",url); | |||
// 保持连接并接收多条消息 | |||
long oldtime = System.currentTimeMillis(); | |||
while (true&&session.isOpen()) { | |||
Thread.sleep(1000); // 每隔一秒钟检查一次是否有新消息 | |||
if (System.currentTimeMillis()-oldtime>3600000){ | |||
session.close(); | |||
} | |||
} | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
public void closeWebsocket() { | |||
try { | |||
//session.close(); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,18 @@ | |||
package com.tuoheng.airportGzdp.config; | |||
import org.springframework.context.annotation.Bean; | |||
import org.springframework.context.annotation.Configuration; | |||
import org.springframework.core.annotation.Order; | |||
import org.springframework.web.socket.server.standard.ServerEndpointExporter; | |||
@Configuration | |||
public class WebSocketConfiguration { | |||
/** | |||
* 注入ServerEndpointExporter, | |||
* 这个bean会自动注册使用了@ServerEndpoint注解声明的Websocket endpoint | |||
*/ | |||
@Bean | |||
public ServerEndpointExporter serverEndpointExporter() { | |||
return new ServerEndpointExporter(); | |||
} | |||
} |
@@ -0,0 +1,92 @@ | |||
package com.tuoheng.airportGzdp.controller; | |||
import com.tuoheng.airportGzdp.common.JsonResult; | |||
import com.tuoheng.airportGzdp.entity.AirlineFile; | |||
import com.tuoheng.airportGzdp.service.IAirlineDataService; | |||
import com.tuoheng.airportGzdp.service.IAirlineFileService; | |||
import com.tuoheng.airportGzdp.service.ITaskService; | |||
import com.tuoheng.airportGzdp.until.SslUtils; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import java.io.BufferedReader; | |||
import java.io.InputStream; | |||
import java.io.InputStreamReader; | |||
import java.net.HttpURLConnection; | |||
import java.net.URL; | |||
import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* <p> | |||
* 前端控制器 | |||
* </p> | |||
* | |||
* @author tzs | |||
* @since 2021-03-13 | |||
*/ | |||
@RestController | |||
@RequestMapping("/airline") | |||
@Slf4j | |||
public class AirLineController { | |||
@Autowired | |||
private IAirlineDataService airlineDataService; | |||
@Autowired | |||
private IAirlineFileService airlineFileService; | |||
/** | |||
* 获取轨迹 | |||
*/ | |||
@RequestMapping("/getPointList") | |||
public JsonResult getInfo(Integer recordId){ | |||
JsonResult jsonResult = airlineDataService.getList(recordId); | |||
return jsonResult; | |||
} | |||
/** | |||
* 获取航线 | |||
* @param id | |||
* @return | |||
*/ | |||
@GetMapping("/getLocationById") | |||
public JsonResult getLocation(int id) { | |||
try { | |||
List list = new ArrayList(); | |||
AirlineFile airlineFile = airlineFileService.getById(id); | |||
String urls = airlineFile.getFileUrl(); | |||
//File file = new File(url); | |||
URL url = new URL(urls); | |||
if("https".equalsIgnoreCase(url.getProtocol())){ | |||
SslUtils.ignoreSsl(); | |||
} | |||
HttpURLConnection urlcon = (HttpURLConnection) url.openConnection(); | |||
urlcon.connect(); //获取连接 | |||
InputStream is = urlcon.getInputStream(); | |||
BufferedReader br = new BufferedReader(new InputStreamReader(is)); | |||
String st; | |||
while ((st = br.readLine()) != null) { | |||
String[] location = st.split("\t"); | |||
if (location.length > 8) { | |||
if (location[8].equals("0") || location[8].contains("0.00000")) { | |||
continue; | |||
} | |||
Map map = new HashMap(); | |||
map.put("lat", location[8]); | |||
map.put("lon", location[9]); | |||
list.add(map); | |||
} | |||
} | |||
br.close(); | |||
return JsonResult.success(list); | |||
} catch (Exception e) { | |||
log.error("",e); | |||
return JsonResult.error(e.getMessage()); | |||
} | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
package com.tuoheng.airportGzdp.controller; | |||
import com.tuoheng.airportGzdp.common.JsonResult; | |||
import com.tuoheng.airportGzdp.service.IAirportService; | |||
import com.tuoheng.airportGzdp.service.impl.TaskServiceImpl; | |||
import com.tuoheng.airportGzdp.until.RedisUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* <p> | |||
* 前端控制器 | |||
* </p> | |||
* | |||
* @author tzs | |||
* @since 2021-03-13 | |||
*/ | |||
@RestController | |||
@RequestMapping("/airport") | |||
public class AirportController { | |||
@Autowired | |||
private IAirportService airportService; | |||
@Autowired | |||
TaskServiceImpl taskService; | |||
/** | |||
*/ | |||
@RequestMapping("/getList") | |||
public JsonResult getInfo(String tenantCode){ | |||
JsonResult jsonResult = airportService.getList(tenantCode); | |||
//taskService.getListToWebsocket(tenantCode, 8); | |||
return jsonResult; | |||
} | |||
@RequestMapping("/getWth") | |||
public JsonResult getInfo(Integer airportId){ | |||
JsonResult jsonResult = airportService.getWather(airportId); | |||
return jsonResult; | |||
} | |||
} |
@@ -0,0 +1,100 @@ | |||
package com.tuoheng.airportGzdp.controller; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.airportGzdp.common.JsonResult; | |||
import com.tuoheng.airportGzdp.until.HttpURLConnectionUtil; | |||
import com.tuoheng.airportGzdp.vo.AirlineFileDto; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.web.bind.annotation.*; | |||
/** | |||
* <p> | |||
* 前端控制器 | |||
* </p> | |||
* | |||
* @author tzs | |||
* @since 2021-03-13 | |||
*/ | |||
@RestController | |||
@RequestMapping("/airportInterface") | |||
@Slf4j | |||
public class InterfaceController { | |||
@Value("${interfaceUrl}") | |||
private String interfaceUrl; | |||
/** | |||
* 任务列表 | |||
*/ | |||
@RequestMapping("/taskByDroneId") | |||
public JSON getInfo(Integer droneId){ | |||
HttpURLConnectionUtil httpURLConnectionUtil = new HttpURLConnectionUtil(); | |||
String url = interfaceUrl+"/taskByDroneId?page=1&limit=1000&droneId="+droneId+""; | |||
String jsonResult = httpURLConnectionUtil.doGet(url); | |||
log.info("请求返回值{}",jsonResult); | |||
return (JSON) JSON.parse(jsonResult); | |||
} | |||
/** | |||
* 任务执行 通过任务id | |||
* @param jsonTaskId | |||
* @return | |||
*/ | |||
@PostMapping("/executeTaskAnsy") | |||
public JSON returnExcResult(@RequestBody JSONObject jsonTaskId) { | |||
jsonTaskId.put("requestId",999); | |||
log.info(Thread.currentThread().getName() + jsonTaskId + "调用"); | |||
HttpURLConnectionUtil httpURLConnectionUtil = new HttpURLConnectionUtil(); | |||
String url = interfaceUrl+"/executeTaskAnsy"; | |||
String jsonResult = httpURLConnectionUtil.doPost(url, JSONObject.toJSONString(jsonTaskId)); | |||
log.info("请求返回值{}",jsonResult); | |||
return (JSON) JSON.parse(jsonResult); | |||
} | |||
/** | |||
* 航线飞行 通过航线id | |||
* @param ob | |||
* @return | |||
*/ | |||
@PostMapping("/excuteByLineId") | |||
public JSON excuteByLineId(@RequestBody JSONObject ob) { | |||
ob.put("requestId",999); | |||
log.info(Thread.currentThread().getName() + ob + "调用"); | |||
HttpURLConnectionUtil httpURLConnectionUtil = new HttpURLConnectionUtil(); | |||
String url = interfaceUrl+"/excuteByLineId"; | |||
String jsonResult = httpURLConnectionUtil.doPost(url, JSONObject.toJSONString(ob)); | |||
log.info("请求返回值{}",jsonResult); | |||
return (JSON) JSON.parse(jsonResult); | |||
} | |||
/** | |||
* 云台控制 | |||
* @param order | |||
* @return | |||
*/ | |||
@PostMapping("/cameraCommand") | |||
public JSON cameraCommand(@RequestBody JSONObject order) { | |||
log.info("云台指令{}",order); | |||
HttpURLConnectionUtil httpURLConnectionUtil = new HttpURLConnectionUtil(); | |||
String url = interfaceUrl+"/cameraCommand"; | |||
String jsonResult = httpURLConnectionUtil.doPost(url, JSONObject.toJSONString(order)); | |||
log.info("云台请求返回值{}",jsonResult); | |||
return (JSON) JSON.parse(jsonResult); | |||
} | |||
/** | |||
* 获取航线列表 | |||
* @param airlineFileDto | |||
* @return | |||
*/ | |||
@PostMapping("/getAirlineFileListForThird") | |||
public JSON getAirlineFileList(@RequestBody AirlineFileDto airlineFileDto) { | |||
log.info("云台指令{}",airlineFileDto); | |||
HttpURLConnectionUtil httpURLConnectionUtil = new HttpURLConnectionUtil(); | |||
String url = interfaceUrl+"/getAirlineFileListForThird"; | |||
String jsonResult = httpURLConnectionUtil.doPost(url, JSONObject.toJSONString(airlineFileDto)); | |||
log.info("云台请求返回值{}",jsonResult); | |||
return (JSON) JSON.parse(jsonResult); | |||
} | |||
} |
@@ -0,0 +1,41 @@ | |||
package com.tuoheng.airportGzdp.controller; | |||
import com.tuoheng.airportGzdp.common.JsonResult; | |||
import com.tuoheng.airportGzdp.service.IAirportService; | |||
import com.tuoheng.airportGzdp.service.ITaskService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.beans.factory.annotation.Value; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
/** | |||
* <p> | |||
* 前端控制器 | |||
* </p> | |||
* | |||
* @author tzs | |||
* @since 2021-03-13 | |||
*/ | |||
@RestController | |||
@RequestMapping("/task") | |||
public class TaskController { | |||
@Autowired | |||
private ITaskService taskService; | |||
/** | |||
*/ | |||
@RequestMapping("/getList") | |||
public JsonResult getInfo(String tenantCode,Integer limit){ | |||
JsonResult jsonResult = taskService.getList(tenantCode,limit); | |||
return jsonResult; | |||
} | |||
@RequestMapping("/getCountList") | |||
public JsonResult getCountList(String tenantCode){ | |||
JsonResult jsonResult = taskService.getCountList(tenantCode); | |||
return jsonResult; | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
package com.tuoheng.airportGzdp.controller; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.tuoheng.airportGzdp.common.JsonResult; | |||
import com.tuoheng.airportGzdp.until.HttpURLConnectionUtil; | |||
import com.tuoheng.airportGzdp.until.RedisUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RequestParam; | |||
import org.springframework.web.bind.annotation.RestController; | |||
@RestController | |||
@RequestMapping("/getWeather") | |||
public class WeatherController { | |||
@Autowired | |||
private RedisUtils redisUtils; | |||
@GetMapping("/day") | |||
public JsonResult getday(String lon, String lat, Integer dailysteps) | |||
{ | |||
if (ObjectUtil.isNotEmpty(redisUtils.hget("CAIYUN",lon+lat))){ | |||
return JsonResult.success(JSONObject.parseObject((String) redisUtils.hget("CAIYUN",lon+lat))); | |||
} | |||
HttpURLConnectionUtil httpURLConnectionUtil = new HttpURLConnectionUtil(); | |||
String url = "https://api.caiyunapp.com/v2.6/dXQNLUhILzwtFxxn/"+lon+","+lat+"/daily?dailysteps="+dailysteps+""; | |||
String response = httpURLConnectionUtil.doGet(url); | |||
redisUtils.hset("CAIYUN",lon+lat,response,3600); | |||
JSON jsonmap = JSONObject.parseObject(response); | |||
return JsonResult.success(jsonmap); | |||
} | |||
/*@GetMapping("/minute") | |||
public JsonResult getminute(String lon,String lat) | |||
{ | |||
HttpURLConnectionUtil httpURLConnectionUtil = new HttpURLConnectionUtil(); | |||
String url = "https://api.caiyunapp.com/v2.6/TAkhjf8d1nlSlspN/"+lon+","+lat+"/minutely"; | |||
String response = httpURLConnectionUtil.doGet(url); | |||
JSON jsonmap = JSONObject.parseObject(response); | |||
return JsonResult.success(jsonmap); | |||
}*/ | |||
} |
@@ -0,0 +1,79 @@ | |||
package com.tuoheng.airportGzdp.entity; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
/** | |||
* <p> | |||
* 航线文件表 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_flight_data_task") | |||
public class AirlineData { | |||
private static final long serialVersionUID = 1L; | |||
/* 主机Ip*/ | |||
private String hostIp; | |||
/* 任务id*/ | |||
private int inspectionId; | |||
/** | |||
* lng | |||
*/ | |||
private String lng; | |||
/** | |||
* lat | |||
*/ | |||
private String lat; | |||
/** | |||
* 高度 | |||
*/ | |||
private String altitude; | |||
/** | |||
* 实时时间 | |||
*/ | |||
private String timestamp; | |||
private long flyTime; | |||
@TableField(exist = false) | |||
private String requestId; | |||
@TableField(exist = false) | |||
private String hspeed; | |||
@TableField(exist = false) | |||
private String vspeed; | |||
@TableField(exist = false) | |||
private String ysingal; | |||
/** | |||
* 创建时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private String createTime; | |||
//水平速度 | |||
private String velocity; | |||
//垂直速度 | |||
private String airspeed; | |||
private String dv; | |||
private String gps; | |||
} |
@@ -0,0 +1,58 @@ | |||
package com.tuoheng.airportGzdp.entity; | |||
import com.baomidou.mybatisplus.annotation.TableField; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 航线文件表 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_airline_file") | |||
public class AirlineFile { | |||
private static final long serialVersionUID = 1L; | |||
private int id ; | |||
/** | |||
* 文件名称 | |||
*/ | |||
private String fileName; | |||
/** | |||
* 文件地址 | |||
*/ | |||
private String fileUrl; | |||
/** | |||
* 航线类型:1,航点航线;2,指点航线;3,指面航线 | |||
*/ | |||
private Integer type; | |||
/** | |||
* 文件备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 航线距离 | |||
*/ | |||
private Double distance; | |||
/** | |||
* 关联机场id | |||
*/ | |||
private Integer airportId; | |||
} |
@@ -0,0 +1,108 @@ | |||
package com.tuoheng.airportGzdp.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import java.io.Serializable; | |||
/** | |||
* <p> | |||
* 机场表 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_airport") | |||
public class Airport implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
private int id; | |||
/** | |||
* 设备编号 | |||
*/ | |||
private String code; | |||
/** | |||
* 设备名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 机场照片 | |||
*/ | |||
private String image; | |||
/** | |||
* 外部监控地址 | |||
*/ | |||
private String externalMonitorUrl; | |||
/** | |||
* 外部监控地址flv | |||
*/ | |||
private String flvExternalMonitorUrl; | |||
/** | |||
* 内部监控地址 | |||
*/ | |||
private String internalMonitorUrl; | |||
/** | |||
* 覆盖范围 | |||
*/ | |||
private String coverage; | |||
/** | |||
* 排序 | |||
*/ | |||
private Integer sort; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 经度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 无人机ID | |||
*/ | |||
private Integer droneId; | |||
/** | |||
* 地面站url | |||
*/ | |||
private String groundStationUrl; | |||
/** | |||
* 控制板Id | |||
*/ | |||
private String edgeId; | |||
/** | |||
* mqtt控制板客户端Id | |||
*/ | |||
private String mqClientId; | |||
/*机场运行状态*/ | |||
private int astatus; | |||
private String address; | |||
private int tenantId; | |||
private int mark; | |||
} |
@@ -0,0 +1,129 @@ | |||
package com.tuoheng.airportGzdp.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 无人机表 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-27 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_drone") | |||
public class Drone { | |||
private static final long serialVersionUID = 1L; | |||
private int id; | |||
/** | |||
* 设备编号 | |||
*/ | |||
private String code; | |||
/** | |||
* 设备名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 无人机照片 | |||
*/ | |||
private String image; | |||
/** | |||
* 产品序号 | |||
*/ | |||
private String productSn; | |||
/** | |||
* 动力类型:1电动 2油动 3混合 | |||
*/ | |||
private Integer powerType; | |||
/** | |||
* 飞控序号 | |||
*/ | |||
private String flightSn; | |||
/** | |||
* 产品类型:1多旋翼 2固定翼 3垂直起降 | |||
*/ | |||
private Integer productType; | |||
/** | |||
* 产品等级:1微型 2轻型 3小型 4中型 5大型 6其他 | |||
*/ | |||
private Integer productLevel; | |||
/** | |||
* 生产厂家 | |||
*/ | |||
private String manufacturer; | |||
/** | |||
* 定位精度(单位:米) | |||
*/ | |||
private String accuracy; | |||
/** | |||
* 续航时间(单位:分钟) | |||
*/ | |||
private Integer lifeTime; | |||
/** | |||
* 状态:1正常 2停用 | |||
*/ | |||
private Integer status; | |||
/** | |||
* 相机ID | |||
*/ | |||
private Integer cameraId; | |||
/** | |||
* 喊话器ID | |||
*/ | |||
private Integer megaphoneId; | |||
/** | |||
* 探照灯ID | |||
*/ | |||
private Integer searchlightId; | |||
/** | |||
* 可见光摄像头地址 | |||
*/ | |||
private String cameraUrl; | |||
/** | |||
* 可见光摄像头地址 | |||
*/ | |||
private String liveUrl; | |||
/** | |||
* 热成像摄像头地址 改 推流地址 | |||
*/ | |||
private String thermalImageryUrl; | |||
/** | |||
* 直播地址-业务平台 | |||
*/ | |||
private String playUrl; | |||
/** | |||
* 排序号 | |||
*/ | |||
private Integer sort; | |||
/** | |||
* 电池代码 | |||
*/ | |||
private String batteryCode; | |||
} |
@@ -0,0 +1,124 @@ | |||
package com.tuoheng.airportGzdp.entity; | |||
import com.baomidou.mybatisplus.annotation.*; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* <p> | |||
* 后台租户管理表 | |||
* </p> | |||
* | |||
* @author ww | |||
* @since 2022-12-6 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_tenant") | |||
public class Tenant implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 用户ID | |||
*/ | |||
/* @TableId(value = "id", type = IdType.AUTO) | |||
private Integer id; | |||
*/ | |||
/** | |||
* 真实姓名 | |||
*/ | |||
private String name; | |||
private String code; | |||
/** | |||
* 关联用户id | |||
*/ | |||
private int userId; | |||
/** | |||
* logo | |||
*/ | |||
private String logo; | |||
/** | |||
*租户类型 | |||
*/ | |||
private Integer type; | |||
/** | |||
* 手机号码 | |||
*/ | |||
private String phone; | |||
/** | |||
* 邮箱地址 | |||
*/ | |||
private String email; | |||
/** | |||
* 平台名称 | |||
*/ | |||
private String platformName; | |||
/** | |||
* 地址 | |||
*/ | |||
private String address; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 主键ID | |||
*/ | |||
@TableId(value = "id", type = IdType.AUTO) | |||
private Integer id; | |||
/** | |||
* 添加人 | |||
*/ | |||
private Integer createUser; | |||
/** | |||
* 创建时间 | |||
*/ | |||
@TableField(fill = FieldFill.INSERT_UPDATE) | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date createTime; | |||
/** | |||
* 更新人 | |||
*/ | |||
private Integer updateUser; | |||
/** | |||
* 更新时间 | |||
*/ | |||
@TableField(fill = FieldFill.INSERT_UPDATE) | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date updateTime; | |||
/** | |||
* 有效标识 | |||
*/ | |||
private Integer mark; | |||
/** | |||
* 账号名 | |||
*/ | |||
private String username; | |||
} |
@@ -0,0 +1,70 @@ | |||
package com.tuoheng.airportGzdp.entity; | |||
import com.baomidou.mybatisplus.annotation.TableName; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import lombok.EqualsAndHashCode; | |||
import lombok.experimental.Accessors; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.io.Serializable; | |||
import java.util.Date; | |||
/** | |||
* @Author: ww | |||
* @CreateTime: 2023-11-07 14:28 | |||
* @Description: 视频回放资源 | |||
* @Version: 2.0.1 | |||
*/ | |||
@Data | |||
@EqualsAndHashCode(callSuper = false) | |||
@Accessors(chain = true) | |||
@TableName("th_vedio_Inspectionrecord") | |||
public class VedioInspectionRecord implements Serializable { | |||
private static final long serialVersionUID = 1L; | |||
/** | |||
* 名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 视频url | |||
*/ | |||
private String url; | |||
/** | |||
* 开始录制时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date startTime; | |||
/** | |||
* 结束录制时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private Date endTime; | |||
/** | |||
* 所属任务记录 | |||
*/ | |||
private Integer recordId; | |||
/** | |||
* 视频宽度 | |||
*/ | |||
private String duration; | |||
/** | |||
* 视频高度 | |||
*/ | |||
private Integer height; | |||
/** | |||
* 视频宽度 | |||
*/ | |||
private Integer Width; | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.airportGzdp.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.airportGzdp.entity.AirlineData; | |||
/** | |||
* <p> | |||
* 航线数据表 Mapper 接口 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
public interface AirlineDataMapper extends BaseMapper<AirlineData> { | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.airportGzdp.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.airportGzdp.entity.AirlineFile; | |||
/** | |||
* <p> | |||
* 航线文件表 Mapper 接口 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
public interface AirlineFileMapper extends BaseMapper<AirlineFile> { | |||
} |
@@ -0,0 +1,17 @@ | |||
package com.tuoheng.airportGzdp.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.airportGzdp.entity.Airport; | |||
/** | |||
* <p> | |||
* 机场表 Mapper 接口 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
public interface AirportMapper extends BaseMapper<Airport> { | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.airportGzdp.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.airportGzdp.entity.Drone; | |||
/** | |||
* <p> | |||
* 无人机表 Mapper 接口 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-27 | |||
*/ | |||
public interface DroneMapper extends BaseMapper<Drone> { | |||
} |
@@ -0,0 +1,29 @@ | |||
package com.tuoheng.airportGzdp.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.airportGzdp.vo.TaskListVo; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* <p> | |||
* Mapper 接口 | |||
* </p> | |||
* @author 拓恒 | |||
*/ | |||
public interface TaskMapper extends BaseMapper<TaskListVo> { | |||
//已完成的任务 | |||
List<TaskListVo> getList(Integer tenantId, int limit); | |||
//待执行的任务 | |||
List<TaskListVo> getPreList(Integer tenantId,int limit); | |||
//运行中的任务 | |||
List<TaskListVo> getRunList(Integer tenantId,int limit); | |||
//运行中的任务 | |||
List<Map> getCountList(Integer tenantId); | |||
List<Map> getRunTaskByAirportId(int id); | |||
} |
@@ -0,0 +1,15 @@ | |||
package com.tuoheng.airportGzdp.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.airportGzdp.entity.Tenant; | |||
/** | |||
* <p> | |||
* 后台租户管理表 Mapper 接口 | |||
* </p> | |||
* @author | |||
* @since 2022-12-30 | |||
*/ | |||
public interface TenantMapper extends BaseMapper<Tenant> { | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.airportGzdp.mapper; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.tuoheng.airportGzdp.entity.VedioInspectionRecord; | |||
/** | |||
* <p> | |||
* 视频回放数据表 Mapper 接口 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2023-12-19 | |||
*/ | |||
public interface VedioDataMapper extends BaseMapper<VedioInspectionRecord> { | |||
} |
@@ -0,0 +1,18 @@ | |||
package com.tuoheng.airportGzdp.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.tuoheng.airportGzdp.common.JsonResult; | |||
import com.tuoheng.airportGzdp.entity.AirlineData; | |||
/** | |||
* <p> | |||
* 航线数据表 服务类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
public interface IAirlineDataService extends IService<AirlineData> { | |||
JsonResult getList(int recordId); | |||
} |
@@ -0,0 +1,18 @@ | |||
package com.tuoheng.airportGzdp.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.tuoheng.airportGzdp.entity.AirlineFile; | |||
/** | |||
* <p> | |||
* 航线文件表 服务类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
public interface IAirlineFileService extends IService<AirlineFile> { | |||
} |
@@ -0,0 +1,18 @@ | |||
package com.tuoheng.airportGzdp.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.tuoheng.airportGzdp.common.JsonResult; | |||
import com.tuoheng.airportGzdp.entity.Airport; | |||
/** | |||
* <p> | |||
* 机场表 服务类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
public interface IAirportService extends IService<Airport> { | |||
JsonResult getList(String tenantCode); | |||
JsonResult getWather(int airportId); | |||
} |
@@ -0,0 +1,18 @@ | |||
package com.tuoheng.airportGzdp.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.tuoheng.airportGzdp.entity.Drone; | |||
/** | |||
* <p> | |||
* 无人机表 服务类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-27 | |||
*/ | |||
public interface IDroneService extends IService<Drone> { | |||
} |
@@ -0,0 +1,23 @@ | |||
package com.tuoheng.airportGzdp.service; | |||
import com.baomidou.mybatisplus.extension.service.IService; | |||
import com.tuoheng.airportGzdp.common.JsonResult; | |||
import com.tuoheng.airportGzdp.vo.TaskListVo; | |||
import java.util.Map; | |||
/** | |||
* <p> | |||
* 机场表 服务类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
public interface ITaskService extends IService<TaskListVo> { | |||
JsonResult getList(String tenantCode,int limit); | |||
JsonResult getCountList(String tenantCode); | |||
Map getRunTaskByAirportId(int id); | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.tuoheng.airportGzdp.service; | |||
import com.tuoheng.airportGzdp.entity.Tenant; | |||
/** | |||
* <p> | |||
* 后台租户管理表 服务类 | |||
* </p> | |||
* @author 拓恒 | |||
* @since 2022-12-30 | |||
*/ | |||
public interface ITenantService { | |||
Tenant selectByTenantCode(String code); | |||
} |
@@ -0,0 +1,48 @@ | |||
package com.tuoheng.airportGzdp.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.core.toolkit.StringUtils; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.tuoheng.airportGzdp.common.JsonResult; | |||
import com.tuoheng.airportGzdp.entity.AirlineData; | |||
import com.tuoheng.airportGzdp.mapper.AirlineDataMapper; | |||
import com.tuoheng.airportGzdp.service.IAirlineDataService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* <p> | |||
* 航线文件表 服务实现类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
@Service | |||
public class AirlineDataServiceImpl extends ServiceImpl<AirlineDataMapper, AirlineData> implements IAirlineDataService { | |||
@Autowired | |||
private AirlineDataMapper airlineDataMapper; | |||
/** | |||
* 查询航线数据列表 | |||
* @param recordId 查询条件 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getList(int recordId) { | |||
// 查询条件 | |||
QueryWrapper<AirlineData> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("record_id", recordId); | |||
queryWrapper.eq("mark", 1); | |||
queryWrapper.orderByAsc("id"); | |||
// 分页设置 | |||
IPage<AirlineData> page = new Page<>(1, Integer.MAX_VALUE); | |||
IPage<AirlineData> pageData = airlineDataMapper.selectPage(page, queryWrapper); | |||
return JsonResult.success(pageData); | |||
} | |||
} |
@@ -0,0 +1,35 @@ | |||
package com.tuoheng.airportGzdp.service.impl; | |||
import cn.hutool.core.convert.Convert; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.tuoheng.airportGzdp.entity.AirlineFile; | |||
import com.tuoheng.airportGzdp.mapper.AirlineFileMapper; | |||
import com.tuoheng.airportGzdp.service.IAirlineFileService; | |||
import org.springframework.beans.BeanUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.util.CollectionUtils; | |||
import java.io.ByteArrayInputStream; | |||
import java.io.ByteArrayOutputStream; | |||
import java.util.List; | |||
import java.util.UUID; | |||
import java.util.stream.Collectors; | |||
/** | |||
* <p> | |||
* 航线文件表 服务实现类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-26 | |||
*/ | |||
@Service | |||
public class AirlineFileServiceImpl extends ServiceImpl<AirlineFileMapper, AirlineFile> implements IAirlineFileService { | |||
} |
@@ -0,0 +1,166 @@ | |||
package com.tuoheng.airportGzdp.service.impl; | |||
import cn.hutool.core.convert.Convert; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.alibaba.fastjson.JSONReader; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.tuoheng.airportGzdp.common.JsonResult; | |||
import com.tuoheng.airportGzdp.entity.Airport; | |||
import com.tuoheng.airportGzdp.entity.Drone; | |||
import com.tuoheng.airportGzdp.entity.Tenant; | |||
import com.tuoheng.airportGzdp.mapper.AirportMapper; | |||
import com.tuoheng.airportGzdp.service.IAirportService; | |||
import com.tuoheng.airportGzdp.service.IDroneService; | |||
import com.tuoheng.airportGzdp.service.ITaskService; | |||
import com.tuoheng.airportGzdp.service.ITenantService; | |||
import com.tuoheng.airportGzdp.until.RedisUtils; | |||
import com.tuoheng.airportGzdp.vo.AirportListVo; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.eclipse.paho.client.mqttv3.internal.wire.MqttReceivedMessage; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.util.ObjectUtils; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* <p> | |||
* 机场表 服务实现类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2023-10-26 | |||
*/ | |||
@Service | |||
@Slf4j | |||
public class AirportServiceImpl extends ServiceImpl<AirportMapper, Airport> implements IAirportService { | |||
@Autowired | |||
private RedisUtils redisUtils; | |||
@Autowired | |||
private ITenantService tenantService; | |||
@Autowired | |||
private IDroneService droneService; | |||
/** | |||
* 查询机场列表 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getList(String tenantCode) { | |||
try { | |||
Tenant tenant = tenantService.selectByTenantCode(tenantCode); | |||
IPage<Airport> page = new Page<>(1, Integer.MAX_VALUE); | |||
IPage<Airport> pageList = this.page(page, new LambdaQueryWrapper<Airport>() | |||
.eq(Airport::getTenantId, tenant.getId()).eq(Airport::getMark, 1)); | |||
//查询在线机场 | |||
//String airportOnline = redisUtils.get("mqttClient") == null ? "" : redisUtils.get("mqttClient").toString(); | |||
pageList.convert(x -> { | |||
AirportListVo airportListVo = Convert.convert(AirportListVo.class, x); | |||
Drone drone = droneService.getById(x.getDroneId()); | |||
if (ObjectUtil.isNotEmpty(drone)) { | |||
airportListVo.setCameraUrl(drone.getCameraUrl()); | |||
} | |||
//status | |||
/*airportListVo.setStatus(1); | |||
Map statusMap = taskService.getRunTaskByAirportId(x.getId()); | |||
if (ObjectUtil.isNotEmpty(statusMap)){ | |||
airportListVo.setStatus(2); | |||
airportListVo.setTaskMap(statusMap); | |||
}*/ | |||
return airportListVo; | |||
}); | |||
return JsonResult.success(pageList); | |||
}catch (Exception e){ | |||
log.error("",e); | |||
} | |||
return JsonResult.error(); | |||
} | |||
/** | |||
* 查询在线机场 | |||
* | |||
* @param airportOnline | |||
* @param airportListVo | |||
* @return | |||
*/ | |||
private boolean getOnline(String airportOnline, AirportListVo airportListVo) { | |||
JSONObject mqObject = JSONObject.parseObject(airportOnline); | |||
//新版 | |||
/*if (ObjectUtil.isNotEmpty(redisUtils.get(airportListVo.getCode() + "_online"))) { | |||
if (redisUtils.get(airportListVo.getCode() + "_online").toString().equals("online")) { | |||
return true; | |||
} else { | |||
return false; | |||
} | |||
}*/ | |||
if (mqObject.get("code").toString().equals("0")) { | |||
List list = (List) mqObject.get("data"); | |||
if (list.size() > 0) { | |||
for (Object ob : list) { | |||
JSONObject obs = (JSONObject) ob; | |||
if (airportListVo.getEdgeId().equals(obs.get("clientid").toString())) { | |||
return true; | |||
}; | |||
} | |||
} | |||
return false; | |||
} | |||
return false; | |||
} | |||
/** | |||
* 获取气象数据 | |||
* @param airportId | |||
* @return | |||
*/ | |||
public JsonResult getWather(int airportId){ | |||
Map map = new HashMap(); | |||
MqttReceivedMessage wth = null; | |||
MqttReceivedMessage droneTmp = null; | |||
Airport airport = this.getById(airportId); | |||
try { | |||
if (!ObjectUtils.isEmpty(redisUtils.hget(airport.getEdgeId() + "_data", "/data/WTH"))) { | |||
JSONObject jsonObject = new JSONObject(); | |||
if (redisUtils.hget(airport.getEdgeId() + "_data", "/data/WTH") instanceof MqttReceivedMessage) { | |||
log.info("天气数据MqttReceivedMessage类型:{}"); | |||
wth = (MqttReceivedMessage) redisUtils.hget(airport.getEdgeId() + "_data", "/data/WTH"); | |||
log.info("天气数据{}",wth.getPayload()); | |||
jsonObject = (JSONObject)JSON.parse(wth.getPayload()); | |||
}else{ | |||
log.info("天气数据JSONObject类型:{}"); | |||
jsonObject = (JSONObject) redisUtils.hget(airport.getEdgeId() + "_data", "/data/WTH"); | |||
log.info("天气数据{}",jsonObject); | |||
} | |||
map.put("wth",jsonObject.get("parmNew")); | |||
} | |||
if (!ObjectUtils.isEmpty(redisUtils.hget(airport.getEdgeId() + "_data", "/data/DroneBMS"))) { | |||
JSONObject jsonObject = new JSONObject(); | |||
if (redisUtils.hget(airport.getEdgeId() + "_data", "/data/DroneBMS") instanceof MqttReceivedMessage) { | |||
log.info("电池数据MqttReceivedMessage类型:{}"); | |||
droneTmp = (MqttReceivedMessage) redisUtils.hget(airport.getEdgeId() + "_data", "/data/DroneBMS"); | |||
jsonObject = (JSONObject)JSON.parse(droneTmp.getPayload()); | |||
}else{ | |||
log.info("电池数据JSONObject类型:{}"); | |||
jsonObject = (JSONObject) redisUtils.hget(airport.getEdgeId() + "_data", "/data/DroneBMS"); | |||
} | |||
map.put("droneTmp",jsonObject.get("parm")); | |||
} | |||
} catch (Exception e) { | |||
log.error("",e); | |||
} | |||
return JsonResult.success(map); | |||
} | |||
} |
@@ -0,0 +1,22 @@ | |||
package com.tuoheng.airportGzdp.service.impl; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.tuoheng.airportGzdp.entity.Drone; | |||
import com.tuoheng.airportGzdp.mapper.DroneMapper; | |||
import com.tuoheng.airportGzdp.service.IDroneService; | |||
import org.springframework.stereotype.Service; | |||
/** | |||
* <p> | |||
* 无人机表 服务实现类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2021-09-27 | |||
*/ | |||
@Service | |||
public class DroneServiceImpl extends ServiceImpl<DroneMapper, Drone> implements IDroneService { | |||
} |
@@ -0,0 +1,128 @@ | |||
package com.tuoheng.airportGzdp.service.impl; | |||
import cn.hutool.core.thread.ThreadUtil; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | |||
import com.tuoheng.airportGzdp.common.JsonResult; | |||
import com.tuoheng.airportGzdp.config.WebSocket; | |||
import com.tuoheng.airportGzdp.entity.Tenant; | |||
import com.tuoheng.airportGzdp.entity.VedioInspectionRecord; | |||
import com.tuoheng.airportGzdp.mapper.TaskMapper; | |||
import com.tuoheng.airportGzdp.mapper.VedioDataMapper; | |||
import com.tuoheng.airportGzdp.service.ITaskService; | |||
import com.tuoheng.airportGzdp.service.ITenantService; | |||
import com.tuoheng.airportGzdp.until.RedisUtils; | |||
import com.tuoheng.airportGzdp.vo.TaskListVo; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.scheduling.annotation.Async; | |||
import org.springframework.stereotype.Service; | |||
import java.util.ArrayList; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
/** | |||
* <p> | |||
* 机场任务表 服务实现类 | |||
* </p> | |||
* | |||
* @author 拓恒 | |||
* @since 2023-10-26 | |||
*/ | |||
@Service | |||
@Slf4j | |||
public class TaskServiceImpl extends ServiceImpl<TaskMapper, TaskListVo> implements ITaskService { | |||
@Autowired | |||
private TaskMapper taskMapper; | |||
@Autowired | |||
private VedioDataMapper vedioDataMapper; | |||
@Autowired | |||
private ITenantService tenantService; | |||
@Autowired | |||
private WebSocket webSocket; | |||
@Autowired | |||
RedisUtils redisUtils; | |||
/** | |||
* 查询机场任务列表 | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getList(String tenantCode,int limit) { | |||
Tenant tenant = tenantService.selectByTenantCode(tenantCode); | |||
//已完成的任务 | |||
List listRun = taskMapper.getRunList(tenant.getId(),limit); | |||
if (listRun.size()>=limit){ | |||
return JsonResult.success(listRun); | |||
} | |||
if (listRun.size()>0){ | |||
limit=limit-listRun.size(); | |||
} | |||
List listAdd = new ArrayList(); | |||
listAdd.addAll(listRun); | |||
//待执行的任务 | |||
List listPre = taskMapper.getPreList(tenant.getId(),limit); | |||
listAdd.addAll(listPre); | |||
if (listPre.size()>=limit){ | |||
return JsonResult.success(listAdd); | |||
} | |||
if (listPre.size()>0){ | |||
limit = limit-listPre.size(); | |||
} | |||
//已完成的任务 | |||
List list = taskMapper.getList(tenant.getId(),limit); | |||
list.stream().map(t -> { | |||
//查询回放视频 | |||
TaskListVo taskListVo = (TaskListVo) t; | |||
List<VedioInspectionRecord> vedioInspectionRecords = vedioDataMapper.selectList(new LambdaQueryWrapper<VedioInspectionRecord>().eq(VedioInspectionRecord::getRecordId,taskListVo.getRecordId())); | |||
taskListVo.setVedioCount(vedioInspectionRecords.size()); | |||
taskListVo.setListVedio(vedioInspectionRecords); | |||
return taskListVo; | |||
}).collect(Collectors.toList());; | |||
if (list.size()>=limit){ | |||
listAdd.addAll(list); | |||
return JsonResult.success(listAdd); | |||
} | |||
return JsonResult.success(listAdd); | |||
} | |||
/** | |||
* 查询任务统计 | |||
* @param tenantCode | |||
* @return | |||
*/ | |||
@Override | |||
public JsonResult getCountList(String tenantCode) { | |||
Tenant tenant = tenantService.selectByTenantCode(tenantCode); | |||
List list = taskMapper.getCountList(tenant.getId());; | |||
return JsonResult.success(list); | |||
} | |||
public Map getRunTaskByAirportId(int id){ | |||
List<Map> list = taskMapper.getRunTaskByAirportId(id); | |||
if (list.size()>0){ | |||
return list.get(0); | |||
} | |||
return null; | |||
} | |||
@Async | |||
public void getListToWebsocket(String tenantCode, int i) { | |||
while (true) { | |||
if (ObjectUtil.isNotEmpty(redisUtils.hget("NXDP","taskSendStatus")) | |||
&&!redisUtils.hget("NXDP","taskSendStatus").toString().equals(Thread.currentThread().getName())){ | |||
return; | |||
} | |||
JsonResult jsonResult = getList(tenantCode, i); | |||
if (jsonResult.getCode()==0) { | |||
JSONObject jsonObject = new JSONObject(); | |||
jsonObject.put("preTasklist",jsonResult.getData()); | |||
webSocket.sendAllMessage(JSONObject.toJSONString(jsonObject)); | |||
} | |||
ThreadUtil.sleep(3000); | |||
redisUtils.hset("NXDP","taskSendStatus",Thread.currentThread().getName(),10); | |||
} | |||
} | |||
} |
@@ -0,0 +1,35 @@ | |||
package com.tuoheng.airportGzdp.service.impl; | |||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | |||
import com.tuoheng.airportGzdp.entity.Tenant; | |||
import com.tuoheng.airportGzdp.mapper.TenantMapper; | |||
import com.tuoheng.airportGzdp.service.ITenantService; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 后台租户管理表 服务实现类 | |||
* </p> | |||
* | |||
* @author | |||
* @since 2022-12-30 | |||
*/ | |||
@Service | |||
public class TenantServiceImpl implements ITenantService { | |||
@Autowired | |||
private TenantMapper tenantMapper; | |||
@Override | |||
public Tenant selectByTenantCode(String code) { | |||
QueryWrapper wrapper = new QueryWrapper(); | |||
wrapper.eq("code", code); | |||
wrapper.eq("mark", 1); | |||
List list = tenantMapper.selectList(wrapper); | |||
if (list.size() > 0) { | |||
return (Tenant) list.get(0); | |||
} | |||
return null; | |||
} | |||
} |
@@ -0,0 +1,307 @@ | |||
package com.tuoheng.airportGzdp.until; | |||
import lombok.extern.slf4j.Slf4j; | |||
import org.springframework.lang.Nullable; | |||
import javax.net.ssl.HttpsURLConnection; | |||
import javax.net.ssl.SSLContext; | |||
import javax.net.ssl.TrustManager; | |||
import javax.net.ssl.X509TrustManager; | |||
import java.io.*; | |||
import java.net.HttpURLConnection; | |||
import java.net.MalformedURLException; | |||
import java.net.URL; | |||
import java.net.URLConnection; | |||
import java.security.cert.CertificateException; | |||
import java.security.cert.X509Certificate; | |||
/** | |||
* @author ww | |||
* @date 2022/07/8 10:42 | |||
*/ | |||
@Slf4j | |||
public class HttpURLConnectionUtil { | |||
/** | |||
* Http get请求 | |||
* @param httpUrl 连接 | |||
* @return 响应数据 | |||
*/ | |||
public static String doGet(String httpUrl){ | |||
log.info("机场平台开始发送http请求,url:{};param:{}",httpUrl); | |||
//链接 | |||
HttpURLConnection connection = null; | |||
InputStream is = null; | |||
BufferedReader br = null; | |||
StringBuffer result = new StringBuffer(); | |||
try { | |||
//创建连接 | |||
URL url = new URL(httpUrl); | |||
if("https".equalsIgnoreCase(url.getProtocol())){ | |||
SslUtils.ignoreSsl(); | |||
} | |||
connection = (HttpURLConnection) url.openConnection(); | |||
//设置请求方式 | |||
connection.setRequestMethod("GET"); | |||
connection.setRequestProperty("accept", "*/*"); | |||
connection.setRequestProperty("connection", "Keep-Alive"); | |||
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); | |||
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8"); | |||
connection.setRequestProperty("Authorization", "Basic YWRtaW46cHVibGlj"); | |||
connection.setRequestProperty("Cookie", "jenkins-timestamper-offset=-28800000; order=id%20desc; serverType=nginx; ltd_end=-1; pro_end=-1; memSize=7768; bt_user_info=%7B%22status%22%3Atrue%2C%22msg%22%3A%22%u83B7%u53D6%u6210%u529F%21%22%2C%22data%22%3A%7B%22username%22%3A%22139****4314%22%7D%7D; sites_path=/www/wwwroot; distribution=centos8; p-1=1; lang=en-US; force=0; b6e922e8cf76dea67efb3a9292724aee=acc59469-46e3-4576-b216-81b907d80a7f.rB3Plw7uc301E0qFoEBeoP_fL4w; load_search=undefined; remember-me=YWRtaW46MTY1ODIxMDYwODA2MDoxY2ZhOTBhMzFlN2IzZTg1YzM5MWQ3Y2M4MWEzYzVlZmYzM2UzOGQ4MTVjZDZhNTUwNjQ4YjFhMjVlYTM3NWJj; JSESSIONID.fc8332ab=node01bo1jsydkd8ql1oo3srksa2k6w288.node0; screenResolution=1920x1080; b2651c13496a99bc2899b024b99bca4f=b4e55bb9-4a3e-44b6-ae8b-c054e7115182.SEaDzMgHxI4d2CGoGwNPnj3L2y4; request_token=hH1LwVtazrgz4sMI4CE1SwEVpCYgiQcHNp4EfyvPni9C32PJ; soft_remarks=%7B%22list%22%3A%5B%22%u4F01%u4E1A%u7248%u3001%u4E13%u4E1A%u7248%u63D2%u4EF6%22%2C%2215%u5929%u65E0%u7406%u7531%u9000%u6B3E%22%2C%22%u53EF%u66F4%u6362IP%22%2C%22%u5E74%u4ED8%u8D60%u90012%u5F20SSL%u8BC1%u4E66%22%2C%22%u5E74%u4ED8%u8D60%u90011000%u6761%u77ED%u4FE1%22%2C%22%u4F4E%u81F32.43%u5143/%u5929%22%2C%22%u5546%u7528%u9632%u706B%u5899%u6388%u6743%22%2C%22%u5E74%u4ED8%u53EF%u5165%u4F01%u4E1A%u7248%u670D%u52A1%u7FA4%22%2C%22%u4EA7%u54C1%u6388%u6743%u8BC1%u4E66%22%5D%2C%22pro_list%22%3A%5B%22%u4E13%u4E1A%u7248%u63D2%u4EF6%22%2C%2215%u5929%u65E0%u7406%u7531%u9000%u6B3E%22%2C%22%u53EF%u66F4%u6362IP%22%2C%22%u4F4E%u81F31.18%u5143/%u5929%22%2C%22%u5546%u7528%u9632%u706B%u5899%u6388%u6743%22%2C%22%u4EA7%u54C1%u6388%u6743%u8BC1%u4E66%22%5D%2C%22kfqq%22%3A%223007255432%22%2C%22kf%22%3A%22http%3A//q.url.cn/CDfQPS%3F_type%3Dwpa%26qidian%3Dtrue%22%2C%22qun%22%3A%22%22%2C%22kf_list%22%3A%5B%7B%22qq%22%3A%223007255432%22%2C%22kf%22%3A%22http%3A//q.url.cn/CDfQPS%3F_type%3Dwpa%26qidian%3Dtrue%22%7D%2C%7B%22qq%22%3A%222927440070%22%2C%22kf%22%3A%22http%3A//wpa.qq.com/msgrd%3Fv%3D3%26uin%3D2927440070%26site%3Dqq%26menu%3Dyes%26from%3Dmessage%26isappinstalled%3D0%22%7D%5D%2C%22wx_list%22%3A%5B%7B%22ps%22%3A%22%u552E%u524D%u54A8%u8BE2%22%2C%22kf%22%3A%22https%3A//work.weixin.qq.com/kfid/kfc72fcbde93e26a6f3%22%7D%5D%7D; load_page=null; load_type=null"); | |||
//设置连接超时时间 | |||
connection.setReadTimeout(15000); | |||
//开始连接 | |||
connection.connect(); | |||
//获取响应数据 | |||
if (connection.getResponseCode() == 200) { | |||
//获取返回的数据 | |||
is = connection.getInputStream(); | |||
if (null != is) { | |||
br = new BufferedReader(new InputStreamReader(is, "UTF-8")); | |||
String temp = null; | |||
while (null != (temp = br.readLine())) { | |||
result.append(temp); | |||
} | |||
} | |||
} | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
log.error("http请求异常,url:{};异常信息:{}",httpUrl,e); | |||
} finally { | |||
if (null != br) { | |||
try { | |||
br.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
if (null != is) { | |||
try { | |||
is.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
//关闭远程连接 | |||
connection.disconnect(); | |||
} | |||
return result.toString(); | |||
} | |||
/** | |||
* Http post请求 | |||
* @param httpUrl 连接 | |||
* @param param 参数 | |||
* @return | |||
*/ | |||
public static String doPost(String httpUrl, @Nullable String param) { | |||
log.info("机场平台开始发送http请求,url:{};param:{}",httpUrl,param); | |||
StringBuffer result = new StringBuffer(); | |||
//连接 | |||
HttpURLConnection connection = null; | |||
OutputStream os = null; | |||
InputStream is = null; | |||
BufferedReader br = null; | |||
trustAllHosts(); | |||
try { | |||
//创建连接对象 | |||
URL url = new URL(httpUrl); | |||
if("https".equalsIgnoreCase(url.getProtocol())){ | |||
SslUtils.ignoreSsl(); | |||
} | |||
//创建连接 | |||
connection = (HttpURLConnection) url.openConnection(); | |||
//设置请求方法 | |||
connection.setRequestMethod("POST"); | |||
//设置连接超时时间 | |||
connection.setConnectTimeout(30000); | |||
//设置读取超时时间 | |||
connection.setReadTimeout(30000); | |||
//DoOutput设置是否向httpUrlConnection输出,DoInput设置是否从httpUrlConnection读入,此外发送post请求必须设置这两个 | |||
//设置是否可读取 | |||
connection.setDoOutput(true); | |||
connection.setDoInput(true); | |||
//设置通用的请求属性 | |||
connection.setRequestProperty("accept", "*/*"); | |||
connection.setRequestProperty("connection", "Keep-Alive"); | |||
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); | |||
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8"); | |||
//拼装参数 | |||
if (null != param && (!param.equals(""))) { | |||
//设置参数 | |||
os = connection.getOutputStream(); | |||
//拼装参数 | |||
os.write(param.getBytes("UTF-8")); | |||
} | |||
//设置权限 | |||
//设置请求头等 | |||
//开启连接 | |||
//connection.connect(); | |||
//读取响应 | |||
if (connection.getResponseCode() == 200) { | |||
is = connection.getInputStream(); | |||
if (null != is) { | |||
//br = new BufferedReader(new InputStreamReader(is, "GBK")); | |||
br = new BufferedReader(new InputStreamReader(is, "UTF-8")); | |||
String temp = null; | |||
while (null != (temp = br.readLine())) { | |||
result.append(temp); | |||
result.append("\r\n"); | |||
} | |||
} | |||
} | |||
}catch (Exception e) { | |||
log.error("http请求异常,url:{};请求参数:{};异常信息:{}",httpUrl,param,e); | |||
} finally { | |||
//关闭连接 | |||
if(br!=null){ | |||
try { | |||
br.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
if(os!=null){ | |||
try { | |||
os.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
if(is!=null){ | |||
try { | |||
is.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
//关闭连接 | |||
connection.disconnect(); | |||
} | |||
return result.toString(); | |||
} | |||
public static String doPut(String httpUrl, @Nullable String param) { | |||
log.info("机场平台开始发送http doPut请求,url:{};param:{}",httpUrl,param); | |||
StringBuffer result = new StringBuffer(); | |||
//连接 | |||
HttpURLConnection connection = null; | |||
OutputStream os = null; | |||
InputStream is = null; | |||
BufferedReader br = null; | |||
try { | |||
//创建连接对象 | |||
URL url = new URL(httpUrl); | |||
if("https".equalsIgnoreCase(url.getProtocol())){ | |||
SslUtils.ignoreSsl(); | |||
} | |||
//创建连接 | |||
connection = (HttpURLConnection) url.openConnection(); | |||
//设置请求方法 | |||
connection.setRequestMethod("PUT"); | |||
//设置连接超时时间 | |||
connection.setConnectTimeout(15000); | |||
//设置读取超时时间 | |||
connection.setReadTimeout(15000); | |||
//DoOutput设置是否向httpUrlConnection输出,DoInput设置是否从httpUrlConnection读入,此外发送post请求必须设置这两个 | |||
//设置是否可读取 | |||
connection.setDoOutput(true); | |||
connection.setDoInput(true); | |||
//设置通用的请求属性 | |||
connection.setRequestProperty("accept", "*/*"); | |||
connection.setRequestProperty("connection", "Keep-Alive"); | |||
connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)"); | |||
connection.setRequestProperty("Content-Type", "application/json;charset=utf-8"); | |||
//拼装参数 | |||
if (null != param && (!param.equals(""))) { | |||
//设置参数 | |||
os = connection.getOutputStream(); | |||
//拼装参数 | |||
os.write(param.getBytes("UTF-8")); | |||
} | |||
//设置权限 | |||
//设置请求头等 | |||
//开启连接 | |||
//connection.connect(); | |||
//读取响应 | |||
if (connection.getResponseCode() == 200) { | |||
is = connection.getInputStream(); | |||
if (null != is) { | |||
//br = new BufferedReader(new InputStreamReader(is, "GBK")); | |||
br = new BufferedReader(new InputStreamReader(is, "UTF-8")); | |||
String temp = null; | |||
while (null != (temp = br.readLine())) { | |||
result.append(temp); | |||
result.append("\r\n"); | |||
} | |||
} | |||
} | |||
}catch (Exception e) { | |||
log.error("http doPut请求异常,url:{};请求参数:{};异常信息:{}",httpUrl,param,e); | |||
} finally { | |||
//关闭连接 | |||
if(br!=null){ | |||
try { | |||
br.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
if(os!=null){ | |||
try { | |||
os.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
if(is!=null){ | |||
try { | |||
is.close(); | |||
} catch (IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
//关闭连接 | |||
connection.disconnect(); | |||
} | |||
return result.toString(); | |||
} | |||
public static void main(String[] args) { | |||
String message = doPost("https://nxdp-test.t-aaron.com/api/airportInterface/executeTaskAnsy", ""); | |||
System.out.println(message); | |||
} | |||
/** | |||
* Trust every server - dont check for any certificate | |||
*/ | |||
private static void trustAllHosts() { | |||
final String TAG = "trustAllHosts"; | |||
// Create a trust manager that does not validate certificate chains | |||
TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() { | |||
public java.security.cert.X509Certificate[] getAcceptedIssuers() { | |||
return new java.security.cert.X509Certificate[]{}; | |||
} | |||
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException { | |||
//Log.i(TAG, "checkClientTrusted"); | |||
} | |||
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { | |||
//Log.i(TAG, "checkServerTrusted"); | |||
} | |||
}}; | |||
// Install the all-trusting trust manager | |||
try { | |||
SSLContext sc = SSLContext.getInstance("TLS"); | |||
sc.init(null, trustAllCerts, new java.security.SecureRandom()); | |||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,609 @@ | |||
package com.tuoheng.airportGzdp.until; | |||
import org.springframework.data.redis.core.RedisTemplate; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Propagation; | |||
import org.springframework.transaction.annotation.Transactional; | |||
import org.springframework.util.CollectionUtils; | |||
import java.util.Collection; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Set; | |||
import java.util.concurrent.TimeUnit; | |||
public class RedisUtils { | |||
private RedisTemplate<String, Object> redisTemplate; | |||
public void setRedisTemplate(RedisTemplate<String, Object> redisTemplate) { | |||
this.redisTemplate = redisTemplate; | |||
} | |||
// =============================common============================ | |||
/** | |||
* 普通缓存获取 | |||
* | |||
* @param | |||
* @return 值 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Set<String> keys(String pattern) { | |||
return redisTemplate.keys(pattern); | |||
} | |||
/** | |||
* 指定缓存失效时间 | |||
* | |||
* @param key 键 | |||
* @param time 时间(秒) | |||
* @return | |||
*/ | |||
public boolean expire(String key, long time) { | |||
try { | |||
if (time > 0) { | |||
redisTemplate.expire(key, time, TimeUnit.SECONDS); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 根据key 获取过期时间 | |||
* | |||
* @param key 键 不能为null | |||
* @return 时间(秒) 返回0代表为永久有效 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public long getExpire(String key) { | |||
return redisTemplate.getExpire(key, TimeUnit.SECONDS); | |||
} | |||
/** | |||
* 判断key是否存在 | |||
* | |||
* @param key 键 | |||
* @return true 存在 false不存在 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public boolean hasKey(String key) { | |||
try { | |||
return redisTemplate.hasKey(key); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 删除缓存 | |||
* | |||
* @param key 可以传一个值 或多个 | |||
*/ | |||
@SuppressWarnings("unchecked") | |||
public void del(String... key) { | |||
if (key != null && key.length > 0) { | |||
if (key.length == 1) { | |||
redisTemplate.delete(key[0]); | |||
} else { | |||
redisTemplate.delete((Collection<String>) CollectionUtils.arrayToList(key)); | |||
} | |||
} | |||
} | |||
// ============================String============================= | |||
/** | |||
* 普通缓存获取 | |||
* | |||
* @param key 键 | |||
* @return 值 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Object get(String key) { | |||
return key == null ? null : redisTemplate.opsForValue().get(key); | |||
} | |||
/** | |||
* 普通缓存放入 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @return true成功 false失败 | |||
*/ | |||
public boolean set(String key, Object value) { | |||
try { | |||
redisTemplate.opsForValue().set(key, value); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 普通缓存放入并设置时间 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 | |||
* @return true成功 false 失败 | |||
*/ | |||
public boolean set(String key, Object value, long time) { | |||
try { | |||
if (time > 0) { | |||
redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); | |||
} else { | |||
set(key, value); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 递增 | |||
* | |||
* @param key 键 | |||
* @param delta 要增加几(大于0) | |||
* @return | |||
*/ | |||
public long incr(String key, long delta) { | |||
if (delta < 0) { | |||
throw new RuntimeException("递增因子必须大于0"); | |||
} | |||
return redisTemplate.opsForValue().increment(key, delta); | |||
} | |||
/** | |||
* 递减 | |||
* | |||
* @param key 键 | |||
* @param delta 要减少几(小于0) | |||
* @return | |||
*/ | |||
public long decr(String key, long delta) { | |||
if (delta < 0) { | |||
throw new RuntimeException("递减因子必须大于0"); | |||
} | |||
return redisTemplate.opsForValue().increment(key, -delta); | |||
} | |||
// ================================Map================================= | |||
/** | |||
* HashGet | |||
* | |||
* @param key 键 不能为null | |||
* @param item 项 不能为null | |||
* @return 值 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Object hget(String key, String item) { | |||
return redisTemplate.opsForHash().get(key, item); | |||
} | |||
/** | |||
* 获取hashKey对应的所有键值 | |||
* | |||
* @param key 键 | |||
* @return 对应的多个键值 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Map<Object, Object> hmget(String key) { | |||
return redisTemplate.opsForHash().entries(key); | |||
} | |||
/** | |||
* HashSet | |||
* | |||
* @param key 键 | |||
* @param map 对应多个键值 | |||
* @return true 成功 false 失败 | |||
*/ | |||
public boolean hmset(String key, Map<String, Object> map) { | |||
try { | |||
redisTemplate.opsForHash().putAll(key, map); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* HashSet 并设置时间 | |||
* | |||
* @param key 键 | |||
* @param map 对应多个键值 | |||
* @param time 时间(秒) | |||
* @return true成功 false失败 | |||
*/ | |||
public boolean hmset(String key, Map<String, Object> map, long time) { | |||
try { | |||
redisTemplate.opsForHash().putAll(key, map); | |||
if (time > 0) { | |||
expire(key, time); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 向一张hash表中放入数据,如果不存在将创建 | |||
* | |||
* @param key 键 | |||
* @param item 项 | |||
* @param value 值 | |||
* @return true 成功 false失败 | |||
*/ | |||
public boolean hset(String key, String item, Object value) { | |||
try { | |||
redisTemplate.opsForHash().put(key, item, value); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 向一张hash表中放入数据,如果不存在将创建 | |||
* | |||
* @param key 键 | |||
* @param item 项 | |||
* @param value 值 | |||
* @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 | |||
* @return true 成功 false失败 | |||
*/ | |||
public boolean hset(String key, String item, Object value, long time) { | |||
try { | |||
redisTemplate.opsForHash().put(key, item, value); | |||
if (time > 0) { | |||
expire(key, time); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 删除hash表中的值 | |||
* | |||
* @param key 键 不能为null | |||
* @param item 项 可以使多个 不能为null | |||
*/ | |||
public void hdel(String key, Object... item) { | |||
redisTemplate.opsForHash().delete(key, item); | |||
} | |||
/** | |||
* 判断hash表中是否有该项的值 | |||
* | |||
* @param key 键 不能为null | |||
* @param item 项 不能为null | |||
* @return true 存在 false不存在 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public boolean hHasKey(String key, String item) { | |||
return redisTemplate.opsForHash().hasKey(key, item); | |||
} | |||
/** | |||
* hash递增 如果不存在,就会创建一个 并把新增后的值返回 | |||
* | |||
* @param key 键 | |||
* @param item 项 | |||
* @param by 要增加几(大于0) | |||
* @return | |||
*/ | |||
public double hincr(String key, String item, double by) { | |||
return redisTemplate.opsForHash().increment(key, item, by); | |||
} | |||
/** | |||
* hash递减 | |||
* | |||
* @param key 键 | |||
* @param item 项 | |||
* @param by 要减少记(小于0) | |||
* @return | |||
*/ | |||
public double hdecr(String key, String item, double by) { | |||
return redisTemplate.opsForHash().increment(key, item, -by); | |||
} | |||
// ============================set============================= | |||
/** | |||
* 根据key获取Set中的所有值 | |||
* | |||
* @param key 键 | |||
* @return | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Set<Object> sGet(String key) { | |||
try { | |||
return redisTemplate.opsForSet().members(key); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return null; | |||
} | |||
} | |||
/** | |||
* 根据value从一个set中查询,是否存在 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @return true 存在 false不存在 | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public boolean sHasKey(String key, Object value) { | |||
try { | |||
return redisTemplate.opsForSet().isMember(key, value); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 将数据放入set缓存 | |||
* | |||
* @param key 键 | |||
* @param values 值 可以是多个 | |||
* @return 成功个数 | |||
*/ | |||
public long sSet(String key, Object... values) { | |||
try { | |||
return redisTemplate.opsForSet().add(key, values); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
/** | |||
* 将set数据放入缓存 | |||
* | |||
* @param key 键 | |||
* @param time 时间(秒) | |||
* @param values 值 可以是多个 | |||
* @return 成功个数 | |||
*/ | |||
public long sSetAndTime(String key, long time, Object... values) { | |||
try { | |||
Long count = redisTemplate.opsForSet().add(key, values); | |||
if (time > 0) { | |||
expire(key, time); | |||
} | |||
return count; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
/** | |||
* 获取set缓存的长度 | |||
* | |||
* @param key 键 | |||
* @return | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public long sGetSetSize(String key) { | |||
try { | |||
return redisTemplate.opsForSet().size(key); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
/** | |||
* 移除值为value的 | |||
* | |||
* @param key 键 | |||
* @param values 值 可以是多个 | |||
* @return 移除的个数 | |||
*/ | |||
public long setRemove(String key, Object... values) { | |||
try { | |||
Long count = redisTemplate.opsForSet().remove(key, values); | |||
return count; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
// ===============================list================================= | |||
/** | |||
* 获取list缓存的内容 | |||
* | |||
* @param key 键 | |||
* @param start 开始 | |||
* @param end 结束 0 到 -1代表所有值 | |||
* @return | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public List<Object> lGet(String key, long start, long end) { | |||
try { | |||
return redisTemplate.opsForList().range(key, start, end); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return null; | |||
} | |||
} | |||
/** | |||
* 获取list缓存的长度 | |||
* | |||
* @param key 键 | |||
* @return | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public long lGetListSize(String key) { | |||
try { | |||
return redisTemplate.opsForList().size(key); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
/** | |||
* 通过索引 获取list中的值 | |||
* | |||
* @param key 键 | |||
* @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 | |||
* @return | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public Object lGetIndex(String key, long index) { | |||
try { | |||
return redisTemplate.opsForList().index(key, index); | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return null; | |||
} | |||
} | |||
/** | |||
* 将list放入缓存 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @param time 时间(秒) | |||
* @return | |||
*/ | |||
public boolean lSet(String key, Object value) { | |||
try { | |||
redisTemplate.opsForList().rightPush(key, value); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 将list放入缓存 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @param time 时间(秒) | |||
* @return | |||
*/ | |||
public boolean lSet(String key, Object value, long time) { | |||
try { | |||
redisTemplate.opsForList().rightPush(key, value); | |||
if (time > 0) { | |||
expire(key, time); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 将list放入缓存 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @param time 时间(秒) | |||
* @return | |||
*/ | |||
public boolean lSet(String key, List<Object> value) { | |||
try { | |||
redisTemplate.opsForList().rightPushAll(key, value); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 将list放入缓存 | |||
* | |||
* @param key 键 | |||
* @param value 值 | |||
* @param time 时间(秒) | |||
* @return | |||
*/ | |||
public boolean lSet(String key, List<Object> value, long time) { | |||
try { | |||
redisTemplate.opsForList().rightPushAll(key, value); | |||
if (time > 0) { | |||
expire(key, time); | |||
} | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 根据索引修改list中的某条数据 | |||
* | |||
* @param key 键 | |||
* @param index 索引 | |||
* @param value 值 | |||
* @return | |||
*/ | |||
public boolean lUpdateIndex(String key, long index, Object value) { | |||
try { | |||
redisTemplate.opsForList().set(key, index, value); | |||
return true; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return false; | |||
} | |||
} | |||
/** | |||
* 移除N个值为value | |||
* | |||
* @param key 键 | |||
* @param count 移除多少个 | |||
* @param value 值 | |||
* @return 移除的个数 | |||
*/ | |||
public long lRemove(String key, long count, Object value) { | |||
try { | |||
Long remove = redisTemplate.opsForList().remove(key, count, value); | |||
return remove; | |||
} catch (Exception e) { | |||
e.printStackTrace(); | |||
return 0; | |||
} | |||
} | |||
/** | |||
* 按键的排序获取对应的值 | |||
* | |||
* @param keys 多个键 | |||
* @return List<Object> | |||
*/ | |||
@Transactional(readOnly = true, propagation = Propagation.REQUIRES_NEW) | |||
public List<Object> mget(Collection<String> keys) { | |||
return redisTemplate.opsForValue().multiGet(keys); | |||
} | |||
} |
@@ -0,0 +1,102 @@ | |||
package com.tuoheng.airportGzdp.until; | |||
import org.springframework.aop.framework.AopContext; | |||
import org.springframework.beans.BeansException; | |||
import org.springframework.beans.factory.NoSuchBeanDefinitionException; | |||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor; | |||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory; | |||
import org.springframework.stereotype.Component; | |||
/** | |||
* spring工具类 方便在非spring管理环境中获取bean | |||
*/ | |||
@Component | |||
public class SpringUtils implements BeanFactoryPostProcessor { | |||
/** | |||
* Spring应用上下文环境 | |||
*/ | |||
private static ConfigurableListableBeanFactory beanFactory; | |||
@Override | |||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException { | |||
SpringUtils.beanFactory = beanFactory; | |||
} | |||
/** | |||
* 获取对象 | |||
* | |||
* @param name | |||
* @return Object 一个以所给名字注册的bean的实例 | |||
* @throws org.springframework.beans.BeansException | |||
*/ | |||
@SuppressWarnings("unchecked") | |||
public static <T> T getBean(String name) throws BeansException { | |||
return (T) beanFactory.getBean(name); | |||
} | |||
/** | |||
* 获取类型为requiredType的对象 | |||
* | |||
* @param clz | |||
* @return | |||
* @throws org.springframework.beans.BeansException | |||
*/ | |||
public static <T> T getBean(Class<T> clz) throws BeansException { | |||
T result = (T) beanFactory.getBean(clz); | |||
return result; | |||
} | |||
/** | |||
* 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true | |||
* | |||
* @param name | |||
* @return boolean | |||
*/ | |||
public static boolean containsBean(String name) { | |||
return beanFactory.containsBean(name); | |||
} | |||
/** | |||
* 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException) | |||
* | |||
* @param name | |||
* @return boolean | |||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException | |||
*/ | |||
public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException { | |||
return beanFactory.isSingleton(name); | |||
} | |||
/** | |||
* @param name | |||
* @return Class 注册对象的类型 | |||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException | |||
*/ | |||
public static Class<?> getType(String name) throws NoSuchBeanDefinitionException { | |||
return beanFactory.getType(name); | |||
} | |||
/** | |||
* 如果给定的bean名字在bean定义中有别名,则返回这些别名 | |||
* | |||
* @param name | |||
* @return | |||
* @throws org.springframework.beans.factory.NoSuchBeanDefinitionException | |||
*/ | |||
public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { | |||
return beanFactory.getAliases(name); | |||
} | |||
/** | |||
* 获取aop代理对象 | |||
* | |||
* @param invoker | |||
* @return | |||
*/ | |||
@SuppressWarnings("unchecked") | |||
public static <T> T getAopProxy(T invoker) { | |||
return (T) AopContext.currentProxy(); | |||
} | |||
} |
@@ -0,0 +1,61 @@ | |||
package com.tuoheng.airportGzdp.until; | |||
import java.security.cert.CertificateException; | |||
import java.security.cert.X509Certificate; | |||
import javax.net.ssl.HostnameVerifier; | |||
import javax.net.ssl.HttpsURLConnection; | |||
import javax.net.ssl.SSLContext; | |||
import javax.net.ssl.SSLSession; | |||
import javax.net.ssl.TrustManager; | |||
import javax.net.ssl.X509TrustManager; | |||
public class SslUtils { | |||
private static void trustAllHttpsCertificates() throws Exception { | |||
TrustManager[] trustAllCerts = new TrustManager[1]; | |||
TrustManager tm = new miTM(); | |||
trustAllCerts[0] = tm; | |||
SSLContext sc = SSLContext.getInstance("SSL"); | |||
sc.init(null, trustAllCerts, null); | |||
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); | |||
} | |||
static class miTM implements TrustManager, X509TrustManager { | |||
public X509Certificate[] getAcceptedIssuers() { | |||
return null; | |||
} | |||
public boolean isServerTrusted(X509Certificate[] certs) { | |||
return true; | |||
} | |||
public boolean isClientTrusted(X509Certificate[] certs) { | |||
return true; | |||
} | |||
public void checkServerTrusted(X509Certificate[] certs, String authType) | |||
throws CertificateException { | |||
return; | |||
} | |||
public void checkClientTrusted(X509Certificate[] certs, String authType) | |||
throws CertificateException { | |||
return; | |||
} | |||
} | |||
/** | |||
* 忽略HTTPS请求的SSL证书,必须在openConnection之前调用 | |||
* | |||
* @throws Exception | |||
*/ | |||
public static void ignoreSsl() throws Exception { | |||
HostnameVerifier hv = new HostnameVerifier() { | |||
public boolean verify(String urlHostName, SSLSession session) { | |||
System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost()); | |||
return true; | |||
} | |||
}; | |||
trustAllHttpsCertificates(); | |||
HttpsURLConnection.setDefaultHostnameVerifier(hv); | |||
} | |||
} |
@@ -0,0 +1,34 @@ | |||
package com.tuoheng.airportGzdp.vo; | |||
import lombok.Data; | |||
import java.util.List; | |||
/** | |||
* @Author: ww | |||
* @CreateTime: 2023-12-24 15:24 | |||
* @Description: 机场航信信息查询DTO-业务方 | |||
* @Version: 1.0 | |||
*/ | |||
@Data | |||
public class AirlineFileDto { | |||
/** | |||
* 系统来源 | |||
*/ | |||
private String code; | |||
/** | |||
* 租户编码 | |||
*/ | |||
private String tenantCode; | |||
/** | |||
* 机场ID | |||
*/ | |||
private Integer airportId; | |||
/** | |||
* 航线ID集合 | |||
*/ | |||
private List<Integer> airlineFileIds; | |||
} |
@@ -0,0 +1,92 @@ | |||
package com.tuoheng.airportGzdp.vo; | |||
import com.alibaba.fastjson.JSON; | |||
import com.alibaba.fastjson.JSONObject; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.Date; | |||
import java.util.List; | |||
import java.util.Map; | |||
/** | |||
* 机场列表Vo | |||
*/ | |||
@Data | |||
public class AirportListVo { | |||
/** | |||
* 机场ID | |||
*/ | |||
private Integer id; | |||
/** | |||
* 设备编号 | |||
*/ | |||
private String code; | |||
/** | |||
* 设备名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 机场照片 | |||
*/ | |||
private String image; | |||
/** | |||
* 外部监控地址 | |||
*/ | |||
private String externalMonitorUrl; | |||
/** | |||
* 内部监控地址 | |||
*/ | |||
private String internalMonitorUrl; | |||
private String cameraUrl; | |||
/** | |||
* 覆盖范围 | |||
*/ | |||
private String coverage; | |||
private String edgeId; | |||
/** | |||
* 备注 | |||
*/ | |||
private String note; | |||
/** | |||
* 经度 | |||
*/ | |||
private String longitude; | |||
/** | |||
* 纬度 | |||
*/ | |||
private String latitude; | |||
/** | |||
* 无人机ID | |||
*/ | |||
private Integer droneId; | |||
/** | |||
* 无人机名称 | |||
*/ | |||
private String droneName; | |||
//机场运行状态 | |||
private int status; | |||
//机场在线状态 | |||
private boolean online; | |||
private String address; | |||
private Object wth; | |||
private Map taskMap; | |||
} |
@@ -0,0 +1,53 @@ | |||
package com.tuoheng.airportGzdp.vo; | |||
import com.fasterxml.jackson.annotation.JsonFormat; | |||
import com.tuoheng.airportGzdp.entity.VedioInspectionRecord; | |||
import lombok.Data; | |||
import org.springframework.format.annotation.DateTimeFormat; | |||
import java.util.List; | |||
/** | |||
* 任务列表Vo | |||
*/ | |||
@Data | |||
public class TaskListVo { | |||
private int id; | |||
/** | |||
* 名称 | |||
*/ | |||
private String name; | |||
/** | |||
* 任务类型 | |||
*/ | |||
private int type; | |||
/** | |||
* 开始时间 | |||
*/ | |||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | |||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") | |||
private String beginTime; | |||
/** | |||
* 状态 | |||
*/ | |||
private int status; | |||
/** | |||
* 航线id | |||
*/ | |||
private int lineId; | |||
private int recordId; | |||
/** | |||
* 回放视频数量 | |||
*/ | |||
private Integer vedioCount; | |||
private List<VedioInspectionRecord> listVedio; | |||
} |
@@ -0,0 +1,44 @@ | |||
#端口号 | |||
server: | |||
port: 8989 | |||
servlet: | |||
# 项目的前缀名 | |||
context-path: /api | |||
#数据库的配置信息 | |||
spring: | |||
datasource: | |||
url: jdbc:mysql://192.168.11.13:3306/tuoheng_airport?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=false&tinyInt1isBit=false | |||
username: root | |||
password: idontcare | |||
redis: | |||
# 缓存库默认索引0 | |||
database: 9 | |||
# Redis服务器地址 | |||
host: 192.168.11.13 | |||
# Redis服务器连接端口 | |||
port: 6379 | |||
# Redis服务器连接密码(默认为空) | |||
password: | |||
# 连接超时时间(毫秒) | |||
timeout: 6000 | |||
# 默认的数据过期时间,主要用于shiro权限管理 | |||
expire: 2592000 | |||
jedis: | |||
pool: | |||
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) | |||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制) | |||
max-idle: 10 # 连接池中的最大空闲连接 | |||
min-idle: 1 # 连接池中的最小空闲连接 | |||
mybatis: | |||
#开启驼峰命名法 | |||
configuration: | |||
map-underscore-to-camel-case: true | |||
mybatis-plus: | |||
# xml地址 | |||
mapper-locations: classpath:mapper/*Mapper.xml | |||
# 实体扫描,多个package用逗号或者分号分隔 | |||
type-aliases-package: com.example.mybatisplus.entity #自己的实体类地址 | |||
configuration: | |||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 | |||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | |||
interfaceUrl: https://airport.t-aaron.com/airport/admin/airportInterface |
@@ -0,0 +1,45 @@ | |||
#端口号 | |||
server: | |||
port: 8989 | |||
servlet: | |||
# 项目的前缀名 | |||
context-path: /api | |||
#数据库的配置信息 | |||
spring: | |||
datasource: | |||
url: jdbc:mysql://rm-uf6x76i111rb1eo48.mysql.rds.aliyuncs.com:3306/tuoheng_airport?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false | |||
username: root | |||
password: TH22#2022 | |||
redis: | |||
# 缓存库默认索引0 | |||
database: 9 | |||
# Redis服务器地址 | |||
host: r-uf6r5lm7c7sfdv3ehb.redis.rds.aliyuncs.com | |||
# Redis服务器连接端口 | |||
port: 6379 | |||
# Redis服务器连接密码(默认为空) | |||
password: | |||
# 连接超时时间(毫秒) | |||
timeout: 6000 | |||
# 默认的数据过期时间,主要用于shiro权限管理 | |||
expire: 2592000 | |||
jedis: | |||
pool: | |||
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) | |||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制) | |||
max-idle: 10 # 连接池中的最大空闲连接 | |||
min-idle: 1 # 连接池中的最小空闲连接 | |||
mybatis: | |||
#开启驼峰命名法 | |||
configuration: | |||
map-underscore-to-camel-case: true | |||
mybatis-plus: | |||
# xml地址 | |||
mapper-locations: classpath:mapper/*Mapper.xml | |||
# 实体扫描,多个package用逗号或者分号分隔 | |||
type-aliases-package: com.example.mybatisplus.entity #自己的实体类地址 | |||
configuration: | |||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 | |||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | |||
websocketurl: wss://airport.t-aaron.com/airport/socket/webSocket |
@@ -0,0 +1,44 @@ | |||
#端口号 | |||
server: | |||
port: 8989 | |||
servlet: | |||
# 项目的前缀名 | |||
context-path: /api | |||
#数据库的配置信息 | |||
spring: | |||
datasource: | |||
url: jdbc:mysql://rm-uf6z740323e8053pj.mysql.rds.aliyuncs.com:3306/tuoheng_airport?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false | |||
username: root | |||
password: TH22#2022 | |||
redis: | |||
# 缓存库默认索引0 | |||
database: 9 | |||
# Redis服务器地址 | |||
host: r-uf6cdzjifj20jszykr.redis.rds.aliyuncs.com | |||
# Redis服务器连接端口 | |||
port: 6379 | |||
# Redis服务器连接密码(默认为空) | |||
password: | |||
# 连接超时时间(毫秒) | |||
timeout: 6000 | |||
# 默认的数据过期时间,主要用于shiro权限管理 | |||
expire: 2592000 | |||
jedis: | |||
pool: | |||
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) | |||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制) | |||
max-idle: 10 # 连接池中的最大空闲连接 | |||
min-idle: 1 # 连接池中的最小空闲连接 | |||
mybatis: | |||
#开启驼峰命名法 | |||
configuration: | |||
map-underscore-to-camel-case: true | |||
mybatis-plus: | |||
# xml地址 | |||
mapper-locations: classpath:mapper/*Mapper.xml | |||
# 实体扫描,多个package用逗号或者分号分隔 | |||
type-aliases-package: com.example.mybatisplus.entity #自己的实体类地址 | |||
configuration: | |||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 | |||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | |||
interfaceUrl: https://airport-test.t-aaron.com/airport/admin/airportInterface |
@@ -0,0 +1 @@ | |||
websocketurl: wss://airport-test.t-aaron.com/airport/socket/webSocket |
@@ -0,0 +1,44 @@ | |||
#端口号 | |||
server: | |||
port: 8988 | |||
servlet: | |||
# 项目的前缀名 | |||
context-path: /nxdp | |||
#数据库的配置信息 | |||
spring: | |||
datasource: | |||
url: jdbc:mysql://rm-uf6z740323e8053pj.mysql.rds.aliyuncs.com:3306/tuoheng_airport?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2b8&useSSL=true&tinyInt1isBit=false | |||
username: root | |||
password: TH22#2022 | |||
redis: | |||
# 缓存库默认索引0 | |||
database: 9 | |||
# Redis服务器地址 | |||
host: r-uf6cdzjifj20jszykr.redis.rds.aliyuncs.com | |||
# Redis服务器连接端口 | |||
port: 6379 | |||
# Redis服务器连接密码(默认为空) | |||
password: | |||
# 连接超时时间(毫秒) | |||
timeout: 6000 | |||
# 默认的数据过期时间,主要用于shiro权限管理 | |||
expire: 2592000 | |||
jedis: | |||
pool: | |||
max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) | |||
max-wait: -1 # 连接池最大阻塞等待时间(使用负值表示没有限制) | |||
max-idle: 10 # 连接池中的最大空闲连接 | |||
min-idle: 1 # 连接池中的最小空闲连接 | |||
mybatis: | |||
#开启驼峰命名法 | |||
configuration: | |||
map-underscore-to-camel-case: true | |||
mybatis-plus: | |||
# xml地址 | |||
mapper-locations: classpath:mapper/*Mapper.xml | |||
# 实体扫描,多个package用逗号或者分号分隔 | |||
type-aliases-package: com.example.mybatisplus.entity #自己的实体类地址 | |||
configuration: | |||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用 | |||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl | |||
interfaceUrl: https://airport-test.t-aaron.com/airport/admin/airportInterface |
@@ -0,0 +1,60 @@ | |||
<?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.tuoheng.airportGzdp.mapper.TaskMapper"> | |||
<select id="getList" resultType="com.tuoheng.airportGzdp.vo.TaskListVo"> | |||
SELECT | |||
i.id,i.`name`,i.type,re.create_time beginTime,re.`status`,i.airline_file_id lineId,re.id recordId | |||
FROM | |||
th_inspection i | |||
LEFT JOIN th_inspection_record re ON i.id = re.task_id | |||
WHERE | |||
i.tenant_id = #{tenantId} and re.`status`=3 and i.mark=1 and re.mark=1 | |||
ORDER BY re.create_time desc limit #{limit} | |||
</select> | |||
<select id="getPreList" resultType="com.tuoheng.airportGzdp.vo.TaskListVo"> | |||
SELECT | |||
i.id,i.`name`,i.type,i.cycle_next_time beginTime,0 status,0 lineId,0 recordId | |||
FROM | |||
th_inspection i | |||
WHERE | |||
i.tenant_id =#{tenantId} and i.mark=1 and i.cycle_next_time>=CURRENT_DATE() ORDER BY i.cycle_next_time limit #{limit} | |||
</select> | |||
<select id="getRunList" resultType="com.tuoheng.airportGzdp.vo.TaskListVo"> | |||
SELECT | |||
i.id,i.`name`,i.type,re.create_time beginTime,re.`status`,i.airline_file_id lineId,re.id recordId | |||
FROM | |||
th_inspection i | |||
LEFT JOIN th_inspection_record re ON i.id = re.task_id | |||
WHERE | |||
i.tenant_id = #{tenantId} and i.mark=1 and re.mark=1 and re.`status` in (1,2) | |||
ORDER BY re.create_time limit #{limit} | |||
</select> | |||
<select id="getCountList" resultType="java.util.HashMap"> | |||
SELECT 'week' dateType,count(1) count | |||
FROM th_inspection_record | |||
WHERE YEARWEEK(update_time) = YEARWEEK(CURDATE()) and `status` =3 and tenant_id =#{tenantId} and mark=1 | |||
union ALL | |||
SELECT 'month',count(1) | |||
FROM th_inspection_record | |||
WHERE YEAR(update_time) = YEAR(CURDATE()) AND MONTH(update_time) = MONTH(CURDATE()) and `status` =3 and tenant_id =#{tenantId} and mark=1 | |||
union ALL | |||
SELECT 'year',count(1) | |||
FROM th_inspection_record | |||
WHERE YEAR(update_time) = YEAR(CURDATE()) and `status` =3 and tenant_id =#{tenantId} and mark=1 | |||
</select> | |||
<select id="getRunTaskByAirportId" resultType="java.util.HashMap"> | |||
SELECT | |||
i.id,i.`name`,i.type,re.create_time beginTime,i.airline_file_id lineId,re.`status` | |||
FROM | |||
th_inspection i | |||
LEFT JOIN th_inspection_record re ON i.id = re.task_id | |||
WHERE | |||
re.aid = #{id} and i.mark=1 and re.mark=1 and re.`status` in (1,2) | |||
ORDER BY re.create_time | |||
</select> | |||
</mapper> |