package com.ltgk.common.constant;

import cn.hutool.core.util.IdUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateFormatUtils;

import java.util.Date;
import java.util.Locale;

public class Constants {


    //渔船籍贯状态： 0 - 本地渔船 1 - 外地渔船
    public final static Integer LOCAL = 0;
    public final static Integer NON_LOCAL = 1;


    //渔船证书状态：有效（正常）、暂停、撤销、注销、证书过期
    public final static String CERTIFICATE_NORMAL = "1";//正常
    public final static String CERTIFICATE_LOGOUT = "-1";//注销
    public final static String CERTIFICATE_NOTBEGIN = "0";//未开始


    /**
     * 渔船状态
     */
    public final static String SHIP_STATUS_ONLINE_TEXT = "在线";
    public final static String SHIP_STATUS_OFFLINE_TEXT = "离线";

    /**
     * 用户角色信息：
     * SUPER_ADMIN 管理员
     * GENERAL  一般用户
     * ROLE_TOWN 街镇管理员
     * OPERATOR 渔船经营人
     */
    public final static String GENERAL = "GENERAL";
    public final static String SUPER_ADMIN = "SUPER_ADMIN";
    public final static String CREW = "CREW";
    public final static String ROLE_TOWN = "ROLE_TOWN";
    public final static String ROLE_VILLAGE = "ROLE_VILLAGE";

    public final static String ROLE_ADMIN = "ROLE_ADMIN";
    public final static String OPERATOR = "OPERATOR";
    public final static String DOCK_STAFF = "DOCK_STAFF";

    /**
     * 渔港名称
     */
    public static final String PORT_NAME = "莲花山渔港";

    /**
     * 未报备出港分析名称
     */
    public final static String NO_REPORT_OUT_PORT_NAME = "未报备出港";

    /**
     * 未报备进港分析名称
     */
    public final static String NO_REPORT_ENTER_PORT_NAME = "未报备进港";

    /**报警通知状态**/
    /**
     * 待通知
     */
    public final static String WAIT_NOTICE = "-1";
    /**
     * 待处理
     */
    public final static String WAIT_DISPOSE = "0";

    /**
     * 处理中
     */
    public final static String DISPOSING = "1";

    /**
     * 处理完成
     */
    public final static String COMPLETE_DISPOSE = "2";

    /**
     * 标注结束
     */
    public final static String MARK_END = "3";

    /**
     * UTF-8 字符集
     */
    public static final String UTF8 = "UTF-8";

    /**
     * GBK 字符集
     */
    public static final String GBK = "GBK";

    /**
     * 字典管理 cache key
     */
    public static final String SYS_DICT_KEY = "sys_dict:";

    /**
     * 部门组织管理 cache key
     */
    public static final String SYS_ORG_KEY = "sys_org";

    // 文件类
    public static final String FILE_BASE = "/file";
    // TODO 临时文件的路径，缓存文件
    public static String TEMP_PATH = "/temp/";
    //TODO 文件存储目录
    public static String FILE_PATTERN = "YYYY-MM/";

    /**
     * 资源映射路径 前缀
     */
    public static final String RESOURCE_PREFIX = "/profile";

    /**
     * 获取存储用文件的绝对路径,带后缀则为文件，不带后缀则为路径
     *
     * @param fileType 文件类型, 获取路径，则传入：”“
     * @return
     */
    public static String tempPath(String fileType) {
        // TODO 文件名称、路径的处理
        fileType = StringUtils.isBlank(fileType) ? "" : ("." + fileType);

        String tempName = IdUtil.simpleUUID() + fileType;
        String tempPath = FILE_BASE + TEMP_PATH + tempName;    // 相对路径

        return tempPath;
    }

    /**
     * 获取存储用文件的相对路径,带后缀则为文件，不带后缀则为路径
     *
     * @param fileType 文件类型, 获取路径，则传入：”“
     * @return
     */
    public static String savePath(String fileType) {
        // TODO 文件名称、路径的处理
        String dirName = DateFormatUtils.format(new Date(), FILE_PATTERN);
        fileType = StringUtils.isBlank(fileType) ? "" : ("." + fileType);

        String saveFileName = IdUtil.simpleUUID() + fileType;
        String relativePath = dirName + saveFileName;    // 相对路径

        return relativePath;
    }

    // 默认boole类型
    public final static int FLAG_TRUE = 1;
    public final static int FLAG_FALSE = 0;
    public final static String FLAG_TRUE_STR = "1";  //是
    public final static String FLAG_FALSE_STR = "0"; //否

    // 登陆终端的标识
    public static final String prefix = "manage-";
    public static final String appClient = "app";
    public static final String webClient = "controller";

