Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dataWareHose
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
黄夏豪
dataWareHose
Commits
9e3ded72
提交
9e3ded72
authored
7月 05, 2021
作者:
ww1xhqc
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[数据模型]
上级
6e686f5a
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
129 行增加
和
21 行删除
+129
-21
GlobalExceptionHandler.java
...ykj/datawarehouse/base/result/GlobalExceptionHandler.java
+1
-0
ModelController.java
.../tykj/datawarehouse/model/controller/ModelController.java
+19
-6
OrderCondition.java
...om/tykj/datawarehouse/model/entity/vo/OrderCondition.java
+23
-0
SearchAllVO.java
...a/com/tykj/datawarehouse/model/entity/vo/SearchAllVO.java
+20
-0
ModelService.java
...va/com/tykj/datawarehouse/model/service/ModelService.java
+3
-2
ModelImpl.java
.../com/tykj/datawarehouse/model/service/impl/ModelImpl.java
+45
-9
MysqlSqlType.java
...va/com/tykj/datawarehouse/model/sqlType/MysqlSqlType.java
+3
-0
OscarSqlType.java
...va/com/tykj/datawarehouse/model/sqlType/OscarSqlType.java
+4
-1
SessionUtil.java
.../java/com/tykj/datawarehouse/model/utils/SessionUtil.java
+2
-1
SqlTypeUtil.java
.../java/com/tykj/datawarehouse/model/utils/SqlTypeUtil.java
+3
-0
DataTestApplicationTests.java
...java/com/tykj/datawarehouse/DataTestApplicationTests.java
+6
-2
没有找到文件。
src/main/java/com/tykj/datawarehouse/base/result/GlobalExceptionHandler.java
浏览文件 @
9e3ded72
...
...
@@ -34,6 +34,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler
(
ApiException
.
class
)
public
ResponseEntity
errorMessage
(
ApiException
e
)
{
log
.
warn
(
"[自定义异常] {}"
,
e
.
toString
());
e
.
printStackTrace
();
if
(
e
.
getResponseEntity
()
!=
null
)
{
return
e
.
getResponseEntity
();
}
...
...
src/main/java/com/tykj/datawarehouse/model/controller/ModelController.java
浏览文件 @
9e3ded72
...
...
@@ -64,7 +64,20 @@ public class ModelController {
tableInfos
=
modelService
.
pageAllEntities
(
searchTableInfoVo
);
return
ResultUtil
.
success
(
tableInfos
,
"数据查询成功!"
);
}
/**
* @return org.springframework.http.ResponseEntity
* @Author WWW
* @Description 根据表名查询所有数据
* @Date 9:30 2021/3/11
**/
@ApiOperation
(
"根据表名查询所有数据"
)
@PostMapping
(
"/getAll"
)
public
ResponseEntity
getAll
(
@RequestBody
SearchAllVO
searchAllVO
)
throws
SQLException
{
if
(
searchAllVO
.
getOrderConditions
()
!=
null
&&
searchAllVO
.
getOrderConditions
().
size
()
>
0
)
{
return
ResultUtil
.
success
(
modelService
.
findAllByName
(
searchAllVO
.
getTableName
(),
searchAllVO
.
getOrderConditions
()),
"查询成功!"
);
}
return
ResultUtil
.
success
(
modelService
.
findAllByName
(
searchAllVO
.
getTableName
()),
"查询成功!"
);
}
/**
* @param searchColumnInfoVo
* @return java.util.List<com.tykj.workflowcore.model_layer.model.ColumnInfo>
...
...
@@ -177,11 +190,11 @@ public class ModelController {
@ApiOperation
(
"编辑操作"
)
@PutMapping
(
"/update"
)
public
ResponseEntity
updateTable
(
@RequestBody
UpdateTableInfoVO
updateTableInfoVO
)
{
int
i
=
modelService
.
updateTable
(
updateTableInfoVO
);
if
(
i
==
1
)
{
return
ResultUtil
.
success
(
""
,
"修改成功!"
);
}
return
ResultUtil
.
failed
(
"业务类型
不支持修改!"
);
return
modelService
.
updateTable
(
updateTableInfoVO
);
//
if (i == 1) {
//
return ResultUtil.success("", "修改成功!");
//
}
// return ResultUtil.failed("业务
不支持修改!");
}
@ApiOperation
(
"删除操作"
)
...
...
src/main/java/com/tykj/datawarehouse/model/entity/vo/OrderCondition.java
0 → 100644
浏览文件 @
9e3ded72
package
com
.
tykj
.
datawarehouse
.
model
.
entity
.
vo
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* @Description TODO
* @Author WWW
* @Date 2021/6/9 17:03
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
OrderCondition
{
@ApiModelProperty
(
"列"
)
private
String
columns
;
@ApiModelProperty
(
"排序"
)
private
String
sortValue
;
}
src/main/java/com/tykj/datawarehouse/model/entity/vo/SearchAllVO.java
0 → 100644
浏览文件 @
9e3ded72
package
com
.
tykj
.
datawarehouse
.
model
.
entity
.
vo
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
/**
* @Description TODO
* @Author WWW
* @Date 2021/6/9 19:24
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
SearchAllVO
{
private
String
tableName
;
List
<
OrderCondition
>
orderConditions
;
}
src/main/java/com/tykj/datawarehouse/model/service/ModelService.java
浏览文件 @
9e3ded72
...
...
@@ -5,6 +5,7 @@ import com.tykj.datawarehouse.model.entity.ColumnInfo;
import
com.tykj.datawarehouse.model.entity.TableInfo
;
import
com.tykj.datawarehouse.model.entity.vo.*
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.sql.SQLException
;
...
...
@@ -79,7 +80,7 @@ public interface ModelService {
*/
List
<
Map
<
String
,
Object
>>
findAllByName
(
String
name
)
throws
SQLException
;
List
<
Map
<
String
,
Object
>>
findAllByName
(
String
name
,
List
<
OrderCondition
>
orderConditions
)
;
/**
* 复杂查询
*
...
...
@@ -105,7 +106,7 @@ public interface ModelService {
* @param updateTableInfoVO
* @return
*/
int
updateTable
(
UpdateTableInfoVO
updateTableInfoVO
);
ResponseEntity
updateTable
(
UpdateTableInfoVO
updateTableInfoVO
);
/**
...
...
src/main/java/com/tykj/datawarehouse/model/service/impl/ModelImpl.java
浏览文件 @
9e3ded72
...
...
@@ -2,7 +2,9 @@ package com.tykj.datawarehouse.model.service.impl;
import
com.github.wenhao.jpa.PredicateBuilder
;
import
com.github.wenhao.jpa.Specifications
;
import
com.oscar.util.OSQLException
;
import
com.tykj.datawarehouse.base.result.ApiException
;
import
com.tykj.datawarehouse.base.result.ResultUtil
;
import
com.tykj.datawarehouse.model.dao.ColumnInfoDao
;
import
com.tykj.datawarehouse.model.dao.QuoteDao
;
import
com.tykj.datawarehouse.model.dao.RuleDao
;
...
...
@@ -28,10 +30,14 @@ import org.hibernate.type.*;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.core.env.Environment
;
import
org.springframework.data.domain.Page
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.sql.SQLException
;
import
java.sql.SQLNonTransientException
;
import
java.sql.SQLSyntaxErrorException
;
import
java.text.SimpleDateFormat
;
import
java.time.LocalDateTime
;
import
java.time.ZoneId
;
...
...
@@ -101,8 +107,8 @@ public class ModelImpl implements ModelService {
private
PredicateBuilder
<
TableInfo
>
createPredicateBySearchTableInfoVo
(
SearchTableInfoVo
stv
)
{
PredicateBuilder
<
TableInfo
>
and
=
Specifications
.
and
();
if
(
stv
!=
null
)
{
and
.
like
(!
isNull
(
stv
.
getModelName
()
.
toUpperCase
())
&&
isNotEmpty
(
stv
.
getModelName
().
toUpperCase
()),
"modelName"
,
"%"
+
stv
.
getModelName
().
toUpperCas
e
()
+
"%"
);
if
(
!
isNull
(
stv
)
)
{
and
.
like
(!
isNull
(
stv
.
getModelName
()
)
&&
isNotEmpty
(
stv
.
getModelName
()),
"modelName"
,
"%"
+
stv
.
getModelNam
e
()
+
"%"
);
and
.
like
(!
isNull
(
stv
.
getModelTitle
())
&&
isNotEmpty
(
stv
.
getModelTitle
()),
"modelTitle"
,
"%"
+
stv
.
getModelTitle
()
+
"%"
);
and
.
in
(!
isNull
(
stv
.
getModelType
())
&&
stv
.
getModelType
().
length
>
0
,
"modelType"
,
stv
.
getModelType
());
and
.
in
(!
isNull
(
stv
.
getIds
())
&&
stv
.
getIds
().
length
>
0
,
"id"
,
stv
.
getIds
());
...
...
@@ -164,7 +170,7 @@ public class ModelImpl implements ModelService {
,
tableInfo
.
getModelName
().
toUpperCase
()
,
tableInfo
.
getId
()
,
columnVO
.
getDescription
()
);
);
ColumnInfo
save
=
columnInfoDao
.
save
(
columnInfo
);
/***/
// List<Quote> quoteList = columnVO.getQuoteList();
...
...
@@ -278,6 +284,7 @@ public class ModelImpl implements ModelService {
//验证
validationAllRuleAndQuote
(
tableInfo
,
value
,
propertyType
,
propertyNames
[
i
]);
}
session
.
saveOrUpdate
(
tableName
,
map
);
}
...
...
@@ -314,6 +321,24 @@ public class ModelImpl implements ModelService {
}
return
new
ArrayList
<>();
}
@Override
public
List
<
Map
<
String
,
Object
>>
findAllByName
(
String
name
,
List
<
OrderCondition
>
orderConditions
)
{
StringBuilder
sb
=
new
StringBuilder
();
if
(
StringUtils
.
isNotEmpty
(
name
))
{
if
(
orderConditions
.
size
()
>
0
)
{
for
(
OrderCondition
orderCondition
:
orderConditions
)
{
sb
.
append
(
orderCondition
.
getColumns
()
+
" "
+
orderCondition
.
getSortValue
()
+
" ,"
);
}
}
String
sql
=
sb
.
substring
(
0
,
sb
.
toString
().
lastIndexOf
(
","
));
try
{
return
jdbcTemplate
.
queryForList
(
"select * from "
+
name
+
" order by "
+
sql
);
}
catch
(
Exception
e
){
throw
new
ApiException
(
"操作数据库失败,请联系管理员"
);
}
}
return
new
ArrayList
<>();
}
@Override
public
CustomPage
complexQueryWithGroup
(
String
tableName
,
GroupCondition
groupCondition
,
List
<
String
>
columnNames
,
List
<
QueryCondition
>
queryConditions
,
String
groupByColumn
,
Integer
page
,
Integer
size
)
{
...
...
@@ -358,7 +383,7 @@ public class ModelImpl implements ModelService {
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
int
updateTable
(
UpdateTableInfoVO
updateTableInfoVO
)
{
public
ResponseEntity
updateTable
(
UpdateTableInfoVO
updateTableInfoVO
)
{
//tableInfo和columnInfo变化
//查询到TableInfo和ColumnInfo
TableVO
tableVO
=
updateTableInfoVO
.
getTableVO
();
...
...
@@ -372,8 +397,6 @@ public class ModelImpl implements ModelService {
tableInfo
.
setDescription
(
tableVO
.
getDescription
());
tableInfo
.
setModelTitle
(
tableVO
.
getModelTitle
());
String
xml
=
createTable
(
tableVO
);
tableInfo
.
setXml
(
xml
);
List
<
ColumnInfo
>
originalColumnInfos
=
columnInfoDao
.
findAllByDbId
(
dbId
);
//新的字段信息
...
...
@@ -387,8 +410,19 @@ public class ModelImpl implements ModelService {
for
(
String
sql
:
sqls
)
{
try
{
jdbcTemplate
.
execute
(
sql
);
}
catch
(
Exception
e
)
{
throw
new
ApiException
(
"sql执行错误"
+
e
.
getMessage
());
}
catch
(
Exception
exception
)
{
//todo
throw
new
ApiException
(
"出错"
);
// if (exception instanceof OSQLException) {
// String error = exception.getMessage();
// error.substring(error.lastIndexOf(":"));
// return ResultUtil.failed("已有数据类型不能转换"+error);
// }
// if (exception instanceof SQLSyntaxErrorException) {
// return ResultUtil.failed("sql语法错误"+ exception.getMessage());
// }
}
}
...
...
@@ -407,10 +441,12 @@ public class ModelImpl implements ModelService {
columnInfoDao
.
delete
(
originColumnInfo
);
}
String
xml
=
createTable
(
tableVO
);
tableInfo
.
setXml
(
xml
);
tableInfoDao
.
save
(
tableInfo
);
sessionUtil
.
addXml
(
xml
);
return
1
;
return
ResultUtil
.
success
(
"修改成功!"
)
;
}
...
...
src/main/java/com/tykj/datawarehouse/model/sqlType/MysqlSqlType.java
浏览文件 @
9e3ded72
...
...
@@ -3,6 +3,9 @@ package com.tykj.datawarehouse.model.sqlType;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author HASEE
*/
public
class
MysqlSqlType
{
/**
...
...
src/main/java/com/tykj/datawarehouse/model/sqlType/OscarSqlType.java
浏览文件 @
9e3ded72
...
...
@@ -3,6 +3,9 @@ package com.tykj.datawarehouse.model.sqlType;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* @author HASEE
*/
public
class
OscarSqlType
{
/**
...
...
@@ -20,7 +23,7 @@ public class OscarSqlType {
TYPE_MAP
.
put
(
"java.lang.Character"
,
"char(1)"
);
TYPE_MAP
.
put
(
"java.lang.String"
,
"varchar"
);
TYPE_MAP
.
put
(
"java.lang.Byte"
,
"tinyint"
);
TYPE_MAP
.
put
(
"java.lang.Boolean"
,
"
number(1)
"
);
TYPE_MAP
.
put
(
"java.lang.Boolean"
,
"
BOOL
"
);
TYPE_MAP
.
put
(
"java.lang.Class"
,
"varchar"
);
TYPE_MAP
.
put
(
"java.util.Date"
,
"date"
);
TYPE_MAP
.
put
(
"java.util.Calendar"
,
"timestamp"
);
...
...
src/main/java/com/tykj/datawarehouse/model/utils/SessionUtil.java
浏览文件 @
9e3ded72
...
...
@@ -84,7 +84,7 @@ public class SessionUtil {
}
public
void
deleteTableInMeteData
(
String
tableName
){
Integer
needDelete
=
-
1
;
int
needDelete
=
-
1
;
List
<
Binding
>
xmlBindings
=
metadataSources
.
getXmlBindings
();
for
(
int
i
=
0
;
i
<
xmlBindings
.
size
();
i
++)
{
Object
root
=
xmlBindings
.
get
(
i
).
getRoot
();
...
...
@@ -103,6 +103,7 @@ public class SessionUtil {
if
(
needDelete
>-
1
){
xmlBindings
.
remove
(
needDelete
);
}
System
.
out
.
println
(
"1"
);
}
}
src/main/java/com/tykj/datawarehouse/model/utils/SqlTypeUtil.java
浏览文件 @
9e3ded72
...
...
@@ -6,6 +6,9 @@ import com.tykj.datawarehouse.model.sqlType.OscarSqlType;
import
java.util.Map
;
/**
* @author HASEE
*/
public
class
SqlTypeUtil
{
public
static
Map
<
String
,
String
>
getSqlTypeMap
(
String
driveName
){
...
...
src/test/java/com/tykj/datawarehouse/DataTestApplicationTests.java
浏览文件 @
9e3ded72
package
com
.
tykj
.
datawarehouse
;
import
com.oscar.util.OSQLException
;
import
com.tykj.datawarehouse.model.dao.RuleDao
;
import
org.assertj.core.util.Lists
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.context.SpringBootTest
;
...
...
@@ -22,9 +24,11 @@ class DataTestApplicationTests {
// boolean matches = pattern.matcher(str).matches();
//
// System.out.println(matches);
System
.
out
.
println
(
ruleDao
.
findAllByColumnId
(
71
));
// System.out.println(ruleDao.findAllByColumnId(71));
String
error
=
"StatementCallback; SQL [ALTER TABLE TB1 MODIFY HAP DOUBLE PRECISION ;]; ERROR, Bad float8 input format 'q1 '\n"
+
"; nested exception is com.oscar.util.: ERROR, Bad float8 input format 'q1 '"
;
System
.
out
.
println
(
error
.
substring
(
error
.
lastIndexOf
(
":"
)));
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论