package cn.cecep.talroad.domain;

import cn.cecep.talroad.common.core.annotation.Excel;
import cn.cecep.talroad.common.core.exception.ServiceException;
import cn.cecep.talroad.common.core.web.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Arrays;
import java.util.Date;


/**
 * 排污许可对象 b_main_poll_dis
 *
 * @author szhpt
 * @date 2023-01-18*/
@ApiModel(value = "排污许可")
@Data
@ToString
@EqualsAndHashCode(callSuper = false)
@TableName("b_main_poll_dis")
public class BMainPollDis extends BaseEntity
{
    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "主键id")
    /** 主键id */
    @TableId(value = "id",type = IdType.ASSIGN_UUID)
    private String id;


    @ApiModelProperty(value = "企业id")
    /** 企业id */
    @Excel(name = "企业id")
    private String factoryId;


    @ApiModelProperty(value = "许可证编号")
    /** 许可证编号 */
    @Excel(name = "许可证编号")
    private String pollDisLicenseCode;


    @ApiModelProperty(value = "业务类型")
    /** 业务类型 */
    @Excel(name = "业务类型")
    private String businessType;


    @ApiModelProperty(value = "版本")
    /** 版本 */
    @Excel(name = "版本")
    private String editionCode;


    @ApiModelProperty(value = "办结日期")
    /** 办结日期 */
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "办结日期", width = 30, dateFormat = "yyyy-MM-dd")
    private Date completionTime;


    @ApiModelProperty(value = "有效期限")
    /** 有效期限 */
    @Excel(name = "有效期限")
    private String pollDisLicenseDeadline;


    @ApiModelProperty(value = "许可证正本")
    /** 许可证正本 */
    @Excel(name = "许可证正本")
    private String pollDisOriginal;


    @ApiModelProperty(value = "许可证副本")
    /** 许可证副本 */
    @Excel(name = "许可证副本")
    private String pollDisEctype;

    @ApiModelProperty(value = "二维码图片地址")
    private String qrCodeUrl;

    @ApiModelProperty(value = "排污许可主键id")
    private String dataId;

    @ApiModelProperty(value = "有效开始日期")
    private String startTime;

    @ApiModelProperty(value = "有效截止日期")
    private String deadlineTime;


    /**
     * 排污许可信息-类型
     */
    public enum PwxkzType {
        TYPE_1("TYPEB","补充申报"),
        TYPE_2("TYPEJ","审批部门变更"),
        TYPE_3("TYPED","延续"),
        TYPE_4("TYPEH","整改后申请"),
        TYPE_5("TYPEC","变更"),
        TYPE_6("TYPEI","重新申请"),
        FILE_7("TYPEA","申领");

        public String code;
        public String desc;

        public static PwxkzType getByCode(String code) {
            return Arrays.stream(PwxkzType.values())
                    .filter(enums -> enums.code.equals(code)).findFirst().orElseThrow(() -> new ServiceException("EnumException"));
        }

        PwxkzType(String code, String desc) {
            this.code = code;
            this.desc = desc;
        }
    }
}
