SubtaskDataServiceImpl.java 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package jnpf.flowable.service.impl;
  2. import cn.hutool.core.collection.CollectionUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import jnpf.base.service.SuperServiceImpl;
  5. import jnpf.flowable.entity.SubtaskDataEntity;
  6. import jnpf.flowable.mapper.SubtaskDataMapper;
  7. import jnpf.flowable.model.task.FlowModel;
  8. import jnpf.flowable.service.SubtaskDataService;
  9. import jnpf.util.JsonUtil;
  10. import jnpf.util.RandomUtil;
  11. import org.springframework.stereotype.Service;
  12. import java.util.ArrayList;
  13. import java.util.List;
  14. /**
  15. * 类的描述
  16. *
  17. * @author JNPF@YinMai Info. Co., Ltd
  18. * @version 5.0.x
  19. * @since 2024/12/6 15:35
  20. */
  21. @Service
  22. public class SubtaskDataServiceImpl extends SuperServiceImpl<SubtaskDataMapper, SubtaskDataEntity> implements SubtaskDataService {
  23. @Override
  24. public List<SubtaskDataEntity> getList(String parentId, String parentCode) {
  25. QueryWrapper<SubtaskDataEntity> queryWrapper = new QueryWrapper<>();
  26. queryWrapper.lambda().eq(SubtaskDataEntity::getParentId, parentId).eq(SubtaskDataEntity::getNodeCode, parentCode)
  27. .orderByAsc(SubtaskDataEntity::getSortCode);
  28. return this.list(queryWrapper);
  29. }
  30. @Override
  31. public void save(List<FlowModel> subTaskData) {
  32. if (CollectionUtil.isEmpty(subTaskData)) {
  33. return;
  34. }
  35. List<SubtaskDataEntity> list = new ArrayList<>();
  36. for (int i = 0; i < subTaskData.size(); i++) {
  37. FlowModel model = subTaskData.get(i);
  38. SubtaskDataEntity entity = new SubtaskDataEntity();
  39. entity.setId(RandomUtil.uuId());
  40. entity.setParentId(model.getParentId());
  41. entity.setNodeCode(model.getSubCode());
  42. entity.setSubtaskJson(JsonUtil.getObjectToString(model));
  43. int sortCode = i + 1;
  44. entity.setSortCode((long) sortCode);
  45. list.add(entity);
  46. }
  47. if (CollectionUtil.isNotEmpty(list)) {
  48. this.saveBatch(list);
  49. }
  50. }
  51. }