    /**
     * 上传图片格式
     */
    public static final String IMG_TYPE_PNG = "png";
    public static final String IMG_TYPE_JPG = "jpg";
    public static final String IMG_TYPE_JPEG = "jpeg";
    public static final String IMG_TYPE_DMG = "bmp";
    public static final String IMG_TYPE_GIF = "gif";
    public static final String IMG_TYPE_SVG = "svg";

    /**
     * 报警开关变量
     */
    public static final String ON_ALARM = "1";
    public static final String OFF_ALARM = "0";
    public static final String ALARM_TITLE = "船舶报警通知";
    public static final String CROSS_BORDER_ALARM = "越界捕捞";
    public static final String BEIDOU_TURNOFF_ALARM = "北斗2H不开机";
    public static final String BEIDOU_TURNOFF_VALUE = "北斗离线阀值";
    public static final String BEIDOU_MULTI_ALARM = "一船多斗";
    public static final String BEIDOU_MULTI_VALUE = "一船多斗距离阈值";
    public static final String OBSTACLE_TURNOFF_ALARM = "碍航物标定";
    public static final String NOT_REPORTED_ALARM = "未报备出海";
    public static final String NOT_LOCAL_ALARM = "非本地渔船进港";
    public static final String NOT_LOCAL_ALARM_OUT = "非本地渔船出港";
    public static final String NOT_PORT_ALARM = "非本港渔船进港";

    public static final String POINT_MAIN = "重点关注";
    public static final String POINT_COLLECT = "收藏渔船";

    /**
     * 渔船进出港审核检查
     */
    public static final String ENTER_OUT_STATUS_0 = "0"; // 未审核
    public static final String ENTER_OUT_STATUS_1 = "1"; // 已通过
    public static final String ENTER_OUT_STATUS_2 = "2"; // 未通过

    /**
     * 预约状态
     */
    public static final Integer APPOINTMENT_STATUS_0 = 0; // 已预约
    public static final Integer APPOINTMENT_STATUS_1 = 1; // 已使用
    public static final Integer APPOINTMENT_STATUS_2 = 2; // 已过期
    public static final Integer APPOINTMENT_STATUS_3 = 3; // 已取消
    public static final Integer APPOINTMENT_STATUS_4 = 4; // 准备驶离
    public static final Integer APPOINTMENT_STATUS_5 = 5; // 已驶离
    public static final Integer APPOINTMENT_STATUS_6 = 6; // 预约失败

    /**
     * 随手拍处置状态
     */
    public static final String MASS_REPORT_0 = "0"; // 未处置
    public static final String MASS_REPORT_1 = "1"; // 已处置

    /**
     * 视频预警 - 处置进程（1-待通知 2-处理中 0-已关闭）
     */
    public static final String WARNING_PROCESS_0 = "0"; // 已关闭
    public static final String WARNING_PROCESS_1 = "1"; // 待通知
    public static final String WARNING_PROCESS_2 = "2"; // 处理中

    public static final String WARNING_TYPE_PROPERTY = "PROPERTY"; // 视频预警-物业预警

    /**
     * 摄像头类型
     */
    public static final String PANORAMA = "全景监控";
    public static final String BERTH = "泊位监控";
    public static final String FIREWORKS = "烟火监控";
    public static final String TRAFFIC = "车流监控";
    public static final String ENTRY_OUT = "进出口监控";
    public static final String PORT_CHANNEL = "港口河道监控";
    public static final String RIVER_CHANNEL = "沥江河道监控";
    public static final String ENVIRONMENT_SAFETY = "环境与安全监控";

    /**
     * 智能分析类型
     */
    public static final String VIDEO = "视频分析";
    public static final String RADER = "雷达分析";

    /**
     * 摄像头联网类型
     */
    public static final String INNET_TYPE = "政务网";

    /**
     * 全部数据权限
     */
    public static final String DATA_SCOPE_ALL = "1";

    /**
     * 自定数据权限
     */
    public static final String DATA_SCOPE_CUSTOM = "2";

    /**
     * 部门数据权限
     */
    public static final String DATA_SCOPE_DEPT = "3";

    /**
     * 部门及以下数据权限
     */
    public static final String DATA_SCOPE_DEPT_AND_CHILD = "4";

    /**
     * 仅本人数据权限
     */
    public static final String DATA_SCOPE_SELF = "5";

    /**
     * 数据权限过滤关键字
     */
    public static final String DATA_SCOPE = "dataScope";

    /**
     * 休闲渔船预约记录已预约状态码
     */
    public static final String RESERVED_CODE = "0";

    /**
     * 休闲渔船预约记录已使用状态码
     */
    public static final String USED_CODE = "1";

