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 = ";";
......
......@@ -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;
......@@ -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,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
......
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;
......@@ -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("获取选中节点异常,请确认!");
......
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);
......
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
......
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 {
......@@ -223,14 +225,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 +290,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 +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();
}
}
}
......
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;
......@@ -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();
......
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,6 +42,8 @@ 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";
/**
* 自动处理图号适配件号
......@@ -70,6 +73,7 @@ public class CADProUtil {
/**
* 自动处理图号适配件号
*
* @param number
* @return
*/
......@@ -86,7 +90,6 @@ public class CADProUtil {
}
/**
* 遍历BOM,下载CAD内容
*
......@@ -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) {
......@@ -180,6 +183,7 @@ public class CADProUtil {
/**
* 根据层级遍历零部件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
......@@ -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;
}
}
}
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 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;
}
}
......@@ -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.
package com.yonde.cadpro.util;
import com.yonde.cadpro.CADProConstants;
import com.yonde.cadpro.bean.TopBOMNode;
import com.yonde.cadpro.bean.TopStructure;
import com.yonde.common.CommonUtil;
import org.apache.log4j.Logger;
import wt.part.WTPart;
import wt.part.WTPartMaster;
import wt.part.WTPartUsageLink;
import wt.session.SessionHelper;
import wt.util.WTException;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class TopStructureExporter {
private static final Logger log = Logger.getLogger(TopStructureExporter.class);
private String type;
private WTPart rootPart;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public WTPart getRootPart() {
return rootPart;
}
public void setRootPart(WTPart rootPart) {
this.rootPart = rootPart;
}
public static TopStructureExporter newTopStructureExporter(String type, WTPart rootPart) {
TopStructureExporter topStructureExporter = new TopStructureExporter();
topStructureExporter.setRootPart(rootPart);
topStructureExporter.setType(type);
return topStructureExporter;
}
public TopStructure doExport() throws Exception {
TopStructure ts = constructTopStructureNode();
Set<String> processedPartNumbers = new HashSet<String>();
constructureData(rootPart, ts, null, processedPartNumbers);
return ts;
}
private TopStructure constructTopStructureNode() throws WTException {
TopStructure topStructure = new TopStructure();
topStructure.setDate(CommonUtil.formatTime(null, DateUtil.DATE_TIME_FORMART));
try {
topStructure.setRequester(
CommonUtil.formatUserDisplay(SessionHelper.manager.getPrincipalReference()));
} catch (Exception e) {
log.error("Get Session User error...", e);
}
return topStructure;
}
private void constructureData(WTPart part, TopStructure topStructure, TopBOMNode parentBOMNode,
Set<String> processedPartNumbers) throws Exception {
if (part != null) {
part = CommonUtil.getOriginal(part, WTPart.class);
String partNumber = part.getNumber();
if (processedPartNumbers.contains(partNumber)) {
log.debug("partNumber [" + partNumber + "] has been processed...");
return;
}
processedPartNumbers.add(partNumber);
TopBOMNode currentBOMNode = TopBOMNode.newTopBOMNode(partNumber);
if (parentBOMNode == null) {//Root Node
//Node根节点封装
topStructure.setTopBOMNode(currentBOMNode);
} else {
parentBOMNode.addChild(currentBOMNode);
}
List<WTPartUsageLink> childLinks = PartUtil.getChildrenLinks(part);
if (childLinks != null) {
for (WTPartUsageLink usageLink : childLinks) {
WTPartMaster childMaster = (WTPartMaster) usageLink.getUses();
String childNumber = childMaster.getNumber();
WTPart childPart = PartUtil.getLatestPart(childNumber,
CADProConstants.VIEW_DESIGN);
if (childPart != null) {
//遍历子件
constructureData(childPart, topStructure, currentBOMNode,
processedPartNumbers);
}
}
}
}
}
}
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.
package com.yonde.common.entity;
import com.yonde.basedata.vo.IdVO;
import com.yonde.common.RfUtil;
import wt.fc.PersistenceHelper;
import wt.folder.Folder;
......
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