package com.persagy.proxy.adm.strategy.relationdata; import java.util.List; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.node.ObjectNode; import com.persagy.dmp.basic.model.QueryCriteria; import com.persagy.dmp.common.model.response.CommonResult; import com.persagy.dmp.digital.client.DigitalRelationFacade; import com.persagy.dmp.digital.entity.ObjectDigital; import com.persagy.dmp.digital.entity.ObjectRelation; import com.persagy.proxy.adm.constant.AdmCommonConstant; import com.persagy.proxy.adm.constant.AdmRelationType; import com.persagy.proxy.adm.constant.AdmRelationTypeEnum; import com.persagy.proxy.adm.constant.SpaceTypeEnum; import com.persagy.proxy.adm.model.AdmRelationObject; import com.persagy.proxy.adm.service.IRelationReportService; /** * * @version 1.0.0 * @company persagy * @author zhangqiankun * @date 2021年9月3日 上午9:42:46 */ @Component(value = AdmRelationType.SP2SP_CONVECTIONNETWORK_3) public class Sp2SpOnewayMechRelationObject extends AbstractReportRelationObject { public Sp2SpOnewayMechRelationObject(IRelationReportService relationReportService) { super(relationReportService); } @Override public long countRelationObjects(String groupCode, String projectId) { QueryCriteria queryCriteria = new QueryCriteria(); ObjectNode objectNode = OBJECT_MAPPER.createObjectNode(); objectNode.put("graphCode", AdmRelationTypeEnum.SP2SP_CONVECTIONNETWORK_3.getGraphCode()); objectNode.put("relCode", AdmRelationTypeEnum.SP2SP_CONVECTIONNETWORK_3.getRelCode()); queryCriteria.setCriteria(objectNode); queryCriteria.setOnlyCount(true); CommonResult> result = DigitalRelationFacade.queryPrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria); return result == null ? 0 : (result.getCount() == null ? 0 : result.getCount()); } @Override protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) { throw new UnsupportedOperationException("未实现的策略类"); } @Override public Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code) { return this.beforeSaveRelationObject(relationObject, AdmRelationTypeEnum.SP2SP_CONVECTIONNETWORK_3, groupCode, projectId, code); } @Override protected String checkRelationObject(ObjectNode master, String masterClassCode, ObjectNode slave, String slaveClassCode) { if (!SpaceTypeEnum.AirConditioningZone.getCode().equals(masterClassCode)) { return "主对象不属于空调分区类型,请参考规则"; } if (!SpaceTypeEnum.AirConditioningZone.getCode().equals(slaveClassCode)) { return "从对象不属于空调分区类型,请参考规则"; } return null; } }