whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
src/main/java/com/whyc/service/NjHomeStationService.java
@@ -70,10 +70,46 @@
    }
   //编辑首页机房配置信息
    public Response updateStationConfig(NjHomeStation njHomeConfig) {
        mapper.update(njHomeConfig, null);
    public Response updateStationConfig(int stationId) {
        NjHomeStation njHomeStation=getStation();
        NjHomeStation nj=getStationById(stationId);
        if(njHomeStation!=null){//判断表中是否有数据
            mapper.update(nj, null);
        }else{
            mapper.insert(nj);
        }
        return new Response().set(1,true);
    }
    //获根据stationId获取信息
    public NjHomeStation getStationById(int stationId) {
        NjHomeStation njHomeStation=new NjHomeStation();
        njHomeStation.setStationId(stationId);
        //获取battinf信息
        QueryWrapper wrapperBinf=new QueryWrapper();
        wrapperBinf.eq("stationId",stationId);
        wrapperBinf.last("limit 1");
        Battinf binf=battInfMapper.selectOne(wrapperBinf);
        if(binf!=null){
            njHomeStation.setBattgroupId(binf.getBattGroupId());
            njHomeStation.setDevId(Integer.valueOf(String.valueOf(binf.getFBSDeviceId())));
        }else {
            njHomeStation.setBattgroupId(0);
            njHomeStation.setDevId(0);
        }
        //获取powerinf信息
        QueryWrapper wrapperPinf=new QueryWrapper();
        wrapperPinf.eq("stationId",stationId);
        wrapperPinf.last("limit 1");
        PowerInf pinf=powerInfMapper.selectOne(wrapperPinf);
        if(pinf!=null){
            njHomeStation.setPowerDevId(pinf.getPowerDeviceId());
        }else {
            njHomeStation.setPowerDevId(0);
        }
        return njHomeStation;
    }
    //添加默认首页机房配置信息
    public Response addStationConfig(NjHomeStation njHomeStation) {
        //先清空表后添加