九 流程审批记录

@ApiOperation(value = "获取流转历史列表")
	@GetMapping(path = "/histoicFlow/{processInstanceId}")
	public Response histoicFlow(
			@PathVariable(name="processInstanceId") String processInstanceId){
			List<Act> histoicFlowList = wfTaskService.histoicList(processInstanceId);
			return Response.success().setData(histoicFlowList);
	}
@Override
	public List<Act> histoicList(String processInstanceId) {
		List<Act> list = histoicMess(processInstanceId);
		return list;
	}
public List<Act> histoicMess(String processInstanceId) {
		List<Act> actList = Lists.newArrayList();

		List<HistoricTaskInstance> list = activitiEngine.getHistoryService().createHistoricTaskInstanceQuery()
				.processInstanceId(processInstanceId).orderByHistoricTaskInstanceStartTime().asc().list();

		for (int i = 0; i < list.size(); i++) {
			HistoricTaskInstance histIns = list.get(i);

			if (StringUtils.isNotBlank(histIns.getAssignee()) && histIns.getEndTime() != null) {

				Act e = new Act();
				String deleteReason = histIns.getDeleteReason();

				if ("".equals(deleteReason) || deleteReason == null || deleteReason.equals("delete")) {
					e.setDeleteReason(WorkFlowConstants.RETURN);// 退回
				} else if (deleteReason.equals("completed")) {
					e.setDeleteReason(WorkFlowConstants.ADOPT);// 审批通过
				} else if (deleteReason.equals("1")) {
					e.setDeleteReason(WorkFlowConstants.WITHDRAW);// 撤回
				} else {
					e.setDeleteReason(WorkFlowConstants.SUBMIT);// 提交
				}

				e.setTaskId(histIns.getId());
				e.setStartTime(DateUtil.formatTime(histIns.getStartTime()));
				if (histIns.getEndTime() != null) {
					e.setEndTime(DateUtil.formatTime(histIns.getEndTime()));
				}
				e.setTenantId(histIns.getTenantId());
				e.setActivityName(histIns.getName());
				if (histIns.getDurationInMillis() != null) {
					long durationInMillis = histIns.getDurationInMillis();
					// 这个方法是将毫秒转化为几天几小时几分几秒
					String dueTime = (durationInMillis / (24 * 60 * 60 * 1000)) + "天"
							+ ((durationInMillis % (24 * 60 * 60 * 1000)) / (60 * 60 * 1000)) + "时"
							+ +((durationInMillis % (24 * 60 * 60 * 1000) % (60 * 60 * 1000)) / (60 * 1000)) + "分"
							+ +((durationInMillis % (24 * 60 * 60 * 1000) % (60 * 60 * 1000) % (60 * 1000)) / 1000)
							+ "秒";
					e.setDueTime(dueTime);
				}
				// 获取任务执行人名称
				if (StringUtils.isNotEmpty(histIns.getAssignee())) {
					PtyUser ptyUser = userService.selectByUsername(histIns.getAssignee());
					e.setAssignee(ptyUser == null ? "" : ptyUser.getUserName());
				}
				// 获取意见评论内容
				if (StringUtils.isNotBlank(histIns.getId())) {
					List<Comment> commentList = activitiEngine.getTaskService().getTaskComments(histIns.getId());
					if (commentList.size() > 0) {
						e.setComment(commentList.get(0).getFullMessage());
					}
				}
				actList.add(e);
			}

			if (histIns.getEndTime() == null) {
				Act e = new Act();
				e.setDeleteReason(WorkFlowConstants.TODOSUBMIT);// 待审核
				e.setStartTime(DateUtil.formatTime(histIns.getStartTime()));
				e.setActivityName(histIns.getName());
				String identityId = null;
				List<String> identityList = new ArrayList<String>();
				if (StringUtils.isNotBlank(histIns.getAssignee())) {
					PtyUser ptyUser = userService.selectByUsername(histIns.getAssignee());
					identityId =(ptyUser==null ? "" : ptyUser.getUserName());
				} else {
					List<IdentityLink> identityLinkList = activitiEngine.getTaskService()
							.getIdentityLinksForTask(histIns.getId());
					for (IdentityLink identityLink : identityLinkList) {
						String userId = identityLink.getUserId();
						String groupid = identityLink.getGroupId();
						if (StringUtils.isNotBlank(userId)) {
							PtyUser ptyUser = userService.selectByUsername(userId);
							identityList.add(ptyUser == null ? "" : ptyUser.getUserName());
						}
						if (StringUtils.isNotBlank(groupid)) {
							PtyRole role = new PtyRole();
							role.setRoleCode(groupid);
							List<PtyRole> ptyRole = roleService.selectByRoleCode(role);
							for (PtyRole roles : ptyRole) {
								identityList.add(roles == null ? "" : roles.getRoleName());
							}
						}
						identityList = identityList.stream().distinct().collect(Collectors.toList());
					}
					identityId = StringUtils.join(identityList.toArray(), ",");
				}
				e.setAssignee(identityId);
				actList.add(e);
			}

		}
		List<ProcessInstance> listProcess = activitiEngine.getRuntimeService().createProcessInstanceQuery()
				.processInstanceId(processInstanceId).list();
		if (listProcess.size() == 0 || listProcess == null) {
			actList.get(actList.size() - 1).setDeleteReason("已终审");
		}
		return actList;
	}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值