Browse Source

1、风柜系统界面优化处理以及添加定时开关机功能;

2、热水系统系统监控参数展示优化;
dev
mh 2 weeks ago
parent
commit
e99c587404
  1. 61
      mh-admin/src/main/java/com/mh/web/controller/device/ChillersParamsController.java
  2. 37
      mh-admin/src/main/java/com/mh/web/controller/monitor/AirHandingUnitsMonitorController.java
  3. 2
      mh-admin/src/main/java/com/mh/web/controller/monitor/HotWaterMonitorController.java
  4. 5
      mh-admin/src/main/resources/application-dev.yml
  5. 8
      mh-common/src/main/java/com/mh/common/core/domain/dto/HotWaterNowDataDTO.java
  6. 5
      mh-common/src/main/java/com/mh/common/core/domain/entity/PolicyManage.java
  7. 2
      mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageVO.java
  8. 223
      mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageVO2.java
  9. 12
      mh-common/src/main/java/com/mh/common/core/domain/vo/HotWaterControlListVO.java
  10. 7
      mh-common/src/main/java/com/mh/common/core/domain/vo/HotWaterControlVO.java
  11. 10
      mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java
  12. 13
      mh-system/src/main/java/com/mh/system/mapper/policy/PolicyManageMapper.java
  13. 74
      mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java
  14. 4
      mh-system/src/main/java/com/mh/system/service/policy/IPolicyManageService.java
  15. 52
      mh-system/src/main/java/com/mh/system/service/policy/impl/PolicyManageServiceImpl.java

61
mh-admin/src/main/java/com/mh/web/controller/device/ChillersParamsController.java

