Commit 9852247d by huangjy

fix:修复bug

parent 5248fa5c
...@@ -466,13 +466,23 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev ...@@ -466,13 +466,23 @@ public class PlatDeviceServiceImpl extends ServiceImpl<PlatDeviceMapper, PlatDev
} }
@Override @Override
@Transactional(rollbackFor = Exception.class)
public void batchEditProperties(PlatDeviceAttrDTO dto) { public void batchEditProperties(PlatDeviceAttrDTO dto) {
if (CollectionUtils.isEmpty(dto.getDeviceIdList())) { if (CollectionUtils.isEmpty(dto.getDeviceIdList())) {
return; return;
} }
Map<String, Object> map = getAttrMap(dto); Map<String, Object> map = getAttrMap(dto);
List<String> resultList = Lists.newArrayList(); List<String> resultList = Lists.newArrayList();
for (String deviceId : dto.getDeviceIdList()) { for (String deviceId : dto.getDeviceIdList()) {
PlatDeviceOther other = platDeviceOtherService.getOne(new QueryWrapper<PlatDeviceOther>().lambda()
.eq(PlatDeviceOther::getOriDeviceId, deviceId)
.last("limit 1"));
if (other != null) {
other.setAttribute(JSON.toJSONString(map));
platDeviceOtherService.updateById(other);
}
String result = devicePropertiesOperateService.deviceWriteAttr(deviceId, map); String result = devicePropertiesOperateService.deviceWriteAttr(deviceId, map);
if (StringUtils.isNotEmpty(result)) { if (StringUtils.isNotEmpty(result)) {
resultList.add(result); resultList.add(result);
......
...@@ -851,9 +851,35 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder ...@@ -851,9 +851,35 @@ public class PlatElderServiceImpl extends ServiceImpl<PlatElderMapper, PlatElder
} }
List<PlatElderHealthInfo> healthInfoList = platElderHealthInfoService.list(new QueryWrapper<PlatElderHealthInfo>().lambda() List<PlatElderHealthInfo> healthInfoList = platElderHealthInfoService.list(new QueryWrapper<PlatElderHealthInfo>().lambda()
.in(PlatElderHealthInfo::getElderId, dto.getIdList())); .in(PlatElderHealthInfo::getElderId, dto.getIdList()));
for (PlatElderHealthInfo elderHealthInfo : healthInfoList) {
BeanUtils.copyProperties(dto, elderHealthInfo); if (CollectionUtils.isNotEmpty(healthInfoList)) {
platElderHealthInfoService.saveOrUpdate(elderHealthInfo); for (PlatElderHealthInfo elderHealthInfo : healthInfoList) {
buildHealthInfo(dto, elderHealthInfo);
platElderHealthInfoService.saveOrUpdate(elderHealthInfo);
}
} else {
for (String s : dto.getIdList()) {
PlatElderHealthInfo elderHealthInfo = new PlatElderHealthInfo();
buildHealthInfo(dto, elderHealthInfo);
elderHealthInfo.setElderId(s);
platElderHealthInfoService.saveOrUpdate(elderHealthInfo);
}
}
}
private static void buildHealthInfo(PlatElderBatchEditDTOVO dto, PlatElderHealthInfo elderHealthInfo) {
if (StringUtils.isNotEmpty(dto.getHeartRate())) {
elderHealthInfo.setHeartRate(dto.getHeartRate());
}
if (StringUtils.isNotEmpty(dto.getHeartExceptionTime())) {
elderHealthInfo.setHeartExceptionTime(dto.getHeartExceptionTime());
}
if (StringUtils.isNotEmpty(dto.getRespiratoryRate())) {
elderHealthInfo.setRespiratoryRate(dto.getRespiratoryRate());
}
if (StringUtils.isNotEmpty(dto.getRespiratoryExceptionTime())) {
elderHealthInfo.setRespiratoryExceptionTime(dto.getRespiratoryExceptionTime());
} }
} }
......
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