whyclxw
2025-05-17 441f4fd8652a5d51c386d19eb27a7dbb2140b10b
查询机房,电源,电池组信息
14个文件已修改
3个文件已添加
573 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/BattInfController.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/ConditionController.java 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/InfoContoller.java 85 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/PowerInfController.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/InfoDto.java 111 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/factory/InfoFactory.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/BattInfMapper.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/PowerInfMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/StationInfMapper.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/db_station/BattInf.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/db_station/PowerInf.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/BattInfService.java 97 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/PowerInfService.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/StationInfService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/BattInfMapper.xml 77 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/PowerInfMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/StationInfMapper.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/BattInfController.java
@@ -20,15 +20,17 @@
    private BattInfService service;
    @ApiOperation(value = "设备添加电池组")
    @PostMapping("addBattInDev")
    /*@ApiOperation(value = "设备添加电池组")
    @PostMapping("addBatt")
    public Response addBatt(@RequestBody BattInf binf){
        return service.addBatt(binf);
        service.addBatt(binf);
        return new Response().set(1,true);
    }
    @ApiOperation(value = "新建电池组(新的设备新的电池组)")
    @PostMapping("addDev")
    public Response addDev(@RequestBody BattInf binf){
        return service.addDev(binf);
         service.addDev(binf);
        return new Response().set(1,true);
    }
    @ApiOperation(value = "删除电池组")
@@ -41,11 +43,11 @@
    @PostMapping("updateBatt")
    public Response updateBatt(@RequestBody BattInf binf){
        return service.updateBatt(binf);
    }
    }*/
    @ApiOperation(value = "查询电池组")
   /* @ApiOperation(value = "查询电池组")
    @PostMapping("getBatt")
    public Response getBatt(@RequestBody BattDto dto){
        return service.getBatt(dto);
    }
    }*/
}
src/main/java/com/whyc/controller/ConditionController.java
@@ -3,6 +3,8 @@
import com.whyc.dto.Response;
import com.whyc.pojo.db_user.User;
import com.whyc.service.BaojigroupService;
import com.whyc.service.BattInfService;
import com.whyc.service.PowerInfService;
import com.whyc.service.StationInfService;
import com.whyc.util.ActionUtil;
import io.swagger.annotations.Api;
@@ -18,7 +20,13 @@
    private StationInfService stationInfService;
    @Autowired
    private PowerInfService  powerInfService;
    @Autowired
    private BaojigroupService bjGroupService;
    @Autowired
    private BattInfService binfService;
    @ApiOperation("获取所有的省份(下拉)")
    @GetMapping("getProviceByUid")
@@ -56,6 +64,54 @@
        return stationInfService.getPowerByUid(uinf.getId(),provice,city,country,stationName);
    }
    @ApiOperation("获取电压等级(下拉)")
    @GetMapping("getStationType")
    public Response getStationTypeByUid() {
        User uinf= ActionUtil.getUser();
        return stationInfService.getStationTypeByUid(uinf.getId());
    }
    @ApiOperation("获取电池品牌(下拉)")
    @GetMapping("getProductByUid")
    public Response getProductByUid() {
        User uinf= ActionUtil.getUser();
        return binfService.getProductByUid(uinf.getId());
    }
    @ApiOperation("获取标称单体电压(下拉)")
    @GetMapping("getMonVolByUid")
    public Response getMonVolByUid() {
        User uinf= ActionUtil.getUser();
        return binfService.getMonVolByUid(uinf.getId());
    }
    @ApiOperation("获取标称容量(下拉)")
    @GetMapping("getMonCapByUid")
    public Response getMonCapByUid() {
        User uinf= ActionUtil.getUser();
        return binfService.getMonCapByUid(uinf.getId());
    }
    @ApiOperation("获取标称内阻(下拉)")
    @GetMapping("getMonResByUid")
    public Response getMonResByUid() {
        User uinf= ActionUtil.getUser();
        return binfService.getMonResByUid(uinf.getId());
    }
    @ApiOperation("获取设备型号(下拉)")
    @GetMapping("getDevTypeByUid")
    public Response getDevTypeByUid() {
        User uinf= ActionUtil.getUser();
        return binfService.getDevTypeByUid(uinf.getId());
    }
    @ApiOperation("获取电源品牌(下拉)")
    @GetMapping("getCompanyByUid")
    public Response getCompanyByUid() {
        User uinf= ActionUtil.getUser();
        return powerInfService.getCompanyByUid(uinf.getId());
    }
    @ApiOperation(value = "当前用户所在包机组下所有的用户(下拉)")
    @GetMapping("getBaojiUserByUid")
