FlowOperatorHolder.java 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package jnpf.flowable.model.util;
  2. import jnpf.util.JsonUtil;
  3. import java.util.ArrayList;
  4. import java.util.HashMap;
  5. import java.util.List;
  6. import java.util.Map;
  7. public class FlowOperatorHolder {
  8. // 审批人
  9. private static final ThreadLocal<List<FlowOperatorModel>> LIST = new ThreadLocal<>();
  10. /**
  11. * 获取审批人
  12. */
  13. public static List<FlowOperatorModel> getOperatorList() {
  14. List<FlowOperatorModel> list = LIST.get() != null ? LIST.get() : new ArrayList<>();
  15. return list;
  16. }
  17. /**
  18. * 添加审批人
  19. */
  20. public static void addOperator(FlowOperatorModel model, Map<String, Map<String, Object>> allData) {
  21. Map<String, Map<String, Object>> data = new HashMap<>();
  22. for (String key : allData.keySet()) {
  23. Map<String, Object> dataValue = JsonUtil.entityToMap(allData.get(key));
  24. data.put(key, dataValue);
  25. }
  26. model.setAllData(data);
  27. List<FlowOperatorModel> list = LIST.get() != null ? LIST.get() : new ArrayList<>();
  28. list.add(model);
  29. LIST.set(list);
  30. }
  31. /**
  32. * 清除数据
  33. */
  34. public static void clear() {
  35. LIST.remove();
  36. }
  37. }