whyclxw
2025-06-10 36429d0693087ee72083d2ff7ce1475e15e9b8e5
设备告警参数查询修改
4个文件已修改
56 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/AlmParamController.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/DevAlmparamMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/BattAlmparamService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/DevAlmparamService.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/AlmParamController.java
@@ -3,16 +3,14 @@
import com.whyc.dto.Real.AlmDto;
import com.whyc.dto.Response;
import com.whyc.pojo.db_param.BattAlmparam;
import com.whyc.pojo.db_param.DevAlmparam;
import com.whyc.service.BattAlmparamService;
import com.whyc.service.DevAlmparamService;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -40,4 +38,15 @@
        return battAlmparamService.setBattAlmParam(almparamList);
    }
    @GetMapping("getDevAlmParam")
    @ApiOperation("获取设备告警参数")
    public Response getDevAlmParam(@RequestParam(required = false) Integer almId,@RequestParam Integer pageNum,@RequestParam Integer pageSize){
        return devAlmparamService.getDevAlmParam(almId,pageNum,pageSize);
    }
    @PostMapping("setDevAlmParam")
    @ApiOperation("修改设备告警参数")
    public Response setDevAlmParam(@RequestBody List<DevAlmparam> almparamList){
        return devAlmparamService.setDevAlmParam(almparamList);
    }
}
src/main/java/com/whyc/mapper/DevAlmparamMapper.java
@@ -1,6 +1,10 @@
package com.whyc.mapper;
import com.whyc.dto.Real.AlmDto;
import com.whyc.pojo.db_param.BattAlmparam;
import com.whyc.pojo.db_param.DevAlmparam;
import java.util.List;
public interface DevAlmparamMapper extends CustomMapper<DevAlmparam>{
}
src/main/java/com/whyc/service/BattAlmparamService.java
@@ -34,4 +34,6 @@
        }
        return new Response().set(1,true,"修改电池告警参数");
    }
}
src/main/java/com/whyc/service/DevAlmparamService.java
@@ -1,11 +1,44 @@
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.Real.AlmDto;
import com.whyc.dto.Response;
import com.whyc.mapper.DevAlmparamMapper;
import com.whyc.pojo.db_param.BattAlmparam;
import com.whyc.pojo.db_param.DevAlmparam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@Service
public class DevAlmparamService {
    @Autowired(required = false)
    private DevAlmparamMapper mapper;
    //获取设备告警参数
    public Response getDevAlmParam(Integer almId,Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        QueryWrapper wrapper=new QueryWrapper();
        if(almId!=null){
            wrapper.eq("alm_id",almId);
        }
        wrapper.orderByAsc("alm_id");
        List<DevAlmparam> list=mapper.selectList(wrapper);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list!=null,pageInfo,"获取设备告警参数");
    }
    //修改设备告警参数
    public Response setDevAlmParam(List<DevAlmparam> almparamList) {
        for (DevAlmparam param:almparamList) {
            UpdateWrapper wrapper=new UpdateWrapper();
            wrapper.eq("alm_id",param.getAlmId());
            mapper.update(param,wrapper);
        }
        return new Response().set(1,true,"修改设备告警参数");
    }
}