whyclxw
2024-02-29 d883ad10fa92a9e5b04fc3408c76a67e24fc355e
南京首页
3个文件已修改
68 ■■■■ 已修改文件
src/main/java/com/whyc/controller/NjHomeStationController.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/NjHomeConfig.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/NjHomeStationService.java 54 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/NjHomeStationController.java
@@ -23,14 +23,14 @@
        return service.getStationConfig();
    }
    @PostMapping("updateStationConfig")
    @ApiOperation("编辑首页机房配置信息")
    public Response updateStationConfig(@RequestBody NjHomeStation njHomeStation){
        return service.updateStationConfig(njHomeStation);
    @GetMapping("updateStationConfig")
    @ApiOperation("编辑首页机房配置信息(不存在则插入)")
    public Response updateStationConfig(@RequestParam int stattionid){
        return service.updateStationConfig(stattionid);
    }
    @PostMapping("addStationConfig")
    /*@PostMapping("addStationConfig")
    @ApiOperation("添加默认首页机房配置信息")
    public Response addStationConfig(@RequestBody NjHomeStation njHomeStation){
        return service.addStationConfig(njHomeStation);
    }
    }*/
}
src/main/java/com/whyc/pojo/NjHomeConfig.java
@@ -33,7 +33,7 @@
    @ApiModelProperty(value = "属性是否显示")
    private Integer configFlag;
    @ApiModelProperty(value = "属性分类")
    @ApiModelProperty(value = "属性分类:1:ac 2:acdc 3:dc 4:fbs9100state 5:rtstate")
    private Integer configType;
    @ApiModelProperty(value = "遥测:0,遥信:1")
src/main/java/com/whyc/service/NjHomeStationService.java
@@ -42,38 +42,74 @@
    public Response getStationConfig() {
        NjHomeStation njHomeStation=getStation();
        if(njHomeStation!=null){
            Map<String,Object> map=new HashMap<>();
            //Map<String,Object> map=new HashMap<>();
            //获取battinf信息
            QueryWrapper wrapperBinf=new QueryWrapper();
            /*QueryWrapper wrapperBinf=new QueryWrapper();
            wrapperBinf.eq("BattGroupId",njHomeStation.getBattgroupId());
            wrapperBinf.last("limit 1");
            Battinf binf=battInfMapper.selectOne(wrapperBinf);
            map.put("binf",binf);
            map.put("binf",binf);*/
            //获取statinf信息
            QueryWrapper wrapperSinf=new QueryWrapper();
            wrapperSinf.eq("stationId",njHomeStation.getStationId());
            wrapperSinf.last("limit 1");
            StationInf sinf=stationInfMapper.selectOne(wrapperSinf);
            map.put("sinf",sinf);
            ///map.put("sinf",sinf);
/*
            //获取powerinf信息
            QueryWrapper wrapperPinf=new QueryWrapper();
            wrapperPinf.eq("PowerDeviceId",njHomeStation.getPowerDevId());
            wrapperPinf.last("limit 1");
            PowerInf pinf=powerInfMapper.selectOne(wrapperPinf);
            map.put("pinf",pinf);
            return new Response().setII(1,true,map,"获取首页机房配置信息");
            map.put("pinf",pinf);*/
            return new Response().setII(1,true,sinf,"获取首页机房配置信息");
        }else{
            return new Response().set(1,false,"获取首页机房配置信息");
        }
    }
   //编辑首页机房配置信息
    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) {
        //先清空表后添加