From 68e4f49cf09a133defc646f10654bbb3fe6ab487 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期一, 12 八月 2024 16:09:49 +0800
Subject: [PATCH] 海康接口调整

---
 ycl-server/src/main/java/com/ycl/calculate/IndexCalculationServe.java |   42 ++++++++++++++++++++++++++----------------
 1 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/calculate/IndexCalculationServe.java b/ycl-server/src/main/java/com/ycl/calculate/IndexCalculationServe.java
index de0049f..6546b7b 100644
--- a/ycl-server/src/main/java/com/ycl/calculate/IndexCalculationServe.java
+++ b/ycl-server/src/main/java/com/ycl/calculate/IndexCalculationServe.java
@@ -1,22 +1,19 @@
 package com.ycl.calculate;
 
 
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ycl.platform.base.CheckIndex;
-import com.ycl.platform.domain.entity.CheckIndexCar;
-import com.ycl.platform.domain.entity.TMonitor;
-import com.ycl.platform.domain.result.HK.SnapshotDataMonitorResult;
-import com.ycl.platform.service.ITMonitorService;
+import com.ycl.platform.domain.entity.YwPoint;
+import com.ycl.platform.mapper.YwPointMapper;
+import constant.ApiConstants;
 import constant.CheckConstants;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
-import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
-import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -25,6 +22,15 @@
 @Component
 @Slf4j
 public class IndexCalculationServe {
+    @Autowired
+    private YwPointMapper pointMapper;
+
+    //涓�鏈轰竴妗e悎鏍肩巼
+    public BigDecimal monitorQualify(Map<String, Object> param) {
+        BigDecimal totalMonitors = new BigDecimal((Integer) param.get("totalMonitors"));
+        BigDecimal qualifyMonitor = new BigDecimal((Integer) param.get("qualifyMonitor"));
+        return qualifyMonitor.divide(totalMonitors, 4, RoundingMode.HALF_UP);
+    }
 
     //鐐逛綅鍦ㄧ嚎鐜�
     public BigDecimal siteOnline(Map<String, Object> param) {
@@ -119,16 +125,20 @@
 
     //杩斿洖鐪佸巺鍥芥爣鐮侀泦鍚�
     public List<String> getProvince() {
-        // TODO: 鍒嗙渷鍘呭競灞� 闇�瑕佽ˉ鍏呴泦鍚堟暟鎹�
-        List<String> list = new ArrayList<>();
-        return list;
+        List<YwPoint> province = pointMapper.selectByTag(null, Boolean.TRUE, null);
+        return CollectionUtils.isEmpty(province) ? new ArrayList<>() : province.stream().map(YwPoint::getSerialNumber).collect(Collectors.toList());
     }
 
     //杩斿洖閲嶇偣鐐逛綅闆嗗悎
     public List<String> getImportant() {
-        // TODO: 閲嶇偣鐐逛綅 闇�瑕佽ˉ鍏呴泦鍚堟暟鎹�
-        List<String> list = new ArrayList<>();
-        return list;
+        List<YwPoint> important = pointMapper.selectByTag(Boolean.TRUE, null, null);
+        return CollectionUtils.isEmpty(important) ? new ArrayList<>() : important.stream().map(YwPoint::getSerialNumber).collect(Collectors.toList());
+    }
+
+    //杩斿洖閲嶇偣鎸囨尌鍥惧儚闆嗗悎
+    public List<String> getCommandImage() {
+        List<YwPoint> commandImages = pointMapper.selectByTag(null, null, Boolean.TRUE);
+        return CollectionUtils.isEmpty(commandImages) ? new ArrayList<>() : commandImages.stream().map(YwPoint::getSerialNumber).collect(Collectors.toList());
     }
 
     //妫�鏌ユ槸鍚﹀瓨鍦ㄥ綋鏃ユ暟鎹�
@@ -138,7 +148,7 @@
         // 妫�鏌ユ槸鍚﹀凡瀛樺湪浠婃棩鏁版嵁
         Optional<T> existingIndex = checkIndexList.stream()
                 .filter(index -> key.equals(index.getDeptId().toString()) &&
-                        (key.startsWith("Province_") ? CheckConstants.Examine_Tag_City.equals(index.getExamineTag())
+                        (key.startsWith(ApiConstants.Province) ? CheckConstants.Examine_Tag_Province.equals(index.getExamineTag())
                                 : CheckConstants.Examine_Tag_County.equals(index.getExamineTag())))
                 .findFirst();
 
@@ -147,8 +157,8 @@
         } else {
             try {
                 checkIndex = clazz.getDeclaredConstructor().newInstance();
-                checkIndex.setDeptId(key.startsWith("Province_") ? Long.parseLong(key.split("_")[1]) : Long.parseLong(key));
-                checkIndex.setExamineTag(key.startsWith("Province_") ? CheckConstants.Examine_Tag_City : CheckConstants.Examine_Tag_County);
+                checkIndex.setDeptId(key.startsWith(ApiConstants.Province) ? Long.parseLong(key.split("_")[1]) : Long.parseLong(key));
+                checkIndex.setExamineTag(key.startsWith(ApiConstants.Province) ? CheckConstants.Examine_Tag_Province : CheckConstants.Examine_Tag_County);
                 checkIndex.setCreateTime(new Date());
             } catch (Exception e) {
                 checkIndex = null;

--
Gitblit v1.8.0