From 5dccf0dc687dfef1c91936af3cea06fe0609b918 Mon Sep 17 00:00:00 2001
From: fuliqi <fuliqi@qq.com>
Date: 星期三, 11 十二月 2024 17:31:11 +0800
Subject: [PATCH] osd时间bug、离线工单bug等

---
 ycl-server/src/main/java/com/ycl/platform/service/impl/TMonitorServiceImpl.java |   43 ++++++++++++++++++++++++++++++++++---------
 1 files changed, 34 insertions(+), 9 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 6fc3f24..755d7c4 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
@@ -610,7 +610,16 @@
             }
         }
         List<String> deviceIds = tMonitorResults.stream().map(BaseResult::getNo).collect(Collectors.toList());
-        Query query = getQuery(deviceIds, exportForm.getMonth());
+        // 灏嗗勾鏈堝瓧绗︿覆瑙f瀽涓篩earMonth瀵硅薄
+        YearMonth yearMonth = YearMonth.parse(exportForm.getMonth());
+        // 鑾峰彇褰撴湀鐨勭涓�澶�
+        LocalDate start = yearMonth.atDay(1);
+        // 鑾峰彇涓嬩釜鏈堢殑绗竴澶╋紙閫氳繃鍔犱笂1涓湀骞惰缃棩涓�1锛�
+        YearMonth nextMonth = yearMonth.plusMonths(1);
+        LocalDate end = nextMonth.atDay(1);
+        //鑾峰彇杩欎釜鏈堜唤鐨勯儴闂ㄦ暟鎹紝褰曞儚鐢变簬鏄墠涓�澶╃殑鎵�浠ヤ笉鐢╟reateTime瀛楁
+        Query query = new Query(Criteria.where("statTime").gte(start).lt(end));
+        query.addCriteria(Criteria.where("no").in(deviceIds));
         //鏈堜唤姣忔棩褰曞儚绾挎暟鎹�
         List<RecordMetaDSumResult> recordResult = mongoTemplate.find(query, RecordMetaDSumResult.class);
         //鍏ㄩ噺琛�
@@ -686,7 +695,16 @@
             }
         }
         List<String> deviceIds = tMonitorResults.stream().map(BaseResult::getNo).collect(Collectors.toList());
-        Query query = getQuery(deviceIds, exportForm.getMonth());
+        // 灏嗗勾鏈堝瓧绗︿覆瑙f瀽涓篩earMonth瀵硅薄
+        YearMonth yearMonth = YearMonth.parse(exportForm.getMonth());
+        // 鑾峰彇褰撴湀鐨勭涓�澶�
+        LocalDate start = yearMonth.atDay(1);
+        // 鑾峰彇涓嬩釜鏈堢殑绗竴澶╋紙閫氳繃鍔犱笂1涓湀骞惰缃棩涓�1锛�
+        YearMonth nextMonth = yearMonth.plusMonths(1);
+        LocalDate end = nextMonth.atDay(1);
+        //鑾峰彇杩欎釜鏈堜唤鐨勯儴闂ㄦ暟鎹紝褰曞儚鐢变簬鏄墠涓�澶╃殑鎵�浠ヤ笉鐢╟reateTime瀛楁
+        Query query = new Query(Criteria.where("statTime").gte(start).lt(end));
+        query.addCriteria(Criteria.where("no").in(deviceIds));
         //鏈堜唤姣忔棩褰曞儚绾挎暟鎹�
         List<RecordMetaDSumResult> recordResult = mongoTemplate.find(query, RecordMetaDSumResult.class);
         //鍏ㄩ噺琛�
@@ -762,7 +780,7 @@
         MongoDatabase database = mongoTemplate.getDb();
         MongoCollection<Document> collection = database.getCollection("uy_record_meta_d_sum");
         Integer examineTag = monitorQuery.getExamineTag();
