From 040437a702cae5ec820c5078833c7dcf21949415 Mon Sep 17 00:00:00 2001 From: mh Date: Fri, 18 Oct 2024 15:37:46 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=8E=A5=E5=8F=A3bug=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/mh/user/mapper/ScreenMapper.java | 2 +- .../user/mapper/chillers/ChillersMapper.java | 4 +- .../chillers/impl/ChillersServiceImpl.java | 54 ++++++++++--------- .../user/service/impl/ScreenServiceImpl.java | 4 +- 4 files changed, 34 insertions(+), 30 deletions(-) diff --git a/user-service/src/main/java/com/mh/user/mapper/ScreenMapper.java b/user-service/src/main/java/com/mh/user/mapper/ScreenMapper.java index 3372c88..fb2a3c5 100644 --- a/user-service/src/main/java/com/mh/user/mapper/ScreenMapper.java +++ b/user-service/src/main/java/com/mh/user/mapper/ScreenMapper.java @@ -208,7 +208,7 @@ public interface ScreenMapper { " group by " + " cur_date, elect " + ") t2 on " + - " t1.cur_date = t2.cur_date order by cur_date ") + " t1.cur_date = t2.cur_date order by t1.cur_date ") List> savingYoyEnergyData(@Param("projectId") String projectId, @Param("startTime") String startTime, @Param("endTime") String endTime, diff --git a/user-service/src/main/java/com/mh/user/mapper/chillers/ChillersMapper.java b/user-service/src/main/java/com/mh/user/mapper/chillers/ChillersMapper.java index e346bde..8ddc831 100644 --- a/user-service/src/main/java/com/mh/user/mapper/chillers/ChillersMapper.java +++ b/user-service/src/main/java/com/mh/user/mapper/chillers/ChillersMapper.java @@ -184,8 +184,8 @@ public interface ChillersMapper { List getStopChillers(); @Select("select mt_type, cur_value, cur_time from meter_manage " + - " where system_id = #{systemId} and project_id = #{proId} and device_id = #{deviceId} " + - " and grade between 0 and 9 group by mt_type, cur_value, cur_time ") + " where system_id = #{systemId} and project_id = #{proId} and device_id = #{deviceId} and mt_type in (1, 2)" + + " and grade between 40 and 49 group by mt_type, cur_value, cur_time ") List> queryTotalData(@Param("systemId") String systemId, @Param("proId") String proId, @Param("deviceId") String deviceId); diff --git a/user-service/src/main/java/com/mh/user/service/chillers/impl/ChillersServiceImpl.java b/user-service/src/main/java/com/mh/user/service/chillers/impl/ChillersServiceImpl.java index fbe134c..5a46ac1 100644 --- a/user-service/src/main/java/com/mh/user/service/chillers/impl/ChillersServiceImpl.java +++ b/user-service/src/main/java/com/mh/user/service/chillers/impl/ChillersServiceImpl.java @@ -11,6 +11,7 @@ import com.mh.user.mapper.ProjectInfoMapper; import com.mh.user.mapper.chillers.ChillersMapper; import com.mh.user.service.chillers.ChillersService; import com.mh.user.utils.DateUtil; +import com.mh.user.utils.ExchangeStringUtil; import com.mh.user.utils.TimeDifferenceUtil; import com.mh.user.vo.HostListVO; import org.springframework.stereotype.Service; @@ -345,16 +346,18 @@ public class ChillersServiceImpl implements ChillersService { List meterManageEntities = meterManageMapper.selectList( new QueryWrapper() .eq("device_id", devicesManageEntity.getId()) + .eq("project_id", devicesManageEntity.getProjectId()) .orderByAsc("sort")); - if (meterManageEntities != null && !meterManageEntities.isEmpty()) { - matchingChillersData(meterManageEntities, hostListVO); - // 额定制冷量 - hostListVO.setRatedRef(String.valueOf(devicesManageEntity.getRatedRefrigerationCapacity())); - // 额定功率 - hostListVO.setRatedPower(String.valueOf(devicesManageEntity.getRatedInputPower())); - // 额定COP - hostListVO.setRatedCop(String.valueOf(devicesManageEntity.getRatedCop())); + if (meterManageEntities == null || meterManageEntities.isEmpty()) { + continue; } + matchingChillersData(meterManageEntities, hostListVO); + // 额定制冷量 + hostListVO.setRatedRef(String.valueOf(devicesManageEntity.getRatedRefrigerationCapacity())); + // 额定功率 + hostListVO.setRatedPower(String.valueOf(devicesManageEntity.getRatedInputPower())); + // 额定COP + hostListVO.setRatedCop(String.valueOf(devicesManageEntity.getRatedCop())); mtArray.add(hostListVO); deviceJson.put("children", mtArray); children.add(deviceJson); @@ -371,66 +374,67 @@ public class ChillersServiceImpl implements ChillersService { hostListVO.reset(); for (MeterManageEntity meterManageEntity : meterManageEntities) { // 匹配HostListVO展示给前端 - String funCode = meterManageEntity.getFuncCode(); - String curValue = String.valueOf(meterManageEntity.getCurValue()); - switch (meterManageEntity.getMtCode()) { + String funCode = ExchangeStringUtil.addZeroForNum(meterManageEntity.getFuncCode(), 2); + + String curValue = new BigDecimal(String.valueOf(meterManageEntity.getCurValue() == null ? 0.00 : meterManageEntity.getCurValue())).setScale(1, RoundingMode.HALF_UP).toString(); + switch (meterManageEntity.getRegisterAddr()) { case "0001": - if (funCode.equals("1")) { - hostListVO.setRunningStatus(curValue); + if (funCode.equals("01")) { + hostListVO.setRunningStatus(String.valueOf(new BigDecimal(curValue).intValue())); } break; case "0003": - if (funCode.equals("3")) { + if (funCode.equals("03")) { hostListVO.setEnteringTempSet(curValue); } break; case "0005": - if (funCode.equals("3")) { + if (funCode.equals("03")) { hostListVO.setEvapLeavingChWTemp(curValue); } break; case "0006": - if (funCode.equals("3")) { + if (funCode.equals("03")) { hostListVO.setEvapEnteringChWTemp(curValue); } break; case "0015": - if (funCode.equals("3")) { + if (funCode.equals("03")) { hostListVO.setEvapApproach(curValue); } break; case "0009": - if (funCode.equals("3")) { + if (funCode.equals("03")) { hostListVO.setCondLeavingChWTemp(curValue); } break; case "0010": - if (funCode.equals("3")) { + if (funCode.equals("03")) { hostListVO.setCondEnteringChWTemp(curValue); } break; case "0023": - if (funCode.equals("3")) { + if (funCode.equals("03")) { hostListVO.setCondApproach(curValue); } break; case "0139": - if (funCode.equals("3")) { + if (funCode.equals("03")) { hostListVO.setRealTimeChillerAmps(curValue); } break; case "0013": - if (funCode.equals("3")) { + if (funCode.equals("03")) { hostListVO.setRealTimePower(curValue); } break; case "0014": - if (funCode.equals("3")) { + if (funCode.equals("03")) { hostListVO.setRealTimeCop(curValue); } break; case "0122": - if (funCode.equals("3")) { + if (funCode.equals("03")) { hostListVO.setRealTimeWarning(curValue); hostListVO.setRealTimeFault(curValue); } @@ -471,7 +475,7 @@ public class ChillersServiceImpl implements ChillersService { BigDecimal ele = resultJson.getBigDecimal("eleUsed") == null ? BigDecimal.ZERO : resultJson.getBigDecimal("eleUsed"); if (coolingUsed.compareTo(BigDecimal.ZERO) > 0 && ele.compareTo(BigDecimal.ZERO) > 0) { - resultJson.put("coolingUsed", coolingUsed + resultJson.put("cop", coolingUsed .divide(new BigDecimal(String.valueOf(resultJson.getBigDecimal("eleUsed"))), 1, RoundingMode.HALF_UP)); } else if (ele.compareTo(BigDecimal.ZERO) == 0) { resultJson.put("cop", 0.0); diff --git a/user-service/src/main/java/com/mh/user/service/impl/ScreenServiceImpl.java b/user-service/src/main/java/com/mh/user/service/impl/ScreenServiceImpl.java index 6cbc6af..dcbf82c 100644 --- a/user-service/src/main/java/com/mh/user/service/impl/ScreenServiceImpl.java +++ b/user-service/src/main/java/com/mh/user/service/impl/ScreenServiceImpl.java @@ -65,8 +65,8 @@ public class ScreenServiceImpl implements ScreenService { String projectId = screenRequestParamDTO.getProjectId(); String startTime = screenRequestParamDTO.getStartTime(); String endTime = screenRequestParamDTO.getEndTime(); - String lastStartTime = DateUtil.yoyDate(startTime + "-01 00:00:00").substring(0, 10); - String lastEndTime = DateUtil.yoyDate(endTime+ "-31 23:59:59").substring(0, 10); + String lastStartTime = DateUtil.yoyDate(startTime + " 00:00:00").substring(0, 10); + String lastEndTime = DateUtil.yoyDate(endTime+ " 23:59:59").substring(0, 10); List> monthData = screenMapper.savingYoyEnergyData(projectId, startTime, endTime, lastStartTime, lastEndTime); resultJson.add(monthData); break;