|  |  | 
 |  |  | import com.ruoyi.device.radar.domain.ArdEquipRadar; | 
 |  |  | import com.ruoyi.device.radar.mapper.ArdEquipRadarMapper; | 
 |  |  | import com.ruoyi.statistical.domain.ArdPumpStatus; | 
 |  |  | import com.ruoyi.statistical.mapper.PumpStatusMapper; | 
 |  |  | import com.ruoyi.statistical.mapper.ArdPumpStatusMapper; | 
 |  |  | import com.ruoyi.statistical.param.ESParam; | 
 |  |  | import com.ruoyi.statistical.param.Para; | 
 |  |  | import com.ruoyi.statistical.service.StatisticalService; | 
 |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private ArdCamerasMapper camerasMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PumpStatusMapper pumpStatusMapper; | 
 |  |  |     private ArdPumpStatusMapper ardPumpStatusMapper; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  | 
 |  |  |             jsonObject.put(sysConfig.getConfigKey(),sysConfig.getConfigValue()); | 
 |  |  |         } | 
 |  |  |         //记录well表中oil_production为抽油机的数据有多少条 | 
 |  |  |         QueryWrapper<ArdAlarmpointsWell> queryWrapperWell = new QueryWrapper<>(); | 
 |  |  |         queryWrapperWell.eq("oil_production","抽油机"); | 
 |  |  |         int num = wellMapper.selectCount(queryWrapperWell); | 
 |  |  | //        QueryWrapper<ArdAlarmpointsWell> queryWrapperWell = new QueryWrapper<>(); | 
 |  |  | //        queryWrapperWell.eq("oil_production","抽油机"); | 
 |  |  | //        queryWrapperWell.eq("well_type","1"); | 
 |  |  |         int num = wellMapper.selectCount(null); | 
 |  |  |         jsonObject.put("well",String.valueOf(num)); | 
 |  |  |         return Results.succeed(jsonObject); | 
 |  |  |     } | 
 |  |  | 
 |  |  |     @Override | 
 |  |  |     public UnitVo unit() { | 
 |  |  |         UnitVo unitVo = new UnitVo(); | 
 |  |  |         //雷达在线数量 | 
 |  |  |         List<ArdEquipRadar> radarList = radarMapper.selectList(null); | 
 |  |  |         Timer timer = new Timer(); | 
 |  |  |         TimerTask timerTask =new TimerTask(){ | 
 |  |  |             @Override | 
 |  |  |             public void run(){ | 
 |  |  |                 Para.setI(0); | 
 |  |  |                for (int i = 0; i < radarList.size(); i++) { | 
 |  |  |                    ArdEquipRadar radar = radarList.get(i); | 
 |  |  |                    String host = radar.getIp(); | 
 |  |  |                    String port = radar.getPort(); | 
 |  |  |                     Thread thread = new Thread(){ | 
 |  |  |                         @Override | 
 |  |  |                         public void run(){ | 
 |  |  |                             try { | 
 |  |  |                                 Socket socket = new Socket(host,Integer.valueOf(port)); | 
 |  |  |                             } catch (Exception e) { | 
 |  |  |                                 int num = Para.getI(); | 
 |  |  |                                 num++; | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     }; | 
 |  |  |                     thread.start(); | 
 |  |  |                 } | 
 |  |  |                 int n = Para.getI(); | 
 |  |  |                 Para.setJ(radarList.size() - Para.getI()); | 
 |  |  |             } | 
 |  |  |         }; | 
 |  |  |         Date date = new Date(); | 
 |  |  |         timer.scheduleAtFixedRate(timerTask,date,5000); | 
 |  |  |         unitVo.setRadar(Para.getJ()); | 
 |  |  |         //光电数量 | 
 |  |  |         QueryWrapper<ArdCameras> queryWrapper = new QueryWrapper<>(); | 
 |  |  |         queryWrapper.select("id").eq("gdtype","0").eq("state","1"); | 
 |  |  |         List<ArdCameras> ardCameras = camerasMapper.selectList(queryWrapper); | 
 |  |  |         QueryWrapper<ArdEquipRadar> queryWrapper = new QueryWrapper<>(); | 
 |  |  |         queryWrapper.eq("state","1"); | 
 |  |  |         List<ArdEquipRadar> radarList = radarMapper.selectList(queryWrapper); | 
 |  |  |         unitVo.setRadar(radarList.size()); | 
 |  |  |         QueryWrapper<ArdCameras> queryWrapperC = new QueryWrapper<>(); | 
 |  |  |         queryWrapperC.select("id").eq("gdtype","0").eq("state","1"); | 
 |  |  |         List<ArdCameras> ardCameras = camerasMapper.selectList(queryWrapperC); | 
 |  |  |         unitVo.setCamera(ardCameras.size()); | 
 |  |  | //        //雷达在线数量 | 
 |  |  | //        List<ArdEquipRadar> radarList = radarMapper.selectList(null); | 
 |  |  | //        Timer timer = new Timer(); | 
 |  |  | //        TimerTask timerTask =new TimerTask(){ | 
 |  |  | //            @Override | 
 |  |  | //            public void run(){ | 
 |  |  | //                Para.setI(0); | 
 |  |  | //               for (int i = 0; i < radarList.size(); i++) { | 
 |  |  | //                   ArdEquipRadar radar = radarList.get(i); | 
 |  |  | //                   String host = radar.getIp(); | 
 |  |  | //                   String port = radar.getPort(); | 
 |  |  | //                    Thread thread = new Thread(){ | 
 |  |  | //                        @Override | 
 |  |  | //                        public void run(){ | 
 |  |  | //                            try { | 
 |  |  | //                                Socket socket = new Socket(host,Integer.valueOf(port)); | 
 |  |  | //                            } catch (Exception e) { | 
 |  |  | //                                int num = Para.getI(); | 
 |  |  | //                                num++; | 
 |  |  | //                            } | 
 |  |  | //                        } | 
 |  |  | //                    }; | 
 |  |  | //                    thread.start(); | 
 |  |  | //                } | 
 |  |  | //                int n = Para.getI(); | 
 |  |  | //                Para.setJ(radarList.size() - Para.getI()); | 
 |  |  | //            } | 
 |  |  | //        }; | 
 |  |  | //        Date date = new Date(); | 
 |  |  | //        timer.scheduleAtFixedRate(timerTask,date,5000); | 
 |  |  | //        unitVo.setRadar(Para.getJ()); | 
 |  |  |         return unitVo; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |         List<TenVo> list = new ArrayList<>(); | 
 |  |  |         QueryWrapper<ArdPumpStatus> queryWrapper = new QueryWrapper<>(); | 
 |  |  |         queryWrapper.eq("alarm_type","运行"); | 
 |  |  |         int y = pumpStatusMapper.selectCount(queryWrapper); | 
 |  |  |         int y = ardPumpStatusMapper.selectCount(queryWrapper); | 
 |  |  |         TenVo tenVo = new TenVo(); | 
 |  |  |         tenVo.setName("运行"); | 
 |  |  |         tenVo.setValue(y); | 
 |  |  |         list.add(tenVo); | 
 |  |  |         QueryWrapper<ArdPumpStatus> queryWrapper1 = new QueryWrapper<>(); | 
 |  |  |         queryWrapper1.eq("alarm_type","停机"); | 
 |  |  |         int t = pumpStatusMapper.selectCount(queryWrapper1); | 
 |  |  |         int t = ardPumpStatusMapper.selectCount(queryWrapper1); | 
 |  |  |         TenVo tenVo1 = new TenVo(); | 
 |  |  |         tenVo1.setName("停机"); | 
 |  |  |         tenVo1.setValue(t); | 
 |  |  | 
 |  |  |                 JSONObject j = list.get(i); | 
 |  |  |                 QueryWrapper<ArdPumpStatus> queryWrapper = new QueryWrapper<>(); | 
 |  |  |                 queryWrapper.eq("target_id",j.getInteger("targetId")).eq("name",j.getString("name")); | 
 |  |  |                 ArdPumpStatus ardPumpStatus1 = pumpStatusMapper.selectOne(queryWrapper); | 
 |  |  |                 ArdPumpStatus ardPumpStatus1 = ardPumpStatusMapper.selectOne(queryWrapper); | 
 |  |  |                 if(ardPumpStatus1 ==null){ | 
 |  |  |                     ArdPumpStatus ardPumpStatus = new ArdPumpStatus(); | 
 |  |  |                     ardPumpStatus.setTargetId(j.getInteger("targetId")); | 
 |  |  | 
 |  |  |                         ardPumpStatus.setAlarmType(j.getString("alarm")); | 
 |  |  |                     } | 
 |  |  |                     ardPumpStatus.setAlarmTime(alarmTime); | 
 |  |  |                     pumpStatusMapper.insert(ardPumpStatus); | 
 |  |  |                     ardPumpStatusMapper.insert(ardPumpStatus); | 
 |  |  |                 }else { | 
 |  |  |                     String alarmType = ardPumpStatus1.getAlarmType(); | 
 |  |  |                     Boolean bo = false; | 
 |  |  | 
 |  |  |                     if(!bo){ | 
 |  |  |                         ardPumpStatus1.setAlarmType(j.getString("alarmType")); | 
 |  |  |                         ardPumpStatus1.setAlarmTime(alarmTime); | 
 |  |  |                         pumpStatusMapper.updateById(ardPumpStatus1); | 
 |  |  |                         ardPumpStatusMapper.updateById(ardPumpStatus1); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } |