package com.njcn.relational.pojo.dto;

import cn.hutool.core.util.StrUtil;
import lombok.Data;

/**
 * DCloud数据同步查询参数封装实体
 */
@Data
public class DcloudSyncQuery {
    /** 表名 */
    private String tableName;
    /** 当前页码 */
    private Integer pageIndex;
    /** 每页条数 */
    private Integer pageSize;
    /** 过滤条件 */
    private String filter;
    /** 排序语句 */
    private String orderStr;
    /** 查询字段列表，逗号分隔 */
    private String propertyList;

    /**
     * 参数空值兜底处理，防止空指针
     */
    public void emptyCover() {
        if (StrUtil.isBlank(filter)) {
            filter = StrUtil.EMPTY;
        }
        if (StrUtil.isBlank(orderStr)) {
            orderStr = StrUtil.EMPTY;
        }
        if (StrUtil.isBlank(propertyList)) {
            propertyList = StrUtil.EMPTY;
        }
    }

    /**
     * 快速构建厂站默认查询参数
     */
    public static DcloudSyncQuery buildPlantDefault(String filter, String orderStr, Integer pageIndex, Integer pageSize) {
        DcloudSyncQuery query = new DcloudSyncQuery();
        query.setTableName("SG_CON_PLANT_C");
        query.setFilter(filter);
        query.setOrderStr(orderStr);
        query.setPageIndex(pageIndex);
        query.setPageSize(pageSize);
        query.setPropertyList("D5000_ID,D5000_NAME,DCLOUD_ID,DCLOUD_NAME,DCLOUD_VOLTAGELEVEL,OWNER,STATUS,UPDATE_TIME");
        return query;
    }

    public static DcloudSyncQuery buildPlantChangZhan(String filter, String orderStr, Integer pageIndex, Integer pageSize) {
        DcloudSyncQuery query = new DcloudSyncQuery();
        query.setTableName("SG_CON_PLANT_B");
        query.setFilter(filter);
        query.setOrderStr(orderStr);
        query.setPageIndex(pageIndex);
        query.setPageSize(pageSize);
        query.setPropertyList("ID,ADDRESS,ALTITUDE,ASSETS_OWNERSHIP,ASSETS_OWNERSHIP_COM_ID,CHECK_CODE,COMM_TAG,COMPANY_ID,CONNECTIVE_PG_ID,DCC_ID,EXPIRY_DATE,FAX_NO,GENCOMPANY_ID,LANDFORM,LATITUDE,LONGITUDE,MAX_VOLTAGE_TYPE,NAME,NAME_ABBREVIATION,OPERATE_DATE,OPERATE_STATE,OWNER,PHONE_NO,PLANT_DETAIL_TYPE,PLANT_TYPE,POSTCODE,REGION,REGISTER_NAME,REMARKS,SCS_TAG,STAMP,STATE_CODE,SYS_FLAG,TAG");
        return query;
    }

    public static DcloudSyncQuery buildPlantBdB(String filter, String orderStr, Integer pageIndex, Integer pageSize) {
        DcloudSyncQuery query = new DcloudSyncQuery();
        query.setTableName("SG_CON_SUBSTATION_B");
        query.setFilter(filter);
        query.setOrderStr(orderStr);
        query.setPageIndex(pageIndex);
        query.setPageSize(pageSize);
        query.setPropertyList("ALTITUDE,ASSETS_OWNERSHIP,ASSETS_OWNERSHIP_COM_ID,CHECK_CODE,COMM_TAG,DCC_ID,DC_VOLTAGE_TYPE,EXPIRY_DATE,ID,LATITUDE,LONGITUDE,MANAGE_DEPT_ID,NAME,OPERATE_DATE,OPERATE_STATE,OWNER,PG_ID,REGION,SCS_TAG,STATE_CODE,SYS_FLAG,TOP_AC_VOLTAGE_TYPE,TYPE,VIDEOSCENEID");
        return query;
    }

    public static DcloudSyncQuery buildPlantBdC(String filter, String orderStr, Integer pageIndex, Integer pageSize) {
        DcloudSyncQuery query = new DcloudSyncQuery();
        query.setTableName("SG_CON_SUBSTATION_C");
        query.setFilter(filter);
        query.setOrderStr(orderStr);
        query.setPageIndex(pageIndex);
        query.setPageSize(pageSize);
        query.setPropertyList("D5000_ID,D5000_NAME,DCC_ID,DCLOUD_ID,DCLOUD_NAME,DCLOUD_VOLTAGELEVEL,OMS_ID,OMS_NAME,OWNER,PMS_ID,PSDB_DEV_TYPE,PSDB_ID,PSDB_NAME,SETTING_ID,SETTING_NAME,STATUS");
        return query;
    }

    public static DcloudSyncQuery buildSgConPlantBNewenergy(String filter, String orderStr, Integer pageIndex, Integer pageSize) {
        DcloudSyncQuery query = new DcloudSyncQuery();
        query.setTableName("SG_CON_PLANT_B_NEWENERGY");
        query.setFilter(filter);
        query.setOrderStr(orderStr);
        query.setPageIndex(pageIndex);
        query.setPageSize(pageSize);
        query.setPropertyList("ID,COMPENSATION_VAR_CAP,CONNECTIVE_STATION_ID,ENERGY_STORAGE_CAPACITY,ENERGY_STORAGE_DEVICE_COUNT,INVERTER_COUNT,OWNER,STAMP,TYPE_NUM,WINDTURBINE_NUM,GROUND_TYPE,FILT_NUM,HOUR_NUM,WINDTOWER_NUM,PHOTOMETER_NUM,WINDRANGE,INSTALL_LOCATION");
        return query;
    }

    public static DcloudSyncQuery buildSgSgDevAclineB(String filter, String orderStr, Integer pageIndex, Integer pageSize) {
        DcloudSyncQuery query = new DcloudSyncQuery();
        query.setTableName("SG_DEV_ACLINE_B");
        query.setFilter(filter);
        query.setOrderStr(orderStr);
        query.setPageIndex(pageIndex);
        query.setPageSize(pageSize);
        query.setPropertyList("ID,NAME,VOLTAGE_TYPE,GRID_ID,SUPPLIER_ID,SYS_FLAG,TAG,ASSETS_COMPANY_ID,CHECK_CODE,COMPACT_ZONE,DEV_ID,DISPATCH_ORG_ID,START_BAY_ID,START_ST_ID,START_TOWER_ID,END_BAY_ID,END_ST_ID,END_TOWER_ID,ERECTINGMETHOD,EXPIRY_DATE,OFF_TIME,ON_TIME,OPERATE_DATE,OWNER,RUNNING_STATE,STAMP,ISOPTICFIBEREQUIPED,IS_COMPACT,LENGTH,LICENSE_ORG_ID,LINETYPE,MEMBER_FEATURE_TAG,STRIDE_FEATURE_TAG");
        return query;
    }
}