|
@@ -248,6 +248,8 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result edit(SomeDataDto param) {
|
|
public Result edit(SomeDataDto param) {
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
// 检查是否是改用户的作品
|
|
// 检查是否是改用户的作品
|
|
@@ -260,17 +262,20 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
// 3秒内防止重复提交
|
|
// 3秒内防止重复提交
|
|
redisUtil.set(editKey, param.toString(), 3, TimeUnit.SECONDS);
|
|
redisUtil.set(editKey, param.toString(), 3, TimeUnit.SECONDS);
|
|
|
|
+ DateUtils.spendTime(startTime, "防重检查");
|
|
|
|
|
|
WorkEntity entity = findByIdForUpdate(id);
|
|
WorkEntity entity = findByIdForUpdate(id);
|
|
|
|
+ DateUtils.spendTime(startTime, "forUpdate");
|
|
if (entity == null) {
|
|
if (entity == null) {
|
|
log.error("作品已被删除,无法编辑, id: " + id);
|
|
log.error("作品已被删除,无法编辑, id: " + id);
|
|
throw new BaseRuntimeException(ErrorEnum.FAILURE_SYS_3001.code(), "作品已被删除,无法编辑, id: " + id);
|
|
throw new BaseRuntimeException(ErrorEnum.FAILURE_SYS_3001.code(), "作品已被删除,无法编辑, id: " + id);
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
// 休眠0.5秒
|
|
// 休眠0.5秒
|
|
- Thread.sleep(500);
|
|
|
|
|
|
+ Thread.sleep(100);
|
|
} catch (InterruptedException e) {
|
|
} catch (InterruptedException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
@@ -281,6 +286,7 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
|
|
|
|
|
|
// 更新作品信息
|
|
// 更新作品信息
|
|
boolean isEdit = editEntity(param, entity);
|
|
boolean isEdit = editEntity(param, entity);
|
|
|
|
+ DateUtils.spendTime(startTime, "更新作品表完成");
|
|
if (!isEdit) {
|
|
if (!isEdit) {
|
|
return Result.failure(ErrorEnum.FAILURE_SYS_3001.code(), "对象不存在");
|
|
return Result.failure(ErrorEnum.FAILURE_SYS_3001.code(), "对象不存在");
|
|
}
|
|
}
|
|
@@ -289,9 +295,11 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
|
|
JSONObject someDataToJson = someDataToJson(param);
|
|
JSONObject someDataToJson = someDataToJson(param);
|
|
// 保存someData.json
|
|
// 保存someData.json
|
|
editSomeData(param);
|
|
editSomeData(param);
|
|
|
|
+ DateUtils.spendTime(startTime, "someData更新oss完成");
|
|
|
|
|
|
// 更新跟目录tour.xml 2022-09-15
|
|
// 更新跟目录tour.xml 2022-09-15
|
|
updateTour(someDataToJson, id);
|
|
updateTour(someDataToJson, id);
|
|
|
|
+ DateUtils.spendTime(startTime, "tour更新oss完成");
|
|
|
|
|
|
return Result.success();
|
|
return Result.success();
|
|
}
|
|
}
|
|
@@ -302,6 +310,7 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
|
|
* @param id
|
|
* @param id
|
|
*/
|
|
*/
|
|
private void updateTour(JSONObject someDataToJson, String id) {
|
|
private void updateTour(JSONObject someDataToJson, String id) {
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
String scenes = someDataToJson.getString("scenes");
|
|
String scenes = someDataToJson.getString("scenes");
|
|
BaseRuntimeException.isBlank(scenes, null, "someData的场景码参数未空");
|
|
BaseRuntimeException.isBlank(scenes, null, "someData的场景码参数未空");
|
|
List<FodderEntity> list = fodderService.batchBySceneCodes(getSceneCodesList(scenes));
|
|
List<FodderEntity> list = fodderService.batchBySceneCodes(getSceneCodesList(scenes));
|
|
@@ -322,6 +331,7 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
|
|
String tourPath = configConstant.serverBasePath + id + "/tour.xml";
|
|
String tourPath = configConstant.serverBasePath + id + "/tour.xml";
|
|
FileUtil.writeUtf8String(builder.toString(), tourPath);
|
|
FileUtil.writeUtf8String(builder.toString(), tourPath);
|
|
log.info("作品tour.xml写入完成");
|
|
log.info("作品tour.xml写入完成");
|
|
|
|
+ DateUtils.spendTime(startTime, "生成tour");
|
|
|
|
|
|
// 上传oss
|
|
// 上传oss
|
|
BaseRuntimeException.isTrue(!FileUtil.isFile(tourPath), ErrorEnum.FAILURE_CODE_3103.code(), "服务器tour.xml文件不存在");
|
|
BaseRuntimeException.isTrue(!FileUtil.isFile(tourPath), ErrorEnum.FAILURE_CODE_3103.code(), "服务器tour.xml文件不存在");
|
|
@@ -329,6 +339,7 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
|
|
String ossKeyPath = configConstant.ossBasePath + id + "/tour.xml";
|
|
String ossKeyPath = configConstant.ossBasePath + id + "/tour.xml";
|
|
aliyunOssUtil.upload(tourPath, ossKeyPath);
|
|
aliyunOssUtil.upload(tourPath, ossKeyPath);
|
|
log.info("tour.xml上传完成 : {}", ossKeyPath);
|
|
log.info("tour.xml上传完成 : {}", ossKeyPath);
|
|
|
|
+ DateUtils.spendTime(startTime, "tour上传oss");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -437,6 +448,7 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
|
|
* 更新someData.json
|
|
* 更新someData.json
|
|
*/
|
|
*/
|
|
private void editSomeData(SomeDataDto param) {
|
|
private void editSomeData(SomeDataDto param) {
|
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
|
|
|
String id = param.getId();
|
|
String id = param.getId();
|
|
String baseSomeDathPath = id + "/someData.json";
|
|
String baseSomeDathPath = id + "/someData.json";
|
|
@@ -448,12 +460,13 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
|
|
if (!FileUtil.isFile(saveSomeDataPath)) {
|
|
if (!FileUtil.isFile(saveSomeDataPath)) {
|
|
Result.failure(ErrorEnum.FAILURE_CODE_3103.code(), "服务器someData.json文件不存在");
|
|
Result.failure(ErrorEnum.FAILURE_CODE_3103.code(), "服务器someData.json文件不存在");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ DateUtils.spendTime(startTime, "someData写入服务器");
|
|
String ossKeyPath = configConstant.ossBasePath + baseSomeDathPath;
|
|
String ossKeyPath = configConstant.ossBasePath + baseSomeDathPath;
|
|
aliyunOssUtil.upload(saveSomeDataPath, ossKeyPath);
|
|
aliyunOssUtil.upload(saveSomeDataPath, ossKeyPath);
|
|
log.info("someData.json 上传完成 : {}", ossKeyPath);
|
|
log.info("someData.json 上传完成 : {}", ossKeyPath);
|
|
String ossUrl = configConstant.ossDomain + ossKeyPath;
|
|
String ossUrl = configConstant.ossDomain + ossKeyPath;
|
|
log.info("ossUrl: {}", ossUrl);
|
|
log.info("ossUrl: {}", ossUrl);
|
|
|
|
+ DateUtils.spendTime(startTime, "someData上传oss");
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|