123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281 |
- package com.fdkankan.manage_jp.httpClient.service;
- import cn.hutool.core.bean.BeanUtil;
- import com.fdkankan.common.util.FileUtils;
- import com.fdkankan.fyun.face.FYunFileServiceInterface;
- import com.fdkankan.manage_jp.httpClient.param.LaserSceneMoveParam;
- import com.fdkankan.manage_jp.service.*;
- import com.fdkankan.rabbitmq.util.RabbitMqProducer;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.fdkankan.manage_jp.common.PageInfo;
- import com.fdkankan.manage_jp.common.Result;
- import com.fdkankan.manage_jp.entity.Camera;
- import com.fdkankan.manage_jp.entity.CameraDetail;
- import com.fdkankan.manage_jp.entity.Company;
- import com.fdkankan.manage_jp.entity.User;
- import com.fdkankan.manage_jp.httpClient.client.LaserClient;
- import com.fdkankan.manage_jp.httpClient.param.LaserSceneParam;
- import com.fdkankan.manage_jp.httpClient.param.SSDownSceneParam;
- import com.fdkankan.manage_jp.httpClient.param.SSToBind;
- import com.fdkankan.manage_jp.httpClient.vo.FdkkResponse;
- import com.fdkankan.manage_jp.httpClient.vo.SSDownSceneVo;
- import com.fdkankan.manage_jp.vo.request.SceneParam;
- import com.fdkankan.manage_jp.vo.response.SceneVo;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.ibatis.annotations.Param;
- 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 java.io.File;
- import java.util.*;
- import java.util.stream.Collectors;
- @Service
- @Slf4j
- public class LaserService {
- @Autowired
- LaserClient laserClient;
- @Value("${4dkk.laserService.basePath}")
- private String basePath;
- @Autowired
- IUserService userService;
- @Autowired
- ICameraDetailService cameraDetailService;
- @Autowired
- ICameraService cameraService;
- @Autowired
- ICompanyService companyService;
- @Autowired
- ITmColdStorageService tmColdStorageService;
- public SSDownSceneVo downOfflineSceneStatus(String num) {
- try {
- SSDownSceneVo vo ;
- SSDownSceneParam param = new SSDownSceneParam();
- param.setSceneCode(num);
- Result responseEntity = laserClient.downOfflineSceneStatus(param);
- if( responseEntity.getCode() != HttpStatus.OK.value()){
- log.error("downOfflineSceneStatus-根据场景码获取激光转台下载状态失败:{}",responseEntity);
- return null;
- }
- vo = JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getData()), SSDownSceneVo.class);
- return vo;
- }catch (Exception e){
- log.error("downOfflineSceneStatus-根据场景码获取激光转台下载状态失败!",e);
- }
- return null ;
- }
- public SSDownSceneVo downOfflineScene(String num) {
- try {
- SSDownSceneVo vo ;
- SSDownSceneParam param = new SSDownSceneParam();
- param.setSceneCode(num);
- Result responseEntity = laserClient.downOfflineScene(param);
- if( responseEntity.getCode() != HttpStatus.OK.value()){
- log.error("downOfflineScene-根据场景码获取激光转台下载失败:{}",responseEntity);
- return null;
- }
- vo = JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getData()), SSDownSceneVo.class);
- return vo ;
- }catch (Exception e){
- log.error("downOfflineScene-根据场景码获取激光转台下载状态失败!",e);
- }
- return null ;
- }
- public Result updateStatus(String num,Integer status) {
- Map<String,Object> params = new HashMap<>();
- params.put("sceneCodes", Arrays.asList(num));
- params.put("status", status);
- return laserClient.updateStatus( params);
- }
- public Result updateBuildObjStatus(String num,Integer status) {
- //生成OBJ状态,0,未生成 1完成,2计算中
- Map<String,Object> params = new HashMap<>();
- params.put("sceneCode", num);
- params.put("buildObjStatus", status);
- return laserClient.updateStatus( params);
- }
- public void toBind(List<String> snCodes,Boolean bind,String phone) {
- try {
- SSToBind param = new SSToBind();
- param.setBind(bind);
- param.setSnCode(snCodes);
- Result result = laserClient.toBind(param);
- if(result.getCode() != HttpStatus.OK.value()){
- log.error("激光场景状态同步失败!");
- }
- }catch (Exception e){
- log.error("激光场景状态同步失败!",e);
- }
- }
- public void copy(Long camaraId, String createTime, String newNum, Integer status,
- String path, String sceneKey, Long userId,String version,
- String oldNum,String algorithmTime,Integer sceneSource,Integer shootCount,Integer location,Integer isObj ){
- String phone = null;
- String snCode = null;
- if(userId != null){
- User user = userService.getById(userId);
- phone = user == null ? null :user.getUserName();
- }
- if(camaraId != null){
- Camera camera = cameraService.getById(camaraId);
- snCode = camera == null ? null :camera.getSnCode();
- }
- Map<String,Object> params = new HashMap<>();
- params.put("childName",snCode);
- params.put("createTime", createTime);
- params.put("phone", phone);
- params.put("sceneCode", newNum);
- params.put("oldSceneCode", oldNum);
- params.put("snCode",snCode);
- params.put("status", status);
- params.put("password", sceneKey);
- //params.put("title", sceneName);
- params.put("userId", userId);
- params.put("isCopy", true);
- params.put("path",path);
- params.put("version",version);
- params.put("sceneSource",sceneSource);
- params.put("algorithmTime",algorithmTime);
- params.put("shootCount",shootCount);
- if(location != null){
- params.put("location",location);
- }
- if(isObj == 1){
- params.put("buildObjStatus",isObj);
- }
- rabbitMqProducer.sendByWorkQueue("laser-update-scene",params);
- }
- public String copyDataSource( String oldDataSource,String dataSource) {
- //计算成功 激光转台相机推送
- log.info("激光转台相机 同步 请求 ");
- try {
- //创建目录
- if(oldDataSource.lastIndexOf("/")!=-1){
- oldDataSource = oldDataSource + "_laserData";
- }else{
- oldDataSource = oldDataSource.substring(0,oldDataSource.length()-1) + "_laserData";
- }
- if(dataSource.lastIndexOf("/")!=-1){
- dataSource = dataSource + "_laserData";
- }else{
- dataSource = dataSource.substring(0,dataSource.length()-1) + "_laserData";
- }
- FileUtils.copyDirectiory(oldDataSource ,dataSource);
- return dataSource + File.separator + "laserData";
- }catch (Exception e){
- e.printStackTrace();
- }
- return null;
- }
- public void move(String num, String snCode, String toSnCode, Long userId, String newDataSource) {
- LaserSceneMoveParam param = new LaserSceneMoveParam();
- param.setSceneCode(num);
- //param.setSnCode(snCode);
- param.setToSnCode(toSnCode);
- param.setUserId(userId);
- param.setDataSource(newDataSource+"_laserData/laserData");
- if(userId != null){
- User user = userService.getById(userId);
- if(user != null){
- param.setPhone(user.getUserName());
- }
- }
- Map<String, Object> map = BeanUtil.beanToMap(param);
- rabbitMqProducer.sendByWorkQueue("laser-migrate-scene",map);
- //return laserClient.migrate(param);
- }
- @Autowired
- private FYunFileServiceInterface fYunFileService;
- @Autowired
- private RabbitMqProducer rabbitMqProducer;
- @Value("${4dkk.laserService.cloud-point-fyun-path:laser_u_data/%s/data/bundle_%s/building/}")
- private String cloudPointFyunPath;
- @Value("${4dkk.laserService.bucket:geosign-4dkk}")
- private String bucket;
- @Value("${queue.application.laser.cloud-point-build:laser-cloud-point-build}")
- private String cloudPointBuild;
- public void cloudPointBuild(String oldSceneCode,String sceneCode) {
- if (!fYunFileService.fileExist(bucket,String.format(cloudPointFyunPath,oldSceneCode,oldSceneCode) +"vision_edit.txt")){
- return;
- }
- log.info("开始同步点云编辑文件");
- // 上传点云编辑文件,并通知激光系统
- fYunFileService.copyFileBetweenBucket(bucket,String.format(cloudPointFyunPath,oldSceneCode,oldSceneCode) + "vision_edit.txt",
- bucket,String.format(cloudPointFyunPath,sceneCode,sceneCode) + "vision_edit.txt");
- fYunFileService.copyFileBetweenBucket(bucket,String.format(cloudPointFyunPath,oldSceneCode,oldSceneCode) + "uuidcloud",
- bucket,String.format(cloudPointFyunPath,sceneCode,sceneCode) + "uuidcloud");
- Map<String, Object> params = new HashMap<>();
- params.put("sceneNum", sceneCode);
- params.put("businessType", 0);
- rabbitMqProducer.sendByWorkQueue(cloudPointBuild, params);
- }
- public HashMap<String, JSONObject> list(List<String> sceneNumList) {
- LaserSceneParam newParam = new LaserSceneParam();
- newParam.setPageNum(1);
- newParam.setPageSize(sceneNumList.size());
- newParam.setSceneCodes(sceneNumList);
- return this.list(newParam);
- }
- public HashMap<String, JSONObject> list(List<String> sceneNumList,Integer status) {
- LaserSceneParam newParam = new LaserSceneParam();
- newParam.setPageNum(1);
- newParam.setPageSize(sceneNumList.size());
- newParam.setSceneCodes(sceneNumList);
- newParam.setStatus(status);
- return this.list(newParam);
- }
- public HashMap<String, JSONObject> list(LaserSceneParam newParam) {
- HashMap<String, JSONObject> map = new HashMap<>();
- FdkkResponse fdkkResponse = laserClient.sceneList(newParam);
- JSONObject jsonObject = fdkkResponse.getData();
- if(jsonObject == null){
- return map;
- }
- JSONArray list = jsonObject.getJSONArray("list");
- for (Object o : list) {
- JSONObject obj = (JSONObject) o;
- map.put(obj.getString("num"),obj);
- }
- return map;
- }
- public JSONObject getSceneByNum(String num) {
- Result result = laserClient.getSceneByNum(num);
- if(result.getCode() != HttpStatus.OK.value()){
- log.error("获取激光转台场景失败!");
- return null;
- }
- return JSONObject.parseObject(JSONObject.toJSONString(result.getData()));
- }
- }
|