@ -4,10 +4,15 @@ import com.mh.common.core.controller.BaseController;
import com.mh.common.core.domain.AjaxResult;
import com.mh.common.core.domain.entity.CollectionParamsManage;
import com.mh.common.core.domain.entity.CommunicationParams;
import com.mh.common.core.domain.entity.SysDictData;
import com.mh.common.core.domain.vo.CollectionParamsManageVO2;
import com.mh.common.core.domain.vo.EnergyConsumptionVO;
import com.mh.common.core.domain.vo.EnergyQueryVO;
import com.mh.common.core.page.TableDataInfo;
import com.mh.common.utils.DateUtils;
import com.mh.common.utils.DictUtils;
import com.mh.common.utils.StringUtils;
import com.mh.common.utils.bean.BeanUtils;
import com.mh.system.service.device.ICollectionParamsManageService;
import com.mh.system.service.device.ICommunicationParamsService;
import com.mh.system.service.energy.IEnergyService;
@ -40,34 +45,84 @@ public class ChillersParamsController extends BaseController {
/**
* 获取注解全部参数内容数据
*
* @param collectionParamsManage
* @return
*/
@GetMapping("/list")
public TableDataInfo list(CollectionParamsManage collectionParamsManage)
{
public TableDataInfo list(CollectionParamsManage collectionParamsManage) {
List<CollectionParamsManage> list = iCollectionParamsManageService.selectCollectionParamsManageList(collectionParamsManage);
// list中的CollectionParamsManage中的other_name去掉“号主机”之前数据
list.forEach(item -> {
String otherName = item.getOtherName();
// 使用正则表达式去掉“号主机”及之前的内容
String result = otherName != null ? otherName.replaceFirst(".*号主机", "") : otherName;
result = result != null ? result.replace("-", "") : result;
item.setOtherName(result);
});
// list中的CollectionParamsManage对象赋值到CollectionParamsManageVO2形成List<CollectionParamsManageVO2>
List<CollectionParamsManageVO2> voList = list.stream()
.filter(item -> item.getIsUse() != 1)
.map(item -> {
CollectionParamsManageVO2 vo = new CollectionParamsManageVO2();
BeanUtils.copyProperties(item, vo);
vo.setCurValue(item.getCurValue().setScale(2).toString());
// 判断运行状态、启停、故障、本地远程
switch (vo.getParamType()) {
case "1": // 运行状态
if (!StringUtils.isEmpty(vo.getCurValue())) {
vo.setCurValue(vo.getCurValue().equals("1") ? "运行" : "停止");
}
break;
case "2": // 启停
if (!StringUtils.isEmpty(vo.getCurValue())) {
vo.setCurValue(vo.getCurValue().equals("1") ? "启动" : "停止");
}
break;
case "5": // 故障
if (!StringUtils.isEmpty(vo.getCurValue())) {
vo.setCurValue(vo.getCurValue().equals("1") ? "故障" : "正常");
}
break;
case "6": // 手自动切换
if (!StringUtils.isEmpty(vo.getCurValue())) {
vo.setCurValue(vo.getCurValue().equals("1") ? "手动" : "自动");
}
break;
case "22": // 本地远程切换
if (!StringUtils.isEmpty(vo.getCurValue())) {
vo.setCurValue(vo.getCurValue().equals("1") ? "远程" : "本地");
}
break;
default:
break;
}
return vo;
})
.collect(Collectors.toList());
// 再根据mtType进行分组
Map<String, List<CollectionParamsManage>> collect = list.stream().collect(Collectors.groupingBy(CollectionParamsManage::getMtType));
Map<String, List<CollectionParamsManageVO2>> collect = voList.stream().collect(Collectors.groupingBy(CollectionParamsManageVO2::getMtType));
// map转list
List<SysDictData> sysMtTypeList = DictUtils.getDictCache("sys_mt_type");
List<Map<String, Object>> result = collect.entrySet().stream().map(entry -> {
Map<String, Object> map = new HashMap<>();
map.put("mtType", entry.getKey());
map.put("mtTypeName", sysMtTypeList.stream().filter(item -> item.getDictValue().equals(entry.getKey())).findFirst().get().getDictLabel());
map.put("list", entry.getValue());
return map;
}).collect(Collectors.toList());
result.sort((map1, map2) -> {
Integer mtType1 = Integer.parseInt((String)map1.get("mtType"));
Integer mtType2 = Integer.parseInt((String)map2.get("mtType"));
return mtType1.compareTo(mtType2); // 升序
});
return getDataTable(result);
}
/**
* 获取折线图数据:冷冻水进出水温度和冷却水进出水温度
*
* @param vo
* @return
*/

37
mh-admin/src/main/java/com/mh/web/controller/monitor/AirHandingUnitsMonitorController.java

@ -1,15 +1,18 @@
package com.mh.web.controller.monitor;
import com.mh.common.core.controller.BaseController;
import com.mh.common.core.domain.AjaxResult;
import com.mh.common.core.domain.dto.DeviceMonitorDTO;
import com.mh.common.core.domain.entity.DeviceLedger;
import com.mh.common.core.domain.entity.PolicyManage;
import com.mh.common.core.page.TableDataInfo;
import com.mh.system.service.device.ICollectionParamsManageService;
import com.mh.system.service.policy.IPolicyManageService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
/**
@ -25,8 +28,11 @@ public class AirHandingUnitsMonitorController extends BaseController {
private final ICollectionParamsManageService iCollectionParamsManageService;
public AirHandingUnitsMonitorController(ICollectionParamsManageService iCollectionParamsManageService) {
private final IPolicyManageService policyManageService;
public AirHandingUnitsMonitorController(ICollectionParamsManageService iCollectionParamsManageService, IPolicyManageService policyManageService) {
this.iCollectionParamsManageService = iCollectionParamsManageService;
this.policyManageService = policyManageService;
}
/**
@ -39,4 +45,25 @@ public class AirHandingUnitsMonitorController extends BaseController {
return getDataTable(list);
}
/**
* 风柜获取定时开关机参数
*/
@GetMapping("/monitor/timeList")
public TableDataInfo timeList(@RequestParam(name = "systemType") String systemType,
@RequestParam(name = "funPolicyType") String funPolicyType,
@RequestParam(name = "houseId") String houseId)
{
List<?> list = policyManageService.selectDDCTimeList(systemType, funPolicyType, houseId);
return getDataTable(list);
}
/**
* 修改定时任务时间参数值
*/
@PutMapping("/monitor/time")
public AjaxResult edit(@RequestParam(name = "policyId") String policyId, @RequestParam(name = "timeValue") String timeValue)
{
return toAjax(policyManageService.updateTimeValue(policyId, timeValue));
}
}

2
mh-admin/src/main/java/com/mh/web/controller/monitor/HotWaterMonitorController.java

@ -48,7 +48,7 @@ public class HotWaterMonitorController extends BaseController {
}
/**
* 获取生活热水监控公共信息列表
* 获取生活热水监控热泵信息
* @param systemType
* @param floorId
* @return

5
mh-admin/src/main/resources/application-dev.yml

@ -195,6 +195,11 @@ mqttSpring:
port: 2883
username: mh
password: mhtech@803
# protocol: MQTT
# host: mqtt.mhito.net
# port: 1883
# username: sa
# password: sa123
client-id: mqtt_mz_producer_dev
# If the protocol is ws/wss, this value is required.
path:

8
mh-common/src/main/java/com/mh/common/core/domain/dto/HotWaterNowDataDTO.java

@ -28,7 +28,13 @@ public class HotWaterNowDataDTO {
private String tankName; //水箱名称
private String envTemp; //环境温度
private String upWaterState; // 供水状态
private String upWaterState1; // 供水1泵状态
private String freq1; // 供水频率1
private String upWaterState2; // 供水2泵状态
private String freq2; // 供水频率2
private String useWaterState; // 补水状态

5
mh-common/src/main/java/com/mh/common/core/domain/entity/PolicyManage.java

@ -89,6 +89,11 @@ public class PolicyManage {
*/
private int digits;
/**
* 房间id
*/
private String houseId;
@Override
public String toString() {
return new ToStringBuilder(this)

2
mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageVO.java

@ -44,6 +44,8 @@ public class CollectionParamsManageVO {
*/
private int cpmOrderNum;
private int mtRatio;
public BigDecimal getCurValue() {
return curValue;
}

223
mh-common/src/main/java/com/mh/common/core/domain/vo/CollectionParamsManageVO2.java

@ -0,0 +1,223 @@
package com.mh.common.core.domain.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.mh.common.core.domain.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.math.BigDecimal;
import java.util.Date;
import java.util.Map;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 数据采集参数配置管理
* @date 2025-01-13 15:23:40
*/
@Setter
@Getter
public class CollectionParamsManageVO2 extends BaseEntity {
/**
* id
*/
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id;
/**
* 设备台账id
*/
private String deviceLedgerId;
/**
* 仪表类型id
*/
private String mtType;
/**
* 仪表编号
*/
private String mtNum;
/**
* 仪表代码
*/
private String mtCode;
/**
* 寄存器地址
*/
private String registerAddr;
/**
* 功能码
*/
private String funcCode;
/**
* 仪表标识码
*/
private String identifyCode;
/**
* 仪表标定脉冲
*/
private String mtCaliberPulse;
/**
* 仪表范围
*/
private BigDecimal mtRange;
/**
* 仪表比率
*/
private Integer mtRatio;
/**
* 初始值
*/
private BigDecimal mtInitValue;
/**
* 小数位数
*/
private Integer digits;
/**
* 数据类型
*/
private Integer dataType;
/**
* 当前值
*/
private String curValue;
/**
* 当前时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date curTime;
/**
* 是否是总表累计值
*/
private Integer mtIsSum;
/**
* 单位
*/
private String unit;
/**
* 排序
*/
private Integer orderNum;
/**
* 网关id
*/
private String gatewayId;
/**
* 通信参数id
*/
private String communicationParamId;
/**
* 通讯协议类型
*/
private String protocolType;
/**
* 通讯类型
*/
private String communicationType;
/**
* 读取响应的寄存器大小创建指令的时候需要
*/
private Integer registerSize;
/**
* 是否使用
*/
private Integer isUse;
/**
* 别名
* @return
*/
private String otherName;
/**
* 累计/瞬时 状态标识
*/
private Integer grade;
/**
* 参数类型0:运行状态1:启停状态2频率调节3频率反馈
*/
private String paramType;
/**
* 系统类型
*/
private String systemType;
/**
* 采集类别0遥测连续变化参数1遥信离散开关状态
*/
private String collectionType;
/**
* 终端设备类型实际上就是设备类型
*/
private String terminalDeviceType;
@Override
public String toString() {
return new ToStringBuilder(this)
.append("id", id)
.append("deviceLedgerId", deviceLedgerId)
.append("mtType", mtType)
.append("mtNum", mtNum)
.append("mtCode", mtCode)
.append("registerAddr", registerAddr)
.append("funcCode", funcCode)
.append("identifyCode", identifyCode)
.append("mtCaliberPulse", mtCaliberPulse)
.append("mtRange", mtRange)
.append("mtRatio", mtRatio)
.append("mtInitValue", mtInitValue)
.append("digits", digits)
.append("dataType", dataType)
.append("curValue", curValue)
.append("curTime", curTime)
.append("mtIsSum", mtIsSum)
.append("unit", unit)
.append("orderNum", orderNum)
.append("gatewayId", gatewayId)
.append("communicationParamId", communicationParamId)
.append("protocolType", protocolType)
.append("communicationType", communicationType)
.append("registerSize", registerSize)
.append("isUse", isUse)
.append("otherName", otherName)
.append("grade", grade)
.append("paramType", paramType)
.append("systemType", systemType)
.append("collectionType", collectionType)
.append("terminalDeviceType", terminalDeviceType)
.toString();
}
}

12
mh-common/src/main/java/com/mh/common/core/domain/vo/HotWaterControlListVO.java

@ -42,6 +42,18 @@ public class HotWaterControlListVO {
private int cpmOrderNum;
public BigDecimal getCurValue() {
return curValue;
}
public void setCurValue(BigDecimal curValue) {
if (curValue!= null) {
// 保留两位小数
curValue = curValue.setScale(2, BigDecimal.ROUND_HALF_UP);
}
this.curValue = curValue;
}
@Override
public String toString() {
return new ToStringBuilder(this)

7
mh-common/src/main/java/com/mh/common/core/domain/vo/HotWaterControlVO.java

@ -121,6 +121,13 @@ public class HotWaterControlVO {
private int orderNum;
public void setCounterSet(BigDecimal counterSet) {
if (counterSet != null) {
counterSet = counterSet.setScale(0, BigDecimal.ROUND_HALF_UP);
}
this.counterSet = counterSet;
}
@Override
public String toString() {
return new ToStringBuilder(this)

10
mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java

@ -12,7 +12,6 @@ import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
* @author LJF
@ -205,7 +204,8 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
" cpm.cur_time, " +
" cpm.param_type," +
" dl.order_num as dl_order_num," +
" cpm.order_num as cpm_order_num " +
" cpm.order_num as cpm_order_num," +
" cpm.mt_ratio as mt_ratio " +
"from " +
" collection_params_manage cpm " +
"left join " +
@ -222,7 +222,7 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
" hi.house_name || right(cpm.other_name, " +
" 4) as name, " +
" cpm.cur_value as value, " +
" cpm.cur_time as curTime " +
" cpm.cur_time as \"curTime\" " +
"from " +
" collection_params_manage cpm " +
"left join device_ledger dl on " +
@ -234,7 +234,6 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
"where " +
" (cpm.param_type = '12' " +
" or cpm.param_type = '13') " +
" and (dl.device_type is null)" +
" and csr.floor_id = #{floorId} " +
" and cpm.system_type = #{systemType}" +
" order by hi.house_name, cpm.param_type ")
@ -297,6 +296,7 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
// " (dl.device_type = '10' or dl.device_type = '16' or dl.device_type = '17' ) " +
" csr.floor_id = #{floorId} " +
" and cpm.system_type = #{systemType} " +
" and cpm.is_use = 0 " +
" order by dl.order_num ")
List<HotWaterControlListVO> selectHotWaterBySystemTypeAndBuildingId(@Param("systemType") String systemType,
@Param("floorId") String floorId);
@ -326,7 +326,7 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
@Param("houseId") String houseId);
@Update("update collection_params_manage set cur_value = #{curValue}, cur_time = #{curTime} where id = #{id} ")
void updateCurValueById(@Param("id") String id, @Param("curValue") BigDecimal curValue, @Param("curTime") Date curTime);
int updateCurValueById(@Param("id") String id, @Param("curValue") BigDecimal curValue, @Param("curTime") Date curTime);
@Select("select" +
" device_ledger_id " +

13
mh-system/src/main/java/com/mh/system/mapper/policy/PolicyManageMapper.java

@ -26,4 +26,17 @@ public interface PolicyManageMapper extends BaseMapper<PolicyManage> {
@Select("select pm.* from policy_manage pm where pm.cpm_id = #{cpmId} limit 1")
PolicyManage selectOntByCpmId(@Param("cpmId") String cpmId);
@Select("select pm.*,cpm.cur_value from policy_manage pm " +
" left join collection_params_manage cpm on pm.cpm_id = cpm.id " +
" where pm.system_type = #{systemType} " +
" and pm.fun_policy_type = #{funPolicyType} " +
" and house_id = #{houseId} " +
" order by pm.policy_type, pm.order_num ")
List<PolicyManage> selectPolicyListByParams(@Param("systemType") String systemType,
@Param("funPolicyType") String funPolicyType,
@Param("houseId") String houseId);
@Select("select cpm_id from policy_manage where id = #{policyId} limit 1")
String selectCpmId(String policyId);
}

74
mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java

@ -243,13 +243,16 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
deviceMonitorVO.setId(param.getId());
deviceMonitorVO.setDeviceLedgerId(param.getDeviceLedgerId());
deviceMonitorVO.setDeviceName(param.getDeviceName());
if (StringUtils.isEmpty(param.getMtType())) {
deviceMonitorVO.setDeviceType("");
}
deviceMonitorVO.setDeviceType(param.getMtType());
deviceMonitorVO.setCollectName(param.getOtherName());
deviceMonitorVO.setCollectTime(param.getCurTime());
// 判断如果是压力,放大1000倍,并保留一位小数
if (param.getParamType().equals("13")) {
BigDecimal bigDecimal = param.getCurValue();
// bigDecimal = bigDecimal.multiply(new BigDecimal(1000));
bigDecimal = bigDecimal.multiply(new BigDecimal(param.getMtRatio()));
param.setCurValue(bigDecimal.setScale(1, RoundingMode.HALF_UP));
}
deviceMonitorVO.setCollectValue(String.valueOf(param.getCurValue().setScale(1, RoundingMode.HALF_UP)));
@ -258,6 +261,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
}
return deviceMonitorVO;
})
.filter(vo -> vo.getDeviceType() != null)
.collect(Collectors.groupingBy(DeviceMonitorVO::getDeviceType));
// 根据deviceType进行分组,赋值给List<DeviceMonitorDTO>得出结果集
@ -332,6 +336,10 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
List<Map<String, Object>> mapList = collectionParamsManageMapper.selectBySystemTypeAndBuildingId(systemType, floorId);
// stream流判断mapList中的数据curTime是否为今天日期,假如不是今天日期,则重新赋值value为"采集失败",然后响应赋值给List<ColumnFilter>
return mapList.stream()
.filter(map -> {
String name = map.get("name").toString();
return !name.contains("热泵");
})
.map(map -> {
// 1. 获取当前记录的 curTime 和 value
Object curTimeObj = map.get("curTime");
@ -358,12 +366,12 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
map.put("value", "采集失败");
} else {
// 4.1 如果是今天,设置 value 为采集到的值
map.put("value", new BigDecimal(String.valueOf(map.get("value"))).setScale(0, RoundingMode.HALF_UP).toString());
map.put("value", new BigDecimal(String.valueOf(map.get("value"))).setScale(2, RoundingMode.HALF_UP).toString());
}
// 4. 转换为 ColumnFilter 对象(假设构造函数为 ColumnFilter(name, value))
return new ColumnFilter(
(String) map.get("name"),
map.get("name").toString().replace("回水阀", ""),
(String) map.get("value")
);
})
@ -405,19 +413,69 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
return dto;
}).collect(Collectors.toList());
// 处理供水泵(deviceType=10)
// 处理供水泵状态(deviceType=10)
List<DeviceMonitorVO> waterPumps = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "10");
// 判断是否存在collectValue>0的记录
boolean hasValidCollectValue = waterPumps.stream()
boolean hasValidCollectValue1 = waterPumps.stream()
.anyMatch(vo -> "1".equals(vo.getParamType())
&& vo.getCollectValue() != null
&& new BigDecimal(vo.getCollectValue()).intValue() > 0
&& vo.getCollectName().contains("供水泵1"));
// 根据判断结果设置状态值
result.forEach(dto -> dto.setUpWaterState1(hasValidCollectValue1 ? "1" : "0"));
// 判断是否存在collectValue>0的记录
boolean hasValidCollectValue2 = waterPumps.stream()
.anyMatch(vo -> "1".equals(vo.getParamType())
&& vo.getCollectValue() != null
&& new BigDecimal(vo.getCollectValue()).intValue() > 0
&& vo.getCollectName().contains("供水泵2"));
// 根据判断结果设置状态值
result.forEach(dto -> dto.setUpWaterState2(hasValidCollectValue2 ? "1" : "0"));
// 频率反馈1
DeviceMonitorVO freq1 = waterPumps.stream()
.filter(vo -> "4".equals(vo.getParamType())
&& vo.getCollectValue() != null
&& vo.getCollectName().contains("供水泵1"))
.collect(Collectors.toList()).getFirst();
// 根据判断结果设置状态值
if (StringUtils.isEmpty(freq1.getCollectValue())) {
freq1.setCollectValue("0");
}
result.forEach(dto -> dto.setFreq1(new BigDecimal(freq1.getCollectValue()).setScale(2, RoundingMode.HALF_UP).toString()));
// 频率反馈2
DeviceMonitorVO freq2 = waterPumps.stream()
.filter(vo -> "4".equals(vo.getParamType())
&& vo.getCollectValue() != null
&& vo.getCollectName().contains("供水泵2"))
.collect(Collectors.toList()).getFirst();
if (StringUtils.isEmpty(freq2.getCollectValue())) {
freq2.setCollectValue("0");
}
// 根据判断结果设置状态值
result.forEach(dto -> dto.setFreq2(new BigDecimal(freq2.getCollectValue()).setScale(2, RoundingMode.HALF_UP).toString()));
// 处理水箱,水箱绑定了补水阀参数(deviceType=16)
List<DeviceMonitorVO> waterValves = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "16");
// 判断是否存在collectValue>0的记录
boolean useWaterState = waterValves.stream()
.anyMatch(vo -> "2".equals(vo.getParamType())
&& vo.getCollectValue() != null
&& new BigDecimal(vo.getCollectValue()).intValue() > 0);
// 根据判断结果设置状态值
result.forEach(dto -> dto.setUseWaterState(useWaterState ? "1" : "0"));
// 处理回水阀(deviceType=22)
List<DeviceMonitorVO> waterBackValves = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "22");
// 判断是否存在collectValue>0的记录
boolean backWaterState = waterBackValves.stream()
.anyMatch(vo -> "2".equals(vo.getParamType())
&& vo.getCollectValue() != null
&& new BigDecimal(vo.getCollectValue()).intValue() > 0);
// 根据判断结果设置状态值
result.forEach(dto -> dto.setUpWaterState(hasValidCollectValue ? "1" : "0"));
result.forEach(dto -> dto.setBackWaterState(backWaterState ? "1" : "0"));
// 处理水箱液位(deviceType=12)
List<DeviceMonitorVO> waterLevels = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "12");
// 处理水箱液位(deviceType=16
List<DeviceMonitorVO> waterLevels = collectionParamsManageMapper.selectHotWaterBySystemTypeAndBuildingIdAndDeviceType(systemType, floorId, "16");
// 计算levelSet平均值(paramType=10)
Double levelSetAvg = waterLevels.stream()

