Ver código fonte

自测createObjRelationsByKeywordAndObjType接口

lijie 3 anos atrás
pai
commit
5713978bce

+ 1 - 1
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/controller/RelationCaclController.java

@@ -44,7 +44,7 @@ public class RelationCaclController {
     @PostMapping("/createObjRelationsByKeywordAndObjType")
     public CommonResult<List<ObjectRelation>> createObjRelationsByKeywordAndObjType(@RequestBody RequestData requestData){
         // 校验必填项
-        if (StrUtil.isBlank(requestData.getGroupCode())
+        if (StrUtil.isBlank(requestData.getGraphCode())
                 || StrUtil.isBlank(requestData.getRelCode())
                 || StrUtil.isBlank(requestData.getMasterObjType())
                 || StrUtil.isBlank(requestData.getSlaveObjType())

+ 6 - 84
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/domain/RelationCalSign.java

@@ -3,10 +3,9 @@ package com.persagy.dmp.rwd.digital.domain;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import lombok.AllArgsConstructor;
-import lombok.Builder;
-import lombok.Data;
-import lombok.NoArgsConstructor;
+import com.persagy.dmp.common.model.entity.AuditableEntity;
+import lombok.*;
+import lombok.experimental.SuperBuilder;
 
 import java.io.Serializable;
 import java.util.Date;
@@ -20,12 +19,9 @@ import java.util.Date;
 @Builder
 @NoArgsConstructor
 @AllArgsConstructor
-public class RelationCalSign implements Serializable {
-    /**
-     * 主键id,与dt_relation保持一致
-     */
-    @TableId(value = "id")
-    private String id;
+@EqualsAndHashCode(callSuper=true)
+@ToString(callSuper = true)
+public class RelationCalSign extends AuditableEntity {
 
     /**
      * 计算标记 1 为手动 2为自动
@@ -33,80 +29,6 @@ public class RelationCalSign implements Serializable {
     @TableField(value = "sign")
     private Integer sign;
 
-    /**
-     * 创建时间,格式为yyyyMMddHHmmss
-     */
-    @TableField(value = "creation_time")
-    private String creationTime;
-
-    /**
-     * 更新时间,格式为yyyyMMddHHmmss
-     */
-    @TableField(value = "modified_time")
-    private String modifiedTime;
-
-    /**
-     * 合法标记,true-有效,false-无效
-     */
-    @TableField(value = "valid")
-    private Byte valid;
-
-    /**
-     * 乐观锁
-     */
-    @TableField(value = "ts")
-    private Date ts;
-
     @TableField(exist = false)
     private static final long serialVersionUID = 1L;
-
-    @Override
-    public boolean equals(Object that) {
-        if (this == that) {
-            return true;
-        }
-        if (that == null) {
-            return false;
-        }
-        if (getClass() != that.getClass()) {
-            return false;
-        }
-        RelationCalSign other = (RelationCalSign) that;
-        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
-            && (this.getSign() == null ? other.getSign() == null : this.getSign().equals(other.getSign()))
-            && (this.getCreationTime() == null ? other.getCreationTime() == null : this.getCreationTime().equals(other.getCreationTime()))
-            && (this.getModifiedTime() == null ? other.getModifiedTime() == null : this.getModifiedTime().equals(other.getModifiedTime()))
-            && (this.getValid() == null ? other.getValid() == null : this.getValid().equals(other.getValid()))
-            && (this.getTs() == null ? other.getTs() == null : this.getTs().equals(other.getTs()));
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
-        result = prime * result + ((getSign() == null) ? 0 : getSign().hashCode());
-        result = prime * result + ((getCreationTime() == null) ? 0 : getCreationTime().hashCode());
-        result = prime * result + ((getModifiedTime() == null) ? 0 : getModifiedTime().hashCode());
-        result = prime * result + ((getValid() == null) ? 0 : getValid().hashCode());
-        result = prime * result + ((getTs() == null) ? 0 : getTs().hashCode());
-        return result;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getClass().getSimpleName());
-        sb.append(" [");
-        sb.append("Hash = ").append(hashCode());
-        sb.append(", id=").append(id);
-        sb.append(", sign=").append(sign);
-        sb.append(", creationTime=").append(creationTime);
-        sb.append(", modifiedTime=").append(modifiedTime);
-        sb.append(", valid=").append(valid);
-        sb.append(", ts=").append(ts);
-        sb.append(", serialVersionUID=").append(serialVersionUID);
-        sb.append("]");
-        return sb.toString();
-    }
 }

+ 14 - 8
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/service/impl/RelationCaclServiceImpl.java

@@ -26,6 +26,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.hibernate.validator.constraints.Length;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.RequestBody;
 
 import javax.validation.constraints.NotNull;
@@ -51,6 +52,7 @@ public class RelationCaclServiceImpl implements RelationCaclService {
      * Update By lijie 2021/9/2 21:24
      */
     @Override
+    @Transactional
     public CommonResult<List<ObjectRelation>> createObjRelationsByKeywordAndObjType(@RequestBody RequestData requestData) {
         // 根据对象信息点和对象内容(主/副)查询对象,然后添加关系及计算标记
         requestData.setProjectId(AppContext.getContext().getProjectId());
@@ -109,11 +111,13 @@ public class RelationCaclServiceImpl implements RelationCaclService {
                 }
                 updateRelations.add(objectRelation);
                 if (flag){
-                    relationCalSigns.add(RelationCalSign
+                    // 因为lombok的SuperBuilder注解还处于实验性,所以暂时不用
+                    RelationCalSign relationCalSign = RelationCalSign
                             .builder()
-                            .id(objectRelation.getId())
                             .sign(NumberUtil.parseInt(requestData.getSign()))
-                            .build());
+                            .build();
+                    relationCalSign.setId(objectRelation.getId());
+                    relationCalSigns.add(relationCalSign);
                 }
                 continue;
             }
@@ -134,13 +138,15 @@ public class RelationCaclServiceImpl implements RelationCaclService {
             }
             objectRelation.setCreator(AppContext.getContext().getAccountId());
             objectRelation.setModifier(AppContext.getContext().getAccountId());
+            objectRelation.setValid(1);
             addRelations.add(objectRelation);
             if (flag){
-                relationCalSigns.add(RelationCalSign
+                RelationCalSign relationCalSign = RelationCalSign
                         .builder()
-                        .id(objectRelation.getId())
                         .sign(NumberUtil.parseInt(requestData.getSign()))
-                        .build());
+                        .build();
+                relationCalSign.setId(objectRelation.getId());
+                relationCalSigns.add(relationCalSign);
             }
         }
         if (CollUtil.isNotEmpty(updateRelations)){
@@ -316,10 +322,10 @@ public class RelationCaclServiceImpl implements RelationCaclService {
         long count = resultList.stream()
                 .filter(ObjectDigital::getMainFlag).count();
         if (count<=0){
-            throw new BusinessException(BusinessErrorRwdCode.A7301.getCode(), requestData.getFromContent()+BusinessErrorRwdCode.A7301.getDesc());
+            throw new BusinessException(BusinessErrorRwdCode.A7301.getCode(), requestData.getMainContent()+BusinessErrorRwdCode.A7301.getDesc());
         }
         if (count>1){
-            throw new BusinessException(BusinessErrorRwdCode.A7302.getCode(), requestData.getFromContent()+BusinessErrorRwdCode.A7302.getDesc());
+            throw new BusinessException(BusinessErrorRwdCode.A7302.getCode(), requestData.getMainContent()+BusinessErrorRwdCode.A7302.getDesc());
         }
     }
 }

+ 2 - 2
dmp-business/dmp-rwd/src/main/resources/mapper/ObjectDigitalMapper.xml

@@ -326,7 +326,7 @@
         SELECT
             dobj.*,
             true AS mainFlag,
-            IFNULL(JSON_UNQUOTE(JSON_EXTRACT(dobj.infos, '$.cADID')),"") AS cadId
+            IFNULL(JSON_UNQUOTE(JSON_EXTRACT(dobj.infos, '$.cADID')),'') AS cadId
         <include refid="queryMasterObjSql">
             <property name="param" value="#{param}"/>
         </include>
@@ -334,7 +334,7 @@
         SELECT
         dobj.*,
         false AS mainFlag,
-        IFNULL(JSON_UNQUOTE(JSON_EXTRACT(dobj.infos, '$.cADID')),"") AS cadId
+        IFNULL(JSON_UNQUOTE(JSON_EXTRACT(dobj.infos, '$.cADID')),'') AS cadId
         FROM
         dt_object AS dobj
         WHERE

+ 1 - 0
dmp-common/src/main/java/com/persagy/dmp/common/model/entity/AuditableEntity.java

@@ -3,6 +3,7 @@ package com.persagy.dmp.common.model.entity;
 import com.persagy.dmp.common.lang.PsDateTime;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
+import lombok.experimental.SuperBuilder;
 
 /**
  * 审计信息父类