main
熊朝柱 1 week ago
commit ac6d6eb42b

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="bomupadte/"/>
<classpathentry kind="lib" path="lib/itextpdf-5.5.5.jar"/>
<classpathentry kind="lib" path="lib/Spire.Office.jar"/>
<classpathentry kind="lib" path="lib/spire.pdf-3.4.2.jar"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="lib" path="lib/activation-1.1.jar"/>
<classpathentry kind="lib" path="lib/antlr-2.7.7.jar"/>
<classpathentry kind="lib" path="lib/apache-commons-codec-1.4.jar"/>
<classpathentry kind="lib" path="lib/apache-mime4j-core-0.7.2.jar"/>
<classpathentry kind="lib" path="lib/axiom-api-1.2.12.jar"/>
<classpathentry kind="lib" path="lib/axiom-dom-1.2.12.jar"/>
<classpathentry kind="lib" path="lib/axiom-impl-1.2.12.jar"/>
<classpathentry kind="lib" path="lib/axis2-adb-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-adb-codegen-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-ant-plugin-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-clustering-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-codegen-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-corba-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-fastinfoset-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-java2wsdl-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-jaxbri-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-jaxws-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-jibx-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-json-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-kernel-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-metadata-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-mtompolicy-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-saaj-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-soapmonitor-servlet-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-spring-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-transport-http-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-transport-local-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/axis2-xmlbeans-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/bcel-5.1.jar"/>
<classpathentry kind="lib" path="lib/commons-beanutils-1.7.0.jar"/>
<classpathentry kind="lib" path="lib/commons-cli-1.2.jar"/>
<classpathentry kind="lib" path="lib/commons-codec-1.3.jar"/>
<classpathentry kind="lib" path="lib/commons-collections-3.2.jar"/>
<classpathentry kind="lib" path="lib/commons-fileupload-1.2.jar"/>
<classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
<classpathentry kind="lib" path="lib/commons-io-1.4.jar"/>
<classpathentry kind="lib" path="lib/commons-lang-2.4.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.1.jar"/>
<classpathentry kind="lib" path="lib/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="lib/ezmorph-1.0.4.jar"/>
<classpathentry kind="lib" path="lib/geronimo-annotation_1.0_spec-1.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-jaxws_2.2_spec-1.0.jar"/>
<classpathentry kind="lib" path="lib/geronimo-jta_1.1_spec-1.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-saaj_1.3_spec-1.0.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-stax-api_1.0_spec-1.0.1.jar"/>
<classpathentry kind="lib" path="lib/geronimo-ws-metadata_2.0_spec-1.1.2.jar"/>
<classpathentry kind="lib" path="lib/httpcore-4.0.jar"/>
<classpathentry kind="lib" path="lib/itext-2.0.3.jar"/>
<classpathentry kind="lib" path="lib/iText-5.0.2.jar"/>
<classpathentry kind="lib" path="lib/iTextAsian.jar"/>
<classpathentry kind="lib" path="lib/jalopy-1.5rc3.jar"/>
<classpathentry kind="lib" path="lib/jaxb-api-2.1.jar"/>
<classpathentry kind="lib" path="lib/jaxb-impl-2.1.7.jar"/>
<classpathentry kind="lib" path="lib/jaxb-xjc-2.1.7.jar"/>
<classpathentry kind="lib" path="lib/jaxen-1.1.6.jar"/>
<classpathentry kind="lib" path="lib/jaxws-tools-2.1.3.jar"/>
<classpathentry kind="lib" path="lib/jdom.jar"/>
<classpathentry kind="lib" path="lib/jettison-1.0-RC2.jar"/>
<classpathentry kind="lib" path="lib/jibx-bind-1.2.jar"/>
<classpathentry kind="lib" path="lib/jibx-run-1.2.jar"/>
<classpathentry kind="lib" path="lib/json-lib-2.2.2-jdk15.jar"/>
<classpathentry kind="lib" path="lib/json-lib-2.2.3-jdk13.jar"/>
<classpathentry kind="lib" path="lib/jsr311-api-1.0.jar"/>
<classpathentry kind="lib" path="lib/juli-6.0.16.jar"/>
<classpathentry kind="lib" path="lib/log4j-1.2.15.jar"/>
<classpathentry kind="lib" path="lib/mail-1.4.jar"/>
<classpathentry kind="lib" path="lib/mex-1.6.2-impl.jar"/>
<classpathentry kind="lib" path="lib/mysql-connector-java-5.0.8-bin.jar"/>
<classpathentry kind="lib" path="lib/neethi-3.0.2.jar"/>
<classpathentry kind="lib" path="lib/ojdbc6.jar"/>
<classpathentry kind="lib" path="lib/regexp-1.2.jar"/>
<classpathentry kind="lib" path="lib/tribes-6.0.16.jar"/>
<classpathentry kind="lib" path="lib/woden-api-1.0M9.jar"/>
<classpathentry kind="lib" path="lib/woden-impl-commons-1.0M9.jar"/>
<classpathentry kind="lib" path="lib/woden-impl-dom-1.0M9.jar"/>
<classpathentry kind="lib" path="lib/wsdl4j-1.6.2.jar"/>
<classpathentry kind="lib" path="lib/wstx-asl-3.2.9.jar"/>
<classpathentry kind="lib" path="lib/xalan-2.7.0.jar"/>
<classpathentry kind="lib" path="lib/xml-resolver-1.2.jar"/>
<classpathentry kind="lib" path="lib/xmlbeans-2.3.0.jar"/>
<classpathentry kind="lib" path="lib/XmlSchema-1.4.7.jar"/>
<classpathentry kind="lib" path="lib/commons-logging.jar"/>
<classpathentry kind="lib" path="lib/fontbox-2.0.11.jar"/>
<classpathentry kind="lib" path="lib/pdfbox-2.0.11.jar"/>
<classpathentry kind="lib" path="lib/pdfbox-debugger-2.0.11.jar"/>
<classpathentry kind="lib" path="lib/pdfbox-tools-2.0.11.jar"/>
<classpathentry kind="lib" path="lib/preflight-2.0.11.jar"/>
<classpathentry kind="lib" path="lib/xmpbox-2.0.11.jar"/>
<classpathentry kind="lib" path="lib/jacob.jar"/>
<classpathentry kind="lib" path="lib/cn.com.origin.autocodemanager_1.0.0.jar"/>
<classpathentry kind="lib" path="lib/aspose-cells-18.9.jar"/>
<classpathentry kind="lib" path="lib/hutool-all-5.0.7.jar"/>
<classpathentry kind="lib" path="lib/datepicker.jar"/>
<classpathentry kind="lib" path="bomupadte/classes12.jar"/>
<classpathentry kind="lib" path="bomupadte/commons-beanutils-1.9.2.jar"/>
<classpathentry kind="lib" path="bomupadte/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="bomupadte/commons-collections-3.2.1.jar"/>
<classpathentry kind="lib" path="bomupadte/commons-dbutils-1.5.jar"/>
<classpathentry kind="lib" path="bomupadte/commons-lang-2.6.jar"/>
<classpathentry kind="lib" path="bomupadte/commons-logging-1.1.3.jar"/>
<classpathentry kind="lib" path="bomupadte/commons-logging-1.1.jar"/>
<classpathentry kind="lib" path="bomupadte/dom4j-1.6.1.jar"/>
<classpathentry kind="lib" path="bomupadte/ezmorph-1.0.6.jar"/>
<classpathentry kind="lib" path="bomupadte/json-lib-2.4-jdk15.jar"/>
<classpathentry kind="lib" path="bomupadte/jsr173_1.0_api.jar"/>
<classpathentry kind="lib" path="bomupadte/jxl_1.0.0.jar"/>
<classpathentry kind="lib" path="bomupadte/ojdbc5.jar"/>
<classpathentry kind="lib" path="bomupadte/ojdbc6.jar"/>
<classpathentry kind="lib" path="bomupadte/ojdbc8.jar"/>
<classpathentry kind="lib" path="bomupadte/poi-3.9-20121203.jar"/>
<classpathentry kind="lib" path="bomupadte/poi-examples-3.9-20121203.jar"/>
<classpathentry kind="lib" path="bomupadte/poi-excelant-3.9-20121203.jar"/>
<classpathentry kind="lib" path="bomupadte/poi-ooxml-3.9-20121203.jar"/>
<classpathentry kind="lib" path="bomupadte/poi-ooxml-schemas-3.9-20121203.jar"/>
<classpathentry kind="lib" path="bomupadte/poi-scratchpad-3.9-20121203.jar"/>
<classpathentry kind="lib" path="bomupadte/sqljdbc4.jar"/>
<classpathentry kind="lib" path="bomupadte/xmlbeans-2.5.0.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="lib/logback-classic-1.2.10.jar"/>
<classpathentry kind="lib" path="lib/logback-core-1.2.10.jar"/>
<classpathentry kind="lib" path="lib/slf4j-api-1.7.30.jar"/>
<classpathentry kind="lib" path="lib/imageio-tiff-3.8.2.jar"/>
<classpathentry kind="lib" path="lib/cn.com.origin.autocode_1.0.0.jar"/>
<classpathentry kind="lib" path="lib/aspose-cad-21.8.jar"/>
<classpathentry kind="lib" path="lib/fastjson2-2.0.15.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

