浏览代码

对象数据-修改接口,bug修复

linhuili 3 年之前
父节点
当前提交
2bad08cc89

+ 69 - 0
dmp-business/dmp-dic/pom.xml

@@ -34,5 +34,74 @@
             <groupId>com.persagy</groupId>
             <artifactId>dmp-digital-starter</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.persagy</groupId>
+            <artifactId>dmp-rwd</artifactId>
+            <version>1.0.0</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
+
+    <build>
+    <finalName>dmp-dic</finalName>
+    <plugins>
+    <plugin>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-maven-plugin</artifactId>
+        <configuration>
+            <fork>true</fork>
+            <jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
+        </configuration>
+        <executions>
+            <execution>
+                <goals>
+                    <goal>repackage</goal>
+                </goals>
+            </execution>
+        </executions>
+    </plugin>
+    <!--
+    -->
+    <plugin>
+        <groupId>com.mysema.maven</groupId>
+        <artifactId>apt-maven-plugin</artifactId>
+        <version>1.1.3</version>
+        <executions>
+            <execution>
+                <phase>generate-sources</phase>
+                <goals>
+                    <goal>process</goal>
+                </goals>
+                <configuration>
+                    <outputDirectory>target/generated-sources</outputDirectory>
+                    <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
+                </configuration>
+            </execution>
+        </executions>
+    </plugin>
+    <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <executions>
+            <execution>
+                <id>copy-resources</id>
+                <phase>package</phase>
+                <goals>
+                    <goal>copy-resources</goal>
+                </goals>
+                <configuration>
+                    <resources>
+                        <resource>
+                            <directory>src/main/resources/</directory>
+                            <includes>
+                                <include>**/*.yml</include>
+                            </includes>
+                        </resource>
+                    </resources>
+                    <outputDirectory>${project.build.directory}/config</outputDirectory>
+                </configuration>
+            </execution>
+        </executions>
+    </plugin>
+    </plugins>
+    </build>
 </project>

+ 1 - 1
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/entity/ObjectDigital.java

@@ -17,7 +17,7 @@ import java.util.List;
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
-@TableName("dt_object")
+@TableName(value = "dt_object",autoResultMap = true)
 public class ObjectDigital extends AuditableEntity {
     /** 项目ID */
     private String projectId;

+ 5 - 4
dmp-business/dmp-rwd/src/main/java/com/persagy/dmp/rwd/digital/service/impl/ObjectDigitalServiceImpl.java

@@ -22,9 +22,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 对象数据 实现类
@@ -94,6 +92,7 @@ public class ObjectDigitalServiceImpl implements IObjectDigitalService {
             dao.updateById(vo);
             // 修改后消息
             messageSender.sendMessage(DigitalMessageConstant.OPERATE_AFTER_UPDATE, dbVO, vo, false);
+
         });
         return voList;
     }
@@ -133,11 +132,13 @@ public class ObjectDigitalServiceImpl implements IObjectDigitalService {
                 String infoCode = infoKeys.next();
                 // 如果信息点中不存在,移除
                 if(!infoMap.containsKey(infoCode)) {
-                    infos.remove(infoCode);
+                   // infos.remove(infoCode);
+                    infoKeys.remove();
                     continue;
                 }
                 // 校验信息点值
                 InfoDataFactory.parse(infoMap.get(infoCode), infos.get(infoCode));
+
             }
         }
     }

+ 12 - 2
dmp-comp/dmp-digital-starter/src/main/java/com/persagy/dmp/basic/utils/JsonNodeUtils.java

@@ -10,6 +10,7 @@ import com.persagy.dmp.common.constant.ResponseCode;
 import com.persagy.dmp.common.exception.BusinessException;
 import com.persagy.dmp.common.helper.SpringHelper;
 import com.persagy.dmp.common.model.entity.BaseEntity;
+import org.springframework.beans.BeanUtils;
 
 import java.io.IOException;
 import java.lang.reflect.Field;
@@ -63,7 +64,7 @@ public class JsonNodeUtils {
         try {
             String voJson = objectMapper.writeValueAsString(voList);
             JavaType javaType = objectMapper.getTypeFactory().constructParametricType(ArrayList.class, ObjectNode.class);
-            array = objectMapper.readValue(array.toString(), javaType);
+            array = objectMapper.readValue(voJson, javaType);
         } catch (IOException e) {
             throw new BusinessException(ResponseCode.A0427.getCode(), ResponseCode.A0427.getDesc());
         }
@@ -172,6 +173,13 @@ public class JsonNodeUtils {
         for(Field field:fields) {
             fieldSet.add(field.getName());
         }
+
+        //添加基础属性
+        Field[] BaseFields = BaseEntity.class.getDeclaredFields();
+        for(Field field:BaseFields) {
+            fieldSet.add(field.getName());
+        }
+
         // 转换node
         for(int i = 0;i < array.size();i++) {
             ObjectNode node = (ObjectNode) array.get(i);
@@ -203,14 +211,16 @@ public class JsonNodeUtils {
             if (classColumns.contains(nodeKey)) {
                 continue;
             }
+
             // 扩展列为空,或在扩展列范围内
             if(CollUtil.isEmpty(extraColumns) || extraColumns.contains(nodeKey)) {
                 // clazz没有的属性添加到扩展属性中
                 extraNode.set(nodeKey, node.get(nodeKey));
             }
             // 移除node中此属性
-            node.remove(nodeKey);
+            nodeKeys.remove();
         }
+        node.set("infos",extraNode);
     }
 
     /**