Contant.java 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. package com.yihu.quota.etl;
  2. import org.joda.time.DateTime;
  3. import org.springframework.util.StringUtils;
  4. import java.text.SimpleDateFormat;
  5. import java.time.LocalDate;
  6. import java.time.format.DateTimeFormatter;
  7. import java.util.Calendar;
  8. import java.util.Date;
  9. /**
  10. * Created by chenweida on 2017/6/1.
  11. */
  12. public class Contant {
  13. //抽取数据的开始时间
  14. public static String startTime = "${start_time}";
  15. //抽取数据的结束时间
  16. public static String endTime = "${end_time}";
  17. //数据库类型
  18. public static class db_type {
  19. public static String oracle = "oracle";
  20. public static String mysql = "mysql";
  21. }
  22. /**
  23. * DateModel的map的key常量
  24. */
  25. public static class extract {
  26. public static final String computeKey1 = "oneKey";
  27. public static final String computeKey2 = "senondKey";
  28. }
  29. /**
  30. * 运算常量
  31. */
  32. public static class compute {
  33. public static final String add = "1"; //累加
  34. public static final String division = "2"; //相除
  35. public static final int perCount = 20000;//单位统计量
  36. }
  37. /**
  38. * 主维度常量
  39. */
  40. public static class main_dimension {
  41. public static final String time_day = "1";//时间维度 日
  42. public static final String time_week = "2";//时间维度 周
  43. public static final String time_month = "3";//时间维度 月
  44. public static final String time_year = "4";//时间维度 年
  45. public static final String area_province = "5";//行政区划 省
  46. public static final String area_city = "6";//行政区划 市
  47. public static final String area_town = "7";//行政区划 区县
  48. public static final String area_org = "8";//行政区划 机构
  49. public static final String area_dept = "9";//科室
  50. }
  51. public static class quota {
  52. public static final String dataLevel_all = "1"; // 全量
  53. public static final String dataLevel_increase = "2"; // 增量
  54. public static final String aggregation_count = "count";
  55. public static final String aggregation_sum = "sum";
  56. public static final String aggregation_list = "list";
  57. public static final String aggregation_distinct = "distinct"; // 去重
  58. }
  59. /**
  60. * areaLevel 具体的值
  61. */
  62. public static class main_dimension_areaLevel {
  63. public static final String area_province = "1";//行政区划 省
  64. public static final String area_city = "2";//行政区划 市
  65. public static final String area_town = "3";//行政区划 区县
  66. public static final String area_org = "4";//行政区划 机构
  67. public static final String area_dept = "5";//行政区划 科室
  68. public static String getAreaLevelByMainDimension(String key) {
  69. switch (key) {
  70. case main_dimension.area_province: {
  71. return area_province;
  72. }
  73. case main_dimension.area_city: {
  74. return area_city;
  75. }
  76. case main_dimension.area_town: {
  77. return area_town;
  78. }
  79. case main_dimension.area_org: {
  80. return area_org;
  81. }
  82. case main_dimension.area_dept: {
  83. return area_dept;
  84. }
  85. }
  86. return "";
  87. }
  88. }
  89. /**
  90. * 主维度 时间维度
  91. */
  92. public static class main_dimension_timeLevel {
  93. public static final String year = "1";
  94. public static final String month = "2";
  95. public static final String week = "3";
  96. public static final String day = "4";
  97. public static String getStartTime(String key) {
  98. LocalDate today = LocalDate.now();
  99. if (StringUtils.isEmpty(key)) {
  100. key = day;
  101. }
  102. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'00:00:00'Z'");
  103. switch (key) {
  104. case year: {
  105. //去年度第一天
  106. return simpleDateFormat.format(getCurrYearFirst(-1));
  107. }
  108. case month: {
  109. //上个月第一天
  110. return getYesterMonthDay(simpleDateFormat, -1);
  111. }
  112. case week: {
  113. //上周周第一天
  114. return getStartDayOfWeek(simpleDateFormat, -1);
  115. }
  116. case day: {
  117. //昨天
  118. return getYesterday();
  119. }
  120. }
  121. return getYesterday();
  122. }
  123. /**
  124. * 获取这个月第一天
  125. *
  126. * @param today
  127. * @return
  128. */
  129. private static String getCurrentMonthDay(LocalDate today) {
  130. LocalDate firstday = LocalDate.of(today.getYear(), today.getMonth(), 1);
  131. return firstday.format(DateTimeFormatter.ISO_DATE);
  132. }
  133. /**
  134. * 获取上个月第一天
  135. *
  136. * @return
  137. */
  138. private static String getYesterMonthDay(SimpleDateFormat simpleDateFormat, Integer n) {
  139. Calendar calendar = Calendar.getInstance();
  140. int month = calendar.get(Calendar.MONTH);
  141. calendar.set(Calendar.MONTH, month + n);
  142. calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMinimum(Calendar.DAY_OF_MONTH));
  143. Date strDateTo = calendar.getTime();
  144. return simpleDateFormat.format(strDateTo);
  145. }
  146. /**
  147. * 获取本周第一天
  148. *
  149. * @param simpleDateFormat
  150. * @param n 为推迟的周数,1本周,-1向前推迟一周,2下周,依次类推
  151. * @return
  152. */
  153. private static String getStartDayOfWeek(SimpleDateFormat simpleDateFormat, Integer n) {
  154. Calendar cal = Calendar.getInstance();
  155. cal.add(Calendar.DATE, n * 7);
  156. cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY);
  157. cal.set(Calendar.HOUR_OF_DAY, 0);
  158. cal.set(Calendar.MINUTE, 0);
  159. cal.set(Calendar.SECOND, 0);
  160. Date date = cal.getTime();
  161. return simpleDateFormat.format(date);
  162. }
  163. /**
  164. * 获取去年的第一天
  165. *
  166. * @return
  167. */
  168. private static Date getCurrYearFirst(Integer n) {
  169. Calendar currCal = Calendar.getInstance();
  170. int currentYear = currCal.get(Calendar.YEAR) + n;
  171. return getYearFirst(currentYear);
  172. }
  173. /**
  174. * 获取某年第一天日期
  175. *
  176. * @param year 年份
  177. * @return Date
  178. */
  179. private static Date getYearFirst(int year) {
  180. Calendar calendar = Calendar.getInstance();
  181. calendar.clear();
  182. calendar.set(Calendar.YEAR, year);
  183. Date currYearFirst = calendar.getTime();
  184. return currYearFirst;
  185. }
  186. /**
  187. * 获取昨天
  188. *
  189. * @return
  190. */
  191. private static String getYesterday() {
  192. return new org.joda.time.LocalDate(new DateTime().minusDays(1)).toString("yyyy-MM-dd'T'00:00:00'Z'");
  193. }
  194. }
  195. public static class save_status {
  196. public static final String success = "1";
  197. public static final String fail = "0";
  198. public static final String executing = "2";
  199. }
  200. public static class save {
  201. public static final String es = "1";
  202. public static final String mysql = "2";
  203. }
  204. public static class convert{
  205. public static String level_age_1="1";
  206. public static String level_age_2="2";
  207. public static String level_age_3="3";
  208. public static String level_age_4="4";
  209. public static String level_age_5="5";
  210. public static String level_age_1_name="0~6";
  211. public static String level_age_2_name="7~17";
  212. public static String level_age_3_name="18~40";
  213. public static String level_age_4_name="41~65";
  214. public static String level_age_5_name=">65";
  215. }
  216. public static class quartz_cron {
  217. //每年 1月1号 0点 0点0秒触发
  218. public static final String everyYearFirstDay = "0 0 0 1 1 ? *";
  219. //每个月1号 0点 0点0秒触发
  220. public static final String everyMonthFirstDay = "0 0 0 1 * ?";
  221. //每周一 0点 0点0秒触发
  222. public static final String everyWeekFirstDay = "0 0 0 ? * MON";
  223. //每天0点0分 0秒触发
  224. public static final String everyDay = "0 0 0 * * ?";
  225. }
  226. public static class orgHealthTypeCode {
  227. public static final String hospital = "hospital"; //医院卫生机构
  228. public static final String basicMedical = "basic_medical"; //基层医疗卫生机构
  229. public static final String pro_public = "pro_public";//专业公共卫生机构
  230. public static final String other = "other";//其他医疗卫生机构
  231. public static final String hospital_Id = "13"; //医院卫生机构
  232. public static final String basicMedical_Id = "57"; //基层医疗卫生机构
  233. public static final String pro_public_Id = "94";//专业公共卫生机构
  234. public static final String other_Id = "134";//其他医疗卫生机构
  235. }
  236. }