src/main/java/com/whyc/controller/InfoContoller.java
New file
@@ -0,0 +1,85 @@
package com.whyc.controller;
import com.whyc.dto.BattDto;
import com.whyc.dto.InfoDto;
import com.whyc.dto.Response;
import com.whyc.factory.InfoFactory;
import com.whyc.pojo.db_station.BattInf;
import com.whyc.pojo.db_station.PowerInf;
import com.whyc.pojo.db_user.User;
import com.whyc.service.BaojigroupService;
import com.whyc.service.BattInfService;
import com.whyc.service.PowerInfService;
import com.whyc.util.ActionUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@Api(tags = "机房,电源,电池组管理")
@RequestMapping("condition")
public class InfoContoller {
    @Autowired
    private PowerInfService pinfService;
    @Autowired
    private BattInfService binfService;
    @Autowired(required = false)
    private BaojigroupService bjService;
    @ApiOperation(value = "新建机房,电源,电池组信息")
    @PostMapping("addInfo")
    public Response addInfo(@RequestBody InfoDto info){
        //先校验当前用户是否存在包机组不存在则不让添加电源
        User user= ActionUtil.getUser();
        int flag=bjService.checkUserBaojiGroup(user.getId());
        String msg="添加成功";
        boolean bl=true;
        if(flag==0){
            bl=false;
            msg="当前用户不存在包机组";
        }
        try {
            PowerInf pinf=InfoFactory.infoToPower(info);
            BattInf binf=InfoFactory.infoToBatt(info);
            pinfService.addPower(pinf);
            binf.setStationId(pinf.getStationId());
            binf.setPowerId(pinf.getPowerId());
            binfService.addDev(binf);
        } catch (Exception e) {
            e.printStackTrace();
            msg="添加失败";
            bl=false;
        }
        return new Response().set(1,bl,msg);
    }
    @ApiOperation(value = "设备下添加电池组")
    @PostMapping("addBatt")
    public Response addBatt(@RequestBody BattInf binf){
        binfService.addBatt(binf);
        return new Response().set(1,true);
    }
    @ApiOperation(value = "删除电池组")
    @GetMapping("delBatt")
    public Response delBatt(@RequestParam Integer stationId,@RequestParam Integer powerId,@RequestParam Integer battgroupId){
        return binfService.delBatt(stationId, powerId, battgroupId);
    }
    /*@ApiOperation(value = "编辑机房,电源,电池组信息")
    @PostMapping("updateInfo")
    public Response updateInfo(@RequestBody InfoDto info){
        PowerInf pinf=InfoFactory.infoToPower(info);
        BattInf binf=InfoFactory.infoToBatt(info);
    }*/
    @ApiOperation(value = "查询机房,电源,电池组信息")
    @PostMapping("getInfo")
    public Response getInfo(@RequestBody BattDto dto){
        return binfService.getInfo(dto);
    }
}
src/main/java/com/whyc/controller/PowerInfController.java
@@ -16,11 +16,12 @@
    @Autowired
    private PowerInfService service;
