Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nnjcy-data-model
Overview
Overview
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ljb
nnjcy-data-model
Commits
2296a378
Commit
2296a378
authored
Sep 06, 2023
by
ljb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善数据汇聚
parent
353d8ce0
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
685 additions
and
43 deletions
+685
-43
dataoperation-server/src/main/java/com/zq/dataoperation/controller/DataCollectController.java
+25
-25
dataoperation-server/src/main/java/com/zq/dataoperation/controller/DataCollectLogController.java
+9
-9
dataoperation-server/src/main/java/com/zq/dataoperation/dao/DataCollectSettingApiDao.java
+8
-0
dataoperation-server/src/main/java/com/zq/dataoperation/dao/DataCollectSettingApiParaDao.java
+8
-0
dataoperation-server/src/main/java/com/zq/dataoperation/dao/DataCollectSettingDbDao.java
+9
-0
dataoperation-server/src/main/java/com/zq/dataoperation/dao/DataCollectSettingFileDao.java
+8
-0
dataoperation-server/src/main/java/com/zq/dataoperation/dao/DataCollectSettingSiteDao.java
+8
-0
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSetting.java
+1
-1
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSettingApi.java
+76
-0
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSettingApiPara.java
+51
-0
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSettingDb.java
+76
-0
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSettingFile.java
+56
-0
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSettingSite.java
+56
-0
dataoperation-server/src/main/java/com/zq/dataoperation/service/DataCollectLogService.java
+38
-2
dataoperation-server/src/main/java/com/zq/dataoperation/service/DataCollectService.java
+141
-6
dataoperation-server/src/main/java/com/zq/dataoperation/vo/DataCollectLogReq.java
+1
-0
dataoperation-server/src/main/java/com/zq/dataoperation/vo/DataCollectSettingAddReq.java
+18
-0
dataoperation-server/src/main/java/com/zq/dataoperation/vo/DataCollectSettingApiAddReq.java
+21
-0
dataoperation-server/src/main/java/com/zq/dataoperation/vo/DataCollectSettingResp.java
+15
-0
dataoperation-server/src/main/java/com/zq/dataoperation/vo/DataCollectTaskLogResp.java
+60
-0
No files found.
dataoperation-server/src/main/java/com/zq/dataoperation/controller/DataCollectController.java
View file @
2296a378
package
com
.
zq
.
dataoperation
.
controller
;
import
cn.hutool.core.util.StrUtil
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.vo.ResultVo
;
//import com.zq.dataoperation.service.DataCleanService;
import
com.zq.dataoperation.entity.DataCollectSetting
;
import
com.zq.dataoperation.service.DataCollectService
;
import
com.zq.dataoperation.vo.DataCollectReq
;
import
com.zq.dataoperation.vo.DataCollectSettingAddReq
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.RequiredArgsConstructor
;
...
...
@@ -26,45 +26,44 @@ public class DataCollectController {
@Resource
private
DataCollectService
dataCollectService
;
@ApiOperation
(
"获取数据汇聚任务列表"
)
@
GetMapping
(
value
=
"/getAll
"
)
public
ResultVo
get
DataCollectList
(
)
{
return
ResultVo
.
success
(
dataCollectService
.
list
(
));
@ApiOperation
(
"
分页
获取数据汇聚任务列表"
)
@
PostMapping
(
value
=
"/list
"
)
public
ResultVo
get
List
(
@RequestBody
DataCollectReq
req
)
{
return
ResultVo
.
success
(
dataCollectService
.
getList
(
req
));
}
@ApiOperation
(
"根据ID获取数据汇聚任务"
)
@GetMapping
(
value
=
"/get
ById
"
)
public
ResultVo
selectById
(
@RequestParam
Long
id
)
{
return
ResultVo
.
success
(
dataCollectService
.
get
ById
(
id
));
@GetMapping
(
value
=
"/get
/{id}
"
)
public
ResultVo
get
(
@PathVariable
Integer
id
)
{
return
ResultVo
.
success
(
dataCollectService
.
get
(
id
));
}
@ApiOperation
(
"分页获取数据汇聚任务"
)
@PostMapping
(
value
=
"/getPageDataCollect"
)
public
ResultVo
getDataCollectDetails
(
@RequestBody
DataCollectReq
req
)
{
return
ResultVo
.
success
(
dataCollectService
.
getPageDataCollect
(
req
));
@ApiOperation
(
"新增数据汇聚设置"
)
@PostMapping
(
value
=
"/add"
)
public
ResultVo
add
(
@RequestBody
DataCollectSettingAddReq
dataCollectSettingAddReq
)
{
dataCollectService
.
add
(
dataCollectSettingAddReq
);
return
ResultVo
.
success
(
"添加成功"
);
}
@ApiOperation
(
"
新增或
修改数据汇聚设置"
)
@P
os
tMapping
(
value
=
"/update"
)
public
ResultVo
selectDataCleanList
(
@RequestBody
DataCollectSetting
dataCollectSetting
)
{
boolean
b
=
dataCollectService
.
saveOrUpdate
(
dataCollectSetting
);
AssertUtils
.
isTrue
(
b
,
"操作失败"
);
return
ResultVo
.
success
(
"
操作
成功"
);
@ApiOperation
(
"修改数据汇聚设置"
)
@P
u
tMapping
(
value
=
"/update"
)
public
ResultVo
update
(
@RequestBody
DataCollectSettingAddReq
dataCollectSettingAddReq
)
{
AssertUtils
.
notNull
(
dataCollectSettingAddReq
.
getId
(),
"修改失败,id不能为空"
);
dataCollectService
.
update
(
dataCollectSettingAddReq
);
return
ResultVo
.
success
(
"
修改
成功"
);
}
@ApiOperation
(
"删除数据汇聚设置"
)
@DeleteMapping
(
value
=
"/delete/{id}"
)
public
ResultVo
delete
(
@PathVariable
Integer
id
)
{
boolean
b
=
dataCollectService
.
removeById
(
id
);
AssertUtils
.
isTrue
(
b
,
"操作失败"
);
return
ResultVo
.
success
(
"操作成功"
);
dataCollectService
.
delete
(
id
);
return
ResultVo
.
success
(
"删除成功"
);
}
@ApiOperation
(
"批量删除数据汇聚设置"
)
@DeleteMapping
(
value
=
"/batchDelete"
)
public
ResultVo
batchDelete
(
@RequestBody
List
<
Long
>
ids
)
{
boolean
b
=
dataCollectService
.
removeByIds
(
ids
);
AssertUtils
.
isTrue
(
b
,
"操作失败"
);
public
ResultVo
batchDelete
(
@RequestBody
List
<
Integer
>
ids
)
{
dataCollectService
.
batchDelete
(
ids
);
return
ResultVo
.
success
(
"操作成功"
);
}
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/controller/DataCollectLogController.java
View file @
2296a378
...
...
@@ -20,16 +20,16 @@ public class DataCollectLogController {
@Resource
private
DataCollectLogService
dataCollectLogService
;
@ApiOperation
(
"获取数据汇聚日志列表"
)
@GetMapping
(
value
=
"/getAll"
)
public
ResultVo
getDataCollectList
()
{
return
ResultVo
.
success
(
dataCollectLogService
.
list
());
}
//
@ApiOperation("获取数据汇聚日志列表")
//
@GetMapping(value = "/getAll")
//
public ResultVo getDataCollectList() {
//
return ResultVo.success(dataCollectLogService.list());
//
}
@ApiOperation
(
"分页获取数据汇聚日志"
)
@PostMapping
(
value
=
"/
getPageDataCollectLog
"
)
@PostMapping
(
value
=
"/
page
"
)
public
ResultVo
getDataCollectDetails
(
@RequestBody
DataCollectLogReq
req
)
{
return
ResultVo
.
success
(
dataCollectLogService
.
getPageDataCollectLog
(
req
));
return
ResultVo
.
success
(
dataCollectLogService
.
page
(
req
));
}
@ApiOperation
(
"删除数据汇聚日志"
)
...
...
@@ -47,5 +47,4 @@ public class DataCollectLogController {
AssertUtils
.
isTrue
(
b
,
"操作失败"
);
return
ResultVo
.
success
(
"操作成功"
);
}
}
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/dao/DataCollectSettingApiDao.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.zq.dataoperation.entity.DataCollectSettingApi
;
public
interface
DataCollectSettingApiDao
extends
BaseMapper
<
DataCollectSettingApi
>
{
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/dao/DataCollectSettingApiParaDao.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.zq.dataoperation.entity.DataCollectSettingApiPara
;
public
interface
DataCollectSettingApiParaDao
extends
BaseMapper
<
DataCollectSettingApiPara
>
{
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/dao/DataCollectSettingDbDao.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.zq.dataoperation.entity.DataCollectSettingDb
;
import
com.zq.dataoperation.entity.QueryDb
;
public
interface
DataCollectSettingDbDao
extends
BaseMapper
<
DataCollectSettingDb
>
{
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/dao/DataCollectSettingFileDao.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.zq.dataoperation.entity.DataCollectSettingFile
;
public
interface
DataCollectSettingFileDao
extends
BaseMapper
<
DataCollectSettingFile
>
{
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/dao/DataCollectSettingSiteDao.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.zq.dataoperation.entity.DataCollectSettingSite
;
public
interface
DataCollectSettingSiteDao
extends
BaseMapper
<
DataCollectSettingSite
>
{
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSetting.java
View file @
2296a378
...
...
@@ -53,7 +53,7 @@ public class DataCollectSetting {
* id
*/
@TableId
(
type
=
IdType
.
AUTO
)
private
Long
id
;
private
Integer
id
;
/**
* 执行计划的corn表达式
...
...
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSettingApi.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
entity
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.Date
;
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
DataCollectSettingApi
{
/**
* id
*/
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
/**
* 数据汇聚id
*/
private
Integer
dataCollectSettingId
;
/**
* Api接口名称
*/
private
String
apiName
;
/**
* api接口URL
*/
private
String
apiUrl
;
/**
* 数据请求方式
*/
private
Integer
requestType
;
/**
* 汇聚任务的名称
*/
private
String
taskName
;
/**
* 请求头参数
*/
private
String
heads
;
/**
* 请求体格式
*/
private
String
body
;
/**
* 下次导入的标记
*/
private
String
nextImportFlag
;
/**
* createTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
/**
* updateTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
private
Date
updateTime
;
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSettingApiPara.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
entity
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.Date
;
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
DataCollectSettingApiPara
{
/**
* id
*/
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
/**
* id
*/
private
Integer
dataCollectSettingApiId
;
/**
* 参数名称
*/
private
String
keyName
;
/**
* 参数值
*/
private
String
keyValue
;
/**
* createTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
/**
* updateTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
private
Date
updateTime
;
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSettingDb.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
entity
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.Date
;
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
DataCollectSettingDb
{
/**
* id
*/
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
/**
* 数据汇聚id
*/
private
Integer
dataCollectSettingId
;
/**
* 数据库名称
*/
private
String
dbName
;
/**
* 数据库ip
*/
private
String
dbIp
;
/**
* 数据库端口
*/
private
Integer
dbPort
;
/**
* 数据库用户名
*/
private
String
username
;
/**
* 数据库密码
*/
private
String
password
;
/**
* 数据库类型(1.Mysql 2.oracle 3.MSSQL )
*/
private
Integer
dbType
;
/**
* 下次导入的标记
*/
private
String
nextImportFlag
;
/**
* createTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
/**
* updateTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
private
Date
updateTime
;
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSettingFile.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
entity
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.Date
;
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
DataCollectSettingFile
{
/**
* id
*/
@TableId
(
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* 数据汇聚id
*/
private
Integer
dataCollectSettingId
;
/**
* 文件存储目录
*/
private
String
fileFolder
;
/**
* 是否需要OCR(0否1是)
*/
private
Integer
ifOcr
;
/**
* 是否导入数据库表(0否1是)
*/
private
Integer
ifToDatabase
;
/**
* createTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
/**
* updateTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
private
Date
updateTime
;;
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/entity/DataCollectSettingSite.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
entity
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.Date
;
@Data
@AllArgsConstructor
@NoArgsConstructor
public
class
DataCollectSettingSite
{
/**
* id
*/
@TableId
(
type
=
IdType
.
AUTO
)
private
Long
id
;
/**
* 数据汇聚id
*/
private
Integer
dataCollectSettingId
;
/**
* 网站名称
*/
private
String
siteName
;
/**
* 网站URL
*/
private
String
siteUrl
;
/**
* 对应的spider_flow定制流程的id
*/
private
String
spiderFlowId
;
/**
* createTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
/**
* updateTime
*/
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
private
Date
updateTime
;
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/service/DataCollectLogService.java
View file @
2296a378
package
com
.
zq
.
dataoperation
.
service
;
import
cn.hutool.core.bean.BeanUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.zq.common.utils.PagingUtils
;
import
com.zq.common.vo.PageVo
;
import
com.zq.dataoperation.dao.DataCollectTaskLogDao
;
import
com.zq.dataoperation.entity.DataCollectSetting
;
import
com.zq.dataoperation.entity.DataCollectTaskLog
;
import
com.zq.dataoperation.vo.DataCollectLogReq
;
import
com.zq.dataoperation.vo.DataCollectTaskLogResp
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
@Service
public
class
DataCollectLogService
extends
ServiceImpl
<
DataCollectTaskLogDao
,
DataCollectTaskLog
>
{
...
...
@@ -18,8 +23,38 @@ public class DataCollectLogService extends ServiceImpl<DataCollectTaskLogDao, Da
@Resource
DataCollectTaskLogDao
dataCollectTaskLogDao
;
public
PageVo
<
DataCollectTaskLog
>
getPageDataCollectLog
(
DataCollectLogReq
req
)
{
@Resource
private
DataCollectService
dataCollectService
;
public
PageVo
getPageDataCollectLog
(
DataCollectLogReq
req
)
{
LambdaQueryWrapper
<
DataCollectTaskLog
>
wrapper
=
new
LambdaQueryWrapper
<>();
PageVo
pageVo
=
PagingUtils
.
paging
(
req
,
dataCollectTaskLogDao
,
DataCollectTaskLog
.
class
,
wrapper
);
List
<
DataCollectTaskLogResp
>
taskLogRespList
=
new
ArrayList
<>(
pageVo
.
getRows
().
size
());
for
(
Object
row
:
pageVo
.
getRows
())
{
DataCollectTaskLog
dataCollectTaskLog
=
(
DataCollectTaskLog
)
row
;
DataCollectTaskLogResp
resp
=
new
DataCollectTaskLogResp
();
DataCollectSetting
dataCollectSetting
=
dataCollectService
.
getById
(
dataCollectTaskLog
.
getDataCollectSettingId
());
resp
.
setTaskName
(
dataCollectSetting
.
getTaskName
());
BeanUtil
.
copyProperties
(
dataCollectTaskLog
,
resp
);
taskLogRespList
.
add
(
resp
);
}
pageVo
.
setRows
(
taskLogRespList
);
return
pageVo
;
}
public
PageVo
page
(
DataCollectLogReq
req
)
{
LambdaQueryWrapper
<
DataCollectTaskLog
>
wrapper
=
new
LambdaQueryWrapper
<>();
return
PagingUtils
.
paging
(
req
,
dataCollectTaskLogDao
,
DataCollectTaskLog
.
class
,
wrapper
);
PageVo
pageVo
=
PagingUtils
.
paging
(
req
,
dataCollectTaskLogDao
,
DataCollectTaskLog
.
class
,
wrapper
);
List
<
DataCollectTaskLogResp
>
taskLogRespList
=
new
ArrayList
<>(
pageVo
.
getRows
().
size
());
for
(
Object
row
:
pageVo
.
getRows
())
{
DataCollectTaskLog
dataCollectTaskLog
=
(
DataCollectTaskLog
)
row
;
DataCollectTaskLogResp
resp
=
new
DataCollectTaskLogResp
();
DataCollectSetting
dataCollectSetting
=
dataCollectService
.
getById
(
dataCollectTaskLog
.
getDataCollectSettingId
());
resp
.
setTaskName
(
dataCollectSetting
.
getTaskName
());
BeanUtil
.
copyProperties
(
dataCollectTaskLog
,
resp
);
taskLogRespList
.
add
(
resp
);
}
pageVo
.
setRows
(
taskLogRespList
);
return
pageVo
;
}
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/service/DataCollectService.java
View file @
2296a378
package
com
.
zq
.
dataoperation
.
service
;
import
cn.hutool.core.bean.BeanUtil
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.zq.common.exception.BusinessException
;
import
com.zq.common.utils.AssertUtils
;
import
com.zq.common.utils.PagingUtils
;
import
com.zq.common.vo.PageVo
;
import
com.zq.dataoperation.dao.
DataCollectDao
;
import
com.zq.dataoperation.entity.
DataCollectSetting
;
import
com.zq.dataoperation.dao.
*
;
import
com.zq.dataoperation.entity.
*
;
import
com.zq.dataoperation.vo.DataCollectReq
;
import
com.zq.dataoperation.vo.DataCollectSettingAddReq
;
import
com.zq.dataoperation.vo.DataCollectSettingApiAddReq
;
import
com.zq.dataoperation.vo.DataCollectSettingResp
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
@Slf4j
@RequiredArgsConstructor
...
...
@@ -21,13 +36,132 @@ public class DataCollectService extends ServiceImpl<DataCollectDao, DataCollectS
@Resource
private
DataCollectDao
dataCollectDao
;
public
PageVo
<
DataCollectSetting
>
getPageDataCollect
(
DataCollectReq
req
)
{
LambdaQueryWrapper
<
DataCollectSetting
>
wrapper
=
new
LambdaQueryWrapper
<>();
return
PagingUtils
.
paging
(
req
,
dataCollectDao
,
DataCollectSetting
.
class
,
wrapper
);
@Resource
private
DataCollectSettingDbDao
dataCollectSettingDbDao
;
@Resource
private
DataCollectSettingFileDao
dataCollectSettingFileDao
;
@Resource
private
DataCollectSettingApiDao
dataCollectSettingApiDao
;
@Resource
private
DataCollectSettingSiteDao
dataCollectSettingSiteDao
;
@Resource
private
DataCollectSettingApiParaDao
dataCollectSettingApiParaDao
;
public
PageVo
<
DataCollectSetting
>
getList
(
DataCollectReq
req
)
{
return
PagingUtils
.
paging
(
req
,
dataCollectDao
,
DataCollectSetting
.
class
,
new
LambdaQueryWrapper
<>());
}
public
DataCollectSettingResp
get
(
Integer
id
){
DataCollectSetting
dataCollectSetting
=
getById
(
id
);
DataCollectSettingResp
resp
=
new
DataCollectSettingResp
();
BeanUtil
.
copyProperties
(
dataCollectSetting
,
resp
);
if
(
dataCollectSetting
.
getDataType
()
!=
3
){
QueryWrapper
wrapper
=
new
QueryWrapper
();
wrapper
.
eq
(
"data_collect_setting_id"
,
resp
.
getId
());
List
list
=
getDao
(
dataCollectSetting
.
getDataType
()).
selectList
(
wrapper
);
resp
.
setDataFromSetting
(
list
);
}
else
{
List
<
DataCollectSettingApi
>
apis
=
dataCollectSettingApiDao
.
selectList
(
new
LambdaQueryWrapper
<
DataCollectSettingApi
>().
eq
(
DataCollectSettingApi:
:
getDataCollectSettingId
,
dataCollectSetting
.
getId
()));
List
<
DataCollectSettingApiAddReq
>
vos
=
BeanUtil
.
copyToList
(
apis
,
DataCollectSettingApiAddReq
.
class
);
for
(
DataCollectSettingApiAddReq
vo
:
vos
)
{
List
<
DataCollectSettingApiPara
>
apiParas
=
dataCollectSettingApiParaDao
.
selectList
(
new
LambdaQueryWrapper
<
DataCollectSettingApiPara
>().
eq
(
DataCollectSettingApiPara:
:
getDataCollectSettingApiId
,
vo
.
getId
()));
vo
.
setApiParas
(
apiParas
);
}
resp
.
setDataFromSetting
(
vos
);
}
return
resp
;
}
public
void
getAll
(
String
month
,
String
tableName
){
@Transactional
public
void
add
(
DataCollectSettingAddReq
dataCollectSettingAddReq
){
boolean
b
=
save
(
dataCollectSettingAddReq
);
AssertUtils
.
isTrue
(
b
,
"添加失败"
);
if
(
dataCollectSettingAddReq
.
getDataType
()
!=
3
){
HashMap
<
String
,
Object
>
map
=
new
HashMap
();
BeanUtil
.
copyProperties
(
dataCollectSettingAddReq
.
getDataFromSetting
(),
map
);
map
.
put
(
"dataCollectSettingId"
,
dataCollectSettingAddReq
.
getId
());
AssertUtils
.
isTrue
(
getDao
(
dataCollectSettingAddReq
.
getDataType
()).
insert
(
map
)==
1
,
"添加失败"
);
}
else
{
DataCollectSettingApiAddReq
apiAddReq
=
new
DataCollectSettingApiAddReq
();
BeanUtil
.
copyProperties
(
dataCollectSettingAddReq
.
getDataFromSetting
(),
apiAddReq
);
apiAddReq
.
setDataCollectSettingId
(
dataCollectSettingAddReq
.
getId
());
AssertUtils
.
isTrue
(
dataCollectSettingApiDao
.
insert
(
apiAddReq
)==
1
,
"添加失败"
);
for
(
DataCollectSettingApiPara
apiPara
:
apiAddReq
.
getApiParas
())
{
apiPara
.
setDataCollectSettingApiId
(
apiAddReq
.
getId
());
AssertUtils
.
isTrue
(
dataCollectSettingApiParaDao
.
insert
(
apiPara
)==
1
,
"添加失败"
);
}
}
}
@Transactional
public
void
update
(
DataCollectSettingAddReq
dataCollectSettingAddReq
){
DataCollectSetting
dataCollectSetting
=
getById
(
dataCollectSettingAddReq
.
getId
());
AssertUtils
.
isTrue
(
dataCollectSetting
.
getDataType
()==
dataCollectSettingAddReq
.
getDataType
(),
"修改失败,数据来源不允许修改"
);
Object
dataFromSetting
=
dataCollectSettingAddReq
.
getDataFromSetting
();
if
(
null
!=
dataFromSetting
){
UpdateWrapper
wrapper
=
new
UpdateWrapper
();
wrapper
.
eq
(
"data_collect_setting_id"
,
dataCollectSetting
.
getId
());
getDao
(
dataCollectSetting
.
getDataType
()).
update
(
dataFromSetting
,
wrapper
);
}
AssertUtils
.
isTrue
(
updateById
(
dataCollectSettingAddReq
),
"修改失败"
);
}
@Transactional
public
void
delete
(
Integer
id
){
DataCollectSetting
dataCollectSetting
=
getById
(
id
);
UpdateWrapper
wrapper
=
new
UpdateWrapper
();
wrapper
.
eq
(
"data_collect_setting_id"
,
dataCollectSetting
.
getId
());
getDao
(
dataCollectSetting
.
getDataType
()).
delete
(
wrapper
);
AssertUtils
.
isTrue
(
removeById
(
id
),
"删除失败"
);
}
public
void
batchDelete
(
List
<
Integer
>
ids
){
for
(
Integer
id
:
ids
)
{
delete
(
id
);
}
}
public
BaseMapper
getDao
(
int
dataType
){
switch
(
dataType
)
{
case
1
:
return
dataCollectSettingDbDao
;
case
2
:
return
dataCollectSettingFileDao
;
case
3
:
return
dataCollectSettingApiDao
;
case
4
:
return
dataCollectSettingSiteDao
;
default
:
throw
new
BusinessException
(
"不支持的类型"
);
}
}
public
Object
getObj
(
int
dataType
){
switch
(
dataType
)
{
case
1
:
return
new
DataCollectSettingDb
();
case
2
:
return
new
DataCollectSettingFile
();
case
3
:
return
new
DataCollectSettingApi
();
case
4
:
return
new
DataCollectSettingSite
();
default
:
throw
new
BusinessException
(
"不支持的类型"
);
}
}
public
<
T
>
List
<
T
>
objToList
(
Object
obj
,
Class
<
T
>
clazz
){
List
<
T
>
list
=
new
ArrayList
<>();
if
(
obj
instanceof
List
<?>){
for
(
Object
o
:
(
List
<?>)
obj
)
{
list
.
add
(
clazz
.
cast
(
o
));
}
}
return
list
;
}
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/vo/DataCollectLogReq.java
View file @
2296a378
...
...
@@ -16,6 +16,7 @@ import java.util.Date;
@NoArgsConstructor
@AllArgsConstructor
public
class
DataCollectLogReq
extends
PageReqVo
{
/**
* 数据汇聚表id
*/
...
...
dataoperation-server/src/main/java/com/zq/dataoperation/vo/DataCollectSettingAddReq.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
vo
;
import
com.zq.dataoperation.entity.DataCollectSetting
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
DataCollectSettingAddReq
extends
DataCollectSetting
{
/**
* 数据来源设置
*/
private
Object
dataFromSetting
;
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/vo/DataCollectSettingApiAddReq.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
vo
;
import
com.zq.dataoperation.entity.DataCollectSettingApi
;
import
com.zq.dataoperation.entity.DataCollectSettingApiPara
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.List
;
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
DataCollectSettingApiAddReq
extends
DataCollectSettingApi
{
/**
* api参数
*/
private
List
<
DataCollectSettingApiPara
>
apiParas
;
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/vo/DataCollectSettingResp.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
vo
;
import
com.zq.dataoperation.entity.DataCollectSetting
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
DataCollectSettingResp
extends
DataCollectSetting
{
private
Object
dataFromSetting
;
}
\ No newline at end of file
dataoperation-server/src/main/java/com/zq/dataoperation/vo/DataCollectTaskLogResp.java
0 → 100644
View file @
2296a378
package
com
.
zq
.
dataoperation
.
vo
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.util.Date
;
@Data
@NoArgsConstructor
@AllArgsConstructor
public
class
DataCollectTaskLogResp
{
/**
* 使用序列
* id
*/
private
Long
id
;
/**
* 数据汇聚表id
*/
private
Integer
dataCollectSettingId
;
/**
* 数据汇聚任务名称
*/
private
String
taskName
;
/**
* 开始时间
*/
private
Date
startTime
;
/**
* 结束时间
*/
private
Date
endTime
;
/**
* 花费多少秒
*/
private
Integer
duration
;
/**
* 状态
* 1运行中 2正常结束 3异常终止
*/
private
Integer
status
;
/**
* 错误信息
* 异常终止时记录异常信息
*/
private
String
error
;
}
\ 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