From c4ab6a24d2825f11a0de0f165667dc533c458a01 Mon Sep 17 00:00:00 2001 From: zxl <763096477@qq.com> Date: 星期五, 21 三月 2025 10:57:44 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- business/src/main/java/com/ycl/service/impl/ProcessLogServiceImpl.java | 110 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 103 insertions(+), 7 deletions(-) diff --git a/business/src/main/java/com/ycl/service/impl/ProcessLogServiceImpl.java b/business/src/main/java/com/ycl/service/impl/ProcessLogServiceImpl.java index 7037772..306abc1 100644 --- a/business/src/main/java/com/ycl/service/impl/ProcessLogServiceImpl.java +++ b/business/src/main/java/com/ycl/service/impl/ProcessLogServiceImpl.java @@ -5,24 +5,30 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.common.base.Result; +import com.ycl.common.core.domain.entity.SysDept; +import com.ycl.common.core.domain.entity.SysRole; +import com.ycl.common.core.domain.entity.SysUser; +import com.ycl.common.enums.business.HandlerTypeEnum; import com.ycl.common.enums.business.ProcessLogEventTypeEnum; import com.ycl.domain.entity.ProcessLog; -import com.ycl.domain.json.DelegateData; -import com.ycl.domain.json.JumpData; -import com.ycl.domain.json.RejectData; -import com.ycl.domain.json.SuperviseData; +import com.ycl.domain.json.*; import com.ycl.domain.query.ProcessLogQuery; import com.ycl.domain.vo.ProcessLogVO; import com.ycl.framework.utils.PageUtil; import com.ycl.mapper.ProcessLogMapper; import com.ycl.service.ProcessLogService; +import com.ycl.system.service.ISysDeptService; +import com.ycl.system.service.ISysRoleService; +import com.ycl.system.service.ISysUserService; import lombok.RequiredArgsConstructor; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.util.Assert; +import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; /** @@ -36,6 +42,9 @@ public class ProcessLogServiceImpl extends ServiceImpl<ProcessLogMapper, ProcessLog> implements ProcessLogService { private final ProcessLogMapper processLogMapper; + private final ISysUserService userService; + private final ISysDeptService deptService; + private final ISysRoleService roleService; /** * 娣诲姞鏃ュ織 @@ -46,7 +55,7 @@ * @param eventDataJson json鎵╁睍鍐呭 */ @Override - public void add(String taskId, String flowInsId, ProcessLogEventTypeEnum eventType, Long projectId, String eventDataJson) { + public void add(String taskId, String flowInsId, ProcessLogEventTypeEnum eventType, String projectId, String eventDataJson) { ProcessLog log = new ProcessLog(); log.setTaskId(taskId); log.setProcessInsId(flowInsId); @@ -125,6 +134,50 @@ return CollectionUtils.isNotEmpty(list); } + @Override + public Boolean taskIsHangup(String taskId, String processInsId) { + Long num = new LambdaQueryChainWrapper<>(baseMapper) + .eq(ProcessLog::getProcessInsId, processInsId) + .eq(ProcessLog::getTaskId, taskId) + .in(ProcessLog::getEventType, ProcessLogEventTypeEnum.HANGUP, ProcessLogEventTypeEnum.CANCEL_HANGUP) + .count(); + return num % 2 != 0; + } + + @Override + public Boolean taskIsWait(String taskId, String processInsId) { + List<ProcessLog> list = new LambdaQueryChainWrapper<>(baseMapper) + .eq(ProcessLog::getProcessInsId, processInsId) + .eq(ProcessLog::getTaskId, taskId) + .list(); + return list.stream().anyMatch(log -> ProcessLogEventTypeEnum.WAIT.equals(log.getEventType())) + && list.stream().filter(log -> ProcessLogEventTypeEnum.FINISHED.equals(log.getEventType())).count() < 1; + } + + @Override + public Boolean taskIsJump(String taskId, String processInsId) { + List<ProcessLog> list = new LambdaQueryChainWrapper<>(baseMapper) + .eq(ProcessLog::getProcessInsId, processInsId) + .eq(ProcessLog::getTaskId, taskId) + .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.JUMP) + .list(); + return list.size() > 0; + } + + @Override + public Boolean taskIsTeamwork(String taskId, String processInsId) { + ProcessLog log = new LambdaQueryChainWrapper<>(baseMapper) + .eq(ProcessLog::getProcessInsId, processInsId) + .eq(ProcessLog::getTaskId, taskId) + .eq(ProcessLog::getEventType, ProcessLogEventTypeEnum.TEAM_WORK) + .one(); + if (Objects.isNull(log)) { + return Boolean.FALSE; + } else { + // 鍒ゆ柇鍗忓悓浜烘槸鍚﹀叏閮ㄥ畬鎴愪簡鍗忓悓銆俆ODO + } + return null; + } @Override public Result projectProcessLogPage(ProcessLogQuery query) { @@ -133,16 +186,59 @@ list.stream().forEach(log -> { if (StringUtils.isNotBlank(log.getEventDataJson())) { if (ProcessLogEventTypeEnum.DELEGATE.equals(log.getEventType())) { - log.setEventDataObj(JSON.parseObject(log.getEventDataJson(), DelegateData.class)); + DelegateData delegateData = JSON.parseObject(log.getEventDataJson(), DelegateData.class); + // 鏌ヨ杞姙鍚庣殑澶勭悊浜哄悕绉� + List<String> names = new ArrayList<>(2); + List<Long> ids = delegateData.getAfterHandlerIds().stream().map(Long::parseLong).collect(Collectors.toList()); + this.getName(delegateData.getAfterHandlerType(), ids, names); + delegateData.setAfterHandlerNames(names); + log.setEventDataObj(delegateData); } else if (ProcessLogEventTypeEnum.JUMP.equals(log.getEventType())) { log.setEventDataObj(JSON.parseObject(log.getEventDataJson(), JumpData.class)); + } else if (ProcessLogEventTypeEnum.WAIT.equals(log.getEventType())) { + log.setEventDataObj(JSON.parseObject(log.getEventDataJson(), WaitData.class)); } else if (ProcessLogEventTypeEnum.REJECT.equals(log.getEventType())) { log.setEventDataObj(JSON.parseObject(log.getEventDataJson(), RejectData.class)); } else if (ProcessLogEventTypeEnum.SUPERVISE.equals(log.getEventType())) { - log.setEventDataObj(JSON.parseObject(log.getEventDataJson(), SuperviseData.class)); + List<SuperviseData> superviseDataList = JSON.parseArray(log.getEventDataJson(), SuperviseData.class); + if (CollectionUtils.isNotEmpty(superviseDataList)) { + SysUser user = userService.selectUserById(Long.parseLong(superviseDataList.get(0).getSenderId())); + if (Objects.nonNull(user)) { + superviseDataList.get(0).setSenderName(user.getNickName() + "(" + (Objects.nonNull(user.getDept()) ? user.getDept().getDeptName() : "鏃犻儴闂�") + ")"); + } + log.setEventDataObj(superviseDataList.get(0)); + } + + } else if (ProcessLogEventTypeEnum.HANGUP.equals(log.getEventType())) { + log.setEventDataObj(JSON.parseObject(log.getEventDataJson(), HangupData.class)); } } }); return Result.ok().data(list); } + + /** + * 瑙f瀽娴佺▼鏃ュ織涓殑鏁版嵁-鍚嶇О + * + * @param handlerType + * @param ids + * @param names + */ + private void getName(HandlerTypeEnum handlerType, List<Long> ids, List<String> names) { + if (HandlerTypeEnum.FIX_USER.equals(handlerType)) { + SysUser user = userService.selectUserById(ids.get(0)); + if (Objects.nonNull(user)) { + names.add(user.getNickName() + "(" + (Objects.nonNull(user.getDept()) ? user.getDept().getDeptName() : "鏃犻儴闂�") + ")"); + } + } else if (HandlerTypeEnum.USER.equals(handlerType)) { + List<SysUser> users = userService.selectUserByIds(ids); + names.addAll(users.stream().map(user -> user.getNickName() + "(" + (Objects.nonNull(user.getDept()) ? user.getDept().getDeptName() : "鏃犻儴闂�") + ")").collect(Collectors.toList())); + } else if (HandlerTypeEnum.DEPT.equals(handlerType)) { + List<SysDept> depts = deptService.selectDeptByIds(ids); + names.addAll(depts.stream().map(SysDept::getDeptName).collect(Collectors.toList())); + } else if (HandlerTypeEnum.ROLE.equals(handlerType)) { + List<SysRole> roles = roleService.selectRoleByIds(ids); + names.addAll(roles.stream().map(SysRole::getRoleName).collect(Collectors.toList())); + } + } } -- Gitblit v1.8.0