网络设备-设备管理、设备运行分析

This commit is contained in:
卢序振 2024-09-03 18:47:15 +08:00
parent 64eb607e4c
commit 76fa809c60
13 changed files with 217 additions and 49 deletions

View File

@ -39,6 +39,13 @@ public class WlsbEqInfoController extends BaseController
List<WlsbEqInfo> list = wlsbEqInfoService.selectWlsbEqInfoList(wlsbEqInfo);
return getDataTable(list);
}
/**
* 查询设备在线数量和总数量
*/
@GetMapping("/wlsbEqInfoForStartStop")
public AjaxResult wlsbEqInfoForStartStop() {
return AjaxResult.success(wlsbEqInfoService.wlsbEqInfoForStartStop());
}
/**
* 导出设备管理列表

View File

@ -63,6 +63,11 @@ public class WlsbEqStateController extends BaseController
return success(wlsbEqStateService.selectWlsbEqStateById(id));
}
@GetMapping(value = "/onlineTime")
public AjaxResult onlineTime() {
return success(wlsbEqStateService.onlineTime());
}
/**
* 新增设备运行分析
*/

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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"));

View File

@ -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;
}

View File

@ -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> onlineTime();
}

View File

@ -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> onlineTime();
}

View File

@ -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> onlineTime() {
List<OnlineTime> 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;
}
}

View File

@ -16,6 +16,10 @@
<result property="note1" column="note1"/>
<result property="note2" column="note2"/>
</resultMap>
<resultMap type="com.god.wlsbEqInfo.domain.WlsbEqInfoForStartStop" id="WlsbEqInfoForStartStop">
<result property="totalDevices" column="total_devices"/>
<result property="onlineDevices" column="online_devices"/>
</resultMap>
<sql id="selectWlsbEqInfoVo">
select id,
@ -71,6 +75,12 @@
WHERE eq_num LIKE CONCAT(#{prefix}, '%')
order by eq_num desc limit 1
</select>
<select id="wlsbEqInfoForStartStop" parameterType="com.god.wlsbEqInfo.domain.WlsbEqInfoForStartStop"
resultMap="WlsbEqInfoForStartStop">
SELECT COUNT(*) AS total_devices,
SUM(CASE WHEN starrt_stop = 0 THEN 1 ELSE 0 END) AS online_devices
FROM wlsb_eq_info
</select>
<insert id="insertWlsbEqInfo" parameterType="WlsbEqInfo">
insert into wlsb_eq_info

View File

@ -1,33 +1,46 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.god.wlsbEqState.mapper.WlsbEqStateMapper">
<resultMap type="WlsbEqState" id="WlsbEqStateResult">
<result property="id" column="id" />
<result property="eqNum" column="eq_num" />
<result property="state" column="state" />
<result property="stateTime" column="state_time" />
<result property="note1" column="note1" />
<result property="note2" column="note2" />
<result property="id" column="id"/>
<result property="eqNum" column="eq_num"/>
<result property="state" column="state"/>
<result property="stateTime" column="state_time"/>
<result property="note1" column="note1"/>
<result property="note2" column="note2"/>
</resultMap>
<resultMap type="com.god.wlsbEqState.domain.OnlineTime" id="OnlineTime">
<result property="onlineTime" column="online_time"/>
<result property="offlineTime" column="offline_time"/>
<result property="eqNum" column="eq_num"/>
<result property="note1" column="note1"/>
</resultMap>
<sql id="selectWlsbEqStateVo">
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
</sql>
<select id="selectWlsbEqStateList" parameterType="WlsbEqState" resultMap="WlsbEqStateResult">
<include refid="selectWlsbEqStateVo"/>
<where>
<if test="eqNum != null and eqNum != ''"> and eq_num = #{eqNum}</if>
<if test="state != null and state != ''"> and state = #{state}</if>
<if test="stateTime != null and stateTime != ''"> and state_time = #{stateTime}</if>
<if test="note1 != null and note1 != ''"> and note1 = #{note1}</if>
<if test="note2 != null and note2 != ''"> and note2 = #{note2}</if>
<where>
<if test="eqNum != null and eqNum != ''"> and eq_num =
#{eqNum}</if>
<if test="state != null and state != ''"> and state =
#{state}</if>
<if test="stateTime != null and stateTime != ''"> and state_time =
#{stateTime}</if>
<if test="note1 != null and note1 != ''"> and note1 =
#{note1}</if>
<if test="note2 != null and note2 != ''"> and note2 =
#{note2}</if>
</where>
ORDER BY state_time DESC
</select>
<select id="selectWlsbEqStateById" parameterType="String" resultMap="WlsbEqStateResult">
<include refid="selectWlsbEqStateVo"/>
where id = #{id}
@ -35,51 +48,83 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectWlsbEqStateByEqNum" resultType="com.god.wlsbEqState.domain.WlsbEqState">
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
</select>
<select id="onlineTime" parameterType="OnlineTime" resultMap="OnlineTime">
SELECT eq_num,note1,
TIMESTAMPDIFF(SECOND, MIN(STR_TO_DATE(state_time, '%Y-%m-%d %H:%i:%s')), NOW()) AS offline_time,
SUM(note2) AS online_time
FROM wlsb_eq_state
GROUP BY eq_num,note1
</select>
<insert id="insertWlsbEqState" parameterType="WlsbEqState">
insert into wlsb_eq_state
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="eqNum != null">eq_num,</if>
<if test="state != null">state,</if>
<if test="stateTime != null">state_time,</if>
<if test="note1 != null">note1,</if>
<if test="note2 != null">note2,</if>
</trim>
<if test="id != null">id
,</if>
<if test="eqNum != null">eq_num
,</if>
<if test="state != null">state
,</if>
<if test="stateTime != null">state_time
,</if>
<if test="note1 != null">note1
,</if>
<if test="note2 != null">note2
,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="eqNum != null">#{eqNum},</if>
<if test="state != null">#{state},</if>
<if test="stateTime != null">#{stateTime},</if>
<if test="note1 != null">#{note1},</if>
<if test="note2 != null">#{note2},</if>
</trim>
<if test="id != null">#{id}
,</if>
<if test="eqNum != null">#{eqNum}
,</if>
<if test="state != null">#{state}
,</if>
<if test="stateTime != null">#{stateTime}
,</if>
<if test="note1 != null">#{note1}
,</if>
<if test="note2 != null">#{note2}
,</if>
</trim>
</insert>
<update id="updateWlsbEqState" parameterType="WlsbEqState">
update wlsb_eq_state
<trim prefix="SET" suffixOverrides=",">
<if test="eqNum != null">eq_num = #{eqNum},</if>
<if test="state != null">state = #{state},</if>
<if test="stateTime != null">state_time = #{stateTime},</if>
<if test="note1 != null">note1 = #{note1},</if>
<if test="note2 != null">note2 = #{note2},</if>
<if test="eqNum != null">eq_num
=
#{eqNum},</if>
<if test="state != null">state
=
#{state},</if>
<if test="stateTime != null">state_time
=
#{stateTime},</if>
<if test="note1 != null">note1
=
#{note1},</if>
<if test="note2 != null">note2
=
#{note2},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteWlsbEqStateById" parameterType="String">
delete from wlsb_eq_state where id = #{id}
delete
from wlsb_eq_state
where id = #{id}
</delete>
<delete id="deleteWlsbEqStateByIds" parameterType="String">
delete from wlsb_eq_state where id in
delete from wlsb_eq_state where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>

View File

@ -218,6 +218,7 @@ export default {
this.loading = false
})
},
//
cancel() {
this.open = false