Browse Source

解决TaskNode批量存储报错的Bug

oyq28 3 years ago
parent
commit
020fd17b7b

+ 3 - 1
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/operationManagementCenter/TaskNodeMapper.xml

@@ -13,7 +13,6 @@
         <result column="task_id" jdbcType="BIGINT" property="taskId"/>
         <result column="task_node_no" jdbcType="VARCHAR" property="taskNodeNo"/>
         <result column="auto_node_code" jdbcType="VARCHAR" property="autoNodeCode"/>
-        <result column="auto_node_id" jdbcType="BIGINT" property="autoNodeId"/>
         <result column="start_time" jdbcType="TIMESTAMP" property="startTime"/>
         <result column="end_time" jdbcType="TIMESTAMP" property="endTime"/>
         <result column="prority" jdbcType="INTEGER" property="prority"/>
@@ -23,6 +22,9 @@
         <result column="exe_status" jdbcType="VARCHAR" property="exeStatus"/>
         <result column="exe_result" jdbcType="VARCHAR" property="exeResult"/>
         <result column="test_result" jdbcType="VARCHAR" property="testResult"/>
+        <association property="autoNode" javaType="com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode">
+            <id column="auto_node_id" jdbcType="BIGINT" property="id"/>
+        </association>
     </resultMap>
 
     <!-- 通用查询结果列 -->

+ 4 - 0
imcs-admin-boot/imcs-business-entity/pom.xml

@@ -49,6 +49,10 @@
             <version>b.2.5-SNAPSHOT</version>
             <scope>compile</scope>
         </dependency>
+        <dependency>
+            <groupId>com.baidubce</groupId>
+            <artifactId>bce-java-sdk</artifactId>
+        </dependency>
     </dependencies>
 
 

+ 2 - 1
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/entity/TaskNode.java

@@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.github.zuihou.base.entity.Entity;
+import com.github.zuihou.business.operationManagementCenter.typeHandler.ResourceAutoCodeHandler;
 import com.github.zuihou.business.productionReadyCenter.entity.*;
 import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
 import com.github.zuihou.common.constant.BizConstant;
@@ -82,7 +83,7 @@ public class TaskNode extends Entity<Long> {
      * 自动化节点ID
      */
     @ApiModelProperty(value = "自动化节点ID")
-    @TableField("auto_node_id")
+    @TableField(value="auto_node_id", typeHandler = ResourceAutoCodeHandler.class)
     @Excel(name = "自动化节点ID")
     private ResourceAutoCode autoNode;
 

+ 39 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/typeHandler/ResourceAutoCodeHandler.java

@@ -0,0 +1,39 @@
+package com.github.zuihou.business.operationManagementCenter.typeHandler;
+
+
+import com.baidubce.util.JsonUtils;
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedJdbcTypes;
+import org.apache.ibatis.type.MappedTypes;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+@MappedTypes(ResourceAutoCode.class)
+@MappedJdbcTypes(JdbcType.VARCHAR)
+public class ResourceAutoCodeHandler extends BaseTypeHandler<ResourceAutoCode> {
+
+    @Override
+    public void setNonNullParameter(PreparedStatement preparedStatement, int i, ResourceAutoCode resourceAutoCode, JdbcType jdbcType) throws SQLException {
+        preparedStatement.setString(i, resourceAutoCode.getId().toString());
+    }
+
+    @Override
+    public ResourceAutoCode getNullableResult(ResultSet resultSet, String columnName) throws SQLException {
+        return JsonUtils.fromJsonString(resultSet.getString(columnName),  ResourceAutoCode.class);
+    }
+
+    @Override
+    public ResourceAutoCode getNullableResult(ResultSet resultSet, int columnIndex) throws SQLException {
+        return JsonUtils.fromJsonString(resultSet.getString(columnIndex), ResourceAutoCode.class);
+    }
+
+    @Override
+    public ResourceAutoCode getNullableResult(CallableStatement callableStatement, int columnIndex) throws SQLException {
+        return JsonUtils.fromJsonString(callableStatement.getString(columnIndex),  ResourceAutoCode.class);
+    }
+}