LaunchUserServiceImpl.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package jnpf.flowable.service.impl;
  2. import cn.hutool.core.collection.CollectionUtil;
  3. import cn.hutool.core.util.ObjectUtil;
  4. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5. import jakarta.annotation.Resource;
  6. import jnpf.base.service.SuperServiceImpl;
  7. import jnpf.flowable.entity.LaunchUserEntity;
  8. import jnpf.flowable.mapper.LaunchUserMapper;
  9. import jnpf.flowable.model.util.FlowNature;
  10. import jnpf.flowable.service.LaunchUserService;
  11. import jnpf.flowable.util.ServiceUtil;
  12. import jnpf.flowable.util.TaskUtil;
  13. import jnpf.permission.entity.UserEntity;
  14. import jnpf.util.RandomUtil;
  15. import org.springframework.beans.factory.annotation.Autowired;
  16. import org.springframework.stereotype.Service;
  17. import java.util.ArrayList;
  18. import java.util.List;
  19. /**
  20. * 类的描述
  21. *
  22. * @author JNPF@YinMai Info. Co., Ltd
  23. * @version 5.0.x
  24. * @since 2024/4/18 9:46
  25. */
  26. @Service
  27. public class LaunchUserServiceImpl extends SuperServiceImpl<LaunchUserMapper, LaunchUserEntity> implements LaunchUserService {
  28. @Autowired
  29. private TaskUtil taskUtil;
  30. @Resource
  31. private ServiceUtil serviceUtil;
  32. @Override
  33. public LaunchUserEntity getInfoByTask(String taskId) {
  34. QueryWrapper<LaunchUserEntity> queryWrapper = new QueryWrapper<>();
  35. queryWrapper.lambda().eq(LaunchUserEntity::getTaskId, taskId);
  36. queryWrapper.lambda().eq(LaunchUserEntity::getType, FlowNature.TaskInitiation);
  37. return this.getOne(queryWrapper);
  38. }
  39. @Override
  40. public List<LaunchUserEntity> getTaskList(String taskId) {
  41. QueryWrapper<LaunchUserEntity> queryWrapper = new QueryWrapper<>();
  42. queryWrapper.lambda().eq(LaunchUserEntity::getTaskId, taskId);
  43. queryWrapper.lambda().eq(LaunchUserEntity::getType, FlowNature.StepInitiation);
  44. return this.list(queryWrapper);
  45. }
  46. @Override
  47. public void createLaunchUser(String taskId, String userId) {
  48. LaunchUserEntity launchUserEntity = this.getInfoByTask(taskId);
  49. if (null != launchUserEntity) {
  50. return;
  51. }
  52. UserEntity user = serviceUtil.getUserInfo(userId);
  53. if (null != user) {
  54. LaunchUserEntity entity = new LaunchUserEntity();
  55. entity.setId(RandomUtil.uuId());
  56. entity.setTaskId(taskId);
  57. entity.setType(FlowNature.TaskInitiation);
  58. taskUtil.launchUser(entity, user);
  59. // Department用到时,再递归获取 serviceUtil.getDepartmentAll
  60. this.save(entity);
  61. }
  62. }
  63. @Override
  64. public void delete(String taskId) {
  65. delete(taskId, new ArrayList<>());
  66. }
  67. @Override
  68. public void delete(String taskId, List<String> nodeCode) {
  69. QueryWrapper<LaunchUserEntity> queryWrapper = new QueryWrapper<>();
  70. queryWrapper.lambda().eq(LaunchUserEntity::getTaskId, taskId);
  71. if (ObjectUtil.isNotEmpty(nodeCode)) {
  72. queryWrapper.lambda().in(LaunchUserEntity::getNodeCode, nodeCode);
  73. }
  74. List<LaunchUserEntity> list = this.list(queryWrapper);
  75. if (CollectionUtil.isNotEmpty(list)) {
  76. this.removeByIds(list);
  77. }
  78. }
  79. @Override
  80. public void deleteStepUser(String taskId) {
  81. List<LaunchUserEntity> list = getTaskList(taskId);
  82. if (CollectionUtil.isNotEmpty(list)) {
  83. this.removeByIds(list);
  84. }
  85. }
  86. }