Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-tool
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tool
amos-tool
Commits
2ce6d0b5
Commit
2ce6d0b5
authored
Dec 06, 2023
by
chenzai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit 合并赵智代码
parent
14e10941
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
287 additions
and
53 deletions
+287
-53
Application.java
src/main/java/com/yeejoin/amos/Application.java
+2
-0
DataBaseNameListResource.java
...in/amos/api/tool/controller/DataBaseNameListResource.java
+4
-4
RelationResource.java
...om/yeejoin/amos/api/tool/controller/RelationResource.java
+27
-5
PictureType.java
...ain/java/com/yeejoin/amos/api/tool/enums/PictureType.java
+41
-0
ProjectModel.java
...va/com/yeejoin/amos/api/tool/face/model/ProjectModel.java
+3
-0
DataBaseLinkService.java
...ejoin/amos/api/tool/face/service/DataBaseLinkService.java
+13
-9
DataBaseNameListService.java
...n/amos/api/tool/face/service/DataBaseNameListService.java
+43
-6
RelationService.java
...m/yeejoin/amos/api/tool/face/service/RelationService.java
+3
-3
StudioResourceService.java
...oin/amos/api/tool/face/service/StudioResourceService.java
+105
-6
TemplateCategoryService.java
...n/amos/api/tool/face/service/TemplateCategoryService.java
+1
-0
DataBaseUtils.java
...n/java/com/yeejoin/amos/api/tool/utils/DataBaseUtils.java
+39
-15
application-dev.properties
src/main/resources/application-dev.properties
+1
-1
application-qa.properties
src/main/resources/application-qa.properties
+5
-4
No files found.
src/main/java/com/yeejoin/amos/Application.java
View file @
2ce6d0b5
...
...
@@ -39,3 +39,5 @@ public class Application {
+
path
+
"/doc.html\n"
+
"----------------------------------------------------------"
);
}
}
src/main/java/com/yeejoin/amos/api/tool/controller/DataBaseNameListResource.java
View file @
2ce6d0b5
...
...
@@ -12,6 +12,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.sql.SQLException
;
import
java.util.List
;
@RestController
...
...
@@ -49,10 +50,9 @@ public class DataBaseNameListResource {
public
ResponseModel
<
Page
<
DataBaseNameListModel
>>
queryForPage
(
@RequestParam
(
value
=
"current"
)
int
current
,
@RequestParam
(
value
=
"size"
)
int
size
,
@RequestParam
Long
ipSeq
)
{
@RequestParam
Long
ipSeq
)
throws
SQLException
,
ClassNotFoundException
{
Page
<
DataBaseNameListModel
>
page
=
new
Page
<>();
page
.
setCurrent
(
current
);
page
.
setSize
(
size
);
return
ResponseHelper
.
buildResponse
(
dataBaseNameListService
.
queryForDataBasePage
(
page
,
ipSeq
));
return
ResponseHelper
.
buildResponse
(
dataBaseNameListService
.
queryForDataBasePage
(
page
,
ipSeq
,
current
,
size
));
}
}
src/main/java/com/yeejoin/amos/api/tool/controller/RelationResource.java
View file @
2ce6d0b5
...
...
@@ -2,8 +2,11 @@ package com.yeejoin.amos.api.tool.controller;
import
com.yeejoin.amos.api.tool.face.service.DataBaseLinkService
;
import
com.yeejoin.amos.api.tool.face.service.RelationService
;
import
com.yeejoin.amos.api.tool.face.service.StudioResourceService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang.StringUtils
;
import
org.checkerframework.checker.units.qual.A
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.typroject.tyboot.core.foundation.enumeration.UserType
;
...
...
@@ -11,7 +14,11 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import
org.typroject.tyboot.core.restful.utils.ResponseHelper
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Enumeration
;
import
java.util.HashMap
;
import
java.util.Map
;
@CrossOrigin
...
...
@@ -23,6 +30,8 @@ public class RelationResource {
private
RelationService
relationService
;
@Autowired
DataBaseLinkService
dataBaseLinkService
;
@Autowired
private
StudioResourceService
studioResourceService
;
/**
* 根据机构ID和数据库sequenceNbr批量删除数据库
...
...
@@ -49,12 +58,24 @@ public class RelationResource {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@GetMapping
(
value
=
"/export/{agencyCode}/{sequenceNbrs}"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"导出"
,
notes
=
"导出"
)
public
ResponseModel
<
String
>
generateSQL
(
// public ResponseModel<String> generateSQL(
// @RequestParam(value = "databaseName",required = false) String databaseName,
public
void
generateSQL
(
@PathVariable
String
agencyCode
,
@PathVariable
String
sequenceNbrs
,
HttpServletResponse
response
)
throws
Exception
{
relationService
.
outputAgency
(
agencyCode
,
sequenceNbrs
,
response
);
return
ResponseHelper
.
buildResponse
(
"yes"
);
HttpServletResponse
response
,
HttpServletRequest
request
)
throws
Exception
{
Map
<
String
,
Object
>
variables
=
new
HashMap
<>();
variables
.
put
(
"agencyCode"
,
agencyCode
);
String
referer
=
request
.
getHeader
(
"Referer"
);
int
start
=
referer
.
indexOf
(
"ipSeq="
)+
6
;
int
end
=
referer
.
indexOf
(
"&agencyCode="
);
String
ipSeq
=
referer
.
substring
(
start
,
end
);
Long
longIpSql
=
Long
.
parseLong
(
ipSeq
);
studioResourceService
.
generateSQL
(
"Agency"
,
"agencyCode"
,
longIpSql
,
variables
,
response
);
// studioResourceService.generateSQLByDatabaseName("Agency","agencyCode",databaseName, longIpSql, variables, response);
// return ResponseHelper.buildResponse("yes");
}
}
\ No newline at end of file
src/main/java/com/yeejoin/amos/api/tool/enums/PictureType.java
0 → 100644
View file @
2ce6d0b5
package
com
.
yeejoin
.
amos
.
api
.
tool
.
enums
;
public
enum
PictureType
{
//应用
VIZMIX
(
"vizmix"
,
"/public/studio/graph/applist/mix-thumb.png"
),
//三维
VIZ3D
(
"viz3d"
,
"/public/studio/graph/applist/3d-thumb.png"
),
//分析
VIZDAFUN
(
"vizdafun"
,
"/public/studio/graph/applist/dafun-thumb.png"
),
//表单
VIZFORM
(
"vizform"
,
"/public/studio/graph/applist/form-thumb.png"
),
//组态
VIZMORPHIC
(
"vizmorphic"
,
"/public/studio/graph/applist/2d-thumb.png"
);
///public/webico/resources/缩略图-人员.png
private
String
designer_type
;
private
String
picturePath
;
PictureType
(
String
designer_type
,
String
picturePath
)
{
this
.
designer_type
=
designer_type
;
this
.
picturePath
=
picturePath
;
}
public
String
getDesigner_type
()
{
return
designer_type
;
}
public
String
getPicturePath
()
{
return
picturePath
;
}
public
static
String
returnPath
(
String
designer_type
){
for
(
PictureType
pictureType
:
PictureType
.
values
())
{
if
(
pictureType
.
getDesigner_type
().
equals
(
designer_type
))
{
return
pictureType
.
getPicturePath
();
}
}
return
null
;
}
}
src/main/java/com/yeejoin/amos/api/tool/face/model/ProjectModel.java
View file @
2ce6d0b5
...
...
@@ -17,4 +17,7 @@ public class ProjectModel {
@ApiModelProperty
(
value
=
"机构编码"
)
private
String
agencyCode
;
@ApiModelProperty
(
value
=
"图片路径"
)
private
String
designerThumb
;
}
src/main/java/com/yeejoin/amos/api/tool/face/service/DataBaseLinkService.java
View file @
2ce6d0b5
...
...
@@ -2,8 +2,7 @@ package com.yeejoin.amos.api.tool.face.service;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.api.tool.face.model.AgencyModel
;
import
com.yeejoin.amos.api.tool.face.model.DataBaseLinkModel
;
import
com.yeejoin.amos.api.tool.face.model.*
;
import
com.yeejoin.amos.api.tool.face.orm.dao.DataBaseLinkMapper
;
import
com.yeejoin.amos.api.tool.face.orm.entity.DataBaseLink
;
import
com.yeejoin.amos.api.tool.utils.AESUtils
;
...
...
@@ -15,12 +14,8 @@ import org.springframework.stereotype.Service;
import
org.typroject.tyboot.core.foundation.utils.Bean
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.sql.DataSource
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.sql.*
;
import
java.util.ArrayList
;
...
...
@@ -40,6 +35,7 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase
@Autowired
private
DataSource
dataSource
;
/**
* 新增
*/
...
...
@@ -55,8 +51,9 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase
/**
* 编辑
*/
public
DataBaseLinkModel
update
(
DataBaseLinkModel
dataBaseLinkModel
)
throws
Exception
{
DataBaseLinkModel
model
=
this
.
decryptPwd
(
dataBaseLinkModel
);
public
DataBaseLinkModel
update
(
DataBaseLinkModel
model
)
throws
Exception
{
// DataBaseLinkModel model = this.decryptPwd(dataBaseLinkModel);
if
(
this
.
testConnection
(
model
))
{
return
this
.
updateWithModel
(
encryptPwd
(
model
));
}
else
{
...
...
@@ -120,6 +117,7 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase
return
records
;
}
/**
* 列表查询
*/
...
...
@@ -148,9 +146,15 @@ public class DataBaseLinkService extends BaseService<DataBaseLinkModel, DataBase
try
{
// 加载数据库驱动
Class
.
forName
(
"com.mysql.cj.jdbc.Driver"
);
if
(
model
.
getPrefix
()
==
null
||
model
.
getPrefix
().
isEmpty
()
||
model
.
getPrefix
().
equals
(
"null"
))
{
model
.
setPrefix
(
""
);
}
if
(
model
.
getSuffix
()
==
null
||
model
.
getSuffix
().
isEmpty
()
||
model
.
getSuffix
().
equals
(
"null"
))
{
model
.
setSuffix
(
""
);
}
// 连接新增的数据库
String
dbUrl
=
"jdbc:mysql://"
+
model
.
getIp
()
+
":"
+
model
.
getPort
()
+
"/"
+
model
.
getPrefix
()
+
model
.
getDbName
()+
model
.
getSuffix
();
model
.
getPrefix
()
+
model
.
getDbName
()
+
model
.
getSuffix
();
// 解密pwd,并连接
return
DriverManager
.
getConnection
(
dbUrl
,
model
.
getUserName
(),
AESUtils
.
decrypt
(
model
.
getPassWord
()));
}
catch
(
SQLException
|
ClassNotFoundException
e
)
{
...
...
src/main/java/com/yeejoin/amos/api/tool/face/service/DataBaseNameListService.java
View file @
2ce6d0b5
...
...
@@ -6,15 +6,14 @@ import com.yeejoin.amos.api.tool.face.model.DataBaseLinkModel;
import
com.yeejoin.amos.api.tool.face.model.DataBaseNameListModel
;
import
com.yeejoin.amos.api.tool.face.orm.dao.DataBaseNameListMapper
;
import
com.yeejoin.amos.api.tool.face.orm.entity.DataBaseNameList
;
import
com.yeejoin.amos.api.tool.utils.DataBaseUtils
;
import
org.apache.commons.beanutils.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
java.sql.Connection
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
import
java.sql.*
;
import
java.util.*
;
@Service
public
class
DataBaseNameListService
extends
BaseService
<
DataBaseNameListModel
,
DataBaseNameList
,
DataBaseNameListMapper
>
{
...
...
@@ -24,8 +23,46 @@ public class DataBaseNameListService extends BaseService<DataBaseNameListModel,
/**
* 分页查询
*/
public
Page
<
DataBaseNameListModel
>
queryForDataBasePage
(
Page
<
DataBaseNameListModel
>
page
,
Long
parentId
)
{
return
this
.
queryForPage
(
page
,
null
,
false
,
parentId
);
public
Page
<
DataBaseNameListModel
>
queryForDataBasePage
(
Page
<
DataBaseNameListModel
>
page
,
Long
parentId
,
int
current
,
int
size
)
throws
ClassNotFoundException
,
SQLException
{
Class
.
forName
(
"com.mysql.cj.jdbc.Driver"
);
DataBaseLinkModel
dataBaseLinkModel
=
dataBaseLinkService
.
queryBySeq
(
parentId
);
String
ip
=
dataBaseLinkModel
.
getIp
();
String
port
=
dataBaseLinkModel
.
getPort
();
String
url
=
"jdbc:mysql://"
+
ip
+
":"
+
port
+
" "
;
String
user
=
"root"
;
String
passWord
=
"Yeejoin@2020"
;
String
sql
=
"show databases"
;
Connection
connection
=
DriverManager
.
getConnection
(
url
,
user
,
passWord
);
Statement
statement
=
connection
.
createStatement
();
ResultSet
rs
=
statement
.
executeQuery
(
sql
);
List
<
DataBaseNameListModel
>
list
=
new
ArrayList
<>();
try
{
while
(
rs
.
next
()){
DataBaseNameListModel
listModel
=
new
DataBaseNameListModel
();
listModel
.
setDbName
(
rs
.
getString
(
"Database"
));
listModel
.
setParentId
(
parentId
);
list
.
add
(
listModel
);
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
if
(
rs
!=
null
)
rs
.
close
();
rs
=
null
;
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
connection
.
close
();
int
count
=
list
.
size
();
page
.
setSize
(
size
);
page
.
setCurrent
(
current
);
page
.
setTotal
(
count
);
//计算分页总页数
page
.
setPages
(
count
%
10
==
0
?
count
/
10
:
count
/
10
+
1
);
page
.
setRecords
(
list
);
return
page
;
}
/**
...
...
src/main/java/com/yeejoin/amos/api/tool/face/service/RelationService.java
View file @
2ce6d0b5
...
...
@@ -70,8 +70,8 @@ public class RelationService extends BaseService<RelationModel, Relation, Relati
for
(
Long
seq
:
(
Long
[])
ConvertUtils
.
convert
(
StringUtil
.
string2Array
(
sequenceNbrs
),
Long
.
class
))
{
DataBaseNameListModel
nameListModel
=
dataBaseNameListService
.
queryBySeq
(
seq
);
DataBaseLinkModel
model
=
dataBaseLinkService
.
queryBySeq
(
nameListModel
.
getParentId
());
model
.
setDbName
(
nameListModel
.
getDbName
());
Connection
connection
=
dataBaseLinkService
.
connectNewDatabase
(
model
);
model
.
setDbName
(
nameListModel
.
getDbName
());
this
.
insertData
(
connection
,
agencyCode
,
model
.
getDbName
(),
seq
,
response
);
}
}
...
...
@@ -119,8 +119,8 @@ public class RelationService extends BaseService<RelationModel, Relation, Relati
* 获取关系表转化为map
*/
public
List
<
HashMap
<
String
,
String
>>
queryRelation
(
String
dbName
)
throws
SQLException
{
StringBuilder
sql
=
new
StringBuilder
(
"SELECT
* FROM
"
);
sql
.
append
(
dbName
).
append
(
"_relation;"
);
StringBuilder
sql
=
new
StringBuilder
(
"SELECT
RESOURCE_INSERT_SQL FROM studio_resource where RESOURCE_CODE = 'Agency'
"
);
// sql.append(dbName).append("_relation;");RESOURCE_PARAMS,
return
relationMapper
.
getPublicItems
(
sql
.
toString
());
}
...
...
src/main/java/com/yeejoin/amos/api/tool/face/service/StudioResourceService.java
View file @
2ce6d0b5
...
...
@@ -2,7 +2,7 @@ package com.yeejoin.amos.api.tool.face.service;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.
baomidou.mybatisplus.extension.plugins.pagination.Pag
e
;
import
com.
yeejoin.amos.api.tool.enums.PictureTyp
e
;
import
com.yeejoin.amos.api.tool.enums.SourceEnum
;
import
com.yeejoin.amos.api.tool.face.model.DataBaseLinkModel
;
import
com.yeejoin.amos.api.tool.face.model.ProjectModel
;
...
...
@@ -176,6 +176,78 @@ public class StudioResourceService extends BaseService<StudioResourceModel, Stud
}
}
public
void
generateSQLByDatabaseName
(
String
resourceCode
,
String
dimension
,
String
databaseName
,
Long
ipSeq
,
Map
<
String
,
Object
>
variables
,
HttpServletResponse
response
)
{
try
{
//根据连接查询到数据库表名
Connection
connection
=
dataBaseLinkService
.
connectNewDatabase
(
dataBaseLinkService
.
queryBySeq
(
ipSeq
));
List
<
String
>
list
=
DataBaseUtils
.
getList
(
"select table_name from information_schema.tables where table_schema='"
+
databaseName
+
"';"
,
connection
);
List
<
StudioResourceModel
>
resourceList
=
queryForStudioResourceList
(
resourceCode
);
File
directory
=
new
File
(
""
);
// 参数为空
String
coursePath
=
directory
.
getCanonicalPath
();
File
parentFile
=
new
File
(
coursePath
).
getParentFile
();
String
backPath
=
parentFile
.
getCanonicalPath
()
+
BACKUP_PATH
;
File
sqlDirectory
=
new
File
(
backPath
);
if
(!
sqlDirectory
.
exists
())
{
sqlDirectory
.
mkdir
();
}
// 备份文件路径名称
String
fileName
=
(
SourceEnum
.
IDX
.
getSource
().
equals
(
resourceCode
.
toLowerCase
())
?
(
resourceCode
.
toLowerCase
()
+
"_"
)
:
"studio_"
)
+
DateFormatUtils
.
format
(
new
Date
(),
"yyyyMMdd"
)
+
"."
+
SUFFIX
;
String
sqlFilePath
=
backPath
+
SLASH
+
fileName
;
File
file
=
new
File
(
sqlFilePath
);
FileOutputStream
out
;
OutputStreamWriter
writer
=
null
;
out
=
new
FileOutputStream
(
file
);
writer
=
new
OutputStreamWriter
(
out
,
"utf8"
);
StringBuffer
deleteSql
=
new
StringBuffer
();
for
(
String
tableName
:
list
)
{
Statement
statement
=
connection
.
createStatement
();
ResultSet
rs
=
statement
.
executeQuery
(
"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS "
+
"WHERE TABLE_NAME = '"
+
tableName
+
"' AND COLUMN_NAME = '"
+
"AGENCY_CODE"
+
"';"
);
if
(!
rs
.
next
())
{
continue
;
}
deleteSql
.
append
(
"DELETE FROM "
+
tableName
+
" WHERE AGENCY_CODE = '"
+
variables
.
get
(
dimension
).
toString
()
+
"';"
+
BR
);
rs
.
close
();
statement
.
close
();
}
StringBuffer
insertSql
=
new
StringBuffer
();
for
(
StudioResourceModel
model
:
resourceList
)
{
String
sql
=
buildInsertSqlByDatabaseName
(
model
,
dimension
,
databaseName
,
list
,
ipSeq
,
variables
);
if
(!
ObjectUtils
.
isEmpty
(
sql
))
insertSql
.
append
(
sql
);
}
if
(
deleteSql
.
length
()
>
0
)
{
print
(
variables
.
get
(
dimension
).
toString
(),
"开始创建delete语句..."
,
"running"
);
writer
.
write
(
BR
+
DELIMITER
+
BR
);
writer
.
write
(
"/**"
+
BR
+
"* 删除历史资源数据 "
+
BR
+
"**/"
+
BR
);
writer
.
write
(
BR
+
DELIMITER
+
BR
);
writer
.
write
(
deleteSql
.
toString
());
writer
.
write
(
BR
+
BR
+
DELIMITER
+
BR
);
print
(
variables
.
get
(
dimension
).
toString
(),
"delete语句创建完成..."
,
"running"
);
}
if
(
insertSql
.
length
()
>
0
)
{
print
(
variables
.
get
(
dimension
).
toString
(),
"开始创建insert语句..."
,
"running"
);
writer
.
write
(
BR
+
DELIMITER
+
BR
);
writer
.
write
(
"/**"
+
BR
+
"* 资源数据"
+
BR
+
"**/"
+
BR
);
writer
.
write
(
BR
+
DELIMITER
+
BR
);
writer
.
write
(
insertSql
.
toString
());
writer
.
write
(
BR
+
BR
+
DELIMITER
+
BR
);
print
(
variables
.
get
(
dimension
).
toString
(),
"insert语句创建完成..."
,
"running"
);
}
writer
.
flush
();
writer
.
close
();
out
.
close
();
download
(
response
,
fileName
,
sqlFilePath
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
void
print
(
String
id
,
String
msg
,
String
step
)
{
String
percent
=
"0"
;
percent
=
ValidationUtil
.
equals
(
step
,
"end"
)
?
"100"
:
ValidationUtil
.
equals
(
step
,
"running"
)
?
"50"
:
"10"
;
...
...
@@ -229,6 +301,35 @@ public class StudioResourceService extends BaseService<StudioResourceModel, Stud
return
sbsql
.
toString
();
}
private
String
buildInsertSqlByDatabaseName
(
StudioResourceModel
resource
,
String
dimension
,
String
databaseName
,
List
<
String
>
list
,
Long
ipSeq
,
Map
<
String
,
Object
>
variables
)
throws
SQLException
{
StringBuffer
sbsql
=
new
StringBuffer
();
DataBaseLinkModel
dataBaseLinkModel
=
dataBaseLinkService
.
queryBySeq
(
ipSeq
);
dataBaseLinkModel
.
setDbName
(
databaseName
);
for
(
String
tableName
:
list
)
{
String
selectsql
=
format
(
"SELECT * from `"
+
tableName
+
"` WHERE AGENCY_CODE = '${agencyCode}';"
,
variables
);
if
(
dimension
.
equals
(
"appSeq"
))
{
dataBaseLinkModel
.
setDbName
(
dataBaseLinkModel
.
getDbName
().
replace
(
"project"
,
"studio"
));
}
else
if
(
dimension
.
equals
(
"projectSeq"
))
{
dataBaseLinkModel
.
setDbName
(
dataBaseLinkModel
.
getDbName
().
replace
(
"project"
,
"idx"
));
}
Connection
connection
=
dataBaseLinkService
.
connectNewDatabase
(
dataBaseLinkModel
);
Statement
statement
=
connection
.
createStatement
();
ResultSet
rs
=
statement
.
executeQuery
(
"SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS "
+
"WHERE TABLE_NAME = '"
+
tableName
+
"' AND COLUMN_NAME = '"
+
"AGENCY_CODE"
+
"';"
);
if
(!
rs
.
next
())
{
continue
;
}
List
<
TableColumn
>
columns
=
DataBaseUtils
.
getTableColumn
(
tableName
,
connection
);
List
<
Map
<
String
,
Object
>>
dataList
=
DataBaseUtils
.
getMaps
(
selectsql
,
connection
);
sbsql
.
append
(
DataBaseUtils
.
getInsertSQL
(
dataList
,
columns
,
tableName
));
rs
.
close
();
statement
.
close
();
connection
.
close
();
}
return
sbsql
.
toString
();
}
public
static
String
format
(
String
sqlTemplate
,
Map
<
String
,
Object
>
parameter
)
{
StringSubstitutor
ss
=
new
StringSubstitutor
(
parameter
);
return
ss
.
replace
(
sqlTemplate
);
...
...
@@ -258,7 +359,7 @@ public class StudioResourceService extends BaseService<StudioResourceModel, Stud
model
.
setDbName
(
"amos_studio"
);
Connection
connection
=
dataBaseLinkService
.
connectNewDatabase
(
model
);
Statement
sql
=
connection
.
createStatement
();
String
sqlStr
=
"select SEQUENCE_NBR,PROJECT_NAME,AGENCY_CODE from
amos_studio
.studio_project "
+
String
sqlStr
=
"select SEQUENCE_NBR,PROJECT_NAME,AGENCY_CODE from
"
+
model
.
getPrefix
()
+
"amos_studio"
+
model
.
getSuffix
()
+
"
.studio_project "
+
"where AGENCY_CODE = "
+
"'"
+
agencyCode
+
"'"
;
// System.out.println(sqlStr);
ResultSet
resultSet
=
sql
.
executeQuery
(
sqlStr
);
...
...
@@ -290,7 +391,7 @@ public class StudioResourceService extends BaseService<StudioResourceModel, Stud
model
.
setDbName
(
"amos_studio"
);
Connection
connection
=
dataBaseLinkService
.
connectNewDatabase
(
model
);
Statement
sql
=
connection
.
createStatement
();
String
sqlStr
=
"select SEQUENCE_NBR,APP_NAME
from amos_studio
.studio_application "
+
String
sqlStr
=
"select SEQUENCE_NBR,APP_NAME
,DESIGNER_TYPE from "
+
model
.
getPrefix
()
+
"amos_studio"
+
model
.
getSuffix
()
+
"
.studio_application "
+
"where PROJECT_SEQ = "
+
"'"
+
projectNbr
+
"'"
;
// System.out.println(sqlStr);
ResultSet
resultSet
=
sql
.
executeQuery
(
sqlStr
);
...
...
@@ -303,6 +404,7 @@ public class StudioResourceService extends BaseService<StudioResourceModel, Stud
ProjectModel
pm
=
new
ProjectModel
();
pm
.
setName
(
resultSet
.
getString
(
"APP_NAME"
));
pm
.
setSequenceNbr
(
resultSet
.
getString
(
"SEQUENCE_NBR"
));
pm
.
setDesignerThumb
(
PictureType
.
returnPath
(
resultSet
.
getString
(
"DESIGNER_TYPE"
)));
listPm
.
add
(
pm
);
}
}
catch
(
SQLException
throwables
)
{
...
...
@@ -343,9 +445,6 @@ public class StudioResourceService extends BaseService<StudioResourceModel, Stud
//关闭资源
connection
.
close
();
}
return
listPm
;
}
}
src/main/java/com/yeejoin/amos/api/tool/face/service/TemplateCategoryService.java
View file @
2ce6d0b5
...
...
@@ -62,6 +62,7 @@ public class TemplateCategoryService extends BaseService<TemplateCategoryModel,
return
getChildren
(
nodes
,
""
,
0L
);
}
/**
* 获得模板分类子节点(递归)
*/
...
...
src/main/java/com/yeejoin/amos/api/tool/utils/DataBaseUtils.java
View file @
2ce6d0b5
package
com
.
yeejoin
.
amos
.
api
.
tool
.
utils
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
com.yeejoin.amos.api.tool.face.orm.entity.TableColumn
;
import
org.eclipse.paho.client.mqttv3.MqttException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.ObjectUtils
;
import
org.typroject.tyboot.component.emq.EmqKeeper
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.sql.DataSource
;
import
java.net.Inet4Address
;
import
java.net.InetAddress
;
import
java.net.NetworkInterface
;
import
java.net.SocketException
;
import
java.sql.*
;
import
java.util.*
;
...
...
@@ -83,6 +70,34 @@ public class DataBaseUtils {
return
list
;
}
public
static
List
<
String
>
getList
(
String
sql
,
Connection
connection
)
throws
SQLException
{
Statement
statement
=
connection
.
createStatement
();
ResultSet
rs
=
statement
.
executeQuery
(
sql
);
List
<
String
>
list
=
new
ArrayList
<
String
>();
try
{
ResultSetMetaData
md
=
rs
.
getMetaData
();
int
columnCount
=
md
.
getColumnCount
();
while
(
rs
.
next
())
{
for
(
int
i
=
1
;
i
<=
columnCount
;
i
++)
{
list
.
add
(
rs
.
getObject
(
i
).
toString
());
}
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
if
(
rs
!=
null
)
rs
.
close
();
rs
=
null
;
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
return
list
;
}
/**
* 获取表单列名
*/
...
...
@@ -145,7 +160,18 @@ public class DataBaseUtils {
}
}
else
{
if
(!
ObjectUtils
.
isEmpty
(
map
.
get
(
column
.
getColumnName
())))
{
if
(
column
.
getColumnName
().
equals
(
"UIOBJECT"
)
||
column
.
getColumnName
().
equals
(
"CONTENT"
)){
int
start
=
sql
.
length
()+
2
;
sql
.
append
(
"'"
).
append
(
JSON
.
toJSONString
(
map
.
get
(
column
.
getColumnName
())).
replaceAll
(
"'"
,
"\\\\'"
)).
append
(
"'"
);
int
end
=
sql
.
length
()-
2
;
sql
.
delete
(
start
-
1
,
start
);
sql
.
delete
(
end
-
1
,
end
);
}
else
if
(
column
.
getColumnName
().
equals
(
"PUBLISH_CODE"
)){
sql
.
append
(
"'"
).
append
((
map
.
get
(
column
.
getColumnName
())).
toString
().
replaceAll
(
"'"
,
"\\\\'"
)).
append
(
"'"
);
}
else
{
sql
.
append
(
"'"
).
append
(
map
.
get
(
column
.
getColumnName
())).
append
(
"'"
);
}
}
else
{
sql
.
append
(
"null"
);
}
...
...
@@ -179,6 +205,4 @@ public class DataBaseUtils {
page
.
setRecords
(
pageList
);
return
page
;
}
}
src/main/resources/application-dev.properties
View file @
2ce6d0b5
#DB properties:
# jdbc_config
spring.datasource.url
=
jdbc:mysql://
39.98.45.134:3306/amos_tool_library_test
?allowMultiQueries=true
spring.datasource.url
=
jdbc:mysql://
172.16.3.18:3306/amos_tool_library
?allowMultiQueries=true
spring.datasource.username
=
root
spring.datasource.password
=
Yeejoin@2020
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
...
...
src/main/resources/application-qa.properties
View file @
2ce6d0b5
#DB properties:
# jdbc_config
spring.datasource.url
=
jdbc:mysql://39.98.45.134:3306/amos_tool_library?allowMultiQueries=true
spring.datasource.url
=
jdbc:mysql://172.16.3.18:3306/amos_tool_library?allowMultiQueries=true
#spring.datasource.url=jdbc:mysql://172.16.3.19:3306/amos_tool_library?allowMultiQueries=true
spring.datasource.username
=
root
spring.datasource.password
=
Yeejoin@2020
spring.datasource.driver-class-name
=
com.mysql.cj.jdbc.Driver
...
...
@@ -15,7 +16,7 @@ spring.datasource.hikari.connection-timeout=30000
spring.datasource.hikari.connection-test-query
=
SELECT 1
#eureka
eureka.instance.hostname
=
39.98.45.134
eureka.instance.hostname
=
172.16.3.18
eureka.client.serviceUrl.defaultZone
=
http://${eureka.instance.hostname}:10001/eureka/
eureka.instance.prefer-ip-address
=
true
eureka.instance.health-check-url
=
http://localhost:${server.port}${server.servlet.context-path}/actuator/health
...
...
@@ -25,7 +26,7 @@ eureka.instance.metadata-map.management.api-docs=http://localhost:${server.port}
#redis
spring.redis.database
=
1
spring.redis.host
=
39.98.45.134
spring.redis.host
=
172.16.3.18
spring.redis.port
=
6379
spring.redis.password
=
yeejoin@2020
spring.redis.timeout
=
0
...
...
@@ -33,7 +34,7 @@ spring.redis.timeout=0
## emqx
emqx.clean-session
=
true
emqx.client-id
=
${spring.application.name}-${random.int[1024,65536]}
emqx.broker
=
tcp://
39.98.45.134
:2883
emqx.broker
=
tcp://
172.16.3.18
:2883
emqx.client-user-name
=
super
emqx.client-password
=
a123456
emqx.max-inflight
=
1000
...
...
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