zxl
4 天以前 c83101eb62f5d4906b9c01ceea6b21a37f9e84d8
ycl-pojo/src/main/java/com/ycl/platform/domain/result/HK/FaceDeviceInspectionResult.java
@@ -1,7 +1,11 @@
package com.ycl.platform.domain.result.HK;
import com.ycl.platform.domain.result.BaseResult;
import com.ycl.platform.domain.vo.DataCenter.SnapClockVO;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.data.mongodb.core.index.TextIndexed;
import org.springframework.data.mongodb.core.mapping.Document;
/**
@@ -11,6 +15,7 @@
 */
@Data
@Document(collection = "hk_face_device_inspection")
@Slf4j
public class FaceDeviceInspectionResult extends BaseResult {
    /**
@@ -68,6 +73,11 @@
     */
    private Integer snapResult;
    /**
     * 抓拍数据量监测结果,1:正常 2:无数据 4:数据量少
     */
    private String snapResultText;
    // 以下为嵌套对象的字段
    /**
@@ -90,6 +100,19 @@
     */
    private SnapUnique snapUnique;
    public String getSnapResultText() {
        if (snapResult == 1) {
            snapResultText = "正常";
        }
        if (snapResult == 2) {
            snapResultText = "无数据";
        }
        if (snapResult == 4) {
            snapResultText = "数据量少";
        }
        return snapResultText;
    }
    // 内嵌对象定义
    @Data
@@ -110,6 +133,11 @@
        private Integer todayClockResult;
        /**
         * 当日接收的当日抓拍数据时钟准确性判定结果:1是合格,0是不合格
         */
        private String todayClockResultText;
        /**
         * 当日接收的全部抓拍数据中时钟准确数据量
         */
        private Integer allClockCount;
@@ -118,6 +146,31 @@
         * 当日接收的全部抓拍数据中时钟准确性判定结果:1是合格,0是不合格
         */
        private Integer allClockResult;
        /**
         * 当日接收的全部抓拍数据中时钟准确性判定结果:1是合格,0是不合格
         */
        private String allClockResultText;
        public String getTodayClockResultText() {
            if (todayClockResult == 1) {
                todayClockResultText = "合格";
            }
            if (todayClockResult == 0) {
                todayClockResultText = "不合格";
            }
            return todayClockResultText;
        }
        public String getAllClockResultText() {
            if (allClockResult == 1) {
                allClockResultText = "合格";
            }
            if (allClockResult == 0) {
                allClockResultText = "不合格";
            }
            return allClockResultText;
        }
    }
    @Data
@@ -153,6 +206,11 @@
        private Integer todayTimelyResult;
        /**
         * 当日接收的当日抓拍数据及时性判定结果:1是合格,0是不合格
         */
        private String todayTimelyResultText;
        /**
         * 当日接收的全部抓拍数据中延迟数据量
         */
        private Integer allDelayCount;
@@ -176,6 +234,31 @@
         * 当日接收的全部抓拍数据中及时性判定结果:1是合格,0是不合格
         */
        private Integer allTimelyResult;
        /**
         * 当日接收的全部抓拍数据中及时性判定结果:1是合格,0是不合格
         */
        private String allTimelyResultText;
        public String getTodayTimelyResultText() {
            if (todayTimelyResult == 1) {
                todayTimelyResultText = "合格";
            }
            if (todayTimelyResult == 0) {
                todayTimelyResultText = "不合格";
            }
            return todayTimelyResultText;
        }
        public String getAllTimelyResultText() {
            if (allTimelyResult == 1) {
                allTimelyResultText = "合格";
            }
            if (allTimelyResult == 0) {
                allTimelyResultText = "不合格";
            }
            return allTimelyResultText;
        }
    }
    @Data
@@ -223,4 +306,37 @@
         */
        private Integer nouniqueCount;
    }
    public static SnapClockVO getVO(FaceDeviceInspectionResult result){
        SnapClockVO snapClockVO = new SnapClockVO();
        BeanUtils.copyProperties(result,snapClockVO);
        SnapClock snapClock = result.getSnapClock();
        if (snapClock != null) {
            snapClockVO.setClockPercent(snapClock.getClockPercent());
            snapClockVO.setTodayClockCount(snapClock.getTodayClockCount());
            snapClockVO.setTodayClockResult(snapClock.getTodayClockResult());
            snapClockVO.setAllClockCount(snapClock.getAllClockCount());
            snapClockVO.setAllClockResult(snapClock.getAllClockResult());
            snapClockVO.setAllClockResultText(snapClock.getAllClockResultText());
            snapClockVO.setTodayClockResultText(snapClock.getTodayClockResultText());
        } else {
            log.info("出现空数据值:{}",result);
            // 空值兜底:给 VO 字段赋默认值,防止前端接收 null 报错
            snapClockVO.setClockPercent(0.0f); // 数值型默认 0.0
            snapClockVO.setTodayClockCount(0); // 计数型默认 0
            snapClockVO.setTodayClockResult(0); // 结果状态默认 0(可根据业务调整)
            snapClockVO.setAllClockCount(0);
            snapClockVO.setAllClockResult(0);
            snapClockVO.setAllClockResultText(""); // 文本型默认空字符串
            snapClockVO.setTodayClockResultText("");
        }
//        snapClockVO.setClockPercent(result.getSnapClock().getClockPercent());
//        snapClockVO.setTodayClockCount(result.getSnapClock().getTodayClockCount());
//        snapClockVO.setTodayClockResult(result.getSnapClock().getTodayClockResult());
//        snapClockVO.setAllClockCount(result.getSnapClock().getAllClockCount());
//        snapClockVO.setAllClockResult(result.getSnapClock().getAllClockResult());
//        snapClockVO.setAllClockResultText(result.getSnapClock().getAllClockResultText());
//        snapClockVO.setTodayClockResultText(result.getSnapClock().getTodayClockResultText());
        return snapClockVO;
    }
}