-        Document matchConditions = new Document("mongoCreateTime", new Document("$gte", startDate).append("$lte", endDate));
+        Document matchConditions = new Document("statTime", new Document("$gte", startDate).append("$lte", endDate));
         // 鏍规嵁examineTag鐨勫�煎姩鎬佹坊鍔犻澶栫殑鏉′欢
         if (examineTag != null && examineTag.equals(1)) {
             matchConditions.append("provinceTag", true);
@@ -772,7 +790,7 @@
         // 鏋勫缓鑱氬悎绠¢亾
         List<Document> pipeline = Arrays.asList(
                 new Document("$match", matchConditions),
-                new Document("$group", new Document("_id", "$mongoCreateTime")
+                new Document("$group", new Document("_id", "$statTime")
                         .append("normalCount", new Document("$sum",
                                 new Document("$cond", Arrays.asList(
                                         new Document("$eq", Arrays.asList("$recordStatus", 1)),
@@ -879,7 +897,7 @@
                 String type = car.replaceAll("3", "浜鸿劯");
                 monitor.setCameraFunType(type);
             }
-            StringBuilder tag = new StringBuilder("" + (monitor.getProvinceTag() ? "鐪佸巺銆�" : "") + (monitor.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (monitor.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (monitor.getDeptTag() ? "閮ㄧ骇銆�" : ""));
+            StringBuilder tag = new StringBuilder("" + (monitor.getProvinceTagVideo() ? "鐪佸巺瑙嗛銆�" : "") + (monitor.getProvinceTagCar() ? "鐪佸巺杞﹁締銆�" : "")+ (monitor.getProvinceTagFace() ? "鐪佸巺浜鸿劯銆�" : "")+ (monitor.getImportantTag() ? "閲嶇偣鐐逛綅銆�" : "") + (monitor.getImportantCommandImageTag() ? "閲嶇偣鎸囨尌鍥惧儚銆�" : "") + (monitor.getDeptTag() ? "閮ㄧ骇銆�" : ""));
             //鍔ㄦ�佸垪澶勭悊鍔犲湪鏍囩閲�
             if (!CollectionUtils.isEmpty(monitor.getDynamicColumnList())) {
                 List<DynamicColumnVO> dynamicColumnList = monitor.getDynamicColumnList();
@@ -894,7 +912,15 @@
             monitor.setTag(tag.toString());
         });
         ExcelUtil<TMonitorExp> util = new ExcelUtil<>(TMonitorExp.class);
-        util.exportExcel(response, monitors, "2".equals(tMonitor.getCameraFunType()) ? "杞﹁締" : "浜鸿劯");
+        String sheetName = "";
+        if("1".equals(tMonitor.getCameraFunType())){
+            sheetName = "瑙嗛";
+        }else if("2".equals(tMonitor.getCameraFunType())){
+            sheetName = "杞﹁締";
+        }else if("3".equals(tMonitor.getCameraFunType())){
+            sheetName = "浜鸿劯";
+        }
+        util.exportExcel(response, monitors,sheetName);
     }
 
 
@@ -950,7 +976,6 @@
             results.add(homecarVO);
         }
 
-        //TODO锛氬湪绾夸慨鏀癸紝闇�瑕佹妸妫�娴嬫捣搴蜂紭浜戞娴嬬殑缁撴灉瀛樺叆mongo锛宮ongo鏌ョ偣浣嶅湪绾�
         MongoCollection<Document> onlineCollection = database.getCollection("t_monitor_online");
         // 鏋勫缓鍩烘湰鐨�$match鏉′欢
         List<Document> onlineMatch = new ArrayList<>();
@@ -1172,7 +1197,7 @@
         //涓�涓澶囧綋鏈堝湪绾挎儏鍐�
         List<RecordMetaDSumResult> recordResults = records.stream().filter(online -> online.getNo().equals(result.getNo())).collect(Collectors.toList());
         for (RecordMetaDSumResult recordResult : recordResults) {
-            int dayOfMonth = recordResult.getMongoCreateTime().getDayOfMonth();
+            int dayOfMonth = DateUtils.getDayOfMonth(recordResult.getStatTime());
             Integer status = recordResult.getRecordStatus();
             String text = "";
             if (ApiConstants.UY_RecordStatus_Interval.equals(status)) {
@@ -1194,7 +1219,7 @@
         //涓�涓澶囧綋鏈堝湪绾挎儏鍐�
         List<RecordMetaDSumResult> recordResults = records.stream().filter(online -> online.getNo().equals(result.getNo())).collect(Collectors.toList());
         for (RecordMetaDSumResult recordResult : recordResults) {
-            int dayOfMonth = recordResult.getMongoCreateTime().getDayOfMonth();
+            int dayOfMonth = DateUtils.getDayOfMonth(recordResult.getStatTime());
             //鍙嶅皠璧嬪�硷紝瀛楁缁熶竴瀹氫箟涓篸ay+1锛�2锛�3...
             Field field = videoDailyExp.getClass().getDeclaredField("day" + dayOfMonth);
             field.setAccessible(true);

--
Gitblit v1.8.0