| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.BattMapInformationMapper; |
| | | import com.whyc.mapper.BattdischargePlanMapper; |
| | | import com.whyc.pojo.BattMapInformation; |
| | | import com.whyc.pojo.BattalarmData; |
| | | import com.whyc.pojo.Battinf; |
| | | import com.whyc.mapper.StationInfMapper; |
| | | import com.whyc.pojo.*; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.apache.commons.collections.map.HashedMap; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private BattMapInformationMapper mapper; |
| | | |
| | | @Resource |
| | | private BattdischargePlanMapper battdischargePlanMapper; |
| | | |
| | | @Resource |
| | |
| | | @Resource |
| | | private BattalarmDataService battalarmDataService; |
| | | |
| | | public Response add(BattMapInformation entity){ |
| | | @Resource |
| | | private StationInfMapper stationInfMapper; |
| | | |
| | | public Response add(BattMapInformation entity) { |
| | | mapper.insert(entity); |
| | | return new Response().set(1,true,"添加成功"); |
| | | //查看在电池组机房是否存在stationId |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | wrapper.eq("stationId", entity.getStationId()); |
| | | wrapper.last("limit 1"); |
| | | StationInf sinf = stationInfMapper.selectOne(wrapper); |
| | | if (sinf != null) { |
| | | UpdateWrapper sinfWrapper = new UpdateWrapper(); |
| | | sinfWrapper.set("stationLongitude", entity.getLongitude()); |
| | | sinfWrapper.set("stationLatitude", entity.getLatitude()); |
| | | sinfWrapper.eq("stationId", entity.getStationId()); |
| | | stationInfMapper.update((StationInf) ActionUtil.objeNull, sinfWrapper); |
| | | } |
| | | return new Response().set(1, true, "添加成功"); |
| | | } |
| | | |
| | | public Response update(BattMapInformation entity){ |
| | | public Response update(BattMapInformation entity) { |
| | | mapper.updateById(entity); |
| | | return new Response().set(1,true,"更新成功"); |
| | | //查看在电池组机房是否存在stationId |
| | | QueryWrapper wrapper = new QueryWrapper(); |
| | | wrapper.eq("stationId", entity.getStationId()); |
| | | wrapper.last("limit 1"); |
| | | StationInf sinf = stationInfMapper.selectOne(wrapper); |
| | | if (sinf != null) { |
| | | UpdateWrapper sinfWrapper = new UpdateWrapper(); |
| | | sinfWrapper.set("stationLongitude", entity.getLongitude()); |
| | | sinfWrapper.set("stationLatitude", entity.getLatitude()); |
| | | sinfWrapper.eq("stationId", entity.getStationId()); |
| | | stationInfMapper.update((StationInf) ActionUtil.objeNull, sinfWrapper); |
| | | } |
| | | return new Response().set(1, true, "更新成功"); |
| | | } |
| | | |
| | | |
| | |
| | | QueryWrapper<BattMapInformation> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("stationId",stationId); |
| | | List<BattMapInformation> list = mapper.selectList(queryWrapper); |
| | | for (BattMapInformation battMapInformation:list) { |
| | | /*for (BattMapInformation battMapInformation:list) { |
| | | String address = battMapInformation.getAddress(); |
| | | String[] split = address.split("-"); |
| | | battMapInformation.setStationName1(split[0]); |
| | | battMapInformation.setStationName2(split[1]); |
| | | battMapInformation.setStationName5(split[2]); |
| | | } |
| | | }*/ |
| | | return new Response().set(1,list,"查询成功"); |
| | | } |
| | | |
| | |
| | | int numPlan=0;//延迟总数 |
| | | |
| | | state="item-normal"; |
| | | numBadBatt=badBattMonService.getBadCountByStationId(stationId); //落后总数 |
| | | //太供局暂不显示落后单体数量 |
| | | //numBadBatt=badBattMonService.getBadCountByStationId(stationId); //落后总数 |
| | | //numAlarm=(new Battalarm_dataDAOImpl()).serchByStationId(binformation); //告警总数 |
| | | List<BattalarmData> alarmDataList = battalarmDataService.getCountByStationId(stationId); //告警确认和未确认总数 |
| | | int battAlarmConfirmed = 0; |
| | |
| | | } |
| | | Map<String,Object> map = new HashedMap(); |
| | | map.put("battAlarmStr",battAlarmStr); |
| | | map.put("numBadBatt",numBadBatt); |
| | | map.put("numPlan",numAlarm); |
| | | map.put("numBadBatt",0); |
| | | map.put("numPlan",numPlan); |
| | | return new Response().set(1,map,"查询成功"); |
| | | |
| | | } |
| | | //可以改造获取落后总数,告警总数,延迟总数 |
| | | public Response findStationState(){ |
| | | UserInf userInf = ActionUtil.getUser(); |
| | | //获取所有机房信息 |
| | | List<BattMapInformation> list = mapper.searchInBattMapByUid(userInf.getUId().intValue()); |
| | | //根据所有落后机房list |
| | | List<BattMapInformation> level1Behind=badBattMonService.findBehind(); |
| | | //获取所有告警机房list |
| | | List<BattMapInformation> level2Alarm=battalarmDataService.findAllStation(); |
| | | //获取所有延迟机房list |
| | | List<BattMapInformation> level3Timeout=battdischargePlanMapper.findTimeoutStation(); |
| | | //所有机房id集合 |
| | | List<String> stationList = new ArrayList<>(); |
| | | for (BattMapInformation information:list){ |
| | | stationList.add(information.getStationId()); |
| | | } |
| | | //设定num为站点状态:分为4级;level4为正常站点;设置所有站点初始状态为正常 |
| | | for (BattMapInformation information:list){ |
| | | information.setNum(4); |
| | | } |
| | | //用户管理内的异常机房id集合 |
| | | ArrayList<String> abnormalList = new ArrayList<>(); |
| | | //太供调整地图显示暂去除异常为1的标识 |
| | | // for (BattMapInformation information:level1Behind){ |
| | | // String stationId = information.getStationId(); |
| | | // //用户管理内的站点进行操作 |
| | | // if(stationList.contains(stationId)){ |
| | | // //从结果机房list定位到对应的元素 |
| | | // int index = stationList.indexOf(stationId); |
| | | // |
| | | // information.setNum(1); |
| | | // |
| | | // list.set(index,information); |
| | | // abnormalList.add(stationId); |
| | | // } |
| | | // } |
| | | for (BattMapInformation information:level2Alarm){ |
| | | String stationId = information.getStationId(); |
| | | //用户管理内的站点进行操作 |
| | | if(stationList.contains(stationId)){ |
| | | if(abnormalList.contains(stationId)){ |
| | | /*//从正常机房list中移除异常站点 |
| | | int indexRmv = stationId.indexOf(stationId); |
| | | level4Normal.remove(indexRmv);*/ |
| | | |
| | | /*int index = abnormalList.indexOf(stationId); |
| | | information.setNum(2); |
| | | resultList.set(index,information);*/ |
| | | }else { |
| | | /*information.setNum(2); |
| | | resultList.add(information); |
| | | abnormalList.add(information.getStationId());*/ |
| | | int index = stationList.indexOf(stationId); |
| | | information.setNum(2); |
| | | list.set(index,information); |
| | | abnormalList.add(stationId); |
| | | } |
| | | } |
| | | } |
| | | for (BattMapInformation information:level3Timeout){ |
| | | String stationId = information.getStationId(); |
| | | //用户管理内的站点进行操作 |
| | | if(stationList.contains(stationId)){ |
| | | if(abnormalList.contains(stationId)){ |
| | | /*//从正常机房list中移除异常站点 |
| | | int indexRmv = stationId.indexOf(stationId); |
| | | level4Normal.remove(indexRmv);*/ |
| | | |
| | | /*int index = abnormalList.indexOf(stationId); |
| | | information.setNum(1); |
| | | resultList.set(index,information);*/ |
| | | }else{ |
| | | /*information.setNum(1); |
| | | resultList.add(information);*/ |
| | | int index = stationList.indexOf(stationId); |
| | | information.setNum(3); |
| | | list.set(index,information); |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | return new Response().set(1,list,"查询成功"); |
| | | } |
| | | |
| | | |
| | | |