blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/alarm/mapper/AlarmMapper.xml
@@ -737,7 +737,7 @@ <!--获取实时警情图表统计数据--> <select id="getAlarmPie" resultType="org.springblade.common.entity.ReportReturnData"> select if(1=1,"紧急求救",0) type,ifnull(count(*),0) count from sys_alarm select if(1=1,"一键求助",0) type,ifnull(count(*),0) count from sys_alarm where waringType="紧急求救" <include refid="alarmConditionPie"></include> </select> blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/equipment/mapper/EquipmentMapper.java
@@ -91,4 +91,22 @@ * @return */ Integer selectEqCys(); /** * 查询所有的设备,不包含故障和警情状态 * @return */ List<Equipment> selAllEq(); /** * 批量更新设备状态改为在线 * @param equipmentListz 设备信息集合 */ void updateEqListz(@Param("equipmentListz") List<Long> equipmentListz); /** * 批量更新设备状态改为离线 * @param equipmentListl 设备信息集合 */ void updateEqListl(@Param("equipmentListl") List<Long> equipmentListl); } blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/equipment/mapper/EquipmentMapper.xml
@@ -478,4 +478,29 @@ <select id="selectEqCg" resultType="Integer"> select COUNT(*) from sys_equipment where heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY) and dtype=3 </select> <!--查询所有的设备,不包含故障和警情状态--> <select id="selAllEq" resultType="org.springblade.jfpt.equipment.entity.Equipment"> select id,dtype,heartbeat from sys_equipment where dtype!=2 and dtype!=3 </select> <!--批量更新设备状态改为在线--> <update id="updateEqListz" parameterType="java.util.Map"> UPDATE sys_equipment SET dtype = 1 WHERE id IN <foreach collection="equipmentListz" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> </update> <!--批量更新设备状态改为离线--> <update id="updateEqListl" parameterType="java.util.Map"> UPDATE sys_equipment SET dtype = 0 WHERE id IN <foreach collection="equipmentListl" index="index" item="id" open="(" separator="," close=")"> #{id} </foreach> </update> </mapper> blade-service/blade-jfpts/src/main/java/org/springblade/jfpt/equipment/service/impl/EquipmentServiceImpl.java
@@ -35,10 +35,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.*; /** * 服务实现类 @@ -234,6 +231,43 @@ */ @Override public Map<String, Object> selEqTypeSum() { //查詢之前先更新设备状态 //查询所有的设备,不包含故障和警情状态 List<Equipment> equipment = baseMapper.selAllEq(); long time = new Date().getTime(); long hearbeat = 0; List<Long> equipmentListz = new ArrayList<>(); List<Long> equipmentListl = new ArrayList<>(); for (Equipment e:equipment) { try { if(null!=e.getHeartbeat()) { hearbeat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(e.getHeartbeat()).getTime(); } } catch (ParseException parseException) { parseException.printStackTrace(); } //对比心跳时间,在线 if (time-hearbeat<TIME_DIFFERENCE){ if (null==e.getDtype() || e.getDtype()!="1"){ equipmentListz.add(e.getId()); } } if (time-hearbeat>=TIME_DIFFERENCE){ if (null==e.getDtype() || e.getDtype()!="0"){ equipmentListl.add(e.getId()); } } } System.out.println("equipmentListl = " + equipmentListl); System.out.println("equipmentListz = " + equipmentListz); //批量更新数据 if (equipmentListz.size()>0){ baseMapper.updateEqListz(equipmentListz); } if (equipmentListl.size()>0){ baseMapper.updateEqListl(equipmentListl); } //设备在线数量 Integer integerz = baseMapper.selectEqCz(); //设备掉线数量