package com.zksy.system.basicData.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.zksy.common.utils.file.ExcelExport;
import com.zksy.common.utils.file.ExcelImport;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDate;
import java.util.Date;
import java.util.regex.Pattern;

/**
 * <p>
 * 行政许可
 * </p>
 *
 * @author ShaoYang
 * @since 2024-03-26
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("crm_administrative_license")
@ApiModel("行政许可")
public class CrmAdministrativeLicense extends Model<CrmAdministrativeLicense> {

    private static final long serialVersionUID = 1L;

    /**
     * 主键id
     */
    @TableId(value = "id", type = IdType.AUTO)
    @ApiModelProperty(value = "主键id")
    private Long id;
    /**
     * 行政相对人名称
     */
    @ExcelImport(value = "行政相对人名称",required = true)
    @ExcelExport(value = "行政相对人名称")
    private String administrativePartyName;

    /**
     * 行政相对人类别
     */
    @ExcelImport(value = "行政相对人类别",required = true)
    @ExcelExport(value = "行政相对人类别")
    private String administrativePartyType;

    /**
     * 主体编码
     */
    @ExcelImport(value = "主体编码")
    @ExcelExport(value = "主体编码")
    private String unifiedSocialCreditCode;

    /**
     * 工商注册号
     */
    @ExcelImport(value = "工商注册号")
    @ExcelExport(value = "工商注册号")
    private String businessRegistrationNumber;

    /**
     * 法定代表人
     */
    @ExcelImport(value = "法定代表人")
    @ExcelExport(value = "法定代表人")
    private String legalRepresentative;

    /**
     * 法定代表人证件类型
     */
    @ExcelImport(value = "法定代表人证件类型")
    @ExcelExport(value = "法定代表人证件类型")
    private String legalRepresentativeIdType;

    /**
     * 法定代表人证件类型其他类型说明
     */
    @ExcelImport(value = "法定代表人证件类型其他类型说明")
    @ExcelExport(value = "法定代表人证件类型其他类型说明")
    private String legalRepresentativeIdOtherTypeDesc;

    /**
     * 法定代表人证件号码
     */
    @ExcelImport(value = "法定代表人证件号码")
    @ExcelExport(value = "法定代表人证件号码")
    private String legalRepresentativeIdNumber;

    /**
     * 证件类型
     */
    @ExcelImport(value = "证件类型")
    @ExcelExport(value = "证件类型")
    private String idType;

    /**
     * 证件类型其他类型说明
     */
    @ExcelImport(value = "证件类型其他类型说明")
    @ExcelExport(value = "证件类型其他类型说明")
    private String idOtherTypeDesc;

    /**
     * 行政许可决定文书名称
     */
    @ExcelImport(value = "行政许可决定文书名称")
    @ExcelExport(value = "行政许可决定文书名称")
    private String administrativeLicenseDecisionDocName;

    /**
     * 行政许可决定文书号
     */
    @ExcelImport(value = "行政许可决定文书号")
    @ExcelExport(value = "行政许可决定文书号")
    private String administrativeLicenseDecisionDocNumber;

    /**
     * 许可类别
     */
    @ExcelImport(value = "许可类别")
    @ExcelExport(value = "许可类别")
    private String licenseType;

    /**
     * 其它许可类别说明
     */
    @ExcelImport(value = "其它许可类别说明")
    @ExcelExport(value = "其它许可类别说明")
    private String licenseTypeExplain;

    /**
     * 许可证书名称
     */
    @ExcelImport(value = "许可证书名称")
    @ExcelExport(value = "许可证书名称")
    private String licenseCertificateName;

    /**
     * 许可编号
     */
    @ExcelImport(value = "许可编号")
    @ExcelExport(value = "许可编号")
    private String licenseNumber;

    /**
     * 许可内容
     */
    @ExcelImport(value = "许可内容")
    @ExcelExport(value = "许可内容")
    private String licenseContent;

    /**
     * 许可决定日期
     */
    @ExcelImport(value = "许可决定日期")
    @ExcelExport(value = "许可决定日期")
    private Date licenseDecisionDate;

    /**
     * 有效期自
     */
    @ExcelImport(value = "有效期自")
    @ExcelExport(value = "有效期自")
    private Date validFrom;

    /**
     * 有效期至
     */
    @ExcelImport(value = "有效期至")
    @ExcelExport(value = "有效期至")
    private Date validUntil;

    /**
     * 许可机关
     */
    @ExcelImport(value = "许可机关")
    @ExcelExport(value = "许可机关")
    private String licensingAuthority;

    /**
     * 许可机关统一社会信用代码
     */
    @ExcelImport(value = "许可机关统一社会信用代码")
    @ExcelExport(value = "许可机关统一社会信用代码")
    private String licensingAuthorityUnifiedSocialCreditCode;

    /**
     * 当前状态
     */
    @ExcelImport(value = "当前状态")
    @ExcelExport(value = "当前状态\n（1-有效；2-无效）")
    private String currentStatus;

    /**
     * 备注
     */
    @ExcelImport(value = "备注")
    @ExcelExport(value = "备注")
    private String remarks;
    /**
     * 法定代表人姓名脱敏：只保留姓氏，名字部分用*代替
     */
    public String getLegalRepresentative() {
        if (this.legalRepresentative == null || this.legalRepresentative.length() <= 1) {
            return this.legalRepresentative;
        }
        return this.legalRepresentative.substring(0, 1) + "*";
    }
}
