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 修改后端版本号 2 months ago
  liaoyitao 719ecde8db 修改后端版本号 2 months ago
  liaoyitao 94aff087f0 增加压缩包内容检测 2 months ago
  liaoyitao 01e63a74a7 增加pak分包 2 months ago
  liaoyitao d51c50d27c 保存模版修改 2 months ago
  liaoyitao fbcda65630 优化代码 2 months ago
  liaoyitao 1d23be9ad4 添加模版增加pak包模版 2 months ago

+ 1 - 1
.gitignore

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

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

@@ -37,12 +37,12 @@ public class ConfigInfoService {
37
             configInfo = configInfoRepository.findById("jarVersion").get();
37
             configInfo = configInfoRepository.findById("jarVersion").get();
38
             String configValue = configInfo.getConfigValue();
38
             String configValue = configInfo.getConfigValue();
39
             JSONObject jsonObject = JSON.parseObject(configValue);
39
             JSONObject jsonObject = JSON.parseObject(configValue);
40
-            jsonObject.put("java", "V1.1.0.20250208");
40
+            jsonObject.put("java", "V1.2.0.20250221");
41
             configInfo.setConfigValue(jsonObject.toJSONString());
41
             configInfo.setConfigValue(jsonObject.toJSONString());
42
             configInfo.setContentType("application/json");
42
             configInfo.setContentType("application/json");
43
         } else {
43
         } else {
44
             JSONObject jsonObject = new JSONObject();
44
             JSONObject jsonObject = new JSONObject();
45
-            jsonObject.put("java", "V1.1.0.20250208");
45
+            jsonObject.put("java", "V1.2.0.20250221");
46
             configInfo = new ConfigInfo("jarVersion", jsonObject.toJSONString(), "application/json");
46
             configInfo = new ConfigInfo("jarVersion", jsonObject.toJSONString(), "application/json");
47
         }
47
         }
48
         configInfoRepository.save(configInfo);
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
     @Column(name = "template_id")
45
     @Column(name = "template_id")
46
     private Integer templateId;
46
     private Integer templateId;
47
 
47
 
