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

11

parent 2c5a919e
......@@ -13,7 +13,7 @@ Absolute.Position.Type=DS
Absolute.Position.Default=1;0;0;0;0;1;0;0;0;0;1;0;0;0;0;1
BOM.AllowPartType=\u4E3B\u89C6\u56FE\u9876\u5C42\u4EF6,DCI,FCI,LO,DS
#For FTP Config
ftp.host=192.168.1.240
ftp.host=192.168.37.138
ftp.port=21
ftp.username=ftpuser
ftp.password=Aa12345678!
......
......@@ -6,9 +6,9 @@
"type": 0,
"sort": 1,
"code": "77d6cf9e-6527-4f38-ae8e-87bd744e405d",
"ftpHost": "192.168.1.240",
"ftpHost": "192.168.37.138",
"ftpSetting": {
"host": "192.168.1.240",
"host": "192.168.37.138",
"port": 21,
"userName": "ftpuser",
"password": "Aa12345678!"
......
#For Catia Transfer Web Service
Catia.Transfer.host=192.168.1.240
Catia.Transfer.host=192.168.1.235
Catia.Transfer.port=8081
Catia.Transfer.targetNameSpace=www.ptc.com/ws
Catia.Transfer.serviceName=ConvertModel2GlbService
#For B3d
Catia.Transfer.B3d.host=192.168.1.240
Catia.Transfer.B3d.host=192.168.1.235
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.240
Catia.ftp.host=192.168.1.235
Catia.ftp.port=21
Catia.ftp.username=ftpuser
Catia.ftp.password=Aa12345678!
......
......@@ -4,7 +4,7 @@ Office.Transfer.port=8082
Office.Transfer.targetNameSpace=www.ptc.com/ws
Office.Transfer.serviceName=ConvertOfficePDFService
#For FTP Config
Office.ftp.host=192.168.1.240
Office.ftp.host=192.168.37.138
Office.ftp.port=21
Office.ftp.username=ftpuser
Office.ftp.password=Aa12345678!
......
package com.yonde.cadpro.bean;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.yonde.cadpro.util.ContentUtil;
import com.yonde.cadpro.util.EPMUtil;
import com.yonde.cadpro.util.WIPUtil;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import wt.content.ApplicationData;
import wt.content.ContentItem;
import wt.content.ContentRoleType;
import wt.epm.EPMDocument;
import wt.epm.EPMDocumentType;
import wt.epm.structure.EPMMemberLink;
import wt.org.WTPrincipal;
import wt.org.WTUser;
import wt.util.WTContext;
import wt.util.WTException;
import wt.vc.wip.CheckoutInfo;
import wt.vc.wip.WorkInProgressHelper;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 模型实体类
* @description:
**/
public class DxCADBomVo implements Serializable {
@JsonIgnore
private EPMDocument cad;
@JsonIgnore
private EPMMemberLink memberLink;
private String cadId;
private String memberLinkId;
private String number;
private String name;
private String displayVersion;
private CADProUser creator;
private CADProUser modifier;
private boolean checkOuted;
/**
* 生命周期状态
*/
private String state;
/**
* 检出者
*/
private CADProUser checkoutUser;
/**
*
*/
private String checkoutStatus;
/**
* 基于父装配的相对坐标
* 4x4 字符串表示
*/
private String transform;
/**
* 模型可视化文件
*/
private DxModelFile visFile;
private boolean hasPMI = false;
/**
* 模型可视化文件
*/
private DxModelFile pmiFile;
/**
* 子模型列表
*/
private List<DxCADBomVo> children = new ArrayList<DxCADBomVo>();
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
private Date modifyTime;
public EPMDocument getCad() {
return cad;
}
public void setCad(EPMDocument cad) {
this.cad = cad;
}
public EPMMemberLink getMemberLink() {
return memberLink;
}
public void setMemberLink(EPMMemberLink memberLink) {
this.memberLink = memberLink;
}
public String getCadId() {
return cadId;
}
public void setCadId(String cadId) {
this.cadId = cadId;
}
public String getMemberLinkId() {
return memberLinkId;
}
public void setMemberLinkId(String memberLinkId) {
this.memberLinkId = memberLinkId;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDisplayVersion() {
return displayVersion;
}
public void setDisplayVersion(String displayVersion) {
this.displayVersion = displayVersion;
}
public CADProUser getCreator() {
return creator;
}
public void setCreator(CADProUser creator) {
this.creator = creator;
}
public CADProUser getModifier() {
return modifier;
}
public void setModifier(CADProUser modifier) {
this.modifier = modifier;
}
public boolean isCheckOuted() {
return checkOuted;
}
public void setCheckOuted(boolean checkOuted) {
this.checkOuted = checkOuted;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public CADProUser getCheckoutUser() {
return checkoutUser;
}
public void setCheckoutUser(CADProUser checkoutUser) {
this.checkoutUser = checkoutUser;
}
public String getCheckoutStatus() {
return checkoutStatus;
}
public void setCheckoutStatus(String checkoutStatus) {
this.checkoutStatus = checkoutStatus;
}
public String getTransform() {
return transform;
}
public void setTransform(String transform) {
this.transform = transform;
}
public DxModelFile getVisFile() {
return visFile;
}
public void setVisFile(DxModelFile visFile) {
this.visFile = visFile;
}
public boolean isHasPMI() {
return hasPMI;
}
public void setHasPMI(boolean hasPMI) {
this.hasPMI = hasPMI;
}
public DxModelFile getPmiFile() {
return pmiFile;
}
public void setPmiFile(DxModelFile pmiFile) {
this.pmiFile = pmiFile;
}
public List<DxCADBomVo> getChildren() {
if (children == null) {
children = new ArrayList<DxCADBomVo>();
}
return children;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public List<DxCADBomVo> addChildren(DxCADBomVo child) {
if (children == null) {
children = new ArrayList<DxCADBomVo>();
}
if (child != null) {
children.add(child);
}
return children;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
public static DxCADBomVo newDxCADBomVo(EPMDocument epm, EPMMemberLink memberLink,
boolean needVisFileUrl) throws WTException {
if (epm == null) {
return null;
}
String oid = EPMUtil.getOROid(epm);
String memberLinkId = "";
if (memberLink != null) {
memberLinkId = EPMUtil.getOROid(memberLink);
} else {
memberLinkId = "Root";
}
String number = epm.getNumber();
String name = epm.getName();
String version = WIPUtil.getVersionDisplayWithOneOff(epm);
Boolean isCheckedOut = WorkInProgressHelper.isCheckedOut(epm);
//Add for 检出状态、检出者
CheckoutInfo checkInfo = epm.getCheckoutInfo();
String checkoutInfoState = checkInfo == null ? "" : checkInfo.getState().toString();
WTPrincipal checkoutUserWtp = WIPUtil.getCheckoutUser(epm);
WTUser checkOutor = null;
if (checkoutUserWtp != null) {
if (checkoutUserWtp instanceof WTUser) {
checkOutor = (WTUser) checkoutUserWtp;
}
}
String state = epm.getLifeCycleState().getDisplay(WTContext.getContext().getLocale());
DxCADBomVo dxCADBomVo = new DxCADBomVo();
dxCADBomVo.setCad(epm);
dxCADBomVo.setMemberLink(memberLink);
if (needVisFileUrl) {
try {
DxModelFile visFile = DxModelFile.newVisFile(epm);
System.out.println("retrive visFile : " + visFile);
dxCADBomVo.setVisFile(visFile);
} catch (Exception e) {
System.out.println("获取模型可视化信息失败"+ e);
}
try {
DxModelFile pmiFile = DxModelFile.newPmiFile(epm);
//判断是否存在PMI
if (pmiFile != null) {
dxCADBomVo.setHasPMI(true);
}
System.out.println("retrive pmiFile : " + pmiFile);
dxCADBomVo.setPmiFile(pmiFile);
} catch (Exception e) {
System.out.println("获取模型PMI可视化信息失败"+ e);
}
}
dxCADBomVo.setCadId(oid);
dxCADBomVo.setMemberLinkId(memberLinkId);
dxCADBomVo.setName(name);
dxCADBomVo.setNumber(number);
dxCADBomVo.setDisplayVersion(version);
dxCADBomVo.setState(state);
dxCADBomVo.setCheckOuted(isCheckedOut);
dxCADBomVo.setCheckoutStatus(checkoutInfoState);
if (checkOutor != null) {
dxCADBomVo.setCheckoutUser(CADProUser.toCADProUser(checkOutor));
}
WTUser creator = (WTUser) epm.getCreator().getPrincipal();
WTUser modifier = (WTUser) epm.getModifier().getPrincipal();
dxCADBomVo.setCreator(CADProUser.toCADProUser(creator));
dxCADBomVo.setModifier(CADProUser.toCADProUser(modifier));
dxCADBomVo.setModifyTime(epm.getModifyTimestamp());
return dxCADBomVo;
}
private static boolean checkPMI(EPMDocument epm) throws Exception {
if (epm == null) {
return false;
}
EPMDocumentType epmComponentType = EPMDocumentType.toEPMDocumentType("CADCOMPONENT");
if (epmComponentType.equals(epm.getDocType())) {
List<ContentItem> contentItems = ContentUtil.getContentsByRole(epm,
new ContentRoleType[] { ContentRoleType.toContentRoleType("CAD_HIDDEN_CONTENT")});
if (contentItems != null && contentItems.size() > 0) {
ContentItem ci = contentItems.get(0);
if (ci instanceof ApplicationData) {
return true;
}
}
}
return false;
}
}
......@@ -179,7 +179,7 @@ public class DxModelFile implements Serializable {
EPMDocumentType epmComponentType = EPMDocumentType.toEPMDocumentType("CADCOMPONENT");
if (epmComponentType.equals(epm.getDocType())) {
List<ContentItem> contentItems = ContentUtil.getContentsByRole(epm,
new ContentRoleType[] { ContentRoleType.toContentRoleType("Additional_Files") });
new ContentRoleType[] { ContentRoleType.toContentRoleType("ADDITIONAL_FILES") });
if (contentItems != null && contentItems.size() > 0) {
ContentItem ci = contentItems.get(0);
if (ci instanceof ApplicationData) {
......@@ -216,7 +216,7 @@ public class DxModelFile implements Serializable {
EPMDocumentType epmComponentType = EPMDocumentType.toEPMDocumentType("CADCOMPONENT");
if (epmComponentType.equals(epm.getDocType())) {
List<ContentItem> contentItems = ContentUtil.getContentsByRole(epm,
new ContentRoleType[] { ContentRoleType.toContentRoleType("CAD_hidden_content") });
new ContentRoleType[] { ContentRoleType.toContentRoleType("CAD_HIDDEN_CONTENT") });
if (contentItems != null && contentItems.size() > 0) {
ContentItem ci = contentItems.get(0);
if (ci instanceof ApplicationData) {
......
package com.yonde.cadpro.controller;
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;
/**
* Created on 2023/6/28 0028
*
* @author
*/
@RestController
@RequestMapping(value = "/cad")
public class CADController {
@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));
}
}
package com.yonde.cadpro.pmi;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
@XmlAccessorType(XmlAccessType.FIELD)
// XML文件中的根标识
@XmlRootElement(name = "Annotation")
// 控制JAXB 绑定类中属性和字段的排序
@XmlType(propOrder = { "id", "name", "type" })
public class PMIAnnotation implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlAttribute
private String id;
@XmlElement(name = "name")
private String name;
@XmlElement(name = "type")
private String type;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
package com.yonde.cadpro.pmi;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
// XML文件中的根标识
@XmlRootElement(name = "AnnotationsRoot")
// 控制JAXB 绑定类中属性和字段的排序
@XmlType(propOrder = { "index", "name", "viewSets", "annotations" })
public class PMIAnnotationsRoot implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlAttribute
private String index;
@XmlAttribute
private String name;
@XmlElement(name = "ViewSets")
private PMIViewSets viewSets;
@XmlElementWrapper(name = "AnnotationSets")
@XmlElement(name = "Annotation")
@JsonProperty(value = "annotationSets")
private List<PMIAnnotation> annotations;
public PMIAnnotationsRoot() {
}
public String getIndex() {
return index;
}
public void setIndex(String index) {
this.index = index;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public PMIViewSets getViewSets() {
return viewSets;
}
public void setViewSets(PMIViewSets viewSets) {
this.viewSets = viewSets;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
\ No newline at end of file
package com.yonde.cadpro.pmi;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
@XmlAccessorType(XmlAccessType.FIELD)
// XML文件中的根标识
@XmlRootElement(name = "Camera")
// 控制JAXB 绑定类中属性和字段的排序
@XmlType(propOrder = { "position", "target", "up", "type" })
public class PMICamera implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlElement(name = "Position")
private String position;
@XmlElement(name = "Target")
private String target;
@XmlElement(name = "Up")
private String up;
@XmlElement(name = "Type")
private String type;
public PMICamera() {
}
public String getPosition() {
return position;
}
public void setPosition(String position) {
this.position = position;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
public String getUp() {
return up;
}
public void setUp(String up) {
this.up = up;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
package com.yonde.cadpro.pmi;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
// XML文件中的根标识
@XmlRootElement(name = "PMIRoot")
// 控制JAXB 绑定类中属性和字段的排序
@XmlType(propOrder = { "id", "partId", "partName", "partNumber", "tool", "annotationsRoot" })
public class PMIRoot implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlAttribute
private String id;
@XmlAttribute
private String partId;
@XmlAttribute
private String partName;
@XmlAttribute
private String partNumber;
@XmlAttribute
private String tool;
@XmlElement(name = "AnnotationsRoot")
private List<PMIAnnotationsRoot> annotationsRoot;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPartId() {
return partId;
}
public void setPartId(String partId) {
this.partId = partId;
}
public String getPartName() {
return partName;
}
public void setPartName(String partName) {
this.partName = partName;
}
public String getPartNumber() {
return partNumber;
}
public void setPartNumber(String partNumber) {
this.partNumber = partNumber;
}
public String getTool() {
return tool;
}
public void setTool(String tool) {
this.tool = tool;
}
public List<PMIAnnotationsRoot> getAnnotationsRoot() {
return annotationsRoot;
}
public void setAnnotationsRoot(List<PMIAnnotationsRoot> annotationsRoot) {
this.annotationsRoot = annotationsRoot;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
package com.yonde.cadpro.pmi;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
@XmlAccessorType(XmlAccessType.FIELD)
// XML文件中的根标识
@XmlRootElement(name = "View")
// 控制JAXB 绑定类中属性和字段的排序
@XmlType(propOrder = { "id", "name", "camera", "pmiIds", "modelIds" })
public class PMIView implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlAttribute
private String id;
@XmlAttribute
private String name;
@XmlElement(name = "Camera")
private PMICamera camera;
@XmlElement(name = "PMIIds")
private String pmiIds;
@XmlElement(name = "ModelIds")
private String modelIds;
public PMIView() {
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public PMICamera getCamera() {
return camera;
}
public void setCamera(PMICamera camera) {
this.camera = camera;
}
public String getPmiIds() {
return pmiIds;
}
public void setPmiIds(String pmiIds) {
this.pmiIds = pmiIds;
}
public String getModelIds() {
return modelIds;
}
public void setModelIds(String modelIds) {
this.modelIds = modelIds;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
package com.yonde.cadpro.pmi;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import javax.xml.bind.annotation.*;
import java.io.Serializable;
import java.util.List;
@XmlAccessorType(XmlAccessType.FIELD)
// XML文件中的根标识
@XmlRootElement(name = "ViewSets")
// 控制JAXB 绑定类中属性和字段的排序
@XmlType(propOrder = { "index", "name", "view" })
public class PMIViewSets implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
@XmlAttribute
private String index;
@XmlAttribute
private String name;
@XmlElement(name = "View")
private List<PMIView> view;
public PMIViewSets() {
}
public String getIndex() {
return index;
}
public void setIndex(String index) {
this.index = index;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<PMIView> getView() {
return view;
}
public void setView(List<PMIView> view) {
this.view = view;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
......@@ -4,8 +4,10 @@ import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.basedata.search.SearchItems;
import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.cadpro.CADProConstants;
import com.yonde.cadpro.bean.*;
import com.yonde.cadpro.config.CatiaClientConfig;
import com.yonde.cadpro.bean.CADProUser;
import com.yonde.cadpro.bean.DxModelFile;
import com.yonde.cadpro.bean.DxPartModelBomVo;
import com.yonde.cadpro.bean.OpenModelFilesCondition;
import com.yonde.cadpro.config.CatiaInteConfigPropertiesUtil;
import com.yonde.cadpro.converter.DxPartModelBomVoConverter;
import com.yonde.cadpro.download.CADProDownloader;
......@@ -14,24 +16,14 @@ import com.yonde.cadpro.download.factroy.InsertDownloaderFactory;
import com.yonde.cadpro.download.factroy.NewDownloaderFactory;
import com.yonde.cadpro.util.*;
import com.yonde.common.CommonUtil;
import com.yonde.common.IBAUtil;
import com.yonde.common.JsonUtils;
import com.yonde.common.PartUtil;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import wt.content.ContentRoleType;
import wt.doc.WTDocumentMaster;
import wt.epm.EPMDocument;
import wt.epm.build.EPMBuildHistory;
import wt.epm.build.EPMBuildRule;
import wt.fc.*;
import wt.fc.collections.WTArrayList;
import wt.fc.collections.WTList;
import wt.inf.container.WTContainer;
import wt.fc.Persistable;
import wt.fc.QueryResult;
import wt.fc.WTObject;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.org.WTPrincipal;
......@@ -39,9 +31,6 @@ import wt.org.WTUser;
import wt.part.WTPart;
import wt.part.WTPartConfigSpec;
import wt.part.WTPartStandardConfigSpec;
import wt.pds.StatementSpec;
import wt.query.QuerySpec;
import wt.query.SearchCondition;
import wt.session.SessionHelper;
import wt.session.SessionServerHelper;
import wt.util.WTException;
......@@ -49,8 +38,10 @@ import wt.vc.config.LatestConfigSpec;
import wt.vc.views.ViewHelper;
import java.io.File;
import java.io.InputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@Service
public class CADProService implements RemoteAccess {
......@@ -63,7 +54,6 @@ public class CADProService implements RemoteAccess {
public static String PART_DEFAULT_TYPE = "wt.part.WTPart";
@SuppressWarnings({ "unchecked" })
public static ApiResult<CADProUser> cadProLogin(String userName, String clientVersion) throws Exception {
System.out.println(">>>cadProLogin login start.....");
......@@ -513,504 +503,7 @@ public class CADProService implements RemoteAccess {
// return url;
// }
/**
* 处理检出或新建模型的检入
* 1. 零部件、数模的创建
* 2. 零部件、数模的属性更新
* 3. 零部件、数模的关联关系
* 4. 零部件、数模的BOMUses关系记录
*
* @param modelBaseInfo
* @param processedModelNumbers
* @param attrMapping
* @param drawingInfos
* @param bomUsesMap
* @param partEPMMap
* @throws Exception
*/
private void processModelBaselInfo2(ModelBaseInfo modelBaseInfo,
Set<String> processedModelNumbers, Map<String, String> attrMapping,
Map<String, List<ModelBaseInfo>> drawingInfos,
Map<WTPart, List<ModelBaseInfo>> bomUsesMap, Map<WTPart, EPMDocument> partEPMMap)
throws Exception {
System.out.println("processModelBaselInfo2 : " + modelBaseInfo.getNumber() + " "
+ modelBaseInfo.getName() + " " + modelBaseInfo.getVersion());
String modelNumber = modelBaseInfo.getNumber();
String modelName = modelBaseInfo.getName();
String modelFileName = modelBaseInfo.getModelFileName();
String modelFileUri = modelBaseInfo.getModelFileUri();
Boolean isDrawing = modelBaseInfo.getIsDrawing();
String modelThumbnailUri = modelBaseInfo.getModelThumbnailUri();
// 新版CAD Pro 不记录/更新客户端位置信息
//String modelRelativePath = modelBaseInfo.getModelRelativePath();
System.out.println("modelNumber : " + modelNumber);
System.out.println("modelName : " + modelName);
System.out.println("modelFileName : " + modelFileName);
System.out.println("modelFileUri : " + modelFileUri);
System.out.println("isDrawing : " + isDrawing);
System.out.println("modelThumbnailUri : " + modelThumbnailUri);
StringBuilder baseCheckSB = new StringBuilder("");
if (StringUtils.isBlank(modelNumber)) {
baseCheckSB.append("待检入模型编号不能为空");
baseCheckSB.append("\r\n");
}
if (StringUtils.isBlank(modelName)) {
baseCheckSB.append("待检入模型名称不能为空");
baseCheckSB.append("\r\n");
}
if (StringUtils.isBlank(modelFileName)) {
baseCheckSB.append("待检入模型文件名称不能为空");
baseCheckSB.append("\r\n");
}
if (StringUtils.isBlank(modelFileUri)) {
baseCheckSB.append("待检入模型文件地址不能为空");
baseCheckSB.append("\r\n");
}
String baseCheck = baseCheckSB.toString();
if (StringUtils.isNotBlank(baseCheck)) {
throw new WTException(baseCheck);
}
modelNumber = modelNumber.toUpperCase();
System.out.println("modelNumber toUpperCase : " + modelNumber);
boolean isDSPart = false;
System.out.println("isDSNumber : " + isDSPart);
String currentUserName = SessionHelper.manager.getPrincipal().getName();
//获取供应商协同区
// WTContainer supplierContainer = supplierService.getSupplierSharingAarea();
boolean isSupplierOP = false;//upplierContainer != null ? true : false;
//判断是否为二维图,三维图处理完成后统一处理
if (isDrawing) {
System.out.println("current model info is Drawing, processing after the all 3D model");
List<ModelBaseInfo> tempChildInfos = modelBaseInfo.getChildren();
if (tempChildInfos == null || tempChildInfos.size() == 0) {
throw new WTException("二维图纸必须与三维模型一起检入!");
}
//二维图 child 引用其三维图
ModelBaseInfo mbi3D = tempChildInfos.get(0);
if (mbi3D == null) {
throw new WTException("二维图纸关联三维模型信息错误!");
}
String associated3DNumber = mbi3D.getNumber();
if (StringUtils.isBlank(associated3DNumber)) {
throw new WTException("二维图纸关联三维模型图号为空!");
}
associated3DNumber = associated3DNumber.toUpperCase();
System.out.println("associated3DNumber : " + associated3DNumber);
List<ModelBaseInfo> model2Ds = drawingInfos.get(associated3DNumber);
if (model2Ds == null) {
model2Ds = new ArrayList<ModelBaseInfo>();
drawingInfos.put(associated3DNumber, model2Ds);
}
model2Ds.add(modelBaseInfo);
} else {
//判断是否已经被处理过
if (processedModelNumbers.contains(modelNumber)) {
System.out.println("The modelNumber[" + modelNumber + "] has been processed, return...");
return;
} else {
processedModelNumbers.add(modelNumber);
}
EPMDocument epm = null;//待创建、更新EPM
WTPart wtPart = null;//待创建、更新Part
String partNumber = modelService.transformPartNumber(modelNumber);
System.out.println("partNumber : " + partNumber);
//从MBD属性中获取IBA属性
List<MBDAttribute> mbdDataList = modelBaseInfo.getMbdDatas();
//Map<String, Object> attsValueMap = retriveProcessIBAs(mbdDataList, attrMapping);
//存储R模型定义属性,暂未为实例化
List<MaterialUsedRDefinitionBean> definitions = new ArrayList<MaterialUsedRDefinitionBean>();
Map<String, Object> attsValueMap = modelService.retriveProcessIBAAndRDefs(mbdDataList,
attrMapping, definitions);
System.out.println("attsValueMap : " + attsValueMap);
System.out.println("definitions size : " + definitions.size());
//判断是否为标准件
boolean isStandardPart = CatiaClientConfig.isStandardPart(attsValueMap);
System.out.println("isStandardPart : " + isStandardPart);
//判断是否为机载设备
boolean isAirborneEquipment = false;
if (!isStandardPart) {
isAirborneEquipment = CatiaClientConfig.isAirborneEquipmentPart(mbdDataList);
}
System.out.println("isAirborneEquipment : " + isAirborneEquipment);
boolean isIngoreUpdate = false;
WTContainer wtc = null;
String folderPath = "";
// 1.搜索EPM,判断是否存在
//SearchUtil searchUtil = new SearchUtil(EPMDocument.class);
//searchUtil.setAccessEnforced(true);
//searchUtil.setNumber(modelNumber);
//searchUtil.setConfigSpec(new LatestConfigSpec());
////appendEPMOrderBys(searchUtil);
//
//QueryResult epmQr = searchUtil.queryObjects();
// 1.搜索EPM,判断是否存在
System.out.println("query epm info numer:" + modelNumber);
QuerySpec qs = new QuerySpec(EPMDocument.class);
qs.appendWhere(new SearchCondition(EPMDocument.class, EPMDocument.NUMBER, SearchCondition.EQUAL, modelNumber), new int[]{0});
qs.appendAnd();
qs.appendWhere(new SearchCondition(EPMDocument.class, EPMDocument.LATEST_ITERATION, SearchCondition.IS_TRUE), new int[]{0});
QueryResult epmQr = PersistenceHelper.manager.find((StatementSpec) qs);
//epmQr = filterIterationsByModifyTime(epmQr);
if (epmQr != null && epmQr.hasMoreElements()) {
epm = (EPMDocument) epmQr.nextElement();
}
if (epm == null) {
System.out.println("创建EPM");
//新建3维模型检查编号和物理文件名称必须一致
modelService.validateNumberWithModelFileName(modelNumber, modelFileName);
//标准件创建切换用户
if (isStandardPart) {
modelService.switchResourceManager();
}
//创建EPM
String epmDocumentType = CatiaClientConfig.getEpmDocumentType(modelFileName);
epm = EPMUtil.createEPMDoc(modelNumber, modelName, modelFileName, epmDocumentType,
CatiaClientConfig.epmAuthoringAppType,
CatiaClientConfig.getEpmDefaultType(), attsValueMap, "", "", null, false, wtc,
folderPath);
} else {
//标准件忽略更新
if (isStandardPart) {
//throw new WTException("标准件[" + epm.getDisplayIdentifier() + "]不允许更新!");
isIngoreUpdate = true;
}
if (!isIngoreUpdate) {
//已存在,校验EPM是否被当前用户检出
System.out.println("EPM已经存在");
if (CommonUtil.isCheckedOut(epm)) {
/*
if (!WorkInProgressHelper.isModifiable(epm)) {
throw new WTException("模型[" + epm.getDisplayIdentifier() + "]被其他用户检出!");
}
*/
if (!CommonUtil.isCheckedOut(epm, null)) {
WTPrincipal checkoutUser = null;
try {
checkoutUser = CommonUtil.getCheckoutUser(epm);
} catch (Exception e) {
System.out.println("getCheckoutUser error..." + e);
}
if (checkoutUser != null) {
throw new WTException("模型[" + epm.getDisplayIdentifier() + "]被其他用户["
+ CommonUtil.formatUserDisplay((WTUser) checkoutUser) + "]检出!");
} else {
throw new WTException(
"模型[" + epm.getDisplayIdentifier() + "]被其他用户检出!");
}
}
} else {
throw new WTException("模型[" + epm.getDisplayIdentifier() + "]尚未检出!");
}
}
}
System.out.println("epm[" + epm.getDisplayIdentifier() + "]");
//处理EPM是新建或者检出,检查Part是否存在
//Part 不存在,新建
//Part 存在,检出
//检查EPM是否已关联Part
wtPart = EPMUtil.getLatestBuidTarget(epm);
if (wtPart == null) {//默认取与CAD文档同编号的
//wtPart = PartUtil.getLatestPartByModifyTime(partNumber,WCGlobalConstant.VIEW_DESIGN, true);
wtPart = CadPartUtil.getLatestPart(partNumber, CADProConstants.VIEW_DESIGN);
}
if (wtPart == null) {
System.out.println("Part创建");
Map<String, Object> baseAttributes = new HashMap<String, Object>();
baseAttributes.put(PartUtil.VIEW, CADProConstants.VIEW_DESIGN);
String mappingPartType = CatiaClientConfig.wtPartDefaultType;
if (isStandardPart) {
mappingPartType = CatiaClientConfig.wtPartStandardType;
} else if (isDSPart) {
mappingPartType = CatiaClientConfig.wtPartDSType;
} else if (isAirborneEquipment) {
mappingPartType = CatiaClientConfig.wtPartAirborneEquipmentType;
}
System.out.println("mappingPartType : " + mappingPartType);
//标准件创建切换用户
if (isStandardPart) {
modelService.switchResourceManager();
}
// //供应商设计账号获取协同区
// if (!isStandardPart && wtc == null && isSupplierOP) {
// wtc = supplierContainer;
// }
//默认型号为AG600
// modelService.checkModelAttr(attsValueMap);
wtPart = CadPartUtil.createPart(partNumber, modelName, mappingPartType, baseAttributes,
attsValueMap, false, wtc, folderPath);
// if (isStandardPart) {
// System.out.println("创建检入数模为标准件,设置Part状态为已发布...");
// wtPart = (WTPart) LifeCycleServerHelper.service.setState(
// (LifeCycleManaged) wtPart, State.toState(GACEConstants.STATE_YFB));
// wtPart = (WTPart) PersistenceHelper.manager.refresh(wtPart);
//
// modelService.switchToOringinalUser(currentUserName);
// }
} else {
//标准件忽略更新
if (isStandardPart) {
//throw new WTException("标准件[" + wtPart.getDisplayIdentifier() + "]不允许更新!");
isIngoreUpdate = true;
}
if (!isIngoreUpdate) {
//已存在,则Part检出
System.out.println("Part已存在,确认检出");
if (CommonUtil.isCheckedOut(wtPart)) {
if (!CommonUtil.isCheckedOut(wtPart, null)) {
WTPrincipal checkoutUser = null;
try {
checkoutUser = CommonUtil.getCheckoutUser(wtPart);
} catch (Exception e) {
System.out.println("getCheckoutUser error..." + e);
}
if (checkoutUser != null) {
throw new WTException("零部件[" + wtPart.getDisplayIdentifier()
+ "]被其他用户["
+ CommonUtil.formatUserDisplay((WTUser) checkoutUser) + "]检出!");
} else {
throw new WTException(
"零部件[" + wtPart.getDisplayIdentifier() + "]被其他用户检出!");
}
}
} else {
wtPart = (WTPart) CommonUtil.doCheckOut(wtPart, "客户端检入数模,系统自动检出关联零部件");
System.out.println("零部件[" + wtPart.getDisplayIdentity() + "]尚未检出,系统自动执行检出!");
}
wtPart = (WTPart) CommonUtil.getWorkingCopyVersion(wtPart);
/*
boolean hasCheckouted = WIPUtil.isCheckedOut(wtPart, null);
if (!hasCheckouted) {
wtPart = (WTPart) WIPUtil.doCheckOut(wtPart, "客户端检入数模,系统自动检出关联零部件");
log.warn("零部件[" + wtPart.getDisplayIdentity() + "]尚未检出,系统自动执行检出!");
}
wtPart = (WTPart) WIPUtil.getWorkingCopyVersion(wtPart);
*/
}
}
System.out.println("wtPart[" + wtPart.getDisplayIdentifier() + "]");
System.out.println("isIngoreUpdate : " + isIngoreUpdate);
//处理改名称情况
System.out.println("开始处理数模名称...");
String epmName = epm.getName();
if (!modelName.equals(epmName)) {
System.out.println("Change epmName[" + epmName + "] to [" + modelName + "]");
CommonUtil.resetWTObjectNumberNameNoTrans(epm, modelName, "");
epm = (EPMDocument) PersistenceHelper.manager.refresh(epm);
}
System.out.println("开始处理零部件名称...");
String partName = wtPart.getName();
if (!modelName.equals(partName)) {
System.out.println("Change partName[" + partName + "] to [" + modelName + "]");
CommonUtil.resetWTObjectNumberNameNoTrans(wtPart, modelName, "");
wtPart = (WTPart) PersistenceHelper.manager.refresh(wtPart);
}
//记录Part EPM
//若是已有标准件,返回服务器信息
partEPMMap.put(wtPart, epm);
if (!isIngoreUpdate) {
//处理EPM
System.out.println("开始处理数模...");
System.out.println(" 数模主内容>>>>");
if (StringUtils.isNotBlank(modelFileUri)) {
//处理EPM主内容
String primaryFilePath = modelService
.transferModelFilePathFromZIPByCopy(modelFileUri, modelFileName);
ContentUtil.addApplicationData(epm, "", primaryFilePath, "",
ContentRoleType.PRIMARY.toString());
epm = (EPMDocument) PersistenceHelper.manager.refresh(epm);
} else {
throw new WTException("创建或更新数模,模型文件不能为空。");
}
System.out.println(" 缩略图处理>>>>");
if (StringUtils.isNotBlank(modelThumbnailUri)) {
//处理三维数模缩略图
String modelThumbnailPath = modelService.transferThumbnailPathByCopy(
modelFileUri, modelThumbnailUri, modelFileName);
if (StringUtils.isNotBlank(modelThumbnailPath)) {
//缩略图后缀
String extension = FilenameUtils.getExtension(modelThumbnailUri);
//模型文件名
String baseName = FilenameUtils.getBaseName(modelFileName);
//缩略图重命名
String modelThumbnailName = baseName + "_Thumbnail";
if (StringUtils.isNotBlank(extension)) {
modelThumbnailName = modelThumbnailName + "." + extension;
}
//EPM缩略图
ContentUtil.addApplicationData(epm, modelThumbnailName, modelThumbnailPath,
"", ContentRoleType.THUMBNAIL);
epm = (EPMDocument) PersistenceHelper.manager.refresh(epm);
//Part缩略图
ContentUtil.addApplicationData(wtPart, modelThumbnailName,
modelThumbnailPath, "", ContentRoleType.THUMBNAIL);
wtPart = (WTPart) PersistenceHelper.manager.refresh(wtPart);
}
}
Set<String> attrKeys = attsValueMap.keySet();
if (attrKeys != null) {
for (String attrKey : attrKeys) {
Object attrValue = attsValueMap.get(attrKey);
System.out.println(" attrKey : " + attrKey);
System.out.println(" attrValue : " + attrValue);
try {
IBAUtil.forceSetIBAValue(wtPart, attrKey, attrValue);
} catch (Exception e) {
System.out.println("wtPart[" + wtPart.getDisplayIdentifier()
+ "] setIBAAnyValue error..." + e);
}
try {
IBAUtil.forceSetIBAValue(epm, attrKey, attrValue);
} catch (Exception e) {
System.out.println("epm [" + epm.getDisplayIdentifier()
+ "] setIBAAnyValue error..." + e);
}
}
epm = (EPMDocument) PersistenceHelper.manager.refresh(epm);
wtPart = (WTPart) PersistenceHelper.manager.refresh(wtPart);
}
//保存MBD属性
System.out.println("保存MBD属性至XML文件");
List<MBDAttribute> mbdAttributes = modelBaseInfo.getMbdDatas();
MBDAttributes mbdDatas = new MBDAttributes();
if (mbdAttributes != null && mbdAttributes.size() > 0) {
mbdDatas.getMbdAttributes().addAll(mbdAttributes);
}
//若无MBD属性,使用空集合覆盖上一版本内容
String mbdSmlStr = JsonUtils.toXMLStr(mbdDatas);
if (StringUtils.isNotBlank(mbdSmlStr)) {
InputStream is = null;
try {
is = IOUtils.toInputStream(mbdSmlStr, "UTF-8");
ContentUtil.addApplicationData(epm, ModelService.FILE_NAME_MBDATTRIBUTES,
is, "", ContentRoleType.SECONDARY.toString());
epm = (EPMDocument) PersistenceHelper.manager.refresh(epm);
} finally {
if (is != null) {
is.close();
}
}
} else {//非R模型,删掉紧固件XML
try {
System.out.println("Non R Model, Delete Fasteners.xml");
epm = (EPMDocument) ContentUtil.deleteSecondaryFile(epm,
ModelService.FILE_NAME_FASTENERS);
wtPart = (WTPart) ContentUtil.deleteSecondaryFile(wtPart,
ModelService.FILE_NAME_FASTENERS);
} catch (Exception e) {
System.out.println("Non R Model, Delete Fasteners.xml error..." + e);
}
}
System.out.println(" 收集上一次检入(新建则无)技术注释、材料注释关联技术文件>>>>");
Set<WTDocumentMaster> previousMBDRefDocs = modelService.previousMBDRefDocs(wtPart);
System.out.println("previousMBDRefDocs : " + previousMBDRefDocs);
System.out.println(" 处理技术附注使用>>>>");
//保存技术附注使用
//创建文与引用档关联关系
Set<WTDocumentMaster> keepOrCreatePartRefLink2DocMasters = new HashSet<WTDocumentMaster>();
System.out.println(" 处理材料使用>>>>");
boolean needRoughSize = true;
String ibaRoughSize = "";
//保存材料附注使用
//创建与引用档关联关系
epm = (EPMDocument) PersistenceHelper.manager.refresh(epm);
wtPart = (WTPart) PersistenceHelper.manager.refresh(wtPart);
System.out.println("处理部件与技术注释、材料注释引用技术文件关联关系>>>>");
System.out.println("keepOrCreatePartRefLink2DocMasters : "
+ keepOrCreatePartRefLink2DocMasters);
//若存在于上一次检入,不存在于此次检入,则需要移除关系
Set<WTDocumentMaster> deletePartRefLink2Doc = new HashSet<WTDocumentMaster>();
for (WTDocumentMaster docMaster : previousMBDRefDocs) {
if (!keepOrCreatePartRefLink2DocMasters.contains(docMaster)) {
deletePartRefLink2Doc.add(docMaster);
}
}
System.out.println("deletePartRefLink2Doc : " + deletePartRefLink2Doc);
// System.out.println(" 删除未引用注释关联技术文件链接>>>> ");
// PartUtil.removePartReferenceLinkByDocMasters(wtPart, deletePartRefLink2Doc);
wtPart = (WTPart) PersistenceHelper.manager.refresh(wtPart);
// System.out.println(" 创建引用注释关联技术文链接>>>> ");
// PartUtil.newPartReferenceLink(wtPart, keepOrCreatePartRefLink2DocMasters);
System.out.println("处理部件数模关系>>>>");
//Part EPM 关联关系
//清除原PartEPMLink关系
System.out.println(" 清除部件关联数模关系>>>>");
CadPartUtil.clearPartEPMLinks(wtPart);
wtPart = (WTPart) PersistenceHelper.manager.refresh(wtPart);
//新建Link关系集合
WTList newLinks = new WTArrayList();
//3-D
EPMBuildRule epmBuildRule = EPMBuildRule.newEPMBuildRule(epm, wtPart);
newLinks.add(epmBuildRule);
EPMBuildHistory ebh = EPMBuildHistory.newEPMBuildHistory(epm, wtPart,
epmBuildRule.getUniqueID());
newLinks.add(ebh);
//创建Links
if (newLinks.size() != 0) {
PersistenceServerHelper.manager.insert(newLinks);
}
System.out.println("记录装配关系");
//记录装配关系
List<ModelBaseInfo> children = modelBaseInfo.getChildren();
if (children != null) {
List<ModelBaseInfo> bomUses = bomUsesMap.get(wtPart);
if (bomUses == null) {
bomUses = new ArrayList<ModelBaseInfo>();
bomUsesMap.put(wtPart, bomUses);
}
bomUses.addAll(children);
}
}
}
}
//
// /**
// * 基于顶层件号获取最新顶层EBOM结构
......@@ -1114,5 +607,4 @@ public class CADProService implements RemoteAccess {
// System.out.println("calulateDSLORelation<<<<<<<<<<");
// return null;
// }
}
......@@ -643,7 +643,7 @@ public class CadCheckService implements RemoteAccess {
if (!isIngoreUpdate) {
//处理EPM
System.out.println("开始处理数模...");
System.out.println(" 数模主内容>>>>");
System.out.println(" 数模主内容>>>>modelFileUri:"+modelFileUri+" modelFileName:"+modelFileName);
if (StringUtils.isNotBlank(modelFileUri)) {
//处理EPM主内容
String primaryFilePath = ModelService.transferModelFilePathFromZIPByCopy(modelFileUri, modelFileName);
......
......@@ -11,6 +11,7 @@ import com.yonde.cadpro.config.CadFTPConfig;
import com.yonde.cadpro.config.CatiaClientConfig;
import com.yonde.cadpro.config.CatiaInteConfigPropertiesUtil;
import com.yonde.cadpro.util.*;
import com.yonde.cadpro.visualization.facade.VisualizationFacade;
import com.yonde.common.*;
import com.yonde.common.util.TypeAttrUtil;
import org.apache.commons.io.FileUtils;
......@@ -88,6 +89,7 @@ public class ModelService {
/**
* 模型查询,参数numbers和name不能同时传递
*
* @param numbers 模型编号列表,使用逗号隔开
* @param name 模型名称,使用*通配符
* @param offSet 起始条目,从1开始
......@@ -183,6 +185,7 @@ public class ModelService {
/**
* 模型查询,参数numbers
*
* @param numbers 模型编号集合
* @return 模型ModelBaseInfo列表
* @throws Exception
......@@ -230,7 +233,7 @@ public class ModelService {
}
/**
*依据编号查询模型结构
* 依据编号查询模型结构
*
* @param number
* @param level -1 All level
......@@ -315,7 +318,7 @@ public class ModelService {
}
/**
*获取顶层结构树,至DS层结束
* 获取顶层结构树,至DS层结束
*
* @param level -1 All level
* @return 模型ModelBaseInfo列表树
......@@ -365,7 +368,7 @@ public class ModelService {
partTypeDisplay = TypeAttrUtil.getAttributeDisplayName(ti.getTypename());
}
} catch (Exception e) {
System.out.println("Get Part typeName error..."+ e);
System.out.println("Get Part typeName error..." + e);
}
System.out.println("partTypeDisplay : " + partTypeDisplay);
if (bomAllowTypes != null && bomAllowTypes.size() > 0) {
......@@ -479,6 +482,7 @@ public class ModelService {
/**
* 依据编号查询模型结构
*
* @param number
* @param baselineId 基线配置规范
* @param level
......@@ -537,9 +541,10 @@ public class ModelService {
partConfigSpec = WTPartConfigSpec
.newWTPartConfigSpec(WTPartStandardConfigSpec
.newWTPartStandardConfigSpec(ViewHelper.service
.getView("Design"), null));;
.getView("Design"), null));
;
} catch (Exception e) {
System.out.println("getBOMWithBaseline partConfigSpec error..."+ e);
System.out.println("getBOMWithBaseline partConfigSpec error..." + e);
throw new WTException(e);
}
}
......@@ -565,6 +570,7 @@ public class ModelService {
/**
* 模型检出
*
* @param numbers
* @return
* @throws Exception
......@@ -621,6 +627,7 @@ public class ModelService {
/**
* 模型检出
*
* @param numbers
* @return
* @throws Exception
......@@ -667,7 +674,7 @@ public class ModelService {
tx.commit();
tx = null;
} catch (Exception e) {
System.out.println("Checkout EPM[" + number + "]error... "+ e);
System.out.println("Checkout EPM[" + number + "]error... " + e);
errorInfos.add(constructErrorInfos(number, "数模[" + number + "]执行检出失败:"
+ e.getMessage()));
} finally {
......@@ -694,6 +701,7 @@ public class ModelService {
/**
* 模型撤销检出
*
* @param numbers
* @return
* @throws Exception
......@@ -753,6 +761,7 @@ public class ModelService {
/**
* 模型撤销检出
*
* @param numbers
* @return
* @throws Exception
......@@ -797,7 +806,7 @@ public class ModelService {
tx.commit();
tx = null;
} catch (Exception e) {
System.out.println("UnDoCheckout EPM[" + number + "]error... "+ e);
System.out.println("UnDoCheckout EPM[" + number + "]error... " + e);
errorInfos.add(constructErrorInfos(number, "数模[" + number + "]执行撤销检出失败:"
+ e.getMessage()));
} finally {
......@@ -817,6 +826,7 @@ public class ModelService {
/**
* 模型撤销检出
*
* @param numbers
* @return
* @throws Exception
......@@ -837,7 +847,7 @@ public class ModelService {
try {
isDSNumber = dsNumberValidator.execute();
} catch (Exception e) {
System.out.println("DSNumberValidator error..."+ e);
System.out.println("DSNumberValidator error..." + e);
}
if (isDSNumber) {
dsNumbers.add(number);
......@@ -855,6 +865,7 @@ public class ModelService {
/**
* 模型检入
*
* @param models
* @throws Exception
*/
......@@ -1118,7 +1129,7 @@ public class ModelService {
// Get Sub Parts
Persistable[][][] all_children = WTPartHelper.service.getUsesWTParts(wtList,
partStandardConfigSpec);
for (ListIterator<WTPart> i = wtList.persistableListIterator(); i.hasNext();) {
for (ListIterator<WTPart> i = wtList.persistableListIterator(); i.hasNext(); ) {
WTPart parent = i.next();
Persistable[][] branch = all_children[i.previousIndex()];
if (branch == null) {
......@@ -1181,13 +1192,13 @@ public class ModelService {
IBAUtil.forceSetIBAValue(wtPart, attrKey, attrValue);
} catch (Exception e) {
System.out.println("wtPart[" + wtPart.getDisplayIdentifier()
+ "] setIBAAnyValue error..."+ e);
+ "] setIBAAnyValue error..." + e);
}
try {
IBAUtil.forceSetIBAValue(epm, attrKey, attrValue);
} catch (Exception e) {
System.out.println("epm [" + epm.getDisplayIdentifier()
+ "] setIBAAnyValue error..."+ e);
+ "] setIBAAnyValue error..." + e);
}
}
epm = (EPMDocument) PersistenceHelper.manager.refresh(epm);
......@@ -1472,7 +1483,7 @@ public class ModelService {
//处理usageLinks集合
if (oringinalUsages != null) {
for (Iterator<WTPartMaster> it = oringinalUsages.keySet().iterator(); it
.hasNext();) {
.hasNext(); ) {
WTPartUsageLink link = oringinalUsages.get(it.next());
if (!remainLinks.contains(link))
deleteLinks.add(link);//需要删除
......@@ -1525,7 +1536,7 @@ public class ModelService {
}
}
} catch (Exception e) {
System.out.println("convertTransform error..."+ e);
System.out.println("convertTransform error..." + e);
}
System.out.println("formatTrasnForm : " + formatTrasnForm);
return formatTrasnForm;
......@@ -1541,6 +1552,7 @@ public class ModelService {
/**
* 从MBD属性中获取待处理IBA属性
*
* @param mbdDatas
* @return
*/
......@@ -1572,7 +1584,6 @@ public class ModelService {
}
/**
*
* @param mbdAttr
* @param attrMapping 属性映射关系
* @param processIBAMap 待处理IBA集合
......@@ -1610,6 +1621,7 @@ public class ModelService {
/**
* 从MBD属性中获取待处理IBA属性、R模型定义属性
*
* @param mbdDatas
* @return
*/
......@@ -1642,6 +1654,7 @@ public class ModelService {
/**
* 模型检入
*
* @param models
* @throws Exception
*/
......@@ -1651,7 +1664,7 @@ public class ModelService {
try {
System.out.println("models Str: " + JsonUtils.toJsonStr(models));
} catch (Exception e) {
System.out.println("toJsonStr error..."+ e);
System.out.println("toJsonStr error..." + e);
}
......@@ -1868,7 +1881,7 @@ public class ModelService {
try {
defaultPostion = CatiaInteConfigPropertiesUtil.getAbsolutePositionDefault();
} catch (Exception e) {
System.out.println("position default..."+ e);
System.out.println("position default..." + e);
}
//Set Default Position
dsPositionInfo = defaultPostion;
......@@ -2276,13 +2289,13 @@ public class ModelService {
IBAUtil.forceSetIBAValue(wtPart, attrKey, attrValue);
} catch (Exception e) {
System.out.println("wtPart[" + wtPart.getDisplayIdentifier()
+ "] setIBAAnyValue error..."+ e);
+ "] setIBAAnyValue error..." + e);
}
try {
IBAUtil.forceSetIBAValue(epm, attrKey, attrValue);
} catch (Exception e) {
System.out.println("epm [" + epm.getDisplayIdentifier()
+ "] setIBAAnyValue error..."+ e);
+ "] setIBAAnyValue error..." + e);
}
}
epm = (EPMDocument) PersistenceHelper.manager.refresh(epm);
......@@ -2362,7 +2375,7 @@ public class ModelService {
wtPart = (WTPart) ContentUtil.deleteSecondaryFile(wtPart,
FILE_NAME_FASTENERS);
} catch (Exception e) {
System.out.println("Non R Model, Delete Fasteners.xml error..."+ e);
System.out.println("Non R Model, Delete Fasteners.xml error..." + e);
}
// }
......@@ -2634,6 +2647,7 @@ public class ModelService {
/**
* 校验零组件编号和模型文件名称是否匹配
*
* @param number
* @param modelFileName
* @throws WTException
......@@ -2648,6 +2662,7 @@ public class ModelService {
/**
* 下载模型文件缓存至服务器
*
* @param modelFileUri
* @param modelFileName
* @return
......@@ -2679,6 +2694,7 @@ public class ModelService {
/**
* 下载模型文件至服务器缓存目录
*
* @param modelFileUri
* @param modelFileName
* @return
......@@ -2750,6 +2766,7 @@ public class ModelService {
/**
* 拷贝模型文件至至服务器缓存目录
*
* @param modelFileUri
* @param modelFileName
* @return
......@@ -2800,17 +2817,34 @@ public class ModelService {
String fileExtension = FilenameUtils.getExtension(modelFileUri);
fileExtension = StringUtils.trimToEmpty(fileExtension);
fileExtension = fileExtension.toLowerCase();
System.out.println("fileExtension : " + fileExtension);
if (!"catzip".equals(fileExtension)) {
throw new WTException("modelFileUri[" + modelFileUri + "] must catzip format");
}
File soruceZip = new File(sourceZipPath);
if (!soruceZip.exists()) {
throw new WTException(soruceZip.getAbsolutePath() + "上传失败!");
//从worker机获取对应的文件文件新下
FtpUtil 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 remoteFilePath = absoluteRootPath + remotePath + zipName;
File file = new File(remoteFilePath);
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
System.out.println(">>>>2871 remoteFilePath" + remoteFilePath);
ftpUtil.downloadFile(remotePath + zipName, remoteFilePath);
ftpUtil.closeServer();
//throw new WTException(soruceZip.getAbsolutePath() + "上传失败!");
}
File toZip = new File(toPath + zipName);
//IOUtils.copyLarge(input, output);
FileUtils.moveFile(soruceZip, toZip);
//解压缩
......@@ -2829,6 +2863,7 @@ public class ModelService {
/**
* 下载缩略图缓存至服务器
*
* @param modelThumbnailUri
* @param modelFileName
* @return
......@@ -2874,6 +2909,7 @@ public class ModelService {
/**
* 下载缩略图至服务器缓存,必须在调用处理主内容之后调用
*
* @param modelThumbnailUri
* @param modelFileName
* @return
......@@ -2925,6 +2961,7 @@ public class ModelService {
/**
* 处理Part、EPM装配结构关系
*
* @param bomUsesMap <Part, 子装配信息>
* @param partEPMMap <Part, 3dEPM>
* @throws Exception
......@@ -2965,7 +3002,7 @@ public class ModelService {
// Get Sub Parts
Persistable[][][] all_children = WTPartHelper.service.getUsesWTParts(wtList,
partStandardConfigSpec);
for (ListIterator<WTPart> i = wtList.persistableListIterator(); i.hasNext();) {
for (ListIterator<WTPart> i = wtList.persistableListIterator(); i.hasNext(); ) {
WTPart parent = i.next();
Persistable[][] branch = all_children[i.previousIndex()];
if (branch == null) {
......@@ -3123,7 +3160,7 @@ public class ModelService {
System.out.println(" 处理需保留的结构关系(非CAD设计工具驱动生成Link)>>>>");
if (oringinalUsages != null) {//原结构关系
for (Iterator<WTPartMaster> it = oringinalUsages.keySet().iterator(); it
.hasNext();) {
.hasNext(); ) {
WTPartUsageLink link = oringinalUsages.get(it.next());
if (!remainLinks.contains(link)) {//在原结构上,不在新结构上
deleteLinks.add(link);//需要删除
......@@ -3151,6 +3188,7 @@ public class ModelService {
/**
* 处理Part、EPM装配结构关系
*
* @param bomUsesMap <Part, 子装配信息>
* @param partEPMMap <Part, 3dEPM>
* @throws Exception
......@@ -3192,7 +3230,7 @@ public class ModelService {
// Get Sub Parts
Persistable[][][] all_children = WTPartHelper.service.getUsesWTParts(wtList,
partStandardConfigSpec);
for (ListIterator<WTPart> i = wtList.persistableListIterator(); i.hasNext();) {
for (ListIterator<WTPart> i = wtList.persistableListIterator(); i.hasNext(); ) {
WTPart parent = i.next();
Persistable[][] branch = all_children[i.previousIndex()];
if (branch == null) {
......@@ -3406,7 +3444,7 @@ public class ModelService {
System.out.println(" 处理需保留的结构关系(非CAD设计工具驱动生成Link)>>>>");
if (oringinalUsages != null) {//原结构关系
for (Iterator<WTPartMaster> it = oringinalUsages.keySet().iterator(); it
.hasNext();) {
.hasNext(); ) {
WTPartUsageLink link = oringinalUsages.get(it.next());
if (!remainLinks.contains(link)) {//在原结构上,不在新结构上
//deleteLinks.add(link);//需要删除
......@@ -3484,7 +3522,7 @@ public class ModelService {
//获取供应商协同区
// WTContainer supplierContainer = supplierService.getSupplierSharingAarea();
//是否供应商操作
boolean isSupplierOP =false;// supplierContainer != null ? true : false;
boolean isSupplierOP = false;// supplierContainer != null ? true : false;
//从MBD属性中获取IBA属性
List<MBDAttribute> mbdDataList = modelBaseInfo.getMbdDatas();
......@@ -3527,7 +3565,7 @@ public class ModelService {
inputContainer = epm3D.getContainer();
inputFolder = epm3D.getLocation();
} catch (Exception e) {
System.out.println("get Container error by [" + epm3D + "]"+ e);
System.out.println("get Container error by [" + epm3D + "]" + e);
}
//创建EPM epmDocumentType_Drawing
......@@ -3628,7 +3666,7 @@ public class ModelService {
try {
IBAUtil.forceSetIBAValue(epm, attrKey, attrValue);
} catch (Exception e) {
System.out.println("epm [" + epm.getDisplayIdentifier() + "] setIBAAnyValue error..."+e);
System.out.println("epm [" + epm.getDisplayIdentifier() + "] setIBAAnyValue error..." + e);
}
}
epm = (EPMDocument) PersistenceHelper.manager.refresh(epm);
......@@ -3651,7 +3689,6 @@ public class ModelService {
}
/**
*
* 若三维模型图号以M-开头,零部件编号需要移除M-
*
* @param modelNumber
......@@ -3667,6 +3704,7 @@ public class ModelService {
/**
* 关联技术注释参考文档
*
* @param part
* @param techAnnotationNumber
* @param techAnnotationVersion
......@@ -3724,6 +3762,7 @@ public class ModelService {
/**
* 关联选用材料的参考文档
*
* @param part
* @param materialNo
* @param materialVersion
......@@ -3795,6 +3834,7 @@ public class ModelService {
/**
* 获取上一次检入关联的MBD引用文档
*
* @param contentHolder
* @return
*/
......@@ -3814,7 +3854,7 @@ public class ModelService {
//处理技术注释引用
ApplicationData appData = ContentUtil.getApplicationData(contentHolder,
new ContentRoleType[] { ContentRoleType.SECONDARY },
new ContentRoleType[]{ContentRoleType.SECONDARY},
FILE_NAME_TECHANNOTATIONS);
if (appData != null) {
InputStream inputstream = null;
......@@ -3867,7 +3907,7 @@ public class ModelService {
//处理材料技术注释引用
ApplicationData appDataMaterialAnno = ContentUtil.getApplicationData(
contentHolder, new ContentRoleType[] { ContentRoleType.SECONDARY },
contentHolder, new ContentRoleType[]{ContentRoleType.SECONDARY},
FILE_NAME_MATERIALANNOTATIONS);
if (appDataMaterialAnno != null) {
InputStream inputstream = null;
......@@ -3939,7 +3979,7 @@ public class ModelService {
}
}
} catch (Exception e) {
System.out.println("previousMBDRefDocs error..."+ e);
System.out.println("previousMBDRefDocs error..." + e);
}
}
return previousDocMasters;
......@@ -3977,6 +4017,7 @@ public class ModelService {
/**
* 切换回原始用户
*
* @param oriUserName
* @throws WTException
*/
......@@ -3987,7 +4028,7 @@ public class ModelService {
SessionHelper.manager.setPrincipal(oriUserName);
}
} catch (Exception e) {
System.out.println("switchToOringinalUser error..."+ e);
System.out.println("switchToOringinalUser error..." + e);
/*
WTPrincipal currentUser = SessionHelper.manager.getPrincipal();
System.out.println("switch to currentUser : " + currentUser.getName());
......@@ -4109,6 +4150,7 @@ public class ModelService {
/**
* 自动处理图号适配件号
*
* @param number
* @return
*/
......
package com.yonde.cadpro.service;
import com.yonde.cadpro.bean.DxCADBomVo;
import com.yonde.cadpro.pmi.PMIRoot;
import com.yonde.cadpro.util.ContentUtil;
import com.yonde.cadpro.util.EPMNumberComparator;
import com.yonde.cadpro.util.EPMUtil;
import com.yonde.cadpro.util.XMLMapper;
import com.yonde.cadpro.visualization.AssembleTransformUtil;
import com.yonde.cadpro.visualization.coordinate.AssembleTransformInfo;
import com.yonde.cadpro.visualization.coordinate.AssembleTransformSnapshot;
import com.yonde.common.CommonUtil;
import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.collections.comparators.ComparatorChain;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import wt.content.ApplicationData;
import wt.content.ContentItem;
import wt.content.ContentRoleType;
import wt.content.ContentServerHelper;
import wt.epm.EPMDocConfigSpec;
import wt.epm.EPMDocument;
import wt.epm.EPMDocumentMaster;
import wt.epm.structure.EPMMemberLink;
import wt.fc.Persistable;
import wt.fc.QueryResult;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.part.WTPart;
import wt.session.SessionServerHelper;
import wt.util.WTException;
import wt.vc.VersionControlException;
import wt.vc.VersionControlHelper;
import wt.vc.struct.StructHelper;
import wt.vc.wip.WorkInProgressException;
import wt.vc.wip.WorkInProgressHelper;
import javax.vecmath.Matrix4d;
import java.beans.PropertyVetoException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal;
import java.nio.charset.Charset;
import java.rmi.RemoteException;
import java.util.*;
@Service
public class PartVisService implements RemoteAccess {
public static final String WTPARTIDPREFIX = "OR:wt.part.WTPart:";
/**
* 获取CAD PMI结构化信息
*
* @param epm
* @return
* @throws WTException
* @throws PropertyVetoException
*/
public PMIRoot pmiInfo(EPMDocument epm) throws Exception {
PMIRoot pmiRoot = null;
if (epm != null) {
System.out.println("process epm : " + epm.getDisplayIdentifier());
List<ContentItem> contentItems = ContentUtil.getContentsByRole(epm,
new ContentRoleType[]{ContentRoleType.XML_FRAGMENT});
if (contentItems != null && contentItems.size() > 0) {
ContentItem ci = contentItems.get(0);
if (ci instanceof ApplicationData) {
ApplicationData appData = (ApplicationData) ci;
InputStream inputstream = null;
try {
inputstream = ContentServerHelper.service.findContentStream(appData);
pmiRoot = XMLMapper.xmlToBean(inputstream, PMIRoot.class, Charset.forName("UTF-8"));
} finally {
if (inputstream != null) {
inputstream.close();
}
}
}
}
}
return pmiRoot;
}
public static void main(String[] args) throws InvocationTargetException, RemoteException {
if (!RemoteMethodServer.ServerFlag) {
RemoteMethodServer.getDefault().invoke("expandCADBom", PartVisService.class.getName(), null,
new Class[]{String.class, String.class}, new Object[]{"OR:wt.epm.EPMDocument:386066", "wcadmin"});
}
}
/**
* 获取CAD父装配及可视化坐标
*
* @param oid
* @param userName
* @return
* @throws WTException
* @throws Exception
*/
public static DxCADBomVo expandCADBom(String oid, String userName) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxCADBomVo) RemoteMethodServer.getDefault().invoke("expandCADBom", PartVisService.class.getName(), null,
new Class[]{String.class, String.class},
new Object[]{oid, userName});
} else {
oid = WTPARTIDPREFIX + oid;
System.out.println(">>>expandCADBom oid:" + oid + " userName:" + userName);
boolean enforced = true;
try {
CommonUtil.initSessionContext(userName);
enforced = SessionServerHelper.manager.setAccessEnforced(false);
Persistable per = CommonUtil.getPersistableByOid(oid);
if (per == null) {
throw new WTException("获取根对象异常");
}
EPMDocument rootEPM = null;
if (per instanceof WTPart) {
WTPart part = (WTPart) per;
rootEPM = EPMUtil.getAssociatedEPM(part);
} 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);
rootMatrix.setIdentity();
rootVo = constructCADBomVo(rootEPM, null, rootMatrix);
if (rootVo != null) {
String trans = matrix4d2String(rootMatrix);
rootVo.setTransform(trans);
}
}
return rootVo;
} catch (Exception e) {
throw new WTException(e);
} finally {
SessionServerHelper.manager.setAccessEnforced(enforced);
}
}
}
public static DxCADBomVo constructCADBomVo(EPMDocument epmDoc, EPMMemberLink forParentMemberLink,
Matrix4d parentMat) throws WTException {
DxCADBomVo cadBOMVo = null;
if (epmDoc != null) {
System.out.println("epmDoc Dis: " + epmDoc + "---- " + epmDoc.getDisplayIdentity());
epmDoc = assemblyOriginal(epmDoc);
System.out.println("forParentMemberLink : " + forParentMemberLink);
cadBOMVo = DxCADBomVo.newDxCADBomVo(epmDoc, forParentMemberLink, true);
System.out.println("cadBOMVo : " + cadBOMVo);
Map<EPMMemberLink, EPMDocument> allChildsWithLink = new HashMap<EPMMemberLink, EPMDocument>();
List<EPMDocument> allChilds = new ArrayList<EPMDocument>();
//使用最新配置规范
EPMDocConfigSpec epmDocConfigSpec = new EPMDocConfigSpec();
epmDocConfigSpec.setLatestActive();
QueryResult qr = StructHelper.service.navigateUsesToIteration(epmDoc,
EPMMemberLink.class, false, epmDocConfigSpec);
if (qr != null) {
while (qr.hasMoreElements()) {
Persistable[] pp = (Persistable[]) qr.nextElement();
EPMMemberLink memberLink = (EPMMemberLink) pp[0];
Persistable per = pp[1];
if (per instanceof EPMDocument) {
EPMDocument childEPM = (EPMDocument) per;
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...");
allChilds.add(childEPM);
}
} else if (per instanceof EPMDocumentMaster) {
System.out.println("[" + per + "] is Master...");
} else {
System.out.println("[" + per + "] is invalid...");
}
}
}
if (allChilds.size() > 0) {
//子件编号排序
Collections.sort(allChilds, new EPMNumberComparator());
StringBuilder cadStructureBuilder = appendEPMInfo(null, epmDoc);
for (EPMDocument childEPM : allChilds) {
appendEPMInfo(cadStructureBuilder, childEPM);
}
String cadStructureKey = cadStructureBuilder.toString();
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);
DxCADBomVo childVo = null;
Matrix4d calculateMatrix = null;
if (snapshot != null) {
//使用parentEPM、childEPM查询assembleTransformInfo
List<AssembleTransformInfo> infoQr = AssembleTransformUtil.findAssembleTransformInfo(
snapshot.getId(), EPMUtil.getOROid(epmDoc),
EPMUtil.getOROid(linkedChildEPM), null,
EPMUtil.getOROid(epmMemberLink));
AssembleTransformInfo assembleTransformInfo = null;
Iterator<AssembleTransformInfo> iterator = infoQr.iterator();
if (iterator.hasNext()) {
assembleTransformInfo = (AssembleTransformInfo) iterator.next();
}
calculateMatrix = calculateMatrixByAssembleTransformInfo2(assembleTransformInfo, parentMat);
System.out.println("calculateMatrix[" + calculateMatrix + "] by ["
+ assembleTransformInfo + "]");
childVo = constructCADBomVo(linkedChildEPM, epmMemberLink, calculateMatrix);
} else {
System.out.println(
"epmDoc[" + epmDoc + "] can't find AssembleTransformSnapshot.....");
childVo = constructCADBomVo(linkedChildEPM, epmMemberLink, null);
}
String trans = matrix4d2String(calculateMatrix);
System.out.println("trans : " + trans);
if (childVo != null) {
childVo.setTransform(trans);
cadBOMVo.getChildren().add(childVo);
}
}
//Sort
ComparatorChain attrComparatorChain = new ComparatorChain();
attrComparatorChain.addComparator(new BeanComparator("number"));
Collections.sort(cadBOMVo.getChildren(), attrComparatorChain);
}
}
return cadBOMVo;
}
private static EPMDocument assemblyOriginal(EPMDocument epmDoc)
throws WorkInProgressException, WTException {
if (epmDoc != null && EPMUtil.isCADAssembly(epmDoc)) {//若是装配需检查是否检出,获取CO版本
if (WorkInProgressHelper.isWorkingCopy(epmDoc)) {
epmDoc = (EPMDocument) WorkInProgressHelper.service.originalCopyOf(epmDoc);
System.out.println("epmDoc is checked out Assembly, get OringinalCopy Version : " + epmDoc);
}
}
return epmDoc;
}
/**
* CADPro检入记录TransformInfo,需要3*3转制,最后一组处理坐标单位除以1000(检入坐标使用mm,可视化使用m)
*
* @param assembleTransformInfo
* @param parentMatrix
* @return
* @throws WTException
*/
public static Matrix4d calculateMatrixByAssembleTransformInfo(
AssembleTransformInfo assembleTransformInfo, Matrix4d parentMatrix) throws WTException {
System.out.println("calculateMatrixByAssembleTransformInfo assembleTransformInfo : "
+ assembleTransformInfo);
Matrix4d calculateMatrix = null;
if (assembleTransformInfo != null) {
String trasnformStr = assembleTransformInfo.getTransform();
System.out.println("trasnformStr : " + trasnformStr);
//Transform transform = null;
Matrix4d matrix4d = null;
if (StringUtils.isNotBlank(trasnformStr)) {
// 装配位置矩阵转换
matrix4d = toMatrix4dByStr(trasnformStr);
/*
if (matrix4d != null) {
transform = Transform.newTransform(matrix4d);
}
*/
//3*3 行列转制
Matrix4d turnMatrix4d = new Matrix4d(matrix4d);
turnMatrix4d.setM00(matrix4d.getM00());
turnMatrix4d.setM01(matrix4d.getM10());
turnMatrix4d.setM02(matrix4d.getM20());
turnMatrix4d.setM10(matrix4d.getM01());
turnMatrix4d.setM11(matrix4d.getM11());
turnMatrix4d.setM12(matrix4d.getM21());
turnMatrix4d.setM20(matrix4d.getM02());
turnMatrix4d.setM21(matrix4d.getM12());
turnMatrix4d.setM22(matrix4d.getM22());
matrix4d = turnMatrix4d;
}
if (matrix4d == null) {
matrix4d = new Matrix4d();
matrix4d.setIdentity();
}
System.out.println("matrix4d : " + matrix4d);
if (parentMatrix != null) {
Matrix4d combmat = new Matrix4d();
combmat.mul(parentMatrix, matrix4d);
calculateMatrix = combmat;
} else {
calculateMatrix = matrix4d;
}
} else {
calculateMatrix = new Matrix4d();
calculateMatrix.setIdentity();
}
System.out.println("calculateMatrix : " + calculateMatrix);
return calculateMatrix;
}
/**
* @param assembleTransformInfo
* @param parentMatrix
* @return
* @throws WTException
*/
public static Matrix4d calculateMatrixByAssembleTransformInfo2(
AssembleTransformInfo assembleTransformInfo, Matrix4d parentMatrix) throws WTException {
System.out.println("calculateMatrixByAssembleTransformInfo assembleTransformInfo : " + assembleTransformInfo);
Matrix4d calculateMatrix = null;
if (assembleTransformInfo != null) {
String trasnformStr = assembleTransformInfo.getTransform();
System.out.println("trasnformStr : " + trasnformStr);
//Transform transform = null;
Matrix4d matrix4d = null;
if (StringUtils.isNotBlank(trasnformStr)) {
// 装配位置矩阵转换
matrix4d = toMatrix4dByStr2(trasnformStr);
/*
if (matrix4d != null) {
transform = Transform.newTransform(matrix4d);
}
*/
}
if (matrix4d == null) {
matrix4d = new Matrix4d();
matrix4d.setIdentity();
}
System.out.println("matrix4d : " + matrix4d);
if (parentMatrix != null) {
Matrix4d combmat = new Matrix4d();
combmat.mul(matrix4d, parentMatrix);
calculateMatrix = combmat;
} else {
calculateMatrix = matrix4d;
}
} else {
calculateMatrix = new Matrix4d();
calculateMatrix.setIdentity();
}
System.out.println("calculateMatrix : " + calculateMatrix);
return calculateMatrix;
}
/**
* 装配矩阵转换, 最后一组处理坐标单位除以1000(检入坐标使用mm,可视化使用m)
*
* @param transfrom(String)
* @return
*/
public static Matrix4d toMatrix4dByStr(String transfrom) {
final String defaultM = "0 0 0 0";
final String[] defaultS = {"0", "0", "0", "0"};
double[] dd = new double[16];
for (int i = 0; i < dd.length; i++) {
dd[i] = 0.0;
}
// 默认值
String m0 = "1 0 0 0";
String m1 = "0 1 0 0";
String m2 = "0 0 1 0";
String m3 = "0 0 0 1";
// 传入值
String[] array = transfrom.split(";");
if (array.length == 4) {
m0 = array[0].trim();
m1 = array[1].trim();
m2 = array[2].trim();
m3 = array[3].trim();
}
String[] mm = new String[]{m0, m1, m2, m3};
for (int row = 0; row < mm.length; row++) {
String s = mm[row];
if (s == null)
s = defaultM;
String[] ss = s.trim().split("\\s+");
if (ss.length != 4) {
System.out.println("坐标变换对象向量定义错误:" + s);
ss = defaultS;
}
for (int j = 0; j < ss.length; j++) {
try {
double m = Double.parseDouble(ss[j]);
if (row == 3 && j < 3) {
m = mul(m, 0.001D);
}
dd[row * 4 + j] = m;
} catch (NumberFormatException nfe) {
System.out.println("坐标变换对象中包含非法数值:==>" + s);
}
}
}
return new Matrix4d(dd);
}
/**
* 装配矩阵转换, 使用空格分隔
*
* @param transfrom(String)
* @return
*/
public static Matrix4d toMatrix4dByStr2(String transfrom) {
System.out.println("toMatrix4dByStr2 by transfrom[" + transfrom + "]");
Matrix4d result = null;
String[] arrays = transfrom.trim().split("\\s+");
if (arrays.length == 16) {
double[] dd = new double[16];
for (int i = 0; i < 16; i++) {
try {
double m = Double.parseDouble(arrays[i]);
dd[i] = m;
} catch (Exception e) {
System.out.println("toMatrix4dByStr2 format error [" + arrays[i] + "]...");
dd[i] = 0.0;
}
}
result = new Matrix4d(dd);
} else {
System.out.println("transfrom[" + transfrom + "] format is invalid, use default Matrix4d...");
result = new Matrix4d();
result.setIdentity();
}
return result;
}
public static double mul(double d1, double d2) {
BigDecimal b1 = new BigDecimal(d1);
BigDecimal b2 = new BigDecimal(d2);
return b1.multiply(b2).doubleValue();
}
/**
* 基于一层结构取AssembleTransformSnapshot
* 若不存在结构hash对应的AssembleTransformSnapshot, 则使用parentEPM查询最新AssembleTransformSnapshot
*
* @param cadStructureKey
* @param parentEPM
* @return
*/
private static AssembleTransformSnapshot getAssembleTransformSnapshotByStructure(
String cadStructureKey, EPMDocument parentEPM) {
AssembleTransformSnapshot assembleTransformSnapshot = null;
System.out.println("cadStructureKey : " + cadStructureKey);
if (StringUtils.isNotBlank(cadStructureKey)) {
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);
} catch (Exception e) {
System.out.println("getAssembleTransformSnapshotByHash error..." + e);
}
}
System.out.println("assembleTransformSnapshot : " + assembleTransformSnapshot);
return assembleTransformSnapshot;
}
public static StringBuilder appendEPMInfo(StringBuilder keyBuilder, EPMDocument epm)
throws VersionControlException {
if (keyBuilder == null) {
keyBuilder = new StringBuilder();
}
if (epm != null) {
System.out.println("append[" + epm.getDisplayIdentity() + "] info");
if (keyBuilder.length() != 0) {
keyBuilder.append("|");
}
keyBuilder.append(epm.getNumber());
keyBuilder.append("<");
keyBuilder.append(VersionControlHelper.getVersionIdentifier(epm).getValue());
keyBuilder.append(".");
keyBuilder.append(VersionControlHelper.getIterationIdentifier(epm).getValue());
keyBuilder.append(">");
}
return keyBuilder;
}
public static String matrix4d2String(Matrix4d matrix4d) throws WTException {
String transformStr = "";
List<Double> elements = new ArrayList<Double>();
if (matrix4d != null) {
for (int j = 0; j < 4; j++) {
for (int k = 0; k < 4; k++) {
double tempElement = matrix4d.getElement(j, k);
elements.add(tempElement);
}
}
if (elements.size() == 16) {
transformStr = elements.toString();
} else {
System.out.println("matrix4d to String error..." + elements);
}
}
return transformStr;
}
/**
* 取数据序号
*
* @param lineNos
* @return
*/
private String getLineNo(List<Integer> lineNos) {
String lineNo = "";
if (lineNos.size() == 0) {
lineNos.add(1);
} else {
Integer temp = lineNos.get((lineNos.size() - 1));
lineNos.add(temp + 1);
}
lineNo = String.valueOf(lineNos.get((lineNos.size() - 1)));
return lineNo;
}
public static final Integer KB_SIZE = 2 << 9;
public static final Integer MB_SIZE = 2 << 19;
public static final Integer GB_SIZE = 2 << 29;
public static BigDecimal bytes2Unit(long bytes, Integer unit) {
BigDecimal size = new BigDecimal(bytes);
BigDecimal u = new BigDecimal(unit);
return size.divide(u, 2, BigDecimal.ROUND_DOWN);
}
public static Long unit2Byte(BigDecimal decimal, Integer unit) {
return decimal.multiply(BigDecimal.valueOf(unit)).longValue();
}
public static Long kb2Byte(BigDecimal decimal) {
return decimal.multiply(BigDecimal.valueOf(KB_SIZE)).longValue();
}
public static Long mb2Byte(BigDecimal decimal) {
return decimal.multiply(BigDecimal.valueOf(MB_SIZE)).longValue();
}
public static Long gb2Byte(BigDecimal decimal) {
return decimal.multiply(BigDecimal.valueOf(GB_SIZE)).longValue();
}
public static BigDecimal bytes2Kb(long bytes) {
return bytes2Unit(bytes, KB_SIZE);
}
public static BigDecimal bytes2Mb(long bytes) {
return bytes2Unit(bytes, MB_SIZE);
}
public static BigDecimal bytes2Gb(long bytes) {
return bytes2Unit(bytes, GB_SIZE);
}
}
package com.yonde.cadpro.util;
import com.ptc.core.components.util.OidHelper;
import com.ptc.core.htmlcomp.jstable.SandboxStatusHelper;
import com.ptc.core.htmlcomp.jstable.ServerStatusHelper;
import org.apache.commons.lang.StringUtils;
import wt.access.AccessControlHelper;
import wt.access.AccessPermission;
import wt.epm.workspaces.EPMWorkspace;
import wt.fc.ObjectReference;
import wt.fc.Persistable;
import wt.fc.WTReference;
import wt.fc.collections.WTCollection;
import wt.folder.Folder;
import wt.inf.container.WTContained;
import wt.inf.container.WTContainer;
import wt.inf.container.WTContainerRef;
import wt.org.WTPrincipal;
import wt.session.SessionHelper;
import wt.session.SessionServerHelper;
import wt.util.WTException;
import wt.util.WTRuntimeException;
import wt.vc.Iterated;
import wt.vc.OneOffVersioned;
import wt.vc.Versioned;
import wt.vc.wip.CheckoutLink;
import wt.vc.wip.WorkInProgressHelper;
import wt.vc.wip.Workable;
import java.util.ArrayList;
public class WIPUtil {
/**
* 执行检出
* @param workable
* @param note
* @return
* @throws WTException
*/
public static Workable doCheckOut(Workable workable, String note) throws WTException {
Workable wrkObj = null;
try {
if (WorkInProgressHelper.isCheckedOut(workable, SessionHelper.manager.getPrincipal())) {//是否当前用户检出
if (WorkInProgressHelper.isWorkingCopy(workable)) {
wrkObj = workable;
} else {
wrkObj = WorkInProgressHelper.service.workingCopyOf(workable);
}
} else {
note = StringUtils.trimToEmpty(note);
Folder folder = WorkInProgressHelper.service.getCheckoutFolder();
CheckoutLink checkoutLink = WorkInProgressHelper.service.checkout(workable, folder,
note);
if (checkoutLink != null) {
wrkObj = checkoutLink.getWorkingCopy();
}
}
} catch (Exception e) {
System.out.println("doCheckOut error..."+ e);
throw new WTException(e);
}
return wrkObj;
}
/**
* 撤销检出
* @param workable
* @return
* @throws WTException
*/
public static Workable undoCheckout(Workable workable) throws WTException {
Workable undoCheckoutObj = null;
if (workable != null) {
if (!WorkInProgressHelper.isCheckedOut(workable,
SessionHelper.manager.getPrincipal())) {
throw new WTException("对象[" + workable + "] 没有检出或者被其他用户检出。");
}
try {
if (!WorkInProgressHelper.isWorkingCopy(workable)) {
workable = WorkInProgressHelper.service.workingCopyOf(workable);
}
undoCheckoutObj = WorkInProgressHelper.service.undoCheckout(workable);
} catch (Exception e) {
System.out.println("undoCheckout error..."+ e);
throw new WTException("Obj[" + workable + "] undo check out error.");
}
}
return undoCheckoutObj;
}
/**
* 执行检入
* @param workable
* @return
* @throws WTException
*/
public static Workable doCheckIn(Workable workable) throws WTException {
return doCheckIn(workable, "Automatically checked in");
}
/**
* 执行检入
* @param workable
* @param comments
* @return
* @throws WTException
*/
public static Workable doCheckIn(Workable workable, String comments) throws WTException {
Workable checkedObj = workable;
try {
if (WorkInProgressHelper.isCheckedOut(workable, SessionHelper.manager.getPrincipal())) {//当前用户检出,则检入
checkedObj = (Workable) WorkInProgressHelper.service.checkin(workable, comments);
} else {
throw new WTException("对象[" + workable + "] 没有检出或者被其他用户检出。");
}
} catch (Exception e) {
System.out.println("doCheckIn error..."+ e);
throw new WTException(e);
}
return checkedObj;
}
/**
* 是否检出
* @param workable
* @return
* @throws WTException
*/
public static boolean isCheckedOut(Workable workable) throws WTException {
return WorkInProgressHelper.isCheckedOut(workable);
}
/**
* 是否检出
* @param workable
* @return
* @throws WTException
*/
public static boolean isCheckedOut(Workable workable, WTPrincipal principal)
throws WTException {
if (principal == null) {
principal = SessionHelper.manager.getPrincipal();
}
return WorkInProgressHelper.isCheckedOut(workable, principal);
}
/**
* 是否是工作副本
* @param workable
* @return
* @throws WTException
*/
public boolean isWorkingCopy(Workable workable) throws WTException {
boolean isWrk = false;
if (workable != null) {
if (WorkInProgressHelper.isWorkingCopy(workable)) {
isWrk = true;
}
}
return isWrk;
}
/**
* 获取工作副本
* @param workable
* @return
* @throws WTException
*/
public static Workable getWorkingCopyVersion(Workable workable) throws WTException {
Workable wrkObj = workable;
if (workable != null) {
try {
if (!WorkInProgressHelper.isWorkingCopy(workable)) {
wrkObj = WorkInProgressHelper.service.workingCopyOf(workable);
} else {
wrkObj = workable;
}
} catch (Exception e) {
System.out.println("getWorkingCopyVersion error..."+ e);
throw new WTException("getWorkingCopyVersion workable[" + workable + "] error.");
}
}
return wrkObj;
}
/**
* 获取检出者
* @param workable
* @return
* @throws WTException
*/
public static WTPrincipal getCheckoutUser(Workable workable) throws WTException {
WTPrincipal checkoutUser = null;
if (workable != null) {
try {
ObjectReference objectRef = ObjectReference.newObjectReference(workable);
WTContainer wtContainer = getContainer(objectRef);
ArrayList<ObjectReference> list = new ArrayList<ObjectReference>();
list.add(objectRef);
WTCollection wtCollection = OidHelper.getWTCollection(list);
ServerStatusHelper serverStatusHelper = new ServerStatusHelper(
wtCollection.subCollection(Workable.class), null,
new SandboxStatusHelper(wtCollection.subCollection(Workable.class), wtContainer), true);
serverStatusHelper.getServerStatus(workable);
//serverStatusHelper.getCheckedOutBy(workable);
checkoutUser = serverStatusHelper.getCheckedOutByUser(workable);
} catch (Exception e) {
System.out.println("getCheckoutUser..."+ e);
}
}
return checkoutUser;
}
private static WTContainer getContainer(WTReference wtRef) throws WTException {
boolean enforce = SessionServerHelper.manager.setAccessEnforced(false);
WTContainer wtContainer;
try {
wtContainer = getContainerAux(wtRef);
} finally {
SessionServerHelper.manager.setAccessEnforced(enforce);
}
if (!AccessControlHelper.manager.hasAccess(SessionHelper.getPrincipal(), wtContainer, AccessPermission.READ)) {
wtContainer = null;
}
return wtContainer;
}
private static WTContainer getContainerAux(WTReference wtReference) throws WTException {
if (wtReference == null) {
return null;
} else if (wtReference instanceof WTContainerRef) {
return ((WTContainerRef) wtReference).getReferencedContainer();
} else {
try {
Persistable per = wtReference.getObject();
if (per instanceof WTContained) {
return ((WTContained) per).getContainer();
} else {
return per instanceof EPMWorkspace ? ((EPMWorkspace) per).getContainer() : null;
}
} catch (WTRuntimeException runtimeException) {
System.out.println("getContainerAux..."+ runtimeException);
return null;
}
}
}
/**
* 获取版本显示值
* @param per
* @return
*/
public static String getVersionDisplayWithOneOff(Persistable per) {
String versionDisplay = "";
if (per == null) {
return versionDisplay;
}
String version = "";
String iteration = "";
String oneOffVersion = "";
if (per instanceof Iterated) {
Iterated iterated = (Iterated) per;
iteration = iterated.getIterationIdentifier().getValue();
}
if (per instanceof Versioned) {
Versioned ver = (Versioned) per;
version = ver.getVersionIdentifier().getValue();
}
if (per instanceof OneOffVersioned) {
OneOffVersioned oneOffVer = (OneOffVersioned) per;
oneOffVersion = oneOffVer.getOneOffVersionIdentifier().getValue();
}
if (StringUtils.isNotBlank(version)) {
versionDisplay = version;
}
if (StringUtils.isNotBlank(oneOffVersion)) {
if (StringUtils.isNotBlank(versionDisplay)) {
versionDisplay = versionDisplay + "-" + oneOffVersion;
} else {
versionDisplay = oneOffVersion;
}
}
if (StringUtils.isNotBlank(iteration)) {
if (StringUtils.isNotBlank(versionDisplay)) {
versionDisplay = versionDisplay + "." + iteration;
} else {
versionDisplay = iteration;
}
}
return versionDisplay;
}
}
package com.yonde.cadpro.util;
import org.apache.commons.lang.StringUtils;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
import wt.util.WTException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import javax.xml.bind.annotation.XmlAnyElement;
import java.io.*;
import java.nio.charset.Charset;
import java.util.Collection;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
public class XMLMapper {
public static String XML_HEADER = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n";
private static ConcurrentMap<Class, JAXBContext> jaxbContexts = new ConcurrentHashMap<Class, JAXBContext>();
/**
* 创建Marshaller并设定encoding(可为null).
* 线程不安全,需要每次创建或pooling。
*/
public static Marshaller createMarshaller(Class clazz, String encoding) {
try {
JAXBContext jaxbContext = getJaxbContext(clazz);
Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
if (StringUtils.isNotBlank(encoding)) {
marshaller.setProperty(Marshaller.JAXB_ENCODING, encoding);
}
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
return marshaller;
} catch (JAXBException e) {
e.printStackTrace();
}
return null;
}
/**
* 创建UnMarshaller.
* 线程不安全,需要每次创建或pooling。
*/
public static Unmarshaller createUnmarshaller(Class clazz) {
try {
JAXBContext jaxbContext = getJaxbContext(clazz);
return jaxbContext.createUnmarshaller();
} catch (JAXBException e) {
e.printStackTrace();
}
return null;
}
/**
* Java Object->Xml with encoding.
*/
public static String toXml(Object root, Class clazz, String encoding) {
try {
StringWriter writer = new StringWriter();
createMarshaller(clazz, encoding).marshal(root, writer);
return writer.toString();
} catch (JAXBException e) {
e.printStackTrace();
}
return "";
}
public static File toXmlFile(Object root, Class clazz, String encoding, String filePath) throws Exception {
File file = null;
FileWriter fWriter = null;
BufferedWriter bWriter = null;
try {
String xmlStr = toXml(root, clazz, encoding);
if(StringUtils.isNotBlank(xmlStr)) {
if(!xmlStr.startsWith(XML_HEADER)) {
xmlStr = XML_HEADER + xmlStr;
}
file = new File(filePath);
fWriter = new FileWriter(file);
bWriter = new BufferedWriter(fWriter);
bWriter.write(xmlStr);
bWriter.flush();
}
} finally {
if(fWriter != null) {
fWriter.close();
}
if(bWriter != null) {
bWriter.close();
}
}
if(file == null || !file.exists()) {
throw new WTException("生成XML文件异常!");
}
return file;
}
/**
* Xml->Java Object.
*/
public static <T> T fromXml(String xml, Class<T> clazz) {
try {
StringReader reader = new StringReader(xml);
return (T) createUnmarshaller(clazz).unmarshal(reader);
} catch (JAXBException e) {
e.printStackTrace();
}
return null;
}
/*
protected static JAXBContext getJaxbContext(Class clazz) {
try {
return JAXBContext.newInstance(clazz, clazz);
} catch (JAXBException e) {
e.printStackTrace();
}
return null;
}*/
protected static JAXBContext getJaxbContext(Class clazz) {
JAXBContext jaxbContext = jaxbContexts.get(clazz);
if (jaxbContext == null) {
try {
jaxbContext = JAXBContext.newInstance(clazz, CollectionWrapper.class);
if(jaxbContext == null){
jaxbContext = JAXBContext.newInstance(clazz);
}
jaxbContexts.putIfAbsent(clazz, jaxbContext);
} catch (JAXBException ex) {
ex.printStackTrace();
}
}
return jaxbContext;
}
/**
* 封装Root Element 是 Collection的情况.
*/
public static class CollectionWrapper {
@XmlAnyElement
protected Collection<?> collection;
}
public static File createXmlFile(String xmlString,String xmlPath,String encoding) throws IOException, DocumentException, WTException{
org.dom4j.Document document = DocumentHelper.parseText(xmlString);
//OutputFormat xmlFormat = OutputFormat.createPrettyPrint();
OutputFormat xmlFormat = new OutputFormat();
xmlFormat.setIndentSize(2);
xmlFormat.setNewlines(false);
xmlFormat.setTrimText(false);
xmlFormat.setPadText(true);
xmlFormat.setEncoding(encoding);
FileOutputStream out = null;
XMLWriter writer = null;
try {
out = new FileOutputStream(new File(xmlPath));
writer = new XMLWriter(out, xmlFormat);
writer.write(document);
writer.flush();
out.flush();
File file = new File(xmlPath);
if(file.exists()){
return file;
}
throw new WTException("生成数据包xml文件失败");
}finally{
if(out != null){
out.close();
}
if(writer != null){
writer.close();
}
}
}
@SuppressWarnings("unchecked")
public static <T> T xmlToBean(String xml , Class<T> clazz ) throws WTException, IOException {
try {
JAXBContext context = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = context.createUnmarshaller();
return (T) unmarshaller.unmarshal(new StringReader(xml));
} catch (JAXBException e) {
throw new WTException(e);
} finally {
}
}
@SuppressWarnings("unchecked")
public static <T> T xmlToBean(File file , Class<T> clazz ) throws WTException, IOException {
try {
JAXBContext context = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = context.createUnmarshaller();
return (T) unmarshaller.unmarshal(file);
} catch (JAXBException e) {
throw new WTException(e);
} finally {
}
}
@SuppressWarnings("unchecked")
public static <T> T xmlToBean(InputStream instream , Class<T> clazz ) throws WTException, IOException {
try {
JAXBContext context = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = context.createUnmarshaller();
InputStreamReader isReader = new InputStreamReader(instream);
return (T) unmarshaller.unmarshal(isReader);
} catch (JAXBException e) {
throw new WTException(e);
} finally {
instream.close();
}
}
@SuppressWarnings("unchecked")
public static <T> T xmlToBean(InputStream instream , Class<T> clazz, Charset charset) throws WTException, IOException {
try {
JAXBContext context = JAXBContext.newInstance(clazz);
Unmarshaller unmarshaller = context.createUnmarshaller();
InputStreamReader isReader = new InputStreamReader(instream, charset);
return (T) unmarshaller.unmarshal(isReader);
} catch (JAXBException e) {
throw new WTException(e);
} finally {
instream.close();
}
}
}
......@@ -39,10 +39,8 @@ public class ConvertCatia2B3dUtil {
HOST = catiaTransferConfig.getValueByKey(CONFIG_KEY_CATIA_TRANSFER_B3D_HOST);
PORT = catiaTransferConfig.getValueByKey(CONFIG_KEY_CATIA_TRANSFER_B3D_PORT);
TARGETNAMESPACE = catiaTransferConfig
.getValueByKey(CONFIG_KEY_CATIA_TRANSFER_B3D_TARGETNAMESPACE);
SERVICENAME = catiaTransferConfig
.getValueByKey(CONFIG_KEY_CATIA_TRANSFER_B3D_SERVICENAME);
TARGETNAMESPACE = catiaTransferConfig.getValueByKey(CONFIG_KEY_CATIA_TRANSFER_B3D_TARGETNAMESPACE);
SERVICENAME = catiaTransferConfig.getValueByKey(CONFIG_KEY_CATIA_TRANSFER_B3D_SERVICENAME);
logger.debug(HOST);
logger.debug(PORT);
......
......@@ -32,8 +32,8 @@ public class VisualizationFacade implements RemoteAccess, Serializable {
private static Logger logger = Logger.getLogger(VisualizationFacade.class);
private static ExtProperties officeTransferConfig = null;
private static ExtProperties catiaTransferConfig = null;
public static ExtProperties officeTransferConfig = null;
public static ExtProperties catiaTransferConfig = null;
private static VisualizationService visualizationService = null;
static {
......
......@@ -159,6 +159,7 @@ public class VisualizationService {
remoteFilePath = remoteFilePath.replace("\\", "/");
System.out.println("remoteFilePath :" + remoteFilePath);
//此处的文件路径为worker机catia.zip的路径
//3. 调用转可视化服务
WsResult wsResult = null;
if (contentHolder instanceof EPMDocument) {
......
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