whyclxw
2025-05-14 f8643a6b03cbc949a875f6018d0b2b5aa5a3a0f0
机房管理
4个文件已修改
2个文件已添加
171 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/BaojiGroupController.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/StationInfController.java 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/StationDto.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/StationInfMapper.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/StationInfService.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/StationInfMapper.xml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/BaojiGroupController.java
@@ -52,19 +52,19 @@
    }
    @GetMapping("stationList")
    @ApiOperation(value = "已添加机房锁和未添加机房锁")
    @ApiOperation(value = "已添加机房锁和未添加机房电源")
    public Response<Map<String,List<PowerInf>>> getStationList(@RequestParam int id){
        Map<String,List<PowerInf>> resultMap = service.getStationList(id);
        return new Response().setII(1,resultMap.size()>0,resultMap,"已添加机房锁和未添加机房锁");
        return new Response().setII(1,resultMap.size()>0,resultMap,"已添加机房锁和未添加机房电源");
    }
    @ApiOperation("查询包机组及包机组对应的用户和对应机房和锁")
    @ApiOperation("查询包机组及包机组对应的用户和对应机房和电源")
    @GetMapping("getAllBaojiInf")
    public Response getAllBaojiInf() {
        return service.getAllBaojiInf();
    }
    @PostMapping("updateStationList")
    @ApiOperation(value = "包机组添加机房和锁|移除机房和锁",notes = "operationFlag为1,添加;-1,移除")
    @ApiOperation(value = "包机组添加机房和锁|移除机房和电源",notes = "operationFlag为1,添加;-1,移除")
    public Response updateStationAndLockList(@RequestBody List<BaojigroupPower> baoJiGroupLockList, @RequestParam int operationFlag){
        service.updateStationAndLockList(baoJiGroupLockList,operationFlag);
        if(operationFlag==1) {
src/main/java/com/whyc/controller/StationInfController.java
New file
@@ -0,0 +1,52 @@
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.dto.StationDto;
import com.whyc.pojo.db_station.StationInf;
import com.whyc.pojo.db_user.User;
import com.whyc.service.StationInfService;
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("stationInf")
public class StationInfController {
    @Autowired
    private StationInfService service;
    @ApiOperation(value = "获取左侧列表")
    @GetMapping("getLeftStation")
    public Response getLeftStation(){
        User uinf= ActionUtil.getUser();
        return service.getLeftStation(uinf.getId());
    }
    @ApiOperation(value = "添加机房")
    @PostMapping("addStatiaon")
    public Response addStatiaon(@RequestBody StationInf sinf){
        return service.addStatiaon(sinf);
    }
    @ApiOperation(value = "删除机房")
    @GetMapping("delStatiaon")
    public Response delStatiaon(@RequestParam Integer stationId){
        return service.delStatiaon(stationId);
    }
    @ApiOperation(value = "修改机房")
    @PostMapping("updateStatiaon")
    public Response updateStatiaon(@RequestBody StationInf sinf){
        return service.updateStatiaon(sinf);
    }
    @ApiOperation(value = "查询机房")
    @PostMapping("getStatiaon")
    public Response getStatiaon(@RequestBody StationDto dto){
        return service.getStatiaon(dto);
    }
}
src/main/java/com/whyc/dto/StationDto.java
New file
@@ -0,0 +1,14 @@
package com.whyc.dto;
import lombok.Data;
@Data
public class StationDto {
    private String provice;
    private String city;
    private String country;
    private String stationName;
    private Integer pageNum;
    private Integer pageSize;
    private Integer uid;
}
src/main/java/com/whyc/mapper/StationInfMapper.java
@@ -8,7 +8,7 @@
public interface StationInfMapper extends CustomMapper<StationInf>{
    //获取当前最大的机房id
    Integer getMaxStationNum();
    Integer getMaxStationId();
    //获取左侧列表
    List<Provice> getLeftStation(@Param("uid") Integer uid);
    //获取所有的省份
src/main/java/com/whyc/service/StationInfService.java
@@ -2,12 +2,15 @@
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.dto.Station.Provice;
import com.whyc.dto.StationDto;
import com.whyc.mapper.BaojigroupMapper;
import com.whyc.mapper.StationInfMapper;
import com.whyc.pojo.db_station.StationInf;
import com.whyc.pojo.db_user.Baojigroup;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -18,8 +21,6 @@
    @Autowired(required = false)
    private StationInfMapper mapper;
    @Autowired(required = false)
    private BaojigroupMapper groupMapper;
    //获取左侧列表
    public Response getLeftStation(int uid) {
@@ -47,41 +48,36 @@
        return new Response().setII(1,list.size()>0,list,"获取省市区县下的站点");
    }
    //添加机房
   /* public Response addStatiaon(StationInf addsinf) {
   public Response addStatiaon(StationInf addsinf) {
        //判断添加锁的时候机房是不是新机房
        String stationName=addsinf.getStationName1()+"_"+addsinf.getStationName2()+"_"+addsinf.getStationName3()+"_"+addsinf.getStationName4();
        String fullName=addsinf.getProvice()+"_"+addsinf.getCity()+"_"+addsinf.getCountry()+"_"+addsinf.getStationName();
        //判断机房是否存在
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("station_name",stationName);
        wrapper.eq("full_name",fullName);
        wrapper.last("limit 1");
        StationInf sinf=mapper.selectOne(wrapper);
        int stationId=0;
        int lockId=0;
        if(sinf!=null){
            return new Response().set(1,false,"机房已存在");
        }else {
            //获取当前最大的机房id
            Integer maxStationNum=mapper.getMaxStationNum();
            if(maxStationNum==0){//数据库中没有站点
            //获取对应的机房id
            stationId=mapper.getMaxStationId();
            if(stationId==0){//数据库中没有站点
                stationId=40000001;
            }else{
                //获取对应的机房id
                stationId=mapper.getStaitonIdByNum(maxStationNum);
                stationId+=1;
            }
            StationInf newSinf=new StationInf();
            newSinf.setStationId(stationId);
            newSinf.setStationName(stationName);
            newSinf.setStationNum(maxStationNum+1);
            newSinf.setStationName1(addsinf.getStationName1());
            newSinf.setStationName2(addsinf.getStationName2());
            newSinf.setStationName3(addsinf.getStationName3());
            newSinf.setStationName4(addsinf.getStationName4());
            newSinf.setStationName(fullName);
            newSinf.setProvice(addsinf.getProvice());
            newSinf.setCity(addsinf.getCity());
            newSinf.setCountry(addsinf.getCountry());
            newSinf.setStationName(addsinf.getStationName());
            mapper.insert(newSinf);
            linfService.insertInbaoji(stationId,lockId);
            return new Response().set(1,true,"添加机房");
        }
    }*/
    }
    //删除机房
    public Response delStatiaon(Integer stationId) {
        UpdateWrapper wrapper=new UpdateWrapper();
@@ -90,56 +86,45 @@
        return new Response().set(1,true);
    }
    //修改机房
   /* public Response updateStatiaon(StationInf sinf) {
    public Response updateStatiaon(StationInf sinf) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("station_id",sinf.getStationId());
        if(sinf.getStationName1()!=null){
            wrapper.set("station_name1",sinf.getStationName1());
        if(sinf.getProvice()!=null){
            wrapper.set("provice",sinf.getProvice());
        }
        if(sinf.getStationName2()!=null){
            wrapper.set("station_name2",sinf.getStationName2());
        if(sinf.getCity()!=null){
            wrapper.set("city",sinf.getCity());
        }
        if(sinf.getStationName3()!=null){
            wrapper.set("station_name3",sinf.getStationName3());
        if(sinf.getCountry()!=null){
            wrapper.set("country",sinf.getCountry());
        }
        if(sinf.getStationName4()!=null){
            wrapper.set("station_name4",sinf.getStationName4());
        if(sinf.getStationName()!=null){
            wrapper.set("station_name",sinf.getStationName());
        }
        String stationName=sinf.getStationName1()+"_"+sinf.getStationName2()+"_"+sinf.getStationName3()+"_"+sinf.getStationName4();
        wrapper.set("station_name",stationName);
        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 getStatiaon(StationDto dto) {
    public Response getStatiaon(StationDto dto) {
        PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
        QueryWrapper wrapper=new QueryWrapper();
        if(dto.getStationName1()!=null){
            wrapper.eq("station_name1",dto.getStationName1());
        if(dto.getProvice()!=null){
            wrapper.eq("provice",dto.getProvice());
        }
        if(dto.getStationName2()!=null){
            wrapper.eq("station_name2",dto.getStationName2());
        if(dto.getCity()!=null){
            wrapper.eq("city",dto.getCity());
        }
        if(dto.getStationName3()!=null){
            wrapper.eq("station_name3",dto.getStationName3());
        if(dto.getCountry()!=null){
            wrapper.eq("country",dto.getCountry());
        }
        if(dto.getStationName4()!=null){
            wrapper.eq("station_name4",dto.getStationName4());
        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,"查询机房");
    }*/
    //根据stationid和包机组id查询机房名和包机组名
    public Response getNamebyId(Integer stationId, Integer baojiId) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("station_id",stationId);
        wrapper.last("limit 1");
        StationInf sinf=mapper.selectOne(wrapper);
        QueryWrapper wrapper1=new QueryWrapper();
        wrapper1.eq("id",baojiId);
        wrapper1.last("limit 1");
        Baojigroup baoji=groupMapper.selectOne(wrapper1);
        return new Response().setIII(1,true,sinf,baoji,"根据stationid和包机组id查询机房名和包机组名");
    }
}
src/main/resources/mapper/StationInfMapper.xml
@@ -2,8 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.whyc.mapper.StationInfMapper">
    <select id="getMaxStationNum" resultType="java.lang.Integer">
        select ifnull(max(station_num),0) from  db_station.tb_station_inf where station_id>0;
    <select id="getMaxStationId" resultType="java.lang.Integer">
        select ifnull(max(station_id),0) from  db_station.tb_station_inf where station_id>0;
    </select>
    <resultMap id="name1List" type="provice">
        <result property="provice" column="provice" ></result>