48
+    /**
49
+     * 类型编号1:fbx文件 2:pak包
50
+     **/
51
+    @Column(name = "type_number")
52
+    private Integer typeNumber;
53
+
48
     public String getName() {
54
     public String getName() {
49
         return modelId.toString();
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
     @Column(name = "effect_address")
65
     @Column(name = "effect_address")
66
     @Schema(description = "模板文件路径")
66
     @Schema(description = "模板文件路径")
67
     private String effectAddress;
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
                         if (!modelInfoMap.containsKey(modelFileName.substring(0, modelFileName.lastIndexOf(".")))) {
93
                         if (!modelInfoMap.containsKey(modelFileName.substring(0, modelFileName.lastIndexOf(".")))) {
94
                             list.add(new ModelInfo(null, category.getCategoryId(), modelFileName.substring(0, modelFileName.lastIndexOf(".")),
94
                             list.add(new ModelInfo(null, category.getCategoryId(), modelFileName.substring(0, modelFileName.lastIndexOf(".")),
95
                                     null, null, null, modelPath,
95
                                     null, null, null, modelPath,
96
-                                    modelIconPath.substring(1), null, null));
96
+                                    modelIconPath.substring(1), null, null, 1));
97
                         } else {
97
                         } else {
98
                             ModelInfo modelInfo = modelInfoMap.get(modelFileName.substring(0, modelFileName.lastIndexOf(".")));
98
                             ModelInfo modelInfo = modelInfoMap.get(modelFileName.substring(0, modelFileName.lastIndexOf(".")));
99
                             modelInfo.setOriginalPath(modelPath);
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
             return result;
80
             return result;
81
         }
81
         }
82
         zoneInfo.setUpdateTime(new Date());
82
         zoneInfo.setUpdateTime(new Date());
83
+        boolean isUpdated = true;
83
         if (zoneInfo.getZoneId() == null) {
84
         if (zoneInfo.getZoneId() == null) {
84
             zoneInfo.setShareCount(0);
85
             zoneInfo.setShareCount(0);
85
             zoneInfo.setViewCount(0);
86
             zoneInfo.setViewCount(0);
86
             zoneInfo.setTemplateUse(0);
87
             zoneInfo.setTemplateUse(0);
87
-        }
88
+        }else {
88
-        Boolean isUpdated = true;
89
-        if (Objects.nonNull(zoneInfo.getZoneId())){
90
             ZoneInfo oldZoneInfo = zoneInfoRepository.findById(zoneInfo.getZoneId()).get();
89
             ZoneInfo oldZoneInfo = zoneInfoRepository.findById(zoneInfo.getZoneId()).get();
91
             isUpdated = !oldZoneInfo.getTemplateFilePath().equals(zoneInfo.getTemplateFilePath());
90
             isUpdated = !oldZoneInfo.getTemplateFilePath().equals(zoneInfo.getTemplateFilePath());
92
-
93
         }
91
         }
94
         ZoneInfo zoneInfo1 = zoneInfoRepository.save(zoneInfo);
92
         ZoneInfo zoneInfo1 = zoneInfoRepository.save(zoneInfo);
95
-
96
         if (StringUtils.isNotBlank(zoneInfo.getTemplateFilePath()) && isUpdated) {
93
         if (StringUtils.isNotBlank(zoneInfo.getTemplateFilePath()) && isUpdated) {
97
             // 清除元素与模型
94
             // 清除元素与模型
98
             geomInfoRepository.deleteAllByZoneId(zoneInfo1.getZoneId());
95
             geomInfoRepository.deleteAllByZoneId(zoneInfo1.getZoneId());
99
             modelInfoRepository.deleteAllByTemplateIds(Collections.singletonList(zoneInfo1.getZoneId()));
96
             modelInfoRepository.deleteAllByTemplateIds(Collections.singletonList(zoneInfo1.getZoneId()));
100
-
101
             // 解压压缩文件
97
             // 解压压缩文件
102
             // 文件目录格式:
98
             // 文件目录格式:
103
             // --geom.json
99
             // --geom.json
@@ -163,41 +159,78 @@ public class ZoneInfoService {
163
                 result.put("msg", "模板压缩文件解压失败!");
159
                 result.put("msg", "模板压缩文件解压失败!");
164
                 return result;
160
                 return result;
165
             }
161
             }
162
+            checkZipContent(zoneInfo1);
166
             TemplateGeom templateGeom = JSON.parseObject(geomJsonString, TemplateGeom.class);
163
             TemplateGeom templateGeom = JSON.parseObject(geomJsonString, TemplateGeom.class);
167
 
164
 
168
             zoneInfo1.setInitLocation(templateGeom.getInit());
165
             zoneInfo1.setInitLocation(templateGeom.getInit());
169
             zoneInfoRepository.save(zoneInfo1);
166
             zoneInfoRepository.save(zoneInfo1);
170
 
167
 
171
             List<TemplateInfo> templateInfoList = templateGeom.getModels();
168
             List<TemplateInfo> templateInfoList = templateGeom.getModels();
172
-
173
-            String modelFolderPath = "./upload/template/" + zoneInfo1.getZoneId() + "/models";
174
-            File modelFolder = new File(modelFolderPath);
175
             List<ModelInfo> list = new ArrayList<>();
169
             List<ModelInfo> list = new ArrayList<>();
176
-            File[] models = modelFolder.listFiles();
170
+            if (zoneInfo1.getTypeNumber() == 1){
177
-            assert models != null;
171
+                String modelFolderPath = "./upload/template/" + zoneInfo1.getZoneId() + "/models";
178
-            for (File model : models) {
172
+                File modelFolder = new File(modelFolderPath);
179
-                if (model.isFile()) {
173
+                File[] models = modelFolder.listFiles();
180
-                    String modelFileName = model.getName();
174
+                assert models != null;
181
-                    if (modelFileName.endsWith(".fbx")) {
175
+                for (File model : models) {
182
-                        String modelPath = aliOSSUtils.upload(model);
176
+                    if (model.isFile()) {
183
-                        list.add(new ModelInfo(null, null, modelFileName.substring(0, modelFileName.lastIndexOf(".")).toLowerCase(),
177
+                        String modelFileName = model.getName();
184
-                                null, null, null, modelPath,
178
+                        if (modelFileName.endsWith(".fbx")) {
185
-                                zoneInfo1.getThumbnail(), null, zoneInfo1.getZoneId()));
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
             List<ModelInfo> modelInfoList = modelInfoRepository.saveAll(list);
214
             List<ModelInfo> modelInfoList = modelInfoRepository.saveAll(list);
215
+
190
             Map<String, ModelInfo> modelPathIdMap = modelInfoList
216
             Map<String, ModelInfo> modelPathIdMap = modelInfoList
191
                     .stream()
217
                     .stream()
192
-                    .collect(Collectors.toMap(ModelInfo::getModelName, ModelInfo -> ModelInfo));
218
+                    .collect(Collectors.toMap(ModelInfo::getOriginalPath, ModelInfo -> ModelInfo));
193
-
219
+            Map<String, String> collect = null;
220
+            if (zoneInfo1.getTypeNumber() == 1) {
221
+                collect = modelInfoList.stream().collect(Collectors.toMap(ModelInfo::getModelName, ModelInfo::getOriginalPath));
222
+            }
194
             List<GeomInfo> geomInfoList = new ArrayList<>();
223
             List<GeomInfo> geomInfoList = new ArrayList<>();
195
             GeometryFactory geometryFactory = new GeometryFactory();
224
             GeometryFactory geometryFactory = new GeometryFactory();
196
             int j = 1;
225
             int j = 1;
197
             for (TemplateInfo templateInfo : templateInfoList) {
226
             for (TemplateInfo templateInfo : templateInfoList) {
198
-
227
+                String modelName = templateInfo.getModelPath();
199
-                String modelName = templateInfo.getModelPath().substring(0, templateInfo.getModelPath().lastIndexOf(".")).toLowerCase();
228
+                if (zoneInfo1.getTypeNumber() == 1) {
229
+                    assert collect != null;
230
+                    modelName = collect.get(modelName.substring(0, modelName.lastIndexOf(".")).toLowerCase());
231
+                }
200
                 ModelInfo modelInfo = modelPathIdMap.get(modelName);
232
                 ModelInfo modelInfo = modelPathIdMap.get(modelName);
233
+
201
                 for (int i = 0; i < templateInfo.getLocation().size(); i++) {
234
                 for (int i = 0; i < templateInfo.getLocation().size(); i++) {
202
                     JSONObject trans = templateInfo.getLocation().get(i);
235
                     JSONObject trans = templateInfo.getLocation().get(i);
203
                     GeomInfo geomInfo = new GeomInfo();
236
                     GeomInfo geomInfo = new GeomInfo();
@@ -227,6 +260,31 @@ public class ZoneInfoService {
227
         return result;
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
     @Transactional
288
     @Transactional
231
     public void deleteTemplate(List<Integer> zoneIds) {
289
     public void deleteTemplate(List<Integer> zoneIds) {
232
         zoneInfoRepository.deleteAllByIdInBatch(zoneIds);
290
         zoneInfoRepository.deleteAllByIdInBatch(zoneIds);
@@ -384,7 +442,7 @@ public class ZoneInfoService {
384
 
442
 
385
         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(),
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
                 template == null ? null : template.getThumbnail(), 0, new Date(), 0, 0,
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
         ZoneInfo newInfo = zoneInfoRepository.save(zoneInfo);
446
         ZoneInfo newInfo = zoneInfoRepository.save(zoneInfo);
389
         GeometryFactory geometryFactory = new GeometryFactory();
447
         GeometryFactory geometryFactory = new GeometryFactory();
390
         if (templateId != null) {
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包';