Commit 64f25ad1 by huangjy

fix:修复bug

parent 1e7572ad
......@@ -192,7 +192,7 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
}
@Transactional
@Transactional(rollbackFor = Exception.class)
@Override
public void edit(PlatDeviceEditDTO dto) {
......@@ -422,10 +422,17 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
log.info("写入设备属性请求参数:{}",JSON.toJSONString(dto));
String deviceId = dto.getDeviceId();
UserServerInfo usrServerInfo = dto.getUsrServerInfo();
Map<String, Object> map = getAttrMap(dto);
if (usrServerInfo != null) {
map.put("usrServerInfo",JSON.toJSONString(usrServerInfo));
}
String result = devicePropertiesOperateService.deviceWriteAttr(deviceId, map);
if (StringUtils.isNotEmpty(result)) {
throw new RuntimeException("设备写入失败:" + result);
}
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, deviceId)
.last("limit 1"));
Map<String, Object> map = getAttrMap(dto);
if (other != null && usrServerInfo != null) {
other.setProtocolAccount(usrServerInfo.getUsername());
other.setProtocolPassword(usrServerInfo.getPassword());
......@@ -436,14 +443,6 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
other.setAttribute(JSON.toJSONString(map));
platDeviceOtherService.updateById(other);
}
if (usrServerInfo != null) {
map.put("usrServerInfo",JSON.toJSONString(usrServerInfo));
}
String result = devicePropertiesOperateService.deviceWriteAttr(deviceId, map);
if (StringUtils.isNotEmpty(result)) {
throw new RuntimeException("设备写入失败:" + result);
}
if (dto.getRadarMount() != null) {
//更新区域设置设备安装方式
platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda()
......@@ -475,8 +474,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
Map<String, Object> map = getAttrMap(dto);
List<String> resultList = Lists.newArrayList();
for (String deviceId : dto.getDeviceIdList()) {
String result = devicePropertiesOperateService.deviceWriteAttr(deviceId, map);
if (StringUtils.isNotEmpty(result)) {
resultList.add(result);
}
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, deviceId)
.last("limit 1"));
......@@ -484,10 +486,6 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
other.setAttribute(JSON.toJSONString(map));
platDeviceOtherService.updateById(other);
}
String result = devicePropertiesOperateService.deviceWriteAttr(deviceId, map);
if (StringUtils.isNotEmpty(result)) {
resultList.add(result);
}
}
if (CollectionUtils.isNotEmpty(resultList)) {
throw new RuntimeException("修改设备属性失败:" + resultList.get(0));
......
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