123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629 |
- package com.fdkankan.common.util;
- import cn.hutool.core.date.DateUtil;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- //import com.fdkankan.base.mq.ModelingMsgProducer;
- import com.fdkankan.common.constant.ConstantFileName;
- import com.fdkankan.common.constant.ConstantFilePath;
- import com.fdkankan.common.constant.ConstantUrl;
- import com.fdkankan.mq.message.BuildSceneMqMessage;
- import lombok.extern.slf4j.Slf4j;
- import org.joda.time.DateTime;
- import org.springframework.stereotype.Component;
- import org.springframework.util.ObjectUtils;
- import org.springframework.util.StringUtils;
- import java.io.File;
- import java.util.*;
- /**
- * 生成场景和计算场景
- * Created by Hb_zzZ on 2019/5/8.
- */
- @Slf4j
- @Component
- public class ComputerUtil {
- public static Map<String,String> computer(String projectNum, String path, String buildType) throws Exception{
- Map<String,String> map = new HashMap<String,String>();
- path = path.replace("//", "/");
- log.info("开始建模:"+projectNum);
- //构建算法isModel去掉,因此改成空字符串
- if("V2".equals(buildType)){
- CreateObjUtil.build3dModelOld(path, "");
- }
- if("V3".equals(buildType)){
- CreateObjUtil.build3dModel(path, "");
- // CreateObjUtil.build3dModel(unicode, "");
- }
- log.info("建模完成转换数据:"+projectNum);
- boolean vision2 = false;
- //读取upload文件,检验需要上传的文件是否存在
- String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
- JSONObject uploadJson = null;
- JSONArray array = null;
- if(uploadData!=null) {
- uploadJson = JSONObject.parseObject(uploadData);
- array = uploadJson.getJSONArray("upload");
- }
- if(array == null){
- String instanceId = FileUtils.readFile("/opt/hosts/hosts.txt");
- FileUtils.writeFile(path + File.separator + "javaErrorNow.log", instanceId + ":计算错误!");
- Thread.sleep(10000L);
- FileUtils.writeFile(path + File.separator + "javaError.log", instanceId + ":计算错误!");
- throw new Exception("upload.json数据出错");
- }
- JSONObject fileJson = null;
- String fileName = "";
- String meshfix = ""; //双模型时候会有改文件路径
- for(int i = 0, len = array.size(); i < len; i++){
- fileJson = array.getJSONObject(i);
- fileName = fileJson.getString("file");
- //文件不存在抛出异常
- if(!new File(path + File.separator + "results" +File.separator + fileName).exists()){
- throw new Exception(path + File.separator + "results" +File.separator + fileName+"文件不存在");
- }
- //判断是否有vision2.txt
- if("vision2.txt".equals(fileName)){
- vision2 = true;
- }
- //tex文件夹
- if(fileJson.getIntValue("clazz") == 2 && !fileJson.containsKey("pack-file")){
- if(fileName.contains("meshfix.txt")){
- meshfix = fileName;
- }else {
- map.put(path + File.separator + "results" +File.separator+ fileName,"images/images"+
- projectNum+"/"+ ConstantFileName.modelUUID+"_50k_texture_jpg_high1/"+fileName.replace("tex/", ""));
- }
- continue;
- }
- //high文件夹
- if(fileJson.getIntValue("clazz") == 3){
- map.put(path + File.separator + "results" +File.separator+ fileName,"images/images"+
- projectNum+"/pan/high/"+ fileName.replace("high/", ""));
- continue;
- }
- //low文件夹
- if(fileJson.getIntValue("clazz") == 4){
- map.put(path + File.separator + "results" +File.separator+ fileName,"images/images"+
- projectNum+"/pan/low/"+ fileName.replace("low/", ""));
- continue;
- }
- //tiles文件夹,亚马逊没有裁剪图片api,不需要上传4k图
- // if(fileJson.getIntValue("clazz") == 5 && !"s3".equals(ossType)){
- // map.put(path + File.separator + "results" + File.separator+ fileName,"images/images"+
- // projectNum+ File.separator + fileName);
- // continue;
- // }
- if(fileJson.getIntValue("clazz") == 5 ){
- map.put(path + File.separator + "results" + File.separator+ fileName,"images/images"+
- projectNum+ File.separator + fileName);
- continue;
- }
- //tiles文件夹,亚马逊瓦片图
- if(fileJson.getIntValue("clazz") == 7 ){
- if(fileName.contains("/4k_")){
- continue;
- }
- map.put(path + File.separator + "results" + File.separator+ fileName,"images/images"+
- projectNum+ File.separator + fileName);
- continue;
- }
- //updown文件复制一份到ecs中并去掉换行符
- if(fileJson.getIntValue("clazz") == 10){
- String updown = FileUtils.readFile(path + File.separator + "results" +File.separator+ fileName);
- JSONObject updownJson = JSONObject.parseObject(updown);
- FileUtils.writeFile(ConstantFilePath.SCENE_PATH + "data" + File.separator + "data" + projectNum +
- File.separator + fileName.replace("updown", "mapping"), updownJson.toString());
- continue;
- }
- //video视频文件或封面图
- if(fileJson.getIntValue("clazz") == 11 || fileJson.getIntValue("cl" +
- "azz") == 12){
- map.put(path + File.separator + "results" + File.separator+ fileName,"video/video"+
- projectNum+ File.separator + fileName.replace("videos/", ""));
- if(fileName.contains(".mp4")){
- // CreateObjUtil.mp4ToFlv(path + File.separator + "results" + File.separator+ fileName,
- // path + File.separator + "results" + File.separator+ fileName.replace("mp4", "flv"));
- map.put(path + File.separator + "results" + File.separator+ fileName.replace("mp4", "flv"),"video/video"+
- projectNum+ File.separator + fileName.replace("videos/", "").replace("mp4", "flv"));
- }
- }
- //2048的模型和贴图
- if(fileJson.getIntValue("clazz") == 16){
- map.put(path + File.separator + "results" + File.separator+ fileName,"data/data"+
- projectNum+ File.separator + fileName);
- }
- if(fileJson.getIntValue("clazz") == 18){
- map.put(path + File.separator + "results" + File.separator+ fileName,"images/images"+
- projectNum+ File.separator + fileName);
- }
- }
- CreateObjUtil.convertTxtToDam( path + File.separator + "results" + File.separator+"tex"+File.separator+"modeldata.txt", path + File.separator + "results" +File.separator+ ConstantFileName.modelUUID+"_50k.dam");
- CreateObjUtil.convertDamToLzma(path + File.separator + "results");
- CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+"tex"+File.separator+"modeldata.txt", path + File.separator + "results" + File.separator+ConstantFileName.modelUUID+"_50k.dam");
- //有meshfix,表示双模型
- if(!"".equals(meshfix)){
- CreateObjUtil.convertTxtToDam( path + File.separator + "results" + File.separator+meshfix, path + File.separator + "results" +File.separator+ ConstantFileName.modelUUID+"_50k2.dam");
- CreateObjUtil.convertDamToLzma2(path + File.separator + "results");
- CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+meshfix, path + File.separator + "results" + File.separator+ConstantFileName.modelUUID+"_50k2.dam");
- map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k2.dam.lzma", "images/images"+projectNum+"/"+ConstantFileName.modelUUID+"_50k2.dam.lzma");
- map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k2.dam", "images/images"+projectNum+"/"+ConstantFileName.modelUUID+"_50k2.dam");
- }
- //8目相机有两个vision.txt因此第二个叫vision2.txt
- CreateObjUtil.convertTxtToVisionmodeldata(path + File.separator + "results" +File.separator+"vision.txt",path + File.separator + "results" +File.separator+"vision.modeldata");
- if(vision2){
- CreateObjUtil.convertTxtToVisionmodeldata(path + File.separator + "results" +File.separator+"vision2.txt",path + File.separator + "results" +File.separator+"vision2.modeldata");
- map.put(path + File.separator + "results" +File.separator+"vision2.modeldata", "images/images"+projectNum+"/"+"vision2.modeldata");
- }else {
- CreateObjUtil.convertTxtToVisionmodeldataCommon(path + File.separator + "results" +File.separator+"vision.txt",path + File.separator + "results" +File.separator+"vision.modeldata");
- }
- log.info("数据转换完成:"+projectNum);
- File file = new File(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam.lzma");
- while(!file.exists())
- {
- Thread.sleep(60000);
- }
- map.put(path + File.separator + "results" +File.separator+"vision.modeldata", "images/images"+projectNum+"/"+"vision.modeldata");
- map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam.lzma", "images/images"+projectNum+"/"+ConstantFileName.modelUUID+"_50k.dam.lzma");
- map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam", "images/images"+projectNum+"/"+ConstantFileName.modelUUID+"_50k.dam");
- file = new File(ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum);
- if(!file.exists())
- {
- file.mkdir();
- }
- FileUtils.copyFile(path + File.separator + "results" +File.separator+"floor.json", ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum+File.separator+"floor.json", true);
- FileUtils.copyFile(path + File.separator + "results" +File.separator+"floorplan.json", ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum+File.separator+"floor.json", true);
- FileUtils.copyFile(path + File.separator + "results" +File.separator+"floorplan.json", ConstantFilePath.SCENE_PATH+"data"+File.separator+"data"+projectNum+File.separator+"floorplan.json", true);
- log.info("floor.json路径:"+ path + File.separator + "results" +File.separator+"floor.json");
- map.put(path + File.separator + "results" +File.separator+"floor.json","data/data"+projectNum+"/floor.json");
- map.put(path + File.separator + "results" +File.separator+"floorplan.json","data/data"+projectNum+"/floor.json");
- // map.put(path + File.separator + "results" +File.separator+"floorplan_cad.json","data/data"+projectNum+"/house_floor.json");
- map.put(path + File.separator + "results" +File.separator+"floorplan_cad.json","data/data"+projectNum+"/floorplan_cad.json");
- log.info("准备上传文件到oss:"+projectNum);
- return map;
- }
- public static Map<String,String> computerRebuildVideo(String projectNum, String path) throws Exception{
- Map<String,String> map = new HashMap<String,String>();
- path = path.replace("//", "/");
- log.info("开始建模:"+projectNum);
- //构建算法isModel去掉,因此改成空字符串
- CreateObjUtil.build3dModel(path, "");
- log.info("建模完成转换数据:"+projectNum);
- boolean vision2 = false;
- //读取upload文件,检验需要上传的文件是否存在
- String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
- JSONObject uploadJson = null;
- JSONArray array = null;
- if(uploadData!=null) {
- uploadJson = JSONObject.parseObject(uploadData);
- array = uploadJson.getJSONArray("upload");
- }
- if(array == null){
- String instanceId = FileUtils.readFile("/opt/hosts/hosts.txt");
- FileUtils.writeFile(path + File.separator + "javaErrorNow.log", instanceId + ":计算错误!");
- Thread.sleep(10000L);
- FileUtils.writeFile(path + File.separator + "javaError.log", instanceId + ":计算错误!");
- throw new Exception("upload.json数据出错");
- }
- JSONObject fileJson = null;
- String fileName = "";
- for(int i = 0, len = array.size(); i < len; i++) {
- fileJson = array.getJSONObject(i);
- fileName = fileJson.getString("file");
- //文件不存在抛出异常
- if (!new File(path + File.separator + "results" + File.separator + fileName).exists()) {
- throw new Exception(path + File.separator + "results" + File.separator + fileName + "文件不存在");
- }
- //video视频文件或封面图
- if (fileJson.getIntValue("clazz") == 20) {
- if (fileName.contains(".flv")) {
- map.put(path + File.separator + "results" + File.separator + fileName, "video/video" +
- projectNum + File.separator + fileName.replace("videos/", ""));
- }
- if (fileName.contains(".mp4")) {
- map.put(path + File.separator + "results" + File.separator + fileName, "video/video" +
- projectNum + File.separator + fileName.replace("videos/", ""));
- }
- }
- }
- log.info("准备上传文件到oss:"+projectNum);
- return map;
- }
- /**
- * 标定算法
- * @param path
- * @throws Exception
- */
- public static Map<String,String> computerCalibration(String path) throws Exception{
- Map<String,String> map = new HashMap<String,String>();
- log.info("开始标定:" );
- //构建算法isModel去掉,因此改成空字符串
- CreateObjUtil.build3dModel(path, "");
- // CreateObjUtil.build3dModel(unicode, "");
- log.info("标定完成转换数据:" );
- boolean vision2 = false;
- //读取upload文件,检验需要上传的文件是否存在
- String uploadData = FileUtils.readFile(path + File.separator + "results" +File.separator+"upload.json");
- JSONObject uploadJson = null;
- JSONArray array = null;
- if(uploadData!=null) {
- uploadJson = JSONObject.parseObject(uploadData);
- array = uploadJson.getJSONArray("upload");
- }
- if(array == null){
- throw new Exception("upload.json数据出错");
- }
- JSONObject fileJson = null;
- String fileName = "";
- for(int i = 0, len = array.size(); i < len; i++) {
- fileJson = array.getJSONObject(i);
- fileName = fileJson.getString("file");
- //文件不存在抛出异常
- if (!new File(path + File.separator + "results" + File.separator + fileName).exists()) {
- throw new Exception(path + File.separator + "results" + File.separator + fileName + "文件不存在");
- }
- if(fileJson.getIntValue("clazz") == 13 || fileJson.getIntValue("clazz") == 14){
- map.put(path + File.separator + "results" +File.separator+ fileName,
- ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") +
- File.separator + fileName);
- }
- }
- return map;
- }
- //
- public static void createJson(String path, String splitType, String skyboxType, String dataDescribe,
- String sceneNum, String dataSource) throws Exception{
- JSONObject projectJson = new JSONObject();
- projectJson.put("version", "201909231830");
- projectJson.put("protocol", "file api 1.4");
- projectJson.put("uuid", UUID.randomUUID().toString());
- projectJson.put("description", "");
- projectJson.put("time", System.currentTimeMillis());
- projectJson.put("category", "default");
- projectJson.put("tag", null);
- projectJson.put("status", null);
- projectJson.put("sceneNum", sceneNum);
- projectJson.put("dataSource", dataSource);
- FileUtils.writeFile(path + File.separator + "project.json", projectJson.toString());
- JSONObject dataJson = new JSONObject();
- dataJson.put("split_type", splitType);
- dataJson.put("skybox_type", skyboxType);
- dataJson.put("extras", null);
- FileUtils.writeFile(path + File.separator + "data.json", dataJson.toString());
- }
- public static void createExtras(String rebuildParam, String hdrParam, String path) throws Exception {
- FileUtils.writeFile( path + File.separator + "extras" + File.separator + "videos_hdr_param.json", hdrParam);
- FileUtils.writeFile( path + File.separator + "extras" + File.separator + "required_videos.json", rebuildParam);
- }
- public static void createExtras(String rebuildParam,String path) throws Exception {
- FileUtils.writeFile( path + File.separator + "extras" + File.separator + "image-ROI.json", rebuildParam);
- }
- /**
- * 生成标定数据
- * @param calPath
- * @param prefix
- * @throws Exception
- */
- public static void createCalibrationData(String calPath, String prefix) throws Exception{
- File calFile = new File(calPath);
- if(calFile.exists()){
- calFile.mkdirs();
- }
- //删除results和capture文件夹
- FileUtils.deleteDirectory(calPath + "/capture");
- FileUtils.deleteDirectory(calPath + "/results");
- // CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + prefix, calPath + "/capture");
- for(File oldFile : new File(prefix).listFiles()){
- FileUtils.copyFile(oldFile.getAbsolutePath(), calPath + "/capture/" + oldFile.getName(), true);
- }
- JSONObject dataJson = new JSONObject();
- dataJson.put("split_type", "SPLIT_V7");
- dataJson.put("skybox_type", "SKYBOX_V5");
- FileUtils.writeFile(calPath + "/data.json", dataJson.toString());
- }
- public static Map<String, String> getTypeString(String cameraType, String algorithm, String resolution){
- Map<String, String> map = new HashMap<>();
- String splitType = "";
- String skyboxType = "";
- String dataDescribe = "";
- if(Integer.parseInt(cameraType) >= 4){
- if("0".equals(resolution)){
- // skyboxType = "SKYBOX_V4"; //tiles
- // skyboxType = "SKYBOX_V6"; //high,low,4k
- skyboxType = "SKYBOX_V7"; //high,low,2k
- }else {
- skyboxType = "SKYBOX_V1";
- }
- splitType = "SPLIT_V1";
- // skyboxType = "SKYBOX_V4"; //tiles
- dataDescribe = "double spherical";
- if(Integer.parseInt(cameraType) == 5 ){
- //新双目相机
- // skyboxType = "SKYBOX_V9";
- splitType = "SPLIT_V9";
- skyboxType = "SKYBOX_V1";
- }
- if(Integer.parseInt(cameraType) == 6){
- //小红屋新双目相机
- // skyboxType = "SKYBOX_V9";
- splitType = "SPLIT_V3";
- skyboxType = "SKYBOX_V7";
- }
- if(Integer.parseInt(cameraType) == 13){
- //转台相机
- skyboxType = "SKYBOX_V6";
- splitType = "SPLIT_V12";
- }
- if(Integer.parseInt(cameraType) == 14){
- //转台相机
- log.info("激光转台相机调用算法");
- skyboxType = "SKYBOX_V11";
- splitType = "SPLIT_V14";
- }
- }else {
- if("sfm".equals(algorithm)){
- splitType = "SPLIT_V2";
- skyboxType = "SKYBOX_V1";
- dataDescribe = "old sfm";
- }else {
- splitType = "SPLIT_V3";
- skyboxType = "SKYBOX_V1";
- dataDescribe = "old slam";
- }
- }
- map.put("splitType", splitType);
- map.put("skyboxType", skyboxType);
- map.put("dataDescribe", dataDescribe);
- return map;
- }
- // public static SceneEntity createScene(String projectNum, Long cameraId, String cameraName, String phoneId, String scenepsd,
- // String unicode, Long cameraType, String fileId, String prefix,
- // String imgsName, String pic, String isModel, Long userId, String userName,
- // String algorithm, Integer sceneShootCount, String sceneName,
- // String sceneDec, Integer sceneType, String gps, ISceneService sceneService,
- // Integer type, ModelingMsgProducer producer, String url, String ecsType,
- // RubberSheetingUtil rubberSheetingUtil)throws Exception{
- // //先返回链接地址
- // SceneEntity scene = new SceneEntity();
- // scene.setWebSite(url+projectNum);
- // scene.setCameraId(cameraId);
- // scene.setPhoneId(phoneId);
- // scene.setNum(String.valueOf(projectNum));
- // if(scenepsd == null)
- // {
- // scenepsd = "";
- // }
- // if(!scenepsd.equals(""))
- // {
- // scene.setSceneKey(scenepsd);
- // }
- //
- // if(!StringUtils.isEmpty(ecsType)){
- // scene.setEcs(ecsType);
- // }
- //
- // String path = ConstantFilePath.BUILD_MODEL_PATH + unicode;
- //
- // if(cameraType.longValue() >= 4){
- // scene.setDataSource(ConstantFilePath.BUILD_MODEL_PATH +
- // cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator + fileId + File.separator + unicode);
- // }else {
- // scene.setDataSource(prefix+imgsName);
- // }
- //
- // if(cameraType.longValue() == 14){
- //
- // scene.setDataSource(ConstantFilePath.BUILD_MODEL_LASER_PATH +
- // cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator +
- // fileId + File.separator + unicode);
- //
- // log.info("激光相机 dataSource :" + scene.getDataSource());
- //
- // }
- //
- //
- // if(pic!=null&&pic.length()>5)
- // {
- // scene.setThumb(pic);
- // }
- // else
- // {
- // scene.setThumb(ConstantUrl.DEFAULT_SCENE_PIC);
- // }
- //
- // String parametr = "";
- // parametr+=unicode+":;"+path+":;"+prefix+":;"+imgsName+":;"+projectNum+":;"+isModel;
- // if(userName!=null&&!userName.trim().equals(""))
- // {
- // parametr+=":;"+userName;
- // scene.setUserId(userId);
- // }
- // else
- // {
- // parametr+=":;noMan";
- // }
- // parametr+=":;"+cameraType;
- // parametr+=":;"+algorithm;
- // parametr += ":;" + fileId;
- // parametr += ":;" + cameraName;
- // parametr += ":;1";
- // log.info("大场景添加到队列:"+parametr);
- // producer.sendMsg(parametr);
- //
- // if(sceneShootCount == null)
- // {
- // scene.setShootCount(0);
- // }
- // else
- // {
- // scene.setShootCount(sceneShootCount);
- // }
- // if(sceneName!=null)
- // {
- // scene.setSceneName(sceneName);
- // }
- // if(sceneDec!=null)
- // {
- // scene.setSceneDec("<p>"+sceneDec+"</p>");
- // }
- //
- // if(sceneType!=null)
- // {
- // scene.setSceneType(sceneType);
- // }
- //
- // if(gps!=null&&!gps.trim().equals(""))
- // {
- // scene.setGps(gps);
- // }
- //
- // scene.setSceneScheme(cameraType.intValue());
- // scene.setAlgorithm(algorithm);
- // log.info("场景记录添加到数据库:"+projectNum);
- // if(type == 0){
- // sceneService.save(scene);
- // }
- //
- // JSONObject scenejson = JSONObject.parseObject(JSONObject.toJSONString(scene));
- // scenejson.put("thumbImg", 0);
- // scenejson.put("version", 0);
- // scenejson.put("floorLogo", 0);
- // if(!scenepsd.equals("")){
- // scenejson.put("scenePsd", scenepsd);
- // scenejson.put("public", 1);
- // }else{
- // scenejson.put("scenePsd", "");
- // scenejson.put("public", 0);
- // }
- // if(cameraType < 4){
- // scenejson.put("visions", 1);
- // }else {
- // scenejson.put("visions", 2);
- // }
- // scenejson.put("createTime", new DateTime(new Date()).toString("yyyy-MM-dd HH:mm"));
- //
- // File file = new File(ConstantFilePath.SCENE_PATH+"data/data"+projectNum);
- // if(!file.exists()||!file.isDirectory())
- // {
- // file.mkdirs();
- // }
- // FileUtils.writeFile(ConstantFilePath.SCENE_PATH+"data/data"+projectNum+File.separator+"scene.json", scenejson.toString());
- //
- // //生成二维码
- // MatrixToImageWriterUtil.createQRCode(url + projectNum, ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+".png", null);
- // MatrixToImageWriterUtil.createQRCode(url + projectNum + "&lang=en", ConstantFilePath.BASE_PATH + File.separator + "sceneQRcode/"+projectNum+"_en.png", null);
- // log.info("二维码生成完成");
- //
- // return scene;
- // }
- public static BuildSceneMqMessage getBuildSceneMqMessage(String projectNum, String cameraName, String unicode,
- Long cameraType, String fileId,String prefix, String imgsName,
- String isModel, String userName,String algorithm, Integer resolution,
- String buildType, String path, Long sceneProId, String sceneName, String webSite,
- Date sceneProCreateTime, Long userId, String dataSource,
- Integer sceneStatus, Integer PayStatus, String thumb) {
- BuildSceneMqMessage mqMsg = new BuildSceneMqMessage();
- mqMsg.setSceneNum(projectNum);
- mqMsg.setCameraName(cameraName);
- mqMsg.setUnicode(unicode);
- mqMsg.setCameraType(String.valueOf(cameraType));
- mqMsg.setFileId(fileId);
- mqMsg.setPrefix(prefix);
- mqMsg.setImgsName(imgsName);
- mqMsg.setIsModel(isModel);
- mqMsg.setUserName(userName);
- mqMsg.setAlgorithm(algorithm);
- mqMsg.setResolution(String.valueOf(resolution));
- mqMsg.setBuildType(buildType);
- mqMsg.setPath(path);
- mqMsg.setSceneName(sceneName);
- mqMsg.setWebSite(webSite);
- mqMsg.setSceneProCreateTime(sceneProCreateTime);
- mqMsg.setUserId(userId);
- mqMsg.setDataSource(dataSource);
- mqMsg.setSceneStatus(sceneStatus);
- mqMsg.setPayStatus(PayStatus);
- mqMsg.setCreateTime(DateUtil.format(Calendar.getInstance().getTime(), DateExtUtil.dateStyle));
- return mqMsg;
- }
- public static String getMQMsg(String projectNum, String cameraName, String unicode, Long cameraType, String fileId,
- String prefix, String imgsName, String isModel,String userName,
- String algorithm, Integer resolution, String buildType, String path) {
- String parametr = "";
- parametr+= unicode +":;"+ path +":;"+ prefix +":;"+ imgsName +":;"+ projectNum +":;"+ isModel;
- if(userName !=null&&!userName.trim().equals("")){
- parametr+=":;"+ userName;
- }else{
- parametr+=":;noMan";
- }
- parametr+=":;"+ cameraType;
- parametr+=":;"+ algorithm;
- parametr += ":;" + fileId;
- parametr += ":;" + cameraName;
- if(resolution == null){
- parametr += ":;0";
- }else {
- parametr += ":;" + resolution.intValue();
- }
- if(buildType != null){
- parametr += ":;" + buildType;
- }
- log.info("pro大场景添加到队列:"+parametr);
- return parametr;
- }
- }
|