ComputerUtil.java 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. package com.fdkankan.common.util;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. //import com.fdkankan.base.mq.ModelingMsgProducer;
  5. import com.fdkankan.common.constant.ConstantFileName;
  6. import com.fdkankan.common.constant.ConstantFilePath;
  7. import com.fdkankan.common.constant.ConstantUrl;
  8. import com.fdkankan.mq.message.BuildSceneMqMessage;
  9. import lombok.extern.slf4j.Slf4j;
  10. import org.joda.time.DateTime;
  11. import org.springframework.stereotype.Component;
  12. import org.springframework.util.ObjectUtils;
  13. import org.springframework.util.StringUtils;
  14. import java.io.File;
  15. import java.util.*;
  16. /**
  17. * 生成场景和计算场景
  18. * Created by Hb_zzZ on 2019/5/8.
  19. */
  20. @Slf4j
  21. @Component
  22. public class ComputerUtil {
  23. public static Map<String,String> computer(String projectNum, String path, String buildType) throws Exception{
  24. Map<String,String> map = new HashMap<String,String>();
  25. path = path.replace("//", "/");
  26. log.info("开始建模:"+projectNum);
  27. //构建算法isModel去掉,因此改成空字符串
  28. if("V2".equals(buildType)){
  29. CreateObjUtil.build3dModelOld(path, "");
  30. }
  31. if("V3".equals(buildType)){
  32. CreateObjUtil.build3dModel(path, "");
  33. // CreateObjUtil.build3dModel(unicode, "");
  34. }
  35. log.info("建模完成转换数据:"+projectNum);
  36. boolean vision2 = false;
  37. //读取upload文件,检验需要上传的文件是否存在
  38. String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
  39. JSONObject uploadJson = null;
  40. JSONArray array = null;
  41. if(uploadData!=null) {
  42. uploadJson = JSONObject.parseObject(uploadData);
  43. array = uploadJson.getJSONArray("upload");
  44. }
  45. if(array == null){
  46. String instanceId = FileUtils.readFile("/opt/hosts/hosts.txt");
  47. FileUtils.writeFile(path + File.separator + "javaErrorNow.log", instanceId + ":计算错误!");
  48. Thread.sleep(10000L);
  49. FileUtils.writeFile(path + File.separator + "javaError.log", instanceId + ":计算错误!");
  50. throw new Exception("upload.json数据出错");
  51. }
  52. JSONObject fileJson = null;
  53. String fileName = "";
  54. String meshfix = ""; //双模型时候会有改文件路径
  55. for(int i = 0, len = array.size(); i < len; i++){
  56. fileJson = array.getJSONObject(i);
  57. fileName = fileJson.getString("file");
  58. //文件不存在抛出异常
  59. if(!new File(path + File.separator + "results" +File.separator + fileName).exists()){
  60. throw new Exception(path + File.separator + "results" +File.separator + fileName+"文件不存在");
  61. }
  62. //判断是否有vision2.txt
  63. if("vision2.txt".equals(fileName)){
  64. vision2 = true;
  65. }
  66. //tex文件夹
  67. if(fileJson.getIntValue("clazz") == 2 && !fileJson.containsKey("pack-file")){
  68. if(fileName.contains("meshfix.txt")){
  69. meshfix = fileName;
  70. }else {
  71. map.put(path + File.separator + "results" +File.separator+ fileName,"images/images"+
  72. projectNum+"/"+ ConstantFileName.modelUUID+"_50k_texture_jpg_high1/"+fileName.replace("tex/", ""));
  73. }
  74. continue;
  75. }
  76. //high文件夹
  77. if(fileJson.getIntValue("clazz") == 3){
  78. map.put(path + File.separator + "results" +File.separator+ fileName,"images/images"+
  79. projectNum+"/pan/high/"+ fileName.replace("high/", ""));
  80. continue;
  81. }
  82. //low文件夹
  83. if(fileJson.getIntValue("clazz") == 4){
  84. map.put(path + File.separator + "results" +File.separator+ fileName,"images/images"+
  85. projectNum+"/pan/low/"+ fileName.replace("low/", ""));
  86. continue;
  87. }
  88. //tiles文件夹,亚马逊没有裁剪图片api,不需要上传4k图
  89. // if(fileJson.getIntValue("clazz") == 5 && !"s3".equals(ossType)){
  90. // map.put(path + File.separator + "results" + File.separator+ fileName,"images/images"+
  91. // projectNum+ File.separator + fileName);
  92. // continue;
  93. // }
  94. if(fileJson.getIntValue("clazz") == 5 ){
  95. map.put(path + File.separator + "results" + File.separator+ fileName,"images/images"+
  96. projectNum+ File.separator + fileName);
  97. continue;
  98. }
  99. //tiles文件夹,亚马逊瓦片图
  100. if(fileJson.getIntValue("clazz") == 7 ){
  101. if(fileName.contains("/4k_")){
  102. continue;
  103. }
  104. map.put(path + File.separator + "results" + File.separator+ fileName,"images/images"+
  105. projectNum+ File.separator + fileName);
  106. continue;
  107. }
  108. //updown文件复制一份到ecs中并去掉换行符
  109. if(fileJson.getIntValue("clazz") == 10){
  110. String updown = FileUtils.readFile(path + File.separator + "results" +File.separator+ fileName);
  111. JSONObject updownJson = JSONObject.parseObject(updown);
  112. FileUtils.writeFile(ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + projectNum +
  113. File.separator + fileName.replace("updown", "mapping"), updownJson.toString());
  114. continue;
  115. }
  116. //video视频文件或封面图
  117. if(fileJson.getIntValue("clazz") == 11 || fileJson.getIntValue("cl" +
  118. "azz") == 12){
  119. map.put(path + File.separator + "results" + File.separator+ fileName,"video/video"+
  120. projectNum+ File.separator + fileName.replace("videos/", ""));
  121. if(fileName.contains(".mp4")){
  122. // CreateObjUtil.mp4ToFlv(path + File.separator + "results" + File.separator+ fileName,
  123. // path + File.separator + "results" + File.separator+ fileName.replace("mp4", "flv"));
  124. map.put(path + File.separator + "results" + File.separator+ fileName.replace("mp4", "flv"),"video/video"+
  125. projectNum+ File.separator + fileName.replace("videos/", "").replace("mp4", "flv"));
  126. }
  127. }
  128. //2048的模型和贴图
  129. if(fileJson.getIntValue("clazz") == 16){
  130. map.put(path + File.separator + "results" + File.separator+ fileName,"data/data"+
  131. projectNum+ File.separator + fileName);
  132. }
  133. if(fileJson.getIntValue("clazz") == 18){
  134. map.put(path + File.separator + "results" + File.separator+ fileName,"images/images"+
  135. projectNum+ File.separator + fileName);
  136. }
  137. }
  138. CreateObjUtil.convertTxtToDam( path + File.separator + "results" + File.separator+"tex"+File.separator+"modeldata.txt", path + File.separator + "results" +File.separator+ ConstantFileName.modelUUID+"_50k.dam");
  139. CreateObjUtil.convertDamToLzma(path + File.separator + "results");
  140. CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+"tex"+File.separator+"modeldata.txt", path + File.separator + "results" + File.separator+ConstantFileName.modelUUID+"_50k.dam");
  141. //有meshfix,表示双模型
  142. if(!"".equals(meshfix)){
  143. CreateObjUtil.convertTxtToDam( path + File.separator + "results" + File.separator+meshfix, path + File.separator + "results" +File.separator+ ConstantFileName.modelUUID+"_50k2.dam");
  144. CreateObjUtil.convertDamToLzma2(path + File.separator + "results");
  145. CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+meshfix, path + File.separator + "results" + File.separator+ConstantFileName.modelUUID+"_50k2.dam");
  146. map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k2.dam.lzma", "images/images"+projectNum+"/"+ConstantFileName.modelUUID+"_50k2.dam.lzma");
  147. map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k2.dam", "images/images"+projectNum+"/"+ConstantFileName.modelUUID+"_50k2.dam");
  148. }
  149. //8目相机有两个vision.txt因此第二个叫vision2.txt
  150. CreateObjUtil.convertTxtToVisionmodeldata(path + File.separator + "results" +File.separator+"vision.txt",path + File.separator + "results" +File.separator+"vision.modeldata");
  151. if(vision2){
  152. CreateObjUtil.convertTxtToVisionmodeldata(path + File.separator + "results" +File.separator+"vision2.txt",path + File.separator + "results" +File.separator+"vision2.modeldata");
  153. map.put(path + File.separator + "results" +File.separator+"vision2.modeldata", "images/images"+projectNum+"/"+"vision2.modeldata");
  154. }else {
  155. CreateObjUtil.convertTxtToVisionmodeldataCommon(path + File.separator + "results" +File.separator+"vision.txt",path + File.separator + "results" +File.separator+"vision.modeldata");
  156. }
  157. log.info("数据转换完成:"+projectNum);
  158. File file = new File(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam.lzma");
  159. while(!file.exists())
  160. {
  161. Thread.sleep(60000);
  162. }
  163. map.put(path + File.separator + "results" +File.separator+"vision.modeldata", "images/images"+projectNum+"/"+"vision.modeldata");
  164. map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam.lzma", "images/images"+projectNum+"/"+ConstantFileName.modelUUID+"_50k.dam.lzma");
  165. map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam", "images/images"+projectNum+"/"+ConstantFileName.modelUUID+"_50k.dam");
  166. file = new File(ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum);
  167. if(!file.exists())
  168. {
  169. file.mkdir();
  170. }
  171. FileUtils.copyFile(path + File.separator + "results" +File.separator+"floor.json", ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum+File.separator+"floor.json", true);
  172. FileUtils.copyFile(path + File.separator + "results" +File.separator+"floorplan.json", ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum+File.separator+"floor.json", true);
  173. FileUtils.copyFile(path + File.separator + "results" +File.separator+"floorplan.json", ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum+File.separator+"floorplan.json", true);
  174. log.info("floor.json路径:"+ path + File.separator + "results" +File.separator+"floor.json");
  175. map.put(path + File.separator + "results" +File.separator+"floor.json","data/data"+projectNum+"/floor.json");
  176. map.put(path + File.separator + "results" +File.separator+"floorplan.json","data/data"+projectNum+"/floor.json");
  177. // map.put(path + File.separator + "results" +File.separator+"floorplan_cad.json","data/data"+projectNum+"/house_floor.json");
  178. map.put(path + File.separator + "results" +File.separator+"floorplan_cad.json","data/data"+projectNum+"/floorplan_cad.json");
  179. log.info("准备上传文件到oss:"+projectNum);
  180. return map;
  181. }
  182. public static Map<String,String> computerRebuildVideo(String projectNum, String path) throws Exception{
  183. Map<String,String> map = new HashMap<String,String>();
  184. path = path.replace("//", "/");
  185. log.info("开始建模:"+projectNum);
  186. //构建算法isModel去掉,因此改成空字符串
  187. CreateObjUtil.build3dModel(path, "");
  188. log.info("建模完成转换数据:"+projectNum);
  189. boolean vision2 = false;
  190. //读取upload文件,检验需要上传的文件是否存在
  191. String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
  192. JSONObject uploadJson = null;
  193. JSONArray array = null;
  194. if(uploadData!=null) {
  195. uploadJson = JSONObject.parseObject(uploadData);
  196. array = uploadJson.getJSONArray("upload");
  197. }
  198. if(array == null){
  199. String instanceId = FileUtils.readFile("/opt/hosts/hosts.txt");
  200. FileUtils.writeFile(path + File.separator + "javaErrorNow.log", instanceId + ":计算错误!");
  201. Thread.sleep(10000L);
  202. FileUtils.writeFile(path + File.separator + "javaError.log", instanceId + ":计算错误!");
  203. throw new Exception("upload.json数据出错");
  204. }
  205. JSONObject fileJson = null;
  206. String fileName = "";
  207. for(int i = 0, len = array.size(); i < len; i++) {
  208. fileJson = array.getJSONObject(i);
  209. fileName = fileJson.getString("file");
  210. //文件不存在抛出异常
  211. if (!new File(path + File.separator + "results" + File.separator + fileName).exists()) {
  212. throw new Exception(path + File.separator + "results" + File.separator + fileName + "文件不存在");
  213. }
  214. //video视频文件或封面图
  215. if (fileJson.getIntValue("clazz") == 20) {
  216. if (fileName.contains(".flv")) {
  217. map.put(path + File.separator + "results" + File.separator + fileName, "video/video" +
  218. projectNum + File.separator + fileName.replace("videos/", ""));
  219. }
  220. if (fileName.contains(".mp4")) {
  221. map.put(path + File.separator + "results" + File.separator + fileName, "video/video" +
  222. projectNum + File.separator + fileName.replace("videos/", ""));
  223. }
  224. }
  225. }
  226. log.info("准备上传文件到oss:"+projectNum);
  227. return map;
  228. }
  229. /**
  230. * 标定算法
  231. * @param path
  232. * @throws Exception
  233. */
  234. public static Map<String,String> computerCalibration(String path) throws Exception{
  235. Map<String,String> map = new HashMap<String,String>();
  236. log.info("开始标定:" );
  237. //构建算法isModel去掉,因此改成空字符串
  238. CreateObjUtil.build3dModel(path, "");
  239. // CreateObjUtil.build3dModel(unicode, "");
  240. log.info("标定完成转换数据:" );
  241. boolean vision2 = false;
  242. //读取upload文件,检验需要上传的文件是否存在
  243. String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
  244. JSONObject uploadJson = null;
  245. JSONArray array = null;
  246. if(uploadData!=null) {
  247. uploadJson = JSONObject.parseObject(uploadData);
  248. array = uploadJson.getJSONArray("upload");
  249. }
  250. if(array == null){
  251. throw new Exception("upload.json数据出错");
  252. }
  253. JSONObject fileJson = null;
  254. String fileName = "";
  255. for(int i = 0, len = array.size(); i < len; i++) {
  256. fileJson = array.getJSONObject(i);
  257. fileName = fileJson.getString("file");
  258. //文件不存在抛出异常
  259. if (!new File(path + File.separator + "results" + File.separator + fileName).exists()) {
  260. throw new Exception(path + File.separator + "results" + File.separator + fileName + "文件不存在");
  261. }
  262. if(fileJson.getIntValue("clazz") == 13 || fileJson.getIntValue("clazz") == 14){
  263. map.put(path + File.separator + "results" +File.separator+ fileName,
  264. ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") +
  265. File.separator + fileName);
  266. }
  267. }
  268. return map;
  269. }
  270. //
  271. public static void createJson(String path, String splitType, String skyboxType, String dataDescribe,
  272. String sceneNum, String dataSource) throws Exception{
  273. JSONObject projectJson = new JSONObject();
  274. projectJson.put("version", "201909231830");
  275. projectJson.put("protocol", "file api 1.4");
  276. projectJson.put("uuid", UUID.randomUUID().toString());
  277. projectJson.put("description", "");
  278. projectJson.put("time", System.currentTimeMillis());
  279. projectJson.put("category", "default");
  280. projectJson.put("tag", null);
  281. projectJson.put("status", null);
  282. projectJson.put("sceneNum", sceneNum);
  283. projectJson.put("dataSource", dataSource);
  284. FileUtils.writeFile(path + File.separator + "project.json", projectJson.toString());
  285. JSONObject dataJson = new JSONObject();
  286. dataJson.put("split_type", splitType);
  287. dataJson.put("skybox_type", skyboxType);
  288. dataJson.put("extras", null);
  289. FileUtils.writeFile(path + File.separator + "data.json", dataJson.toString());
  290. }
  291. public static void createExtras(String rebuildParam, String hdrParam, String path) throws Exception {
  292. FileUtils.writeFile( path + File.separator + "extras" + File.separator + "videos_hdr_param.json", hdrParam);
  293. FileUtils.writeFile( path + File.separator + "extras" + File.separator + "required_videos.json", rebuildParam);
  294. }
  295. public static void createExtras(String rebuildParam,String path) throws Exception {
  296. FileUtils.writeFile( path + File.separator + "extras" + File.separator + "image-ROI.json", rebuildParam);
  297. }
  298. /**
  299. * 生成标定数据
  300. * @param calPath
  301. * @param prefix
  302. * @throws Exception
  303. */
  304. public static void createCalibrationData(String calPath, String prefix) throws Exception{
  305. File calFile = new File(calPath);
  306. if(calFile.exists()){
  307. calFile.mkdirs();
  308. }
  309. //删除results和capture文件夹
  310. FileUtils.deleteDirectory(calPath + "/capture");
  311. FileUtils.deleteDirectory(calPath + "/results");
  312. // CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + prefix, calPath + "/capture");
  313. for(File oldFile : new File(prefix).listFiles()){
  314. FileUtils.copyFile(oldFile.getAbsolutePath(), calPath + "/capture/" + oldFile.getName(), true);
  315. }
  316. JSONObject dataJson = new JSONObject();
  317. dataJson.put("split_type", "SPLIT_V7");
  318. dataJson.put("skybox_type", "SKYBOX_V5");
  319. FileUtils.writeFile(calPath + "/data.json", dataJson.toString());
  320. }
  321. public static Map<String, String> getTypeString(String cameraType, String algorithm, String resolution){
  322. Map<String, String> map = new HashMap<>();
  323. String splitType = "";
  324. String skyboxType = "";
  325. String dataDescribe = "";
  326. if(Integer.parseInt(cameraType) >= 4){
  327. if("0".equals(resolution)){
  328. // skyboxType = "SKYBOX_V4"; //tiles
  329. // skyboxType = "SKYBOX_V6"; //high,low,4k
  330. skyboxType = "SKYBOX_V7"; //high,low,2k
  331. }else {
  332. skyboxType = "SKYBOX_V1";
  333. }
  334. splitType = "SPLIT_V1";
  335. // skyboxType = "SKYBOX_V4"; //tiles
  336. dataDescribe = "double spherical";
  337. if(Integer.parseInt(cameraType) == 5 ){
  338. //新双目相机
  339. // skyboxType = "SKYBOX_V9";
  340. splitType = "SPLIT_V9";
  341. skyboxType = "SKYBOX_V1";
  342. }
  343. if(Integer.parseInt(cameraType) == 6){
  344. //小红屋新双目相机
  345. // skyboxType = "SKYBOX_V9";
  346. splitType = "SPLIT_V3";
  347. skyboxType = "SKYBOX_V7";
  348. }
  349. if(Integer.parseInt(cameraType) == 13){
  350. //转台相机
  351. skyboxType = "SKYBOX_V6";
  352. splitType = "SPLIT_V12";
  353. }
  354. if(Integer.parseInt(cameraType) == 14){
  355. //转台相机
  356. log.info("激光转台相机调用算法");
  357. skyboxType = "SKYBOX_V11";
  358. splitType = "SPLIT_V14";
  359. }
  360. }else {
  361. if("sfm".equals(algorithm)){
  362. splitType = "SPLIT_V2";
  363. skyboxType = "SKYBOX_V1";
  364. dataDescribe = "old sfm";
  365. }else {
  366. splitType = "SPLIT_V3";
  367. skyboxType = "SKYBOX_V1";
  368. dataDescribe = "old slam";
  369. }
  370. }
  371. map.put("splitType", splitType);
  372. map.put("skyboxType", skyboxType);
  373. map.put("dataDescribe", dataDescribe);
  374. return map;
  375. }
  376. // public static SceneEntity createScene(String projectNum, Long cameraId, String cameraName, String phoneId, String scenepsd,
  377. // String unicode, Long cameraType, String fileId, String prefix,
  378. // String imgsName, String pic, String isModel, Long userId, String userName,
  379. // String algorithm, Integer sceneShootCount, String sceneName,
  380. // String sceneDec, Integer sceneType, String gps, ISceneService sceneService,
  381. // Integer type, ModelingMsgProducer producer, String url, String ecsType,
  382. // RubberSheetingUtil rubberSheetingUtil)throws Exception{
  383. // //先返回链接地址
  384. // SceneEntity scene = new SceneEntity();
  385. // scene.setWebSite(url+projectNum);
  386. // scene.setCameraId(cameraId);
  387. // scene.setPhoneId(phoneId);
  388. // scene.setNum(String.valueOf(projectNum));
  389. // if(scenepsd == null)
  390. // {
  391. // scenepsd = "";
  392. // }
  393. // if(!scenepsd.equals(""))
  394. // {
  395. // scene.setSceneKey(scenepsd);
  396. // }
  397. //
  398. // if(!StringUtils.isEmpty(ecsType)){
  399. // scene.setEcs(ecsType);
  400. // }
  401. //
  402. // String path = ConstantFilePath.BUILD_MODEL_PATH + unicode;
  403. //
  404. // if(cameraType.longValue() >= 4){
  405. // scene.setDataSource(ConstantFilePath.BUILD_MODEL_PATH +
  406. // cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode);
  407. // }else {
  408. // scene.setDataSource(prefix+imgsName);
  409. // }
  410. //
  411. // if(cameraType.longValue() == 14){
  412. //
  413. // scene.setDataSource(ConstantFilePath.BUILD_MODEL_LASER_PATH +
  414. // cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator +
  415. // fileId + File.separator + unicode);
  416. //
  417. // log.info("激光相机 dataSource :" + scene.getDataSource());
  418. //
  419. // }
  420. //
  421. //
  422. // if(pic!=null&&pic.length()>5)
  423. // {
  424. // scene.setThumb(pic);
  425. // }
  426. // else
  427. // {
  428. // scene.setThumb(ConstantUrl.DEFAULT_SCENE_PIC);
  429. // }
  430. //
  431. // String parametr = "";
  432. // parametr+=unicode+":;"+path+":;"+prefix+":;"+imgsName+":;"+projectNum+":;"+isModel;
  433. // if(userName!=null&&!userName.trim().equals(""))
  434. // {
  435. // parametr+=":;"+userName;
  436. // scene.setUserId(userId);
  437. // }
  438. // else
  439. // {
  440. // parametr+=":;noMan";
  441. // }
  442. // parametr+=":;"+cameraType;
  443. // parametr+=":;"+algorithm;
  444. // parametr += ":;" + fileId;
  445. // parametr += ":;" + cameraName;
  446. // parametr += ":;1";
  447. // log.info("大场景添加到队列:"+parametr);
  448. // producer.sendMsg(parametr);
  449. //
  450. // if(sceneShootCount == null)
  451. // {
  452. // scene.setShootCount(0);
  453. // }
  454. // else
  455. // {
  456. // scene.setShootCount(sceneShootCount);
  457. // }
  458. // if(sceneName!=null)
  459. // {
  460. // scene.setSceneName(sceneName);
  461. // }
  462. // if(sceneDec!=null)
  463. // {
  464. // scene.setSceneDec("<p>"+sceneDec+"</p>");
  465. // }
  466. //
  467. // if(sceneType!=null)
  468. // {
  469. // scene.setSceneType(sceneType);
  470. // }
  471. //
  472. // if(gps!=null&&!gps.trim().equals(""))
  473. // {
  474. // scene.setGps(gps);
  475. // }
  476. //
  477. // scene.setSceneScheme(cameraType.intValue());
  478. // scene.setAlgorithm(algorithm);
  479. // log.info("场景记录添加到数据库:"+projectNum);
  480. // if(type == 0){
  481. // sceneService.save(scene);
  482. // }
  483. //
  484. // JSONObject scenejson = JSONObject.parseObject(JSONObject.toJSONString(scene));
  485. // scenejson.put("thumbImg", 0);
  486. // scenejson.put("version", 0);
  487. // scenejson.put("floorLogo", 0);
  488. // if(!scenepsd.equals("")){
  489. // scenejson.put("scenePsd", scenepsd);
  490. // scenejson.put("public", 1);
  491. // }else{
  492. // scenejson.put("scenePsd", "");
  493. // scenejson.put("public", 0);
  494. // }
  495. // if(cameraType < 4){
  496. // scenejson.put("visions", 1);
  497. // }else {
  498. // scenejson.put("visions", 2);
  499. // }
  500. // scenejson.put("createTime", new DateTime(new Date()).toString("yyyy-MM-dd HH:mm"));
  501. //
  502. // File file = new File(ConstantFilePath.SCENE_PATH+"data/data"+projectNum);
  503. // if(!file.exists()||!file.isDirectory())
  504. // {
  505. // file.mkdirs();
  506. // }
  507. // FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"scene.json", scenejson.toString());
  508. //
  509. // //生成二维码
  510. // MatrixToImageWriterUtil.createQRCode(url + projectNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+".png", null);
  511. // MatrixToImageWriterUtil.createQRCode(url + projectNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+"_en.png", null);
  512. // log.info("二维码生成完成");
  513. //
  514. // return scene;
  515. // }
  516. public static BuildSceneMqMessage getBuildSceneMqMessage(String projectNum, String cameraName, String unicode, Long cameraType, String fileId,
  517. String prefix, String imgsName, String isModel, String userName,
  518. String algorithm, Integer resolution, String buildType, String path) {
  519. BuildSceneMqMessage mqMsg = new BuildSceneMqMessage();
  520. mqMsg.setSceneNum(projectNum);
  521. mqMsg.setCameraName(cameraName);
  522. mqMsg.setUnicode(unicode);
  523. mqMsg.setCameraType(String.valueOf(cameraType));
  524. mqMsg.setFileId(fileId);
  525. mqMsg.setPrefix(prefix);
  526. mqMsg.setImgsName(imgsName);
  527. mqMsg.setIsModel(isModel);
  528. mqMsg.setUserName(userName);
  529. mqMsg.setAlgorithm(algorithm);
  530. mqMsg.setResolution(String.valueOf(resolution));
  531. mqMsg.setBuildType(buildType);
  532. mqMsg.setPath(path);
  533. return mqMsg;
  534. }
  535. public static String getMQMsg(String projectNum, String cameraName, String unicode, Long cameraType, String fileId,
  536. String prefix, String imgsName, String isModel,String userName,
  537. String algorithm, Integer resolution, String buildType, String path) {
  538. String parametr = "";
  539. parametr+= unicode +":;"+ path +":;"+ prefix +":;"+ imgsName +":;"+ projectNum +":;"+ isModel;
  540. if(userName !=null&&!userName.trim().equals("")){
  541. parametr+=":;"+ userName;
  542. }else{
  543. parametr+=":;noMan";
  544. }
  545. parametr+=":;"+ cameraType;
  546. parametr+=":;"+ algorithm;
  547. parametr += ":;" + fileId;
  548. parametr += ":;" + cameraName;
  549. if(resolution == null){
  550. parametr += ":;0";
  551. }else {
  552. parametr += ":;" + resolution.intValue();
  553. }
  554. if(buildType != null){
  555. parametr += ":;" + buildType;
  556. }
  557. log.info("pro大场景添加到队列:"+parametr);
  558. return parametr;
  559. }
  560. }