package cn.cecep.talroad.vo.query;

import cn.cecep.talroad.common.core.utils.StringUtils;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.cecep.talroad.domain.BMainThreeSupervisionEnforc;
import cn.cecep.talroad.common.core.domain.query.PageQuery;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;


/**
 * 三监联动执法信息对象 b_main_three_supervision_enforc
 *
 * @author szhpt
 * @date 2023-03-29*/
@ApiModel(value = "三监联动执法信息")
@EqualsAndHashCode(callSuper = false)
@Data
public class BMainThreeSupervisionEnforcQuery extends PageQuery
{

    @ApiModelProperty(value = "id")
    private String taskId;
    @ApiModelProperty(value = "任务名称")
    private String taskName;
    @ApiModelProperty(value = "排污单位")
    private String factoryId;
    @ApiModelProperty(value = "排污单位名称")
    private String factoryName;
    @ApiModelProperty(value = "区域名称")
    private String districtName;
    @ApiModelProperty(value = "区域编码")
    private String districtCode;
    @ApiModelProperty(value = "所属行业名称")
    private String industryCategoryName;
    @ApiModelProperty(value = "所属行业编码")
    private String industryCategoryCode;
    @ApiModelProperty(value = "管理类别;(重点=focus、简化=simplify、登记=register)")
    private String manType;
    @ApiModelProperty(value = "行业类别")
    private String industryCategory;
    @ApiModelProperty(value = "办结时间")
    private Date closingTime;
    @ApiModelProperty(value = "归档时间")
    private Date archiveTime;
    @ApiModelProperty(value = "任务状态;字典bus_task_status(任务状态（0=办理中 5=已办结 9=已归档)")
    private String taskStatus;
    @ApiModelProperty(value = "发起部门id")
    private String initiatingDeptId;
    @ApiModelProperty(value = "发起部门名称")
    private String initiatingDeptName;
    @ApiModelProperty(value = "紧急程度;字典bus_emergency_level(1=一般,2=紧急,3=特急)")
    private String emergencyLevel;
    @ApiModelProperty(value = "发起时间")
    private Date initiatingTime;
    @ApiModelProperty(value = "预计完成时间")
    private Date estimatedCompletionTime;
    @ApiModelProperty(value = "单位地址")
    private String factoryAddress;
    @ApiModelProperty(value = "具体问题")
    private String specificIssues;
    @ApiModelProperty(value = "任务描述")
    private String taskDetails;
    @ApiModelProperty(value = "问题附件")
    private String questionAttachment;
    @ApiModelProperty(value = "接受部门ids")
    private String receivingDeptIds;
    @ApiModelProperty(value = "接受部门名称")
    private String receivingDeptNames;

    @ApiModelProperty(value = "创建开始时间")
    private String startTime;
    @ApiModelProperty(value = "创建时间")
    private String endTime;


    /**
     *
     * @Title: getQueryWrapper
     * @Description: 查询参数组装
     * @param: @return
     * @return: QueryWrapper<BasIndustry>
     * @throws
     */
    public static QueryWrapper<BMainThreeSupervisionEnforc> createLambdaQueryWrapper(BMainThreeSupervisionEnforcQuery query) {
        QueryWrapper<BMainThreeSupervisionEnforc> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotEmpty(query.getTaskId()), "task_id", query.getTaskId());
        wrapper.like(StringUtils.isNotEmpty(query.getTaskName()), "task_name", query.getTaskName());
        wrapper.eq(StringUtils.isNotEmpty(query.getFactoryId()), "factory_id", query.getFactoryId());
        wrapper.like(StringUtils.isNotEmpty(query.getFactoryName()), "factory_name", query.getFactoryName());
        wrapper.eq(StringUtils.isNotEmpty(query.getDistrictName()), "district_name", query.getDistrictName());
        wrapper.eq(StringUtils.isNotEmpty(query.getDistrictCode()), "district_code", query.getDistrictCode());
        wrapper.eq(StringUtils.isNotEmpty(query.getIndustryCategoryName()), "industry_category_name", query.getIndustryCategoryName());
        wrapper.eq(StringUtils.isNotEmpty(query.getIndustryCategoryCode()), "industry_category_code", query.getIndustryCategoryCode());
        wrapper.eq(StringUtils.isNotEmpty(query.getManType()), "man_type", query.getManType());
        wrapper.eq(StringUtils.isNotEmpty(query.getIndustryCategory()), "industry_category", query.getIndustryCategory());
        wrapper.eq(ObjectUtil.isNotNull(query.getClosingTime()), "closing_time", query.getClosingTime());
        wrapper.eq(ObjectUtil.isNotNull(query.getArchiveTime()), "archive_time", query.getArchiveTime());
        wrapper.eq(StringUtils.isNotEmpty(query.getTaskStatus()), "task_status", query.getTaskStatus());
        wrapper.eq(StringUtils.isNotEmpty(query.getInitiatingDeptId()), "initiating_dept_id", query.getInitiatingDeptId());
        wrapper.eq(StringUtils.isNotEmpty(query.getInitiatingDeptName()), "initiating_dept_name", query.getInitiatingDeptName());
        wrapper.eq(StringUtils.isNotEmpty(query.getEmergencyLevel()), "emergency_level", query.getEmergencyLevel());
        wrapper.eq(ObjectUtil.isNotNull(query.getInitiatingTime()), "initiating_time", query.getInitiatingTime());
        wrapper.eq(ObjectUtil.isNotNull(query.getEstimatedCompletionTime()), "estimated_completion_time", query.getEstimatedCompletionTime());
        wrapper.eq(StringUtils.isNotEmpty(query.getFactoryAddress()), "factory_address", query.getFactoryAddress());
        wrapper.eq(StringUtils.isNotEmpty(query.getSpecificIssues()), "specific_issues", query.getSpecificIssues());
        wrapper.eq(StringUtils.isNotEmpty(query.getTaskDetails()), "task_details", query.getTaskDetails());
        wrapper.eq(StringUtils.isNotEmpty(query.getQuestionAttachment()), "question_attachment", query.getQuestionAttachment());
        wrapper.eq(StringUtils.isNotEmpty(query.getReceivingDeptIds()), "receiving_dept_id", query.getReceivingDeptIds());
        wrapper.eq(StringUtils.isNotEmpty(query.getReceivingDeptNames()), "receiving_dept_name", query.getReceivingDeptNames());

        wrapper.between(ObjectUtil.isNotNull(query.getStartTime()) && ObjectUtil.isNotNull(query.getEndTime()), "to_char(create_time, 'YYYY-MM-DD')", query.getStartTime(), query.getEndTime());

        wrapper.orderByDesc("create_time");

        return wrapper;
        }
}
