소스 검색

文件问题

liujing-123 1 주 전
부모
커밋
20552c22fa

+ 21 - 15
delivery-module-core/delivery-module-core-biz/src/main/java/com/unis/module/coding/service/crkxx/CrkxxServiceImpl.java

@@ -1,6 +1,7 @@
1 1
 package com.unis.module.coding.service.crkxx;
2 2
 
3 3
 import cn.hutool.core.collection.CollectionUtil;
4
+import cn.hutool.core.util.ObjectUtil;
4 5
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 6
 import com.github.yitter.idgen.YitIdHelper;
6 7
 import com.unis.framework.common.util.collection.CollectionUtils;
@@ -126,15 +127,16 @@ public class CrkxxServiceImpl implements CrkxxService {
126 127
         crkxxDOPageResult.getList().forEach(dos -> {
127 128
             //获取文件id
128 129
             String fileIds = dos.getFileIds();
129
-            fileIds = fileIds.replaceAll(Pattern.quote("["), "").replaceAll(Pattern.quote("]"), "");
130
-            String[] parts = fileIds.split(",");
131 130
             List<Long> longList = new ArrayList<>();
132
-
133
-            for (String part : parts) {
134
-                try {
135
-                    longList.add(Long.parseLong(part.trim()));
136
-                } catch (NumberFormatException e) {
137
-                    System.err.println("无法将 " + part + " 转换为 Long 类型: " + e.getMessage());
131
+            if(ObjectUtil.isNotEmpty(fileIds)){
132
+                fileIds = fileIds.replaceAll(Pattern.quote("["), "").replaceAll(Pattern.quote("]"), "");
133
+                String[] parts = fileIds.split(",");
134
+                for (String part : parts) {
135
+                    try {
136
+                        longList.add(Long.parseLong(part.trim()));
137
+                    } catch (NumberFormatException e) {
138
+                        System.err.println("无法将 " + part + " 转换为 Long 类型: " + e.getMessage());
139
+                    }
138 140
                 }
139 141
             }
140 142
             List<FileDO> files = new ArrayList<>();
@@ -156,16 +158,20 @@ public class CrkxxServiceImpl implements CrkxxService {
156 158
     public CrkxxRespVO getCrkxxFiles(CrkxxDO dos) {
157 159
         //获取文件id
158 160
         String fileIds = dos.getFileIds();
159
-        fileIds = fileIds.replaceAll(Pattern.quote("["), "").replaceAll(Pattern.quote("]"), "");
160
-        String[] parts = fileIds.split(",");
161
+
161 162
         List<Long> longList = new ArrayList<>();
162
-        for (String part : parts) {
163
-            try {
164
-                longList.add(Long.parseLong(part.trim()));
165
-            } catch (NumberFormatException e) {
166
-                System.err.println("无法将 " + part + " 转换为 Long 类型: " + e.getMessage());
163
+        if(ObjectUtil.isNotEmpty(fileIds)){
164
+            fileIds = fileIds.replaceAll(Pattern.quote("["), "").replaceAll(Pattern.quote("]"), "");
165
+            String[] parts = fileIds.split(",");
166
+            for (String part : parts) {
167
+                try {
168
+                    longList.add(Long.parseLong(part.trim()));
169
+                } catch (NumberFormatException e) {
170
+                    System.err.println("无法将 " + part + " 转换为 Long 类型: " + e.getMessage());
171
+                }
167 172
             }
168 173
         }
174
+
169 175
         //循环获取文件信息
170 176
         List<FileDO> files = new ArrayList<>();
171 177
         if (CollectionUtil.isNotEmpty(longList)) {

+ 11 - 9
delivery-module-core/delivery-module-core-biz/src/main/java/com/unis/module/coding/service/zjxx/ZjxxServiceImpl.java

@@ -1,11 +1,13 @@
1 1
 package com.unis.module.coding.service.zjxx;
2 2
 
3 3
 import cn.hutool.core.collection.CollectionUtil;
4
+import cn.hutool.core.util.ObjectUtil;
4 5
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5 6
 import com.github.yitter.idgen.YitIdHelper;
6 7
 import com.unis.framework.common.pojo.PageResult;
7 8
 import com.unis.framework.common.util.collection.CollectionUtils;
8 9
 import com.unis.framework.common.util.object.BeanUtils;
10
+import com.unis.framework.common.util.object.ObjectUtils;
9 11
 import com.unis.module.coding.controller.admin.crkxx.vo.CrkxxRespVO;
10 12
 import com.unis.module.coding.controller.admin.zjxx.vo.ZjxxPageReqVO;
11 13
 import com.unis.module.coding.controller.admin.zjxx.vo.ZjxxRespVO;
@@ -110,22 +112,22 @@ public class ZjxxServiceImpl implements ZjxxService {
110 112
         PageResult<ZjxxRespVO> zjxxRespVOPageResult = new PageResult<>();
111 113
         List<ZjxxRespVO> zjxxRespVOList = new ArrayList<>();
112 114
         zjxxRespVOPageResult.setTotal(zjxxDOPageResult.getTotal());
113
-        List<Object> list = new ArrayList<>();
114 115
         //处理文件问题
115 116
         zjxxDOPageResult.getList().forEach(dos -> {
116 117
             //获取文件id
117 118
             String fileIds = dos.getFileIds();
118
-            fileIds = fileIds.replaceAll(Pattern.quote("["), "").replaceAll(Pattern.quote("]"), "");
119
-            String[] parts = fileIds.split(",");
120 119
             List<Long> longList = new ArrayList<>();
121
-            for (String part : parts) {
122
-                try {
123
-                    longList.add(Long.parseLong(part.trim()));
124
-                } catch (NumberFormatException e) {
125
-                    System.err.println("无法将 " + part + " 转换为 Long 类型: " + e.getMessage());
120
+            if(ObjectUtil.isNotEmpty(fileIds)){
121
+                fileIds = fileIds.replaceAll(Pattern.quote("["), "").replaceAll(Pattern.quote("]"), "");
122
+                String[] parts = fileIds.split(",");
123
+                for (String part : parts) {
124
+                    try {
125
+                        longList.add(Long.parseLong(part.trim()));
126
+                    } catch (NumberFormatException e) {
127
+                        System.err.println("无法将 " + part + " 转换为 Long 类型: " + e.getMessage());
128
+                    }
126 129
                 }
127 130
             }
128
-
129 131
             List<FileDO> files = new ArrayList<>();
130 132
             if (CollectionUtil.isNotEmpty(longList)) {
131 133
                 files = fileService.getFiles(longList);