|
@@ -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);
|
|
@@ -273,16 +292,19 @@ public class ZoneInfoService {
|
273
|
292
|
result.put("msg", "不能与已有作品重名!");
|
274
|
293
|
return result;
|
275
|
294
|
}
|
276
|
|
- ZoneInfo zoneInfo = new ZoneInfo(null, userInfo.getUserId(), name, null,
|
277
|
|
- null, 0, new Date(), 0, 0,
|
|
295
|
+
|
|
296
|
+ ZoneInfo template = null;
|
|
297
|
+ if (templateId != null) {
|
|
298
|
+ template = zoneInfoRepository.findById(templateId).get();
|
|
299
|
+ }
|
|
300
|
+
|
|
301
|
+ ZoneInfo zoneInfo = new ZoneInfo(null, userInfo.getUserId(), name, template == null ? null : template.getInitLocation(),
|
|
302
|
+ template == null ? null : template.getThumbnail(), 0, new Date(), 0, 0,
|
278
|
303
|
null, null, 0);
|
279
|
304
|
ZoneInfo newInfo = zoneInfoRepository.save(zoneInfo);
|
280
|
305
|
|
281
|
306
|
if (templateId != null) {
|
282
|
307
|
GeometryFactory geometryFactory = new GeometryFactory();
|
283
|
|
- ZoneInfo template = zoneInfoRepository.findById(templateId).get();
|
284
|
|
- newInfo.setThumbnail(template.getThumbnail());
|
285
|
|
- zoneInfoRepository.save(newInfo);
|
286
|
308
|
if (geomInfoRepository.hasGeom(templateId)) {
|
287
|
309
|
List<GeomInfo> geomInfoList = geomInfoRepository.findAllByZoneId(templateId);
|
288
|
310
|
List<GeomInfo> list = new ArrayList<>();
|
|
@@ -303,11 +325,11 @@ public class ZoneInfoService {
|
303
|
325
|
}
|
304
|
326
|
geomInfoRepository.saveAll(list);
|
305
|
327
|
}
|
|
328
|
+ // 模板使用次数+1
|
|
329
|
+ zoneInfoRepository.addTemplateUse(templateId);
|
306
|
330
|
}
|
307
|
331
|
result.put("zone", newInfo);
|
308
|
332
|
|
309
|
|
- // 模板使用次数+1
|
310
|
|
- zoneInfoRepository.addTemplateUse(templateId);
|
311
|
333
|
return result;
|
312
|
334
|
}
|
313
|
335
|
|