lxw
2023-12-13 df709b80155d1fd6a1d3fa5a049a3283cc40c68f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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;
 
import java.util.List;
 
@Service
public class GatewayInfService {
    @Autowired(required = false)
    private GatewayInfMapper mapper;
 
    //获取网关配置
    public Response getGatewayInf(int pageCurr, int pageSize, String gatewayType, String commType) {
        PageHelper.startPage(pageCurr,pageSize);
        QueryWrapper wrapper=new QueryWrapper();
        if(gatewayType!=null){
            wrapper.eq("gateway_type",gatewayType);
        }
        if(commType!=null){
            wrapper.eq("comm_type",commType);
        }
        List<BreakerInf> list=mapper.selectList(wrapper);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list!=null,pageInfo,"获取网关配置");
    }
    //获取网关类别
    public Response getGatewayType() {
        List<String> list=mapper.getGatewayType();
        return new Response().setII(1,list!=null,list,"获取网关类别");
    }
    //获取通讯类别
    public Response getCommType() {
        List<String> list=mapper.getCommType();
        return new Response().setII(1,list!=null,list,"获取通讯类别");
    }
    //获取所属网关
    public Response getGatewayName() {
        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) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("num",num);
        int flag=mapper.delete(wrapper);
        return new Response().set(1,flag>0,"删除网关");
    }
}