wangliang 1 год назад
Родитель
Сommit
ffa3a13d35

+ 3 - 2
sop-business/src/main/java/com/qmth/sop/business/mapper/TBSopInfoMapper.java

@@ -64,11 +64,12 @@ public interface TBSopInfoMapper extends BaseMapper<TBSopInfo> {
     /**
      * 查询所有列
      *
+     * @param dbName
      * @param tableName
      * @return
      */
     @SuppressWarnings("MybatisXMapperMethodInspection")
-    List<Map<String, String>> selectDynamicSopAll(@Param("tableName") String tableName);
+    List<Map<String, String>> selectDynamicSopAll(@Param("dbName") String dbName, @Param("tableName") String tableName);
 
     /**
      * sop列表接口
@@ -102,5 +103,5 @@ public interface TBSopInfoMapper extends BaseMapper<TBSopInfo> {
      */
     List<SopInfoResult> findFlowByServiceId(@Param("serviceId") Long serviceId, @Param("userId") Long userId);
 
-    List<SysUser> userList(@Param("id")  Long id);
+    List<SysUser> userList(@Param("id") Long id);
 }

+ 5 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -22,6 +22,7 @@ import org.activiti.engine.TaskService;
 import org.activiti.engine.task.IdentityLink;
 import org.activiti.engine.task.Task;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -76,6 +77,9 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     @Resource
     SysUserService sysUserService;
 
+    @Value("${db.name}")
+    String databaseName;
+
     /**
      * 查询动态sop表名是否存在
      *
@@ -131,7 +135,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         int count = this.selectDynamicSop(tableName, tfCustomFlow.getFlowDeploymentId(), flowId);
         if (count == 0) {//插入操作
             //查询所有列
-            List<Map<String, String>> dynamicFieldList = this.baseMapper.selectDynamicSopAll(tableName);
+            List<Map<String, String>> dynamicFieldList = this.baseMapper.selectDynamicSopAll(databaseName, tableName);
             Map<String, Object> map = new LinkedHashMap<>();
             if (!CollectionUtils.isEmpty(dynamicFieldList)) {
                 StringJoiner stringJoinerFieldName = new StringJoiner(",");

+ 1 - 1
sop-business/src/main/resources/mapper/TBSopInfoMapper.xml

@@ -38,7 +38,7 @@
     </select>
 
     <select id="selectDynamicSopAll" resultType="java.util.Map">
-        SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=#{tableName}
+        SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = #{dbName} and TABLE_NAME = #{tableName}
     </select>
 
     <select id="list" resultType="java.util.Map">