123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518 |
- package com.persagy.proxy.adm.controller;
- import cn.hutool.core.collection.CollUtil;
- import cn.hutool.core.util.StrUtil;
- 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.common.model.entity.BaseEntity;
- import com.persagy.dmp.define.client.DigitalDefineFacade;
- import com.persagy.dmp.define.entity.ObjectTypeDefine;
- import com.persagy.dmp.digital.client.DigitalObjectFacade;
- import com.persagy.dmp.digital.client.DigitalRelationFacade;
- import com.persagy.dmp.digital.entity.ObjectRelation;
- import com.persagy.proxy.adm.constant.AdmCommonConstant;
- import com.persagy.proxy.adm.model.*;
- import com.persagy.proxy.adm.request.AdmCreateRequest;
- import com.persagy.proxy.adm.request.AdmQueryCriteria;
- import com.persagy.proxy.adm.request.AdmResponse;
- import com.persagy.proxy.adm.service.IAdmBuildingService;
- import com.persagy.proxy.adm.service.IAdmFloorService;
- import com.persagy.proxy.adm.service.IAdmSystemService;
- import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
- import com.persagy.proxy.adm.utils.ObjectNameUtil;
- import com.persagy.proxy.common.entity.InstanceUrlParam;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.web.bind.annotation.*;
- import javax.json.JsonObject;
- import javax.validation.constraints.NotNull;
- import javax.ws.rs.QueryParam;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- /**
- * Adm 系统 API
- * @author lvxy
- * @date 2021/8/16
- */
- @RestController
- @RequestMapping("/object/general-system")
- public class AdmSystemController {
- @Autowired
- private IAdmSystemService service;
- @Autowired
- private IAdmBuildingService buildingService;
- @Autowired
- private IAdmFloorService floorService;
- @Value("${middleware.group.code}")
- private String groupCode;
- /**
- * 统计
- * @param projectId
- * @param request
- * @return
- * @throws Exception
- */
- @PostMapping("/count")
- public AdmResponse count(@QueryParam("projectId") String projectId,
- @RequestBody AdmQueryCriteria request) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- request.setName(AdmSystem.OBJ_TYPE);
- request.setOnlyCount(true);
- return service.doQuery(context, request, AdmSystem.class);
- }
- /**
- * 创建
- * @param createRequest
- * @return
- * @throws Exception
- */
- @PostMapping("/create")
- public AdmResponse create(@RequestBody AdmCreateRequest<AdmSystem> createRequest, @QueryParam("projectId") String projectId) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- List<AdmSystem> vos = CollUtil.newArrayList(createRequest.getContent());
- vos = service.doInsert(context, AdmSystem.class, vos);
- return AdmResponse.success(vos);
- }
- /**
- * 创建系统信息-处理建筑楼层
- * @param createRequest
- * @return
- * @throws Exception
- */
- @PostMapping("/create-bd-fl")
- public AdmResponse createBdFl(@RequestBody AdmCreateRequest<AdmSystem> createRequest, @QueryParam("projectId") String projectId) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- List<AdmSystem> vos = CollUtil.newArrayList(createRequest.getContent());
- Map<String, AdmSystem> admSystemMap = CollUtil.fieldValueMap(vos, "classCode");
- QueryCriteria defineCriteria = new QueryCriteria();
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- ArrayNode array = criteria.putObject("code").putArray("$in");
- admSystemMap.keySet().stream().forEach(classCode -> array.add(classCode));
- defineCriteria.setCriteria(criteria);
- List<ObjectTypeDefine> defineList = DigitalDefineFacade.queryObjectType(context.getGroupCode(),context.getProjectId(),context.getAppId(),null,defineCriteria);
- Map<String, ObjectTypeDefine> defineMap = CollUtil.fieldValueMap(defineList, "code");
- vos.stream().forEach(admSystem -> {
- if(StrUtil.isEmpty(admSystem.getName())){
- if(CollUtil.isNotEmpty(defineList) && defineMap.containsKey(admSystem.getClassCode())){
- admSystem.setName(ObjectNameUtil.objectName(defineMap.get(admSystem.getClassCode()).getName()+"系统-"));
- }else {
- admSystem.setName(ObjectNameUtil.objectName("系统-"));
- }
- }
- });
- vos = service.doInsert(context, AdmSystem.class, vos);
- return AdmResponse.success(vos);
- }
- /**
- * 根据ID删除
- * @param vos
- * @return
- * @throws Exception
- */
- @PostMapping("/delete")
- public AdmResponse delete(@QueryParam("projectId") String projectId, @RequestBody List<AdmSystem> vos) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- service.doDelete(context, vos);
- return AdmResponse.success();
- }
- /**
- * 更新
- * @param createRequest
- * @return
- * @throws Exception
- */
- @PostMapping("/update")
- public AdmResponse update(@RequestBody AdmCreateRequest<AdmSystem> createRequest, @QueryParam("projectId") String projectId) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- List<AdmSystem> vos = CollUtil.newArrayList(createRequest.getContent());
- vos = service.doUpdate(context, AdmSystem.class, vos);
- return AdmResponse.success(vos);
- }
- /**
- * 系统绑定的动态信息点或静态信息点
- * type: static(静态),iot (动态)
- * @param projectId
- * @param request
- * @return
- * @throws Exception
- */
- @GetMapping("/export")
- public AdmResponse exportInfos(@QueryParam("projectId") String projectId,
- @RequestBody AdmQueryCriteria request) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- request.setName(AdmSystem.OBJ_TYPE);
- return service.doQuery(context, request, AdmSystem.class);
- }
- /**
- * 创建系统下的设备关系
- * @param createRequest
- * @return
- * @throws Exception
- */
- @PostMapping("/link-equip")
- public AdmResponse createRelateEquip(@RequestBody JsonObject createRequest, @QueryParam("projectId") String projectId) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- String sysId = createRequest.get("sysId").toString();
- List<String> equipIdList = (List<String>)createRequest.get("equipIdList");
- List<ObjectNode> relations = new ArrayList<>(equipIdList.size());
- equipIdList.stream().forEach(euipId -> {
- ObjectNode objectNode = JsonNodeFactory.instance.objectNode();
- objectNode.put("relCode", "Sy2Eq");
- objectNode.put("graphCode","MechSubset");
- objectNode.put("objFrom", sysId);
- objectNode.put("objTo", euipId);
- });
- List<ObjectRelation> list = DigitalRelationFacade.create(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, relations);
- return AdmResponse.success(list);
- }
- /**
- * 查询
- * @param projectId
- * @param request
- * @return
- * @throws Exception
- */
- @PostMapping("/query")
- public AdmResponse query(@QueryParam("projectId") String projectId,
- @RequestBody AdmQueryCriteria request) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- request.setName(AdmSystem.OBJ_TYPE);
- return service.doQuery(context, request, AdmSystem.class);
- }
- /**
- * 查询系统信息-系统建筑楼层一对多
- * MajorName 专业名称 ,级联查询 系统分类名(categoryNames),系统下的设备(equipmentList),系统下的竖井(shaftList),业务空间(zoneSpaceBaseTableList)
- *
- * 这个参见中心代码,
- * @param projectId
- * @param buildingId buildingId=1,未明确建筑
- * @param floorId floorId=1,未明确楼层
- * @param request
- * @return
- * @throws Exception
- */
- @PostMapping("/query-new")
- public AdmResponse queryNew(@QueryParam("projectId") String projectId, @QueryParam("buildingId") String buildingId,
- @QueryParam("floorId") String floorId, @RequestBody AdmQueryCriteria request) throws Exception {
- if(StrUtil.isEmpty(projectId)){
- return AdmResponse.failure("项目id为空");
- }
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- if(StrUtil.isAllNotEmpty(buildingId, floorId) && !"1".equals(buildingId) && !"1".equals(floorId)){
- //系统级联建筑 楼层
- AdmResponse syses = service.doQuery(context, request, AdmSystem.class);
- if(CollUtil.isEmpty(syses.getContent())){
- return syses;
- }
- AdmQueryCriteria admQueryCriteria = new AdmQueryCriteria();
- admQueryCriteria.setName(AdmBuilding.OBJ_TYPE);
- admQueryCriteria.setFilters("id = "+buildingId);
- AdmResponse buildings = buildingService.doQuery(context, request, AdmBuilding.class);
- admQueryCriteria = new AdmQueryCriteria();
- admQueryCriteria.setName(AdmFloor.OBJ_TYPE);
- admQueryCriteria.setFilters("id = "+floorId);
- AdmResponse floors = floorService.doQuery(context, request, AdmFloor.class);
- //处理数据 BuildingFloorInfo
- AdmBuildingFloorInfo buildingFloorInfo = new AdmBuildingFloorInfo();
- if(CollUtil.isNotEmpty(floors.getContent())){
- AdmFloor floor = (AdmFloor) floors.getContent().get(0);
- buildingFloorInfo.setFloorName(floor.getLocalName());
- buildingFloorInfo.setFloorID(floorId);
- }
- if(CollUtil.isNotEmpty(buildings.getContent())){
- AdmBuilding building = (AdmBuilding) floors.getContent().get(0);
- buildingFloorInfo.setBuildName(building.getLocalName());
- buildingFloorInfo.setBuildID(buildingId);
- }
- List<AdmSystem> admSystemList = (List<AdmSystem>) syses.getContent();
- admSystemList.stream().forEach( admSystem -> {
- admSystem.setBuildingFloorInfoList(CollUtil.newArrayList(buildingFloorInfo));
- });
- syses.setContent(admSystemList);
- return syses;
- }
- return null;
- /*
- QueryCriteria queryCriteria_sysInFl = new QueryCriteria();
- ObjectNode criteria_sysInFl = JsonNodeFactory.instance.objectNode();
- criteria_sysInFl.put("relCode","Sy2Fl");
- criteria_sysInFl.put("graphCode", "MechInArch");
- QueryCriteria queryCriteria_sysInBd = new QueryCriteria();
- ObjectNode criteria_sysInBd= JsonNodeFactory.instance.objectNode();
- criteria_sysInBd.put("graphCode", "MechInArch");
- criteria_sysInBd.put("relCode","Sy2Bd");
- QueryCriteria queryCriteriaObj = AdmQueryCriteriaHelper.toDmpCriteria(request);
- ObjectNode criteria_obj = JsonNodeFactory.instance.objectNode();
- criteria_obj.put("objType", AdmSystem.OBJ_TYPE);
- Set<String> sysIds = new HashSet<>();
- List<ObjectRelation> relations_SysInFl = null;
- if(StrUtil.isAllNotEmpty(buildingId,floorId)&&!floorId.equals("1")){
- *//** 楼层id不为空且不为1,建筑id为空 ---> 系统和楼层关系表 取系统id 408 --> 明确建筑明确楼层->空间*//*
- criteria_sysInFl.put("objTo", floorId);
- queryCriteria_sysInFl.setCriteria(criteria_sysInFl);
- relations_SysInFl = DigitalRelationFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteria_sysInFl);
- if(CollUtil.isNotEmpty(relations_SysInFl)){
- sysIds = relations_SysInFl.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toSet());
- }
- ensureCondion(context, null, sysIds, criteria_obj,true);
- }else if(StrUtil.isAllNotEmpty(buildingId,floorId)&&floorId.equals("1")&&!buildingId.equals("1")){
- *//** 楼层id为空,建筑id不为空且不为1 ---> 系统和建筑关系表 取系统id 421*//*
- // 明确建筑 未明确楼层
- relations_SysInFl = DigitalRelationFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteria_sysInFl);
- if(CollUtil.isNotEmpty(relations_SysInFl)){
- List<String> sysIds_floor = relations_SysInFl.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toList());
- criteria_sysInBd.put("objTo", buildingId);
- ArrayNode arrayNode = criteria_sysInBd.putObject("$notcontains").putArray("objFrom");
- sysIds_floor.stream().forEach(id -> arrayNode.add(id));
- queryCriteria_sysInBd.setCriteria(criteria_sysInBd);
- ensureCondion(context, queryCriteria_sysInBd, sysIds, criteria_obj,true);
- }
- }else if(StrUtil.isEmpty(floorId) && StrUtil.isNotEmpty(buildingId) && buildingId.equals("1")){
- *//** 楼层id为1,建筑id为1 ---> 系统id不在(系统和楼层关系表 取系统id 系统和建筑关系表 取系统id)之内 450*//*
- //未明确建筑 没有Sy2Bd关系的系统
- ensureCondion(context, queryCriteria_sysInBd, sysIds, criteria_obj,false);
- }else if(StrUtil.isEmpty(floorId) && StrUtil.isNotEmpty(buildingId) && !buildingId.equals("1")){
- *//** 楼层id不为空,建筑id不为空 ---> 系统和楼层关系表 取系统id 将建筑id作为条件 461*//*
- criteria_sysInBd.put("objTo", buildingId);
- queryCriteria_sysInBd.setCriteria(criteria_sysInBd);
- ensureCondion(context, queryCriteria_sysInBd, sysIds, criteria_obj,true);
- } else if(StrUtil.isAllEmpty(floorId, buildingId)){
- *//** 楼层id为空,建筑id为空 ---> 查询所有 *//*
- }
- queryCriteriaObj.setCriteria(criteria_obj);
- List<ObjectNode> systems = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaObj);
- if(CollUtil.isNotEmpty(systems)){
- List<AdmSystem> admSystemList = JSONUtil.toList(systems.toString(), AdmSystem.class);
- if(StrUtil.isNotEmpty(buildingId)){
- if(!buildingId.equals("1")){
- //处理数据 添加每个系统关联的建筑楼层信息, 查看全部信息展示所在建筑
- //查询关联的建筑信息
- QueryCriteria queryCriteriaInfo = new QueryCriteria();
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- ArrayNode arrayNode = criteria.putObject("id").putArray("$in");
- arrayNode.add(buildingId);
- if(StrUtil.isNotEmpty(floorId)){
- //明确的建筑,明确的楼层 查询建筑关联的楼层信息 如果Sy2Fl -> Sy2Bd & Bd2Fl
- if(!floorId.equals("1")){
- arrayNode.add(floorId);
- }
- queryCriteriaInfo.setCriteria(criteria);
- List<ObjectNode> objs = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaInfo);
- if(CollUtil.isNotEmpty(objs)){
- List<ObjectDigital> objectDigitals = JSONUtil.toList(objs.toString(), ObjectDigital.class);
- AdmBuildingFloorInfo admBuildingFloorInfo = new AdmBuildingFloorInfo();
- objectDigitals.forEach(objectDigital -> {
- if(objectDigital.getObjType().equals(AdmFloor.OBJ_TYPE)){
- admBuildingFloorInfo.setFloorID(objectDigital.getId());
- admBuildingFloorInfo.setFloorName(objectDigital.getLocalName());
- }
- if(objectDigital.getObjType().equals(AdmBuilding.OBJ_TYPE)){
- admBuildingFloorInfo.setBuildID(objectDigital.getId());
- admBuildingFloorInfo.setBuildName(objectDigital.getLocalName());
- }
- });
- admSystemList.stream().forEach(admSystem -> admSystem.setBuildingFloorInfoList(CollUtil.newArrayList(admBuildingFloorInfo)));
- }
- }
- }
- }else{
- //查询每个系统的建筑楼层信息
- Map<String, AdmSystem> admSystemMap = CollUtil.fieldValueMap(admSystemList, BaseEntity.PROP_ID);
- //查询
- //查询楼层
- }
- return AdmResponse.success(systems);
- }else{
- return AdmResponse.success();
- }*/
- }
- /*private void ensureCondion(InstanceUrlParam context, QueryCriteria queryCriteria_sysInBd, Set<String>sysIds, ObjectNode criteria_obj, boolean ifInCondition){
- if(queryCriteria_sysInBd != null){
- List<ObjectRelation> relations_SysInBd = DigitalRelationFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteria_sysInBd);
- if(CollUtil.isNotEmpty(relations_SysInBd)){
- sysIds = relations_SysInBd.stream().map(ObjectRelation::getObjFrom).collect(Collectors.toSet());
- }
- }
- if(CollUtil.isNotEmpty(sysIds)){
- if(ifInCondition){
- criteria_obj.put("id", sysIds.toArray().toString());
- }else {
- ArrayNode arrayNode = criteria_obj.putObject("$notcontains").putArray("id");
- sysIds.stream().forEach(id -> arrayNode.add(id));
- }
- }
- }*/
- /**
- * 查询系统信息-试图级联建筑楼层 暂未使用
- * @param projectId
- * @param request
- * @return
- * @throws Exception
- */
- @PostMapping("/query-bdfl")
- public AdmResponse queryUnBdFl(@QueryParam("projectId") String projectId,
- @RequestBody AdmQueryCriteria request) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- request.setName(AdmSystem.OBJ_TYPE);
- return service.doQuery(context, request, AdmSystem.class);
- }
- /**
- * 查询没有和当前系统关联的设备
- * id 为系统id
- * @param projectId
- * @param request
- * @return
- * @throws Exception
- */
- @PostMapping("/un-sys-equip")
- public AdmResponse queryUnEquip(@QueryParam("projectId") String projectId, @NotNull @QueryParam("sysId") String sysId,
- @RequestBody AdmQueryCriteria request) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- AdmResponse admResponse = queryObjectByType(context,sysId,request,"Sy2Eq","MechSubset", AdmEquipment.OBJ_TYPE);
- return admResponse;
- }
- /**
- * 查询没有和当前系统关联的竖井
- * id 为系统id
- * @param projectId
- * @param request
- * @return
- * @throws Exception
- */
- @PostMapping("/un-sys-shaft")
- public AdmResponse queryUnSh(@QueryParam("projectId") String projectId, @NotNull @QueryParam("sysId") String sysId,
- @RequestBody AdmQueryCriteria request) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- AdmResponse admResponse = queryObjectByType(context,sysId,request,"Sy2Sh",null, AdmShaft.OBJ_TYPE);
- return admResponse;
- }
- /**
- * 查询没有和当前系统关联的业务空间
- * id 为系统id
- * @param projectId
- * @param request
- * @return
- * @throws Exception
- */
- @PostMapping("/un-sys-zoneSpaceBaseTable")
- public AdmResponse queryUnZoneSp(@QueryParam("projectId") String projectId,@NotNull @QueryParam("sysId") String sysId,
- @RequestBody AdmQueryCriteria request) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- AdmResponse admResponse = queryObjectByType(context,sysId,request,"Sy2Sp",null, AdmSpace.OBJ_TYPE);
- return admResponse;
- }
- /**
- * 查询没有和当前空间绑定的系统
- * 例如:prijectId=Pj4201050001,type=AirConditioningZone spaceId=Sp4201050001df2091cdf719443b80bb737aeabf0525 spaceId 为当前空间id type为当前空间类型
- * @param projectId
- * @param request
- * @return
- * @throws Exception
- */
- @PostMapping("/unspace-sys")
- public AdmResponse queryUnSpSy(@QueryParam("projectId") String projectId, @QueryParam("type") String type, @QueryParam("spaceId") String spaceId,
- @RequestBody AdmQueryCriteria request) throws Exception {
- // 组装上下文条件
- InstanceUrlParam context = new InstanceUrlParam(groupCode, null, projectId, AdmCommonConstant.APP_ID);
- if(StrUtil.isNotEmpty(spaceId)){
- AdmResponse admResponse = queryObjectByType(context, spaceId, request,"Sy2Sp",null, AdmSystem.OBJ_TYPE);
- return admResponse;
- }else{
- if(StrUtil.isNotEmpty(type)){
- QueryCriteria queryCriteriaObj = AdmQueryCriteriaHelper.toDmpCriteria(request);
- ObjectNode criteriaObj = JsonNodeFactory.instance.objectNode();
- criteriaObj.put("objType", AdmSpace.OBJ_TYPE);
- queryCriteriaObj.setCriteria(criteriaObj);
- List<ObjectNode> objs = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaObj);
- QueryCriteria queryCriteriaObjSys = AdmQueryCriteriaHelper.toDmpCriteria(request);
- ObjectNode criteriaSys = JsonNodeFactory.instance.objectNode();
- criteriaObj.put("objType", AdmSystem.OBJ_TYPE);
- if(CollUtil.isNotEmpty(objs)){
- ArrayNode arrayNode = criteriaObj.putObject("id").putArray("$notcontains");
- for(ObjectNode objectNode: objs){
- arrayNode.add(objectNode.get("id").toString());
- }
- }
- queryCriteriaObj.setCriteria(criteriaObj);
- List<ObjectNode> syses = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaObjSys);
- return AdmResponse.success(syses);
- }
- return AdmResponse.success();
- }
- }
- private AdmResponse queryObjectByType(InstanceUrlParam context, String sysId, AdmQueryCriteria request, String relCode, String graphCode, String objType){
- QueryCriteria queryCriteria = new QueryCriteria();
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- criteria.put("objFrom", sysId);
- criteria.put("relCode", relCode);
- if(StrUtil.isNotEmpty(graphCode)){
- criteria.put("graphCode", graphCode);
- }
- queryCriteria.setCriteria(criteria);
- queryCriteria.setSize(request.getPageSize()*1L);
- queryCriteria.setPage(request.getPageNumber()*1L);
- List<ObjectRelation> relations = DigitalRelationFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteria);
- QueryCriteria queryCriteriaObj = AdmQueryCriteriaHelper.toDmpCriteria(request);
- ObjectNode criteriaObj = JsonNodeFactory.instance.objectNode();
- criteriaObj.put("objType", objType);
- if(CollUtil.isNotEmpty(relations)){
- Map<String, ObjectRelation> objectRelationMap = CollUtil.fieldValueMap(relations,BaseEntity.PROP_ID);
- ArrayNode arrayNode = criteriaObj.putObject("id").putArray("$notcontains");
- objectRelationMap.keySet().stream().forEach(id -> arrayNode.add(id));
- }
- queryCriteriaObj.setCriteria(criteriaObj);
- List<ObjectNode> obj = DigitalObjectFacade.query(context.getGroupCode(),context.getProjectId(), context.getAppId(), null, queryCriteriaObj);
- return AdmResponse.success(obj);
- }
- }
|