|
@@ -7,23 +7,27 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
+import com.persagy.dmp.basic.dto.RelationCalDTO;
|
|
|
+import com.persagy.dmp.basic.dto.RelationCalRuleDTO;
|
|
|
import com.persagy.dmp.basic.dto.RequestData;
|
|
|
import com.persagy.dmp.common.constant.CommonConstant;
|
|
|
import com.persagy.dmp.common.context.AppContext;
|
|
|
import com.persagy.dmp.common.exception.BusinessException;
|
|
|
+import com.persagy.dmp.common.helper.SpringHelper;
|
|
|
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.define.entity.RelationDefine;
|
|
|
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.basic.constant.CalRuleTypeEnum;
|
|
|
+import com.persagy.dmp.rwd.define.service.IRelationDefineService;
|
|
|
import com.persagy.dmp.rwd.digital.dao.ObjectDigitalMapper;
|
|
|
-import com.persagy.dmp.rwd.digital.service.IObjectRelationService;
|
|
|
-import com.persagy.dmp.rwd.digital.service.RelationCaclService;
|
|
|
-import com.persagy.dmp.rwd.digital.service.RelationCalSignService;
|
|
|
-import com.persagy.dmp.rwd.digital.service.RelationProjectCalService;
|
|
|
+import com.persagy.dmp.rwd.digital.domain.CalculatingDTO;
|
|
|
+import com.persagy.dmp.rwd.digital.service.*;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -36,12 +40,13 @@ import java.util.stream.Collectors;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
@RequiredArgsConstructor
|
|
|
-public class RelationCaclServiceImpl implements RelationCaclService {
|
|
|
+public class RelationCalServiceImpl implements RelationCalService {
|
|
|
|
|
|
private final ObjectDigitalMapper objectDigitalMapper;
|
|
|
private final IObjectRelationService objectRelationService;
|
|
|
private final RelationCalSignService relationCalSignService;
|
|
|
private final RelationProjectCalService relationProjectCalService;
|
|
|
+ private final IRelationDefineService relationDefineService;
|
|
|
|
|
|
|
|
|
|
|
@@ -209,12 +214,132 @@ public class RelationCaclServiceImpl implements RelationCaclService {
|
|
|
*/
|
|
|
@Override
|
|
|
public CommonResult<List<ObjectRelation>> calculatingObjRelation(RequestData requestData) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ CalculatingDTO calculatingDTO = copyRequestDataToDTO(requestData);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ LambdaQueryWrapper<RelationDefine> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+
|
|
|
+
|
|
|
+ queryWrapper.eq(BaseEntity::getValid,true);
|
|
|
+ List<RelationDefine> relationDefines = relationDefineService.queryByCondition(queryWrapper);
|
|
|
+ if (CollUtil.isEmpty(relationDefines)){
|
|
|
+ throw new BusinessException(BusinessErrorRwdCode.A7309.getCode(),BusinessErrorRwdCode.A7309.getDesc());
|
|
|
+ }
|
|
|
+
|
|
|
+ Optional<RelationDefine> currentRelationDefineList = relationDefines.stream()
|
|
|
+ .filter(relationDefine ->
|
|
|
+ relationDefine.getGraphCode().equals(calculatingDTO.getGraphCode())
|
|
|
+ && relationDefine.getCode().equals(calculatingDTO.getRelCode()))
|
|
|
+ .findFirst();
|
|
|
+ if (!currentRelationDefineList.isPresent()){
|
|
|
+ throw new BusinessException(BusinessErrorRwdCode.A7309.getCode(),BusinessErrorRwdCode.A7309.getDesc());
|
|
|
+ }
|
|
|
+ RelationDefine currentRelationDefine = currentRelationDefineList.get();
|
|
|
+ Map<String, RelationDefine> relationDefineMap = relationDefines.stream().collect(Collectors.toMap(relationDefine ->
|
|
|
+ relationDefine.getGraphCode() + StrUtil.UNDERLINE + relationDefine.getCode(),
|
|
|
+ relationDefine -> relationDefine, (k1, k2) -> k1));
|
|
|
+ calculatingDTO.setRelationDefineMap(relationDefineMap);
|
|
|
+
|
|
|
+ handlePreRelation(currentRelationDefine,calculatingDTO);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return ResultHelper.multi(new ArrayList<>(),0L);
|
|
|
}
|
|
|
+
|
|
|
+ * Description: 拷贝请求参数到DTO中
|
|
|
+ * @param requestData : 请求参数
|
|
|
+ * @return : com.persagy.dmp.rwd.digital.domain.CalculatingDTO
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/9/8 14:56
|
|
|
+ * Update By lijie 2021/9/8 14:56
|
|
|
+ */
|
|
|
+ private CalculatingDTO copyRequestDataToDTO(RequestData requestData) {
|
|
|
+ return CalculatingDTO.builder()
|
|
|
+ .graphCode(requestData.getGraphCode())
|
|
|
+ .relCode(requestData.getRelCode())
|
|
|
+ .mainContent(requestData.getMainContent())
|
|
|
+ .slaveContent(requestData.getSlaveContent())
|
|
|
+ .relValue(requestData.getRelValue())
|
|
|
+ .calBeforeRelFlag(requestData.getCalBeforeRelFlag())
|
|
|
+ .groupCode(AppContext.getContext().getGroupCode())
|
|
|
+ .projectId(AppContext.getContext().getProjectId())
|
|
|
+ .appId(AppContext.getContext().getAppId())
|
|
|
+ .accountId(AppContext.getContext().getAccountId())
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * Description: 计算关系前先校验一下数据(fast-fail)
|
|
|
+ * @param requestData : 请求参数
|
|
|
+ * @return : com.persagy.dmp.rwd.digital.domain.CalculatingDTO
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/9/8 11:44
|
|
|
+ * Update By lijie 2021/9/8 11:44
|
|
|
+ */
|
|
|
+ private void calculationRelationDatas(RequestData requestData) {
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * Description: 计算前置关系
|
|
|
+ * @param currentRelationDefine : 当前关系定义
|
|
|
+ * @param calculatingDTO : 请求参数
|
|
|
+ * @return : void
|
|
|
+ * @author : lijie
|
|
|
+ * @date :2021/9/8 11:03
|
|
|
+ * Update By lijie 2021/9/8 11:03
|
|
|
+ */
|
|
|
+ private void handlePreRelation(RelationDefine currentRelationDefine, CalculatingDTO calculatingDTO) {
|
|
|
+ if (CollUtil.isEmpty(currentRelationDefine.getBeforeCalRels())){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ if (StrUtil.isBlank(relationCalDTO.getGraphCode())
|
|
|
+ || 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());
|
|
|
+ }
|
|
|
+ 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.A7312.getCode(),BusinessErrorRwdCode.A7312.getDesc());
|
|
|
+ }
|
|
|
+ if (CalRuleTypeEnum.REL_CHAIN.getIndex().equals(calRules.getCalRuleType())){
|
|
|
+ CalculateService calculateService = SpringHelper
|
|
|
+ .getBean(CalRuleTypeEnum.REL_CHAIN.getBeanName(), CalculateService.class);
|
|
|
+ calculateService.calculateRelation(calRules,calculatingDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
|
|
|
* Description: 根据项目id和图类型编码及关系类型编码更新计算时间
|