Browse Source

1、冷源监视:一键启动接口。

2、冷源策略管理接口;
dev
mh 1 month ago
parent
commit
5bdc1921b8
  1. 4
      mh-admin/src/main/java/com/mh/web/controller/monitor/CoolingSystemMonitorController.java
  2. 32
      mh-admin/src/main/java/com/mh/web/controller/policy/PolicyManageController.java
  3. 1
      mh-admin/src/main/resources/application-dev.yml
  4. 1
      mh-admin/src/main/resources/application-druid.yml
  5. 92
      mh-common/src/main/java/com/mh/common/core/domain/entity/PolicyManage.java
  6. 2
      mh-framework/src/main/java/com/mh/framework/mqtt/config/MqttInboundConfig.java
  7. 2
      mh-quartz/src/main/java/com/mh/quartz/task/GetWeatherDataTask.java
  8. 26
      mh-system/src/main/java/com/mh/system/mapper/policy/PolicyManageMapper.java
  9. 3
      mh-system/src/main/java/com/mh/system/service/device/ICoolingSystemMonitorService.java
  10. 2
      mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java
  11. 6
      mh-system/src/main/java/com/mh/system/service/device/impl/CoolingSystemMonitorServiceImpl.java
  12. 9
      mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java
  13. 14
      mh-system/src/main/java/com/mh/system/service/policy/IPolicyManageService.java
  14. 55
      mh-system/src/main/java/com/mh/system/service/policy/impl/PolicyManageServiceImpl.java
  15. 28
      sql/表结构设计.sql

4
mh-admin/src/main/java/com/mh/web/controller/monitor/CoolingSystemMonitorController.java

@ -89,5 +89,9 @@ public class CoolingSystemMonitorController extends BaseController {
return AjaxResult.success(iCoolingSystemMonitorService.getSysPerformance());
}
@GetMapping("/oneKeyButton")
public AjaxResult getOneKeyButton(@RequestParam(name = "systemType") String systemType, @RequestParam(name = "paramType") String paramType) {
return AjaxResult.success(iCoolingSystemMonitorService.getOneKeyButton(systemType, paramType));
}
}

32
mh-admin/src/main/java/com/mh/web/controller/policy/PolicyManageController.java

@ -0,0 +1,32 @@
package com.mh.web.controller.policy;
import com.mh.common.core.controller.BaseController;
import com.mh.common.core.page.TableDataInfo;
import com.mh.system.service.policy.IPolicyManageService;
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;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 策略管理
* @date 2025-04-01 14:51:48
*/
@RestController
@RequestMapping("/policy")
public class PolicyManageController extends BaseController {
private final IPolicyManageService policyManageService;
public PolicyManageController(IPolicyManageService policyManageService) {
this.policyManageService = policyManageService;
}
@GetMapping("/list")
public TableDataInfo getPolicyList(@RequestParam(required = false) String systemType, @RequestParam(required = false) String funPolicyType){
return getDataTable(policyManageService.selectPolicyList(systemType,funPolicyType));
}
}

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

@ -99,6 +99,7 @@ spring:
master:
#添加allowMultiQueries=true 在批量更新时才不会出错
url: jdbc:postgresql://127.0.0.1:5432/eemcs_hw
# url: jdbc:postgresql://127.0.0.1:5432/eemcs
username: postgres
password: mh@803
# 从库数据源

1
mh-admin/src/main/resources/application-druid.yml

@ -8,6 +8,7 @@ spring:
master:
#添加allowMultiQueries=true 在批量更新时才不会出错
url: jdbc:postgresql://127.0.0.1:5432/eemcs_hw
# url: jdbc:postgresql://127.0.0.1:5432/eemcs
username: postgres
password: mh@803
# 从库数据源

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

@ -0,0 +1,92 @@
package com.mh.common.core.domain.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.math.BigDecimal;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 策略管理
* @date 2025-04-01 14:26:31
*/
@Setter
@Getter
@TableName("policy_manage")
public class PolicyManage {
@TableId(value = "id", type = IdType.ASSIGN_UUID)
private String id;
/**
* 策略类型
*/
private String policyType;
/**
* 策略名称
*/
private String policyName;
/**
* 点位名称
*/
private String pointName;
/**
* 输入类型
*/
private String inputType;
/**
* 输入值
*/
private BigDecimal curValue;
/**
* 单位
*/
private String unit;
/**
* 采集点位名称
*/
private String cpmId;
/**
* 系统类型
*/
private String systemType;
/**
* 功能策略类型
*/
private String funPolicyType;
/**
* 排序
*/
private int orderNum;
@Override
public String toString() {
return new ToStringBuilder(this)
.append("id", id)
.append("policyType", policyType)
.append("policyName", policyName)
.append("pointName", pointName)
.append("inputType", inputType)
.append("unit", unit)
.append("cpmId", cpmId)
.append("systemType", systemType)
.append("funPolicyType", funPolicyType)
.toString();
}
}

2
mh-framework/src/main/java/com/mh/framework/mqtt/config/MqttInboundConfig.java

