EquipPowerEqBackupRelationObject.java 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package com.persagy.proxy.adm.strategy.relationdata;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.Set;
  5. import org.springframework.stereotype.Component;
  6. import com.fasterxml.jackson.databind.node.ObjectNode;
  7. import com.persagy.dmp.basic.dto.RequestData;
  8. import com.persagy.dmp.basic.model.QueryCriteria;
  9. import com.persagy.dmp.common.model.response.CommonResult;
  10. import com.persagy.dmp.digital.client.DigitalRelationFacade;
  11. import com.persagy.dmp.digital.entity.ObjectDigital;
  12. import com.persagy.dmp.digital.entity.ObjectRelation;
  13. import com.persagy.proxy.adm.constant.AdmCommonConstant;
  14. import com.persagy.proxy.adm.constant.AdmObjectInfoConstant;
  15. import com.persagy.proxy.adm.constant.AdmRelationType;
  16. import com.persagy.proxy.adm.constant.AdmRelationTypeEnum;
  17. import com.persagy.proxy.adm.model.AdmRelationObject;
  18. import com.persagy.proxy.adm.service.IRelationReportService;
  19. import cn.hutool.core.collection.CollectionUtil;
  20. import cn.hutool.core.util.StrUtil;
  21. /**
  22. *
  23. * @version 1.0.0
  24. * @company persagy
  25. * @author zhangqiankun
  26. * @date 2021年9月3日 上午9:42:46
  27. */
  28. @Component(value = AdmRelationType.EQUIPPOWER_EQBACKUP)
  29. public class EquipPowerEqBackupRelationObject extends AbstractReportRelationObject {
  30. public EquipPowerEqBackupRelationObject(IRelationReportService relationReportService) {
  31. super(relationReportService);
  32. }
  33. @Override
  34. public long countRelationObjects(String groupCode, String projectId) {
  35. QueryCriteria queryCriteria = new QueryCriteria();
  36. ObjectNode objectNode = OBJECT_MAPPER.createObjectNode();
  37. objectNode.put("graphCode", AdmRelationTypeEnum.EQ2EQ_EQUIPPOWER_2.getGraphCode());
  38. objectNode.put("relCode", AdmRelationTypeEnum.EQ2EQ_EQUIPPOWER_2.getRelCode());
  39. queryCriteria.setCriteria(objectNode);
  40. queryCriteria.setOnlyCount(true);
  41. CommonResult<List<ObjectRelation>> result = DigitalRelationFacade.queryPrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
  42. return result == null ? 0 : (result.getCount() == null ? 0 : result.getCount());
  43. }
  44. @Override
  45. public List<ObjectDigital> queryAllRelations(String groupCode, String projectId, String mainContent, Set<String> slaveContent) {
  46. RequestData requestData = new RequestData();
  47. requestData.setGraphCode(AdmRelationTypeEnum.EQ2EQ_EQUIPPOWER_2.getGraphCode());
  48. requestData.setRelCode(AdmRelationTypeEnum.EQ2EQ_EQUIPPOWER_2.getRelCode());
  49. if (StrUtil.isNotBlank(mainContent)) {
  50. requestData.setMainContent(mainContent);
  51. }
  52. if (CollectionUtil.isNotEmpty(slaveContent)) {
  53. requestData.setSlaveContent(slaveContent);
  54. }
  55. requestData.setPage(1L);
  56. requestData.setSize(500L);
  57. List<ObjectDigital> allDigitals = new ArrayList<ObjectDigital>();
  58. this.queryPageRelations(allDigitals, requestData, groupCode, projectId);
  59. return allDigitals;
  60. }
  61. @Override
  62. protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
  63. throw new UnsupportedOperationException("未实现的策略类");
  64. }
  65. @Override
  66. public Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code) {
  67. return this.beforeSaveRelationObject(relationObject, AdmRelationTypeEnum.EQ2EQ_EQUIPPOWER_2, groupCode, projectId, code);
  68. }
  69. @Override
  70. protected String checkRelationObject(ObjectNode master, String masterClassCode, ObjectNode slave,
  71. String slaveClassCode) {
  72. if (!AdmObjectInfoConstant.CHECK_CLASS_CODES.contains(masterClassCode)) {
  73. return "主对象不属于低/高压开关柜,请参考规则";
  74. }
  75. return null;
  76. }
  77. }