package jnpf.flowable.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import jakarta.annotation.Resource; import jnpf.base.service.SuperServiceImpl; import jnpf.flowable.entity.LaunchUserEntity; import jnpf.flowable.mapper.LaunchUserMapper; import jnpf.flowable.model.util.FlowNature; import jnpf.flowable.service.LaunchUserService; import jnpf.flowable.util.ServiceUtil; import jnpf.flowable.util.TaskUtil; import jnpf.permission.entity.UserEntity; import jnpf.util.RandomUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; /** * 类的描述 * * @author JNPF@YinMai Info. Co., Ltd * @version 5.0.x * @since 2024/4/18 9:46 */ @Service public class LaunchUserServiceImpl extends SuperServiceImpl implements LaunchUserService { @Autowired private TaskUtil taskUtil; @Resource private ServiceUtil serviceUtil; @Override public LaunchUserEntity getInfoByTask(String taskId) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(LaunchUserEntity::getTaskId, taskId); queryWrapper.lambda().eq(LaunchUserEntity::getType, FlowNature.TaskInitiation); return this.getOne(queryWrapper); } @Override public List getTaskList(String taskId) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(LaunchUserEntity::getTaskId, taskId); queryWrapper.lambda().eq(LaunchUserEntity::getType, FlowNature.StepInitiation); return this.list(queryWrapper); } @Override public void createLaunchUser(String taskId, String userId) { LaunchUserEntity launchUserEntity = this.getInfoByTask(taskId); if (null != launchUserEntity) { return; } UserEntity user = serviceUtil.getUserInfo(userId); if (null != user) { LaunchUserEntity entity = new LaunchUserEntity(); entity.setId(RandomUtil.uuId()); entity.setTaskId(taskId); entity.setType(FlowNature.TaskInitiation); taskUtil.launchUser(entity, user); // Department用到时,再递归获取 serviceUtil.getDepartmentAll this.save(entity); } } @Override public void delete(String taskId) { delete(taskId, new ArrayList<>()); } @Override public void delete(String taskId, List nodeCode) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.lambda().eq(LaunchUserEntity::getTaskId, taskId); if (ObjectUtil.isNotEmpty(nodeCode)) { queryWrapper.lambda().in(LaunchUserEntity::getNodeCode, nodeCode); } List list = this.list(queryWrapper); if (CollectionUtil.isNotEmpty(list)) { this.removeByIds(list); } } @Override public void deleteStepUser(String taskId) { List list = getTaskList(taskId); if (CollectionUtil.isNotEmpty(list)) { this.removeByIds(list); } } }