Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
datacollector
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenweisong
datacollector
Commits
be1b3b48
Commit
be1b3b48
authored
Apr 21, 2020
by
chenweisong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
b0b6a290
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
201 additions
and
14 deletions
+201
-14
SimplePage.java
src/main/java/com/keymobile/rest/common/bean/SimplePage.java
+13
-0
DataFileUtil.java
...in/java/com/keymobile/rest/common/utils/DataFileUtil.java
+32
-0
TaskController.java
...in/java/com/keymobile/rest/controller/TaskController.java
+31
-6
TemplateController.java
...ava/com/keymobile/rest/controller/TemplateController.java
+22
-7
FilePathDao.java
src/main/java/com/keymobile/rest/dao/FilePathDao.java
+10
-0
ProcessDao.java
src/main/java/com/keymobile/rest/dao/ProcessDao.java
+5
-1
FilePath.java
src/main/java/com/keymobile/rest/model/FilePath.java
+23
-0
FilePathService.java
...main/java/com/keymobile/rest/service/FilePathService.java
+30
-0
ProcessService.java
src/main/java/com/keymobile/rest/service/ProcessService.java
+35
-0
No files found.
src/main/java/com/keymobile/rest/common/bean/SimplePage.java
View file @
be1b3b48
...
@@ -26,4 +26,17 @@ public class SimplePage<T> {
...
@@ -26,4 +26,17 @@ public class SimplePage<T> {
.
totalPages
(
page
.
getTotalPages
())
.
totalPages
(
page
.
getTotalPages
())
.
build
();
.
build
();
}
}
public
static
<
T
>
SimplePage
of
(
Page
<
T
>
page
,
List
list
)
{
return
SimplePage
.
builder
()
.
content
((
List
<
Object
>)
list
)
.
pageNumber
(
page
.
getPageable
().
getPageNumber
())
.
pageSize
(
page
.
getPageable
().
getPageSize
())
.
totalElements
(
page
.
getTotalElements
())
.
totalPages
(
page
.
getTotalPages
())
.
build
();
}
}
}
src/main/java/com/keymobile/rest/common/utils/DataFileUtil.java
View file @
be1b3b48
...
@@ -54,6 +54,38 @@ public class DataFileUtil {
...
@@ -54,6 +54,38 @@ public class DataFileUtil {
}
}
}
}
public
static
Object
convertDatToJson
(
String
path
,
int
dataAt
)
{
List
ArrList
=
new
ArrayList
();
//读取文件
BufferedReader
br
=
null
;
StringBuffer
sb
=
null
;
try
{
br
=
new
BufferedReader
(
new
InputStreamReader
(
new
FileInputStream
(
new
File
(
path
)),
"utf-8"
));
//这里可以控制编码
sb
=
new
StringBuffer
();
String
line
=
null
;
int
count
=
0
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
count
++;
if
(
count
<
dataAt
)
{
continue
;
}
sb
.
append
(
line
);
// 一行的所有数据
String
[]
lineData
=
line
.
toString
().
split
(
"\\s+"
);
ArrList
.
add
(
lineData
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
try
{
br
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
JSONObject
.
toJSON
(
ArrList
);
}
public
static
Object
convertDatToJson
(
MultipartFile
file
,
int
dataAt
)
{
public
static
Object
convertDatToJson
(
MultipartFile
file
,
int
dataAt
)
{
List
ArrList
=
new
ArrayList
();
List
ArrList
=
new
ArrayList
();
//读取文件
//读取文件
...
...
src/main/java/com/keymobile/rest/controller/TaskController.java
View file @
be1b3b48
...
@@ -16,6 +16,7 @@ import com.keymobile.rest.vo.Mission;
...
@@ -16,6 +16,7 @@ import com.keymobile.rest.vo.Mission;
import
com.keymobile.rest.vo.SimpleTask
;
import
com.keymobile.rest.vo.SimpleTask
;
import
io.swagger.annotations.*
;
import
io.swagger.annotations.*
;
import
org.activiti.engine.*
;
import
org.activiti.engine.*
;
import
org.activiti.engine.history.HistoricActivityInstance
;
import
org.activiti.engine.repository.Deployment
;
import
org.activiti.engine.repository.Deployment
;
import
org.activiti.engine.repository.ProcessDefinition
;
import
org.activiti.engine.repository.ProcessDefinition
;
import
org.activiti.engine.runtime.ProcessInstance
;
import
org.activiti.engine.runtime.ProcessInstance
;
...
@@ -60,6 +61,8 @@ public class TaskController {
...
@@ -60,6 +61,8 @@ public class TaskController {
private
RuntimeService
runtimeService
;
private
RuntimeService
runtimeService
;
@Autowired
@Autowired
private
TaskService
taskService
;
private
TaskService
taskService
;
@Autowired
private
HistoryService
historyService
;
@ApiOperation
(
value
=
"获取首页活动列表"
)
@ApiOperation
(
value
=
"获取首页活动列表"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
...
@@ -327,13 +330,35 @@ public class TaskController {
...
@@ -327,13 +330,35 @@ public class TaskController {
@ApiOperation
(
value
=
"进度列表"
)
@ApiOperation
(
value
=
"进度列表"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前页"
,
paramType
=
"query"
,
required
=
true
,
dataType
=
"int"
,
defaultValue
=
"1"
),
@ApiImplicitParam
(
name
=
"pageNo"
,
value
=
"当前页"
,
paramType
=
"query"
,
required
=
true
,
dataType
=
"int"
,
defaultValue
=
"1"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"当前页条数"
,
paramType
=
"query"
,
required
=
true
,
dataType
=
"int"
,
defaultValue
=
"10"
),
@ApiImplicitParam
(
name
=
"pageSize"
,
value
=
"当前页条数"
,
paramType
=
"query"
,
required
=
true
,
dataType
=
"int"
,
defaultValue
=
"10"
)
@ApiImplicitParam
(
name
=
"name"
,
value
=
"名称"
,
paramType
=
"query"
,
dataType
=
"string"
),
@ApiImplicitParam
(
name
=
"status"
,
value
=
"状态"
,
paramType
=
"query"
,
dataType
=
"integer"
)
})
})
@GetMapping
(
value
=
"/task/progresses"
)
@GetMapping
(
value
=
"/progresses"
)
public
Object
viewTasksProgress
(
int
pageNo
,
int
pageSize
,
String
name
,
Integer
status
)
{
public
SimplePage
viewTasksProgress
(
int
pageNo
,
int
pageSize
)
{
return
null
;
String
orderBy
=
"descending"
;
//
String
propBy
=
"id"
;
// groupBy
Page
<
Process
>
page
=
processService
.
findAll
(
pageNo
,
pageSize
,
orderBy
,
propBy
);
List
<
Process
>
processes
=
page
.
getContent
();
List
<
Map
>
list
=
new
ArrayList
<>();
processes
.
forEach
(
process
->
{
Map
map
=
new
HashMap
();
map
.
put
(
"id"
,
process
.
getId
());
List
<
HistoricActivityInstance
>
lisst
=
historyService
// 历史相关Service
.
createHistoricActivityInstanceQuery
()
// 创建历史活动实例查询
.
processInstanceId
(
process
.
getProcessId
())
// 执行流程实例id
.
finished
()
.
list
();
for
(
HistoricActivityInstance
hai
:
lisst
)
{
System
.
out
.
println
(
"活动ID:"
+
hai
.
getId
());
}
List
<
ProcessInstance
>
s
=
runtimeService
.
createProcessInstanceQuery
()
.
processInstanceId
(
process
.
getProcessId
())
.
list
();
for
(
ProcessInstance
hai
:
s
)
{
System
.
out
.
println
(
"活动ID:"
+
hai
.
getId
());
System
.
out
.
println
(
"流程实例ID:"
+
hai
.
getProcessInstanceId
()
+
hai
.
isEnded
()
+
hai
.
isSuspended
());
}
});
return
SimplePage
.
of
(
page
,
list
);
}
}
public
Mission
convertTaskToMission
(
Task
task
,
Map
<
String
,
Object
>
params
)
{
public
Mission
convertTaskToMission
(
Task
task
,
Map
<
String
,
Object
>
params
)
{
...
...
src/main/java/com/keymobile/rest/controller/TemplateController.java
View file @
be1b3b48
...
@@ -5,11 +5,8 @@ import com.keymobile.rest.common.utils.DateUtil;
...
@@ -5,11 +5,8 @@ import com.keymobile.rest.common.utils.DateUtil;
import
com.keymobile.rest.common.validator.CommonValidator
;
import
com.keymobile.rest.common.validator.CommonValidator
;
import
com.keymobile.rest.controller.constant.CommonConstant
;
import
com.keymobile.rest.controller.constant.CommonConstant
;
import
com.keymobile.rest.dto.DataForm
;
import
com.keymobile.rest.dto.DataForm
;
import
com.keymobile.rest.model.User
;
import
com.keymobile.rest.model.*
;
import
com.keymobile.rest.model.Activity
;
import
com.keymobile.rest.model.DataInfo
;
import
com.keymobile.rest.model.Process
;
import
com.keymobile.rest.model.Process
;
import
com.keymobile.rest.model.Template
;
import
com.keymobile.rest.service.*
;
import
com.keymobile.rest.service.*
;
import
io.swagger.annotations.*
;
import
io.swagger.annotations.*
;
import
org.activiti.engine.*
;
import
org.activiti.engine.*
;
...
@@ -24,7 +21,8 @@ import java.util.Map;
...
@@ -24,7 +21,8 @@ import java.util.Map;
@Api
(
tags
=
"模板 控制器"
,
description
=
"Template Mgr"
)
@Api
(
tags
=
"模板 控制器"
,
description
=
"Template Mgr"
)
@RestController
@RestController
public
class
TemplateController
{
public
class
TemplateController
{
@Autowired
private
FilePathService
filePathService
;
@Autowired
@Autowired
private
TemplateService
templateService
;
private
TemplateService
templateService
;
@Autowired
@Autowired
...
@@ -122,17 +120,34 @@ public class TemplateController {
...
@@ -122,17 +120,34 @@ public class TemplateController {
return
info
;
return
info
;
}
}
@ApiOperation
(
value
=
"获取上流文件路径"
)
@GetMapping
(
value
=
"/excel/getDataPaths"
)
public
Object
getPaths
()
{
return
filePathService
.
findAll
();
}
@ApiOperation
(
value
=
"获取txt或者dat文件的数据"
)
@ApiOperation
(
value
=
"获取txt或者dat文件的数据"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"dataAt"
,
required
=
true
,
value
=
"该行起读取数据(表头行数)"
,
dataType
=
"integer"
,
paramType
=
"query"
,
defaultValue
=
"1"
)
@ApiImplicitParam
(
name
=
"dataAt"
,
required
=
true
,
value
=
"该行起读取数据(表头行数)"
,
dataType
=
"integer"
,
paramType
=
"query"
,
defaultValue
=
"1"
)
})
})
@
PostMapping
(
value
=
"/excel/getDatData
"
)
@
GetMapping
(
value
=
"/excel/getDatDataByFile
"
)
public
Object
getDatData
(
MultipartFile
file
,
int
dataAt
)
{
public
Object
getDatData
ByFile
(
MultipartFile
file
,
int
dataAt
)
{
CommonValidator
.
notNull
(
file
,
"文件不能为空"
);
CommonValidator
.
notNull
(
file
,
"文件不能为空"
);
CommonValidator
.
notLessThan
(
dataAt
,
0
,
"dataAt不能小于0"
);
CommonValidator
.
notLessThan
(
dataAt
,
0
,
"dataAt不能小于0"
);
return
DataFileUtil
.
convertDatToJson
(
file
,
dataAt
);
return
DataFileUtil
.
convertDatToJson
(
file
,
dataAt
);
}
}
@ApiOperation
(
value
=
"获取txt或者dat文件的数据"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"pathId"
,
required
=
true
,
value
=
"path id"
,
dataType
=
"long"
,
paramType
=
"query"
),
@ApiImplicitParam
(
name
=
"dataAt"
,
required
=
true
,
value
=
"该行起读取数据(表头行数)"
,
dataType
=
"integer"
,
paramType
=
"query"
,
defaultValue
=
"1"
)
})
@GetMapping
(
value
=
"/excel/getDatDataByPath"
)
public
Object
getDatDataByPath
(
long
pathId
,
int
dataAt
)
{
FilePath
path
=
filePathService
.
findById
(
pathId
);
CommonValidator
.
notNull
(
path
,
"文件不存在"
);
return
DataFileUtil
.
convertDatToJson
(
path
.
getPath
(),
dataAt
);
}
@ApiOperation
(
value
=
"按列名拆分excel"
,
hidden
=
true
)
@ApiOperation
(
value
=
"按列名拆分excel"
,
hidden
=
true
)
@ApiImplicitParams
({
@ApiImplicitParams
({
...
...
src/main/java/com/keymobile/rest/dao/FilePathDao.java
0 → 100644
View file @
be1b3b48
package
com
.
keymobile
.
rest
.
dao
;
import
com.keymobile.rest.model.FilePath
;
import
org.springframework.data.jpa.repository.JpaRepository
;
public
interface
FilePathDao
extends
JpaRepository
<
FilePath
,
Long
>
{
FilePath
findById
(
long
id
);
}
src/main/java/com/keymobile/rest/dao/ProcessDao.java
View file @
be1b3b48
package
com
.
keymobile
.
rest
.
dao
;
package
com
.
keymobile
.
rest
.
dao
;
import
com.keymobile.rest.model.Process
;
import
com.keymobile.rest.model.Process
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
public
interface
ProcessDao
extends
JpaRepository
<
Process
,
Long
>
{
public
interface
ProcessDao
extends
JpaRepository
<
Process
,
Long
>
{
Process
findByProcessId
(
String
processId
);
Process
findByProcessId
(
String
processId
);
Page
<
Process
>
findAll
(
Pageable
pageable
);
}
}
src/main/java/com/keymobile/rest/model/FilePath.java
0 → 100644
View file @
be1b3b48
package
com
.
keymobile
.
rest
.
model
;
import
lombok.Data
;
import
javax.persistence.*
;
import
java.io.Serializable
;
@Data
@Entity
@Table
(
name
=
"t_path"
)
public
class
FilePath
implements
Serializable
{
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
private
Long
id
;
@Column
(
columnDefinition
=
(
"varchar(20) comment '文件名称'"
))
private
String
name
;
@Column
(
columnDefinition
=
(
"varchar(20) comment '文件路劲'"
))
private
String
path
;
}
src/main/java/com/keymobile/rest/service/FilePathService.java
0 → 100644
View file @
be1b3b48
package
com
.
keymobile
.
rest
.
service
;
import
com.keymobile.rest.dao.FilePathDao
;
import
com.keymobile.rest.model.FilePath
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
@Service
public
class
FilePathService
{
@Autowired
private
FilePathDao
filePathDao
;
public
List
<
FilePath
>
findAll
()
{
return
filePathDao
.
findAll
();
}
public
FilePath
findById
(
long
id
)
{
return
filePathDao
.
findById
(
id
);
}
public
FilePath
save
(
FilePath
filePath
)
{
filePathDao
.
save
(
filePath
);
return
filePath
;
}
}
src/main/java/com/keymobile/rest/service/ProcessService.java
View file @
be1b3b48
package
com
.
keymobile
.
rest
.
service
;
package
com
.
keymobile
.
rest
.
service
;
import
com.keymobile.rest.dao.ProcessDao
;
import
com.keymobile.rest.dao.ProcessDao
;
import
com.keymobile.rest.model.Activity
;
import
com.keymobile.rest.model.Process
;
import
com.keymobile.rest.model.Process
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -21,4 +26,34 @@ public class ProcessService {
...
@@ -21,4 +26,34 @@ public class ProcessService {
return
processDao
.
findByProcessId
(
processId
);
return
processDao
.
findByProcessId
(
processId
);
}
}
public
Page
<
Process
>
findAll
(
int
pageNo
,
int
pageSize
,
String
orderBy
,
String
propBy
)
{
Pageable
pageable
=
convert
(
pageNo
,
pageSize
,
orderBy
,
propBy
);
return
processDao
.
findAll
(
pageable
);
}
private
Pageable
convert
(
int
pageNo
,
int
pageSize
,
String
orderBy
,
String
propBy
)
{
pageNo
--;
if
(
pageNo
<
0
)
{
pageNo
=
0
;
}
Sort
.
Direction
direction
=
orderBy
.
equals
(
"descending"
)
?
Sort
.
Direction
.
DESC
:
Sort
.
Direction
.
ASC
;
Sort
sort
;
if
(
propBy
.
contains
(
"-"
))
{
sort
=
Sort
.
by
(
direction
,
propBy
.
split
(
"-"
));
}
else
{
sort
=
Sort
.
by
(
direction
,
propBy
);
}
Pageable
pageable
=
PageRequest
.
of
(
pageNo
,
pageSize
,
sort
);
return
pageable
;
}
private
Pageable
convert
(
int
pageNo
,
int
pageSize
)
{
pageNo
--;
if
(
pageNo
<
0
)
{
pageNo
=
0
;
}
Pageable
pageable
=
PageRequest
.
of
(
pageNo
,
pageSize
);
return
pageable
;
}
}
}
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