Commit 33fbd503 by 罗志长

fix: 区域设置设备安装方式同步

parent f037f4a2
...@@ -395,11 +395,15 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -395,11 +395,15 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
.eq(PlatDeviceOther::getDeviceId, id).last("limit 1")); .eq(PlatDeviceOther::getDeviceId, id).last("limit 1"));
PlatDeviceBaseAttrDTO iotAttr = getDeviceBaseAttrDTO(db); PlatDeviceBaseAttrDTO iotAttr = getDeviceBaseAttrDTO(db);
Integer radarMount = iotAttr.getRadarMount();
if (other != null) { if (other != null) {
String oldAttr = other.getAttribute(); String oldAttr = other.getAttribute();
if (StringUtils.isBlank(other.getAttribute())) { if (StringUtils.isBlank(other.getAttribute())) {
PlatDeviceBaseAttrDTO defaultAttr = getDefaultAttr(db); PlatDeviceBaseAttrDTO defaultAttr = getDefaultAttr(db);
String attr = defaultAttr != null ? JSON.toJSONString(defaultAttr) : null; String attr = defaultAttr != null ? JSON.toJSONString(defaultAttr) : null;
if (defaultAttr != null) {
radarMount = radarMount == null ? defaultAttr.getRadarMount() : radarMount;
}
other.setAttribute(attr); other.setAttribute(attr);
} }
BeanUtils.copyProperties(other, vo); BeanUtils.copyProperties(other, vo);
...@@ -408,11 +412,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -408,11 +412,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
if (!StringUtils.equals(oldAttr, attr)) { if (!StringUtils.equals(oldAttr, attr)) {
other.setAttribute(attr); other.setAttribute(attr);
platDeviceOtherService.updateById(other); platDeviceOtherService.updateById(other);
if (iotAttr.getRadarMount() != null) { if (radarMount != null) {
List<PlatDevice> platDeviceList = list(new QueryWrapper<PlatDevice>().lambda().eq(PlatDevice::getOriDeviceId, db.getOriDeviceId())); List<PlatDevice> platDeviceList = list(new QueryWrapper<PlatDevice>().lambda().eq(PlatDevice::getOriDeviceId, db.getOriDeviceId()));
//更新区域设置设备安装方式 //更新区域设置设备安装方式
platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda() platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda()
.set(PlatRegionSetting::getInstallType, iotAttr.getRadarMount()) .set(PlatRegionSetting::getInstallType, radarMount)
.in(CollectionUtils.isNotEmpty(platDeviceList),PlatRegionSetting::getDeviceId, StreamUtil.map(platDeviceList,BaseEntity::getId))); .in(CollectionUtils.isNotEmpty(platDeviceList),PlatRegionSetting::getDeviceId, StreamUtil.map(platDeviceList,BaseEntity::getId)));
} }
} }
...@@ -483,11 +487,15 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -483,11 +487,15 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
.last("limit 1")); .last("limit 1"));
PlatDeviceBaseAttrDTO iotAttr = getDeviceBaseAttrDTO(platDevice); PlatDeviceBaseAttrDTO iotAttr = getDeviceBaseAttrDTO(platDevice);
Integer radarMount = iotAttr.getRadarMount();
if (other != null) { if (other != null) {
String oldAttr = other.getAttribute(); String oldAttr = other.getAttribute();
if (StringUtils.isBlank(other.getAttribute())) { if (StringUtils.isBlank(other.getAttribute())) {
PlatDeviceBaseAttrDTO defaultAttr = getDefaultAttr(platDevice); PlatDeviceBaseAttrDTO defaultAttr = getDefaultAttr(platDevice);
String attr = defaultAttr != null ? JSON.toJSONString(defaultAttr) : null; String attr = defaultAttr != null ? JSON.toJSONString(defaultAttr) : null;
if (defaultAttr != null) {
radarMount = radarMount == null ? defaultAttr.getRadarMount() : radarMount;
}
other.setAttribute(attr); other.setAttribute(attr);
} }
BeanUtils.copyProperties(other, vo); BeanUtils.copyProperties(other, vo);
...@@ -496,11 +504,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -496,11 +504,11 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
if (!StringUtils.equals(oldAttr, attr)) { if (!StringUtils.equals(oldAttr, attr)) {
other.setAttribute(attr); other.setAttribute(attr);
platDeviceOtherService.updateById(other); platDeviceOtherService.updateById(other);
if (iotAttr.getRadarMount() != null) { if (radarMount != null) {
List<PlatDevice> platDeviceList = list(new QueryWrapper<PlatDevice>().lambda().eq(PlatDevice::getOriDeviceId, platDevice.getOriDeviceId())); List<PlatDevice> platDeviceList = list(new QueryWrapper<PlatDevice>().lambda().eq(PlatDevice::getOriDeviceId, platDevice.getOriDeviceId()));
//更新区域设置设备安装方式 //更新区域设置设备安装方式
platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda() platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda()
.set(PlatRegionSetting::getInstallType, iotAttr.getRadarMount()) .set(PlatRegionSetting::getInstallType, radarMount)
.in(CollectionUtils.isNotEmpty(platDeviceList),PlatRegionSetting::getDeviceId, StreamUtil.map(platDeviceList,BaseEntity::getId))); .in(CollectionUtils.isNotEmpty(platDeviceList),PlatRegionSetting::getDeviceId, StreamUtil.map(platDeviceList,BaseEntity::getId)));
} }
} }
...@@ -689,22 +697,26 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -689,22 +697,26 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
PlatDeviceOther platDeviceOther = platDeviceOtherService.getOne(deviceOtherLambdaQueryWrapper, false); PlatDeviceOther platDeviceOther = platDeviceOtherService.getOne(deviceOtherLambdaQueryWrapper, false);
PlatDeviceBaseAttrDTO iotAttr = getDeviceBaseAttrDTO(platDevice); PlatDeviceBaseAttrDTO iotAttr = getDeviceBaseAttrDTO(platDevice);
Integer radarMount = iotAttr.getRadarMount();
if (platDeviceOther != null) { if (platDeviceOther != null) {
String oldAttr = platDeviceOther.getAttribute(); String oldAttr = platDeviceOther.getAttribute();
if (StringUtils.isBlank(platDeviceOther.getAttribute())) { if (StringUtils.isBlank(platDeviceOther.getAttribute())) {
PlatDeviceBaseAttrDTO defaultAttr = getDefaultAttr(platDevice); PlatDeviceBaseAttrDTO defaultAttr = getDefaultAttr(platDevice);
String attr = defaultAttr != null ? JSON.toJSONString(defaultAttr) : null; String attr = defaultAttr != null ? JSON.toJSONString(defaultAttr) : null;
if (defaultAttr != null) {
radarMount = radarMount == null ? defaultAttr.getRadarMount() : radarMount;
}
platDeviceOther.setAttribute(attr); platDeviceOther.setAttribute(attr);
} }
String attr = getAfterComparisonAttr(iotAttr, platDeviceOther.getAttribute()); String attr = getAfterComparisonAttr(iotAttr, platDeviceOther.getAttribute());
if (!StringUtils.equals(oldAttr, attr)) { if (!StringUtils.equals(oldAttr, attr)) {
platDeviceOther.setAttribute(attr); platDeviceOther.setAttribute(attr);
platDeviceOtherService.updateById(platDeviceOther); platDeviceOtherService.updateById(platDeviceOther);
if (iotAttr.getRadarMount() != null) { if (radarMount != null) {
List<PlatDevice> platDeviceList = list(new QueryWrapper<PlatDevice>().lambda().eq(PlatDevice::getOriDeviceId, platDevice.getOriDeviceId())); List<PlatDevice> platDeviceList = list(new QueryWrapper<PlatDevice>().lambda().eq(PlatDevice::getOriDeviceId, platDevice.getOriDeviceId()));
//更新区域设置设备安装方式 //更新区域设置设备安装方式
platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda() platRegionSettingService.update(new UpdateWrapper<PlatRegionSetting>().lambda()
.set(PlatRegionSetting::getInstallType, iotAttr.getRadarMount()) .set(PlatRegionSetting::getInstallType, radarMount)
.in(CollectionUtils.isNotEmpty(platDeviceList),PlatRegionSetting::getDeviceId, StreamUtil.map(platDeviceList,BaseEntity::getId))); .in(CollectionUtils.isNotEmpty(platDeviceList),PlatRegionSetting::getDeviceId, StreamUtil.map(platDeviceList,BaseEntity::getId)));
} }
} }
......
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