Commit ee6bf74d authored by hanson.yao's avatar hanson.yao

develop 3d view

parent 9a2c6e4b
......@@ -9,7 +9,7 @@ Catia.Transfer.B3d.port=8081
Catia.Transfer.B3d.targetNameSpace=www.ptc.com/ws
Catia.Transfer.B3d.serviceName=ConvertModel2B3dService
#For FTP Config
Catia.ftp.host=192.168.1.235
Catia.ftp.host=192.168.1.177
Catia.ftp.port=21
Catia.ftp.username=ftpuser
Catia.ftp.password=Aa12345678!
......
......@@ -3,17 +3,13 @@ package com.yonde.cadpro.checker.impl;
import com.yonde.cadpro.checker.AbstractCADProChecker;
import com.yonde.cadpro.config.CADProConfigPropertiesUtil;
import com.yonde.cadpro.util.CADProUtil;
import org.apache.log4j.Logger;
import wt.fc.WTObject;
import wt.log4j.LogR;
import java.util.ArrayList;
import java.util.List;
public class DICOpenChecker extends AbstractCADProChecker {
private static final Logger log = LogR.getLogger(DICOpenChecker.class.getName());
@Override
public List<WTObject> check(List<String> ids) throws Exception {
//必选校验
......
......@@ -5,10 +5,8 @@ import com.yonde.cadpro.checker.AbstractCADProChecker;
import com.yonde.cadpro.config.CADProConfigPropertiesUtil;
import com.yonde.cadpro.util.EPMUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import wt.epm.EPMDocument;
import wt.fc.WTObject;
import wt.log4j.LogR;
import wt.part.WTPart;
import wt.util.WTException;
......@@ -16,7 +14,6 @@ import java.util.ArrayList;
import java.util.List;
public class NewOpenChecker extends AbstractCADProChecker {
private static final Logger log = LogR.getLogger(NewOpenChecker.class.getName());
@Override
public List<WTObject> check(List<String> ids) throws Exception {
......
package com.yonde.cadpro.config;
/**
* Created on 2023/5/5 0005
* <p>
* * #For FTP Config
*
* @author
*/
public class CadFTPConfig {
public static final String HOST = "192.168.1.240";
public static final Integer PORT = 21;
public static final String USERNAME = "ftpuser";
public static final String PASSWORD = "Aa12345678!";
public static final String REMOTEPATH = "/";
public static final String ROOTPATH = "D:/Inetpub/ftproot";
public static final String VISUALIZATIONPATH = "D:/Inetpub/ftproot/Visualization";
public static final String TRANSFERRESULTPATH = "D:/Inetpub/ftproot/3D_transfer_result";
}
......@@ -536,7 +536,6 @@ public class CadCheckService implements RemoteAccess {
searchUtil.setConfigSpec(new LatestConfigSpec());
QueryResult epmQr = searchUtil.queryObjects();
//epmQr = filterIterationsByModifyTime(epmQr);
if (epmQr != null && epmQr.hasMoreElements()) {
epm = (EPMDocument) epmQr.nextElement();
}
......@@ -558,7 +557,6 @@ public class CadCheckService implements RemoteAccess {
}
if (!isIngoreUpdate) {
//已存在,校验EPM是否被当前用户检出
System.out.println("EPM已经存在");
if (CommonUtil.isCheckedOut(epm)) {
if (!CommonUtil.isCheckedOut(epm, null)) {
WTPrincipal checkoutUser = null;
......
......@@ -7,7 +7,6 @@ import com.yonde.cadpro.bean.MBDAttribute;
import com.yonde.cadpro.bean.MBDAttributes;
import com.yonde.cadpro.bean.MaterialUsedRDefinitionBean;
import com.yonde.cadpro.bean.ModelBaseInfo;
import com.yonde.cadpro.config.CadFTPConfig;
import com.yonde.cadpro.config.CatiaClientConfig;
import com.yonde.cadpro.config.CatiaInteConfigPropertiesUtil;
import com.yonde.cadpro.util.*;
......@@ -1160,8 +1159,12 @@ public class ModelService {
remotePath = remotePath.substring(0, remotePath.lastIndexOf("/"));
System.out.println("remotePath : " + remotePath);
ExtProperties catiaTransferConfig = VisualizationFacade.catiaTransferConfig;
FTPOperation ftpOperation = new FTPOperation();
boolean connect = ftpOperation.connect(CadFTPConfig.HOST, CadFTPConfig.PORT, CadFTPConfig.USERNAME, CadFTPConfig.PASSWORD);
boolean connect = ftpOperation.connect(catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_HOST),
Integer.valueOf(catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PORT)),
catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_USERNAME),
catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PASSWORD));
if (!connect) {
throw new WTException("FTP连接失败,请重试或联系系统管理员。");
}
......@@ -2676,9 +2679,12 @@ public class ModelService {
String remotePath = FilenameUtils.getFullPath(modelFileUri);
System.out.println("remotePath : " + remotePath);
ExtProperties catiaTransferConfig = VisualizationFacade.catiaTransferConfig;
FTPOperation ftpOperation = new FTPOperation();
boolean connect = ftpOperation.connect(CadFTPConfig.HOST, CadFTPConfig.PORT, CadFTPConfig.USERNAME, CadFTPConfig.PASSWORD);
boolean connect = ftpOperation.connect(catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_HOST),
Integer.valueOf(catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PORT)),
catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_USERNAME),
catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PASSWORD));
if (!connect) {
throw new WTException("FTP连接失败,请重试或联系系统管理员。");
......@@ -2734,10 +2740,12 @@ public class ModelService {
throw new WTException("modelFileUri[" + modelFileUri + "] must catzip format");
}
ExtProperties catiaTransferConfig = VisualizationFacade.catiaTransferConfig;
FTPOperation ftpOperation = new FTPOperation();
boolean connect = ftpOperation.connect(CadFTPConfig.HOST, CadFTPConfig.PORT, CadFTPConfig.USERNAME, CadFTPConfig.PASSWORD);
boolean connect = ftpOperation.connect(catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_HOST),
Integer.valueOf(catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PORT)),
catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_USERNAME),
catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PASSWORD));
if (!connect) {
throw new WTException("FTP连接失败,请重试或联系系统管理员。");
}
......@@ -2792,7 +2800,9 @@ public class ModelService {
String remotePath = FilenameUtils.getFullPath(modelFileUri);
System.out.println("remotePath : " + remotePath);
String absoluteRootPath = CadFTPConfig.ROOTPATH;
String absoluteRootPath = CatiaInteConfigPropertiesUtil.getFtpRootPath();;
absoluteRootPath = absoluteRootPath.replace("\\", "/");
if (absoluteRootPath.endsWith("/")) {
absoluteRootPath.substring(0, absoluteRootPath.length() - 1);
......@@ -2890,8 +2900,12 @@ public class ModelService {
modelThumbnailName = modelThumbnailName + "." + extension;
}
ExtProperties catiaTransferConfig = VisualizationFacade.catiaTransferConfig;
FTPOperation ftpOperation = new FTPOperation();
boolean connect = ftpOperation.connect(CadFTPConfig.HOST, CadFTPConfig.PORT, CadFTPConfig.USERNAME, CadFTPConfig.PASSWORD);
boolean connect = ftpOperation.connect(catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_HOST),
Integer.valueOf(catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PORT)),
catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_USERNAME),
catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PASSWORD));
if (!connect) {
......@@ -2930,7 +2944,7 @@ public class ModelService {
String remotePath = FilenameUtils.getFullPath(modelFileUri);
System.out.println("remotePath : " + remotePath);
String absoluteRootPath = CadFTPConfig.ROOTPATH;
String absoluteRootPath = CatiaInteConfigPropertiesUtil.getFtpRootPath();;
absoluteRootPath = absoluteRootPath.replace("\\", "/");
if (absoluteRootPath.endsWith("/")) {
absoluteRootPath.substring(0, absoluteRootPath.length() - 1);
......
......@@ -100,10 +100,12 @@ public class PartVisService implements RemoteAccess {
*/
public static DxCADBomVo expandCADBom(String oid, String userName) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxCADBomVo) RemoteMethodServer.getDefault().invoke("expandCADBom", PartVisService.class.getName(), null,
Object obj = RemoteMethodServer.getDefault().invoke("expandCADBom", PartVisService.class.getName(), null,
new Class[]{String.class, String.class},
new Object[]{oid, userName});
return obj == null ? null : (DxCADBomVo) obj;
} else {
DxCADBomVo rootVo = null;
oid = WTPARTIDPREFIX + oid;
System.out.println(">>>expandCADBom oid:" + oid + " userName:" + userName);
boolean enforced = true;
......@@ -121,7 +123,6 @@ public class PartVisService implements RemoteAccess {
} else if (per instanceof EPMDocument) {
rootEPM = (EPMDocument) per;
}
DxCADBomVo rootVo = null;
if (rootEPM != null) {
System.out.println("process rootEPM : " + rootEPM.getDisplayIdentifier());
Matrix4d rootMatrix = calculateMatrixByAssembleTransformInfo2(null, null);
......@@ -132,11 +133,11 @@ public class PartVisService implements RemoteAccess {
rootVo.setTransform(trans);
}
}
return rootVo;
} catch (Exception e) {
throw new WTException(e);
e.printStackTrace();
} finally {
SessionServerHelper.manager.setAccessEnforced(enforced);
return rootVo;
}
}
}
......@@ -158,8 +159,7 @@ public class PartVisService implements RemoteAccess {
EPMDocConfigSpec epmDocConfigSpec = new EPMDocConfigSpec();
epmDocConfigSpec.setLatestActive();
QueryResult qr = StructHelper.service.navigateUsesToIteration(epmDoc,
EPMMemberLink.class, false, epmDocConfigSpec);
QueryResult qr = StructHelper.service.navigateUsesToIteration(epmDoc, EPMMemberLink.class, false, epmDocConfigSpec);
if (qr != null) {
while (qr.hasMoreElements()) {
Persistable[] pp = (Persistable[]) qr.nextElement();
......@@ -167,15 +167,13 @@ public class PartVisService implements RemoteAccess {
Persistable per = pp[1];
if (per instanceof EPMDocument) {
EPMDocument childEPM = (EPMDocument) per;
System.out.println("put memberLink[" + memberLink + "] = childEPM["
+ childEPM.getDisplayIdentity() + "] to allChildsWithLink...");
System.out.println("put memberLink[" + memberLink + "] = childEPM[" + childEPM.getDisplayIdentity() + "] to allChildsWithLink...");
childEPM = assemblyOriginal(childEPM);
allChildsWithLink.put(memberLink, childEPM);
if (!allChilds.contains(childEPM)) {
System.out.println("add childEPM[" + childEPM.getDisplayIdentity()
+ "] to allChilds...");
System.out.println("add childEPM[" + childEPM.getDisplayIdentity() + "] to allChilds...");
allChilds.add(childEPM);
}
} else if (per instanceof EPMDocumentMaster) {
......@@ -195,14 +193,12 @@ public class PartVisService implements RemoteAccess {
appendEPMInfo(cadStructureBuilder, childEPM);
}
String cadStructureKey = cadStructureBuilder.toString();
AssembleTransformSnapshot snapshot = getAssembleTransformSnapshotByStructure(
cadStructureKey, epmDoc);
AssembleTransformSnapshot snapshot = getAssembleTransformSnapshotByStructure(cadStructureKey, epmDoc);
Set<EPMMemberLink> allMemberlinks = allChildsWithLink.keySet();
for (EPMMemberLink epmMemberLink : allMemberlinks) {
EPMDocument linkedChildEPM = allChildsWithLink.get(epmMemberLink);
System.out.println("process epmMemberLink : " + epmMemberLink + ", linkedChildEPM : "
+ linkedChildEPM);
System.out.println("process epmMemberLink : " + epmMemberLink + ", linkedChildEPM : " + linkedChildEPM);
DxCADBomVo childVo = null;
Matrix4d calculateMatrix = null;
......@@ -463,7 +459,6 @@ public class PartVisService implements RemoteAccess {
try {
int structureKeyHash = cadStructureKey.hashCode();
System.out.println("structureKeyHash : " + structureKeyHash);
assembleTransformSnapshot = AssembleTransformUtil.findAssembleTransformSnapshot(EPMUtil.getOROid(parentEPM), structureKeyHash);
System.out.println("assembleTransformSnapshot by structureKeyHash[" + structureKeyHash + "]:" + assembleTransformSnapshot);
......
......@@ -443,12 +443,9 @@ public class CADProUtil {
*/
public static Map<String, String> getCADProIbaMapping() {
try {
String mappingFile = CADProConstants.wthome + CAD_PRO_IBA_MAPPING_FILE;
log.debug("mappingFile : " + mappingFile);
String jsonStr = FileUtils.readFileToString(new File(mappingFile), "UTF-8");
return (Map<String, String>) JSONObject.parseObject(jsonStr, Map.class);
} catch (Exception e) {
log.error("getCADProIbaMapping error...", e);
}
......
This diff is collapsed.
......@@ -11,6 +11,7 @@ import wt.util.WTException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
......@@ -33,16 +34,19 @@ public class AssembleTransformUtil {
}
StringBuffer sql = new StringBuffer("select * from ASSEMBLETRANSFORMSNAPSHOT ast where 1 =1 ");
if (StringUtils.isNotBlank(parentId)) {
sql.append("and PARENTID = " + parentId);
sql.append("and PARENTID = '" + parentId + "' ");
}
if (snapshotHash != 0) {
sql.append("and SNAPSHOTHASH = '" + snapshotHash+"' ");
sql.append("and SNAPSHOTHASH = '" + snapshotHash + "' ");
}
System.out.println(">>>findAssembleTransformSnapshot sql:" + sql);
Object obj = DBUtil.queryForObject(sql.toString(), AssembleTransformSnapshot.class);
Object obj = DBUtil.queryForMap(sql.toString());
if (obj != null) {
return (AssembleTransformSnapshot) obj;
System.out.println(">>>findAssembleTransformSnapshot map:" + obj);
return new AssembleTransformSnapshot((Map<String, Object>)obj);
} else {
System.out.println(">>>findAssembleTransformSnapshot map is null");
return null;
}
}
......
package com.yonde.cadpro.visualization.coordinate;
import java.io.Serializable;
import java.util.Map;
/**
* @description: 装配矩阵关系对象,用于保存装配的装配关系各模型版本快照
......@@ -22,6 +23,16 @@ public class AssembleTransformSnapshot implements Serializable {
*/
private String snapshotHash;
public AssembleTransformSnapshot(Map<String,Object> map) {
if (!map.isEmpty()){
this.id = String.valueOf(map.get("id"));
this.parentId = String.valueOf(map.get("parentId"));
this.snapshotHash = String.valueOf(map.get("snapshotHash"));
}else {
new AssembleTransformSnapshot();
}
}
public String getId() {
return id;
}
......
......@@ -10,7 +10,6 @@ import com.yonde.cadpro.visualization.catia.xmlb3dbean.B3dRoot;
import com.yonde.cadpro.visualization.catia.xmlb3dbean.B3dStructer;
import com.yonde.cadpro.visualization.coordinate.AssembleTransformInfo;
import com.yonde.cadpro.visualization.coordinate.AssembleTransformSnapshot;
import com.yonde.common.CommonUtil;
import com.yonde.common.RfUtil;
import com.yonde.doc.entity.WsResult;
import org.apache.commons.io.FileUtils;
......@@ -96,17 +95,15 @@ public class VisualizationService {
//1. 下载文件至临时目录
String uuidStr = UUID.randomUUID().toString();
//pdm临时目录
String tempFolderPath = CADProConstants.wttemp + catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_TEMPFOLDERPATH) + uuidStr + "/";
tempFolderPath = tempFolderPath.replace("\\", "/");
System.out.println("tempFolderPath : " + tempFolderPath);
File tempFolder = new File(tempFolderPath);
if (!tempFolder.exists()) {
tempFolder.mkdirs();
}
File appDataFile = ContentUtil.downloadApplicationData(appData, tempFolderPath, "", contentHolder);
System.out.println("appDataFile : " + appDataFile);
List<File> uploadFiles = new ArrayList<File>();
if (!transferModel) {
......@@ -119,38 +116,30 @@ public class VisualizationService {
retriveChildrenAppDataFiles(rootEpm, childrenAppDataFiles, tempFolderPath);
uploadFiles.addAll(childrenAppDataFiles);
}
System.out.println("uploadFiles : " + uploadFiles);
//2. 上传至FTP目录
//2. 上传worker机至FTP目录
FtpUtil ftpUtil = new FtpUtil(catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_HOST),
Integer.valueOf(catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PORT)),
catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_USERNAME),
catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PASSWORD));
if (!ftpUtil.connectServer()) {
throw new WTException("FTP连接失败,请重试或联系系统管理员。");
}
String ftpRemoteFolder = "";
if (transferModel) {
ftpRemoteFolder = catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_TEMPFOLDERPATH) + uuidStr + "/";
}
ftpRemoteFolder = ftpRemoteFolder.replace("\\", "/");
System.out.println("ftpRemoteFolder : " + ftpRemoteFolder);
ftpUtil.uploadFile(ftpRemoteFolder, uploadFiles);
ftpUtil.closeServer();
String remoteFilePath = ftpRemoteFolder + appDataFile.getName();
remoteFilePath = remoteFilePath.replace("\\", "/");
System.out.println("remoteFilePath :" + remoteFilePath);
//此处的文件路径为worker机catia.zip的路径
//3. 调用转可视化服务
//3. 调用worker机转可视化服务
WsResult wsResult = null;
if (contentHolder instanceof EPMDocument) {
//处理三维可视化
wsResult = new ConvertCatia2B3dUtil(catiaTransferConfig).convert(remoteFilePath);
}
......@@ -161,7 +150,6 @@ public class VisualizationService {
if (wsResult.isResult()) {
transformedFileRemotePath = wsResult.getInfo();
transformedFileRemotePath = transformedFileRemotePath.replace("\\", "/");
System.out.println("transformedFileRemotePath :" + transformedFileRemotePath);
String transformedFtpFullPath = "";
if (!transferModel) {
......@@ -174,7 +162,6 @@ public class VisualizationService {
}
}
transformedFtpFullPath = transformedFtpFullPath.replace("\\", "/");
System.out.println("transformedFtpFullPath :" + transformedFtpFullPath);
if (StringUtils.isBlank(transformedFtpFullPath)) {
throw new WTException("获取可视化转换文件失败");
......@@ -190,7 +177,7 @@ public class VisualizationService {
}
System.out.println("transformedFtpPath :" + transformedFtpPath);
System.out.println("transformedFileName :" + transformedFileName);
//woker机b3d转换完成后将文件通过ftp下载到pdm codebase/tempDownload/时间戳/ 文件夹下
//worker机b3d转换完成后将文件通过ftp下载到pdm codebase/tempDownload/时间戳/ 文件夹下
ftpUtil = new FtpUtil(
VisualizationFacade.catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_HOST),
Integer.valueOf(VisualizationFacade.catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PORT)),
......@@ -255,10 +242,8 @@ public class VisualizationService {
String b3dFilePath = part.getFilePath();
b3dFilePath = tempFolderPath + b3dFilePath;
System.out.println("b3dFilePath : " + b3dFilePath);
String transform = StringUtils.trimToEmpty(part.getRelativeTransform());
System.out.println("transform : " + transform);
Set<String> b3ds = numberVisMap.get(cadNumber);
if (b3ds == null) {
b3ds = new HashSet<String>();
......@@ -407,7 +392,7 @@ public class VisualizationService {
}
}
if (snapshot == null) {
snapshot = AssembleTransformUtil.newAssembleTransformSnapshot(CommonUtil.getPersistableOid(rootCAD), cadStructureKey);
snapshot = AssembleTransformUtil.newAssembleTransformSnapshot( EPMUtil.getOROid(rootCAD), String.valueOf(structureKeyHash));
}
if (snapshot != null) {
Set<EPMMemberLink> allMembership = memberLinkWithTrasform
......@@ -582,6 +567,11 @@ public class VisualizationService {
try {
FileUtils.cleanDirectory(tempFolder);
FileUtils.deleteQuietly(tempFolder);
File xmlFile = new File(downloadFile);
if (xmlFile.exists()){
FileUtils.cleanDirectory(xmlFile.getParentFile());
FileUtils.deleteQuietly(xmlFile.getParentFile());
}
} catch (Exception e) {
logger.error("Delete tempFolder[" + tempFolder + "] error...", e);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment