|
|
@@ -29,10 +29,7 @@ import com.xunmei.iot.mapper.IotDeviceInfoMapper;
|
|
|
import com.xunmei.iot.mapper.IotServerProductMapper;
|
|
|
import com.xunmei.iot.service.IIotDeviceInfoService;
|
|
|
import com.xunmei.iot.service.IotDeviceInfoExtendService;
|
|
|
-import com.xunmei.iot.vo.deviceInfo.DeviceDetailInfoVo;
|
|
|
-import com.xunmei.iot.vo.deviceInfo.DvrHostDeviceInfoVo;
|
|
|
-import com.xunmei.iot.vo.deviceInfo.IotDeviceInfoPageVo;
|
|
|
-import com.xunmei.iot.vo.deviceInfo.NetHostDeviceInfoVo;
|
|
|
+import com.xunmei.iot.vo.deviceInfo.*;
|
|
|
import com.xunmei.system.api.RemoteHostService;
|
|
|
import com.xunmei.system.api.RemoteOrgService;
|
|
|
import com.xunmei.system.api.domain.SysOrg;
|
|
|
@@ -196,6 +193,20 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
resp.setServerIp(extend.getNetAddress());
|
|
|
resp.setServerPort(extend.getPort().toString());
|
|
|
|
|
|
+ LambdaQueryWrapper<IotDeviceInfo> channelWrapper = new LambdaQueryWrapper<>();
|
|
|
+ channelWrapper.eq(IotDeviceInfo::getHostCode, deviceInfo.getDeviceCode());
|
|
|
+ channelWrapper.select(IotDeviceInfo::getId, IotDeviceInfo::getDeviceCode, IotDeviceInfo::getDeviceName, IotDeviceInfo::getEnable);
|
|
|
+ List<IotDeviceInfo> channelList = baseMapper.selectList(channelWrapper);
|
|
|
+ channelList.stream().map(r -> {
|
|
|
+ final ChannelInfoVo vo = new ChannelInfoVo();
|
|
|
+ vo.setId(r.getId());
|
|
|
+ vo.setChannelCode(r.getDeviceCode());
|
|
|
+ vo.setChannelName(r.getDeviceName());
|
|
|
+ vo.setEnable(r.getEnable());
|
|
|
+ return vo;
|
|
|
+ }).forEach(resp::addChildren);
|
|
|
+
|
|
|
+
|
|
|
return resp;
|
|
|
}
|
|
|
|
|
|
@@ -203,20 +214,28 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Integer editDvrHostDevice(EditDvrHostDeviceDto req) {
|
|
|
Long deviceId = req.getId();
|
|
|
+ IotDeviceInfo deviceInfo;
|
|
|
SysOrg sysOrg = orgService.selectOrgById(req.getOrgId(), SecurityConstants.INNER);
|
|
|
int effect = 0;
|
|
|
if (deviceId == null) {
|
|
|
- IotDeviceInfo deviceInfo = new IotDeviceInfo();
|
|
|
+ deviceInfo = new IotDeviceInfo();
|
|
|
buildDeviceInfo(deviceInfo, req, sysOrg);
|
|
|
effect = baseMapper.insert(deviceInfo);
|
|
|
deviceId = deviceInfo.getId();
|
|
|
} else {
|
|
|
- IotDeviceInfo deviceInfo = baseMapper.selectById(deviceId);
|
|
|
- if (deviceInfo != null) {
|
|
|
- buildDeviceInfo(deviceInfo, req, sysOrg);
|
|
|
- }
|
|
|
+ deviceInfo = baseMapper.selectById(deviceId);
|
|
|
+ buildDeviceInfo(deviceInfo, req, sysOrg);
|
|
|
effect = baseMapper.updateById(deviceInfo);
|
|
|
}
|
|
|
+ if (ObjectUtil.isNotEmpty(req.getChildrenInfos())) {
|
|
|
+ for (ChannelInfoVo childrenInfo : req.getChildrenInfos()) {
|
|
|
+ final LambdaUpdateWrapper<IotDeviceInfo> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(IotDeviceInfo::getId, childrenInfo.getId());
|
|
|
+ wrapper.set(IotDeviceInfo::getDeviceName, childrenInfo.getChannelName());
|
|
|
+ wrapper.set(IotDeviceInfo::getEnable, childrenInfo.getEnable());
|
|
|
+ baseMapper.update(null, wrapper);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
extendService.updateByDeviceId(deviceId, req);
|
|
|
return effect;
|
|
|
@@ -228,14 +247,14 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
deviceInfo.setDeviceProduct(req.getDeviceProduct());
|
|
|
IotServerProduct product = baseMapper.selectProduct(req.getDeviceProduct());
|
|
|
SysMultiLayerDictionary dictionary = baseMapper.selectMultiLayerDictionaryByName(product.getProducer());
|
|
|
- if (dictionary!=null){
|
|
|
+ if (dictionary != null) {
|
|
|
deviceInfo.setDeviceBrand(dictionary.getId());
|
|
|
}
|
|
|
deviceInfo.setDeviceModel(req.getModels());
|
|
|
deviceInfo.setEnable(req.getEnable());
|
|
|
deviceInfo.setDeleted(0);
|
|
|
deviceInfo.setSyncStatus(DeviceSyncStatus.NOT_SYNC.getCode());
|
|
|
- if (deviceInfo.getId()==null){
|
|
|
+ if (deviceInfo.getId() == null) {
|
|
|
deviceInfo.setOrgId(req.getOrgId());
|
|
|
deviceInfo.setOrgName(sysOrg.getShortName());
|
|
|
deviceInfo.setOrgPath(sysOrg.getPath());
|
|
|
@@ -507,7 +526,8 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
deviceInfo = new IotDeviceInfo();
|
|
|
deviceInfo.setCreateTime(new Date());
|
|
|
deviceInfo.setCreateBy(sysUser.getId().toString());
|
|
|
- deviceInfo.setIotToken(req.getIotCode()); deviceInfo.setOrgId(sysOrg.getId());
|
|
|
+ deviceInfo.setIotToken(req.getIotCode());
|
|
|
+ deviceInfo.setOrgId(sysOrg.getId());
|
|
|
deviceInfo.setOrgName(sysOrg.getShortName());
|
|
|
deviceInfo.setOrgPath(sysOrg.getPath());
|
|
|
deviceInfo.setDeleted(0);
|
|
|
@@ -558,7 +578,7 @@ public class IotDeviceInfoServiceImpl extends ServiceImpl<IotDeviceInfoMapper, I
|
|
|
final LambdaUpdateWrapper<IotDeviceInfo> wrapper = new LambdaUpdateWrapper<>();
|
|
|
wrapper.eq(IotDeviceInfo::getId, id);
|
|
|
wrapper.set(IotDeviceInfo::getSyncStatus, DeviceSyncStatus.SYNCING.getCode());
|
|
|
- baseMapper.update(null,wrapper);
|
|
|
+ baseMapper.update(null, wrapper);
|
|
|
remoteHostService.syncDeviceToHost(id);
|
|
|
return 1;
|
|
|
}
|