Bladeren bron

优化

tags/24080901
WendyYang 7 maanden geleden
bovenliggende
commit
d5a663836a
4 gewijzigde bestanden met toevoegingen van 51 en 21 verwijderingen
  1. +9
    -6
      hz-pm-api/src/main/java/com/hz/pm/api/common/helper/WflowHelper.java
  2. +12
    -5
      hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/TaskCreatedListener.java
  3. +26
    -9
      hz-pm-api/src/test/java/com/hz/pm/api/todocenter/MhApiClientTest.java
  4. +4
    -1
      hz-pm-api/src/test/resources/application-dev.yml

+ 9
- 6
hz-pm-api/src/main/java/com/hz/pm/api/common/helper/WflowHelper.java Bestand weergeven

@@ -1,19 +1,16 @@
package com.hz.pm.api.common.helper;

import com.wflow.workflow.service.ProcessInstanceService;
import lombok.RequiredArgsConstructor;
import org.flowable.bpmn.model.Activity;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.Process;
import org.flowable.bpmn.model.UserTask;
import org.flowable.engine.HistoryService;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricActivityInstance;
import org.flowable.engine.history.HistoricActivityInstanceQuery;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.task.api.Task;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.variable.api.history.HistoricVariableInstance;
import org.springframework.stereotype.Component;

@@ -46,18 +43,24 @@ public class WflowHelper {
List<UserTask> userTasks = processes.get(0).findFlowElementsOfType(UserTask.class);
for (UserTask userTask : userTasks) {
if (userTask.getId().equals(activityId)) {
return userTask.getLoopCharacteristics().isSequential();
return !userTask.getLoopCharacteristics().isSequential();
}
}
return false;
}

