Commit 766187f2 authored by shyWang's avatar shyWang

PDM前端改造

更改相关
parent a13aef6d
##需要修改
LDAPUrl=ldap://pdm91.yonde.com:389
LDAPManager=cn=Manager
LDAPPwd=ldapadmin
LDAPSearchBase=cn=AdministrativeLdap,cn=Windchill_9.1,o=ptc
package com.yonde.basedata.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yonde.basedata.vo.lc.LifecycleTemplateVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@RestController
@RequestMapping({"/LifecycleTemplate"})
/*@Api(
tags = {"生命周期模板相关"}
)*/
public class LifecycleTemplateController {
//@ApiOperation("根据模板id查询模板信息,包含模板节点、路径、及节点下的事件 路径下的事件")
@GetMapping({"/findDetail/{id}"})
public LifecycleTemplateVO findDetail(@PathVariable Long id) {
return null;
}
}
package com.yonde.basedata.controller;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.yonde.common.LdapUtil;
import org.springframework.web.bind.annotation.*;
import wt.util.WTException;
import java.io.IOException;
@RestController
@RequestMapping({"/login"})
public class LoginController {
/**
* 用户认证
* @param userName
* @return
* @throws JsonProcessingException
*/
@RequestMapping(value = "/userPwd", method = RequestMethod.GET)
@ResponseBody
public String getUserPwd(@RequestParam(name = "userName") String userName) {
String result = null;
try {
result = LdapUtil.getUserPwd(userName);
} catch (WTException e) {
e.printStackTrace();
}
return result;
}
}
......@@ -85,6 +85,8 @@ public class SearchOperatorEnumUtil {
//TODO add
typeStrPrefixMap.put("com.yonde.dcs.xbom.common.entity.vo.DxPartVO", "wt.part.WTPart:");
typeStrPrefixMap.put("DxPart", "wt.part.WTPart:");
typeStrPrefixMap.put("DxDocument", "wt.doc.WTDocument:");
typeStrPrefixMap.put("com.yonde.dcs.document.common.entity.vo.DxDocumentVO", "wt.doc.WTDocument:");
}
......
package com.yonde.change.controller;
import com.alibaba.fastjson.JSON;
import com.yonde.basedata.entity.api.ApiResult;
import com.yonde.change.vo.ecn.DxChangeNoticeVo;
import com.yonde.change.vo.ecr.DxChangeRequestVo;
import com.yonde.change.vo.pr.DxProblemReportVo;
import com.yonde.common.ObjectsUtil;
import com.yonde.part.service.DxPartService;
import com.yonde.part.vo.DxPartVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
@RestController
@RequestMapping({"/changeOrder"})
public class DxChangeOrderController {
//@ApiOperation("深度保存对象")
@PostMapping({"createPR"})
public ApiResult recursionPR(@RequestBody Map entity, HttpServletRequest request) {
DxPartVO part = null;
try {
String jsonString = JSON.toJSONString(entity);
DxProblemReportVo entityVO = JSON.parseObject(jsonString, DxProblemReportVo.class);
String portUserName = request.getHeader("portUserName");
if (ObjectsUtil.nonNull(entityVO.getOperator()) && entityVO.getOperator().equals("NO_CHANGE")) {
//更新link
//part = DxPartService.updateDxPartUsageLink(entityVO);
} else {
//part = DxPartService.createDxPart(entityVO, portUserName);
}
return ApiResult.ok(part);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("501", e.getLocalizedMessage(), e);
}
}
//@ApiOperation("深度保存对象")
@PostMapping({"createECR"})
public ApiResult recursionECR(@RequestBody Map entity, HttpServletRequest request) {
DxPartVO part = null;
try {
String jsonString = JSON.toJSONString(entity);
DxChangeRequestVo entityVO = JSON.parseObject(jsonString, DxChangeRequestVo.class);
String portUserName = request.getHeader("portUserName");
if (ObjectsUtil.nonNull(entityVO.getOperator()) && entityVO.getOperator().equals("NO_CHANGE")) {
//更新link
//part = DxPartService.updateDxPartUsageLink(entityVO);
} else {
//part = DxPartService.createDxPart(entityVO, portUserName);
}
return ApiResult.ok(part);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("501", e.getLocalizedMessage(), e);
}
}
//@ApiOperation("深度保存对象")
@PostMapping({"createECN"})
public ApiResult recursionECN(@RequestBody Map entity, HttpServletRequest request) {
DxPartVO part = null;
try {
String jsonString = JSON.toJSONString(entity);
DxChangeNoticeVo entityVO = JSON.parseObject(jsonString, DxChangeNoticeVo.class);
String portUserName = request.getHeader("portUserName");
if (ObjectsUtil.nonNull(entityVO.getOperator()) && entityVO.getOperator().equals("NO_CHANGE")) {
//更新link
//part = DxPartService.updateDxPartUsageLink(entityVO);
} else {
//part = DxPartService.createDxPart(entityVO, portUserName);
}
return ApiResult.ok(part);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("501", e.getLocalizedMessage(), e);
}
}
}
package com.yonde.change.service;
import com.yonde.basedata.search.SearchOperatorEnumUtil;
import com.yonde.change.vo.DxChangeAffectedDataVo;
import com.yonde.change.vo.ecn.DxChangeNoticeVo;
import com.yonde.change.vo.ecr.DxChangeRequestVo;
import com.yonde.change.vo.pr.DxProblemReportVo;
import com.yonde.common.ChangeOrderUtil;
import com.yonde.common.CommonUtil;
import com.yonde.common.RfUtil;
import com.yonde.doc.service.DxDocService;
import wt.change2.Changeable2;
import wt.change2.WTChangeOrder2;
import wt.method.RemoteMethodServer;
import java.util.ArrayList;
import java.util.List;
public class DXChangeOrderService {
public void createPR(DxProblemReportVo problemReportVo) {
}
public void createECR(DxChangeRequestVo changeRequestVo) {
}
public static DxChangeNoticeVo createECN(DxChangeNoticeVo changeNoticeVo, String userName) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (DxChangeNoticeVo) RemoteMethodServer.getDefault().invoke("checkin", DxDocService.class.getName(), null,
new Class[] { DxChangeNoticeVo.class, String.class},
new Object[] { changeNoticeVo, userName});
}
CommonUtil.initSessionContext(userName);
WTChangeOrder2 wtChangeOrder2 = ChangeOrderUtil.createWTChangeOrder2(changeNoticeVo.getName(), null, null, "",changeNoticeVo.getDynamicAttrs());
List<Changeable2> affectedDataList = new ArrayList<Changeable2>();
List<DxChangeAffectedDataVo> affectedDatas = changeNoticeVo.getChangeAffectedDatas();
for (DxChangeAffectedDataVo affectedData : affectedDatas) {
String pboClass = affectedData.getPboType();
String prefix = SearchOperatorEnumUtil.typeStrPrefixMap.get(pboClass);
Long pboId = affectedData.getPboId();
Changeable2 wtObjectByOid = (Changeable2) RfUtil.getWTObjectByOid("OR:" + prefix + pboId);
affectedDataList.add(wtObjectByOid);
}
wtChangeOrder2 = ChangeOrderUtil.addAffectedDataToChangeNotice(wtChangeOrder2, affectedDataList, null);
List<Changeable2> afterDataList = new ArrayList<Changeable2>();
ChangeOrderUtil.addChangeableAfterToChangeNotice(wtChangeOrder2, afterDataList, null);
//TODO
ChangeOrderUtil.addChangeNoticeToChangeRequest(wtChangeOrder2,null);
changeNoticeVo = new DxChangeNoticeVo(wtChangeOrder2);
return changeNoticeVo;
}
}
package com.yonde.change.vo;
import com.yonde.basedata.vo.RevisionControlledVO;
import com.yonde.common.entity.DxIterationVOHolder;
/**
* 受影响对象LINK
*/
public class DxChangeAffectedDataVo {
private String pboType;
private Long pboId;
private Boolean isDraft;
private String draftName;
private String draftNumber;
private String draftType;
private String draftTypeDisplayName;
private String draftVersion;
private Long draftDxViewId;
private String draftDxViewName;
private String displayName;
private String displayNumber;
private String displayType;
private String displayTypeName;
private String displayVersion;
private String displayState;
private String displayId;
private Long displayDxViewId;
public String displayDxViewName;
private RevisionControlledVO target;
private Long sourceId;
private String sourceIdType;
private Long targetId;
private String targetIdType;
public String getPboType() {
return pboType;
}
public void setPboType(String pboType) {
this.pboType = pboType;
}
public Long getPboId() {
return pboId;
}
public void setPboId(Long pboId) {
this.pboId = pboId;
}
public Boolean getDraft() {
return isDraft;
}
public void setDraft(Boolean draft) {
isDraft = draft;
}
public String getDraftName() {
return draftName;
}
public void setDraftName(String draftName) {
this.draftName = draftName;
}
public String getDraftNumber() {
return draftNumber;
}
public void setDraftNumber(String draftNumber) {
this.draftNumber = draftNumber;
}
public String getDraftType() {
return draftType;
}
public void setDraftType(String draftType) {
this.draftType = draftType;
}
public String getDraftTypeDisplayName() {
return draftTypeDisplayName;
}
public void setDraftTypeDisplayName(String draftTypeDisplayName) {
this.draftTypeDisplayName = draftTypeDisplayName;
}
public String getDraftVersion() {
return draftVersion;
}
public void setDraftVersion(String draftVersion) {
this.draftVersion = draftVersion;
}
public Long getDraftDxViewId() {
return draftDxViewId;
}
public void setDraftDxViewId(Long draftDxViewId) {
this.draftDxViewId = draftDxViewId;
}
public String getDraftDxViewName() {
return draftDxViewName;
}
public void setDraftDxViewName(String draftDxViewName) {
this.draftDxViewName = draftDxViewName;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getDisplayNumber() {
return displayNumber;
}
public void setDisplayNumber(String displayNumber) {
this.displayNumber = displayNumber;
}
public String getDisplayType() {
return displayType;
}
public void setDisplayType(String displayType) {
this.displayType = displayType;
}
public String getDisplayTypeName() {
return displayTypeName;
}
public void setDisplayTypeName(String displayTypeName) {
this.displayTypeName = displayTypeName;
}
public String getDisplayVersion() {
return displayVersion;
}
public void setDisplayVersion(String displayVersion) {
this.displayVersion = displayVersion;
}
public String getDisplayState() {
return displayState;
}
public void setDisplayState(String displayState) {
this.displayState = displayState;
}
public String getDisplayId() {
return displayId;
}
public void setDisplayId(String displayId) {
this.displayId = displayId;
}
public Long getDisplayDxViewId() {
return displayDxViewId;
}
public void setDisplayDxViewId(Long displayDxViewId) {
this.displayDxViewId = displayDxViewId;
}
public String getDisplayDxViewName() {
return displayDxViewName;
}
public void setDisplayDxViewName(String displayDxViewName) {
this.displayDxViewName = displayDxViewName;
}
public RevisionControlledVO getTarget() {
return target;
}
public void setTarget(RevisionControlledVO target) {
this.target = target;
}
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;
}
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;
}
}
package com.yonde.change.vo;
import com.yonde.basedata.vo.RevisionControlledVO;
/**
* 改后对象LINK
*/
public class DxChangeAfterDataVo {
private RevisionControlledVO target;
private Long sourceId;
private String sourceIdType;
private Long targetId;
private String targetIdType;
public RevisionControlledVO getTarget() {
return target;
}
public void setTarget(RevisionControlledVO target) {
this.target = target;
}
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;
}
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;
}
}
package com.yonde.change.vo;
import com.yonde.basedata.vo.RevisionControlledVO;
import java.io.Serializable;
/**
* 受影响对象
*/
public class DxReportedAgainstVo implements Serializable {
private RevisionControlledVO target;
private Long sourceId;
private String sourceIdType;
private Long targetId;
private String targetIdType;
public RevisionControlledVO getTarget() {
return target;
}
public void setTarget(RevisionControlledVO target) {
this.target = target;
}
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;
}
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;
}
}
package com.yonde.change.vo.ecn;
import com.yonde.change.vo.ecr.DxChangeRequestVo;
public class DxAddressedByVo {
private DxChangeRequestVo source;
private DxChangeNoticeVo target;
private Long sourceId;
private String sourceIdType;
private Long targetId;
private String targetIdType;
public DxChangeRequestVo getSource() {
return source;
}
public void setSource(DxChangeRequestVo source) {
this.source = source;
}
public DxChangeNoticeVo getTarget() {
return target;
}
public void setTarget(DxChangeNoticeVo target) {
this.target = target;
}
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;
}
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;
}
}
package com.yonde.change.vo.ecn;
import com.yonde.basedata.vo.DxOrganizationVO;
import com.yonde.basedata.vo.IdVO;
import com.yonde.basedata.vo.ObjFileLinkVO;
import com.yonde.change.vo.DxChangeAffectedDataVo;
import com.yonde.change.vo.DxChangeAfterDataVo;
import com.yonde.common.ChangeOrderUtil;
import com.yonde.common.DxCommonUtils;
import com.yonde.common.IBAHelper;
import com.yonde.context.vo.DxContextVO;
import wt.change2.WTChangeOrder2;
import wt.org.WTOrganization;
import wt.util.WTException;
import java.io.Serializable;
import java.util.List;
public class DxChangeNoticeVo extends IdVO implements Serializable {
private String number;
private String name;
private String state;
private DxContextVO dxContext;
private Long dxContextId;
private DxOrganizationVO dxOrganization;
private Long dxOrganizationId;
private String dxOrganizationIdType;
private List<DxAddressedByVo> addressedBys;
private List<DxChangeAfterDataVo> sourceDxCMReferenceLink;
private List<DxChangeAffectedDataVo> changeAffectedDatas;
private List<ObjFileLinkVO> objFileLinks;
public DxChangeNoticeVo() {
}
public DxChangeNoticeVo(WTChangeOrder2 wtChangeOrder2) throws Exception {
super(wtChangeOrder2);
this.name = wtChangeOrder2.getName();
this.number = wtChangeOrder2.getNumber();
this.state = wtChangeOrder2.getState().getState().toString();
WTOrganization organization = wtChangeOrder2.getOrganization();
this.setDxOrganization(new DxOrganizationVO(organization));
this.setDxContext(new DxContextVO(wtChangeOrder2.getContainer()));
this.dynamicAttrs = IBAHelper.getAllIBAValues(wtChangeOrder2);
this.setObjFileLinks(DxCommonUtils.buildObjFileLinks(wtChangeOrder2));
//ChangeOrderUtil.get
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public DxContextVO getDxContext() {
return dxContext;
}
public void setDxContext(DxContextVO dxContext) {
this.dxContext = dxContext;
}
public Long getDxContextId() {
return dxContextId;
}
public void setDxContextId(Long dxContextId) {
this.dxContextId = dxContextId;
}
public DxOrganizationVO getDxOrganization() {
return dxOrganization;
}
public void setDxOrganization(DxOrganizationVO dxOrganization) {
this.dxOrganization = dxOrganization;
}
public Long getDxOrganizationId() {
return dxOrganizationId;
}
public void setDxOrganizationId(Long dxOrganizationId) {
this.dxOrganizationId = dxOrganizationId;
}
public String getDxOrganizationIdType() {
return dxOrganizationIdType;
}
public void setDxOrganizationIdType(String dxOrganizationIdType) {
this.dxOrganizationIdType = dxOrganizationIdType;
}
public List<ObjFileLinkVO> getObjFileLinks() {
return objFileLinks;
}
public void setObjFileLinks(List<ObjFileLinkVO> objFileLinks) {
this.objFileLinks = objFileLinks;
}
public List<DxAddressedByVo> getAddressedBys() {
return addressedBys;
}
public void setAddressedBys(List<DxAddressedByVo> addressedBys) {
this.addressedBys = addressedBys;
}
public List<DxChangeAfterDataVo> getSourceDxCMReferenceLink() {
return sourceDxCMReferenceLink;
}
public void setSourceDxCMReferenceLink(List<DxChangeAfterDataVo> sourceDxCMReferenceLink) {
this.sourceDxCMReferenceLink = sourceDxCMReferenceLink;
}
public List<DxChangeAffectedDataVo> getChangeAffectedDatas() {
return changeAffectedDatas;
}
public void setChangeAffectedDatas(List<DxChangeAffectedDataVo> changeAffectedDatas) {
this.changeAffectedDatas = changeAffectedDatas;
}
}
package com.yonde.change.vo.ecr;
import com.yonde.basedata.vo.DxOrganizationVO;
import com.yonde.basedata.vo.IdVO;
import com.yonde.basedata.vo.ObjFileLinkVO;
import com.yonde.change.vo.DxChangeAffectedDataVo;
import com.yonde.context.vo.DxContextVO;
import java.util.List;
/**
* ECR
*/
public class DxChangeRequestVo extends IdVO {
private String number;
private String name;
private String state;
private DxContextVO dxContext;
private Long dxContextId;
private DxOrganizationVO dxOrganization;
private Long dxOrganizationId;
private String dxOrganizationIdType;
private List<ObjFileLinkVO> objFileLinks;
//受影响对象
private List<DxChangeAffectedDataVo> changeAffectedDatas;
}
package com.yonde.change.vo.pr;
import com.yonde.basedata.vo.IdVO;
import com.yonde.change.vo.DxReportedAgainstVo;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* PR
*/
public class DxProblemReportVo extends IdVO implements Serializable {
private String problemSource;
private String problemCategory;
private String comments;
private Date offerDate;
private String offere;
private String problemIdentity;
private Short technologyPriority;
private List<DxReportedAgainstVo> reportedAgainsts;
public String getProblemSource() {
return problemSource;
}
public void setProblemSource(String problemSource) {
this.problemSource = problemSource;
}
public String getProblemCategory() {
return problemCategory;
}
public void setProblemCategory(String problemCategory) {
this.problemCategory = problemCategory;
}
public String getComments() {
return comments;
}
public void setComments(String comments) {
this.comments = comments;
}
public Date getOfferDate() {
return offerDate;
}
public void setOfferDate(Date offerDate) {
this.offerDate = offerDate;
}
public String getOffere() {
return offere;
}
public void setOffere(String offere) {
this.offere = offere;
}
public String getProblemIdentity() {
return problemIdentity;
}
public void setProblemIdentity(String problemIdentity) {
this.problemIdentity = problemIdentity;
}
public Short getTechnologyPriority() {
return technologyPriority;
}
public void setTechnologyPriority(Short technologyPriority) {
this.technologyPriority = technologyPriority;
}
public List<DxReportedAgainstVo> getReportedAgainsts() {
return reportedAgainsts;
}
public void setReportedAgainsts(List<DxReportedAgainstVo> reportedAgainsts) {
this.reportedAgainsts = reportedAgainsts;
}
}
This diff is collapsed.
......@@ -74,11 +74,6 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
}
public static PagingQueryResult findByConfigSpecSelect (SearchQueryCondition searchQueryCondition) throws Exception {
/* if (!RemoteMethodServer.ServerFlag) {
return (List<IdVO>) RemoteMethodServer.getDefault().invoke("findByConfigSpecSelect", DxSearchUtil.class.getName(), null,
new Class[] { SearchQueryCondition.class},
new Object[] { searchQueryCondition});
}*/
CommonUtil.initSessionContext(null);
boolean enforce = SessionServerHelper.manager.setAccessEnforced(false);
List partList;
......@@ -122,49 +117,31 @@ public class DxSearchUtil implements RemoteAccess, Serializable {
bpqs.setOffset((searchQueryCondition.getPageFrom()-1)*searchQueryCondition.getPageSize());
bpqs.setRange(searchQueryCondition.getPageSize());
bpqs.setBackgroundThreadEnabled(false);
bpqs.setLimitModeEnabled(true);
//bpqs.setAdvancedQueryEnabled();
PagingQueryResult qr = (PagingQueryResult) PersistenceHelper.manager.find(bpqs);
return qr;
//LatestConfigSpec lcs = new LatestConfigSpec();
//qr = lcs.process(qr);
} finally {
SessionServerHelper.manager.setAccessEnforced(enforce);
}
//logger.error("IdVOList=====" + partList.size());
//return partList;
}
/**
* 生成反馈结果
* @param o
* @param partList
* @param indices
* @throws Exception
*/
public static void buildQueryResult(WTObject o, List partList, List<String> indices) throws Exception {
if (o instanceof WTPart) {
WTPart wtPart = (WTPart) o;
logger.error("WTPart===111" + wtPart.getNumber() + ":" +wtPart.isLatestIteration());
if (CollectionUtils.isNotEmpty(indices)) {
if (WorkInProgressHelper.isWorkingCopy(wtPart) || !wtPart.isLatestIteration()) {
return;
}
} else {
if (WorkInProgressHelper.isWorkingCopy(wtPart)) {
return;
}
}
DxPartVO dxPartVO = new DxPartVO(wtPart);
logger.error("DxPartVO===111" + dxPartVO.getName());
partList.add(dxPartVO);
return;
}
if (o instanceof WTDocument) {
WTDocument document = (WTDocument) o;
if (CollectionUtils.isNotEmpty(indices)) {
if (WorkInProgressHelper.isWorkingCopy(document) || !document.isLatestIteration()) {
return;
}
} else {
if (WorkInProgressHelper.isWorkingCopy(document)) {
return;
}
}
DxDocumentVO dxPartVO = new DxDocumentVO(document);
partList.add(dxPartVO);
} else {
......
......@@ -19,6 +19,7 @@ import com.ptc.core.meta.common.DefinitionIdentifier;
import com.ptc.core.meta.common.TypeInstanceIdentifier;
import com.ptc.core.meta.server.TypeIdentifierUtility;
import com.ptc.core.meta.type.common.TypeInstance;
import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import wt.fc.*;
import wt.iba.definition.DefinitionLoader;
......@@ -83,6 +84,9 @@ public class IBAHelper implements Serializable, RemoteAccess {
for (int j = 0; j < avv.length; j++) {
AttributeDefDefaultView definition = avv[j].getDefinition();
String thisIBAName = definition.getLogicalIdentifier();
if (StringUtils.isEmpty(thisIBAName)) {
continue;
}
String thisIBAClass = definition.getAttributeDefinitionClassName();
if (thisIBAClass.equals("wt.iba.definition.FloatDefinition")) {
float value = (float) ((FloatValueDefaultView) avv[j]).getValue();
......@@ -92,7 +96,7 @@ public class IBAHelper implements Serializable, RemoteAccess {
hashtable.put(thisIBAName, String.valueOf(value));
} else if (thisIBAClass.equals("wt.iba.definition.StringDefinition")) {
String value = ((StringValueDefaultView) avv[j]).getValue();
hashtable.put(thisIBAName, value);
hashtable.put(thisIBAName, value==null?"":value);
}
}
}
......
package com.yonde.common;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import wt.util.WTException;
import javax.naming.Context;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.SearchControls;
import javax.naming.directory.SearchResult;
import javax.naming.ldap.InitialLdapContext;
import javax.naming.ldap.LdapContext;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public abstract class LdapUtil {
private static final Log logger = LogFactory.getLog(LdapUtil.class);
private static Map<String, String> env = new HashMap<String, String>();
private static String ldapUrl = "";
private static String ldapManager = "";
private static String ldapPwd = "";
private static String ldapSearchBase = "";
static {
Properties properties = new Properties();
InputStream input = LdapUtil.class.getResourceAsStream("/config/yonde/ldap.properties");
try {
properties.load(input);
ldapUrl = properties.getProperty("LDAPUrl");
ldapManager = properties.getProperty("LDAPManager");
ldapPwd = properties.getProperty("LDAPPwd");
ldapSearchBase = properties.getProperty("LDAPSearchBase");
logger.debug("ldapUrl: " + ldapUrl);
logger.debug("ldapManager: " + ldapManager);
logger.debug("ldapPwd: " + ldapPwd);
logger.debug("ldapSearchBase: " + ldapSearchBase);
init();
} catch (IOException e) {
logger.error(e.getLocalizedMessage(), e);
} finally {
try {
if (input != null) {
input.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* initial connection
*/
public static void init() {
env.clear();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, ldapUrl);
env.put("java.naming.ldap.version", "3");
env.put(Context.SECURITY_AUTHENTICATION, "simple");
env.put(Context.SECURITY_PRINCIPAL, ldapManager);
env.put(Context.SECURITY_CREDENTIALS, ldapPwd);
env.put("com.sun.jndi.ldap.connect.pool", "true");
env.put("com.sun.jndi.ldap.connect.pool.prefsize", "50");
env.put("com.sun.jndi.ldap.connect.pool.maxsize", "100");
env.put(Context.REFERRAL, "follow");
env.put("java.naming.ldap.attributes.binary", "userCertificate");
}
public static LdapContext getContext() throws WTException {
try {
return new InitialLdapContext(toHashtable(env), null);
} catch (NamingException e) {
logger.error(e.getLocalizedMessage(), e);
throw new WTException(e, e.getLocalizedMessage());
}
}
public static void close(LdapContext context) throws NamingException {
if (context != null) {
context.close();
}
}
/**
* get user's DN from LDAP
*
* @param userName
* @param context
* @return
* @throws Exception
*/
public static String getUserDn(String userName, LdapContext context) throws WTException {
String userDn = null;
try {
SearchControls search = new SearchControls();
search.setSearchScope(SearchControls.SUBTREE_SCOPE);
String searchFilter = "uid=" + userName;
NamingEnumeration answer = context.search(ldapSearchBase, searchFilter, search);
if (answer.hasMoreElements()) {
SearchResult rs = (SearchResult) answer.next();
userDn = rs.getNameInNamespace();
}
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
throw new WTException(e, e.getLocalizedMessage());
}
return userDn;
}
public static String getUserPwd(String userName) throws WTException {
try {
SearchControls search = new SearchControls();
search.setSearchScope(SearchControls.SUBTREE_SCOPE);
String searchFilter = "uid=" + userName;
LdapContext context = getContext();
NamingEnumeration answer = context.search(ldapSearchBase, searchFilter, search);
if (answer.hasMoreElements()) {
SearchResult rs = (SearchResult) answer.next();
BasicAttribute upwd = (BasicAttribute) rs.getAttributes().get("userpassword");
if (upwd != null) {
byte[] bytes = (byte[]) upwd.get();
return new String(bytes);
}
}
return null;
} catch (NamingException e) {
e.printStackTrace();
throw new WTException(e, e.getLocalizedMessage());
}
}
/**
* check user whether in LDAP
*
* @param userName
* @return
* @throws Exception
*/
public static boolean isUserInAD(String userName, LdapContext context) throws WTException {
boolean userInAd = false;
try {
context = getContext();
SearchControls search = new SearchControls();
search.setSearchScope(SearchControls.SUBTREE_SCOPE);
String searchFilter = "cn=" + userName;
NamingEnumeration answer = context.search(ldapSearchBase, searchFilter, search);
if (answer.hasMoreElements()) {
userInAd = true;
}
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
throw new WTException(e, e.getLocalizedMessage());
}
return userInAd;
}
public static void checkUserName(String userName) throws WTException {
init();
LdapContext context = null;
try {
context = getContext();
SearchControls search = new SearchControls();
search.setSearchScope(SearchControls.SUBTREE_SCOPE);
// String searchFilter = "objectClass=mil-user";
String searchFilter = "uid=" + userName;
String[] returnAtts = {"cn", "uniqueMember"};
// search.setReturningAttributes(returnAtts);
NamingEnumeration answer = context.search(ldapSearchBase, searchFilter, search);
if (!answer.hasMoreElements()) {
throw new Exception("User " + userName + " does not exist!");
}
} catch (Exception e) {
logger.error(e.getLocalizedMessage(), e);
throw new WTException(e, e.getLocalizedMessage());
} finally {
try {
close(context);
} catch (NamingException e) {
logger.error(e.getLocalizedMessage(), e);
}
}
}
public static Hashtable toHashtable(Map<String, String> env) {
Hashtable<String, String> tab = new Hashtable<String, String>();
Iterator<Map.Entry<String, String>> iter = env.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry<String, String> el = iter.next();
tab.put(el.getKey(), el.getValue());
}
return tab;
}
public static void main(String[] args) {
}
}
package com.yonde.common;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.Vector;
public class ObjectsUtil {
public static boolean isNull(Object obj) {
......@@ -19,4 +24,12 @@ public class ObjectsUtil {
}
return joiner.substring(0, joiner.lastIndexOf(delimiter));
}
public static Vector toVector(List vote) {
Vector vector = new Vector();
if (CollectionUtils.isEmpty(vote)) {
vector.addAll(vote);
}
return vector;
}
}
......@@ -195,7 +195,6 @@ public class DxPartController extends AbstractBaseController {
String portUserName = request.getHeader("portUserName");
DxPartService.convertViewAll(id, portUserName);
} catch (Exception e) {
e.printStackTrace();
return ApiResult.error("501", e.getLocalizedMessage(), new DxBusinessException("501", e.getLocalizedMessage()));
}
return ApiResult.ok("转视图成功");
......
......@@ -18,6 +18,7 @@ import wt.log4j.LogR;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
import wt.part.*;
import wt.pom.Transaction;
import wt.session.SessionContext;
import wt.session.SessionHelper;
import wt.session.SessionServerHelper;
......@@ -552,12 +553,18 @@ public class DxPartService implements RemoteAccess, Serializable {
return;
}
//SessionContext previous = SessionContext.newContext();
boolean enforced = true;
Transaction ts = null;
try {
//SessionHelper.manager.setAdministrator();
CommonUtil.initSessionContext(userName);
enforced = SessionServerHelper.manager.setAccessEnforced(false);
WTPart partById = DxPartUtil.getPartById(id);
String viewName = partById.getViewName();
if(!viewName.equalsIgnoreCase("Planning")){
ts = new Transaction();
ts.start();
WTPart ppart = PartUtil.getLatestViewPart(partById.getNumber(),"Planning");
ArrayList<WTPart> list = new ArrayList<WTPart>();
if(ppart==null){
......@@ -578,20 +585,30 @@ public class DxPartService implements RemoteAccess, Serializable {
CommonUtil.setFolder("/Default/PBOM/PBOM零部件", tempPart.getContainerReference(), p2);
PersistenceHelper.manager.save(p2);
}
}
ts.commit();
ts = null;
}else{
throw new Exception("无需转视图");
throw new Exception("P视图已存在,无需转视图!");
}
} finally {
//SessionContext.setContext(previous);
} catch (Exception e){
ts.rollback();
ts = null;
throw new WTException(String.format("视图转换异常:%s", e.getLocalizedMessage()));
}finally {
if (ObjectsUtil.nonNull(ts)) {
ts.rollback();
}
SessionServerHelper.manager.setAccessEnforced(enforced);
}
}
/**
* 创建工艺签审流程
* @param id
* @throws Exception
*/
public static void createProcess(Long id) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
RemoteMethodServer.getDefault().invoke("createProcess", DxPartService.class.getName(), null,
......
......@@ -15,6 +15,7 @@ import com.yonde.wfc.vo.DxWfTaskOperationArgsVO;
import org.apache.commons.lang.StringUtils;
import wt.doc.WTDocument;
import wt.fc.Persistable;
import wt.fc.QueryResult;
import wt.fc.WTObject;
import wt.method.RemoteAccess;
import wt.method.RemoteMethodServer;
......@@ -25,6 +26,7 @@ import wt.session.SessionHelper;
import wt.util.WTException;
import wt.workflow.engine.WfProcess;
import wt.workflow.work.WorkItem;
import wt.workflow.work.WorkflowHelper;
import java.util.ArrayList;
import java.util.List;
......@@ -191,6 +193,33 @@ public class WfcProcessService implements RemoteAccess {
return taskVOList;
}
/**
* 获取用户未完成待办数量
* @param userName
* @return
* @throws Exception
*/
public static int getTodoTaskListSize(String userName) throws Exception {
if (!RemoteMethodServer.ServerFlag) {
return (Integer) RemoteMethodServer.getDefault().invoke("getTodoTaskListSize", WfcProcessService.class.getName(), null,
new Class[] { String.class},
new Object[] { userName });
}
SessionContext previous = SessionContext.newContext();
int taskSize = 0;
try {
SessionHelper.manager.setAdministrator();
WTUser user = WTUserUtil.getUser(userName);
if (ObjectsUtil.nonNull(user)) {
QueryResult workItems = WorkflowHelper.service.getUncompletedWorkItems(user);
taskSize = workItems.size();
}
} finally {
SessionContext.setContext(previous);
}
return taskSize;
}
/**
* 获取用户待办
* @param userName
......
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