    /**
     * 休闲渔船预约记录已取消状态码
     */
    public static final String CANCELED_CODE = "2";

    /**
     * 休闲渔船预约记录已预约状态码
     */
    public static final String EXPIRED_CODE = "3";


    /**
     * 航线不可预约状态
     */
    public static final String UN_RESERVABLE_CODE = "0";

    /**
     * 航线可预约状态
     */
    public static final String RESERVABLE_CODE = "1";


    /**
     * 未发布状态
     */
    public static final Integer PUBLISH_0 = 0;


    /**
     * 已经发布状态
     */
    public static final Integer PUBLISH_1 = 1;


    /**
     * 已撤销状态
     */
    public static final Integer PUBLISH_2 = 2;

    /**
     * 已成功状态
     */
    public static final Integer PUBLISH_3 = 3;


    /**
     * 应急系统事故处理流程执行状态 未执行
     */
    public static final String EXECUTE_STATUS_0 = "0";

    /**
     * 应急系统事故处理流程执行状态 执行中
     */
    public static final String EXECUTE_STATUS_1 = "1";

    /**
     * 应急系统事故处理流程执行状态 执行完毕
     */
    public static final String EXECUTE_STATUS_2 = "2";

    /**
     * 环境巡查不正常
     */
    public static final String PROBLEM_CODE = "0";

    /**
     * 环境巡查正常
     */
    public static final String NO_PROBLEM_CODE = "1";

    public static final String AREA_WARN_CODE = "131588";

    public static final String AREA_WARN_NAME = "区域入侵";

    public static final String IDENTIFY_CODE = "192516";

    public static final String IDENTIFY_NAME = "渔船识别";

    public static final String CODE = "code";

    public static final String SUCCESS_CODE = "0";


    /**
     * 系统语言
     */
    public static final Locale DEFAULT_LOCALE = Locale.SIMPLIFIED_CHINESE;

    /**
     * www主域
     */
    public static final String WWW = "www.";

    /**
     * http请求
     */
    public static final String HTTP = "http://";

    /**
     * https请求
     */
    public static final String HTTPS = "https://";

    /**
     * 通用成功标识
     */
    public static final String SUCCESS = "0";

    /**
     * 通用失败标识
     */
    public static final String FAIL = "1";

    /**
     * 登录成功
     */
    public static final String LOGIN_SUCCESS = "Success";

    /**
     * 注销
     */
    public static final String LOGOUT = "Logout";

    /**
     * 注册
     */
    public static final String REGISTER = "Register";

    /**
     * 登录失败
     */
    public static final String LOGIN_FAIL = "Error";

    /**
     * 所有权限标识
     */
    public static final String ALL_PERMISSION = "*:*:*";

    /**
     * 角色权限分隔符
     */
    public static final String ROLE_DELIMETER = ",";

    /**
     * 权限标识分隔符
     */
    public static final String PERMISSION_DELIMETER = ",";

    /**
     * 验证码有效期（分钟）
     */
    public static final Integer CAPTCHA_EXPIRATION = 2;

    /**
     * 令牌
     */
    public static final String TOKEN = "token";

    /**
     * 令牌前缀
     */
    public static final String TOKEN_PREFIX = "Bearer ";

    /**
     * 令牌前缀
     */
    public static final String LOGIN_USER_KEY = "login_user_key";

    /**
     * 用户ID
     */
    public static final String JWT_USERID = "userid";

    /**
     * 用户名称
     */
    //public static final String JWT_USERNAME = Claims.SUBJECT;

    /**
     * 用户头像
     */
    public static final String JWT_AVATAR = "avatar";

    /**
     * 创建时间
     */
    public static final String JWT_CREATED = "created";

    /**
     * 用户权限
     */
    public static final String JWT_AUTHORITIES = "authorities";

    /**
     * RMI 远程方法调用
     */
    public static final String LOOKUP_RMI = "rmi:";

    /**
     * LDAP 远程方法调用
     */
    public static final String LOOKUP_LDAP = "ldap:";

    /**
     * LDAPS 远程方法调用
     */
    public static final String LOOKUP_LDAPS = "ldaps:";

    /**
     * 自动识别json对象白名单配置（仅允许解析的包名，范围越小越安全）
     */
    public static final String[] JSON_WHITELIST_STR = {"org.springframework", "com.ltgk"};

    /**
     * 定时任务白名单配置（仅允许访问的包名，如其他需要可以自行添加）
     */
    public static final String[] JOB_WHITELIST_STR = {"com.c.quartz.task"};

    /**
     * 定时任务违规的字符
     */
    public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
            "org.springframework", "org.apache", "com.ltgk.common.utils.file", "com.ltgk.common.config", "com.ltgk.generator"};
}
