Browse Source

平天路

huangtf 5 months ago
parent
commit
a7e1fd7138

+ 1 - 1
blade-service/blade-archive/src/main/java/org/springblade/archive/external/impl/ExternalDataArchiveAutoService.java

@@ -220,7 +220,7 @@ public class ExternalDataArchiveAutoService {
         addArchives.stream()
                 .filter(archive -> archive.getOutId() != null && archive.getId() != null)
                 .forEach(archive ->
-                        archiveMapping.putIfAbsent(archive.getOutId(), archive.getId())
+                        archiveMapping.put(archive.getOutId(), archive.getId())
                 );
     }
 

+ 10 - 5
blade-service/blade-archive/src/main/java/org/springblade/archive/external/impl/ExternalDataArchiveFileService.java

@@ -203,11 +203,16 @@ public class ExternalDataArchiveFileService {
         }
 
         Map<String, Long> fileMapping = externalDataInfo.getFileIdMapping();
-        localFiles.stream()
-                .filter(file -> file.getOutId() != null && file.getId() != null)
-                .forEach(file ->
-                        fileMapping.putIfAbsent(file.getOutId(), file.getId())
-                );
+//        localFiles.stream()
+//                .filter(file -> file.getOutId() != null && file.getId() != null)
+//                .forEach(file ->
+//                        fileMapping.putIfAbsent(file.getOutId(), file.getId())
+//                );
+        for (ArchiveFile file : localFiles) {
+            if (file.getOutId() != null && file.getId() != null) {
+                fileMapping.put(file.getOutId(), file.getId());
+            }
+        }
     }
 
 

+ 2 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/external/impl/ExternalDataArchiveMetaService.java

@@ -173,9 +173,11 @@ public class ExternalDataArchiveMetaService {
 
                 // 执行SQL
                 try {
+                    System.out.println("AAAA " + cleanSql);
                     jdbcTemplate.execute(cleanSql);
                 } catch (DataAccessException e) {
                     // 添加错误处理(例如记录日志+抛出业务异常)
+                    System.out.println("SQL 执行失败,错误信息: " + e.getMessage());
                     throw new RuntimeException("批量插入元数据失败,位置[" + i + "-" + toIndex + "]", e);
                 }
             }

+ 3 - 2
blade-service/blade-archive/src/main/java/org/springblade/archive/external/impl/ExternalDataArchiveTreeService.java

@@ -34,7 +34,7 @@ public class ExternalDataArchiveTreeService {
             externalDataInfo.setParent(archiveTreeContract);
         }
 
-        if (externalDataInfo.getMetadataClassifications()== null){
+        if (externalDataInfo.getMetadataClassifications()== null || externalDataInfo.getMetadataClassifications().size() == 0){
             List<MetadataClassification> metadataClassificationList =   metadataClassificationClient.getMetadataClassification();
             if (metadataClassificationList!= null ) {
                 externalDataInfo.setMetadataClassifications(metadataClassificationList);
@@ -259,7 +259,8 @@ public class ExternalDataArchiveTreeService {
 
             // 线程安全操作(如果存在并发场景)
             synchronized (idMapping) {
-                if (!idMapping.containsKey(outId)) {
+                //if (!idMapping.containsKey(outId))
+                {
                     idMapping.put(outId, localId);
                 }
             }

+ 20 - 2
blade-service/blade-archive/src/main/java/org/springblade/archive/external/utils/TransUtil.java

@@ -189,13 +189,31 @@ public class TransUtil {
             for (Map.Entry<String, Object> entry : metaData.entrySet()) {
                 String label = TransUtil.LABEL_MAPPING.get(entry.getKey());
                 if (label != null) {
-                    keyValue.put(label, entry.getValue());
+                    Object value = entry.getValue();
+
+                    // 处理字符串长度限制
+                    if (value instanceof String) {
+                        String strValue = (String) value;
+                        if (strValue.length() > 255) {
+                            // 根据业务需求选择处理方式:
+                            // 1.直接截断(常用在非关键字段)
+                            value = strValue.substring(0, 255);
+
+                            // 2.抛出异常(严格场景)
+                            // throw new IllegalArgumentException("Value exceeds 255 chars: " + entry.getKey());
+
+                            // 3.日志警告(推荐组合使用)
+                            // log.warn("Value truncated for key: {}", entry.getKey());
+                        }
+                    }
+
+                    keyValue.put(label, value);
                 }
             }
 
             // 构建单条记录的VALUES
             StringBuilder valueBuilder = new StringBuilder()
-                    .append(String.format("'%s', -1, -1, '%s', -1, '%s', 0, 0, '%s', '%s'",
+                    .append(String.format("'%s', -1, 123, '%s', -1, '%s', 0, 0, '%s', '%s'",
                             metaId,
                             getCurrentDateTime(),
                             getCurrentDateTime(),

+ 3 - 5
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.xml

@@ -1358,18 +1358,16 @@
 
 
     <select id="getOutArchiveFilesByOutIds" resultMap="archiveFileResultMap1">
-        select *
+        select  *
         from u_archive_file
-        where project_id = #{projectId}
-        and is_deleted=0
-        and
+        where
         out_id in
         <foreach collection="ids" item="id" open="(" separator="," close=")">
             #{id}
         </foreach>
     </select>
     <select id="getMetadaFileByFileIds" resultType="java.util.Map">
-        SELECT *
+        SELECT id,file_id
         FROM u_metadata_file
         WHERE file_id IN
         <foreach collection="fileIds" item="fileId" open="(" close=")" separator=",">