| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- package com.persagy.proxy.adm.strategy.relationdata;
- import java.util.List;
- import java.util.Set;
- import com.fasterxml.jackson.databind.node.ObjectNode;
- import com.persagy.dmp.basic.dto.RequestData;
- import com.persagy.dmp.common.model.response.CommonResult;
- import com.persagy.dmp.digital.client.DigitalObjectFacade;
- 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.AdmRelationTypeEnum;
- import com.persagy.proxy.report.model.AdmRelationObject;
- import com.persagy.proxy.report.service.IRelationReportService;
- import cn.hutool.core.collection.CollectionUtil;
- /**
- * 普通操作抽象类
- *
- * @version 1.0.0
- * @company persagy
- * @author zhangqiankun
- * @date 2021年9月2日 下午11:00:26
- */
- public abstract class AbstractRelationObject implements RelationObjectStrategy {
- protected IRelationReportService relationReportService;
-
- public AbstractRelationObject(IRelationReportService reportDownloadService) {
- this.relationReportService = reportDownloadService;
- }
-
- @Override
- public long countRelationObjects(String groupCode, String projectId, AdmRelationTypeEnum typeEnum) {
- return this.countRelationObjects(groupCode, projectId);
- }
-
- /**
- * 统计关系总数
- *
- * @param groupCode
- * @param projectId
- * @return
- */
- protected abstract long countRelationObjects(String groupCode, String projectId);
-
- @Override
- public List<ObjectDigital> queryAllRelations(String groupCode, String projectId, String mainContent, Set<String> slaveContent, AdmRelationTypeEnum typeEnum) {
- return this.queryAllRelations(groupCode, projectId, mainContent, slaveContent);
- }
-
- /**
- * 查询出所有的关系对象数据
- *
- * @param groupCode 集团编码
- * @param projectId 项目ID
- * @param mainContent 主对象的筛选关键字,筛选范围为id,name,local_id,local_name,cADID.为关系左侧对象
- * @param slaveContent 从对象的筛选关键字.objTo对应的对象,筛选范围为id,name,local_id,local_name.为关系右侧对象
- * @return 不会返回null
- */
- protected abstract List<ObjectDigital> queryAllRelations(String groupCode, String projectId, String mainContent, Set<String> slaveContent);
-
-
- @Override
- public void queryPageRelations(List<ObjectDigital> allDigitals, RequestData requestData, String groupCode, String projectId) {
- CommonResult<List<ObjectDigital>> queryPrototype = DigitalObjectFacade.queryObjectListByGraphCodeAndRelCodePrototype(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, requestData);
- Long count = queryPrototype.getCount();
- List<ObjectDigital> infos = queryPrototype.getData();
- if (count == null || CollectionUtil.isEmpty(infos)) {
- return;
- }
-
- allDigitals.addAll(infos);
- if (count < 500) {
- return;
- } else if ((infos.size()*requestData.getPage()) > count) {
- return;
- } else {
- requestData.setPage((requestData.getPage() + 1));
- this.queryPageRelations(allDigitals, requestData, groupCode, projectId);
- }
- }
-
- @Override
- public boolean saveRelationObject(ObjectNode relationObject, String groupCode, String projectId) {
- ObjectRelation objectRelation = DigitalRelationFacade.createOne(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, relationObject);
- return objectRelation != null;
- }
-
- @Override
- public boolean saveRelationObjects(List<ObjectNode> relationObjects, String groupCode, String projectId) {
- List<ObjectRelation> create = DigitalRelationFacade.create(groupCode, projectId, AdmCommonConstant.APP_ID, AdmCommonConstant.USER_ID, relationObjects);
- return CollectionUtil.isNotEmpty(create);
- }
-
- /**************************************************** 默认不实现的类 *******************************************************/
-
- @Override
- public List<AdmRelationObject> exportRelationObject(String groupCode, String projectId) {
- throw new UnsupportedOperationException("未实现的策略方法");
- }
- @Override
- public Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code, AdmRelationTypeEnum typeEnum) {
- return this.beforeSaveRelationObject(relationObject, groupCode, projectId, code);
- }
-
- protected Object beforeSaveRelationObject(AdmRelationObject relationObject, String groupCode, String projectId, String code) {
- throw new UnsupportedOperationException("未实现的策略方法");
- }
-
- }
|