8
.idea/.gitignore vendored

@ -0,0 +1,8 @@
# 默认忽略的文件
/shelf/
/workspace.xml
# 基于编辑器的 HTTP 客户端请求
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/com/connor/rb/plm/exportBOM/ExportBOMDialog.java" charset="GBK" />
<file url="file://$PROJECT_DIR$/src/com/connor/rb/plm/exportBOM/ExportBOMOperation.java" charset="GBK" />
<file url="file://$PROJECT_DIR$/src/com/connor/rb/plm/rb026/Rb026Dialog.java" charset="GBK" />
</component>
</project>

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GitToolBoxBlameSettings">
<option name="version" value="2" />
</component>
</project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ASMSmaliIdeaPluginConfiguration">
<asm skipDebug="true" skipFrames="true" skipCode="false" expandFrames="false" />
<groovy codeStyle="LEGACY" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_22" default="true" project-jdk-name="openjdk-22" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/classes" />
</component>
</project>

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.connor.rb.plm</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

@ -0,0 +1,15 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8

@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.ui.text.custom_code_templates=

File diff suppressed because it is too large Load Diff

@ -0,0 +1,433 @@
package com.connor.rb.plm.rb025;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFDialog;
import com.teamcenter.rac.aifrcp.AIFUtility;
import com.teamcenter.rac.kernel.TCClassService;
import com.teamcenter.rac.kernel.TCClassificationService;
import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCComponentForm;
import com.teamcenter.rac.kernel.TCComponentICO;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCException;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.kernel.ics.ICSAdminClass;
import com.teamcenter.rac.kernel.ics.ICSKeyLov;
import com.teamcenter.rac.kernel.ics.ICSProperty;
import com.teamcenter.rac.kernel.ics.ICSPropertyDescription;
import com.teamcenter.rac.util.MessageBox;
import net.sf.json.JSONArray;
/**
* 修改分类属性
*/
public class EditClassificationDialog extends AbstractAIFDialog {
private static final long serialVersionUID = 1L;
private AbstractAIFApplication app;
private TCSession session;
private TCComponent target;
private Map<String, JComponent> propMap;
private TCClassificationService myService;
final EditClassificationDialog DIALOG = this;
private TCComponentItemRevision rev;
private int[] ids;
private String[] values;
private String[] names;
private boolean finished;
private ICSPropertyDescription[] desc;
public EditClassificationDialog(AbstractAIFApplication app) throws TCException {
this.app = app;
this.session = (TCSession) app.getSession();
this.myService = session.getClassificationService();
this.target = (TCComponent) AIFUtility.getCurrentApplication().getTargetComponent();
System.out.println(target.getType());
System.out.println(target instanceof TCComponentItemRevision ? "是" : "否");
if (target instanceof TCComponentItemRevision) {
try {
rev = (TCComponentItemRevision) target;
boolean isAccess = session.getTCAccessControlService().checkPrivilege(rev, "WRITE");
if (!isAccess) {
JOptionPane.showMessageDialog(this, "没有版本修改权限,请联系系统管理员", "提示", JOptionPane.WARNING_MESSAGE);
return;
}
initUI();
} catch (Exception e) {
e.printStackTrace();
}
} else {
MessageBox.post("请选择版本", "错误", MessageBox.ERROR);
}
}
/**
* 获取分类属性LOV显示值
* @param icsD
* @return
*/
public static String getClassDisplayableValue(ICSPropertyDescription icsD) {
String result = "";
ICSKeyLov lov = icsD.getFormat().getKeyLov();
if (lov != null) {
String[] keys = lov.getKeys();
for (String key : keys) {
result = lov.getValueOfKey(key);
return result;
}
}
return result;
}
private void initUI() {
this.setTitle("修改分类属性");
JPanel rootPanel = new JPanel();
rootPanel.setLayout(null);
rootPanel.setPreferredSize(new Dimension(600, 350));
Map<ICSProperty, ICSPropertyDescription> displayMap = new LinkedHashMap<ICSProperty, ICSPropertyDescription>();
propMap = new HashMap<String, JComponent>();
try {
if (rev.getClassificationClass() != null && !"".equals(rev.getClassificationClass())) {
try {
rev.refresh();
System.out.println("rev.getClassificationClass()=" + rev.getClassificationClass());
TCComponentICO ico = rev.getClassificationObjects()[0];
ICSProperty[] props = ico.getICSProperties(true);
desc = ico.getICSPropertyDescriptors();
for (int i = 0; i < props.length; i++) {
// System.out.println(props[i].getId() + "===>" + props[i].getValue());// 30101===>
// desc.getName=Type and size series 就是分类属性的名字||| desc.getId=30101就是分类属性ID
// System.out.println("desc.getName=" + desc[i].getName() + " desc.getId=" + desc[i].getId());
displayMap.put(props[i], desc[i]);
}
} catch (TCException e1) {
e1.printStackTrace();
}
} else {
this.disposeDialog();
MessageBox.post("当前版本未被分类", "错误", MessageBox.ERROR);
return;
}
} catch (TCException e) {
e.printStackTrace();
}
if (displayMap.size() == 0) {
return;
}
JPanel content = new JPanel();
content.setLayout(null);
content.setPreferredSize(new Dimension(600, displayMap.size() * (25 + 10)));
int num = 0;
// 通过对象获取所有的分类属性,然后遍历分类属性
for (Entry<ICSProperty, ICSPropertyDescription> entry : displayMap.entrySet()) {
JLabel label = new JLabel(entry.getValue().getName() + "");
label.setBounds(10, num * 35 + 10, 100, 25);
ICSKeyLov lov = entry.getValue().getFormat().getKeyLov();
// ArrayList<Object> list = new ArrayList<>();
if (lov != null) {
String[] keys = lov.getKeys();
JComboBox<ClassPropBean> combo = new JComboBox<ClassPropBean>();
combo.addItem(new ClassPropBean("", "", ""));
for (String key : keys) {
combo.addItem(new ClassPropBean(key, lov.getValueOfKey(key), ""));
}
String v = entry.getKey().getValue();
for (int i = 0; i < combo.getItemCount(); i++) {
if (v.equals(combo.getItemAt(i).getId())) {
combo.setSelectedIndex(i);
break;
}
}
// combo.setSelectedItem(v);
// if (!Arrays.asList(lov.getDisplayValues()).contains(v)) {
// combo.addItem(v);
// combo.setSelectedItem(v);
// }
combo.setBounds(130, num * 35 + 10, 350, 25);
propMap.put(entry.getValue().getName(), combo);
content.add(combo);
} else {
JTextField text = new JTextField(entry.getKey().getValue());
text.setBounds(130, num * 35 + 10, 350, 25);
propMap.put(entry.getValue().getName(), text);
content.add(text);
}
content.add(label);
num++;
}
JButton okBtn = new JButton("确认");
okBtn.setBounds(40, 310, 100, 25);
okBtn.setSelected(true);
okBtn.addActionListener(ok());
JButton cancelBtn = new JButton("取消");
cancelBtn.setBounds(160, 310, 100, 25);
cancelBtn.addActionListener(cancel());
JScrollPane jsp = new JScrollPane(content);
jsp.getVerticalScrollBar().setUnitIncrement(16);
jsp.setBounds(0, 0, 600, 300);
jsp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
rootPanel.add(jsp);
rootPanel.add(okBtn);
rootPanel.add(cancelBtn);
this.add(rootPanel);
this.pack();
this.centerToScreen();
this.setAutoRequestFocus(true);
// this.setResizable(false);
this.setAlwaysOnTop(true);
this.showDialog();
}
private ActionListener ok() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
((JButton) e.getSource()).setEnabled(false);
rev = (TCComponentItemRevision) target;
new Thread(new Runnable() {
@Override
public void run() {
int i = 1;
while (!DIALOG.finished) {
try {
DIALOG.setTitle("正在修改分类属性 " + StringCreateUtil.createPoint(i++ % 3));
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}).start();
EditClassificationDialog.this.setAlwaysOnTop(false);
if (saveClassification(rev)) {
MessageBox.post("修改分类属性成功!", "", MessageBox.ERROR);
EditClassificationDialog.this.disposeDialog();
} else {
MessageBox.post("修改分类属性失败!", "", MessageBox.ERROR);
}
}
};
}
private ActionListener cancel() {
return new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DIALOG.disposeDialog();
}
};
}
@SuppressWarnings("unchecked")
private boolean saveClassification(TCComponentItemRevision rev) {
try {
TCComponentForm form = (TCComponentForm) rev.getRelatedComponents("IMAN_master_form_rev")[0];
TCComponent[] status = form.getRelatedComponents("release_status_list");
for (TCComponent comp : status) {
if (comp.getProperty("object_name").contains("正式")) {
JOptionPane.showMessageDialog(this, "版本表单已正式发布,不允许修改分类属性", "提示", JOptionPane.WARNING_MESSAGE);
return false;
}
}
TCComponentICO[] icoS = rev.getClassificationObjects();
System.out.println("======>获取的分类对象有:" + icoS.length);
String classID = rev.getClassificationClass();
if (icoS == null || icoS.length == 0) {
return false;
}
for (int i = 0; i < icoS.length; i++) {
List<ClassProperty> propList = new ArrayList<>();
TCComponentICO ico = icoS[i];
ICSPropertyDescription[] desc = ico.getICSPropertyDescriptors();
ICSProperty[] oldICSProps = ico.getICSProperties(true);
ids = new int[oldICSProps.length];
values = new String[oldICSProps.length];
names = new String[oldICSProps.length];
for (int j = 0; j < oldICSProps.length; j++) {
ids[j] = oldICSProps[j].getId();
if (propMap.get(desc[j].getName()) instanceof JComboBox) {
ClassPropBean bean = (ClassPropBean) ((JComboBox<ClassPropBean>) propMap.get(desc[j].getName())).getSelectedItem();
String str = bean.getId();
values[j] = " ".equals(str) ? "" : str;
} else {
values[j] = ((JTextField) propMap.get(desc[j].getName())).getText();
}
names[j] = desc[j].getName();
ClassProperty prop = new ClassProperty(ids[j], values[j]);
propList.add(prop);
}
String json = objectToJson(propList);
System.out.println("classID=" + classID);
System.out.println("json=" + json);
System.out.println("删除分类属性...");
try {
deleteClass(getICO(rev, classID).getUid());
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("发送分类属性...");
if (sendToClass(rev.getUid(), classID, json)) {
return true;
} else {
return false;
}
}
} catch (TCException e1) {
e1.printStackTrace();
JOptionPane.showMessageDialog(null, e1, "错误", JOptionPane.ERROR_MESSAGE);
return false;
}
return true;
}
private TCComponentICO getICO(TCComponentItemRevision rev, String classId) throws Exception {
if (rev == null || classId.equals("")) {
return null;
}
TCComponentICO[] icos = rev.getClassificationObjects();
System.out.println(rev + " -> 已存在分类:" + Arrays.toString(icos));
int len = icos.length;
if (len == 0) {
return null;
}
TCClassificationService classService = session.getClassificationService();
for (int i = 0; i < len; i++) {
TCComponentICO ico = icos[i];
classService.loadICOs(new String[] { ico.getUid() }, "");
if (ico.getClassId() == null || ico.getClassId().equals("")) {
throw new Exception("分类加载异常,请联系管理员处理");
}
if (classId.equals(ico.getClassId())) {
return ico;
}
}
return null;
}
public void deleteClass(String icoPuid) {
try {
ServiceClient sc = new ServiceClient();
Options opts = new Options();
String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session);// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL";
EndpointReference end = new EndpointReference(url);
opts.setTo(end);
opts.setAction("DeleteClass");
sc.setOptions(opts);
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", "");
OMElement method = fac.createOMElement("DeleteClass", omNs);
OMElement value = fac.createOMElement("icoPuid", omNs);
value.setText(icoPuid);
method.addChild(value);
OMElement res = sc.sendReceive(method);
res.getFirstElement().getText();
System.out.println(res.getFirstElement().getText());
} catch (AxisFault e) {
e.printStackTrace();
}
}
public boolean sendToClass(String wsoPUID, String classID, String json) {
try {
ServiceClient sc = new ServiceClient();
Options opts = new Options();
String url = JDMethodUtil.getPrefStr("Autocode_SendClassServer_URL", session);
// "http://10.201.5.203:19090/ErpWebService.asmx?WSDL";
EndpointReference end = new EndpointReference(url);
opts.setTo(end);
opts.setAction("SendToClass");
sc.setOptions(opts);
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://tempuri.org/", "");
OMElement method = fac.createOMElement("SendToClass", omNs);
OMElement value = fac.createOMElement("wsoPuiid", omNs);
value.setText(wsoPUID);
OMElement value1 = fac.createOMElement("classID", omNs);
value1.setText(classID);
OMElement value2 = fac.createOMElement("JsonContainer", omNs);
// "[{\"value\":\"1\",\"propertyID\":-500003},{\"value\":\"1\",\"propertyID\":-500011}]"
value2.setText(json);
method.addChild(value);
method.addChild(value1);
method.addChild(value2);
OMElement res = sc.sendReceive(method);
res.getFirstElement().getText();
System.out.println(res.getFirstElement().getText());
} catch (AxisFault e) {
// MessageBox.post("发送分类失败!", "", MessageBox.ERROR);
e.printStackTrace();
return false;
}
return true;
}
public static String objectToJson(List<ClassProperty> props) {
String str = null;
try {
JSONArray json = JSONArray.fromObject(props);// 将java对象转换为json对象
str = json.toString();// 将json对象转换为字符串
} catch (Exception e) {
e.printStackTrace();
}
System.out.println("JSON =>" + str);
return str;
}
}

