package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import com.whyc.dto.Response;
|
import com.whyc.mapper.*;
|
import com.whyc.pojo.BattRtdata;
|
import com.whyc.pojo.StationInf;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
@Service
|
public class StationInfService {
|
@Autowired(required = false)
|
private StationInfMapper mapper;
|
|
@Autowired(required = false)
|
private BattRtdataMapper rtdataMapper;
|
|
@Autowired(required = false)
|
private BattalarmDataMapper battAlmMapper;
|
|
@Autowired(required = false)
|
private DevalarmDataMapper devAlmMapper;
|
|
@Autowired(required = false)
|
private PwrdevAlarmMapper pwrAlmMapper;
|
|
//插入站点
|
public Response insertStation(StationInf stationInf) {
|
int flag = mapper.insert(stationInf);
|
return new Response().set(1, flag > 0, "插入站点");
|
}
|
|
//查询所有的站点
|
public Response searchStationAll(int pageCurr, int pageSize) {
|
PageHelper.startPage(pageCurr, pageSize);
|
List<StationInf> list = mapper.selectList(null);
|
PageInfo pageInfo = new PageInfo(list);
|
return new Response().setII(1, list.size() > 0, pageInfo, "查询站点");
|
}
|
|
//删除总站点
|
public Response deleteStation(int num) {
|
UpdateWrapper wrapper = new UpdateWrapper();
|
wrapper.eq("num", num);
|
int flag = mapper.delete(wrapper);
|
return new Response().set(1, flag > 0, "插入站点");
|
}
|
|
//管理员首页:站点实时数据推送
|
public Response getSystemAll(int userId) {
|
List<StationInf> list = mapper.getSystemAll(userId);
|
for (StationInf inf : list) {
|
String stationId = inf.getStationId();
|
//查询机房下最大的单体电压和单体
|
BattRtdata maxData = rtdataMapper.maxData(stationId);
|
inf.setMaxVol(maxData.getMonVol());
|
inf.setMaxNum(maxData.getMonNum());
|
//查询机房下最低的单体电压和单体
|
BattRtdata minData = rtdataMapper.minData(stationId);
|
inf.setMinVol(maxData.getMonVol());
|
inf.setMinNum(maxData.getMonNum());
|
//查询实时告警总数
|
int battAlm = battAlmMapper.getbattAlm(stationId);
|
int devAlm = devAlmMapper.getdevAlm(stationId);
|
int pwrAlm = pwrAlmMapper.getpwrAlm(stationId);
|
inf.setAlarmNum(battAlm + devAlm + pwrAlm);
|
}
|
return new Response().setII(1, list.size() > 0, list, "站点实时数据推送");
|
}
|
|
public String getMaxStationId() {
|
QueryWrapper<StationInf> query = Wrappers.query();
|
query.select("stationId").orderByDesc("num").last(" limit 1");
|
StationInf stationInf = mapper.selectOne(query);
|
if (stationInf == null) {
|
return "42000000";
|
} else {
|
return stationInf.getStationId();
|
}
|
}
|
|
public Response getStationStatistic(int userId) {
|
return null;
|
}
|
|
//运维层首页:站点实时数据推送
|
public Object getDevOpAll(int userId) {
|
Map<String, Object> map = null;
|
try {
|
map = new HashMap();
|
|
List<StationInf> list = mapper.getSystemAll(userId);
|
map.put("data", list);
|
} catch (Exception e) {
|
return new Response().set(1, false, "发生异常:" + e.getCause());
|
}
|
return new Response().setII(1, true, map, "站点实时数据推送");
|
}
|
|
//总机房
|
public int geStation(int userId) {
|
return mapper.geStation(userId);
|
}
|
}
|