|
|
@ -40,6 +40,9 @@ import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
import org.springframework.util.Assert; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.time.LocalDateTime; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
@ -75,12 +78,16 @@ public class ParamServiceImpl implements IParamService { |
|
|
|
throw new ServiceException("获取设备实例物模型属性失败!"); |
|
|
|
throw new ServiceException("获取设备实例物模型属性失败!"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
// 获取实时数据
|
|
|
|
// 获取实时数据
|
|
|
|
List<String> signageList = paramDeviceAttrR.getData().stream().filter(o->StringUtil.isNotBlank(o.getSignage()) && StringUtil.isNotBlank(o.getFacDeviceAttrId())).map(DeviceInstanceAttrVO::getSignage).collect(Collectors.toList()); |
|
|
|
List<String> signageList = paramDeviceAttrR.getData().stream() |
|
|
|
|
|
|
|
.filter(o->StringUtil.isNotBlank(o.getSignage()) && StringUtil.isNotBlank(o.getFacDeviceAttrId())) |
|
|
|
|
|
|
|
.map(DeviceInstanceAttrVO::getSignage).collect(Collectors.toList()); |
|
|
|
Result<DeviceDataDTO> realDataR = deviceDataClient.getDeviceRealDataByCode(emCode, signageList); |
|
|
|
Result<DeviceDataDTO> realDataR = deviceDataClient.getDeviceRealDataByCode(emCode, signageList); |
|
|
|
Assert.isTrue(realDataR.isSuccess(),() -> { |
|
|
|
Assert.isTrue(realDataR.isSuccess(),() -> { |
|
|
|
throw new ServiceException("参数召回获取实时数据失败"); |
|
|
|
throw new ServiceException("参数召回获取实时数据失败"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
Map<ParamGroupVO, List<ParamVO>> paramGroupVOListMap = paramDeviceAttrR.getData().stream().filter(o->StringUtil.isNotBlank(o.getFacDeviceAttrId())).map(this::convert).collect(Collectors.groupingBy(p -> { |
|
|
|
Map<ParamGroupVO, List<ParamVO>> paramGroupVOListMap = paramDeviceAttrR.getData().stream() |
|
|
|
|
|
|
|
.filter(o->StringUtil.isNotBlank(o.getFacDeviceAttrId()) && o.getIsParam() == 1) |
|
|
|
|
|
|
|
.map(this::convert).collect(Collectors.groupingBy(p -> { |
|
|
|
ParamGroupVO paramGroupVO = new ParamGroupVO(); |
|
|
|
ParamGroupVO paramGroupVO = new ParamGroupVO(); |
|
|
|
paramGroupVO.setGroupId(String.valueOf(p.getModelClassifyId())); |
|
|
|
paramGroupVO.setGroupId(String.valueOf(p.getModelClassifyId())); |
|
|
|
paramGroupVO.setGroupName(p.getModelClassifyName()); |
|
|
|
paramGroupVO.setGroupName(p.getModelClassifyName()); |
|
|
@ -92,7 +99,11 @@ public class ParamServiceImpl implements IParamService { |
|
|
|
list.stream().filter(p -> realDataR.getData().getDataMap().containsKey(p.getSignage())).forEach(p -> { |
|
|
|
list.stream().filter(p -> realDataR.getData().getDataMap().containsKey(p.getSignage())).forEach(p -> { |
|
|
|
String realData = JSON.toJSONString(realDataR.getData().getDataMap().get(p.getSignage())); |
|
|
|
String realData = JSON.toJSONString(realDataR.getData().getDataMap().get(p.getSignage())); |
|
|
|
if("0".equals(JSONObject.parseObject(realData).getString("q"))) { |
|
|
|
if("0".equals(JSONObject.parseObject(realData).getString("q"))) { |
|
|
|
p.setValue(JSONObject.parseObject(realData).getString("v")); |
|
|
|
String value = JSONObject.parseObject(realData).getString("v"); |
|
|
|
|
|
|
|
if(StringUtil.isNotBlank(p.getDbType()) && "double".equals(p.getDbType())) { |
|
|
|
|
|
|
|
value = String.valueOf(new BigDecimal(value).setScale(p.getKeepFigures(), RoundingMode.HALF_UP).doubleValue()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
p.setValue(value); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
paramTreeVO.setParamList(list); |
|
|
|
paramTreeVO.setParamList(list); |
|
|
|