Browse Source

1、生活热水供水系统获取设备状态信息数据

dev_mz
25604 2 weeks ago
parent
commit
dcc9307d54
  1. 20
      mh-admin/src/main/java/com/mh/web/controller/monitor/HotWaterMonitorController.java
  2. 81
      mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceState.java
  3. 40
      mh-quartz/src/main/java/com/mh/quartz/task/HotWaterTask.java
  4. 8
      mh-system/src/main/java/com/mh/system/mapper/device/DeviceLedgerMapper.java
  5. 22
      mh-system/src/main/java/com/mh/system/mapper/device/DeviceStateMapper.java
  6. 5
      mh-system/src/main/java/com/mh/system/service/device/IDeviceLedgerService.java
  7. 20
      mh-system/src/main/java/com/mh/system/service/device/impl/DeviceLedgerServiceImpl.java

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

@ -1,14 +1,15 @@
package com.mh.web.controller.monitor; package com.mh.web.controller.monitor;
import com.mh.common.core.controller.BaseController; import com.mh.common.core.controller.BaseController;
import com.mh.common.core.domain.ColumnData;
import com.mh.common.core.domain.ColumnFilter; import com.mh.common.core.domain.ColumnFilter;
import com.mh.common.core.domain.entity.DeviceState;
import com.mh.common.core.domain.dto.HotWaterControlDTO; import com.mh.common.core.domain.dto.HotWaterControlDTO;
import com.mh.common.core.domain.dto.HotWaterNowDataDTO; import com.mh.common.core.domain.dto.HotWaterNowDataDTO;
import com.mh.common.core.domain.dto.PumpInfoDTO; import com.mh.common.core.domain.dto.PumpInfoDTO;
import com.mh.common.core.domain.entity.ChillersEntity; import com.mh.common.core.domain.entity.ChillersEntity;
import com.mh.common.core.page.TableDataInfo; import com.mh.common.core.page.TableDataInfo;
import com.mh.system.service.device.ICollectionParamsManageService; import com.mh.system.service.device.ICollectionParamsManageService;
import com.mh.system.service.device.IDeviceLedgerService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -30,9 +31,12 @@ public class HotWaterMonitorController extends BaseController {
private final ICollectionParamsManageService iCollectionParamsManageService; private final ICollectionParamsManageService iCollectionParamsManageService;
private final IDeviceLedgerService deviceLedgerService;
@Autowired @Autowired
public HotWaterMonitorController(ICollectionParamsManageService iCollectionParamsManageService) { public HotWaterMonitorController(ICollectionParamsManageService iCollectionParamsManageService, IDeviceLedgerService deviceLedgerService) {
this.iCollectionParamsManageService = iCollectionParamsManageService; this.iCollectionParamsManageService = iCollectionParamsManageService;
this.deviceLedgerService = deviceLedgerService;
} }
/** /**
@ -89,4 +93,16 @@ public class HotWaterMonitorController extends BaseController {
return getDataTable(list); return getDataTable(list);
} }
/**
* 获取设备状态信息数据
* @param systemType
* @return
*/
@GetMapping("/deviceState")
public TableDataInfo deviceState(@RequestParam("systemType") String systemType) {
startPage();
List<DeviceState> list = deviceLedgerService.deviceState(systemType);
return getDataTable(list);
}
} }

81
mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceState.java

@ -0,0 +1,81 @@
package com.mh.common.core.domain.entity;
import lombok.Data;
import java.util.Date;
/**
* @author LJF
* @version 1.0
* @date 2025-02-14 09:30:47
* @description 设备统计状态表
*/
@Data
public class DeviceState {
/**
* 当前时间
*/
private Date curDate;
/**
* 设备数目
*/
private int deviceNum;
/**
* 电表数目
*/
private int electNum;
/**
* 水表数目
*/
private int waterNum;
/**
* 泵数目
*/
private int pumpNum;
/**
* 压力表数目
*/
private int pressureNum;
/**
* 在线设备数目
*/
private int onlineNum;
/**
* 离线设备数目
*/
private int offlineNum;
/**
* 故障设备数目
*/
private int faultNum;
/**
* 上次故障数目
*/
private int lastFaultNum;
/**
* 故障环比
*/
private String faultP;
/**
* 热泵正在运行的数目
*/
private int pumpOnline;
/**
* 其他设备数目
*/
private int otherNum;
}

40
mh-quartz/src/main/java/com/mh/quartz/task/HotWaterTask.java

@ -0,0 +1,40 @@
package com.mh.quartz.task;
import com.mh.system.service.device.IDeviceLedgerService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 生活热水供水系统定时器
* @date 2025-06-17 16:12:04
*/
@Slf4j
@Component("hotWaterTask")
public class HotWaterTask {
@Resource
private IDeviceLedgerService deviceLedgerService;
private boolean createOrUpdateDeviceState = false;
/**
* 新增或者更新设备状态表
*/
public void createOrUpdateDeviceState() {
try {
if (!createOrUpdateDeviceState) {
createOrUpdateDeviceState = true;
deviceLedgerService.createOrUpdateDeviceState();
}
} catch (Exception e) {
log.error("新增或者更新设备状态表失败", e);
createOrUpdateDeviceState = false;
} finally {
createOrUpdateDeviceState = false;
}
}
}

