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.dto.result.SystemGrdoupBatt;
|
import com.whyc.mapper.*;
|
import com.whyc.pojo.*;
|
import com.whyc.util.ActionUtil;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.context.annotation.Lazy;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
import java.util.*;
|
import java.util.stream.Collectors;
|
|
@Service
|
public class StationInfService {
|
@Autowired(required = false)
|
private StationInfMapper mapper;
|
|
@Autowired(required = false)
|
private BattRtdataMapper rtdataMapper;
|
|
@Autowired(required = false)
|
private BattRtstateMapper rtstateMapper;
|
|
@Autowired(required = false)
|
private PwrdevAcdcdataMapper acdcMapper;
|
|
@Autowired(required = false)
|
private BattalarmDataMapper battAlmMapper;
|
|
@Autowired(required = false)
|
private DevalarmDataMapper devAlmMapper;
|
|
@Autowired(required = false)
|
private PwrdevAlarmMapper pwrAlmMapper;
|
|
@Autowired(required = false)
|
private BadbattMonMapper badMapper;
|
|
@Autowired(required = false)
|
private BattEnduranceMapper endMapper;
|
@Autowired
|
@Lazy
|
private BattInfService battInfService;
|
@Autowired
|
private Fbs9100StateService fbs9100StateService;
|
@Autowired
|
private BattalarmDataService battAlarmDataService;
|
@Autowired
|
private DevalarmDataService devAlarmDataService;
|
@Autowired
|
private PwrdevAlarmService powerAlarmService;
|
|
@Resource
|
private BadbattMonMapper badbattMonMapper;
|
@Resource
|
private AlarmParamMapper alarmParamMapper;
|
|
@Resource
|
private BattInfMapper binfMapper;
|
|
@Resource
|
private PowerInfMapper pinfMapper;
|
|
@Resource
|
private BattMapInformationMapper mapMapper;
|
@Resource
|
private BatttestdataInfService testInfService;
|
|
//查询最大的自增标识同一机房的标识
|
public int getMaxTogetherFlag() {
|
int togetherFlag = mapper.getMaxTogetherFlag();
|
return togetherFlag;
|
}
|
|
//根据statidonId去查同一机房的标识
|
public int getTogetherFlag(String stationIdTogether) {
|
int togetherFlag = mapper.getTogetherFlag(stationIdTogether);
|
return togetherFlag;
|
}
|
|
//根据stationId和togetherFlag查询另外相同的机房
|
public Response getTogetherFlagStationInf(String stationId, int togetherFlag) {
|
QueryWrapper wrapper = Wrappers.query();
|
wrapper.eq("together_flag", togetherFlag);
|
wrapper.ne("stationId", stationId);
|
wrapper.last("limit 1");
|
StationInf sinf = mapper.selectOne(wrapper);
|
return new Response().setII(1, sinf != null ? true : false, sinf, "根据stationId和togetherFlag查询另外相同的机房");
|
}
|
|
//插入站点
|
@Transactional
|
public Response insertStation(StationInf stationInf) {
|
String stationId = stationInf.getStationId();
|
String stationIdTogether = stationInf.getStationIdTogether();
|
int togetherFlag = 0;
|
if (stationId == null || stationId.isEmpty()) {
|
stationId = String.valueOf(Integer.valueOf(getMaxStationId()) + 1);
|
stationInf.setStationId(stationId);
|
}
|
if (stationIdTogether == null || stationIdTogether.isEmpty()) {
|
togetherFlag = mapper.getMaxTogetherFlag() + 1;
|
} else {
|
//1.先验证同一机房结点信息和电压等级是否一样,若不一样则不允许添加
|
QueryWrapper wrapper = Wrappers.query();
|
wrapper.ne("stationId", stationIdTogether);
|
wrapper.last("limit 1");
|
StationInf sinf = mapper.selectOne(wrapper);
|
if (stationInf.getNodeStation() != sinf.getNodeStation()) {
|
return new Response().set(1, false, "设置同一站点时,两站点节点属性不一致");
|
}
|
if (!stationInf.getStationType().equals(sinf.getStationType())) {
|
return new Response().set(1, false, "设置同一站点时,两站点电压等级属性不一致");
|
}
|
//2.相同设置同一站点
|
togetherFlag = mapper.getTogetherFlag(stationIdTogether);
|
}
|
stationInf.setTogetherFlag(togetherFlag);
|
int flag = mapper.insert(stationInf);
|
//往map表插入
|
BattMapInformation mapInfo = new BattMapInformation();
|
mapInfo.setStationId(stationId);
|
mapInfo.setStationName(stationInf.getStationName());
|
mapInfo.setAddress(stationInf.getStationAddr() == null ? "" : stationInf.getStationAddr());
|
mapInfo.setLongitude(stationInf.getStationLongitude());
|
mapInfo.setLatitude(stationInf.getStationLatitude());
|
mapInfo.setStationName3(stationInf.getStationName3());
|
mapMapper.insert(mapInfo);
|
return new Response().set(1, flag > 0, flag > 0 ? "插入站点成功" : "插入站点失败");
|
}
|
|
//编辑机房名
|
@Transactional
|
public Response updateName(String stationName, String stationName1, String stationName2, String stationName3, String stationName4, String stationName5
|
, String stationIdTogether, String stationId) {
|
UpdateWrapper wrapper = new UpdateWrapper();
|
wrapper.eq("stationId", stationId);
|
UpdateWrapper sinfWrapper = new UpdateWrapper();
|
sinfWrapper.eq("stationId", stationId);
|
if (stationName != null && !stationName.isEmpty()) {
|
wrapper.set("stationName", stationName);
|
sinfWrapper.set("stationName", stationName);
|
}
|
if (stationName1 != null && !stationName1.isEmpty()) {
|
wrapper.set("stationName1", stationName1);
|
sinfWrapper.set("stationName1", stationName1);
|
}
|
if (stationName2 != null && !stationName2.isEmpty()) {
|
wrapper.set("stationName2", stationName2);
|
sinfWrapper.set("stationName2", stationName2);
|
}
|
if (stationName3 != null && !stationName3.isEmpty()) {
|
wrapper.set("stationName3", stationName3);
|
sinfWrapper.set("stationName3", stationName3);
|
}
|
if (stationName4 != null && !stationName4.isEmpty()) {
|
wrapper.set("stationName4", stationName4);
|
sinfWrapper.set("stationName4", stationName4);
|
}
|
if (stationName5 != null && !stationName5.isEmpty()) {
|
wrapper.set("stationName5", stationName5);
|
sinfWrapper.set("stationName5", stationName5);
|
}
|
if (stationIdTogether != null && !stationIdTogether.isEmpty()) {
|
//1.先验证同一机房结点信息和电压等级是否一样,若不一样则不允许添加
|
QueryWrapper wrapperZj = new QueryWrapper();
|
QueryWrapper wrapperGl = new QueryWrapper();
|
wrapperZj.eq("stationId", stationId);
|
wrapperGl.eq("stationId", stationIdTogether);
|
wrapper.last("limit 1");
|
StationInf sinfZj = mapper.selectOne(wrapperZj);
|
StationInf sinfGl = mapper.selectOne(wrapperGl);
|
if (sinfZj.getNodeStation() != sinfGl.getNodeStation()) {
|
return new Response().set(1, false, "设置同一站点时,两站点节点属性不一致");
|
}
|
if (!sinfZj.getStationType().equals(sinfGl.getStationType())) {
|
return new Response().set(1, false, "设置同一站点时,两站点电压等级属性不一致");
|
}
|
if (sinfZj.getStationLongitude() != sinfGl.getStationLongitude()) {
|
return new Response().set(1, false, "设置同一站点时,两站点地址的经度属性不一致");
|
}
|
if (sinfZj.getStationLatitude() != sinfGl.getStationLatitude()) {
|
return new Response().set(1, false, "设置同一站点时,两站点地址的维度属性不一致");
|
}
|
if (!sinfZj.getStationAddr().equals(sinfGl.getStationAddr())) {
|
return new Response().set(1, false, "设置同一站点时,两站点详细地址属性不一致");
|
}
|
int togetherFlag = mapper.getTogetherFlag(stationIdTogether);
|
sinfWrapper.set("together_flag", togetherFlag);
|
} else {
|
int togetherFlag = mapper.getMaxTogetherFlag() + 1;
|
sinfWrapper.set("together_flag", togetherFlag);
|
}
|
int flag = mapper.update(null, sinfWrapper);
|
QueryWrapper queryWrapper = new QueryWrapper();
|
queryWrapper.eq("stationId", stationId);
|
List listB = binfMapper.selectList(queryWrapper);
|
if (listB != null && listB.size() > 0) {
|
binfMapper.update(null, wrapper);
|
}
|
List listP = pinfMapper.selectList(queryWrapper);
|
if (listP != null && listP.size() > 0) {
|
pinfMapper.update(null, wrapper);
|
}
|
return new Response().set(1, flag > 0, flag > 0 ? "编辑机房名成功" : "编辑机房名失败");
|
}
|
|
//编辑站点
|
@Transactional
|
public Response updateStation(String nodeStation, String stationType
|
, String stationLongitude, String stationLatitude
|
, String stationAddr, int togetherFlag, String stationId) {
|
int nofla = 0;
|
int stlag = 0;
|
int lofla = 0;
|
int lafla = 0;
|
int addfla = 0;
|
//往map表插入
|
BattMapInformation mapInfo = new BattMapInformation();
|
UpdateWrapper wrapper = new UpdateWrapper();
|
UpdateWrapper wrapperEx = new UpdateWrapper();
|
UpdateWrapper infwrapper = new UpdateWrapper();
|
UpdateWrapper infwrapperEx = new UpdateWrapper();
|
UpdateWrapper mapwrapper = new UpdateWrapper();
|
UpdateWrapper mapwrapperEx = new UpdateWrapper();
|
wrapper.eq("stationId", stationId);
|
infwrapper.eq("stationId", stationId);
|
mapwrapper.eq("stationId", stationId);
|
//根据togetherFlag和stationId查询相同机房
|
QueryWrapper togetWapper = Wrappers.query();
|
togetWapper.eq("together_flag", togetherFlag);
|
togetWapper.ne("stationId", stationId);
|
togetWapper.last("limit 1");
|
StationInf sinfEx = mapper.selectOne(togetWapper);
|
|
if (nodeStation != null && !nodeStation.isEmpty()) {
|
nofla = 1;
|
wrapper.set("nodeStation", nodeStation);
|
infwrapper.set("nodeStation", nodeStation);
|
wrapperEx.set("nodeStation", nodeStation);
|
infwrapperEx.set("nodeStation", nodeStation);
|
}
|
if (stationType != null && !stationType.isEmpty()) {
|
stlag = 1;
|
wrapper.set("stationType", stationType);
|
infwrapper.set("stationType", stationType);
|
wrapperEx.set("stationType", stationType);
|
infwrapperEx.set("stationType", stationType);
|
}
|
if (stationLongitude != null && !stationLongitude.isEmpty()) {
|
lofla = 1;
|
mapInfo.setLongitude(Double.parseDouble(stationLongitude));
|
wrapper.set("stationLongitude", stationLongitude);
|
wrapperEx.set("stationLongitude", stationLongitude);
|
mapwrapper.set("longitude", stationLongitude);
|
mapwrapperEx.set("longitude", stationLongitude);
|
|
}
|
if (stationLatitude != null && !stationLatitude.isEmpty()) {
|
lafla = 1;
|
mapInfo.setLatitude(Double.parseDouble(stationLatitude));
|
wrapper.set("stationLatitude", stationLatitude);
|
wrapperEx.set("stationLatitude", stationLatitude);
|
mapwrapper.set("latitude", stationLatitude);
|
mapwrapperEx.set("latitude", stationLatitude);
|
}
|
if (stationAddr != null && !stationAddr.isEmpty()) {
|
addfla = 1;
|
mapInfo.setAddress(stationAddr);
|
wrapper.set("stationAddr", stationAddr);
|
wrapperEx.set("stationAddr", stationAddr);
|
mapwrapper.set("address", stationAddr);
|
mapwrapperEx.set("address", stationAddr);
|
} else {
|
mapInfo.setAddress("");
|
}
|
int flag = mapper.update(null, wrapper);
|
if (nofla > 0 || stlag > 0) {
|
QueryWrapper qwrapper = new QueryWrapper();
|
qwrapper.eq("stationId", stationId);
|
List list = binfMapper.selectList(qwrapper);
|
if (list.size() > 0) {
|
binfMapper.update(null, infwrapper);
|
}
|
//修改相同机房
|
if (sinfEx != null) {
|
wrapperEx.eq("stationId", sinfEx.getStationId());
|
infwrapperEx.eq("stationId", sinfEx.getStationId());
|
mapper.update(null, wrapperEx);
|
binfMapper.update(null, infwrapperEx);
|
}
|
}
|
if (lofla > 0 || lafla > 0 || addfla > 0) {
|
QueryWrapper mwrapper = new QueryWrapper();
|
mwrapper.eq("stationId", stationId);
|
List list = mapMapper.selectList(mwrapper);
|
if (list.size() > 0) {
|
mapMapper.update(null, mapwrapper);
|
} else {
|
QueryWrapper swrapper = new QueryWrapper();
|
swrapper.eq("stationId", stationId);
|
swrapper.last("limit 1");
|
StationInf sinf = mapper.selectOne(swrapper);
|
//插入map
|
mapInfo.setStationId(stationId);
|
mapInfo.setStationName(sinf.getStationName());
|
mapInfo.setStationName3(sinf.getStationName3());
|
mapMapper.insert(mapInfo);
|
}
|
//修改相同机房
|
if (sinfEx != null) {
|
QueryWrapper mwrapperEx = new QueryWrapper();
|
mwrapperEx.eq("stationId", sinfEx.getStationId());
|
List listEx = mapMapper.selectList(mwrapperEx);
|
if (listEx.size() > 0) {
|
mapMapper.update(null, mapwrapperEx);
|
} else {
|
//插入map
|
mapInfo.setStationId(sinfEx.getStationId());
|
mapInfo.setStationName(sinfEx.getStationName());
|
mapInfo.setStationName3(sinfEx.getStationName3());
|
mapMapper.insert(mapInfo);
|
}
|
}
|
}
|
return new Response().set(1, flag > 0, "编辑站点");
|
}
|
|
//查询所有的站点
|
public Response searchStationAll(int pageCurr, int pageSize, String stationName1, String stationName2, String stationName5, String nodeStation, String stationType) {
|
PageHelper.startPage(pageCurr, pageSize);
|
/* QueryWrapper wrapper = new QueryWrapper();
|
if (!(stationName1 == null || stationName1.isEmpty())) {
|
wrapper.eq("stationName1", stationName1);
|
}
|
if (!(stationName2 == null || stationName2.isEmpty())) {
|
wrapper.eq("stationName2", stationName2);
|
}
|
if (!(stationName5 == null || stationName5.isEmpty())) {
|
wrapper.eq("stationName5", stationName5);
|
}
|
List<StationInf> list = mapper.selectList(wrapper);*/
|
String uId = ActionUtil.getUser().getUId().toString();
|
List<StationInf> list = mapper.searchStationAll(stationName1, stationName2, stationName5, nodeStation, stationType, uId);
|
PageInfo pageInfo = new PageInfo(list);
|
return new Response().setII(1, list.size() > 0, pageInfo, "查询站点");
|
}
|
|
//删除总站点
|
@Transactional
|
public Response deleteStation(String stationId) {
|
UpdateWrapper wrapper = new UpdateWrapper();
|
wrapper.eq("stationId", stationId);
|
int flag = mapper.delete(wrapper);
|
QueryWrapper queryWrapper = new QueryWrapper();
|
queryWrapper.eq("stationId", stationId);
|
List listB = binfMapper.selectList(queryWrapper);
|
if (listB != null && listB.size() > 0) {
|
binfMapper.delete(wrapper);
|
}
|
List listP = pinfMapper.selectList(queryWrapper);
|
if (listP != null && listP.size() > 0) {
|
pinfMapper.delete(wrapper);
|
}
|
return new Response().set(1, flag > 0, "删除总站点");
|
}
|
|
//管理员首页:站点实时数据推送
|
public Response getSystemAll(int userId) {
|
try {
|
Map<String, Object> map = new HashMap();
|
//头部统计数据
|
int stationNum = mapper.getStation(userId);
|
map.put("stationNum", stationNum);
|
//浮充/充电
|
List<BattRtstate> stateList = rtstateMapper.getBattStateStatic(userId);
|
Map<String, Integer> statemap = new HashMap();
|
statemap.put("batt1", 0);
|
statemap.put("batt2", 0);
|
statemap.put("batt3", 0);
|
Map<Integer, List<BattRtstate>> battstateMap = stateList.stream().collect(Collectors.groupingBy(BattRtstate::getBattState));
|
for (Integer state : battstateMap.keySet()) {
|
if (state == 1 || state == 2 || state == 3) {
|
statemap.put("batt" + state, battstateMap.get(state).size());
|
}
|
}
|
map.put("battState", statemap);
|
//整流器故障/负载熔断
|
List<PwrdevAcdcdata> acdcList = acdcMapper.getAcdcStatic(userId);
|
Map<String, Integer> errmap = new HashMap();
|
Map<Integer, List<PwrdevAcdcdata>> aderrMap = acdcList.stream().collect(Collectors.groupingBy(PwrdevAcdcdata::getAcdcErr));
|
errmap.put("err0", 0);
|
errmap.put("err1", 0);
|
for (Integer acdcerr : aderrMap.keySet()) {
|
errmap.put("err" + acdcerr, aderrMap.get(acdcerr).size());
|
}
|
map.put("errmap", errmap);
|
Map<String, Integer> fusemap = new HashMap();
|
fusemap.put("fuse0", 0);
|
fusemap.put("fuse1", 0);
|
Map<Integer, List<PwrdevAcdcdata>> adfuseMap = acdcList.stream().collect(Collectors.groupingBy(PwrdevAcdcdata::getIsLoaderFuse));
|
for (Integer fuse : adfuseMap.keySet()) {
|
fusemap.put("fuse" + fuse, adfuseMap.get(fuse).size());
|
}
|
map.put("fusemap", fusemap);
|
//本年度核容放电电池组.
|
int hrdisNum = testInfService.getYearAnalysis(userId);
|
map.put("hrdisNum", hrdisNum);
|
//实时停电放电
|
int jcdisNum = fbs9100StateService.getJcAnalysis(userId);
|
map.put("jcdisNum", jcdisNum);
|
//视图
|
List<StationInf> list = mapper.getSystemAll(userId);
|
for (StationInf inf : list) {
|
String stationId = inf.getStationId();
|
//查询分组电池信息
|
List<SystemGrdoupBatt> sgblist = rtstateMapper.selectSystemGrdoupBatt(stationId);
|
for (int i = 0; i < sgblist.size(); i++) {
|
int battGroupId = sgblist.get(i).getBattGroupId();
|
//查询机房下最大的单体电压和单体
|
BattRtdata maxData = rtdataMapper.maxData(battGroupId);
|
sgblist.get(i).setMaxVol(maxData.getMonVol());
|
sgblist.get(i).setMaxNum(maxData.getMonNum());
|
//查询机房下最低的单体电压和单体
|
BattRtdata minData = rtdataMapper.minData(battGroupId);
|
sgblist.get(i).setMinVol(minData.getMonVol());
|
sgblist.get(i).setMinNum(minData.getMonNum());
|
//查询实时告警总数
|
int battAlm = battAlmMapper.getbattAlm(battGroupId);
|
sgblist.get(i).setBattAlm(battAlm);
|
}
|
inf.setSgbList(sgblist);
|
int devAlm = devAlmMapper.getdevAlm(stationId);
|
inf.setDevAlm(devAlm);
|
int pwrAlm = pwrAlmMapper.getpwrAlm(stationId);
|
inf.setPwrAlm(pwrAlm);
|
}
|
map.put("data", list);
|
return new Response().setII(1, true, map, "站点实时数据推送");
|
} catch (Exception e) {
|
return new Response().set(1, false, "发生异常:" + e.getCause());
|
}
|
}
|
//找最大的stationid
|
public String getMaxStationId() {
|
/*QueryWrapper<StationInf> query = Wrappers.query();
|
query.select("stationId").orderByDesc("stationId").last(" limit 1");
|
StationInf stationInf = mapper.selectOne(query);
|
if (stationInf == null) {
|
return "42000000";
|
} else {
|
return stationInf.getStationId();
|
}*/
|
String stationid = mapper.getMaxStationId();
|
if (stationid == null) {
|
return "42000000";
|
} else {
|
return stationid;
|
}
|
}
|
|
/**
|
*
|
* @param userId
|
* @return
|
* 站点数:
|
* 110v/35v:
|
* 节点站:
|
* 普通站:
|
* 停点站: tb_fbs9100_state.dev_workstate=3
|
* 核容放电站:tb_fbs9100_state.dev_workstate=2
|
* 故障告警站:
|
* 站点地图:
|
*/
|
public Response getStationStatistic(int userId) {
|
try {
|
Map<String, Object> stationInfoMap = new HashMap<>();
|
List<StationInf> stationInfList = mapper.getStationInfList(userId);
|
//站点数
|
stationInfoMap.put("stationCount", stationInfList.size());
|
//110v/35v/...
|
Map<String, List<StationInf>> stationTypeMap = stationInfList.stream().filter(stationInf -> !stationInf.getStationType().equals("")).collect(Collectors.groupingBy(StationInf::getStationType));
|
Set<String> stationTypeSet = stationTypeMap.keySet();
|
for (String stationType : stationTypeSet) {
|
stationInfoMap.put(stationType, stationTypeMap.get(stationType).size());
|
}
|
//节点站和普通站
|
//List<Battinf> stationList = battInfService.getSateAnalysis(userId);
|
Map<Integer, List<StationInf>> nodeStationMap = stationInfList.stream().collect(Collectors.groupingBy(StationInf::getNodeStation));
|
|
stationInfoMap.put("nomalStation", nodeStationMap.get(0) == null ? 0 : nodeStationMap.get(0).size());
|
stationInfoMap.put("nodeStation", nodeStationMap.get(1) == null ? 0 : nodeStationMap.get(1).size());
|
|
//停电站和核容放电站
|
List<Fbs9100State> stateList = fbs9100StateService.getStateList(userId);
|
Map<Integer, List<Fbs9100State>> stateMap = stateList.stream().collect(Collectors.groupingBy(Fbs9100State::getDevWorkstate));
|
stationInfoMap.put("checkCapDischarge", stateMap.get(2) == null ? 0 : stateMap.get(2).size());
|
stationInfoMap.put("powerOff", stateMap.get(3) == null ? 0 : stateMap.get(3).size());
|
//故障告警站: 电池/设备/电源告警
|
List<Integer> battStationList = battAlarmDataService.getStationList(userId);
|
List<Integer> devStationList = devAlarmDataService.getStationList(userId);
|
List<Integer> powerStationList = powerAlarmService.getStationList(userId);
|
List<Integer> stationIdList = new LinkedList<>(battStationList);
|
for (Integer integer : devStationList) {
|
if (!stationIdList.contains(integer)) {
|
stationIdList.add(integer);
|
}
|
}
|
for (Integer integer : powerStationList) {
|
if (!stationIdList.contains(integer)) {
|
stationIdList.add(integer);
|
}
|
}
|
stationInfoMap.put("alarmStationCount", stationIdList.size());
|
//站点地图
|
List<StationInf> mapAndWorkStateList = getStationMapAndWorkState(userId);
|
stationInfoMap.put("stationMap", mapAndWorkStateList);
|
return new Response().setII(1, true, stationInfoMap, null);
|
} catch (Exception e) {
|
return new Response().set(1, false, "发生异常:" + e.getCause());
|
}
|
}
|
|
public List<StationInf> getStationMapAndWorkState(int userId) {
|
return mapper.getStationMapAndWorkState(userId);
|
}
|
|
//监控层地图信息
|
public List<StationInf> getStationMapInMonitor(int userId) {
|
//下面各个站点数据
|
List<StationInf> list = mapper.getSystemAll(userId);
|
return list;
|
}
|
|
//运维层首页:站点实时数据推送
|
public Object getDevOpAll(int userId) {
|
try {
|
Map<String, Object> map = new HashMap();
|
//头部统计数据
|
int stationNum = mapper.getStation(userId);
|
map.put("stationNum", stationNum);
|
//浮充/充电
|
List<BattRtstate> stateList = rtstateMapper.getBattStateStatic(userId);
|
Map<String, Integer> statemap = new HashMap();
|
statemap.put("batt1", 0);
|
statemap.put("batt2", 0);
|
statemap.put("batt3", 0);
|
Map<Integer, List<BattRtstate>> battstateMap = stateList.stream().collect(Collectors.groupingBy(BattRtstate::getBattState));
|
for (Integer state : battstateMap.keySet()) {
|
if (state == 1 || state == 2 || state == 3) {
|
statemap.put("batt" + state, battstateMap.get(state).size());
|
}
|
}
|
map.put("battState", statemap);
|
//整流器故障/负载熔断
|
List<PwrdevAcdcdata> acdcList = acdcMapper.getAcdcStatic(userId);
|
Map<String, Integer> errmap = new HashMap();
|
Map<Integer, List<PwrdevAcdcdata>> aderrMap = acdcList.stream().collect(Collectors.groupingBy(PwrdevAcdcdata::getAcdcErr));
|
errmap.put("err0", 0);
|
errmap.put("err1", 0);
|
for (Integer acdcerr : aderrMap.keySet()) {
|
errmap.put("err" + acdcerr, aderrMap.get(acdcerr).size());
|
}
|
map.put("errmap", errmap);
|
Map<String, Integer> fusemap = new HashMap();
|
fusemap.put("fuse0", 0);
|
fusemap.put("fuse1", 0);
|
Map<Integer, List<PwrdevAcdcdata>> adfuseMap = acdcList.stream().collect(Collectors.groupingBy(PwrdevAcdcdata::getIsLoaderFuse));
|
for (Integer fuse : adfuseMap.keySet()) {
|
fusemap.put("fuse" + fuse, adfuseMap.get(fuse).size());
|
}
|
map.put("fusemap", fusemap);
|
//本年度核容放电电池组
|
int hrdisNum = testInfService.getYearAnalysis(userId);
|
map.put("hrdisNum", hrdisNum);
|
//实时停电放电
|
int jcdisNum = fbs9100StateService.getJcAnalysis(userId);
|
map.put("jcdisNum", jcdisNum);
|
//下面各个站点数据
|
List<StationInf> list = mapper.getSystemAll(userId);
|
for (StationInf inf : list) {
|
String stationId = inf.getStationId();
|
//查询分组电池信息
|
List<SystemGrdoupBatt> sgblist = rtstateMapper.selectSystemGrdoupBatt(stationId);
|
if (sgblist != null && sgblist.size() > 0) {
|
for (int i = 0; i < sgblist.size(); i++) {
|
//判断是否落后
|
int battGroupId = sgblist.get(i).getBattGroupId();
|
Integer badbattFlag = badMapper.judgeBatt(battGroupId);
|
sgblist.get(i).setBadbattFlag(badbattFlag);
|
//根据电池组查询续航时间
|
String enduranceActualTimelong = endMapper.getACTime(battGroupId);
|
if (enduranceActualTimelong == null) {
|
enduranceActualTimelong = "0";
|
}
|
sgblist.get(i).setEnduranceActualTimelong(Float.valueOf(enduranceActualTimelong));
|
}
|
inf.setSgbList(sgblist);
|
}
|
}
|
map.put("data", list);
|
//站点统计
|
//List<StationInf> stationInfList = mapper.getStationInfList(userId);
|
List<StationInf> stationInfList = mapper.getSateAnalysis(userId);//和homeAdmin相同
|
//110kv/35kv/...
|
Map<String, Object> kvMap = new HashMap();
|
Map<String, List<StationInf>> stationTypeMap = stationInfList.stream().filter(stationInf -> !stationInf.getStationType().equals("")).collect(Collectors.groupingBy(StationInf::getStationType));
|
Set<String> stationTypeSet = stationTypeMap.keySet();
|
for (String stationType : stationTypeSet) {
|
kvMap.put(stationType, stationTypeMap.get(stationType).size());
|
}
|
map.put("kvMap", kvMap);
|
//节点站和普通站
|
//List<Battinf> stationList = battInfService.getSateAnalysis(userId);
|
//Map<Integer, List<Battinf>> nodeStationMap = stationList.stream().collect(Collectors.groupingBy(Battinf::getNodeStation));
|
Map<Integer, List<StationInf>> nodeStationMap = stationInfList.stream().collect(Collectors.groupingBy(StationInf::getNodeStation));
|
map.put("nomalStation", nodeStationMap.get(0) == null ? 0 : nodeStationMap.get(0).size());
|
map.put("nodeStation", nodeStationMap.get(1) == null ? 0 : nodeStationMap.get(1).size());
|
|
//停电站和核容放电站
|
List<Fbs9100State> f9100stateList = fbs9100StateService.getStateList(userId);
|
Map<Integer, List<Fbs9100State>> stateMap = f9100stateList.stream().collect(Collectors.groupingBy(Fbs9100State::getDevWorkstate));
|
map.put("checkCapDischarge", stateMap.get(2) == null ? 0 : stateMap.get(2).size());
|
map.put("powerOff", stateMap.get(3) == null ? 0 : stateMap.get(3).size());
|
|
//1.查询劣化(告警)和损坏(更换)的阈值
|
QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper();
|
alarmWrapper.and(wrapper -> {
|
return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange");
|
});
|
alarmWrapper.orderByAsc("alm_id");
|
List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
|
float capAlarm = 0f;
|
float capChange = 0f;
|
if (paramList != null && paramList.size() > 0) {
|
capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
|
capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
|
} else {
|
capAlarm = 0.8f;
|
capChange = 0.6f;
|
}
|
//站点劣化数量(包含损坏)
|
int alarmNum = badbattMonMapper.getQualityAnalysisStation(userId, capAlarm);
|
//站点损坏数量
|
int changeNum = badbattMonMapper.getQualityAnalysisStation(userId, capChange);
|
map.put("alarmNum", (alarmNum - changeNum));
|
map.put("changeNum", changeNum);
|
|
//电池告警机房
|
int battAlarmNum = battAlmMapper.getQualityAnalysisStation(userId);
|
//设备告警机房
|
int devAlarmNum = devAlmMapper.getQualityAnalysisStation(userId);
|
//电源设备告警机房
|
int powerAlarmNum = pwrAlmMapper.getQualityAnalysisStation(userId);
|
map.put("battAlarmNum", battAlarmNum);
|
map.put("devAlarmNum", devAlarmNum);
|
map.put("powerAlarmNum", powerAlarmNum);
|
return new Response().setII(1, true, map, "站点实时数据推送");
|
} catch (Exception e) {
|
return new Response().set(1, false, "发生异常:" + e.getCause());
|
}
|
|
}
|
|
//总机房
|
public int getStation(int userId) {
|
return mapper.getStation(userId);
|
}
|
|
|
//运维层首页:头部统计
|
public Response getDevOpSkipHead(int userId) {
|
try {
|
Map<String, Object> map = new HashMap();
|
//头部统计数据
|
int stationNum = mapper.getStation(userId);
|
map.put("stationNum", stationNum);
|
//浮充/充电
|
List<BattRtstate> stateList = rtstateMapper.getBattStateStatic(userId);
|
Map<String, Integer> statemap = new HashMap();
|
statemap.put("batt1", 0);
|
statemap.put("batt2", 0);
|
statemap.put("batt3", 0);
|
Map<Integer, List<BattRtstate>> battstateMap = stateList.stream().collect(Collectors.groupingBy(BattRtstate::getBattState));
|
for (Integer state : battstateMap.keySet()) {
|
if (state == 1 || state == 2 || state == 3) {
|
statemap.put("batt" + state, battstateMap.get(state).size());
|
}
|
}
|
map.put("battState", statemap);
|
//整流器故障/负载熔断
|
List<PwrdevAcdcdata> acdcList = acdcMapper.getAcdcStatic(userId);
|
Map<String, Integer> errmap = new HashMap();
|
Map<Integer, List<PwrdevAcdcdata>> aderrMap = acdcList.stream().collect(Collectors.groupingBy(PwrdevAcdcdata::getAcdcErr));
|
errmap.put("err0", 0);
|
errmap.put("err1", 0);
|
for (Integer acdcerr : aderrMap.keySet()) {
|
errmap.put("err" + acdcerr, aderrMap.get(acdcerr).size());
|
}
|
map.put("errmap", errmap);
|
Map<String, Integer> fusemap = new HashMap();
|
fusemap.put("fuse0", 0);
|
fusemap.put("fuse1", 0);
|
Map<Integer, List<PwrdevAcdcdata>> adfuseMap = acdcList.stream().collect(Collectors.groupingBy(PwrdevAcdcdata::getIsLoaderFuse));
|
for (Integer fuse : adfuseMap.keySet()) {
|
fusemap.put("fuse" + fuse, adfuseMap.get(fuse).size());
|
}
|
map.put("fusemap", fusemap);
|
//本年度核容放电电池组.停电放电电池组
|
int hrdisNum = testInfService.getYearAnalysis(userId);
|
map.put("hrdisNum", hrdisNum);
|
//实时停电放电
|
int jcdisNum = fbs9100StateService.getJcAnalysis(userId);
|
map.put("jcdisNum", jcdisNum);
|
//站点统计
|
List<StationInf> stationInfList = mapper.getStationInfList(userId);
|
//110v/35v/...
|
Map<String, List<StationInf>> stationTypeMap = stationInfList.stream().filter(stationInf -> !stationInf.getStationType().equals("")).collect(Collectors.groupingBy(StationInf::getStationType));
|
Set<String> stationTypeSet = stationTypeMap.keySet();
|
for (String stationType : stationTypeSet) {
|
map.put(stationType, stationTypeMap.get(stationType).size());
|
}
|
//节点站和普通站
|
//List<Battinf> stationList = battInfService.getSateAnalysis(userId);
|
//Map<Integer, List<Battinf>> nodeStationMap = stationList.stream().collect(Collectors.groupingBy(Battinf::getNodeStation));
|
Map<Integer, List<StationInf>> nodeStationMap = stationInfList.stream().collect(Collectors.groupingBy(StationInf::getNodeStation));
|
map.put("nomalStation", nodeStationMap.get(0) == null ? 0 : nodeStationMap.get(0).size());
|
map.put("nodeStation", nodeStationMap.get(1) == null ? 0 : nodeStationMap.get(1).size());
|
|
//停电站和核容放电站
|
List<Fbs9100State> f9100stateList = fbs9100StateService.getStateList(userId);
|
Map<Integer, List<Fbs9100State>> stateMap = f9100stateList.stream().collect(Collectors.groupingBy(Fbs9100State::getDevWorkstate));
|
map.put("checkCapDischarge", stateMap.get(2) == null ? 0 : stateMap.get(2).size());
|
map.put("powerOff", stateMap.get(3) == null ? 0 : stateMap.get(3).size());
|
|
//1.查询劣化(告警)和损坏(更换)的阈值
|
QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper();
|
alarmWrapper.and(wrapper -> {
|
return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange");
|
});
|
alarmWrapper.orderByAsc("alm_id");
|
List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
|
float capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
|
float capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
|
//站点劣化数量(包含损坏)
|
int alarmNum = badbattMonMapper.getQualityAnalysisStation(userId, capAlarm);
|
//站点损坏数量
|
int changeNum = badbattMonMapper.getQualityAnalysisStation(userId, capChange);
|
map.put("alarmNum", (alarmNum - changeNum));
|
map.put("changeNum", changeNum);
|
|
//电池告警机房
|
int battAlarmNum = battAlmMapper.getQualityAnalysisStation(userId);
|
//设备告警机房
|
int devAlarmNum = devAlmMapper.getQualityAnalysisStation(userId);
|
//电源设备告警机房
|
int powerAlarmNum = pwrAlmMapper.getQualityAnalysisStation(userId);
|
map.put("battAlarmNum", battAlarmNum);
|
map.put("devAlarmNum", devAlarmNum);
|
map.put("powerAlarmNum", powerAlarmNum);
|
return new Response().setII(1, true, map, "站点实时数据推送");
|
} catch (Exception e) {
|
return new Response().set(1, false, "发生异常:" + e.getCause());
|
}
|
|
}
|
|
//指定站点详情第一次跳转机房id为0:message
|
public Response getDevOpSkipStation(int userId, String stationId) {
|
//查询指定机房信息
|
StationInf inf = mapper.getSystemSkipStation(userId, stationId);
|
if (inf != null) {
|
//查询分组电池信息
|
List<SystemGrdoupBatt> sgblist = rtstateMapper.selectSystemGrdoupBatt(stationId);
|
if (sgblist != null && sgblist.size() > 0) {
|
for (int i = 0; i < sgblist.size(); i++) {
|
//判断是否落后
|
int battGroupId = sgblist.get(i).getBattGroupId();
|
int badbattFlag = badMapper.judgeBatt(battGroupId);
|
sgblist.get(i).setBadbattFlag(badbattFlag);
|
//根据电池组查询续航时间
|
String enduranceActualTimelong = endMapper.getACTime(battGroupId);
|
if (enduranceActualTimelong == null) {
|
enduranceActualTimelong = "0";
|
}
|
sgblist.get(i).setEnduranceActualTimelong(Float.valueOf(enduranceActualTimelong));
|
}
|
inf.setSgbList(sgblist);
|
}
|
return new Response().setII(1, true, inf, "指定站点详情");
|
} else {
|
return new Response().set(1, false, "指定站点详情");
|
}
|
}
|
|
//查询省
|
public Response searchAllStationName1(int uId) {
|
List<String> list = mapper.getStationName1ByUserId(uId);
|
return new Response().set(1, list, "查询成功");
|
}
|
|
public Response searchAllStationName2(Integer uId, String stationName1) {
|
List<String> list = mapper.getStationName2ByUseridAndSt1(uId, stationName1);
|
return new Response().set(1, list, "查询成功");
|
}
|
|
public Response searchAllStationName5(Integer uId, String stationName1, String stationName2) {
|
List<String> list = mapper.getStationName5ByUseridAndSt1AndSt2(stationName1, stationName2, uId);
|
return new Response().set(1, list, "查询成功");
|
}
|
|
//穿梭框查询所有的站点
|
public Response searchShuttle() {
|
long uId = ActionUtil.getUser().getUId();
|
List<StationInf> list = mapper.searchShuttle(uId);
|
return new Response().setII(1, list.size() > 0, list, "穿梭框查询所有的站点");
|
}
|
|
//穿梭框移除或者添加站点
|
@Transactional
|
public Response updateShuttle(List<StationInf> stationInfs) {
|
int flag = 0;
|
if (stationInfs != null && stationInfs.size() > 0) {
|
for (StationInf inf : stationInfs) {
|
UpdateWrapper sinfWrapper = new UpdateWrapper();
|
sinfWrapper.set("nodeStation", inf.getNodeStation());
|
sinfWrapper.eq("stationId", inf.getStationId());
|
flag += mapper.update(null, sinfWrapper);
|
//查看在电池组机房是否存在stationId
|
QueryWrapper wrapper = new QueryWrapper();
|
wrapper.eq("stationId", inf.getStationId());
|
wrapper.last("limit 1");
|
Battinf binf = binfMapper.selectOne(wrapper);
|
if (binf != null) {
|
UpdateWrapper binfWrapper = new UpdateWrapper();
|
binfWrapper.set("nodeStation", inf.getNodeStation());
|
binfWrapper.eq("stationId", inf.getStationId());
|
flag += binfMapper.update(null, binfWrapper);
|
}
|
}
|
}
|
return new Response().set(1, flag > 0, "穿梭框移除或者添加站点");
|
}
|
|
//首页上点击整流器故障
|
public Response searchAcdcModError() {
|
String uId = String.valueOf(ActionUtil.getUser().getUId());
|
List<PowerInf> list = acdcMapper.searchAcdcModError(uId);
|
return new Response().setII(1, list.size() > 0, list, "首页上点击整流器故障");
|
}
|
|
//首页上点击负载熔断
|
public Response searchFuse() {
|
String uId = String.valueOf(ActionUtil.getUser().getUId());
|
List<PowerInf> list = acdcMapper.searchFuse(uId);
|
return new Response().setII(1, list.size() > 0, list, "首页上点击整流器故障");
|
}
|
|
//首页上点击停电站
|
public Response searchPowerOff() {
|
String uId = String.valueOf(ActionUtil.getUser().getUId());
|
List<Battinf> list = fbs9100StateService.searchPowerOff(uId);
|
return new Response().setII(1, list.size() > 0, list, "首页上点击停电站");
|
}
|
|
//首页上点击核容放电站
|
public Response searchCheckCapDischarge() {
|
String uId = String.valueOf(ActionUtil.getUser().getUId());
|
List<Battinf> list = fbs9100StateService.searchCheckCapDischarge(uId);
|
return new Response().setII(1, list.size() > 0, list, "首页上点击核容放电站");
|
}
|
|
//首页上点击容量不足站
|
public Response searchCapAlarm() {
|
int uId = ActionUtil.getUser().getUId().intValue();
|
//1.查询劣化(告警)和损坏(更换)的阈值
|
QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper();
|
alarmWrapper.and(wrapper -> {
|
return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange");
|
});
|
alarmWrapper.orderByAsc("alm_id");
|
List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
|
float capAlarm = paramList.get(0).getAlmLowCoe();//劣化参数0.8
|
float capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
|
List<Battinf> list = badbattMonMapper.searchCapAlarm(uId, capAlarm, capChange);
|
return new Response().setII(1, list.size() > 0, list, "首页上点击容量不足站");
|
}
|
|
//首页上点击电池损坏站
|
public Response searCapChange() {
|
int uId = ActionUtil.getUser().getUId().intValue();
|
//1.查询劣化(告警)和损坏(更换)的阈值
|
QueryWrapper<AlarmParam> alarmWrapper = new QueryWrapper();
|
alarmWrapper.and(wrapper -> {
|
return wrapper.eq("alm_name", "Batt_Alarm_Type_CapAlarm").or().eq("alm_name", "Batt_Alarm_Type_CapChange");
|
});
|
alarmWrapper.orderByAsc("alm_id");
|
List<AlarmParam> paramList = alarmParamMapper.selectList(alarmWrapper);
|
float capChange = paramList.get(1).getAlmLowCoe();//损坏参数0.6
|
|
List<Battinf> list = badbattMonMapper.searCapChange(uId, capChange);
|
return new Response().setII(1, list.size() > 0, list, "首页上点击电池损坏站");
|
}
|
|
//站点信息
|
public List<StationInf> getSateAnalysis(int userId) {
|
List<StationInf> list = mapper.getSateAnalysis(userId);
|
return list;
|
}
|
|
public List<StationInf> getStationInfList(int userId) {
|
return mapper.getStationInfList(userId);
|
}
|
|
//查询所有的站点电压等级
|
public Response searStationType() {
|
List<String> list = mapper.searStationType();
|
return new Response().setII(1, list.size() > 0 ? true : false, list, "查询所有的站点电压等级");
|
}
|
|
//添加关联时下拉显示
|
public Response getTogetherStations(String stationName1, String stationName2, String stationName5) {
|
List<StationInf> list = mapper.getTogetherStations(stationName1, stationName2, stationName5);
|
return new Response().set(1, list, "查询成功");
|
}
|
}
|