From 65190d56d14afaa35eeecd35305611b43116aa3b Mon Sep 17 00:00:00 2001 From: hezi66677 <847517741@qq.com> Date: Mon, 25 Nov 2024 00:14:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E6=97=B6=E7=9B=91=E6=B5=8B=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/RealtimeController.java | 104 +++++++++++++++++ .../com/ruoyi/system/domain/Realtime.java | 107 ++++++++++++++++++ .../ruoyi/system/mapper/RealtimeMapper.java | 61 ++++++++++ .../system/service/IRealtimeService.java | 61 ++++++++++ .../service/impl/RealtimeServiceImpl.java | 93 +++++++++++++++ .../mapper/system/RealtimeMapper.xml | 76 +++++++++++++ 6 files changed, 502 insertions(+) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/controller/RealtimeController.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/Realtime.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/mapper/RealtimeMapper.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/IRealtimeService.java create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RealtimeServiceImpl.java create mode 100644 ruoyi-system/src/main/resources/mapper/system/RealtimeMapper.xml diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/controller/RealtimeController.java b/ruoyi-system/src/main/java/com/ruoyi/system/controller/RealtimeController.java new file mode 100644 index 0000000..99030a6 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/controller/RealtimeController.java @@ -0,0 +1,104 @@ +package com.ruoyi.system.controller; + +import java.util.List; +import javax.servlet.http.HttpServletResponse; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.system.domain.Realtime; +import com.ruoyi.system.service.IRealtimeService; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.common.core.page.TableDataInfo; + +/** + * 实时状况Controller + * + * @author 徐天乐 + * @date 2024-11-24 + */ +@RestController +@RequestMapping("/system/realtime") +public class RealtimeController extends BaseController +{ + @Autowired + private IRealtimeService realtimeService; + + /** + * 查询实时状况列表 + */ + @PreAuthorize("@ss.hasPermi('system:realtime:list')") + @GetMapping("/list") + public TableDataInfo list(Realtime realtime) + { + startPage(); + List list = realtimeService.selectRealtimeList(realtime); + return getDataTable(list); + } + + /** + * 导出实时状况列表 + */ + @PreAuthorize("@ss.hasPermi('system:realtime:export')") + @Log(title = "实时状况", businessType = BusinessType.EXPORT) + @PostMapping("/export") + public void export(HttpServletResponse response, Realtime realtime) + { + List list = realtimeService.selectRealtimeList(realtime); + ExcelUtil util = new ExcelUtil(Realtime.class); + util.exportExcel(response, list, "实时状况数据"); + } + + /** + * 获取实时状况详细信息 + */ + @PreAuthorize("@ss.hasPermi('system:realtime:query')") + @GetMapping(value = "/{id}") + public AjaxResult getInfo(@PathVariable("id") Long id) + { + return success(realtimeService.selectRealtimeById(id)); + } + + /** + * 新增实时状况 + */ + @PreAuthorize("@ss.hasPermi('system:realtime:add')") + @Log(title = "实时状况", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody Realtime realtime) + { + return toAjax(realtimeService.insertRealtime(realtime)); + } + + /** + * 修改实时状况 + */ + @PreAuthorize("@ss.hasPermi('system:realtime:edit')") + @Log(title = "实时状况", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody Realtime realtime) + { + return toAjax(realtimeService.updateRealtime(realtime)); + } + + /** + * 删除实时状况 + */ + @PreAuthorize("@ss.hasPermi('system:realtime:remove')") + @Log(title = "实时状况", businessType = BusinessType.DELETE) + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) + { + return toAjax(realtimeService.deleteRealtimeByIds(ids)); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/Realtime.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Realtime.java new file mode 100644 index 0000000..145a6c1 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/Realtime.java @@ -0,0 +1,107 @@ +package com.ruoyi.system.domain; + +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 实时状况对象 realtime + * + * @author 徐天乐 + * @date 2024-11-24 + */ +public class Realtime extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** id */ + private Long id; + + /** 实时负荷 */ + @Excel(name = "实时负荷") + private String powertime; + + /** 设备总数 */ + @Excel(name = "设备总数") + private String equipmenttime; + + /** 设备在线 */ + @Excel(name = "设备在线") + private String onlinetime; + + /** 警告次数 */ + @Excel(name = "警告次数") + private String alarmtime; + + /** 今日用电 */ + @Excel(name = "今日用电") + private String electricitytime; + + public void setId(Long id) + { + this.id = id; + } + + public Long getId() + { + return id; + } + public void setPowertime(String powertime) + { + this.powertime = powertime; + } + + public String getPowertime() + { + return powertime; + } + public void setEquipmenttime(String equipmenttime) + { + this.equipmenttime = equipmenttime; + } + + public String getEquipmenttime() + { + return equipmenttime; + } + public void setOnlinetime(String onlinetime) + { + this.onlinetime = onlinetime; + } + + public String getOnlinetime() + { + return onlinetime; + } + public void setAlarmtime(String alarmtime) + { + this.alarmtime = alarmtime; + } + + public String getAlarmtime() + { + return alarmtime; + } + public void setElectricitytime(String electricitytime) + { + this.electricitytime = electricitytime; + } + + public String getElectricitytime() + { + return electricitytime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("powertime", getPowertime()) + .append("equipmenttime", getEquipmenttime()) + .append("onlinetime", getOnlinetime()) + .append("alarmtime", getAlarmtime()) + .append("electricitytime", getElectricitytime()) + .toString(); + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RealtimeMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RealtimeMapper.java new file mode 100644 index 0000000..383f4bc --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/RealtimeMapper.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.mapper; + +import java.util.List; +import com.ruoyi.system.domain.Realtime; + +/** + * 实时状况Mapper接口 + * + * @author 徐天乐 + * @date 2024-11-24 + */ +public interface RealtimeMapper +{ + /** + * 查询实时状况 + * + * @param id 实时状况主键 + * @return 实时状况 + */ + public Realtime selectRealtimeById(Long id); + + /** + * 查询实时状况列表 + * + * @param realtime 实时状况 + * @return 实时状况集合 + */ + public List selectRealtimeList(Realtime realtime); + + /** + * 新增实时状况 + * + * @param realtime 实时状况 + * @return 结果 + */ + public int insertRealtime(Realtime realtime); + + /** + * 修改实时状况 + * + * @param realtime 实时状况 + * @return 结果 + */ + public int updateRealtime(Realtime realtime); + + /** + * 删除实时状况 + * + * @param id 实时状况主键 + * @return 结果 + */ + public int deleteRealtimeById(Long id); + + /** + * 批量删除实时状况 + * + * @param ids 需要删除的数据主键集合 + * @return 结果 + */ + public int deleteRealtimeByIds(Long[] ids); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/IRealtimeService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/IRealtimeService.java new file mode 100644 index 0000000..f0451d4 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/IRealtimeService.java @@ -0,0 +1,61 @@ +package com.ruoyi.system.service; + +import java.util.List; +import com.ruoyi.system.domain.Realtime; + +/** + * 实时状况Service接口 + * + * @author 徐天乐 + * @date 2024-11-24 + */ +public interface IRealtimeService +{ + /** + * 查询实时状况 + * + * @param id 实时状况主键 + * @return 实时状况 + */ + public Realtime selectRealtimeById(Long id); + + /** + * 查询实时状况列表 + * + * @param realtime 实时状况 + * @return 实时状况集合 + */ + public List selectRealtimeList(Realtime realtime); + + /** + * 新增实时状况 + * + * @param realtime 实时状况 + * @return 结果 + */ + public int insertRealtime(Realtime realtime); + + /** + * 修改实时状况 + * + * @param realtime 实时状况 + * @return 结果 + */ + public int updateRealtime(Realtime realtime); + + /** + * 批量删除实时状况 + * + * @param ids 需要删除的实时状况主键集合 + * @return 结果 + */ + public int deleteRealtimeByIds(Long[] ids); + + /** + * 删除实时状况信息 + * + * @param id 实时状况主键 + * @return 结果 + */ + public int deleteRealtimeById(Long id); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RealtimeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RealtimeServiceImpl.java new file mode 100644 index 0000000..258ee37 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/RealtimeServiceImpl.java @@ -0,0 +1,93 @@ +package com.ruoyi.system.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.system.mapper.RealtimeMapper; +import com.ruoyi.system.domain.Realtime; +import com.ruoyi.system.service.IRealtimeService; + +/** + * 实时状况Service业务层处理 + * + * @author 徐天乐 + * @date 2024-11-24 + */ +@Service +public class RealtimeServiceImpl implements IRealtimeService +{ + @Autowired + private RealtimeMapper realtimeMapper; + + /** + * 查询实时状况 + * + * @param id 实时状况主键 + * @return 实时状况 + */ + @Override + public Realtime selectRealtimeById(Long id) + { + return realtimeMapper.selectRealtimeById(id); + } + + /** + * 查询实时状况列表 + * + * @param realtime 实时状况 + * @return 实时状况 + */ + @Override + public List selectRealtimeList(Realtime realtime) + { + return realtimeMapper.selectRealtimeList(realtime); + } + + /** + * 新增实时状况 + * + * @param realtime 实时状况 + * @return 结果 + */ + @Override + public int insertRealtime(Realtime realtime) + { + return realtimeMapper.insertRealtime(realtime); + } + + /** + * 修改实时状况 + * + * @param realtime 实时状况 + * @return 结果 + */ + @Override + public int updateRealtime(Realtime realtime) + { + return realtimeMapper.updateRealtime(realtime); + } + + /** + * 批量删除实时状况 + * + * @param ids 需要删除的实时状况主键 + * @return 结果 + */ + @Override + public int deleteRealtimeByIds(Long[] ids) + { + return realtimeMapper.deleteRealtimeByIds(ids); + } + + /** + * 删除实时状况信息 + * + * @param id 实时状况主键 + * @return 结果 + */ + @Override + public int deleteRealtimeById(Long id) + { + return realtimeMapper.deleteRealtimeById(id); + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/RealtimeMapper.xml b/ruoyi-system/src/main/resources/mapper/system/RealtimeMapper.xml new file mode 100644 index 0000000..7d7e9c7 --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/system/RealtimeMapper.xml @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + select id, powertime, equipmenttime, onlinetime, alarmtime, electricitytime from realtime + + + + + + + + insert into realtime + + powertime, + equipmenttime, + onlinetime, + alarmtime, + electricitytime, + + + #{powertime}, + #{equipmenttime}, + #{onlinetime}, + #{alarmtime}, + #{electricitytime}, + + + + + update realtime + + powertime = #{powertime}, + equipmenttime = #{equipmenttime}, + onlinetime = #{onlinetime}, + alarmtime = #{alarmtime}, + electricitytime = #{electricitytime}, + + where id = #{id} + + + + delete from realtime where id = #{id} + + + + delete from realtime where id in + + #{id} + + + \ No newline at end of file