Explorar o código

Merge branch 'release/V1.0.0/test' of http://192.168.4.240:3000/LINK/LINK-SERVER into feature/v1.0.0.0/lyt/fixbug

liaoyitao hai 3 meses
pai
achega
d128ae1534

+ 14 - 0
src/main/java/com/lqkj/link/module/zone/domain/TemplateGeom.java

@@ -0,0 +1,14 @@
1
+package com.lqkj.link.module.zone.domain;
2
+
3
+import com.alibaba.fastjson2.JSONObject;
4
+import lombok.Getter;
5
+import lombok.Setter;
6
+
7
+import java.util.List;
8
+
9
+@Getter
10
+@Setter
11
+public class TemplateGeom {
12
+    private JSONObject init;
13
+    private List<TemplateInfo> models;
14
+}

+ 62 - 40
src/main/java/com/lqkj/link/module/zone/service/ZoneInfoService.java

@@ -4,10 +4,7 @@ import com.alibaba.fastjson2.JSON;
4 4
 import com.alibaba.fastjson2.JSONObject;
5 5
 import com.lqkj.link.module.authority.domain.UserInfo;
6 6
 import com.lqkj.link.module.authority.repository.UserInfoRepository;
7
-import com.lqkj.link.module.zone.domain.GeomInfo;
8
-import com.lqkj.link.module.zone.domain.ModelInfo;
9
-import com.lqkj.link.module.zone.domain.TemplateInfo;
10
-import com.lqkj.link.module.zone.domain.ZoneInfo;
7
+import com.lqkj.link.module.zone.domain.*;
11 8
 import com.lqkj.link.module.zone.repository.GeomInfoRepository;
12 9
 import com.lqkj.link.module.zone.repository.ModelInfoRepository;
13 10
 import com.lqkj.link.module.zone.repository.ZoneInfoRepository;
@@ -78,37 +75,59 @@ public class ZoneInfoService {
78 75
                 // ----model2.json 模型2材质
79 76
                 //
80 77
                 // geom.json文件总json格式:
81
-                // [
82
-                //      {
83
-                //          "modelPath": "model1.fbx",
84
-                //          "location":[
85
-                //              {
86
-                //                  "rotation":
87
-                //                  {
88
-                //                      "x": 0,
89
-                //                      "y": 0,
90
-                //                      "z": 0,
91
-                //                      "w": 0
92
-                //                  },
93
-                //                  "translation":
94
-                //                  {
95
-                //                      "x": 0,
96
-                //                      "y": 0,
97
-                //                      "z": 0
98
-                //                  },
99
-                //                  "scale3D":
100
-                //                  {
101
-                //                      "x": 0,
102
-                //                      "y": 0,
103
-                //                      "z": 0
104
-                //                  }
105
-                //              }
106
-                //          ]
107
-                //      }
108
-                // ]
78
+                // 	{
79
+                //		"init": {
80
+                //			"rotation": {
81
+                //				"x": 0,
82
+                //				"y": 0,
83
+                //				"z": 0,
84
+                //				"w": 0
85
+                //			},
86
+                //			"translation": {
87
+                //				"x": 0,
88
+                //				"y": 0,
89
+                //				"z": 0
90
+                //			},
91
+                //			"scale3D": {
92
+                //				"x": 0,
93
+                //				"y": 0,
94
+                //				"z": 0
95
+                //			}
96
+                //		},
97
+                //		"models": [
98
+                //			{
99
+                //				"modelPath": "model1.fbx",
100
+                //				"location": [
101
+                //					{
102
+                //						"rotation": {
103
+                //							"x": 0,
104
+                //							"y": 0,
105
+                //							"z": 0,
106
+                //							"w": 0
107
+                //						},
108
+                //						"translation": {
109
+                //							"x": 0,
110
+                //							"y": 0,
111
+                //							"z": 0
112
+                //						},
113
+                //						"scale3D": {
114
+                //							"x": 0,
115
+                //							"y": 0,
116
+                //							"z": 0
117
+                //						}
118
+                //					}
119
+                //				]
120
+                //			}
121
+                //		]
122
+                //	}
109 123
                 Unzipper.unZipFiles(new File("." + zoneInfo.getTemplateFilePath()), "./upload/template/" + zoneInfo1.getZoneId() + "/");
110 124
                 String geomJsonString = Files.readString(Paths.get("./upload/template/" + zoneInfo1.getZoneId() + "/geom.json"));
111
-                List<TemplateInfo> templateInfoList = JSON.parseArray(geomJsonString, TemplateInfo.class);
125
+                TemplateGeom templateGeom = JSON.parseObject(geomJsonString, TemplateGeom.class);
126
+
127
+                zoneInfo1.setInitLocation(templateGeom.getInit());
128
+                zoneInfoRepository.save(zoneInfo1);
129
+
130
+                List<TemplateInfo> templateInfoList = templateGeom.getModels();
112 131
 
113 132
                 String modelFolderPath = "./upload/template/" + zoneInfo1.getZoneId() + "/models";
114 133
                 File modelFolder = new File(modelFolderPath);
@@ -276,16 +295,19 @@ public class ZoneInfoService {
276 295
             result.put("msg", "不能与已有作品重名!");
277 296
             return result;
278 297
         }
279
-        ZoneInfo zoneInfo = new ZoneInfo(null, userInfo.getUserId(), name, null,
280
-                null, 0, new Date(), 0, 0,
298
+
299
+        ZoneInfo template = null;
300
+        if (templateId != null) {
301
+            template = zoneInfoRepository.findById(templateId).get();
302
+        }
303
+
304
+        ZoneInfo zoneInfo = new ZoneInfo(null, userInfo.getUserId(), name, template == null ? null : template.getInitLocation(),
305
+                template == null ? null : template.getThumbnail(), 0, new Date(), 0, 0,
281 306
                 null, null, 0);
282 307
         ZoneInfo newInfo = zoneInfoRepository.save(zoneInfo);
283 308
 
284 309
         if (templateId != null) {
285 310
             GeometryFactory geometryFactory = new GeometryFactory();
286
-            ZoneInfo template = zoneInfoRepository.findById(templateId).get();
287
-            newInfo.setThumbnail(template.getThumbnail());
288
-            zoneInfoRepository.save(newInfo);
289 311
             if (geomInfoRepository.hasGeom(templateId)) {
290 312
                 List<GeomInfo> geomInfoList = geomInfoRepository.findAllByZoneId(templateId);
291 313
                 List<GeomInfo> list = new ArrayList<>();
@@ -306,11 +328,11 @@ public class ZoneInfoService {
306 328
                 }
307 329
                 geomInfoRepository.saveAll(list);
308 330
             }
331
+            // 模板使用次数+1
332
+            zoneInfoRepository.addTemplateUse(templateId);
309 333
         }
310 334
         result.put("zone", newInfo);
311 335
 
312
-        // 模板使用次数+1
313
-        zoneInfoRepository.addTemplateUse(templateId);
314 336
         return result;
315 337
     }
316 338