| | |
| | | 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 (examineTag != null && examineTag.equals(2)) { |
| | | matchConditions.add(new Document("deptTag", true)); |
| | | } |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | |
| | | .append("dataCount", new Document("$sum", "$dataCount")) |
| | | ) |
| | | ); |
| | | |
| | | // 执行聚合查询并获取结果 |
| | | AggregateIterable<Document> result = collection.aggregate(pipeline); |
| | | for (Document doc : result) { |
| | |
| | | results.add(homecarVO); |
| | | } |
| | | |
| | | //mongo查点位在线 |
| | | //TODO:在线修改,需要把检测海康优云检测的结果存入mongo,mongo查点位在线 |
| | | MongoCollection<Document> onlineCollection = database.getCollection("t_monitor_online"); |
| | | // 构建基本的$match条件 |
| | | List<Document> onlineMatch = new ArrayList<>(); |
| | |
| | | onlineMatch.add(new Document("monitorType", new Document("$regex", "2"))); |
| | | if (examineTag != null && examineTag.equals(1)) { |
| | | onlineMatch.add(new Document("provinceTag", true)); |
| | | } else if (examineTag != null && examineTag.equals(2)) { |
| | | onlineMatch.add(new Document("deptTag", true)); |
| | | } |
| | | // 构建聚合管道 |
| | | List<Document> onlinePipeline = Arrays.asList( |
| | |
| | | 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 (examineTag != null && examineTag.equals(2)) { |
| | | matchConditions.add(new Document("deptTag", true)); |
| | | } |
| | | // 构建聚合管道 |
| | | List<Document> pipeline = Arrays.asList( |
| | |
| | | onlineMatch.add(new Document("monitorType", new Document("$regex", "3"))); |
| | | if (examineTag != null && examineTag.equals(1)) { |
| | | onlineMatch.add(new Document("provinceTag", true)); |
| | | } else if (examineTag != null && examineTag.equals(2)) { |
| | | onlineMatch.add(new Document("deptTag", true)); |
| | | } |
| | | // 构建聚合管道 |
| | | List<Document> onlinePipeline = Arrays.asList( |
| | |
| | | </select> |
| | | |
| | | <select id="recoveryException" resultType="java.util.Map"> |
| | | SELECT count(*) AS totalPosts, |
| | | IFNULL(SUM(IF(p.online = 1, 1, 0)), 0) AS totalMembers, |
| | | IFNULL(SUM(IF(p.online = 0, 1, 0)), 0) AS postsPercentage, |
| | | IFNULL(ROUND(SUM(IF(p.online = 1, 1, 0)) / count(*) * 100, 2), 0) as viewsPercentage |
| | | FROM t_monitor t |
| | | LEFT JOIN t_yw_point p ON t.serial_number = p.serial_number |
| | | left join sys_dept d on p.dept_id = d.dept_id and d.del_flag = 0 |
| | | SELECT count(*) AS totalPosts, |
| | | IFNULL(SUM(IF(p.online = 1, 1, 0)), 0) AS totalMembers, |
| | | IFNULL(SUM(IF(p.online = -1, 1, 0)), 0) AS postsPercentage, |
| | | IFNULL(SUM(IF(p.online = 0, 1, 0)), 0) AS unknownNumbers, |
| | | IFNULL(ROUND(SUM(IF(p.online = 1 , 1, 0)) / count(*) * 100, 2), 0) as viewsPercentage FROM t_monitor m |
| | | <where> |
| | | p.examine_status = 1 |
| | | <!-- (p.recovery = 1 OR TIMESTAMPDIFF(DAY, p.recovery_time, NOW()) <![CDATA[<=]]> #{time}) --> |
| | | <if test="provinceTag!=null"> |
| | | and p.province_tag = #{provinceTag} |
| | | </if> |
| | | <if test="deptTag!=null"> |
| | | and p.dept_tag = #{deptTag} |
| | | </if> |
| | | ${params.dataScope} |
| | | </where> |
| | | </select> |