|
@@ -0,0 +1,152 @@
|
|
|
|
+package com.fdkankan.agent.httpClient.service;
|
|
|
|
+
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
+import com.fdkankan.agent.common.PageInfo;
|
|
|
|
+import com.fdkankan.agent.entity.Camera;
|
|
|
|
+import com.fdkankan.agent.entity.CameraDetail;
|
|
|
|
+import com.fdkankan.agent.httpClient.client.LaserClient;
|
|
|
|
+import com.fdkankan.agent.httpClient.request.LaserSceneMoveParam;
|
|
|
|
+import com.fdkankan.agent.httpClient.request.LaserSceneParam;
|
|
|
|
+import com.fdkankan.agent.httpClient.response.FdkkResponse;
|
|
|
|
+import com.fdkankan.agent.request.SceneParam;
|
|
|
|
+import com.fdkankan.agent.response.SceneVo;
|
|
|
|
+import com.fdkankan.agent.service.ICameraDetailService;
|
|
|
|
+import com.fdkankan.agent.service.ICameraService;
|
|
|
|
+import com.fdkankan.agent.service.IUserService;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import javax.annotation.Resource;
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+@Slf4j
|
|
|
|
+public class LaserService {
|
|
|
|
+
|
|
|
|
+ @Resource
|
|
|
|
+ LaserClient laserClient;
|
|
|
|
+ @Value("${4dkk.laserService.basePath}")
|
|
|
|
+ private String basePath;
|
|
|
|
+ @Autowired
|
|
|
|
+ IUserService userService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICameraDetailService cameraDetailService;
|
|
|
|
+ @Autowired
|
|
|
|
+ ICameraService cameraService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public PageInfo pageList(SceneParam param) {
|
|
|
|
+ LaserSceneParam laserSceneParam = getLaserSceneParam(param);
|
|
|
|
+ FdkkResponse response = laserClient.sceneList(laserSceneParam);
|
|
|
|
+ JSONObject jsonObject =response.getData();
|
|
|
|
+ if(jsonObject == null){
|
|
|
|
+ Page<SceneVo> voPage = new Page<>(param.getPageNum(),param.getPageSize());
|
|
|
|
+ voPage.setRecords(new ArrayList<>());
|
|
|
|
+ voPage.setTotal(0);
|
|
|
|
+ return PageInfo.PageInfo(voPage);
|
|
|
|
+ }
|
|
|
|
+ JSONArray list = jsonObject.getJSONArray("list");
|
|
|
|
+ long total =jsonObject.getLong("total");
|
|
|
|
+
|
|
|
|
+ List<SceneVo> sceneVoList = new ArrayList<>();
|
|
|
|
+ String newBasePath = basePath;
|
|
|
|
+ //String newBasePath = basePath.contains("uat")? basePath += "/uat" : basePath;
|
|
|
|
+ newBasePath = newBasePath.contains("dev")? newBasePath += "/dev" : newBasePath;
|
|
|
|
+ for (Object o : list) {
|
|
|
|
+ String res = JSONObject.toJSONString(o);
|
|
|
|
+ SceneVo vo = JSONObject.parseObject(res,SceneVo.class);
|
|
|
|
+ //深时状态,-1:场景被删 0:计算中 1计算失败 2计算成功 3封存 4生成OBJ中
|
|
|
|
+ JSONObject obj = (JSONObject) o;
|
|
|
|
+ vo.setStatusString(getLaserStatus(vo.getStatus()));
|
|
|
|
+ vo.setStatus(toFdStatus(vo.getStatus()));
|
|
|
|
+ if(vo.getStatus() == -3){
|
|
|
|
+ vo.setPayStatus(-1);
|
|
|
|
+ }else {
|
|
|
|
+ vo.setPayStatus(1);
|
|
|
|
+ }
|
|
|
|
+ vo.setSceneName(obj.getString("title"));
|
|
|
|
+ vo.setUserName(obj.getString("phone"));
|
|
|
|
+ vo.setThumb(newBasePath +"/index.html?m="+vo.getNum() );
|
|
|
|
+ vo.setPayStatus(1);
|
|
|
|
+ sceneVoList.add(vo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Page<SceneVo> voPage = new Page<>(param.getPageNum(),param.getPageSize());
|
|
|
|
+ voPage.setRecords(sceneVoList);
|
|
|
|
+ voPage.setTotal(total);
|
|
|
|
+ return PageInfo.PageInfo(voPage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private LaserSceneParam getLaserSceneParam(SceneParam param) {
|
|
|
|
+ if(StringUtils.isNotBlank(param.getUserName())){
|
|
|
|
+ List<CameraDetail> cameraDetails = cameraDetailService.getByUserName(param.getAgentId(),param.getUserName());
|
|
|
|
+ param.setSnCodes(this.setSnCodes(cameraDetails));
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isNotBlank(param.getUserName()) && StringUtils.isBlank(param.getSnCode()) &&
|
|
|
|
+ (param.getSnCodes() == null || param.getSnCodes().size() <=0)){
|
|
|
|
+ param.setSnCode("phoneEmptySelect");
|
|
|
|
+ }
|
|
|
|
+ LaserSceneParam newParam = new LaserSceneParam();
|
|
|
|
+ BeanUtils.copyProperties(param,newParam);
|
|
|
|
+ newParam.setTitle(param.getSceneName());
|
|
|
|
+ return newParam;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private List<String> setSnCodes(List<CameraDetail> cameraDetails) {
|
|
|
|
+ if(cameraDetails != null && cameraDetails.size() >0){
|
|
|
|
+ Set<Long> cameraIds = cameraDetails.stream()
|
|
|
|
+ .filter(entity -> entity.getGoodsId() == 10).map(CameraDetail::getCameraId).collect(Collectors.toSet());
|
|
|
|
+ if(cameraIds.size() >0){
|
|
|
|
+ List<Camera> cameraList = cameraService.listByIds(cameraIds);
|
|
|
|
+ return cameraList.stream().map(Camera::getSnCode).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private Integer toFdStatus(Integer status) {
|
|
|
|
+ //深时状态,-1:场景被删 0:计算中 1计算失败 2计算成功 3封存 4生成OBJ中
|
|
|
|
+ switch (status){
|
|
|
|
+ case 0 :
|
|
|
|
+ case 4 :
|
|
|
|
+ return 0;
|
|
|
|
+ case 2 : return -2;
|
|
|
|
+ case 3 : return -3;
|
|
|
|
+ default: return -1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static String getLaserStatus(Integer status){
|
|
|
|
+ //深时状态,-1:场景被删 0:计算中 1计算失败 2计算成功 3封存 4生成OBJ中
|
|
|
|
+ switch (status){
|
|
|
|
+ case -1 : return "场景已删除";
|
|
|
|
+ case 0 : return "计算中";
|
|
|
|
+ case 1 : return "计算失败";
|
|
|
|
+ case 2 : return "计算成功";
|
|
|
|
+ case 3 : return "封存";
|
|
|
|
+ case 4 : return "生成OBJ中";
|
|
|
|
+ default: return "";
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void move(String num, String snCode, String toSnCode) {
|
|
|
|
+ LaserSceneMoveParam param = new LaserSceneMoveParam();
|
|
|
|
+ param.setSceneCode(num);
|
|
|
|
+ param.setSnCode(snCode);
|
|
|
|
+ param.setToSnCode(toSnCode);
|
|
|
|
+ laserClient.migrate(param);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|