/*
    @ApiOperation(value = "添加电源")
    @PostMapping("addPower")
    public Response addPower(@RequestBody PowerInf pinf){
        return service.addPower(pinf);
        service.addPower(pinf);
        return new Response().set(1,true,"添加成功");
    }
    @ApiOperation(value = "删除电源")
@@ -39,5 +40,5 @@
    @PostMapping("getPower")
    public Response getPower(@RequestBody PowerDto dto){
        return service.getPower(dto);
    }
    }*/
}
src/main/java/com/whyc/dto/InfoDto.java
New file
@@ -0,0 +1,111 @@
package com.whyc.dto;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
public class InfoDto {
    @ApiModelProperty(value = "机房Id")
    private Integer stationId;
    @ApiModelProperty(value = "站点名称")
    private String stationName;
    @ApiModelProperty(value = "省")
    private String provice;
    @ApiModelProperty(value = "市")
    private String city;
    @ApiModelProperty(value = "区县")
    private String country;
    @ApiModelProperty(value = "站点电压等级[(35kv/110kv/220kv 字符串类型)]")
    private String stationType;
    @ApiModelProperty(value = "机房名称[拼接后的]")
    private String fullName;
    @ApiModelProperty(value = "经度")
    private Double longitude;
    @ApiModelProperty(value = "纬度")
    private Double latitude;
    @ApiModelProperty(value = "电源id")
    private Integer powerId;
    @ApiModelProperty(value = "电源编号")
    private Integer powerNum;
    @ApiModelProperty(value = "电源名称")
    private String powerName;
    @ApiModelProperty(value = "厂家")
    private String company;
    @ApiModelProperty(value = "型号")
    private String powerModel;
    @ApiModelProperty(value = "协议")
    private String protocol;
    @ApiModelProperty(value = "电源ip")
    private String powerIp;
    @ApiModelProperty(value = "设备id")
    private Integer devId;
    @ApiModelProperty(value = "设备ip")
    private String devIp;
    @ApiModelProperty(value = "设备名称")
    private String devName;
    @ApiModelProperty(value = "设备类型")
    private String devType;
    @ApiModelProperty(value = "设备编号")
    private Integer devNum;
    @ApiModelProperty(value = "电池组id")
    private Integer battgroupId;
    @ApiModelProperty(value = "电池组名称")
    private String battgroupName;
    @ApiModelProperty(value = "电池组编号")
    private Integer battgroupNum;
    @ApiModelProperty(value = "标称电压")
    private Float monvolstd;
    @ApiModelProperty(value = "标称容量")
    private Float moncapstd;
    @ApiModelProperty(value = "标称内阻")
    private Float monresstd;
    @ApiModelProperty(value = "每组单体个数")
    private Float moncount;
    @ApiModelProperty(value = "品牌")
    private String product;
    @ApiModelProperty(value = "型号")
    private String battModel;
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai")
    private Date createTime;
}
src/main/java/com/whyc/factory/InfoFactory.java
New file
@@ -0,0 +1,40 @@
package com.whyc.factory;
import com.whyc.dto.InfoDto;
import com.whyc.pojo.db_station.BattInf;
import com.whyc.pojo.db_station.PowerInf;
import com.whyc.pojo.db_station.StationInf;
public class InfoFactory {
    //将info对象转为电源对象
    public static PowerInf infoToPower(InfoDto info) {
        PowerInf pinf = new PowerInf();
        pinf.setCompany(info.getCompany())
                .setPowerModel(info.getPowerModel())
                .setProtocol(info.getProtocol())
                .setPowerIp(info.getPowerIp());
        StationInf sinf=new StationInf();
        sinf.setProvice(info.getProvice())
                .setCity(info.getCity())
                .setCountry(info.getCountry())
                .setStationName(info.getStationName())
                .setStationType(info.getStationType())
                .setLatitude(info.getLatitude())
                .setLongitude(info.getLongitude());
        pinf.setSinf(sinf);
        return pinf;
    }
    //将info对象转为电池组对象
    public static BattInf infoToBatt(InfoDto info) {
        BattInf binf = new BattInf();
        binf.setDevIp(info.getDevIp())
                .setDevType(info.getDevType())
                .setMoncapstd(info.getMoncapstd())
                .setMoncount(info.getMoncount())
                .setMonresstd(info.getMonresstd())
                .setMonvolstd(info.getMonvolstd())
                .setProduct(info.getProduct())
                .setBattModel(info.getBattModel());
        return binf;
    }
}
src/main/java/com/whyc/mapper/BattInfMapper.java
@@ -1,6 +1,7 @@
package com.whyc.mapper;
import com.whyc.dto.BattDto;
import com.whyc.dto.InfoDto;
import com.whyc.pojo.db_station.BattInf;
import org.apache.ibatis.annotations.Param;
@@ -11,10 +12,22 @@
    Integer getMaxdevId();
    //获取对应的电池组id
    Integer getMaxBattGroupId();
    //查询电池
    List<BattInf> getBatt(BattDto dto);
    //查询机房,电源,电池组信息
    List<InfoDto> getInfo(BattDto dto);
    //检测电源下是否存在设备
    Integer getMaxDevNum(@Param("powerId") Integer powerId);
    //检测设备下是否存在电池组
    Integer getMaxBattgroupNum(@Param("devId")Integer devId);
    //获取电池品牌(下拉)
    List<String> getProductByUid(@Param("devId") Integer uid);
    //获取标称单体电压(下拉)
    List<String> getMonVolByUid(@Param("devId") Integer uid);
    //获取设备型号(下拉)
    List<String> getDevTypeByUid(@Param("devId") Integer uid);
    //获取标称容量(下拉)
    List<String> getMonCapByUid(@Param("devId") Integer uid);
    //获取标称内阻(下拉)
    List<String> getMonResByUid(@Param("devId") Integer uid);
}
src/main/java/com/whyc/mapper/PowerInfMapper.java
@@ -15,4 +15,6 @@
    List<PowerInf> getPower(PowerDto dto);
    //电源需要编号,powerNum编号,电源名称自动生成通讯电源+powerNum
    int getMaxPowerNum(@Param("stationId") Integer stationId);
    //获取电源品牌(下拉)
    List<String> getCompanyByUid(Integer uid);
}
src/main/java/com/whyc/mapper/StationInfMapper.java
@@ -22,4 +22,6 @@
    List<StationInf> getStationByUid(@Param("uid") Integer uid,@Param("provice") String provice,@Param("city") String city,@Param("country") String country);
    //获取站点下的电源(下拉)
    List<PowerInf> getPowerByUid(@Param("uid") Integer uid, @Param("provice") String provice, @Param("city") String city, @Param("country") String country, @Param("stationName") String stationName);
    //获取电压等级(下拉)
    List<String> getStationTypeByUid(@Param("uid") Integer uid);
}
src/main/java/com/whyc/pojo/db_station/BattInf.java
@@ -78,7 +78,7 @@
    private String product;
    @ApiModelProperty(value = "型号")
    private String model;
    private String battModel;
    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "Asia/Shanghai")
