修改topic订阅发布问题
This commit is contained in:
@ -130,7 +130,8 @@ public class MqttConfigUtil {
|
|||||||
"+/device/e9eee97d793756fa",
|
"+/device/e9eee97d793756fa",
|
||||||
"+/device/8c062827b5c1548b",
|
"+/device/8c062827b5c1548b",
|
||||||
"+/device/d143856d757625e1",
|
"+/device/d143856d757625e1",
|
||||||
"+/device/3522ab4e7faf28b8"
|
"+/device/3522ab4e7faf28b8",
|
||||||
|
"1/device/+"
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import com.ho.common.tools.util.PageResult;
|
|||||||
import com.ho.filecenter.entity.MediaFile;
|
import com.ho.filecenter.entity.MediaFile;
|
||||||
import com.ho.filecenter.service.AnotherFileService;
|
import com.ho.filecenter.service.AnotherFileService;
|
||||||
import com.ho.filecenter.service.FileService;
|
import com.ho.filecenter.service.FileService;
|
||||||
|
import com.ho.filecenter.service.MqttTopicService;
|
||||||
import com.ho.filecenter.util.MqttConfigUtil;
|
import com.ho.filecenter.util.MqttConfigUtil;
|
||||||
import com.ho.filecenter.vo.mqtt.*;
|
import com.ho.filecenter.vo.mqtt.*;
|
||||||
import com.ho.filecenter.vo.resp.*;
|
import com.ho.filecenter.vo.resp.*;
|
||||||
@ -58,6 +59,9 @@ public class FileController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
AnotherFileService anotherFileService;
|
AnotherFileService anotherFileService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
MqttTopicService mqttTopicService;
|
||||||
@PostMapping("filePage")
|
@PostMapping("filePage")
|
||||||
@ApiOperation(value = "分页查询文件")
|
@ApiOperation(value = "分页查询文件")
|
||||||
public DataResult<PageResult<MediaFile>> filePage(@RequestBody FilePageVO vo, HttpServletRequest request) {
|
public DataResult<PageResult<MediaFile>> filePage(@RequestBody FilePageVO vo, HttpServletRequest request) {
|
||||||
@ -158,7 +162,7 @@ public class FileController {
|
|||||||
return DataResult.success(fileAttributeResp);
|
return DataResult.success(fileAttributeResp);
|
||||||
}
|
}
|
||||||
String serialNo = vo.getSerialNo();
|
String serialNo = vo.getSerialNo();
|
||||||
List<String> snList = MqttConfigUtil.getSnList();
|
List<String> snList = mqttTopicService.getSnList();
|
||||||
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
||||||
fileAttributeResp = fileService.getFileAttribute(vo);
|
fileAttributeResp = fileService.getFileAttribute(vo);
|
||||||
}else{
|
}else{
|
||||||
@ -180,7 +184,7 @@ public class FileController {
|
|||||||
return DataResult.success(fileDeleteResp);
|
return DataResult.success(fileDeleteResp);
|
||||||
}
|
}
|
||||||
String serialNo = fileDeleteReqVO.getSerialNo();
|
String serialNo = fileDeleteReqVO.getSerialNo();
|
||||||
List<String> snList = MqttConfigUtil.getSnList();
|
List<String> snList = mqttTopicService.getSnList();
|
||||||
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
||||||
fileDeleteResp = fileService.deleteDeviceFiles(fileDeleteReqVO);
|
fileDeleteResp = fileService.deleteDeviceFiles(fileDeleteReqVO);
|
||||||
}else{
|
}else{
|
||||||
@ -210,7 +214,7 @@ public class FileController {
|
|||||||
resp.setMsg(CommonConstant.Heartbeat.MSG + serialNo + CommonConstant.Heartbeat.SUCCESS);
|
resp.setMsg(CommonConstant.Heartbeat.MSG + serialNo + CommonConstant.Heartbeat.SUCCESS);
|
||||||
resp.setHeartbeatStatus(CommonConstant.ONE);
|
resp.setHeartbeatStatus(CommonConstant.ONE);
|
||||||
log.info("文件上传(向边端上传)开始上传");
|
log.info("文件上传(向边端上传)开始上传");
|
||||||
List<String> snList = MqttConfigUtil.getSnList();
|
List<String> snList = mqttTopicService.getSnList();
|
||||||
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
||||||
fileService.fileUploadForDevice(file, stationId, serialNo, filePath);
|
fileService.fileUploadForDevice(file, stationId, serialNo, filePath);
|
||||||
}else{
|
}else{
|
||||||
@ -240,7 +244,7 @@ public class FileController {
|
|||||||
log.info("文件下载(从边端下载到云端)开始下载");
|
log.info("文件下载(从边端下载到云端)开始下载");
|
||||||
fileService.downloadFromDevice(fileForDeviceReqVO);
|
fileService.downloadFromDevice(fileForDeviceReqVO);
|
||||||
String serialNo = fileForDeviceReqVO.getSerialNo();
|
String serialNo = fileForDeviceReqVO.getSerialNo();
|
||||||
List<String> snList = MqttConfigUtil.getSnList();
|
List<String> snList = mqttTopicService.getSnList();
|
||||||
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
if(snList.stream().anyMatch(s -> s.contains(serialNo))){
|
||||||
fileService.downloadFromDevice(fileForDeviceReqVO);
|
fileService.downloadFromDevice(fileForDeviceReqVO);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@ -19,6 +19,7 @@ import com.ho.common.tools.util.PageResult;
|
|||||||
import com.ho.filecenter.feignclient.BusinessFeignClient;
|
import com.ho.filecenter.feignclient.BusinessFeignClient;
|
||||||
import com.ho.filecenter.feignclient.UserFeignClient;
|
import com.ho.filecenter.feignclient.UserFeignClient;
|
||||||
import com.ho.filecenter.service.AnotherOrderSendService;
|
import com.ho.filecenter.service.AnotherOrderSendService;
|
||||||
|
import com.ho.filecenter.service.MqttTopicService;
|
||||||
import com.ho.filecenter.service.OrderSendService;
|
import com.ho.filecenter.service.OrderSendService;
|
||||||
import com.ho.filecenter.util.MqttConfigUtil;
|
import com.ho.filecenter.util.MqttConfigUtil;
|
||||||
import com.ho.filecenter.vo.mqtt.*;
|
import com.ho.filecenter.vo.mqtt.*;
|
||||||
@ -65,6 +66,9 @@ public class OrderSendController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
AnotherOrderSendService anotherOrderSendService;
|
AnotherOrderSendService anotherOrderSendService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
MqttTopicService mqttTopicService;
|
||||||
|
|
||||||
public static final Long TIME_LIMIT = 90L;
|
public static final Long TIME_LIMIT = 90L;
|
||||||
|
|
||||||
@PostMapping("orderIssued")
|
@PostMapping("orderIssued")
|
||||||
@ -163,8 +167,8 @@ public class OrderSendController {
|
|||||||
return DataResult.success(heartbeatResp);
|
return DataResult.success(heartbeatResp);
|
||||||
}
|
}
|
||||||
log.info("指令下发正常开始下发");
|
log.info("指令下发正常开始下发");
|
||||||
List<String> snList = MqttConfigUtil.getSnList();
|
List<String> snList = mqttTopicService.getSnList();
|
||||||
if(snList.contains(sn)){
|
if(snList.stream().anyMatch(s -> s.contains(sn))){
|
||||||
orderSendService.orderIssued(vo);
|
orderSendService.orderIssued(vo);
|
||||||
}else{
|
}else{
|
||||||
anotherOrderSendService.orderIssued(vo);
|
anotherOrderSendService.orderIssued(vo);
|
||||||
@ -333,9 +337,9 @@ public class OrderSendController {
|
|||||||
@TokenIgnore
|
@TokenIgnore
|
||||||
public DataResult<HeartbeatResp> sendPlanPowerOrder(@RequestBody OrderPlanPowerReq vo) {
|
public DataResult<HeartbeatResp> sendPlanPowerOrder(@RequestBody OrderPlanPowerReq vo) {
|
||||||
String sn = vo.getSn();
|
String sn = vo.getSn();
|
||||||
List<String> snList = MqttConfigUtil.getSnList();
|
List<String> snList = mqttTopicService.getSnList();
|
||||||
HeartbeatResp heartbeatResp = null;
|
HeartbeatResp heartbeatResp = null;
|
||||||
if(snList.contains(sn)){
|
if(snList.stream().anyMatch(s -> s.contains(sn))){
|
||||||
heartbeatResp = orderSendService.sendPlanPowerOrder(vo);
|
heartbeatResp = orderSendService.sendPlanPowerOrder(vo);
|
||||||
}else{
|
}else{
|
||||||
heartbeatResp = anotherOrderSendService.sendPlanPowerOrder(vo);
|
heartbeatResp = anotherOrderSendService.sendPlanPowerOrder(vo);
|
||||||
|
|||||||
@ -0,0 +1,10 @@
|
|||||||
|
package com.ho.filecenter.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kerwin
|
||||||
|
*/
|
||||||
|
public interface MqttTopicMapper {
|
||||||
|
List<String> getSnList();
|
||||||
|
}
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
package com.ho.filecenter.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kerwin
|
||||||
|
*/
|
||||||
|
public interface MqttTopicService {
|
||||||
|
|
||||||
|
List<String> getSnList();
|
||||||
|
}
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
package com.ho.filecenter.service.impl;
|
||||||
|
|
||||||
|
import com.ho.filecenter.mapper.MqttTopicMapper;
|
||||||
|
import com.ho.filecenter.service.MqttTopicService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kerwin
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class MqttTopicServiceImpl implements MqttTopicService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
MqttTopicMapper mqttTopicMapper;
|
||||||
|
@Override
|
||||||
|
public List<String> getSnList() {
|
||||||
|
return mqttTopicMapper.getSnList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -135,7 +135,8 @@ public class MqttConfigUtil {
|
|||||||
"+/device/e9eee97d793756fa",
|
"+/device/e9eee97d793756fa",
|
||||||
"+/device/8c062827b5c1548b",
|
"+/device/8c062827b5c1548b",
|
||||||
"+/device/d143856d757625e1",
|
"+/device/d143856d757625e1",
|
||||||
"+/device/3522ab4e7faf28b8"
|
"+/device/3522ab4e7faf28b8",
|
||||||
|
"1/device/+"
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -181,13 +182,4 @@ public class MqttConfigUtil {
|
|||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取SN配置合集
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static List<String> getSnList(){
|
|
||||||
List<String> strings = Arrays.asList(commonTopic);
|
|
||||||
return strings;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
10
file-center/src/main/resources/mapper/MqttTopicMapper.xml
Normal file
10
file-center/src/main/resources/mapper/MqttTopicMapper.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.ho.filecenter.mapper.MqttTopicMapper">
|
||||||
|
|
||||||
|
<select id="getSnList" resultType="java.lang.String">
|
||||||
|
select topic from mqtt_topic
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user