IAdmComAndEquipService.java 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.persagy.proxy.adm.service;
  2. import cn.hutool.core.collection.CollUtil;
  3. import cn.hutool.json.JSONUtil;
  4. import com.alibaba.fastjson.JSONArray;
  5. import com.fasterxml.jackson.databind.node.ArrayNode;
  6. import com.fasterxml.jackson.databind.node.JsonNodeFactory;
  7. import com.fasterxml.jackson.databind.node.ObjectNode;
  8. import com.persagy.dmp.basic.model.QueryCriteria;
  9. import com.persagy.dmp.define.entity.ObjectTypeDefine;
  10. import com.persagy.proxy.common.entity.DmpResult;
  11. import com.persagy.proxy.common.entity.InstanceUrlParam;
  12. import java.util.HashMap;
  13. import java.util.List;
  14. import java.util.Map;
  15. import java.util.Set;
  16. /**
  17. * @author lvxy
  18. * @date 2021/9/2
  19. */
  20. public interface IAdmComAndEquipService {
  21. default QueryCriteria getDmpCriteria(InstanceUrlParam context, Set<String> classCodes, String objType){
  22. QueryCriteria criteriaObject = new QueryCriteria();
  23. ObjectNode criteriaEq = JsonNodeFactory.instance.objectNode();
  24. ArrayNode array = criteriaEq.putObject("code").putArray("$in");
  25. classCodes.forEach(code -> array.add(code));
  26. criteriaEq.put("objType", objType);
  27. criteriaObject.setCriteria(criteriaEq);
  28. criteriaObject.setSize(classCodes.size() * 1L);
  29. criteriaObject.setPage(1L);
  30. criteriaObject.setWithoutCount(true);
  31. return criteriaObject;
  32. }
  33. default Map<String, ObjectTypeDefine> getDefineMap(DmpResult<JSONArray> resultDef){
  34. Map<String, ObjectTypeDefine> defClassMap = new HashMap<String, ObjectTypeDefine>();
  35. if(resultDef.getResult().equals(DmpResult.SUCCESS)){
  36. JSONArray defArr = resultDef.getData();
  37. List<ObjectTypeDefine> defineList = JSONUtil.toList(defArr.toString(), ObjectTypeDefine.class);
  38. defClassMap = CollUtil.fieldValueMap(defineList, "code");
  39. }
  40. return defClassMap;
  41. }
  42. }