Commit dac003fb authored by shyWang's avatar shyWang

Merge remote-tracking branch 'origin/master'

parents 87f3dc5e d9acbec7
[
{
"comment": "GACE UAT Server",
"comment": "615 Server",
"serverAddress": "http://192.168.1.240/Windchill/extRest/",
"workspace": "D:\\CADProTestWorkspace",
"workspace": "D:\\CATIA_WORK",
"type": 0,
"sort": 1,
"code": "77d6cf9e-6527-4f38-ae8e-87bd744e405d",
......@@ -15,9 +15,9 @@
}
},
{
"comment": "GACE Prod Server",
"comment": "615 Server",
"serverAddress": "http://192.168.1.240/Windchill/extRest/",
"workspace": "D:\\CADProWorkspace",
"workspace": "D:\\CATIA_WORK",
"type": 0,
"sort": 2,
"code": "1111a947-b018-4c24-9f32-24c9fab5d37e",
......
#MCADPro Client Version
MCADProClient.version=v1.0.20211126
#For Part Default Type by Catia Check In
WTPart.DefaultType={domain}.MechanicalPart
WTPart.StandardType={domain}.StandardPart
WTPart.DSType={domain}.DS
WTPart.AirborneEquipmentType={domain}.AirborneEquipment
Transfrom.Default=1 0 0 0;0 1 0 0;0 0 1 0;0 0 0 1
IBA.PARTTYPE=part_type
PARTTYPE.STANDARD=\u6807\u51C6\u4EF6
BOMEndRecursion.types=DS
Absolute.Position.Type=DS
Absolute.Position.Default=1;0;0;0;0;1;0;0;0;0;1;0;0;0;0;1
BOM.AllowPartType=\u4E3B\u89C6\u56FE\u9876\u5C42\u4EF6,DCI,FCI,LO,DS
#For FTP Config
ftp.host=192.168.1.240
ftp.port=21
ftp.username=ftpuser
ftp.password=Aa12345678!
ftp.remotePath=/
ftp.rootPath=D:/Inetpub/ftproot
{
"产品代号": "productCode",
"材料": "material",
"重量": "singleWeight",
"重量代码": "weightCode",
"物品码": "materialCode",
"零部件类型": "part_type"
}
\ No newline at end of file
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.springframework.web.bind.annotation.*;
import wt.method.RemoteAccess;
import wt.util.WTException;
import java.io.IOException;
@RestController
@RequestMapping({"/login"})
public class LoginController {
public class LoginController implements RemoteAccess {
/**
* 用户认证
*
* @param userName
* @return
* @throws JsonProcessingException
......@@ -28,4 +32,18 @@ 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 {
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;
......@@ -74,6 +76,13 @@ public class ApiResult<T> {
return error(error.getCode(), error.getValue(), exception);
}
public static ApiResult error(String message){
ApiResult result = new ApiResult();
result.setCode(DxErrorCodeData.Service_Error.getCode());
result.setMessage(message);
return result;
}
public static <T> ApiResult ok(T obj, String message) {
ApiResult result = new ApiResult(obj);
result.setMessage(message);
......
......@@ -24,7 +24,8 @@ public enum DxErrorCodeData implements DxEnumData {
ILLEGALARGS(18, "目标类[%s]不可分配给可编辑类[%s]"),
PROP_MAPPING_ERROR(19, "目标类[%s]属性映射错误[%s]"),
CURRENT_NOT_SUPPORT_CUSTOM_TYPE(20, "当前系统不支持自定义类型(json转对象)"),
CAN_NOT_FOUND_DX_TYPE(21, "没有找见对应的dxType类型[%s]");
CAN_NOT_FOUND_DX_TYPE(21, "没有找见对应的dxType类型[%s]"),
Service_Error(2100,"CADPro登录异常");;
public static final String PREFIX = "BASEDATA_";
final String code;
final String value;
......
......@@ -33,6 +33,16 @@ public class SearchQueryCondition extends BaseSearchCondition implements Seriali
public SearchQueryCondition(){
}
private boolean onlyCAD = false;
public boolean isOnlyCAD() {
return onlyCAD;
}
public void setOnlyCAD(boolean onlyCAD) {
this.onlyCAD = onlyCAD;
}
public SearchQueryCondition(SearchItems searchItems, Integer pageFrom, Integer pageSize, List<SortItem> sortItem, List<String> indices, String keyWord, String name, Boolean parentFilter, SearchQueryCondition.SearchVersion searchVersion, boolean globalSearch, Boolean seriesFlag, List<SearchQueryCondition> openProps) {
super(searchItems, pageFrom, pageSize, sortItem);
this.indices = indices;
......
......@@ -2,13 +2,11 @@ package com.yonde.basedata.service;
import com.yonde.basedata.data.DxPageImpl;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.basedata.entity.users.DxUserVO;
import com.yonde.basedata.search.SearchOperatorEnumUtil;
import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.basedata.vo.IdVO;
import com.yonde.basedata.vo.ObjFileLinkVO;
import com.yonde.baseline.vo.DxBaselineVO;
import com.yonde.change.service.DXChangeOrderService;
import com.yonde.change.vo.ecn.DxChangeNoticeVo;
import com.yonde.change.vo.ecr.DxChangeRequestVo;
import com.yonde.change.vo.pr.DxProblemReportVo;
......@@ -45,7 +43,6 @@ import wt.session.SessionServerHelper;
import wt.util.WTException;
import wt.util.WTProperties;
import wt.vc.baseline.ManagedBaseline;
import wt.vc.wip.WorkInProgressHelper;
import java.io.File;
import java.util.ArrayList;
......
......@@ -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;
......@@ -387,7 +385,8 @@ public class DxPartModelBomVo {
DxModelFile modelFile = DxModelFile.newModelFile(epm);
dxPartModelBomVo.setModelFile(modelFile);
} catch (Exception e) {
log.error("获取模型信息失败", e);
e.printStackTrace();
System.out.println("获取模型信息失败");
}
}
......
......@@ -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
......
......@@ -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;
}
}
package com.yonde.cadpro.checker;
import com.yonde.cadpro.CADProConstants;
import com.yonde.common.CommonUtil;
import org.apache.commons.lang.StringUtils;
......@@ -20,7 +21,7 @@ public abstract class AbstractCADProChecker implements CADProChecker {
* 1. Size > 0
* 2. id转对象
* 3. 对象必须是WTPart或者EPMDocument
*
*
* @param ids
* @return
* @throws Exception
......@@ -59,10 +60,10 @@ public abstract class AbstractCADProChecker implements CADProChecker {
throw new WTException("选中节点获取对象异常,请确认:"
+ StringUtils.join(invalidIds, CADProConstants.COMMA));
}
if (invalidTypeIds.size() > 0) {
throw new WTException("选中节点对象类型非法,请确认:"
+ StringUtils.join(invalidTypeIds, CADProConstants.COMMA));
}
//if (invalidTypeIds.size() > 0) {
// throw new WTException("选中节点对象类型非法,请确认:"
// + StringUtils.join(invalidTypeIds, CADProConstants.COMMA));
//}
if (selectedNodes.size() == 0) {
throw new WTException("获取选中节点异常,请确认!");
......
......@@ -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;
}
}
......@@ -3,7 +3,6 @@ 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 org.apache.log4j.Logger;
......@@ -46,17 +45,17 @@ public class NewOpenChecker extends AbstractCADProChecker {
}
//类型校验
String typeDisplay = CADProUtil.getPartDisplayType(wto);
if (!allowTypes.contains(typeDisplay)) {
invalidTypeObjs.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 (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,8 +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
+ "ext" + File.separator + "gace" + File.separator + "config" + 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;
}
......
package com.yonde.cadpro.controller;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.cadpro.bean.*;
import com.yonde.cadpro.config.CADProConfigPropertiesUtil;
import com.yonde.cadpro.config.CADProSettingTypeEnum;
import com.yonde.cadpro.config.DxCADProSetting;
import com.yonde.cadpro.service.CADProService;
import com.yonde.cadpro.service.CadCheckService;
import com.yonde.cadpro.util.Base64Util;
import com.yonde.cadpro.util.CADProUtil;
import com.yonde.context.vo.SelectOption;
import org.springframework.web.bind.annotation.*;
import wt.util.WTException;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping(value = "/partModel")
public class CADProController {
/**
* 撤销检出模型
*
* @param numbers
* @return
*/
@RequestMapping(value = "/batch/undoCheckout", method = RequestMethod.POST)
public ApiResult<List<BatchResult>> batchUndoCheckout(@RequestBody List<String> numbers, HttpServletRequest request) throws Exception {
String userName = Base64Util.decodeForUserName(request);
System.out.println(">>>batchCheckin userName:" + userName);
return ApiResult.ok(CadCheckService.batchUndoCheckout(numbers, userName), "撤销检出模型完成");
}
/**
* 检出模型
*
* @param numbers
* @return
*/
@RequestMapping(value = "/batch/checkout", method = RequestMethod.POST)
public ApiResult<List<BatchResult>> batchCheckout(@RequestBody List<String> numbers, HttpServletRequest request) throws Exception {
String userName = Base64Util.decodeForUserName(request);
System.out.println(">>>batchCheckin userName:" + userName);
return ApiResult.ok(CadCheckService.batchCheckout(numbers, userName), "执行检出模型完成");
}
/**
* searchQueryCondition模型查询
*
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "/search", method = RequestMethod.POST)
public ApiResult<List<DxPartModelBomVo>> searchPartCADModel(@RequestBody(required = false) SearchQueryCondition searchQueryCondition,
HttpServletRequest request) throws Exception {
System.out.println("searchQueryCondition : " + searchQueryCondition);
String userName = Base64Util.decodeForUserName(request);
System.out.println(">>>batchCheckin userName:" + userName);
return ApiResult.ok(CADProService.searchModel(searchQueryCondition, userName), "模型查询成功");
}
/**
* 撤销检出模型
*
* @param models
* @return
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "/batch/checkin", method = RequestMethod.POST)
public ApiResult<List<BatchResult>> batchCheckin(@RequestBody List<ModelBaseInfo> models, HttpServletRequest request) throws Exception {
String userName = Base64Util.decodeForUserName(request);
System.out.println(">>>batchCheckin userName:" + userName);
return ApiResult.ok(CadCheckService.batchCheckin(models, userName), "检入模型完成");
}
/**
* 基于CADPro打开条件,收集模型,并封装路径地址
*
* @param openModelFilesCondition
* @return
*/
@SuppressWarnings("unchecked")
@PostMapping("/collectModelFiles")
public ApiResult<List<DxModelFile>> collectModelFiles(@RequestBody OpenModelFilesCondition openModelFilesCondition, HttpServletRequest request) throws Exception {
if (openModelFilesCondition == null) {
throw new WTException("打开模型参数不能为空");
}
String userName = Base64Util.decodeForUserName(request);
System.out.println(">>>batchCheckin userName:" + userName);
List<DxModelFile> result = CADProService.collectModelFiles(openModelFilesCondition, userName);
return ApiResult.ok(result, "success");
}
/**
* searchQueryCondition模型查询
*
* @return
* @throws Exception
*/
@SuppressWarnings("unchecked")
@RequestMapping(value = "/searchCAD", method = RequestMethod.POST)
public ApiResult<List<DxPartModelBomVo>> searchCADModel(@RequestBody SearchQueryCondition searchQueryCondition, HttpServletRequest request) throws Exception {
if (searchQueryCondition == null) {
throw new WTException("查询条件不允许为空!");
}
searchQueryCondition.setOnlyCAD(true);
String userName = Base64Util.decodeForUserName(request);
System.out.println(">>>batchCheckin userName:" + userName);
List<DxPartModelBomVo> models = CADProService.searchModel(searchQueryCondition, userName);
return ApiResult.ok(models, "模型查询成功");
}
/**
* 获取结构
* baselineId
* level
* 0 -- 自己
* 1 -- 向下一层
* n -- 向下n层
* -1 -- 全部
* partCADId
* number
* eff
*
* @return
*/
@SuppressWarnings("unchecked")
@RequestMapping(method = RequestMethod.POST)
public ApiResult<DxPartModelBomVo> modelTree(@RequestBody(required = false) SearchQueryCondition searchQueryCondition, HttpServletRequest request) throws Exception {
String userName = Base64Util.decodeForUserName(request);
System.out.println(">>>modelTree userName:" + userName);
return ApiResult.ok(CADProService.modelTree(searchQueryCondition, userName), "获取模型树成功");
}
//
///**
// * 6.2.4 生成所有模型文件ZIP
// *
// * @param oids
// * @return
// */
//@SuppressWarnings("unchecked")
//@RequestMapping(value = "/createModelZip", method = RequestMethod.POST)
//public ApiResult<Map<String, Object>> createModelZip(@RequestBody List<String> oids) {
// try {
// String url = cadProService.createModelZip(oids);
// return ApiResult.ok(url, "生成所有模型文件ZIP");
// } catch (Exception e) {
// log.error("createModelZip error...", e);
// return ExceptionUtil.constructErrorAPIResult(e);
// }
//}
//
//
@GetMapping("/bomViewOptions")
public ApiResult<List<SelectOption>> bomViewOptions() throws Exception {
return ApiResult.ok(CADProConfigPropertiesUtil.getBOMViews(SelectOption.class), "success");
}
@GetMapping("/config/cadProSetting")
public ApiResult<List<DxCADProSetting>> getCADProSettings(@RequestParam String settingType) {
CADProSettingTypeEnum.valueOf(settingType);
return ApiResult.ok(CADProUtil.getCADProSettings(settingType), "查询成功");
}
//
//
//
///**
// * 获取顶层BOM结构
// * @param partNum
// * @return
// */
//@RequestMapping(value = "/pullTopStructure", method = RequestMethod.GET)
//public ApiResult<String> pullTopStructure(@RequestParam String partNum) {
// try {
// String xmlUrl = cadProService.pullTopStructure(partNum);
// return ApiResult.ok(xmlUrl, "获取顶层BOM结构化文件完成");
// } catch (Exception e) {
// log.error("pullTopStructure error...", e);
// return ExceptionUtil.constructErrorAPIResult(e);
// }
//}
//
///**
// * @return
// */
//@RequestMapping(value = "/pullDICNumber", method = RequestMethod.GET)
//public ApiResult<String> pullDICNumber(@RequestParam String partNum) {
// try {
// String dicNumber = cadProService.pullDICNumber(partNum);
// return ApiResult.ok(dicNumber, "获取DIC编号完成");
// } catch (Exception e) {
// log.error("pullDICNumber error...", e);
// return ExceptionUtil.constructErrorAPIResult(e);
// }
//}
//
///**
// * 基于选中的节点,封装DS、LO挂接关系
// *
// *
// * @return
// */
//@PostMapping("/calulateDSLORelation")
//public ApiResult<Map<String, String>> calulateDSLORelation(
// @RequestBody(required = true) OpenModelFilesCondition openModelFilesCondition) {
// try {
// Map<String, String> result = cadProService
// .calulateDSLORelation(openModelFilesCondition);
// return ApiResult.ok(result, "success");
// } catch (Exception e) {
// log.error("calulateAssemblyRel error...", e);
// return ExceptionUtil.constructErrorAPIResult(e);
// }
//}
}
......@@ -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);
......@@ -110,7 +112,7 @@ public class DxPartModelBomVoConverter {
if (StringUtils.isBlank(bomPath)) {
bomPath = partNumber;
}
bomPath = PartUtil.appendPathSuffixPrefix(bomPath);
bomPath = CadPartUtil.appendPathSuffixPrefix(bomPath);
String partTypeDisplay = "";
try {
......@@ -213,24 +215,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 +286,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 +322,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;
......
......@@ -6,28 +6,31 @@ import com.yonde.cadpro.download.ClientModelPathRule;
import com.yonde.cadpro.download.impl.ClientModelPathAsConfigRule;
import com.yonde.cadpro.download.impl.ClientModelPathAsDSRule;
import com.yonde.cadpro.download.impl.ClientModelPathAsParentRule;
import com.yonde.cadpro.download.impl.CommonPathAsConfigRule;
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);
......@@ -39,7 +42,7 @@ public class ClientModelPathRuleFactory {
return new ClientModelPathAsDSRule(part);
} else {
//throw new WTException("此操作场景暂不支持");
return null;
return new CommonPathAsConfigRule();
}
}
}
......
......@@ -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
......
package com.yonde.cadpro.download.impl;
import com.yonde.cadpro.bean.DxModelFile;
import com.yonde.cadpro.config.CADProConfigPropertiesUtil;
import com.yonde.cadpro.download.ClientModelPathRule;
/**
* 通用part parth rule
*/
public class CommonPathAsConfigRule implements ClientModelPathRule {
private String configPath = "";
public CommonPathAsConfigRule() {
}
@Override
public String getPath() throws Exception {
configPath = CADProConfigPropertiesUtil.getDownloadStorageAsTempClientFoderPath();
configPath = configPath.replace(DxModelFile.PATH_SPLIT, DxModelFile.PATH_SPLIT_BACK);
if (!configPath.startsWith(DxModelFile.PATH_SPLIT_BACK)) {
configPath = DxModelFile.PATH_SPLIT_BACK + configPath;
}
return configPath;
}
@Override
public boolean applyChild() {
return true;
}
}
......@@ -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 {
......
package com.yonde.cadpro.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ptc.core.meta.server.TypeIdentifierUtility;
import com.yonde.cadpro.CADProConstants;
import com.yonde.cadpro.bean.DxModelFile;
......@@ -7,7 +9,6 @@ import com.yonde.cadpro.config.CADProSettingTypeEnum;
import com.yonde.cadpro.config.DxCADProSetting;
import com.yonde.common.CommonUtil;
import com.yonde.common.IBAUtil;
import com.yonde.common.JsonUtils;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
......@@ -41,10 +42,12 @@ public class CADProUtil {
private static final Logger log = Logger.getLogger(CADProUtil.class);
private static String CAD_PRO_SETTING_FILE = "/codebase/com/yonde/config/cadpro/CADProSetting.json";
private static String CAD_PRO_IBA_MAPPING_FILE = "/codebase/com/yonde/config/cadpro/CatiaIntegrationAttrMapping.json";
/**
* 自动处理图号适配件号
*
*
* @param numbers
*/
public static List<String> mergePartNumsByModelNums(List<String> numbers) {
......@@ -70,6 +73,7 @@ public class CADProUtil {
/**
* 自动处理图号适配件号
*
* @param number
* @return
*/
......@@ -86,10 +90,9 @@ public class CADProUtil {
}
/**
* 遍历BOM,下载CAD内容
*
*
* @param part
* @param epm
* @param tmpPath
......@@ -128,7 +131,7 @@ public class CADProUtil {
String tmpFilePath = tmpPath;
if (!CommonUtil.isTypeOf(part, CADProConstants.TYPE_STANDARDPART)) {
// 获取模型路径
String modelRelativePath = (String) IBAUtil.getIBAValue(epm,CADProConstants.IBA_MODELRELATIVEPATH);
String modelRelativePath = (String) IBAUtil.getIBAValue(epm, CADProConstants.IBA_MODELRELATIVEPATH);
modelRelativePath = modelRelativePath.replaceAll("\\\\", "/");
if (!(modelRelativePath.length() == 0 || modelRelativePath.equals("/"))) {
if (modelRelativePath.endsWith("/")) {
......@@ -164,7 +167,7 @@ public class CADProUtil {
}
List<ContentItem> contents = ContentUtil.getContentsByRole(epm,
new ContentRoleType[] { ContentRoleType.PRIMARY });
new ContentRoleType[]{ContentRoleType.PRIMARY});
if (contents != null && contents.size() > 0) {
ContentItem contentItem = contents.get(0);
if (contentItem instanceof ApplicationData) {
......@@ -179,7 +182,8 @@ public class CADProUtil {
}
/**
* 根据层级遍历零部件bom,获取其CAD内容文件
* 根据层级遍历零部件bom,获取其CAD内容文件
*
* @param part
* @param level
* @param needlevel
......@@ -209,7 +213,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(
......@@ -231,6 +235,7 @@ public class CADProUtil {
/**
* 根据层级遍历CAD bom,并获取CAD内容文件
*
* @param epm
* @param level
* @param needlevel
......@@ -262,7 +267,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 +309,7 @@ public class CADProUtil {
/**
* 获取Part逻辑标识符最后一段
*
*
* @param per
* @return
* @throws Exception
......@@ -341,7 +346,7 @@ public class CADProUtil {
/**
* 获取Part类型显示名称
*
*
* @param per
* @return
* @throws Exception
......@@ -366,13 +371,11 @@ public class CADProUtil {
if (part == null) {
throw new WTException("[" + per + "]获取零部件异常");
}
displayType= ClientTypedUtility.getLocalizedTypeName(part,Locale.SIMPLIFIED_CHINESE);
displayType = ClientTypedUtility.getLocalizedTypeName(part, Locale.SIMPLIFIED_CHINESE);
return displayType;
}
private static void processBOMPath(String singleBOMPath, Set<String> outputSet) {
if (StringUtils.isNotBlank(singleBOMPath)) {
List<String> source = Arrays.asList(StringUtils.split(singleBOMPath, "/"));
......@@ -384,6 +387,7 @@ public class CADProUtil {
}
}
}
public static Set<String> splitBOMPaths(Set<String> inputSet) {
Set<String> outputSet = new HashSet<String>();
if (inputSet == null || inputSet.size() == 0) {
......@@ -401,6 +405,7 @@ public class CADProUtil {
/**
* 基于服务器端配置,获取指定配置
*
* @param seetingType
* @return
*/
......@@ -413,8 +418,9 @@ public class CADProUtil {
log.debug("configFilePath : " + configFilePath);
//InputStream is = IOUtils.toInputStream(configFilePath, "UTF-8");
String jsonStr = FileUtils.readFileToString(new File(configFilePath), "UTF-8");
List<DxCADProSetting> settings = JsonUtils.fromJson(jsonStr, List.class,
DxCADProSetting.class);
//List<DxCADProSetting> settings = JsonUtils.fromJson(jsonStr, List.class, DxCADProSetting.class);
List<DxCADProSetting> settings = JSON.parseArray(jsonStr, DxCADProSetting.class);
for (DxCADProSetting dxCADProSetting : settings) {
if (CADProSettingTypeEnum.valueOf(seetingType)
.equals(dxCADProSetting.getType())) {
......@@ -429,4 +435,23 @@ public class CADProUtil {
return cadProSettings;
}
/**
* 获取cadPro iba映射配置信息
*
* @param
* @return
*/
public static Map<String, String> getCADProIbaMapping() {
try {
String mappingFile = CADProConstants.wthome + CAD_PRO_IBA_MAPPING_FILE;
log.debug("mappingFile : " + mappingFile);
String jsonStr = FileUtils.readFileToString(new File(mappingFile), "UTF-8");
return (Map<String, String>) JSONObject.parseObject(jsonStr, Map.class);
} catch (Exception e) {
log.error("getCADProIbaMapping error...", e);
}
return null;
}
}
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.
package com.yonde.cadpro.util;
import com.yonde.basedata.entity.api.ApiResult;
import org.apache.commons.lang.exception.ExceptionUtils;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;
public class ExceptionUtil {
public static String getErrorMessage(Throwable th) {
String errMsg = "";
Throwable rootCause = ExceptionUtils.getRootCause(th);
if (rootCause == null) {
rootCause = th;
}
if (rootCause instanceof WTException) {
WTException ex = (WTException) rootCause;
errMsg = ex.getLocalizedMessage();
} else if (rootCause instanceof WTPropertyVetoException) {
WTPropertyVetoException ex = (WTPropertyVetoException) rootCause;
errMsg = ex.getLocalizedMessage();
} else {
errMsg = ExceptionUtils.getMessage(rootCause);
}
return errMsg;
}
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));
}
}
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;
}
}
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...");
......
......@@ -17,7 +17,7 @@ public class SearchConditionConverter {
/**
* 解析SearchItems中Items条件
*
*
* @param sis
* @return
* @throws WTException
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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