Ss2SyShipRelationObject.java 2.8 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.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. * 图类型编码 -- SensorRelationship
  18. *
  19. * @version 1.0.0
  20. * @company persagy
  21. * @author zhangqiankun
  22. * @date 2021年9月3日 上午9:42:46
  23. */
  24. @Component(value = AdmRelationType.EQ2SY_SENSORRELATIONSHIP_SS2SY)
  25. public class Ss2SyShipRelationObject extends AbstractReportRelationObject {
  26. public Ss2SyShipRelationObject(IRelationReportService relationReportService) {
  27. super(relationReportService);
  28. }
  29. @Override
  30. public long countRelationObjects(String groupCode, String projectId) {
  31. QueryCriteria queryCriteria = new QueryCriteria();
  32. ObjectNode objectNode = OBJECT_MAPPER.createObjectNode();
  33. objectNode.put("graphCode", AdmRelationTypeEnum.EQ2SY_SENSORRELATIONSHIP_SS2SY.getGraphCode());
  34. objectNode.put("relCode", AdmRelationTypeEnum.EQ2SY_SENSORRELATIONSHIP_SS2SY.getRelCode());
  35. queryCriteria.setCriteria(objectNode);
  36. queryCriteria.setOnlyCount(true);
  37. CommonResult<List<ObjectRelation>> result = DigitalRelationFacade.queryPrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, queryCriteria);
  38. return result == null ? 0 : (result.getCount() == null ? 0 : result.getCount());
  39. }
  40. @Override
  41. public List<AdmRelationObject> findRelationObject(String groupCode, String projectId) {
  42. throw new UnsupportedOperationException("未实现的策略类");
  43. }
  44. @Override
  45. protected AdmRelationObject handleObjectDigital(ObjectDigital master, ObjectDigital slave, String groupCode, String projectId) {
  46. throw new UnsupportedOperationException("未实现的策略类");
  47. }
  48. @Override
  49. public Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code) {
  50. return this.beforeSaveRelationObject(relationObject, AdmRelationTypeEnum.EQ2SY_SENSORRELATIONSHIP_SS2SY, groupCode, projectId, code);
  51. }
  52. @Override
  53. protected String checkRelationObject(ObjectNode master, String masterClassCode, ObjectNode slave,
  54. String slaveClassCode) {
  55. if (!AdmObjectInfoConstant.CHECK_SENSOR_CODES.contains(masterClassCode)) {
  56. return "主对象不是传感器,请参考规则";
  57. }
  58. return null;
  59. }
  60. }