Browse Source

1、生活热水接口优化;

2、更新采集点不用全局更新;
dev
mh 1 week ago
parent
commit
b5c1250f2b
  1. 6
      mh-admin/src/main/java/com/mh/web/controller/device/OperationController.java
  2. 109
      mh-common/src/main/java/com/mh/common/core/domain/vo/HotWaterControlVO.java
  3. 9
      mh-system/src/main/java/com/mh/system/mapper/device/CollectionParamsManageMapper.java
  4. 92
      mh-system/src/main/java/com/mh/system/service/device/impl/CollectionParamsManageServiceImpl.java

6
mh-admin/src/main/java/com/mh/web/controller/device/OperationController.java

@ -1,15 +1,16 @@
package com.mh.web.controller.device; package com.mh.web.controller.device;
import com.mh.common.annotation.ControlDeviceAno; import com.mh.common.annotation.ControlDeviceAno;
import com.mh.common.annotation.Log;
import com.mh.common.core.controller.BaseController; import com.mh.common.core.controller.BaseController;
import com.mh.common.core.domain.AjaxResult; import com.mh.common.core.domain.AjaxResult;
import com.mh.common.core.domain.dto.DeviceMonitorDTO; import com.mh.common.core.domain.dto.DeviceMonitorDTO;
import com.mh.common.core.domain.entity.OrderEntity; import com.mh.common.core.domain.entity.OrderEntity;
import com.mh.common.core.domain.vo.DeviceOperateMonitorVO; import com.mh.common.core.domain.vo.DeviceOperateMonitorVO;
import com.mh.common.core.page.TableDataInfo; import com.mh.common.core.page.TableDataInfo;
import com.mh.common.enums.BusinessType;
import com.mh.framework.mqtt.service.IMqttGatewayService; import com.mh.framework.mqtt.service.IMqttGatewayService;
import com.mh.system.service.device.ICollectionParamsManageService; import com.mh.system.service.device.ICollectionParamsManageService;
import com.mh.system.service.mqtt.IMqttSubscriptionService;
import com.mh.system.service.operation.IOperationDeviceService; import com.mh.system.service.operation.IOperationDeviceService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -86,13 +87,14 @@ public class OperationController extends BaseController {
*/ */
@PreAuthorize("@ss.hasPermi('device:cpm:operation')") @PreAuthorize("@ss.hasPermi('device:cpm:operation')")
@PostMapping("/operation") @PostMapping("/operation")
@Log(title = "设备指令操作操作", businessType = BusinessType.UPDATE)
@ControlDeviceAno(value = "设备操作") @ControlDeviceAno(value = "设备操作")
public AjaxResult operationDevice(@RequestBody List<OrderEntity> changeValues) { public AjaxResult operationDevice(@RequestBody List<OrderEntity> changeValues) {
try { try {
String sendOrder = iOperationService.operationDevice(changeValues); String sendOrder = iOperationService.operationDevice(changeValues);
// 获取mqtt操作队列(后期通过mqtt队列配置发送主题) // 获取mqtt操作队列(后期通过mqtt队列配置发送主题)
log.info("发送主题:{},消息:{}", controlTopic, sendOrder); log.info("发送主题:{},消息:{}", controlTopic, sendOrder);
iMqttGatewayService.publish(controlTopic, sendOrder, 1); // iMqttGatewayService.publish(controlTopic, sendOrder, 1);
} catch (Exception e) { } catch (Exception e) {
log.error("设备操作失败", e); log.error("设备操作失败", e);
return AjaxResult.error(); return AjaxResult.error();

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

@ -23,27 +23,98 @@ public class HotWaterControlVO {
private String name; private String name;
private String alarmStatus; // 运行状态 1
private int runningStatus;
private String runningStatusId;
private String switchStatus; // 启停控制 2
private int switchStatus;
private String switchStatusId;
// 频率设置 3
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0")
private BigDecimal frequencySet;
private String frequencySetId;
// 频率 4
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0")
private BigDecimal frequency;
private String frequencyId;
// 故障状态 5
private int alarmStatus;
private String alarmStatusId;
// 手动自动切换 6
private int handAutomaticSwitch;
private String handAutomaticSwitchId;
// 开控制 8
private int openSwitch;
private String openSwitchId;
// 关控制 9
private int closeSwitch;
private String closeSwitchId;
// 水位设置 10
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.0")
private BigDecimal waterLevelSet;
private String waterLevelSetId;
// 水位 11
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.0")
private BigDecimal waterLevel;
private String waterLevelId;
// 温度 12
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0")
private BigDecimal temp; private BigDecimal temp;
private String tempId;
// 压力 13
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0")
private BigDecimal pressure;
private String pressureId;
// 温度设置 14
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0")
private BigDecimal tempSet; private BigDecimal tempSet;
private String tempSetId;
// 压力设置 15
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0")
private BigDecimal frequency; private BigDecimal pressureSet;
private String pressureSetId;
// 延时时间设置 34
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0")
private BigDecimal frequencySet; private BigDecimal delayTimeSet;
private String delayTimeSetId;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.0") // 差值设置 35
private BigDecimal waterLevel; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0")
private BigDecimal diffValueSet;
private String diffValueSetId;
// 计数器设置 36
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0")
private BigDecimal counterSet;
private String counterSetId;
// 切换时间设置 37
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0")
private BigDecimal switchTimeSet;
private String switchTimeSetId;
// 故障复位状态 38
private int faultResetStatus;
private String faultResetStatusId;
// 急停状态 39
private int emergencyStopStatus;
private String emergencyStopStatusId;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "0.0")
private BigDecimal waterLevelSet;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date curTime; private Date curTime;
@ -55,14 +126,26 @@ public class HotWaterControlVO {
return new ToStringBuilder(this) return new ToStringBuilder(this)
.append("id", id) .append("id", id)
.append("name", name) .append("name", name)
.append("alarmStatus", alarmStatus) .append("runningStatus", runningStatus)
.append("switchStatus", switchStatus) .append("switchStatus", switchStatus)
.append("temp", temp)
.append("tempSet", tempSet)
.append("frequency", frequency)
.append("frequencySet", frequencySet) .append("frequencySet", frequencySet)
.append("waterLevel", waterLevel) .append("frequency", frequency)
.append("alarmStatus", alarmStatus)
.append("handAutomaticSwitch", handAutomaticSwitch)
.append("openSwitch", openSwitch)
.append("closeSwitch", closeSwitch)
.append("waterLevelSet", waterLevelSet) .append("waterLevelSet", waterLevelSet)
.append("waterLevel", waterLevel)
.append("temp", temp)
.append("pressure", pressure)
.append("tempSet", tempSet)
.append("pressureSet", pressureSet)
.append("delayTimeSet", delayTimeSet)
.append("diffValueSet", diffValueSet)
.append("counterSet", counterSet)
.append("switchTimeSet", switchTimeSet)
.append("faultResetStatus", faultResetStatus)
.append("emergencyStopStatus", emergencyStopStatus)
.append("curTime", curTime) .append("curTime", curTime)
.append("orderNum", orderNum) .append("orderNum", orderNum)
.toString(); .toString();

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

@ -214,8 +214,7 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
"where " + "where " +
" (cpm.param_type = '12' " + " (cpm.param_type = '12' " +
" or cpm.param_type = '13') " + " or cpm.param_type = '13') " +
" and (dl.device_type = '13' " + " and (dl.device_type is null)" +
" or dl.device_type = '14') " +
" and csr.floor_id = #{floorId} " + " and csr.floor_id = #{floorId} " +
" and cpm.system_type = #{systemType}" + " and cpm.system_type = #{systemType}" +
" order by hi.house_name, cpm.param_type ") " order by hi.house_name, cpm.param_type ")
@ -258,7 +257,7 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
" hi.id as house_id, " + " hi.id as house_id, " +
" hi.house_name, " + " hi.house_name, " +
" dl.device_name, " + " dl.device_name, " +
" dl.id as dl_id, " + " COALESCE(dl.id, '0') as dl_id, " +
" cpm.cur_value, " + " cpm.cur_value, " +
" cpm.cur_time, " + " cpm.cur_time, " +
" cpm.param_type, " + " cpm.param_type, " +
@ -275,8 +274,8 @@ public interface CollectionParamsManageMapper extends BaseMapper<CollectionParam
"left join house_info hi on " + "left join house_info hi on " +
" csr.house_id = hi.id " + " csr.house_id = hi.id " +
"where " + "where " +
" (dl.device_type = '10' or dl.device_type = '11' or dl.device_type = '12' ) " + // " (dl.device_type = '10' or dl.device_type = '16' or dl.device_type = '17' ) " +
" and csr.floor_id = #{floorId} " + " csr.floor_id = #{floorId} " +
" and cpm.system_type = #{systemType} " + " and cpm.system_type = #{systemType} " +
" order by dl.order_num ") " order by dl.order_num ")
List<HotWaterControlListVO> selectHotWaterBySystemTypeAndBuildingId(@Param("systemType") String systemType, List<HotWaterControlListVO> selectHotWaterBySystemTypeAndBuildingId(@Param("systemType") String systemType,

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

@ -158,7 +158,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
// 批量更新 // 批量更新
chillersEntities.forEach(chillerEntity -> { chillersEntities.forEach(chillerEntity -> {
log.info("chillerEntity: {}", chillerEntity.toString()); log.info("chillerEntity: {}", chillerEntity.toString());
if (chillerEntity.getId()!= null && !StringUtils.isEmpty(chillerEntity.getId())) { if (chillerEntity.getId() != null && !StringUtils.isEmpty(chillerEntity.getId())) {
collectionParamsManageMapper.updateCurValueById(chillerEntity.getId(), chillerEntity.getCurValue(), chillerEntity.getCurTime()); collectionParamsManageMapper.updateCurValueById(chillerEntity.getId(), chillerEntity.getCurValue(), chillerEntity.getCurTime());
} }
}); });
@ -466,7 +466,7 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
} }
return hotWaterControlListVOS.stream() return hotWaterControlListVOS.stream()
.peek(vo -> System.out.println(vo.getHiOrderNum())) // .peek(vo -> System.out.println(vo.getHiOrderNum()))
.collect(Collectors.groupingBy(HotWaterControlListVO::getHouseId)) .collect(Collectors.groupingBy(HotWaterControlListVO::getHouseId))
.entrySet().stream() .entrySet().stream()
.map(houseEntry -> { .map(houseEntry -> {
@ -482,35 +482,97 @@ public class CollectionParamsManageServiceImpl implements ICollectionParamsManag
HotWaterControlVO vo = new HotWaterControlVO(); HotWaterControlVO vo = new HotWaterControlVO();
List<HotWaterControlListVO> dlItems = dlEntry.getValue(); List<HotWaterControlListVO> dlItems = dlEntry.getValue();
vo.setId(dlEntry.getKey()); vo.setId(dlEntry.getKey());
vo.setName(dlItems.getFirst().getDeviceName()); if (StringUtils.isEmpty(dlItems.getFirst().getDeviceName())) {
// 如果设备名称为空,则使用房间号
vo.setName(dto.getName());
} else {
vo.setName(dlItems.getFirst().getDeviceName());
}
vo.setOrderNum(dlItems.getFirst().getDlOrderNum()); vo.setOrderNum(dlItems.getFirst().getDlOrderNum());
dlItems.forEach(item -> { dlItems.forEach(item -> {
switch (item.getParamType()) { switch (item.getParamType()) {
case "1":
// 运行状态
vo.setRunningStatus(item.getCurValue().intValue());
vo.setRunningStatusId(item.getCpmId());
break;
case "2": case "2":
vo.setSwitchStatus(String.valueOf(item.getCurValue())); vo.setSwitchStatus(item.getCurValue().intValue());
vo.setSwitchStatusId(item.getCpmId());
break;
case "3":
vo.setFrequencySet(item.getCurValue());
vo.setFrequencySetId(item.getCpmId());
break;
case "4":
vo.setFrequency(item.getCurValue());
vo.setFrequencyId(item.getCpmId());
break; break;
case "5": case "5":
vo.setAlarmStatus(String.valueOf(item.getCurValue())); vo.setAlarmStatus(item.getCurValue().intValue());
vo.setAlarmStatusId(item.getCpmId());
break; break;
case "14": case "6":
vo.setTempSet(item.getCurValue()); vo.setHandAutomaticSwitch(item.getCurValue().intValue());
vo.setHandAutomaticSwitchId(item.getCpmId());
break; break;
case "12": case "8":
vo.setTemp(item.getCurValue()); vo.setOpenSwitch(item.getCurValue().intValue());
vo.setOpenSwitchId(item.getCpmId());
break; break;
case "4": case "9":
vo.setFrequency(item.getCurValue()); vo.setCloseSwitch(item.getCurValue().intValue());
vo.setCloseSwitchId(item.getCpmId());
break; break;
case "3": case "10":
vo.setFrequencySet(item.getCurValue()); vo.setWaterLevelSet(item.getCurValue());
vo.setWaterLevelSetId(item.getCpmId());
break; break;
case "11": case "11":
vo.setWaterLevel(item.getCurValue()); vo.setWaterLevel(item.getCurValue());
vo.setCurTime(item.getCurTime()); vo.setCurTime(item.getCurTime());
vo.setWaterLevelId(item.getCpmId());
break; break;
case "10": case "12":
vo.setWaterLevelSet(item.getCurValue()); vo.setTemp(item.getCurValue());
vo.setTempId(item.getCpmId());
break;
case "13":
vo.setPressure(item.getCurValue());
vo.setPressureId(item.getCpmId());
break;
case "14":
vo.setTempSet(item.getCurValue());
vo.setTempSetId(item.getCpmId());
break;
case "15":
vo.setPressureSet(item.getCurValue());
vo.setPressureSetId(item.getCpmId());
break;
case "34":
vo.setDelayTimeSet(item.getCurValue());
vo.setDelayTimeSetId(item.getCpmId());
break;
case "35":
vo.setDiffValueSet(item.getCurValue());
vo.setDiffValueSetId(item.getCpmId());
break;
case "36":
vo.setCounterSet(item.getCurValue());
vo.setCounterSetId(item.getCpmId());
break;
case "37":
vo.setSwitchTimeSet(item.getCurValue());
vo.setSwitchTimeSetId(item.getCpmId());
break;
case "38":
vo.setFaultResetStatus(item.getCurValue().intValue());
vo.setFaultResetStatusId(item.getCpmId());
break;
case "39":
vo.setEmergencyStopStatus(item.getCurValue().intValue());
vo.setEmergencyStopStatusId(item.getCpmId());
break; break;
default: default:
// 处理未识别的paramType或忽略 // 处理未识别的paramType或忽略

Loading…
Cancel
Save