|  |  | 
 |  |  | import com.ruoyi.device.camera.mapper.ArdCamerasMapper; | 
 |  |  | 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.ArdPumpStatusMapper; | 
 |  |  | import com.ruoyi.statistical.param.ESParam; | 
 |  |  | import com.ruoyi.statistical.param.Para; | 
 |  |  | import com.ruoyi.statistical.service.StatisticalService; | 
 |  |  | import com.ruoyi.statistical.vo.CountVo; | 
 |  |  | import com.ruoyi.statistical.vo.TenVo; | 
 |  |  | import com.ruoyi.statistical.vo.UnitVo; | 
 |  |  | import com.ruoyi.system.mapper.SysConfigMapper; | 
 |  |  | import com.ruoyi.utils.result.Results; | 
 |  |  | 
 |  |  |     private ArdEquipRadarMapper radarMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private ArdCamerasMapper camerasMapper; | 
 |  |  |     @Autowired | 
 |  |  |     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 List<CountVo> stealelecMonth(ESParam esParam) { | 
 |  |  |         List<CountVo> list = stealelecMapper.stealelecMonth(esParam); | 
 |  |  |         return esMonth(list,esParam.getEnd()); | 
 |  |  |         return esMonth(list,esParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<CountVo> cameraMonth(ESParam esParam) { | 
 |  |  |         List<CountVo> list = cameraMapper.cameraMonth(esParam); | 
 |  |  |         return esMonth(list,esParam.getEnd()); | 
 |  |  |         return esMonth(list,esParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<CountVo> moveMonth(ESParam esParam) { | 
 |  |  |         List<CountVo> list = moveMapper.moveMonth(esParam); | 
 |  |  |         return esMonth(list,esParam.getEnd()); | 
 |  |  |         return esMonth(list,esParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<CountVo> fireMonth(ESParam esParam) { | 
 |  |  |         List<CountVo> list = fireMapper.fileMonth(esParam); | 
 |  |  |         return esMonth(list,esParam.getEnd()); | 
 |  |  |         return esMonth(list,esParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<CountVo> externalMonth(ESParam esParam) { | 
 |  |  |         List<CountVo> list = externalMapper.externalMonth(esParam); | 
 |  |  |         return esMonth(list,esParam.getEnd()); | 
 |  |  |         return esMonth(list,esParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<CountVo> accessMonth(ESParam esParam) { | 
 |  |  |         List<CountVo> list = accessMapper.accessMonth(esParam); | 
 |  |  |         return esMonth(list,esParam.getEnd()); | 
 |  |  |         return esMonth(list,esParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<CountVo> apponekeyMonth(ESParam esParam) { | 
 |  |  |         List<CountVo> list = apponekeyMapper.apponekeyMonth(esParam); | 
 |  |  |         return esMonth(list,esParam.getEnd()); | 
 |  |  |         return esMonth(list,esParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<CountVo> pumpMonth(ESParam esParam) { | 
 |  |  |         List<CountVo> list = pumpMapper.pumpMonth(esParam); | 
 |  |  |         return esMonth(list,esParam.getEnd()); | 
 |  |  |         return esMonth(list,esParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<CountVo> wallMonth(ESParam esParam) { | 
 |  |  |         List<CountVo> list = wallMapper.wallMonth(esParam); | 
 |  |  |         return esMonth(list,esParam.getEnd()); | 
 |  |  |         return esMonth(list,esParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<CountVo> digitizationMonth(ESParam esParam) { | 
 |  |  |         List<CountVo> list = digitization3Mapper.digitizationMonth(esParam); | 
 |  |  |         return esMonth(list,esParam.getEnd()); | 
 |  |  |         return esMonth(list,esParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<CountVo> tubeMonth(ESParam esParam) { | 
 |  |  |         List<CountVo> list = tubeMapper.tubeMonth(esParam); | 
 |  |  |         return esMonth(list,esParam.getEnd()); | 
 |  |  |         return esMonth(list,esParam); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @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(Object o : radarList){ | 
 |  |  |                     Thread thread = new Thread(){ | 
 |  |  |                         @Override | 
 |  |  |                         public void run(){ | 
 |  |  |                             try { | 
 |  |  |                                 Socket socket = new Socket("192.168.5.226",1200); | 
 |  |  |                             } catch (Exception e) { | 
 |  |  |                                 // TODO Auto-generated catch block | 
 |  |  |                                 e.printStackTrace(); | 
 |  |  |                                 int i = Para.getI(); | 
 |  |  |                                 i++; | 
 |  |  |                             } | 
 |  |  |                         } | 
 |  |  |                     }; | 
 |  |  |                     thread.start(); | 
 |  |  |                 } | 
 |  |  |                 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; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public List<CountVo> es(List<CountVo> list){ | 
 |  |  |         for (int i = 1; i <= 12 ; i++) { | 
 |  |  |             String month; | 
 |  |  |             if(i<=10){ | 
 |  |  |                 month = "0"+i; | 
 |  |  |             }else { | 
 |  |  |                 month = String.valueOf(i); | 
 |  |  |             } | 
 |  |  |             Boolean bo = false; | 
 |  |  |             for (int j = 0; j < list.size(); j++) { | 
 |  |  |                 CountVo countVo = list.get(j); | 
 |  |  |                 String mon = countVo.getDate(); | 
 |  |  |                 if(mon.equals(month)){ | 
 |  |  |                     bo = true; | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             if(!bo){ | 
 |  |  |                 CountVo countVo = new CountVo(); | 
 |  |  |                 countVo.setDate(month); | 
 |  |  |                 countVo.setCount(0); | 
 |  |  |                 list.add(countVo); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     @Override | 
 |  |  |     public int stealelecNum() { | 
 |  |  |         return stealelecMapper.selectCount(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public int cameraNum() { | 
 |  |  |         return cameraMapper.selectCount(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public int moveNum() { | 
 |  |  |         return moveMapper.selectCount(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public int fireNum() { | 
 |  |  |         return fireMapper.selectCount(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public int externalNum() { | 
 |  |  |         return externalMapper.selectCount(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public int accessNum() { | 
 |  |  |         return accessMapper.selectCount(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public int apponekeyNum() { | 
 |  |  |         return apponekeyMapper.selectCount(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public int pumpNum() { | 
 |  |  |         return pumpMapper.selectCount(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public int wallNum() { | 
 |  |  |         return wallMapper.selectCount(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public int digitizationNum() { | 
 |  |  |         return digitization3Mapper.selectCount(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public int tubeNum() { | 
 |  |  |         return tubeMapper.selectCount(null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<TenVo> ten() { | 
 |  |  |         return moveMapper.ten(); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public List<TenVo> pump() { | 
 |  |  |         List<TenVo> list = new ArrayList<>(); | 
 |  |  |         QueryWrapper<ArdPumpStatus> queryWrapper = new QueryWrapper<>(); | 
 |  |  |         queryWrapper.eq("alarm_type","运行"); | 
 |  |  |         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 = ardPumpStatusMapper.selectCount(queryWrapper1); | 
 |  |  |         TenVo tenVo1 = new TenVo(); | 
 |  |  |         tenVo1.setName("停机"); | 
 |  |  |         tenVo1.setValue(t); | 
 |  |  |         list.add(tenVo1); | 
 |  |  |         return list; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public List<CountVo> esMonth(List<CountVo> list,String end){ | 
 |  |  |         Integer day = Integer.valueOf(end.substring(end.length() - 2)); | 
 |  |  |         for (int i = 1; i <= day ; i++) { | 
 |  |  |             String d; | 
 |  |  |             if(i<=10){ | 
 |  |  |                 d = "0"+i; | 
 |  |  |             }else { | 
 |  |  |                 d = String.valueOf(i); | 
 |  |  |     @Override | 
 |  |  |     public void data(String msg) { | 
 |  |  |         JSONObject jsonObject = JSONObject.parseObject(msg); | 
 |  |  |         String alarmTime = jsonObject.getString("alarmTime"); | 
 |  |  |         List<JSONObject> list = (List<JSONObject>) jsonObject.get("ardAlarmRadars"); | 
 |  |  |         if(list.size()>0){ | 
 |  |  |             for (int i = 0; i < list.size(); i++) { | 
 |  |  |                 JSONObject j = list.get(i); | 
 |  |  |                 QueryWrapper<ArdPumpStatus> queryWrapper = new QueryWrapper<>(); | 
 |  |  |                 queryWrapper.eq("target_id",j.getInteger("targetId")).eq("name",j.getString("name")); | 
 |  |  |                 ArdPumpStatus ardPumpStatus1 = ardPumpStatusMapper.selectOne(queryWrapper); | 
 |  |  |                 if(ardPumpStatus1 ==null){ | 
 |  |  |                     ArdPumpStatus ardPumpStatus = new ArdPumpStatus(); | 
 |  |  |                     ardPumpStatus.setTargetId(j.getInteger("targetId")); | 
 |  |  |                     ardPumpStatus.setName(j.getString("name")); | 
 |  |  |                     if(j.containsKey("alarmType")){ | 
 |  |  |                         ardPumpStatus.setAlarmType(j.getString("alarmType")); | 
 |  |  |                     }else if(j.containsKey("alarm")){ | 
 |  |  |                         ardPumpStatus.setAlarmType(j.getString("alarm")); | 
 |  |  |                     } | 
 |  |  |                     ardPumpStatus.setAlarmTime(alarmTime); | 
 |  |  |                     ardPumpStatusMapper.insert(ardPumpStatus); | 
 |  |  |                 }else { | 
 |  |  |                     String alarmType = ardPumpStatus1.getAlarmType(); | 
 |  |  |                     Boolean bo = false; | 
 |  |  |                     if(j.containsKey("alarmType")){ | 
 |  |  |                         if(alarmType.equals(j.getString("alarmType"))){ | 
 |  |  |                             bo = true; | 
 |  |  |                         } | 
 |  |  |                     }else if(j.containsKey("alarm")){ | 
 |  |  |                         if(alarmType.equals(j.getString("alarm"))){ | 
 |  |  |                             bo = true; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     if(!bo){ | 
 |  |  |                         ardPumpStatus1.setAlarmType(j.getString("alarmType")); | 
 |  |  |                         ardPumpStatus1.setAlarmTime(alarmTime); | 
 |  |  |                         ardPumpStatusMapper.updateById(ardPumpStatus1); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public List<CountVo> es(List<CountVo> list){ | 
 |  |  |         List<CountVo> countVoList = new ArrayList<>(); | 
 |  |  |         for (int i = 1; i <= 12 ; i++) { | 
 |  |  |             CountVo vo = new CountVo(); | 
 |  |  |             String month = i + "月"; | 
 |  |  |             Boolean bo = false; | 
 |  |  |             for (int j = 0; j < list.size(); j++) { | 
 |  |  |                 CountVo countVo = list.get(j); | 
 |  |  |                 String mon = countVo.getDate(); | 
 |  |  |                 if(mon.equals(d)){ | 
 |  |  |                 String mon = Integer.valueOf(countVo.getDate()) + "月"; | 
 |  |  |                 if(mon.equals(month)){ | 
 |  |  |                     bo = true; | 
 |  |  |                     vo.setDate(mon); | 
 |  |  |                     vo.setCount(countVo.getCount()); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             if(!bo){ | 
 |  |  |                 CountVo countVo = new CountVo(); | 
 |  |  |                 countVo.setDate(d); | 
 |  |  |                 countVo.setCount(0); | 
 |  |  |                 list.add(countVo); | 
 |  |  |                 vo.setDate(month); | 
 |  |  |                 vo.setCount(0); | 
 |  |  |             } | 
 |  |  |             countVoList.add(vo); | 
 |  |  |         } | 
 |  |  |         return list; | 
 |  |  |         return countVoList; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public List<CountVo> esMonth(List<CountVo> list,ESParam esParam){ | 
 |  |  |         List<CountVo> countVoList = new ArrayList<>(); | 
 |  |  |         Integer day = Integer.valueOf(esParam.getEnd().substring(esParam.getEnd().length() - 2)); | 
 |  |  |         Integer month = esParam.getMonth(); | 
 |  |  |         for (int i = 1; i <= day ; i++) { | 
 |  |  |             CountVo vo = new CountVo(); | 
 |  |  |             String d = month + "-" + i ; | 
 |  |  |             Boolean bo = false; | 
 |  |  |             for (int j = 0; j < list.size(); j++) { | 
 |  |  |                 CountVo countVo = list.get(j); | 
 |  |  |                 String mon = month + "-" + Integer.valueOf(countVo.getDate()); | 
 |  |  |                 if(mon.equals(d)){ | 
 |  |  |                     bo = true; | 
 |  |  |                     vo.setDate(mon); | 
 |  |  |                     vo.setCount(countVo.getCount()); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             if(!bo){ | 
 |  |  |                 vo.setDate(d); | 
 |  |  |                 vo.setCount(0); | 
 |  |  |             } | 
 |  |  |             countVoList.add(vo); | 
 |  |  |         } | 
 |  |  |         return countVoList; | 
 |  |  |     } | 
 |  |  | } |