1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045 |
- package com.persagy.proxy.adm.controller;
- import cn.hutool.core.collection.CollUtil;
- import cn.hutool.core.util.ReflectUtil;
- import cn.hutool.core.util.StrUtil;
- import cn.hutool.json.JSONUtil;
- import com.alibaba.fastjson.JSONObject;
- import com.fasterxml.jackson.databind.JsonNode;
- 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.dto.RequestData;
- import com.persagy.dmp.basic.model.QueryCriteria;
- import com.persagy.dmp.common.constant.ResponseCode;
- import com.persagy.dmp.common.model.entity.BaseEntity;
- import com.persagy.dmp.define.client.DigitalObjectInfoFacade;
- import com.persagy.dmp.define.entity.ObjectInfoDefine;
- import com.persagy.dmp.digital.client.DigitalObjectFacade;
- import com.persagy.dmp.digital.client.DigitalRelationFacade;
- import com.persagy.dmp.digital.entity.ObjectRelation;
- import com.persagy.dmp.simple.client.DigitalObjectSimpleFacade;
- import com.persagy.proxy.adm.constant.AdmCommonConstant;
- import com.persagy.proxy.adm.constant.enums.AdmDictCategoryEnum;
- import com.persagy.proxy.adm.model.*;
- import com.persagy.proxy.adm.model.equip.EquipUpDateEnclosure;
- 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.IAdmComponentService;
- import com.persagy.proxy.adm.service.IAdmDictService;
- import com.persagy.proxy.adm.service.IAdmEquipmentService;
- import com.persagy.proxy.adm.service.IAdmSystemService;
- import com.persagy.proxy.adm.utils.AdmContextUtil;
- import com.persagy.proxy.adm.utils.AdmQueryCriteriaHelper;
- import com.persagy.proxy.common.entity.DmpResult;
- 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.ws.rs.QueryParam;
- import java.lang.reflect.Field;
- import java.util.*;
- import java.util.stream.Collectors;
- /**
- * 设备报表API
- * @author lvxy
- * @date 2021/9/18
- */
- @RestController
- @RequestMapping("/equip-query")
- public class AdmReportEquipController {
- @Value("${middleware.group.code}")
- private String groupCode;
- @Autowired
- private IAdmDictService dictService;
- @Autowired
- private IAdmEquipmentService equipmentService;
- @Autowired
- private IAdmComponentService componentService;
- @Autowired
- private IAdmSystemService systemService;
- /**
- * 查询设备信息 关联的部件 资产信息
- * 查询设备关联资产部件数量
- *
- *
- * @param request
- * @return
- * @throws Exception
- */
- @PostMapping("/equip-components")
- public AdmResponse getEquipAssetComponents(@RequestBody AdmQueryCriteria request) throws Exception {
- //查询设备
- request.setName(AdmEquipment.OBJ_TYPE);
- List<AdmQueryCriteria> cascade = new ArrayList<>();
- //查询设备关联的部件
- AdmQueryCriteria cascadeCom = new AdmQueryCriteria();
- cascadeCom.setName("component");
- cascade.add(cascadeCom);
- //查询设备关联的系统
- AdmQueryCriteria cascadeSys = new AdmQueryCriteria();
- cascadeSys.setName("linkSystem");
- cascade.add(cascadeSys);
- request.setCascade(cascade);
- AdmResponse admResponse = equipmentService.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
- List<AdmEquipment> equipmentList = (List<AdmEquipment>) admResponse.getContent();
- if(CollUtil.isNotEmpty(equipmentList)){
- equipmentList.stream().forEach(equip -> {
- if (CollUtil.isNotEmpty(equip.getComponent())) {
- equip.setCount(equip.getComponent().size());
- equip.setComponent(null);
- } else {
- equip.setCount(0);
- }
- });
- //查询设备的类型信息,取list中的第一个数据
- AdmEquipment admEquipment = equipmentList.get(0);
- QueryCriteria defineCriteria = new QueryCriteria();
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- criteria.put("code", admEquipment.getClassCode());
- defineCriteria.setCriteria(criteria);
- AdmResponse defRes = dictService.doQueryObjectType(AdmContextUtil.toDmpContext(), defineCriteria, AdmObjectType.class);
- if (CollUtil.isNotEmpty(defRes.getContent())) {
- List<AdmObjectType> componentCategory = (List<AdmObjectType>) defRes.getContent();
- admEquipment.setComponentCategory(componentCategory);
- equipmentList.set(0, admEquipment);
- }
- }else{
- equipmentList = new ArrayList<>();
- }
- return AdmResponse.success(equipmentList);
- }
- /**
- * 查询当前设备类型下的部件分类以及数量
- *
- * @param request 查询信息条件
- * @return 查询结果
- */
- @PostMapping("/components-count")
- public AdmResponse getEquipComponentsCount(@RequestBody AdmQueryCriteria request){
- QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
- ObjectNode criteria = queryCriteria.getCriteria();
- if(JSONUtil.isNull(criteria)){
- return AdmResponse.failure("请求参数错误");
- }
- JsonNode euipId = criteria.get("id");
- RequestData requestData = new RequestData();
- requestData.setEquipmentId(String.valueOf(euipId));
- List result = DigitalObjectSimpleFacade.queryComponentsCountByEquipId(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(),null,requestData);
- if(CollUtil.isNotEmpty(result)){
- return AdmResponse.success(result);
- }else{
- return AdmResponse.success();
- }
- }
- /**
- * 查詢部件关联的资产
- * 资产相关暂未支持
- *
- * @param request 查询信息条件
- * @return 查询结果
- */
- @PostMapping("/components-property")
- public AdmResponse getComponentProperty(@RequestBody AdmQueryCriteria request){
- request.setName(AdmComponent.OBJ_TYPE);
- return componentService.doQuery(AdmContextUtil.toDmpContext(), request, AdmComponent.class);
- }
- /**
- *查询当前设备类型的允许下所有部件类型,设备下的部件对应数量
- *
- * @param id 设备id
- * @param category 分类
- */
- @GetMapping("/equip-compon")
- public AdmResponse getEquipCompon(@QueryParam("id") String id, @QueryParam("category") String category){
- //return rEquipComponService.getEquipCompon(id,category)
- RequestData requestData = new RequestData();
- if(StrUtil.isNotEmpty(id)){
- requestData.setEquipmentId(id);
- }
- if(StrUtil.isNotEmpty(category)){
- requestData.setClassCode(category);
- }
- List result = DigitalObjectSimpleFacade.queryEquipComponentsByProjectId(AdmContextUtil.toDmpContext().getGroupCode(), AdmContextUtil.toDmpContext().getProjectId(), AdmContextUtil.toDmpContext().getAppId(),null, requestData);
- if(CollUtil.isNotEmpty(result)){
- return AdmResponse.success(result);
- }else{
- return AdmResponse.success();
- }
- }
- /**
- * TODO
- * 根据设备批量创建资产
- * 资产相关暂未支持
- */
- @PostMapping("/creat-propertys")
- public AdmResponse batchCreation(@RequestBody AdmCreateRequest<AdmEquipment> createRequest, @QueryParam("projectId") String projectId) {
- //return EquipmentService.batchCreationProperty(request)
- return null;
- }
- /**
- * 根据条件查询统计数量 查询设备或部件
- * 例子: 根据设备类型或部件类型查询(\"Filters\": \"category ='SISU'\")," +
- * "根据设备类型和建筑查询(\"Filters\": \"category ='FASE';buildingId = '建筑id'\")," +
- * "根据设备类型和建筑楼层查询(\"Filters\": \"category ='FASE';buildingId = '建筑id';floorId = '楼层id'\")"
- */
- @PostMapping("/count")
- public AdmResponse count(@RequestBody AdmQueryCriteria request) {
- QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- if(StrUtil.isNotEmpty(request.getFilters()) && request.getFilters().contains("category")){
- criteria.put("classCode", criteria.get("category").textValue());
- criteria.remove("category");
- }
- queryCriteria.setCriteria(criteria);
- queryCriteria.setOnlyCount(true);
- List<ObjectNode> euipCom = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteria);
- if(CollUtil.isNotEmpty(euipCom)){
- return AdmResponse.success(euipCom);
- }else{
- return AdmResponse.success();
- }
- }
- /**
- * 查询设备或部件
- *
- * 例子: 根据设备类型或部件类型查询(\"Filters\": \"category ='SISU'\")," +
- * "根据设备类型和建筑查询(\"Filters\": \"category ='FASE';buildingId = '建筑id'\")," +
- * "根据设备类型和建筑楼层查询(\"Filters\": \"category ='FASE';buildingId = '建筑id';floorId = '楼层id'\")"
- */
- @PostMapping("/pagequery")
- public AdmResponse pageQuery(@RequestBody AdmQueryCriteria request) {
- QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- queryCriteria.setCriteria(criteria);
- if(StrUtil.isNotEmpty(request.getFilters()) && request.getFilters().contains("category")){
- criteria.put("classCode", criteria.get("category").textValue());
- criteria.remove("category");
- }
- List<ObjectNode> euipCom = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteria);
- if(CollUtil.isNotEmpty(euipCom)){
- return AdmResponse.success(euipCom);
- }else{
- return AdmResponse.success();
- }
- }
- /**
- * 跟维新确认过 暂未使用
- *
- * 根据建筑, 楼层, 业务空间类型, 业务空间id 查询设备
- *
- * description = "例子: 根据设备类型或部件类型查询(\"Filters\": \"category ='SISU'\")," +
- * "根据设备类型和建筑查询(\"Filters\": \"category ='FASE';buildingId = '建筑id'\")," +
- * "根据设备类型和建筑楼层查询(\"Filters\": \"category ='FASE';buildingId = '建筑id';floorId = '楼层id'\")" +
- * "所属业务空间类型填在ZoneType字段, 所属业务空间id填在ZoneId字段" +
- * "如果是查询不属于任何业务空间的对象, 设置notInZone = true"
- */
- @PostMapping("/zone-query")
- public AdmResponse zoneQuery(@RequestBody AdmZoneEquipQueryRequest request) {
- request.setName(AdmEquipment.OBJ_TYPE);
- if(StrUtil.isAllEmpty(request.getZoneType(),request.getZoneId())){
- return pageQuery(request);
- }else{
- }
- return null;
- }
- /**
- * 跟维新确认过 暂未使用
- * 根据建筑, 楼层, 业务空间类型, 业务空间id 查询部件
- *
- * 根据建筑, 楼层, 业务空间类型, 业务空间id查询部件", description = "例子: 根据设备类型或部件类型查询(\"Filters\": \"category ='SISU'\")," +
- * "根据设备类型和建筑查询(\"Filters\": \"category ='FASE';buildingId = '建筑id'\")," +
- * "根据设备类型和建筑楼层查询(\"Filters\": \"category ='FASE';buildingId = '建筑id';floorId = '楼层id'\")" +
- * "所属业务空间类型填在ZoneType字段, 所属业务空间id填在ZoneId字段" +
- * "如果是查询不属于任何业务空间的对象, 设置notInZone = true"
- */
- @PostMapping("/zone-component-query")
- public AdmResponse zoneComponentQuery(@RequestBody AdmZoneEquipQueryRequest request) {
- if(StrUtil.isAllEmpty(request.getZoneType(),request.getZoneId())){
- request.setName(AdmComponent.OBJ_TYPE);
- return pageQuery(request);
- }
- return null;
- }
- /**
- * 批量创建设备同时创建资产、创建设备和系统的关系
- *
- */
- @PostMapping("/creat-equip-pro")
- public AdmResponse create(@RequestBody AdmCreateRequest<AdmEquipment> createRequest){
- //return EquipmentProSyService.createList(request)
- List<AdmEquipment> vos = CollUtil.newArrayList(createRequest.getContent());
- vos = equipmentService.doInsertEuip(AdmContextUtil.toDmpContext(), AdmEquipment.class, vos);
- return AdmResponse.success(vos);
- }
- /**
- * 查询不在当前系统下的设备
- */
- @PostMapping("/equip-sys")
- public AdmResponse pageQueryEquipSys(@RequestBody AdmQueryCriteria request,@QueryParam("sysId") String sysId){
- //return EquipmentService.queryBeforeEquipSy(sysId,request)
- QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
- ObjectNode criteriaEquip = JsonNodeFactory.instance.objectNode();
- criteriaEquip.put("objType", AdmEquipment.OBJ_TYPE);
- JSONObject relationTo = new JSONObject();
- relationTo.put("relCode", "Sy2Eq");
- relationTo.put("graphCode", "MechSubset");
- JSONObject objFrom = new JSONObject();
- objFrom.put("$ne",sysId);
- relationTo.put("objFrom", objFrom);
- criteriaEquip.putPOJO("relationTo",relationTo);
- queryCriteria.setCriteria(criteriaEquip);
- List<ObjectNode> equips = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteria);
- if (CollUtil.isEmpty(equips))
- return AdmResponse.success();
- else
- return AdmResponse.success(equips);
- }
- /**
- * 查询当前系统下的设备
- *
- * datacenter 查询目标是SysEquip 没先查询系统,根据系统id查询系统和设备的关系,根据关系查询设备,拼接数据
- */
- @PostMapping("/sys-equip")
- public AdmResponse pageQuerySysEquip(@RequestBody AdmQueryCriteria request){
- //return SysEquipService.pageQuery(request, arrayListOf(SFilter.eq("projectId", SPageAdmContextUtil.toDmpContext().getHeader("projectId").toString())))
- request.setName(AdmSystem.OBJ_TYPE);
- QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
- queryCriteria.setSize(500l);
- List<ObjectNode> objectNodeList = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteria);
- if(CollUtil.isEmpty(objectNodeList)){
- return AdmResponse.success();
- }
- List<AdmSystem> admSystemList = JSONUtil.toList(objectNodeList.toString(), AdmSystem.class);
- Map<String, AdmSystem> admSystemMap = CollUtil.fieldValueMap(admSystemList, BaseEntity.PROP_ID);
- QueryCriteria queryCriteriaRelation = new QueryCriteria();
- queryCriteriaRelation.setPage(request.getPageNumber() == null ? 0 : request.getPageNumber()*1l);
- queryCriteriaRelation.setSize(request.getPageSize() == null ? 0 : request.getPageSize()*1l);
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- criteria.put("relCode", "Sy2Eq");
- criteria.put("graphCode", "MechSubset");
- ArrayNode arrayNode = criteria.putObject("objTo").putArray("$in");
- admSystemMap.keySet().stream().forEach(id -> arrayNode.add(id));
- queryCriteriaRelation.setCriteria(criteria);
- List<ObjectRelation> relations = DigitalRelationFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteriaRelation);
- if(CollUtil.isEmpty(relations)){
- AdmResponse.success();
- }
- //objfrom = euipId
- Map<String, ObjectRelation> relationMap = CollUtil.fieldValueMap(relations,"objFrom");
- QueryCriteria queryCriteriaEqu = new QueryCriteria();
- ObjectNode criteriaEquip = JsonNodeFactory.instance.objectNode();
- criteriaEquip.put("objType", AdmEquipment.OBJ_TYPE);
- ArrayNode array = criteriaEquip.putObject("id").putArray("$in");
- relationMap.keySet().stream().forEach(id -> array.add(id));
- queryCriteriaEqu.setCriteria(criteriaEquip);
- List<ObjectNode> equips = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteriaEqu);
- List<AdmEquipment> equipsList = JSONUtil.toList(equips.toString(), AdmEquipment.class);
- Map<String, AdmEquipment> admEquipmentMap = CollUtil.fieldValueMap(equipsList, BaseEntity.PROP_ID);
- List<AdmSystem> admSystems = new ArrayList<>(relations.size());
- relationMap.keySet().stream().forEach(euipId -> {
- ObjectRelation relation = relationMap.get(euipId);
- AdmSystem admSystem = admSystemMap.get(relation.getObjTo());
- admSystem.setEquipId(euipId);
- admSystem.setEquipLocalName(admEquipmentMap.get(euipId).getLocalName());
- admSystems.add(admSystem);
- });
- AdmResponse admResponse = new AdmResponse();
- admResponse.setPageNumber(request.getPageNumber());
- admResponse.setPageSize(admSystems.size());
- admResponse.setContent(admSystems);
- admResponse.setResult(DmpResult.SUCCESS);
- return admResponse;
- }
- /**
- * 查询项目下的所有设备和部件的类型、以及类型名称
- */
- @GetMapping("/equip-compon-category")
- public AdmResponse equipORComponCategory(@QueryParam("projectId") String projectId){
- //return EquipORComponCategoryService.getEquipORComponCategory()
- RequestData requestData = new RequestData();
- if(StrUtil.isNotEmpty(projectId)){
- requestData.setProjectId(projectId);
- }
- requestData.setObjTypes(CollUtil.newHashSet(AdmEquipment.OBJ_TYPE, AdmComponent.OBJ_TYPE));
- List<Map<String, Object>> result = DigitalObjectSimpleFacade.queryDefineInfoByObjType(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmContextUtil.toDmpContext().getAppId(),null,requestData);
- if(CollUtil.isNotEmpty(result)){
- return AdmResponse.success(result);
- }else{
- return AdmResponse.success();
- }
- }
- /**
- * 批量处理设备关联资产、 查询接口
- * 查询项目下的设备或部件-根据项目、建筑、楼层、设备或部件分类、业务空间实例筛选设备 然后通过计算匹配资产
- * 查询条件中建筑id必须书写为buildingId,楼层id必须书写为floorId,spacrType物理世界定义的空间类型,spaceIdList业务空间实例id列表,category设备或部件类型
- * TODO 资产相关功能暂时不提供,之后根据业务进行需求处理
- */
- @PostMapping("/equip-category-property")
- public AdmResponse equipProperty(@QueryParam("category") String category, @RequestBody AdmQueryCriteria request, @RequestBody List<String> spaceIdList, @QueryParam("spacrType") String spacrType){
- //return EquipmentComService.equipProperty(category, request, spaceIdList, spacrType)
- return null;
- }
- /**
- * 批量添加设备和资产的关系
- * TODO 资产相关功能暂时不提供,之后根据业务进行需求处理
- */
- @PostMapping("/equip-r-property")
- public AdmResponse equipRelationshipProperty(@RequestBody AdmCreateRequest<AdmProperty> createRequest, @QueryParam("projectId") String projectId) {
- //return EquipmentComService.equipPro(request)
- return null;
- }
- /**
- * 修改设备的附件功能
- * {
- * "content":"{....}" EquipUpDateEnclosure 实体list
- * }
- */
- @PostMapping("/update")
- public AdmResponse equipUpDateEnclosure(@RequestBody ObjectNode equipUpDateEnclosureRequest) {
- //return EquipmentService.equipUpDateEnclosurs(equipUpDateEnclosureRequest)
- if(JSONUtil.isNull(equipUpDateEnclosureRequest)){
- return AdmResponse.failure(ResponseCode.A0400.getDesc()+",不能为空");
- }
-
- List<EquipUpDateEnclosure> equipUpDateEnclosure = JSONUtil.toList(equipUpDateEnclosureRequest.get("content").toString(), EquipUpDateEnclosure.class);
- if(CollUtil.isNotEmpty(equipUpDateEnclosure)){
- Map<String, EquipUpDateEnclosure> equipUpDateEnclosureMap = CollUtil.fieldValueMap(equipUpDateEnclosure, BaseEntity.PROP_ID);
- if(equipUpDateEnclosureMap.size() < equipUpDateEnclosure.size()) {
- return AdmResponse.failure("设备id不能为空");
- }
- //获取待更新的设备
- QueryCriteria queryCriteria = new QueryCriteria();
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- criteria.put("objType", AdmEquipment.OBJ_TYPE);
- ArrayNode arrayNode = criteria.putObject("id").putArray("$in");
- equipUpDateEnclosureMap.keySet().stream().forEach(equipId -> arrayNode.add(equipId));
- queryCriteria.setCriteria(criteria);
- AdmResponse equips = equipmentService.doQuery(AdmContextUtil.toDmpContext(), queryCriteria, AdmEquipment.class);
- if(CollUtil.isEmpty(equips.getContent())){
- return AdmResponse.failure(ResponseCode.A0400.getDesc());
- }
- //将需要更新的数据放到待更新的设备中
- List<AdmEquipment> equipmentList = JSONUtil.toList(equips.getContent().toString(), AdmEquipment.class);
- //获取所有属性
- Map<String, Field> fieldMap = ReflectUtil.getFieldMap(EquipUpDateEnclosure.class);
- //对每个设备更新属性
- equipmentList.stream().forEach(admEquipment -> {
- fieldMap.keySet().forEach(fieldName -> {
- EquipUpDateEnclosure enclosure = equipUpDateEnclosureMap.get(admEquipment.getId());
- List<AdmTaskPic> newAttr = (List<AdmTaskPic>) ReflectUtil.getFieldValue(enclosure,fieldName);
- if(CollUtil.isNotEmpty(newAttr)){
- dealTaskFiles(admEquipment, fieldName, newAttr);
- }
- });
- });
- List<AdmEquipment> vos = equipmentService.doUpdate(AdmContextUtil.toDmpContext(), AdmEquipment.class, equipmentList);
- return AdmResponse.success(vos);
- }else{
- return AdmResponse.failure(ResponseCode.A0400.getDesc());
- }
- }
- /**
- * 根据模型id查询待删除的设备数量
- [{
- * "modelId":"",
- * "count":""
- * }]
- */
- @PostMapping("/equip-del-com")
- public AdmResponse equipComDel(@RequestBody List<ObjectNode> equipComDelList){
- //return EquipmentService.equipComDels(equipComDelList)
- if(CollUtil.isEmpty(equipComDelList)){
- return AdmResponse.failure(ResponseCode.A0400.getCode());
- }
- QueryCriteria queryCriteriaEuip = new QueryCriteria();
- ObjectNode criteriaEquip = JsonNodeFactory.instance.objectNode();
- criteriaEquip.put("objType", AdmEquipment.OBJ_TYPE);
- criteriaEquip.put("taskState",-1);
- ArrayNode array = criteriaEquip.putObject("modelId").putArray("$in");
- equipComDelList.stream().forEach(nodeObj -> {
- if(StrUtil.isNotEmpty(nodeObj.get("modelId").textValue())) {
- array.add(nodeObj.get("modelId").textValue());
- }
- });
- queryCriteriaEuip.setCriteria(criteriaEquip);
- List<ObjectNode> equipList = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteriaEuip);
- if(CollUtil.isEmpty(equipList)){
- return AdmResponse.success(equipComDelList);
- }
- Map<String, ObjectNode> equipDelMap = new HashMap<>(equipComDelList.size());
- for (ObjectNode equipComDel : equipComDelList) {
- String modelIdObj = equipComDel.get("modelId").toString();
- equipDelMap.put(modelIdObj, equipComDel);
- }
- equipList.stream().forEach(euip -> {
- String modelIdEq = euip.get("modelId").textValue();
- if(equipDelMap.containsKey(modelIdEq)){
- Integer count = Integer.parseInt(equipDelMap.get(modelIdEq).get("count").textValue()) + 1;
- equipDelMap.get(modelIdEq).put("count", count);
- }
- });
- return AdmResponse.success(equipDelMap.values().stream().collect(Collectors.toList()));
- }
- /**
- * 根据模型id查询待补充的设备数量
- * [{
- * "modelId":"",
- * "count":""
- * }]
- */
- @PostMapping("/equip-supply")
- public AdmResponse equipPropertySupply(@RequestBody List<ObjectNode> equipComDelList){
- //return EquipmentService.equipPropertySupplys(equipComDelList)
- //
- if(CollUtil.isEmpty(equipComDelList)){
- return AdmResponse.failure(ResponseCode.A0400.getCode());
- }
- //1. 根据modelId查询楼层信息
- QueryCriteria queryCriteria = new QueryCriteria();
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- criteria.put("objType", AdmFloor.OBJ_TYPE);
- ArrayNode arrayNode = criteria.putObject("modelId").putArray("$in");
- equipComDelList.stream().forEach(node -> {
- arrayNode.add(node.get("modelId").textValue());
- });
- queryCriteria.setCriteria(criteria);
- List<ObjectNode> floorList = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null,queryCriteria);
- if(CollUtil.isEmpty(floorList)){
- return AdmResponse.success();
- }
- List<AdmFloor> admFloorList = JSONUtil.toList(floorList.toString(), AdmFloor.class);
- Map<String, AdmFloor> admFloorMap = CollUtil.fieldValueMap(admFloorList, BaseEntity.PROP_ID);
- //2. 根据楼层信息 查询需要补充设备(bimId isnull,bimLocation not isnull,modelId isnull)数量
- QueryCriteria queryCriteriaEuip = new QueryCriteria();
- ObjectNode criteriaEquip = JsonNodeFactory.instance.objectNode();
- criteriaEquip.put("objType", AdmEquipment.OBJ_TYPE);
- ArrayNode array = criteriaEquip.putObject("floorId").putArray("$in");
- admFloorMap.keySet().stream().forEach(id -> array.add(id));
- JSONObject bimId = new JSONObject();
- bimId.put("$null", true);
- criteria.putPOJO("bimId", bimId);
- JSONObject bimLocation = new JSONObject();
- bimId.put("$null", false);
- criteriaEquip.putPOJO("bimLocation", bimLocation);
- JSONObject modelId = new JSONObject();
- modelId.put("$null", true);
- criteriaEquip.putPOJO("modelId", modelId);
- queryCriteriaEuip.setCriteria(criteriaEquip);
- List<ObjectNode> equipList = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteriaEuip);
- if(CollUtil.isEmpty(equipList)){
- return AdmResponse.success(equipComDelList);
- }
- equipList.stream().forEach(equip -> {
- String floolId = equip.get("floorId").textValue();
- if(admFloorMap.containsKey(floolId)){
- Integer count = Integer.parseInt(admFloorMap.get(floolId).getCount()) + 1;
- admFloorMap.get(floolId).setCount(count.toString());
- }
- });
- // 3 根据floorId,modelId 汇总
- Map<String, ObjectNode> equipDelMap = new HashMap<>(equipComDelList.size());
- for (ObjectNode equipComDel : equipComDelList) {
- String modelIdObj = equipComDel.get("modelId").toString();
- equipDelMap.put(modelIdObj, equipComDel);
- }
- admFloorMap.values().stream().forEach(floor -> {
- String modelIdFl = floor.getModelId();
- if(equipDelMap.containsKey(modelIdFl)){
- Integer count = Integer.parseInt(equipDelMap.get(modelIdFl).get("count").textValue()) + Integer.parseInt(floor.getCount());
- equipDelMap.get(modelIdFl).put("count", count);
- }
- });
- return AdmResponse.success(equipDelMap.values().stream().collect(Collectors.toList()));
- }
- /**
- * 模型质量报告 待删除的设备
- * 级联-任务(scanTaskBase)、资产(property)、设备类型(equipCategory),级联任务的时候需要设置条件(TaskState = 0 添加时间降序 取第一个值 )
- */
- @PostMapping("/equip-comm-del")
- public AdmResponse equipCommDel(@RequestBody AdmQueryCriteria request){
- //return EquipDelService.pageQuery(sQueryRequest,withFilterList)
- //e.task_state = '-1'::integer
- //AND NOT e.model_id IS NULL
- //TODO 关联 revit.model_floor revit.model_folder 展示模型相关内容
- request.setName(AdmEquipment.OBJ_TYPE);
- QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(request);
- ObjectNode criteria = queryCriteria.getCriteria();
- JSONObject modelId = new JSONObject();
- modelId.put("$null", false);
- criteria.putPOJO("modelId", modelId);
- criteria.put("taskState","-1");
- queryCriteria.setCriteria(criteria);
- AdmResponse equipRes = equipmentService.doQuery(AdmContextUtil.toDmpContext(), queryCriteria, AdmEquipment.class);
- return equipRes;
- }
- /**
- * 模型质量报告 待补充的设备
- * 级联-设备类型(equipFamily)
- */
- @PostMapping("/property-equip-supp")
- public AdmResponse propertyEquip(@RequestBody AdmQueryCriteria request){
-
- //return EquipmentService.equipPropertySupp(sQueryRequest)
- //equipment.bim_id IS NULL
- // AND equipment.model_id IS NULL
- // AND NOT equipment.bim_location IS NULL;
- AdmQueryCriteria admQueryCriteria = request;
- StringBuilder filters = new StringBuilder();
- filters.append("floorId startwith 'Eq'");
- filters.append(";buildingId startwith 'Bd'");
- filters.append(";bimId isnull");
- filters.append(";modelId isnull");
- admQueryCriteria.setFilters(filters.toString());
- admQueryCriteria.setName(AdmEquipment.OBJ_TYPE);
- QueryCriteria queryCriteria = AdmQueryCriteriaHelper.toDmpCriteria(admQueryCriteria);
- ObjectNode criteria = queryCriteria.getCriteria();
- JSONObject bimLocation = new JSONObject();
- bimLocation.put("$null", false);
- criteria.putPOJO("bimLocation", bimLocation);
- queryCriteria.setCriteria(criteria);
- AdmResponse equipRes = equipmentService.doQuery(AdmContextUtil.toDmpContext(), queryCriteria, AdmEquipment.class);
- if(CollUtil.isNotEmpty(equipRes.getContent())){
- List<AdmEquipment> admEquipments = JSONUtil.toList(equipRes.getContent().toString(), AdmEquipment.class);
- Map<String, AdmEquipment> admEquipmentMap = CollUtil.fieldValueMap(admEquipments, BaseEntity.PROP_ID);
- if(CollUtil.isEmpty(request.getCascade())){
- List<AdmQueryCriteria> cascade = new ArrayList<>();
- AdmQueryCriteria admQueryCriteriaBd = new AdmQueryCriteria();
- admQueryCriteriaBd.setName(AdmBuilding.OBJ_TYPE);
- cascade.add(admQueryCriteriaBd);
- AdmQueryCriteria admQueryCriteriaFl = new AdmQueryCriteria();
- admQueryCriteriaFl.setName(AdmFloor.OBJ_TYPE);
- cascade.add(admQueryCriteriaFl);
- request.setCascade(cascade);
- request.setName(AdmEquipment.OBJ_TYPE);
- }
- ArrayNode arrayNode = JsonNodeFactory.instance.arrayNode();
- admEquipmentMap.keySet().stream().forEach(id -> arrayNode.add(id));
- String filter = "";
- if(StrUtil.isNotEmpty(request.getFilters())){
- filter = request.getFilters();
- }
- filter = filter + ";id in "+arrayNode.toString();
- request.setFilters(filter);
- AdmResponse admResponse = equipmentService.doQuery(AdmContextUtil.toDmpContext(), request, AdmEquipment.class);
- if(CollUtil.isNotEmpty(admResponse.getContent())){
- //处理数据
- List<ObjectNode> objectNodeList = (List<ObjectNode>) admResponse.getContent();
- objectNodeList.stream().forEach(equip ->{
- JsonNode building = equip.get("building");
- JsonNode floor = equip.get("floor");
- if(!JSONUtil.isNull(building)){
- equip.put("buildingName", building.get("localName").textValue());
- }
- if(!JSONUtil.isNull(floor)){
- equip.put("floorName", floor.get("localName").textValue());
- equip.put("modelId", floor.get("modelId").textValue());
- }
- });
- }
- return admResponse;
- }else{
- return AdmResponse.success();
- }
- /** sql
- * SELECT equipment.id,
- * equipment.name,
- * equipment.local_id,
- * equipment.local_name,
- * equipment.bim_id,
- * equipment.bim_location,
- * equipment.floor_id,
- * equipment.building_id,
- * equipment.cad_id,
- * equipment.project_id,
- * equipment.find_people,
- * equipment.class_code,
- * equipment.infos,
- * JSON_EXTRACT(floor.infos, '$.modeId') as model_id,
- * floor.local_name as floor_name,
- * (SELECT building.local_name
- * FROM dt_object building
- * WHERE building.id = JSON_EXTRACT(equipment.infos, '$.buildingId') and building.obj_type = 'building') AS building_name,
- *
- * (SELECT def_class.name
- * FROM dt_define_type def_class
- * WHERE def_class.code = equipment.class_code
- * LIMIT 1) AS code_name
- *
- * from ( SELECT equipment.id,
- * equipment.name,
- * equipment.local_id,
- * equipment.local_name,
- * equipment.class_code,
- * JSON_EXTRACT(equipment.infos, '$.bimId') bim_id,
- * JSON_EXTRACT(equipment.infos, '$.bimLocation') bim_location,
- * JSON_EXTRACT(equipment.infos, '$.floorId') floor_id,
- * JSON_EXTRACT(equipment.infos, '$.buildingId') building_id,
- * JSON_EXTRACT(equipment.infos, '$.cadId') cad_id,
- * equipment.project_id,
- * JSON_EXTRACT(equipment.infos, '$.findPeople') find_people,
- * equipment.infos
- * FROM dt_object equipment
- * WHERE equipment.obj_type='equipment'
- * AND JSON_EXTRACT(equipment.infos, '$.bimId') IS NULL
- * AND JSON_EXTRACT(equipment.infos, '$.modeId') IS NULL
- * AND JSON_EXTRACT(equipment.infos, '$.buildingId') IS NOT NULL
- * AND JSON_EXTRACT(equipment.infos, '$.floorId') IS NOT NULL
- * AND JSON_EXTRACT(equipment.infos, '$.bimLocation') IS NOT NULL
- * ) equipment left join dt_object floor on fl
- */
- }
- /**
- * 设备信息点
- * 统计设备信息点与总数据占比
- */
- @PostMapping("/info-point")
- public AdmResponse infoPoint(@QueryParam("projectId") String projectId) {
- //return customSqlService.infoPoints()
-
- JSONObject gatherInfoPoint = calInfoPointByObjType(AdmEquipment.OBJ_TYPE, false, false);
- JSONObject infoPoint = new JSONObject();
- infoPoint.put("dynamicInfoPoint",gatherInfoPoint.getString("gatherDynamicInfoPointCounts"));
- infoPoint.put("staticInfoPoint",gatherInfoPoint.getString("gatherStaticInfoPointCounts"));
- return AdmResponse.success(CollUtil.newArrayList(infoPoint));
- }
- /**
- * 设备已采集信息点
- * 统计设备信息点与需采集数据占比
- */
- @PostMapping("/gather-info-point")
- public AdmResponse gatherInfoPoint(@QueryParam("projectId") String projectId) {
- //return customSqlService.gatherInfoPoints()
- if(StrUtil.isEmpty(projectId)){
- return AdmResponse.failure(ResponseCode.A0400.getCode());
- }
-
- JSONObject gatherInfoPoint = calInfoPointByObjType(AdmEquipment.OBJ_TYPE, true, true);
- return AdmResponse.success(CollUtil.newArrayList(gatherInfoPoint));
- }
- /**
- * 统计系统信息点与需采集数据占比
- */
- @PostMapping("/system-info-point")
- public AdmResponse systemInfoPoin(@QueryParam("projectId") String projectId) {
- if(StrUtil.isEmpty(projectId)){
- return AdmResponse.failure(ResponseCode.A0400.getCode());
- }
-
- JSONObject gatherInfoPoint = calInfoPointByObjType(AdmSystem.OBJ_TYPE,true, true);
- return AdmResponse.success(CollUtil.newArrayList(gatherInfoPoint));
- }
- /**
- * 台账中待删除的对象 数量统计
- */
- @PostMapping("/del-equip-comm-pro")
- public AdmResponse deleteObj(@QueryParam("projectId") String projectId){
- QueryCriteria queryCriteria = new QueryCriteria();
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- criteria.put("taskState", -1);
- criteria.put("objType","['equipment','component']");
- queryCriteria.setCriteria(criteria);
- queryCriteria.setOnlyCount(true);
- List<ObjectNode> euipCom = DigitalObjectFacade.query(groupCode,AdmContextUtil.toDmpContext().getProjectId(),AdmCommonConstant.APP_ID,null, queryCriteria);
- if(CollUtil.isNotEmpty(euipCom)){
- return AdmResponse.success(euipCom);
- }else{
- return AdmResponse.success();
- }
- }
- /**
- * 项目下的所有设备类型以及名称
- *
- * @return 返回对象列表
- */
- @PostMapping("/type")
- public AdmResponse equipType(@QueryParam("projectId") String projectId){
- RequestData requestData = new RequestData();
- if(StrUtil.isNotEmpty(projectId)){
- requestData.setProjectId(projectId);
- }
- requestData.setObjType(AdmEquipment.OBJ_TYPE);
- List<Map<String, Object>> result = DigitalObjectSimpleFacade.queryDefineInfoByObjType(AdmContextUtil.toDmpContext().getGroupCode(),AdmContextUtil.toDmpContext().getProjectId(),AdmContextUtil.toDmpContext().getAppId(),null,requestData);
- if(CollUtil.isNotEmpty(result)){
- return AdmResponse.success(result);
- }else{
- return AdmResponse.success();
- }
- }
- /**
- * 查询系统-设备类树
- * @return
- * @throws Exception
- */
- @GetMapping("/type/tree")
- public AdmResponse querySystemEquipCategory() throws Exception {
- // 组装上下文条件
- AdmDict request = new AdmDict();
- InstanceUrlParam context = AdmContextUtil.toDmpContext();
- request.setType(AdmDictCategoryEnum.SYSTEM_EQUIP.getValue());
- return dictService.queryCategory(context,request,AdmObjectType.class);
- }
- /**
- * 计算动态、静态信息点
- */
- private Map<String, Integer> calculate(List<ObjectInfoDefine> dynamicInfoPointCodes, List<ObjectInfoDefine> staticInfoPointCodes, List<ObjectNode> objectNodeList, Integer num) {
- Map<String, Integer> hashMap = new HashMap<String, Integer>();
- int dynamicInfoPoint = 0;
- int staticInfoPoint = 0;
- int customInfoPoint=0;
- Iterator<ObjectInfoDefine> iterator1 = staticInfoPointCodes.iterator();
- for (ObjectNode objectNode : objectNodeList) {
- while (iterator1.hasNext()) {
- ObjectInfoDefine infoDefine = iterator1.next();
- if (objectNode.get("id") != null && "id" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode()) {
- staticInfoPoint++;
- iterator1.remove();
- }
- if (objectNode.get("name") != null && "name" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode()) {
- staticInfoPoint++;
- iterator1.remove();
- }
- if (objectNode.get("localId") != null && "localId" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode()) {
- staticInfoPoint++;
- iterator1.remove();
- }
- if (objectNode.get("localName") != null && "localName" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode()) {
- staticInfoPoint++;
- iterator1.remove();
- }
- if (objectNode.get("qrCode") != null && "qRCode" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode()) {
- staticInfoPoint++;
- iterator1.remove();
- }
- if (objectNode.get("cADID") != null && "cADID" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode() && num==0) {
- staticInfoPoint++;
- iterator1.remove();
- }
- if (objectNode.get("bimId") != null && "bimId" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode() && num==0) {
- staticInfoPoint++;
- iterator1.remove();
- }
- if (objectNode.get("bimLocation") != null && "bimLocation" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode()) {
- staticInfoPoint++;
- iterator1.remove();
- }
- if (objectNode.get("equipSerial") != null && "equipSerial" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode()) {
- staticInfoPoint++;
- iterator1.remove();
- }
- if (objectNode.get("bimFamilyName") != null && "bimFamilyName" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode()) {
- staticInfoPoint++;
- iterator1.remove();
- }
- if (objectNode.get("bimFamilySymbol") != null && "bimFamilySymbol" == infoDefine.getCode() && objectNode.get("classCode").textValue() == infoDefine.getClassCode()) {
- staticInfoPoint++;
- iterator1.remove();
- }
- }
- }
- for (ObjectNode objectNode : objectNodeList) {
- if (objectNode.get("infos") != null) {
- Map<String,Object> dynamic = calculateInfoPoints(objectNode.get("infos").toString(), objectNode.get("classCode").textValue().toString(), dynamicInfoPointCodes);
- Map<String,Object> staticMap = calculateInfoPoints(objectNode.get("infos").toString(), objectNode.get("classCode").textValue().toString(), staticInfoPointCodes);
- dynamicInfoPoint += Integer.parseInt(dynamic.get("counts").toString());
- staticInfoPoint += Integer.parseInt(staticMap.get("counts").toString());
- dynamicInfoPointCodes.remove(dynamic.get("next"));
- staticInfoPointCodes.remove(staticMap.get("next"));
- }
- }
- hashMap.put("dynamicInfoPoint", dynamicInfoPoint);
- hashMap.put("staticInfoPoint", staticInfoPoint);
- hashMap.put("customInfoPoint", customInfoPoint);
- return hashMap;
- }
- /**
- * 计算信息点
- *
- */
- private Map<String,Object> calculateInfoPoints(String str, String type, List<ObjectInfoDefine> infoPointCodes) {
- int counts = 0;
- Map<String,Object> hashMap = new HashMap<String,Object>();
- Iterator<ObjectInfoDefine> iterator = infoPointCodes.iterator();
- while (iterator.hasNext()){
- ObjectInfoDefine nextInfo = iterator.next();
- if(str.contains(nextInfo.getCode()) && type==nextInfo.getClassCode()){
- counts ++;
- hashMap.put("next", nextInfo);
- iterator.remove();
- }
- }
- hashMap.put("counts", counts);
- return hashMap;
- }
- private JSONObject calInfoPointByObjType(String objType, Boolean visible, Boolean getInfoCounts){
- //1 查询项目下所有现有的系统
- AdmQueryCriteria admQueryCriteriaObj = new AdmQueryCriteria();
- if(objType.equals(AdmEquipment.OBJ_TYPE)){
- admQueryCriteriaObj.setProjection(Arrays.asList("id","name","localId","localName","cadId","bimId","bimLocation","infos","classCode","equipSerial","bimFamilyName","bimFamilySymbol"));
- }else{
- admQueryCriteriaObj.setProjection(Arrays.asList("id","name","localId","localName","cadId","bimId","infos","classCode"));
- }
- admQueryCriteriaObj.setName(objType);
- QueryCriteria queryCriteriaSys = AdmQueryCriteriaHelper.toDmpCriteria(admQueryCriteriaObj);
- List<ObjectNode> admObjList = DigitalObjectFacade.query(groupCode, AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteriaSys);
- //2 获取动态 静态 信息点
- // 2.1 根据objType获取定义
- Set<String> classCodeSet = new HashSet<>();
- if(AdmSystem.OBJ_TYPE.equals(objType)){
- QueryCriteria queryCriteriaType = new QueryCriteria();
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- criteria.put("objType", objType);
- queryCriteriaType.setCriteria(criteria);
- AdmResponse admResponseType = dictService.doQueryObjectType(AdmContextUtil.toDmpContext(), queryCriteriaType, AdmObjectType.class);
- if(CollUtil.isEmpty(admResponseType.getContent())){
- return null;
- }
- List<AdmObjectType> admObjectTypes = (List<AdmObjectType>) admResponseType.getContent();
- Map<String, AdmObjectType> admObjectTypeMap = CollUtil.fieldValueMap(admObjectTypes, "code");
- classCodeSet = admObjectTypeMap.keySet();
- }else {
- List<AdmEquipment> equipmentList = JSONUtil.toList(admObjList.toString(), AdmEquipment.class);
- Map<String, AdmEquipment> admObjectTypeMap = CollUtil.fieldValueMap(equipmentList, "code");
- classCodeSet = admObjectTypeMap.keySet();
- }
- JSONObject gatherInfoPoint = new JSONObject();
- if(CollUtil.isEmpty(admObjList)){
- gatherInfoPoint.put("gatherInfoPointCounts", 0);
- gatherInfoPoint.put("gatherCustomInfoPointCounts",0);
- gatherInfoPoint.put("gatherDynamicInfoPointCounts",0);
- gatherInfoPoint.put("gatherStaticInfoPointCounts",0);
- } else {
- // 2.2 根据定义获取信息点
- //查询当前实例所有信息点总数
- long controlInfoCounts = 0l;
- QueryCriteria queryCriteria = new QueryCriteria();
- ObjectNode criteria = JsonNodeFactory.instance.objectNode();
- criteria = JsonNodeFactory.instance.objectNode();
- ArrayNode arrayNode = criteria.putObject("classCode").putArray("$in");
- classCodeSet.stream().forEach(classCode -> arrayNode.add(classCode));
- criteria.put("type", "commo");
- if(getInfoCounts){
- criteria.put("valid","['0','1']");
- queryCriteria.setCriteria(criteria);
- queryCriteria.setOnlyCount(true);
- List<ObjectInfoDefine> totalInfo = DigitalObjectInfoFacade.query(groupCode, AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
- controlInfoCounts = totalInfo.size();
- criteria.remove("valid");
- }
- //静态信息点
- criteria.put("category","STATIC");
- if(visible){
- criteria.put("valid", "1");
- }else{
- criteria.put("valid","['0','1']");
- }
- queryCriteria.setCriteria(criteria);
- List<ObjectInfoDefine> staticInfoCode = DigitalObjectInfoFacade.query(groupCode, AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
- criteria.remove("category");
- //动态信息点
- JSONObject category = new JSONObject();
- category.put("$ne","STATIC");
- criteria.putPOJO("category", category);
- queryCriteria.setCriteria(criteria);
- List<ObjectInfoDefine> dynamicInfoCode = DigitalObjectInfoFacade.query(groupCode, AdmContextUtil.toDmpContext().getProjectId(), AdmCommonConstant.APP_ID,null,queryCriteria);
- //4 计算已采集的和需要采集的信息点占比
- //return customSqlService.systemInfoPoins()
- Map<String, Integer> hashMap = calculate(dynamicInfoCode, staticInfoCode, admObjList, 1);
- gatherInfoPoint.put("gatherCustomInfoPointCounts",hashMap.get("customInfoPoint"));
- gatherInfoPoint.put("gatherDynamicInfoPointCounts",hashMap.get("dynamicInfoPoint"));
- gatherInfoPoint.put("gatherStaticInfoPointCounts",hashMap.get("staticInfoPoint"));
- gatherInfoPoint.put("gatherInfoPointCounts", controlInfoCounts);
- }
- return gatherInfoPoint;
- }
- /**
- * 处理设备属性文件 -> 设备的信息点
- * @param equip
- * @param attribute
- */
- private void dealTaskFiles(AdmEquipment equip, String attribute, List<AdmTaskPic> upTarget){
- Map<String, Object> infos = equip.getInfos();
- boolean containsKey1 = infos.containsKey(attribute);
- if (containsKey1) {
- if (infos.get(attribute) != null && StrUtil.isNotEmpty(infos.get(attribute).toString())){
- List<AdmTaskPic> list = JSONUtil.toList(infos.get(attribute).toString(), AdmTaskPic.class);
- list.addAll(upTarget);
- infos.put(attribute, list);
- }else {
- infos.put(attribute, upTarget);
- }
- } else {
- infos.put(attribute, upTarget);
- }
- }
- }
|