From 76fa809c604164e824e88cae9ee455269595ba18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=A2=E5=BA=8F=E6=8C=AF?= Date: Tue, 3 Sep 2024 18:47:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=BB=9C=E8=AE=BE=E5=A4=87-=E8=AE=BE?= =?UTF-8?q?=E5=A4=87=E7=AE=A1=E7=90=86=E3=80=81=E8=AE=BE=E5=A4=87=E8=BF=90?= =?UTF-8?q?=E8=A1=8C=E5=88=86=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wlsbEqInfo/WlsbEqInfoController.java | 7 + .../wlsbEqState/WlsbEqStateController.java | 5 + .../domain/WlsbEqInfoForStartStop.java | 24 ++++ .../wlsbEqInfo/mapper/WlsbEqInfoMapper.java | 23 ++-- .../service/IWlsbEqInfoService.java | 6 + .../service/impl/WlsbEqInfoServiceImpl.java | 10 ++ .../god/wlsbEqState/domain/OnlineTime.java | 26 ++++ .../wlsbEqState/mapper/WlsbEqStateMapper.java | 3 + .../service/IWlsbEqStateService.java | 6 +- .../service/impl/WlsbEqStateServiceImpl.java | 22 ++++ .../mapper/wlsbEqInfo/WlsbEqInfoMapper.xml | 10 ++ .../mapper/wlsbEqState/WlsbEqStateMapper.xml | 123 ++++++++++++------ .../src/views/wlsbEqState/eqState/index.vue | 1 + 13 files changed, 217 insertions(+), 49 deletions(-) create mode 100644 God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/domain/WlsbEqInfoForStartStop.java create mode 100644 God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/domain/OnlineTime.java diff --git a/God-Vue-master/god-admin/src/main/java/com/god/web/controller/wlsbEqInfo/WlsbEqInfoController.java b/God-Vue-master/god-admin/src/main/java/com/god/web/controller/wlsbEqInfo/WlsbEqInfoController.java index ea4cf30c..de280947 100644 --- a/God-Vue-master/god-admin/src/main/java/com/god/web/controller/wlsbEqInfo/WlsbEqInfoController.java +++ b/God-Vue-master/god-admin/src/main/java/com/god/web/controller/wlsbEqInfo/WlsbEqInfoController.java @@ -39,6 +39,13 @@ public class WlsbEqInfoController extends BaseController List list = wlsbEqInfoService.selectWlsbEqInfoList(wlsbEqInfo); return getDataTable(list); } + /** + * 查询设备在线数量和总数量 + */ + @GetMapping("/wlsbEqInfoForStartStop") + public AjaxResult wlsbEqInfoForStartStop() { + return AjaxResult.success(wlsbEqInfoService.wlsbEqInfoForStartStop()); + } /** * 导出设备管理列表 diff --git a/God-Vue-master/god-admin/src/main/java/com/god/web/controller/wlsbEqState/WlsbEqStateController.java b/God-Vue-master/god-admin/src/main/java/com/god/web/controller/wlsbEqState/WlsbEqStateController.java index 6fc9001a..e076f301 100644 --- a/God-Vue-master/god-admin/src/main/java/com/god/web/controller/wlsbEqState/WlsbEqStateController.java +++ b/God-Vue-master/god-admin/src/main/java/com/god/web/controller/wlsbEqState/WlsbEqStateController.java @@ -63,6 +63,11 @@ public class WlsbEqStateController extends BaseController return success(wlsbEqStateService.selectWlsbEqStateById(id)); } + @GetMapping(value = "/onlineTime") + public AjaxResult onlineTime() { + return success(wlsbEqStateService.onlineTime()); + } + /** * 新增设备运行分析 */ diff --git a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/domain/WlsbEqInfoForStartStop.java b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/domain/WlsbEqInfoForStartStop.java new file mode 100644 index 00000000..8bfae91d --- /dev/null +++ b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/domain/WlsbEqInfoForStartStop.java @@ -0,0 +1,24 @@ +package com.god.wlsbEqInfo.domain; + +import lombok.Data; + +/** + * 设备管理对象 wlsb_eq_info + * + * @author Lxz + * @date 2024-09-02 + */ +@Data +public class WlsbEqInfoForStartStop { + + /** + * 总数量 + */ + private String totalDevices; + + /** + * 在线数量 + */ + private String onlineDevices; + +} diff --git a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/mapper/WlsbEqInfoMapper.java b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/mapper/WlsbEqInfoMapper.java index 2a134c1d..ec3f0ffa 100644 --- a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/mapper/WlsbEqInfoMapper.java +++ b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/mapper/WlsbEqInfoMapper.java @@ -1,20 +1,20 @@ package com.god.wlsbEqInfo.mapper; import com.god.wlsbEqInfo.domain.WlsbEqInfo; +import com.god.wlsbEqInfo.domain.WlsbEqInfoForStartStop; import java.util.List; /** * 设备管理Mapper接口 - * + * * @author Lxz * @date 2024-09-02 */ -public interface WlsbEqInfoMapper -{ +public interface WlsbEqInfoMapper { /** * 查询设备管理 - * + * * @param id 设备管理主键 * @return 设备管理 */ @@ -22,7 +22,7 @@ public interface WlsbEqInfoMapper /** * 查询设备管理列表 - * + * * @param wlsbEqInfo 设备管理 * @return 设备管理集合 */ @@ -30,7 +30,7 @@ public interface WlsbEqInfoMapper /** * 新增设备管理 - * + * * @param wlsbEqInfo 设备管理 * @return 结果 */ @@ -38,7 +38,7 @@ public interface WlsbEqInfoMapper /** * 修改设备管理 - * + * * @param wlsbEqInfo 设备管理 * @return 结果 */ @@ -46,7 +46,7 @@ public interface WlsbEqInfoMapper /** * 删除设备管理 - * + * * @param id 设备管理主键 * @return 结果 */ @@ -54,11 +54,16 @@ public interface WlsbEqInfoMapper /** * 批量删除设备管理 - * + * * @param ids 需要删除的数据主键集合 * @return 结果 */ public int deleteWlsbEqInfoByIds(String[] ids); String getMaxSnByPrefix(String yyyyMM); + + /** + * 查询设备在线数量和总数量 + */ + WlsbEqInfoForStartStop wlsbEqInfoForStartStop(); } diff --git a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/service/IWlsbEqInfoService.java b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/service/IWlsbEqInfoService.java index e63c32c1..8b12be67 100644 --- a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/service/IWlsbEqInfoService.java +++ b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/service/IWlsbEqInfoService.java @@ -1,6 +1,7 @@ package com.god.wlsbEqInfo.service; import com.god.wlsbEqInfo.domain.WlsbEqInfo; +import com.god.wlsbEqInfo.domain.WlsbEqInfoForStartStop; import java.util.List; @@ -59,4 +60,9 @@ public interface IWlsbEqInfoService * @return 结果 */ public int deleteWlsbEqInfoById(String id); + + /** + * 查询设备在线数量和总数量 + */ + WlsbEqInfoForStartStop wlsbEqInfoForStartStop(); } diff --git a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/service/impl/WlsbEqInfoServiceImpl.java b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/service/impl/WlsbEqInfoServiceImpl.java index 729e3cda..10b359a5 100644 --- a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/service/impl/WlsbEqInfoServiceImpl.java +++ b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqInfo/service/impl/WlsbEqInfoServiceImpl.java @@ -3,6 +3,7 @@ package com.god.wlsbEqInfo.service.impl; import com.god.common.utils.serialNumber.SerialNumberService; import com.god.common.utils.uuid.IdUtils; import com.god.wlsbEqInfo.domain.WlsbEqInfo; +import com.god.wlsbEqInfo.domain.WlsbEqInfoForStartStop; import com.god.wlsbEqInfo.mapper.WlsbEqInfoMapper; import com.god.wlsbEqInfo.service.IWlsbEqInfoService; import com.god.wlsbEqState.domain.WlsbEqState; @@ -107,6 +108,15 @@ public class WlsbEqInfoServiceImpl implements IWlsbEqInfoService { return wlsbEqInfoMapper.deleteWlsbEqInfoById(id); } + /** + * 查询设备在线数量和总数量 + */ + @Override + public WlsbEqInfoForStartStop wlsbEqInfoForStartStop() { + return wlsbEqInfoMapper.wlsbEqInfoForStartStop(); + } + + //以下是插入设备运行记录 void instertWlsbEqState(WlsbEqInfo wlsbEqInfo) { String formattedDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); diff --git a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/domain/OnlineTime.java b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/domain/OnlineTime.java new file mode 100644 index 00000000..35113f4c --- /dev/null +++ b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/domain/OnlineTime.java @@ -0,0 +1,26 @@ +package com.god.wlsbEqState.domain; + +import lombok.Data; + +/** + * 设备在线离线管理对象 wlsb_eq_info + * + * @author Lxz + * @date 2024-09-02 + */ +@Data +public class OnlineTime { + + /** + * 在线时长 + */ + private String onlineTime; + + /** + * 离线时长 + */ + private String offlineTime; + private String eqNum; + private String note1; + +} diff --git a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/mapper/WlsbEqStateMapper.java b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/mapper/WlsbEqStateMapper.java index d49f6101..94e36d40 100644 --- a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/mapper/WlsbEqStateMapper.java +++ b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/mapper/WlsbEqStateMapper.java @@ -1,5 +1,6 @@ package com.god.wlsbEqState.mapper; +import com.god.wlsbEqState.domain.OnlineTime; import com.god.wlsbEqState.domain.WlsbEqState; import java.util.List; @@ -61,4 +62,6 @@ public interface WlsbEqStateMapper public int deleteWlsbEqStateByIds(String[] ids); //查询运行时间 WlsbEqState selectWlsbEqStateByEqNum(String eqNum); + + List onlineTime(); } diff --git a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/service/IWlsbEqStateService.java b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/service/IWlsbEqStateService.java index 32baf196..100aa2a4 100644 --- a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/service/IWlsbEqStateService.java +++ b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/service/IWlsbEqStateService.java @@ -1,8 +1,10 @@ package com.god.wlsbEqState.service; -import java.util.List; +import com.god.wlsbEqState.domain.OnlineTime; import com.god.wlsbEqState.domain.WlsbEqState; +import java.util.List; + /** * 设备运行分析Service接口 * @@ -58,4 +60,6 @@ public interface IWlsbEqStateService * @return 结果 */ public int deleteWlsbEqStateById(String id); + + List onlineTime(); } diff --git a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/service/impl/WlsbEqStateServiceImpl.java b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/service/impl/WlsbEqStateServiceImpl.java index 789ae0ff..2491bfcb 100644 --- a/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/service/impl/WlsbEqStateServiceImpl.java +++ b/God-Vue-master/god-system/src/main/java/com/god/wlsbEqState/service/impl/WlsbEqStateServiceImpl.java @@ -1,6 +1,7 @@ package com.god.wlsbEqState.service.impl; import com.god.common.utils.uuid.IdUtils; +import com.god.wlsbEqState.domain.OnlineTime; import com.god.wlsbEqState.domain.WlsbEqState; import com.god.wlsbEqState.mapper.WlsbEqStateMapper; import com.god.wlsbEqState.service.IWlsbEqStateService; @@ -95,4 +96,25 @@ public class WlsbEqStateServiceImpl implements IWlsbEqStateService { public int deleteWlsbEqStateById(String id) { return wlsbEqStateMapper.deleteWlsbEqStateById(id); } + + @Override + public List onlineTime() { + List onlineTimeList = wlsbEqStateMapper.onlineTime(); + + for (OnlineTime time : onlineTimeList) { + try { + double offlineTime = Double.parseDouble(time.getOfflineTime()); + double onlineTimeValue = Double.parseDouble(time.getOnlineTime()); + + // 计算并设置新的离线时间 + double calculatedOfflineTime = offlineTime - onlineTimeValue; + time.setOfflineTime(String.valueOf(calculatedOfflineTime)); + } catch (NumberFormatException e) { + // 处理异常,记录日志并设置默认值 + System.err.println("Invalid number format in OnlineTime: " + e.getMessage()); + time.setOfflineTime("0"); + } + } + return onlineTimeList; + } } diff --git a/God-Vue-master/god-system/src/main/resources/mapper/wlsbEqInfo/WlsbEqInfoMapper.xml b/God-Vue-master/god-system/src/main/resources/mapper/wlsbEqInfo/WlsbEqInfoMapper.xml index d9795cbb..1c7c4ac7 100644 --- a/God-Vue-master/god-system/src/main/resources/mapper/wlsbEqInfo/WlsbEqInfoMapper.xml +++ b/God-Vue-master/god-system/src/main/resources/mapper/wlsbEqInfo/WlsbEqInfoMapper.xml @@ -16,6 +16,10 @@ + + + + select id, @@ -71,6 +75,12 @@ WHERE eq_num LIKE CONCAT(#{prefix}, '%') order by eq_num desc limit 1 + insert into wlsb_eq_info diff --git a/God-Vue-master/god-system/src/main/resources/mapper/wlsbEqState/WlsbEqStateMapper.xml b/God-Vue-master/god-system/src/main/resources/mapper/wlsbEqState/WlsbEqStateMapper.xml index 0e902f2d..6a297716 100644 --- a/God-Vue-master/god-system/src/main/resources/mapper/wlsbEqState/WlsbEqStateMapper.xml +++ b/God-Vue-master/god-system/src/main/resources/mapper/wlsbEqState/WlsbEqStateMapper.xml @@ -1,33 +1,46 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + - - - - - - + + + + + + + + + + + + - select id, eq_num, state, state_time, note1, note2 from wlsb_eq_state ORDER BY state_time DESC + select id, eq_num, state, state_time, note1, note2 + from wlsb_eq_state - + SELECT TIMESTAMPDIFF( SECOND, state_time, - NOW()) AS note2 ,state + NOW()) AS note2, + state FROM (SELECT id, eq_num, state, state_time, note1, note2 FROM wlsb_eq_state where eq_num = #{eqNum} ORDER BY state_time DESC LIMIT 1) AS latest_record + insert into wlsb_eq_state - id, - eq_num, - state, - state_time, - note1, - note2, - + id + , + eq_num + , + state + , + state_time + , + note1 + , + note2 + , + - #{id}, - #{eqNum}, - #{state}, - #{stateTime}, - #{note1}, - #{note2}, - + #{id} + , + #{eqNum} + , + #{state} + , + #{stateTime} + , + #{note1} + , + #{note2} + , + update wlsb_eq_state - eq_num = #{eqNum}, - state = #{state}, - state_time = #{stateTime}, - note1 = #{note1}, - note2 = #{note2}, + eq_num + = + #{eqNum}, + state + = + #{state}, + state_time + = + #{stateTime}, + note1 + = + #{note1}, + note2 + = + #{note2}, where id = #{id} - delete from wlsb_eq_state where id = #{id} + delete + from wlsb_eq_state + where id = #{id} - delete from wlsb_eq_state where id in + delete from wlsb_eq_state where id in #{id} diff --git a/god-ui/src/views/wlsbEqState/eqState/index.vue b/god-ui/src/views/wlsbEqState/eqState/index.vue index cd727d3a..879ab22b 100644 --- a/god-ui/src/views/wlsbEqState/eqState/index.vue +++ b/god-ui/src/views/wlsbEqState/eqState/index.vue @@ -218,6 +218,7 @@ export default { this.loading = false }) }, + // 取消按钮 cancel() { this.open = false