1.场景
2.代码
package ext.plm.review.fileOutgoingReview;
import cn.hutool.core.util.IdUtil;
import com.ptc.core.lwc.common.view.TypeDefinitionReadView;
import com.ptc.core.lwc.server.TypeDefinitionServiceHelper;
import com.ptc.core.meta.common.TypeIdentifier;
import com.ptc.core.meta.common.TypeIdentifierHelper;
import ext.plm.bean.CtBeanFactory;
import ext.plm.review.fileOutgoingReview.bo.CtFileOutgoingReviewBo;
import wt.change2.ChangeHelper2;
import wt.change2.WTChangeReview;
import wt.doc.WTDocument;
import wt.epm.EPMDocument;
import wt.fc.QueryResult;
import wt.fc.WTObject;
public class CtFileOutgoingReviewPlugin {
private static CtFileOutgoingReviewService ctFileOutgoingReviewService = CtBeanFactory.newCtBeanFactory().getBean(CtFileOutgoingReviewService.class);
/**
* 初始化供应商列表
* ext.plm.review.fileOutgoingReview.CtFileOutgoingReviewPlugin.initFileOutgoingReviewInfo(primaryBusinessObject);
*
* @param obj
* @throws Exception
*/
public static void initFileOutgoingReviewInfo(WTObject obj) throws Exception {
WTChangeReview review = (WTChangeReview) obj;
Long branchId = review.getBranchIdentifier();
QueryResult qr = ChangeHelper2.service.getChangeables(review);
while (qr.hasMoreElements()) {
Object o = qr.nextElement();
String docNumber = "";
String docName = "";
String docVersion = null;
String docType = "";
if (o instanceof WTDocument) {
WTDocument doc = (WTDocument) o;
//获取图文档编号
docNumber = doc.getNumber();
//获取图文档名称
docName = doc.getName();
//获取图文档版本
docVersion = doc.getVersionIdentifier().getValue() + "." + doc.getIterationIdentifier().getValue();
//获取图文档类型
TypeIdentifier typeIdentifier = TypeIdentifierHelper.getType(doc);
TypeDefinitionReadView readView = TypeDefinitionServiceHelper.service.getTypeDefView(typeIdentifier);
docType = readView.getDisplayName();
} else if (o instanceof EPMDocument) {
EPMDocument doc = (EPMDocument) o;
//获取图文档编号
docNumber = doc.getNumber();
//获取图文档名称
docName = doc.getName();
//获取图文档版本
docVersion = doc.getVersionIdentifier().getValue() + "." + doc.getIterationIdentifier().getValue();
//获取图文档类型
TypeIdentifier typeIdentifier = TypeIdentifierHelper.getType(doc);
TypeDefinitionReadView readView = TypeDefinitionServiceHelper.service.getTypeDefView(typeIdentifier);
docType = readView.getDisplayName();
}
CtFileOutgoingReviewBo bo = new CtFileOutgoingReviewBo();
bo.setId(IdUtil.randomUUID());
bo.setBranchId(branchId);
bo.setFigureDocNumber(docNumber);
bo.setFigureDocName(docName);
bo.setFigureDocVersion(docVersion);
bo.setFigureDocType(docType);
ctFileOutgoingReviewService.addFileOutgoing(bo);
}
}
}