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
9e2b5d10
Commit
9e2b5d10
authored
Mar 31, 2020
by
chenweisong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新
parent
efa5a86f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
102 additions
and
52 deletions
+102
-52
TaskController.java
...in/java/com/keymobile/rest/controller/TaskController.java
+64
-41
application-test.yml
src/main/resources/application-test.yml
+2
-1
ProcessTest.java
src/test/java/com/keymobile/ProcessTest.java
+36
-10
No files found.
src/main/java/com/keymobile/rest/controller/TaskController.java
View file @
9e2b5d10
...
@@ -97,57 +97,80 @@ public class TaskController {
...
@@ -97,57 +97,80 @@ public class TaskController {
})
})
@PostMapping
(
value
=
"/getMyTasks"
)
@PostMapping
(
value
=
"/getMyTasks"
)
public
ApiResponse
getMyMissions
(
long
userId
)
{
public
ApiResponse
getMyMissions
(
long
userId
)
{
Map
user
=
feignAuthService
.
getUserById
(
userId
);
// Map user = feignAuthService.getUserById(userId);
CommonValidator
.
notNull
(
user
,
"用户不存在"
);
// CommonValidator.notNull(user, "用户不存在");
// String username = user.get("name").toString();
String
username
=
"汤颖思1"
;
List
<
Map
>
missions
=
new
ArrayList
<>();
List
<
Task
>
tasks
=
taskService
.
createTaskQuery
().
taskAssignee
(
username
).
active
().
list
();
tasks
.
forEach
(
task
->
{
Map
mission
=
new
HashMap
();
mission
.
put
(
"id"
,
task
.
getId
());
mission
.
put
(
"user"
,
task
.
getAssignee
());
mission
.
put
(
"createAt"
,
DateUtil
.
formatDateTime
(
task
.
getCreateTime
()));
if
(
task
.
getTaskDefinitionKey
().
toLowerCase
().
equals
(
"dataenter"
))
{
mission
.
put
(
"kind"
,
1
);
mission
.
put
(
"mission"
,
"填写补录数据"
);
}
else
if
(
task
.
getTaskDefinitionKey
().
toLowerCase
().
equals
(
"dataaudit"
))
{
mission
.
put
(
"kind"
,
2
);
mission
.
put
(
"mission"
,
"审核补录数据"
);
}
else
if
(
task
.
getTaskDefinitionKey
().
toLowerCase
().
equals
(
"useraudit"
))
{
mission
.
put
(
"kind"
,
3
);
mission
.
put
(
"mission"
,
"审核人审核"
);
}
else
if
(
task
.
getTaskDefinitionKey
().
toLowerCase
().
equals
(
"databackflow"
))
{
mission
.
put
(
"kind"
,
4
);
mission
.
put
(
"mission"
,
"数据回流"
);
}
missions
.
add
(
mission
);
});
List
<
UserTemplateMapper
>
mappers
=
userTemplateMapperService
.
findAllByUserIdAndActivityStatus
(
userId
,
Activity
.
STATUS_BEGIN
);
List
<
UserTemplateMapper
>
mappers
=
userTemplateMapperService
.
findAllByUserIdAndActivityStatus
(
userId
,
Activity
.
STATUS_BEGIN
);
String
username
=
user
.
get
(
"name"
).
toString
();
mappers
.
forEach
(
mapper
->
{
mappers
.
forEach
(
mapper
->
{
Template
template
=
mapper
.
getTemplate
();
Template
template
=
mapper
.
getTemplate
();
// 查找当前模板的任务
// 查找当前模板的任务
List
<
Task
>
tasks
=
taskService
.
createTaskQuery
().
taskCandidateUser
(
"id:"
+
template
.
getId
())
List
<
Task
>
tas
s
ks
=
taskService
.
createTaskQuery
().
taskCandidateUser
(
"id:"
+
template
.
getId
())
.
list
();
.
list
();
System
.
out
.
println
(
"taskLength:"
+
tasks
.
size
());
System
.
out
.
println
(
"taskLength:"
+
tas
s
ks
.
size
());
});
});
List
<
Map
>
missions
=
new
ArrayList
<>();
List
<
Task
>
tasks
=
taskService
.
createTaskQuery
().
taskAssigneeLike
(
username
)
List
<
Task
>
tas
asdas
ks
=
taskService
.
createTaskQuery
().
taskAssigneeLike
(
username
)
.
list
();
.
list
();
tasks
.
forEach
(
task
->
{
//
tasks.forEach(task -> {
String
assignee
=
task
.
getAssignee
();
//
String assignee = task.getAssignee();
Map
map
=
new
HashMap
();
//
Map map = new HashMap();
long
templateId
=
Long
.
parseLong
(
assignee
.
split
(
":template:"
)[
1
]);
//
long templateId = Long.parseLong(assignee.split(":template:")[1]);
String
processId
=
task
.
getProcessInstanceId
();
//
String processId = task.getProcessInstanceId();
Process
process
=
processService
.
findByProcessId
(
processId
);
//
Process process = processService.findByProcessId(processId);
Mission
mission
=
missionService
.
findByProcessIdAndUsernameAndTemplateIdAndStatusAndType
(
process
.
getId
(),
username
,
templateId
,
Mission
.
STATUS_BEGIN
);
//
Mission mission = missionService.findByProcessIdAndUsernameAndTemplateIdAndStatusAndType(process.getId(), username, templateId, Mission.STATUS_BEGIN);
mission
.
setTaskId
(
task
.
getId
());
//
mission.setTaskId(task.getId());
missionService
.
save
(
mission
);
//
missionService.save(mission);
map
.
put
(
"id"
,
mission
.
getId
());
//
map.put("id", mission.getId());
Template
template
=
mission
.
getTemplate
();
//
Template template = mission.getTemplate();
Map
_template
=
new
HashMap
();
//
Map _template = new HashMap();
_template
.
put
(
"id"
,
mission
.
getId
());
//
_template.put("id", mission.getId());
_template
.
put
(
"config"
,
template
.
getConfig
());
//
_template.put("config", template.getConfig());
_template
.
put
(
"name"
,
template
.
getName
());
//
_template.put("name", template.getName());
_template
.
put
(
"createAt"
,
template
.
getCreateAt
());
//
_template.put("createAt", template.getCreateAt());
map
.
put
(
"excelList"
,
Arrays
.
asList
(
_template
));
//
map.put("excelList", Arrays.asList(_template));
//
if
(
task
.
getTaskDefinitionKey
().
toLowerCase
().
equals
(
"dataenter"
))
{
//
if (task.getTaskDefinitionKey().toLowerCase().equals("dataenter")) {
map
.
put
(
"kind"
,
1
);
//
map.put("kind", 1);
map
.
put
(
"mission"
,
"填写补录数据"
);
//
map.put("mission", "填写补录数据");
}
else
if
(
task
.
getTaskDefinitionKey
().
toLowerCase
().
equals
(
"dataaudit"
))
{
//
} else if (task.getTaskDefinitionKey().toLowerCase().equals("dataaudit")) {
map
.
put
(
"kind"
,
2
);
//
map.put("kind", 2);
map
.
put
(
"mission"
,
"审核补录数据"
);
//
map.put("mission", "审核补录数据");
}
else
if
(
task
.
getTaskDefinitionKey
().
toLowerCase
().
equals
(
"useraudit"
))
{
//
} else if (task.getTaskDefinitionKey().toLowerCase().equals("useraudit")) {
map
.
put
(
"kind"
,
3
);
//
map.put("kind", 3);
map
.
put
(
"mission"
,
"审核人审核"
);
//
map.put("mission", "审核人审核");
}
else
if
(
task
.
getTaskDefinitionKey
().
toLowerCase
().
equals
(
"databackflow"
))
{
//
} else if (task.getTaskDefinitionKey().toLowerCase().equals("databackflow")) {
map
.
put
(
"kind"
,
4
);
//
map.put("kind", 4);
map
.
put
(
"mission"
,
"数据回流"
);
//
map.put("mission", "数据回流");
}
//
}
missions
.
add
(
map
);
//
missions.add(map);
});
//
});
return
ApiResponse
.
ok
(
missions
);
return
ApiResponse
.
ok
(
missions
);
}
}
...
...
src/main/resources/application-test.yml
View file @
9e2b5d10
...
@@ -40,7 +40,8 @@ spring:
...
@@ -40,7 +40,8 @@ spring:
max-file-size
:
20Mb
max-file-size
:
20Mb
max-request-size
:
100Mb
max-request-size
:
100Mb
redis
:
redis
:
host
:
192.168.0.192
# host: 192.168.0.192
host
:
127.0.0.1
port
:
6379
port
:
6379
session
:
session
:
store-type
:
redis
store-type
:
redis
...
...
src/test/java/com/keymobile/ProcessTest.java
View file @
9e2b5d10
package
com
.
keymobile
;
package
com
.
keymobile
;
import
com.google.common.collect.ImmutableMap
;
import
com.keymobile.rest.model.Process
;
import
com.keymobile.rest.service.ActivityService
;
import
com.keymobile.rest.service.ActivityService
;
import
org.activiti.engine.*
;
import
org.activiti.engine.*
;
import
org.activiti.engine.history.HistoricProcessInstance
;
import
org.activiti.engine.history.HistoricProcessInstance
;
...
@@ -9,11 +7,11 @@ import org.activiti.engine.history.HistoricProcessInstanceQuery;
...
@@ -9,11 +7,11 @@ import org.activiti.engine.history.HistoricProcessInstanceQuery;
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
;
import
org.activiti.engine.task.IdentityLink
;
import
org.activiti.engine.task.Task
;
import
org.activiti.engine.task.Task
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.context.junit4.SpringRunner
;
...
@@ -22,6 +20,7 @@ import java.util.Arrays;
...
@@ -22,6 +20,7 @@ import java.util.Arrays;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.concurrent.atomic.AtomicInteger
;
@RunWith
(
SpringRunner
.
class
)
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
@SpringBootTest
...
@@ -41,7 +40,7 @@ public class ProcessTest {
...
@@ -41,7 +40,7 @@ public class ProcessTest {
// @Value("${app.active-process}")
// @Value("${app.active-process}")
private
String
process
=
"MoreSubProcessStandard.bpmn"
;
private
String
process
=
"MoreSubProcessStandard.bpmn"
;
//
@Test
@Test
public
void
createActivitiTask
()
{
public
void
createActivitiTask
()
{
// 加载的我们创建好的demo.bpmn 文件还有png文件
// 加载的我们创建好的demo.bpmn 文件还有png文件
// 获取流的引擎
// 获取流的引擎
...
@@ -66,7 +65,6 @@ public class ProcessTest {
...
@@ -66,7 +65,6 @@ public class ProcessTest {
// 指定发起人
// 指定发起人
Map
<
String
,
Object
>
variables
=
new
HashMap
<>();
Map
<
String
,
Object
>
variables
=
new
HashMap
<>();
variables
.
put
(
"manager"
,
"你妈的发起人啊圣诞节阿思"
);
variables
.
put
(
"groups"
,
Arrays
.
asList
(
"组1"
,
"组2"
,
"组3"
));
variables
.
put
(
"groups"
,
Arrays
.
asList
(
"组1"
,
"组2"
,
"组3"
));
//启动流程
//启动流程
...
@@ -74,10 +72,17 @@ public class ProcessTest {
...
@@ -74,10 +72,17 @@ public class ProcessTest {
List
<
Task
>
tasks
=
taskService
.
createTaskQuery
().
processInstanceId
(
processInstance
.
getId
()).
list
();
List
<
Task
>
tasks
=
taskService
.
createTaskQuery
().
processInstanceId
(
processInstance
.
getId
()).
list
();
tasks
.
forEach
(
task
->
{
tasks
.
forEach
(
task
->
{
if
(
StringUtils
.
isEmpty
(
task
.
getAssignee
()))
{
// taskService.claim(task.getId(), "肥仔宋");
if
(
StringUtils
.
isEmpty
(
task
.
getAssignee
()))
{
List
<
IdentityLink
>
identityLinkList
=
taskService
.
getIdentityLinksForTask
(
task
.
getId
());
if
(
identityLinkList
!=
null
&&
identityLinkList
.
size
()
>
0
)
{
identityLinkList
.
forEach
(
identityLink
->
{
System
.
out
.
println
(
"link :"
+
identityLink
.
getType
());
});
}
}
}
System
.
out
.
println
(
task
.
getAssignee
());
});
});
// Task resultTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).
// Task resultTask = taskService.createTaskQuery().processInstanceId(processInstance.getId()).
...
@@ -98,7 +103,7 @@ public class ProcessTest {
...
@@ -98,7 +103,7 @@ public class ProcessTest {
}
}
//
@Test
@Test
public
void
start
()
{
public
void
start
()
{
// 65046
// 65046
...
@@ -108,7 +113,7 @@ public class ProcessTest {
...
@@ -108,7 +113,7 @@ public class ProcessTest {
// 187538
// 187538
// taskService.claim("210033", "chenws2");
// taskService.claim("210033", "chenws2");
taskService
.
complete
(
"210040"
,
ImmutableMap
.
of
());
//
taskService.complete("210040", ImmutableMap.of());
// taskService.complete(resultTask.getId());
// taskService.complete(resultTask.getId());
...
@@ -119,6 +124,27 @@ public class ProcessTest {
...
@@ -119,6 +124,27 @@ public class ProcessTest {
// 最后一条需要传递 ${needConfirm == 'true'}
// 最后一条需要传递 ${needConfirm == 'true'}
// taskService.complete(resultTask.getId(), ImmutableMap.of("signConfirm", "true", "needDataBackflow", "true"));
// taskService.complete(resultTask.getId(), ImmutableMap.of("signConfirm", "true", "needDataBackflow", "true"));
// System.out.println(resultTask);
// System.out.println(resultTask);
List
<
Task
>
tasks
=
taskService
.
createTaskQuery
().
active
().
list
();
AtomicInteger
i
=
new
AtomicInteger
();
tasks
.
forEach
(
task
->
{
if
(
StringUtils
.
isEmpty
(
task
.
getAssignee
()))
{
List
<
IdentityLink
>
identityLinkList
=
taskService
.
getIdentityLinksForTask
(
task
.
getId
());
if
(
identityLinkList
!=
null
&&
identityLinkList
.
size
()
>
0
)
{
identityLinkList
.
forEach
(
identityLink
->
{
System
.
out
.
println
(
"link :"
+
identityLink
.
getType
());
if
(
identityLink
.
getType
().
equals
(
"candidate"
))
{
i
.
getAndIncrement
();
taskService
.
claim
(
task
.
getId
(),
"汤颖思"
+
i
);
}
});
}
}
});
}
}
@Test
@Test
...
...
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