All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dahuatech.icc.multiinone.face.vo.FaceSearchRequest Maven / Gradle / Ivy

There is a newer version: 1.0.13.7
Show newest version
package com.dahuatech.icc.multiinone.face.vo;

import com.dahuatech.icc.multiinone.exception.BusinessException;
import com.dahuatech.icc.multiinone.utils.StringUtils;
import com.dahuatech.icc.multiinone.vo.BaseRequest;

import java.io.File;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

public class FaceSearchRequest extends BaseRequest {

    private Integer searchGroupType = 1;//数据检索库类型,1 抓拍库,2 注册库,默认抓拍库
    private File image;
    private String threshold;//相似度,推荐 60 ~ 100
    private List groupIds;//searchGroupTyp = 2; 时有效,人像库ID集合
    private List deviceCodes;//searchGroupTyp = 2 时有效,设备编码集合,不超过10个
    private String startTime;//searchGroupTyp = 1 时有效, 格式:yyyy-MM-dd HH:mm:ss
    private String endTime;//searchGroupTyp = 1 时有效, 格式:yyyy-MM-dd HH:mm:ss
    private Map> deviceChannels;//searchGroupTyp= 1时有效,设备对应通道映射集合,键值对不超过10个

    private int pageNum = 1;//页码
    private int pageSize = 10;//分页大小
    private Integer ordered;//排序方式1-按相似度从高到底,2-按相似度从底到高,3-按时间正序,4-按时间倒序 备注:当searchGroupType=2,只有按相似度排序。

    private Integer queryTimeOut = 30;

    private String sessionId;//查询流水ID

    public Integer getSearchGroupType() {
        return searchGroupType;
    }

    public void setSearchGroupType(Integer searchGroupType) {
        this.searchGroupType = searchGroupType;
    }

    public String getThreshold() {
        return threshold;
    }

    public void setThreshold(String threshold) {
        this.threshold = threshold;
    }

    public List getGroupIds() {
        return groupIds;
    }

    public void setGroupIds(List groupIds) {
        this.groupIds = groupIds;
    }

    public List getDeviceCodes() {
        return deviceCodes;
    }

    public void setDeviceCodes(List deviceCodes) {
        this.deviceCodes = deviceCodes;
    }

    public String getStartTime() {
        return startTime;
    }

    public void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public Map> getDeviceChannels() {
        return deviceChannels;
    }

    public void setDeviceChannels(Map> deviceChannels) {
        this.deviceChannels = deviceChannels;
    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public Integer getOrdered() {
        return ordered;
    }

    public void setOrdered(Integer ordered) {
        this.ordered = ordered;
    }

    public Integer getQueryTimeOut() {
        return queryTimeOut;
    }

    public void setQueryTimeOut(Integer queryTimeOut) {
        this.queryTimeOut = queryTimeOut;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public File getImage() {
        return image;
    }

    public void setImage(File image) {
        this.image = image;
    }

    public void businessValid() {
        if(searchGroupType == null){
            throw new BusinessException("数据检索库类型为空");
        }
        if(searchGroupType != 1 && searchGroupType != 2){//抓拍库
            throw new BusinessException("数据检索库类型非法");
        }
        if(StringUtils.isEmpty(sessionId)){
            if(searchGroupType == 1){
                if(StringUtils.isEmpty(startTime)){
                    throw new BusinessException("查询开始时间为空");
                }
                if(StringUtils.isEmpty(endTime)){
                    throw new BusinessException("查询结束时间为空");
                }
                DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                dateFormat.setLenient(false);
                try {
                    dateFormat.parse(startTime);
                } catch (ParseException e) {
                    throw new BusinessException("查询开始时间非法");
                }
                try {
                    dateFormat.parse(endTime);
                } catch (ParseException e) {
                    throw new BusinessException("查询结束时间非法");
                }
                if(deviceChannels == null || deviceChannels.size() > 10){
                    throw new BusinessException("设备对应通道映射集合非法");
                }
                int size = 0;
                for(Map.Entry> item : deviceChannels.entrySet()){
                    if(item.getValue() == null || item.getValue().size() == 0 || item.getValue().size() > 10){
                        throw new BusinessException("设备[" + item.getKey() + "]对应通道映射集合非法");
                    }
                    size += item.getValue().size();
                }
                if(size > 10){
                    throw new BusinessException("设备对应通道映射集合 键值个数超限");
                }
            }else{
                if(groupIds == null || groupIds.size() == 0){
                    throw new BusinessException("人像库ID集合为空");
                }
                if(deviceCodes == null || deviceCodes.size() == 0){
                    throw new BusinessException("设备编码集合超限");
                }
            }
            if(image == null){
                throw new BusinessException("图片内容为空");
            }
//            if(StringUtils.isEmpty(base64Img)){
//                throw new BusinessException("图片内容为空");
//            }
        }

    }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy