|
@@ -15,10 +15,11 @@ import com.persagy.dmp.common.model.entity.BaseEntity;
|
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
import com.persagy.dmp.common.utils.ResultHelper;
|
|
|
import com.persagy.dmp.digital.entity.ObjectDigital;
|
|
|
+import com.persagy.dmp.digital.entity.ObjectRelation;
|
|
|
+import com.persagy.dmp.digital.entity.RelationCalSign;
|
|
|
import com.persagy.dmp.digital.entity.RelationProjectCal;
|
|
|
import com.persagy.dmp.rwd.basic.constant.BusinessErrorRwdCode;
|
|
|
import com.persagy.dmp.rwd.digital.dao.ObjectDigitalMapper;
|
|
|
-import com.persagy.dmp.rwd.digital.domain.RelationCalSign;
|
|
|
import com.persagy.dmp.rwd.digital.service.IObjectRelationService;
|
|
|
import com.persagy.dmp.rwd.digital.service.RelationCaclService;
|
|
|
import com.persagy.dmp.rwd.digital.service.RelationCalSignService;
|
|
@@ -53,7 +54,7 @@ public class RelationCaclServiceImpl implements RelationCaclService {
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public CommonResult<List<RelationProjectCal>> createObjRelationsByKeywordAndObjType(@RequestBody RequestData requestData) {
|
|
|
+ public CommonResult<List<ObjectRelation>> createObjRelationsByKeywordAndObjType(@RequestBody RequestData requestData) {
|
|
|
// 0.更新计算时间,根据项目id和图类型编码及关系类型编码
|
|
|
updateComputeTimeByProjectAndGraphCodeAndRelCode(requestData.getGraphCode(),requestData.getRelCode());
|
|
|
// 根据对象信息点和对象内容(主/副)查询对象,然后添加关系及计算标记
|
|
@@ -88,12 +89,12 @@ public class RelationCaclServiceImpl implements RelationCaclService {
|
|
|
.filter(objectDigital -> !objectDigital.getMainFlag())
|
|
|
.collect(Collectors.toList());
|
|
|
// 4.3 根据主对象id和从对象id数组查询已经存在的关系
|
|
|
- Map<String, RelationProjectCal> relationMap =
|
|
|
+ Map<String, ObjectRelation> relationMap =
|
|
|
queryObjectRelationMapByFromIdAndToIds(masterObjectDigital.getId(),slaveObjectDigitals
|
|
|
.stream().map(BaseEntity::getId).collect(Collectors.toList()));
|
|
|
// 4.3 创建关系
|
|
|
- List<RelationProjectCal> addRelations = new ArrayList<>();
|
|
|
- List<RelationProjectCal> updateRelations = new ArrayList<>();
|
|
|
+ List<ObjectRelation> addRelations = new ArrayList<>();
|
|
|
+ List<ObjectRelation> updateRelations = new ArrayList<>();
|
|
|
List<RelationCalSign> relationCalSigns = new ArrayList<>();
|
|
|
boolean flag = StrUtil.isNotBlank(requestData.getSign()) && NumberUtil.isInteger(requestData.getSign());
|
|
|
for (ObjectDigital slaveObjectDigital : slaveObjectDigitals) {
|
|
@@ -105,7 +106,7 @@ public class RelationCaclServiceImpl implements RelationCaclService {
|
|
|
masterObjectDigital.getId(),
|
|
|
slaveObjectDigital.getId());
|
|
|
if (relationMap.containsKey(uniqueKey)){
|
|
|
- RelationProjectCal objectRelation = relationMap.get(uniqueKey);
|
|
|
+ ObjectRelation objectRelation = relationMap.get(uniqueKey);
|
|
|
objectRelation.setUpdateApp(AppContext.getContext().getAppId());
|
|
|
objectRelation.setModifier(AppContext.getContext().getAccountId());
|
|
|
if (requestData.getHasRelValue()){
|
|
@@ -124,7 +125,7 @@ public class RelationCaclServiceImpl implements RelationCaclService {
|
|
|
continue;
|
|
|
}
|
|
|
// 生成插入关系
|
|
|
- RelationProjectCal objectRelation = new RelationProjectCal();
|
|
|
+ ObjectRelation objectRelation = new ObjectRelation();
|
|
|
objectRelation.setId(IdWorker.getIdStr());
|
|
|
objectRelation.setGraphCode(requestData.getGraphCode());
|
|
|
objectRelation.setGroupCode(AppContext.getContext().getGroupCode());
|
|
@@ -175,22 +176,22 @@ public class RelationCaclServiceImpl implements RelationCaclService {
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public CommonResult<List<RelationProjectCal>> deleteObjRelationsByRelId(RelationProjectCal objectRelation) {
|
|
|
+ public CommonResult<List<ObjectRelation>> deleteObjRelationsByRelId(ObjectRelation objectRelation) {
|
|
|
// 1.先查询关系
|
|
|
- LambdaQueryWrapper<RelationProjectCal> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(RelationProjectCal::getGraphCode,objectRelation.getGraphCode());
|
|
|
- queryWrapper.eq(RelationProjectCal::getRelCode,objectRelation.getRelCode());
|
|
|
- queryWrapper.eq(RelationProjectCal::getObjFrom,objectRelation.getObjFrom());
|
|
|
- queryWrapper.eq(RelationProjectCal::getObjTo,objectRelation.getObjTo());
|
|
|
- queryWrapper.eq(RelationProjectCal::getValid,true);
|
|
|
- List<RelationProjectCal> objectRelations = objectRelationService.list(queryWrapper);
|
|
|
+ LambdaQueryWrapper<ObjectRelation> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(ObjectRelation::getGraphCode,objectRelation.getGraphCode());
|
|
|
+ queryWrapper.eq(ObjectRelation::getRelCode,objectRelation.getRelCode());
|
|
|
+ queryWrapper.eq(ObjectRelation::getObjFrom,objectRelation.getObjFrom());
|
|
|
+ queryWrapper.eq(ObjectRelation::getObjTo,objectRelation.getObjTo());
|
|
|
+ queryWrapper.eq(ObjectRelation::getValid,true);
|
|
|
+ List<ObjectRelation> objectRelations = objectRelationService.list(queryWrapper);
|
|
|
if (CollUtil.isEmpty(objectRelations)){
|
|
|
throw new BusinessException(BusinessErrorRwdCode.A7201.getCode(),BusinessErrorRwdCode.A7201.getDesc());
|
|
|
}
|
|
|
// 2.先更新计算时间
|
|
|
updateComputeTimeByProjectAndGraphCodeAndRelCode(objectRelation.getGraphCode(),objectRelation.getRelCode());
|
|
|
// 3.删除关系
|
|
|
- for (RelationProjectCal relation : objectRelations) {
|
|
|
+ for (ObjectRelation relation : objectRelations) {
|
|
|
relation.setValid(0);
|
|
|
relation.setModifier(AppContext.getContext().getAccountId());
|
|
|
relation.setUpdateApp(AppContext.getContext().getAppId());
|
|
@@ -209,11 +210,11 @@ public class RelationCaclServiceImpl implements RelationCaclService {
|
|
|
* Update By lijie 2021/9/4 23:14
|
|
|
*/
|
|
|
private void updateComputeTimeByProjectAndGraphCodeAndRelCode(String graphCode,String relCode) {
|
|
|
- LambdaUpdateWrapper<com.persagy.dmp.rwd.digital.domain.RelationProjectCal> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.eq(com.persagy.dmp.rwd.digital.domain.RelationProjectCal::getProjectId,AppContext.getContext().getProjectId());
|
|
|
- updateWrapper.eq(com.persagy.dmp.rwd.digital.domain.RelationProjectCal::getGraphCode,graphCode);
|
|
|
- updateWrapper.eq(com.persagy.dmp.rwd.digital.domain.RelationProjectCal::getRelCode,relCode);
|
|
|
- com.persagy.dmp.rwd.digital.domain.RelationProjectCal relationProjectCal = new com.persagy.dmp.rwd.digital.domain.RelationProjectCal();
|
|
|
+ LambdaUpdateWrapper<RelationProjectCal> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.eq(RelationProjectCal::getProjectId,AppContext.getContext().getProjectId());
|
|
|
+ updateWrapper.eq(RelationProjectCal::getGraphCode,graphCode);
|
|
|
+ updateWrapper.eq(RelationProjectCal::getRelCode,relCode);
|
|
|
+ RelationProjectCal relationProjectCal = new RelationProjectCal();
|
|
|
relationProjectCal.setComputingTime(DateUtil.format(new Date(),"yyyyMMddHHmmss"));
|
|
|
relationProjectCalService.update(relationProjectCal,updateWrapper);
|
|
|
}
|
|
@@ -228,15 +229,15 @@ public class RelationCaclServiceImpl implements RelationCaclService {
|
|
|
* @date :2021/9/3 16:29
|
|
|
* Update By lijie 2021/9/3 16:29
|
|
|
*/
|
|
|
- private Map<String, RelationProjectCal> queryObjectRelationMapByFromIdAndToIds(String fromId, List<String> toIds) {
|
|
|
+ private Map<String, ObjectRelation> queryObjectRelationMapByFromIdAndToIds(String fromId, List<String> toIds) {
|
|
|
if (StrUtil.isBlank(fromId) || CollUtil.isEmpty(toIds)){
|
|
|
return new HashMap<>();
|
|
|
}
|
|
|
- LambdaQueryWrapper<RelationProjectCal> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.in(RelationProjectCal::getObjTo,toIds);
|
|
|
- queryWrapper.eq(RelationProjectCal::getObjFrom,fromId);
|
|
|
- queryWrapper.eq(RelationProjectCal::getValid,true);
|
|
|
- List<RelationProjectCal> objectRelations = objectRelationService.list(queryWrapper);
|
|
|
+ LambdaQueryWrapper<ObjectRelation> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(ObjectRelation::getObjTo,toIds);
|
|
|
+ queryWrapper.eq(ObjectRelation::getObjFrom,fromId);
|
|
|
+ queryWrapper.eq(ObjectRelation::getValid,true);
|
|
|
+ List<ObjectRelation> objectRelations = objectRelationService.list(queryWrapper);
|
|
|
if (CollUtil.isEmpty(objectRelations)){
|
|
|
return new HashMap<>();
|
|
|
}
|