|
@@ -25,15 +25,16 @@ public class VisibleIdCreater extends AbstractIdCreater<Integer> {
|
|
super(machineId, dataCenterId);
|
|
super(machineId, dataCenterId);
|
|
}
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
|
/**
|
|
/**
|
|
- * 对外id生成规则
|
|
|
|
- * 180905123451110001
|
|
|
|
- * 180905 - 12345 - 1 - 1 - 1 - 0001
|
|
|
|
- * 日期 - 秒数 - 业务 - 机器 - 数据中心 - 秒内自增
|
|
|
|
- * @param type 业务id 1.订单 2.交易 3.退款
|
|
|
|
- * @return 生成的id
|
|
|
|
|
|
+ * 对外id生成规则
|
|
|
|
+ * 180905123451110001
|
|
|
|
+ * 180905 - 12345 - 1 - 1 - 1 - 0001
|
|
|
|
+ * 日期 - 秒数 - 业务 - 机器 - 数据中心 - 秒内自增
|
|
|
|
+ *
|
|
|
|
+ * @param type 业务id 1.订单 2.交易 3.退款
|
|
|
|
+ * @return 生成的id
|
|
*/
|
|
*/
|
|
|
|
+ @Override
|
|
public synchronized Long getNextId(Integer type) {
|
|
public synchronized Long getNextId(Integer type) {
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
Calendar calendar = Calendar.getInstance();
|
|
@@ -64,6 +65,16 @@ public class VisibleIdCreater extends AbstractIdCreater<Integer> {
|
|
return Long.valueOf(date + String.format("%05d", seconds) + String.valueOf(type) + machineId + dataCenterId + sequence);
|
|
return Long.valueOf(date + String.format("%05d", seconds) + String.valueOf(type) + machineId + dataCenterId + sequence);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 对外id生成规则
|
|
|
|
+ * 1809051234550001
|
|
|
|
+ * 180905 - 12345 - 1 - 0001
|
|
|
|
+ * 日期 - 秒数 - 业务 - 秒内自增
|
|
|
|
+ *
|
|
|
|
+ * @param type 业务id 1.订单 2.交易 3.退款
|
|
|
|
+ * @return 生成的id
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
public synchronized Long getNextShortId(Integer type) {
|
|
public synchronized Long getNextShortId(Integer type) {
|
|
Calendar calendar = Calendar.getInstance();
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|