Commit 1073a8b0 by lzy

Merge branch 'dev' of git.xmmakeit.com:huangjiay/iot-platform-server into dev

parents 48fbec66 cb720511
......@@ -94,7 +94,7 @@ public class RedisConst {
public static final String ALARM_DEVICE_ID = "alarm:device:id:";
public static final String ALARM_CONFIG_ORG_ID = "alram:config:org:id";
public static final String ALARM_CONFIG_ORG_ID = "alarm:config:org:id";
......
......@@ -7,11 +7,12 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public enum DeviceState {
notActive("禁用"),
offline("离线"),
online("在线");
notActive("notActive","禁用"),
offline("offline","离线"),
online("online","在线");
private final String text;
private final String value;
private final String name;
}
......@@ -7,10 +7,11 @@ import lombok.Getter;
@AllArgsConstructor
@Getter
public enum DeviceType {
device("直连设备"),
childrenDevice("网关子设备"),
gateway("网关设备");
device("device","直连设备"),
childrenDevice("device","网关子设备"),
gateway("gateway","网关设备");
private final String value;
private final String text;
......
package com.makeit.entity.platform.device;
import com.makeit.common.entity.BaseBusEntity;
import com.makeit.module.iot.enums.DeviceState;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
......@@ -47,7 +48,10 @@ public class PlatDevice extends BaseBusEntity {
@ApiModelProperty(value = "说明")
private String description;
@ApiModelProperty(value = "状态 数据字典 1 在线 0离线")
/**
* @see DeviceState
*/
@ApiModelProperty(value = "状态 数据字典 1 在线 0离线 ")
private String status;
@ApiModelProperty(value = "组织id")
......
......@@ -453,7 +453,11 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
public List<PlatOrg> createOrgTree(List<PlatOrg> orgList) {
Map<String, PlatOrg> orgMap = orgList.stream().collect(Collectors.toMap(BaseEntity::getId, vo -> vo, (a, b) -> a));
for (PlatOrg platOrg : orgList) {
String[] split = platOrg.getPath().split(",");
String path = platOrg.getPath();
if(StringUtils.isBlank(path)){
continue;
}
String[] split = path.split(",");
findParent(orgMap,platOrg,split,split.length-1);
}
return orgList.stream().filter(vo->StringUtils.isBlank(vo.getParentNodeId())).collect(Collectors.toList());
......@@ -514,7 +518,7 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
private LambdaQueryWrapper<PlatOrg> getLambdaQueryWrapper(PlatOrgQueryDTO dto) {
LambdaQueryWrapper<PlatOrg> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(PlatOrg::getParentId, dto.getParentId())
queryWrapper.eq(StringUtils.isNotBlank(dto.getParentId()), PlatOrg::getParentId, dto.getParentId())
.orderByDesc(BaseEntity::getUpdateDate);
return queryWrapper;
}
......@@ -524,8 +528,21 @@ public class PlatOrgServiceImpl extends ServiceImpl<PlatOrgMapper, PlatOrg>
public List<PlatOrg> subOrgList(PlatOrgQueryDTO platOrgQueryDTO) {
LambdaQueryWrapper<PlatOrg> queryWrapper = getLambdaQueryWrapper(platOrgQueryDTO);
List<PlatOrg> list = list(queryWrapper);
List<PlatOrg> orgTree = createOrgTree2(list);
return orgTree;
}
private List<PlatOrg> createOrgTree2(List<PlatOrg> orgList){
if(CollectionUtils.isEmpty(orgList)){
return new ArrayList<>();
}
Map<String, List<PlatOrg>> parentMap = orgList.stream().collect(Collectors.groupingBy(PlatOrg::getParentId));
orgList.forEach(vo->{
vo.setChildren(parentMap.get(vo.getId()));
});
return list(queryWrapper);
return orgList.stream().filter(vo->StringUtils.equals(vo.getParentId(),"1")).collect(Collectors.toList());
}
/**
......
......@@ -106,7 +106,7 @@ public class IotSyncTask {
platDevice.setRegistrationDate(registryTime);
platDevice.setDescription(iotDevice.getDescribe());
String state = iotDevice.getState();
platDevice.setStatus(StringUtils.equals("online", state) ? CommonEnum.YES.getValue() : CommonEnum.NO.getValue());
platDevice.setStatus(state);
//todo 根据类型名称来匹配
platDevice.setCategory(dicNameIdMap.get(iotDevice.getProductName()));
......
......@@ -44,9 +44,7 @@ public class MqttConfig {
@Bean
public MqttPushClient getMqttPushClient() {
String iotToken = iotTokenService.getIotToken();
clientId = StringUtils.isNotEmpty(iotToken) ? iotToken : clientId;
clientId = StringUtils.isNotEmpty(clientId) ? clientId : iotTokenService.getIotToken();
mqttPushClient.connect(hostUrl, clientId, username, password, timeout, keepalive);
// 订阅主题
mqttPushClient.subscribe(defaultTopic, 0);
......
......@@ -84,7 +84,7 @@ public class PushCallback implements MqttCallback {
DeviceInfo device = JSON.parseObject(payload, DeviceInfo.class);
// todo
checkAlarm(device);
// checkAlarm(device);
}
@Override
......
......@@ -115,7 +115,7 @@ mqtt:
username: admin|1693982115969
password: 8e3795ef7b5e95869fa8c323b865b3a9
hostUrl: tcp://124.71.33.17:11883
clientId: ab3a2fd694c8c838aba2686df3a80e7b
clientId:
defaultTopic: /device/*/*/**
timeout: 10
keepalive: 60
......
......@@ -112,7 +112,7 @@ mqtt:
username: admin|1693982115969
password: 8e3795ef7b5e95869fa8c323b865b3a9
hostUrl: tcp://124.71.33.17:11883
clientId: ab3a2fd694c8c838aba2686df3a80e7b
clientId:
defaultTopic: /device/*/*/**
timeout: 10
keepalive: 60
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment