| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.api.R; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.BattMapInformationMapper; |
| | | import com.whyc.pojo.BattMapInformation; |
| | | import com.whyc.pojo.BattalarmData; |
| | | import com.whyc.mapper.BattdischargePlanMapper; |
| | | 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; |
| | | |
| | | @Service |
| | | public class BattMapInformationService { |
| | | |
| | | @Resource |
| | | private BattMapInformationMapper mapper; |
| | | @Resource |
| | | private BattdischargePlanMapper battdischargePlanMapper; |
| | | |
| | | @Resource |
| | | private BadBattMonService badBattMonService; |
| | | @Resource |
| | | private BattalarmDataService battalarmDataService; |
| | | |
| | | public Response add(BattMapInformation entity){ |
| | | if (mapper.insert(entity)>0){ |
| | | return new Response().set(1,"添加成功"); |
| | | }else { |
| | | return new Response().set(0,"添加失败"); |
| | | @Resource |
| | | private StationInfMapper stationInfMapper; |
| | | |
| | | public Response add(BattMapInformation entity) { |
| | | mapper.insert(entity); |
| | | //查看在电池组机房是否存在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) { |
| | | mapper.updateById(entity); |
| | | //查看在电池组机房是否存在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 searchNotInBattMapByUid(int uId){ |
| | | List<Battinf> list = mapper.searchNotInBattMapByUid(uId); |
| | | return new Response().set(1,list,"查询成功"); |
| | | } |
| | | |
| | | |
| | | //首页上查询用户管理的已经设置过位置的机房信息 |
| | | public Response searchUserManageStation(int uId){ |
| | | List<BattMapInformation> list = mapper.serchInBattMapByUid(uId); |
| | | List<BattMapInformation> list = mapper.searchInBattMapByUid(uId); |
| | | return new Response().set(1,list,"查询成功"); |
| | | } |
| | | |
| | |
| | | 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,"查询成功"); |
| | | } |
| | | |
| | |
| | | queryWrapper.eq(battMapInformation.getStationName3()!=null,"stationName3",battMapInformation.getStationName3()); |
| | | queryWrapper.eq(battMapInformation.getLongitude()!=null,"longitude",battMapInformation.getLongitude()); |
| | | queryWrapper.eq(battMapInformation.getLatitude()!=null,"latitude",battMapInformation.getLatitude()); |
| | | int affectRows = mapper.delete(queryWrapper); |
| | | if (affectRows>0){ |
| | | return new Response().set(1,"删除成功"); |
| | | }else { |
| | | return new Response().set(0,"删除失败"); |
| | | } |
| | | mapper.delete(queryWrapper); |
| | | return new Response().set(1,true,"删除成功"); |
| | | } |
| | | |
| | | |
| | | |
| | | public Response multiAmount(String stationId){ |
| | | Response model = new Response(); |
| | | String state=""; |
| | | int numBadBatt=0;//落后总数 |
| | | int numAlarm=0;//告警总数 |
| | | 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; |
| | |
| | | } |
| | | |
| | | String battAlarmStr = battAlarmConfirmed+","+battAlarmNoConfirmed; |
| | | //todo 延迟总数 |
| | | // numPlan=(new BattDischarge_planImpl()).serchByStationId(binformation); //延迟总数 |
| | | // if(numBadBatt>0){ |
| | | // state="item-behind"; //落后机房 |
| | | // }else{ |
| | | // if(numAlarm > 0){ |
| | | // state="item-warn"; //告警机房 |
| | | // }else{ |
| | | // if(numPlan > 0){ |
| | | // state="item-timeout"; //延迟机房 |
| | | // } |
| | | // } |
| | | // } |
| | | //} |
| | | //model.setCode(numAlarm); //告警总数 |
| | | model.setMsg(battAlarmStr); //告警总数 |
| | | // model.setSum(numBadBatt); //落后总数 |
| | | // model.setNewsum(numPlan); //延时总数 |
| | | // model.setMsg(state); //61850状态 |
| | | // model.setMsgN(binformation.getFBSDeviceId().toString()); |
| | | return model; |
| | | numPlan=battdischargePlanMapper.searchByStationId(stationId); //延迟总数 |
| | | if(numBadBatt>0){ |
| | | state="item-behind"; //落后机房 |
| | | }else{ |
| | | if(numAlarm > 0){ |
| | | state="item-warn"; //告警机房 |
| | | }else{ |
| | | if(numPlan > 0){ |
| | | state="item-timeout"; //延迟机房 |
| | | } |
| | | } |
| | | } |
| | | Map<String,Object> map = new HashedMap(); |
| | | map.put("battAlarmStr",battAlarmStr); |
| | | 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,"查询成功"); |
| | | } |
| | | |
| | | |
| | | |