@ -51,7 +51,7 @@ public class MqttInboundConfig {
clientId,
mqttClientFactory,
options.getInboundTopic().split(","));
System.out.println("每一次都会入站适配器吗?"+clientId);
// System.out.println("每一次都会入站适配器吗?"+clientId);
DefaultPahoMessageConverter converter = new DefaultPahoMessageConverter();
// 统一是字节处理
converter.setPayloadAsBytes(true);

2
mh-quartz/src/main/java/com/mh/quartz/task/GetWeatherDataTask.java

@ -47,7 +47,7 @@ public class GetWeatherDataTask {
String returnResult = restTemplate.getForObject(url, String.class);
if (!StringUtils.isBlank(returnResult)) {
JSONObject jsonObject = JSON.parseObject(returnResult);
System.out.println(jsonObject);
//System.out.println(jsonObject);
if ("1".equals(jsonObject.get("status"))) {
try {
WeatherData weatherData = new WeatherData();

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

@ -0,0 +1,26 @@
package com.mh.system.mapper.policy;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.common.core.domain.entity.PolicyManage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 策略管理
* @date 2025-04-01 15:11:28
*/
@Mapper
public interface PolicyManageMapper extends BaseMapper<PolicyManage> {
@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} order by pm.policy_type, pm.order_num ")
List<PolicyManage> selectPolicyList(@Param("systemType") String systemType,
@Param("funPolicyType") String funPolicyType);
}

3
mh-system/src/main/java/com/mh/system/service/device/ICoolingSystemMonitorService.java

@ -1,6 +1,7 @@
package com.mh.system.service.device;
import com.mh.common.core.domain.dto.SysPerformanceDTO;
import com.mh.common.core.domain.entity.CollectionParamsManage;
import java.util.Map;
@ -30,4 +31,6 @@ public interface ICoolingSystemMonitorService {
* @return
*/
SysPerformanceDTO getSysPerformance();
CollectionParamsManage getOneKeyButton(String systemType, String paramType);
}

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

@ -222,6 +222,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
// 如果paramType="4",则是频率反馈,则赋值给frequency
// 使用Stream API处理数据
Map<String, List<DeviceMonitorVO>> groupedByDeviceType = collectionParamsManages.stream()
.filter(p -> p.getDeviceLedgerId() != null && StringUtils.isNotEmpty(p.getDeviceLedgerId()))
.collect(Collectors.groupingBy(CollectionParamsManageVO::getId))
.values()
.stream()
@ -266,6 +267,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
// 按设备台账ID分组
Map<String, List<CollectionParamsManageVO>> groupedByDevice = collectionParamsManages.stream()
.sorted(Comparator.comparing(CollectionParamsManageVO::getDlOrderNum))
.filter(p -> p.getDeviceLedgerId() != null && StringUtils.isNotEmpty(p.getDeviceLedgerId()))
.collect(Collectors.groupingBy(CollectionParamsManageVO::getDeviceLedgerId));
// 转换分组结果为监控VO列表

6
mh-system/src/main/java/com/mh/system/service/device/impl/CoolingSystemMonitorServiceImpl.java

@ -5,6 +5,7 @@ import com.mh.common.core.domain.dto.SysPerformanceDTO;
import com.mh.common.core.domain.entity.CollectionParamsManage;
import com.mh.common.core.domain.entity.SysParams;
import com.mh.common.core.domain.entity.WeatherData;
import com.mh.common.core.domain.vo.DeviceOperateMonitorVO;
import com.mh.common.utils.DateUtils;
import com.mh.common.utils.WeatherUtil;
import com.mh.system.mapper.SysParamsMapper;
@ -42,6 +43,11 @@ public class CoolingSystemMonitorServiceImpl implements ICoolingSystemMonitorSer
this.collectionParamsManageMapper = collectionParamsManageMapper;
}
@Override
public CollectionParamsManage getOneKeyButton(String systemType, String paramType) {
return collectionParamsManageMapper.selectOne(new QueryWrapper<CollectionParamsManage>().eq("system_type", systemType).eq("param_type", paramType));
}
@Override
public SysPerformanceDTO getSysPerformance() {
SysPerformanceDTO sysPerformanceDTO = new SysPerformanceDTO();

9
mh-system/src/main/java/com/mh/system/service/overview/impl/ProOverviewServiceImpl.java

@ -92,8 +92,11 @@ public class ProOverviewServiceImpl implements IProOverviewService {
// 热泵生活热水系统
// 查询供回水温度
List<CollectionParamsManage> realInAndOutTempParams = queryCollectionParams("12", "1", 140);
BigDecimal avgInTemp = new BigDecimal("0.00");
BigDecimal avgOutTemp = new BigDecimal("0.00");
if (null != realInAndOutTempParams && !realInAndOutTempParams.isEmpty()) {
// 查询供水温度的平均值
BigDecimal avgOutTemp = realInAndOutTempParams.stream()
avgOutTemp = realInAndOutTempParams.stream()
.filter(param -> param != null
&& param.getOtherName() != null
&& param.getOtherName().contains("供水"))
@ -102,7 +105,7 @@ public class ProOverviewServiceImpl implements IProOverviewService {
.reduce(BigDecimal.ZERO, BigDecimal::add)
.divide(new BigDecimal(realInAndOutTempParams.size()), 2, BigDecimal.ROUND_HALF_UP);
// 查询回水温度的平均值
BigDecimal avgInTemp = realInAndOutTempParams.stream()
avgInTemp = realInAndOutTempParams.stream()
.filter(param -> param != null
&& param.getOtherName() != null
&& param.getOtherName().contains("回水"))
@ -110,7 +113,7 @@ public class ProOverviewServiceImpl implements IProOverviewService {
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add)
.divide(new BigDecimal(realInAndOutTempParams.size()), 2, BigDecimal.ROUND_HALF_UP);
}
ColumnFilter inTempColumn = new ColumnFilter("回水平均温度", avgInTemp.toString());
ColumnFilter outTempColumn = new ColumnFilter("供水平均温度", avgOutTemp.toString());
DeviceMonitorDTO deviceMonitorDTO2 = new DeviceMonitorDTO();

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

@ -0,0 +1,14 @@
package com.mh.system.service.policy;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 策略管理
* @date 2025-04-01 15:04:53
*/
public interface IPolicyManageService {
List<?> selectPolicyList(String systemType, String funPolicyType);
}

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

@ -0,0 +1,55 @@
package com.mh.system.service.policy.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mh.common.core.domain.dto.DeviceMonitorDTO;
import com.mh.common.core.domain.entity.PolicyManage;
import com.mh.system.mapper.policy.PolicyManageMapper;
import com.mh.system.service.policy.IPolicyManageService;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 策略管理服务实现类
* @date 2025-04-01 15:05:43
*/
@Service
public class PolicyManageServiceImpl implements IPolicyManageService {
private final PolicyManageMapper policyManageMapper;
public PolicyManageServiceImpl(PolicyManageMapper policyManageMapper) {
this.policyManageMapper = policyManageMapper;
}
@Override
public List<?> selectPolicyList(String systemType, String funPolicyType) {
// QueryWrapper<PolicyManage> queryWrapper = new QueryWrapper<>();
// queryWrapper.eq("system_type", systemType);
// queryWrapper.eq("fun_policy_type", funPolicyType);
// queryWrapper.orderByAsc("order_num");
List<PolicyManage> policyManages = policyManageMapper.selectPolicyList(systemType, funPolicyType);
// policyManages使用stream流,根据policyType进行数据分组,
Map<String, List<PolicyManage>> listMap = policyManages.stream()
// 先按PolicyType排序
.sorted(Comparator.comparing(PolicyManage::getPolicyType))
// 再按PolicyName分组
.collect(Collectors.groupingBy(PolicyManage::getPolicyName, Collectors.toList()));
// 在遍历赋值给DeviceMonitorDTO,key给name,value给list
List<DeviceMonitorDTO> list = new ArrayList<>();
listMap.keySet().forEach(k -> {
DeviceMonitorDTO deviceMonitorDTO = new DeviceMonitorDTO();
deviceMonitorDTO.setName(k);
deviceMonitorDTO.setValues(listMap.get(k));
list.add(deviceMonitorDTO);
});
return list;
}
}

28
sql/表结构设计.sql

@ -659,3 +659,31 @@ COMMENT ON COLUMN weather_data.wind_direction IS '风向描述';
COMMENT ON COLUMN weather_data.wind_power IS '风力等级描述';
COMMENT ON COLUMN weather_data.report_time IS '天气数据报告时间,数据来源的原始时间';
COMMENT ON COLUMN weather_data.created_time IS '记录创建时间,系统自动记录';
-- 建表语句
CREATE TABLE policy_manage (
id VARCHAR(36) PRIMARY KEY not NULL,
policy_type VARCHAR(50) NOT NULL,
policy_name VARCHAR(50) NOT NULL,
point_name VARCHAR(100) NOT NULL,
input_type VARCHAR(50) NOT NULL,
unit VARCHAR(20),
cpm_id VARCHAR(36) NOT NULL,
system_type VARCHAR(10) NOT NULL,
fun_policy_type varchar(10) not null,
FOREIGN KEY (cpm_id) REFERENCES collection_params_manage(id)
) WITH (OIDS = FALSE);
-- 添加注释
COMMENT ON TABLE policy_manage IS '策略管理核心表';
COMMENT ON COLUMN policy_manage.policy_type IS '策略类型(枚举值)';
COMMENT ON COLUMN policy_manage.policy_name IS '策略名称';
COMMENT ON COLUMN policy_manage.input_type IS '输入类型:select,text等';
COMMENT ON COLUMN policy_manage.unit IS '单位符号,允许为空表示无单位';
COMMENT ON COLUMN policy_manage.cpm_id IS '采集点位参数id';
COMMENT ON COLUMN policy_manage.system_type IS '项目类型';
COMMENT ON COLUMN policy_manage.fun_policy_type IS '功能策略类型:0 设备策略,1 定时策略';
-- 创建索引
CREATE INDEX idx_binding_param ON policy_manage(cpm_id);
Loading…
Cancel
Save