4
mh-system/src/main/java/com/mh/system/service/policy/IPolicyManageService.java

@ -11,4 +11,8 @@ import java.util.List;
*/
public interface IPolicyManageService {
List<?> selectPolicyList(String systemType, String funPolicyType);
List<?> selectDDCTimeList(String systemType, String funPolicyType, String houseId);
int updateTimeValue(String policyId, String timeValue);
}

52
mh-system/src/main/java/com/mh/system/service/policy/impl/PolicyManageServiceImpl.java

@ -3,16 +3,14 @@ package com.mh.system.service.policy.impl;
import com.mh.common.core.domain.dto.DeviceMonitorDTO;
import com.mh.common.core.domain.entity.CollectionParamsManage;
import com.mh.common.core.domain.entity.PolicyManage;
import com.mh.common.utils.StringUtils;
import com.mh.system.mapper.device.CollectionParamsManageMapper;
import com.mh.system.mapper.policy.PolicyManageMapper;
import com.mh.system.service.policy.IPolicyManageService;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -34,6 +32,44 @@ public class PolicyManageServiceImpl implements IPolicyManageService {
this.collectionParamsManageMapper = collectionParamsManageMapper;
}
@Override
public int updateTimeValue(String policyId, String timeValue) {
String cpmId = policyManageMapper.selectCpmId(policyId);
if (StringUtils.isEmpty(cpmId)) {
throw new RuntimeException("未找到该时间策略值");
}
return collectionParamsManageMapper.updateCurValueById(cpmId, new BigDecimal(timeValue), new Date());
}
@Override
public List<?> selectDDCTimeList(String systemType, String funPolicyType, String houseId) {
List<PolicyManage> policyManages = policyManageMapper.selectPolicyListByParams(systemType, funPolicyType, houseId);
Map<String, List<PolicyManage>> listMap = policyManages.stream()
// 先排序(例如按 policyType)
.sorted(Comparator.comparing(PolicyManage::getPolicyType))
// 处理每个PolicyManage对象的curValue字段
.peek(policy -> {
policy.setCurValue(BigDecimal.valueOf(policy.getCurValue().intValue())); // 除以1000并保留整数
})
// 分组时使用 LinkedHashMap 来保持插入顺序
.collect(Collectors.groupingBy(
PolicyManage::getPolicyName, // 分组键
LinkedHashMap::new, // 使用 LinkedHashMap 保持顺序 ✅
Collectors.toList() // 下游收集器
));
// 转换为 DeviceMonitorDTO 列表
List<DeviceMonitorDTO> result = new ArrayList<>();
listMap.forEach((name, values) -> {
DeviceMonitorDTO dto = new DeviceMonitorDTO();
dto.setName(name);
dto.setValues(values);
result.add(dto);
});
return result;
}
@Override
public List<?> selectPolicyList(String systemType, String funPolicyType) {
// QueryWrapper<PolicyManage> queryWrapper = new QueryWrapper<>();
@ -69,8 +105,12 @@ public class PolicyManageServiceImpl implements IPolicyManageService {
}
}
})
// 再按PolicyName分组
.collect(Collectors.groupingBy(PolicyManage::getPolicyName, Collectors.toList()));
// 分组时使用 LinkedHashMap 来保持插入顺序
.collect(Collectors.groupingBy(
PolicyManage::getPolicyName, // 分组键
LinkedHashMap::new, // 使用 LinkedHashMap 保持顺序 ✅
Collectors.toList() // 下游收集器
));
// 在遍历赋值给DeviceMonitorDTO,key给name,value给list
List<DeviceMonitorDTO> list = new ArrayList<>();
listMap.keySet().forEach(k -> {

Loading…
Cancel
Save