src/main/java/com/whyc/pojo/db_station/PowerInf.java
@@ -49,7 +49,7 @@
    private String company;
    @ApiModelProperty(value = "型号")
    private String model;
    private String powerModel;
    @ApiModelProperty(value = "协议")
    private String protocol;
src/main/java/com/whyc/service/BattInfService.java
@@ -5,9 +5,12 @@
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.BattDto;
import com.whyc.dto.InfoDto;
import com.whyc.dto.PowerDto;
import com.whyc.dto.Response;
import com.whyc.mapper.BattInfMapper;
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;
@@ -25,12 +28,18 @@
    @Autowired(required = false)
    private BattInfMapper mapper;
    @Autowired(required = false)
    private PowerInfMapper pinfMapper;
    @Autowired(required = false)
    private StationInfMapper sinfMapper;
    /*新建电池组(新的设备新的电池组)
     * @param binf
     * 1.在电源下新建设备,记录设备编号,devNum,设备名称为设备类型+devNum
     */
    @Transactional
    public Response addDev(BattInf adddinf) {
    public void addDev(BattInf adddinf) {
        //检测电源下是否存在设备
        int devNum=mapper.getMaxDevNum(adddinf.getPowerId());
        if(devNum==0){
@@ -59,11 +68,10 @@
        adddinf.setBattgroupNum(1);
        adddinf.setCreateTime(new Date());
        mapper.insert(adddinf);
        return new Response().set(1, true, "新建电池组(新的设备新的电池组)");
    }
    //设备下添加电池组
    @Transactional
    public Response addBatt(BattInf  addbinf) {
    public void addBatt(BattInf  addbinf) {
        //获取设备的通用信息
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("dev_id",addbinf.getDevId());
@@ -95,20 +103,55 @@
        addbinf.setBattgroupNum(battgroupNum);
        addbinf.setCreateTime(new Date());
        mapper.insert(addbinf);
        return new Response().set(1, true, "设备下添加电池组");
    }
    //删除电源
    public Response delBatt(Integer bid) {
    //删除电池组
    @Transactional
    public Response delBatt(Integer stationId,  Integer powerId,Integer battgroupId) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("battgroup_id",bid);
        wrapper.eq("battgroup_id",battgroupId);
        mapper.delete(wrapper);
        //检测如果powerId下电池组删除完了,要将电源也删除掉
        QueryWrapper wrapper1=new QueryWrapper();
        wrapper1.eq("power_id",powerId);
        List<BattInf> binfList=mapper.selectList(wrapper1);
        if(binfList==null){
            UpdateWrapper wrapper2=new UpdateWrapper();
            wrapper2.eq("power_id",powerId);
            pinfMapper.delete(wrapper);
            //再检测如果机房下电源也全删除了,要将机房也删除
            QueryWrapper wrapper3=new QueryWrapper();
            wrapper3.eq("station_id",stationId);
            List<PowerInf> pinfList=pinfMapper.selectList(wrapper3);
            if(pinfList==null){
                UpdateWrapper wrapper4=new UpdateWrapper();
                wrapper4.eq("station_id",stationId);
                sinfMapper.delete(wrapper4);
            }
        }
        return new Response().set(1,true);
    }
    //修改电源
    //修改电池组
    public Response updateBatt(BattInf binf) {
        UpdateWrapper wrapper1=new UpdateWrapper();
        wrapper1.eq("dev_id",binf.getDevId());
        if(binf.getDevIp()!=null){
            wrapper1.set("dev_ip",binf.getDevIp());
        }
        if(binf.getDevName()!=null){
            wrapper1.set("dev_name",binf.getDevName());
        }
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("battgroup_id",binf.getBattgroupId());
        if(binf.getBattgroupName()!=null){
            //检测该机房下要修改的电源名是否粗在
            QueryWrapper queryWrapper=new QueryWrapper();
            queryWrapper.eq("battgroup_name",binf.getBattgroupName());
            queryWrapper.eq("dev_id",binf.getDevId());
            queryWrapper.last("limit 1");
            BattInf juegeb=mapper.selectOne(queryWrapper);
            if(juegeb!=null){
                return new Response().set(1,false,"该设备下已存在"+binf.getBattgroupName()+"的电池组");
            }
            wrapper.set("battgroup_name",binf.getBattgroupName());
        }
        if(binf.getMonvolstd()!=null){
@@ -126,18 +169,18 @@
        if(binf.getMoncount()!=null){
            wrapper.set("moncount",binf.getMoncount());
        }
        if(binf.getModel()!=null){
            wrapper.set("model",binf.getModel());
        if(binf.getBattModel()!=null){
            wrapper.set("batt_model",binf.getBattModel());
        }
        mapper.update((BattInf) ActionUtil.objeNull,wrapper);
        return new Response().set(1,true);
    }
    //查询电池
    public Response getBatt(BattDto dto) {
    //查询机房,电源,电池组信息
    public Response getInfo(BattDto dto) {
        User user= ActionUtil.getUser();
        dto.setUid(user.getId());
        PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
        List<BattInf> list=mapper.getBatt(dto);
        List<InfoDto> list=mapper.getInfo(dto);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list!=null,pageInfo,"查询电池");
    }
@@ -147,4 +190,32 @@
        wrapper.eq("power_id",pid);
        mapper.delete(wrapper);
    }
    //获取电池品牌(下拉)
    public Response getProductByUid(Integer uid) {
        List<String> list=mapper.getProductByUid(uid);
        return new Response().setII(1,list.size()>0,list,"获取电池品牌(下拉)");
    }
    //获取标称单体电压(下拉)
    public Response getMonVolByUid(Integer uid) {
        List<String> list=mapper.getMonVolByUid(uid);
        return new Response().setII(1,list.size()>0,list,"获取标称单体电压(下拉)");
    }
    //获取标称容量(下拉)
    public Response getMonCapByUid(Integer uid) {
        List<String> list=mapper.getMonCapByUid(uid);
        return new Response().setII(1,list.size()>0,list,"获取标称容量(下拉)");
    }
    //获取标称内阻(下拉)
    public Response getMonResByUid(Integer uid) {
        List<String> list=mapper.getMonResByUid(uid);
        return new Response().setII(1,list.size()>0,list,"获取标称内阻(下拉)");
    }
    //获取设备型号(下拉)
    public Response getDevTypeByUid(Integer uid) {
        List<String> list=mapper.getDevTypeByUid(uid);
        return new Response().setII(1,list.size()>0,list,"获取设备型号(下拉)");
    }
}
src/main/java/com/whyc/service/PowerInfService.java
@@ -39,13 +39,7 @@
    3.电源需要编号,powerNum编号,电源名称自动生成通讯电源+powerNum
    */
    @Transactional
   public Response addPower(PowerInf addpinf) {
       //先校验当前用户是否存在包机组不存在则不让添加电源
       User user= ActionUtil.getUser();
       int flag=bjService.checkUserBaojiGroup(user.getId());
       if(flag==0){
           return new Response().set(1,false,"当前用户不存在包机组");
       }
   public void addPower(PowerInf addpinf) {
        //机房信息
        StationInf addsinf= addpinf.getSinf();
        //判断添加锁的时候机房是不是新机房
@@ -91,7 +85,6 @@
        }
        addpinf.setPowerId(powerId);
        mapper.insert(addpinf);
        return new Response().set(1, true, "添加电源");
    }
    //删除电源(删除包机组下记录,删除电源下的电池组设备)
    @Transactional
@@ -111,13 +104,22 @@
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("power_id",pinf.getPowerId());
        if(pinf.getPowerName()!=null){
            //检测该机房下要修改的电源名是否粗在
            QueryWrapper queryWrapper=new QueryWrapper();
            queryWrapper.eq("power_name",pinf.getPowerName());
            queryWrapper.eq("station_id",pinf.getStationId());
            queryWrapper.last("limit 1");
            PowerInf juegep=mapper.selectOne(queryWrapper);
            if(juegep!=null){
                return new Response().set(1,false,"该机房下已存在"+pinf.getPowerName()+"的电源");
            }
            wrapper.set("power_name",pinf.getPowerName());
        }
        if(pinf.getCompany()!=null){
            wrapper.set("company",pinf.getCompany());
        }
        if(pinf.getModel()!=null){
            wrapper.set("model",pinf.getModel());
        if(pinf.getPowerModel()!=null){
            wrapper.set("power_model",pinf.getPowerModel());
        }
        if(pinf.getProtocol()!=null){
            wrapper.set("protocol",pinf.getProtocol());
@@ -137,5 +139,9 @@
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list!=null,pageInfo,"查询电源");
    }
    //获取电源品牌(下拉)
    public Response getCompanyByUid(Integer uid) {
        List<String> list=mapper.getCompanyByUid(uid);
        return new Response().setII(1,list.size()>0,list,"获取电源品牌(下拉)");
    }
}
src/main/java/com/whyc/service/StationInfService.java
@@ -50,4 +50,10 @@
        List<PowerInf> list=mapper.getPowerByUid(uid,provice,city,country,stationName);
        return new Response().setII(1,list.size()>0,list,"获取站点下的电源(下拉)");
    }
    //获取电压等级(下拉)
    public Response getStationTypeByUid(Integer uid) {
        List<String> list=mapper.getStationTypeByUid(uid);
        return new Response().setII(1,list.size()>0,list,"获取电压等级(下拉)");
    }
}
src/main/resources/mapper/BattInfMapper.xml
@@ -15,11 +15,11 @@
        select ifnull(max(battgroup_num),0) from  db_station.tb_batt_inf where dev_id=#{devId};
    </select>
    <select id="getBatt" resultType="com.whyc.pojo.db_station.BattInf">
        select tb_batt_inf.*,tb_station_inf.station_name,tb_power_inf.power_name
        from db_station.tb_power_inf,db_station.tb_station_inf,db_station.tb_batt_inf
        where tb_batt_inf.station_id=tb_station_inf.station_id
          and tb_batt_inf.power_id=tb_power_inf.power_id
    <select id="getInfo" resultType="com.whyc.dto.InfoDto">
        SELECT * from  db_station.tb_station_inf
        LEFT JOIN  db_station.tb_power_inf on tb_station_inf.station_id=tb_power_inf.station_id
        LEFT JOIN  db_station.tb_batt_inf on tb_batt_inf.station_id=tb_station_inf.station_id and tb_power_inf.power_id=tb_batt_inf.power_id
        <where>
        <if test="provice!=null">
            and tb_station_inf.provice=#{provice}
        </if>
