package com.persagy.proxy.adm.service; import cn.hutool.core.collection.CollUtil; import cn.hutool.json.JSONUtil; import com.alibaba.fastjson.JSONArray; import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.persagy.dmp.basic.model.QueryCriteria; import com.persagy.dmp.define.entity.ObjectTypeDefine; import com.persagy.proxy.common.entity.DmpResult; import com.persagy.proxy.common.entity.InstanceUrlParam; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; /** * @author lvxy * @date 2021/9/2 */ public interface IAdmComAndEquipService { default QueryCriteria getDmpCriteria(InstanceUrlParam context, Set classCodes, String objType){ QueryCriteria criteriaObject = new QueryCriteria(); ObjectNode criteriaEq = JsonNodeFactory.instance.objectNode(); ArrayNode array = criteriaEq.putObject("code").putArray("$in"); classCodes.forEach(code -> array.add(code)); criteriaEq.put("objType", objType); criteriaObject.setCriteria(criteriaEq); criteriaObject.setSize(classCodes.size() * 1L); criteriaObject.setPage(1L); criteriaObject.setWithoutCount(true); return criteriaObject; } default Map getDefineMap(DmpResult resultDef){ Map defClassMap = new HashMap(); if(resultDef.getResult().equals(DmpResult.SUCCESS)){ JSONArray defArr = resultDef.getData(); List defineList = JSONUtil.toList(defArr.toString(), ObjectTypeDefine.class); defClassMap = CollUtil.fieldValueMap(defineList, "code"); } return defClassMap; } }