增加统计接口
This commit is contained in:
parent
65c40fab6f
commit
d82ac864bd
|
@ -57,7 +57,11 @@ public class DeviceController {
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
@OperationLog(description = "新增设备", type = LogType.ADD)
|
@OperationLog(description = "新增设备", type = LogType.ADD)
|
||||||
public Response<String> add(@RequestBody @Valid DeviceCreateDTO deviceCreateDTO) {
|
public Response<String> add(@RequestBody @Valid DeviceCreateDTO deviceCreateDTO) {
|
||||||
|
try {
|
||||||
deviceService.add(deviceCreateDTO);
|
deviceService.add(deviceCreateDTO);
|
||||||
|
}catch (NumberFormatException e){
|
||||||
|
throw new BusinessException("设备编号只能为纯数字格式");
|
||||||
|
}
|
||||||
return Response.succeed();
|
return Response.succeed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,15 +93,6 @@ public class DeviceController {
|
||||||
return Response.succeed(deviceService.getDeviceControlData(deviceId));
|
return Response.succeed(deviceService.getDeviceControlData(deviceId));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存设备控制数据
|
|
||||||
*/
|
|
||||||
@PostMapping("/saveDeviceControlData")
|
|
||||||
public Response<String> saveDeviceControlData(@RequestBody Map<String,String> controlData,@RequestParam Long deviceId) {
|
|
||||||
deviceService.saveDeviceControlData(controlData,deviceId);
|
|
||||||
return Response.succeed();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取设备历史数据
|
* 获取设备历史数据
|
||||||
*/
|
*/
|
||||||
|
@ -130,17 +125,6 @@ public class DeviceController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 控制开/关井
|
|
||||||
*
|
|
||||||
* @Param isOpen 1 开井 0 关井
|
|
||||||
* @Param deviceId 设备id
|
|
||||||
*/
|
|
||||||
@GetMapping("/wellCtl")
|
|
||||||
public Response<String> wellCtl(@RequestParam Integer isOpen, @RequestParam Long deviceId) {
|
|
||||||
deviceService.wellCtl(isOpen,deviceId);
|
|
||||||
return Response.succeed();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,17 +1,9 @@
|
||||||
package com.isu.gaswellwatch.controller;
|
package com.isu.gaswellwatch.controller;
|
||||||
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import com.isu.gaswellwatch.annotation.OperationLog;
|
|
||||||
import com.isu.gaswellwatch.dto.DepartmentDTO;
|
|
||||||
import com.isu.gaswellwatch.dto.DepartmentEditDTO;
|
|
||||||
import com.isu.gaswellwatch.entity.Department;
|
|
||||||
import com.isu.gaswellwatch.entity.Dictionary;
|
import com.isu.gaswellwatch.entity.Dictionary;
|
||||||
import com.isu.gaswellwatch.entity.Response;
|
import com.isu.gaswellwatch.entity.Response;
|
||||||
import com.isu.gaswellwatch.enums.LogType;
|
|
||||||
import com.isu.gaswellwatch.service.DepartmentService;
|
|
||||||
import com.isu.gaswellwatch.service.DictionaryService;
|
import com.isu.gaswellwatch.service.DictionaryService;
|
||||||
import com.isu.gaswellwatch.vo.DepartmentVO;
|
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.isu.gaswellwatch.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.annotation.OperationLog;
|
||||||
|
import com.isu.gaswellwatch.dto.LoginDTO;
|
||||||
|
import com.isu.gaswellwatch.entity.Response;
|
||||||
|
import com.isu.gaswellwatch.enums.LogType;
|
||||||
|
import com.isu.gaswellwatch.service.SummaryService;
|
||||||
|
import com.isu.gaswellwatch.vo.UserLoginInfoVO;
|
||||||
|
import com.isu.gaswellwatch.vo.summary.PieSummaryVO;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("summary")
|
||||||
|
public class SummaryController {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SummaryService summaryService;
|
||||||
|
|
||||||
|
@GetMapping("/getIndexPieSummary")
|
||||||
|
public Response<List<PieSummaryVO>> getIndexPieSummary(){
|
||||||
|
return Response.succeed(summaryService.getIndexPieSummary());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
@Repository
|
@Repository
|
||||||
|
@ -34,5 +35,7 @@ public interface DeviceDao extends BaseMapper<Device> {
|
||||||
@Param("startTime")Date startTime,
|
@Param("startTime")Date startTime,
|
||||||
@Param("endTime")Date endTime,
|
@Param("endTime")Date endTime,
|
||||||
@Param("deviceId") Long deviceId);
|
@Param("deviceId") Long deviceId);
|
||||||
|
|
||||||
|
List<DeviceVO> getDeviceVOByIds(@Param("idList")List<Long> deviceIdList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@ import com.isu.gaswellwatch.dao.DeviceDao;
|
||||||
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
import com.isu.gaswellwatch.dto.modbus.ModbusCommandDto;
|
||||||
import com.isu.gaswellwatch.entity.Response;
|
import com.isu.gaswellwatch.entity.Response;
|
||||||
import com.isu.gaswellwatch.modbus.CommandService;
|
import com.isu.gaswellwatch.modbus.CommandService;
|
||||||
|
import com.isu.gaswellwatch.service.DeviceOptLogService;
|
||||||
import com.isu.gaswellwatch.vo.command.Command;
|
import com.isu.gaswellwatch.vo.command.Command;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
@ -28,10 +30,22 @@ public class CommandServiceImpl implements CommandService {
|
||||||
|
|
||||||
private final DeviceDao deviceDao;
|
private final DeviceDao deviceDao;
|
||||||
private final RestTemplate restTemplate = new RestTemplate();
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
|
@Resource
|
||||||
|
private DeviceOptLogService deviceOptLogService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Response<String> control(Command command) {
|
public Response<String> control(Command command) {
|
||||||
return this.sendCommand("control", command);
|
Response<String> result = this.sendCommand("control", command);
|
||||||
|
|
||||||
|
//记录用户保存控制指令日志
|
||||||
|
Integer flag = null;
|
||||||
|
if(Command.KNPCV1_TURN_ON_THE_WELL.equals(command.getCode())){
|
||||||
|
flag = 1;
|
||||||
|
}else if(Command.KNPCV1_TURN_OFF_THE_WELL.equals(command.getCode())){
|
||||||
|
flag = 0;
|
||||||
|
};
|
||||||
|
deviceOptLogService.saveGasWellOptLog(flag,command.getDeviceId());
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,6 +10,7 @@ import com.isu.gaswellwatch.vo.DeviceHistoryVO;
|
||||||
import com.isu.gaswellwatch.vo.DeviceVO;
|
import com.isu.gaswellwatch.vo.DeviceVO;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public interface DeviceService extends IService<Device> {
|
public interface DeviceService extends IService<Device> {
|
||||||
|
@ -26,12 +27,10 @@ public interface DeviceService extends IService<Device> {
|
||||||
|
|
||||||
Map<String,String> getDeviceControlData(Long deviceId);
|
Map<String,String> getDeviceControlData(Long deviceId);
|
||||||
|
|
||||||
void saveDeviceControlData(Map<String, String> controlData, Long deviceId);
|
|
||||||
|
|
||||||
Page<DeviceHistoryVO> getDeviceHistoryData(Integer currentPage, Integer pageSize, String startTime, String endTime, Long deviceId) throws ParseException;
|
Page<DeviceHistoryVO> getDeviceHistoryData(Integer currentPage, Integer pageSize, String startTime, String endTime, Long deviceId) throws ParseException;
|
||||||
|
|
||||||
void wellCtl(Integer isOpen, Long deviceId);
|
|
||||||
|
|
||||||
Page<DeviceOptLog> getDeviceLogData(Integer currentPage, Integer pageSize, String startTime, String endTime, Long deviceId) throws ParseException;
|
Page<DeviceOptLog> getDeviceLogData(Integer currentPage, Integer pageSize, String startTime, String endTime, Long deviceId) throws ParseException;
|
||||||
|
|
||||||
|
List<DeviceVO> getDeviceVOByIds(List<Long> deviceIdList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.isu.gaswellwatch.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.vo.summary.PieSummaryVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface SummaryService{
|
||||||
|
|
||||||
|
List<PieSummaryVO> getIndexPieSummary();
|
||||||
|
}
|
||||||
|
|
|
@ -12,12 +12,14 @@ import com.isu.gaswellwatch.entity.*;
|
||||||
import com.isu.gaswellwatch.exception.BusinessException;
|
import com.isu.gaswellwatch.exception.BusinessException;
|
||||||
import com.isu.gaswellwatch.modbus.data.PersistenceHandler;
|
import com.isu.gaswellwatch.modbus.data.PersistenceHandler;
|
||||||
import com.isu.gaswellwatch.modbus.data.Redis2DBPersistenceService;
|
import com.isu.gaswellwatch.modbus.data.Redis2DBPersistenceService;
|
||||||
|
import com.isu.gaswellwatch.modbus.data.listener.DynamicRabbitListener;
|
||||||
import com.isu.gaswellwatch.service.*;
|
import com.isu.gaswellwatch.service.*;
|
||||||
import com.isu.gaswellwatch.utils.ConverterUtil;
|
import com.isu.gaswellwatch.utils.ConverterUtil;
|
||||||
import com.isu.gaswellwatch.vo.DeviceHistoryVO;
|
import com.isu.gaswellwatch.vo.DeviceHistoryVO;
|
||||||
import com.isu.gaswellwatch.vo.DeviceVO;
|
import com.isu.gaswellwatch.vo.DeviceVO;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.data.redis.RedisConnectionFailureException;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -47,6 +49,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
||||||
private DictionaryService dictionaryService;
|
private DictionaryService dictionaryService;
|
||||||
@Resource
|
@Resource
|
||||||
private DeviceOptLogService deviceOptLogService;
|
private DeviceOptLogService deviceOptLogService;
|
||||||
|
@Resource
|
||||||
|
private DynamicRabbitListener dynamicRabbitListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName,Long deviceTypeId){
|
public Page<DeviceVO> page(Integer currentPage, Integer pageSize, String gasWellName, String gasStationName,Long deviceTypeId){
|
||||||
|
@ -57,6 +61,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
||||||
Map<String, Dictionary> runModeMap = dictionaryService.getValueMapByType("runMode");
|
Map<String, Dictionary> runModeMap = dictionaryService.getValueMapByType("runMode");
|
||||||
Map<String, Dictionary> plugStatusMap = dictionaryService.getValueMapByType("plugStatus");
|
Map<String, Dictionary> plugStatusMap = dictionaryService.getValueMapByType("plugStatus");
|
||||||
|
|
||||||
|
try {
|
||||||
for (DeviceVO deviceVO : deviceVOList) {
|
for (DeviceVO deviceVO : deviceVOList) {
|
||||||
String deviceKey = PersistenceHandler.DEVICE_DATA_CACHE + deviceVO.getId();
|
String deviceKey = PersistenceHandler.DEVICE_DATA_CACHE + deviceVO.getId();
|
||||||
Object casPressure = redisTemplate.opsForHash().get(deviceKey, "casPressure");
|
Object casPressure = redisTemplate.opsForHash().get(deviceKey, "casPressure");
|
||||||
|
@ -90,12 +95,16 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}catch (RedisConnectionFailureException e){
|
||||||
|
log.error("redis连接失败,请检查redis连接");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return ConverterUtil.convertPage(page, DeviceVO.class);
|
return ConverterUtil.convertPage(page, DeviceVO.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(DeviceCreateDTO deviceCreateDTO){
|
public void add(DeviceCreateDTO deviceCreateDTO) throws NumberFormatException{
|
||||||
//查重
|
//查重
|
||||||
List<Device> list = list(new LambdaQueryWrapper<Device>().eq(Device::getId, deviceCreateDTO.getCode()));
|
List<Device> list = list(new LambdaQueryWrapper<Device>().eq(Device::getId, deviceCreateDTO.getCode()));
|
||||||
if(CollectionUtil.isNotEmpty(list)) {
|
if(CollectionUtil.isNotEmpty(list)) {
|
||||||
|
@ -117,6 +126,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
||||||
|
|
||||||
//在气井中绑定设备
|
//在气井中绑定设备
|
||||||
gasWellService.bindDevice(deviceCreateDTO.getGasWell(),device.getId());
|
gasWellService.bindDevice(deviceCreateDTO.getGasWell(),device.getId());
|
||||||
|
|
||||||
|
//创建该设备在mq中的事件队列
|
||||||
|
dynamicRabbitListener.registerDeviceAndListener(device.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -126,10 +138,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(Long id){
|
public void delete(Long id){
|
||||||
|
Long gasWellId = getDevice(id).getGasWell().getId();
|
||||||
//删除设备
|
//删除设备
|
||||||
removeById(id);
|
removeById(id);
|
||||||
//解绑气井
|
//解绑气井
|
||||||
gasWellService.unbindDevice(id);
|
gasWellService.unbindDevice(gasWellId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -157,15 +170,11 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveDeviceControlData(Map<String, String> controlData, Long deviceId) {
|
public List<DeviceVO> getDeviceVOByIds(List<Long> deviceIdList) {
|
||||||
|
return deviceDao.getDeviceVOByIds(deviceIdList);
|
||||||
//TODO 等待封装控制指令
|
|
||||||
|
|
||||||
|
|
||||||
//记录用户保存控制指令日志
|
|
||||||
deviceOptLogService.saveGasWellOptLog(null,deviceId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Page<DeviceHistoryVO> getDeviceHistoryData(Integer currentPage, Integer pageSize, String startTime, String endTime, Long deviceId) throws ParseException {
|
public Page<DeviceHistoryVO> getDeviceHistoryData(Integer currentPage, Integer pageSize, String startTime, String endTime, Long deviceId) throws ParseException {
|
||||||
Date start = null;
|
Date start = null;
|
||||||
|
@ -192,14 +201,6 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceDao, Device> implements
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void wellCtl(Integer isOpen, Long deviceId) {
|
|
||||||
//TODO 待封装控制指令
|
|
||||||
|
|
||||||
|
|
||||||
//记录用户操作开关井日志
|
|
||||||
deviceOptLogService.saveGasWellOptLog(isOpen,deviceId);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,109 @@
|
||||||
|
package com.isu.gaswellwatch.service.impl;
|
||||||
|
|
||||||
|
import com.isu.gaswellwatch.service.DeviceService;
|
||||||
|
import com.isu.gaswellwatch.service.SummaryService;
|
||||||
|
import com.isu.gaswellwatch.vo.DeviceVO;
|
||||||
|
import com.isu.gaswellwatch.vo.summary.PieDataVO;
|
||||||
|
import com.isu.gaswellwatch.vo.summary.PieSummaryVO;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static com.isu.gaswellwatch.modbus.data.PersistenceHandler.*;
|
||||||
|
|
||||||
|
@Service("summaryService")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public class SummaryServiceImpl implements SummaryService {
|
||||||
|
|
||||||
|
@Resource(name = "stringRedisTemplate")
|
||||||
|
private RedisTemplate redisTemplate;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DeviceService deviceService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<PieSummaryVO> getIndexPieSummary() {
|
||||||
|
// Map<String,String> onlineMap = redisTemplate.opsForHash().entries(ONLINE_DEVICE_CACHE);
|
||||||
|
//TODO 记得改回从缓存里取值
|
||||||
|
Map<String,String> onlineMap = new HashMap<>();
|
||||||
|
onlineMap.put("1","true");
|
||||||
|
onlineMap.put("2","false");
|
||||||
|
onlineMap.put("3","true");
|
||||||
|
onlineMap.put("4","true");
|
||||||
|
List<Long> deviceIdList = onlineMap.keySet().stream().map(Long::parseLong).toList();
|
||||||
|
|
||||||
|
List<DeviceVO> deviceVOList = deviceService.getDeviceVOByIds(deviceIdList);
|
||||||
|
|
||||||
|
//将所有设备按不同的设备品牌进行分组
|
||||||
|
Map<String,List<DeviceVO>> deviceGroup = new HashMap<>();
|
||||||
|
for (DeviceVO deviceVO : deviceVOList) {
|
||||||
|
if(deviceGroup.containsKey(deviceVO.getProduct().getCode())){
|
||||||
|
deviceGroup.get(deviceVO.getProduct().getCode()).add(deviceVO);
|
||||||
|
}else {
|
||||||
|
deviceGroup.put(deviceVO.getProduct().getCode(),List.of(deviceVO));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PieSummaryVO> pieSummaryVOList = new ArrayList<>();
|
||||||
|
|
||||||
|
addKNPCDeviceSummary(KNPCV1_MODBUS_TYPE,deviceGroup, onlineMap, pieSummaryVOList,"KNPCV1");
|
||||||
|
addKNPCDeviceSummary(ETC_MODBUS_TYPE,deviceGroup, onlineMap, pieSummaryVOList,"ETC");
|
||||||
|
addKNPCDeviceSummary(SCSS_MODBUS_TYPE,deviceGroup, onlineMap, pieSummaryVOList,"四川双晟");
|
||||||
|
|
||||||
|
//计算总数
|
||||||
|
PieSummaryVO pieSummaryVO = new PieSummaryVO();
|
||||||
|
pieSummaryVO.setChartName("total");
|
||||||
|
pieSummaryVO.setTitle("设备总数");
|
||||||
|
|
||||||
|
Integer onLineCount = 0;
|
||||||
|
Integer offLineCount = 0;
|
||||||
|
for(DeviceVO deviceVO : deviceVOList){
|
||||||
|
if("true".equalsIgnoreCase(onlineMap.get(deviceVO.getId().toString()))){
|
||||||
|
onLineCount++;
|
||||||
|
}else {
|
||||||
|
offLineCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PieDataVO onlinePieDataVO = new PieDataVO("在线",onLineCount);
|
||||||
|
PieDataVO offlinePieDataVO = new PieDataVO("离线",offLineCount);
|
||||||
|
pieSummaryVO.setData(List.of(onlinePieDataVO,offlinePieDataVO));
|
||||||
|
|
||||||
|
pieSummaryVOList.add(pieSummaryVO);
|
||||||
|
|
||||||
|
return pieSummaryVOList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void addKNPCDeviceSummary(String productName, Map<String, List<DeviceVO>> deviceGroup, Map<String, String> onlineMap, List<PieSummaryVO> pieSummaryVOList, String title) {
|
||||||
|
List<DeviceVO> knpcDeviceList = deviceGroup.get(productName);
|
||||||
|
PieSummaryVO pieSummaryVO = new PieSummaryVO();
|
||||||
|
pieSummaryVO.setChartName(productName);
|
||||||
|
pieSummaryVO.setTitle(title);
|
||||||
|
if(knpcDeviceList != null){
|
||||||
|
//根据设备列表查找在线map中的状态进行统计在线数量
|
||||||
|
Integer onLineCount = 0;
|
||||||
|
Integer offLineCount = 0;
|
||||||
|
for(DeviceVO deviceVO : knpcDeviceList){
|
||||||
|
if("true".equalsIgnoreCase(onlineMap.get(deviceVO.getId().toString()))){
|
||||||
|
onLineCount++;
|
||||||
|
}else {
|
||||||
|
offLineCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PieDataVO onlinePieDataVO = new PieDataVO("在线",onLineCount);
|
||||||
|
PieDataVO offlinePieDataVO = new PieDataVO("离线",offLineCount);
|
||||||
|
pieSummaryVO.setData(List.of(onlinePieDataVO,offlinePieDataVO));
|
||||||
|
}else{
|
||||||
|
//无值时需要构建空值结构
|
||||||
|
pieSummaryVO.setData(new ArrayList<>());
|
||||||
|
}
|
||||||
|
pieSummaryVOList.add(pieSummaryVO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.isu.gaswellwatch.vo.summary;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class PieDataVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Integer value;
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
|
public PieDataVO(String name, Integer value) {
|
||||||
|
this.name = name;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.isu.gaswellwatch.vo.summary;
|
||||||
|
|
||||||
|
import lombok.*;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class PieSummaryVO implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private List<PieDataVO> data;
|
||||||
|
|
||||||
|
private String chartName;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -89,5 +89,15 @@
|
||||||
order by t.create_time desc
|
order by t.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getDeviceVOByIds" resultMap="DeviceVOMap">
|
||||||
|
select u.id, u.device_type, u.code, u.gas_station, u.product, u.gateway_sn,
|
||||||
|
u.gas_well, u.details, u.create_time, u.update_time
|
||||||
|
from device u
|
||||||
|
where u.id in
|
||||||
|
<foreach collection="idList" item="id" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue