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);
}
......
......@@ -15,20 +15,20 @@ import java.util.Map;
* 用于Oracle数据库操作
*/
public class DBUtil {
public static WTConnection getWtConnection() {
System.out.println("------ begin get connection");
try {
try {
WTConnection conn = (WTConnection) MethodContext.getContext().getConnection();
return conn;
} catch (Exception e) {
System.out.println("获取数据库连接失败"+ e);
System.out.println("获取数据库连接失败" + e);
}
return null;
}
public static void freeWTConnection(WTConnection wtconnection) {
System.out.println("------ begin free connection");
System.out.println("------ begin free connection");
if (!wtconnection.isTransactionActive()) {
MethodContext.getContext().freeConnection();
}
......@@ -48,8 +48,7 @@ public class DBUtil {
* 执行SQL语句
*
* @param sql
* @param parameters
* 参数
* @param parameters 参数
* @return
*/
public static int executeUpdate(String sql, Object[] parameters) {
......@@ -67,7 +66,7 @@ public class DBUtil {
transaction = null;
return result;
} catch (SQLException e) {
System.out.println("执行sql语句错误:" + sql+" errorMsg: "+e);
System.out.println("执行sql语句错误:" + sql + " errorMsg: " + e);
} finally {
if (stmt != null)
con.freeStatement(sql, stmt, true);
......@@ -78,7 +77,7 @@ public class DBUtil {
}
}
} catch (Exception e) {
System.out.println("执行sql语句错误:" + sql+" errorMsg: "+e);
System.out.println("执行sql语句错误:" + sql + " errorMsg: " + e);
}
return -1;
}
......@@ -142,7 +141,7 @@ public class DBUtil {
stmt = conn.prepareStatement(sql);
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<String, Object>();
ResultSetMetaData meta = rs.getMetaData();
for (int i = 1; i <= meta.getColumnCount(); i++) {
......@@ -152,7 +151,7 @@ public class DBUtil {
}
} catch (SQLException e) {
System.out.println("执行sql语句错误:" + sql+" errorMsg: "+e);
System.out.println("执行sql语句错误:" + sql + " errorMsg: " + e);
return null;
} finally {
if (stmt != null)
......@@ -169,7 +168,7 @@ public class DBUtil {
*/
public static List<Map<String, Object>> queryForList(String sql) {
WTConnection conn = getWtConnection();
System.out.println("------ get a connection : "+conn);
System.out.println("------ get a connection : " + conn);
if (conn != null) {
return queryForList(conn, sql);
}
......@@ -208,7 +207,7 @@ public class DBUtil {
}
} catch (SQLException e) {
System.out.println("执行sql语句错误:" + sql+" errorMsg: "+e);
System.out.println("执行sql语句错误:" + sql + " errorMsg: " + e);
} finally {
if (stmt != null)
conn.freeStatement(sql, stmt, true);
......@@ -233,7 +232,7 @@ public class DBUtil {
}
} catch (SQLException e) {
System.out.println("执行sql语句错误:" + sql+" errorMsg: "+e);
System.out.println("执行sql语句错误:" + sql + " errorMsg: " + e);
return 0;
} finally {
if (stmt != null)
......@@ -266,11 +265,11 @@ public class DBUtil {
ResultSet rs = stmt.executeQuery();
if (rs.next()) {
Object obj = rs.getObject(1);
if(clazz.isInstance(obj)) return obj;
if (clazz.isInstance(obj)) return obj;
}
} catch (SQLException e) {
System.out.println("执行sql语句错误:" + sql+" errorMsg: "+e);
System.out.println("执行sql语句错误:" + sql + " errorMsg: " + e);
return null;
} finally {
if (stmt != null)
......@@ -295,14 +294,15 @@ public class DBUtil {
/**
* query for object list.
*
* @param sql
* @param parameters
* @return
*/
public static List<Object> queryForObjectList(String sql,Object[] parameters) {
public static List<Object> queryForObjectList(String sql, Object[] parameters) {
WTConnection conn = getWtConnection();
if (conn != null) {
return queryForObjectList(conn, sql,parameters);
return queryForObjectList(conn, sql, parameters);
}
return new ArrayList<Object>();
}
......@@ -313,27 +313,27 @@ public class DBUtil {
* @param sql
* @return
*/
public static List<Object> queryForObjectList(WTConnection conn,String sql,Object[] parameters) {
PreparedStatement stmt = null;
List<Object> ResultList = new ArrayList<Object>();
try {
if (parameters == null){
stmt = conn.prepareStatement(sql);
}else{
stmt = prepareStatement(sql,parameters,conn);
}
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
ResultList.add(rs.getObject(1));
}
rs.close();
} catch (SQLException e) {
System.out.println("执行sql语句错误:" + sql+" errorMsg: "+e);
} finally {
if (stmt != null)
conn.freeStatement(sql, stmt, true);
public static List<Object> queryForObjectList(WTConnection conn, String sql, Object[] parameters) {
PreparedStatement stmt = null;
List<Object> ResultList = new ArrayList<Object>();
try {
if (parameters == null) {
stmt = conn.prepareStatement(sql);
} else {
stmt = prepareStatement(sql, parameters, conn);
}
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
ResultList.add(rs.getObject(1));
}
return ResultList;
rs.close();
} catch (SQLException e) {
System.out.println("执行sql语句错误:" + sql + " errorMsg: " + e);
} finally {
if (stmt != null)
conn.freeStatement(sql, stmt, true);
}
return ResultList;
}
/**
......@@ -343,7 +343,7 @@ public class DBUtil {
* @return
*/
public static List<Object> queryForObjectList(WTConnection conn, String sql) {
return queryForObjectList(conn,sql,null);
return queryForObjectList(conn, sql, null);
}
/**
......@@ -352,7 +352,7 @@ public class DBUtil {
* @param sequence
* @return
*/
public static int getSequenceNextValue(String sequence){
public static int getSequenceNextValue(String sequence) {
return queryForInt("select " + sequence + ".nextval seq from dual");
}
......@@ -361,7 +361,7 @@ public class DBUtil {
*
* @param sequence
*/
public static void forceSequenceExist(String sequence){
public static void forceSequenceExist(String sequence) {
if (queryForInt("select count(*) from user_sequences where sequence_name = '" + sequence.toUpperCase() + "'") <= 0) {
executeUpdate("create sequence " + sequence);
}
......@@ -375,7 +375,7 @@ public class DBUtil {
* @param end
* @return
*/
public static String getPagingSql(String sql, int begin, int end){
public static String getPagingSql(String sql, int begin, int end) {
return "select * from (select rownum row_,t.*,count(*)over() total_ from (" + sql + ") t) where row_>" + begin
+ " and row_<" + (end + 1);
}
......@@ -388,7 +388,7 @@ public class DBUtil {
* @param end
* @return
*/
public static List<Map<String, Object>> getPagingList(String sql, int begin, int end){
public static List<Map<String, Object>> getPagingList(String sql, int begin, int end) {
// int count = queryForInt("select count(*) from (" + sql + ")");
// if (count < begin)
// begin = count - count % (end - begin);
......@@ -400,100 +400,103 @@ public class DBUtil {
// }
return queryForList(getPagingSql(sql, begin, end));
}
/**分页之后,获取结果集中的总条数
* @param resultList
* @return
*/
public static int getTotalByResultList(List<Map<String, Object>> resultList){
if(resultList.isEmpty()){
return 0;
}
Map<String, Object> key2ValueMap = resultList.get(0);
return Integer.valueOf(key2ValueMap.get("total_").toString());
}
//-----------------------------------------------------------------------------------------------------
public static PreparedStatement getPreparedStatement(String sql, List<Object> objList, WTConnection wtConnection) throws SQLException{
PreparedStatement preparedStatement = wtConnection.prepareStatement(sql);
/**
* 分页之后,获取结果集中的总条数
*
* @param resultList
* @return
*/
public static int getTotalByResultList(List<Map<String, Object>> resultList) {
if (resultList.isEmpty()) {
return 0;
}
Map<String, Object> key2ValueMap = resultList.get(0);
return Integer.valueOf(key2ValueMap.get("total_").toString());
}
//-----------------------------------------------------------------------------------------------------
public static PreparedStatement getPreparedStatement(String sql, List<Object> objList, WTConnection wtConnection) throws SQLException {
PreparedStatement preparedStatement = wtConnection.prepareStatement(sql);
for (int index = 1, size = objList.size(); index <= size; index++) {
Object obj = objList.get(index - 1);
if (obj instanceof String) {
preparedStatement.setString(index, (String) obj);
}else if (obj instanceof Date) {
preparedStatement.setDate(index, (Date) obj);
}else if (obj instanceof Integer) {
preparedStatement.setInt(index, ((Integer) obj).intValue());
}else if (obj instanceof Double) {
preparedStatement.setDouble(index, ((Double) obj).doubleValue());
}else if (obj instanceof Long) {
preparedStatement.setLong(index, ((Long) obj).longValue());
}else if (obj instanceof BigDecimal) {
preparedStatement.setBigDecimal(index, ((BigDecimal) obj));
}
preparedStatement.setString(index, (String) obj);
} else if (obj instanceof Date) {
preparedStatement.setDate(index, (Date) obj);
} else if (obj instanceof Integer) {
preparedStatement.setInt(index, ((Integer) obj).intValue());
} else if (obj instanceof Double) {
preparedStatement.setDouble(index, ((Double) obj).doubleValue());
} else if (obj instanceof Long) {
preparedStatement.setLong(index, ((Long) obj).longValue());
} else if (obj instanceof BigDecimal) {
preparedStatement.setBigDecimal(index, ((BigDecimal) obj));
}
}
return preparedStatement;
}
public static List<Map<String, Object>> getResultListByQuery(String sql, List<Object> objList){
List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
}
public static List<Map<String, Object>> getResultListByQuery(String sql, List<Object> objList) {
List<Map<String, Object>> resultList = new ArrayList<Map<String, Object>>();
PreparedStatement prepareStatement = null;
WTConnection wtConnection = null;
try {
wtConnection = getWtConnection();
wtConnection = getWtConnection();
prepareStatement = getPreparedStatement(sql, objList, wtConnection);
ResultSet rs = prepareStatement.executeQuery();
List<String> columnNameList = null;
Map<String, Object> resultMap = null;
while (rs.next()) {
columnNameList = new ArrayList<String>();
ResultSetMetaData meta = rs.getMetaData();
for (int index = 1, size = meta.getColumnCount(); index <= size; index++) {
columnNameList.add(meta.getColumnName(index).toLowerCase());
}
resultMap = new HashMap<String, Object>();
for (String columnName : columnNameList) {
resultMap.put(columnName, rs.getObject(columnName));
}
resultList.add(resultMap);
columnNameList = new ArrayList<String>();
ResultSetMetaData meta = rs.getMetaData();
for (int index = 1, size = meta.getColumnCount(); index <= size; index++) {
columnNameList.add(meta.getColumnName(index).toLowerCase());
}
resultMap = new HashMap<String, Object>();
for (String columnName : columnNameList) {
resultMap.put(columnName, rs.getObject(columnName));
}
resultList.add(resultMap);
}
} catch (SQLException e) {
System.out.println("执行sql语句错误:" + sql+" errorMsg: "+e);
System.out.println("执行sql语句错误:" + sql + " errorMsg: " + e);
} finally {
wtConnection.freeStatement(sql, prepareStatement, true);
wtConnection.freeStatement(sql, prepareStatement, true);
}
return resultList;
}
public static List<Map<String, String>> getStringResultListByQuery(String sql, List<Object> objList){
List<Map<String, String>> resultList = new ArrayList<Map<String, String>>();
List<Map<String, Object>> list = getResultListByQuery(sql,objList);
for(Map<String,Object> row:list) {
Map<String,String> map = new HashMap<String,String>();
for(String key: row.keySet()) {
Object obj = row.get(key);
map.put(key, obj==null?"":obj.toString());
}
resultList.add(map);
}
return resultList;
}
public static Integer getCountByQuery(String sql, List<Object> objList){
}
public static List<Map<String, String>> getStringResultListByQuery(String sql, List<Object> objList) {
List<Map<String, String>> resultList = new ArrayList<Map<String, String>>();
List<Map<String, Object>> list = getResultListByQuery(sql, objList);
for (Map<String, Object> row : list) {
Map<String, String> map = new HashMap<String, String>();
for (String key : row.keySet()) {
Object obj = row.get(key);
map.put(key, obj == null ? "" : obj.toString());
}
resultList.add(map);
}
return resultList;
}
public static Integer getCountByQuery(String sql, List<Object> objList) {
PreparedStatement prepareStatement = null;
WTConnection wtConnection = null;
try {
wtConnection = getWtConnection();
wtConnection = getWtConnection();
prepareStatement = getPreparedStatement(sql, objList, wtConnection);
ResultSet rs = prepareStatement.executeQuery();
while (rs.next()) {
return rs.getInt(1);
return rs.getInt(1);
}
} catch (SQLException e) {
System.out.println("执行sql语句错误:" + sql+" errorMsg: "+e);
System.out.println("执行sql语句错误:" + sql + " errorMsg: " + e);
} finally {
wtConnection.freeStatement(sql, prepareStatement, true);
wtConnection.freeStatement(sql, prepareStatement, true);
}
return 0;
}
}
}
......@@ -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