Commit 780369c0 authored by shyWang's avatar shyWang

PDM前端改造

DEX、PDM系统联调(单表、BOM树、详情页)通过初版提交
parent e20bdba5
......@@ -8,18 +8,18 @@ import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.basedata.service.BaseSearchService;
import com.yonde.basedata.vo.IdVO;
import com.yonde.common.ObjectsUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.*;
public class AbstractBaseController<V extends IdVO, S extends BaseSearchService> {
public abstract class AbstractBaseController<V extends IdVO, S extends BaseSearchService> {
protected abstract S getService();
//S getService();
S getService() {
return (S) new BaseSearchService<V>();
}
/*
@PostMapping({"recursion"})
ApiResult recursionObj(@RequestBody V entity) {
return ApiResult.ok(this.getService().saveRecursion(entity));
}
......@@ -35,7 +35,19 @@ public abstract class AbstractBaseController<V extends IdVO, S extends BaseSearc
return ApiResult.ok(this.getService().search(searchQueryCondition));
}
SearchItems getPermSearchItems(BaseSearchCondition permSearchParams) {
@GetMapping({"/version/getWorkingCopy/{id}"})
//@ApiOperation("获取工作副本")
ApiResult getWorkingCopy(@PathVariable Long id) {
try {
return ApiResult.ok(this.getService().getWorkingCopy(id));
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("","",e);
}
}*/
public SearchItems getPermSearchItems(BaseSearchCondition permSearchParams) {
SearchItems searchItems = new SearchItems();
searchItems.setOperator(SearchItems.BooleanOperator.AND);
if (ObjectsUtil.nonNull(permSearchParams) && ObjectsUtil.nonNull(permSearchParams.getSearchItems())) {
......@@ -45,6 +57,18 @@ public abstract class AbstractBaseController<V extends IdVO, S extends BaseSearc
return searchItems;
}
public SearchItems getVersionPermSearchItems(BaseSearchCondition permSearchParams) {
SearchItems searchItems = new SearchItems();
searchItems.setOperator(SearchItems.BooleanOperator.AND);
if (ObjectsUtil.nonNull(permSearchParams) && ObjectsUtil.nonNull(permSearchParams.getSearchItems())) {
searchItems = permSearchParams.getSearchItems();
}
return searchItems;
}
//TODO 其他基础接口
}
package com.yonde.basedata.data;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class DxPageImpl<T> {
public class DxPageImpl<T> implements Serializable {
private List<T> content;
private int number;
private int size;
private long totalElements;
private int totalPages;
/* public DxPageImpl<T> convertToPage() {
return new DxPageImpl(this.content, PageRequest.of(this.number, this.size), this.totalElements);
}*/
public PageImpl<T> convertToPage() {
return new PageImpl(this.content, new PageRequest(this.number, this.size), this.totalElements);
}
public static <T> DxPageImpl<T> fromPage(DxPageImpl<T> page) {
public static <T> DxPageImpl<T> fromPage(PageImpl<T> page) {
DxPageImpl<T> dxPage = (DxPageImpl<T>) builder().number(page.getNumber()).size(page.getSize()).totalElements(page.getTotalElements()).totalPages(page.getTotalPages()).build();
if (CollectionUtils.size(page.getContent()) == 0) {
dxPage.setContent(new ArrayList<T>());
......
package com.yonde.basedata.entity.users;
import com.yonde.basedata.vo.IdVO;
import wt.fc.PersistenceHelper;
import wt.fc.WTObject;
import wt.method.RemoteAccess;
import wt.org.WTPrincipal;
import wt.util.WTException;
public class DxPrincipalVO extends IdVO {
import java.io.Serializable;
public class DxPrincipalVO extends IdVO implements Serializable {
private String name;
private String num;
private String description;
public DxPrincipalVO() {
}
public DxPrincipalVO(WTPrincipal principal) throws WTException {
super(principal);
this.num = principal.getName();
this.setId(PersistenceHelper.getObjectIdentifier(principal).getId());
}
public String getName() {
return name;
}
......
......@@ -2,11 +2,14 @@ package com.yonde.basedata.entity.users;
import com.yonde.basedata.entity.users.DxPrincipalVO;
import wt.fc.PersistenceHelper;
import wt.method.RemoteAccess;
import wt.org.WTPrincipal;
import wt.org.WTUser;
import wt.util.WTException;
public class DxUserVO extends DxPrincipalVO {
import java.io.Serializable;
public class DxUserVO extends DxPrincipalVO implements Serializable, RemoteAccess {
private String nickName;
private String gender;
......@@ -26,12 +29,11 @@ public class DxUserVO extends DxPrincipalVO {
}
public DxUserVO(WTPrincipal principal) throws WTException {
super(principal);
if (principal != null) {
WTUser user = (WTUser) principal;
this.userId = PersistenceHelper.getObjectIdentifier(user).getId();
this.userId = this.id;
this.setName(user.getFullName());
this.setNum(user.getName());
this.setId(userId);
this.telephone = user.getTelephoneNumber();
this.mail = user.getEMail();
......
......@@ -3,15 +3,19 @@ package com.yonde.basedata.search;
import com.yonde.basedata.data.Logical;
import com.yonde.common.ObjectsUtil;
import java.io.Serializable;
import java.util.*;
public class BaseSearchCondition {
public class BaseSearchCondition implements Serializable {
protected SearchItems searchItems;
protected Integer pageFrom;
protected Integer pageSize;
protected List<SortItem> sortItem;
public BaseSearchCondition() {
}
public BaseSearchCondition(SearchItems searchItems, Integer pageFrom, Integer pageSize, List<SortItem> sortItem) {
this.convert(searchItems);
this.searchItems = searchItems;
......@@ -127,7 +131,7 @@ public class BaseSearchCondition {
if (!ObjectsUtil.isNull(branchIds) && !branchIds.isEmpty()) {
SearchItem si = new SearchItem();
si.fieldName = "branchId";
si.operator = SearchItem.Operator.IN;
si.operator = SearchItem.Operator.IN.value;
si.value = ObjectsUtil.join(",", branchIds);
this.searchItems.addItem(si);
this.addSearchItemWithOr(si);
......
package com.yonde.basedata.search;
import com.yonde.basedata.data.DxPageImpl;
import com.yonde.common.ObjectsUtil;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.util.Assert;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class DxPageUtils {
public static final Sort.Direction DEFAULT_DIRECTION;
static {
DEFAULT_DIRECTION = Sort.Direction.ASC;
}
public DxPageUtils() {
}
public static <T> T getFirst(Page<T> page) {
return page.getTotalElements() > 0L ? page.getContent().get(0) : null;
}
public static <T> T getFirst(DxPageImpl<T> page) {
return page.getTotalElements() > 0L ? page.getContent().get(0) : null;
}
public static Sort buildSortItem(List<SortItem> sortItems) {
if (ObjectsUtil.isNull(sortItems)) {
return new Sort(new ArrayList<Sort.Order>());
} else {
List<Sort.Order> orders = new ArrayList(sortItems.size());
Iterator var2 = sortItems.iterator();
while(var2.hasNext()) {
SortItem sortParam = (SortItem)var2.next();
if (Sort.Direction.DESC.toString().equalsIgnoreCase(sortParam.getSortOrder())) {
orders.add(new Sort.Order(Sort.Direction.DESC, sortParam.getFieldName()));
} else {
orders.add(new Sort.Order(Sort.Direction.ASC, sortParam.getFieldName()));
}
}
return new Sort(orders);
}
}
public static Pageable getPageRequest(SearchQueryCondition searchQueryCondition) {
String desc = "desc";
int page = ObjectsUtil.nonNull(searchQueryCondition.getPageFrom()) ? searchQueryCondition.getPageFrom() - 1 : 0;
int size = ObjectsUtil.nonNull(searchQueryCondition.getPageSize()) ? searchQueryCondition.getPageSize() : 9999;
List<SortItem> sortItems = searchQueryCondition.getSortItem();
Sort sort = null;
if (ObjectsUtil.nonNull(sortItems) && !sortItems.isEmpty()) {
for(int i = 0; i < sortItems.size(); ++i) {
Sort.Direction direction = desc.equalsIgnoreCase(((SortItem)sortItems.get(i)).getSortOrder()) ? Sort.Direction.DESC : Sort.Direction.ASC;
if (i == 0) {
sort = by(direction, new String[]{((SortItem)sortItems.get(i)).getFieldName()});
} else {
sort = sort.and(by(direction, new String[]{((SortItem)sortItems.get(i)).getFieldName()}));
}
}
}
if (page < 0) {
page = 0;
}
return ObjectsUtil.nonNull(sort) ? new PageRequest(page, size, sort) : new PageRequest(page, size);
}
public static Sort.Order by(String property) {
return new Sort.Order(Sort.DEFAULT_DIRECTION, property);
}
public static Sort by(List<Sort.Order> orders) {
Assert.notNull(orders, "Orders must not be null!");
return orders.isEmpty() ? unsorted() : new Sort(orders);
}
public static Sort by(String... properties) {
Assert.notNull(properties, "Properties must not be null!");
return properties.length == 0 ? unsorted() : new Sort(DEFAULT_DIRECTION, Arrays.asList(properties));
}
public static Sort unsorted() {
return by();
}
public static Sort by(Sort.Direction direction, String... properties) {
Assert.notNull(direction, "Direction must not be null!");
Assert.notNull(properties, "Properties must not be null!");
Assert.isTrue(properties.length > 0, "At least one property must be given!");
List<Sort.Order> resultList = new ArrayList<Sort.Order>();
for (String property : properties) {
resultList.add(new Sort.Order(direction, property));
}
return by(resultList);
}
public static <T> DxPageImpl convertPageImpl(Page page, SearchQueryCondition condition) {
Pageable pageable = getPageRequest(condition);
DxPageImpl<T> dxPage = (DxPageImpl<T>) DxPageImpl.builder().number(pageable.getPageNumber()).size(pageable.getPageSize()).totalElements(page.getTotalElements()).totalPages(page.getTotalPages()).build();
if (CollectionUtils.size(page.getContent()) == 0) {
dxPage.setContent(new ArrayList());
} else {
dxPage.setContent(new ArrayList(page.getContent()));
}
return dxPage;
}
}
......@@ -2,25 +2,27 @@ package com.yonde.basedata.search;
import com.yonde.basedata.data.DxEnumData;
public class SearchItem {
import java.io.Serializable;
public class SearchItem implements Serializable {
public String fieldName;
public Object value;
public Object value1;
public SearchItem.Operator operator;
public String operator;
public String searchItemType;
public SearchItem() {
}
public SearchItem(String fieldName, SearchItem.Operator operator, Object value, Object value1) {
public SearchItem(String fieldName, String operator, Object value, Object value1) {
this.fieldName = fieldName;
this.value = value;
this.operator = operator;
this.value1 = value1;
}
public static enum Operator implements DxEnumData {
public enum Operator implements DxEnumData {
EQ(1, "等于"),
NEQ(2, "不等于"),
LIKE(3, "模糊查询"),
......@@ -29,7 +31,7 @@ public class SearchItem {
GTE(6, "大于等于"),
LTE(7, "小于等于"),
BTWN(8, "范围查询"),
IN(9, "多值查询"),
IN(9, "in"),
ISNULL(10, "空值查询"),
NOTNULL(11, "非空查询"),
FULLLIKE(12, "全模糊查询"),
......@@ -38,7 +40,7 @@ public class SearchItem {
final String code;
final String value;
private Operator(int code, String value) {
Operator(int code, String value) {
this.code = String.format("%04d", code);
this.value = value;
}
......@@ -51,7 +53,7 @@ public class SearchItem {
return this.value;
}
private Operator(String code, String value) {
Operator(String code, String value) {
this.code = code;
this.value = value;
}
......
package com.yonde.basedata.search;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class SearchItems {
public class SearchItems implements Serializable {
private List<SearchItem> items = new ArrayList();
private List<SearchItems> children = new ArrayList();
......@@ -208,7 +209,7 @@ public class SearchItems {
}
}
public static enum BooleanOperator {
public enum BooleanOperator {
AND,
OR;
......
package com.yonde.basedata.search;
import wt.doc.WTDocument;
import wt.part.WTPart;
import wt.query.SearchCondition;
import wt.vc.views.ViewReference;
import java.util.HashMap;
import java.util.Map;
public class SearchOperatorEnumUtil {
public static final String DX_VIEWID = "dxViewId";
public static final String DX_ID = "id";
public static final String DX_NAME = "name";
public static final String DX_NUMBER = "number";
public static final String DX_STATE = "state";
public static final Map<String, String> commonSearchItemMap = new HashMap();// 通用搜索条件
public static final Map<String, String> partSearchItemMap = new HashMap();// 部件搜索条件
public static final Map<String, String> docSearchItemMap = new HashMap();// 文档搜索条件
public static final Map<Class<?>, Map<String, String>> typeSearchItemMap = new HashMap();// 类型搜索条件映射
static {
initSearchItemMap();
initPartItemMap();
initDocItemMap();
}
public static void initSearchItemMap() {
commonSearchItemMap.put("NEQ", SearchCondition.NOT_EQUAL);
commonSearchItemMap.put("EQ", SearchCondition.EQUAL);
commonSearchItemMap.put("LIKE", SearchCondition.LIKE);
}
public static void initPartItemMap() {
partSearchItemMap.put(DX_ID, WTPart.PERSIST_INFO + ".key.id");
partSearchItemMap.put(DX_NUMBER, WTPart.NUMBER);
partSearchItemMap.put(DX_NAME, WTPart.NAME);
partSearchItemMap.put(DX_VIEWID, WTPart.VIEW + "."
+ ViewReference.KEY);
partSearchItemMap.put(DX_STATE, WTPart.LIFE_CYCLE_STATE);
//部件类型映射
typeSearchItemMap.put(WTPart.class, partSearchItemMap);
}
public static void initDocItemMap() {
docSearchItemMap.put(DX_ID, WTDocument.PERSIST_INFO + ".key.id");
docSearchItemMap.put(DX_NUMBER, WTDocument.NUMBER);
docSearchItemMap.put(DX_NAME, WTDocument.NAME);
docSearchItemMap.put(DX_STATE, WTDocument.LIFE_CYCLE_STATE);
//文档类型映射
typeSearchItemMap.put(WTDocument.class, docSearchItemMap);
}
}
package com.yonde.basedata.search;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
public class SearchQueryCondition extends BaseSearchCondition{
public class SearchQueryCondition extends BaseSearchCondition implements Serializable {
private final Integer maxPageSize = 10000;
/** @deprecated */
@Deprecated
......@@ -29,6 +30,8 @@ public class SearchQueryCondition extends BaseSearchCondition{
private Boolean seriesFlag;
private List<SearchQueryCondition> openProps;
private List<String> retainProps;
public SearchQueryCondition(){
}
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);
......@@ -435,4 +438,9 @@ public class SearchQueryCondition extends BaseSearchCondition{
return "SearchQueryCondition.SearchVersion(versionRelationType=" + ", id=" + this.getId() + ", searchItems=" + this.getSearchItems() + ")";
}
}
public String toString() {
return "SearchQueryCondition(super=" + super.toString() + ", maxPageSize=" + this.getMaxPageSize() + ", indices=" + this.getIndices() + ", keyWord=" + this.getKeyWord() + ", name=" + this.getName() + ", parentFilter=" + this.getParentFilter() + ", searchVersion=" + this.getSearchVersion() + ", globalSearch=" + this.isGlobalSearch() + ", seriesFlag=" + this.getSeriesFlag() + ", openProps=" + this.getOpenProps() + ", retainProps=" + this.getRetainProps() + ")";
}
}
package com.yonde.basedata.search;
public class SortItem {
import java.io.Serializable;
public class SortItem implements Serializable {
private String fieldName;
private String sortOrder;
......
......@@ -2,10 +2,11 @@ package com.yonde.basedata.search;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class SpecSearch {
public class SpecSearch implements Serializable {
private List<String> searchTypes = new ArrayList();
@JsonUnwrapped
......
......@@ -4,10 +4,38 @@ import com.yonde.basedata.data.DxPageImpl;
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.RfUtil;
import com.yonde.doc.vo.DxDocumentVO;
import wt.doc.WTDocument;
import wt.fc.WTObject;
import wt.part.WTPart;
import wt.util.WTException;
public interface BaseSearchService <V extends IdVO>{
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
DxPageImpl<V> search(SearchQueryCondition searchQueryCondition);
public class BaseSearchService <V extends IdVO>{
ApiResult saveRecursion(V entity);
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 + "");
if (wtObjectByOid instanceof WTDocument) {
WTDocument doc = (WTDocument) wtObjectByOid;
WTDocument workingCopyOfDoc = DocUtil.getWorkingCopyOfDoc(doc);
DxDocumentVO dxDocumentVO = new DxDocumentVO(workingCopyOfDoc);
return dxDocumentVO;
}
if (wtObjectByOid instanceof WTPart) {
}
return null;
}
}
......@@ -10,9 +10,10 @@ import wt.part.WTPart;
import wt.part.WTPartMaster;
import wt.util.WTException;
import java.io.Serializable;
import java.util.Locale;
public class DxMasterVO {
public class DxMasterVO implements Serializable {
private String number;
private String name;
......
......@@ -4,7 +4,9 @@ import wt.fc.PersistenceHelper;
import wt.org.WTOrganization;
import wt.util.WTException;
public class DxOrganizationVO extends IdVO{
import java.io.Serializable;
public class DxOrganizationVO extends IdVO implements Serializable {
private String name;
private String num;
......@@ -18,4 +20,28 @@ public class DxOrganizationVO extends IdVO{
this.description = organization.getDescription();
this.id = PersistenceHelper.getObjectIdentifier(organization).getId();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNum() {
return num;
}
public void setNum(String num) {
this.num = num;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
......@@ -6,7 +6,9 @@ import wt.fc.PersistenceHelper;
import wt.util.WTException;
import wt.vc.wip.WorkInProgressHelper;
public class DxVersionVO {
import java.io.Serializable;
public class DxVersionVO implements Serializable {
private String versionKey;
private String versionSeries;
......
package com.yonde.basedata.vo;
import java.io.Serializable;
import java.util.Map;
public class IdOnlyVO {
public class IdOnlyVO implements Serializable {
protected Long id;
protected String subTypeName;
......
......@@ -2,57 +2,49 @@ package com.yonde.basedata.vo;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.yonde.basedata.entity.users.DxUserVO;
import com.yonde.common.DateTimeUtil;
import wt.fc.PersistenceHelper;
import wt.fc.WTObject;
import wt.session.SessionContext;
import wt.session.SessionHelper;
import wt.util.WTException;
import java.io.Serializable;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, property = "dxClassname",visible = true)
public class IdVO extends IdOnlyVO{
public class IdVO extends IdOnlyVO implements Serializable {
protected String dxClassname;
protected DxUserVO creator;
protected DxUserVO modifier;
protected Long creatorId;
protected Long modifierId;
protected String modifyTime;
protected String createTime;
public String getDxClassname() {
return dxClassname;
}
public void setDxClassname(String dxClassname) {
this.dxClassname = dxClassname;
public IdVO() {
}
public DxUserVO getCreator() {
return creator;
}
public IdVO(WTObject object) throws WTException {
SessionContext previous = SessionContext.newContext();
try {
// To set the user of the session to be the administrator
SessionHelper.manager.setAdministrator();
this.setId(PersistenceHelper.getObjectIdentifier(object).getId());
this.createTime = DateTimeUtil.timeStampToString(object.getCreateTimestamp());
this.modifyTime = DateTimeUtil.timeStampToString(object.getModifyTimestamp());
}finally {
SessionContext.setContext(previous);
}
public void setCreator(DxUserVO creator) {
this.creator = creator;
}
public DxUserVO getModifier() {
return modifier;
}
public void setModifier(DxUserVO modifier) {
this.modifier = modifier;
}
public Long getCreatorId() {
return creatorId;
public String getDxClassname() {
return dxClassname;
}
public void setCreatorId(Long creatorId) {
this.creatorId = creatorId;
public void setDxClassname(String dxClassname) {
this.dxClassname = dxClassname;
}
public Long getModifierId() {
return modifierId;
}
public void setModifierId(Long modifierId) {
this.modifierId = modifierId;
}
public String getModifyTime() {
return modifyTime;
......
package com.yonde.basedata.vo;
public class RevisionControlledVO extends IdVO{
import com.yonde.basedata.entity.users.DxUserVO;
import com.yonde.common.DateTimeUtil;
import wt.enterprise.RevisionControlled;
import wt.fc.Persistable;
import wt.org.WTPrincipal;
import wt.org.WTUser;
import wt.session.SessionContext;
import wt.session.SessionHelper;
import wt.util.WTException;
import java.io.Serializable;
public class RevisionControlledVO extends IdVO implements Serializable {
private DxVersionVO version;
private Long versionId;
private String versionKey;
......@@ -12,6 +24,41 @@ public class RevisionControlledVO extends IdVO{
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;
public RevisionControlledVO() {
}
public RevisionControlledVO(RevisionControlled object) throws WTException {
super(object);
SessionContext previous = SessionContext.newContext();
try {
// To set the user of the session to be the administrator
SessionHelper.manager.setAdministrator();
this.setModifier(new DxUserVO((WTPrincipal) object.getModifier().getObject()));
this.setCreator(new DxUserVO((WTPrincipal) object.getCreator().getObject()));
System.out.println("createor=========" + this.creator);
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));
}
}finally {
SessionContext.setContext(previous);
}
//object.c
}
public DxVersionVO getVersion() {
return version;
}
......@@ -37,6 +84,63 @@ public class RevisionControlledVO extends IdVO{
//this.number = masterVO.getNumber();
}
public String getLockNote() {
return lockNote;
}
public void setLockNote(String lockNote) {
this.lockNote = lockNote;
}
public String getLockDate() {
return lockDate;
}
public void setLockDate(String lockDate) {
this.lockDate = lockDate;
}
public DxUserVO getLocker() {
return locker;
}
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;
}
public void setCreatorId(Long creatorId) {
this.creatorId = creatorId;
}
public Long getModifierId() {
return modifierId;
}
public void setModifierId(Long modifierId) {
this.modifierId = modifierId;
}
public Long getMasterId() {
return masterId;
}
......
package com.yonde.common;
import com.ptc.windchill.enterprise.templateutil.ActionValidator;
import wt.access.AccessControlHelper;
import wt.access.AccessPermission;
import wt.doc.WTDocument;
import wt.lifecycle.LifeCycleHelper;
import wt.lifecycle.LifeCycleManaged;
import wt.lifecycle.State;
import wt.method.RemoteAccess;
import wt.part.WTPart;
import wt.util.WTException;
import wt.util.WTPropertyVetoException;
import wt.vc.wip.CheckoutLink;
import wt.vc.wip.WorkInProgressHelper;
import wt.vc.wip.Workable;
import java.io.Serializable;
public class DxCommonUtils implements RemoteAccess, Serializable {
/**
*
* 返回检出的工作副本,如果已经检出,则返回已经存在的工作副本
*
* @param workable
* 需要检出的对象
* @return WTPart
* @throws WTException
* @throws WTPropertyVetoException
*/
public static Workable checkout(Workable workable, String checkOutNote)
throws WTException, WTPropertyVetoException {
Workable workingCopy = null;
if (WorkInProgressHelper.isWorkingCopy(workable)) {
workingCopy = workable;
return workingCopy;
}
if (WorkInProgressHelper.isCheckedOut(workable)) {
workingCopy = WorkInProgressHelper.service.workingCopyOf(workable);
return workingCopy;
}
String name = "";
String number = "";
if (workable instanceof WTPart) {
WTPart wtpart = (WTPart) workable;
name = wtpart.getName();
number = wtpart.getNumber();
} else if (workable instanceof WTDocument) {
WTDocument wtdoc = (WTDocument) workable;
name = wtdoc.getName();
number = wtdoc.getNumber();
}
if (!AccessControlHelper.manager.hasAccess(workable,
AccessPermission.MODIFY)) {
throw new WTException("当前用户不具有对象[编号:" + number + ",名称:" + name
+ "]的检出权限。");
}
// 判断是否有检出权限)
if (ActionValidator.isCheckOutValid(workable)) {
wt.folder.Folder checkOutFolder = null;
CheckoutLink checkOutLink = null;
checkOutFolder = WorkInProgressHelper.service
.getCheckoutFolder();
checkOutLink = WorkInProgressHelper.service.checkout(workable,
checkOutFolder, checkOutNote);
workingCopy = checkOutLink.getWorkingCopy();
if (!WorkInProgressHelper.isWorkingCopy(workingCopy)) {
workingCopy = WorkInProgressHelper.service
.workingCopyOf(workingCopy);
}
} else {
throw new WTException("当前用户不具有对象[编号:" + number + ",名称:" + name
+ "]的检出权限。");
}
return workingCopy;
}
/**
* 检入
* @param workable
* @param checkInNote
* @return
* @throws WTException
* @throws WTPropertyVetoException
*/
public static Workable checkin(Workable workable, String checkInNote)
throws WTException, WTPropertyVetoException {
// 判断是否需要检入
if (!WorkInProgressHelper.isWorkingCopy(workable)) {
workable = WorkInProgressHelper.service.workingCopyOf(workable);
}
if (WorkInProgressHelper.isCheckedOut(workable)) {
// 如果处于检出状态
workable = WorkInProgressHelper.service.checkin(workable, checkInNote);
}
return workable;
}
/**
* 撤销检出
* @param workable
* @return
* @throws Exception
*/
public static Workable undoCheckout(Workable workable) throws Exception {
if (WorkInProgressHelper.isCheckedOut(workable)) {
workable = WorkInProgressHelper.service.undoCheckout(workable);
}
return workable;
}
/**
* 更改对象状态
* @param lcm
* @param toState
* @return
* @throws Exception
*/
public static LifeCycleManaged setState(LifeCycleManaged lcm, String toState) throws Exception {
State state = State.toState(toState);
if (LifeCycleHelper.service.isState(LifeCycleHelper.service.getLifeCycleTemplate(lcm), state)) {
lcm = LifeCycleHelper.service.setLifeCycleState(lcm, state);
}
return lcm;
}
}
package com.yonde.common;
import com.yonde.part.vo.DxPartVO;
import com.yonde.part.vo.DxUsageLinkVO;
import org.apache.log4j.Logger;
import wt.fc.PersistenceHelper;
import wt.fc.QueryResult;
import wt.lifecycle.LifeCycleManaged;
import wt.log4j.LogR;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.part.WTPart;
import wt.part.WTPartHelper;
import wt.part.WTPartUsageLink;
import wt.session.SessionContext;
import wt.session.SessionHelper;
import wt.vc.wip.CheckoutLink;
import wt.vc.wip.WorkInProgressHelper;
import wt.vc.wip.Workable;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class DxPartUtil implements RemoteAccess, Serializable {
private static Logger logger = LogR.getLogger(DxPartUtil.class.getName());
private static final long serialVersionUID = 1L;
/**
*
* @param id
* @param checkOutNote
* @return
* @throws Exception
*/
public static DxPartVO checkout(Long id, String checkOutNote) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxPartVO) RemoteMethodServer.getDefault().invoke("checkout", DxPartUtil.class.getName(), null,
new Class[] { Long.class, String.class},
new Object[] { id, checkOutNote});
}
WTPart partById = getPartById(id);
WTPart checkout = (WTPart) DxCommonUtils.checkout(partById, checkOutNote);
return new DxPartVO(checkout);
}
/**
*
* @param id
* @param checkOutNote
* @return
* @throws Exception
*/
public static DxPartVO checkin(Long id, String checkOutNote) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxPartVO) RemoteMethodServer.getDefault().invoke("checkout", DxPartUtil.class.getName(), null,
new Class[] { Long.class, String.class},
new Object[] { id, checkOutNote});
}
WTPart partById = getPartById(id);
WTPart checkout = (WTPart) DxCommonUtils.checkout(partById, checkOutNote);
return new DxPartVO(checkout);
}
/**
* part层级展开
* @param id
* @param level
* @return
* @throws Exception
*/
public static DxPartVO expendBOM(Long id, Integer level) throws Exception {
SessionContext previous = SessionContext.newContext();
DxPartVO dxPartVO = null;
try {
dxPartVO = getDxPartVO(id);
if (2 == level) {
List<DxUsageLinkVO> childList = new ArrayList<DxUsageLinkVO>();
WTPart wtPart = dxPartVO.getWtPart();
QueryResult partMasters = WTPartHelper.service.getUsesWTPartMasters(wtPart);
while (partMasters.hasMoreElements()) {
WTPartUsageLink link = (WTPartUsageLink) partMasters.nextElement();
DxUsageLinkVO dxUsageLinkVO = new DxUsageLinkVO(link, level);
childList.add(dxUsageLinkVO);
}
dxPartVO.setSourceUsageLinks(childList);
}
}finally {
SessionContext.setContext(previous);
}
return dxPartVO;
}
/**
* 根据id 查询DxPart
* @param id
* @return
* @throws Exception
*/
public static DxPartVO getDxPartVO(long id) throws Exception {
String oid = "OR:wt.part.WTPart:" + id;
WTPart part = RfUtil.getPart(oid);
DxPartVO dxPartVO = new DxPartVO(part);
/*if (ObjectsUtil.nonNull(part)) {
WTPart copyOfPart = getWorkingCopyOfPart(part);
dxPartVO = new DxPartVO(copyOfPart);
}*/
return dxPartVO;
}
/**
* 根据id 查询DxPart
* @param id
* @return
* @throws Exception
*/
public static WTPart getPartById(long id) throws Exception {
String oid = "OR:wt.part.WTPart:" + id;
WTPart part = RfUtil.getPart(oid);
return part;
}
/**
* 获取工作副本
*
* @param part
* 部件
* @return 结果
* @throws Exception
* 异常
*/
public static WTPart getWorkingCopyOfPart(WTPart part)
throws Exception {
WTPart workingPart = null;
if (!WorkInProgressHelper.isCheckedOut(part)) {
wt.folder.Folder folder = WorkInProgressHelper.service.getCheckoutFolder();
CheckoutLink checkoutlink = WorkInProgressHelper.service.checkout(part, folder, "");
workingPart = (WTPart)checkoutlink.getWorkingCopy();
}
else {
if (!WorkInProgressHelper.isWorkingCopy(part)) {
workingPart = (WTPart)WorkInProgressHelper.service.workingCopyOf(part);
}
else {
workingPart = part;
}
}
return workingPart;
}
}
This diff is collapsed.
......@@ -2,19 +2,19 @@ package com.yonde.common;
import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
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 com.fasterxml.jackson.dataformat.xml.XmlMapper;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.core.annotation.AnnotationUtils;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
......@@ -26,12 +26,12 @@ public class JsonUtils {
/** @deprecated */
@Deprecated
private static ObjectMapper objectMapper = null;
private static XmlMapper xmlMapper = null;
//private static XmlMapper xmlMapper = null;
public JsonUtils() {
}
static {
xmlMapper = initXmlMapper();
//xmlMapper = initXmlMapper();
}
......@@ -47,7 +47,7 @@ public class JsonUtils {
return objectMapper;
}
private static XmlMapper initXmlMapper() {
/*private static XmlMapper initXmlMapper() {
XmlMapper newXmlMapper = new XmlMapper();
//newXmlMapper.findAndRegisterModules();
......@@ -60,33 +60,29 @@ public class JsonUtils {
return newXmlMapper;
}
/**
*//**
* 对象转为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.isEmpty(xmlString)) {
return null;
......@@ -109,7 +105,7 @@ public class JsonUtils {
log.error("parse xml input error", e);
return null;
}
}
}*/
public static String toJsonStr(Object value) {
return toJsonStr(value, getObjectMapper());
}
......
......@@ -11,6 +11,8 @@ import wt.fc.Persistable;
import wt.fc.PersistenceHelper;
import wt.fc.PersistenceServerHelper;
import wt.fc.QueryResult;
import wt.part.WTPart;
import wt.session.SessionServerHelper;
import wt.util.WTException;
import java.util.ArrayList;
......@@ -307,4 +309,69 @@ public class LinkObjUtil {
logger.debug("the link has alseardy exist,do not need to create it again");
return false;
}
/**
* 获取部件下的所有层子件。
*
* @param part
* @param partList
* @param isA
* @throws WTException
*//*
public static void getAllUsesPartList(WTPart part, ArrayList<WTPart> partList, boolean needVersionA, String containerName) throws WTException {
if (part == null)
return;
boolean accessEnforceds = SessionServerHelper.manager.setAccessEnforced(false);
try{
WTPart wtpart = null;
String viewName = part.getViewName();
// partList.add(part);
for (QueryResult queryresult = WTPartHelper.service.getUsesWTPartMasters(part); queryresult.hasMoreElements();) {
WTPartUsageLink link = (WTPartUsageLink) queryresult.nextElement();
WTPartMaster wtpartmaster = (WTPartMaster) link.getUses();
QueryResult queryresult1 = VersionControlHelper.service.allVersionsOf(wtpartmaster);
while (queryresult1.hasMoreElements()) {
wtpart = (WTPart) queryresult1.nextElement();
// 判断如果为工作副本的话就过滤
if (WorkInProgressHelper.isWorkingCopy(wtpart)) {
continue;
}
// 获取最新版本part
if (!wtpart.isLatestIteration()) {
continue;
}
if (!wtpart.getViewName().equals(viewName)){
continue;
}
if(needVersionA) {
//判断是否借用件
if(!wtpart.getContainerName().equals(containerName)) {
partList.add(wtpart);
Debug.P("找到其子部件(借用件最新)>>>>>" + wtpart.getIdentity());
getAllUsesPartList(wtpart, partList, needVersionA, containerName);
break;
} else {
//取A版本
if("A".equals(wtpart.getVersionIdentifier().getValue())) {
partList.add(wtpart);
Debug.P("找到其子部件(A版)>>>>>" + wtpart.getIdentity());
getAllUsesPartList(wtpart, partList, needVersionA, containerName);
break;
}
}
}else{
partList.add(wtpart);
Debug.P("找到其子部件(最新)>>>>>" + wtpart.getIdentity());
getAllUsesPartList(wtpart, partList, needVersionA, containerName);
break;
}
}
}
}catch(WTException e){
e.printStackTrace();
}finally{
SessionServerHelper.manager.setAccessEnforced(accessEnforceds);
}
}*/
}
......@@ -6,6 +6,9 @@ import wt.fc.ReferenceFactory;
import wt.fc.WTObject;
import wt.fc.WTReference;
import wt.lifecycle.LifeCycleHelper;
import wt.part.WTPart;
import wt.session.SessionContext;
import wt.session.SessionHelper;
import wt.session.SessionServerHelper;
import wt.util.WTException;
import wt.vc.VersionControlException;
......@@ -28,6 +31,19 @@ public class RfUtil {
}
}
public static WTPart getPart(String oid){
//checkArgument(isNotBlank(oid));
SessionContext previous = SessionContext.newContext();
try {
SessionHelper.manager.setAdministrator();
return (WTPart) rf.getReference(oid).getObject();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
SessionContext.setContext(previous);
}
}
/**
* 获取对象OR id,不是VR id
*
......
......@@ -2,6 +2,7 @@ package com.yonde.context.vo;
import com.yonde.basedata.vo.IdVO;
import com.yonde.common.DateTimeUtil;
import wt.fc.PersistenceHelper;
import wt.inf.container.WTContainer;
import wt.pdmlink.PDMLinkProduct;
......@@ -19,7 +20,16 @@ public class DxContextVO extends IdVO {
PDMLinkProduct linkProduct = (PDMLinkProduct) container;
this.createTime = DateTimeUtil.timeStampToString(linkProduct.getCreateTimestamp());
this.modifyTime = DateTimeUtil.timeStampToString(linkProduct.getModifyTimestamp());
this.setId(PersistenceHelper.getObjectIdentifier(linkProduct).getId());
}
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
......@@ -80,7 +80,7 @@ public class DxDocController extends AbstractBaseController {
return ApiResult.ok(this.getService().getDocIterationsByObjId(objId), "查询成功");
}
@Override
protected DxDocService getService() {
return docService;
}
......
package com.yonde.doc.service;
import com.yonde.basedata.service.BaseSearchService;
import com.yonde.common.DocUtil;
import com.yonde.doc.vo.DxDocumentVO;
import org.springframework.stereotype.Service;
import wt.util.WTException;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.List;
@Service
public class DxDocService {
public DxDocumentVO updateDocumentStatus(DxDocumentVO var1) {
return null;
}
public interface DxDocService extends BaseSearchService {
DxDocumentVO updateDocumentStatus(DxDocumentVO var1);
//List<DxDocumentVO> findDocByContextId(Long var1, SearchQueryCondition var2);
public DxDocumentVO findByNumber(String var1) throws WTException, RemoteException, InvocationTargetException {
return new DxDocumentVO(DocUtil.getDoc(var1));
}
DxDocumentVO findByNumber(String var1) throws WTException, RemoteException, InvocationTargetException;
String getFirstVersion();
public String getFirstVersion() {
return null;
}
DxDocumentVO submitReviewing(DxDocumentVO var1);
DxDocumentVO getDocumentWithFiles(Long var1);
public DxDocumentVO submitReviewing(DxDocumentVO var1) {
return null;
}
DxDocumentVO findLastestIterationByVersionId(Long versionId);
Boolean callBackBindFile(Long var1, String var2, Long var3);
public DxDocumentVO getDocumentWithFiles(Long var1) {
return null;
}
List<DxDocumentVO> findDocHistory(Long var1);
List<DxDocumentVO> getDocIterationsByObjId(Long var1);
public DxDocumentVO findLastestIterationByVersionId(Long versionId) {
return null;
}
public Boolean callBackBindFile(Long var1, String var2, Long var3) {
return null;
}
public List<DxDocumentVO> findDocHistory(Long var1) {
return null;
}
public List<DxDocumentVO> getDocIterationsByObjId(Long var1) {
return null;
}
}
package com.yonde.doc.service.impl;
import com.yonde.basedata.data.DxPageImpl;
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.doc.service.DxDocService;
import com.yonde.doc.vo.DxDocumentVO;
import org.springframework.stereotype.Service;
import wt.util.WTException;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.List;
public class DxDocServiceImpl implements DxDocService {
@Override
@Service
public class DxDocServiceImpl {
public DxDocumentVO updateDocumentStatus(DxDocumentVO var1) {
return null;
}
@Override
public DxDocumentVO findByNumber(String var1) throws WTException, RemoteException, InvocationTargetException {
return new DxDocumentVO(DocUtil.getDoc(var1));
}
@Override
public String getFirstVersion() {
return null;
}
@Override
public DxDocumentVO submitReviewing(DxDocumentVO var1) {
return null;
}
@Override
public DxDocumentVO getDocumentWithFiles(Long var1) {
return null;
}
@Override
public DxDocumentVO findLastestIterationByVersionId(Long versionId) {
return null;
}
@Override
public Boolean callBackBindFile(Long var1, String var2, Long var3) {
return null;
}
@Override
public List<DxDocumentVO> findDocHistory(Long var1) {
return null;
}
@Override
public List<DxDocumentVO> getDocIterationsByObjId(Long var1) {
return null;
}
@Override
/*
public DxPageImpl search(SearchQueryCondition searchQueryCondition) {
return null;
}
@Override
public ApiResult saveRecursion(IdVO entity) {
return null;
}
}*/
}
......@@ -42,7 +42,7 @@ public class ConvertDoc2PdfUtil {
}
String serverPath = serverPdfFile.substring(0, serverPdfFile.lastIndexOf(File.separator) + 1);
String pdfFile = serverPdfFile.substring(serverPdfFile.lastIndexOf(File.separator) + 1);
FtpClient.downloadFile(serverPath, pdfFile, DocTransferProperties.office2pdf);
// FtpClient.downloadFile(serverPath, pdfFile, DocTransferProperties.office2pdf);
return DocTransferProperties.office2pdf + pdfFile;
}
......
package com.yonde.doc.util;
import com.yonde.doc.entity.DocTransferProperties;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import wt.log4j.LogR;
import java.io.*;
/**
* description:
*/
......@@ -16,7 +11,7 @@ public class FtpClient {
private static final Logger log=LogR.getLogger(FtpClient.class.getName());
/**
/* *//**
* FTPClient ftp = new FTPClient();
* FTPClientConfig config = new FTPClientConfig();
* config.setXXX(YYY); // change required options
......@@ -54,7 +49,7 @@ public class FtpClient {
* }
* System.exit(error ? 1 : 0);
* }
*/
*//*
public static void initFtp(FTPClient ftp) throws IOException {
ftp.connect(DocTransferProperties.hostname, DocTransferProperties.ftpport);
ftp.login(DocTransferProperties.username, DocTransferProperties.password);
......@@ -86,14 +81,14 @@ public class FtpClient {
}
}
/**
*//**
* 下载文件 *
*
* @param pathname FTP服务器文件目录 *
* @param fileName 文件名称 *
* @param localPath 下载后的文件路径 *
* @return
*/
*//*
public static void downloadFile(String pathname, String fileName, String localPath) {
FTPClient ftp = new FTPClient();
try {
......@@ -133,14 +128,14 @@ public class FtpClient {
}
}
/**
*//**
* 上传文件
*
* @param pathname ftp服务保存地址
* @param fileName 上传到ftp的文件名
* @param originfilename 待上传文件的名称(绝对地址) *
* @return
*/
*//*
public static void uploadFile(String pathname, String fileName, String originfilename) {
FTPClient ftp = new FTPClient();
try {
......@@ -166,14 +161,14 @@ public class FtpClient {
}
/**
*//**
* 上传文件
*
* @param pathname ftp服务保存地址
* @param fileName 上传到ftp的文件名
* @param inputStream 输入文件流
* @return
*/
*//*
public static boolean uploadFile(String pathname, String fileName, InputStream inputStream) {
FTPClient ftp = new FTPClient();
try {
......@@ -226,5 +221,5 @@ public class FtpClient {
fileName = new String(fileName.getBytes("utf-8"), "ISO-8859-1");
ftp.storeFile(fileName, inputStream);
inputStream.close();
}
}*/
}
......@@ -36,9 +36,7 @@ public class DxDocumentVO extends RevisionControlledVO {
//private boolean endItem;
private boolean latest;
private boolean checkOuted;
private String lockNote;
private String lockDate;
private String locker;
private String subTypeName;
private String subTypeDisplayName;
......@@ -56,12 +54,13 @@ public class DxDocumentVO extends RevisionControlledVO {
public DxDocumentVO(WTDocument wtDoc) throws WTException, RemoteException, InvocationTargetException {
super(wtDoc);
//TODO
//Team team = TeamHelper.service.getTeam("");
//team.getOwnership().
WTOrganization organization = wtDoc.getOrganization();
this.setDxOrganization(new DxOrganizationVO(organization));
this.id = PersistenceHelper.getObjectIdentifier(wtDoc).getId();
this.setMasterVO(new DxMasterVO(wtDoc));
this.setVersion(new DxVersionVO(wtDoc));
this.setDxContext(new DxContextVO(wtDoc.getContainer()));
......@@ -74,16 +73,6 @@ public class DxDocumentVO extends RevisionControlledVO {
this.subTypeDisplayName = ClientTypedUtility.getLocalizedTypeName(wtDoc, Locale.SIMPLIFIED_CHINESE);
this.latest = wtDoc.isLatestIteration();
this.checkOuted = WorkInProgressHelper.isCheckedOut(wtDoc);
Persistable object = wtDoc.getLocker().getObject();
if (object != null) {
WTUser locker = ((WTUser) object);
this.setLockNote(wtDoc.getLockNote());
this.setLockDate(DateTimeUtil.timeStampToString(wtDoc.getLockDate()));
this.setLocker(String.format("%s(%s)", locker.getFullName(), locker.getName()));
}
this.createTime = DateTimeUtil.timeStampToString(wtDoc.getCreateTimestamp());
this.modifyTime = DateTimeUtil.timeStampToString(wtDoc.getModifyTimestamp());
this.lifecycleTemplateId = PersistenceHelper.getObjectIdentifier(wtDoc.getLifeCycleTemplate().getObject()).getId();
......@@ -189,30 +178,6 @@ public class DxDocumentVO extends RevisionControlledVO {
this.checkOuted = checkOuted;
}
public String getLockNote() {
return lockNote;
}
public void setLockNote(String lockNote) {
this.lockNote = lockNote;
}
public String getLockDate() {
return lockDate;
}
public void setLockDate(String lockDate) {
this.lockDate = lockDate;
}
public String getLocker() {
return locker;
}
public void setLocker(String locker) {
this.locker = locker;
}
public String getModifyTime() {
return modifyTime;
......@@ -247,48 +212,6 @@ public class DxDocumentVO extends RevisionControlledVO {
this.id = var1;
}
@Override
public Long getCreatorId() {
return this.creatorId;
}
@Override
public void setCreatorId(Long var1) {
this.creatorId = var1;
}
@Override
public DxUserVO getCreator() {
return this.creator;
}
@Override
public void setCreator(DxUserVO var1) {
this.creator = var1;
this.creatorId = var1.getUserId();
}
@Override
public Long getModifierId() {
return modifierId;
}
@Override
public void setModifierId(Long var1) {
this.modifierId = var1;
}
@Override
public DxUserVO getModifier() {
return this.modifier;
}
@Override
public void setModifier(DxUserVO var1) {
this.modifier = var1;
this.modifierId = var1.getUserId();
}
public String getSubTypeName() {
return this.subTypeName;
}
......
package com.yonde.part.controller;
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.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;
@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) {
try {
DxPageImpl<DxPartVO> configSpec = this.getService().findByConfigSpec(specSearch);
List<DxPartVO> partVOS = configSpec.getContent();
return partVOS;
} 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));
DxPartVO dxPartVO = null;
try {
dxPartVO = DxPartService.getDxPartWorkingCopy(id);
} catch (Exception e) {
e.printStackTrace();
}
return dxPartVO;
}
@GetMapping({"/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检出");
} catch (Exception e) {
e.printStackTrace();
}
return dxPartVO;
}
@GetMapping({"/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);
} catch (Exception e) {
e.printStackTrace();
}
return dxPartVO;
}
@GetMapping({"/version/{id}/checkin"})
//@ApiOperation("获取工作副本")
public DxPartVO checkin(@PathVariable Long id, @RequestParam String node) {
DxPartVO dxPartVO = null;
try {
dxPartVO = DxPartService.checkin(id, node);
} catch (Exception e) {
e.printStackTrace();
}
return dxPartVO;
}
//@ApiOperation("配置规范查询")
@PostMapping({"findBySpecPage"})
ApiResult findByConfigSpecPage(@RequestBody BaseSearchCondition sq) {
return ApiResult.ok(this.getService().findByConfigSpecPage(sq));
}
//@ApiOperation("展开BOM")
@PostMapping({"expandBOM"})
public DxPartVO expandBOM(@RequestBody BOMQueryVO bomQuery) {
try {
return DxPartService.expandBOM(bomQuery);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
//@ApiOperation("展开BOM")
@PostMapping({"findBySpecP"})
public ApiResult<DxPartVO> findBySpecP(@RequestBody BaseSearchCondition bomQuery) {
return ApiResult.ok(this.getService().findByConfigSpecPage(bomQuery));
}
@PutMapping({"/lifecycle/changeStatus"})
//@SubPermission({"modify"})
public ApiResult<DxPartVO> changeStatus(@RequestBody DxPartVO lifecycleManageBaseVO) {
String state = lifecycleManageBaseVO.getState();
Long id = lifecycleManageBaseVO.getId();
try {
return ApiResult.ok(DxPartService.setState(id, state), "修改成功");
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("501", e.getLocalizedMessage(), e);
}
}
//@ApiOperation("深度保存对象")
/* @PostMapping({"recursion"})
public ApiResult recursionObj(@RequestBody DxPartVO entity) {
return ApiResult.ok(this.getService().saveRecursion(entity));
}*/
protected DxPartService getService() {
return dxPartService;
}
}
package com.yonde.part.service;
import com.yonde.basedata.data.DxPageImpl;
import com.yonde.basedata.search.BaseSearchCondition;
import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.common.CommonUtil;
import com.yonde.common.DxCommonUtils;
import com.yonde.common.DxPartUtil;
import com.yonde.common.DxSearchUtil;
import com.yonde.part.vo.BOMQueryVO;
import com.yonde.part.vo.DxPartVO;
import com.yonde.part.vo.DxUsageLinkVO;
import org.springframework.stereotype.Service;
import wt.fc.QueryResult;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.part.WTPart;
import wt.part.WTPartHelper;
import wt.part.WTPartUsageLink;
import wt.session.SessionContext;
import wt.session.SessionHelper;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Service
public class DxPartService implements RemoteAccess, Serializable {
public DxPageImpl<DxPartVO> findByConfigSpec(SearchQueryCondition searchQueryCondition) throws Exception {
DxPageImpl<DxPartVO> byConfigSpecSelect = DxSearchUtil.findByConfigSpecSelect(searchQueryCondition);
return byConfigSpecSelect;
}
public List<DxPartVO> findByConfigSpecSelect(SearchQueryCondition searchQueryCondition) throws Exception {
DxPageImpl<DxPartVO> byConfigSpecSelect = DxSearchUtil.findByConfigSpecSelect(searchQueryCondition);
return byConfigSpecSelect.getContent();
}
public DxPageImpl<DxPartVO> findByConfigSpecPage(BaseSearchCondition specSearch) {
return null;
}
/**
* 部件BOM展示
* @param bomQueryVo
* @return
* @throws Exception
*/
public static DxPartVO expandBOM(BOMQueryVO bomQueryVo) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxPartVO) RemoteMethodServer.getDefault().invoke("expandBOM", DxPartService.class.getName(), null,
new Class[] { BOMQueryVO.class},
new Object[] { bomQueryVo });
}
Long partId = bomQueryVo.getPartId();
Integer level = bomQueryVo.getLevel();
SessionContext previous = SessionContext.newContext();
DxPartVO dxPartVO = null;
try {
SessionHelper.manager.setAdministrator();
dxPartVO = DxPartUtil.getDxPartVO(partId);
if (2 == level) {
List<DxUsageLinkVO> childList = new ArrayList<DxUsageLinkVO>();
WTPart wtPart = dxPartVO.getWtPart();
QueryResult partMasters = WTPartHelper.service.getUsesWTPartMasters(wtPart);
while (partMasters.hasMoreElements()) {
WTPartUsageLink link = (WTPartUsageLink) partMasters.nextElement();
DxUsageLinkVO dxUsageLinkVO = new DxUsageLinkVO(link, level);
childList.add(dxUsageLinkVO);
}
dxPartVO.setSourceUsageLinks(childList);
}
} finally {
SessionContext.setContext(previous);
}
return dxPartVO;
}
/**
* 检入
* @param id
* @param checkOutNote
* @return
* @throws Exception
*/
public static DxPartVO checkin(Long id, String checkOutNote) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxPartVO) RemoteMethodServer.getDefault().invoke("checkout", DxPartService.class.getName(), null,
new Class[] { Long.class, String.class},
new Object[] { id, checkOutNote});
}
WTPart partById = DxPartUtil.getPartById(id);
WTPart checkIn = (WTPart) DxCommonUtils.checkin(partById, checkOutNote);
return new DxPartVO(checkIn);
}
/**
* 撤销检出
* @param id
* @return
* @throws Exception
*/
public static DxPartVO undoCheckout(Long id) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxPartVO) RemoteMethodServer.getDefault().invoke("undoCheckout", DxPartService.class.getName(), null,
new Class[] { Long.class },
new Object[] { id });
}
WTPart partById = DxPartUtil.getPartById(id);
WTPart workable = (WTPart) DxCommonUtils.undoCheckout(partById);
return new DxPartVO(workable);
}
/**
* 获取工作副本
* @param id
* @return
* @throws Exception
*/
public static DxPartVO getDxPartWorkingCopy(Long id) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxPartVO) RemoteMethodServer.getDefault().invoke("getDxPartWorkingCopy", DxPartService.class.getName(), null,
new Class[] { Long.class},
new Object[] { id});
}
SessionContext previous = SessionContext.newContext();
DxPartVO dxPartVO = null;
try {
SessionHelper.manager.setAdministrator();
WTPart partById = DxPartUtil.getPartById(id);
if (CommonUtil.isCheckedOut(partById)) {
partById = (WTPart) CommonUtil.getWorkingCopyVersion(partById);
}
dxPartVO = new DxPartVO(partById);
} finally {
SessionContext.setContext(previous);
}
return dxPartVO;
}
/**
* 设置状态
* @param id
* @param toState
* @return
* @throws Exception
*/
public static DxPartVO setState(Long id, String toState) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxPartVO) RemoteMethodServer.getDefault().invoke("setState", DxPartService.class.getName(), null,
new Class[] { Long.class, String.class},
new Object[] { id, toState});
}
WTPart partById = DxPartUtil.getPartById(id);
partById = (WTPart) DxCommonUtils.setState(partById, toState);
return new DxPartVO(partById);
}
}
package com.yonde.part.service.impl;
import com.yonde.basedata.data.DxPageImpl;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.basedata.search.SpecSearch;
import com.yonde.basedata.vo.IdVO;
import com.yonde.common.DxSearchUtil;
import com.yonde.part.vo.BOMQueryVO;
import com.yonde.part.vo.DxPartVO;
import org.springframework.stereotype.Service;
@Service
public class DxPartServiceImpl {
public DxPageImpl search(SearchQueryCondition searchQueryCondition) {
return null;
}
public ApiResult saveRecursion(IdVO entity) {
return null;
}
public DxPageImpl<DxPartVO> findByConfigSpec(SpecSearch specSearch) {
SearchQueryCondition searchQueryCondition = specSearch.getSearchQueryCondition();
DxPageImpl<DxPartVO> byConfigSpecSelect = null;
try {
byConfigSpecSelect = DxSearchUtil.findByConfigSpecSelect(searchQueryCondition);
} catch (Exception e) {
e.printStackTrace();
}
return byConfigSpecSelect;
}
public DxPageImpl<DxPartVO> findByConfigSpecPage(SearchQueryCondition specSearch) {
return null;
}
public DxPartVO expandBOM(BOMQueryVO bomQueryVo) {
return null;
}
}
package com.yonde.part.vo;
import com.yonde.basedata.search.SearchQueryCondition;
import com.yonde.common.ObjectsUtil;
import java.io.Serializable;
import java.util.List;
public class BOMQueryVO implements Serializable {
private Integer level;
private Long partId;
private List<String> states;
private Long sandboxId = 0L;
private Long dxViewId;
private Long baseLineId;
private List<String> fileContentTypes;
private List<String> partOpenProps;
/** @deprecated */
@Deprecated
private SearchQueryCondition customQuery;
private Boolean needMaster = false;
private Boolean needMarkLeaf = true;
public Boolean getNeedMaster() {
return ObjectsUtil.isNull(this.needMaster) ? false : this.needMaster;
}
public Long getSandboxId() {
return ObjectsUtil.isNull(this.sandboxId) ? 0L : this.sandboxId;
}
public Boolean getNeedMarkLeaf() {
return ObjectsUtil.isNull(this.needMarkLeaf) ? true : this.needMarkLeaf;
}
/*public static BOMQueryVO.BOMQueryVOBuilder builder() {
return new BOMQueryVO.BOMQueryVOBuilder();
}*/
public Integer getLevel() {
return this.level;
}
public Long getPartId() {
return this.partId;
}
public List<String> getStates() {
return this.states;
}
public Long getDxViewId() {
return this.dxViewId;
}
public Long getBaseLineId() {
return this.baseLineId;
}
public List<String> getFileContentTypes() {
return this.fileContentTypes;
}
public List<String> getPartOpenProps() {
return this.partOpenProps;
}
/** @deprecated */
@Deprecated
public SearchQueryCondition getCustomQuery() {
return this.customQuery;
}
public void setLevel(Integer level) {
this.level = level;
}
public void setPartId(Long partId) {
this.partId = partId;
}
public void setStates(List<String> states) {
this.states = states;
}
public void setSandboxId(Long sandboxId) {
this.sandboxId = sandboxId;
}
public void setDxViewId(Long dxViewId) {
this.dxViewId = dxViewId;
}
public void setBaseLineId(Long baseLineId) {
this.baseLineId = baseLineId;
}
public void setFileContentTypes(List<String> fileContentTypes) {
this.fileContentTypes = fileContentTypes;
}
public void setPartOpenProps(List<String> partOpenProps) {
this.partOpenProps = partOpenProps;
}
/** @deprecated */
@Deprecated
public void setCustomQuery(SearchQueryCondition customQuery) {
this.customQuery = customQuery;
}
public void setNeedMaster(Boolean needMaster) {
this.needMaster = needMaster;
}
public void setNeedMarkLeaf(Boolean needMarkLeaf) {
this.needMarkLeaf = needMarkLeaf;
}
public String toString() {
return "BOMQueryVO(level=" + this.getLevel() + ", partId=" + this.getPartId() + ", states=" + this.getStates() + ", sandboxId=" + this.getSandboxId() + ", dxViewId=" + this.getDxViewId() + ", baseLineId=" + this.getBaseLineId() + ", fileContentTypes=" + this.getFileContentTypes() + ", partOpenProps=" + this.getPartOpenProps() + ", customQuery=" + this.getCustomQuery() + ", needMaster=" + this.getNeedMaster() + ", needMarkLeaf=" + this.getNeedMarkLeaf() + ")";
}
public BOMQueryVO() {
}
public BOMQueryVO(Integer level, Long partId, List<String> states, Long sandboxId, Long dxViewId, Long baseLineId, List<String> fileContentTypes, List<String> partOpenProps, SearchQueryCondition customQuery, Boolean needMaster, Boolean needMarkLeaf) {
this.level = level;
this.partId = partId;
this.states = states;
this.sandboxId = sandboxId;
this.dxViewId = dxViewId;
this.baseLineId = baseLineId;
this.fileContentTypes = fileContentTypes;
this.partOpenProps = partOpenProps;
this.customQuery = customQuery;
this.needMaster = needMaster;
this.needMarkLeaf = needMarkLeaf;
}
}
package com.yonde.part.vo;
import com.yonde.basedata.vo.IdVO;
import com.yonde.doc.vo.DxDocumentVO;
public class DxPartDescribeLinkVO extends IdVO {
private DxDocumentVO target;
private DxPartVO source;
private Long targetId;
private String targetIdType;
private Long sourceId;
private String sourceIdType;
// TODO
public DxDocumentVO getTarget() {
return target;
}
public void setTarget(DxDocumentVO target) {
this.target = target;
}
public DxPartVO getSource() {
return source;
}
public void setSource(DxPartVO source) {
this.source = source;
}
public Long getTargetId() {
return targetId;
}
public void setTargetId(Long targetId) {
this.targetId = targetId;
}
public String getTargetIdType() {
return targetIdType;
}
public void setTargetIdType(String targetIdType) {
this.targetIdType = targetIdType;
}
public Long getSourceId() {
return sourceId;
}
public void setSourceId(Long sourceId) {
this.sourceId = sourceId;
}
public String getSourceIdType() {
return sourceIdType;
}
public void setSourceIdType(String sourceIdType) {
this.sourceIdType = sourceIdType;
}
}
package com.yonde.part.vo;
import com.yonde.basedata.vo.IdVO;
import com.yonde.doc.vo.DxDocumentVO;
public class DxPartReferenceLinkVO extends IdVO {
private DxDocumentVO target;
private DxPartVO source;
private Long targetId;
private String targetIdType;
private Long sourceId;
private String sourceIdType;
// TODO
public DxDocumentVO getTarget() {
return target;
}
public void setTarget(DxDocumentVO target) {
this.target = target;
}
public DxPartVO getSource() {
return source;
}
public void setSource(DxPartVO source) {
this.source = source;
}
public Long getTargetId() {
return targetId;
}
public void setTargetId(Long targetId) {
this.targetId = targetId;
}
public String getTargetIdType() {
return targetIdType;
}
public void setTargetIdType(String targetIdType) {
this.targetIdType = targetIdType;
}
public Long getSourceId() {
return sourceId;
}
public void setSourceId(Long sourceId) {
this.sourceId = sourceId;
}
public String getSourceIdType() {
return sourceIdType;
}
public void setSourceIdType(String sourceIdType) {
this.sourceIdType = sourceIdType;
}
}
This diff is collapsed.
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;
import wt.part.WTPartUsageLink;
import wt.util.WTException;
import java.lang.reflect.InvocationTargetException;
import java.rmi.RemoteException;
import java.util.List;
public class DxUsageLinkVO extends IdVO {
//private List<DxPartSubstituteLinkVO> partSubstituteLinks;
private DxPartVO target;
private DxPartVO source;
//private List<DxProcessRouteVO> dxProcessRoutes;
private Double amount;
private String unit;
private Long targetId;
private String targetIdType;
private Long sourceId;
private String sourceIdType;
//TODO
private String dxClassname = "com.yonde.dcs.xbom.common.entity.vo.DxUsageLinkVO";
public DxUsageLinkVO(WTPartUsageLink usageLink, int level) throws WTException, RemoteException, InvocationTargetException {
super(usageLink);
WTPart parent = (WTPart)usageLink.getUsedBy();
Quantity qt = usageLink.getQuantity();
this.setAmount(qt.getAmount());
this.setUnit(qt.getUnit().toString());
WTPartMaster uses = (WTPartMaster) usageLink.getUses();
WTPart child = PartUtil.getLatestPartByNoViewWithState(uses.getNumber(), parent.getViewName(), null, false);
this.setTargetId(PersistenceHelper.getObjectIdentifier(child).getId());
this.setSourceId(PersistenceHelper.getObjectIdentifier(parent).getId());
if (level > 0) {
this.setTarget(new DxPartVO(child));
}
if (level < 0) {
this.setSource(new DxPartVO(parent));
}
this.dynamicAttrs = IBAHelper.getAllIBAValues(usageLink);
}
public DxPartVO getTarget() {
return target;
}
public void setTarget(DxPartVO target) {
this.target = target;
}
public DxPartVO getSource() {
return source;
}
public void setSource(DxPartVO source) {
this.source = source;
}
public Double getAmount() {
return amount;
}
public void setAmount(Double amount) {
this.amount = amount;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
public Long getTargetId() {
return targetId;
}
public void setTargetId(Long targetId) {
this.targetId = targetId;
}
public String getTargetIdType() {
return targetIdType;
}
public void setTargetIdType(String targetIdType) {
this.targetIdType = targetIdType;
}
public Long getSourceId() {
return sourceId;
}
public void setSourceId(Long sourceId) {
this.sourceId = sourceId;
}
public String getSourceIdType() {
return sourceIdType;
}
public void setSourceIdType(String sourceIdType) {
this.sourceIdType = sourceIdType;
}
@Override
public String getDxClassname() {
return dxClassname;
}
@Override
public void setDxClassname(String dxClassname) {
this.dxClassname = dxClassname;
}
}
package com.yonde.part.vo;
import com.yonde.basedata.vo.IdVO;
import wt.fc.PersistenceHelper;
import wt.part.WTPart;
import wt.util.WTException;
import wt.vc.views.View;
import wt.vc.views.ViewHelper;
public class DxViewVO extends IdVO {
private String name;
private Integer level;
private Boolean buildInView;
private Boolean innerView = false;
public DxViewVO() {
}
public DxViewVO(WTPart wtPart) throws WTException {
super(wtPart);
View view = ViewHelper.getView(wtPart);
this.name = view.getName();
this.level = ViewHelper.service.getViewLevel(view);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getLevel() {
return level;
}
public void setLevel(Integer level) {
this.level = level;
}
public Boolean getBuildInView() {
return buildInView;
}
public void setBuildInView(Boolean buildInView) {
this.buildInView = buildInView;
}
public Boolean getInnerView() {
return innerView;
}
public void setInnerView(Boolean innerView) {
this.innerView = innerView;
}
}
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