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 cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;

import java.util.Arrays;


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


    @ApiModelProperty(value = "主键id")
    @TableId(value = "file_id",type = IdType.AUTO)
    /** 主键id */
    private Long fileId;


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


    @ApiModelProperty(value = "排污许可表id")
    /** 排污许可表id */
    @Excel(name = "排污许可表id")
    private String pollDisId;


    @ApiModelProperty(value = "文件类型名称")
    /** 文件类型名称 */
    @Excel(name = "文件类型名称")
    private String fileType;


    @ApiModelProperty(value = "文件名称")
    /** 文件名称 */
    @Excel(name = "文件名称")
    private String fileName;

    @ApiModelProperty(value = "文件地址")
    /** 文件地址 */
    @Excel(name = "文件地址")
    private String fileUrl;

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("fileId", getFileId())
                .append("factoryId", getFactoryId())
                .append("pollDisId", getPollDisId())
                .append("fileType", getFileType())
                .append("fileName", getFileName())
                .append("fileUrl", getFileUrl())
                .toString();
    }

    /**
     * @throws
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     */
    public static QueryWrapper<BMainPollDisFile> createLambdaQueryWrapper(String factoryId, String pollDisId) {
        QueryWrapper<BMainPollDisFile> wrapper = new QueryWrapper<>();
        wrapper.eq(ObjectUtil.isNotNull(factoryId), "factory_id", factoryId);
        wrapper.eq(ObjectUtil.isNotNull(pollDisId), "poll_dis_id", pollDisId);
        return wrapper;
    }

    /**
     * 排污许可信息-附件信息
     */
    public enum PwxkzFile {

        FILE_1("1","守法承诺书（需法人签字）"),

        FILE_2("2","符合建设项目环境影响评价程序的相关文件或证明材料"),

        FILE_3("3","排污许可证申领信息公开情况说明表"),

        FILE_4("4","通过排污权交易获取排污权指标的证明材料"),

        FILE_5("5","城镇污水集中处理设施应提供纳污范围、管网布置、排放去向等材料"),

        FILE_6("6","排污口和监测孔规范化设置情况说明材料"),

        FILE_7("7","达标证明材料（说明：包括环评、监测数据证明、工程数据证明等。）"),

        FILE_8("8","生产工艺流程图"),

        FILE_9("9","生产厂区总平面布置图"),

        FILE_10("10","监测点位示意图"),

        FILE_11("11","粪污处理利用工艺流程图"),

        FILE_12("12","地下水监测井布置图（标明井深参数）"),

        FILE_13("13","防渗层结构图"),

        FILE_14("14","封场结构图"),

        FILE_15("15","申请年排放量限值计算过程"),

        FILE_16("16","自行监测相关材料"),

        FILE_17("17","地方规定排污许可证申请表文件"),

        FILE_18("18","整改报告"),

        FILE_19("19","排污单位通过污染物排放量削减替代获得重点污染物排放总量控制指标的说明材料项"),

        FILE_20("20","其他"),

//        FILE_21("21","排污许可证正本"),
        FILE_21("21","排污许可证正本复印件"),

        FILE_22("22","排污许可证副本"),

        FILE_23("23","排污许可证编码对照表"),
        FILE_24("24","排污许可证申请表"),
        FILE_25("25","排污许可证申领信息公开情况说明"),
        FILE_26("26","与变更排污许可事项有关的其他材料"),
        FILE_27("27","锅炉燃料信息文件"),
        FILE_28("25","污水处理工艺流程图");

        public String code;
        public String desc;

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

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