Commit 86f0cded authored by hanson.yao's avatar hanson.yao

可视化逻辑修改

parent e1ad43e1
package com.yonde.cadpro.controller;
import com.yonde.cadpro.CADProConstants;
import com.yonde.cadpro.bean.DxCADBomVo;
import com.yonde.cadpro.service.PartVisService;
import com.yonde.cadpro.util.Base64Util;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.cadpro.service.PartVisService;
import com.yonde.cadpro.util.Base64Util;
import javax.servlet.http.HttpServletRequest;
/**
......@@ -17,13 +18,23 @@ import javax.servlet.http.HttpServletRequest;
* @author
*/
@RestController
@RequestMapping(value = "/cad")
@RequestMapping(value = "/DxEPMDocument")
public class CADController {
private static String PORT_USER = "portUserName";
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/expandCADBom", method = RequestMethod.GET)
public ApiResult expandCADBom(@RequestParam String oid, HttpServletRequest request) throws Exception {
String userName = Base64Util.decodeForUserName(request);
return ApiResult.ok(PartVisService.expandCADBom(oid,userName));
@RequestMapping(value = "/expandBOM", method = RequestMethod.GET)
public DxCADBomVo expandCADBom(@RequestParam String oid, HttpServletRequest request) throws Exception {
String authorization = request.getHeader(CADProConstants.AUTHORIZATION);
String userName = "";
if (StringUtils.isNotBlank(authorization)) {
userName = Base64Util.decodeForUserName(request);
}
String portUserName = request.getHeader(PORT_USER);
if (StringUtils.isNotBlank(portUserName)) {
userName = portUserName;
}
return PartVisService.expandCADBom(oid, userName);
}
}
......@@ -275,18 +275,18 @@ public class FtpUtil {
/**
* 从ftp下载文件到本地
*
* @param filename 服务器上的文件名
* @param newfilename 本地生成的文件名
* @param fileName 服务器上的文件名
* @param newFileName 本地生成的文件名
* @return
* @throws Exception
*/
public long downloadFile(String filename, String newfilename){
public long downloadFile(String fileName, String newFileName) throws IOException {
long result = 0;
TelnetInputStream is = null;
FileOutputStream os = null;
try{
is = ftpClient.get(filename);
File outfile = new File(newfilename);
is = ftpClient.get(fileName);
File outfile = new File(newFileName);
os = new FileOutputStream(outfile);
byte[] bytes = new byte[1024];
int c;
......@@ -296,6 +296,7 @@ public class FtpUtil {
}
}catch (IOException e){
e.printStackTrace();
throw new IOException("ftp download file failed... ",e);
}finally{
try {
if(is != null){
......
......@@ -11,6 +11,7 @@ import wt.util.WTException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
......@@ -120,7 +121,7 @@ public class AssembleTransformUtil {
StringBuffer insert = new StringBuffer(" insert into AssembleTransformInfo(SNAPSHOTID,ID,PARENTMODEL,CHILDMODEL,TRANSFORM,IDENTIFY) VALUES (");
insert.append("'" + snapshot.getId() + "',");
insert.append("'" + System.currentTimeMillis() + "',");
insert.append("'" + UUID.randomUUID().toString() + "',");
insert.append("'" + EPMUtil.getOROid(rootCAD) + "',");
insert.append("'" + EPMUtil.getOROid(linkedChildEPM) + "',");
insert.append("'" + EPMUtil.getOROid(epmMemberLink) + "',");
......@@ -138,7 +139,7 @@ public class AssembleTransformUtil {
*/
public static AssembleTransformSnapshot newAssembleTransformSnapshot(String parentId, String snapshotHash) throws WTException {
System.out.println(">>>newAssembleTransformSnapshot start......");
String id = String.valueOf(System.currentTimeMillis());
String id = UUID.randomUUID().toString();
StringBuffer insert = new StringBuffer(" insert into ASSEMBLETRANSFORMSNAPSHOT(ID,PARENTID,SNAPSHOTHASH) VALUES (");
insert.append("'" + id + "',");
insert.append("'" + parentId + "',");
......
package com.yonde.cadpro.visualization.facade;
import com.yonde.cadpro.CADProConstants;
import com.yonde.cadpro.config.CatiaInteConfigPropertiesUtil;
import com.yonde.cadpro.util.*;
import com.yonde.cadpro.visualization.AssembleTransformUtil;
import com.yonde.cadpro.visualization.catia.ConvertCatia2B3dUtil;
......@@ -121,31 +122,17 @@ public class VisualizationService {
System.out.println("uploadFiles : " + uploadFiles);
//2. 上传至FTP目录
FtpUtil ftpUtil = null;
if (!transferModel) {
ftpUtil = new FtpUtil(
officeTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_OFFICE_FTP_HOST),
Integer.valueOf(officeTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_OFFICE_FTP_PORT)),
officeTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_OFFICE_FTP_USERNAME),
officeTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_OFFICE_FTP_PASSWORD));
} else {
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));
}
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 = officeTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_OFFICE_TEMPFOLDERPATH) + uuidStr + "/";
} else {
if (transferModel) {
ftpRemoteFolder = catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_TEMPFOLDERPATH) + uuidStr + "/";
}
......@@ -203,11 +190,24 @@ public class VisualizationService {
}
System.out.println("transformedFtpPath :" + transformedFtpPath);
System.out.println("transformedFileName :" + transformedFileName);
//woker机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)),
VisualizationFacade.catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_USERNAME),
VisualizationFacade.catiaTransferConfig.getValueByKey(CADProConstants.CONFIG_KEY_CATIA_FTP_PASSWORD));
if (!ftpUtil.connectServer()) {
throw new WTException("FTP连接失败,请重试或联系系统管理员。");
}
String downloadFile = ContentUtil.getTempPath() + transformedFileName;
ftpUtil.downloadFile(transformedFtpPath + transformedFileName, downloadFile);
ftpUtil.closeServer();
//4. 上传转可视化之后文件至contentHolder
if (StringUtils.isNotBlank(transformedFtpPath) && StringUtils.isNotBlank(transformedFileName)) {
if (transferModel) {
String xmlFile = transformedFileRemotePath;
String xmlFile = downloadFile;
System.out.println("xmlFile : " + xmlFile);
//处理下载文件
Map<String, Set<String>> numberVisMap = new HashMap<String, Set<String>>();
......@@ -413,18 +413,13 @@ public class VisualizationService {
Set<EPMMemberLink> allMembership = memberLinkWithTrasform
.keySet();
for (EPMMemberLink epmMemberLink : allMembership) {
Map<EPMDocument, String> epmTrans = memberLinkWithTrasform
.get(epmMemberLink);
Map<EPMDocument, String> epmTrans = memberLinkWithTrasform.get(epmMemberLink);
if (epmTrans != null) {
Set<Entry<EPMDocument, String>> epmKeyEnters = epmTrans
.entrySet();
Iterator<Entry<EPMDocument, String>> itEntry = epmKeyEnters
.iterator();
Set<Entry<EPMDocument, String>> epmKeyEnters = epmTrans.entrySet();
Iterator<Entry<EPMDocument, String>> itEntry = epmKeyEnters.iterator();
if (itEntry.hasNext()) {
Entry<EPMDocument, String> epmKeyEntry = itEntry
.next();
EPMDocument linkedChildEPM = epmKeyEntry
.getKey();
Entry<EPMDocument, String> epmKeyEntry = itEntry.next();
EPMDocument linkedChildEPM = epmKeyEntry.getKey();
String formatTransform = epmKeyEntry.getValue();
System.out.println("process snapshot :" + snapshot
+ ", epm:" + rootCAD
......@@ -495,13 +490,24 @@ public class VisualizationService {
Set<String> b3dPaths = numberVisMap.get(cadNumber);
if (b3dPaths != null) {
for (String b3dPath : b3dPaths) {
System.out.println("b3dPath : " + b3dPath);
File file = new File(transformedFileRemotePath);
String parent = file.getParent()+File.separator;
String parent = file.getParent() + File.separator;
b3dPath = b3dPath.replace(tempFolderPath, parent);
if (!ftpUtil.connectServer()) {
throw new WTException("FTP连接失败,请重试或联系系统管理员。");
}
System.out.println("b3dPath2 : " + b3dPath);
File b3dFile = new File(b3dPath);
if (!b3dFile.exists() || b3dFile.isDirectory()) {
if (!b3dFile.getParentFile().exists()){
b3dFile.getParentFile().mkdirs();
b3dFile.createNewFile();
}
//将worker机的b3d文件存储到pdm服务器临时目录中
String replace = b3dPath.replace(new File(CatiaInteConfigPropertiesUtil.getFtpRootPath()).getPath(), "");
ftpUtil.downloadFile(replace, b3dPath);
ftpUtil.closeServer();
if (!b3dFile.exists() || b3dFile.isDirectory() || b3dFile.length()<1) {
logger.error("b3dPath File [" + b3dPath + "] is not exist,continue...");
continue;
}
......@@ -512,7 +518,7 @@ public class VisualizationService {
ContentRoleType.toContentRoleType("ADDITIONAL_FILES"));
epm = (EPMDocument) PersistenceHelper.manager.refresh(epm);
b3dFile.deleteOnExit();
//处理PMI 轻量化文件
//String fileName = FilenameUtils.getBaseName(b3dPath);
......@@ -616,13 +622,6 @@ public class VisualizationService {
if (element instanceof EPMDocument) {
child = (EPMDocument) element;
} else if (element instanceof EPMDocumentMaster) {
/*
QueryResult versionQr = VersionControlHelper.service
.allVersionsOf((EPMDocumentMaster) element);
if (versionQr != null && versionQr.hasMoreElements()) {
child = (EPMDocument) versionQr.nextElement();
}
*/
child = EPMUtil.getEPM(((EPMDocumentMaster) element).getNumber(), "", "");
}
if (child != null) {
......
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