8
mh-system/src/main/java/com/mh/system/mapper/device/DeviceLedgerMapper.java

@ -2,10 +2,14 @@ package com.mh.system.mapper.device;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.common.core.domain.entity.DeviceLedger; import com.mh.common.core.domain.entity.DeviceLedger;
import com.mh.common.core.domain.entity.DeviceState;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import java.util.List;
/** /**
* @author LJF * @author LJF
* @version 1.0 * @version 1.0
@ -21,4 +25,8 @@ public interface DeviceLedgerMapper extends BaseMapper<DeviceLedger> {
@Update("update device_ledger set status = #{status}, update_time = current_timestamp where id = #{id}") @Update("update device_ledger set status = #{status}, update_time = current_timestamp where id = #{id}")
void updateOnlineOrOfflineStatus(@Param("id") String deviceLedgerId, @Param("status") int integer); void updateOnlineOrOfflineStatus(@Param("id") String deviceLedgerId, @Param("status") int integer);
@Select("SELECT pro_device_state(#{curDate})")
void createOrUpdateDeviceState(@Param("curDate") String curDate);
} }

22
mh-system/src/main/java/com/mh/system/mapper/device/DeviceStateMapper.java

@ -0,0 +1,22 @@
package com.mh.system.mapper.device;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mh.common.core.domain.entity.DeviceState;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* @author LJF
* @version 1.0
* @project EEMCS
* @description 设备状态mapper类
* @date 2025-06-17 17:40:14
*/
@Mapper
public interface DeviceStateMapper extends BaseMapper<DeviceState> {
@Select("select * from device_state where system_type = #{systemType} and date(cur_date) = date(curdate()) limit 1")
List<DeviceState> deviceState(String systemType);
}

5
mh-system/src/main/java/com/mh/system/service/device/IDeviceLedgerService.java

@ -1,5 +1,6 @@
package com.mh.system.service.device; package com.mh.system.service.device;
import com.mh.common.core.domain.entity.DeviceState;
import com.mh.common.core.domain.entity.DeviceLedger; import com.mh.common.core.domain.entity.DeviceLedger;
import java.util.List; import java.util.List;
@ -23,4 +24,8 @@ public interface IDeviceLedgerService {
int deleteDeviceLedgerByIds(String[] ledgerIds); int deleteDeviceLedgerByIds(String[] ledgerIds);
void updateDeviceLedgerStatus(); void updateDeviceLedgerStatus();
List<DeviceState> deviceState(String systemType);
void createOrUpdateDeviceState();
} }

20
mh-system/src/main/java/com/mh/system/service/device/impl/DeviceLedgerServiceImpl.java

@ -1,11 +1,12 @@
package com.mh.system.service.device.impl; package com.mh.system.service.device.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mh.common.core.domain.entity.CollectionParamsManage; import com.mh.common.core.domain.entity.DeviceState;
import com.mh.common.core.domain.entity.DeviceLedger; import com.mh.common.core.domain.entity.DeviceLedger;
import com.mh.common.utils.StringUtils; import com.mh.common.utils.StringUtils;
import com.mh.system.mapper.device.CollectionParamsManageMapper; import com.mh.system.mapper.device.CollectionParamsManageMapper;
import com.mh.system.mapper.device.DeviceLedgerMapper; import com.mh.system.mapper.device.DeviceLedgerMapper;
import com.mh.system.mapper.device.DeviceStateMapper;
import com.mh.system.service.device.IDeviceLedgerService; import com.mh.system.service.device.IDeviceLedgerService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -27,9 +28,26 @@ public class DeviceLedgerServiceImpl implements IDeviceLedgerService {
@Resource @Resource
private DeviceLedgerMapper deviceLedgerMapper; private DeviceLedgerMapper deviceLedgerMapper;
@Resource
private DeviceStateMapper deviceStateMapper;
@Resource @Resource
private CollectionParamsManageMapper collectionParamsManageMapper; private CollectionParamsManageMapper collectionParamsManageMapper;
@Override
public List<DeviceState> deviceState(String systemType) {
if (StringUtils.isEmpty(systemType)) {
return List.of();
}
return deviceStateMapper.deviceState(systemType);
}
@Override
public void createOrUpdateDeviceState() {
String currentDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
deviceLedgerMapper.createOrUpdateDeviceState(currentDate);
}
@Override @Override
public void updateDeviceLedgerStatus() { public void updateDeviceLedgerStatus() {
// 先从采集点为中查询,看看当天是否有数据上来 // 先从采集点为中查询,看看当天是否有数据上来

Loading…
Cancel
Save