Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cash-loan-flow-boss
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QG
cash-loan-flow-boss
Commits
a54d22ed
Commit
a54d22ed
authored
Aug 09, 2019
by
WeiWei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除无效代码
parent
687bb4a5
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
126 deletions
+0
-126
BossDSConfig.java
...ashloanflowboss/core/configuration/data/BossDSConfig.java
+0
-1
IdGenerator.java
...tgroup/cashloanflowboss/core/persistence/IdGenerator.java
+0
-20
SnowflakeGenerator.java
...cashloanflowboss/core/persistence/SnowflakeGenerator.java
+0
-105
No files found.
src/main/java/cn/quantgroup/cashloanflowboss/core/configuration/data/BossDSConfig.java
View file @
a54d22ed
...
@@ -20,7 +20,6 @@ import javax.persistence.EntityManagerFactory;
...
@@ -20,7 +20,6 @@ import javax.persistence.EntityManagerFactory;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
@Configuration
@Configuration
@EntityScan
(
basePackages
=
{
"cn.quantgroup.cashloanflowboss.api.*.entity.boss"
})
@EnableTransactionManagement
@EnableTransactionManagement
@EnableJpaRepositories
(
basePackages
=
{
"cn.quantgroup.cashloanflowboss.api.*.repository.boss"
},
@EnableJpaRepositories
(
basePackages
=
{
"cn.quantgroup.cashloanflowboss.api.*.repository.boss"
},
entityManagerFactoryRef
=
"bossEntityManager"
,
entityManagerFactoryRef
=
"bossEntityManager"
,
...
...
src/main/java/cn/quantgroup/cashloanflowboss/core/persistence/IdGenerator.java
deleted
100644 → 0
View file @
687bb4a5
package
cn
.
quantgroup
.
cashloanflowboss
.
core
.
persistence
;
import
cn.quantgroup.cashloanflowboss.core.Application
;
import
org.hibernate.HibernateException
;
import
org.hibernate.engine.spi.SessionImplementor
;
import
org.hibernate.id.IdentityGenerator
;
import
java.io.Serializable
;
/**
* Created by WeiWei on 2017/5/17.
*/
public
class
IdGenerator
extends
IdentityGenerator
{
@Override
public
Serializable
generate
(
SessionImplementor
session
,
Object
object
)
throws
HibernateException
{
return
Application
.
getBean
(
SnowflakeGenerator
.
class
).
nextId
();
}
}
src/main/java/cn/quantgroup/cashloanflowboss/core/persistence/SnowflakeGenerator.java
deleted
100644 → 0
View file @
687bb4a5
package
cn
.
quantgroup
.
cashloanflowboss
.
core
.
persistence
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
/**
* Created by WeiWei on 2017/5/17.
*/
@Component
public
class
SnowflakeGenerator
{
/**
* 开始时间截 (2015-01-01)
*/
private
final
long
START_STMP
=
1420041600000L
;
/**
* 每一部分占用的位数
*/
private
final
static
long
SEQUENCE_BIT
=
12
;
//序列号占用的位数
private
final
static
long
MACHINE_BIT
=
5
;
//机器标识占用的位数
private
final
static
long
DATA_CENTER_BIT
=
5
;
//数据中心占用的位数
/**
* 每一部分的最大值
*/
private
final
static
long
MAX_SEQUENCE_NUMBER
=
-
1L
^
(-
1L
<<
SEQUENCE_BIT
);
private
final
static
long
MAX_MACHINE_NUMBER
=
-
1L
^
(-
1L
<<
MACHINE_BIT
);
private
final
static
long
MAX_DATA_CENTER_NUMBER
=
-
1L
^
(-
1L
<<
DATA_CENTER_BIT
);
/**
* 每一部分向左的位移
*/
private
final
static
long
MACHINE_LEFT
=
SEQUENCE_BIT
;
private
final
static
long
DATA_CENTER_LEFT
=
SEQUENCE_BIT
+
MACHINE_BIT
;
private
final
static
long
TIMESTAMP_LEFT
=
DATA_CENTER_LEFT
+
DATA_CENTER_BIT
;
/**
* 数据中心ID
*/
@Value
(
"${application.server.dataCenterId:0}"
)
private
long
dataCenterId
;
/**
* 机器标识ID
*/
@Value
(
"${application.server.machineId:0}"
)
private
long
machineId
;
/**
* 序列号
*/
private
long
sequence
;
/**
* 上次记录时间
*/
private
long
lastTimestamp
=
-
1L
;
public
SnowflakeGenerator
()
{
if
(
dataCenterId
>
MAX_DATA_CENTER_NUMBER
||
dataCenterId
<
0
)
{
throw
new
IllegalArgumentException
(
"dataCenterId can't be greater than MAX_DATA_CENTER_NUMBER or less than 0"
);
}
if
(
machineId
>
MAX_MACHINE_NUMBER
||
machineId
<
0
)
{
throw
new
IllegalArgumentException
(
"machineId can't be greater than MAX_MACHINE_NUMBER or less than 0"
);
}
}
/**
* 生成下一个ID
*
* @return
*/
public
synchronized
long
nextId
()
{
long
currentTimestamp
=
System
.
currentTimeMillis
();
if
(
currentTimestamp
<
lastTimestamp
)
{
throw
new
IllegalStateException
(
"Clock moved backwards. Refusing to generate id"
);
}
if
(
currentTimestamp
==
lastTimestamp
)
{
//相同毫秒内,序列号自增
sequence
=
(
sequence
+
1
)
&
MAX_SEQUENCE_NUMBER
;
//同一毫秒的序列数已经达到最大
if
(
sequence
==
0L
)
{
while
(
currentTimestamp
<=
lastTimestamp
)
{
currentTimestamp
=
System
.
currentTimeMillis
();
}
}
}
else
{
//不同毫秒内,序列号置为0
sequence
=
0L
;
}
lastTimestamp
=
currentTimestamp
;
return
(
currentTimestamp
-
START_STMP
)
<<
TIMESTAMP_LEFT
|
dataCenterId
<<
DATA_CENTER_LEFT
|
machineId
<<
MACHINE_LEFT
|
sequence
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment