Browse Source

后端

tags/V1.0.2
wangwei 11 months ago
parent
commit
1e4f3470e0
8 changed files with 97 additions and 67 deletions
  1. +1
    -1
      pom.xml
  2. +1
    -1
      src/main/java/com/tuoheng/airportGzdp/config/WebSocketClient.java
  3. +5
    -0
      src/main/java/com/tuoheng/airportGzdp/controller/AirportController.java
  4. +1
    -0
      src/main/java/com/tuoheng/airportGzdp/service/IAirportService.java
  5. +36
    -19
      src/main/java/com/tuoheng/airportGzdp/service/impl/AirportServiceImpl.java
  6. +4
    -0
      src/main/java/com/tuoheng/airportGzdp/vo/TaskListVo.java
  7. +43
    -40
      src/main/resources/application.yml
  8. +6
    -6
      src/main/resources/mapper/TaskMapper.xml

+ 1
- 1
pom.xml View File

@@ -12,7 +12,7 @@
<artifactId>springboot-airport-gzdp</artifactId>
<version>0.0.1-SNAPSHOT</version>

<packaging>war</packaging>
<packaging>jar</packaging>
<name>springboot-airport-gzdp</name>
<description>Demo project for Spring Boot</description>


+ 1
- 1
src/main/java/com/tuoheng/airportGzdp/config/WebSocketClient.java View File

@@ -66,7 +66,7 @@ public class WebSocketClient {

public void closeWebsocket() {
try {
session.close();
//session.close();
} catch (Exception e) {
e.printStackTrace();
}

+ 5
- 0
src/main/java/com/tuoheng/airportGzdp/controller/AirportController.java View File

@@ -28,4 +28,9 @@ public class AirportController {
return jsonResult;
}

@RequestMapping("/getWth")
public JsonResult getInfo(Integer airportId){
JsonResult jsonResult = airportService.getWather(airportId);
return jsonResult;
}
}

+ 1
- 0
src/main/java/com/tuoheng/airportGzdp/service/IAirportService.java View File

@@ -14,4 +14,5 @@ import com.tuoheng.airportGzdp.entity.Airport;
*/
public interface IAirportService extends IService<Airport> {
JsonResult getList(String tenantCode);
JsonResult getWather(int airportId);
}

+ 36
- 19
src/main/java/com/tuoheng/airportGzdp/service/impl/AirportServiceImpl.java View File

@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;


import java.util.HashMap;
import java.util.List;
import java.util.Map;

@@ -49,8 +50,7 @@ public class AirportServiceImpl extends ServiceImpl<AirportMapper, Airport> impl
private ITenantService tenantService;
@Autowired
private IDroneService droneService;
@Autowired
private ITaskService taskService;

/**
* 查询机场列表
* @return
@@ -63,34 +63,20 @@ public class AirportServiceImpl extends ServiceImpl<AirportMapper, Airport> impl
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();
//String airportOnline = redisUtils.get("mqttClient") == null ? "" : redisUtils.get("mqttClient").toString();
pageList.convert(x -> {
AirportListVo airportListVo = Convert.convert(AirportListVo.class, x);
boolean online = getOnline(airportOnline, airportListVo);
airportListVo.setOnline(online);

MqttReceivedMessage wth = null;
// MqttReceivedMessage tah = null;
try {
if (!ObjectUtils.isEmpty(redisUtils.hget(airportListVo.getEdgeId() + "_data", "/data/WTH"))) {
wth = (MqttReceivedMessage) redisUtils.hget(airportListVo.getEdgeId() + "_data", "/data/WTH");
log.info("天气数据{}",wth.getPayload());
airportListVo.setWth(JSON.parse(wth.getPayload()));
}
} catch (Exception e) {
log.error("",e);
}
Drone drone = droneService.getById(x.getDroneId());
if (ObjectUtil.isNotEmpty(drone)) {
airportListVo.setCameraUrl(drone.getCameraUrl());
}
//status
airportListVo.setStatus(1);
/*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);
@@ -131,4 +117,35 @@ public class AirportServiceImpl extends ServiceImpl<AirportMapper, Airport> impl
}
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"))) {
wth = (MqttReceivedMessage) redisUtils.hget(airport.getEdgeId() + "_data", "/data/WTH");
log.info("天气数据{}",wth.getPayload());
JSONObject jsonObject = (JSONObject)JSON.parse(wth.getPayload());
map.put("wth",jsonObject.get("parmNew"));
}
if (!ObjectUtils.isEmpty(redisUtils.hget(airport.getEdgeId() + "_data", "/data/DroneBMS"))) {
droneTmp = (MqttReceivedMessage) redisUtils.hget(airport.getEdgeId() + "_data", "/data/DroneBMS");
log.info("电池数据{}",droneTmp.getPayload());
JSONObject jsonObject = (JSONObject)JSON.parse(droneTmp.getPayload());
map.put("droneTmp",jsonObject.get("parm"));
}
} catch (Exception e) {
log.error("",e);
}
return JsonResult.success(map);
}

}

+ 4
- 0
src/main/java/com/tuoheng/airportGzdp/vo/TaskListVo.java View File

@@ -34,4 +34,8 @@ public class TaskListVo {
*/
private int status;

/**
* 航线id
*/
private int lineId;
}

