Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
T
traffic-front
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wangxiaoming
traffic-front
Commits
f31033d6
Commit
f31033d6
authored
Jun 28, 2018
by
neo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BUG] bug fiex db cannot creat when add project
parent
69146937
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
ProjectServiceImpl.java
...ava/pwc/taxtech/atms/service/impl/ProjectServiceImpl.java
+18
-8
No files found.
atms-api/src/main/java/pwc/taxtech/atms/service/impl/ProjectServiceImpl.java
View file @
f31033d6
...
@@ -273,6 +273,14 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -273,6 +273,14 @@ public class ProjectServiceImpl implements ProjectService {
return
result
;
return
result
;
}
}
static
class
DbName
{
String
dbName
;
public
DbName
(
String
dbName
)
{
this
.
dbName
=
dbName
;
}
}
private
String
generateDatabase
(
Project
project
,
String
accsetid
)
{
//TODO: should be impl future(neo)
private
String
generateDatabase
(
Project
project
,
String
accsetid
)
{
//TODO: should be impl future(neo)
String
maxDbName
=
projectMapper
.
maxDbName
(
project
.
getYear
());
String
maxDbName
=
projectMapper
.
maxDbName
(
project
.
getYear
());
String
dbName
=
""
;
String
dbName
=
""
;
...
@@ -282,12 +290,14 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -282,12 +290,14 @@ public class ProjectServiceImpl implements ProjectService {
}
else
{
}
else
{
dbName
=
generateProjectDbName
(
dbName
,
project
.
getYear
()
+
""
);
dbName
=
generateProjectDbName
(
dbName
,
project
.
getYear
()
+
""
);
}
}
DbName
sbDbName
=
new
DbName
(
dbName
);
createDatabaseByName
(
d
bName
,
project
);
createDatabaseByName
(
sbD
bName
,
project
);
ShardingContextHolder
.
setDataSourceKey
(
dbName
);
ShardingContextHolder
.
setDataSourceKey
(
sbDbName
.
dbName
);
try
(
SqlSession
sqlSession
=
dynamicSqlSessionTemplate
.
getSqlSessionFactory
().
openSession
();
try
(
SqlSession
sqlSession
=
dynamicSqlSessionTemplate
.
getSqlSessionFactory
().
openSession
();
BufferedReader
bufferedReader
=
new
BufferedReader
(
prepareRunScriptReader
(
DB_MYSQL_PATH
,
dbName
,
project
,
accsetid
));)
{
BufferedReader
bufferedReader
=
new
BufferedReader
(
prepareRunScriptReader
(
DB_MYSQL_PATH
,
sbDbName
.
dbName
,
project
,
accsetid
));)
{
ScriptRunner
scriptRunner
=
new
ScriptRunner
(
sqlSession
.
getConnection
());
//only support mysql
ScriptRunner
scriptRunner
=
new
ScriptRunner
(
sqlSession
.
getConnection
());
//only support mysql
scriptRunner
.
setAutoCommit
(
true
);
scriptRunner
.
setAutoCommit
(
true
);
...
@@ -298,7 +308,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -298,7 +308,7 @@ public class ProjectServiceImpl implements ProjectService {
}
}
initStandardAccount
(
project
.
getIndustryID
());
initStandardAccount
(
project
.
getIndustryID
());
return
dbName
;
return
sbDbName
.
toString
()
;
}
}
...
@@ -328,7 +338,7 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -328,7 +338,7 @@ public class ProjectServiceImpl implements ProjectService {
}
}
}
}
prepareAccount
.
forEach
(
m
->
vatStandardAccountMapper
.
insert
(
m
));
prepareAccount
.
forEach
(
m
->
vatStandardAccountMapper
.
insert
(
m
));
}
}
...
@@ -395,11 +405,11 @@ public class ProjectServiceImpl implements ProjectService {
...
@@ -395,11 +405,11 @@ public class ProjectServiceImpl implements ProjectService {
}
}
private
void
createDatabaseByName
(
String
dbName
,
Project
project
)
{
private
void
createDatabaseByName
(
DbName
dbName
,
Project
project
)
{
int
result
=
databaseAgent
.
createDatabase
(
dbName
);
int
result
=
databaseAgent
.
createDatabase
(
dbName
.
dbName
);
if
(
result
==
Constant
.
CREATE_DB_EXISTS
)
{
if
(
result
==
Constant
.
CREATE_DB_EXISTS
)
{
dbName
=
generateProjectDbName
(
dbName
,
project
.
getYear
()
+
""
);
dbName
.
dbName
=
generateProjectDbName
(
dbName
.
dbName
,
project
.
getYear
()
+
""
);
createDatabaseByName
(
dbName
,
project
);
createDatabaseByName
(
dbName
,
project
);
}
else
if
(
result
==
Constant
.
CREATE_DB_FAILED
)
{
}
else
if
(
result
==
Constant
.
CREATE_DB_FAILED
)
{
LOGGER
.
debug
(
"should throws biz exception"
);
//TODO: should shrow biz exception in futrue(neo)
LOGGER
.
debug
(
"should throws biz exception"
);
//TODO: should shrow biz exception in futrue(neo)
...
...
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