| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.GatewayInfMapper; |
| | | import com.whyc.pojo.db_ckpwrdev_inf.BreakerInf; |
| | | import com.whyc.pojo.db_ckpwrdev_inf.GatewayInf; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | private GatewayInfMapper mapper; |
| | | |
| | | //获取网关配置 |
| | | public Response getGatewayInf(int pageCurr, int pageSize, Integer gatewayType, String commType) { |
| | | public Response getGatewayInf(int pageCurr, int pageSize, String gatewayType, String commType) { |
| | | PageHelper.startPage(pageCurr,pageSize); |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | if(gatewayType!=null){ |
| | |
| | | } |
| | | //获取网关类别 |
| | | public Response getGatewayType() { |
| | | List<Integer> list=mapper.getGatewayType(); |
| | | List<String> list=mapper.getGatewayType(); |
| | | return new Response().setII(1,list!=null,list,"获取网关类别"); |
| | | } |
| | | //获取通讯类别 |
| | |
| | | List<String> list=mapper.getGatewayName(); |
| | | return new Response().setII(1,list!=null,list,"获取所属网关"); |
| | | } |
| | | //增加网关 |
| | | public Response addGateway(GatewayInf ginf) { |
| | | //查询库中最大的网关 |
| | | Integer gatewayId=mapper.getMaxGatewayId(); |
| | | if(gatewayId==null){ |
| | | gatewayId=10001; |
| | | }else{ |
| | | gatewayId+=1; |
| | | } |
| | | ginf.setGatewayId(gatewayId); |
| | | int flag=mapper.insert(ginf); |
| | | return new Response().set(1,flag>0,"增加网关"); |
| | | } |
| | | //编辑网关 |
| | | public Response updateGateway(GatewayInf ginf) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("num",ginf.getNum()); |
| | | int flag=mapper.update(ginf,wrapper); |
| | | return new Response().set(1,flag>0,"编辑网关"); |
| | | } |
| | | //删除网关 |
| | | public Response deleteGateway(int num) { |
| | | //删除之前判断是否被占用 |
| | | BreakerInf breakerInf=mapper.judgeBreaker(num); |
| | | if(breakerInf!=null){ |
| | | return new Response().set(1,false,"网关被占用,无法删除"); |
| | | }else{ |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("num",num); |
| | | int flag=mapper.delete(wrapper); |
| | | return new Response().set(1,flag>0?true:false,flag>0?"删除网关成功":"删除网关失败"); |
| | | } |
| | | } |
| | | } |