代码优化
This commit is contained in:
@@ -27,6 +27,7 @@ import com.njcn.access.service.ICsDeviceOnlineLogsService;
|
||||
import com.njcn.access.service.ICsEquipmentDeliveryService;
|
||||
import com.njcn.access.service.ICsLineModelService;
|
||||
import com.njcn.access.service.ICsTopicService;
|
||||
import com.njcn.access.utils.ChannelObjectUtil;
|
||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.*;
|
||||
@@ -43,7 +44,8 @@ import com.njcn.mq.template.AppFileMessageTemplate;
|
||||
import com.njcn.mq.template.AppFileStreamMessageTemplate;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import com.njcn.zlevent.api.WaveFeignClient;
|
||||
import com.njcn.zlevent.pojo.dto.WaveTimeDto;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
@@ -93,6 +95,8 @@ public class MqttMessageHandler {
|
||||
private final DevCapacityFeignClient devCapacityFeignClient;
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
private final OverlimitMapper overlimitMapper;
|
||||
private final ChannelObjectUtil channelObjectUtil;
|
||||
private final WaveFeignClient waveFeignClient;
|
||||
@Autowired
|
||||
Validator validator;
|
||||
|
||||
@@ -667,15 +671,34 @@ public class MqttMessageHandler {
|
||||
switch (fileDto.getType()){
|
||||
case 4657:
|
||||
log.info("获取文件信息" + fileDto);
|
||||
String key = AppRedisKey.PROJECT_INFO + nDid;
|
||||
if (Objects.isNull(fileDto.getMsg().getType())) {
|
||||
handleDefaultCase(fileDto, nDid);
|
||||
} else {
|
||||
if (Objects.equals("dir", fileDto.getMsg().getType())) {
|
||||
saveDirectoryInfo(fileDto.getMsg().getDirInfo(), key);
|
||||
} else if (Objects.equals("file", fileDto.getMsg().getType())){
|
||||
saveFileInfo(fileDto.getMsg().getFileInfo(), key);
|
||||
appFileMessageTemplate.sendMember(appFileMessage);
|
||||
if (Objects.equals(fileDto.getCode(),AccessEnum.SUCCESS.getCode())) {
|
||||
String key = AppRedisKey.PROJECT_INFO + nDid;
|
||||
if (Objects.isNull(fileDto.getMsg().getType())) {
|
||||
handleDefaultCase(fileDto, nDid);
|
||||
} else {
|
||||
if (Objects.equals("dir", fileDto.getMsg().getType())) {
|
||||
saveDirectoryInfo(fileDto.getMsg().getDirInfo(), key);
|
||||
} else if (Objects.equals("file", fileDto.getMsg().getType())){
|
||||
saveFileInfo(fileDto.getMsg().getFileInfo(), key);
|
||||
appFileMessageTemplate.sendMember(appFileMessage);
|
||||
}
|
||||
}
|
||||
} else if (Objects.equals(fileDto.getCode(),AccessEnum.NOT_FIND.getCode())) {
|
||||
Object object = redisUtil.getObjectByKey("fileMid:" + nDid);
|
||||
if (Objects.nonNull(object)) {
|
||||
String data = redisUtil.getObjectByKey("fileMid:" + nDid).toString();
|
||||
String [] arr = data.split("concat");
|
||||
Integer mid = Integer.parseInt(arr[0]);
|
||||
String fileName = arr[1];
|
||||
if (Objects.equals(mid,fileDto.getMid())) {
|
||||
List<WaveTimeDto> list = channelObjectUtil.objectToList( redisUtil.getObjectByKey("eventFile:" + nDid),WaveTimeDto.class);
|
||||
list.removeIf(item -> item.getFileName().equals(fileName));
|
||||
redisUtil.saveByKey("eventFile:" + nDid, list);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
redisUtil.delete("handleEvent:" + nDid);
|
||||
waveFeignClient.channelWave(nDid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -105,17 +105,6 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
|
||||
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
|
||||
executeMainTask(scheduler,nDid,version);
|
||||
}
|
||||
// //自动接入
|
||||
// else if (expiredKey.startsWith("autoAccess")) {
|
||||
// List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getAll();
|
||||
// list.forEach(item->{
|
||||
// String version = csTopicService.getVersion(item.getNdid());
|
||||
// if (!Objects.isNull(version)){
|
||||
// csDeviceService.devAccessAskTemplate(item.getNdid(),version,1);
|
||||
// redisUtil.saveByKey(AppRedisKey.DEVICE_MID + item.getNdid(),1);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
|
||||
//主任务
|
||||
|
||||
Reference in New Issue
Block a user