+ 43
- 40
src/main/resources/application.yml View File

@@ -1,42 +1,45 @@
#端口号
server:
port: 8989
#数据库的配置信息
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: 30000
# 默认的数据过期时间,主要用于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
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-test.t-aaron.com/airport/socket/webSocket
websocketurl: wss://airport-test.t-aaron.com/airport/socket/webSocket

+ 6
- 6
src/main/resources/mapper/TaskMapper.xml View File

@@ -4,7 +4,7 @@

<select id="getList" resultType="com.tuoheng.airportGzdp.vo.TaskListVo">
SELECT
i.id,i.`name`,i.type,re.create_time beginTime,re.`status`
i.id,i.`name`,i.type,re.create_time beginTime,re.`status`,i.airline_file_id lineId
FROM
th_inspection i
LEFT JOIN th_inspection_record re ON i.id = re.task_id
@@ -15,7 +15,7 @@

<select id="getPreList" resultType="com.tuoheng.airportGzdp.vo.TaskListVo">
SELECT
i.id,i.`name`,i.type,i.cycle_next_time beginTime,0
i.id,i.`name`,i.type,i.cycle_next_time beginTime,0,0 lineId
FROM
th_inspection i
WHERE
@@ -24,7 +24,7 @@

<select id="getRunList" resultType="com.tuoheng.airportGzdp.vo.TaskListVo">
SELECT
i.id,i.`name`,i.type,re.create_time beginTime,re.`status`
i.id,i.`name`,i.type,re.create_time beginTime,re.`status`,i.airline_file_id lineId
FROM
th_inspection i
LEFT JOIN th_inspection_record re ON i.id = re.task_id
@@ -36,15 +36,15 @@
<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 =65
WHERE YEARWEEK(update_time) = YEARWEEK(CURDATE()) and `status` =3 and tenant_id =#{tenantId}
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 =65
WHERE YEAR(update_time) = YEAR(CURDATE()) AND MONTH(update_time) = MONTH(CURDATE()) and `status` =3 and tenant_id =#{tenantId}
union ALL
SELECT 'year',count(1)
FROM th_inspection_record
WHERE YEAR(update_time) = YEAR(CURDATE()) and `status` =3 and tenant_id =65
WHERE YEAR(update_time) = YEAR(CURDATE()) and `status` =3 and tenant_id =#{tenantId}
</select>

<select id="getRunTaskByAirportId" resultType="java.util.HashMap">

Loading…
Cancel
Save