| | |
| | | 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.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; |
| | | |
| | | /** |
| | |
| | | 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; |
| | | |
| | | /** |
| | | * 添加日志 |
| | |
| | | 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.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)); |
| | | SuperviseData superviseData = JSON.parseObject(log.getEventDataJson(), SuperviseData.class); |
| | | SysUser user = userService.selectUserById(Long.parseLong(superviseData.getSenderId())); |
| | | if (Objects.nonNull(user)) { |
| | | superviseData.setSenderName(user.getNickName() + "(" + (Objects.nonNull(user.getDept()) ? user.getDept().getDeptName() : "无部门") + ")"); |
| | | } |
| | | log.setEventDataObj(superviseData); |
| | | } |
| | | } |
| | | }); |
| | | return Result.ok().data(list); |
| | | } |
| | | |
| | | /** |
| | | * 解析流程日志中的数据-名称 |
| | | * |
| | | * @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 = 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 = depts.stream().map(SysDept::getDeptName).collect(Collectors.toList()); |
| | | } else if (HandlerTypeEnum.ROLE.equals(handlerType)) { |
| | | List<SysRole> roles = roleService.selectRoleByIds(ids); |
| | | names = roles.stream().map(SysRole::getRoleName).collect(Collectors.toList()); |
| | | } |
| | | } |
| | | } |