whycxzp
2025-03-26 fca1721e4ef9d92242942f6151d026400ab9bd0b
src/main/java/com/whyc/service/PowerInfService.java
@@ -110,19 +110,21 @@
        }
        //电源id查询最大值
        int powerId = mapper.getMaxPowerId();
        powerInf.setPowerId(powerId);
        powerInf.setPowerId(powerId+1);
        //对站点名称进行查询,如果存在则直接绑定关系
        //如果不存在,则新增后,再绑定关系
        StationInf stationInf = stationInfService.getByStationName(powerInf.getStationName());
        Integer stationId = stationInf.getSinfId();
        if(stationInf == null){
            StationInf stationNew = new StationInf();
            stationNew.setSinfName(powerInf.getStationName());
            int stationId = stationInfService.getMaxStationId();
            stationNew.setSinfId(stationId+1);
            int stationIdInDB = stationInfService.getMaxStationId();
            stationId = stationIdInDB + 1;
            stationNew.setSinfId(stationId);
            stationInfService.add(stationNew);
        }
            //站点和电源id关联
            stationPowerRelationService.add(stationId,powerId);
        }
        mapper.insert(powerInf);
        return new Response().setII(1,"新增完成");
    }