whyclxw
2025-04-17 efd756706f9ffacd21992714f7fc97e8d477df20
机房管理
3个文件已修改
1个文件已添加
155 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/StationInfController.java 35 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/dto/StationDto.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/LockInfService.java 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/StationInfService.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/StationInfController.java
@@ -1,6 +1,9 @@
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.dto.StationDto;
import com.whyc.pojo.plus_inf.LockInf;
import com.whyc.pojo.plus_inf.StationInf;
import com.whyc.pojo.plus_user.UserInf;
import com.whyc.service.StationInfService;
import com.whyc.service.UserInfService;
@@ -8,14 +11,11 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
@RestController
@Api(tags = "左侧列表管理")
@Api(tags = "机房(左侧列表)管理")
@RequestMapping("stationInf")
public class StationInfController {
    @Autowired
@@ -27,4 +27,29 @@
        UserInf uinf= ActionUtil.getUser();
        return service.getLeftStation(uinf.getUid());
    }
    @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 stationName1;
    private String stationName2;
    private String stationName3;
    private String stationName4;
    private Integer pageNum;
    private Integer pageSize;
    private Integer uid;
}
src/main/java/com/whyc/service/LockInfService.java
@@ -121,7 +121,7 @@
        return new Response().set(1,true);
    }
    //包机组操作
    private void insertInbaoji(Integer stationId,Integer lockId){
    public void insertInbaoji(Integer stationId,Integer lockId){
        //重启线程并将锁加到当前人的包机组
        UserInf uinf= ActionUtil.getUser();
        QueryWrapper wrapper1=new QueryWrapper();
@@ -163,7 +163,7 @@
        processSurveyService.setUpThreadRestart();
    }
    //获取当前及放下最大的锁id
    private int getMaxLockId(Integer stationId) {
    public int getMaxLockId(Integer stationId) {
        int lockId=mapper.getMaxLockId(stationId);
        return lockId;
    }
@@ -217,14 +217,7 @@
        mapper.update((LockInf) ActionUtil.objeNull,wrapper);
        return new Response().set(1,true);
    }
    //查询所有锁名信息(用于下拉)
    /*public Response getLinf() {
        List<LockInf> list=mapper.selectList(null);
        List<String> lnameList = list.stream()
                .map(LockInf::getLockName) // 提取名字
                .collect(Collectors.toList()); // 转换为列表
        return new Response().setII(1,list!=null,lnameList,"查询所有锁名信息(用于下拉)");
    }*/
    //查询屏柜的全部类型(下拉)
    public Response getScreenType(Integer uid) {
src/main/java/com/whyc/service/StationInfService.java
@@ -1,10 +1,16 @@
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.dto.Station.Provice;
import com.whyc.dto.StationDto;
import com.whyc.mapper.StationInfMapper;
import com.whyc.pojo.plus_inf.LockInf;
import com.whyc.pojo.plus_inf.StationInf;
import com.whyc.util.ActionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -15,6 +21,9 @@
public class StationInfService {
    @Autowired(required = false)
    private StationInfMapper mapper;
    @Autowired(required = false)
    private LockInfService linfService;
    //获取左侧列表
    public Response getLeftStation(int uid) {
@@ -46,4 +55,88 @@
        List<LockInf> list=mapper.getLockByUid(uid,stationName1,stationName2,stationName3,stationName4);
        return new Response().setII(1,list.size()>0,list,"获取省市区县机房站点下的锁");
    }
    //添加机房
    public Response addStatiaon(StationInf addsinf) {
        //判断添加锁的时候机房是不是新机房
        String stationName=addsinf.getStationName1()+"_"+addsinf.getStationName2()+"_"+addsinf.getStationName3()+"_"+addsinf.getStationName4();
        //判断机房是否存在
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("station_name",stationName);
        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){//数据库中没有站点
                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());
            mapper.insert(newSinf);
            linfService.insertInbaoji(stationId,lockId);
            return new Response().set(1,true,"添加机房");
        }
    }
    //删除机房
    public Response delStatiaon(Integer stationId) {
        UpdateWrapper wrapper=new UpdateWrapper();
        wrapper.eq("station_id",stationId);
        mapper.delete(wrapper);
        return new Response().set(1,true);
    }
    //修改机房
    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.getStationName2()!=null){
            wrapper.set("station_name2",sinf.getStationName2());
        }
        if(sinf.getStationName3()!=null){
            wrapper.set("station_name3",sinf.getStationName3());
        }
        if(sinf.getStationName4()!=null){
            wrapper.set("station_name4",sinf.getStationName4());
        }
        String stationName=sinf.getStationName1()+"_"+sinf.getStationName2()+"_"+sinf.getStationName3()+"_"+sinf.getStationName4();
        wrapper.set("station_name",stationName);
        mapper.update((StationInf) ActionUtil.objeNull,wrapper);
        return new Response().set(1,true);
    }
    //查询机房
    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.getStationName2()!=null){
            wrapper.eq("station_name2",dto.getStationName2());
        }
        if(dto.getStationName3()!=null){
            wrapper.eq("station_name3",dto.getStationName3());
        }
        if(dto.getStationName4()!=null){
            wrapper.eq("station_name4",dto.getStationName4());
        }
        List<StationInf> list=mapper.selectList(wrapper);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list!=null,pageInfo,"查询机房");
    }
}