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

com.dahuatech.icc.multiinone.visitor.vo.AppointmentRequest Maven / Gradle / Ivy

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

import com.dahuatech.icc.multiinone.exception.BusinessException;
import com.dahuatech.icc.multiinone.utils.CollectionsUtils;
import com.dahuatech.icc.multiinone.utils.StringUtils;
import com.dahuatech.icc.multiinone.visitor.domain.VisitorInfo;
import com.dahuatech.icc.multiinone.vo.BaseRequest;

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

public class AppointmentRequest extends BaseRequest {

    private String isv_id;
    private String v_name;
    private String v_phone;
    private String v_dw;
    private String v_plateNumber;
    private String v_certificateType;
    private String v_certificateNumber;
    private Integer v_personSum = 1;
    private String v_reason;
    private String v_timeStr;
    private String v_lvTimeStr;
    private File faceFile;
    private String visitorType = "0";
    private Integer approveFlag = 0;
    private List followVisitors;
    public String getIsv_id() {
        return isv_id;
    }

    public void setIsv_id(String isv_id) {
        this.isv_id = isv_id;
    }

    public String getV_name() {
        return v_name;
    }

    public void setV_name(String v_name) {
        this.v_name = v_name;
    }

    public String getV_phone() {
        return v_phone;
    }

    public void setV_phone(String v_phone) {
        this.v_phone = v_phone;
    }

    public String getV_dw() {
        return v_dw;
    }

    public void setV_dw(String v_dw) {
        this.v_dw = v_dw;
    }

    public String getV_plateNumber() {
        return v_plateNumber;
    }

    public void setV_plateNumber(String v_plateNumber) {
        this.v_plateNumber = v_plateNumber;
    }

    public String getV_certificateType() {
        return v_certificateType;
    }

    public void setV_certificateType(String v_certificateType) {
        this.v_certificateType = v_certificateType;
    }

    public String getV_certificateNumber() {
        return v_certificateNumber;
    }

    public void setV_certificateNumber(String v_certificateNumber) {
        this.v_certificateNumber = v_certificateNumber;
    }

    public Integer getV_personSum() {
        return v_personSum;
    }

    public void setV_personSum(Integer v_personSum) {
        this.v_personSum = v_personSum;
    }

    public String getV_reason() {
        return v_reason;
    }

    public void setV_reason(String v_reason) {
        this.v_reason = v_reason;
    }

    public String getV_timeStr() {
        return v_timeStr;
    }

    public void setV_timeStr(String v_timeStr) {
        this.v_timeStr = v_timeStr;
    }

    public String getV_lvTimeStr() {
        return v_lvTimeStr;
    }

    public void setV_lvTimeStr(String v_lvTimeStr) {
        this.v_lvTimeStr = v_lvTimeStr;
    }

    public File getFaceFile() {
        return faceFile;
    }

    public void setFaceFile(File faceFile) {
        this.faceFile = faceFile;
    }

    public String getVisitorType() {
        return visitorType;
    }

    public void setVisitorType(String visitorType) {
        this.visitorType = visitorType;
    }

    public Integer getApproveFlag() {
        return approveFlag;
    }

    public void setApproveFlag(Integer approveFlag) {
        this.approveFlag = approveFlag;
    }

    public List getFollowVisitors() {
        return followVisitors;
    }

    public void setFollowVisitors(List followVisitors) {
        this.followVisitors = followVisitors;
    }

    public void businessValid() {
        if(StringUtils.isEmpty(v_name) || !v_name.matches("^[a-zA-Z0-9\\-_\\u4E00-\\u9FA5]{1,20}$")){
            throw new BusinessException("访客姓名非法");
        }
        if(StringUtils.isEmpty(v_phone) || !v_phone.matches("^(([0\\+][0-9]{2,3}-)?(0[0-9]{2,3})-)?(\\d{7,8})(-(\\d{3,}))?$|^1[3|4|5|7|8|9][0-9]{9}$")){
            throw new BusinessException("访客手机号非法");
        }
        if(StringUtils.isEmpty(v_certificateType)){
            throw new BusinessException("访客证件类型为空");
        }
        if(StringUtils.isEmpty(v_certificateNumber) || !v_certificateNumber.matches("^[a-zA-Z0-9]+$")){
            throw new BusinessException("访客证件号码非法");
        }
        if(!StringUtils.isEmpty(v_plateNumber) && (v_plateNumber.length() > 8 || v_plateNumber.length() < 7)){
            throw new BusinessException("访客车牌号非法");
        }
        if(StringUtils.isEmpty(v_reason)){
            throw new BusinessException("访客来访事由为空");
        }
        if(StringUtils.isEmpty(isv_id)){
            throw new BusinessException("被访人id为空");
        }
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        dateFormat.setLenient(false);
        if(StringUtils.isEmpty(v_timeStr)){
            throw new BusinessException("预约来访时间为空");
        }
        if(StringUtils.isEmpty(v_lvTimeStr)){
            throw new BusinessException("预约离访时间为空");
        }
        try{
            dateFormat.parse(v_timeStr);
        }catch (Exception e){
            throw new BusinessException("预约来访时间格式非法");
        }
        try{
            dateFormat.parse(v_lvTimeStr);
        }catch (Exception e){
            throw new BusinessException("预约离访时间格式非法");
        }
        if(!CollectionsUtils.isEmpty(followVisitors)){
            for(VisitorInfo visitorInfo : followVisitors){
                if(StringUtils.isEmpty(visitorInfo.getV_name()) || !visitorInfo.getV_name().matches("^[a-zA-Z0-9\\-_\\u4E00-\\u9FA5]{1,20}$")){
                    throw new BusinessException("随访访客姓名非法");
                }
                if(StringUtils.isEmpty(visitorInfo.getV_phone()) || !visitorInfo.getV_phone().matches("^(([0\\+][0-9]{2,3}-)?(0[0-9]{2,3})-)?(\\d{7,8})(-(\\d{3,}))?$|^1[3|4|5|7|8|9][0-9]{9}$")){
                    throw new BusinessException("随访访客手机号非法");
                }
                if(StringUtils.isEmpty(visitorInfo.getV_certificateNumber()) || !visitorInfo.getV_certificateNumber().matches("^[a-zA-Z0-9]+$")){
                    throw new BusinessException("随访访客证件号码非法");
                }
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy