|
@@ -1,8 +1,11 @@
|
|
|
package com.gis.service.impl;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.gis.common.constant.ConfigConstant;
|
|
|
+import com.gis.common.constant.MsgCode;
|
|
|
+import com.gis.common.exception.BaseRuntimeException;
|
|
|
import com.gis.common.util.*;
|
|
|
import com.gis.domain.dto.PageDto;
|
|
|
import com.gis.domain.dto.SomeDataDto;
|
|
@@ -11,6 +14,7 @@ import com.gis.domain.entity.CatalogEntity;
|
|
|
import com.gis.domain.entity.SceneEntity;
|
|
|
import com.gis.domain.entity.WorkEntity;
|
|
|
import com.gis.domain.tree.CatalogTree;
|
|
|
+import com.gis.domain.vo.ProSceneVo;
|
|
|
import com.gis.domain.vo.WorkInfoVo;
|
|
|
import com.gis.mapper.CatalogMapper;
|
|
|
import com.gis.mapper.SceneMapper;
|
|
@@ -22,6 +26,9 @@ import com.gis.service.WorkService;
|
|
|
import com.gis.tree.CatalogTreeUtil;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -30,6 +37,7 @@ import javax.transaction.Transactional;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
@@ -124,7 +132,7 @@ public class WorkServiceImpl extends IBaseServiceImpl<WorkEntity, Long> implemen
|
|
|
|
|
|
// 创建二维码、二维码url
|
|
|
String shareUrl = configConstant.domain4dKK + "/panorama/show.html?id=" + id;
|
|
|
- String qrCode = qrCodeUtils.generateLogoQrCode(shareUrl, configConstant.serverBasePath, configConstant.ossBasePath, configConstant.ossDomain);
|
|
|
+ String qrCode = qrCodeUtils.generateLogoQrCode(shareUrl, configConstant.serverBasePath, configConstant.ossBasePath, configConstant.ossDomain, id);
|
|
|
jsonObject.put("share", shareUrl);
|
|
|
jsonObject.put("qrCode", qrCode);
|
|
|
|
|
@@ -246,11 +254,27 @@ public class WorkServiceImpl extends IBaseServiceImpl<WorkEntity, Long> implemen
|
|
|
String someData = param.getSomeData();
|
|
|
JSONObject sd = JSONObject.parseObject(someData);
|
|
|
entity.setName(sd.getString("name"));
|
|
|
- entity.setDescription(sd.getString("description"));
|
|
|
+// String description = sd.getString("description");
|
|
|
+// if (description != null && description.length() >= 254 ) {
|
|
|
+// throw new BaseRuntimeException(-1, "简介超出长度");
|
|
|
+// }
|
|
|
+// entity.setDescription(description);
|
|
|
entity.setIcon(sd.getString("icon"));
|
|
|
entity.setShare(sd.getString("share"));
|
|
|
entity.setQrCode(sd.getString("qrCode"));
|
|
|
entity.setStatus(sd.getInteger("status"));
|
|
|
+ entity.setPassword(sd.getString("password"));
|
|
|
+ // 更新logoQrCode
|
|
|
+ Boolean logoChange = sd.getBoolean("logoChange");
|
|
|
+ String logoUrl = sd.getString("logo");
|
|
|
+ if (logoChange) {
|
|
|
+ Boolean isLogo = updateQrCode(id, logoUrl);
|
|
|
+ if (!isLogo) {
|
|
|
+ log.error("二维码创建失败");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
entity.setUpdateTime(new Date());
|
|
|
|
|
@@ -259,6 +283,25 @@ public class WorkServiceImpl extends IBaseServiceImpl<WorkEntity, Long> implemen
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /** 更新二维码 */
|
|
|
+ private Boolean updateQrCode(Long id, String logoUrl){
|
|
|
+
|
|
|
+ // 网络下载logo图片
|
|
|
+ logoUrl = logoUrl + "?m=" + System.currentTimeMillis();
|
|
|
+ String localBasePath = configConstant.serverBasePath + id;
|
|
|
+ FileUtils.downLoadFromUrl(logoUrl, "logo.jpg", localBasePath);
|
|
|
+ String logoPath = localBasePath + "/logo.jpg";
|
|
|
+ if (!FileUtil.isFile(logoPath)) {
|
|
|
+ log.error("logo.jpg文件不存在");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ log.info("网络下载logo完成");
|
|
|
+ String shareUrl = configConstant.domain4dKK + "/panorama/show.html?id=" + id;
|
|
|
+ qrCodeUtils.diyLogoQrCode(shareUrl, configConstant.serverBasePath, configConstant.ossBasePath, configConstant.ossDomain, id, logoPath);
|
|
|
+ log.info("二维码更新完成");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 更新someData.json
|
|
@@ -284,4 +327,85 @@ public class WorkServiceImpl extends IBaseServiceImpl<WorkEntity, Long> implemen
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Result select4dkk(PageDto param, Long workId) {
|
|
|
+ startPage(param);
|
|
|
+
|
|
|
+// String url = "https://test.4dkankan.com/api/user/scene/list";
|
|
|
+ String url = configConstant.domain4dKK + "/api/user/scene/list";
|
|
|
+ JSONObject reqParam = new JSONObject();
|
|
|
+ reqParam.put("pageNum", param.getPageNum().toString());
|
|
|
+ reqParam.put("pageSize", param.getPageSize().toString());
|
|
|
+ reqParam.put("searchKey", param.getSearchKey());
|
|
|
+ // type=11, 计算成功的场景
|
|
|
+ reqParam.put("type", "11");
|
|
|
+
|
|
|
+ HashMap<String, String> headers = new HashMap<>();
|
|
|
+ String token = getToken();
|
|
|
+ if (StringUtils.isBlank(token)) {
|
|
|
+ return Result.failure("token无空");
|
|
|
+ }
|
|
|
+ headers.put("token", token);
|
|
|
+ String restResult = null;
|
|
|
+ JSONObject reJson = null;
|
|
|
+ try {
|
|
|
+ HttpResponse httpResponse = HttpUtils.doPost(url, headers, reqParam);
|
|
|
+ restResult = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
|
|
|
+ log.debug("restResult: " + restResult);
|
|
|
+
|
|
|
+
|
|
|
+ reJson = JSONObject.parseObject(restResult);
|
|
|
+ int code = reJson.getInteger("code");
|
|
|
+ log.info("resultCode: {}", code);
|
|
|
+
|
|
|
+ if (code == 3004) {
|
|
|
+ String msg = reJson.getString("msg");
|
|
|
+ log.info("获取四维看看列表失败,{}", msg);
|
|
|
+ return Result.failure(5001, msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (code != 0) {
|
|
|
+ String msg = reJson.getString("msg");
|
|
|
+ log.info("获取四维看看列表失败,{}", msg);
|
|
|
+ return Result.failure(msg);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject dataJson = reJson.getJSONObject("data");
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+// JSONArray list = dataJson.getJSONArray("list");
|
|
|
+//
|
|
|
+//
|
|
|
+// // 作品场景查重
|
|
|
+// List<String> useScenes = this.strFindByWorkId(workId, "4dkk");
|
|
|
+//
|
|
|
+// List<ProSceneVo> result = new ArrayList<>();
|
|
|
+// if (list.size() > 0) {
|
|
|
+// for (Object entity : list) {
|
|
|
+// JSONObject proJson = JSONObject.parseObject(entity.toString());
|
|
|
+// ProSceneVo pro = new ProSceneVo();
|
|
|
+// pro.setNum(proJson.getString("num"));
|
|
|
+// pro.setSceneName(proJson.getString("sceneName"));
|
|
|
+// pro.setThumb(proJson.getString("thumb"));
|
|
|
+// pro.setStatus(proJson.getInteger("status"));
|
|
|
+// pro.setCreateTime(proJson.getString("createTime"));
|
|
|
+//
|
|
|
+// if (useScenes.contains(pro.getNum())) {
|
|
|
+// pro.setIsUse(1);
|
|
|
+// }
|
|
|
+// result.add(pro);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// dataJson.put("list", result);
|
|
|
+//
|
|
|
+//
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+ return Result.success(reJson);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|