whycxzp
2025-03-24 a9a9e8eea1a9d254b631164d14fe164671e9c6e4
电池和电源信息管理
5个文件已修改
5个文件已添加
293 ■■■■■ 已修改文件
src/main/java/com/whyc/controller/BattInfController.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/PowerInfController.java 50 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/mapper/BattInfMapper.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/db_batt/BattInf.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/db_batt/PowerInf.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/db_power_rt/PowerRealRt1.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/db_power_rt/PowerRealRt2.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/db_power_rt/PowerRealRt3.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/BattInfService.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/PowerInfService.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/controller/BattInfController.java
New file
@@ -0,0 +1,50 @@
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.pojo.db_batt.BattInf;
import com.whyc.service.BattInfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@Api(tags = "电池信息")
@RequestMapping("battInf")
public class BattInfController {
    @Autowired
    private BattInfService service;
    @ApiOperation("新增")
    @PostMapping("add")
    public Response add(@RequestBody BattInf battInf){
        return service.add(battInf);
    }
    @ApiOperation("删除")
    @PostMapping("delete")
    public Response delete(@RequestParam int battGroupId){
        return service.delete(battGroupId);
    }
    @ApiOperation("修改")
    @PostMapping("update")
    public Response update(@RequestBody BattInf battInf){
        return service.update(battInf);
    }
    @ApiOperation("查询-分页")
    @GetMapping("getPage")
    public Response getPage(@RequestParam int pageNum,@RequestParam int pageSize){
        return service.getPage(pageNum,pageSize);
    }
    @ApiOperation("查询-根据id")
    @GetMapping("getById")
    public Response getById(@RequestParam int battGroupId){
        return service.getById(battGroupId);
    }
}
src/main/java/com/whyc/controller/PowerInfController.java
New file
@@ -0,0 +1,50 @@
package com.whyc.controller;
import com.whyc.dto.Response;
import com.whyc.pojo.db_batt.PowerInf;
import com.whyc.service.PowerInfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@Api(tags = "电源信息")
@RequestMapping("powerInf")
public class PowerInfController {
    @Autowired
    private PowerInfService service;
    @ApiOperation("新增")
    @PostMapping("add")
    public Response add(@RequestBody PowerInf powerInf){
        return service.add(powerInf);
    }
    @ApiOperation("删除")
    @PostMapping("delete")
    public Response delete(@RequestParam int powerId){
        return service.delete(powerId);
    }
    @ApiOperation("修改")
    @PostMapping("update")
    public Response update(@RequestBody PowerInf powerInf){
        return service.update(powerInf);
    }
    @ApiOperation("查询-分页")
    @GetMapping("getPage")
    public Response getPage(@RequestParam int pageNum,@RequestParam int pageSize){
        return service.getPage(pageNum,pageSize);
    }
    @ApiOperation("查询-根据id")
    @GetMapping("getById")
    public Response getById(@RequestParam int powerId){
        return service.getById(powerId);
    }
}
src/main/java/com/whyc/mapper/BattInfMapper.java
New file
@@ -0,0 +1,6 @@
package com.whyc.mapper;
import com.whyc.pojo.db_batt.BattInf;
public interface BattInfMapper extends CustomMapper<BattInf>{
}
src/main/java/com/whyc/pojo/db_batt/BattInf.java
New file
@@ -0,0 +1,81 @@
package com.whyc.pojo.db_batt;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.ToString;
@TableName(schema = "db_batt",value = "batt_inf")
@ToString
public class BattInf {
    @TableId(value = "binf_id", type = IdType.AUTO)
    private Integer battGroupId;
    @TableField("binf_name")
    private String battGroupName;
    private Integer monCount;
    private Float monVol;
    private Float monCap;
    private Float monRes;
    private Float loadCurr;
    public Integer getBattGroupId() {
        return battGroupId;
    }
    public void setBattGroupId(Integer battGroupId) {
        this.battGroupId = battGroupId;
    }
    public String getBattGroupName() {
        return battGroupName;
    }
    public void setBattGroupName(String battGroupName) {
        this.battGroupName = battGroupName;
    }
    public Integer getMonCount() {
        return monCount;
    }
    public void setMonCount(Integer monCount) {
        this.monCount = monCount;
    }
    public Float getMonVol() {
        return monVol;
    }
    public void setMonVol(Float monVol) {
        this.monVol = monVol;
    }
    public Float getMonCap() {
        return monCap;
    }
    public void setMonCap(Float monCap) {
        this.monCap = monCap;
    }
    public Float getMonRes() {
        return monRes;
    }
    public void setMonRes(Float monRes) {
        this.monRes = monRes;
    }
    public Float getLoadCurr() {
        return loadCurr;
    }
    public void setLoadCurr(Float loadCurr) {
        this.loadCurr = loadCurr;
    }
}
src/main/java/com/whyc/pojo/db_batt/PowerInf.java
@@ -1,6 +1,8 @@
package com.whyc.pojo.db_batt;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
@@ -20,7 +22,7 @@
@TableName(schema = "db_batt",value = "power_inf")
public class PowerInf {
    @TableField("power_id")
    @TableId(type = IdType.AUTO)
    @ApiModelProperty("电源id")
    private Integer powerId;
src/main/java/com/whyc/pojo/db_power_rt/PowerRealRt1.java
@@ -14,12 +14,7 @@
import java.util.Date;
/**
 * <p>
 *
 * </p>
 *
 * @author lxw
 * @since 2024-12-04
 * 电源类型1实时数据
 */
@Data
@EqualsAndHashCode(callSuper = false)
src/main/java/com/whyc/pojo/db_power_rt/PowerRealRt2.java
@@ -14,12 +14,7 @@
import java.util.Date;
/**
 * <p>
 *
 * </p>
 *
 * @author lxw
 * @since 2024-12-04
 * 电源类型2实时数据
 */
@Data
@EqualsAndHashCode(callSuper = false)
src/main/java/com/whyc/pojo/db_power_rt/PowerRealRt3.java
@@ -14,12 +14,9 @@
import java.util.Date;
/**
 * <p>
 *
 * </p>
 * 电源类型3实时数据
 *
 * @author lxw
 * @since 2024-12-04
 */
@Data
@EqualsAndHashCode(callSuper = false)
src/main/java/com/whyc/service/BattInfService.java
New file
@@ -0,0 +1,51 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.mapper.*;
import com.whyc.pojo.db_batt.BattInf;
import com.whyc.pojo.db_power_alarm.PowerAlarm;
import com.whyc.pojo.db_real_batt.RtData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class BattInfService {
    @Autowired(required = false)
    private BattInfMapper mapper;
    public Response add(BattInf battInf) {
        mapper.insert(battInf);
        return new Response().setII(1,"新增完成");
    }
    public Response delete(int battGroupId) {
        mapper.deleteById(battGroupId);
        return new Response().setII(1,"删除完成");
    }
    public Response update(BattInf battInf) {
        mapper.updateById(battInf);
        return new Response().setII(1,"修改完成");
    }
    public Response getPage(int pageNum, int pageSize) {
        PageHelper helper = new PageHelper();
        helper.startPage(pageNum,pageSize);
        List<BattInf> battInfs = mapper.selectList(null);
        PageInfo<BattInf> pageInfo = new PageInfo<>(battInfs);
        return new Response().set(1,pageInfo);
    }
    public Response getById(int battGroupId) {
        BattInf battInf = mapper.selectById(battGroupId);
        return new Response().set(1,battInf);
    }
}
src/main/java/com/whyc/service/PowerInfService.java
@@ -1,6 +1,9 @@
package com.whyc.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.whyc.dto.Response;
import com.whyc.mapper.*;
import com.whyc.pojo.db_batt.PowerInf;
import com.whyc.pojo.db_power_alarm.PowerAlarm;
@@ -77,4 +80,33 @@
        List<RtData> list=rtDataMapper.selectList(wrapper);
        return list;
    }
    public Response add(PowerInf powerInf) {
        mapper.insert(powerInf);
        return new Response().setII(1,"新增完成");
    }
    public Response delete(int powerId) {
        mapper.deleteById(powerId);
        return new Response().setII(1,"删除完成");
    }
    public Response update(PowerInf powerInf) {
        mapper.updateById(powerInf);
        return new Response().setII(1,"修改完成");
    }
    public Response getPage(int pageNum, int pageSize) {
        PageHelper helper = new PageHelper();
        helper.startPage(pageNum,pageSize);
        List<PowerInf> powerInfs = mapper.selectList(null);
        PageInfo<PowerInf> pageInfo = new PageInfo<>(powerInfs);
        return new Response().set(1,pageInfo);
    }
    public Response getById(int powerId) {
        PowerInf powerInf = mapper.selectById(powerId);
        return new Response().set(1,powerInf);
    }
}