@@ -29,7 +29,7 @@
        <if test="country!=null">
            and tb_station_inf.country=#{country}
        </if>
        <if test="stationName!=null">
       <!-- <if test="stationName!=null">
            and tb_station_inf.station_name like concat('%',#{stationName},'%')
        </if>
        <if test="powerName!=null">
@@ -37,7 +37,7 @@
        </if>
        <if test="battgroupName!=null">
            and tb_batt_inf.battgroup_name like concat('%',#{battgroupName},'%')
        </if>
        </if>-->
        <if test="uid>100">
            and tb_power_inf.power_id in(
            select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
@@ -45,6 +45,69 @@
            and tb_baojigroup_usr.uid=#{uid}
            )
        </if>
        </where>
    </select>
    <select id="getProductByUid" resultType="java.lang.String">
        select distinct product from db_station.tb_batt_inf
        <where>
            <if test="uid>100">
                and tb_batt_inf.power_id in(
                select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
    <select id="getMonVolByUid" resultType="java.lang.String">
        select distinct monvolstd from db_station.tb_batt_inf
        <where>
            <if test="uid>100">
                and tb_batt_inf.power_id in(
                select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
    <select id="getDevTypeByUid" resultType="java.lang.String">
        select distinct dev_type from db_station.tb_batt_inf
        <where>
            <if test="uid>100">
                and tb_batt_inf.power_id in(
                select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
    <select id="getMonCapByUid" resultType="java.lang.String">
        select distinct moncapstd from db_station.tb_batt_inf
        <where>
            <if test="uid>100">
                and tb_batt_inf.power_id in(
                select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
    <select id="getMonResByUid" resultType="java.lang.String">
        select distinct monresstd from db_station.tb_batt_inf
        <where>
            <if test="uid>100">
                and tb_batt_inf.power_id in(
                select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
</mapper>
src/main/resources/mapper/PowerInfMapper.xml
@@ -41,5 +41,17 @@
        </if>
    </select>
    <select id="getCompanyByUid" resultType="java.lang.String">
        select distinct company from db_station.tb_power_inf
        <where>
            <if test="uid>100">
                and tb_power_inf.power_id in(
                select distinct power_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
</mapper>
src/main/resources/mapper/StationInfMapper.xml
@@ -156,4 +156,17 @@
            </if>
        </where>
    </select>
    <select id="getStationTypeByUid" resultType="java.lang.String">
        select distinct station_type from db_station.tb_station_inf
        <where>
            <if test="uid>100">
                and tb_station_inf.station_id in(
                select distinct station_id from db_user.tb_baojigroup_power,db_user.tb_baojigroup_usr
                where   tb_baojigroup_power.baoji_group_id=tb_baojigroup_usr.baoji_group_id
                and tb_baojigroup_usr.uid=#{uid}
                )
            </if>
        </where>
    </select>
</mapper>