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 = ";";
......
......@@ -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() {
}
......
......@@ -12,6 +12,7 @@ import wt.content.ContentRoleType;
import wt.epm.EPMDocument;
import wt.epm.EPMDocumentType;
import java.io.Serializable;
import java.util.List;
......@@ -21,7 +22,7 @@ import java.util.List;
* @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 = "\\";
......
......@@ -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;
......@@ -26,9 +25,8 @@ 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,7 +12,7 @@ import java.util.List;
* @author wyue
*
*/
public class MBDAttribute {
public class MBDAttribute implements Serializable {
/**
* 属性名称
......
......@@ -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 + "]";
}
}
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;
}
}
......@@ -26,6 +26,7 @@ public abstract class AbstractCADProChecker implements CADProChecker {
* @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);
}
}
......
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);
......
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
......
......@@ -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 {
......@@ -223,14 +227,14 @@ public class DxPartModelBomVoConverter {
}
// }
} 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;
......@@ -288,7 +292,7 @@ public class DxPartModelBomVoConverter {
// }
}
} 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);
......
......@@ -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;
......@@ -23,8 +21,6 @@ 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();
......@@ -41,10 +37,9 @@ public class InsertDownloader implements CADProDownloader {
@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 {//目标有效性为空
......
......@@ -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;
......@@ -23,8 +21,6 @@ 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();
......@@ -42,7 +38,7 @@ public class NewDownloader implements CADProDownloader {
@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);
// }
// }
......
This diff is collapsed.
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();
......
......@@ -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(
......
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;
}
}
}
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());
}
}
}
......@@ -58,10 +58,10 @@ public class EPMUtil {
EPMDocument epmDoc = null;
EPMContextHelper.setApplication(EPMApplicationType.getEPMApplicationTypeDefault());
EPMDocumentType epmType = EPMDocumentType.toEPMDocumentType(epmDocumentType);//CADASSEMBLY,CADCOMPONENT,CADDRAWING
//CADASSEMBLY,CADCOMPONENT,CADDRAWING
EPMDocumentType epmType = EPMDocumentType.toEPMDocumentType(epmDocumentType);
EPMAuthoringAppType appType = EPMAuthoringAppType
.toEPMAuthoringAppType(epmAuthoringAppType);
EPMAuthoringAppType appType = EPMAuthoringAppType.toEPMAuthoringAppType(epmAuthoringAppType);
Map<String, Object> objMBAs = new HashMap<String, Object>();
objMBAs.put("Number", epmNumber);
......@@ -81,19 +81,7 @@ public class EPMUtil {
TypeIdentifier id = TypeIdentifierHelper.getTypeIdentifier(epmSubType);
epmDoc = (EPMDocument) CoreMetaUtility.setType(epmDoc, id);
WTContainer wtContainer = null;
// if (inputContainer == null) {
// // Container Config Impl
// ContainerProvider containerProvider = new ContainerProviderImpl();
// wtContainer = containerProvider.getAssignedContainer(epmSubType, EPMDocument.class,
// attsValueMap, null);
//
// }
// else {
wtContainer = inputContainer;
// }
WTContainer wtContainer = inputContainer;
if (wtContainer == null) {
throw new WTException("Get AssignedContainer Fail by [" + epmSubType + "]...");
}
......@@ -104,15 +92,7 @@ public class EPMUtil {
epmDoc.setContainerReference(wtContainerRef);
//获取存储位置
String folder = "";
// if (StringUtils.isBlank(inputFolderPath)) {
// FolderPathProvider fpProvider = new FolderPathProviderImpl();
// folder = fpProvider.getAssignedFolderPath(epmSubType, EPMDocument.class, objMBAs,
// attsValueMap, null);
// }
// else {
folder = inputFolderPath;
// }
String folder = inputFolderPath;
if (StringUtils.isNotBlank(folder)) {
Folder location = null;
try {
......@@ -143,8 +123,7 @@ public class EPMUtil {
// set primary content
if (StringUtils.isNotBlank(primaryContent)) {
ContentUtil.addApplicationData(epmDoc, newFileName, primaryContent, "",
ContentRoleType.PRIMARY.toString());
ContentUtil.addApplicationData(epmDoc, newFileName, primaryContent, "", ContentRoleType.PRIMARY.toString());
}
// set secondary content
......@@ -196,6 +175,7 @@ public class EPMUtil {
/**
* 清除EPM的MemberLink
*
* @param epm
* @throws WTException
*/
......@@ -291,6 +271,7 @@ public class EPMUtil {
/**
* 通过EPMDocument获取子EPMDocument的装配坐标
*
* @param epm
*/
public static List<Map<String, String>> getChildEPMTransformMatrix4D(EPMDocument epm)
......@@ -332,7 +313,7 @@ public class EPMUtil {
+ String.valueOf((int) epmMemberLink.getTransform().toMatrix4d().m33);
*/
Transform transform = epmMemberLink.getTransform();
if(transform != null) {
if (transform != null) {
Matrix4d matrix4d = transform.toMatrix4d();
if (matrix4d != null) {
m0 = ArithUtil.doubleToString(matrix4d.m00) + " "
......@@ -448,6 +429,7 @@ public class EPMUtil {
/**
* 判断EPM是否为二维图
*
* @param epmDoc
* @return
*/
......@@ -458,6 +440,7 @@ public class EPMUtil {
/**
* 判断EPM是否为装配件
*
* @param epmDoc
* @return
*/
......@@ -578,7 +561,6 @@ public class EPMUtil {
}
/**
* 编号查询EPM
*
......@@ -596,11 +578,11 @@ public class EPMUtil {
QuerySpec qs = new QuerySpec(EPMDocument.class);
qs.appendWhere(new SearchCondition(EPMDocument.class, EPMDocument.NUMBER,
SearchCondition.EQUAL, epmNumber), new int[] { 0 });
SearchCondition.EQUAL, epmNumber), new int[]{0});
qs.appendAnd();
qs.appendWhere(new SearchCondition(EPMDocument.class, EPMDocument.LATEST_ITERATION,
SearchCondition.IS_TRUE), new int[] { 0 });
SearchCondition.IS_TRUE), new int[]{0});
// Order by version iteration
qs = new VersionedOrderByPrimitive().appendOrderBy(qs, 0, true);
......@@ -610,7 +592,7 @@ public class EPMUtil {
ClassAttribute modifyStampAttr = new ClassAttribute(EPMDocument.class,
WTObject.MODIFY_TIMESTAMP);
int index = qs.getFromClause().getPosition(EPMDocument.class);
qs.appendOrderBy(new OrderBy(modifyStampAttr, true), new int[] { index }); //从晚到早desc
qs.appendOrderBy(new OrderBy(modifyStampAttr, true), new int[]{index}); //从晚到早desc
//logger.debug("getLatestEPMByModifyTime qs : " + qs);
QueryResult result = PersistenceHelper.manager.find((StatementSpec) qs);
......@@ -707,7 +689,6 @@ public class EPMUtil {
// }
// return findValue;
// }
public static EPMDocument getEPM(String number, String version, String iteration)
throws WTException {
EPMDocument epm = null;
......@@ -718,33 +699,34 @@ public class EPMUtil {
QuerySpec queryspec = new QuerySpec(EPMDocument.class);
queryspec.appendWhere(new SearchCondition(EPMDocument.class, EPMDocument.NUMBER,
SearchCondition.EQUAL, number.toUpperCase()), new int[] { 0 });
SearchCondition.EQUAL, number.toUpperCase()), new int[]{0});
queryspec.appendAnd();
queryspec.appendWhere(new SearchCondition(EPMDocument.class, "interopInfo.iopState",
SearchCondition.NOT_EQUAL, "terminal"), new int[] { 0 });
//todo 9.1interopInfo.iopState 不存在该属性
//queryspec.appendAnd();
//queryspec.appendWhere(new SearchCondition(EPMDocument.class, "interopInfo.iopState",
// SearchCondition.NOT_EQUAL, "terminal"), new int[] { 0 });
if (StringUtils.isNotBlank(version)) {
queryspec.appendAnd();
queryspec.appendWhere(new SearchCondition(EPMDocument.class,
Versioned.VERSION_IDENTIFIER + "." + VersionIdentifier.VERSIONID,
SearchCondition.EQUAL, version), new int[] { 0 });
SearchCondition.EQUAL, version), new int[]{0});
if (StringUtils.isNotBlank(iteration)) {
queryspec.appendAnd();
queryspec.appendWhere(new SearchCondition(EPMDocument.class,
Iterated.ITERATION_IDENTIFIER + "." + IterationIdentifier.ITERATIONID,
SearchCondition.EQUAL, iteration), new int[] { 0 });
SearchCondition.EQUAL, iteration), new int[]{0});
} else {
queryspec.appendAnd();
queryspec.appendWhere(new SearchCondition(EPMDocument.class,
Iterated.ITERATION_INFO + "." + IterationInfo.LATEST,
SearchCondition.IS_TRUE), new int[] { 0 });
SearchCondition.IS_TRUE), new int[]{0});
}
} else {
queryspec.appendAnd();
queryspec.appendWhere(new SearchCondition(EPMDocument.class,
Iterated.ITERATION_INFO + "." + IterationInfo.LATEST,
SearchCondition.IS_TRUE), new int[] { 0 });
SearchCondition.IS_TRUE), new int[]{0});
}
if (logger.isDebugEnabled()) {
logger.debug("getEPM.queryspec = " + queryspec);
......@@ -781,11 +763,11 @@ public class EPMUtil {
return null;
}
public static EPMDocument rename(EPMDocument emp , String number, String name) throws Exception {
if(!number.equals(emp.getNumber()) || !name.equals(emp.getName())){
public static EPMDocument rename(EPMDocument emp, String number, String name) throws Exception {
if (!number.equals(emp.getNumber()) || !name.equals(emp.getName())) {
EPMDocumentMaster master = (EPMDocumentMaster) emp.getMaster();
IdentificationObject identificationobject = master.getIdentificationObject();
EPMDocumentMasterIdentity epmMasterIdentity = (EPMDocumentMasterIdentity)identificationobject;
EPMDocumentMasterIdentity epmMasterIdentity = (EPMDocumentMasterIdentity) identificationobject;
epmMasterIdentity.setNumber(number);
epmMasterIdentity.setName(name);
IdentityHelper.service.changeIdentity((Identified) master, epmMasterIdentity);
......
package com.yonde.cadpro.util;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
public class FTPConfig {
/**
* ftp服务器地址
*/
@Value("${ftp.host}")
private String host;
/**
* ftp服务器端口
*/
@Value("${ftp.port}")
private int port;
/**
* ftp服务器用户名
*/
@Value("${ftp.username}")
private String username;
/**
* ftp服务器密码
*/
@Value("${ftp.password}")
private String password;
/**
* ftp服务器存放文件的路径
*/
@Value("${ftp.remotePath}")
private String remotePath;
/**
* FTP服务根目录物理地址
*/
@Value("${ftp.rootPath}")
private String rootPath;
/**
* 下载文件时,存放在本地的路径
*/
//@Value("${ftp.downloadDir}")
//private String downloadDir;
public void setHost(String host) {
this.host = host;
}
public String getHost() {
return host;
}
public void setPort(int port) {
this.port = port;
}
public int getPort() {
return port;
}
public void setUsername(String username) {
this.username = username;
}
public String getUsername() {
return username;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}
public void setRemotePath(String remotePath) {
this.remotePath = remotePath;
}
public String getRemotePath() {
return remotePath;
}
public void setRootPath(String rootPath) {
this.rootPath = rootPath;
}
public String getRootPath() {
return rootPath;
}
}
......@@ -28,7 +28,10 @@ import wt.vc.wip.CheckoutInfo;
import wt.vc.wip.WorkInProgressHelper;
import java.beans.PropertyVetoException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
public class ModelBaseInfoByLatestPartConverter {
private static Logger log = Logger.getLogger(ModelBaseInfoByLatestPartConverter.class);
......@@ -341,7 +344,7 @@ public class ModelBaseInfoByLatestPartConverter {
log.debug(" partMaster : " + partMaster);
}
if (partMaster != null) {
WTPart childPart = PartUtil.getLatestPart(partMaster.getNumber(),
WTPart childPart = CadPartUtil.getLatestPart(partMaster.getNumber(),
CADProConstants.VIEW_DESIGN);
if (childPart != null) {
if (log.isDebugEnabled()) {
......@@ -402,7 +405,7 @@ public class ModelBaseInfoByLatestPartConverter {
public static void testOut(String number, int level) throws Exception {
ModelBaseInfo mbi = null;
//依据图号查询部件
WTPart part = PartUtil.getLatestPart(number, CADProConstants.VIEW_DESIGN);
WTPart part = CadPartUtil.getLatestPart(number, CADProConstants.VIEW_DESIGN);
ModelBaseInfoByLatestPartConverter mbiConverter = new ModelBaseInfoByLatestPartConverter(
part, true, true, level, 0, null);
mbi = mbiConverter.getModelBaseInfo();
......
......@@ -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()) {
......
This diff is collapsed.
This diff is collapsed.
package com.yonde.cadpro.util;
import wt.fc.WTObject;
import java.util.Comparator;
public class WTObjectModifyTimeCompator implements Comparator<WTObject> {
boolean isDesc = false;
public WTObjectModifyTimeCompator(boolean isDesc) {
this.isDesc = isDesc;
}
@Override
public int compare(WTObject o1, WTObject o2) {
if (o1 == null && o2 == null) {
return 0;
}
if (o1 == null) {
return isDesc ? 1 : -1;
}
if (o2 == null) {
return isDesc ? -1 : 1;
}
return (o1.getModifyTimestamp().compareTo(o2.getModifyTimestamp())) * (isDesc ? -1 : 1);
}
}
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