Commit ee457e27 authored by shyWang's avatar shyWang

PDM前端改造

产品中心改造初始提交
parent e27fad09
package com.yonde.basedata.controller;
import com.yonde.basedata.data.DxPageImpl;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.basedata.search.BaseSearchCondition;
import com.yonde.basedata.search.SearchItems;
import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.basedata.service.BaseSearchService;
import com.yonde.basedata.vo.IdVO;
import com.yonde.basedata.vo.lc.LifecycleTemplateVO;
import com.yonde.common.ObjectsUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
public class AbstractBaseController<V extends IdVO, S extends BaseSearchService> {
import java.util.List;
S getService() {
return (S) new BaseSearchService<V>();
}
public class AbstractBaseController {
/*
@PostMapping({"recursion"})
ApiResult recursionObj(@RequestBody V entity) {
return ApiResult.ok(this.getService().saveRecursion(entity));
//@ApiOperation("根据模板id查询模板信息,包含模板节点、路径、及节点下的事件 路径下的事件")
@GetMapping({"/findDetail/{id}"})
public ApiResult<LifecycleTemplateVO> findDetail(@PathVariable Long id) {
//return ApiResult.ok(this.getService().findDetail(id));
return ApiResult.ok("");
}
@PostMapping({"/search"})
//@ApiOperation("查询所有")
ApiResult<DxPageImpl<V>> findAll(@RequestBody SearchQueryCondition searchQueryCondition, @RequestParam(required = false) BaseSearchCondition permSearchParams) {
SearchItems searchItems = searchQueryCondition.getSearchItems();
if (ObjectsUtil.nonNull(searchItems)) {
SearchItems permSearchItems = this.getPermSearchItems(permSearchParams);
searchQueryCondition.getSearchItems().addChild(permSearchItems);
//@ApiOperation("配置规范查询")
@PostMapping({"findBySpec"})
List<IdVO> findByConfigSpec(@RequestBody SearchQueryCondition specSearch) {
try {
List<IdVO> partVOS = BaseSearchService.findByConfigSpecSelect(specSearch);
return partVOS;
} catch (Exception e) {
e.printStackTrace();
return null;
}
return ApiResult.ok(this.getService().search(searchQueryCondition));
}
@GetMapping({"/version/getWorkingCopy/{id}"})
//@ApiOperation("获取工作副本")
ApiResult getWorkingCopy(@PathVariable Long id) {
//@ApiOperation("深度查询")
@PostMapping({"find/recursion"})
List<IdVO> findRecursion(@RequestBody SearchQueryCondition specSearch) {
try {
List<IdVO> partVOS = BaseSearchService.findByConfigSpecSelect(specSearch);
return partVOS;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
/* //@ApiOperation("配置规范查询")
@PostMapping({"findBySpec"})
List<DxPartVO> findByConfigSpec(@RequestBody SearchQueryCondition specSearch) {
try {
return ApiResult.ok(this.getService().getWorkingCopy(id));
List<DxPartVO> partVOS = DxPartService.findByConfigSpecSelect(specSearch);
return partVOS;
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("","",e);
return null;
}
}
//@ApiOperation("深度查询")
@PostMapping({"find/recursion"})
List<DxPartVO> findRecursion(@RequestBody SearchQueryCondition specSearch) {
try {
List<DxPartVO> partVOS = DxPartService.findByConfigSpecSelect(specSearch);
return partVOS;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}*/
public SearchItems getPermSearchItems(BaseSearchCondition permSearchParams) {
SearchItems searchItems = new SearchItems();
searchItems.setOperator(SearchItems.BooleanOperator.AND);
......@@ -68,7 +95,6 @@ public class AbstractBaseController<V extends IdVO, S extends BaseSearchService>
}
//TODO 其他基础接口
}
......@@ -21,7 +21,6 @@ public class DxPrincipalVO extends IdVO implements Serializable {
public DxPrincipalVO(WTPrincipal principal) throws WTException {
super(principal);
this.num = principal.getName();
this.setId(PersistenceHelper.getObjectIdentifier(principal).getId());
}
public String getName() {
......
......@@ -24,6 +24,9 @@ public class DxUserVO extends DxPrincipalVO implements Serializable, RemoteAcces
private Boolean existAccount;
private Long userId;
private String userName;
private String number;
private String lockerName;
public DxUserVO() {
}
......@@ -32,8 +35,10 @@ public class DxUserVO extends DxPrincipalVO implements Serializable, RemoteAcces
super(principal);
if (principal != null) {
WTUser user = (WTUser) principal;
this.userId = this.id;
this.setName(user.getFullName());
this.userId = PersistenceHelper.getObjectIdentifier(user).getId();
this.userName = user.getFullName();
this.number = String.valueOf(userId);
this.setName(userName);
this.telephone = user.getTelephoneNumber();
this.mail = user.getEMail();
......@@ -42,6 +47,30 @@ public class DxUserVO extends DxPrincipalVO implements Serializable, RemoteAcces
}
}
public String getLockerName() {
return lockerName;
}
public void setLockerName(String lockerName) {
this.lockerName = lockerName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getNickName() {
return nickName;
}
......
......@@ -131,7 +131,7 @@ public class BaseSearchCondition implements Serializable {
if (!ObjectsUtil.isNull(branchIds) && !branchIds.isEmpty()) {
SearchItem si = new SearchItem();
si.fieldName = "branchId";
si.operator = SearchItem.Operator.IN.value;
si.operator = SearchItem.Operator.IN;
si.value = ObjectsUtil.join(",", branchIds);
this.searchItems.addItem(si);
this.addSearchItemWithOr(si);
......
package com.yonde.basedata.search;
import com.yonde.basedata.entity.users.DxUserVO;
import com.yonde.basedata.vo.DxMasterVO;
import com.yonde.basedata.vo.DxVersionVO;
import com.yonde.context.vo.DxContextVO;
import com.yonde.doc.vo.DxDocumentVO;
import com.yonde.part.vo.DxPartVO;
import com.yonde.part.vo.DxViewVO;
import wt.clients.beans.query.WTAttribute;
import wt.doc.WTDocument;
import wt.part.WTPart;
import wt.query.SearchCondition;
import wt.util.WTAttributeNameIfc;
import wt.vc.views.ViewReference;
import java.util.HashMap;
......@@ -20,6 +29,8 @@ public class SearchOperatorEnumUtil {
public static final String DX_STATE = "state";
public static final String DX_TYPE = "type";
public static final Map<String, String> commonSearchItemMap = new HashMap();// 通用搜索条件
public static final Map<String, String> partSearchItemMap = new HashMap();// 部件搜索条件
......@@ -28,10 +39,34 @@ public class SearchOperatorEnumUtil {
public static final Map<Class<?>, Map<String, String>> typeSearchItemMap = new HashMap();// 类型搜索条件映射
public static final Map<Class<?>, String> typeItemMap = new HashMap();// 类型映射
public static final Map<Long, String> viewMap = new HashMap();// 视图映射
static {
initSearchItemMap();
initPartItemMap();
initDocItemMap();
initTypeItemMap();
initViewMap();
}
public static void initViewMap() {
viewMap.put(1L, "Design");
viewMap.put(2L, "Planning");
viewMap.put(3L, "Manufacture");
}
public static void initTypeItemMap() {
typeItemMap.put(DxPartVO.class, "com.yonde.dcs.xbom.common.entity.vo.DxPartVO");
typeItemMap.put(DxDocumentVO.class, "com.yonde.dcs.document.common.entity.vo.DxDocumentVO");
typeItemMap.put(DxUserVO.class, "");
typeItemMap.put(DxViewVO.class, "com.yonde.dex.view.common.entity.DxViewVO");
typeItemMap.put(DxVersionVO.class, "com.yonde.dex.version.plugin.common.entity.DxVersionVO");
typeItemMap.put(DxMasterVO.class, "com.yonde.dex.version.plugin.common.entity.DxMasterVO");
typeItemMap.put(DxContextVO.class, "com.yonde.dex.context.common.vo.DxContextProjectVO");
//TODO add
}
public static void initSearchItemMap() {
......@@ -41,7 +76,7 @@ public class SearchOperatorEnumUtil {
}
public static void initPartItemMap() {
partSearchItemMap.put(DX_ID, WTPart.PERSIST_INFO + ".key.id");
partSearchItemMap.put(DX_ID, WTAttributeNameIfc.ID_NAME);
partSearchItemMap.put(DX_NUMBER, WTPart.NUMBER);
partSearchItemMap.put(DX_NAME, WTPart.NAME);
partSearchItemMap.put(DX_VIEWID, WTPart.VIEW + "."
......@@ -53,7 +88,7 @@ public class SearchOperatorEnumUtil {
}
public static void initDocItemMap() {
docSearchItemMap.put(DX_ID, WTDocument.PERSIST_INFO + ".key.id");
docSearchItemMap.put(DX_ID, WTAttributeNameIfc.ID_NAME);
docSearchItemMap.put(DX_NUMBER, WTDocument.NUMBER);
docSearchItemMap.put(DX_NAME, WTDocument.NAME);
docSearchItemMap.put(DX_STATE, WTDocument.LIFE_CYCLE_STATE);
......
......@@ -5,25 +5,31 @@ import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.basedata.vo.IdVO;
import com.yonde.common.DocUtil;
import com.yonde.common.DxSearchUtil;
import com.yonde.common.RfUtil;
import com.yonde.doc.vo.DxDocumentVO;
import com.yonde.part.service.DxPartService;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import wt.doc.WTDocument;
import wt.fc.WTObject;
import wt.log4j.LogR;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.part.WTPart;
import wt.util.WTException;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
public class BaseSearchService <V extends IdVO>{
import java.util.List;
@Service
public class BaseSearchService <V extends IdVO> implements RemoteAccess {
private static Logger logger = LogR.getLogger(BaseSearchService.class.getName());
public DxPageImpl<V> search(SearchQueryCondition searchQueryCondition){
return null;
};
public ApiResult saveRecursion(V entity) {
return null;
};
}
public IdVO getWorkingCopy(Long id) throws Exception {
WTObject wtObjectByOid = RfUtil.getWTObjectByOid(id + "");
......@@ -38,4 +44,16 @@ public class BaseSearchService <V extends IdVO>{
}
return null;
}
public static List findByConfigSpecSelect (SearchQueryCondition searchQueryCondition) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (List) RemoteMethodServer.getDefault().invoke("findByConfigSpecSelect", BaseSearchService.class.getName(), null,
new Class[] { SearchQueryCondition.class},
new Object[] { searchQueryCondition});
}
logger.error("findByConfigSpecSelect===111" + searchQueryCondition.toString());
/*boolean enforce = SessionServerHelper.manager.setAccessEnforced(false);*/
List<IdVO> partList = DxSearchUtil.findByConfigSpecSelect(searchQueryCondition);;
return partList;
}
}
......@@ -12,5 +12,35 @@ public class DxDocumentFolderVO extends IdVO{
private List<DxDocumentVO> dxDocuments;
public String getFullPath() {
return fullPath;
}
public void setFullPath(String fullPath) {
this.fullPath = fullPath;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Boolean getLeaf() {
return isLeaf;
}
public void setLeaf(Boolean leaf) {
isLeaf = leaf;
}
public List<DxDocumentVO> getDxDocuments() {
return dxDocuments;
}
public void setDxDocuments(List<DxDocumentVO> dxDocuments) {
this.dxDocuments = dxDocuments;
}
}
......@@ -2,6 +2,7 @@ package com.yonde.basedata.vo;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.yonde.basedata.entity.users.DxUserVO;
import com.yonde.basedata.search.SearchOperatorEnumUtil;
import com.yonde.common.DateTimeUtil;
import wt.fc.PersistenceHelper;
import wt.fc.WTObject;
......@@ -11,14 +12,17 @@ import wt.util.WTException;
import java.io.Serializable;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "dxClassname",visible = true)
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "className",visible = true)
public class IdVO extends IdOnlyVO implements Serializable {
protected String dxClassname;
private String dxClassname = SearchOperatorEnumUtil.typeItemMap.get(this.getClass());
private String className;
private DxUserVO creator;
private DxUserVO modifier;
protected String modifyTime;
protected String createTime;
private String operator;
public IdVO() {
}
......@@ -36,6 +40,38 @@ public class IdVO extends IdOnlyVO implements Serializable {
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getOperator() {
return operator;
}
public void setOperator(String operator) {
this.operator = operator;
}
public DxUserVO getCreator() {
return creator;
}
public void setCreator(DxUserVO creator) {
this.creator = creator;
}
public DxUserVO getModifier() {
return modifier;
}
public void setModifier(DxUserVO modifier) {
this.modifier = modifier;
}
public String getDxClassname() {
return dxClassname;
}
......
package com.yonde.basedata.vo;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.yonde.basedata.entity.users.DxUserVO;
import com.yonde.common.DateTimeUtil;
import com.yonde.part.vo.DxPartVO;
import wt.enterprise.RevisionControlled;
import wt.fc.Persistable;
import wt.org.WTPrincipal;
......@@ -12,6 +14,12 @@ import wt.util.WTException;
import java.io.Serializable;
@JsonTypeInfo(
use = JsonTypeInfo.Id.CLASS,
property = "classname",
visible = true,
defaultImpl = RevisionControlledVO.class
)
public class RevisionControlledVO extends IdVO implements Serializable {
private DxVersionVO version;
private Long versionId;
......@@ -24,14 +32,17 @@ public class RevisionControlledVO extends IdVO implements Serializable {
private DxMasterVO masterVO;
private Long masterId;
private DxUserVO creator;
private DxUserVO modifier;
private Long creatorId;
private Long modifierId;
private String lockNote;
private String lockDate;
private DxUserVO locker;
private Long lockerId;
private Long sandboxId = 0L;
private String secretCode = "NonSecret";
public RevisionControlledVO() {
}
......@@ -43,15 +54,20 @@ public class RevisionControlledVO extends IdVO implements Serializable {
// To set the user of the session to be the administrator
SessionHelper.manager.setAdministrator();
this.setModifier(new DxUserVO((WTPrincipal) object.getModifier().getObject()));
this.modifierId = this.getModifier().getId();
this.setCreator(new DxUserVO((WTPrincipal) object.getCreator().getObject()));
System.out.println("createor=========" + this.creator);
Persistable persistable = object.getLocker().getObject();
this.creatorId = this.getCreator().getId();
this.setLockerVO(object);
/* Persistable persistable = object.getLocker().getObject();
if (persistable != null) {
WTUser locker = ((WTUser) persistable);
this.setLockNote(object.getLockNote());
this.setLockDate(DateTimeUtil.timeStampToString(object.getLockDate()));
this.setLocker(new DxUserVO(locker));
}
DxUserVO dxUserVO = new DxUserVO(locker);
dxUserVO.setLockerName(dxUserVO.getUserName());
this.setLocker(dxUserVO);
this.lockerId = this.getLocker().getId();
}*/
}finally {
SessionContext.setContext(previous);
}
......@@ -59,6 +75,19 @@ public class RevisionControlledVO extends IdVO implements Serializable {
//object.c
}
public void setLockerVO(RevisionControlled object) throws WTException {
Persistable persistable = object.getLocker().getObject();
if (persistable != null) {
WTUser locker = ((WTUser) persistable);
this.setLockNote(object.getLockNote());
this.setLockDate(DateTimeUtil.timeStampToString(object.getLockDate()));
DxUserVO dxUserVO = new DxUserVO(locker);
dxUserVO.setLockerName(dxUserVO.getUserName());
this.setLocker(dxUserVO);
this.lockerId = this.getLocker().getId();
}
}
public DxVersionVO getVersion() {
return version;
}
......@@ -84,6 +113,30 @@ public class RevisionControlledVO extends IdVO implements Serializable {
//this.number = masterVO.getNumber();
}
public Long getSandboxId() {
return sandboxId;
}
public void setSandboxId(Long sandboxId) {
this.sandboxId = sandboxId;
}
public String getSecretCode() {
return secretCode;
}
public void setSecretCode(String secretCode) {
this.secretCode = secretCode;
}
public Long getLockerId() {
return lockerId;
}
public void setLockerId(Long lockerId) {
this.lockerId = lockerId;
}
public String getLockNote() {
return lockNote;
}
......@@ -107,23 +160,7 @@ public class RevisionControlledVO extends IdVO implements Serializable {
public void setLocker(DxUserVO locker) {
this.locker = locker;
}
public DxUserVO getCreator() {
return creator;
}
public void setCreator(DxUserVO creator) {
this.creator = creator;
this.creatorId = creator.getId();
}
public DxUserVO getModifier() {
return modifier;
}
public void setModifier(DxUserVO modifier) {
this.modifier = modifier;
this.modifierId = modifier.getId();
}
public Long getCreatorId() {
return creatorId;
......
package com.yonde.basedata.vo.lc;
public class LifecycleStateVO {
}
package com.yonde.basedata.vo.lc;
import java.util.List;
public class LifecycleTemplateVO {
//@ApiModelProperty("描述")
private String description;
//@ApiModelProperty("是否启用")
private Boolean enable;
//@ApiModelProperty("状态变化流程图描述")
private String layout;
/* @XmlElementProperty(
name = "stateVos",
isList = true
)*/
private List<LifecycleStateVO> stateVos;
/* @XmlElementProperty(
name = "stateTraceVos",
isList = true
)*/
//private List<LifecycleStateTraceVO> stateTraceVos;
}
......@@ -3,6 +3,7 @@ package com.yonde.common;
import com.ptc.core.components.util.OidHelper;
import com.ptc.core.htmlcomp.jstable.SandboxStatusHelper;
import com.ptc.core.htmlcomp.jstable.ServerStatusHelper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import wt.access.AccessControlHelper;
......@@ -19,6 +20,8 @@ import wt.epm.workspaces.EPMWorkspace;
import wt.fc.*;
import wt.fc.collections.WTCollection;
import wt.folder.Folder;
import wt.folder.FolderEntry;
import wt.folder.FolderHelper;
import wt.inf.container.WTContained;
import wt.inf.container.WTContainer;
import wt.inf.container.WTContainerRef;
......@@ -63,6 +66,7 @@ import java.rmi.RemoteException;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
public class CommonUtil implements RemoteAccess {
private static final Logger log = LogR.getLogger(CommonUtil.class.getName());
......@@ -686,6 +690,64 @@ public class CommonUtil implements RemoteAccess {
}
}
public static void setFolder(WTContainerRef wtcontainerref, FolderEntry folderentry, String s) throws WTException {
if (s != null && wtcontainerref != null) {
Folder folder = null;
//处理文件
List<String> folderPathList = new ArrayList<String>();
recursionCreateFolder(s, folderPathList);
int i = 0;
String[] ida = new String[folderPathList.size()];
for (Iterator it = folderPathList.iterator(); it.hasNext(); )
ida[i++] = ((String) it.next());
Arrays.sort(ida, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
int x = o1.length();
int y = o2.length();
//(x < y) ? -1 : ((x == y) ? 0 : 1)
return (x < y) ? -1 : ((x == y) ? 0 : 1);
}
});
/* folderPathList.stream()
.sorted(
(a, b) -> {
return Integer.compare(a.length(), b.length());
})
.collect(Collectors.toList());*/
System.out.println(">>>>>>folderPathList=" + folderPathList);
//创建不存在的文件夹信息
if (CollectionUtils.isNotEmpty(folderPathList)) {
for (String folderPath : folderPathList) {
try {
folder = FolderHelper.service.getFolder(folderPath, wtcontainerref);
} catch (WTException e) {
folder = null;
}
if (folder == null) {
folder = FolderHelper.service.createSubFolder(folderPath, wtcontainerref);
}
}
}
if (folder == null) {
throw new WTException("文件夹不存在请检查文件夹路径!" + s);
}
FolderHelper.assignLocation(folderentry, folder);
}
}
public static List recursionCreateFolder(String folderPath, List folderList) {
if (StringUtils.contains(folderPath, "/") && (!StringUtils.equalsIgnoreCase(folderPath, "/Default"))) {
folderList.add(folderPath);
folderPath = folderPath.substring(0, folderPath.lastIndexOf("/"));
recursionCreateFolder(folderPath, folderList);
}
return folderList;
}
}
This diff is collapsed.
......@@ -19,8 +19,6 @@ import java.io.Serializable;
public class DxCommonUtils implements RemoteAccess, Serializable {
/**
*
* 返回检出的工作副本,如果已经检出,则返回已经存在的工作副本
......
This diff is collapsed.
This diff is collapsed.
package com.yonde.context.controller;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.context.service.DxContextService;
import com.yonde.context.vo.DxContextVO;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(value = "/DxContext")
public class DxContentController {
@GetMapping({"/treeWithCondition"})
public List<DxContextVO> getAllTreeByCondition(@RequestParam(required = false) String state, @RequestParam(required = false) String subTypeName, @RequestParam(required = false) Boolean currentUserFlag) {
try {
return DxContextService.queryProduct("","");
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
package com.yonde.context.service;
import com.yonde.context.vo.DxContextVO;
import com.yonde.part.service.DxPartService;
import com.yonde.part.vo.DxPartVO;
import org.apache.commons.lang.StringUtils;
import wt.fc.PersistenceHelper;
import wt.fc.QueryResult;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.pdmlink.PDMLinkProduct;
import wt.pds.StatementSpec;
import wt.query.QuerySpec;
import wt.query.SearchCondition;
import java.util.ArrayList;
import java.util.List;
public class DxContextService implements RemoteAccess {
/**
* 根据产品名称,类型查询系统中指定子类型的产品对象
*
* @param proName
* @param type
* @return
* @throws Exception
*/
public static List<DxContextVO> queryProduct(String proName, String type) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (List<DxContextVO>) RemoteMethodServer.getDefault().invoke("queryProduct", DxContextService.class.getName(), null,
new Class[] { String.class, String.class},
new Object[] { proName, type});
}
ArrayList<PDMLinkProduct> resultList = new ArrayList<PDMLinkProduct>();
List<DxContextVO> contextVOS = new ArrayList<DxContextVO>();
QuerySpec spec;
spec = new QuerySpec();
spec.setAdvancedQueryEnabled(true);
int docIndex = spec.appendClassList(PDMLinkProduct.class, true);
/* if (spec.getConditionCount() > 0) {
spec.appendAnd();
}*/
//VTC 产品
/* TypeDefinitionReference tdr = TypedUtility.getTypeDefinitionReference(Global.Type.VTC_PDMLINKPRODUCT);
SearchCondition typeDefinitionCondition =
new SearchCondition(
PDMLinkProduct.class,
PDMLinkProduct.TYPE_DEFINITION_REFERENCE
+ "."
+ TypeDefinitionReference.KEY
+ "."
+ TypeDefinitionForeignKey.BRANCH_ID,
SearchCondition.NOT_EQUAL,
tdr.getKey().getBranchId());
spec.appendWhere(typeDefinitionCondition, new int[] {docIndex});
if (spec.getConditionCount() > 0) {
spec.appendAnd();
}*/
//委任代表 产品
/* TypeDefinitionReference tdr2 = TypedUtility.getTypeDefinitionReference(Global.Type.AR_PDMLINKPRODUCT);
SearchCondition typeDefinitionCondition2 =
new SearchCondition(
PDMLinkProduct.class,
PDMLinkProduct.TYPE_DEFINITION_REFERENCE
+ "."
+ TypeDefinitionReference.KEY
+ "."
+ TypeDefinitionForeignKey.BRANCH_ID,
SearchCondition.NOT_EQUAL,
tdr2.getKey().getBranchId());
spec.appendWhere(typeDefinitionCondition2, new int[] {docIndex});
if (spec.getConditionCount() > 0) {
spec.appendAnd();
}*/
//科研管理 产品
/* TypeDefinitionReference tdr3 = TypedUtility.getTypeDefinitionReference(Global.Type.SRM_PRODUCT);
SearchCondition typeDefinitionCondition3 =
new SearchCondition(
PDMLinkProduct.class,
PDMLinkProduct.TYPE_DEFINITION_REFERENCE
+ "."
+ TypeDefinitionReference.KEY
+ "."
+ TypeDefinitionForeignKey.BRANCH_ID,
SearchCondition.NOT_EQUAL,
tdr3.getKey().getBranchId());
spec.appendWhere(typeDefinitionCondition3, new int[] {docIndex});*/
/* if (spec.getConditionCount() > 0) {
spec.appendAnd();
}
//证后管理 产品
TypeDefinitionReference tdr4 = TypedUtility.getTypeDefinitionReference(Global.Type.ZH_PRODUCT);
SearchCondition typeDefinitionCondition4 =
new SearchCondition(
PDMLinkProduct.class,
PDMLinkProduct.TYPE_DEFINITION_REFERENCE
+ "."
+ TypeDefinitionReference.KEY
+ "."
+ TypeDefinitionForeignKey.BRANCH_ID,
SearchCondition.NOT_EQUAL,
tdr4.getKey().getBranchId());
spec.appendWhere(typeDefinitionCondition4, new int[] {docIndex});*/
if (null != proName && StringUtils.isNotEmpty(proName.trim())) {
if (spec.getConditionCount() > 0) {
spec.appendAnd();
}
spec.appendWhere(
new SearchCondition(
PDMLinkProduct.class, PDMLinkProduct.NAME, SearchCondition.LIKE, "%" + proName + "%"),
new int[] {docIndex});
}
// 执行搜索
try {
QueryResult qr = PersistenceHelper.manager.find((StatementSpec) spec);
while (qr.hasMoreElements()) {
Object[] objs = (Object[]) qr.nextElement();
PDMLinkProduct mPro = (PDMLinkProduct) objs[0];
/* if(mPro.getName().contains("适航指令")){
continue;
}*/
resultList.add(mPro);
contextVOS.add(new DxContextVO(mPro));
}
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
}
return contextVOS;
}
}
package com.yonde.context.vo;
import com.yonde.basedata.entity.users.DxUserVO;
import com.yonde.basedata.vo.IdVO;
import com.yonde.common.DateTimeUtil;
import wt.fc.PersistenceHelper;
import wt.inf.container.WTContainer;
import wt.org.WTPrincipal;
import wt.pdmlink.PDMLinkProduct;
import wt.util.WTException;
import java.util.List;
public class DxContextVO extends IdVO {
protected String name;
private List<DxContextTeamVO> dxContextTeams;
private Boolean tabShowFlag;
private String state;
private String name;
private String remark;
private Boolean operationFlag;
private Boolean isLeaf;
public DxContextVO() {
}
public DxContextVO(WTContainer container) {
public DxContextVO(WTContainer container) throws WTException {
this.name = container.getName();
if (container instanceof PDMLinkProduct) {
PDMLinkProduct linkProduct = (PDMLinkProduct) container;
this.createTime = DateTimeUtil.timeStampToString(linkProduct.getCreateTimestamp());
this.modifyTime = DateTimeUtil.timeStampToString(linkProduct.getModifyTimestamp());
this.setId(PersistenceHelper.getObjectIdentifier(linkProduct).getId());
WTPrincipal owner = linkProduct.getOwner();
this.setCreator(new DxUserVO(owner));
this.setModifier(new DxUserVO(owner));
}
}
public List<DxContextTeamVO> getDxContextTeams() {
return dxContextTeams;
}
public void setDxContextTeams(List<DxContextTeamVO> dxContextTeams) {
this.dxContextTeams = dxContextTeams;
}
public Boolean getTabShowFlag() {
return tabShowFlag;
}
public void setTabShowFlag(Boolean tabShowFlag) {
this.tabShowFlag = tabShowFlag;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Boolean getOperationFlag() {
return operationFlag;
}
public void setOperationFlag(Boolean operationFlag) {
this.operationFlag = operationFlag;
}
public Boolean getLeaf() {
return isLeaf;
}
public void setLeaf(Boolean leaf) {
isLeaf = leaf;
}
public String getName() {
......
......@@ -15,6 +15,87 @@ public class DxDocController extends AbstractBaseController {
@Autowired
private DxDocService docService;
@GetMapping({"/version/getWorkingCopy/{id}"})
//@ApiOperation("获取工作副本")
public DxDocumentVO getWorkingCopy(@PathVariable Long id) {
DxDocumentVO dxDocumentVO = null;
try {
dxDocumentVO = DxDocService.getDxDocWorkingCopy(id);
} catch (Exception e) {
e.printStackTrace();
}
return dxDocumentVO;
}
@GetMapping({"/version/{id}"})
//@ApiOperation("获取部件对象")
public DxDocumentVO getDxPart(@PathVariable Long id) {
DxDocumentVO DxDocumentVO = null;
try {
DxDocumentVO = DxDocService.getDxDoc(id);
} catch (Exception e) {
e.printStackTrace();
}
return DxDocumentVO;
}
@PostMapping({"/version/{id}/checkout"})
//@ApiOperation("获取工作副本")
public DxDocumentVO checkout(@PathVariable Long id) {
DxDocumentVO DxDocumentVO = null;
try {
DxDocumentVO = DxDocService.checkout(id, "Dex检出");
} catch (Exception e) {
e.printStackTrace();
}
return DxDocumentVO;
}
@PostMapping({"/version/{id}/undoCheckout"})
//@ApiOperation("获取工作副本")
public DxDocumentVO undoCheckout(@PathVariable Long id) {
DxDocumentVO DxDocumentVO = null;
try {
DxDocumentVO = DxDocService.undoCheckout(id);
} catch (Exception e) {
e.printStackTrace();
}
return DxDocumentVO;
}
@PostMapping({"/version/{id}/checkin"})
//@ApiOperation("获取工作副本")
public DxDocumentVO checkin(@PathVariable Long id, @RequestBody String node) {
System.out.println("check in====" + node);
DxDocumentVO DxDocumentVO = null;
try {
DxDocumentVO = DxDocService.checkin(id, node);
} catch (Exception e) {
e.printStackTrace();
}
return DxDocumentVO;
}
//@ApiOperation("深度保存对象")
@PostMapping({"recursion"})
public ApiResult recursionObj(@RequestBody DxDocumentVO entity) {
//return ApiResult.ok(this.getService().saveRecursion(entity));
try {
DxDocumentVO doc = DxDocService.createDxDoc(entity);
return ApiResult.ok(doc);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("501", e.getLocalizedMessage(), e);
}
}
//@ApiOperation("更改文档状态")
@PostMapping({"/updateDocumentStatus"})
public ApiResult<DxDocumentVO> updateDocumentStatusRaw(@RequestBody DxDocumentVO dxDocumentVo) {
......
package com.yonde.doc.service;
import com.yonde.common.DocUtil;
import com.yonde.common.*;
import com.yonde.doc.util.DxDocUtil;
import com.yonde.doc.vo.DxDocumentVO;
import com.yonde.part.service.DxPartService;
import com.yonde.part.vo.DxPartVO;
import org.springframework.stereotype.Service;
import wt.doc.WTDocument;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.part.WTPart;
import wt.session.SessionContext;
import wt.session.SessionHelper;
import wt.util.WTException;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.List;
@Service
public class DxDocService {
public class DxDocService implements RemoteAccess {
/**
* 获取工作副本
* @param id
* @return
* @throws Exception
*/
public static DxDocumentVO getDxDocWorkingCopy(Long id) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("getDxDocWorkingCopy", DxDocService.class.getName(), null,
new Class[] { Long.class},
new Object[] { id});
}
SessionContext previous = SessionContext.newContext();
DxDocumentVO dxDocumentVO = null;
try {
SessionHelper.manager.setAdministrator();
WTDocument docById = DxDocUtil.getDocById(id);
if (CommonUtil.isCheckedOut(docById)) {
WTDocument document = (WTDocument) CommonUtil.getWorkingCopyVersion(docById);
dxDocumentVO = new DxDocumentVO(document);
if (ObjectsUtil.isNull(dxDocumentVO.getLocker())) {
dxDocumentVO.setLockerVO(docById);
}
} else {
dxDocumentVO = new DxDocumentVO(docById);
}
} finally {
SessionContext.setContext(previous);
}
return dxDocumentVO;
}
/**
* 获取对象
* @param id
* @return
* @throws Exception
*/
public static DxDocumentVO getDxDoc(Long id) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("getDxDoc", DxDocService.class.getName(), null,
new Class[] { Long.class},
new Object[] { id});
}
SessionContext previous = SessionContext.newContext();
DxDocumentVO dxDocumentVO = null;
try {
SessionHelper.manager.setAdministrator();
WTDocument docById = DxDocUtil.getDocById(id);
dxDocumentVO = new DxDocumentVO(docById);
} finally {
SessionContext.setContext(previous);
}
return dxDocumentVO;
}
/**
* 检入
* @param id
* @param checkOutNote
* @return
* @throws Exception
*/
public static DxDocumentVO checkin(Long id, String checkOutNote) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("checkin", DxDocService.class.getName(), null,
new Class[] { Long.class, String.class},
new Object[] { id, checkOutNote});
}
SessionContext previous = SessionContext.newContext();
DxDocumentVO dxDocumentVO = null;
try {
SessionHelper.manager.setAdministrator();
WTDocument docById = DxDocUtil.getDocById(id);
WTDocument checkIn = (WTDocument) DxCommonUtils.checkin(docById, checkOutNote);
dxDocumentVO = new DxDocumentVO(checkIn);
} finally {
SessionContext.setContext(previous);
}
return dxDocumentVO;
}
/**
*
* @param id
* @param checkOutNote
* @return
* @throws Exception
*/
public static DxDocumentVO checkout(Long id, String checkOutNote) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("checkout", DxDocService.class.getName(), null,
new Class[] { Long.class, String.class},
new Object[] { id, checkOutNote});
}
SessionContext previous = SessionContext.newContext();
DxDocumentVO dxDocumentVO = null;
try {
SessionHelper.manager.setAdministrator();
WTDocument docById = DxDocUtil.getDocById(id);
WTDocument checkout = (WTDocument) DxCommonUtils.checkout(docById, checkOutNote);
dxDocumentVO = new DxDocumentVO(checkout);
} finally {
SessionContext.setContext(previous);
}
return dxDocumentVO;
}
/**
* 撤销检出
* @param id
* @return
* @throws Exception
*/
public static DxDocumentVO undoCheckout(Long id) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("undoCheckout", DxDocService.class.getName(), null,
new Class[] { Long.class },
new Object[] { id });
}
SessionContext previous = SessionContext.newContext();
DxDocumentVO dxdocVO = null;
try {
SessionHelper.manager.setAdministrator();
WTDocument docById = DxDocUtil.getDocById(id);
WTDocument workable = (WTDocument) DxCommonUtils.undoCheckout(docById);
dxdocVO = new DxDocumentVO(workable);
} finally {
SessionContext.setContext(previous);
}
return dxdocVO;
}
public static DxDocumentVO createDxDoc(DxDocumentVO dxDocumentVO) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxDocumentVO) RemoteMethodServer.getDefault().invoke("createDxDoc", DxDocService.class.getName(), null,
new Class[] { DxDocumentVO.class},
new Object[] { dxDocumentVO });
}
SessionContext previous = SessionContext.newContext();
try {
SessionHelper.manager.setAdministrator();
WTDocument part = DxDocUtil.createDoc(dxDocumentVO);
dxDocumentVO = new DxDocumentVO(part);
} finally {
SessionContext.setContext(previous);
}
return dxDocumentVO;
}
public DxDocumentVO updateDocumentStatus(DxDocumentVO var1) {
return null;
}
......
package com.yonde.doc.util;
import com.yonde.basedata.service.BaseSearchService;
import com.yonde.basedata.vo.DxDocumentFolderVO;
import com.yonde.common.CommonUtil;
import com.yonde.common.IBAUtil;
import com.yonde.common.RfUtil;
import com.yonde.doc.vo.DxDocumentVO;
import org.apache.log4j.Logger;
import wt.doc.DepartmentList;
import wt.doc.DocumentType;
import wt.doc.WTDocument;
import wt.fc.PersistenceHelper;
import wt.iba.value.IBAHolder;
import wt.inf.container.WTContainer;
import wt.inf.container.WTContainerRef;
import wt.lifecycle.LifeCycleHelper;
import wt.lifecycle.LifeCycleServerHelper;
import wt.lifecycle.LifeCycleTemplate;
import wt.lifecycle.State;
import wt.log4j.LogR;
import wt.method.RemoteMethodServer;
import wt.type.ClientTypedUtility;
import wt.type.TypeDefinitionReference;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.text.ParseException;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class DxDocUtil {
private static Logger log = LogR.getLogger(DxDocUtil.class.getName());
/**
* 根据id 查询DxDoc
* @param id
* @return
* @throws Exception
*/
public static WTDocument getDocById(long id) throws Exception {
String oid = "OR:wt.doc.WTDocument:" + id;
WTDocument doc = RfUtil.getDoc(oid);
return doc;
}
public static WTDocument createDoc(DxDocumentVO dxDocumentVO)
throws WTException, WTPropertyVetoException, RemoteException, ParseException, InvocationTargetException {
String fullType = dxDocumentVO.getSubTypeName();
String number = dxDocumentVO.getNumber();
String name = dxDocumentVO.getName();
String containerName = dxDocumentVO.getDxContext().getName();
DxDocumentFolderVO dxDocumentFolder = dxDocumentVO.getDxDocumentFolder();
String folderPath = dxDocumentFolder == null?"/Default":dxDocumentFolder.getFullPath();
String lifecycleTemplateName = null;//TODO
String state = dxDocumentVO.getState();
Map ibaMap = dxDocumentVO.getDynamicAttrs();
if (fullType == null || fullType.length() == 0) {
fullType = "wt.doc.WTDocument";
}
//TypeIdentifier objType = CoreMetaUtility.getTypeIdentifier(fullType);
//WTDocument doc = (WTDocument) CoreMetaUtility.newInstance(objType);
WTDocument doc = WTDocument.newWTDocument();
TypeDefinitionReference tdr = ClientTypedUtility.getTypeDefinitionReference(fullType);
doc.setTypeDefinitionReference(tdr);
doc.setNumber(number);
doc.setName(name);
doc.setDocType(DocumentType.getDocumentTypeDefault());
doc.setDepartment(DepartmentList.getDepartmentListDefault());
WTContainer container = CommonUtil.getContainerByName(containerName);
WTContainerRef cref = WTContainerRef.newWTContainerRef(container);
doc.setContainerReference(cref);
CommonUtil.setFolder(cref, doc, folderPath);
/*
* if(folderPath != null){ Folder folder = FolderHelper.service.getFolder(folderPath, cref);
* FolderHelper.assignLocation(doc, folder); }
*/
doc.setDomainRef(cref.getReferencedContainerReadOnly().getDefaultDomainReference());
if (lifecycleTemplateName != null && lifecycleTemplateName.length() > 0) {
LifeCycleTemplate lt = LifeCycleHelper.service.getLifeCycleTemplate(lifecycleTemplateName, cref);
if (lt == null) {
throw new WTException("未在系统中找到生命周期模板:" + lifecycleTemplateName);
}
LifeCycleHelper.setLifeCycle(doc, lt.getLifeCycleTemplateReference());
}
if (state != null && state.length() > 0) {
doc = (WTDocument) LifeCycleServerHelper.setState(doc, State.toState(state));
}
doc = (WTDocument) PersistenceHelper.manager.save(doc);
log.info(">>>>>>>>>refresh.doc=" + doc.getNumber());
//doc = (WTDocument) PersistenceHelper.manager.refresh(doc);
int ibaSize = ibaMap == null ? 0 : ibaMap.size();
log.debug("开始设置软属性,数:" + ibaSize);
if (ibaSize > 0) {
doc = (WTDocument) IBAUtil.forceSetIBAValues(doc, ibaMap);
}
/* if (ibaSize > 0) {
Set keySet = ibaMap.keySet();
for (Iterator it = keySet.iterator(); it.hasNext(); ) {
String ibaName = (String) it.next();
Object value = ibaMap.get(ibaName);
if (value != null) {
IBAUtility.setIBAAnyValue(doc, ibaName, value.toString());
}
}
}*/
log.debug("软属性设置结束...");
if (doc != null) {
log.debug("文档创建成功:" + doc.getDisplayIdentity());
} else {
log.debug("文档创建失败...");
}
return doc;
}
}
......@@ -50,6 +50,10 @@ public class DxDocumentVO extends RevisionControlledVO {
private Long dxOrganizationId;
private String dxOrganizationIdType;
private DxDocumentFolderVO dxDocumentFolder;
private Long dxDocumentFolderId;
private String dxDocumentFolderIdType;
//TODO link
......@@ -89,6 +93,30 @@ public class DxDocumentVO extends RevisionControlledVO {
}
}
public DxDocumentFolderVO getDxDocumentFolder() {
return dxDocumentFolder;
}
public void setDxDocumentFolder(DxDocumentFolderVO dxDocumentFolder) {
this.dxDocumentFolder = dxDocumentFolder;
}
public Long getDxDocumentFolderId() {
return dxDocumentFolderId;
}
public void setDxDocumentFolderId(Long dxDocumentFolderId) {
this.dxDocumentFolderId = dxDocumentFolderId;
}
public String getDxDocumentFolderIdType() {
return dxDocumentFolderIdType;
}
public void setDxDocumentFolderIdType(String dxDocumentFolderIdType) {
this.dxDocumentFolderIdType = dxDocumentFolderIdType;
}
public Long getDxOrganizationId() {
return dxOrganizationId;
}
......
package com.yonde.part.controller;
import com.alibaba.fastjson.JSON;
import com.yonde.basedata.controller.AbstractBaseController;
import com.yonde.basedata.data.DxPageImpl;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.basedata.search.BaseSearchCondition;
import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.common.DxPartUtil;
import com.yonde.common.ObjectsUtil;
import com.yonde.part.service.DxPartService;
import com.yonde.part.service.PartService;
import com.yonde.part.vo.BOMQueryVO;
import com.yonde.part.vo.DxPartVO;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = "/DxPart")
public class DxPartController extends AbstractBaseController {
private DxPartService dxPartService = new DxPartService();
//@ApiOperation("通过number获取对象")
@GetMapping({"/findByNum"})
public Object getPartByNumber(@RequestParam String number, @RequestParam String view) throws Exception {
return PartService.getPartByNumber(number, view);
}
//@ApiOperation("配置规范查询")
@PostMapping({"findBySpec"})
List<DxPartVO> findByConfigSpec(@RequestBody SearchQueryCondition specSearch) {
@GetMapping({"/version/getWorkingCopy/{id}"})
//@ApiOperation("获取工作副本")
public DxPartVO getWorkingCopy(@PathVariable Long id) {
DxPartVO dxPartVO = null;
try {
DxPageImpl<DxPartVO> configSpec = this.getService().findByConfigSpec(specSearch);
List<DxPartVO> partVOS = configSpec.getContent();
return partVOS;
dxPartVO = DxPartService.getDxPartWorkingCopy(id);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
@GetMapping({"/version/getWorkingCopy/{id}"})
//@ApiOperation("获取工作副本")
public DxPartVO getWorkingCopy(@PathVariable Long id) {
//return ApiResult.ok(this.getService().getWorkingCopy(id));
return dxPartVO;
}
@GetMapping({"/version/{id}"})
//@ApiOperation("获取部件对象")
public DxPartVO getDxPart(@PathVariable Long id) {
DxPartVO dxPartVO = null;
try {
dxPartVO = DxPartService.getDxPartWorkingCopy(id);
dxPartVO = DxPartService.getDxPart(id);
} catch (Exception e) {
e.printStackTrace();
}
......@@ -54,14 +49,12 @@ public class DxPartController extends AbstractBaseController {
return dxPartVO;
}
@GetMapping({"/version/{id}/checkout"})
@PostMapping({"/version/{id}/checkout"})
//@ApiOperation("获取工作副本")
public DxPartVO checkout(@PathVariable Long id) {
//return ApiResult.ok(this.getService().getWorkingCopy(id));
DxPartVO dxPartVO = null;
try {
dxPartVO = DxPartUtil.checkout(id, "Dex检出");
dxPartVO = DxPartService.checkout(id, "Dex检出");
} catch (Exception e) {
e.printStackTrace();
}
......@@ -69,11 +62,9 @@ public class DxPartController extends AbstractBaseController {
return dxPartVO;
}
@GetMapping({"/version/{id}/undoCheckout"})
@PostMapping({"/version/{id}/undoCheckout"})
//@ApiOperation("获取工作副本")
public DxPartVO undoCheckout(@PathVariable Long id) {
//return ApiResult.ok(this.getService().getWorkingCopy(id));
DxPartVO dxPartVO = null;
try {
dxPartVO = DxPartService.undoCheckout(id);
......@@ -85,17 +76,16 @@ public class DxPartController extends AbstractBaseController {
}
@GetMapping({"/version/{id}/checkin"})
@PostMapping({"/version/{id}/checkin"})
//@ApiOperation("获取工作副本")
public DxPartVO checkin(@PathVariable Long id, @RequestParam String node) {
public DxPartVO checkin(@PathVariable Long id, @RequestBody String node) {
System.out.println("check in====" + node);
DxPartVO dxPartVO = null;
try {
dxPartVO = DxPartService.checkin(id, node);
} catch (Exception e) {
e.printStackTrace();
}
return dxPartVO;
}
......@@ -103,7 +93,7 @@ public class DxPartController extends AbstractBaseController {
//@ApiOperation("配置规范查询")
@PostMapping({"findBySpecPage"})
ApiResult findByConfigSpecPage(@RequestBody BaseSearchCondition sq) {
return ApiResult.ok(this.getService().findByConfigSpecPage(sq));
return ApiResult.ok(DxPartService.findByConfigSpecPage(sq));
}
//@ApiOperation("展开BOM")
......@@ -117,10 +107,28 @@ public class DxPartController extends AbstractBaseController {
return null;
}
@DeleteMapping({"/version/del/{id}"})
//@SubPermission({"remove"})
public ApiResult deleteAllIterationFromSameVersion(@PathVariable("id") Long id) {
//this.getService().deleteAllIterationFromSameVersion(id);
return ApiResult.ok((Object)null, "删除成功");
}
@GetMapping({"/version/latest"})
public ApiResult getNextVersionOfLatestVersion(@RequestParam("id") Long id, @RequestParam(value = "sourceViewId",required = false) Long sourceViewId, @RequestParam(value = "targetViewId",required = false) Long targetViewId) {
//return ApiResult.ok(this.getService().getNextVersionOfLatestVersion(id, sourceViewId, targetViewId));
try {
return ApiResult.ok(DxPartService.getNextVersion(id));
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("500", e.getLocalizedMessage(), e);
}
}
//@ApiOperation("展开BOM")
@PostMapping({"findBySpecP"})
public ApiResult<DxPartVO> findBySpecP(@RequestBody BaseSearchCondition bomQuery) {
return ApiResult.ok(this.getService().findByConfigSpecPage(bomQuery));
return ApiResult.ok(DxPartService.findByConfigSpecPage(bomQuery));
}
@PutMapping({"/lifecycle/changeStatus"})
......@@ -137,12 +145,22 @@ public class DxPartController extends AbstractBaseController {
}
//@ApiOperation("深度保存对象")
/* @PostMapping({"recursion"})
public ApiResult recursionObj(@RequestBody DxPartVO entity) {
return ApiResult.ok(this.getService().saveRecursion(entity));
}*/
protected DxPartService getService() {
return dxPartService;
@PostMapping({"recursion"})
public ApiResult recursionObj(@RequestBody Map entity) {
DxPartVO part = null;
try {
String jsonString = JSON.toJSONString(entity);
DxPartVO entityVO = JSON.parseObject(jsonString, DxPartVO.class);
if (ObjectsUtil.nonNull(entityVO.getOperator()) && entityVO.getOperator().equals("NO_CHANGE")) {
//更新link
part = DxPartService.updateDxPartUsageLink(entityVO);
} else {
part = DxPartService.createDxPart(entityVO);
}
return ApiResult.ok(part);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("501", e.getLocalizedMessage(), e);
}
}
}
package com.yonde.part.controller;
import com.alibaba.fastjson.JSON;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.part.service.DxPartService;
import com.yonde.part.vo.DxPartVO;
import com.yonde.part.vo.DxUsageLinkVO;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping(value = "/DxUsageLink")
public class DxUsageLinkController {
//@ApiOperation("深度保存对象")
@PostMapping({"recursion"})
public ApiResult recursionObj(@RequestBody Map entity) {
//return ApiResult.ok(this.getService().saveRecursion(entity));
try {
String jsonString = JSON.toJSONString(entity);
DxUsageLinkVO entityVO = JSON.parseObject(jsonString, DxUsageLinkVO.class);
entityVO = DxPartService.createDxPartUsageLink(entityVO);
return ApiResult.ok(entityVO);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("501", e.getLocalizedMessage(), e);
}
}
//@ApiOperation("深度保存对象")
@PostMapping({"recursions"})
public ApiResult recursionObj(@RequestBody List entity) {
//return ApiResult.ok(this.getService().saveRecursion(entity));
try {
String jsonString = JSON.toJSONString(entity);
List entityVOList = JSON.parseObject(jsonString, List.class);
List<DxUsageLinkVO> resultList = new ArrayList<DxUsageLinkVO>();
for (Object o : entityVOList) {
DxUsageLinkVO entityVO = DxPartService.createDxPartUsageLink((DxUsageLinkVO)o);
resultList.add(entityVO);
}
return ApiResult.ok(resultList);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("501", e.getLocalizedMessage(), e);
}
}
@DeleteMapping({"/batch/{id}"})// id,id2,id3 linkId
//@SubPermission({"remove"})
public ApiResult deleteDxPartUsageLink(@PathVariable("id") Long id) {
//this.getService().deleteAllIterationFromSameVersion(id);
return ApiResult.ok((Object)null, "删除成功");
}
}
......@@ -22,7 +22,7 @@ public class DxPartServiceImpl {
return null;
}
public DxPageImpl<DxPartVO> findByConfigSpec(SpecSearch specSearch) {
/* public DxPageImpl<DxPartVO> findByConfigSpec(SpecSearch specSearch) {
SearchQueryCondition searchQueryCondition = specSearch.getSearchQueryCondition();
DxPageImpl<DxPartVO> byConfigSpecSelect = null;
......@@ -32,7 +32,7 @@ public class DxPartServiceImpl {
e.printStackTrace();
}
return byConfigSpecSelect;
}
}*/
public DxPageImpl<DxPartVO> findByConfigSpecPage(SearchQueryCondition specSearch) {
......
package com.yonde.part.vo;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yonde.basedata.entity.users.DxUserVO;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.yonde.basedata.vo.DxMasterVO;
import com.yonde.basedata.vo.DxOrganizationVO;
import com.yonde.basedata.vo.DxVersionVO;
import com.yonde.basedata.vo.RevisionControlledVO;
import com.yonde.common.CommonUtil;
import com.yonde.common.DateTimeUtil;
import com.yonde.common.IBAHelper;
import com.yonde.context.vo.DxContextVO;
import wt.fc.Persistable;
import wt.fc.PersistenceHelper;
import wt.fc.WTObject;
import wt.method.RemoteAccess;
import wt.org.WTOrganization;
import wt.org.WTUser;
import wt.part.WTPart;
import wt.part.WTPartHelper;
import wt.session.SessionContext;
import wt.session.SessionHelper;
import wt.type.ClientTypedUtility;
......@@ -31,7 +24,13 @@ import java.rmi.RemoteException;
import java.util.List;
import java.util.Locale;
public class DxPartVO extends RevisionControlledVO implements RemoteAccess, Serializable {
@JsonTypeInfo(
use = JsonTypeInfo.Id.CLASS,
property = "classname",
visible = true,
defaultImpl = DxPartVO.class
)
public class DxPartVO extends RevisionControlledVO implements Serializable {
@JsonIgnore
private WTPart wtPart;
......@@ -67,7 +66,6 @@ public class DxPartVO extends RevisionControlledVO implements RemoteAccess, Seri
private Integer dxViewId;
private Long predecessorId; //TODO 对象上一版本
private Long originId;
//private String dxClassname = "com.yonde.dcs.xbom.common.entity.vo.DxUsageLinkVO";
private Boolean upperPart = false;
......@@ -89,7 +87,7 @@ public class DxPartVO extends RevisionControlledVO implements RemoteAccess, Seri
public DxPartVO(WTPart wtPart) throws WTException, RemoteException, InvocationTargetException {
super(wtPart);
System.out.println("DxPartVO===user" + wtPart.getCreator());
System.out.println("DxPartVO===user" + this.getCreator());
SessionContext previous = SessionContext.newContext();
try {
// To set the user of the session to be the administrator
......
package com.yonde.part.vo;
import com.yonde.basedata.entity.users.DxUserVO;
import com.yonde.basedata.vo.IdVO;
import com.yonde.common.DateTimeUtil;
import com.yonde.common.IBAHelper;
import com.yonde.common.PartUtil;
import wt.fc.PersistenceHelper;
import wt.fc.PersistenceServerHelper;
import wt.part.Quantity;
import wt.part.WTPart;
import wt.part.WTPartMaster;
......@@ -15,7 +12,6 @@ import wt.util.WTException;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.List;
public class DxUsageLinkVO extends IdVO {
......@@ -30,7 +26,7 @@ public class DxUsageLinkVO extends IdVO {
private Long sourceId;
private String sourceIdType;
//TODO
private String dxClassname = "com.yonde.dcs.xbom.common.entity.vo.DxUsageLinkVO";
//private String dxClassname = "com.yonde.dcs.xbom.common.entity.vo.DxUsageLinkVO";
public DxUsageLinkVO(WTPartUsageLink usageLink, int level) throws WTException, RemoteException, InvocationTargetException {
super(usageLink);
......@@ -115,13 +111,4 @@ public class DxUsageLinkVO extends IdVO {
this.sourceIdType = sourceIdType;
}
@Override
public String getDxClassname() {
return dxClassname;
}
@Override
public void setDxClassname(String dxClassname) {
this.dxClassname = dxClassname;
}
}
......@@ -21,7 +21,8 @@ public class DxViewVO extends IdVO {
super(wtPart);
View view = ViewHelper.getView(wtPart);
this.name = view.getName();
this.level = ViewHelper.service.getViewLevel(view);
this.level = ViewHelper.service.getViewLevel(view) + 1;//TOOD 两边视图id不一致
this.id = Long.valueOf(this.level);
}
public String getName() {
......
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