Browse Source

# 参数下发剔除掉非参数的属性

# 上次报文时间格式化

(cherry picked from commit cad0af0c31)
zhongwei
haungxing 11 months ago
parent
commit
5688addac8
  1. 3
      hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java
  2. 27
      hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamServiceImpl.java

3
hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java

@ -13,6 +13,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.constraints.Range;
import org.springblade.core.tenant.mp.TenantEntity;
import org.springblade.core.tool.utils.DateUtil;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
@ -251,6 +252,8 @@ public class EmInfoEntity extends TenantEntity {
private List<EmInfoEntity> infoChildren;
@ApiModelProperty("最后下发时间")
@DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME)
@JsonFormat(pattern = DateUtil.PATTERN_DATETIME)
private LocalDateTime lastDistributeTime;
@ApiModelProperty("机组类别")

27
hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamServiceImpl.java

@ -40,6 +40,9 @@ import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringUtil;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
@ -75,24 +78,32 @@ public class ParamServiceImpl implements IParamService {
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);
Assert.isTrue(realDataR.isSuccess(),() -> {
throw new ServiceException("参数召回获取实时数据失败");
});
Map<ParamGroupVO, List<ParamVO>> paramGroupVOListMap = paramDeviceAttrR.getData().stream().filter(o->StringUtil.isNotBlank(o.getFacDeviceAttrId())).map(this::convert).collect(Collectors.groupingBy(p -> {
ParamGroupVO paramGroupVO = new ParamGroupVO();
paramGroupVO.setGroupId(String.valueOf(p.getModelClassifyId()));
paramGroupVO.setGroupName(p.getModelClassifyName());
return paramGroupVO;
}));
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.setGroupId(String.valueOf(p.getModelClassifyId()));
paramGroupVO.setGroupName(p.getModelClassifyName());
return paramGroupVO;
}));
paramGroupVOListMap.forEach((groupVO,list) -> {
ParamTreeVO paramTreeVO = new ParamTreeVO();
paramTreeVO.setParamGroup(groupVO);
list.stream().filter(p -> realDataR.getData().getDataMap().containsKey(p.getSignage())).forEach(p -> {
String realData = JSON.toJSONString(realDataR.getData().getDataMap().get(p.getSignage()));
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);

Loading…
Cancel
Save