ValuePool.java 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. package cn.com.ty.lift.common.utils;
  2. import java.time.LocalDate;
  3. import java.time.LocalDateTime;
  4. import java.time.LocalTime;
  5. import java.util.Objects;
  6. /**
  7. * Copy to jodd.util
  8. * <p>
  9. * Pool of <code>String</code> constants to prevent repeating of
  10. * hard-coded <code>String</code> literals in the code.
  11. * Due to fact that these are <code>public static final</code>
  12. * they will be inlined by java compiler and
  13. * reference to this class will be dropped.
  14. * There is <b>no</b> performance gain of using this pool.
  15. * Read: https://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.5
  16. * <ul>
  17. * <li>Literal strings within the same class in the same package represent references to the same <code>String</code> object.</li>
  18. * <li>Literal strings within different classes in the same package represent references to the same <code>String</code> object.</li>
  19. * <li>Literal strings within different classes in different packages likewise represent references to the same <code>String</code> object.</li>
  20. * <li>Strings computed by constant expressions are computed at compile time and then treated as if they were literals.</li>
  21. * <li>Strings computed by concatenation at run time are newly created and therefore distinct.</li>
  22. * </ul>
  23. */
  24. public interface ValuePool {
  25. String AMPERSAND = "&";
  26. String AND = "and";
  27. String AT = "@";
  28. String ASTERISK = "*";
  29. String STAR = ASTERISK;
  30. String BACK_SLASH = "\\";
  31. String COLON = ":";
  32. String COMMA = ",";
  33. String DASH = "-";
  34. String DOLLAR = "$";
  35. String DOT = ".";
  36. String DOTDOT = "..";
  37. String DOT_CLASS = ".class";
  38. String DOT_JAVA = ".java";
  39. String EMPTY = "";
  40. String EQUALS = "=";
  41. String FALSE = "false";
  42. String SLASH = "/";
  43. String HASH = "#";
  44. String HAT = "^";
  45. String LEFT_BRACE = "{";
  46. String LEFT_BRACKET = "(";
  47. String LEFT_CHEV = "<";
  48. String NEWLINE = "\n";
  49. String N = "n";
  50. String NO = "no";
  51. String NULL = "null";
  52. String OFF = "off";
  53. String ON = "on";
  54. String PERCENT = "%";
  55. String PIPE = "|";
  56. String PLUS = "+";
  57. String QUESTION_MARK = "?";
  58. String EXCLAMATION_MARK = "!";
  59. String QUOTE = "\"";
  60. String RETURN = "\r";
  61. String TAB = "\t";
  62. String RIGHT_BRACE = "}";
  63. String RIGHT_BRACKET = ")";
  64. String RIGHT_CHEV = ">";
  65. String SEMICOLON = ";";
  66. String SINGLE_QUOTE = "'";
  67. String SPACE = " ";
  68. String LEFT_SQ_BRACKET = "[";
  69. String RIGHT_SQ_BRACKET = "]";
  70. String TRUE = "true";
  71. String UNDERSCORE = "_";
  72. String UTF_8 = "UTF-8";
  73. String ISO_8859_1 = "ISO-8859-1";
  74. String Y = "y";
  75. String YES = "yes";
  76. String ONE = "1";
  77. String ZERO = "0";
  78. String DOLLAR_LEFT_BRACE = "${";
  79. String HASH_LEFT_BRACE = "#{";
  80. String CRLF = "\r\n";
  81. //HTML
  82. String HTML_NBSP = "&nbsp;";
  83. String HTML_AMP = "&amp";
  84. String HTML_QUOTE = "&quot;";
  85. String HTML_LT = "&lt;";
  86. String HTML_GT = "&gt;";
  87. // ----------------------------------------------------------------log
  88. String LOG_PREFIX = "###| ";
  89. String LOG_LINE = "============================================================";
  90. String LOG_GLOBAL_EXCEPTION_LINE = "====================== GlobalDefaultException ======================";
  91. String LOG_URL = LOG_PREFIX + "URL : ";
  92. String LOG_IP = LOG_PREFIX + "IP : ";
  93. String LOG_CLASS_METHOD = LOG_PREFIX + "CLASS_METHOD : ";
  94. String LOG_ARGS = LOG_PREFIX + "ARGS : ";
  95. String LOG_RESPONSE = LOG_PREFIX + "RESPONSE : ";
  96. String LOG_STATUS = LOG_PREFIX + "STATUS : ";
  97. String LOG_EXCEPTION = LOG_PREFIX + "EXCEPTION : ";
  98. //是否打印全部的结果
  99. boolean LOG_PRINT_ALL = false;
  100. // 结果字符串 > LOG_PRINT_MAX ,格式化打印首尾(LOG_PRINT_MAX / 2)部分,中间省略
  101. int LOG_PRINT_MAX = 1000;
  102. // 方法处理耗时 > LOG_GOOD_TIME,日志到warn中
  103. long LOG_GOOD_TIME = 10 * 1000;
  104. // ---------------------------------------------------------------- array
  105. String[] EMPTY_ARRAY = new String[0];
  106. byte[] BYTES_NEW_LINE = NEWLINE.getBytes();
  107. long PLATFORM_IDENTIFICATION = 10086;
  108. //android平台的推送
  109. String PUSH_QUEUE_ANDROID_TOKEN = "liftmanager_queue_android_token";
  110. //ios平台的推送
  111. String PUSH_QUEUE_IOS_TOKEN = "liftmanager_queue_ios_token";
  112. //android全平台的推送
  113. String PUSH_QUEUE_ANDROID_ALL = "liftmanager_queue_android_all";
  114. //ios全平台的推送
  115. String PUSH_QUEUE_IOS_ALL = "liftmanager_queue_ios_all";
  116. //一次最多推送的账号个数
  117. int PUSH_MAX_SIZE = 1000;
  118. //消息推送失败后重新尝试的最多次数
  119. int PUSH_TRY_MAX_TIMES = 100;
  120. String PATTERN_NAME = "^[\u4e00-\u9fa5a-zA-Z0-9·.。;&\\s]{1,20}$";
  121. String PATTERN_TELEPHONE = "^1[345789]\\d{9}|0[1-9](\\d{1,2}\\-?)[1-9]\\d{6,7}$";
  122. //======================年检相关状态值和判断方法======================================
  123. /**
  124. * 年检待完成
  125. */
  126. int INSPECTION_STATUS_TO_DO = 0;
  127. int INSPECTION_STATUS_COMPLETE = 1;
  128. int INSPECTION_STATUS_OVERDUE = 2;
  129. /**
  130. * 年检 第一阶段
  131. */
  132. int INSPECTION_STEP_ONE = 1;
  133. /**
  134. * 年检 第二阶段
  135. */
  136. int INSPECTION_STEP_TWO = 2;
  137. /**
  138. * 年检 第三阶段
  139. */
  140. int INSPECTION_STEP_THREE = 3;
  141. /**
  142. * 年检 第四阶段
  143. */
  144. int INSPECTION_STEP_FOUR = 4;
  145. /**
  146. * 1 维保工确认年检计划
  147. */
  148. int INSPECTION_STAGE_CONFIRM = 1;
  149. /**
  150. * 2 维保工上传自检报告,选择自检时间 或者 文员设置 是否检查限速器和荷载年检设置,
  151. * 文员也可以上传自检报告或者确认自检报告和自检时间,自检时间以最后设置的为准
  152. */
  153. int INSPECTION_STAGE_SELFCHECK = 2;
  154. /**
  155. * 3 企业文员确认现场检验时间
  156. * 录入人员信息,政府质检,企业质检,联系电话
  157. */
  158. int INSPECTION_STAGE_CONFIRM_CHECK = 3;
  159. /**
  160. * 4 维保工上传检验结果
  161. */
  162. int INSPECTION_STAGE_UPLOAD_CHECK = 4;
  163. /**
  164. * 5 企业文员确认检验结果-合格 --> 不能算年检超期
  165. */
  166. int INSPECTION_STAGE_CHECK_QUALIFIED = 5;
  167. /**
  168. * 6 企业文员确认检验结果-整改 --> 回到第二阶段
  169. */
  170. int INSPECTION_STAGE_CHECK_RECTIFICATION = 6;
  171. /**
  172. * 7 企业文员确认检验结果-不合格 --> 可以算年检超期
  173. */
  174. int INSPECTION_STAGE_CHECK_UNQUALIFIED = 7;
  175. /**
  176. * 8 维保工上传年检报告和合格证
  177. */
  178. int INSPECTION_STAGE_UPLOAD_CERT_REPORT = 8;
  179. /**
  180. * 9 企业文员确认年检报告和合格证-合格
  181. */
  182. int INSPECTION_STAGE_CERT_REPORT_QUALIFIED = 9;
  183. /**
  184. * 10 企业文员确认年检报告和合格证-不合格 -->停用电梯
  185. */
  186. int INSPECTION_STAGE_CERT_REPORT_UNQUALIFIED = 10;
  187. String INSPECTION_NOT_EXIST = "年检不存在,请确认年检计划";
  188. static String inspectionStepToNext(String previous, String current) {
  189. return String.format("请先完成%s再进行%s操作", previous, current);
  190. }
  191. static String inspectionCurrentStepStatusIllegal(int currentStepStatus, String step) {
  192. return String.format("年检当前状态(%s),不能进行%s操作", currentStepStatus, step);
  193. }
  194. static String inspectionNewStepStatusIllegal(int newStepStatus, String step) {
  195. return String.format("年检新状态(%s),不能进行%s操作", newStepStatus, step);
  196. }
  197. static String inspectionLastPlanDate(LocalDate previous, LocalDate deadline) {
  198. return String.format("上次年检时间%tF,下次年检设置%tF之前有效", previous, deadline);
  199. }
  200. static String inspectionMustOnStage(String stage) {
  201. return String.format("年检必须在%s才能操作", stage);
  202. }
  203. String INSPECTION_EXIST_SAME = "年检计划已存在。";
  204. //===================急修相关状态值和判断方法======================================
  205. /**
  206. * 急修状态(-1 暂停中)
  207. */
  208. int EMERGENCY_STATE_STOPPING = -1;
  209. /**
  210. * 急修状态(0 待修理)
  211. */
  212. int EMERGENCY_STATE_TO_DO = 0;
  213. /**
  214. * 急修状态(1 修理中)
  215. */
  216. int EMERGENCY_STATE_DOING = 1;
  217. /**
  218. * 急修状态(2 完成)
  219. */
  220. int EMERGENCY_STATE_COMPLETE = 2;
  221. /**
  222. * 急修状态(3 关闭)
  223. */
  224. int EMERGENCY_STATE_CLOSE = 3;
  225. String EMERGENCY_NOT_EXIST = "急修记录不存在,请核查";
  226. String EMERGENCY_COST_NOT_EXIST = "急修收费项不存在,请核查";
  227. String EMERGENCY_FAULT_MISSING = "缺少电梯故障项";
  228. String EMERGENCY_HAVE_REPAIRING = "该电梯存在未完成的急修,无法创建";
  229. String EMERGENCY_HAD_TAKEN = "急修已经接单,不能转派";
  230. String EMERGENCY_MUST_TO_DO = "急修状态为待处理才能操作";
  231. String EMERGENCY_MUST_IN_DOING = "急修状态为处理中才能操作";
  232. String EMERGENCY_MUST_COMPLETE = "急修完成后才能操作";
  233. String EMERGENCY_HAD_EVALUATE = "急修已经评价了";
  234. String EMERGENCY_COST_INCORRECT_AMOUNT = "急修收费项金额有误";
  235. String EMERGENCY_LIFT_IS_IN_INSPECTION = "电梯正在年检中,无法创建急修";
  236. static String emergencyProcessTimeIllegal(String options, LocalDateTime optionsTime) {
  237. return String.format("急修处理时间不能早于上次操作时间(%s: %tF %tT)", options, optionsTime, optionsTime);
  238. }
  239. //===================上传相关状态值和判断方法======================================
  240. /**
  241. * 图片上传最大大小10M * 1024 * 1024
  242. */
  243. long UPLOAD_MAX_SIZE_PIC = 10 << 20;
  244. String UPLOAD_MAX_SIZE_PIC_DESC = "图片文件大小不超过10M";
  245. /**
  246. * 文件上传最大大小50M * 1024 * 1024
  247. */
  248. long UPLOAD_MAX_SIZE_FILE = 50 << 20;
  249. String UPLOAD_MAX_SIZE_FILE_DESC = "常用文件大小不超过50M";
  250. /**
  251. * 视频上传最大大小100M * 1024 * 1024
  252. */
  253. long UPLOAD_MAX_SIZE_VIDEO = 100 << 20;
  254. String UPLOAD_MAX_SIZE_VIDEO_DESC = "视频文件大小不超过100M";
  255. /**
  256. * 上传图片文件类型
  257. */
  258. String[] UPLOAD_TYPE_PICS = {".jpg", ".jpeg", ".png", ".bmp", ".gif"};
  259. /**
  260. * 上传其他文件类型
  261. */
  262. String[] UPLOAD_TYPE_FILES = {".pdf", ".txt", ".rar", ".zip", ".7z", ".xls", ".xlsx", ".doc", ".docx", ".ppt", ".pptx"};
  263. /**
  264. * 上传视频文件类型
  265. */
  266. String[] UPLOAD_TYPE_VIDEOS = {".mov", ".mp4", ".avi", ".mpg", ".mpeg", ".rm", ".rmvb", ".wmv"};
  267. String UPLOAD_DATA_MISSING = "没有接收到文件数据";
  268. String UPLOAD_FAIL = "上传文件失败";
  269. String UPLOAD_FORMAT_NOT_SUPPORT = "文件格式暂时不支持";
  270. String UPLOAD_FORMAT_MISSING = "原文件名解析不到文件格式";
  271. String UPLOAD_FORMAT_ILLEGAL = "原文件名不合法";
  272. String UPLOAD_ORIGINAL_NAME_MISSING = "未解析到原文件名";
  273. //===================操作证相关======================================
  274. String LIFT_CERT_MUST_TO_AUDIT = "操作证待审核才能操作";
  275. String LIFT_CERT_HAD_EXIST = "操作证已存在,请核查";
  276. String LIFT_CERT_NOT_EXIST = "操作证不存在,请核查";
  277. //===================打卡相关======================================
  278. String ATTEND_SET_AM_TIME = "请设置上午的上/下班时间";
  279. String ATTEND_SET_PM_TIME = "请设置下午的上/下班时间";
  280. String ATTEND_SET_OT_TIME = "请设置加班的上/下班时间";
  281. static String attendInvalidAmTime(LocalTime topTime, LocalTime downTime) {
  282. return String.format("上午的上(%tT)/下班(%tT)时间有误", topTime, downTime);
  283. }
  284. static String attendInvalidPmTime(LocalTime topTimePm, LocalTime downTimePm) {
  285. return String.format("下午的上(%tT)/下班(%tT)时间有误", topTimePm, downTimePm);
  286. }
  287. static String attendInvalidOtTime(LocalTime topTimeOt, LocalTime downTimeOt) {
  288. return String.format("加班的上(%tT)/下班(%tT)时间有误", topTimeOt, downTimeOt);
  289. }
  290. String ATTEND_AM_TOP_CLOCK = "上午上班打卡";
  291. String ATTEND_AM_DOWN_CLOCK = "上午下班打卡";
  292. String ATTEND_PM_TOP_CLOCK = "下午上班打卡";
  293. String ATTEND_PM_DOWN_CLOCK = "下午下班打卡";
  294. String ATTEND_OT_TOP_CLOCK = "加班上班打卡";
  295. String ATTEND_OT_DOWN_CLOCK = "加班下班打卡";
  296. String ATTEND_HAD_CLOCK = "打卡记录已存在。";
  297. String ATTEND_MISSING_TIME = "请至少设置一组打卡时间";
  298. static String attendAmDownPmTop(LocalTime downTime, LocalTime topTimePm) {
  299. return String.format("下午的上班(%tT)时间不得早于上午的下班(%tT)时间", topTimePm, downTime);
  300. }
  301. static String attendPmDownOtTop(LocalTime downTimePm, LocalTime topTimeOt) {
  302. return String.format("加班的上班(%tT)时间不得早于下午的下班(%tT)时间", topTimeOt, downTimePm);
  303. }
  304. String ATTEND_MAINTAIN_COMPANY_MISSING = "维保公司不存在,请核查";
  305. String ATTEND_MISSING = "打卡记录不存在,请核查";
  306. String ATTEND_UNKNOWN_TYPE = "打卡类型未知,请核查";
  307. //===================导入相关======================================
  308. String EXCEL_IMPORT_DATA_MISSING = "未解析到有效数据";
  309. String EXCEL_IMPORT_FORMAT_SUPPORT = "文件格式不支持,暂时只支持xls,xlsx";
  310. String[] EXCEL_IMPORT_FORMATS = {".xls", ".xlsx"};
  311. /**
  312. * 一次导入表格的最大有效记录数
  313. */
  314. int EXCEL_IMPORT_MAX_ROWS_ONETIME = 5000;
  315. String EXCEL_IMPORT_MAX_ROWS_DESC = "一次性导入不能超过5000条数据";
  316. //三元运算,判断object是否为空,为空返回默认值
  317. static <T> T nullable(T object, T valueForNull) {
  318. return Objects.isNull(object) ? valueForNull : object;
  319. }
  320. String MAINTENANCE_RECORD_NOT_EXIST = "维保记录不存在,请核查";
  321. String MAINTENANCE_PLAN_NOT_EXIST = "维保计划不存在,请核查";
  322. String MAINTENANCE_OPTION_NOT_EXIST = "维保操作项不存在,请核查";
  323. String MAINTENANCE_RECORD_MUST_AUDITING = "维保单必须待审核才能操作,请核查";
  324. String MAINTENANCE_RECORD_MUST_COMPLETE = "维保单必须完成后才能操作,请核查";
  325. String MAINTENANCE_HAD_EVALUATE = "维保已经评价了";
  326. //法规维保间隔15天
  327. int MAINTENANCE_INTERVAL = 15;
  328. int EVALUATE_SOURCE_MAINTENANCE = 1;
  329. int EVALUATE_SOURCE_EMERGENCY = 2;
  330. String SYSTEM_USER_DIR = System.getProperty("user.dir");
  331. }