| | |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.PowerDto; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.Statistic.Pwr7Stic; |
| | | import com.whyc.dto.Statistic.StationStic; |
| | | import com.whyc.mapper.BaojigroupPowerMapper; |
| | | import com.whyc.mapper.BaojigroupUsrMapper; |
| | | import com.whyc.mapper.PowerInfMapper; |
| | | import com.whyc.mapper.StationInfMapper; |
| | | import com.whyc.pojo.db_station.BattInf; |
| | | import com.whyc.pojo.db_station.PowerInf; |
| | | import com.whyc.pojo.db_station.StationInf; |
| | | import com.whyc.pojo.db_user.BaojigroupPower; |
| | | import com.whyc.pojo.db_user.BaojigroupUsr; |
| | | import com.whyc.pojo.db_user.User; |
| | | import com.whyc.util.ActionUtil; |
| | | import org.apache.commons.math3.analysis.function.Power; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | @Autowired(required = false) |
| | | private StationInfMapper sinfMapper; |
| | | |
| | | //添加机房 |
| | | public Response addPower(PowerInf addpinf) { |
| | | /* //判断添加锁的时候机房是不是新机房 |
| | | String fullName=addpinf.getProvice()+"_"+addpinf.getCity()+"_"+addpinf.getCountry()+"_"+addsinf.getStationName(); |
| | | @Autowired(required = false) |
| | | private BaojigroupUsrMapper bjUserMapper; |
| | | |
| | | @Autowired(required = false) |
| | | private BaojigroupPowerMapper bjPowerMapper; |
| | | |
| | | /*添加电源 |
| | | 1.判断当前用户是否是包组用户 |
| | | 2.判断机房是否存在,若存在则在机房下添加电源,若不存在则新建机房+新建电源 |
| | | 3.电源需要编号,powerNum编号,电源名称自动生成通讯电源+powerNum |
| | | */ |
| | | @Transactional |
| | | public void addPower(PowerInf addpinf) { |
| | | //机房信息 |
| | | StationInf addsinf= addpinf.getSinf(); |
| | | //判断添加锁的时候机房是不是新机房 |
| | | String fullName=addsinf.getProvice()+"_"+addsinf.getCity()+"_"+addsinf.getCountry()+"_"+addsinf.getStationName(); |
| | | //判断机房是否存在 |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("full_name",fullName); |
| | | wrapper.last("limit 1"); |
| | | PowerInf pinf=mapper.selectOne(wrapper); |
| | | StationInf sinf=sinfMapper.selectOne(wrapper); |
| | | int stationId=0; |
| | | if(pinf!=null){ |
| | | return new Response().set(1,false,"机房已存在"); |
| | | int powerId=0; |
| | | if(sinf!=null){ |
| | | stationId=sinf.getStationId(); |
| | | }else { |
| | | //获取对应的机房id |
| | | stationId=sinfMapper.getMaxStationId(); |
| | | if(stationId==0){//数据库中没有站点 |
| | | stationId=40000001; |
| | | }else{ |
| | | stationId+=1; |
| | | stationId = sinfMapper.getMaxStationId(); |
| | | if (stationId == 0) {//数据库中没有站点 |
| | | stationId = 40000001; |
| | | } else { |
| | | stationId += 1; |
| | | } |
| | | StationInf newSinf=new StationInf(); |
| | | newSinf.setStationId(stationId); |
| | | newSinf.setStationName(fullName); |
| | | newSinf.setProvice(addsinf.getProvice()); |
| | | newSinf.setCity(addsinf.getCity()); |
| | | newSinf.setCountry(addsinf.getCountry()); |
| | | newSinf.setStationName(addsinf.getStationName()); |
| | | mapper.insert(newSinf);*/ |
| | | return new Response().set(1,true,"添加机房"); |
| | | } |
| | | //删除机房 |
| | | public Response delPower(Integer pid) { |
| | | /* UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("station_id",stationId); |
| | | mapper.delete(wrapper);*/ |
| | | return new Response().set(1,true); |
| | | } |
| | | //修改机房 |
| | | public Response updatePower(PowerInf pinf) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | /*wrapper.eq("station_id",sinf.getStationId()); |
| | | if(sinf.getProvice()!=null){ |
| | | wrapper.set("provice",sinf.getProvice()); |
| | | addsinf.setFullName(fullName); |
| | | addsinf.setStationId(stationId); |
| | | sinfMapper.insert(addsinf); |
| | | } |
| | | if(sinf.getCity()!=null){ |
| | | wrapper.set("city",sinf.getCity()); |
| | | //电源需要编号,powerNum编号,电源名称自动生成通讯电源+powerNum |
| | | int powerNum=mapper.getMaxPowerNum(stationId); |
| | | if(powerNum==0){ |
| | | powerNum=1; |
| | | }else{ |
| | | powerNum+=1; |
| | | } |
| | | if(sinf.getCountry()!=null){ |
| | | wrapper.set("country",sinf.getCountry()); |
| | | //再添加电源信息 |
| | | addpinf.setStationId(stationId); |
| | | addpinf.setPowerNum(powerNum); |
| | | addpinf.setPowerName("通讯电源"+powerNum); |
| | | //获取对应的电源id |
| | | powerId = mapper.getMaxPowerId(); |
| | | if (powerId == 0) {//数据库中没有站点 |
| | | powerId = 10001; |
| | | } else { |
| | | powerId += 1; |
| | | } |
| | | if(sinf.getStationName()!=null){ |
| | | wrapper.set("station_name",sinf.getStationName()); |
| | | addpinf.setPowerId(powerId); |
| | | int flag=mapper.insert(addpinf); |
| | | if(flag>0){ |
| | | //当前人所在的包机组添加电源机房 |
| | | insertInbaoji(stationId,powerId); |
| | | } |
| | | String fullName=sinf.getProvice()+"_"+sinf.getCity()+"_"+sinf.getCountry()+"_"+sinf.getStationName(); |
| | | wrapper.set("full_name",fullName); |
| | | mapper.update((StationInf) ActionUtil.objeNull,wrapper);*/ |
| | | return new Response().set(1,true); |
| | | } |
| | | //查询机房 |
| | | public Response getPower(PowerDto dto) { |
| | | PageHelper.startPage(dto.getPageNum(),dto.getPageSize()); |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | if(dto.getProvice()!=null){ |
| | | wrapper.eq("provice",dto.getProvice()); |
| | | } |
| | | if(dto.getCity()!=null){ |
| | | wrapper.eq("city",dto.getCity()); |
| | | } |
| | | if(dto.getCountry()!=null){ |
| | | wrapper.eq("country",dto.getCountry()); |
| | | } |
| | | if(dto.getStationName()!=null){ |
| | | wrapper.eq("station_name",dto.getStationName()); |
| | | } |
| | | List<StationInf> list=mapper.selectList(wrapper); |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list!=null,pageInfo,"查询机房"); |
| | | } |
| | | |
| | | } |
| | | //当前人所在的包机组添加电源机房 |
| | | public void insertInbaoji(Integer stationId,Integer powerId){ |
| | | //重启线程并将锁加到当前人的包机组 |
| | | User uinf= ActionUtil.getUser(); |
| | | QueryWrapper wrapper1=new QueryWrapper(); |
| | | wrapper1.eq("uid",uinf.getId()); |
| | | List<BaojigroupUsr> groupIdList=bjUserMapper.selectList(wrapper1); |
| | | List<BaojigroupPower> baojigroupList=new ArrayList(); |
| | | if(groupIdList!=null&&groupIdList.size()>0){ |
| | | for (BaojigroupUsr bjUser:groupIdList) { |
| | | BaojigroupPower bjPower=new BaojigroupPower(); |
| | | bjPower.setStationId(stationId); |
| | | bjPower.setPowerId(powerId); |
| | | bjPower.setBaojiGroupId(bjUser.getBaojiGroupId()); |
| | | baojigroupList.add(bjPower); |
| | | } |
| | | } |
| | | bjPowerMapper.insertBatchSomeColumn(baojigroupList); |
| | | //processSurveyService.setUpThreadRestart(); |
| | | } |
| | | //获取电源品牌(下拉) |
| | | public Response getCompanyByUid(Integer uid) { |
| | | List<String> list=mapper.getCompanyByUid(uid); |
| | | return new Response().setII(1,list.size()>0,list,"获取电源品牌(下拉)"); |
| | | } |
| | | //获取电源型号(下拉) |
| | | public Response getPowerModelByUid(Integer uid) { |
| | | List<String> list=mapper.getPowerModelByUid(uid); |
| | | return new Response().setII(1,list.size()>0,list,"获取电源型号(下拉)"); |
| | | } |
| | | //获取电源协议(下拉) |
| | | public Response getProtocolByUid(Integer uid) { |
| | | List<String> list=mapper.getProtocolByUid(uid); |
| | | return new Response().setII(1,list.size()>0,list,"获取电源协议(下拉)"); |
| | | } |
| | | //获取电源信息 |
| | | public PowerInf getPowerInfById(Integer powerId) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("power_id",powerId); |
| | | wrapper.last("limit 1"); |
| | | PowerInf pinf=mapper.selectOne(wrapper); |
| | | return pinf; |
| | | } |
| | | //电源信息统计 |
| | | public Response getPowerStatistic(StationStic stic) { |
| | | PageHelper.startPage(stic.getPageNum(),stic.getPageSize()); |
| | | List<PowerInf> list=mapper.getPowerStatistic(stic); |
| | | PageInfo<PowerInf> pageInfo=new PageInfo<>(list); |
| | | return new Response().setII(1,list.size()>0,pageInfo,"电源信息统计"); |
| | | } |
| | | //优良电源数量统计(1.2.7) |
| | | public List<PowerInf> getPwr7Statistic(Pwr7Stic stic) { |
| | | return mapper.getPwr7Statistic(stic); |
| | | } |
| | | } |