feat: 设备管理-系统设备概况
This commit is contained in:
@@ -9,6 +9,7 @@ import com.jero.common.api.vo.Results;
|
|||||||
import com.jero.modules.entity.KhDevice;
|
import com.jero.modules.entity.KhDevice;
|
||||||
import com.jero.modules.service.IKhDeviceService;
|
import com.jero.modules.service.IKhDeviceService;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.jero.modules.vo.DeviceStatisticsVO;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.jero.common.system.base.controller.JeroController;
|
import com.jero.common.system.base.controller.JeroController;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -56,6 +57,18 @@ public class KhDeviceController extends JeroController<KhDevice, IKhDeviceServic
|
|||||||
return Results.OK(pageList);
|
return Results.OK(pageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统设备概况
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@AutoLog(value = "设备-系统设备概况")
|
||||||
|
@ApiOperation(value="设备-系统设备概况", notes="设备-系统设备概况")
|
||||||
|
@GetMapping(value = "/statistics")
|
||||||
|
public Results<DeviceStatisticsVO> statistics() {
|
||||||
|
return Results.OK(khDeviceService.statistics());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表查询
|
* 列表查询
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.jero.modules.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description
|
||||||
|
* @date 2022/1/21 15:22
|
||||||
|
* @auth zhn
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum DeviceTypeEnum {
|
||||||
|
|
||||||
|
RTU("RTU控制器","1"),
|
||||||
|
NG("天然气数据远传终端","2");
|
||||||
|
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
final String value;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.jero.modules.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description
|
||||||
|
* @date 2022/1/21 15:22
|
||||||
|
* @auth zhn
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum WellTypeEnum {
|
||||||
|
|
||||||
|
OIL("油井","1"),
|
||||||
|
WATER("水井","2");
|
||||||
|
|
||||||
|
|
||||||
|
final String name;
|
||||||
|
final String value;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ import com.jero.modules.entity.KhDevice;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.jero.modules.vo.DeviceStatisticsVO;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,4 +75,10 @@ public interface IKhDeviceService extends IService<KhDevice> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
KhDevice queryById(String id);
|
KhDevice queryById(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统设备概况
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
DeviceStatisticsVO statistics();
|
||||||
}
|
}
|
||||||
|
|||||||
+37
@@ -3,16 +3,25 @@ package com.jero.modules.service.impl;
|
|||||||
import cn.hutool.core.util.RandomUtil;
|
import cn.hutool.core.util.RandomUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.jero.modules.entity.KhDevice;
|
import com.jero.modules.entity.KhDevice;
|
||||||
|
import com.jero.modules.entity.KhWellhead;
|
||||||
|
import com.jero.modules.enums.DeviceTypeEnum;
|
||||||
|
import com.jero.modules.enums.WellTypeEnum;
|
||||||
import com.jero.modules.enums.YesOrNoEnum;
|
import com.jero.modules.enums.YesOrNoEnum;
|
||||||
import com.jero.modules.mapper.KhDeviceMapper;
|
import com.jero.modules.mapper.KhDeviceMapper;
|
||||||
import com.jero.modules.service.IKhDeviceService;
|
import com.jero.modules.service.IKhDeviceService;
|
||||||
|
import com.jero.modules.service.IKhWellheadService;
|
||||||
|
import com.jero.modules.vo.DeviceStatisticsVO;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.jero.common.exception.JeroBootException;
|
import com.jero.common.exception.JeroBootException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.jero.common.system.query.QueryGenerator;
|
import com.jero.common.system.query.QueryGenerator;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
@@ -28,6 +37,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
@Transactional(rollbackFor = JeroBootException.class)
|
@Transactional(rollbackFor = JeroBootException.class)
|
||||||
public class KhDeviceServiceImpl extends ServiceImpl<KhDeviceMapper, KhDevice> implements IKhDeviceService {
|
public class KhDeviceServiceImpl extends ServiceImpl<KhDeviceMapper, KhDevice> implements IKhDeviceService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IKhWellheadService wellheadService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
@@ -122,4 +133,30 @@ public class KhDeviceServiceImpl extends ServiceImpl<KhDeviceMapper, KhDevice> i
|
|||||||
public KhDevice queryById(String id) {
|
public KhDevice queryById(String id) {
|
||||||
return getById(id);
|
return getById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DeviceStatisticsVO statistics() {
|
||||||
|
DeviceStatisticsVO vo = new DeviceStatisticsVO();
|
||||||
|
List<KhWellhead> wellList = wellheadService.list();
|
||||||
|
List<KhDevice> deviceList = list();
|
||||||
|
vo.setDeviceCount(deviceList.size())
|
||||||
|
.setOnlineDeviceCount((int) deviceList.stream().filter(d -> d.getDeviceStatus().equals(YesOrNoEnum.YES.getValue())).count())
|
||||||
|
.setOfflineDeviceCount((int) deviceList.stream().filter(d -> d.getDeviceStatus().equals(YesOrNoEnum.NO.getValue())).count());
|
||||||
|
|
||||||
|
vo.setWellCount(wellList.size())
|
||||||
|
.setWaterWellCount((int) wellList.stream().filter(d -> d.getWellheadType().equals(WellTypeEnum.WATER.getValue())).count())
|
||||||
|
.setOilWellCount((int) wellList.stream().filter(d -> d.getWellheadType().equals(WellTypeEnum.OIL.getValue())).count());
|
||||||
|
|
||||||
|
List<KhDevice> rtuDeviceList = deviceList.stream().filter(d -> d.getDeviceType().equals(DeviceTypeEnum.RTU.getValue())).collect(Collectors.toList());
|
||||||
|
List<KhDevice> ngDeviceList = deviceList.stream().filter(d -> d.getDeviceType().equals(DeviceTypeEnum.NG.getValue())).collect(Collectors.toList());
|
||||||
|
|
||||||
|
vo.setRtuCount(rtuDeviceList.size())
|
||||||
|
.setOnlineRtuCount((int) rtuDeviceList.stream().filter(d -> d.getDeviceStatus().equals(YesOrNoEnum.YES.getValue())).count())
|
||||||
|
.setOfflineRtuCount((int) rtuDeviceList.stream().filter(d -> d.getDeviceStatus().equals(YesOrNoEnum.NO.getValue())).count());
|
||||||
|
|
||||||
|
vo.setNgCount(ngDeviceList.size())
|
||||||
|
.setOnlineNgCount((int) rtuDeviceList.stream().filter(d -> d.getDeviceStatus().equals(YesOrNoEnum.YES.getValue())).count())
|
||||||
|
.setOfflineNgCount((int) rtuDeviceList.stream().filter(d -> d.getDeviceStatus().equals(YesOrNoEnum.NO.getValue())).count());
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.jero.modules.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author: Mzaxd
|
||||||
|
* @Date: 2024/4/2 10:15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class DeviceStatisticsVO {
|
||||||
|
|
||||||
|
// 设备总数
|
||||||
|
@ApiModelProperty(value = "设备总数")
|
||||||
|
private int deviceCount;
|
||||||
|
// 在线
|
||||||
|
@ApiModelProperty(value = "在线")
|
||||||
|
private int onlineDeviceCount;
|
||||||
|
// 离线
|
||||||
|
@ApiModelProperty(value = "离线")
|
||||||
|
private int offlineDeviceCount;
|
||||||
|
// 总井数量
|
||||||
|
@ApiModelProperty(value = "总井数量")
|
||||||
|
private int wellCount;
|
||||||
|
// 水井数量
|
||||||
|
@ApiModelProperty(value = "水井数量")
|
||||||
|
private int waterWellCount;
|
||||||
|
// 油井数量
|
||||||
|
@ApiModelProperty(value = "油井数量")
|
||||||
|
private int oilWellCount;
|
||||||
|
// RTU控制器数量
|
||||||
|
@ApiModelProperty(value = "RTU控制器数量")
|
||||||
|
private int rtuCount;
|
||||||
|
// 在线RTU控制器数量
|
||||||
|
@ApiModelProperty(value = "在线RTU控制器数量")
|
||||||
|
private int onlineRtuCount;
|
||||||
|
// 离线RTU控制器数量
|
||||||
|
@ApiModelProperty(value = "离线RTU控制器数量")
|
||||||
|
private int offlineRtuCount;
|
||||||
|
// 天然气数据远传终端数量
|
||||||
|
@ApiModelProperty(value = "天然气数据远传终端数量")
|
||||||
|
private int ngCount;
|
||||||
|
// 在线天然气数据远传终端数量
|
||||||
|
@ApiModelProperty(value = "在线天然气数据远传终端数量")
|
||||||
|
private int onlineNgCount;
|
||||||
|
// 离线天然气数据远传终端数量
|
||||||
|
@ApiModelProperty(value = "离线天然气数据远传终端数量")
|
||||||
|
private int offlineNgCount;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user