ComputerUtil.java 28 KB

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