|
@@ -205,7 +205,7 @@ public class RelationCalServiceImpl implements RelationCalService {
|
|
|
return ResultHelper.multi(objectRelations,objectRelations.size());
|
|
|
}
|
|
|
|
|
|
- * Description: 关系计算
|
|
|
+ * Description: 关系计算(整体计算采用fast-fail机制处理,遇到失败立即中止,不进行计算)
|
|
|
* @param requestData : 请求参数
|
|
|
* @return : com.persagy.dmp.common.model.response.CommonResult<java.util.List<com.persagy.dmp.digital.entity.ObjectRelation>>
|
|
|
* @author : lijie
|
|
@@ -213,6 +213,7 @@ public class RelationCalServiceImpl implements RelationCalService {
|
|
|
* Update By lijie 2021/9/7 14:36
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public CommonResult<List<ObjectRelation>> calculatingObjRelation(RequestData requestData) {
|
|
|
|
|
|
CalculatingDTO calculatingDTO = copyRequestDataToDTO(requestData);
|
|
@@ -303,42 +304,37 @@ public class RelationCalServiceImpl implements RelationCalService {
|
|
|
if (!calculatingDTO.getCalBeforeRelFlag()){
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
List<RelationCalDTO> beforeCalRels = currentRelationDefine.getBeforeCalRels();
|
|
|
+
|
|
|
Map<String, RelationDefine> relationDefineMap = calculatingDTO.getRelationDefineMap();
|
|
|
- String prefixDefineObjType = "";
|
|
|
- int size = beforeCalRels.size();
|
|
|
- for (int i = 0; i < size; i++) {
|
|
|
- RelationCalDTO relationCalDTO = beforeCalRels.get(i);
|
|
|
+
|
|
|
+ Map<String, String> calRuleTypeMap = CalRuleTypeEnum.getCalRuleTypeMap();
|
|
|
+ for (RelationCalDTO relationCalDTO : beforeCalRels) {
|
|
|
+
|
|
|
if (StrUtil.isBlank(relationCalDTO.getGraphCode())
|
|
|
- || StrUtil.isBlank(relationCalDTO.getRelCode())){
|
|
|
- throw new BusinessException(BusinessErrorRwdCode.A7307.getCode(),BusinessErrorRwdCode.A7307.getDesc());
|
|
|
+ || StrUtil.isBlank(relationCalDTO.getRelCode())) {
|
|
|
+ throw new BusinessException(BusinessErrorRwdCode.A7307.getCode(), BusinessErrorRwdCode.A7307.getDesc());
|
|
|
}
|
|
|
- String tempKey = relationCalDTO.getGraphCode()+StrUtil.UNDERLINE+relationCalDTO.getRelCode();
|
|
|
- if (!relationDefineMap.containsKey(tempKey)){
|
|
|
- throw new BusinessException(BusinessErrorRwdCode.A7309.getCode(),BusinessErrorRwdCode.A7309.getDesc());
|
|
|
+
|
|
|
+ String tempKey = relationCalDTO.getGraphCode() + StrUtil.UNDERLINE + relationCalDTO.getRelCode();
|
|
|
+ if (!relationDefineMap.containsKey(tempKey)) {
|
|
|
+ throw new BusinessException(BusinessErrorRwdCode.A7309.getCode(), BusinessErrorRwdCode.A7309.getDesc());
|
|
|
}
|
|
|
+
|
|
|
RelationDefine relationDefine = relationDefineMap.get(tempKey);
|
|
|
RelationCalRuleDTO calRules = relationDefine.getCalRules();
|
|
|
- if (!(CalRuleTypeEnum.REL_CHAIN.getIndex().equals(calRules.getCalRuleType())
|
|
|
- || CalRuleTypeEnum.COORDINATE.getIndex().equals(calRules.getCalRuleType()))){
|
|
|
- throw new BusinessException(BusinessErrorRwdCode.A7308.getCode(),BusinessErrorRwdCode.A7308.getDesc());
|
|
|
- }
|
|
|
- if (CalRuleTypeEnum.REL_CHAIN.getIndex().equals(calRules.getCalRuleType())){
|
|
|
- CalculateService calculateService = SpringHelper
|
|
|
- .getBean(CalRuleTypeEnum.REL_CHAIN.getBeanName(), CalculateService.class);
|
|
|
- calculateService.calculateRelation(calRules,calculatingDTO);
|
|
|
+ if (!calRuleTypeMap.containsKey(calRules.getCalRuleType())) {
|
|
|
+ throw new BusinessException(BusinessErrorRwdCode.A7308.getCode(), BusinessErrorRwdCode.A7308.getDesc());
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ calculatingDTO.setRelationDefine(relationDefine);
|
|
|
+
|
|
|
+ CalculateService calculateService = SpringHelper
|
|
|
+ .getBean(calRuleTypeMap.get(calRules.getCalRuleType()), CalculateService.class);
|
|
|
+
|
|
|
+ calculateService.calculateRelation(calRules, calculatingDTO);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|