Browse Source

# 站点集中监控属性配置同步监测点优化

zhongwei
haungxing 2 years ago
parent
commit
1c7f1a24f5
  1. 9
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java
  2. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java
  3. 76
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java

9
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationAttributeController.java

@ -91,12 +91,13 @@ public class StationAttributeController extends BladeController {
return R.status(stationAttributeService.deleteLogic(Func.toLongList(ids))); return R.status(stationAttributeService.deleteLogic(Func.toLongList(ids)));
} }
@PutMapping("/bandingMonitor") @GetMapping("/bandingMonitor")
@ApiOperation("根据设备编码更新集中监控监测点绑定") @ApiOperation("根据设备编码更新集中监控监测点绑定")
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
public R<List<StationAttributeVo>> bandingMonitor(@ApiParam(value = "设备编码",required = true) String emCode, public R<List<StationAttributeVo>> bandingMonitor(@ApiParam(value = "站点编码",required = true) String stationCode,
@ApiParam(value = "设备编码",required = true) String emCode,
@ApiParam(value = "站点类型",required = true) String stationType, @ApiParam(value = "站点类型",required = true) String stationType,
@ApiParam(value = "设备类型",required = true) String emType) { @ApiParam(value = "机组类型",required = true) String setType) {
return R.data(stationAttributeService.bandingMonitor(emCode,stationType,emType)); return R.data(stationAttributeService.bandingMonitor(stationCode,emCode,stationType,setType));
} }
} }

2
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/IStationAttributeService.java

@ -45,5 +45,5 @@ public interface IStationAttributeService extends BaseService<StationAttributeEn
*/ */
void removeByStationCode(String stationCode); void removeByStationCode(String stationCode);
List<StationAttributeVo> bandingMonitor(String emCode,String stationType,String emType); List<StationAttributeVo> bandingMonitor(String stationCode,String emCode,String stationType,String setType);
} }

76
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationAttributeServiceImpl.java

@ -209,13 +209,14 @@ public class StationAttributeServiceImpl extends BaseServiceImpl<StationAttribut
* @return * @return
*/ */
@Override @Override
public List<StationAttributeVo> bandingMonitor(String emCode,String stationType,String emType) { public List<StationAttributeVo> bandingMonitor(String stationCode,String emCode,String stationType,String setType) {
List<StationAttributeVo> result; List<StationAttributeVo> result;
// 获取集中监控属性配置 // 获取集中监控属性配置
List<FocusAttributeEntity> attributes = attributeService.list(Wrappers.<FocusAttributeEntity>lambdaQuery() List<FocusAttributeEntity> attributes = attributeService.list(Wrappers.<FocusAttributeEntity>lambdaQuery()
.eq(FocusAttributeEntity::getDomainId, stationType) .eq(FocusAttributeEntity::getDomainId, stationType)
.eq(FocusAttributeEntity::getGroupId, emType) .eq(FocusAttributeEntity::getGroupId, setType)
.eq(FocusAttributeEntity::getStatus, 0) .eq(FocusAttributeEntity::getStatus, 0)
.orderByAsc(FocusAttributeEntity::getSort)
); );
// 标识 // 标识
List<String> signages = attributes.stream().map(FocusAttributeEntity::getSignage).filter(Func::isNotEmpty).collect(Collectors.toList()); List<String> signages = attributes.stream().map(FocusAttributeEntity::getSignage).filter(Func::isNotEmpty).collect(Collectors.toList());
@ -225,19 +226,64 @@ public class StationAttributeServiceImpl extends BaseServiceImpl<StationAttribut
deviceChildrenDTO.setDeviceCode(emCode); deviceChildrenDTO.setDeviceCode(emCode);
deviceChildrenDTO.setType("attr"); deviceChildrenDTO.setType("attr");
Result<List<DeviceChildrenVO>> deviceChildrenListResult = deviceClient.getRealId(deviceChildrenDTO); Result<List<DeviceChildrenVO>> deviceChildrenListResult = deviceClient.getRealId(deviceChildrenDTO);
boolean facAttrFlag = deviceChildrenListResult.isSuccess() && CollectionUtil.isNotEmpty(deviceChildrenListResult.getData()); List<DeviceChildrenVO> modelAttr = deviceChildrenListResult.isSuccess() && CollectionUtil.isNotEmpty(deviceChildrenListResult.getData())
// 根据集中监控属性配置获取站点集中监控属性配置 ? deviceChildrenListResult.getData() : new ArrayList<>();
Function<FocusAttributeEntity,StationAttributeVo> convert = focusAttr -> { // 获取
StationAttributeVo vo = BeanUtil.copy(focusAttr,StationAttributeVo.class); LambdaQueryWrapper<StationAttributeEntity> queryWrapper = Wrappers.<StationAttributeEntity>lambdaQuery()
if(facAttrFlag) { .eq(StationAttributeEntity::getStationId, stationCode)
List<DeviceChildrenVO> data = deviceChildrenListResult.getData(); .eq(StationAttributeEntity::getEmCode, emCode);
Optional<DeviceChildrenVO> facAttrOptional = data.stream().filter(attr -> focusAttr.getSignage().equals(attr.getSignage())).findAny(); List<StationAttributeEntity> stationAttrList = this.list(queryWrapper);
vo.setMonitorId(facAttrOptional.map(DeviceChildrenVO::getRealId).orElse(null)); result = attributes.stream().map(focusAttr -> this.fillFacAttr(modelAttr,focusAttr,stationCode,emCode))
vo.setMonitorName(facAttrOptional.map(DeviceChildrenVO::getName).orElse(null)); .map(stationAttr -> this.fillAttrId(stationAttrList,stationAttr))
} .sorted(Comparator.comparing(StationAttributeVo::getSort,Comparator.nullsLast(Integer::compareTo)))
return vo; .collect(Collectors.toList());
};
result = attributes.stream().map(convert).collect(Collectors.toList());
return result; return result;
} }
/**
* 根据请求设备实例物模型属性填充集中监控属性配置采集点
* @param modelAttr 设备实例物模型属性
* @param focusAttr 集中监控属性配置
* @return
*/
private StationAttributeVo fillFacAttr(List<DeviceChildrenVO> modelAttr,FocusAttributeEntity focusAttr,String stationCode,String emCode) {
StationAttributeVo vo = BeanUtil.copy(focusAttr,StationAttributeVo.class);
Optional<DeviceChildrenVO> facAttrOptional = modelAttr.stream().filter(attr -> focusAttr.getSignage().equals(attr.getSignage())).findAny();
vo.setMonitorId(facAttrOptional.map(DeviceChildrenVO::getRealId).orElse(null));
vo.setMonitorName(facAttrOptional.map(DeviceChildrenVO::getName).orElse(null));
vo.setStationId(stationCode);
vo.setEmCode(emCode);
vo.setEnableShow(true);
vo.setId(null);
vo.setCreateUser(null);
vo.setCreateDept(null);
vo.setCreateTime(null);
vo.setUpdateTime(null);
vo.setUpdateUser(null);
return vo;
}
/**
* 填充属性ID
* @param stationAttrList 已保存进数据库的记录
* @param stationAttr 填充采集点后的属性模板
* @return
*/
private StationAttributeVo fillAttrId(List<StationAttributeEntity> stationAttrList,StationAttributeVo stationAttr) {
if(CollectionUtil.isNotEmpty(stationAttrList)) {
Optional<StationAttributeEntity> attribute = stationAttrList.stream().filter(sa -> stationAttr.getAttributes().equals(sa.getAttributes())).findAny();
if(attribute.isPresent()) {
StationAttributeVo result = BeanUtil.copy(attribute.get(),StationAttributeVo.class);
result.setSignage(stationAttr.getSignage());
result.setSignageName(stationAttr.getSignageName());
result.setMonitorId(stationAttr.getMonitorId());
result.setMonitorName(stationAttr.getMonitorName());
result.setUpdateUser(null);
result.setUpdateTime(null);
return result;
}
stationAttr.setSort(null);
}
return stationAttr;
}
} }

Loading…
Cancel
Save