|
@@ -1,290 +0,0 @@
|
|
-package com.gis.service.impl;
|
|
|
|
-
|
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
-import com.gis.common.constant.ConfigConstant;
|
|
|
|
-import com.gis.common.constant.ErrorEnum;
|
|
|
|
-import com.gis.common.util.*;
|
|
|
|
-import com.gis.domain.dto.*;
|
|
|
|
-import com.gis.domain.entity.SceneEntity;
|
|
|
|
-import com.gis.domain.vo.ProSceneVo;
|
|
|
|
-import com.gis.mapper.IBaseMapper;
|
|
|
|
-import com.gis.mapper.SceneMapper;
|
|
|
|
-import com.gis.service.SceneService;
|
|
|
|
-import com.gis.service.WorkService;
|
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
-import org.apache.http.HttpResponse;
|
|
|
|
-import org.apache.http.util.EntityUtils;
|
|
|
|
-import org.junit.Test;
|
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
-import org.springframework.web.multipart.MultipartFile;
|
|
|
|
-
|
|
|
|
-import java.util.*;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-/**
|
|
|
|
- * Created by owen on 2020/3/11 0011 16:16
|
|
|
|
- */
|
|
|
|
-@Slf4j
|
|
|
|
-@Service
|
|
|
|
-public class SceneServiceImpl extends IBaseServiceImpl<SceneEntity, Long> implements SceneService {
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- private SceneMapper entityMapper;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- WorkService workService;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- ConfigConstant configConstant;
|
|
|
|
-
|
|
|
|
- @Autowired
|
|
|
|
- FileUtils fileUtils;
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public IBaseMapper<SceneEntity, Long> getBaseMapper() {
|
|
|
|
- return this.entityMapper;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<SceneEntity> findByCatalogId(Long catalogId) {
|
|
|
|
- return entityMapper.findByCatalogId(catalogId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Result select4dkk(PageDto param, String 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);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- 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);
|
|
|
|
- return Result.failure(ErrorEnum.FAILURE_API_3201.code(), msg);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (code != 0) {
|
|
|
|
- String msg = reJson.getString("msg");
|
|
|
|
- log.info("获取四维看看列表失败,{}", msg);
|
|
|
|
- return Result.failure(ErrorEnum.FAILURE_API_3201.code(),msg);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- JSONObject dataJson = reJson.getJSONObject("data");
|
|
|
|
- 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);
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<String> strFindByWorkId(String workId, String type) {
|
|
|
|
- return entityMapper.strFindByWorkId(workId, type);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public SceneEntity findByIdForUpdate(Long id) {
|
|
|
|
- return entityMapper.findByIdForUpdate(id);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Result setSort(Map<String, String> param) {
|
|
|
|
- log.info("sort size: " + param.size());
|
|
|
|
- int n = 1;
|
|
|
|
- for (Map.Entry<String, String> m : param.entrySet()) {
|
|
|
|
- String id = m.getKey();
|
|
|
|
-
|
|
|
|
- String sort = m.getValue();
|
|
|
|
- log.info("id: " + id);
|
|
|
|
- log.info("sort: " + sort);
|
|
|
|
- entityMapper.setSortById(id, sort);
|
|
|
|
- n++;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return Result.success();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public void startPage(PageDto param) {
|
|
|
|
- super.startPage(param);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Result upload(MultipartFile file) {
|
|
|
|
-
|
|
|
|
- // 检查非法文件上传
|
|
|
|
- boolean checkFile = FileUtils.checkFile(file);
|
|
|
|
- if (!checkFile) {
|
|
|
|
- return Result.failure("上传文件格式有误, 请重新上传");
|
|
|
|
- }
|
|
|
|
- return Result.success(fileUtils.renameUploadOss(file, configConstant.serverBasePath, configConstant.ossBasePath, configConstant.ossDomain));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Result editXml(XmlDataDto param) {
|
|
|
|
- Long id = param.getId();
|
|
|
|
- SceneEntity entity = entityMapper.findByIdForUpdate(id);
|
|
|
|
- if (entity == null) {
|
|
|
|
- log.error("对象不存在,id : " + id);
|
|
|
|
- return Result.failure("场景码不存在");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 保存初始视觉
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
- jsonObject.put("hlookat", param.getHlookat());
|
|
|
|
- jsonObject.put("vlookat", param.getVlookat());
|
|
|
|
-
|
|
|
|
- entity.setInitVisual(jsonObject.toJSONString());
|
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
|
- this.update(entity);
|
|
|
|
-
|
|
|
|
- return Result.success();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void test() {
|
|
|
|
- String a = "/home/data/cms_pano_fcb_data/p19/fcb_px2rJW96F/fcb_px2rJW96F.jpg";
|
|
|
|
- String s = StringUtils.substringBeforeLast(a, "/");
|
|
|
|
- System.out.println(s);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<SceneEntity> findBySceneCode(String sceneCode) {
|
|
|
|
- return entityMapper.findBySceneCode(sceneCode);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Result editSomeData(EditSomeDataDto param) {
|
|
|
|
- Long id = param.getId();
|
|
|
|
- SceneEntity entity = this.findById(id);
|
|
|
|
-
|
|
|
|
- if (entity == null) {
|
|
|
|
- log.error("场景不存在, id: " + id);
|
|
|
|
- return Result.failure("场景不存在");
|
|
|
|
- }
|
|
|
|
- BeanUtils.copyProperties(param, entity);
|
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
|
- this.update(entity);
|
|
|
|
- log.info("更新场景完成");
|
|
|
|
- return Result.success();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Test
|
|
|
|
- public void tess() {
|
|
|
|
- String a = "/home/data/cms_pano_fcb_data/fcb_pano1348947775971389440/pano.jpg";
|
|
|
|
- String s = StringUtils.substringBeforeLast(a, "/");
|
|
|
|
- System.out.println(s);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Result saveUseHots(UseHotsDto param) {
|
|
|
|
- Long id = param.getId();
|
|
|
|
- SceneEntity entity = this.findById(id);
|
|
|
|
- if (entity == null) {
|
|
|
|
- log.info("对象不存在:" + id);
|
|
|
|
- return Result.failure("对象不存在");
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
|
- jsonObject.put("data", param.getSceneCodes());
|
|
|
|
- entity.setUseHots(jsonObject.toJSONString());
|
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
|
- this.update(entity);
|
|
|
|
- return Result.success();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public List<SceneEntity> findByWorkId(String workId) {
|
|
|
|
- return entityMapper.findByWorkId(workId);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- @Override
|
|
|
|
- public Result editEntity(BaseDto param) {
|
|
|
|
- Long id = param.getId();
|
|
|
|
- SceneEntity entity = findById(id);
|
|
|
|
- if (entity == null) {
|
|
|
|
- log.error("对象不存在: " + id);
|
|
|
|
- Result.failure("对象不存在");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- entity.setSceneTitle(param.getName());
|
|
|
|
- entity.setUpdateTime(new Date());
|
|
|
|
- this.update(entity);
|
|
|
|
-
|
|
|
|
- return Result.success();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-}
|
|
|