From 5688addac8a79cf04718b584079d4c2c66aea2b9 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Mon, 18 Dec 2023 11:22:39 +0800 Subject: [PATCH] =?UTF-8?q?#=20=E5=8F=82=E6=95=B0=E4=B8=8B=E5=8F=91?= =?UTF-8?q?=E5=89=94=E9=99=A4=E6=8E=89=E9=9D=9E=E5=8F=82=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E5=B1=9E=E6=80=A7=20#=20=E4=B8=8A=E6=AC=A1=E6=8A=A5=E6=96=87?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (cherry picked from commit cad0af0c31906e9c140e97210639f1b1214f9c63) --- .../hnac/hzims/equipment/entity/EmInfoEntity.java | 3 +++ .../emParam/service/impl/ParamServiceImpl.java | 27 +++++++++++++++------- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java b/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java index f9b0dbc..6263434 100644 --- a/hzims-service-api/equipment-api/src/main/java/com/hnac/hzims/equipment/entity/EmInfoEntity.java +++ b/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 infoChildren; @ApiModelProperty("最后下发时间") + @DateTimeFormat(pattern = DateUtil.PATTERN_DATETIME) + @JsonFormat(pattern = DateUtil.PATTERN_DATETIME) private LocalDateTime lastDistributeTime; @ApiModelProperty("机组类别") diff --git a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamServiceImpl.java b/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamServiceImpl.java index 12fced6..ffbdb7f 100644 --- a/hzims-service/equipment/src/main/java/com/hnac/hzims/emParam/service/impl/ParamServiceImpl.java +++ b/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 signageList = paramDeviceAttrR.getData().stream().filter(o->StringUtil.isNotBlank(o.getSignage()) && StringUtil.isNotBlank(o.getFacDeviceAttrId())).map(DeviceInstanceAttrVO::getSignage).collect(Collectors.toList()); + List signageList = paramDeviceAttrR.getData().stream() + .filter(o->StringUtil.isNotBlank(o.getSignage()) && StringUtil.isNotBlank(o.getFacDeviceAttrId())) + .map(DeviceInstanceAttrVO::getSignage).collect(Collectors.toList()); Result realDataR = deviceDataClient.getDeviceRealDataByCode(emCode, signageList); Assert.isTrue(realDataR.isSuccess(),() -> { throw new ServiceException("参数召回获取实时数据失败"); }); - Map> 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> 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);