|
@@ -1,14 +1,21 @@
|
|
|
package com.platform.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.platform.dao.SceneDao;
|
|
|
+import com.platform.entity.Result;
|
|
|
import com.platform.entity.SceneEntity;
|
|
|
+import com.platform.enums.ResultCodeEnum;
|
|
|
+import com.platform.exception.CommonBaseException;
|
|
|
import com.platform.service.SceneService;
|
|
|
import com.platform.utils.R;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
@@ -28,6 +35,9 @@ public class SceneServiceImpl implements SceneService {
|
|
|
@Autowired
|
|
|
private SceneDao sceneDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ZhiHouseService zhiHouseService;
|
|
|
+
|
|
|
@Override
|
|
|
public SceneEntity queryObject(Integer id) {
|
|
|
return sceneDao.queryObject(id);
|
|
@@ -44,13 +54,13 @@ public class SceneServiceImpl implements SceneService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public int save(SceneEntity brand) {
|
|
|
- SceneEntity SceneEntity = sceneDao.findByName(brand.getName());
|
|
|
+ public int save(SceneEntity sceneEntity) {
|
|
|
+ SceneEntity SceneEntity = sceneDao.findByName(sceneEntity.getName());
|
|
|
if(SceneEntity != null){
|
|
|
log.error("场景已经被绑定");
|
|
|
return 0;
|
|
|
}
|
|
|
- return sceneDao.save(brand);
|
|
|
+ return sceneDao.save(sceneEntity);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -101,4 +111,36 @@ public class SceneServiceImpl implements SceneService {
|
|
|
map.put("createUserId",userId);
|
|
|
return sceneDao.queryList(map);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void sync4dkkSceneData(String mobile,Long userId) {
|
|
|
+ // 请求指房宝获取四维看看数据
|
|
|
+ ResponseEntity<Result> responseEntity = zhiHouseService.sync4dkkSceneData(mobile);
|
|
|
+ if(responseEntity.getStatusCode()!= HttpStatus.OK){
|
|
|
+ throw new CommonBaseException(ResultCodeEnum.D100);
|
|
|
+ }
|
|
|
+ // 解析数据,获取相机及场景数据,并入库
|
|
|
+ HashMap<String,List<HashMap<String,String>>> result = (HashMap<String, List<HashMap<String, String>>>)responseEntity.getBody().getData();
|
|
|
+
|
|
|
+ List<HashMap<String, String>> scenes = result.get("scenes");
|
|
|
+
|
|
|
+ if(!ObjectUtils.isEmpty(scenes)){
|
|
|
+ scenes.parallelStream().forEach(map->{
|
|
|
+ SceneEntity scene = new SceneEntity();
|
|
|
+ scene.setName(map.get("sceneName"));
|
|
|
+ scene.setSceneUrl(map.get("webSite"));
|
|
|
+ scene.setSceneNum(map.get("num"));
|
|
|
+ scene.setIsShow(0);
|
|
|
+ scene.setCreateUserId(userId);
|
|
|
+ scene.setUpdateUserId(userId);
|
|
|
+ scene.setIsShow(0);
|
|
|
+ try {
|
|
|
+ save(scene);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("场景同步失败:{}",JSONObject.toJSONString(map));
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|