feat(autocode): 新增文档创建后自动带出数据集模板功能

- 新增功能:文档创建后,根据 ID(编码规则名称)自动带出数据集模板
- 实现步骤:1. 在文档创建过程中,判断新建对象是否属于“文档”类别
  2. 如果是文档,则在创建完成后,根据编码规则名称查询对应的数据集模板 3. 将查询到的数据集模板上传到新建的文档版本对象中
- 相关代码修改:
  - 在 `addGeneralPropComosite` 方法中修改了文档类别属性的处理逻辑 - 在 `getFinalPattern` 方法中增加了文档类别的判断和处理
  - 在 `createItem` 方法中实现了数据集模板的查询和上传功能
main
熊朝柱 2 months ago
parent 3415d4587c
commit ae80682690

@ -8,6 +8,7 @@ package cn.com.origin.autocode.newitem.generatcode;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.datatransfer.StringSelection;
import java.io.File;
import java.io.IOException;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
@ -107,6 +108,7 @@ import com.teamcenter.rac.kernel.TCComponentPseudoFolder;
import com.teamcenter.rac.kernel.TCComponentQuery;
import com.teamcenter.rac.kernel.TCComponentQueryType;
import com.teamcenter.rac.kernel.TCComponentRole;
import com.teamcenter.rac.kernel.TCComponentTcFile;
import com.teamcenter.rac.kernel.TCComponentUser;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCExceptionPartial;
@ -134,7 +136,7 @@ import com.teamcenter.soaictstubs.stringSeq_tHolder;
public class NewCodeItemDialog extends Dialog {
//是否为文档
private boolean isDoc = false;
private String leftMostCodeRuleNameString = "";
private String leftMostCodeRuleNameString = "";//选中的编码规则名称
private String docTypeValue = "";
// 表单类型中英文对照
private SashForm sashFormCodeView;
@ -646,6 +648,7 @@ public class NewCodeItemDialog extends Dialog {
* UI -LabelobjPropComposite
*/
public void addGeneralPropComosite() {
System.out.println("addGeneralPropComosite");
boolean isDocType = false;//当前属性名称是否为文档类型?
for (int i = 0; i < generalPropLabelList.size(); i++) {
Label label = generalPropLabelList.get(i);
@ -661,7 +664,7 @@ public class NewCodeItemDialog extends Dialog {
//20250425新增 将最左侧选中的编码规则名称写入到最右侧的文档类别中
String currentPropName = cnProp.getDisplayName();//当前遍历的对象or分类属性名称
System.out.println("当前创建的UI组件Label名称="+currentPropName);
if(currentPropName != null && currentPropName.equals("文档类") && docTypeValue != null && !docTypeValue.equals("")){
if(currentPropName != null && currentPropName.equals("文档类") && docTypeValue != null && !docTypeValue.equals("")){
System.out.println("“文档类别”匹配成功!属性值设置为最左侧选中编码名称="+docTypeValue);
isDocType = true;
}
@ -1660,7 +1663,7 @@ public class NewCodeItemDialog extends Dialog {
if(selectedData.getChildrenTreeData() != null && selectedData.getChildrenTreeData().length>0) {
System.out.println("不是最底层");
btFlg = true;
System.out.println("nodeName:"+selectedData.getPackCodeNodeInfo().getNode_name());
System.out.println("》》》nodeName:"+selectedData.getPackCodeNodeInfo().getNode_name());
return;
}else {
System.out.println("是最底层");
@ -1671,9 +1674,10 @@ public class NewCodeItemDialog extends Dialog {
String name = "";
// 得到编码相关信息
getCodeInfo(selectedData);
//TODO 根据得到的编码信息,假设得到创建对象的类型为文档
//KUMA 根据得到的编码信息,假设得到创建对象的类型为文档
if(isDoc){//如果创建对象是文档,
//1.获取最左侧区域选中的的编码规则名称
System.out.println("当前新建对象类型为“文档”");
AbstractTreeData leftTreeData = selectedData.getParentTreeData();
if (leftTreeData != null) {
leftMostCodeRuleNameString = leftTreeData.getPackCodeNodeInfo().getNode_name();
@ -1692,7 +1696,7 @@ public class NewCodeItemDialog extends Dialog {
System.out.println("第一部分: " + firstPart);
System.out.println("第二部分: " + secondPart);
if (firstPart.equals(leftMostCodeRuleNameString)) {
//将此secondPart填入最右侧区域中的属性“文档类别”下
//将此secondPart赋值给全局变量docTypeValue将在addGeneralPropComosite中填入最右侧区域中的属性“文档类别”下
docTypeValue = secondPart;
break;
}else {
@ -1730,12 +1734,13 @@ public class NewCodeItemDialog extends Dialog {
if (currentNodeDesc.trim().length() > 0) {
codeDesc = codeDesc + currentNodeDesc;
}
if (!TCPreferenceUitl.isTrueTCPreferenceValue(session,
origin_isItemNameTextDefaultNull)) {
//ss
if (!TCPreferenceUitl.isTrueTCPreferenceValue(session,origin_isItemNameTextDefaultNull)) {
nameText.setText(name);
} else {
nameText.setText("");
}
getFinalPattern();
// idText.setText(pattern);
idText.setText(finalPattern);
@ -1796,8 +1801,7 @@ public class NewCodeItemDialog extends Dialog {
icoPropertyMap = listView.getIcoPropertyMap();
revText.setText(tccomponentitemtype.getNewRev(null));
if (!TCPreferenceUitl.isTrueTCPreferenceValue(session,
origin_isItemNameTextDefaultNull)) {
if (!TCPreferenceUitl.isTrueTCPreferenceValue(session,origin_isItemNameTextDefaultNull)) {
nameText.setText(firstListICOName);
} else {
nameText.setText("");
@ -1940,6 +1944,16 @@ public class NewCodeItemDialog extends Dialog {
String parentName = "";
if (treeData != null) {
//判断当前新建对象是否属于“文档”这一类别
String nodeNameCurrent = treeData.getPackCodeNodeInfo().getNode_name();
String nodetypeCurrent = treeData.getPackCodeNodeInfo().getNode_type();
System.out.println("当前节点【"+nodeNameCurrent+"】属于【"+nodetypeCurrent+"】类别");
if (nodeNameCurrent.contains("文档")){
System.out.println("当前节点属于【文档】类别");
isDoc = true;
}
AbstractTreeData parentData = treeData.getParentTreeData();
if ((parentData != null) && (parentData.getPackCodeNodeInfo().getNodeComponent() != null)) {
@ -1968,9 +1982,12 @@ public class NewCodeItemDialog extends Dialog {
originFatherData = treeData;
}
}
if (originFatherData != null) {
System.out.println("编码树视图选中对象的始祖对象="+originFatherData.getPackCodeNodeInfo().getNode_name()+"\n 类型="+originFatherData.getPackCodeNodeInfo().getNode_type());
}
}
private void initTreeOrListMouseClick() {
try {
if (treeViewOperation.getSelectedTreeNode(classificationTreeViewer) == null) {
@ -3221,15 +3238,41 @@ public class NewCodeItemDialog extends Dialog {
//20250425 新增:文档创建后,根据 ID=编码规则名称 带出数据集模板
if (newComp != null && isDoc){
if (leftMostCodeRuleNameString != null && !leftMostCodeRuleNameString.isEmpty()){
//1.调用查询,获取版本对象,下载数据集到本地
//获取新建对象的版本对象-rev
TCComponentItemRevision rev = null;
if (newComp instanceof TCComponentItemRevision){
rev = (TCComponentItemRevision) newComp;
} else if (newComp instanceof TCComponentItem) {
rev = ((TCComponentItem) newComp).getLatestItemRevision();
}
if (leftMostCodeRuleNameString != null && !leftMostCodeRuleNameString.isEmpty()){
//1.KUMA 调用查询,获取版本对象,下载数据集到本地
TCComponent[] searchs = session.search("零组件 ID",
new String[] { "零组件 ID"},
new String[] { leftMostCodeRuleNameString});
if (searchs.length > 0){
if (searchs[0] instanceof TCComponentItemRevision){
TCComponentItemRevision itemRevision = (TCComponentItemRevision) searchs[0];
//将查询到的版本对象的"规范"关系下的数据集
TCComponent[] referenceListProperty = itemRevision.getReferenceListProperty("IMAN_specification");
if (referenceListProperty != null && referenceListProperty.length > 0){
for (TCComponent tcComponent : referenceListProperty){
if (tcComponent instanceof TCComponentDataset) {
TCComponentDataset dataset_old = (TCComponentDataset) tcComponent;
TCComponentDataset dataset_new = dataset_old.saveAs(null);
//2.将数据集上传到新建版本对象中
rev.add("IMAN_specification", dataset_new);
}
//2.将本地数据集上传到新建版本对象中
}
}
}
}
}
}
if (targetObject != null) {
targetObject.refresh();

Loading…
Cancel
Save