Merge remote-tracking branch 'origin/master'

This commit is contained in:
dinggang 2022-04-22 18:21:45 +08:00
commit d70cb67c06
7 changed files with 138 additions and 75 deletions

View File

@ -8,6 +8,8 @@ import io.renren.modules.activiti.dto.ProcessActivityDTO;
import io.renren.modules.activiti.dto.ProcessInstanceDTO;
import io.renren.modules.activiti.service.ActHistoryService;
import io.renren.modules.activiti.service.ActivitiService;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.sys.dto.SysUserDTO;
import io.renren.modules.sys.service.SysUserService;
import io.swagger.annotations.Api;
@ -42,6 +44,9 @@ public class HistoryController {
@Autowired
private SysUserService sysUserService;
@Autowired
private TAbilityApplicationService abilityApplicationService;
@GetMapping("getInstImage")
@ApiOperation(value = "获取流程活动图", produces = "application/octet-stream")
@ApiImplicitParam(name = "processInstanceId", value = "流程实例ID", paramType = "query", dataType = "String")
@ -113,6 +118,11 @@ public class HistoryController {
SysUserDTO userDTO = sysUserService.get(Long.valueOf(activityDTO.getAssignee()));
activityDTO.setAssigneeName(userDTO != null ? userDTO.getRealName() : "");
}
TAbilityApplicationDTO abilityApplicationDTO =
abilityApplicationService.get(Long.valueOf(activityDTO.getBusinessKey()));
if (abilityApplicationDTO != null) {
activityDTO.setResourceName(abilityApplicationDTO.getSystem());
}
}
return new Result().ok(page);
}

View File

@ -36,7 +36,7 @@ public class HistoryDetailDTO {
@ApiModelProperty(value = "执行ID")
private String executionId;
@ApiModelProperty(value = "受理人")
@ApiModelProperty(value = "受理人id")
private String assignee;
@ApiModelProperty(value = "开始时间")
@ -50,4 +50,7 @@ public class HistoryDetailDTO {
@ApiModelProperty(value = "审批意见")
private String comment;
@ApiModelProperty(value = "受理人姓名")
private String assigneeName;
}

View File

@ -47,4 +47,7 @@ public class ProcessActivityDTO {
@ApiModelProperty(value = "受理人姓名")
private String assigneeName;
@ApiModelProperty(value = "申请资源名称")
private String resourceName;
}

View File

@ -37,4 +37,6 @@ public class HistoryDetailEntity {
private String comment;
private String assigneeName;
}

View File

@ -8,9 +8,14 @@ import io.renren.common.page.PageData;
import io.renren.common.service.impl.BaseServiceImpl;
import io.renren.common.utils.MessageUtils;
import io.renren.modules.activiti.dto.TaskDTO;
import io.renren.modules.processForm.dto.TAbilityApplicationDTO;
import io.renren.modules.processForm.service.TAbilityApplicationService;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.sys.service.SysRoleUserService;
import org.activiti.engine.*;
import org.activiti.engine.HistoryService;
import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.delegate.Expression;
import org.activiti.engine.history.HistoricActivityInstance;
import org.activiti.engine.history.HistoricProcessInstance;
@ -30,6 +35,7 @@ import org.activiti.engine.task.Task;
import org.activiti.engine.task.TaskInfo;
import org.activiti.engine.task.TaskQuery;
import org.apache.commons.lang3.StringUtils;
import org.codehaus.jackson.map.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -54,6 +60,9 @@ public class ActTaskService extends BaseServiceImpl {
@Autowired
private SysRoleUserService sysRoleUserService;
@Autowired
private TAbilityApplicationService tAbilityApplicationService;
/**
* 根据参数获取当前运行的任务信息
*
@ -96,6 +105,13 @@ public class ActTaskService extends BaseServiceImpl {
for (Task task : list) {
TaskDTO dto = new TaskDTO();
this.convertTaskInfo(task, dto);
TAbilityApplicationDTO abilityApplicationDTO =
tAbilityApplicationService.get(Long.valueOf(dto.getBusinessKey()));
if (abilityApplicationDTO != null) {
ObjectMapper oMapper = new ObjectMapper();
Map<String, Object> variables = oMapper.convertValue(abilityApplicationDTO, Map.class);
dto.setParams(variables);
}
listDto.add(dto);
}
return new PageData<>(listDto, (int) taskQuery.count());
@ -211,6 +227,7 @@ public class ActTaskService extends BaseServiceImpl {
/**
* 更新任务变量
*
* @param taskDTO
*/
public void updateTaskVariable(TaskDTO taskDTO) {
@ -220,6 +237,7 @@ public class ActTaskService extends BaseServiceImpl {
/**
* 根据任务ID判断是否为多实例任务
*
* @param taskId
* @return
*/
@ -269,6 +287,7 @@ public class ActTaskService extends BaseServiceImpl {
/**
* 任务回退至上一用户任务节点
*
* @param taskId
* @return
*/
@ -458,6 +477,7 @@ public class ActTaskService extends BaseServiceImpl {
/**
* 转换Task对象
*
* @param task
* @param dto
*/
@ -481,6 +501,7 @@ public class ActTaskService extends BaseServiceImpl {
/**
* 驳回至第一个用户任务
*
* @param taskId
*/
@Transactional(rollbackFor = Exception.class)

View File

@ -48,24 +48,33 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
@Override
public void notify(DelegateTask delegateTask) {
logger.error("-------------------------进入部门动态审批人流程-------------------------------");
Map<String, Object> kv = delegateTask.getVariables();
Gson gson = new Gson();
JsonElement jsonElement = gson.toJsonTree(kv);
TAbilityApplicationDTO abilityApplicationDTO = gson.fromJson(jsonElement, TAbilityApplicationDTO.class);
SysRoleDTO roleDTO = sysRoleService.getByName(roleName);
logger.info("roleDTOId:" + roleDTO.getId());
logger.info("abilityApplicationDTO:" + abilityApplicationDTO.toString());
ResourceDTO resourceEntityDto = resourceService.get(Long.valueOf(abilityApplicationDTO.getResourceId()));
logger.error("roleDTOId:" + roleDTO.getId());
ResourceDTO resourceEntityDto = null;
Long deptId = null;
if (abilityApplicationDTO != null) {
logger.error("abilityApplicationDTO:" + abilityApplicationDTO.toString());
resourceEntityDto = resourceService.get(Long.valueOf(abilityApplicationDTO.getResourceId()));
}
if (resourceEntityDto != null && resourceEntityDto.getDeptId() != null) {
deptId = resourceEntityDto.getDeptId();
SysDeptDTO deptDTO =
sysDeptService.get(resourceEntityDto.getDeptId());
if (deptDTO != null && deptDTO.getName().equals("青岛市大数据发展管理局")) {
logger.error("第二级别审批仍然为 青岛市大数据发展管理局");
taskService.complete(delegateTask.getId(), delegateTask.getVariables());
}
} else {
logger.info("表单内单位名称:" + abilityApplicationDTO.getUnit());
logger.error("表单内单位名称:" + abilityApplicationDTO.getUnit());
SysDeptDTO deptDTO = sysDeptService.getByName(abilityApplicationDTO.getUnit());
if (deptDTO != null) {
logger.info("deptDTOId:" + deptDTO.getId());
logger.error("deptDTOId:" + deptDTO.getId());
deptId = deptDTO.getId();
}
@ -74,14 +83,14 @@ public class CorrectionListener implements TaskListener, ExecutionListener, Acti
if (deptId != null) {
userDTO = sysUserService.getByDeptIdAndRoleId(deptId, roleDTO.getId()); // 搜出审批人
}
delegateTask.setAssignee("1513432847327199233");
if (userDTO != null) {
logger.info("审批人id:" + userDTO.getId());
logger.error("审批人id:" + userDTO.getId());
taskService.setAssignee(delegateTask.getId(), userDTO.getId().toString());
} else {
logger.info("未查到该部门对应 " + roleName);
logger.error("未查到该部门对应的 " + roleName);
taskService.setAssignee(delegateTask.getId(), "1513432847327199233");
}
logger.error("-------------------------结束部门动态审批人流程-------------------------------");
}
@Override

View File

@ -56,13 +56,28 @@
</select>
<select id="getTaskHandleDetailInfo" resultMap="HistoryDetail">
SELECT ahc.ID_, ahc.TYPE_, aht.ID_ as TASK_ID_, aht.PROC_INST_ID_, ahc.MESSAGE_,
aht.PROC_DEF_ID_, aht.EXECUTION_ID_, aht.NAME_, aht.ASSIGNEE_, aht.START_TIME_,
aht.END_TIME_ from ACT_HI_TASKINST aht
left join ACT_HI_COMMENT ahc on ahc.TASK_ID_ = aht.ID_ and ahc.TYPE_ = 'comment'
where aht.PROC_INST_ID_ = #{processInstanceId}
and aht.end_time_ is not null
order by aht.START_TIME_ desc
SELECT
ahc.ID_,
ahc.TYPE_,
aht.ID_ AS TASK_ID_,
aht.PROC_INST_ID_,
ahc.MESSAGE_,
aht.PROC_DEF_ID_,
aht.EXECUTION_ID_,
aht.NAME_,
aht.ASSIGNEE_,
aht.START_TIME_,
aht.END_TIME_,
( SELECT user1.real_name FROM sys_user user1 WHERE user1.id = aht.ASSIGNEE_ ) ASSIGNEE_NAME_
FROM
ACT_HI_TASKINST aht
LEFT JOIN ACT_HI_COMMENT ahc ON ahc.TASK_ID_ = aht.ID_
AND ahc.TYPE_ = 'comment'
WHERE
aht.PROC_INST_ID_ = #{processInstanceId}
AND aht.end_time_ IS NOT NULL
ORDER BY
aht.START_TIME_ DESC
</select>
</mapper>