|  |  |  | 
|---|
|  |  |  | //此ID生成器在各个子系统中难免为同一类数据生成相同的ID,造成数据库插入因主键相同而报错, | 
|---|
|  |  |  | //所以设计此后缀,每个子系统后缀不同 | 
|---|
|  |  |  | private static int suffix = 0 ; | 
|---|
|  |  |  | private static final int noSuffix = 0 ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | static { | 
|---|
|  |  |  | last = current() ; | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return ID | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static Long generateTodayStartId(){ | 
|---|
|  |  |  | return (currentTodayStart() * chengShu) * 100 + suffix; | 
|---|
|  |  |  | return (currentTodayStart() * chengShu) * 100 + noSuffix; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return ID | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static Long generateTodayEndId(){ | 
|---|
|  |  |  | return (currentTodayEnd() * chengShu) * 100 + suffix; | 
|---|
|  |  |  | return (currentTodayEnd() * chengShu) * 100 + noSuffix; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return ID | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static Long generateBeforeXDayStartId(int xday){ | 
|---|
|  |  |  | return (beforeXDayStart(xday) * chengShu) * 100 + suffix; | 
|---|
|  |  |  | return (beforeXDayStart(xday) * chengShu) * 100 + noSuffix; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | * @return ID | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | public static Long generateBeforeXDayEndId(int xday){ | 
|---|
|  |  |  | return (beforeXDayEnd(xday) * chengShu) * 100 + suffix; | 
|---|
|  |  |  | return (beforeXDayEnd(xday) * chengShu) * 100 + noSuffix; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|