Eq2EqEqBackupRelationObject.java 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.digital.client.DigitalRelationFacade;
  7. import com.persagy.dmp.digital.entity.ObjectDigital;
  8. import com.persagy.dmp.digital.entity.ObjectRelation;
  9. import com.persagy.proxy.adm.constant.AdmCommonConstant;
  10. import com.persagy.proxy.adm.constant.AdmObjectInfoConstant;
  11. import com.persagy.proxy.adm.constant.AdmRelationType;
  12. import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
  13. import com.persagy.proxy.adm.model.AdmRelationObject;
  14. import com.persagy.proxy.adm.service.IRelationReportService;
  15. import cn.hutool.core.collection.CollectionUtil;
  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 AbstractQueryRelationObject {
  25. public Eq2EqEqBackupRelationObject(IRelationReportService relationReportService) {
  26. super(relationReportService);
  27. }
  28. @Override
  29. public int 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. List<ObjectRelation> result = DigitalRelationFacade.query(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
  37. return CollectionUtil.isEmpty(result) ? 0 : result.size();
  38. }
  39. @Override
  40. public List<AdmRelationObject> findRelationObject(String groupCode, String projectId) {
  41. throw new UnsupportedOperationException("未实现的策略类");
  42. }
  43. @Override
  44. protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
  45. throw new UnsupportedOperationException("未实现的策略类");
  46. }
  47. @Override
  48. public Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code) {
  49. return this.beforeSaveRelationObject(relationObject, AdmRelationTypeEnum.EQ2EQ_EQUIPPOWER_2, groupCode, projectId, code);
  50. }
  51. @Override
  52. protected String checkRelationObject(ObjectNode master, String masterClassCode, ObjectNode slave,
  53. String slaveClassCode) {
  54. if (!AdmObjectInfoConstant.CHECK_CLASS_CODES.contains(masterClassCode)) {
  55. return "主对象不属于低/高压开关柜,请参考规则";
  56. }
  57. return null;
  58. }
  59. }