8 Commits dfd77bdb09 ... fa41b66689

Author SHA1 Message Date
  liaoyitao fa41b66689 Merge branch 'release/V1.2.0/test' of http://192.168.4.240:3000/LINK/LINK-SERVER into release/V2.0.0/test 1 month ago
  liaoyitao 5579cfcffa 修改后端版本号 1 month ago
  liaoyitao 719ecde8db 修改后端版本号 1 month ago
  liaoyitao 94aff087f0 增加压缩包内容检测 1 month ago
  liaoyitao 01e63a74a7 增加pak分包 1 month ago
  liaoyitao d51c50d27c 保存模版修改 1 month ago
  liaoyitao fbcda65630 优化代码 1 month ago
  liaoyitao 1d23be9ad4 添加模版增加pak包模版 1 month ago

+ 1 - 1
.gitignore

@@ -31,7 +31,7 @@ build/
31 31
 
32 32
 ### VS Code ###
33 33
 .vscode/
34
-/config/application.yml
34
+/config/*.yml
35 35
 /log/*.log
36 36
 log
37 37
 log/

+ 2 - 2
src/main/java/com/lqkj/link/module/config/service/ConfigInfoService.java

@@ -37,12 +37,12 @@ public class ConfigInfoService {
37 37
             configInfo = configInfoRepository.findById("jarVersion").get();
38 38
             String configValue = configInfo.getConfigValue();
39 39
             JSONObject jsonObject = JSON.parseObject(configValue);
40
-            jsonObject.put("java", "V1.1.0.20250208");
40
+            jsonObject.put("java", "V1.2.0.20250221");
41 41
             configInfo.setConfigValue(jsonObject.toJSONString());
42 42
             configInfo.setContentType("application/json");
43 43
         } else {
44 44
             JSONObject jsonObject = new JSONObject();
45
-            jsonObject.put("java", "V1.1.0.20250208");
45
+            jsonObject.put("java", "V1.2.0.20250221");
46 46
             configInfo = new ConfigInfo("jarVersion", jsonObject.toJSONString(), "application/json");
47 47
         }
48 48
         configInfoRepository.save(configInfo);

+ 6 - 0
src/main/java/com/lqkj/link/module/zone/domain/ModelInfo.java

@@ -45,6 +45,12 @@ public class ModelInfo {
45 45
     @Column(name = "template_id")
46 46
     private Integer templateId;
47 47
 
48
+    /**
49
+     * 类型编号1:fbx文件 2:pak包
50
+     **/
51
+    @Column(name = "type_number")
52
+    private Integer typeNumber;
53
+
48 54
     public String getName() {
49 55
         return modelId.toString();
50 56
     }

+ 8 - 0
src/main/java/com/lqkj/link/module/zone/domain/ZoneInfo.java

@@ -65,4 +65,12 @@ public class ZoneInfo {
65 65
     @Column(name = "effect_address")
66 66
     @Schema(description = "模板文件路径")
67 67
     private String effectAddress;
68
+
69
+    @Column(name = "type_number")
70
+    @Schema(description = "类型编号1:不需下载pak包 2:需下载pak包")
71
+    private Integer typeNumber;
72
+
73
+    @Schema(description = "pak文件地址")
74
+    @Column(name = "pak_path")
75
+    private String pakPath;
68 76
 }

+ 1 - 1
src/main/java/com/lqkj/link/module/zone/service/ResourceService.java

