Eq2EqEqBackupRelationObject.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package com.persagy.proxy.adm.strategy.relationdata;
  2. import java.util.List;
  3. import org.springframework.stereotype.Component;
  4. import com.fasterxml.jackson.databind.node.ObjectNode;
  5. import com.persagy.dmp.basic.model.QueryCriteria;
  6. import com.persagy.dmp.common.model.response.CommonResult;
  7. import com.persagy.dmp.digital.client.DigitalRelationFacade;
  8. import com.persagy.dmp.digital.entity.ObjectDigital;
  9. import com.persagy.dmp.digital.entity.ObjectRelation;
  10. import com.persagy.proxy.adm.constant.AdmCommonConstant;
  11. import com.persagy.proxy.adm.constant.AdmObjectInfoConstant;
  12. import com.persagy.proxy.adm.constant.AdmRelationType;
  13. import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
  14. import com.persagy.proxy.adm.model.AdmRelationObject;
  15. import com.persagy.proxy.adm.service.IRelationReportService;
  16. /**
  17. *
  18. * @version 1.0.0
  19. * @company persagy
  20. * @author zhangqiankun
  21. * @date 2021年9月3日 上午9:42:46
  22. */
  23. @Component(value = AdmRelationType.EQ2EQ_EQUIPPOWER_2)
  24. public class Eq2EqEqBackupRelationObject extends AbstractReportRelationObject {
  25. public Eq2EqEqBackupRelationObject(IRelationReportService relationReportService) {
  26. super(relationReportService);
  27. }
  28. @Override
  29. public long countRelationObjects(String groupCode, String projectId) {
  30. QueryCriteria queryCriteria = new QueryCriteria();
  31. ObjectNode objectNode = OBJECT_MAPPER.createObjectNode();
  32. objectNode.put("graphCode", AdmRelationTypeEnum.EQ2EQ_EQUIPPOWER_2.getGraphCode());
  33. objectNode.put("relCode", AdmRelationTypeEnum.EQ2EQ_EQUIPPOWER_2.getRelCode());
  34. queryCriteria.setCriteria(objectNode);
  35. queryCriteria.setOnlyCount(true);
  36. CommonResult<List<ObjectRelation>> result = DigitalRelationFacade.queryPrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
  37. return result == null ? 0 : (result.getCount() == null ? 0 : result.getCount());
  38. }
  39. @Override
  40. protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
  41. throw new UnsupportedOperationException("未实现的策略类");
  42. }
  43. @Override
  44. public Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code) {
  45. return this.beforeSaveRelationObject(relationObject, AdmRelationTypeEnum.EQ2EQ_EQUIPPOWER_2, groupCode, projectId, code);
  46. }
  47. @Override
  48. protected String checkRelationObject(ObjectNode master, String masterClassCode, ObjectNode slave,
  49. String slaveClassCode) {
  50. if (!AdmObjectInfoConstant.CHECK_CLASS_CODES.contains(masterClassCode)) {
  51. return "主对象不属于低/高压开关柜,请参考规则";
  52. }
  53. return null;
  54. }
  55. }