123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- package cn.com.ty.lift.common.utils;
- import java.time.LocalDate;
- import java.time.LocalDateTime;
- import java.time.LocalTime;
- import java.util.Objects;
- /**
- * Copy to jodd.util
- * <p>
- * Pool of <code>String</code> constants to prevent repeating of
- * hard-coded <code>String</code> literals in the code.
- * Due to fact that these are <code>public static final</code>
- * they will be inlined by java compiler and
- * reference to this class will be dropped.
- * There is <b>no</b> performance gain of using this pool.
- * Read: https://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.5
- * <ul>
- * <li>Literal strings within the same class in the same package represent references to the same <code>String</code> object.</li>
- * <li>Literal strings within different classes in the same package represent references to the same <code>String</code> object.</li>
- * <li>Literal strings within different classes in different packages likewise represent references to the same <code>String</code> object.</li>
- * <li>Strings computed by constant expressions are computed at compile time and then treated as if they were literals.</li>
- * <li>Strings computed by concatenation at run time are newly created and therefore distinct.</li>
- * </ul>
- */
- public interface ValuePool {
- String AMPERSAND = "&";
- String AND = "and";
- String AT = "@";
- String ASTERISK = "*";
- String STAR = ASTERISK;
- String BACK_SLASH = "\\";
- String COLON = ":";
- String COMMA = ",";
- String DASH = "-";
- String DOLLAR = "$";
- String DOT = ".";
- String DOTDOT = "..";
- String DOT_CLASS = ".class";
- String DOT_JAVA = ".java";
- String EMPTY = "";
- String EQUALS = "=";
- String FALSE = "false";
- String SLASH = "/";
- String HASH = "#";
- String HAT = "^";
- String LEFT_BRACE = "{";
- String LEFT_BRACKET = "(";
- String LEFT_CHEV = "<";
- String NEWLINE = "\n";
- String N = "n";
- String NO = "no";
- String NULL = "null";
- String OFF = "off";
- String ON = "on";
- String PERCENT = "%";
- String PIPE = "|";
- String PLUS = "+";
- String QUESTION_MARK = "?";
- String EXCLAMATION_MARK = "!";
- String QUOTE = "\"";
- String RETURN = "\r";
- String TAB = "\t";
- String RIGHT_BRACE = "}";
- String RIGHT_BRACKET = ")";
- String RIGHT_CHEV = ">";
- String SEMICOLON = ";";
- String SINGLE_QUOTE = "'";
- String SPACE = " ";
- String LEFT_SQ_BRACKET = "[";
- String RIGHT_SQ_BRACKET = "]";
- String TRUE = "true";
- String UNDERSCORE = "_";
- String UTF_8 = "UTF-8";
- String ISO_8859_1 = "ISO-8859-1";
- String Y = "y";
- String YES = "yes";
- String ONE = "1";
- String ZERO = "0";
- String DOLLAR_LEFT_BRACE = "${";
- String HASH_LEFT_BRACE = "#{";
- String CRLF = "\r\n";
- //HTML
- String HTML_NBSP = " ";
- String HTML_AMP = "&";
- String HTML_QUOTE = """;
- String HTML_LT = "<";
- String HTML_GT = ">";
- // ----------------------------------------------------------------log
- String LOG_PREFIX = "###| ";
- String LOG_LINE = "============================================================";
- String LOG_GLOBAL_EXCEPTION_LINE = "====================== GlobalDefaultException ======================";
- String LOG_URL = LOG_PREFIX + "URL : ";
- String LOG_IP = LOG_PREFIX + "IP : ";
- String LOG_CLASS_METHOD = LOG_PREFIX + "CLASS_METHOD : ";
- String LOG_ARGS = LOG_PREFIX + "ARGS : ";
- String LOG_RESPONSE = LOG_PREFIX + "RESPONSE : ";
- String LOG_STATUS = LOG_PREFIX + "STATUS : ";
- String LOG_EXCEPTION = LOG_PREFIX + "EXCEPTION : ";
- //是否打印全部的结果
- boolean LOG_PRINT_ALL = false;
- // 结果字符串 > LOG_PRINT_MAX ,格式化打印首尾(LOG_PRINT_MAX / 2)部分,中间省略
- int LOG_PRINT_MAX = 1000;
- // 方法处理耗时 > LOG_GOOD_TIME,日志到warn中
- long LOG_GOOD_TIME = 10 * 1000;
- // ---------------------------------------------------------------- array
- String[] EMPTY_ARRAY = new String[0];
- byte[] BYTES_NEW_LINE = NEWLINE.getBytes();
- long PLATFORM_IDENTIFICATION = 10086;
- // ---------------推送相关-------------------------------------------------
- //android平台的推送
- String PUSH_QUEUE_ANDROID_TOKEN = "liftmanager_queue_android_token";
- //ios平台的推送
- String PUSH_QUEUE_IOS_TOKEN = "liftmanager_queue_ios_token";
- //android全平台的推送
- String PUSH_QUEUE_ANDROID_ALL = "liftmanager_queue_android_all";
- //ios全平台的推送
- String PUSH_QUEUE_IOS_ALL = "liftmanager_queue_ios_all";
- //一次最多推送的账号个数
- int PUSH_MAX_SIZE = 1000;
- //消息推送失败后重新尝试的最多次数
- int PUSH_TRY_MAX_TIMES = 100;
- int PUSH_DEVICE_MODEL_ANDROID = 1;
- int PUSH_DEVICE_MODEL_IOS = 2;
- String PATTERN_NAME = "^[\u4e00-\u9fa5a-zA-Z0-9·.。;&\\s]{1,20}$";
- String PATTERN_TELEPHONE = "^1[345789]\\d{9}|0[1-9](\\d{1,2}\\-?)[1-9]\\d{6,7}$";
- static String beginTimeIllegalToEndTime(LocalDate begin, LocalDate end) {
- return String.format("开始时间(%tF)不能晚于结束时间(%tF)", begin, end);
- }
- //======================年检相关状态值和判断方法======================================
- /**
- * 年检待完成
- */
- int INSPECTION_STATUS_TO_DO = 0;
- int INSPECTION_STATUS_COMPLETE = 1;
- int INSPECTION_STATUS_OVERDUE = 2;
- /**
- * 年检 第一阶段
- */
- int INSPECTION_STEP_ONE = 1;
- /**
- * 年检 第二阶段
- */
- int INSPECTION_STEP_TWO = 2;
- /**
- * 年检 第三阶段
- */
- int INSPECTION_STEP_THREE = 3;
- /**
- * 年检 第四阶段
- */
- int INSPECTION_STEP_FOUR = 4;
- /**
- * 1 维保工确认年检计划
- */
- int INSPECTION_STAGE_CONFIRM = 1;
- /**
- * 2 维保工上传自检报告,选择自检时间 或者 文员设置 是否检查限速器和荷载年检设置,
- * 文员也可以上传自检报告或者确认自检报告和自检时间,自检时间以最后设置的为准
- */
- int INSPECTION_STAGE_SELFCHECK = 2;
- /**
- * 3 企业文员确认现场检验时间
- * 录入人员信息,政府质检,企业质检,联系电话
- */
- int INSPECTION_STAGE_CONFIRM_CHECK = 3;
- /**
- * 4 维保工上传检验结果
- */
- int INSPECTION_STAGE_UPLOAD_CHECK = 4;
- /**
- * 5 企业文员确认检验结果-合格 --> 不能算年检超期
- */
- int INSPECTION_STAGE_CHECK_QUALIFIED = 5;
- /**
- * 6 企业文员确认检验结果-整改 --> 回到第二阶段
- */
- int INSPECTION_STAGE_CHECK_RECTIFICATION = 6;
- /**
- * 7 企业文员确认检验结果-不合格 --> 可以算年检超期
- */
- int INSPECTION_STAGE_CHECK_UNQUALIFIED = 7;
- /**
- * 8 维保工上传年检报告和合格证
- */
- int INSPECTION_STAGE_UPLOAD_CERT_REPORT = 8;
- /**
- * 9 企业文员确认年检报告和合格证-合格
- */
- int INSPECTION_STAGE_CERT_REPORT_QUALIFIED = 9;
- /**
- * 10 企业文员确认年检报告和合格证-不合格 -->停用电梯
- */
- int INSPECTION_STAGE_CERT_REPORT_UNQUALIFIED = 10;
- String INSPECTION_NOT_EXIST = "年检不存在,请确认年检计划";
- String INSPECTION_EXIST_SAME = "年检计划已存在。";
- static String inspectionStepToNext(String previous, String current) {
- return String.format("请先完成%s再进行%s操作", previous, current);
- }
- static String inspectionCurrentStepStatusIllegal(int currentStepStatus, String step) {
- return String.format("年检当前状态(%s),不能进行%s操作", currentStepStatus, step);
- }
- static String inspectionNewStepStatusIllegal(int newStepStatus, String step) {
- return String.format("年检新状态(%s),不能进行%s操作", newStepStatus, step);
- }
- static String inspectionLastPlanDate(LocalDate previous, LocalDate deadline) {
- return String.format("上次年检时间%tF,下次年检设置%tF之前有效", previous, deadline);
- }
- static String inspectionMustOnStage(String stage) {
- return String.format("年检必须在%s才能操作", stage);
- }
- //===================急修相关状态值和判断方法======================================
- /**
- * 急修状态(-1 暂停中)
- */
- int EMERGENCY_STATE_STOPPING = -1;
- /**
- * 急修状态(0 待修理)
- */
- int EMERGENCY_STATE_TO_DO = 0;
- /**
- * 急修状态(1 修理中)
- */
- int EMERGENCY_STATE_DOING = 1;
- /**
- * 急修状态(2 完成)
- */
- int EMERGENCY_STATE_COMPLETE = 2;
- /**
- * 急修状态(3 关闭)
- */
- int EMERGENCY_STATE_CLOSE = 3;
- String EMERGENCY_NOT_EXIST = "急修记录不存在,请核查";
- String EMERGENCY_COST_NOT_EXIST = "急修收费项不存在,请核查";
- String EMERGENCY_FAULT_MISSING = "缺少电梯故障项";
- String EMERGENCY_HAVE_REPAIRING = "该电梯存在未完成的急修,无法创建";
- String EMERGENCY_HAD_TAKEN = "急修已经接单,不能转派";
- String EMERGENCY_MUST_TO_DO = "急修状态为待处理才能操作";
- String EMERGENCY_MUST_IN_DOING = "急修状态为处理中才能操作";
- String EMERGENCY_MUST_COMPLETE = "急修完成后才能操作";
- String EMERGENCY_HAD_EVALUATE = "急修已经评价了";
- String EMERGENCY_COST_INCORRECT_AMOUNT = "急修收费项金额有误";
- String EMERGENCY_LIFT_IS_IN_INSPECTION = "电梯正在年检中,无法创建急修";
- static String emergencyProcessTimeIllegal(String options, LocalDateTime optionsTime) {
- return String.format("急修处理时间不能早于上次操作时间(%s: %tF %tT)", options, optionsTime, optionsTime);
- }
- //===================上传相关状态值和判断方法======================================
- /**
- * 图片上传最大大小10M * 1024 * 1024
- */
- long UPLOAD_MAX_SIZE_PIC = 10 << 20;
- String UPLOAD_MAX_SIZE_PIC_DESC = "图片文件大小不超过10M";
- /**
- * 文件上传最大大小50M * 1024 * 1024
- */
- long UPLOAD_MAX_SIZE_FILE = 50 << 20;
- String UPLOAD_MAX_SIZE_FILE_DESC = "常用文件大小不超过50M";
- /**
- * 视频上传最大大小100M * 1024 * 1024
- */
- long UPLOAD_MAX_SIZE_VIDEO = 100 << 20;
- String UPLOAD_MAX_SIZE_VIDEO_DESC = "视频文件大小不超过100M";
- /**
- * 上传图片文件类型
- */
- String[] UPLOAD_TYPE_PICS = {".jpg", ".jpeg", ".png", ".bmp", ".gif"};
- /**
- * 上传其他文件类型
- */
- String[] UPLOAD_TYPE_FILES = {".pdf", ".txt", ".rar", ".zip", ".7z", ".xls", ".xlsx", ".doc", ".docx", ".ppt", ".pptx"};
- /**
- * 上传视频文件类型
- */
- String[] UPLOAD_TYPE_VIDEOS = {".mov", ".mp4", ".avi", ".mpg", ".mpeg", ".rm", ".rmvb", ".wmv"};
- String UPLOAD_DATA_MISSING = "没有接收到文件数据";
- String UPLOAD_FAIL = "上传文件失败";
- String UPLOAD_FORMAT_NOT_SUPPORT = "文件格式暂时不支持";
- String UPLOAD_FORMAT_MISSING = "原文件名解析不到文件格式";
- String UPLOAD_FORMAT_ILLEGAL = "原文件名不合法";
- String UPLOAD_ORIGINAL_NAME_MISSING = "未解析到原文件名";
- //===================操作证相关======================================
- String LIFT_CERT_MUST_TO_AUDIT = "操作证待审核才能操作";
- String LIFT_CERT_HAD_EXIST = "操作证已存在,请核查";
- String LIFT_CERT_NOT_EXIST = "操作证不存在,请核查";
- //===================打卡相关======================================
- String ATTEND_SET_AM_TIME = "请设置上午的上/下班时间";
- String ATTEND_SET_PM_TIME = "请设置下午的上/下班时间";
- String ATTEND_SET_OT_TIME = "请设置加班的上/下班时间";
- static String attendInvalidAmTime(LocalTime topTime, LocalTime downTime) {
- return String.format("上午的上(%tT)/下班(%tT)时间有误", topTime, downTime);
- }
- static String attendInvalidPmTime(LocalTime topTimePm, LocalTime downTimePm) {
- return String.format("下午的上(%tT)/下班(%tT)时间有误", topTimePm, downTimePm);
- }
- static String attendInvalidOtTime(LocalTime topTimeOt, LocalTime downTimeOt) {
- return String.format("加班的上(%tT)/下班(%tT)时间有误", topTimeOt, downTimeOt);
- }
- String ATTEND_AM_TOP_CLOCK = "上午上班打卡";
- String ATTEND_AM_DOWN_CLOCK = "上午下班打卡";
- String ATTEND_PM_TOP_CLOCK = "下午上班打卡";
- String ATTEND_PM_DOWN_CLOCK = "下午下班打卡";
- String ATTEND_OT_TOP_CLOCK = "加班上班打卡";
- String ATTEND_OT_DOWN_CLOCK = "加班下班打卡";
- String ATTEND_HAD_CLOCK = "打卡记录已存在。";
- String ATTEND_MISSING_TIME = "请至少设置一组打卡时间";
- static String attendAmDownPmTop(LocalTime downTime, LocalTime topTimePm) {
- return String.format("下午的上班(%tT)时间不得早于上午的下班(%tT)时间", topTimePm, downTime);
- }
- static String attendPmDownOtTop(LocalTime downTimePm, LocalTime topTimeOt) {
- return String.format("加班的上班(%tT)时间不得早于下午的下班(%tT)时间", topTimeOt, downTimePm);
- }
- String ATTEND_MAINTAIN_COMPANY_MISSING = "维保公司不存在,请核查";
- String ATTEND_MISSING = "打卡记录不存在,请核查";
- String ATTEND_UNKNOWN_TYPE = "打卡类型未知,请核查";
- //===================导入相关======================================
- String EXCEL_IMPORT_DATA_MISSING = "未解析到有效数据";
- String EXCEL_IMPORT_FORMAT_SUPPORT = "文件格式不支持,暂时只支持xls,xlsx";
- String[] EXCEL_IMPORT_FORMATS = {".xls", ".xlsx"};
- /**
- * 一次导入表格的最大有效记录数
- */
- int EXCEL_IMPORT_MAX_ROWS_ONETIME = 5000;
- String EXCEL_IMPORT_MAX_ROWS_DESC = "一次性导入不能超过5000条数据";
- //三元运算,判断object是否为空,为空返回默认值
- static <T> T nullable(T object, T valueForNull) {
- return Objects.isNull(object) ? valueForNull : object;
- }
- //===================维保相关======================================
- String MAINTENANCE_RECORD_NOT_EXIST = "维保记录不存在,请核查";
- String MAINTENANCE_PLAN_NOT_EXIST = "维保计划不存在,请核查";
- String MAINTENANCE_OPTION_NOT_EXIST = "维保操作项不存在,请核查";
- String MAINTENANCE_RECORD_MUST_AUDITING = "维保单必须待审核才能操作,请核查";
- String MAINTENANCE_RECORD_MUST_COMPLETE = "维保单必须完成后才能操作,请核查";
- String MAINTENANCE_HAD_EVALUATE = "维保已经评价了";
- //法规维保间隔15天
- int MAINTENANCE_INTERVAL = 15;
- int EVALUATE_SOURCE_MAINTENANCE = 1;
- int EVALUATE_SOURCE_EMERGENCY = 2;
- String SYSTEM_USER_DIR = System.getProperty("user.dir");
- }
|