LaserService.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. package com.fdkankan.manage_jp.httpClient.service;
  2. import cn.hutool.core.bean.BeanUtil;
  3. import com.fdkankan.common.util.FileUtils;
  4. import com.fdkankan.fyun.face.FYunFileServiceInterface;
  5. import com.fdkankan.manage_jp.httpClient.param.LaserSceneMoveParam;
  6. import com.fdkankan.manage_jp.service.*;
  7. import com.fdkankan.rabbitmq.util.RabbitMqProducer;
  8. import com.alibaba.fastjson.JSONArray;
  9. import com.alibaba.fastjson.JSONObject;
  10. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  11. import com.fdkankan.manage_jp.common.PageInfo;
  12. import com.fdkankan.manage_jp.common.Result;
  13. import com.fdkankan.manage_jp.entity.Camera;
  14. import com.fdkankan.manage_jp.entity.CameraDetail;
  15. import com.fdkankan.manage_jp.entity.Company;
  16. import com.fdkankan.manage_jp.entity.User;
  17. import com.fdkankan.manage_jp.httpClient.client.LaserClient;
  18. import com.fdkankan.manage_jp.httpClient.param.LaserSceneParam;
  19. import com.fdkankan.manage_jp.httpClient.param.SSDownSceneParam;
  20. import com.fdkankan.manage_jp.httpClient.param.SSToBind;
  21. import com.fdkankan.manage_jp.httpClient.vo.FdkkResponse;
  22. import com.fdkankan.manage_jp.httpClient.vo.SSDownSceneVo;
  23. import com.fdkankan.manage_jp.vo.request.SceneParam;
  24. import com.fdkankan.manage_jp.vo.response.SceneVo;
  25. import lombok.extern.slf4j.Slf4j;
  26. import org.apache.commons.lang3.StringUtils;
  27. import org.apache.ibatis.annotations.Param;
  28. import org.springframework.beans.BeanUtils;
  29. import org.springframework.beans.factory.annotation.Autowired;
  30. import org.springframework.beans.factory.annotation.Value;
  31. import org.springframework.http.HttpStatus;
  32. import org.springframework.stereotype.Service;
  33. import java.io.File;
  34. import java.util.*;
  35. import java.util.stream.Collectors;
  36. @Service
  37. @Slf4j
  38. public class LaserService {
  39. @Autowired
  40. LaserClient laserClient;
  41. @Value("${4dkk.laserService.basePath}")
  42. private String basePath;
  43. @Autowired
  44. IUserService userService;
  45. @Autowired
  46. ICameraDetailService cameraDetailService;
  47. @Autowired
  48. ICameraService cameraService;
  49. @Autowired
  50. ICompanyService companyService;
  51. @Autowired
  52. ITmColdStorageService tmColdStorageService;
  53. public SSDownSceneVo downOfflineSceneStatus(String num) {
  54. try {
  55. SSDownSceneVo vo ;
  56. SSDownSceneParam param = new SSDownSceneParam();
  57. param.setSceneCode(num);
  58. Result responseEntity = laserClient.downOfflineSceneStatus(param);
  59. if( responseEntity.getCode() != HttpStatus.OK.value()){
  60. log.error("downOfflineSceneStatus-根据场景码获取激光转台下载状态失败:{}",responseEntity);
  61. return null;
  62. }
  63. vo = JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getData()), SSDownSceneVo.class);
  64. return vo;
  65. }catch (Exception e){
  66. log.error("downOfflineSceneStatus-根据场景码获取激光转台下载状态失败!",e);
  67. }
  68. return null ;
  69. }
  70. public SSDownSceneVo downOfflineScene(String num) {
  71. try {
  72. SSDownSceneVo vo ;
  73. SSDownSceneParam param = new SSDownSceneParam();
  74. param.setSceneCode(num);
  75. Result responseEntity = laserClient.downOfflineScene(param);
  76. if( responseEntity.getCode() != HttpStatus.OK.value()){
  77. log.error("downOfflineScene-根据场景码获取激光转台下载失败:{}",responseEntity);
  78. return null;
  79. }
  80. vo = JSONObject.parseObject(JSONObject.toJSONString(responseEntity.getData()), SSDownSceneVo.class);
  81. return vo ;
  82. }catch (Exception e){
  83. log.error("downOfflineScene-根据场景码获取激光转台下载状态失败!",e);
  84. }
  85. return null ;
  86. }
  87. public Result updateStatus(String num,Integer status) {
  88. Map<String,Object> params = new HashMap<>();
  89. params.put("sceneCodes", Arrays.asList(num));
  90. params.put("status", status);
  91. return laserClient.updateStatus( params);
  92. }
  93. public Result updateBuildObjStatus(String num,Integer status) {
  94. //生成OBJ状态,0,未生成 1完成,2计算中
  95. Map<String,Object> params = new HashMap<>();
  96. params.put("sceneCode", num);
  97. params.put("buildObjStatus", status);
  98. return laserClient.updateStatus( params);
  99. }
  100. public void toBind(List<String> snCodes,Boolean bind,String phone) {
  101. try {
  102. SSToBind param = new SSToBind();
  103. param.setBind(bind);
  104. param.setSnCode(snCodes);
  105. Result result = laserClient.toBind(param);
  106. if(result.getCode() != HttpStatus.OK.value()){
  107. log.error("激光场景状态同步失败!");
  108. }
  109. }catch (Exception e){
  110. log.error("激光场景状态同步失败!",e);
  111. }
  112. }
  113. public void copy(Long camaraId, String createTime, String newNum, Integer status,
  114. String path, String sceneKey, Long userId,String version,
  115. String oldNum,String algorithmTime,Integer sceneSource,Integer shootCount,Integer location,Integer isObj ){
  116. String phone = null;
  117. String snCode = null;
  118. if(userId != null){
  119. User user = userService.getById(userId);
  120. phone = user == null ? null :user.getUserName();
  121. }
  122. if(camaraId != null){
  123. Camera camera = cameraService.getById(camaraId);
  124. snCode = camera == null ? null :camera.getSnCode();
  125. }
  126. Map<String,Object> params = new HashMap<>();
  127. params.put("childName",snCode);
  128. params.put("createTime", createTime);
  129. params.put("phone", phone);
  130. params.put("sceneCode", newNum);
  131. params.put("oldSceneCode", oldNum);
  132. params.put("snCode",snCode);
  133. params.put("status", status);
  134. params.put("password", sceneKey);
  135. //params.put("title", sceneName);
  136. params.put("userId", userId);
  137. params.put("isCopy", true);
  138. params.put("path",path);
  139. params.put("version",version);
  140. params.put("sceneSource",sceneSource);
  141. params.put("algorithmTime",algorithmTime);
  142. params.put("shootCount",shootCount);
  143. if(location != null){
  144. params.put("location",location);
  145. }
  146. if(isObj == 1){
  147. params.put("buildObjStatus",isObj);
  148. }
  149. rabbitMqProducer.sendByWorkQueue("laser-update-scene",params);
  150. }
  151. public String copyDataSource( String oldDataSource,String dataSource) {
  152. //计算成功 激光转台相机推送
  153. log.info("激光转台相机 同步 请求 ");
  154. try {
  155. //创建目录
  156. if(oldDataSource.lastIndexOf("/")!=-1){
  157. oldDataSource = oldDataSource + "_laserData";
  158. }else{
  159. oldDataSource = oldDataSource.substring(0,oldDataSource.length()-1) + "_laserData";
  160. }
  161. if(dataSource.lastIndexOf("/")!=-1){
  162. dataSource = dataSource + "_laserData";
  163. }else{
  164. dataSource = dataSource.substring(0,dataSource.length()-1) + "_laserData";
  165. }
  166. FileUtils.copyDirectiory(oldDataSource ,dataSource);
  167. return dataSource + File.separator + "laserData";
  168. }catch (Exception e){
  169. e.printStackTrace();
  170. }
  171. return null;
  172. }
  173. public void move(String num, String snCode, String toSnCode, Long userId, String newDataSource) {
  174. LaserSceneMoveParam param = new LaserSceneMoveParam();
  175. param.setSceneCode(num);
  176. //param.setSnCode(snCode);
  177. param.setToSnCode(toSnCode);
  178. param.setUserId(userId);
  179. param.setDataSource(newDataSource+"_laserData/laserData");
  180. if(userId != null){
  181. User user = userService.getById(userId);
  182. if(user != null){
  183. param.setPhone(user.getUserName());
  184. }
  185. }
  186. Map<String, Object> map = BeanUtil.beanToMap(param);
  187. rabbitMqProducer.sendByWorkQueue("laser-migrate-scene",map);
  188. //return laserClient.migrate(param);
  189. }
  190. @Autowired
  191. private FYunFileServiceInterface fYunFileService;
  192. @Autowired
  193. private RabbitMqProducer rabbitMqProducer;
  194. @Value("${4dkk.laserService.cloud-point-fyun-path:laser_u_data/%s/data/bundle_%s/building/}")
  195. private String cloudPointFyunPath;
  196. @Value("${4dkk.laserService.bucket:geosign-4dkk}")
  197. private String bucket;
  198. @Value("${queue.application.laser.cloud-point-build:laser-cloud-point-build}")
  199. private String cloudPointBuild;
  200. public void cloudPointBuild(String oldSceneCode,String sceneCode) {
  201. if (!fYunFileService.fileExist(bucket,String.format(cloudPointFyunPath,oldSceneCode,oldSceneCode) +"vision_edit.txt")){
  202. return;
  203. }
  204. log.info("开始同步点云编辑文件");
  205. // 上传点云编辑文件,并通知激光系统
  206. fYunFileService.copyFileBetweenBucket(bucket,String.format(cloudPointFyunPath,oldSceneCode,oldSceneCode) + "vision_edit.txt",
  207. bucket,String.format(cloudPointFyunPath,sceneCode,sceneCode) + "vision_edit.txt");
  208. fYunFileService.copyFileBetweenBucket(bucket,String.format(cloudPointFyunPath,oldSceneCode,oldSceneCode) + "uuidcloud",
  209. bucket,String.format(cloudPointFyunPath,sceneCode,sceneCode) + "uuidcloud");
  210. Map<String, Object> params = new HashMap<>();
  211. params.put("sceneNum", sceneCode);
  212. params.put("businessType", 0);
  213. rabbitMqProducer.sendByWorkQueue(cloudPointBuild, params);
  214. }
  215. public HashMap<String, JSONObject> list(List<String> sceneNumList) {
  216. LaserSceneParam newParam = new LaserSceneParam();
  217. newParam.setPageNum(1);
  218. newParam.setPageSize(sceneNumList.size());
  219. newParam.setSceneCodes(sceneNumList);
  220. return this.list(newParam);
  221. }
  222. public HashMap<String, JSONObject> list(List<String> sceneNumList,Integer status) {
  223. LaserSceneParam newParam = new LaserSceneParam();
  224. newParam.setPageNum(1);
  225. newParam.setPageSize(sceneNumList.size());
  226. newParam.setSceneCodes(sceneNumList);
  227. newParam.setStatus(status);
  228. return this.list(newParam);
  229. }
  230. public HashMap<String, JSONObject> list(LaserSceneParam newParam) {
  231. HashMap<String, JSONObject> map = new HashMap<>();
  232. FdkkResponse fdkkResponse = laserClient.sceneList(newParam);
  233. JSONObject jsonObject = fdkkResponse.getData();
  234. if(jsonObject == null){
  235. return map;
  236. }
  237. JSONArray list = jsonObject.getJSONArray("list");
  238. for (Object o : list) {
  239. JSONObject obj = (JSONObject) o;
  240. map.put(obj.getString("num"),obj);
  241. }
  242. return map;
  243. }
  244. public JSONObject getSceneByNum(String num) {
  245. Result result = laserClient.getSceneByNum(num);
  246. if(result.getCode() != HttpStatus.OK.value()){
  247. log.error("获取激光转台场景失败!");
  248. return null;
  249. }
  250. return JSONObject.parseObject(JSONObject.toJSONString(result.getData()));
  251. }
  252. }