From 8f2e8522daf081ad4da027c39a776fdd9483b97e Mon Sep 17 00:00:00 2001 From: zxl <763096477@qq.com> Date: 星期一, 15 九月 2025 15:20:51 +0800 Subject: [PATCH] 新需求 --- ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java | 309 +++++++++++++++++++++++++++++++++++++------------- 1 files changed, 227 insertions(+), 82 deletions(-) diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java index 3127208..625dd78 100644 --- a/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java +++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java @@ -71,6 +71,7 @@ import java.util.*; import java.util.concurrent.*; import java.util.function.Function; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -674,18 +675,20 @@ .map(CompletableFuture::join) .flatMap(List::stream) .collect(Collectors.toList()); - log.error("鎵撳嵃鍏ㄩ噺鏁版嵁:{}",totalExps); ExcelExp excelExp = new ExcelExp("鍏ㄩ噺", totalExps, VideoDailyExp.class); mysheet.add(excelExp); + + long face = totalExps.stream().filter(item -> item.getType().contains("1")).count(); + long car = totalExps.stream().filter(item -> item.getType().contains("2")).count(); + long video = totalExps.stream().filter(item -> item.getType().contains("3")).count(); + log.error("浜鸿劯鏁�:{}",face); + log.error("car鏁�:{}",car); + log.error("video鏁�:{}",video); //娣诲姞鏂扮殑sheet 绂荤嚎鏁扮粺璁¤〃 List<VideoTypeOffOnlineExp> videoTypeOffOnlineExps = new ArrayList<>(); - //鎻掑叆excel鏃剁‘淇濇暟鎹嚭鐜板湪鏈�鍚� - List<VideoTypeOffOnlineExp> allVideoTypeOffOnlineExps = new ArrayList<>(); //鍦ㄧ嚎鐜囩粺璁¤〃 List<VideoOnlineRateExp> videoOnlineRateExps = new ArrayList<>(); - //鎻掑叆excel鏃剁‘淇濇暟鎹嚭鐜板湪鏈�鍚� - List<VideoOnlineRateExp> allVideoOnlineRateExps = new ArrayList<>(); for (Integer deptId : map.keySet()){ List<VideoDailyExp> list = map.get(deptId); @@ -694,17 +697,17 @@ //璁惧绫诲瀷 1浜鸿劯 2杞﹁締 3瑙嗛 //浜鸿劯 log.error("浼犲叆閮ㄩ棬闆嗗悎澶у皬:{} + 閮ㄩ棬id:{}" ,list.size(),deptId); - VideoTypeOffOnlineExp faceVideoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"1",areaDeptEnum,false); + VideoTypeOffOnlineExp faceVideoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"1",areaDeptEnum); //鍗″彛 - VideoTypeOffOnlineExp carVideoTypeOffOnlineExp =this.getListOfflineCountInfo(list,"2",areaDeptEnum,false); + VideoTypeOffOnlineExp carVideoTypeOffOnlineExp =this.getListOfflineCountInfo(list,"2",areaDeptEnum); //瑙嗛 - VideoTypeOffOnlineExp videoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"3",areaDeptEnum,false); + VideoTypeOffOnlineExp videoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"3",areaDeptEnum); - VideoOnlineRateExp faceVideoOnlineRateExp = this.getListOnLineCountInfo(list,"1",areaDeptEnum,false); + VideoOnlineRateExp faceVideoOnlineRateExp = this.getListOnLineCountInfo(list,"1",areaDeptEnum); //鍗″彛 - VideoOnlineRateExp carVideoOnlineRateExp =this.getListOnLineCountInfo(list,"2",areaDeptEnum,false); + VideoOnlineRateExp carVideoOnlineRateExp =this.getListOnLineCountInfo(list,"2",areaDeptEnum); //瑙嗛 - VideoOnlineRateExp VideoOnlineRateExp = this.getListOnLineCountInfo(list,"3",areaDeptEnum,false); + VideoOnlineRateExp VideoOnlineRateExp = this.getListOnLineCountInfo(list,"3",areaDeptEnum); //灏嗚鍖哄煙绫讳笁绉嶈澶囩被鍨嬬殑 淇℃伅 鏀惧叆 excel瀵硅薄鍐� @@ -718,36 +721,48 @@ videoOnlineRateExps.add(faceVideoOnlineRateExp); videoOnlineRateExps.add(carVideoOnlineRateExp); videoOnlineRateExps.add(VideoOnlineRateExp); - - - VideoTypeOffOnlineExp ALLfaceVideoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"1",areaDeptEnum,true); - //鍗″彛 - VideoTypeOffOnlineExp ALLcarVideoTypeOffOnlineExp =this.getListOfflineCountInfo(list,"2",areaDeptEnum,true); - //瑙嗛 - VideoTypeOffOnlineExp ALLvideoTypeOffOnlineExp = this.getListOfflineCountInfo(list,"3",areaDeptEnum,true); - - VideoOnlineRateExp ALLfaceVideoOnlineRateExp = this.getListOnLineCountInfo(list,"1",areaDeptEnum,true); - //鍗″彛 - VideoOnlineRateExp ALLcarVideoOnlineRateExp =this.getListOnLineCountInfo(list,"2",areaDeptEnum,true); - //瑙嗛 - VideoOnlineRateExp ALLVideoOnlineRateExp = this.getListOnLineCountInfo(list,"3",areaDeptEnum,true); - - //娣诲姞鍚堣鏁版嵁 - allVideoTypeOffOnlineExps.add(ALLfaceVideoTypeOffOnlineExp); - //鏀惧叆褰撳墠鍖哄煙鐨勮溅杈嗚澶囩浉鍏宠缁� - allVideoTypeOffOnlineExps.add(ALLcarVideoTypeOffOnlineExp); - //鏀惧叆褰撳墠鍖哄煙鐨勮棰戣澶囩浉鍏宠缁� - allVideoTypeOffOnlineExps.add(ALLvideoTypeOffOnlineExp); - - allVideoOnlineRateExps.add(ALLfaceVideoOnlineRateExp); - allVideoOnlineRateExps.add(ALLcarVideoOnlineRateExp); - allVideoOnlineRateExps.add(ALLVideoOnlineRateExp); - } + + //璁$畻鑷础甯傚悎璁� + //鎻掑叆excel鏃剁‘淇濇暟鎹嚭鐜板湪鏈�鍚� + List<VideoTypeOffOnlineExp> allVideoTypeOffOnlineExps = new ArrayList<>(); + //鎻掑叆excel鏃剁‘淇濇暟鎹嚭鐜板湪鏈�鍚� + List<VideoOnlineRateExp> allVideoOnlineRateExps = new ArrayList<>(); + + //鎵�鏈夌绾挎暟鎹腑锛屽悇鍖鸿澶囦负浜鸿劯鐨勫璞� 鍚堣瑁呴厤瀵硅薄 + VideoTypeOffOnlineExp allFaceVideosOffline = new VideoTypeOffOnlineExp(); + setAllVideoTypeOffOnlineExpCount(videoTypeOffOnlineExps,allFaceVideosOffline,"浜鸿劯"); + + VideoTypeOffOnlineExp allCarVideosOffline = new VideoTypeOffOnlineExp(); + setAllVideoTypeOffOnlineExpCount(videoTypeOffOnlineExps,allCarVideosOffline,"鍗″彛"); + + VideoTypeOffOnlineExp allVideosOffline = new VideoTypeOffOnlineExp(); + setAllVideoTypeOffOnlineExpCount(videoTypeOffOnlineExps,allVideosOffline,"瑙嗛"); + + allVideoTypeOffOnlineExps.add(allFaceVideosOffline); + allVideoTypeOffOnlineExps.add(allCarVideosOffline); + allVideoTypeOffOnlineExps.add(allVideosOffline); + + //鎵�鏈夊湪绾挎暟鎹� 鍚堣瑁呴厤瀵硅薄 + VideoOnlineRateExp allFaceVideosOnline = new VideoOnlineRateExp(); + setAllVideoTypeOnlineExpCount(face,videoOnlineRateExps,allFaceVideosOnline,"浜鸿劯"); + + + VideoOnlineRateExp allCarVideosOnline = new VideoOnlineRateExp(); + setAllVideoTypeOnlineExpCount(car,videoOnlineRateExps,allCarVideosOnline,"鍗″彛"); + + VideoOnlineRateExp allVideosOnline = new VideoOnlineRateExp(); + setAllVideoTypeOnlineExpCount(video,videoOnlineRateExps,allVideosOnline,"瑙嗛"); + + + allVideoOnlineRateExps.add(allFaceVideosOnline); + allVideoOnlineRateExps.add(allCarVideosOnline); + allVideoOnlineRateExps.add(allVideosOnline); + videoTypeOffOnlineExps.addAll(allVideoTypeOffOnlineExps); videoOnlineRateExps.addAll(allVideoOnlineRateExps); log.error("鎵撳嵃璁$畻绂荤嚎鐨勪俊鎭�:{}" ,videoTypeOffOnlineExps ); - log.error("鎵撳嵃璁″湪绾跨殑淇℃伅:{}" ,videoOnlineRateExps ); + log.error("鎵撳嵃鍦ㄧ嚎鐨勪俊鎭�:{}" ,videoOnlineRateExps ); //娣诲姞鍚堣鏁版嵁 ExcelExp excelTypeOffLineExp = new ExcelExp("绂荤嚎鏁扮粺璁�", videoTypeOffOnlineExps, VideoTypeOffOnlineExp.class); @@ -761,6 +776,103 @@ util.exportExcelManySheet(response, mysheet); log.error("瀵煎嚭缁撴潫"); } + //绂荤嚎璁惧鏁版嵁锛屽悎璁″璞★紝淇℃伅瑁呴厤 + public void setAllVideoTypeOffOnlineExpCount(List<VideoTypeOffOnlineExp> videoTypeOffOnlineExps, + VideoTypeOffOnlineExp videoTypeOffOnlineExp, + String type) throws NoSuchFieldException, IllegalAccessException { + List<VideoTypeOffOnlineExp> filterExps = videoTypeOffOnlineExps.stream().filter(exp -> type.equals(exp.getType())).collect(Collectors.toList()); + long allCount = 0; + for (VideoTypeOffOnlineExp obj :filterExps){ + //obj 瀵硅薄浠h〃浜嗚鍖� 绛涢�変簡鐨勬寚瀹歵ype鐨勮澶囩殑瀵硅薄 + //璁$畻鎬荤殑璁惧绂荤嚎鎬绘暟 + long count = Long.parseLong(obj.getOfflineCount()); + allCount += count; + //璁$畻姣忔棩 + for (int i =1 ;i <= 31; i++){ + String fieldName = "day" + i; + Field dayField = obj.getClass().getDeclaredField(fieldName); + dayField.setAccessible(true); + Object value = dayField.get(obj); //鑾峰彇瀛楁鍊� + if (value != null) { + long newFieldValue = Long.parseLong(value.toString()); + //鑾峰彇闇�瑕佸~鍏呯殑瀛楁 + Field videoTypeOffOnlineExpField = videoTypeOffOnlineExp.getClass().getDeclaredField(fieldName); + videoTypeOffOnlineExpField.setAccessible(true); + //鍏堣幏鍙栦竴娆� + Object oldValue = videoTypeOffOnlineExpField.get(videoTypeOffOnlineExp); + + //涓簄ull 绗竴娆$洿鎺ヨ璧嬪�� + if (oldValue == null){ + videoTypeOffOnlineExpField.set(videoTypeOffOnlineExp,newFieldValue + ""); + }else { + //瀛樺湪鏃у�� 鐩稿姞瑕嗙洊 + videoTypeOffOnlineExpField.set(videoTypeOffOnlineExp, (Long.parseLong(oldValue.toString()) + newFieldValue) + ""); + } + } + + + + } + + } + videoTypeOffOnlineExp.setOfflineCount(String.valueOf(allCount)); + videoTypeOffOnlineExp.setArea("鑷础甯�"); + videoTypeOffOnlineExp.setType(type + "鍚堣"); + } + //鍦ㄧ嚎璁惧鏁版嵁锛屽悎璁″璞★紝淇℃伅瑁呴厤 + public void setAllVideoTypeOnlineExpCount( + long allVideoCount,List<VideoOnlineRateExp> videoOnlineRateExps, + VideoOnlineRateExp videoOnlineRateExp, + String type) throws NoSuchFieldException, IllegalAccessException{ + List<VideoOnlineRateExp> filterExps = videoOnlineRateExps.stream().filter(item -> type.equals(item.getType())).collect(Collectors.toList()); + + for (VideoOnlineRateExp obj :filterExps){ + for (int i = 1;i <= 31; i++){ + String countFileName = "count" +i; + Field countField = obj.getClass().getDeclaredField(countFileName); + countField.setAccessible(true); + long newFieldValue = countField.getLong(obj); + Field videoOnlineRateExpField = obj.getClass().getDeclaredField(countFileName); + videoOnlineRateExpField.setAccessible(true); + Object oldValue = videoOnlineRateExpField.get(videoOnlineRateExp); + if (oldValue == null){ + videoOnlineRateExpField.setLong(videoOnlineRateExp,newFieldValue); + }else { + //瀛樺湪鏃у�� 鐩稿姞瑕嗙洊 + videoOnlineRateExpField.setLong(videoOnlineRateExp, Long.parseLong(oldValue.toString()) + newFieldValue); + } + } + } + //璁$畻瀹屾瘡鏃ュ湪绾胯澶囨暟 + //寰幆涓�涓湀 + for (int i = 1;i <= 31 ;i++){ + //鍦ㄧ嚎鐜囪绠� + String countFileName = "count" +i; + Field countField = videoOnlineRateExp.getClass().getDeclaredField(countFileName); + countField.setAccessible(true); + long newFieldValue = countField.getLong(videoOnlineRateExp); + String fieldName = "day" + i; + //姣忔棩鍦ㄧ嚎鐜� + double rate = (double) newFieldValue / allVideoCount; + //鍙嶅皠娣诲姞鍒板璞″睘鎬т腑 + Field field = videoOnlineRateExp.getClass().getDeclaredField(fieldName); + //璁剧疆姣忔棩鍦ㄧ嚎璁惧璁惧鏁� + field.setAccessible(true); + String rateStr = String.format("%.2f", rate * 100) +"%"; + if (!"0.00%".equals(rateStr)){ + field.set(videoOnlineRateExp, rateStr); + } + + } + + + videoOnlineRateExp.setArea("鑷础甯�"); + videoOnlineRateExp.setType(type + "鍚堣"); + } + + + + /** * 璁$畻绂荤嚎璁惧excel瀵硅薄淇℃伅 @@ -771,8 +883,8 @@ */ public VideoTypeOffOnlineExp getListOfflineCountInfo(List<VideoDailyExp> videoDailyExps, String type, - AreaDeptEnum areaDeptEnum, - boolean isTotal){ + AreaDeptEnum areaDeptEnum + ){ VideoTypeOffOnlineExp videoTypeOffOnlineExp = new VideoTypeOffOnlineExp(); List<VideoDailyExp> list = videoDailyExps.stream() @@ -781,45 +893,36 @@ //绂荤嚎鏁伴噺 try { //璁剧疆绂荤嚎鏁伴噺 浠ュ強姣忔棩绂荤嚎鏁伴噺 - setVideoTypeOffOnlineExpCountAndDays(list,videoTypeOffOnlineExp,isTotal); + setVideoTypeOffOnlineExpCountAndDays(list,videoTypeOffOnlineExp); } catch (Exception e) { log.error(e.getMessage()); } //璁惧绫诲瀷 - if(isTotal){ - if ("1".equals(type)){ - videoTypeOffOnlineExp.setType("浜鸿劯鍚堣"); - }else if ("2".equals(type)){ - videoTypeOffOnlineExp.setType("鍗″彛鍚堣"); - }else if ("3".equals(type)){ - videoTypeOffOnlineExp.setType("瑙嗛鍚堣"); - } - }else { - if ("1".equals(type)){ - videoTypeOffOnlineExp.setType("浜鸿劯"); - }else if ("2".equals(type)){ - videoTypeOffOnlineExp.setType("鍗″彛"); - }else if ("3".equals(type)){ - videoTypeOffOnlineExp.setType("瑙嗛"); - } + if ("1".equals(type)){ + videoTypeOffOnlineExp.setType("浜鸿劯"); + }else if ("2".equals(type)){ + videoTypeOffOnlineExp.setType("鍗″彛"); } + else if ("3".equals(type)){ + videoTypeOffOnlineExp.setType("瑙嗛"); + } + //淇敼鍖哄煙 videoTypeOffOnlineExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName()); return videoTypeOffOnlineExp; } - private void setVideoTypeOffOnlineExpCountAndDays(List<VideoDailyExp> videoDailyExps,VideoTypeOffOnlineExp videoTypeOffOnlineExp,boolean isTotal)throws NoSuchFieldException, IllegalAccessException { + private void setVideoTypeOffOnlineExpCountAndDays(List<VideoDailyExp> videoDailyExps,VideoTypeOffOnlineExp videoTypeOffOnlineExp)throws NoSuchFieldException, IllegalAccessException { //寰幆涓�涓湀 //绂荤嚎鎬绘暟 long AllOffLineCount = 0; - log.error("浼犲叆闆嗗悎澶у皬:{}", videoDailyExps.size()); for (VideoDailyExp videoDailyExp : videoDailyExps) { if (videoDailyExp.isAllOfflineByMonth()) { AllOffLineCount++; } } //鏄悎璁℃暟鎹笉闇�瑕佷笅鏂规暟鎹� -// if (!isTotal) { + for (int i = 1; i <= 31; i++) { //姣忔棩绂荤嚎鏁� long count = 0; @@ -857,8 +960,8 @@ */ public VideoOnlineRateExp getListOnLineCountInfo(List<VideoDailyExp> videoDailyExps, String type, - AreaDeptEnum areaDeptEnum, - boolean isTotal){ + AreaDeptEnum areaDeptEnum + ){ VideoOnlineRateExp videoOnlineRateExp = new VideoOnlineRateExp(); List<VideoDailyExp> list = videoDailyExps.stream() @@ -866,28 +969,17 @@ log.error("绛涢�夊畬璁惧绫诲瀷 锛歿} 鍚庨泦鍚堢殑澶у皬锛歿}",type,list.size()); //绂荤嚎鏁伴噺 try { - //璁剧疆绂荤嚎鏁伴噺 浠ュ強姣忔棩绂荤嚎鏁伴噺 - setVideoOnlineRateExpCountAndDays(list,videoOnlineRateExp,isTotal); + setVideoOnlineRateExpCountAndDays(list,videoOnlineRateExp); } catch (Exception e) { log.error(e.getMessage()); } //璁惧绫诲瀷 - if(isTotal) { - if ("1".equals(type)) { - videoOnlineRateExp.setType("浜鸿劯鍚堣"); - } else if ("2".equals(type)) { - videoOnlineRateExp.setType("鍗″彛鍚堣"); - } else if ("3".equals(type)) { - videoOnlineRateExp.setType("瑙嗛鍚堣"); - } - }else { - if ("1".equals(type)) { - videoOnlineRateExp.setType("浜鸿劯"); - } else if ("2".equals(type)) { - videoOnlineRateExp.setType("鍗″彛"); - } else if ("3".equals(type)) { - videoOnlineRateExp.setType("瑙嗛"); - } + if ("1".equals(type)) { + videoOnlineRateExp.setType("浜鸿劯"); + } else if ("2".equals(type)) { + videoOnlineRateExp.setType("鍗″彛"); + } else if ("3".equals(type)) { + videoOnlineRateExp.setType("瑙嗛"); } //淇敼鍖哄煙 videoOnlineRateExp.setArea(areaDeptEnum == null ? "鏈煡" : areaDeptEnum.getName()); @@ -895,13 +987,13 @@ } - private void setVideoOnlineRateExpCountAndDays(List<VideoDailyExp> videoDailyExps,VideoOnlineRateExp videoOnlineRateExp,boolean isTotal)throws NoSuchFieldException, IllegalAccessException { - + private void setVideoOnlineRateExpCountAndDays(List<VideoDailyExp> videoDailyExps,VideoOnlineRateExp videoOnlineRateExp)throws NoSuchFieldException, IllegalAccessException { //寰幆涓�涓湀 for (int i = 1;i <= 31 ;i++){ //鍦ㄧ嚎鐜囪绠� long count = 0; String fieldName = "day" + i; + String countName = "count" + i; for(VideoDailyExp videoDailyExp: videoDailyExps){ // 鏋勯�犲瓧娈靛悕 Field field = videoDailyExp.getClass().getDeclaredField(fieldName); @@ -917,6 +1009,10 @@ double rate = (double) count / videoDailyExps.size(); //鍙嶅皠娣诲姞鍒板璞″睘鎬т腑 Field field = videoOnlineRateExp.getClass().getDeclaredField(fieldName); + Field countField = videoOnlineRateExp.getClass().getDeclaredField(countName); + countField.setAccessible(true); + //璁剧疆姣忔棩鍦ㄧ嚎璁惧璁惧鏁� + countField.setLong(videoOnlineRateExp, count); field.setAccessible(true); String rateStr = String.format("%.2f", rate * 100) +"%"; if (!"0.00%".equals(rateStr)){ @@ -1174,6 +1270,7 @@ @Override public Map<String, Object> videoHome(HomeQuery monitorQuery) throws ParseException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { List<HomeVideoVO> results = new ArrayList<>(); + String month = monitorQuery.getDate(); if (StringUtils.isEmpty(month)) { //濡傛灉涓虹┖鏌ユ湰鏈堢殑鏁版嵁 @@ -1200,13 +1297,30 @@ MongoDatabase database = mongoTemplate.getDb(); MongoCollection<Document> collection = database.getCollection("uy_record_meta_d_sum"); Integer examineTag = monitorQuery.getExamineTag(); + String arealayerno = monitorQuery.getArea(); Document matchConditions = new Document("statTime", new Document("$gte", startDate).append("$lte", endDate)); // 鏍规嵁examineTag鐨勫�煎姩鎬佹坊鍔犻澶栫殑鏉′欢 if (examineTag != null && examineTag.equals(1)) { matchConditions.append("provinceTag", true); } else if (examineTag != null && examineTag.equals(2)) { matchConditions.append("deptTag", true); + } else if(StringUtils.isNotBlank(arealayerno)){ + matchConditions.append("arealayerno", + new Document("$regex", "^" + arealayerno)); } + Document noExpr = new Document("$and", Arrays.asList( + new Document("$gte", Arrays.asList(new Document("$strLenCP", "$no"), 3)), + new Document("$ne", Arrays.asList( + new Document("$substrCP", Arrays.asList( + "$no", + new Document("$subtract", Arrays.asList(new Document("$strLenCP", "$no"), 3)), + 1 + )), + "3" + )) + )); +// 姝g‘娣诲姞$expr鏉′欢锛堥敭涓�"$expr"锛屽�间负涓婇潰瀹氫箟鐨勬潯浠讹級 + matchConditions.append("$expr", noExpr); // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( new Document("$match", matchConditions), @@ -1242,6 +1356,7 @@ homeVideoVO.setIntegrityNum(doc.getInteger("normalCount")); homeVideoVO.setLoseNum(doc.getInteger("loseCount")); homeVideoVO.setErrNum(doc.getInteger("errCount")); + results.add(homeVideoVO); } @@ -1255,8 +1370,24 @@ onlineMatch.add(new Document("provinceTag", true)); } else if (examineTag != null && examineTag.equals(2)) { onlineMatch.add(new Document("deptTag", true)); - } + } else if(StringUtils.isNotBlank(arealayerno)){ + Document noStartsWith = new Document("no", new Document("$regex", "^" + arealayerno)); + // 鏋勫缓鍊掓暟绗笁浣嶄笉鏄�3鐨勬潯浠� + Document noThirdLastNot3 = new Document("$expr", new Document("$and", Arrays.asList( + new Document("$gte", Arrays.asList(new Document("$strLenCP", "$no"), 3)), + new Document("$ne", Arrays.asList( + new Document("$substrCP", Arrays.asList( + "$no", + new Document("$subtract", Arrays.asList(new Document("$strLenCP", "$no"), 3)), + 1 + )), + "3" + )) + ))); + // 灏嗕袱涓潯浠剁敤$and缁勫悎鍚庢坊鍔犲埌鏉′欢鍒楄〃 + onlineMatch.add(new Document("$and", Arrays.asList(noStartsWith, noThirdLastNot3))); + } // 鏋勫缓鑱氬悎绠¢亾 List<Document> onlinePipeline = Arrays.asList( new Document("$match", new Document("$and", onlineMatch)), @@ -1270,6 +1401,10 @@ )) ) ); + //鎺掗櫎鍗″彛闆嗗悎 + + + // 鎵ц鑱氬悎鏌ヨ骞惰幏鍙栫粨鏋� AggregateIterable<Document> onlineResult = onlineCollection.aggregate(onlinePipeline); for (Document doc : onlineResult) { @@ -1401,10 +1536,13 @@ Integer examineTag = monitorQuery.getExamineTag(); // 鏋勫缓鍩烘湰鐨�$match鏉′欢 List<Document> matchConditions = new ArrayList<>(); + String arealayerno = monitorQuery.getArea(); matchConditions.add(new Document("mongoCreateTime", new Document("$gte", startDate).append("$lte", endDate))); matchConditions.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_CAR))); if (examineTag != null && examineTag.equals(1)) { matchConditions.add(new Document("provinceTag", true)); + }else if(StringUtils.isNotBlank(arealayerno)){ + matchConditions.add(new Document("orgCode",new Document("$eq", arealayerno))); } // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -1429,6 +1567,8 @@ onlineMatch.add(new Document("monitorType", new Document("$regex", "2"))); if (examineTag != null && examineTag.equals(1)) { onlineMatch.add(new Document("provinceTag", true)); + }else if(StringUtils.isNotBlank(arealayerno)){ + onlineMatch.add(new Document("no", new Document("$regex", "^" + arealayerno))); } // 鏋勫缓鑱氬悎绠¢亾 List<Document> onlinePipeline = Arrays.asList( @@ -1507,6 +1647,7 @@ calendar.add(Calendar.DAY_OF_MONTH, -1); // 鑾峰彇鏈堜唤鏈�鍚庝竴澶╃殑Date Date endDate = calendar.getTime(); + String arealayerno = monitorQuery.getArea(); //mongo鏌ユ姄鎷嶉噺 MongoDatabase database = mongoTemplate.getDb(); MongoCollection<Document> collection = database.getCollection("hk_snapshot_data_monitor"); @@ -1517,6 +1658,8 @@ matchConditions.add(new Document("dataType", new Document("$eq", ApiConstants.HK_DataType_FACE))); if (examineTag != null && examineTag.equals(1)) { matchConditions.add(new Document("provinceTag", true)); + }else if(StringUtils.isNotBlank(arealayerno)){ + matchConditions.add(new Document("orgCode",new Document("$eq", arealayerno))); } // 鏋勫缓鑱氬悎绠¢亾 List<Document> pipeline = Arrays.asList( @@ -1543,6 +1686,8 @@ onlineMatch.add(new Document("monitorType", new Document("$regex", "3"))); if (examineTag != null && examineTag.equals(1)) { onlineMatch.add(new Document("provinceTag", true)); + }else if(StringUtils.isNotBlank(arealayerno)){ + onlineMatch.add(new Document("no", new Document("$regex", "^" + arealayerno))); } // 鏋勫缓鑱氬悎绠¢亾 List<Document> onlinePipeline = Arrays.asList( -- Gitblit v1.8.0