package com.ruoyi.ibs.grid.domain.excel;

import com.ruoyi.common.annotation.Excel;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.Objects;

/**
 * @Author 吴凯程
 * @Date 2025/2/21
 **/
@Data
public class RegionGridCreateExcelDTO {

    @Excel(name = "网格层级", readConverterExp = "1=一级网格,2=二级网格", combo = "一级网格,二级网格")
    @NotNull(message = "网格层级不能为空！")
    private String gridLevel;

    @Excel(name = "网格名")
    @NotNull(message = "网格名不能为空！")
    private String gridName;

    @Excel(name = "网格名")
    @NotNull(message = "网格名不能为空！")
    private String topGridName;

    @Excel(name = "网格责任类型", readConverterExp = "1=责任网格,2=竞争网格", combo = "责任网格,竞争网格")
    @NotNull(message = "责任类型不能为空！")
    private String gridDutyType;

    @Excel(name = "关联行政区划（行政区县-行政街道-行政村）")
    @NotNull(message = "关联行政区划不能为空！")
    private String adminDivisionList;

    @Excel(name = "关联机构")
    @NotNull(message = "关联机构不能为空！")
    private String deptList;

    @Excel(name = "关联柜员号")
    @NotNull(message = "关联柜员不能为空！")
    private String userList;

    public Boolean isValid() {
        if (Objects.isNull(gridName) || Objects.isNull(gridDutyType) || Objects.isNull(adminDivisionList) || Objects.isNull(gridLevel)){
            return false;
        }
        if (gridName.isEmpty() || gridDutyType.isEmpty() || adminDivisionList.isEmpty() || gridLevel.isEmpty()){
            return false;
        }
        if(gridLevel.equals("1")){
            if(Objects.isNull(deptList) || deptList.isEmpty()){
                return false;
            }
        }
        if(gridLevel.equals("2")){
            if (Objects.isNull(topGridName) || topGridName.isEmpty() || Objects.isNull(userList) || userList.isEmpty()){
                return false;
            }
        }
        return true;
    }


}