public List<Task> listUnFinishedTasks(String activityId) {
public List<Task> listPendingTasks(String activityId) {
return taskService.createTaskQuery()
.taskDefinitionKey(activityId)
.list();
}

public List<HistoricTaskInstance> listFinishedTasks(String activityId) {
return historyService.createHistoricTaskInstanceQuery()
.taskDefinitionKey(activityId)
.list();
}

/**
* 所有流程是否完成(审核通过)
*


+ 12
- 5
hz-pm-api/src/main/java/com/hz/pm/api/scheduler/listener/TaskCreatedListener.java Bestand weergeven

@@ -5,6 +5,7 @@ import cn.hutool.extra.spring.SpringUtil;
import com.hz.pm.api.common.enumeration.ProjectProcessStageEnum;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.common.helper.WflowHelper;
import com.hz.pm.api.common.util.ThreadPoolUtil;
import com.hz.pm.api.external.MhApiClient;
import com.hz.pm.api.external.model.dto.MhZwddWorkNoticeDTO;
import com.hz.pm.api.external.todo.MHTodoClient;
@@ -26,11 +27,11 @@ import org.flowable.common.engine.api.delegate.event.FlowableEngineEntityEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEventType;
import org.flowable.common.engine.api.delegate.event.FlowableEvent;
import org.flowable.common.engine.api.delegate.event.FlowableEventListener;
import org.flowable.task.api.Task;
import org.flowable.task.api.TaskInfo;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.springframework.stereotype.Component;

import java.time.Instant;
import java.util.List;
import java.util.Optional;
import java.util.Set;
@@ -58,6 +59,11 @@ public class TaskCreatedListener implements FlowableEventListener {

@Override
public void onEvent(FlowableEvent event) {
Instant instant = Instant.now().plusSeconds(5);
ThreadPoolUtil.SCHEDULER.schedule(() -> handleEvent(event), instant);
}

private void handleEvent(FlowableEvent event) {
if (event.getType().equals(FlowableEngineEventType.TASK_CREATED)) {
FlowableEngineEntityEvent entityEvent = (FlowableEngineEntityEvent) event;
String procDefId = entityEvent.getProcessDefinitionId();
@@ -127,15 +133,16 @@ public class TaskCreatedListener implements FlowableEventListener {
}
TaskEntity taskEntity = (TaskEntity) entityEvent.getEntity();
WflowHelper wflowHelper = SpringUtil.getBean(WflowHelper.class);
boolean orUserTask = wflowHelper.isOrUserTask(procDefId, taskEntity.getTaskDefinitionId());
String taskDefKey = taskEntity.getTaskDefinitionKey();
boolean orUserTask = wflowHelper.isOrUserTask(procDefId, taskDefKey);
switch (procType.get()) {
case XC_APPROVAL_PROCESS:
case PROJECT_RECORD_APPROVAL_PROCESS:
case ACCEPTANCE_DECLARATION_APPROVAL_PROCESS:
MHTodoTypeEnum todoType = getMhTodoTypeEnum(procType.get());
if (orUserTask) {
List<Task> tasks = wflowHelper.listUnFinishedTasks(taskEntity.getTaskDefinitionId());
Set<String> taskIds = CollUtils.fieldSet(tasks, TaskInfo::getId);
List<HistoricTaskInstance> tasks = wflowHelper.listFinishedTasks(taskDefKey);
Set<String> taskIds = CollUtils.fieldSet(tasks, HistoricTaskInstance::getId);
taskIds.add(taskEntity.getId());
mhTodoClient.completeTodo(todoType, taskIds);
} else {


+ 26
- 9
hz-pm-api/src/test/java/com/hz/pm/api/todocenter/MhApiClientTest.java Bestand weergeven

@@ -3,7 +3,10 @@ package com.hz.pm.api.todocenter;
import cn.hutool.json.JSONObject;
import com.hz.pm.api.AppTests;
import com.hz.pm.api.common.helper.UserInfoHelper;
import com.hz.pm.api.external.MhApiClient;
import com.hz.pm.api.external.model.dto.MhZwddWorkNoticeDTO;
import com.hz.pm.api.external.todo.MHTodoClient;
import com.hz.pm.api.external.todo.dto.MhTodoExtraParamDTO;
import com.hz.pm.api.external.todo.enumerization.MHTodoTypeEnum;
import com.hz.pm.api.user.security.model.UserFullInfoDTO;
import org.junit.Test;
@@ -22,20 +25,34 @@ public class MhApiClientTest extends AppTests {
@Autowired
private MHTodoClient mhTodoClient;
@Autowired
private UserInfoHelper userInfoHelper;
private MhApiClient mhApiClient;

@Test
public void sendTodo() {
UserFullInfoDTO assignee = new UserFullInfoDTO();
assignee.setUserId(347873L);
assignee.setUserId(150L);
assignee.setMhUserId("62697f4ed80d823fa1f26c5a082d989e");
JSONObject paramObj = new JSONObject();
paramObj.set("projectId", 1213);
paramObj.set("instId", 1213);
paramObj.set("taskId", 1213);
String content = String.format("【%s】的【%s】需要您审核,请及时处理。",
"市住保房管局深化信创项目", "立项备案审批");
mhTodoClient.addTodo(paramObj, assignee, MHTodoTypeEnum.XCFHX_INSPECT_AUDIT, "1212121", content);
MhTodoExtraParamDTO paramObj = MhTodoExtraParamDTO.builder()
.bidId(117L)
.path("/toDoCenter/handleDuringExamine")
.projectId(2333L)
.userName("杨云迪")
.nodeId("node_65f010952418b30a56467594")
.taskId("a733d3fb-e049-11ee-aa3b-024410885fae")
.instanceId("8edc9888-e049-11ee-aa3b-024410885fae")
.build();
mhTodoClient.addTodo(paramObj, assignee, MHTodoTypeEnum.XCFHX_INSPECT_AUDIT, "1212121", null);
}

@Test
public void test(){
MhZwddWorkNoticeDTO notice = MhZwddWorkNoticeDTO.builder()
.title(MHTodoTypeEnum.DECLARED_RECORD_AUDIT.getVal())
.targetUser("ce44b47503147319fc3b5c826cb51fd2")
.content(String.format("【%s】的【%s】需要您审核,请及时处理。",
"市住保房管局深化信创项目", "立项备案审批"))
.build();
mhApiClient.sendZwddWorkNotice(notice);
}

}

+ 4
- 1
hz-pm-api/src/test/resources/application-dev.yml Bestand weergeven

@@ -246,10 +246,13 @@ sync-mh-user:
sync-mh-company:
open: false
mh:
zwdd-work-notice:
client-id: ningda-74a5e5da-3bc3-414a-b9e6-004b7d87e310
client-secret: ningda-df746ce4-0c79-4242-b3c7-90ff8630c9742c6727cd-3ae7-48ae-87ad-2b39188ebabd
sso:
client-id: ningda-74a5e5da-3bc3-414a-b9e6-004b7d87e310
client-secret: ningda-df746ce4-0c79-4242-b3c7-90ff8630c9742c6727cd-3ae7-48ae-87ad-2b39188ebabd
api-host: https://hzszxc.hzswb.cn:8443/test/mh-gateway/auth-single
api-host: https://hzszxc.hzswb.cn:8443/mh-gateway/auth-single
expert-qr-code-url: https://jiema.wwei.cn/uploads/2023/12/28/658d7a3f15f06.jpg
file:
down-url: https://weixin.hzszxc.hzswb.cn:8443/test/mh-gateway/oss/oss/previewFileLogin


Laden…
Annuleren
Opslaan