1.设备列表接口修改,警情状态的排最前
2.新增设备查询的拦截器,更新设备状态
5 files modified
2 files added
| | |
| | | <!--查询符合条件的数据并导出--> |
| | | <select id="exportAlarm" resultType="org.springblade.common.entity.AlarmExcel"> |
| | | select |
| | | a.id,a.alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,a.bz, |
| | | a.id, "一键求助" as alarmType,a.alarmPeople,a.alarmTime,a.galarmPeople,a.sex,a.phoneNumber,a.place,a.content,a.waringType,a.bz, |
| | | a.deviceNumber,a.region,a.district,a.vaddress,a.aaddress, |
| | | a.alarmId,a.LEVEL,e.jd,e.wd,a.jtype,a.rname,a.jjTime,a.province,a.city, |
| | | e.serialNumber,e.oneContacts,e.ThreeContacts,e.twoContacts,e.onePhone,e.twoPhone,e.ThreePhone |
| | |
| | | List<DeptVo> deptVos = deptFeignApi.selDeptList(); |
| | | //获取设备数据信息 |
| | | IPage<EquipmentVO> page = equipmentService.selectDeptPages(Condition.getPage(query), equipment, pid, dxtype); |
| | | System.out.println("page = " + page); |
| | | //遍历数据 |
| | | for (int j = 0; j < page.getRecords().size(); j++) { |
| | | if (null!=page.getRecords().get(j).getDeptId()){ |
| | |
| | | deviceNumber |
| | | ) alarm ON alarm.deviceN = equipment.deviceNumber |
| | | where 1=1 |
| | | |
| | | <if test="equipment.deviceName!=null"> |
| | | and (deviceName like concat('%',#{equipment.deviceName},'%') or deviceNumber like |
| | | concat('%',#{equipment.deviceName},'%')) |
| | | </if> |
| | | |
| | | <if test="equipment.beginTime!=null and equipment.beginTime!=''"> |
| | | and expireTime>=#{equipment.beginTime} |
| | | </if> |
| | | <if test="equipment.endTime!=null and equipment.endTime!=''"> |
| | | and expireTime<=#{equipment.endTime} |
| | | </if> |
| | | |
| | | <if test="equipment.district!=null"> |
| | | and district like concat('%',#{equipment.district},'%') |
| | | </if> |
| | |
| | | <if test="equipment.manufacturers!=null and equipment.manufacturers!=''"> |
| | | and manufacturers = #{equipment.manufacturers} |
| | | </if> |
| | | |
| | | <if test="equipment.devicestate!=null"> |
| | | and devicestate =#{equipment.devicestate} |
| | | </if> |
| | | |
| | | <if test="equipment.dtype!=null"> |
| | | and dtype=#{equipment.dtype} |
| | | </if> |
| | | |
| | | <if test="dxtype!=null and dxtype == 0"> |
| | | and heartbeat < DATE_SUB(NOW(),INTERVAL 1 DAY) |
| | | and heartbeat < DATE_SUB(NOW(),INTERVAL 1 DAY) and dtype=0 |
| | | </if> |
| | | <if test="dxtype!=null and dxtype == 1"> |
| | | and heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY) |
| | | and heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY) and dtype=1 |
| | | </if> |
| | | <if test="dxtype!=null and dxtype == 2"> |
| | | and alarm.jtype IS NOT NULL |
| | | and heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY) and dtype=2 |
| | | </if> |
| | | <if test="dxtype!=null and dxtype == 3"> |
| | | and heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY) and state!=null |
| | | and heartbeat >= DATE_SUB(NOW(),INTERVAL 1 DAY) and dtype=3 |
| | | </if> |
| | | <if test="pid!=null and pid!=''"> |
| | | and deptId like concat('%',#{pid},'%') |
| | | </if> |
| | | |
| | | order by ( |
| | | case |
| | | when dtype=2 then 1 |
| | | when dtype=3 then 2 |
| | | when dtype=0 then 3 |
| | | when dtype=1 then 4 |
| | | END) |
| | | </select> |
| | | |
| | | <!--新增--> |
| | |
| | | * @return |
| | | */ |
| | | Map<String,Object> selEqTypeSum(); |
| | | |
| | | /** |
| | | * 更新设备状态 |
| | | */ |
| | | void updateEquipmentDtype(); |
| | | } |
| | |
| | | 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(); |
| | | //设备掉线数量 |
| | | Integer integerd = baseMapper.selectEqCd(); |
| | | //设备预警数量 |
| | | Integer alarmSum = baseMapper.selectEqCys(); |
| | | //设备故障数量 |
| | | Integer integerg = baseMapper.selectEqCg(); |
| | | //封装数据 |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("zx", integerz); |
| | | map.put("dx", integerd); |
| | | map.put("yj", alarmSum); |
| | | map.put("gz", integerg); |
| | | //返回数据 |
| | | return map; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 更新设备状态 |
| | | */ |
| | | @Override |
| | | public void updateEquipmentDtype() { |
| | | //查询所有的设备,不包含故障和警情状态 |
| | | List<Equipment> equipment = baseMapper.selAllEq(); |
| | | long time = new Date().getTime(); |
| | | long hearbeat = 0; |
| | |
| | | if (equipmentListl.size()>0){ |
| | | baseMapper.updateEqListl(equipmentListl); |
| | | } |
| | | //设备在线数量 |
| | | Integer integerz = baseMapper.selectEqCz(); |
| | | //设备掉线数量 |
| | | Integer integerd = baseMapper.selectEqCd(); |
| | | //设备预警数量 |
| | | Integer alarmSum = baseMapper.selectEqCys(); |
| | | //设备故障数量 |
| | | Integer integerg = baseMapper.selectEqCg(); |
| | | //封装数据 |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("zx", integerz); |
| | | map.put("dx", integerd); |
| | | map.put("yj", alarmSum); |
| | | map.put("gz", integerg); |
| | | //返回数据 |
| | | return map; |
| | | } |
| | | } |
| New file |
| | |
| | | package org.springblade.jfpt.interceptor; |
| | | |
| | | import org.springframework.context.annotation.Configuration; |
| | | import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
| | | import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport; |
| | | |
| | | /** |
| | | * 添加设备拦截器 |
| | | * @author zhongrj |
| | | * @time 2021-5-7 |
| | | */ |
| | | |
| | | @Configuration |
| | | public class EquipmentAdapter extends WebMvcConfigurationSupport { |
| | | |
| | | /** |
| | | * 新增拦截 |
| | | * @param registry |
| | | */ |
| | | @Override |
| | | public void addInterceptors(InterceptorRegistry registry) { |
| | | registry.addInterceptor(new EquipmentInterceptor()). |
| | | addPathPatterns("/equipment/equipment/listAll", |
| | | "/equipment/equipment/pages", |
| | | "/equipment/equipment/pageDept", |
| | | "/equipment/equipment/selectList", |
| | | "/equipment/equipment/SeleCs", |
| | | "/equipment/equipment/SeleC", |
| | | "/equipment/equipment/detail", |
| | | "/equipment/equipment/list" |
| | | ); |
| | | super.addInterceptors(registry); |
| | | } |
| | | } |
| New file |
| | |
| | | package org.springblade.jfpt.interceptor; |
| | | |
| | | import org.springblade.jfpt.equipment.service.IEquipmentService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import org.springframework.web.servlet.HandlerInterceptor; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | import javax.annotation.PostConstruct; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * 设备管理拦截器,管理设备的在线状态 |
| | | * @author zhongrj |
| | | * @time 2021-5-7 |
| | | */ |
| | | |
| | | |
| | | @Component |
| | | public class EquipmentInterceptor implements HandlerInterceptor { |
| | | |
| | | @Autowired |
| | | private IEquipmentService iEquipmentService; |
| | | |
| | | public static EquipmentInterceptor equipmentInterceptor; |
| | | |
| | | @PostConstruct |
| | | public void init(){ |
| | | equipmentInterceptor = this; |
| | | } |
| | | |
| | | /** |
| | | * 拦截所有的设备查询操作,在此之前做更新设备状态的操作 |
| | | * @param request 请求域 |
| | | * @param response 响应域 |
| | | * @param handler 处理器 |
| | | * @return |
| | | * @throws Exception 异常 |
| | | */ |
| | | @Override |
| | | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { |
| | | //更新设备状态 |
| | | equipmentInterceptor.iEquipmentService.updateEquipmentDtype(); |
| | | //放行 |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { |
| | | |
| | | } |
| | | } |