123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038 |
- 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 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);
- 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.success();
- }
- 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.success();
- }
- //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 = AdmDict.builder().type(AdmDictCategoryEnum.SYSTEM_EQUIP.getValue()).build();
- return dictService.queryCategory(AdmContextUtil.toDmpContext(),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);
- }
- }
- }
|