@@ -93,7 +93,7 @@ public class ResourceService {
93 93
                         if (!modelInfoMap.containsKey(modelFileName.substring(0, modelFileName.lastIndexOf(".")))) {
94 94
                             list.add(new ModelInfo(null, category.getCategoryId(), modelFileName.substring(0, modelFileName.lastIndexOf(".")),
95 95
                                     null, null, null, modelPath,
96
-                                    modelIconPath.substring(1), null, null));
96
+                                    modelIconPath.substring(1), null, null, 1));
97 97
                         } else {
98 98
                             ModelInfo modelInfo = modelInfoMap.get(modelFileName.substring(0, modelFileName.lastIndexOf(".")));
99 99
                             modelInfo.setOriginalPath(modelPath);

+ 82 - 24
src/main/java/com/lqkj/link/module/zone/service/ZoneInfoService.java

@@ -80,24 +80,20 @@ public class ZoneInfoService {
80 80
             return result;
81 81
         }
82 82
         zoneInfo.setUpdateTime(new Date());
83
+        boolean isUpdated = true;
83 84
         if (zoneInfo.getZoneId() == null) {
84 85
             zoneInfo.setShareCount(0);
85 86
             zoneInfo.setViewCount(0);
86 87
             zoneInfo.setTemplateUse(0);
87
-        }
88
-        Boolean isUpdated = true;
89
-        if (Objects.nonNull(zoneInfo.getZoneId())){
88
+        }else {
90 89
             ZoneInfo oldZoneInfo = zoneInfoRepository.findById(zoneInfo.getZoneId()).get();
91 90
             isUpdated = !oldZoneInfo.getTemplateFilePath().equals(zoneInfo.getTemplateFilePath());
92
-
93 91
         }
94 92
         ZoneInfo zoneInfo1 = zoneInfoRepository.save(zoneInfo);
95
-
96 93
         if (StringUtils.isNotBlank(zoneInfo.getTemplateFilePath()) && isUpdated) {
97 94
             // 清除元素与模型
98 95
             geomInfoRepository.deleteAllByZoneId(zoneInfo1.getZoneId());
99 96
             modelInfoRepository.deleteAllByTemplateIds(Collections.singletonList(zoneInfo1.getZoneId()));
100
-
101 97
             // 解压压缩文件
102 98
             // 文件目录格式:
103 99
             // --geom.json
@@ -163,41 +159,78 @@ public class ZoneInfoService {
163 159
                 result.put("msg", "模板压缩文件解压失败!");
164 160
                 return result;
165 161
             }
162
+            checkZipContent(zoneInfo1);
166 163
             TemplateGeom templateGeom = JSON.parseObject(geomJsonString, TemplateGeom.class);
167 164
 
168 165
             zoneInfo1.setInitLocation(templateGeom.getInit());
169 166
             zoneInfoRepository.save(zoneInfo1);
170 167
 
171 168
             List<TemplateInfo> templateInfoList = templateGeom.getModels();
172
-
173
-            String modelFolderPath = "./upload/template/" + zoneInfo1.getZoneId() + "/models";
174
-            File modelFolder = new File(modelFolderPath);
175 169
             List<ModelInfo> list = new ArrayList<>();
176
-            File[] models = modelFolder.listFiles();
177
-            assert models != null;
178
-            for (File model : models) {
179
-                if (model.isFile()) {
180
-                    String modelFileName = model.getName();
181
-                    if (modelFileName.endsWith(".fbx")) {
182
-                        String modelPath = aliOSSUtils.upload(model);
183
-                        list.add(new ModelInfo(null, null, modelFileName.substring(0, modelFileName.lastIndexOf(".")).toLowerCase(),
184
-                                null, null, null, modelPath,
185
-                                zoneInfo1.getThumbnail(), null, zoneInfo1.getZoneId()));
170
+            if (zoneInfo1.getTypeNumber() == 1){
171
+                String modelFolderPath = "./upload/template/" + zoneInfo1.getZoneId() + "/models";
172
+                File modelFolder = new File(modelFolderPath);
173
+                File[] models = modelFolder.listFiles();
174
+                assert models != null;
175
+                for (File model : models) {
176
+                    if (model.isFile()) {
177
+                        String modelFileName = model.getName();
178
+                        if (modelFileName.endsWith(".fbx")) {
179
+                            String modelPath = aliOSSUtils.upload(model);
180
+                            ModelInfo modelInfo = new ModelInfo();
181
+                            modelInfo.setModelName(modelFileName.substring(0, modelFileName.lastIndexOf(".")).toLowerCase());
182
+                            modelInfo.setOriginalPath(modelPath);
183
+                            modelInfo.setModelIcon(zoneInfo1.getThumbnail());
184
+                            modelInfo.setTemplateId(zoneInfo1.getZoneId());
185
+                            modelInfo.setTypeNumber(1);
186
+                            list.add(modelInfo);
187
+                        }
186 188
                     }
187 189
                 }
190
+            }else {
191
+                String directoryPath = "./upload/template/" + zoneInfo1.getZoneId();
192
+                File directory = new File(directoryPath);
193
+                // 获取目录下的所有文件
194
+                File[] files = directory.listFiles((dir, name) -> name.endsWith(".pak"));
195
+                assert files != null;
196
+                StringBuilder pakPath = new StringBuilder();
197
+                for (File file : files){
198
+                    assert false;
199
+                    pakPath.append(aliOSSUtils.upload(file)).append(",");
200
+
201
+                }
202
+                zoneInfo1.setPakPath(pakPath.toString());
203
+                zoneInfoRepository.save(zoneInfo1);
204
+                for (TemplateInfo templateInfo : templateInfoList) {
205
+                    ModelInfo modelInfo = new ModelInfo();
206
+                    modelInfo.setModelName(templateInfo.getModelPath().substring(templateInfo.getModelPath().lastIndexOf(".") + 1));
207
+                    modelInfo.setOriginalPath(templateInfo.getModelPath());
208
+                    modelInfo.setModelIcon(zoneInfo1.getThumbnail());
209
+                    modelInfo.setTemplateId(zoneInfo1.getZoneId());
210
+                    modelInfo.setTypeNumber(2);
211
+                    list.add(modelInfo);
212
+                }
188 213
             }
189 214
             List<ModelInfo> modelInfoList = modelInfoRepository.saveAll(list);
215
+
190 216
             Map<String, ModelInfo> modelPathIdMap = modelInfoList
191 217
                     .stream()
192
-                    .collect(Collectors.toMap(ModelInfo::getModelName, ModelInfo -> ModelInfo));
193
-
218
+                    .collect(Collectors.toMap(ModelInfo::getOriginalPath, ModelInfo -> ModelInfo));
219
+            Map<String, String> collect = null;
220
+            if (zoneInfo1.getTypeNumber() == 1) {
221
+                collect = modelInfoList.stream().collect(Collectors.toMap(ModelInfo::getModelName, ModelInfo::getOriginalPath));
222
+            }
194 223
             List<GeomInfo> geomInfoList = new ArrayList<>();
195 224
             GeometryFactory geometryFactory = new GeometryFactory();
196 225
             int j = 1;
197 226
             for (TemplateInfo templateInfo : templateInfoList) {
198
-
199
-                String modelName = templateInfo.getModelPath().substring(0, templateInfo.getModelPath().lastIndexOf(".")).toLowerCase();
227
+                String modelName = templateInfo.getModelPath();
228
+                if (zoneInfo1.getTypeNumber() == 1) {
229
+                    assert collect != null;
230
+                    modelName = collect.get(modelName.substring(0, modelName.lastIndexOf(".")).toLowerCase());
231
+                }
200 232
                 ModelInfo modelInfo = modelPathIdMap.get(modelName);
233
+
201 234
                 for (int i = 0; i < templateInfo.getLocation().size(); i++) {
202 235
                     JSONObject trans = templateInfo.getLocation().get(i);
203 236
                     GeomInfo geomInfo = new GeomInfo();
@@ -227,6 +260,31 @@ public class ZoneInfoService {
227 260
         return result;
228 261
     }
229 262
 
263
+    /**
264
+     * 检查zip包内容
265
+     * @param zoneInfo
266
+     */
267
+    private void checkZipContent(ZoneInfo zoneInfo) {
268
+        int fileLength;
269
+        if (zoneInfo.getTypeNumber() == 1){
270
+            String modelFolderPath = "./upload/template/" + zoneInfo.getZoneId() + "/models";
271
+            File modelFolder = new File(modelFolderPath);
272
+            File[] models = modelFolder.listFiles();
273
+            fileLength = models == null ? 0 : models.length;
274
+        }
275
+        else {
276
+            String directoryPath = "./upload/template/" + zoneInfo.getZoneId();
277
+            File directory = new File(directoryPath);
278
+            // 获取目录下的所有文件
279
+            File[] files = directory.listFiles((dir, name) -> name.endsWith(".pak"));
280
+            fileLength = files == null ? 0 : files.length;
281
+        }
282
+        if (fileLength == 0){
283
+            throw new RuntimeException("模板内容选择有误,请确认后重新上传!");
284
+        }
285
+
286
+    }
287
+
230 288
     @Transactional
231 289
     public void deleteTemplate(List<Integer> zoneIds) {
232 290
         zoneInfoRepository.deleteAllByIdInBatch(zoneIds);
@@ -384,7 +442,7 @@ public class ZoneInfoService {
384 442
 
385 443
         ZoneInfo zoneInfo = new ZoneInfo(null, userInfo.getUserId(), name, template == null ? new JSONObject(JSON.parseObject("{\"rotation\":{\"x\":0,\"y\":0.4383658766746521,\"z\":0,\"w\":0.8987966179847717},\"translation\":{\"x\":-820.947265625,\"y\":0,\"z\":955.6719360351563},\"scale3D\":{\"x\":1,\"y\":1,\"z\":1}}")) : template.getInitLocation(),
386 444
                 template == null ? null : template.getThumbnail(), 0, new Date(), 0, 0,
387
-                null, null, 0,0, null);
445
+                null, null, 0,0, null, template == null ? 1 : template.getTypeNumber(), template == null ? null : template.getPakPath());
388 446
         ZoneInfo newInfo = zoneInfoRepository.save(zoneInfo);
389 447
         GeometryFactory geometryFactory = new GeometryFactory();
390 448
         if (templateId != null) {

+ 11 - 0
src/main/resources/db/migration/V13__1.2.0.sql

@@ -0,0 +1,11 @@
1
+ALTER TABLE zone_info
2
+    add COLUMN if not exists type_number int default 1;
3
+comment on column zone_info.type_number is '类型编号1:不需下载pak包 2:需下载pak包';
4
+
5
+ALTER TABLE zone_info
6
+    add COLUMN if not exists pak_path varchar(999);
7
+comment on column zone_info.pak_path is 'pak文件地址';
8
+
9
+ALTER TABLE model_info
10
+    add COLUMN if not exists type_number int default 1;
11
+comment on column model_info.type_number is '类型编号1:fbx文件 2:pak包';