Commit 573130d6 authored by hanson.yao's avatar hanson.yao

test cadpro client

parent 4adeaf5a
......@@ -18,4 +18,4 @@ ftp.port=21
ftp.username=ftpuser
ftp.password=Aa12345678!
ftp.remotePath=/
ftp.rootPath=E:/FTPHome
ftp.rootPath=D:/Inetpub/ftproot
package com.yonde.basedata.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.cadpro.bean.CADProUser;
import com.yonde.cadpro.service.CADProService;
import com.yonde.common.LdapUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.bind.annotation.*;
import wt.method.RemoteAccess;
import wt.util.WTException;
@RestController
@RequestMapping({"/login"})
public class LoginController {
public class LoginController implements RemoteAccess {
private static final Log log = LogFactory.getLog(LoginController.class);
/**
* 用户认证
*
* @param userName
* @return
* @throws JsonProcessingException
......@@ -26,4 +36,19 @@ public class LoginController {
}
return result;
}
/**
* CAD用户认证
*
* @param userName
* @return
*/
@SuppressWarnings("unchecked")
@RequestMapping(method = RequestMethod.POST)
@ResponseBody
public ApiResult<CADProUser> cadLoginAuth(@RequestParam String userName,
@RequestParam(required = false) String clientVersion) throws Exception {
System.out.print("cadLoginAuth info [userName]:" + userName + " [clientVersion]" + clientVersion);
return CADProService.cadProLogin(userName, clientVersion);
}
}
......@@ -6,7 +6,9 @@ import com.yonde.basedata.exception.DxErrorCodeData;
import org.apache.commons.lang.StringUtils;
import org.springframework.core.NestedExceptionUtils;
public class ApiResult<T> {
import java.io.Serializable;
public class ApiResult<T> implements Serializable {
public static final String SUCCESS = "0";
private String code;
......
......@@ -25,7 +25,7 @@ public enum DxErrorCodeData implements DxEnumData {
PROP_MAPPING_ERROR(19, "目标类[%s]属性映射错误[%s]"),
CURRENT_NOT_SUPPORT_CUSTOM_TYPE(20, "当前系统不支持自定义类型(json转对象)"),
CAN_NOT_FOUND_DX_TYPE(21, "没有找见对应的dxType类型[%s]"),
Service_Error(2100,"服务异常");
Service_Error(2100,"CADPro登录异常");
public static final String PREFIX = "BASEDATA_";
final String code;
final String value;
......
......@@ -13,7 +13,9 @@ import java.io.File;
public class CADProConstants {
public static String PART_DEFAULT_TYPE = "wt.part.WTPart";
public static final String AUTHORIZATION = "authorization";
public static final String BASIC = "Basic ";
public static String COMMA = ",";
public static String COMMA_ZH = ",";
public static String SEMICOLON = ";";
......
package com.yonde.cadpro;
public class DBConstant {
public static class ObjectSearchCondition{
public static String VIEW_ID = "view.key.id";
public static String ROLE_A_ID = "roleAObjectRef.key.id";
public static String ROLE_B_ID = "roleBObjectRef.key.id";
public static String THE_INFO_ID = "thePersistInfo.theObjectIdentifier.id";
public static String ROLE_A_CLASSNAME = "roleAObjectRef.key.classname";
public static String ROLE_B_CLASSNAME = "roleBObjectRef.key.classname";
public static String MASTER_ID = "masterReference.key.id";
public static String BRANCH_ID = "iterationInfo.branchId";
public static String STATE = "state.state";
public static String CREATOR = "creator.key.id";
public static String ITERATION_CREATOR = "iterationInfo.creator.key.id";
public static String MODIFIER = "modifier.key.id";
public static String ITERATION_MODIFIER = "iterationInfo.modifier.key.id";
public static String INTEROPINFO_IOPSTATE = "interopInfo.iopState";
public static String LATEST = "iterationInfo.latest";
public static String TYPE_BRANCHID = "typeDefinitionReference.key.branchId";
public static String IDENTIFIER_ID = "iterationInfo.identifier.iterationId";//iterationIdA2iterationInfo
}
public static class ObjectSearchCondition{
public static String VIEW_ID = "view.key.id";
public static String ROLE_A_ID = "roleAObjectRef.key.id";
public static String ROLE_B_ID = "roleBObjectRef.key.id";
public static String THE_INFO_ID = "thePersistInfo.theObjectIdentifier.id";
public static String ROLE_A_CLASSNAME = "roleAObjectRef.key.classname";
public static String ROLE_B_CLASSNAME = "roleBObjectRef.key.classname";
public static String MASTER_ID = "masterReference.key.id";
public static String BRANCH_ID = "iterationInfo.branchId";
public static String STATE = "state.state";
public static String CREATOR = "creator.key.id";
public static String ITERATION_CREATOR = "iterationInfo.creator.key.id";
public static String MODIFIER = "modifier.key.id";
public static String ITERATION_MODIFIER = "iterationInfo.modifier.key.id";
public static String INTEROPINFO_IOPSTATE = "interopInfo.iopState";
public static String LATEST = "iterationInfo.latest";
public static String TYPE_BRANCHID = "typeDefinitionReference.key.branchId";
public static String IDENTIFIER_ID = "iterationInfo.identifier.iterationId";//iterationIdA2iterationInfo
}
}
......@@ -5,7 +5,9 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
public class BatchResult {
import java.io.Serializable;
public class BatchResult implements Serializable {
public BatchResult() {
}
......
......@@ -30,7 +30,7 @@ public class DxBaseAttr {
* 属性单位
*/
private String unit;
public String getName() {
return name;
}
......
......@@ -12,16 +12,17 @@ import wt.content.ContentRoleType;
import wt.epm.EPMDocument;
import wt.epm.EPMDocumentType;
import java.io.Serializable;
import java.util.List;
/**
* @description:描述模型文件基本信息
*
*
* @author: Mr.Kent
* @create: 2020-11-24
**/
public class DxModelFile {
public class DxModelFile implements Serializable {
public static String PATH_SPLIT_BACK = "/";
public static String PATH_SPLIT = "\\";
......@@ -206,7 +207,7 @@ public class DxModelFile {
}
return visFile;
}
public static DxModelFile newPmiFile(EPMDocument epm) throws Exception {
DxModelFile visFile = null;
if (epm == null) {
......@@ -256,13 +257,13 @@ public class DxModelFile {
String modelFileUri = "";
long modelFileSize = 0L;
long modelFileCheckSum = 0L;
modelFileUri = ContentHelper.getDownloadURL(epm, primaryAppData, false, modelFileName)
.toExternalForm();
modelFileSize = primaryAppData.getFileSize();
modelFileCheckSum = primaryAppData.getChecksum();
modelFile = new DxModelFile();
modelFile.setFileId(primaryAppData.getPersistInfo().getObjectIdentifier().getId());
modelFile.setFileName(modelFileName);
......@@ -270,12 +271,12 @@ public class DxModelFile {
modelFile.setFileUri(modelFileUri);
modelFile.setFileCheckSum(String.valueOf(modelFileCheckSum));
modelFile.setFileType(FilenameUtils.getExtension(modelFileName));
//获取模型路径
String modelRelativePath = LWCUtil.getStringValue(epm,
GACEConstants.IBA_MODELRELATIVEPATH);
modelFile.setRelativePath(modelRelativePath);
modelFile.setSelectedNode(selectedNode);
}
return modelFile;
......
......@@ -51,7 +51,7 @@ public class DxParameter {
public void setChildren(List<DxParameter> children) {
this.children = children;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
......
......@@ -49,7 +49,7 @@ public class DxParameterAttr {
public void setLock(boolean isLock) {
this.isLock = isLock;
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
......
......@@ -4,8 +4,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.yonde.common.CommonUtil;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import wt.epm.EPMDocument;
import wt.org.WTPrincipal;
import wt.org.WTUser;
......@@ -15,6 +13,7 @@ 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;
......@@ -24,11 +23,10 @@ import java.util.Map;
* 部件模型实体类
*
* @description:
*
*
**/
public class DxPartModelBomVo {
public class DxPartModelBomVo implements Serializable {
private static Logger log = LoggerFactory.getLogger(DxPartModelBomVo.class);
private String partId;
......@@ -327,7 +325,7 @@ public class DxPartModelBomVo {
String oid = CommonUtil.getPersistableOid(wtPart);
String number = wtPart.getNumber();
String name = wtPart.getName();
String version = CommonUtil.getVersionDisplayWithOneOff(wtPart);
//String version = CommonUtil.getVersionDisplayWithOneOff(wtPart);
Boolean isCheckedOut = WorkInProgressHelper.isCheckedOut(wtPart);
//Add for 检出状态、检出者
CheckoutInfo checkInfo = wtPart.getCheckoutInfo();
......@@ -345,7 +343,7 @@ public class DxPartModelBomVo {
dxPartModelBomVo.setPartId(oid);
dxPartModelBomVo.setName(name);
dxPartModelBomVo.setNumber(number);
dxPartModelBomVo.setDisplayVersion(version);
//dxPartModelBomVo.setDisplayVersion(version);
dxPartModelBomVo.setState(state);
dxPartModelBomVo.setPartType(partTypeDisplay);
dxPartModelBomVo.setCheckOuted(isCheckedOut);
......@@ -367,7 +365,7 @@ public class DxPartModelBomVo {
String oid = CommonUtil.getPersistableOid(epm);
String number = epm.getNumber();
String name = epm.getName();
String version = CommonUtil.getVersionDisplayWithOneOff(epm);
//String version = CommonUtil.getVersionDisplayWithOneOff(epm);
Boolean isCheckedOut = WorkInProgressHelper.isCheckedOut(epm);
//Add for 检出状态、检出者
CheckoutInfo checkInfo = epm.getCheckoutInfo();
......@@ -387,14 +385,15 @@ public class DxPartModelBomVo {
DxModelFile modelFile = DxModelFile.newModelFile(epm);
dxPartModelBomVo.setModelFile(modelFile);
} catch (Exception e) {
log.error("获取模型信息失败", e);
e.printStackTrace();
System.out.println("获取模型信息失败");
}
}
dxPartModelBomVo.setPartId(oid);
dxPartModelBomVo.setName(name);
dxPartModelBomVo.setNumber(number);
dxPartModelBomVo.setDisplayVersion(version);
//dxPartModelBomVo.setDisplayVersion(version);
dxPartModelBomVo.setState(state);
dxPartModelBomVo.setPartType(partTypeDisplay);
dxPartModelBomVo.setCheckOuted(isCheckedOut);
......
......@@ -3,6 +3,7 @@ package com.yonde.cadpro.bean;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
......@@ -11,13 +12,13 @@ import java.util.List;
* @author wyue
*
*/
public class MBDAttribute {
public class MBDAttribute implements Serializable {
/**
* 属性名称
*/
private String key = "";
/**
* 属性值
*/
......
......@@ -3,6 +3,7 @@ package com.yonde.cadpro.bean;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
......@@ -10,7 +11,7 @@ import java.util.List;
* @author wyue
*
*/
public class MBDAttributes {
public class MBDAttributes implements Serializable {
@JacksonXmlElementWrapper(useWrapping = false)
@JacksonXmlProperty(localName = "MBDAttribute")
......
package com.yonde.cadpro.bean;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* 用于结构化数模的基本信息
* @author wyue
*
* @author wyue
*/
public class ModelBaseInfo {
public class ModelBaseInfo implements Serializable {
/**
* 模型OID
......@@ -110,9 +111,42 @@ public class ModelBaseInfo {
*/
private String modelRelativePath = "";
/**
* 产品代号(用于当前cad数据寻找容器)
*/
private String productCode;
public ModelBaseInfo() {
}
public ModelBaseInfo(String oid, String number, String name, String version, Boolean isCheckedOut,
String checkoutInfoState, String checkoutUser, String partTypeDisplay, String state,
String owner, String modelFileName, String modelFileUri, Long modelFileSize, Long modelFileCheckSum,
List<ModelBaseInfo> children, List<MBDAttribute> mbdDatas, String transform, Boolean isDrawing,
String modelThumbnailUri, String modelRelativePath, String productCode) {
this.oid = oid;
this.number = number;
this.name = name;
this.version = version;
this.isCheckedOut = isCheckedOut;
this.checkoutInfoState = checkoutInfoState;
this.checkoutUser = checkoutUser;
this.partTypeDisplay = partTypeDisplay;
this.state = state;
this.owner = owner;
this.modelFileName = modelFileName;
this.modelFileUri = modelFileUri;
this.modelFileSize = modelFileSize;
this.modelFileCheckSum = modelFileCheckSum;
this.children = children;
this.mbdDatas = mbdDatas;
this.transform = transform;
this.isDrawing = isDrawing;
this.modelThumbnailUri = modelThumbnailUri;
this.modelRelativePath = modelRelativePath;
this.productCode = productCode;
}
public ModelBaseInfo(String oid, String number, String name, String version,
Boolean isCheckedOut, String checkoutInfoState, String checkoutUser,
String partTypeDisplay, String state, String owner, String modelFileName,
......@@ -312,6 +346,14 @@ public class ModelBaseInfo {
this.modelRelativePath = modelRelativePath;
}
public String getProductCode() {
return productCode;
}
public void setProductCode(String productCode) {
this.productCode = productCode;
}
@Override
public String toString() {
return "ModelBaseInfo [oid=" + oid + ", number=" + number + ", name=" + name + ", version="
......@@ -321,7 +363,8 @@ public class ModelBaseInfo {
+ modelFileName + ", modelFileUri=" + modelFileUri + ", modelFileSize="
+ modelFileSize + ", modelFileCheckSum=" + modelFileCheckSum + ", children="
+ children + ", mbdDatas=" + mbdDatas + ", transform=" + transform + ", isDrawing=" + isDrawing + ", modelThumbnailUri="
+ modelThumbnailUri + ", modelRelativePath=" + modelRelativePath + "]";
+ modelThumbnailUri + ", modelRelativePath=" + modelRelativePath
+ ", productCode=" + productCode + "]";
}
}
......@@ -10,8 +10,8 @@ import java.util.List;
/**
* CADPro 打开模型Vo
*
*
*
*
*/
public class OpenModelFilesCondition implements Serializable {
......
package com.yonde.cadpro.bean;
import com.yonde.cadpro.CADProConstants;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlType;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
@XmlType(propOrder = { "number", "inDicNumber", "children" })
public class TopBOMNode {
private String number;
private String inDicNumber;
private List<TopBOMNode> children;
@XmlAttribute
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
setInDicNumber(CADProConstants.DIC_PREFIX + number);
}
@XmlAttribute
public String getInDicNumber() {
return inDicNumber;
}
public void setInDicNumber(String inDicNumber) {
this.inDicNumber = inDicNumber;
}
@XmlElementWrapper(name="children")
@XmlElement(name = "TopBOMNode")
public List<TopBOMNode> getChildren() {
return children;
}
public void setChildren(List<TopBOMNode> children) {
this.children = children;
}
public static TopBOMNode newTopBOMNode(String partNumber) {
TopBOMNode topBOMNode = new TopBOMNode();
topBOMNode.setNumber(partNumber);
return topBOMNode;
}
public void addChild(TopBOMNode child) {
if (children == null) {
children = new ArrayList<TopBOMNode>();
}
children.add(child);
}
}
package com.yonde.cadpro.bean;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
*
*/
@XmlRootElement(name = "TopStructure")
@XmlType(propOrder = { "date", "type", "requester", "topBOMNode" })
public class TopStructure {
private String date;
private String type;
private String requester;
private TopBOMNode topBOMNode;
@XmlAttribute(name = "date")
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
@XmlAttribute(name = "type")
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
@XmlAttribute(name = "requester")
public String getRequester() {
return requester;
}
public void setRequester(String requester) {
this.requester = requester;
}
@XmlElement(name = "TopBOMNode")
public TopBOMNode getTopBOMNode() {
return topBOMNode;
}
public void setTopBOMNode(TopBOMNode topBOMNode) {
this.topBOMNode = topBOMNode;
}
}
......@@ -20,12 +20,13 @@ public abstract class AbstractCADProChecker implements CADProChecker {
* 1. Size > 0
* 2. id转对象
* 3. 对象必须是WTPart或者EPMDocument
*
*
* @param ids
* @return
* @throws Exception
*/
protected List<WTObject> selectedCheck(List<String> ids) throws Exception {
System.out.println(">>>selectedCheck begin......ids:"+ids);
List<WTObject> selectedNodes = new ArrayList<WTObject>();
if (ids == null || ids.size() == 0) {
throw new WTException("获取选中节点为空,请确认!");
......@@ -34,23 +35,30 @@ public abstract class AbstractCADProChecker implements CADProChecker {
List<String> invalidIds = new ArrayList<String>();
List<String> invalidTypeIds = new ArrayList<String>();
for (String id : ids) {
System.out.println(">>>selectedCheck begin......id:"+id);
if (StringUtils.isBlank(id)) {
throw new WTException("选中节点id为空,请确认!");
}
Persistable per = null;
try {
per = CommonUtil.getPersistableByOid(id);
System.out.println(">>>selectedCheck begin......per:"+per);
} catch (Exception e) {
log.error("selectedCheck Get Per error...", e);
}
if (per == null) {
System.out.println(">>>selectedCheck begin......per is null");
invalidIds.add(id);
continue;
}
if (per instanceof WTPart || per instanceof EPMDocument) {
System.out.println(">>>selectedCheck begin......per ["+id+"] is WTPart or EPMDocument");
selectedNodes.add((WTObject) per);
} else {
System.out.println(">>>selectedCheck begin......per ["+id+"] not is WTPart or EPMDocument");
invalidTypeIds.add(id);
}
}
......
......@@ -6,5 +6,5 @@ import com.yonde.cadpro.checker.CADProChecker;
public interface CADProCheckerFactory {
public CADProChecker getChecker();
}
package com.yonde.cadpro.checker.impl;
import com.yonde.cadpro.CADProConstants;
import com.yonde.cadpro.checker.AbstractCADProChecker;
import com.yonde.cadpro.config.CADProConfigPropertiesUtil;
import com.yonde.cadpro.util.CADProUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import wt.fc.WTObject;
import wt.util.WTException;
import wt.log4j.LogR;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import wt.log4j.LogR;
public class DICOpenChecker extends AbstractCADProChecker {
......@@ -33,11 +30,11 @@ public class DICOpenChecker extends AbstractCADProChecker {
}
}
if (invalidTypeObjs.size() > 0) {
throw new WTException(
"选中节点类型非法,仅支持[" + StringUtils.join(allowTypes, CADProConstants.COMMA) + "]:"
+ StringUtils.join(invalidTypeObjs, CADProConstants.COMMA));
}
//if (invalidTypeObjs.size() > 0) {
// throw new WTException(
// "选中节点类型非法,仅支持[" + StringUtils.join(allowTypes, CADProConstants.COMMA) + "]:"
// + StringUtils.join(invalidTypeObjs, CADProConstants.COMMA));
//}
return selectedNodes;
}
......
package com.yonde.cadpro.checker.impl;
import com.yonde.cadpro.CADProConstants;
import com.yonde.cadpro.checker.AbstractCADProChecker;
import com.yonde.cadpro.config.CADProConfigPropertiesUtil;
import com.yonde.cadpro.util.CADProUtil;
import com.yonde.cadpro.util.EPMUtil;
import org.apache.commons.lang.StringUtils;
import wt.epm.EPMDocument;
import wt.fc.WTObject;
import wt.part.WTPart;
import wt.util.WTException;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import wt.log4j.LogR;
public class InsertChecker extends AbstractCADProChecker {
private static final Logger log = LogR.getLogger(InsertChecker.class.getName());
@Override
public List<WTObject> check(List<String> ids) throws Exception {
//必选校验
List<WTObject> selectedNodes = selectedCheck(ids);
if (selectedNodes.size() != 1) {
throw new WTException("插入仅支持一个根节点");
}
List<String> invalidTypeObjs = new ArrayList<String>();
List<String> noModelObjs = new ArrayList<String>();
//类型校验
List<String> allowTypes = CADProConfigPropertiesUtil.getOpenInsertTypes();
for (WTObject wto : selectedNodes) {
EPMDocument epm = null;
//必须关联CAD文档
if (wto instanceof EPMDocument) {
epm = (EPMDocument) wto;
} else if (wto instanceof WTPart) {
WTPart temp = (WTPart) wto;
epm = EPMUtil.getAssociatedEPM(temp);
}
if (epm == null) {
noModelObjs.add(wto.getDisplayIdentity().toString());
}
//类型校验
String typeDisplay = CADProUtil.getPartDisplayType(wto);
if (!allowTypes.contains(typeDisplay)) {
invalidTypeObjs.add(wto.getDisplayIdentity().toString());
}
}
if (invalidTypeObjs.size() > 0) {
throw new WTException(
"选中节点类型非法,仅支持[" + StringUtils.join(allowTypes, CADProConstants.COMMA) + "]:"
+ StringUtils.join(invalidTypeObjs, CADProConstants.COMMA));
}
if (noModelObjs.size() > 0) {
throw new WTException(
"选中节点未关联CAD模型:" + StringUtils.join(noModelObjs, CADProConstants.COMMA));
}
return selectedNodes;
}
}
......@@ -52,11 +52,11 @@ public class NewOpenChecker extends AbstractCADProChecker {
}
}
if (invalidTypeObjs.size() > 0) {
throw new WTException(
"选中节点类型非法,仅支持[" + StringUtils.join(allowTypes, CADProConstants.COMMA) + "]:"
+ StringUtils.join(invalidTypeObjs, CADProConstants.COMMA));
}
//if (invalidTypeObjs.size() > 0) {
// throw new WTException(
// "选中节点类型非法,仅支持[" + StringUtils.join(allowTypes, CADProConstants.COMMA) + "]:"
// + StringUtils.join(invalidTypeObjs, CADProConstants.COMMA));
//}
if (noModelObjs.size() > 0) {
throw new WTException(
"选中节点未关联CAD模型:" + StringUtils.join(noModelObjs, CADProConstants.COMMA));
......
......@@ -17,7 +17,7 @@ public class CADProConfigPropertiesUtil implements RemoteAccess {
private static final Logger log = LogR.getLogger(CADProConfigPropertiesUtil.class.getName());
private static String CATIAINTE_CONFIG_URL = File.separator + "codebase" + File.separator
+ "ext" + File.separator + "gace" + File.separator + "config" + File.separator
+ "com" + File.separator + "yonde" + File.separator + "config" + File.separator
+ "cadpro" + File.separator + "CADProConfig.properties";
private static String CONFIG_OPEN_NEW_TYPES = "Open.NEW.Types";
......@@ -129,6 +129,7 @@ public class CADProConfigPropertiesUtil implements RemoteAccess {
public static List<String> getDownloadStorageAsDsNumberTypes() throws Exception {
List<String> tempTypes = new ArrayList<String>();
//EBOM顶层结构,安装视图顶层件,主视图顶层件,DCI,FCI,LO,DS
String configValue = getValue(CONFIG_DOWNLOAD_STORAGE_DSNUMBER_TYPES);
if (StringUtils.isNotBlank(configValue)) {
configValue = configValue.replace(CADProConstants.COMMA_ZH, CADProConstants.COMMA);
......
......@@ -4,7 +4,7 @@ public enum CADProSettingTypeEnum {
Server(0),
DesignTool(1);
private CADProSettingTypeEnum(int key) {
this.key = key;
}
......@@ -18,5 +18,5 @@ public enum CADProSettingTypeEnum {
public void setKey(int key) {
this.key = key;
}
}
package com.yonde.cadpro.config;
/**
* Created on 2023/5/5 0005
* <p>
* * #For FTP Config
*
* @author
*/
public class CadFTPConfig {
public static final String HOST = "192.168.1.240";
public static final Integer PORT = 21;
public static final String USERNAME = "ftpuser";
public static final String PASSWORD = "Aa12345678!";
public static final String REMOTEPATH = "/";
public static final String ROOTPATH = "D:/Inetpub/ftproot";
}
......@@ -15,7 +15,7 @@ public class CatiaInteConfigPropertiesUtil implements RemoteAccess {
private static final Logger LOGGER = LogR.getLogger(CLASSNAME);
private static String CATIAINTE_CONFIG_URL = File.separator + "codebase" + File.separator
+ "config" + File.separator + "yonde" + File.separator + "CatiaIntegration.properties";
+ "com" + File.separator + "yonde" + File.separator + "config" + File.separator + "CatiaIntegration.properties";
private static String getValue(String key) throws Exception {
return StringUtils
......
......@@ -21,5 +21,5 @@ public class CatiaIntegrationAttrMapping {
}
return mappingIBA;
}
}
......@@ -124,7 +124,7 @@ public class DxCADProSetting implements Comparable<DxCADProSetting> {
public void setFtpSetting(DxCADProFTPSetting ftpSetting) {
this.ftpSetting = ftpSetting;
}
public String getCode() {
return code;
}
......
......@@ -2,17 +2,18 @@ package com.yonde.cadpro.converter;
import com.ptc.core.meta.common.TypeIdentifier;
import com.ptc.core.meta.common.impl.TypeIdentifierUtilityHelper;
import com.yonde.cadpro.CADProConstants;
import com.yonde.cadpro.bean.DxPartModelBomVo;
import com.yonde.cadpro.util.CadPartUtil;
import com.yonde.cadpro.util.DxPartModelBomVoCompator;
import com.yonde.cadpro.util.EPMUtil;
import com.yonde.cadpro.util.PartUtil;
import com.yonde.common.util.TypeAttrUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.log4j.Logger;
import wt.epm.EPMDocument;
import wt.fc.Persistable;
import wt.fc.collections.WTArrayList;
import wt.log4j.LogR;
import wt.part.*;
import wt.util.WTException;
import wt.vc.config.ConfigSpec;
......@@ -24,7 +25,7 @@ import java.util.ListIterator;
import java.util.Set;
public class DxPartModelBomVoConverter {
private static Logger log = LoggerFactory.getLogger(DxPartModelBomVoConverter.class);
private static final Logger log = LogR.getLogger(DxPartModelBomVoConverter.class.getName());
//private static String DEFALUT_POSITION_INFO = "1;0;0;0;0;1;0;0;0;0;1;0;0;0;0;1";
private DxPartModelBomVo dxPartModelBomVo = null;
......@@ -71,12 +72,13 @@ public class DxPartModelBomVoConverter {
* @throws WTException
*/
private void inintialConfigSpec() throws WTException {
System.out.println(">>>>inintialConfigSpec start......");
if (partConfigSpec == null) {
WTPartStandardConfigSpec partStandardConfigSpec = WTPartStandardConfigSpec
.newWTPartStandardConfigSpec();
try {
partStandardConfigSpec
.setView(ViewHelper.service.getView("Design"));
.setView(ViewHelper.service.getView(CADProConstants.VIEW_DESIGN));
partConfigSpec = partStandardConfigSpec;
} catch (Exception e) {
log.error("Set View error for WTPartStandardConfigSpec... ", e);
......@@ -86,6 +88,8 @@ public class DxPartModelBomVoConverter {
}
private void initialDxPartModelBomVo() throws Exception {
System.out.println(">>>>initialDxPartModelBomVo start......");
if (wtPart == null && epm == null) {
throw new WTException("零部件和数模不能同时为空");
}
......@@ -110,7 +114,7 @@ public class DxPartModelBomVoConverter {
if (StringUtils.isBlank(bomPath)) {
bomPath = partNumber;
}
bomPath = PartUtil.appendPathSuffixPrefix(bomPath);
bomPath = CadPartUtil.appendPathSuffixPrefix(bomPath);
String partTypeDisplay = "";
try {
......@@ -213,24 +217,24 @@ public class DxPartModelBomVoConverter {
// }
// }
//if (goFlag) {//继续遍历
DxPartModelBomVoConverter mbiConverter = new DxPartModelBomVoConverter(
childPart, partConfigSpec, needChildren, needModelFileUrl,
totalLevel, nextLevel, endRecursionTypes, needEffFilter,
childBOMPath, toLOBOMPaths, singleEffTopBaselineConfig);
DxPartModelBomVo childMbi = mbiConverter.getDxPartModelBomVo();
if (childMbi != null) {
children.add(childMbi);
}
// }
DxPartModelBomVoConverter mbiConverter = new DxPartModelBomVoConverter(
childPart, partConfigSpec, needChildren, needModelFileUrl,
totalLevel, nextLevel, endRecursionTypes, needEffFilter,
childBOMPath, toLOBOMPaths, singleEffTopBaselineConfig);
DxPartModelBomVo childMbi = mbiConverter.getDxPartModelBomVo();
if (childMbi != null) {
children.add(childMbi);
}
// }
} else {
log.error(" per{} is not WTPart, ignore... ", per);
log.error(" per"+per+" is not WTPart, ignore... ");
}
}
}
}
private boolean hasChildren(WTPart wtPart) throws Exception {
log.debug("hasChildren by {}", wtPart.getDisplayIdentifier());
log.debug("hasChildren by "+ wtPart.getDisplayIdentifier());
boolean hasChildren = false;
ConfigSpec cs = partConfigSpec;
boolean bomPathFiler = false;
......@@ -284,11 +288,11 @@ public class DxPartModelBomVoConverter {
// hasChildren = true;
// }
// } else {
hasChildren = true;
// }
hasChildren = true;
// }
}
} else {
log.error(" per{} is not WTPart, ignore... ", per);
log.error(" per{"+per+"} is not WTPart, ignore... ");
}
if (hasChildren) {
break;
......@@ -320,7 +324,7 @@ public class DxPartModelBomVoConverter {
WTPartMaster partMaster = (WTPartMaster) usageLink.getUses();
log.debug(" partMaster : " + partMaster);
if (partMaster != null) {
WTPart childPart = PartUtil.getLatestPart(partMaster.getNumber(),
WTPart childPart = CadPartUtil.getLatestPart(partMaster.getNumber(),
"Design");
if (childPart != null) {
hasChildren = true;
......
......@@ -8,26 +8,28 @@ import com.yonde.cadpro.download.impl.ClientModelPathAsDSRule;
import com.yonde.cadpro.download.impl.ClientModelPathAsParentRule;
import com.yonde.common.util.TypeAttrUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.log4j.Logger;
import wt.fc.WTObject;
import wt.log4j.LogR;
import wt.part.WTPart;
import java.util.List;
public class ClientModelPathRuleFactory {
private static final Logger log = LoggerFactory.getLogger(ClientModelPathRuleFactory.class);
private static final Logger log = LogR.getLogger(ClientModelPathRuleFactory.class.getName());
public static ClientModelPathRule getRule(OpenModelFilesCondition.OpenModelType openModelType, WTPart part,
String parentPath) throws Exception {
log.debug("getRule param {},{},{}", openModelType, part, parentPath);
log.debug("getRule param"+ openModelType+","+ part+","+ parentPath);
if (OpenModelFilesCondition.OpenModelType.INSERT.equals(openModelType)) {//插入
log.debug("IS INSERT ");
parentPath = StringUtils.trimToEmpty(parentPath);
return new ClientModelPathAsParentRule(parentPath);
} else {
//EBOM顶层结构,安装视图顶层件,主视图顶层件,DCI,FCI,LO,DS
List<String> numberTypes = CADProConfigPropertiesUtil
.getDownloadStorageAsDsNumberTypes();
//自制件,标准件,机载设备
List<String> tempTypes = CADProConfigPropertiesUtil.getDownloadStorageTempTypes();
log.debug("numberTypes : " + numberTypes);
log.debug("tempTypes : " + tempTypes);
......
......@@ -15,8 +15,8 @@ public class ClientModelPathAsDSRule implements ClientModelPathRule {
public ClientModelPathAsDSRule(WTPart wtPart) throws WTException {
//if (PartUtil.isDS(wtPart)) {
this.dsPart = wtPart;
// }
this.dsPart = wtPart;
// }
}
@Override
......
......@@ -8,10 +8,8 @@ import com.yonde.cadpro.checker.factory.DICOpenCheckerFactory;
import com.yonde.cadpro.download.CADProDownloader;
import com.yonde.cadpro.download.ClientModelPathRule;
import com.yonde.cadpro.download.factroy.ClientModelPathRuleFactory;
import com.yonde.cadpro.util.CadPartUtil;
import com.yonde.cadpro.util.EPMUtil;
import com.yonde.cadpro.util.PartUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import wt.epm.EPMDocument;
import wt.fc.QueryResult;
import wt.fc.WTObject;
......@@ -23,7 +21,6 @@ import java.util.List;
public class DICDownloader implements CADProDownloader {
private static final Logger log = LoggerFactory.getLogger(DICDownloader.class);
@Override
public List<WTObject> check(List<String> ids) throws Exception {
......@@ -34,7 +31,7 @@ public class DICDownloader implements CADProDownloader {
@Override
public List<DxModelFile> download(List<WTObject> selectedNodes,
String parentPath) throws Exception {
log.debug("DICDownloader download param {},{}", selectedNodes);
System.out.println("DICDownloader download param "+selectedNodes );
ArrayList<DxModelFile> modelFiles = new ArrayList<DxModelFile>();
ArrayList<String> processedObjs = new ArrayList<String>();
......@@ -69,19 +66,19 @@ public class DICDownloader implements CADProDownloader {
if (part == null) {
throw new WTException("零部件不能为空");
}
log.debug("process part[" + part.getDisplayIdentity() + "]...");
System.out.println("process part[" + part.getDisplayIdentity() + "]...");
//if (pathRule == null) {
// throw new WTException("此操作场景暂不支持");
//}
if (pathRule == null) {
throw new WTException("此操作场景暂不支持");
}
String relativePath = pathRule.getPath();
log.debug("relativePath : " + relativePath);
System.out.println("relativePath : " + relativePath);
String processedKey = part.getPersistInfo().getObjectIdentifier().getId() + "___"
+ relativePath;
if (processedObjs.contains(processedKey)) {
log.debug("partId[" + part.getDisplayIdentity() + "] has been processed...");
System.out.println("partId[" + part.getDisplayIdentity() + "] has been processed...");
return;
}
processedObjs.add(processedKey);
......@@ -93,7 +90,7 @@ public class DICDownloader implements CADProDownloader {
modelFiles.add(modelFile);
}
QueryResult qr = PartUtil.getSubParts(part,
QueryResult qr = CadPartUtil.getSubParts(part,
CADProConstants.designViewConfig,false);
while (qr.hasMoreElements()) {
WTPart childPart = (WTPart) qr.nextElement();
......
package com.yonde.cadpro.download.impl;
import com.yonde.cadpro.checker.CADProChecker;
import com.yonde.cadpro.checker.factory.DICOpenCheckerFactory;
import com.yonde.cadpro.util.EPMUtil;
import com.yonde.cadpro.util.PartUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import wt.epm.EPMDocument;
import wt.fc.QueryResult;
import wt.fc.WTObject;
import wt.part.WTPart;
import wt.part.WTPartConfigSpec;
import wt.part.WTPartStandardConfigSpec;
import wt.util.WTException;
import wt.vc.views.ViewHelper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class InDICDSLOFinder {
private static final Logger log = LoggerFactory.getLogger(InDICDSLOFinder.class);
public List<WTObject> check(List<String> ids) throws Exception {
CADProChecker cadProChecker = new DICOpenCheckerFactory().getChecker();
return cadProChecker.check(ids);
}
public Map<String, String> find(List<WTObject> selectedNodes )
throws Exception {
log.debug("InDICParentFinder find param {},{}", selectedNodes);
Map<String, String> dsLOMap = new HashMap<String, String>();
List<WTPart> processedObjs = new ArrayList<WTPart>();
for (WTObject wtObject : selectedNodes) {
WTPart rootPart = null;
if (wtObject instanceof WTPart) {
rootPart = (WTPart) wtObject;
} else if (wtObject instanceof EPMDocument) {
EPMDocument epm = (EPMDocument) wtObject;
rootPart = EPMUtil.getLatestBuidTarget(epm);
}
collectDSLORelation(null, rootPart, dsLOMap, processedObjs);
}
return dsLOMap;
}
public void collectDSLORelation(WTPart parentPart, WTPart part,
Map<String, String> dsLOMap, List<WTPart> processedObjs) throws Exception {
if (part == null) {
throw new WTException("零部件不能为空");
}
log.debug("process part[" + part.getDisplayIdentity() + "]...");
if (processedObjs.contains(part)) {
log.debug("part[" + part.getDisplayIdentity() + "] has been processed...");
return;
}
processedObjs.add(part);
// if (PartUtil.isDS(part)) {
// WTPart lo = null;
// if (parentPart == null) {
// lo = CollectionUtil.getFirst(PartUtil.getParentPart(part));
// } else {
// lo = parentPart;
// }
// EPMDocument epmDoc = EPMUtil.getAssociatedEPM(part);
// if (epmDoc != null) {
// String dsModelNumber = epmDoc.getCADName();
// if (lo != null) {
// dsLOMap.put(dsModelNumber, CADProConstants.DIC_PREFIX + lo.getNumber());
// } else {
// dsLOMap.put(dsModelNumber, "");
// }
// }
// } else {
//WTPartConfigSpec.newWTPartConfigSpec(WTPartStandardConfigSpec.newWTPartStandardConfigSpec(designView, null));
QueryResult qr = PartUtil.getSubParts(part,
WTPartConfigSpec.newWTPartConfigSpec(WTPartStandardConfigSpec.newWTPartStandardConfigSpec(ViewHelper.service.getView("Design"), null)),false);
while (qr.hasMoreElements()) {
WTPart childPart = (WTPart) qr.nextElement();
collectDSLORelation(part, childPart, dsLOMap, processedObjs);
}
}
}
......@@ -8,10 +8,8 @@ import com.yonde.cadpro.checker.factory.NewOpenCheckerFactory;
import com.yonde.cadpro.download.CADProDownloader;
import com.yonde.cadpro.download.ClientModelPathRule;
import com.yonde.cadpro.download.factroy.ClientModelPathRuleFactory;
import com.yonde.cadpro.util.CadPartUtil;
import com.yonde.cadpro.util.EPMUtil;
import com.yonde.cadpro.util.PartUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import wt.epm.EPMDocument;
import wt.fc.QueryResult;
import wt.fc.WTObject;
......@@ -22,9 +20,7 @@ import java.util.ArrayList;
import java.util.List;
public class InsertDownloader implements CADProDownloader {
private static final Logger log = LoggerFactory.getLogger(InsertDownloader.class);
@Override
public List<WTObject> check(List<String> ids) throws Exception {
CADProChecker cadProChecker = new NewOpenCheckerFactory().getChecker();
......@@ -36,15 +32,14 @@ public class InsertDownloader implements CADProDownloader {
* 1. 以选中根节点遍历收集所有模型文件
* 2. 模型客户端存储路径基于入参
* 3. 忽略有效性参数
*
*
*/
@Override
public List<DxModelFile> download(List<WTObject> selectedNodes,
String parentPath) throws Exception {
log.debug("InsertDownloader download param {},{}", selectedNodes);
System.out.println("InsertDownloader download param "+selectedNodes );
ClientModelPathRule pathRule = ClientModelPathRuleFactory.getRule(OpenModelFilesCondition.OpenModelType.INSERT,
null, parentPath);
ClientModelPathRule pathRule = ClientModelPathRuleFactory.getRule(OpenModelFilesCondition.OpenModelType.INSERT, null, parentPath);
ArrayList<DxModelFile> modelFiles = new ArrayList<DxModelFile>();
ArrayList<String> processedObjs = new ArrayList<String>();
for (WTObject wtObject : selectedNodes) {
......@@ -58,7 +53,7 @@ public class InsertDownloader implements CADProDownloader {
collectModelFilesByPartBOM(rootPart, pathRule, true, modelFiles,
processedObjs);
}
//log.debug("modelFiles:" + modelFiles);
//System.out.println("modelFiles:" + modelFiles);
return modelFiles;
}
......@@ -69,19 +64,19 @@ public class InsertDownloader implements CADProDownloader {
if (part == null) {
throw new WTException("零部件不能为空");
}
log.debug("process part[" + part.getDisplayIdentity() + "]...");
System.out.println("process part[" + part.getDisplayIdentity() + "]...");
if (pathRule == null) {
throw new WTException("此操作场景暂不支持,请确认");
}
//if (pathRule == null) {
// throw new WTException("此操作场景暂不支持,请确认");
//}
String relativePath = pathRule.getPath();
log.debug("relativePath : " + relativePath);
System.out.println("relativePath : " + relativePath);
String processedKey = part.getPersistInfo().getObjectIdentifier().getId() + "___"
+ relativePath;
if (processedObjs.contains(processedKey)) {
log.debug("partId[" + part.getDisplayIdentity() + "] has been processed...");
System.out.println("partId[" + part.getDisplayIdentity() + "] has been processed...");
return;
}
processedObjs.add(processedKey);
......@@ -93,7 +88,7 @@ public class InsertDownloader implements CADProDownloader {
modelFiles.add(modelFile);
}
QueryResult qr = PartUtil.getSubParts(part, CADProConstants.designViewConfig,false);
QueryResult qr = CadPartUtil.getSubParts(part, CADProConstants.designViewConfig,false);
while (qr.hasMoreElements()) {
WTPart childPart = (WTPart) qr.nextElement();
// if (ext.gace.service.ebom.util.PartUtil.isLO(childPart)) {//LO校验有效性
......@@ -103,7 +98,7 @@ public class InsertDownloader implements CADProDownloader {
// collectModelFilesByPartBOM(childPart, effFilter, pathRule, false,
// modelFiles, processedObjs);
// } else {
// log.debug("LO{}-Eff{} is invalid by {}", childPart.getDisplayIdentity(),
// System.out.println("LO{}-Eff{} is invalid by {}", childPart.getDisplayIdentity(),
// effValue, effFilter);
// }
// } else {//目标有效性为空
......@@ -111,10 +106,10 @@ public class InsertDownloader implements CADProDownloader {
// processedObjs);
// }
// }
// else {
collectModelFilesByPartBOM(childPart, pathRule, false, modelFiles,
processedObjs);
// }
// else {
collectModelFilesByPartBOM(childPart, pathRule, false, modelFiles,
processedObjs);
// }
}
}
......
......@@ -8,10 +8,8 @@ import com.yonde.cadpro.checker.factory.NewOpenCheckerFactory;
import com.yonde.cadpro.download.CADProDownloader;
import com.yonde.cadpro.download.ClientModelPathRule;
import com.yonde.cadpro.download.factroy.ClientModelPathRuleFactory;
import com.yonde.cadpro.util.CadPartUtil;
import com.yonde.cadpro.util.EPMUtil;
import com.yonde.cadpro.util.PartUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import wt.epm.EPMDocument;
import wt.fc.QueryResult;
import wt.fc.WTObject;
......@@ -22,9 +20,7 @@ import java.util.ArrayList;
import java.util.List;
public class NewDownloader implements CADProDownloader {
private static final Logger log = LoggerFactory.getLogger(NewDownloader.class);
@Override
public List<WTObject> check(List<String> ids) throws Exception {
CADProChecker cadProChecker = new NewOpenCheckerFactory().getChecker();
......@@ -33,16 +29,16 @@ public class NewDownloader implements CADProDownloader {
/**
* 新窗口下载
*
*
* 1. 以选中根节点遍历收集所有模型文件
* 2. 模型客户端存储路径基于配置文件获取
* 3. 忽略有效性参数
*
*
*/
@Override
public List<DxModelFile> download(List<WTObject> selectedNodes,
String parentPath) throws Exception {
log.debug("NewDownloader download param {},{}", selectedNodes);
System.out.println("NewDownloader download param "+selectedNodes);
WTObject wtObject = selectedNodes.get(0);//新窗口打开仅一个根节点
WTPart rootPart = null;
......@@ -57,7 +53,7 @@ public class NewDownloader implements CADProDownloader {
ArrayList<DxModelFile> modelFiles = new ArrayList<DxModelFile>();
ArrayList<String> processedObjs = new ArrayList<String>();
collectModelFilesByPartBOM(rootPart, pathRule, true, modelFiles, processedObjs);
//log.debug("modelFiles:" + modelFiles);
//System.out.println("modelFiles:" + modelFiles);
return modelFiles;
}
......@@ -68,18 +64,18 @@ public class NewDownloader implements CADProDownloader {
if (part == null) {
throw new WTException("零部件不能为空");
}
log.debug("process part[" + part.getDisplayIdentity() + "]...");
System.out.println("process part[" + part.getDisplayIdentity() + "]...");
if (pathRule == null) {
throw new WTException("此操作场景暂不支持");
}
//if (pathRule == null) {
// throw new WTException("此操作场景暂不支持");
//}
String relativePath = pathRule.getPath();
log.debug("relativePath : " + relativePath);
System.out.println("relativePath : " + relativePath);
String processedKey = part.getPersistInfo().getObjectIdentifier().getId() + "___"
+ relativePath;
if (processedObjs.contains(processedKey)) {
log.debug("partId[" + part.getDisplayIdentity() + "] has been processed...");
System.out.println("partId[" + part.getDisplayIdentity() + "] has been processed...");
return;
}
processedObjs.add(processedKey);
......@@ -91,7 +87,7 @@ public class NewDownloader implements CADProDownloader {
modelFiles.add(modelFile);
}
QueryResult qr = PartUtil.getSubParts(part, CADProConstants.designViewConfig,false);
QueryResult qr = CadPartUtil.getSubParts(part, CADProConstants.designViewConfig,false);
while (qr.hasMoreElements()) {
WTPart childPart = (WTPart) qr.nextElement();
// if (ext.gace.service.ebom.util.PartUtil.isLO(childPart)) {//LO校验有效性
......@@ -101,7 +97,7 @@ public class NewDownloader implements CADProDownloader {
// collectModelFilesByPartBOM(childPart, effFilter, pathRule, false,
// modelFiles, processedObjs);
// } else {
// log.debug("LO{}-Eff{} is invalid by {}", childPart.getDisplayIdentity(),
// System.out.println("LO{}-Eff{} is invalid by {}", childPart.getDisplayIdentity(),
// effValue, effFilter);
// }
// }
......@@ -110,10 +106,10 @@ public class NewDownloader implements CADProDownloader {
// processedObjs);
// }
// }
// else {
collectModelFilesByPartBOM(childPart, pathRule, false, modelFiles,
processedObjs);
// }
// else {
collectModelFilesByPartBOM(childPart, pathRule, false, modelFiles,
processedObjs);
// }
}
}
......
This diff is collapsed.
......@@ -82,7 +82,7 @@ public class ArithUtil {
* 提供(相对)精确的除非运算,当发生除不尽的情况时,由scale参数指定精度,以后的数字四舍五入
* @param v1
* @param v2
* @return
* @return
*/
public static double div(double v1, double v2) {
return div(v1, v2, DEF_SCALE);
......@@ -142,7 +142,7 @@ public class ArithUtil {
}
return transferDouble;
}
public static String doubleToString(double inputDouble) {
String out = "0";
try {
......
package com.yonde.cadpro.util;
import com.yonde.cadpro.CADProConstants;
import sun.misc.BASE64Decoder;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
/**
* Created on 2023/5/8 0008
*
* @author
*/
public class Base64Util {
/**
* jdk1.6解密basic`认证
*
* @param basic
* @return
*/
public static String decode(String basic) throws IOException {
byte[] decodeResult = new BASE64Decoder().decodeBuffer(basic);
System.out.println(new String(decodeResult));
return new String(decodeResult);
}
/**
* jdk1.6解密basic`认证
*
* @param request
* @return
*/
public static String decode(HttpServletRequest request) throws IOException {
String auth = request.getHeader(CADProConstants.AUTHORIZATION);
System.out.println(">>>auth:" + auth);
auth = auth.replace(CADProConstants.BASIC, "");
return decode(auth);
}
/**
* 拆分basic明文信息 获取用户名称
*/
public static String decodeForUserName(HttpServletRequest request) throws IOException {
String[] split =decode(request).split(":");
return split[0];
}
}
......@@ -6,6 +6,7 @@ import com.ptc.core.meta.type.mgmt.server.impl.TypeDomainHelper;
import com.yonde.cadpro.CADProConstants;
import com.yonde.common.CommonUtil;
import com.yonde.common.IBAUtil;
import com.yonde.common.PartUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import wt.doc.WTDocument;
......@@ -250,7 +251,7 @@ public class CADDocumentUtil {
objMBAs.put("Name", name);
// ContainerProvider containerProvider = new ContainerProviderImpl();
WTContainer wtContainer=null;
WTPart part = PartUtil.getLatestPart(number, CADProConstants.VIEW_DESIGN);//containerProvider.getAssignedContainer(subTypeName, EPMDocument.class, attsValueMap, (String[])null);
WTPart part = CadPartUtil.getLatestPart(number, CADProConstants.VIEW_DESIGN);//containerProvider.getAssignedContainer(subTypeName, EPMDocument.class, attsValueMap, (String[])null);
if(part!=null){
wtContainer = part.getContainer();
......@@ -266,7 +267,7 @@ public class CADDocumentUtil {
wtContainer = (WTContainer)PersistenceHelper.manager.refresh(wtContainer);
WTContainerRef wtContainerRef = WTContainerRef.newWTContainerRef(wtContainer);
String folder = part.getFolderPath();
// FolderPathProviderImpl fpProvider;
// FolderPathProviderImpl fpProvider;
// if (StringUtils.isBlank(epmtFolder)) {
// fpProvider = new FolderPathProviderImpl();
// folder = fpProvider.getAssignedFolderPath(subTypeName, EPMDocument.class, objMBAs, attsValueMap, (String[])null);
......@@ -760,7 +761,7 @@ public class CADDocumentUtil {
}
String cadStructureKey = cadStructureBuilder.toString();
// AssembleTransformSnapshot snapshot = getAssembleTransformSnapshotByStructure(cadStructureKey, parentEPM);
// AssembleTransformSnapshot snapshot = getAssembleTransformSnapshotByStructure(cadStructureKey, parentEPM);
// if (snapshot == null) {
// log.error("parentEPM[" + parentEPM + "] with[" + configspec + "] can't find AssembleTransformSnapshot.....");
// } else {
......
......@@ -44,7 +44,7 @@ public class CADProUtil {
/**
* 自动处理图号适配件号
*
*
* @param numbers
*/
public static List<String> mergePartNumsByModelNums(List<String> numbers) {
......@@ -89,7 +89,7 @@ public class CADProUtil {
/**
* 遍历BOM,下载CAD内容
*
*
* @param part
* @param epm
* @param tmpPath
......@@ -209,7 +209,7 @@ public class CADProUtil {
}
modelMap.put(partId, modelFile);
if (level < needlevel || needlevel == -1) {
List<WTPart> children = PartUtil.getChildPart(part,true);
List<WTPart> children = CadPartUtil.getChildPart(part,true);
/*
QueryResult qr = WTPartHelper.service.getUsesWTParts(part,
WTPartStandardConfigSpec.newWTPartStandardConfigSpec(
......@@ -262,7 +262,7 @@ public class CADProUtil {
while (linklist.hasMoreElements()) {
EPMMemberLink link = (EPMMemberLink) linklist.nextElement();
EPMDocumentMaster master = (EPMDocumentMaster) link.getUses();
EPMDocument childEPM = EPMUtil.getEPM(master.getNumber(), "", "");
Map<String, DxModelFile> childModelMap = getModelFileByEPMBom(childEPM, level++,
needlevel);
......@@ -304,7 +304,7 @@ public class CADProUtil {
/**
* 获取Part逻辑标识符最后一段
*
*
* @param per
* @return
* @throws Exception
......@@ -341,7 +341,7 @@ public class CADProUtil {
/**
* 获取Part类型显示名称
*
*
* @param per
* @return
* @throws Exception
......
package com.yonde.cadpro.util;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
import com.fasterxml.jackson.databind.ser.impl.SimpleFilterProvider;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import wt.log4j.LogR;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @author LiBanggui
* @description
* @date 2019/6/12
*/
public class CadJsonUtils {
private static Logger log = LogR.getLogger(CadJsonUtils.class.getName());
private static ObjectMapper objectMapper = null;
private static XmlMapper xmlMapper = null;
static {
objectMapper = initObjectMapper();
xmlMapper = initXmlMapper();
}
private static ObjectMapper initObjectMapper() {
ObjectMapper newObjectMapper = new ObjectMapper();
// 设置默认日期格式
// newObjectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
newObjectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
newObjectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
newObjectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
newObjectMapper.disable(MapperFeature.USE_GETTERS_AS_SETTERS);
return newObjectMapper;
}
private static XmlMapper initXmlMapper() {
XmlMapper newXmlMapper = new XmlMapper();
//newXmlMapper.findAndRegisterModules();
//newXmlMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
newXmlMapper.enable(SerializationFeature.INDENT_OUTPUT);
newXmlMapper.disable(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES);
newXmlMapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
//newXmlMapper.setDefaultUseWrapper(false);
newXmlMapper.configure(ToXmlGenerator.Feature.WRITE_XML_DECLARATION, true);
return newXmlMapper;
}
/**
* 将对象转换成json字符串格式(默认将转换所有的属性)
*
* @param value
* @return
*/
public static String toJsonStr(Object value) {
try {
return objectMapper.writeValueAsString(value);
} catch (JsonProcessingException e) {
log.error("Json转换失败", e);
throw new RuntimeException(e);
}
}
/**
* 将对象转换成json字符串格式(默认将转换所有的属性)
*
* @param value
* @return
*/
public static byte[] toJsonBytes(Object value) {
try {
return objectMapper.writeValueAsBytes(value);
} catch (JsonProcessingException e) {
log.error("Json转换失败", e);
throw new RuntimeException(e);
}
}
/**
* 将对象转换成json字符串格式
*
* @param value
* 需要转换的对象
* @param properties
* 需要转换的属性
*/
public static String toJsonStr(Object value, String[] properties) {
try {
SimpleBeanPropertyFilter sbp = SimpleBeanPropertyFilter.filterOutAllExcept(properties);
FilterProvider filterProvider = new SimpleFilterProvider()
.addFilter("propertyFilterMixIn", sbp);
return objectMapper.writer(filterProvider).writeValueAsString(value);
} catch (Exception e) {
log.error("Json转换失败", e);
throw new RuntimeException(e);
}
}
/**
* 将对象转换成json字符串格式
*
* @param value
* 需要转换的对象
* @param properties2Exclude
* 需要排除的属性
*/
public static String toJsonStrWithExcludeProperties(Object value, String[] properties2Exclude) {
try {
SimpleBeanPropertyFilter sbp = SimpleBeanPropertyFilter
.serializeAllExcept(properties2Exclude);
FilterProvider filterProvider = new SimpleFilterProvider()
.addFilter("propertyFilterMixIn", sbp);
return objectMapper.writer(filterProvider).writeValueAsString(value);
} catch (Exception e) {
log.error("Json转换失败", e);
throw new RuntimeException(e);
}
}
/**
* 将对象json格式直接写出到流对象中(默认将转换所有的属性)
*
* @param out
* @return
*/
public static void writeJsonStr(OutputStream out, Object value) {
try {
objectMapper.writeValue(out, value);
} catch (Exception e) {
log.error("Json转换失败", e);
throw new RuntimeException(e);
}
}
/**
* 反序列化POJO或简单Collection如List<String>.
*
* 如果JSON字符串为Null或"null"字符串, 返回Null. 如果JSON字符串为"[]", 返回空集合.
*
* 如需反序列化复杂Collection如List<MyBean>, 请使用fromJson(String, JavaType)
*/
public static <T> T fromJson(String jsonString, Class<T> clazz) {
if (StringUtils.isEmpty(jsonString)) {
return null;
}
try {
return objectMapper.readValue(jsonString, clazz);
} catch (IOException e) {
log.error("parse json string error:" + jsonString, e);
return null;
}
}
/**
* 反序列化POJO或简单Collection如List<String>.
*
* 如果JSON字符串为Null或"null"字符串, 返回Null. 如果JSON字符串为"[]", 返回空集合.
*
* 如需反序列化复杂Collection如List<MyBean>, 请使用fromJson(String, JavaType)
*/
public static <T> T fromJson(String jsonString, Class<T> clazz, Class<?>... elementClasses) {
if (StringUtils.isEmpty(jsonString)) {
return null;
}
try {
if (elementClasses.length == 0) {
return objectMapper.readValue(jsonString, clazz);
} else {
return objectMapper.readValue(jsonString, getGenericsType(clazz, elementClasses));
}
} catch (IOException e) {
log.error("parse json string error:" + jsonString, e);
return null;
}
}
/**
* 获取泛型的Collection Type
*
* @param collectionClass
* 泛型的Collection
* @param elementClasses
* 元素类
* @return JavaType Java类型
* @since 1.0
*/
public static JavaType getGenericsType(Class<?> collectionClass, Class<?>... elementClasses) {
return objectMapper.getTypeFactory().constructParametricType(collectionClass,
elementClasses);
}
/**
* 对象转为XML字符串
* @param value
* @return
* @throws JsonProcessingException
*/
public static String toXMLStr(Object value) throws JsonProcessingException {
return xmlMapper.writeValueAsString(value);
}
/**
* 对象转xml写入流
* @param value
* @return
* @throws IOException
*/
public static void writeXmlStr(OutputStream os, Object value) throws IOException {
xmlMapper.writeValue(os, value);
}
/**
* xml字符串转为对象
* @param <T>
* @param xmlString
* @param clazz
* @return
*/
public static <T> T fromXml(String xmlString, Class<T> clazz) {
if (StringUtils.isBlank(xmlString)) {
return null;
}
try {
return xmlMapper.readValue(xmlString, clazz);
} catch (IOException e) {
log.error("parse xml string error:" + xmlString, e);
return null;
}
}
public static <T> T fromXml(InputStream xmlInput, Class<T> clazz) {
if (xmlInput == null) {
return null;
}
try {
return xmlMapper.readValue(xmlInput, clazz);
} catch (IOException e) {
log.error("parse xml input error", e);
return null;
}
}
}
......@@ -356,7 +356,7 @@ public class ContentUtil {
*/
public static ContentHolder addSecondaryFile(ContentHolder holder, File file,
String newFileName, String desc) throws WTException, WTPropertyVetoException,
java.beans.PropertyVetoException, IOException {
java.beans.PropertyVetoException, IOException {
ApplicationData applicationdata = ApplicationData.newApplicationData(holder);
applicationdata.setRole(ContentRoleType.SECONDARY);
applicationdata.setUploadedFromPath(file.getParent());
......@@ -371,18 +371,18 @@ public class ContentUtil {
PersistenceServerHelper.manager.update(applicationdata);
return holder;
}
public static ContentHolder replaceSecondaryFile(ContentHolder holder, File file,
String newFileName) throws WTException, PropertyVetoException, IOException {
holder = deleteSecondaryFile(holder ,newFileName );
return addSecondaryFile(holder,file,newFileName);
holder = deleteSecondaryFile(holder ,newFileName );
return addSecondaryFile(holder,file,newFileName);
}
public static ContentHolder replaceSecondaryFile(ContentHolder holder, File file,
String newFileName, String desc) throws WTException, PropertyVetoException, IOException {
holder = deleteSecondaryFile(holder ,newFileName );
return addSecondaryFile(holder,file,newFileName,desc);
}
public static ContentHolder copySecondarys(ContentHolder source, ContentHolder target) throws WTException, PropertyVetoException, IOException {
List<ApplicationData> sourceApps = getSecondarys(source);
for(ApplicationData sourceApp: sourceApps){
......@@ -570,7 +570,7 @@ public class ContentUtil {
* @param holder
* @param contentRoleTypes
* @param fileName
* @return
* @return
* @throws WTException
* @throws PropertyVetoException
*/
......
......@@ -16,7 +16,7 @@ public class DSNumberValidator {
//-000 ~ -999 后四位为-xxx结尾,xxx为3为数字
//public static String regEx = "^M-[A-Z]{1}[0-9]{4}[A-Z]{1}[0-9]{5}-[0-9]{3}$";
//-051 ~ -099 后四位为-0xx结尾,xx为51 - 99
//-051 ~ -099 后四位为-0xx结尾,xx为51 - 99
public static String regEx1 = "^M-[A-Z]{1}[0-9]{4}[A-Z]{1}[0-9]{5}-0[5-9]{1}[1-9]{1}$";
//骨架模型DS GJ_D5380K00000-051
......@@ -50,7 +50,7 @@ public class DSNumberValidator {
}
Matcher matcher = pattern.matcher(input);
matchFlag = matcher.matches();
//骨架模型DS
if (!matchFlag) {
if (caseInsensitive) {
......@@ -61,7 +61,7 @@ public class DSNumberValidator {
matcher = pattern.matcher(input);
matchFlag = matcher.matches();
}
//边界模型DS
//边界模型DS
if (!matchFlag) {
......@@ -73,7 +73,7 @@ public class DSNumberValidator {
matcher = pattern.matcher(input);
matchFlag = matcher.matches();
}
return matchFlag;
}
......@@ -82,7 +82,7 @@ public class DSNumberValidator {
System.out.println(dsNumberValidator.execute());
dsNumberValidator = new DSNumberValidator("M-D5380K00000-051");
System.out.println(dsNumberValidator.execute());
dsNumberValidator = new DSNumberValidator("BJ_D5380K00000-051");
System.out.println(dsNumberValidator.execute());
}
......
package com.yonde.cadpro.util;
import wt.method.RemoteAccess;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.SimpleTimeZone;
import java.util.TimeZone;
public class DateUtil implements RemoteAccess {
public static String DATE_TIME_FORMART = "yyyy-MM-dd HH:mm:ss";
public static String DATE_FORMART = "yyyy-MM-dd";
public static String formatTimestamp(String format, Timestamp timestamp){
SimpleDateFormat dateFormat = new SimpleDateFormat(format);
TimeZone zone = new SimpleTimeZone(28800000,"Asia/Shanghai");
dateFormat.setTimeZone(zone);
String time = dateFormat.format(timestamp);
return time;
}
public static Timestamp timestampVal(String val){
if(val == null || val.trim().isEmpty()){
return null;
}else{
return Timestamp.valueOf(val.trim());
}
}
}
This diff is collapsed.
......@@ -7,7 +7,7 @@ import wt.util.WTException;
import wt.util.WTPropertyVetoException;
public class ExceptionUtil {
public static String getErrorMessage(Throwable th) {
String errMsg = "";
Throwable rootCause = ExceptionUtils.getRootCause(th);
......@@ -29,7 +29,7 @@ public class ExceptionUtil {
public static ApiResult constructErrorAPIResult(Exception exception) {
return ApiResult.error(getErrorMessage(exception));
}
public static ApiResult constructErrorAPIResult(String errorMsgPrefix, Exception exception) {
return ApiResult.error(errorMsgPrefix + getErrorMessage(exception));
}
......
This diff is collapsed.
This diff is collapsed.
......@@ -7,6 +7,7 @@ import com.yonde.cadpro.bean.ModelBaseInfo;
import com.yonde.cadpro.config.CatiaInteConfigPropertiesUtil;
import com.yonde.common.CommonUtil;
import com.yonde.common.IBAUtil;
import com.yonde.common.PartUtil;
import com.yonde.common.util.TypeAttrUtil;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
......@@ -550,7 +551,7 @@ public class ModelBaseInfoConverter {
}
if (partMaster != null) {
//WTPart childPart = PartUtil.getLatestPartByModifyTime(partMaster.getNumber(), GACEConstants.VIEW_DESIGN, true);
WTPart childPart = PartUtil.getLatestPart(partMaster.getNumber(),
WTPart childPart = CadPartUtil.getLatestPart(partMaster.getNumber(),
CADProConstants.VIEW_DESIGN);
if (childPart != null) {
if (log.isDebugEnabled()) {
......@@ -591,12 +592,12 @@ public class ModelBaseInfoConverter {
// }
// }
//else {
ModelBaseInfoConverter mbiConverter = new ModelBaseInfoConverter(
childPart, partConfigSpec, needChildren, needModelFileUrl,
totalLevel, nextLevel, endRecursionTypes);
ModelBaseInfo childMbi = mbiConverter.getModelBaseInfo();
children.add(childMbi);
// }
ModelBaseInfoConverter mbiConverter = new ModelBaseInfoConverter(
childPart, partConfigSpec, needChildren, needModelFileUrl,
totalLevel, nextLevel, endRecursionTypes);
ModelBaseInfo childMbi = mbiConverter.getModelBaseInfo();
children.add(childMbi);
// }
}
} else {
log.error(" partMaster is null...");
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -32,7 +32,7 @@ public class JsonUtils {
public JsonUtils() {
}
static {
//xmlMapper = initXmlMapper();
xmlMapper = initXmlMapper();
}
......
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