@ -0,0 +1,106 @@
package com.connor.rb.plm.rb027;
import java.util.Iterator;
import java.util.Map;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import com.teamcenter.rac.aif.AbstractAIFApplication;
import com.teamcenter.rac.aif.AbstractAIFCommand;
import com.teamcenter.rac.aif.kernel.InterfaceAIFComponent;
import com.teamcenter.rac.kernel.TCComponentItemRevision;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.util.MessageBox;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
public class GetNumberCommand extends AbstractAIFCommand {
private AbstractAIFApplication app;
private TCSession session;
public GetNumberCommand(AbstractAIFApplication app, TCSession session) {
// TODO Auto-generated constructor stub
this.app = app;
this.session = session;
}
@Override
public void executeModal() throws Exception {
// TODO Auto-generated method stub
//获取选中对象
InterfaceAIFComponent comp = app.getTargetComponent();
if(!(comp instanceof TCComponentItemRevision))
{
MessageBox.post("请选中版本对象!", "错误", MessageBox.ERROR);
return;
}
TCComponentItemRevision itemRevision = (TCComponentItemRevision) comp;
String result = sendPost("http://10.20.7.27:9889/jde/getNumber");
System.out.println(result);
//获取返回结果
JSONObject resultJson = JSONObject.fromObject(result);
JSONArray jsonArray = resultJson.getJSONArray("data");
for (int i=0; i < jsonArray.size(); i++) {
//获取autoNextNumber
String autoNextNumber = "";
JSONObject jsonObject = jsonArray.getJSONObject(i);
Iterator iter = jsonObject.entrySet().iterator();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
System.out.println(entry.getKey().toString());
switch (entry.getKey().toString()) {
case "autoNextNumber":
System.out.println(entry.getValue().toString());
autoNextNumber = entry.getValue().toString();
break;
default:
break;
}
}
itemRevision.setStringProperty("rb3_spm", autoNextNumber);
itemRevision.refresh();
MessageBox.post("获取商品码成功!", "成功", MessageBox.INFORMATION);
return;
}
super.executeModal();
}
public static String sendPost(String url) {
String response = null;
try {
CloseableHttpClient httpclient = null;
CloseableHttpResponse httpresponse = null;
try {
httpclient = HttpClients.createDefault();
HttpGet httpGet = new HttpGet(url);
httpresponse = httpclient.execute(httpGet);
response = EntityUtils.toString(httpresponse.getEntity());
} catch (Exception e) {
e.printStackTrace();
} finally {
if (httpclient != null) {
httpclient.close();
}
if (httpresponse != null) {
httpresponse.close();
}
}
} catch (Exception e) {
e.printStackTrace();
}
return response;
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save